pwc-sdk-wallet 0.6.3
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/README.md +2062 -0
- package/dist/Vault.d.ts +493 -0
- package/dist/Vault.js +1090 -0
- package/dist/chain/ChainService.d.ts +84 -0
- package/dist/chain/ChainService.js +136 -0
- package/dist/chain/SolanaChainService.d.ts +94 -0
- package/dist/chain/SolanaChainService.js +167 -0
- package/dist/config/chains.d.ts +233 -0
- package/dist/config/chains.js +285 -0
- package/dist/config/constants.d.ts +102 -0
- package/dist/config/constants.js +109 -0
- package/dist/config/environment.d.ts +46 -0
- package/dist/config/environment.js +114 -0
- package/dist/config/gas.d.ts +107 -0
- package/dist/config/gas.js +123 -0
- package/dist/crypto/EncryptionService.d.ts +74 -0
- package/dist/crypto/EncryptionService.js +178 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.js +96 -0
- package/dist/keyrings/HDKeyring.d.ts +72 -0
- package/dist/keyrings/HDKeyring.js +156 -0
- package/dist/keyrings/SimpleKeyring.d.ts +31 -0
- package/dist/keyrings/SimpleKeyring.js +49 -0
- package/dist/keyrings/SolanaKeyring.d.ts +71 -0
- package/dist/keyrings/SolanaKeyring.js +159 -0
- package/dist/services/BatchProcessor.d.ts +42 -0
- package/dist/services/BatchProcessor.js +188 -0
- package/dist/services/MultiTransferService.d.ts +78 -0
- package/dist/services/MultiTransferService.js +252 -0
- package/dist/services/QRCodeService.d.ts +193 -0
- package/dist/services/QRCodeService.js +299 -0
- package/dist/services/TokenUtils.d.ts +307 -0
- package/dist/services/TokenUtils.js +429 -0
- package/dist/services/nft/MetadataResolver.d.ts +57 -0
- package/dist/services/nft/MetadataResolver.js +162 -0
- package/dist/services/nft/NFTAPIService.d.ts +53 -0
- package/dist/services/nft/NFTAPIService.js +122 -0
- package/dist/services/nft/NFTService.d.ts +241 -0
- package/dist/services/nft/NFTService.js +910 -0
- package/dist/types/multiTransfer.d.ts +68 -0
- package/dist/types/multiTransfer.js +2 -0
- package/dist/types/nft/index.d.ts +68 -0
- package/dist/types/nft/index.js +2 -0
- package/dist/types/nft.d.ts +265 -0
- package/dist/types/nft.js +6 -0
- package/package.json +70 -0
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import { ethers } from 'ethers';
|
|
2
|
+
/**
|
|
3
|
+
* Set global RPC configuration from mobile app (highest priority)
|
|
4
|
+
* @param config - RPC URLs configuration
|
|
5
|
+
*/
|
|
6
|
+
export declare function setGlobalRPCConfig(config: Record<string, string>): void;
|
|
7
|
+
/**
|
|
8
|
+
* Set global explorer configuration from mobile app (highest priority)
|
|
9
|
+
* @param config - Explorer URLs configuration
|
|
10
|
+
*/
|
|
11
|
+
export declare function setGlobalExplorerConfig(config: Record<string, string>): void;
|
|
12
|
+
/**
|
|
13
|
+
* Get global RPC configuration
|
|
14
|
+
* @returns Current global RPC configuration
|
|
15
|
+
*/
|
|
16
|
+
export declare function getGlobalRPCConfig(): Record<string, string>;
|
|
17
|
+
/**
|
|
18
|
+
* Get global explorer configuration
|
|
19
|
+
* @returns Current global explorer configuration
|
|
20
|
+
*/
|
|
21
|
+
export declare function getGlobalExplorerConfig(): Record<string, string>;
|
|
22
|
+
/**
|
|
23
|
+
* Clear global configurations
|
|
24
|
+
*/
|
|
25
|
+
export declare function clearGlobalConfigs(): void;
|
|
26
|
+
/**
|
|
27
|
+
* Interface representing chain configuration
|
|
28
|
+
*/
|
|
29
|
+
export interface ChainConfig {
|
|
30
|
+
name: string;
|
|
31
|
+
rpcUrl: string;
|
|
32
|
+
explorerUrl: string;
|
|
33
|
+
nativeCurrency: {
|
|
34
|
+
name: string;
|
|
35
|
+
symbol: string;
|
|
36
|
+
decimals: number;
|
|
37
|
+
};
|
|
38
|
+
type: 'evm' | 'solana';
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Configuration object containing all supported blockchain networks.
|
|
42
|
+
* Each chain has its RPC URL, explorer URL, native currency details, and type.
|
|
43
|
+
* RPC URLs can be customized via environment variables.
|
|
44
|
+
*/
|
|
45
|
+
export declare const SUPPORTED_CHAINS: {
|
|
46
|
+
readonly '1': {
|
|
47
|
+
readonly name: "Ethereum";
|
|
48
|
+
readonly rpcUrl: string;
|
|
49
|
+
readonly explorerUrl: string;
|
|
50
|
+
readonly nativeCurrency: {
|
|
51
|
+
readonly name: "Ether";
|
|
52
|
+
readonly symbol: "ETH";
|
|
53
|
+
readonly decimals: 18;
|
|
54
|
+
};
|
|
55
|
+
readonly type: "evm";
|
|
56
|
+
};
|
|
57
|
+
readonly '56': {
|
|
58
|
+
readonly name: "BNB Smart Chain";
|
|
59
|
+
readonly rpcUrl: string;
|
|
60
|
+
readonly explorerUrl: string;
|
|
61
|
+
readonly nativeCurrency: {
|
|
62
|
+
readonly name: "BNB";
|
|
63
|
+
readonly symbol: "BNB";
|
|
64
|
+
readonly decimals: 18;
|
|
65
|
+
};
|
|
66
|
+
readonly type: "evm";
|
|
67
|
+
};
|
|
68
|
+
readonly '137': {
|
|
69
|
+
readonly name: "Polygon";
|
|
70
|
+
readonly rpcUrl: string;
|
|
71
|
+
readonly explorerUrl: string;
|
|
72
|
+
readonly nativeCurrency: {
|
|
73
|
+
readonly name: "MATIC";
|
|
74
|
+
readonly symbol: "MATIC";
|
|
75
|
+
readonly decimals: 18;
|
|
76
|
+
};
|
|
77
|
+
readonly type: "evm";
|
|
78
|
+
};
|
|
79
|
+
readonly '42161': {
|
|
80
|
+
readonly name: "Arbitrum One";
|
|
81
|
+
readonly rpcUrl: string;
|
|
82
|
+
readonly explorerUrl: string;
|
|
83
|
+
readonly nativeCurrency: {
|
|
84
|
+
readonly name: "Ether";
|
|
85
|
+
readonly symbol: "ETH";
|
|
86
|
+
readonly decimals: 18;
|
|
87
|
+
};
|
|
88
|
+
readonly type: "evm";
|
|
89
|
+
};
|
|
90
|
+
readonly '10': {
|
|
91
|
+
readonly name: "OP Mainnet";
|
|
92
|
+
readonly rpcUrl: string;
|
|
93
|
+
readonly explorerUrl: string;
|
|
94
|
+
readonly nativeCurrency: {
|
|
95
|
+
readonly name: "Ether";
|
|
96
|
+
readonly symbol: "ETH";
|
|
97
|
+
readonly decimals: 18;
|
|
98
|
+
};
|
|
99
|
+
readonly type: "evm";
|
|
100
|
+
};
|
|
101
|
+
readonly '8453': {
|
|
102
|
+
readonly name: "Base";
|
|
103
|
+
readonly rpcUrl: string;
|
|
104
|
+
readonly explorerUrl: string;
|
|
105
|
+
readonly nativeCurrency: {
|
|
106
|
+
readonly name: "Ether";
|
|
107
|
+
readonly symbol: "ETH";
|
|
108
|
+
readonly decimals: 18;
|
|
109
|
+
};
|
|
110
|
+
readonly type: "evm";
|
|
111
|
+
};
|
|
112
|
+
readonly solana: {
|
|
113
|
+
readonly name: "Solana";
|
|
114
|
+
readonly rpcUrl: string;
|
|
115
|
+
readonly explorerUrl: string;
|
|
116
|
+
readonly nativeCurrency: {
|
|
117
|
+
readonly name: "SOL";
|
|
118
|
+
readonly symbol: "SOL";
|
|
119
|
+
readonly decimals: 9;
|
|
120
|
+
};
|
|
121
|
+
readonly type: "solana";
|
|
122
|
+
};
|
|
123
|
+
readonly 'solana-devnet': {
|
|
124
|
+
readonly name: "Solana Devnet";
|
|
125
|
+
readonly rpcUrl: string;
|
|
126
|
+
readonly explorerUrl: string;
|
|
127
|
+
readonly nativeCurrency: {
|
|
128
|
+
readonly name: "SOL";
|
|
129
|
+
readonly symbol: "SOL";
|
|
130
|
+
readonly decimals: 9;
|
|
131
|
+
};
|
|
132
|
+
readonly type: "solana";
|
|
133
|
+
};
|
|
134
|
+
readonly '97': {
|
|
135
|
+
readonly name: "BNB Smart Chain Testnet";
|
|
136
|
+
readonly rpcUrl: string;
|
|
137
|
+
readonly explorerUrl: string;
|
|
138
|
+
readonly nativeCurrency: {
|
|
139
|
+
readonly name: "BNB";
|
|
140
|
+
readonly symbol: "tBNB";
|
|
141
|
+
readonly decimals: 18;
|
|
142
|
+
};
|
|
143
|
+
readonly type: "evm";
|
|
144
|
+
};
|
|
145
|
+
};
|
|
146
|
+
/**
|
|
147
|
+
* Type representing the supported chain IDs.
|
|
148
|
+
* Can be either EVM chain IDs (as strings) or Solana network identifiers.
|
|
149
|
+
*/
|
|
150
|
+
export type ChainId = keyof typeof SUPPORTED_CHAINS;
|
|
151
|
+
/**
|
|
152
|
+
* Type representing the blockchain type.
|
|
153
|
+
* 'evm' for Ethereum-compatible chains, 'solana' for Solana blockchain.
|
|
154
|
+
*/
|
|
155
|
+
export type ChainType = 'evm' | 'solana';
|
|
156
|
+
/**
|
|
157
|
+
* Creates and returns an ethers.js provider for the specified EVM chain.
|
|
158
|
+
* @param chainId - The chain ID to create a provider for (must be an EVM chain)
|
|
159
|
+
* @returns An ethers.js JsonRpcProvider instance for the specified chain
|
|
160
|
+
* @throws Error if the chain is not supported or is not an EVM chain
|
|
161
|
+
*/
|
|
162
|
+
export declare const getProvider: (chainId: ChainId) => ethers.JsonRpcProvider;
|
|
163
|
+
/**
|
|
164
|
+
* BIP-44 derivation paths for different blockchain types.
|
|
165
|
+
* Used for deterministic wallet generation from mnemonics.
|
|
166
|
+
*/
|
|
167
|
+
export declare const DERIVATION_PATHS: {
|
|
168
|
+
/** Standard EVM derivation path following BIP-44 */
|
|
169
|
+
readonly EVM: "m/44'/60'/0'/0/0";
|
|
170
|
+
/** Solana derivation path following BIP-44 with hardened derivation */
|
|
171
|
+
readonly SOLANA: "m/44'/501'/0'/0'";
|
|
172
|
+
};
|
|
173
|
+
/**
|
|
174
|
+
* Register a custom chain (new chain not in built-in list)
|
|
175
|
+
* @param chainId - Custom chain ID (e.g., 'custom-1', 'my-chain')
|
|
176
|
+
* @param config - Complete chain configuration
|
|
177
|
+
*/
|
|
178
|
+
export declare function registerCustomChain(chainId: string, config: ChainConfig): void;
|
|
179
|
+
/**
|
|
180
|
+
* Override a built-in chain configuration
|
|
181
|
+
* @param chainId - Built-in chain ID to override
|
|
182
|
+
* @param override - Partial configuration to override (only specify fields to change)
|
|
183
|
+
* @throws Error if chainId is not a built-in chain
|
|
184
|
+
*/
|
|
185
|
+
export declare function overrideChain(chainId: string, override: Partial<ChainConfig>): void;
|
|
186
|
+
/**
|
|
187
|
+
* Override multiple built-in chains at once
|
|
188
|
+
* @param overrides - Object containing multiple chain overrides
|
|
189
|
+
*/
|
|
190
|
+
export declare function overrideChains(overrides: Record<string, Partial<ChainConfig>>): void;
|
|
191
|
+
/**
|
|
192
|
+
* Get chain configuration with priority: Custom > Override > Built-in
|
|
193
|
+
* @param chainId - Chain ID to get configuration for
|
|
194
|
+
* @returns Chain configuration
|
|
195
|
+
* @throws Error if chain is not found
|
|
196
|
+
*/
|
|
197
|
+
export declare function getChainConfig(chainId: string): ChainConfig;
|
|
198
|
+
/**
|
|
199
|
+
* Setup chain configurations with overrides and custom chains
|
|
200
|
+
* @param options - Configuration options
|
|
201
|
+
*/
|
|
202
|
+
export declare function setupChainConfigs(options: {
|
|
203
|
+
overrides?: Record<string, Partial<ChainConfig>>;
|
|
204
|
+
customChains?: Record<string, ChainConfig>;
|
|
205
|
+
}): void;
|
|
206
|
+
/**
|
|
207
|
+
* Get all available chains (built-in + custom)
|
|
208
|
+
* @returns Object containing all chain configurations
|
|
209
|
+
*/
|
|
210
|
+
export declare function getAllAvailableChains(): Record<string, ChainConfig>;
|
|
211
|
+
/**
|
|
212
|
+
* Clear all custom chains
|
|
213
|
+
*/
|
|
214
|
+
export declare function clearCustomChains(): void;
|
|
215
|
+
/**
|
|
216
|
+
* Clear all chain overrides
|
|
217
|
+
*/
|
|
218
|
+
export declare function clearOverrides(): void;
|
|
219
|
+
/**
|
|
220
|
+
* Clear override for a specific chain
|
|
221
|
+
* @param chainId - Chain ID to clear override for
|
|
222
|
+
*/
|
|
223
|
+
export declare function clearOverride(chainId: string): void;
|
|
224
|
+
/**
|
|
225
|
+
* Get all custom chains
|
|
226
|
+
* @returns Object containing custom chain configurations
|
|
227
|
+
*/
|
|
228
|
+
export declare function getCustomChains(): Record<string, ChainConfig>;
|
|
229
|
+
/**
|
|
230
|
+
* Get all chain overrides
|
|
231
|
+
* @returns Object containing chain override configurations
|
|
232
|
+
*/
|
|
233
|
+
export declare function getOverrides(): Record<string, Partial<ChainConfig>>;
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DERIVATION_PATHS = exports.getProvider = exports.SUPPORTED_CHAINS = void 0;
|
|
4
|
+
exports.setGlobalRPCConfig = setGlobalRPCConfig;
|
|
5
|
+
exports.setGlobalExplorerConfig = setGlobalExplorerConfig;
|
|
6
|
+
exports.getGlobalRPCConfig = getGlobalRPCConfig;
|
|
7
|
+
exports.getGlobalExplorerConfig = getGlobalExplorerConfig;
|
|
8
|
+
exports.clearGlobalConfigs = clearGlobalConfigs;
|
|
9
|
+
exports.registerCustomChain = registerCustomChain;
|
|
10
|
+
exports.overrideChain = overrideChain;
|
|
11
|
+
exports.overrideChains = overrideChains;
|
|
12
|
+
exports.getChainConfig = getChainConfig;
|
|
13
|
+
exports.setupChainConfigs = setupChainConfigs;
|
|
14
|
+
exports.getAllAvailableChains = getAllAvailableChains;
|
|
15
|
+
exports.clearCustomChains = clearCustomChains;
|
|
16
|
+
exports.clearOverrides = clearOverrides;
|
|
17
|
+
exports.clearOverride = clearOverride;
|
|
18
|
+
exports.getCustomChains = getCustomChains;
|
|
19
|
+
exports.getOverrides = getOverrides;
|
|
20
|
+
const ethers_1 = require("ethers");
|
|
21
|
+
// Global config registry for mobile app overrides
|
|
22
|
+
let GLOBAL_RPC_CONFIG = {};
|
|
23
|
+
let GLOBAL_EXPLORER_CONFIG = {};
|
|
24
|
+
/**
|
|
25
|
+
* Set global RPC configuration from mobile app (highest priority)
|
|
26
|
+
* @param config - RPC URLs configuration
|
|
27
|
+
*/
|
|
28
|
+
function setGlobalRPCConfig(config) {
|
|
29
|
+
GLOBAL_RPC_CONFIG = { ...GLOBAL_RPC_CONFIG, ...config };
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Set global explorer configuration from mobile app (highest priority)
|
|
33
|
+
* @param config - Explorer URLs configuration
|
|
34
|
+
*/
|
|
35
|
+
function setGlobalExplorerConfig(config) {
|
|
36
|
+
GLOBAL_EXPLORER_CONFIG = { ...GLOBAL_EXPLORER_CONFIG, ...config };
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Get global RPC configuration
|
|
40
|
+
* @returns Current global RPC configuration
|
|
41
|
+
*/
|
|
42
|
+
function getGlobalRPCConfig() {
|
|
43
|
+
return { ...GLOBAL_RPC_CONFIG };
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Get global explorer configuration
|
|
47
|
+
* @returns Current global explorer configuration
|
|
48
|
+
*/
|
|
49
|
+
function getGlobalExplorerConfig() {
|
|
50
|
+
return { ...GLOBAL_EXPLORER_CONFIG };
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Clear global configurations
|
|
54
|
+
*/
|
|
55
|
+
function clearGlobalConfigs() {
|
|
56
|
+
GLOBAL_RPC_CONFIG = {};
|
|
57
|
+
GLOBAL_EXPLORER_CONFIG = {};
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Environment-based configuration for RPC URLs
|
|
61
|
+
* Allows customization via environment variables with fallbacks to public RPCs
|
|
62
|
+
* Priority: Mobile App Config > Environment Variables > SDK Defaults
|
|
63
|
+
*/
|
|
64
|
+
const getRpcUrl = (chainId, defaultUrl) => {
|
|
65
|
+
// Priority: Mobile App Config > Environment Variables > SDK Defaults
|
|
66
|
+
return GLOBAL_RPC_CONFIG[chainId] ||
|
|
67
|
+
process.env[`RPC_URL_${chainId}`] ||
|
|
68
|
+
defaultUrl;
|
|
69
|
+
};
|
|
70
|
+
const getExplorerUrl = (chainId, defaultUrl) => {
|
|
71
|
+
// Priority: Mobile App Config > Environment Variables > SDK Defaults
|
|
72
|
+
return GLOBAL_EXPLORER_CONFIG[chainId] ||
|
|
73
|
+
process.env[`EXPLORER_URL_${chainId}`] ||
|
|
74
|
+
defaultUrl;
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* Configuration object containing all supported blockchain networks.
|
|
78
|
+
* Each chain has its RPC URL, explorer URL, native currency details, and type.
|
|
79
|
+
* RPC URLs can be customized via environment variables.
|
|
80
|
+
*/
|
|
81
|
+
exports.SUPPORTED_CHAINS = {
|
|
82
|
+
'1': {
|
|
83
|
+
name: 'Ethereum',
|
|
84
|
+
rpcUrl: getRpcUrl('1', 'https://eth.llamarpc.com'),
|
|
85
|
+
explorerUrl: getExplorerUrl('1', 'https://etherscan.io'),
|
|
86
|
+
nativeCurrency: { name: 'Ether', symbol: 'ETH', decimals: 18 },
|
|
87
|
+
type: 'evm'
|
|
88
|
+
},
|
|
89
|
+
'56': {
|
|
90
|
+
name: 'BNB Smart Chain',
|
|
91
|
+
rpcUrl: getRpcUrl('56', 'https://bsc-dataseed.binance.org/'),
|
|
92
|
+
explorerUrl: getExplorerUrl('56', 'https://bscscan.com'),
|
|
93
|
+
nativeCurrency: { name: 'BNB', symbol: 'BNB', decimals: 18 },
|
|
94
|
+
type: 'evm'
|
|
95
|
+
},
|
|
96
|
+
'137': {
|
|
97
|
+
name: 'Polygon',
|
|
98
|
+
rpcUrl: getRpcUrl('137', 'https://polygon-rpc.com/'),
|
|
99
|
+
explorerUrl: getExplorerUrl('137', 'https://polygonscan.com'),
|
|
100
|
+
nativeCurrency: { name: 'MATIC', symbol: 'MATIC', decimals: 18 },
|
|
101
|
+
type: 'evm'
|
|
102
|
+
},
|
|
103
|
+
'42161': {
|
|
104
|
+
name: 'Arbitrum One',
|
|
105
|
+
rpcUrl: getRpcUrl('42161', 'https://arb1.arbitrum.io/rpc'),
|
|
106
|
+
explorerUrl: getExplorerUrl('42161', 'https://arbiscan.io'),
|
|
107
|
+
nativeCurrency: { name: 'Ether', symbol: 'ETH', decimals: 18 },
|
|
108
|
+
type: 'evm'
|
|
109
|
+
},
|
|
110
|
+
'10': {
|
|
111
|
+
name: 'OP Mainnet',
|
|
112
|
+
rpcUrl: getRpcUrl('10', 'https://mainnet.optimism.io'),
|
|
113
|
+
explorerUrl: getExplorerUrl('10', 'https://optimistic.etherscan.io'),
|
|
114
|
+
nativeCurrency: { name: 'Ether', symbol: 'ETH', decimals: 18 },
|
|
115
|
+
type: 'evm'
|
|
116
|
+
},
|
|
117
|
+
'8453': {
|
|
118
|
+
name: 'Base',
|
|
119
|
+
rpcUrl: getRpcUrl('8453', 'https://mainnet.base.org'),
|
|
120
|
+
explorerUrl: getExplorerUrl('8453', 'https://basescan.org'),
|
|
121
|
+
nativeCurrency: { name: 'Ether', symbol: 'ETH', decimals: 18 },
|
|
122
|
+
type: 'evm'
|
|
123
|
+
},
|
|
124
|
+
'solana': {
|
|
125
|
+
name: 'Solana',
|
|
126
|
+
rpcUrl: getRpcUrl('solana', 'https://api.mainnet-beta.solana.com'),
|
|
127
|
+
explorerUrl: getExplorerUrl('solana', 'https://solscan.io'),
|
|
128
|
+
nativeCurrency: { name: 'SOL', symbol: 'SOL', decimals: 9 },
|
|
129
|
+
type: 'solana'
|
|
130
|
+
},
|
|
131
|
+
'solana-devnet': {
|
|
132
|
+
name: 'Solana Devnet',
|
|
133
|
+
rpcUrl: getRpcUrl('solana-devnet', 'https://api.devnet.solana.com'),
|
|
134
|
+
explorerUrl: getExplorerUrl('solana-devnet', 'https://solscan.io?cluster=devnet'),
|
|
135
|
+
nativeCurrency: { name: 'SOL', symbol: 'SOL', decimals: 9 },
|
|
136
|
+
type: 'solana'
|
|
137
|
+
},
|
|
138
|
+
'97': {
|
|
139
|
+
name: 'BNB Smart Chain Testnet',
|
|
140
|
+
rpcUrl: getRpcUrl('97', 'https://bsc-testnet-dataseed.bnbchain.org'),
|
|
141
|
+
explorerUrl: getExplorerUrl('97', 'https://testnet.bscscan.com'),
|
|
142
|
+
nativeCurrency: { name: 'BNB', symbol: 'tBNB', decimals: 18 },
|
|
143
|
+
type: 'evm'
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
/**
|
|
147
|
+
* Creates and returns an ethers.js provider for the specified EVM chain.
|
|
148
|
+
* @param chainId - The chain ID to create a provider for (must be an EVM chain)
|
|
149
|
+
* @returns An ethers.js JsonRpcProvider instance for the specified chain
|
|
150
|
+
* @throws Error if the chain is not supported or is not an EVM chain
|
|
151
|
+
*/
|
|
152
|
+
const getProvider = (chainId) => {
|
|
153
|
+
const chainInfo = exports.SUPPORTED_CHAINS[chainId];
|
|
154
|
+
if (!chainInfo) {
|
|
155
|
+
throw new Error(`Unsupported chain: ${chainId}`);
|
|
156
|
+
}
|
|
157
|
+
if (chainInfo.type !== 'evm') {
|
|
158
|
+
throw new Error(`Chain ${chainId} is not an EVM chain`);
|
|
159
|
+
}
|
|
160
|
+
return new ethers_1.ethers.JsonRpcProvider(chainInfo.rpcUrl);
|
|
161
|
+
};
|
|
162
|
+
exports.getProvider = getProvider;
|
|
163
|
+
/**
|
|
164
|
+
* BIP-44 derivation paths for different blockchain types.
|
|
165
|
+
* Used for deterministic wallet generation from mnemonics.
|
|
166
|
+
*/
|
|
167
|
+
exports.DERIVATION_PATHS = {
|
|
168
|
+
/** Standard EVM derivation path following BIP-44 */
|
|
169
|
+
EVM: "m/44'/60'/0'/0/0",
|
|
170
|
+
/** Solana derivation path following BIP-44 with hardened derivation */
|
|
171
|
+
SOLANA: "m/44'/501'/0'/0'", // Solana BIP-44 path
|
|
172
|
+
};
|
|
173
|
+
// Global registry for custom chains and overrides
|
|
174
|
+
let CUSTOM_CHAINS = {};
|
|
175
|
+
let CHAIN_OVERRIDES = {};
|
|
176
|
+
/**
|
|
177
|
+
* Register a custom chain (new chain not in built-in list)
|
|
178
|
+
* @param chainId - Custom chain ID (e.g., 'custom-1', 'my-chain')
|
|
179
|
+
* @param config - Complete chain configuration
|
|
180
|
+
*/
|
|
181
|
+
function registerCustomChain(chainId, config) {
|
|
182
|
+
CUSTOM_CHAINS[chainId] = config;
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Override a built-in chain configuration
|
|
186
|
+
* @param chainId - Built-in chain ID to override
|
|
187
|
+
* @param override - Partial configuration to override (only specify fields to change)
|
|
188
|
+
* @throws Error if chainId is not a built-in chain
|
|
189
|
+
*/
|
|
190
|
+
function overrideChain(chainId, override) {
|
|
191
|
+
const supportedChains = exports.SUPPORTED_CHAINS;
|
|
192
|
+
if (!supportedChains[chainId]) {
|
|
193
|
+
throw new Error(`Cannot override chain ${chainId} - not a built-in chain`);
|
|
194
|
+
}
|
|
195
|
+
CHAIN_OVERRIDES[chainId] = override;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Override multiple built-in chains at once
|
|
199
|
+
* @param overrides - Object containing multiple chain overrides
|
|
200
|
+
*/
|
|
201
|
+
function overrideChains(overrides) {
|
|
202
|
+
Object.entries(overrides).forEach(([chainId, override]) => {
|
|
203
|
+
overrideChain(chainId, override);
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Get chain configuration with priority: Custom > Override > Built-in
|
|
208
|
+
* @param chainId - Chain ID to get configuration for
|
|
209
|
+
* @returns Chain configuration
|
|
210
|
+
* @throws Error if chain is not found
|
|
211
|
+
*/
|
|
212
|
+
function getChainConfig(chainId) {
|
|
213
|
+
// 1. Check custom chains first (highest priority)
|
|
214
|
+
if (CUSTOM_CHAINS[chainId]) {
|
|
215
|
+
return CUSTOM_CHAINS[chainId];
|
|
216
|
+
}
|
|
217
|
+
// 2. Check overrides
|
|
218
|
+
if (CHAIN_OVERRIDES[chainId]) {
|
|
219
|
+
const baseConfig = exports.SUPPORTED_CHAINS[chainId];
|
|
220
|
+
if (!baseConfig) {
|
|
221
|
+
throw new Error(`Chain ${chainId} not found`);
|
|
222
|
+
}
|
|
223
|
+
return { ...baseConfig, ...CHAIN_OVERRIDES[chainId] };
|
|
224
|
+
}
|
|
225
|
+
// 3. Check built-in chains
|
|
226
|
+
const builtInConfig = exports.SUPPORTED_CHAINS[chainId];
|
|
227
|
+
if (!builtInConfig) {
|
|
228
|
+
throw new Error(`Chain ${chainId} not found`);
|
|
229
|
+
}
|
|
230
|
+
return builtInConfig;
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Setup chain configurations with overrides and custom chains
|
|
234
|
+
* @param options - Configuration options
|
|
235
|
+
*/
|
|
236
|
+
function setupChainConfigs(options) {
|
|
237
|
+
if (options.overrides) {
|
|
238
|
+
overrideChains(options.overrides);
|
|
239
|
+
}
|
|
240
|
+
if (options.customChains) {
|
|
241
|
+
Object.entries(options.customChains).forEach(([chainId, config]) => {
|
|
242
|
+
registerCustomChain(chainId, config);
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Get all available chains (built-in + custom)
|
|
248
|
+
* @returns Object containing all chain configurations
|
|
249
|
+
*/
|
|
250
|
+
function getAllAvailableChains() {
|
|
251
|
+
return { ...exports.SUPPORTED_CHAINS, ...CUSTOM_CHAINS };
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Clear all custom chains
|
|
255
|
+
*/
|
|
256
|
+
function clearCustomChains() {
|
|
257
|
+
CUSTOM_CHAINS = {};
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Clear all chain overrides
|
|
261
|
+
*/
|
|
262
|
+
function clearOverrides() {
|
|
263
|
+
CHAIN_OVERRIDES = {};
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Clear override for a specific chain
|
|
267
|
+
* @param chainId - Chain ID to clear override for
|
|
268
|
+
*/
|
|
269
|
+
function clearOverride(chainId) {
|
|
270
|
+
delete CHAIN_OVERRIDES[chainId];
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Get all custom chains
|
|
274
|
+
* @returns Object containing custom chain configurations
|
|
275
|
+
*/
|
|
276
|
+
function getCustomChains() {
|
|
277
|
+
return { ...CUSTOM_CHAINS };
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Get all chain overrides
|
|
281
|
+
* @returns Object containing chain override configurations
|
|
282
|
+
*/
|
|
283
|
+
function getOverrides() {
|
|
284
|
+
return { ...CHAIN_OVERRIDES };
|
|
285
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration constants for PWC Wallet SDK
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Configuration object for vanity wallet generation.
|
|
6
|
+
* Contains default settings and limits for generating wallets with specific address prefixes.
|
|
7
|
+
*/
|
|
8
|
+
export declare const VANITY_WALLET_CONFIG: {
|
|
9
|
+
/** Default prefix for vanity addresses (without '0x' for EVM chains) */
|
|
10
|
+
readonly DEFAULT_PREFIX: "aaa";
|
|
11
|
+
/** Maximum attempts for generating vanity wallet before giving up */
|
|
12
|
+
readonly DEFAULT_MAX_ATTEMPTS: 1000000;
|
|
13
|
+
/** Whether prefix matching should be case sensitive (false = ignore case) */
|
|
14
|
+
readonly DEFAULT_CASE_SENSITIVE: false;
|
|
15
|
+
/** Progress update interval in number of attempts (for progress callbacks) */
|
|
16
|
+
readonly PROGRESS_UPDATE_INTERVAL: 1000;
|
|
17
|
+
/** Non-blocking interval to allow event loop to breathe (prevents UI freezing) */
|
|
18
|
+
readonly NON_BLOCKING_INTERVAL: 10000;
|
|
19
|
+
/** Maximum prefix length allowed (for performance and security reasons) */
|
|
20
|
+
readonly MAX_PREFIX_LENGTH: 10;
|
|
21
|
+
/** Maximum attempts limit as a safety cap to prevent infinite loops */
|
|
22
|
+
readonly MAX_ATTEMPTS_LIMIT: 10000000;
|
|
23
|
+
/** Mobile-optimized prefix (much easier to find) */
|
|
24
|
+
readonly MOBILE_DEFAULT_PREFIX: "a";
|
|
25
|
+
/** Mobile-optimized max attempts (faster completion) */
|
|
26
|
+
readonly MOBILE_DEFAULT_MAX_ATTEMPTS: 50000;
|
|
27
|
+
/** Mobile-optimized progress update interval (more frequent updates) */
|
|
28
|
+
readonly MOBILE_PROGRESS_UPDATE_INTERVAL: 500;
|
|
29
|
+
/** Mobile-optimized non-blocking interval (more frequent yields) */
|
|
30
|
+
readonly MOBILE_NON_BLOCKING_INTERVAL: 1000;
|
|
31
|
+
/** Batch size for mobile processing (process multiple attempts in batches) */
|
|
32
|
+
readonly MOBILE_BATCH_SIZE: 100;
|
|
33
|
+
/** Mobile timeout in milliseconds (prevent infinite running) */
|
|
34
|
+
readonly MOBILE_TIMEOUT_MS: 30000;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Security configuration constants
|
|
38
|
+
*/
|
|
39
|
+
export declare const SECURITY_CONFIG: {
|
|
40
|
+
/** AES key size in bits */
|
|
41
|
+
readonly AES_KEY_SIZE: 256;
|
|
42
|
+
/** Salt length in bytes */
|
|
43
|
+
readonly SALT_LENGTH: 16;
|
|
44
|
+
/** IV length in bytes */
|
|
45
|
+
readonly IV_LENGTH: 12;
|
|
46
|
+
/** Minimum password length */
|
|
47
|
+
readonly MIN_PASSWORD_LENGTH: 8;
|
|
48
|
+
/** Maximum vault unlock attempts before lockout */
|
|
49
|
+
readonly MAX_UNLOCK_ATTEMPTS: 5;
|
|
50
|
+
/** Lockout duration in milliseconds */
|
|
51
|
+
readonly LOCKOUT_DURATION: 300000;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Get PBKDF2 iterations based on environment
|
|
55
|
+
* @returns Number of iterations (5000 for development, 10000 for production)
|
|
56
|
+
*/
|
|
57
|
+
export declare function getPBKDF2Iterations(): number;
|
|
58
|
+
/**
|
|
59
|
+
* Network configuration constants
|
|
60
|
+
*/
|
|
61
|
+
export declare const NETWORK_CONFIG: {
|
|
62
|
+
/** Default timeout for RPC calls in milliseconds */
|
|
63
|
+
readonly RPC_TIMEOUT: 30000;
|
|
64
|
+
/** Retry attempts for failed RPC calls */
|
|
65
|
+
readonly RPC_RETRY_ATTEMPTS: 3;
|
|
66
|
+
/** Delay between retry attempts in milliseconds */
|
|
67
|
+
readonly RPC_RETRY_DELAY: 1000;
|
|
68
|
+
/** Maximum batch size for multi-transfer operations */
|
|
69
|
+
readonly MAX_BATCH_SIZE: 50;
|
|
70
|
+
/** Delay between batches in milliseconds */
|
|
71
|
+
readonly BATCH_DELAY: 500;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Cache configuration constants
|
|
75
|
+
*/
|
|
76
|
+
export declare const CACHE_CONFIG: {
|
|
77
|
+
/** Default cache TTL in milliseconds */
|
|
78
|
+
readonly DEFAULT_TTL: 30000;
|
|
79
|
+
/** Balance cache TTL in milliseconds */
|
|
80
|
+
readonly BALANCE_TTL: 60000;
|
|
81
|
+
/** Token info cache TTL in milliseconds */
|
|
82
|
+
readonly TOKEN_INFO_TTL: 300000;
|
|
83
|
+
/** Transaction cache TTL in milliseconds */
|
|
84
|
+
readonly TRANSACTION_TTL: 600000;
|
|
85
|
+
/** Maximum cache size in number of entries */
|
|
86
|
+
readonly MAX_CACHE_SIZE: 1000;
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* Validation configuration constants
|
|
90
|
+
*/
|
|
91
|
+
export declare const VALIDATION_CONFIG: {
|
|
92
|
+
/** Minimum address length */
|
|
93
|
+
readonly MIN_ADDRESS_LENGTH: 26;
|
|
94
|
+
/** Maximum address length */
|
|
95
|
+
readonly MAX_ADDRESS_LENGTH: 44;
|
|
96
|
+
/** Minimum amount for transfers */
|
|
97
|
+
readonly MIN_TRANSFER_AMOUNT: "0.000001";
|
|
98
|
+
/** Maximum amount for transfers (safety limit) */
|
|
99
|
+
readonly MAX_TRANSFER_AMOUNT: "1000000";
|
|
100
|
+
/** Maximum decimal places for amounts */
|
|
101
|
+
readonly MAX_DECIMAL_PLACES: 18;
|
|
102
|
+
};
|