@portal-hq/utils
Advanced tools
Comparing version 0.3.6 to 0.3.7
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Storage = exports.KeychainAdapter = void 0; | ||
exports.Storage = exports.MpcStatuses = exports.KeychainAdapter = void 0; | ||
class KeychainAdapter { | ||
@@ -14,3 +14,3 @@ deleteAddress() { | ||
} | ||
getDkgResult(isSim) { | ||
getDkgResult(isSim, _progress = () => { }) { | ||
throw new Error(`[Portal] KeychainAdapter method getDkgResult(${isSim}) cannot be called directly. Please extend KeychainAdapter.`); | ||
@@ -21,3 +21,3 @@ } | ||
} | ||
storeDkgResult(result, isSim) { | ||
storeDkgResult(result, isSim, _progress = () => { }) { | ||
throw new Error(`[Portal] KeychainAdapter method storeDkgResult(${result}, ${isSim}) cannot be called directly. Please extend KeychainAdapter.`); | ||
@@ -27,2 +27,14 @@ } | ||
exports.KeychainAdapter = KeychainAdapter; | ||
var MpcStatuses; | ||
(function (MpcStatuses) { | ||
MpcStatuses["DecryptingShare"] = "Decrypting share"; | ||
MpcStatuses["Done"] = "Done"; | ||
MpcStatuses["EncryptingShare"] = "Encrypting share"; | ||
MpcStatuses["GeneratingShare"] = "Generating share"; | ||
MpcStatuses["ParsingShare"] = "Parsing share"; | ||
MpcStatuses["ReadingShare"] = "Reading share"; | ||
MpcStatuses["RecoveringBackupShare"] = "Recovering backup share"; | ||
MpcStatuses["RecoveringSigningShare"] = "Recovering signing share"; | ||
MpcStatuses["StoringShare"] = "Storing share"; | ||
})(MpcStatuses = exports.MpcStatuses || (exports.MpcStatuses = {})); | ||
class Storage { | ||
@@ -29,0 +41,0 @@ delete() { |
@@ -37,2 +37,4 @@ "use strict"; | ||
PortalErrorCodes[PortalErrorCodes["SigningNetworkError"] = 211] = "SigningNetworkError"; | ||
PortalErrorCodes[PortalErrorCodes["BlockedAddressByDefault"] = 212] = "BlockedAddressByDefault"; | ||
PortalErrorCodes[PortalErrorCodes["BlockedAddressByEnvironment"] = 213] = "BlockedAddressByEnvironment"; | ||
// General Errors | ||
@@ -39,0 +41,0 @@ PortalErrorCodes[PortalErrorCodes["FailedToComputeEthAddress"] = 300] = "FailedToComputeEthAddress"; |
@@ -12,3 +12,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.parseRequest = exports.hexStringToString = exports.hexStringToNumber = exports.hexStringToByteArray = void 0; | ||
exports.parseRequest = exports.numberToHexString = exports.hexStringToString = exports.hexStringToNumber = exports.hexStringToByteArray = void 0; | ||
const currency_1 = require("../currency"); | ||
@@ -57,2 +57,6 @@ const hexStringToByteArray = (hexString) => { | ||
exports.hexStringToString = hexStringToString; | ||
const numberToHexString = (value) => { | ||
return `0x${value.toString(16)}`; | ||
}; | ||
exports.numberToHexString = numberToHexString; | ||
const parseRequest = (method, params) => __awaiter(void 0, void 0, void 0, function* () { | ||
@@ -79,2 +83,4 @@ let requestData; | ||
case 'personal_sign': | ||
case 'eth_signTypedData_v3': | ||
case 'eth_signTypedData_v4': | ||
requestData = { | ||
@@ -81,0 +87,0 @@ message: (0, exports.hexStringToString)(txParam0), |
@@ -6,3 +6,8 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.HttpRequester = exports.HttpRequest = exports.parseRequest = exports.Events = exports.RpcErrorCodes = exports.ProviderRpcError = exports.PortalMpcError = exports.PortalErrorCodeTypes = exports.PortalErrorCodes = exports.NoAddressError = exports.MpcSigningError = exports.MissingOptionError = exports.InvalidGatewayConfigError = exports.InvalidChainIdError = exports.InvalidApiKeyError = exports.HttpError = exports.Storage = exports.KeychainAdapter = exports.convert = exports.convertCryptoToLocal = exports.convertLocalToCrypto = void 0; | ||
exports.HttpRequester = exports.HttpRequest = exports.parseRequest = exports.numberToHexString = exports.Events = exports.RpcErrorCodes = exports.ProviderRpcError = exports.PortalMpcError = exports.PortalErrorCodeTypes = exports.PortalErrorCodes = exports.NoAddressError = exports.MpcSigningError = exports.MissingOptionError = exports.InvalidGatewayConfigError = exports.InvalidChainIdError = exports.InvalidApiKeyError = exports.HttpError = exports.Storage = exports.MpcStatuses = exports.KeychainAdapter = exports.convert = exports.convertCryptoToLocal = exports.convertLocalToCrypto = exports.getChainNameForId = exports.getChainIdForName = exports.chainNameToId = exports.chainIdToName = void 0; | ||
var chains_1 = require("./chains"); | ||
Object.defineProperty(exports, "chainIdToName", { enumerable: true, get: function () { return chains_1.chainIdToName; } }); | ||
Object.defineProperty(exports, "chainNameToId", { enumerable: true, get: function () { return chains_1.chainNameToId; } }); | ||
Object.defineProperty(exports, "getChainIdForName", { enumerable: true, get: function () { return chains_1.getChainIdForName; } }); | ||
Object.defineProperty(exports, "getChainNameForId", { enumerable: true, get: function () { return chains_1.getChainNameForId; } }); | ||
var currency_1 = require("./currency"); | ||
@@ -14,2 +19,3 @@ Object.defineProperty(exports, "convertLocalToCrypto", { enumerable: true, get: function () { return currency_1.convertLocalToCrypto; } }); | ||
Object.defineProperty(exports, "KeychainAdapter", { enumerable: true, get: function () { return definitions_1.KeychainAdapter; } }); | ||
Object.defineProperty(exports, "MpcStatuses", { enumerable: true, get: function () { return definitions_1.MpcStatuses; } }); | ||
Object.defineProperty(exports, "Storage", { enumerable: true, get: function () { return definitions_1.Storage; } }); | ||
@@ -32,2 +38,3 @@ var errors_1 = require("./errors"); | ||
var eth_requests_1 = require("./eth-requests"); | ||
Object.defineProperty(exports, "numberToHexString", { enumerable: true, get: function () { return eth_requests_1.numberToHexString; } }); | ||
Object.defineProperty(exports, "parseRequest", { enumerable: true, get: function () { return eth_requests_1.parseRequest; } }); | ||
@@ -34,0 +41,0 @@ var http_request_1 = require("./http-request"); |
@@ -11,3 +11,3 @@ export class KeychainAdapter { | ||
} | ||
getDkgResult(isSim) { | ||
getDkgResult(isSim, _progress = () => { }) { | ||
throw new Error(`[Portal] KeychainAdapter method getDkgResult(${isSim}) cannot be called directly. Please extend KeychainAdapter.`); | ||
@@ -18,6 +18,18 @@ } | ||
} | ||
storeDkgResult(result, isSim) { | ||
storeDkgResult(result, isSim, _progress = () => { }) { | ||
throw new Error(`[Portal] KeychainAdapter method storeDkgResult(${result}, ${isSim}) cannot be called directly. Please extend KeychainAdapter.`); | ||
} | ||
} | ||
export var MpcStatuses; | ||
(function (MpcStatuses) { | ||
MpcStatuses["DecryptingShare"] = "Decrypting share"; | ||
MpcStatuses["Done"] = "Done"; | ||
MpcStatuses["EncryptingShare"] = "Encrypting share"; | ||
MpcStatuses["GeneratingShare"] = "Generating share"; | ||
MpcStatuses["ParsingShare"] = "Parsing share"; | ||
MpcStatuses["ReadingShare"] = "Reading share"; | ||
MpcStatuses["RecoveringBackupShare"] = "Recovering backup share"; | ||
MpcStatuses["RecoveringSigningShare"] = "Recovering signing share"; | ||
MpcStatuses["StoringShare"] = "Storing share"; | ||
})(MpcStatuses || (MpcStatuses = {})); | ||
export class Storage { | ||
@@ -24,0 +36,0 @@ delete() { |
@@ -34,2 +34,4 @@ export var PortalErrorCodes; | ||
PortalErrorCodes[PortalErrorCodes["SigningNetworkError"] = 211] = "SigningNetworkError"; | ||
PortalErrorCodes[PortalErrorCodes["BlockedAddressByDefault"] = 212] = "BlockedAddressByDefault"; | ||
PortalErrorCodes[PortalErrorCodes["BlockedAddressByEnvironment"] = 213] = "BlockedAddressByEnvironment"; | ||
// General Errors | ||
@@ -36,0 +38,0 @@ PortalErrorCodes[PortalErrorCodes["FailedToComputeEthAddress"] = 300] = "FailedToComputeEthAddress"; |
@@ -50,2 +50,5 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
}; | ||
export const numberToHexString = (value) => { | ||
return `0x${value.toString(16)}`; | ||
}; | ||
export const parseRequest = (method, params) => __awaiter(void 0, void 0, void 0, function* () { | ||
@@ -72,2 +75,4 @@ let requestData; | ||
case 'personal_sign': | ||
case 'eth_signTypedData_v3': | ||
case 'eth_signTypedData_v4': | ||
requestData = { | ||
@@ -74,0 +79,0 @@ message: hexStringToString(txParam0), |
@@ -0,7 +1,8 @@ | ||
export { chainIdToName, chainNameToId, getChainIdForName, getChainNameForId, } from './chains'; | ||
export { convertLocalToCrypto, convertCryptoToLocal, convert } from './currency'; | ||
export { KeychainAdapter, Storage } from './definitions'; | ||
export { KeychainAdapter, MpcStatuses, Storage, } from './definitions'; | ||
export { HttpError, InvalidApiKeyError, InvalidChainIdError, InvalidGatewayConfigError, MissingOptionError, MpcSigningError, NoAddressError, PortalErrorCodes, PortalErrorCodeTypes, PortalMpcError, ProviderRpcError, RpcErrorCodes, } from './errors'; | ||
export { default as Events } from './events'; | ||
export { parseRequest } from './eth-requests'; | ||
export { numberToHexString, parseRequest } from './eth-requests'; | ||
export { default as HttpRequest } from './http-request'; | ||
export { HttpRequester } from './requesters'; |
{ | ||
"name": "@portal-hq/utils", | ||
"version": "0.3.6", | ||
"version": "0.3.7", | ||
"main": "lib/commonjs/index", | ||
@@ -28,3 +28,4 @@ "module": "lib/esm/index", | ||
"typescript": "^4.8.4" | ||
} | ||
}, | ||
"gitHead": "18d87e63fe27be1ed2f13753f2207aa9bdf629d4" | ||
} |
@@ -1,2 +0,8 @@ | ||
import { ClientWithCustodianData, Dapp, DkgData, Network } from '../../types' | ||
import { | ||
type ClientWithCustodianData, | ||
type Dapp, | ||
type DkgData, | ||
type Network, | ||
type ProgressCallback, | ||
} from '../../types' | ||
@@ -19,3 +25,6 @@ export abstract class KeychainAdapter { | ||
} | ||
getDkgResult(isSim?: boolean): Promise<string> { | ||
getDkgResult( | ||
isSim?: boolean, | ||
_progress: ProgressCallback = () => {}, | ||
): Promise<string> { | ||
throw new Error( | ||
@@ -30,3 +39,7 @@ `[Portal] KeychainAdapter method getDkgResult(${isSim}) cannot be called directly. Please extend KeychainAdapter.`, | ||
} | ||
storeDkgResult(result: DkgData, isSim?: boolean): Promise<void> { | ||
storeDkgResult( | ||
result: DkgData, | ||
isSim?: boolean, | ||
_progress: ProgressCallback = () => {}, | ||
): Promise<void> { | ||
throw new Error( | ||
@@ -38,2 +51,14 @@ `[Portal] KeychainAdapter method storeDkgResult(${result}, ${isSim}) cannot be called directly. Please extend KeychainAdapter.`, | ||
export enum MpcStatuses { | ||
DecryptingShare = 'Decrypting share', | ||
Done = 'Done', | ||
EncryptingShare = 'Encrypting share', | ||
GeneratingShare = 'Generating share', | ||
ParsingShare = 'Parsing share', | ||
ReadingShare = 'Reading share', | ||
RecoveringBackupShare = 'Recovering backup share', | ||
RecoveringSigningShare = 'Recovering signing share', | ||
StoringShare = 'Storing share', | ||
} | ||
export declare class PortalApi { | ||
@@ -40,0 +65,0 @@ getClient(): Promise<ClientWithCustodianData> |
@@ -40,2 +40,4 @@ export interface PortalError { | ||
SigningNetworkError = 211, | ||
BlockedAddressByDefault = 212, | ||
BlockedAddressByEnvironment = 213, | ||
@@ -42,0 +44,0 @@ // General Errors |
@@ -68,2 +68,6 @@ import { convert } from '../currency' | ||
export const numberToHexString = (value: number): string => { | ||
return `0x${value.toString(16)}` | ||
} | ||
export const parseRequest = async ( | ||
@@ -97,2 +101,4 @@ method: string, | ||
case 'personal_sign': | ||
case 'eth_signTypedData_v3': | ||
case 'eth_signTypedData_v4': | ||
requestData = { | ||
@@ -99,0 +105,0 @@ message: hexStringToString(txParam0), |
@@ -0,4 +1,16 @@ | ||
export { | ||
chainIdToName, | ||
chainNameToId, | ||
getChainIdForName, | ||
getChainNameForId, | ||
} from './chains' | ||
export { convertLocalToCrypto, convertCryptoToLocal, convert } from './currency' | ||
export { KeychainAdapter, type PortalApi, Storage } from './definitions' | ||
export { | ||
KeychainAdapter, | ||
MpcStatuses, | ||
type PortalApi, | ||
Storage, | ||
} from './definitions' | ||
@@ -23,3 +35,3 @@ export { | ||
export { parseRequest } from './eth-requests' | ||
export { numberToHexString, parseRequest } from './eth-requests' | ||
@@ -31,4 +43,5 @@ export { default as HttpRequest } from './http-request' | ||
export { | ||
type Address, | ||
type Balance, | ||
type ClientWithCustodianData, | ||
type Address, | ||
type Dapp, | ||
@@ -39,11 +52,15 @@ type DappImage, | ||
type HttpOptions, | ||
type HttpRequestOptions, | ||
type HttpRequesterOptions, | ||
type HttpRequestOptions, | ||
type MessageData, | ||
type MpcStatus, | ||
type NFT, | ||
type Network, | ||
type OutgoingRequest, | ||
type OutgoingRequestData, | ||
type ProgressCallback, | ||
type SignableTransactionData, | ||
type SigningRequestArguments, | ||
type SigningResponse, | ||
type Transaction, | ||
} from '../types' |
106
types.d.ts
@@ -0,3 +1,7 @@ | ||
import { MpcStatuses } from './src/definitions' | ||
export type OutgoingRequestData = MessageData | SignableTransactionData | ||
export type ProgressCallback = (status: MpcStatus) => void | Promise<void> | ||
export type ValidHttpRequestMethods = 'DELETE' | 'GET' | 'POST' | 'PUT' | ||
@@ -54,8 +58,2 @@ | ||
share: string | ||
pubkey: Pubkey | ||
bks: Bk[] | ||
} | ||
export interface DkgDataV1 { | ||
share: string | ||
ssid: string | ||
@@ -108,2 +106,7 @@ pubkey: Pubkey | ||
export interface MpcStatus { | ||
status: MpcStatuses | ||
done: boolean | ||
} | ||
export interface Network { | ||
@@ -156,1 +159,92 @@ id: string | ||
} | ||
export interface NFTContract { | ||
address: string | ||
} | ||
export interface NFT { | ||
contract: NFTContract | ||
id: TokenId | ||
balance: string | ||
title: string | ||
description: string | ||
tokenUri: TokenUri | ||
media: Media[] | ||
metadata: Metadata | ||
timeLastUpdated: string | ||
contractMetadata: ContractMetadata | ||
} | ||
export interface Transaction { | ||
asset: string | ||
blockNum: string | ||
category: string | ||
erc1155Metadata: null | string | ||
erc721TokenId: null | string | ||
from: string | ||
hash: string | ||
rawContract: { | ||
address: string | ||
decimal: string | ||
value: string | ||
} | ||
to: string | ||
tokenId: null | string | ||
uniqueId: string | ||
value: number | ||
} | ||
export interface Balance { | ||
contractAddress: string | ||
balance: string | ||
} | ||
export interface TokenId { | ||
tokenId: string | ||
tokenMetadata: TokenMetadata | ||
} | ||
export interface TokenMetadata { | ||
tokenType: string | ||
} | ||
export interface TokenUri { | ||
gateway: string | ||
raw: string | ||
} | ||
export interface Media { | ||
gateway: string | ||
thumbnail: string | ||
raw: string | ||
format: string | ||
bytes: number | ||
} | ||
export interface Metadata { | ||
name: string | ||
description: string | ||
image: string | ||
external_url?: string | ||
} | ||
export interface ContractMetadata { | ||
name: string | ||
symbol: string | ||
tokenType: string | ||
contractDeployer: string | ||
deployedBlockNumber: number | ||
openSea?: OpenSeaMetadata | ||
} | ||
export interface OpenSeaMetadata { | ||
collectionName: string | ||
safelistRequestStatus: string | ||
imageUrl?: string | ||
description: string | ||
externalUrl: string | ||
lastIngestedAt: string | ||
floorPrice?: number | ||
twitterUsername?: string | ||
discordUrl?: string | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
124075
69
3628