@portal-hq/utils 4.2.9 → 4.2.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/chains/index.js +74 -1
- package/lib/commonjs/config/index.js +9 -0
- package/lib/commonjs/definitions/index.js +99 -1
- package/lib/commonjs/events/index.js +9 -0
- package/lib/commonjs/index.js +16 -1
- package/lib/commonjs/version/version.json +1 -1
- package/lib/esm/chains/index.js +73 -0
- package/lib/esm/config/index.js +6 -0
- package/lib/esm/definitions/index.js +98 -0
- package/lib/esm/events/index.js +9 -0
- package/lib/esm/index.js +3 -2
- package/lib/esm/version/version.json +1 -1
- package/package.json +2 -2
- package/src/chains/index.ts +94 -0
- package/src/config/index.ts +6 -0
- package/src/definitions/index.ts +105 -0
- package/src/events/index.ts +11 -0
- package/src/index.ts +20 -0
- package/src/version/version.json +1 -1
|
@@ -1,18 +1,91 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getChainNameForId = exports.getChainIdForName = exports.chainNameToId = exports.chainIdToName = void 0;
|
|
3
|
+
exports.getChainNameForId = exports.getChainIdForName = exports.chainNameToId = exports.chainIdToName = exports.CAIP2_CHAIN_ID_REGEX = exports.DEFAULT_CHAIN_ID_CAIP2 = exports.DEFAULT_CHAIN_ID_NUMERIC = exports.SUPPORTED_BITCOIN_P2WPKH_CHAINS = exports.FRIENDLY_CHAIN_NAME_TO_CAIP2 = exports.ALL_CHAIN_IDS = exports.BITCOIN_CHAIN_IDS = exports.SOLANA_CHAIN_IDS = exports.EVM_CHAIN_IDS = exports.NAMESPACE_TO_CURVE = exports.CHAIN_NAMESPACES = void 0;
|
|
4
|
+
exports.CHAIN_NAMESPACES = {
|
|
5
|
+
EIP155: 'eip155',
|
|
6
|
+
SOLANA: 'solana',
|
|
7
|
+
BIP122: 'bip122',
|
|
8
|
+
STELLAR: 'stellar',
|
|
9
|
+
TRON: 'tron', // Tron (partial support)
|
|
10
|
+
};
|
|
11
|
+
exports.NAMESPACE_TO_CURVE = {
|
|
12
|
+
[exports.CHAIN_NAMESPACES.EIP155]: 'SECP256K1',
|
|
13
|
+
[exports.CHAIN_NAMESPACES.BIP122]: 'SECP256K1',
|
|
14
|
+
[exports.CHAIN_NAMESPACES.TRON]: 'SECP256K1',
|
|
15
|
+
[exports.CHAIN_NAMESPACES.SOLANA]: 'ED25519',
|
|
16
|
+
[exports.CHAIN_NAMESPACES.STELLAR]: 'ED25519',
|
|
17
|
+
};
|
|
18
|
+
exports.EVM_CHAIN_IDS = {
|
|
19
|
+
ETHEREUM_MAINNET: 'eip155:1',
|
|
20
|
+
ETHEREUM_SEPOLIA: 'eip155:11155111',
|
|
21
|
+
BASE_MAINNET: 'eip155:8453',
|
|
22
|
+
BASE_SEPOLIA: 'eip155:84531',
|
|
23
|
+
POLYGON_MAINNET: 'eip155:137',
|
|
24
|
+
POLYGON_MUMBAI: 'eip155:80001',
|
|
25
|
+
POLYGON_AMOY: 'eip155:80002',
|
|
26
|
+
OPTIMISM_MAINNET: 'eip155:10',
|
|
27
|
+
ARBITRUM_MAINNET: 'eip155:42161',
|
|
28
|
+
AVALANCHE_MAINNET: 'eip155:43114',
|
|
29
|
+
};
|
|
30
|
+
exports.SOLANA_CHAIN_IDS = {
|
|
31
|
+
SOLANA_MAINNET: 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp',
|
|
32
|
+
SOLANA_DEVNET: 'solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1',
|
|
33
|
+
};
|
|
34
|
+
exports.BITCOIN_CHAIN_IDS = {
|
|
35
|
+
BITCOIN_P2WPKH_MAINNET: 'bip122:000000000019d6689c085ae165831e93-p2wpkh',
|
|
36
|
+
BITCOIN_P2WPKH_TESTNET: 'bip122:000000000933ea01ad0ee984209779ba-p2wpkh',
|
|
37
|
+
};
|
|
38
|
+
exports.ALL_CHAIN_IDS = Object.assign(Object.assign(Object.assign({}, exports.EVM_CHAIN_IDS), exports.SOLANA_CHAIN_IDS), exports.BITCOIN_CHAIN_IDS);
|
|
39
|
+
exports.FRIENDLY_CHAIN_NAME_TO_CAIP2 = {
|
|
40
|
+
// EVM chains
|
|
41
|
+
ethereum: exports.EVM_CHAIN_IDS.ETHEREUM_MAINNET,
|
|
42
|
+
sepolia: exports.EVM_CHAIN_IDS.ETHEREUM_SEPOLIA,
|
|
43
|
+
base: exports.EVM_CHAIN_IDS.BASE_MAINNET,
|
|
44
|
+
'base-sepolia': exports.EVM_CHAIN_IDS.BASE_SEPOLIA,
|
|
45
|
+
polygon: exports.EVM_CHAIN_IDS.POLYGON_MAINNET,
|
|
46
|
+
'polygon-mumbai': exports.EVM_CHAIN_IDS.POLYGON_MUMBAI,
|
|
47
|
+
'polygon-amoy': exports.EVM_CHAIN_IDS.POLYGON_AMOY,
|
|
48
|
+
optimism: exports.EVM_CHAIN_IDS.OPTIMISM_MAINNET,
|
|
49
|
+
arbitrum: exports.EVM_CHAIN_IDS.ARBITRUM_MAINNET,
|
|
50
|
+
avalanche: exports.EVM_CHAIN_IDS.AVALANCHE_MAINNET,
|
|
51
|
+
// Solana chains
|
|
52
|
+
solana: exports.SOLANA_CHAIN_IDS.SOLANA_MAINNET,
|
|
53
|
+
'solana-devnet': exports.SOLANA_CHAIN_IDS.SOLANA_DEVNET,
|
|
54
|
+
// Bitcoin chains
|
|
55
|
+
'bitcoin-p2wpkh-mainnet': exports.BITCOIN_CHAIN_IDS.BITCOIN_P2WPKH_MAINNET,
|
|
56
|
+
'bitcoin-p2wpkh-testnet': exports.BITCOIN_CHAIN_IDS.BITCOIN_P2WPKH_TESTNET,
|
|
57
|
+
};
|
|
58
|
+
exports.SUPPORTED_BITCOIN_P2WPKH_CHAINS = [
|
|
59
|
+
exports.BITCOIN_CHAIN_IDS.BITCOIN_P2WPKH_MAINNET,
|
|
60
|
+
exports.BITCOIN_CHAIN_IDS.BITCOIN_P2WPKH_TESTNET,
|
|
61
|
+
];
|
|
62
|
+
exports.DEFAULT_CHAIN_ID_NUMERIC = 11155111;
|
|
63
|
+
exports.DEFAULT_CHAIN_ID_CAIP2 = exports.EVM_CHAIN_IDS.ETHEREUM_SEPOLIA;
|
|
64
|
+
exports.CAIP2_CHAIN_ID_REGEX = /^(?:(?:eip155|solana|stellar|tron):[a-zA-Z0-9-]+|bip122:[0-9a-f]+-[a-z0-9-]+)$/;
|
|
65
|
+
/**
|
|
66
|
+
* @deprecated Legacy mapping - kept for backward compatibility
|
|
67
|
+
*/
|
|
4
68
|
exports.chainIdToName = {
|
|
5
69
|
5: 'goerli',
|
|
6
70
|
11155111: 'sepolia',
|
|
7
71
|
};
|
|
72
|
+
/**
|
|
73
|
+
* @deprecated Legacy mapping - kept for backward compatibility
|
|
74
|
+
*/
|
|
8
75
|
exports.chainNameToId = {
|
|
9
76
|
goerli: 5,
|
|
10
77
|
sepolia: 11155111,
|
|
11
78
|
};
|
|
79
|
+
/**
|
|
80
|
+
* @deprecated Use FRIENDLY_CHAIN_NAME_TO_CAIP2 instead
|
|
81
|
+
*/
|
|
12
82
|
const getChainIdForName = (chainName) => {
|
|
13
83
|
return exports.chainNameToId[chainName];
|
|
14
84
|
};
|
|
15
85
|
exports.getChainIdForName = getChainIdForName;
|
|
86
|
+
/**
|
|
87
|
+
* @deprecated Use FRIENDLY_CHAIN_NAME_TO_CAIP2 instead
|
|
88
|
+
*/
|
|
16
89
|
const getChainNameForId = (chainId) => {
|
|
17
90
|
return exports.chainIdToName[chainId];
|
|
18
91
|
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEFAULT_HOSTS = void 0;
|
|
4
|
+
exports.DEFAULT_HOSTS = {
|
|
5
|
+
API: 'api.portalhq.io',
|
|
6
|
+
MPC: 'mpc.portalhq.io',
|
|
7
|
+
ENCLAVE_MPC: 'mpc-client.portalhq.io',
|
|
8
|
+
WEBSOCKET: 'connect.portalhq.io',
|
|
9
|
+
};
|
|
@@ -1,6 +1,104 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PasswordStorage = exports.Storage = exports.MpcStatuses = exports.KeychainAdapter = void 0;
|
|
3
|
+
exports.PasswordStorage = exports.Storage = exports.MpcStatuses = exports.KeychainAdapter = exports.PortalRequestMethod = void 0;
|
|
4
|
+
var PortalRequestMethod;
|
|
5
|
+
(function (PortalRequestMethod) {
|
|
6
|
+
// ETH Methods
|
|
7
|
+
PortalRequestMethod["EthAccounts"] = "eth_accounts";
|
|
8
|
+
PortalRequestMethod["EthBlockNumber"] = "eth_blockNumber";
|
|
9
|
+
PortalRequestMethod["EthCall"] = "eth_call";
|
|
10
|
+
PortalRequestMethod["EthChainId"] = "eth_chainId";
|
|
11
|
+
PortalRequestMethod["EthEstimateGas"] = "eth_estimateGas";
|
|
12
|
+
PortalRequestMethod["EthGasPrice"] = "eth_gasPrice";
|
|
13
|
+
PortalRequestMethod["EthGetBalance"] = "eth_getBalance";
|
|
14
|
+
PortalRequestMethod["EthGetBlockTransactionCountByNumber"] = "eth_getBlockTransactionCountByNumber";
|
|
15
|
+
PortalRequestMethod["EthGetCode"] = "eth_getCode";
|
|
16
|
+
PortalRequestMethod["EthGetStorageAt"] = "eth_getStorageAt";
|
|
17
|
+
PortalRequestMethod["EthGetTransactionCount"] = "eth_getTransactionCount";
|
|
18
|
+
PortalRequestMethod["EthSendTransaction"] = "eth_sendTransaction";
|
|
19
|
+
PortalRequestMethod["EthSendRawTransaction"] = "eth_sendRawTransaction";
|
|
20
|
+
PortalRequestMethod["EthSign"] = "eth_sign";
|
|
21
|
+
PortalRequestMethod["EthSignTransaction"] = "eth_signTransaction";
|
|
22
|
+
PortalRequestMethod["EthSignTypedDataV3"] = "eth_signTypedData_v3";
|
|
23
|
+
PortalRequestMethod["EthSignTypedDataV4"] = "eth_signTypedData_v4";
|
|
24
|
+
PortalRequestMethod["PersonalSign"] = "personal_sign";
|
|
25
|
+
// Wallet Methods (MetaMask)
|
|
26
|
+
PortalRequestMethod["WalletAddEthereumChain"] = "wallet_addEthereumChain";
|
|
27
|
+
PortalRequestMethod["WalletGetPermissions"] = "wallet_getPermissions";
|
|
28
|
+
PortalRequestMethod["WalletRegisterOnboarding"] = "wallet_registerOnboarding";
|
|
29
|
+
PortalRequestMethod["WalletRequestPermissions"] = "wallet_requestPermissions";
|
|
30
|
+
PortalRequestMethod["WalletRevokePermissions"] = "wallet_revokePermissions";
|
|
31
|
+
PortalRequestMethod["WalletSwitchEthereumChain"] = "wallet_switchEthereumChain";
|
|
32
|
+
PortalRequestMethod["WalletWatchAsset"] = "wallet_watchAsset";
|
|
33
|
+
PortalRequestMethod["WalletGetCapabilities"] = "wallet_getCapabilities";
|
|
34
|
+
// Net Methods
|
|
35
|
+
PortalRequestMethod["NetVersion"] = "net_version";
|
|
36
|
+
PortalRequestMethod["NetListening"] = "net_listening";
|
|
37
|
+
// Web3 Methods
|
|
38
|
+
PortalRequestMethod["Web3ClientVersion"] = "web3_clientVersion";
|
|
39
|
+
PortalRequestMethod["Web3Sha3"] = "web3_sha3";
|
|
40
|
+
// Solana RPC Methods
|
|
41
|
+
PortalRequestMethod["SolGetAccountInfo"] = "getAccountInfo";
|
|
42
|
+
PortalRequestMethod["SolGetBalance"] = "getBalance";
|
|
43
|
+
PortalRequestMethod["SolGetBlock"] = "getBlock";
|
|
44
|
+
PortalRequestMethod["SolGetBlockCommitment"] = "getBlockCommitment";
|
|
45
|
+
PortalRequestMethod["SolGetBlockHeight"] = "getBlockHeight";
|
|
46
|
+
PortalRequestMethod["SolGetBlockProduction"] = "getBlockProduction";
|
|
47
|
+
PortalRequestMethod["SolGetBlockTime"] = "getBlockTime";
|
|
48
|
+
PortalRequestMethod["SolGetBlocks"] = "getBlocks";
|
|
49
|
+
PortalRequestMethod["SolGetBlocksWithLimit"] = "getBlocksWithLimit";
|
|
50
|
+
PortalRequestMethod["SolGetClusterNodes"] = "getClusterNodes";
|
|
51
|
+
PortalRequestMethod["SolGetEpochInfo"] = "getEpochInfo";
|
|
52
|
+
PortalRequestMethod["SolGetEpochSchedule"] = "getEpochSchedule";
|
|
53
|
+
PortalRequestMethod["SolGetFeeForMessage"] = "getFeeForMessage";
|
|
54
|
+
PortalRequestMethod["SolGetFirstAvailableBlock"] = "getFirstAvailableBlock";
|
|
55
|
+
PortalRequestMethod["SolGetGenesisHash"] = "getGenesisHash";
|
|
56
|
+
PortalRequestMethod["SolGetHealth"] = "getHealth";
|
|
57
|
+
PortalRequestMethod["SolGetHighestSnapshotSlot"] = "getHighestSnapshotSlot";
|
|
58
|
+
PortalRequestMethod["SolGetIdentity"] = "getIdentity";
|
|
59
|
+
PortalRequestMethod["SolGetInflationGovernor"] = "getInflationGovernor";
|
|
60
|
+
PortalRequestMethod["SolGetInflationRate"] = "getInflationRate";
|
|
61
|
+
PortalRequestMethod["SolGetInflationReward"] = "getInflationReward";
|
|
62
|
+
PortalRequestMethod["SolGetLargestAccounts"] = "getLargestAccounts";
|
|
63
|
+
PortalRequestMethod["SolGetLatestBlockhash"] = "getLatestBlockhash";
|
|
64
|
+
PortalRequestMethod["SolGetLeaderSchedule"] = "getLeaderSchedule";
|
|
65
|
+
PortalRequestMethod["SolGetMaxRetransmitSlot"] = "getMaxRetransmitSlot";
|
|
66
|
+
PortalRequestMethod["SolGetMaxShredInsertSlot"] = "getMaxShredInsertSlot";
|
|
67
|
+
PortalRequestMethod["SolGetMinimumBalanceForRentExemption"] = "getMinimumBalanceForRentExemption";
|
|
68
|
+
PortalRequestMethod["SolGetMultipleAccounts"] = "getMultipleAccounts";
|
|
69
|
+
PortalRequestMethod["SolGetProgramAccounts"] = "getProgramAccounts";
|
|
70
|
+
PortalRequestMethod["SolGetRecentPerformanceSamples"] = "getRecentPerformanceSamples";
|
|
71
|
+
PortalRequestMethod["SolGetRecentPrioritizationFees"] = "getRecentPrioritizationFees";
|
|
72
|
+
PortalRequestMethod["SolGetSignatureStatuses"] = "getSignatureStatuses";
|
|
73
|
+
PortalRequestMethod["SolGetSignaturesForAddress"] = "getSignaturesForAddress";
|
|
74
|
+
PortalRequestMethod["SolGetSlot"] = "getSlot";
|
|
75
|
+
PortalRequestMethod["SolGetSlotLeader"] = "getSlotLeader";
|
|
76
|
+
PortalRequestMethod["SolGetSlotLeaders"] = "getSlotLeaders";
|
|
77
|
+
PortalRequestMethod["SolGetStakeActivation"] = "getStakeActivation";
|
|
78
|
+
PortalRequestMethod["SolGetStakeMinimumDelegation"] = "getStakeMinimumDelegation";
|
|
79
|
+
PortalRequestMethod["SolGetSupply"] = "getSupply";
|
|
80
|
+
PortalRequestMethod["SolGetTokenAccountBalance"] = "getTokenAccountBalance";
|
|
81
|
+
PortalRequestMethod["SolGetTokenAccountsByDelegate"] = "getTokenAccountsByDelegate";
|
|
82
|
+
PortalRequestMethod["SolGetTokenAccountsByOwner"] = "getTokenAccountsByOwner";
|
|
83
|
+
PortalRequestMethod["SolGetTokenLargestAccounts"] = "getTokenLargestAccounts";
|
|
84
|
+
PortalRequestMethod["SolGetTokenSupply"] = "getTokenSupply";
|
|
85
|
+
PortalRequestMethod["SolGetTransaction"] = "getTransaction";
|
|
86
|
+
PortalRequestMethod["SolGetTransactionCount"] = "getTransactionCount";
|
|
87
|
+
PortalRequestMethod["SolGetVersion"] = "getVersion";
|
|
88
|
+
PortalRequestMethod["SolGetVoteAccounts"] = "getVoteAccounts";
|
|
89
|
+
PortalRequestMethod["SolIsBlockhashValid"] = "isBlockhashValid";
|
|
90
|
+
PortalRequestMethod["SolMinimumLedgerSlot"] = "minimumLedgerSlot";
|
|
91
|
+
PortalRequestMethod["SolRequestAirdrop"] = "requestAirdrop";
|
|
92
|
+
PortalRequestMethod["SolSendTransaction"] = "sendTransaction";
|
|
93
|
+
PortalRequestMethod["SolSimulateTransaction"] = "simulateTransaction";
|
|
94
|
+
// Solana Wallet Methods
|
|
95
|
+
PortalRequestMethod["SolSignAndConfirmTransaction"] = "sol_signAndConfirmTransaction";
|
|
96
|
+
PortalRequestMethod["SolSignAndSendTransaction"] = "sol_signAndSendTransaction";
|
|
97
|
+
PortalRequestMethod["SolSignMessage"] = "sol_signMessage";
|
|
98
|
+
PortalRequestMethod["SolSignTransaction"] = "sol_signTransaction";
|
|
99
|
+
// Raw
|
|
100
|
+
PortalRequestMethod["RawSign"] = "raw_sign";
|
|
101
|
+
})(PortalRequestMethod = exports.PortalRequestMethod || (exports.PortalRequestMethod = {}));
|
|
4
102
|
class KeychainAdapter {
|
|
5
103
|
loadMetadata() {
|
|
6
104
|
throw new Error('[Portal] KeychainAdapter method loadMetadata cannot be called directly. Please extend KeychainAdapter.');
|
|
@@ -49,5 +49,14 @@ var Events;
|
|
|
49
49
|
Events["HypernativeScanNFTs"] = "Hypernative Scan NFTs";
|
|
50
50
|
Events["HypernativeScanTokens"] = "Hypernative Scan Tokens";
|
|
51
51
|
Events["HypernativeScanURL"] = "Hypernative Scan URL";
|
|
52
|
+
Events["BlockaidScanEVMTx"] = "Blockaid Scan EVM Transaction";
|
|
53
|
+
Events["BlockaidScanSolanaTx"] = "Blockaid Scan Solana Transaction";
|
|
54
|
+
Events["BlockaidScanAddress"] = "Blockaid Scan Address";
|
|
55
|
+
Events["BlockaidScanTokens"] = "Blockaid Scan Tokens";
|
|
56
|
+
Events["BlockaidScanURL"] = "Blockaid Scan URL";
|
|
57
|
+
Events["DelegationsApprove"] = "Delegations Approve";
|
|
58
|
+
Events["DelegationsRevoke"] = "Delegations Revoke";
|
|
59
|
+
Events["DelegationsStatus"] = "Delegations Status";
|
|
60
|
+
Events["DelegationsTransferFrom"] = "Delegations TransferFrom";
|
|
52
61
|
})(Events || (Events = {}));
|
|
53
62
|
exports.default = Events;
|
package/lib/commonjs/index.js
CHANGED
|
@@ -3,12 +3,25 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.EvaluateTransactionOperationType = exports.HttpRequester = exports.PortalRequests = exports.HttpRequest = exports.parseRequest = exports.numberToHexString = exports.getClientPlatformVersion = 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.CloudStorageReadError = exports.Storage = exports.MpcStatuses = exports.KeychainAdapter = exports.convert = exports.convertCryptoToLocal = exports.convertLocalToCrypto = exports.getChainNameForId = exports.getChainIdForName = exports.chainNameToId = exports.chainIdToName = void 0;
|
|
6
|
+
exports.EvaluateTransactionOperationType = exports.HttpRequester = exports.PortalRequests = exports.HttpRequest = exports.parseRequest = exports.numberToHexString = exports.getClientPlatformVersion = 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.CloudStorageReadError = exports.Storage = exports.PortalRequestMethod = exports.PasswordStorage = exports.MpcStatuses = exports.KeychainAdapter = exports.convert = exports.convertCryptoToLocal = exports.convertLocalToCrypto = exports.DEFAULT_HOSTS = exports.NAMESPACE_TO_CURVE = exports.ALL_CHAIN_IDS = exports.BITCOIN_CHAIN_IDS = exports.SOLANA_CHAIN_IDS = exports.EVM_CHAIN_IDS = exports.DEFAULT_CHAIN_ID_CAIP2 = exports.DEFAULT_CHAIN_ID_NUMERIC = exports.CAIP2_CHAIN_ID_REGEX = exports.FRIENDLY_CHAIN_NAME_TO_CAIP2 = exports.SUPPORTED_BITCOIN_P2WPKH_CHAINS = exports.CHAIN_NAMESPACES = exports.getChainNameForId = exports.getChainIdForName = exports.chainNameToId = exports.chainIdToName = void 0;
|
|
7
7
|
var chains_1 = require("./chains");
|
|
8
8
|
Object.defineProperty(exports, "chainIdToName", { enumerable: true, get: function () { return chains_1.chainIdToName; } });
|
|
9
9
|
Object.defineProperty(exports, "chainNameToId", { enumerable: true, get: function () { return chains_1.chainNameToId; } });
|
|
10
10
|
Object.defineProperty(exports, "getChainIdForName", { enumerable: true, get: function () { return chains_1.getChainIdForName; } });
|
|
11
11
|
Object.defineProperty(exports, "getChainNameForId", { enumerable: true, get: function () { return chains_1.getChainNameForId; } });
|
|
12
|
+
Object.defineProperty(exports, "CHAIN_NAMESPACES", { enumerable: true, get: function () { return chains_1.CHAIN_NAMESPACES; } });
|
|
13
|
+
Object.defineProperty(exports, "SUPPORTED_BITCOIN_P2WPKH_CHAINS", { enumerable: true, get: function () { return chains_1.SUPPORTED_BITCOIN_P2WPKH_CHAINS; } });
|
|
14
|
+
Object.defineProperty(exports, "FRIENDLY_CHAIN_NAME_TO_CAIP2", { enumerable: true, get: function () { return chains_1.FRIENDLY_CHAIN_NAME_TO_CAIP2; } });
|
|
15
|
+
Object.defineProperty(exports, "CAIP2_CHAIN_ID_REGEX", { enumerable: true, get: function () { return chains_1.CAIP2_CHAIN_ID_REGEX; } });
|
|
16
|
+
Object.defineProperty(exports, "DEFAULT_CHAIN_ID_NUMERIC", { enumerable: true, get: function () { return chains_1.DEFAULT_CHAIN_ID_NUMERIC; } });
|
|
17
|
+
Object.defineProperty(exports, "DEFAULT_CHAIN_ID_CAIP2", { enumerable: true, get: function () { return chains_1.DEFAULT_CHAIN_ID_CAIP2; } });
|
|
18
|
+
Object.defineProperty(exports, "EVM_CHAIN_IDS", { enumerable: true, get: function () { return chains_1.EVM_CHAIN_IDS; } });
|
|
19
|
+
Object.defineProperty(exports, "SOLANA_CHAIN_IDS", { enumerable: true, get: function () { return chains_1.SOLANA_CHAIN_IDS; } });
|
|
20
|
+
Object.defineProperty(exports, "BITCOIN_CHAIN_IDS", { enumerable: true, get: function () { return chains_1.BITCOIN_CHAIN_IDS; } });
|
|
21
|
+
Object.defineProperty(exports, "ALL_CHAIN_IDS", { enumerable: true, get: function () { return chains_1.ALL_CHAIN_IDS; } });
|
|
22
|
+
Object.defineProperty(exports, "NAMESPACE_TO_CURVE", { enumerable: true, get: function () { return chains_1.NAMESPACE_TO_CURVE; } });
|
|
23
|
+
var config_1 = require("./config");
|
|
24
|
+
Object.defineProperty(exports, "DEFAULT_HOSTS", { enumerable: true, get: function () { return config_1.DEFAULT_HOSTS; } });
|
|
12
25
|
var currency_1 = require("./currency");
|
|
13
26
|
Object.defineProperty(exports, "convertLocalToCrypto", { enumerable: true, get: function () { return currency_1.convertLocalToCrypto; } });
|
|
14
27
|
Object.defineProperty(exports, "convertCryptoToLocal", { enumerable: true, get: function () { return currency_1.convertCryptoToLocal; } });
|
|
@@ -16,6 +29,8 @@ Object.defineProperty(exports, "convert", { enumerable: true, get: function () {
|
|
|
16
29
|
var definitions_1 = require("./definitions");
|
|
17
30
|
Object.defineProperty(exports, "KeychainAdapter", { enumerable: true, get: function () { return definitions_1.KeychainAdapter; } });
|
|
18
31
|
Object.defineProperty(exports, "MpcStatuses", { enumerable: true, get: function () { return definitions_1.MpcStatuses; } });
|
|
32
|
+
Object.defineProperty(exports, "PasswordStorage", { enumerable: true, get: function () { return definitions_1.PasswordStorage; } });
|
|
33
|
+
Object.defineProperty(exports, "PortalRequestMethod", { enumerable: true, get: function () { return definitions_1.PortalRequestMethod; } });
|
|
19
34
|
Object.defineProperty(exports, "Storage", { enumerable: true, get: function () { return definitions_1.Storage; } });
|
|
20
35
|
var errors_1 = require("./errors");
|
|
21
36
|
Object.defineProperty(exports, "CloudStorageReadError", { enumerable: true, get: function () { return errors_1.CloudStorageReadError; } });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{ "version": "4.2.
|
|
1
|
+
{ "version": "4.2.13" }
|
package/lib/esm/chains/index.js
CHANGED
|
@@ -1,14 +1,87 @@
|
|
|
1
|
+
export const CHAIN_NAMESPACES = {
|
|
2
|
+
EIP155: 'eip155',
|
|
3
|
+
SOLANA: 'solana',
|
|
4
|
+
BIP122: 'bip122',
|
|
5
|
+
STELLAR: 'stellar',
|
|
6
|
+
TRON: 'tron', // Tron (partial support)
|
|
7
|
+
};
|
|
8
|
+
export const NAMESPACE_TO_CURVE = {
|
|
9
|
+
[CHAIN_NAMESPACES.EIP155]: 'SECP256K1',
|
|
10
|
+
[CHAIN_NAMESPACES.BIP122]: 'SECP256K1',
|
|
11
|
+
[CHAIN_NAMESPACES.TRON]: 'SECP256K1',
|
|
12
|
+
[CHAIN_NAMESPACES.SOLANA]: 'ED25519',
|
|
13
|
+
[CHAIN_NAMESPACES.STELLAR]: 'ED25519',
|
|
14
|
+
};
|
|
15
|
+
export const EVM_CHAIN_IDS = {
|
|
16
|
+
ETHEREUM_MAINNET: 'eip155:1',
|
|
17
|
+
ETHEREUM_SEPOLIA: 'eip155:11155111',
|
|
18
|
+
BASE_MAINNET: 'eip155:8453',
|
|
19
|
+
BASE_SEPOLIA: 'eip155:84531',
|
|
20
|
+
POLYGON_MAINNET: 'eip155:137',
|
|
21
|
+
POLYGON_MUMBAI: 'eip155:80001',
|
|
22
|
+
POLYGON_AMOY: 'eip155:80002',
|
|
23
|
+
OPTIMISM_MAINNET: 'eip155:10',
|
|
24
|
+
ARBITRUM_MAINNET: 'eip155:42161',
|
|
25
|
+
AVALANCHE_MAINNET: 'eip155:43114',
|
|
26
|
+
};
|
|
27
|
+
export const SOLANA_CHAIN_IDS = {
|
|
28
|
+
SOLANA_MAINNET: 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp',
|
|
29
|
+
SOLANA_DEVNET: 'solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1',
|
|
30
|
+
};
|
|
31
|
+
export const BITCOIN_CHAIN_IDS = {
|
|
32
|
+
BITCOIN_P2WPKH_MAINNET: 'bip122:000000000019d6689c085ae165831e93-p2wpkh',
|
|
33
|
+
BITCOIN_P2WPKH_TESTNET: 'bip122:000000000933ea01ad0ee984209779ba-p2wpkh',
|
|
34
|
+
};
|
|
35
|
+
export const ALL_CHAIN_IDS = Object.assign(Object.assign(Object.assign({}, EVM_CHAIN_IDS), SOLANA_CHAIN_IDS), BITCOIN_CHAIN_IDS);
|
|
36
|
+
export const FRIENDLY_CHAIN_NAME_TO_CAIP2 = {
|
|
37
|
+
// EVM chains
|
|
38
|
+
ethereum: EVM_CHAIN_IDS.ETHEREUM_MAINNET,
|
|
39
|
+
sepolia: EVM_CHAIN_IDS.ETHEREUM_SEPOLIA,
|
|
40
|
+
base: EVM_CHAIN_IDS.BASE_MAINNET,
|
|
41
|
+
'base-sepolia': EVM_CHAIN_IDS.BASE_SEPOLIA,
|
|
42
|
+
polygon: EVM_CHAIN_IDS.POLYGON_MAINNET,
|
|
43
|
+
'polygon-mumbai': EVM_CHAIN_IDS.POLYGON_MUMBAI,
|
|
44
|
+
'polygon-amoy': EVM_CHAIN_IDS.POLYGON_AMOY,
|
|
45
|
+
optimism: EVM_CHAIN_IDS.OPTIMISM_MAINNET,
|
|
46
|
+
arbitrum: EVM_CHAIN_IDS.ARBITRUM_MAINNET,
|
|
47
|
+
avalanche: EVM_CHAIN_IDS.AVALANCHE_MAINNET,
|
|
48
|
+
// Solana chains
|
|
49
|
+
solana: SOLANA_CHAIN_IDS.SOLANA_MAINNET,
|
|
50
|
+
'solana-devnet': SOLANA_CHAIN_IDS.SOLANA_DEVNET,
|
|
51
|
+
// Bitcoin chains
|
|
52
|
+
'bitcoin-p2wpkh-mainnet': BITCOIN_CHAIN_IDS.BITCOIN_P2WPKH_MAINNET,
|
|
53
|
+
'bitcoin-p2wpkh-testnet': BITCOIN_CHAIN_IDS.BITCOIN_P2WPKH_TESTNET,
|
|
54
|
+
};
|
|
55
|
+
export const SUPPORTED_BITCOIN_P2WPKH_CHAINS = [
|
|
56
|
+
BITCOIN_CHAIN_IDS.BITCOIN_P2WPKH_MAINNET,
|
|
57
|
+
BITCOIN_CHAIN_IDS.BITCOIN_P2WPKH_TESTNET,
|
|
58
|
+
];
|
|
59
|
+
export const DEFAULT_CHAIN_ID_NUMERIC = 11155111;
|
|
60
|
+
export const DEFAULT_CHAIN_ID_CAIP2 = EVM_CHAIN_IDS.ETHEREUM_SEPOLIA;
|
|
61
|
+
export const CAIP2_CHAIN_ID_REGEX = /^(?:(?:eip155|solana|stellar|tron):[a-zA-Z0-9-]+|bip122:[0-9a-f]+-[a-z0-9-]+)$/;
|
|
62
|
+
/**
|
|
63
|
+
* @deprecated Legacy mapping - kept for backward compatibility
|
|
64
|
+
*/
|
|
1
65
|
export const chainIdToName = {
|
|
2
66
|
5: 'goerli',
|
|
3
67
|
11155111: 'sepolia',
|
|
4
68
|
};
|
|
69
|
+
/**
|
|
70
|
+
* @deprecated Legacy mapping - kept for backward compatibility
|
|
71
|
+
*/
|
|
5
72
|
export const chainNameToId = {
|
|
6
73
|
goerli: 5,
|
|
7
74
|
sepolia: 11155111,
|
|
8
75
|
};
|
|
76
|
+
/**
|
|
77
|
+
* @deprecated Use FRIENDLY_CHAIN_NAME_TO_CAIP2 instead
|
|
78
|
+
*/
|
|
9
79
|
export const getChainIdForName = (chainName) => {
|
|
10
80
|
return chainNameToId[chainName];
|
|
11
81
|
};
|
|
82
|
+
/**
|
|
83
|
+
* @deprecated Use FRIENDLY_CHAIN_NAME_TO_CAIP2 instead
|
|
84
|
+
*/
|
|
12
85
|
export const getChainNameForId = (chainId) => {
|
|
13
86
|
return chainIdToName[chainId];
|
|
14
87
|
};
|
|
@@ -1,3 +1,101 @@
|
|
|
1
|
+
export var PortalRequestMethod;
|
|
2
|
+
(function (PortalRequestMethod) {
|
|
3
|
+
// ETH Methods
|
|
4
|
+
PortalRequestMethod["EthAccounts"] = "eth_accounts";
|
|
5
|
+
PortalRequestMethod["EthBlockNumber"] = "eth_blockNumber";
|
|
6
|
+
PortalRequestMethod["EthCall"] = "eth_call";
|
|
7
|
+
PortalRequestMethod["EthChainId"] = "eth_chainId";
|
|
8
|
+
PortalRequestMethod["EthEstimateGas"] = "eth_estimateGas";
|
|
9
|
+
PortalRequestMethod["EthGasPrice"] = "eth_gasPrice";
|
|
10
|
+
PortalRequestMethod["EthGetBalance"] = "eth_getBalance";
|
|
11
|
+
PortalRequestMethod["EthGetBlockTransactionCountByNumber"] = "eth_getBlockTransactionCountByNumber";
|
|
12
|
+
PortalRequestMethod["EthGetCode"] = "eth_getCode";
|
|
13
|
+
PortalRequestMethod["EthGetStorageAt"] = "eth_getStorageAt";
|
|
14
|
+
PortalRequestMethod["EthGetTransactionCount"] = "eth_getTransactionCount";
|
|
15
|
+
PortalRequestMethod["EthSendTransaction"] = "eth_sendTransaction";
|
|
16
|
+
PortalRequestMethod["EthSendRawTransaction"] = "eth_sendRawTransaction";
|
|
17
|
+
PortalRequestMethod["EthSign"] = "eth_sign";
|
|
18
|
+
PortalRequestMethod["EthSignTransaction"] = "eth_signTransaction";
|
|
19
|
+
PortalRequestMethod["EthSignTypedDataV3"] = "eth_signTypedData_v3";
|
|
20
|
+
PortalRequestMethod["EthSignTypedDataV4"] = "eth_signTypedData_v4";
|
|
21
|
+
PortalRequestMethod["PersonalSign"] = "personal_sign";
|
|
22
|
+
// Wallet Methods (MetaMask)
|
|
23
|
+
PortalRequestMethod["WalletAddEthereumChain"] = "wallet_addEthereumChain";
|
|
24
|
+
PortalRequestMethod["WalletGetPermissions"] = "wallet_getPermissions";
|
|
25
|
+
PortalRequestMethod["WalletRegisterOnboarding"] = "wallet_registerOnboarding";
|
|
26
|
+
PortalRequestMethod["WalletRequestPermissions"] = "wallet_requestPermissions";
|
|
27
|
+
PortalRequestMethod["WalletRevokePermissions"] = "wallet_revokePermissions";
|
|
28
|
+
PortalRequestMethod["WalletSwitchEthereumChain"] = "wallet_switchEthereumChain";
|
|
29
|
+
PortalRequestMethod["WalletWatchAsset"] = "wallet_watchAsset";
|
|
30
|
+
PortalRequestMethod["WalletGetCapabilities"] = "wallet_getCapabilities";
|
|
31
|
+
// Net Methods
|
|
32
|
+
PortalRequestMethod["NetVersion"] = "net_version";
|
|
33
|
+
PortalRequestMethod["NetListening"] = "net_listening";
|
|
34
|
+
// Web3 Methods
|
|
35
|
+
PortalRequestMethod["Web3ClientVersion"] = "web3_clientVersion";
|
|
36
|
+
PortalRequestMethod["Web3Sha3"] = "web3_sha3";
|
|
37
|
+
// Solana RPC Methods
|
|
38
|
+
PortalRequestMethod["SolGetAccountInfo"] = "getAccountInfo";
|
|
39
|
+
PortalRequestMethod["SolGetBalance"] = "getBalance";
|
|
40
|
+
PortalRequestMethod["SolGetBlock"] = "getBlock";
|
|
41
|
+
PortalRequestMethod["SolGetBlockCommitment"] = "getBlockCommitment";
|
|
42
|
+
PortalRequestMethod["SolGetBlockHeight"] = "getBlockHeight";
|
|
43
|
+
PortalRequestMethod["SolGetBlockProduction"] = "getBlockProduction";
|
|
44
|
+
PortalRequestMethod["SolGetBlockTime"] = "getBlockTime";
|
|
45
|
+
PortalRequestMethod["SolGetBlocks"] = "getBlocks";
|
|
46
|
+
PortalRequestMethod["SolGetBlocksWithLimit"] = "getBlocksWithLimit";
|
|
47
|
+
PortalRequestMethod["SolGetClusterNodes"] = "getClusterNodes";
|
|
48
|
+
PortalRequestMethod["SolGetEpochInfo"] = "getEpochInfo";
|
|
49
|
+
PortalRequestMethod["SolGetEpochSchedule"] = "getEpochSchedule";
|
|
50
|
+
PortalRequestMethod["SolGetFeeForMessage"] = "getFeeForMessage";
|
|
51
|
+
PortalRequestMethod["SolGetFirstAvailableBlock"] = "getFirstAvailableBlock";
|
|
52
|
+
PortalRequestMethod["SolGetGenesisHash"] = "getGenesisHash";
|
|
53
|
+
PortalRequestMethod["SolGetHealth"] = "getHealth";
|
|
54
|
+
PortalRequestMethod["SolGetHighestSnapshotSlot"] = "getHighestSnapshotSlot";
|
|
55
|
+
PortalRequestMethod["SolGetIdentity"] = "getIdentity";
|
|
56
|
+
PortalRequestMethod["SolGetInflationGovernor"] = "getInflationGovernor";
|
|
57
|
+
PortalRequestMethod["SolGetInflationRate"] = "getInflationRate";
|
|
58
|
+
PortalRequestMethod["SolGetInflationReward"] = "getInflationReward";
|
|
59
|
+
PortalRequestMethod["SolGetLargestAccounts"] = "getLargestAccounts";
|
|
60
|
+
PortalRequestMethod["SolGetLatestBlockhash"] = "getLatestBlockhash";
|
|
61
|
+
PortalRequestMethod["SolGetLeaderSchedule"] = "getLeaderSchedule";
|
|
62
|
+
PortalRequestMethod["SolGetMaxRetransmitSlot"] = "getMaxRetransmitSlot";
|
|
63
|
+
PortalRequestMethod["SolGetMaxShredInsertSlot"] = "getMaxShredInsertSlot";
|
|
64
|
+
PortalRequestMethod["SolGetMinimumBalanceForRentExemption"] = "getMinimumBalanceForRentExemption";
|
|
65
|
+
PortalRequestMethod["SolGetMultipleAccounts"] = "getMultipleAccounts";
|
|
66
|
+
PortalRequestMethod["SolGetProgramAccounts"] = "getProgramAccounts";
|
|
67
|
+
PortalRequestMethod["SolGetRecentPerformanceSamples"] = "getRecentPerformanceSamples";
|
|
68
|
+
PortalRequestMethod["SolGetRecentPrioritizationFees"] = "getRecentPrioritizationFees";
|
|
69
|
+
PortalRequestMethod["SolGetSignatureStatuses"] = "getSignatureStatuses";
|
|
70
|
+
PortalRequestMethod["SolGetSignaturesForAddress"] = "getSignaturesForAddress";
|
|
71
|
+
PortalRequestMethod["SolGetSlot"] = "getSlot";
|
|
72
|
+
PortalRequestMethod["SolGetSlotLeader"] = "getSlotLeader";
|
|
73
|
+
PortalRequestMethod["SolGetSlotLeaders"] = "getSlotLeaders";
|
|
74
|
+
PortalRequestMethod["SolGetStakeActivation"] = "getStakeActivation";
|
|
75
|
+
PortalRequestMethod["SolGetStakeMinimumDelegation"] = "getStakeMinimumDelegation";
|
|
76
|
+
PortalRequestMethod["SolGetSupply"] = "getSupply";
|
|
77
|
+
PortalRequestMethod["SolGetTokenAccountBalance"] = "getTokenAccountBalance";
|
|
78
|
+
PortalRequestMethod["SolGetTokenAccountsByDelegate"] = "getTokenAccountsByDelegate";
|
|
79
|
+
PortalRequestMethod["SolGetTokenAccountsByOwner"] = "getTokenAccountsByOwner";
|
|
80
|
+
PortalRequestMethod["SolGetTokenLargestAccounts"] = "getTokenLargestAccounts";
|
|
81
|
+
PortalRequestMethod["SolGetTokenSupply"] = "getTokenSupply";
|
|
82
|
+
PortalRequestMethod["SolGetTransaction"] = "getTransaction";
|
|
83
|
+
PortalRequestMethod["SolGetTransactionCount"] = "getTransactionCount";
|
|
84
|
+
PortalRequestMethod["SolGetVersion"] = "getVersion";
|
|
85
|
+
PortalRequestMethod["SolGetVoteAccounts"] = "getVoteAccounts";
|
|
86
|
+
PortalRequestMethod["SolIsBlockhashValid"] = "isBlockhashValid";
|
|
87
|
+
PortalRequestMethod["SolMinimumLedgerSlot"] = "minimumLedgerSlot";
|
|
88
|
+
PortalRequestMethod["SolRequestAirdrop"] = "requestAirdrop";
|
|
89
|
+
PortalRequestMethod["SolSendTransaction"] = "sendTransaction";
|
|
90
|
+
PortalRequestMethod["SolSimulateTransaction"] = "simulateTransaction";
|
|
91
|
+
// Solana Wallet Methods
|
|
92
|
+
PortalRequestMethod["SolSignAndConfirmTransaction"] = "sol_signAndConfirmTransaction";
|
|
93
|
+
PortalRequestMethod["SolSignAndSendTransaction"] = "sol_signAndSendTransaction";
|
|
94
|
+
PortalRequestMethod["SolSignMessage"] = "sol_signMessage";
|
|
95
|
+
PortalRequestMethod["SolSignTransaction"] = "sol_signTransaction";
|
|
96
|
+
// Raw
|
|
97
|
+
PortalRequestMethod["RawSign"] = "raw_sign";
|
|
98
|
+
})(PortalRequestMethod || (PortalRequestMethod = {}));
|
|
1
99
|
export class KeychainAdapter {
|
|
2
100
|
loadMetadata() {
|
|
3
101
|
throw new Error('[Portal] KeychainAdapter method loadMetadata cannot be called directly. Please extend KeychainAdapter.');
|
package/lib/esm/events/index.js
CHANGED
|
@@ -47,5 +47,14 @@ var Events;
|
|
|
47
47
|
Events["HypernativeScanNFTs"] = "Hypernative Scan NFTs";
|
|
48
48
|
Events["HypernativeScanTokens"] = "Hypernative Scan Tokens";
|
|
49
49
|
Events["HypernativeScanURL"] = "Hypernative Scan URL";
|
|
50
|
+
Events["BlockaidScanEVMTx"] = "Blockaid Scan EVM Transaction";
|
|
51
|
+
Events["BlockaidScanSolanaTx"] = "Blockaid Scan Solana Transaction";
|
|
52
|
+
Events["BlockaidScanAddress"] = "Blockaid Scan Address";
|
|
53
|
+
Events["BlockaidScanTokens"] = "Blockaid Scan Tokens";
|
|
54
|
+
Events["BlockaidScanURL"] = "Blockaid Scan URL";
|
|
55
|
+
Events["DelegationsApprove"] = "Delegations Approve";
|
|
56
|
+
Events["DelegationsRevoke"] = "Delegations Revoke";
|
|
57
|
+
Events["DelegationsStatus"] = "Delegations Status";
|
|
58
|
+
Events["DelegationsTransferFrom"] = "Delegations TransferFrom";
|
|
50
59
|
})(Events || (Events = {}));
|
|
51
60
|
export default Events;
|
package/lib/esm/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export { chainIdToName, chainNameToId, getChainIdForName, getChainNameForId, } from './chains';
|
|
1
|
+
export { chainIdToName, chainNameToId, getChainIdForName, getChainNameForId, CHAIN_NAMESPACES, SUPPORTED_BITCOIN_P2WPKH_CHAINS, FRIENDLY_CHAIN_NAME_TO_CAIP2, CAIP2_CHAIN_ID_REGEX, DEFAULT_CHAIN_ID_NUMERIC, DEFAULT_CHAIN_ID_CAIP2, EVM_CHAIN_IDS, SOLANA_CHAIN_IDS, BITCOIN_CHAIN_IDS, ALL_CHAIN_IDS, NAMESPACE_TO_CURVE, } from './chains';
|
|
2
|
+
export { DEFAULT_HOSTS } from './config';
|
|
2
3
|
export { convertLocalToCrypto, convertCryptoToLocal, convert } from './currency';
|
|
3
|
-
export { KeychainAdapter, MpcStatuses, Storage, } from './definitions';
|
|
4
|
+
export { KeychainAdapter, MpcStatuses, PasswordStorage, PortalRequestMethod, Storage, } from './definitions';
|
|
4
5
|
export { CloudStorageReadError, HttpError, InvalidApiKeyError, InvalidChainIdError, InvalidGatewayConfigError, MissingOptionError, MpcSigningError, NoAddressError, PortalErrorCodes, PortalErrorCodeTypes, PortalMpcError, ProviderRpcError, RpcErrorCodes, } from './errors';
|
|
5
6
|
export { default as Events } from './events';
|
|
6
7
|
export { getClientPlatformVersion } from './version';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{ "version": "4.2.
|
|
1
|
+
{ "version": "4.2.13" }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@portal-hq/utils",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.13",
|
|
4
4
|
"main": "lib/commonjs/index",
|
|
5
5
|
"module": "lib/esm/index",
|
|
6
6
|
"source": "src/index",
|
|
@@ -26,5 +26,5 @@
|
|
|
26
26
|
"ts-jest": "^29.0.3",
|
|
27
27
|
"typescript": "^4.8.4"
|
|
28
28
|
},
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "cd2865d204185bcfedd02b94487afc46f4922780"
|
|
30
30
|
}
|
package/src/chains/index.ts
CHANGED
|
@@ -1,17 +1,111 @@
|
|
|
1
|
+
export const CHAIN_NAMESPACES = {
|
|
2
|
+
EIP155: 'eip155', // Ethereum and EVM-compatible chains
|
|
3
|
+
SOLANA: 'solana', // Solana
|
|
4
|
+
BIP122: 'bip122', // Bitcoin
|
|
5
|
+
STELLAR: 'stellar', // Stellar (partial support)
|
|
6
|
+
TRON: 'tron', // Tron (partial support)
|
|
7
|
+
} as const
|
|
8
|
+
|
|
9
|
+
export type ChainNamespace =
|
|
10
|
+
(typeof CHAIN_NAMESPACES)[keyof typeof CHAIN_NAMESPACES]
|
|
11
|
+
|
|
12
|
+
export const NAMESPACE_TO_CURVE = {
|
|
13
|
+
[CHAIN_NAMESPACES.EIP155]: 'SECP256K1',
|
|
14
|
+
[CHAIN_NAMESPACES.BIP122]: 'SECP256K1',
|
|
15
|
+
[CHAIN_NAMESPACES.TRON]: 'SECP256K1',
|
|
16
|
+
[CHAIN_NAMESPACES.SOLANA]: 'ED25519',
|
|
17
|
+
[CHAIN_NAMESPACES.STELLAR]: 'ED25519',
|
|
18
|
+
} as const
|
|
19
|
+
|
|
20
|
+
export const EVM_CHAIN_IDS = {
|
|
21
|
+
ETHEREUM_MAINNET: 'eip155:1',
|
|
22
|
+
ETHEREUM_SEPOLIA: 'eip155:11155111',
|
|
23
|
+
BASE_MAINNET: 'eip155:8453',
|
|
24
|
+
BASE_SEPOLIA: 'eip155:84531',
|
|
25
|
+
POLYGON_MAINNET: 'eip155:137',
|
|
26
|
+
POLYGON_MUMBAI: 'eip155:80001',
|
|
27
|
+
POLYGON_AMOY: 'eip155:80002',
|
|
28
|
+
OPTIMISM_MAINNET: 'eip155:10',
|
|
29
|
+
ARBITRUM_MAINNET: 'eip155:42161',
|
|
30
|
+
AVALANCHE_MAINNET: 'eip155:43114',
|
|
31
|
+
} as const
|
|
32
|
+
|
|
33
|
+
export const SOLANA_CHAIN_IDS = {
|
|
34
|
+
SOLANA_MAINNET: 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp',
|
|
35
|
+
SOLANA_DEVNET: 'solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1',
|
|
36
|
+
} as const
|
|
37
|
+
|
|
38
|
+
export const BITCOIN_CHAIN_IDS = {
|
|
39
|
+
BITCOIN_P2WPKH_MAINNET: 'bip122:000000000019d6689c085ae165831e93-p2wpkh',
|
|
40
|
+
BITCOIN_P2WPKH_TESTNET: 'bip122:000000000933ea01ad0ee984209779ba-p2wpkh',
|
|
41
|
+
} as const
|
|
42
|
+
|
|
43
|
+
export const ALL_CHAIN_IDS = {
|
|
44
|
+
...EVM_CHAIN_IDS,
|
|
45
|
+
...SOLANA_CHAIN_IDS,
|
|
46
|
+
...BITCOIN_CHAIN_IDS,
|
|
47
|
+
} as const
|
|
48
|
+
|
|
49
|
+
export const FRIENDLY_CHAIN_NAME_TO_CAIP2 = {
|
|
50
|
+
// EVM chains
|
|
51
|
+
ethereum: EVM_CHAIN_IDS.ETHEREUM_MAINNET,
|
|
52
|
+
sepolia: EVM_CHAIN_IDS.ETHEREUM_SEPOLIA,
|
|
53
|
+
base: EVM_CHAIN_IDS.BASE_MAINNET,
|
|
54
|
+
'base-sepolia': EVM_CHAIN_IDS.BASE_SEPOLIA,
|
|
55
|
+
polygon: EVM_CHAIN_IDS.POLYGON_MAINNET,
|
|
56
|
+
'polygon-mumbai': EVM_CHAIN_IDS.POLYGON_MUMBAI,
|
|
57
|
+
'polygon-amoy': EVM_CHAIN_IDS.POLYGON_AMOY,
|
|
58
|
+
optimism: EVM_CHAIN_IDS.OPTIMISM_MAINNET,
|
|
59
|
+
arbitrum: EVM_CHAIN_IDS.ARBITRUM_MAINNET,
|
|
60
|
+
avalanche: EVM_CHAIN_IDS.AVALANCHE_MAINNET,
|
|
61
|
+
// Solana chains
|
|
62
|
+
solana: SOLANA_CHAIN_IDS.SOLANA_MAINNET,
|
|
63
|
+
'solana-devnet': SOLANA_CHAIN_IDS.SOLANA_DEVNET,
|
|
64
|
+
// Bitcoin chains
|
|
65
|
+
'bitcoin-p2wpkh-mainnet': BITCOIN_CHAIN_IDS.BITCOIN_P2WPKH_MAINNET,
|
|
66
|
+
'bitcoin-p2wpkh-testnet': BITCOIN_CHAIN_IDS.BITCOIN_P2WPKH_TESTNET,
|
|
67
|
+
} as const
|
|
68
|
+
|
|
69
|
+
export type FriendlyChainName = keyof typeof FRIENDLY_CHAIN_NAME_TO_CAIP2
|
|
70
|
+
|
|
71
|
+
export const SUPPORTED_BITCOIN_P2WPKH_CHAINS = [
|
|
72
|
+
BITCOIN_CHAIN_IDS.BITCOIN_P2WPKH_MAINNET,
|
|
73
|
+
BITCOIN_CHAIN_IDS.BITCOIN_P2WPKH_TESTNET,
|
|
74
|
+
] as const
|
|
75
|
+
|
|
76
|
+
export const DEFAULT_CHAIN_ID_NUMERIC = 11155111
|
|
77
|
+
|
|
78
|
+
export const DEFAULT_CHAIN_ID_CAIP2 = EVM_CHAIN_IDS.ETHEREUM_SEPOLIA
|
|
79
|
+
|
|
80
|
+
export const CAIP2_CHAIN_ID_REGEX =
|
|
81
|
+
/^(?:(?:eip155|solana|stellar|tron):[a-zA-Z0-9-]+|bip122:[0-9a-f]+-[a-z0-9-]+)$/
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* @deprecated Legacy mapping - kept for backward compatibility
|
|
85
|
+
*/
|
|
1
86
|
export const chainIdToName: Record<number, string> = {
|
|
2
87
|
5: 'goerli',
|
|
3
88
|
11155111: 'sepolia',
|
|
4
89
|
}
|
|
5
90
|
|
|
91
|
+
/**
|
|
92
|
+
* @deprecated Legacy mapping - kept for backward compatibility
|
|
93
|
+
*/
|
|
6
94
|
export const chainNameToId: Record<string, number> = {
|
|
7
95
|
goerli: 5,
|
|
8
96
|
sepolia: 11155111,
|
|
9
97
|
}
|
|
10
98
|
|
|
99
|
+
/**
|
|
100
|
+
* @deprecated Use FRIENDLY_CHAIN_NAME_TO_CAIP2 instead
|
|
101
|
+
*/
|
|
11
102
|
export const getChainIdForName = (chainName: string): number => {
|
|
12
103
|
return chainNameToId[chainName]
|
|
13
104
|
}
|
|
14
105
|
|
|
106
|
+
/**
|
|
107
|
+
* @deprecated Use FRIENDLY_CHAIN_NAME_TO_CAIP2 instead
|
|
108
|
+
*/
|
|
15
109
|
export const getChainNameForId = (chainId: number): string => {
|
|
16
110
|
return chainIdToName[chainId]
|
|
17
111
|
}
|
package/src/definitions/index.ts
CHANGED
|
@@ -79,6 +79,111 @@ export interface RequestOptions {
|
|
|
79
79
|
sponsorGas?: boolean
|
|
80
80
|
signatureApprovalMemo?: string
|
|
81
81
|
}
|
|
82
|
+
|
|
83
|
+
export enum PortalRequestMethod {
|
|
84
|
+
// ETH Methods
|
|
85
|
+
EthAccounts = 'eth_accounts',
|
|
86
|
+
EthBlockNumber = 'eth_blockNumber',
|
|
87
|
+
EthCall = 'eth_call',
|
|
88
|
+
EthChainId = 'eth_chainId',
|
|
89
|
+
EthEstimateGas = 'eth_estimateGas',
|
|
90
|
+
EthGasPrice = 'eth_gasPrice',
|
|
91
|
+
EthGetBalance = 'eth_getBalance',
|
|
92
|
+
EthGetBlockTransactionCountByNumber = 'eth_getBlockTransactionCountByNumber',
|
|
93
|
+
EthGetCode = 'eth_getCode',
|
|
94
|
+
EthGetStorageAt = 'eth_getStorageAt',
|
|
95
|
+
EthGetTransactionCount = 'eth_getTransactionCount',
|
|
96
|
+
EthSendTransaction = 'eth_sendTransaction',
|
|
97
|
+
EthSendRawTransaction = 'eth_sendRawTransaction',
|
|
98
|
+
EthSign = 'eth_sign',
|
|
99
|
+
EthSignTransaction = 'eth_signTransaction',
|
|
100
|
+
EthSignTypedDataV3 = 'eth_signTypedData_v3',
|
|
101
|
+
EthSignTypedDataV4 = 'eth_signTypedData_v4',
|
|
102
|
+
PersonalSign = 'personal_sign',
|
|
103
|
+
|
|
104
|
+
// Wallet Methods (MetaMask)
|
|
105
|
+
WalletAddEthereumChain = 'wallet_addEthereumChain',
|
|
106
|
+
WalletGetPermissions = 'wallet_getPermissions',
|
|
107
|
+
WalletRegisterOnboarding = 'wallet_registerOnboarding',
|
|
108
|
+
WalletRequestPermissions = 'wallet_requestPermissions',
|
|
109
|
+
WalletRevokePermissions = 'wallet_revokePermissions',
|
|
110
|
+
WalletSwitchEthereumChain = 'wallet_switchEthereumChain',
|
|
111
|
+
WalletWatchAsset = 'wallet_watchAsset',
|
|
112
|
+
WalletGetCapabilities = 'wallet_getCapabilities',
|
|
113
|
+
|
|
114
|
+
// Net Methods
|
|
115
|
+
NetVersion = 'net_version',
|
|
116
|
+
NetListening = 'net_listening',
|
|
117
|
+
|
|
118
|
+
// Web3 Methods
|
|
119
|
+
Web3ClientVersion = 'web3_clientVersion',
|
|
120
|
+
Web3Sha3 = 'web3_sha3',
|
|
121
|
+
|
|
122
|
+
// Solana RPC Methods
|
|
123
|
+
SolGetAccountInfo = 'getAccountInfo',
|
|
124
|
+
SolGetBalance = 'getBalance',
|
|
125
|
+
SolGetBlock = 'getBlock',
|
|
126
|
+
SolGetBlockCommitment = 'getBlockCommitment',
|
|
127
|
+
SolGetBlockHeight = 'getBlockHeight',
|
|
128
|
+
SolGetBlockProduction = 'getBlockProduction',
|
|
129
|
+
SolGetBlockTime = 'getBlockTime',
|
|
130
|
+
SolGetBlocks = 'getBlocks',
|
|
131
|
+
SolGetBlocksWithLimit = 'getBlocksWithLimit',
|
|
132
|
+
SolGetClusterNodes = 'getClusterNodes',
|
|
133
|
+
SolGetEpochInfo = 'getEpochInfo',
|
|
134
|
+
SolGetEpochSchedule = 'getEpochSchedule',
|
|
135
|
+
SolGetFeeForMessage = 'getFeeForMessage',
|
|
136
|
+
SolGetFirstAvailableBlock = 'getFirstAvailableBlock',
|
|
137
|
+
SolGetGenesisHash = 'getGenesisHash',
|
|
138
|
+
SolGetHealth = 'getHealth',
|
|
139
|
+
SolGetHighestSnapshotSlot = 'getHighestSnapshotSlot',
|
|
140
|
+
SolGetIdentity = 'getIdentity',
|
|
141
|
+
SolGetInflationGovernor = 'getInflationGovernor',
|
|
142
|
+
SolGetInflationRate = 'getInflationRate',
|
|
143
|
+
SolGetInflationReward = 'getInflationReward',
|
|
144
|
+
SolGetLargestAccounts = 'getLargestAccounts',
|
|
145
|
+
SolGetLatestBlockhash = 'getLatestBlockhash',
|
|
146
|
+
SolGetLeaderSchedule = 'getLeaderSchedule',
|
|
147
|
+
SolGetMaxRetransmitSlot = 'getMaxRetransmitSlot',
|
|
148
|
+
SolGetMaxShredInsertSlot = 'getMaxShredInsertSlot',
|
|
149
|
+
SolGetMinimumBalanceForRentExemption = 'getMinimumBalanceForRentExemption',
|
|
150
|
+
SolGetMultipleAccounts = 'getMultipleAccounts',
|
|
151
|
+
SolGetProgramAccounts = 'getProgramAccounts',
|
|
152
|
+
SolGetRecentPerformanceSamples = 'getRecentPerformanceSamples',
|
|
153
|
+
SolGetRecentPrioritizationFees = 'getRecentPrioritizationFees',
|
|
154
|
+
SolGetSignatureStatuses = 'getSignatureStatuses',
|
|
155
|
+
SolGetSignaturesForAddress = 'getSignaturesForAddress',
|
|
156
|
+
SolGetSlot = 'getSlot',
|
|
157
|
+
SolGetSlotLeader = 'getSlotLeader',
|
|
158
|
+
SolGetSlotLeaders = 'getSlotLeaders',
|
|
159
|
+
SolGetStakeActivation = 'getStakeActivation',
|
|
160
|
+
SolGetStakeMinimumDelegation = 'getStakeMinimumDelegation',
|
|
161
|
+
SolGetSupply = 'getSupply',
|
|
162
|
+
SolGetTokenAccountBalance = 'getTokenAccountBalance',
|
|
163
|
+
SolGetTokenAccountsByDelegate = 'getTokenAccountsByDelegate',
|
|
164
|
+
SolGetTokenAccountsByOwner = 'getTokenAccountsByOwner',
|
|
165
|
+
SolGetTokenLargestAccounts = 'getTokenLargestAccounts',
|
|
166
|
+
SolGetTokenSupply = 'getTokenSupply',
|
|
167
|
+
SolGetTransaction = 'getTransaction',
|
|
168
|
+
SolGetTransactionCount = 'getTransactionCount',
|
|
169
|
+
SolGetVersion = 'getVersion',
|
|
170
|
+
SolGetVoteAccounts = 'getVoteAccounts',
|
|
171
|
+
SolIsBlockhashValid = 'isBlockhashValid',
|
|
172
|
+
SolMinimumLedgerSlot = 'minimumLedgerSlot',
|
|
173
|
+
SolRequestAirdrop = 'requestAirdrop',
|
|
174
|
+
SolSendTransaction = 'sendTransaction',
|
|
175
|
+
SolSimulateTransaction = 'simulateTransaction',
|
|
176
|
+
|
|
177
|
+
// Solana Wallet Methods
|
|
178
|
+
SolSignAndConfirmTransaction = 'sol_signAndConfirmTransaction',
|
|
179
|
+
SolSignAndSendTransaction = 'sol_signAndSendTransaction',
|
|
180
|
+
SolSignMessage = 'sol_signMessage',
|
|
181
|
+
SolSignTransaction = 'sol_signTransaction',
|
|
182
|
+
|
|
183
|
+
// Raw
|
|
184
|
+
RawSign = 'raw_sign',
|
|
185
|
+
}
|
|
186
|
+
|
|
82
187
|
export interface SendAssetParams {
|
|
83
188
|
to: string
|
|
84
189
|
amount: string
|
package/src/events/index.ts
CHANGED
|
@@ -49,6 +49,17 @@ enum Events {
|
|
|
49
49
|
HypernativeScanNFTs = 'Hypernative Scan NFTs',
|
|
50
50
|
HypernativeScanTokens = 'Hypernative Scan Tokens',
|
|
51
51
|
HypernativeScanURL = 'Hypernative Scan URL',
|
|
52
|
+
|
|
53
|
+
BlockaidScanEVMTx = 'Blockaid Scan EVM Transaction',
|
|
54
|
+
BlockaidScanSolanaTx = 'Blockaid Scan Solana Transaction',
|
|
55
|
+
BlockaidScanAddress = 'Blockaid Scan Address',
|
|
56
|
+
BlockaidScanTokens = 'Blockaid Scan Tokens',
|
|
57
|
+
BlockaidScanURL = 'Blockaid Scan URL',
|
|
58
|
+
|
|
59
|
+
DelegationsApprove = 'Delegations Approve',
|
|
60
|
+
DelegationsRevoke = 'Delegations Revoke',
|
|
61
|
+
DelegationsStatus = 'Delegations Status',
|
|
62
|
+
DelegationsTransferFrom = 'Delegations TransferFrom',
|
|
52
63
|
}
|
|
53
64
|
|
|
54
65
|
export default Events
|
package/src/index.ts
CHANGED
|
@@ -3,8 +3,23 @@ export {
|
|
|
3
3
|
chainNameToId,
|
|
4
4
|
getChainIdForName,
|
|
5
5
|
getChainNameForId,
|
|
6
|
+
CHAIN_NAMESPACES,
|
|
7
|
+
SUPPORTED_BITCOIN_P2WPKH_CHAINS,
|
|
8
|
+
FRIENDLY_CHAIN_NAME_TO_CAIP2,
|
|
9
|
+
CAIP2_CHAIN_ID_REGEX,
|
|
10
|
+
DEFAULT_CHAIN_ID_NUMERIC,
|
|
11
|
+
DEFAULT_CHAIN_ID_CAIP2,
|
|
12
|
+
EVM_CHAIN_IDS,
|
|
13
|
+
SOLANA_CHAIN_IDS,
|
|
14
|
+
BITCOIN_CHAIN_IDS,
|
|
15
|
+
ALL_CHAIN_IDS,
|
|
16
|
+
NAMESPACE_TO_CURVE,
|
|
17
|
+
type ChainNamespace,
|
|
18
|
+
type FriendlyChainName,
|
|
6
19
|
} from './chains'
|
|
7
20
|
|
|
21
|
+
export { DEFAULT_HOSTS } from './config'
|
|
22
|
+
|
|
8
23
|
export { convertLocalToCrypto, convertCryptoToLocal, convert } from './currency'
|
|
9
24
|
|
|
10
25
|
export {
|
|
@@ -13,7 +28,12 @@ export {
|
|
|
13
28
|
type IPortalProvider,
|
|
14
29
|
KeychainAdapter,
|
|
15
30
|
MpcStatuses,
|
|
31
|
+
PasswordStorage,
|
|
32
|
+
PortalRequestMethod,
|
|
33
|
+
type RawSignOptions,
|
|
16
34
|
type RequestArguments,
|
|
35
|
+
type RequestOptions,
|
|
36
|
+
type SendAssetParams,
|
|
17
37
|
Storage,
|
|
18
38
|
} from './definitions'
|
|
19
39
|
|
package/src/version/version.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{ "version": "4.2.
|
|
1
|
+
{ "version": "4.2.13" }
|