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
package/dist/Vault.d.ts
ADDED
|
@@ -0,0 +1,493 @@
|
|
|
1
|
+
import { type EncryptedData } from './crypto/EncryptionService';
|
|
2
|
+
import { type ChainId } from './config/chains';
|
|
3
|
+
import { Recipient, MultiTransferResult } from './types/multiTransfer';
|
|
4
|
+
import { NFTDetailExtended, NFTOptions } from './types/nft';
|
|
5
|
+
export interface Account {
|
|
6
|
+
address: string;
|
|
7
|
+
type: 'HD' | 'Simple' | 'Solana';
|
|
8
|
+
name: string;
|
|
9
|
+
}
|
|
10
|
+
export interface TransactionResponse {
|
|
11
|
+
hash: string;
|
|
12
|
+
from: string;
|
|
13
|
+
to: string;
|
|
14
|
+
blockNumber?: number;
|
|
15
|
+
}
|
|
16
|
+
export interface Token {
|
|
17
|
+
address: string;
|
|
18
|
+
name: string;
|
|
19
|
+
symbol: string;
|
|
20
|
+
decimals: number;
|
|
21
|
+
totalSupply?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface VaultConfig {
|
|
24
|
+
rpcUrls?: Record<string, string>;
|
|
25
|
+
explorerUrls?: Record<string, string>;
|
|
26
|
+
gasConfig?: Partial<typeof import('./config/gas').GAS_CONFIG>;
|
|
27
|
+
networkGasConfig?: Record<string, Partial<{
|
|
28
|
+
maxFeePerGas: bigint;
|
|
29
|
+
maxPriorityFeePerGas: bigint;
|
|
30
|
+
}>>;
|
|
31
|
+
defaultChainId?: ChainId;
|
|
32
|
+
supportedChains?: ChainId[];
|
|
33
|
+
features?: {
|
|
34
|
+
enableEIP1559?: boolean;
|
|
35
|
+
enableBatchProcessing?: boolean;
|
|
36
|
+
enableGasEstimation?: boolean;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
export declare class Vault {
|
|
40
|
+
private keyrings;
|
|
41
|
+
private chainId;
|
|
42
|
+
private config?;
|
|
43
|
+
private static exportAttempts;
|
|
44
|
+
private static readonly MAX_EXPORT_ATTEMPTS;
|
|
45
|
+
private static readonly EXPORT_COOLDOWN_MS;
|
|
46
|
+
/**
|
|
47
|
+
* Creates a new Vault instance with the specified keyrings.
|
|
48
|
+
* @param keyrings - Array of keyrings to initialize the vault with. Defaults to empty array.
|
|
49
|
+
*/
|
|
50
|
+
private constructor();
|
|
51
|
+
/**
|
|
52
|
+
* Creates a new Vault with a fresh mnemonic.
|
|
53
|
+
* @param password - The password used to encrypt the vault data
|
|
54
|
+
* @param chainType - The type of blockchain to support ('evm' for Ethereum-compatible chains or 'solana' for Solana). Defaults to 'evm'
|
|
55
|
+
* @returns Promise resolving to an object containing the created vault instance and its encrypted data
|
|
56
|
+
* @throws Error if mnemonic generation or keyring initialization fails
|
|
57
|
+
*/
|
|
58
|
+
static createNew(password: string, chainType?: 'evm' | 'solana', config?: VaultConfig): Promise<{
|
|
59
|
+
vault: Vault;
|
|
60
|
+
encryptedVault: EncryptedData;
|
|
61
|
+
}>;
|
|
62
|
+
/**
|
|
63
|
+
* Creates a new Vault from an existing mnemonic phrase.
|
|
64
|
+
* @param mnemonic - The existing mnemonic phrase (12, 15, 18, 21, or 24 words)
|
|
65
|
+
* @param password - The password used to encrypt the vault data
|
|
66
|
+
* @param chainType - The type of blockchain to support ('evm' for Ethereum-compatible chains or 'solana' for Solana). Defaults to 'evm'
|
|
67
|
+
* @returns Promise resolving to an object containing the created vault instance and its encrypted data
|
|
68
|
+
* @throws Error if mnemonic is invalid or keyring initialization fails
|
|
69
|
+
*/
|
|
70
|
+
static createFromMnemonic(mnemonic: string, password: string, chainType?: 'evm' | 'solana', config?: VaultConfig): Promise<{
|
|
71
|
+
vault: Vault;
|
|
72
|
+
encryptedVault: EncryptedData;
|
|
73
|
+
}>;
|
|
74
|
+
/**
|
|
75
|
+
* Loads a Vault from its encrypted state using the provided password.
|
|
76
|
+
* @param password - The password used to decrypt the vault data
|
|
77
|
+
* @param encryptedVault - The encrypted vault data to decrypt and load
|
|
78
|
+
* @returns Promise resolving to the loaded Vault instance
|
|
79
|
+
* @throws Error if password is incorrect or decryption fails
|
|
80
|
+
*/
|
|
81
|
+
static load(password: string, encryptedVault: EncryptedData, config?: VaultConfig): Promise<Vault>;
|
|
82
|
+
/**
|
|
83
|
+
* Adds a new account derived from the HD keyring using BIP-44 derivation.
|
|
84
|
+
* @returns Promise resolving to the newly created account information
|
|
85
|
+
* @throws Error if no HD keyring is available in the vault
|
|
86
|
+
*/
|
|
87
|
+
addNewHDAccount(): Promise<Account>;
|
|
88
|
+
/**
|
|
89
|
+
* Adds a new Solana account derived from the Solana keyring.
|
|
90
|
+
* @returns Promise resolving to the newly created Solana account information
|
|
91
|
+
* @throws Error if no Solana keyring is available in the vault
|
|
92
|
+
*/
|
|
93
|
+
addNewSolanaAccount(): Promise<Account>;
|
|
94
|
+
/**
|
|
95
|
+
* Imports an account from a private key and adds it to the vault.
|
|
96
|
+
* @param privateKey - The private key to import (hex string without '0x' prefix for EVM, base58 for Solana)
|
|
97
|
+
* @returns Promise resolving to the imported account information
|
|
98
|
+
* @throws Error if the private key is already managed by an HD keyring or if import fails
|
|
99
|
+
*/
|
|
100
|
+
importAccount(privateKey: string): Promise<Account>;
|
|
101
|
+
/**
|
|
102
|
+
* Returns a list of all accounts managed by the vault across all keyrings.
|
|
103
|
+
* @returns Array of Account objects representing all accounts in the vault
|
|
104
|
+
*/
|
|
105
|
+
getAccounts(): Account[];
|
|
106
|
+
/**
|
|
107
|
+
* Exports the mnemonic phrase from the vault for backup purposes.
|
|
108
|
+
* Requires password verification and includes rate limiting for security.
|
|
109
|
+
* @param password - The vault password to verify before exporting
|
|
110
|
+
* @returns Promise resolving to the mnemonic phrase as a string
|
|
111
|
+
* @throws Error if password is incorrect, no mnemonic exists, or rate limit exceeded
|
|
112
|
+
*/
|
|
113
|
+
exportMnemonic(password: string): Promise<string>;
|
|
114
|
+
/**
|
|
115
|
+
* Gets a unique identifier for this vault used for rate limiting purposes.
|
|
116
|
+
* @returns String identifier based on the first account address
|
|
117
|
+
*/
|
|
118
|
+
private getVaultId;
|
|
119
|
+
/**
|
|
120
|
+
* Encrypts the entire vault's state using the provided password.
|
|
121
|
+
* @param password - The password to use for encryption
|
|
122
|
+
* @returns Promise resolving to the encrypted vault data
|
|
123
|
+
* @throws Error if encryption fails
|
|
124
|
+
*/
|
|
125
|
+
encrypt(password: string): Promise<EncryptedData>;
|
|
126
|
+
/**
|
|
127
|
+
* Retrieves the private key for a specific address from the appropriate keyring.
|
|
128
|
+
* @param address - The account address to get the private key for
|
|
129
|
+
* @returns Promise resolving to the private key as a string
|
|
130
|
+
* @throws Error if the address is not found in any keyring
|
|
131
|
+
*/
|
|
132
|
+
getPrivateKeyFor(address: string): Promise<string>;
|
|
133
|
+
/**
|
|
134
|
+
* Gets the token balance for a specific account and token contract.
|
|
135
|
+
* @param accountAddress - The account address to check balance for
|
|
136
|
+
* @param tokenAddress - The contract address of the token
|
|
137
|
+
* @param chainId - The ID of the blockchain where the token is deployed
|
|
138
|
+
* @returns Promise resolving to the token balance as a bigint
|
|
139
|
+
* @throws Error if account or token not found, or chain service fails
|
|
140
|
+
*/
|
|
141
|
+
getTokenBalance(accountAddress: string, tokenAddress: string, chainId: ChainId): Promise<bigint>;
|
|
142
|
+
/**
|
|
143
|
+
* Sends tokens from a specific account to another address.
|
|
144
|
+
* @param fromAddress - The sender's account address
|
|
145
|
+
* @param to - The recipient's address
|
|
146
|
+
* @param amount - The amount of tokens to send as a string
|
|
147
|
+
* @param tokenAddress - The contract address of the token to send
|
|
148
|
+
* @param chainId - The ID of the blockchain for the transaction
|
|
149
|
+
* @returns Promise resolving to the transaction response with hash and details
|
|
150
|
+
* @throws Error if insufficient balance, invalid addresses, or transaction fails
|
|
151
|
+
*/
|
|
152
|
+
sendToken(fromAddress: string, to: string, amount: string, tokenAddress: string, chainId: ChainId): Promise<TransactionResponse>;
|
|
153
|
+
/**
|
|
154
|
+
* Generates a vanity HD wallet with a specific address prefix.
|
|
155
|
+
* Uses default configuration from VANITY_WALLET_CONFIG for optimal settings.
|
|
156
|
+
* The prefix defaults to 'aaa' as configured in VANITY_WALLET_CONFIG.DEFAULT_PREFIX.
|
|
157
|
+
*
|
|
158
|
+
* @param password - The password to encrypt the generated vault
|
|
159
|
+
* @param onProgress - Optional callback function for progress updates (attempts count and current address)
|
|
160
|
+
* @returns Promise resolving to an object containing the generated vault, encrypted vault, number of attempts, and the found address
|
|
161
|
+
* @throws Error if generation fails or max attempts exceeded
|
|
162
|
+
*
|
|
163
|
+
* @example
|
|
164
|
+
* ```typescript
|
|
165
|
+
* // Simple usage - will use default prefix 'aaa'
|
|
166
|
+
* const result = await Vault.generateVanityHDWallet("mypassword");
|
|
167
|
+
*
|
|
168
|
+
* // With progress callback
|
|
169
|
+
* const result = await Vault.generateVanityHDWallet(
|
|
170
|
+
* "mypassword",
|
|
171
|
+
* (attempts, address) => console.log(`Attempt ${attempts}: ${address}`)
|
|
172
|
+
* );
|
|
173
|
+
* ```
|
|
174
|
+
*/
|
|
175
|
+
static generateVanityHDWallet(password: string, onProgress?: (attempts: number, currentAddress: string) => void): Promise<{
|
|
176
|
+
vault: Vault;
|
|
177
|
+
encryptedVault: EncryptedData;
|
|
178
|
+
attempts: number;
|
|
179
|
+
foundAddress: string;
|
|
180
|
+
}>;
|
|
181
|
+
/**
|
|
182
|
+
* Generates a vanity HD wallet optimized for mobile devices.
|
|
183
|
+
* Uses mobile-optimized settings for faster completion and better UX.
|
|
184
|
+
*
|
|
185
|
+
* @param password - The password to encrypt the generated vault
|
|
186
|
+
* @param onProgress - Optional callback function for progress updates (attempts count and current address)
|
|
187
|
+
* @param options - Optional configuration options for mobile optimization
|
|
188
|
+
* @returns Promise resolving to an object containing the generated vault, encrypted vault, number of attempts, and the found address
|
|
189
|
+
* @throws Error if generation fails, max attempts exceeded, or timeout reached
|
|
190
|
+
*
|
|
191
|
+
* @example
|
|
192
|
+
* ```typescript
|
|
193
|
+
* // Simple mobile-optimized usage
|
|
194
|
+
* const result = await Vault.generateVanityHDWalletMobile("mypassword");
|
|
195
|
+
*
|
|
196
|
+
* // With custom options
|
|
197
|
+
* const result = await Vault.generateVanityHDWalletMobile(
|
|
198
|
+
* "mypassword",
|
|
199
|
+
* (attempts, address) => console.log(`Attempt ${attempts}: ${address}`),
|
|
200
|
+
* { prefix: 'ab', maxAttempts: 10000 }
|
|
201
|
+
* );
|
|
202
|
+
* ```
|
|
203
|
+
*/
|
|
204
|
+
static generateVanityHDWalletMobile(password: string, onProgress?: (attempts: number, currentAddress: string) => void, options?: {
|
|
205
|
+
prefix?: string;
|
|
206
|
+
maxAttempts?: number;
|
|
207
|
+
caseSensitive?: boolean;
|
|
208
|
+
timeout?: number;
|
|
209
|
+
}): Promise<{
|
|
210
|
+
vault: Vault;
|
|
211
|
+
encryptedVault: EncryptedData;
|
|
212
|
+
attempts: number;
|
|
213
|
+
foundAddress: string;
|
|
214
|
+
}>;
|
|
215
|
+
/**
|
|
216
|
+
* Ultra-optimized vanity wallet generation for maximum performance.
|
|
217
|
+
* Bypasses heavy HDKeyring initialization and uses direct cryptographic operations.
|
|
218
|
+
* Similar to web-based vanity generators for maximum speed.
|
|
219
|
+
*
|
|
220
|
+
* @param password - The password to encrypt the generated vault
|
|
221
|
+
* @param onProgress - Optional callback function for progress updates
|
|
222
|
+
* @param options - Configuration options for ultra-optimized generation
|
|
223
|
+
* @returns Promise resolving to generated vault data
|
|
224
|
+
*/
|
|
225
|
+
static generateVanityHDWalletUltra(password: string, onProgress?: (attempts: number, currentAddress: string) => void, options?: {
|
|
226
|
+
prefix?: string;
|
|
227
|
+
maxAttempts?: number;
|
|
228
|
+
caseSensitive?: boolean;
|
|
229
|
+
timeout?: number;
|
|
230
|
+
batchSize?: number;
|
|
231
|
+
}): Promise<{
|
|
232
|
+
vault: Vault;
|
|
233
|
+
encryptedVault: EncryptedData;
|
|
234
|
+
attempts: number;
|
|
235
|
+
foundAddress: string;
|
|
236
|
+
}>;
|
|
237
|
+
/**
|
|
238
|
+
* Transfers native tokens to multiple recipients in a single operation.
|
|
239
|
+
* Uses batch processing for optimal performance and provides progress tracking.
|
|
240
|
+
*
|
|
241
|
+
* @param fromAddress - The sender's account address
|
|
242
|
+
* @param recipients - Array of recipients with addresses and amounts
|
|
243
|
+
* @param chainId - The ID of the blockchain for the transaction
|
|
244
|
+
* @param onProgress - Optional callback for progress updates (completed, total, txHash)
|
|
245
|
+
* @returns Promise resolving to the multi-transfer result with success/failure details
|
|
246
|
+
* @throws Error if validation fails, insufficient balance, or transfer fails
|
|
247
|
+
*
|
|
248
|
+
* @example
|
|
249
|
+
* ```typescript
|
|
250
|
+
* const recipients = [
|
|
251
|
+
* { address: '0x123...', amount: '0.1' },
|
|
252
|
+
* { address: '0x456...', amount: '0.2' },
|
|
253
|
+
* { address: '0x789...', amount: '0.05' }
|
|
254
|
+
* ];
|
|
255
|
+
*
|
|
256
|
+
* const result = await vault.multiTransferNativeTokens(
|
|
257
|
+
* '0xmyAddress',
|
|
258
|
+
* recipients,
|
|
259
|
+
* '1', // Ethereum
|
|
260
|
+
* (completed, total, txHash) => console.log(`Completed ${completed}/${total}: ${txHash}`)
|
|
261
|
+
* );
|
|
262
|
+
*
|
|
263
|
+
* console.log(`Success: ${result.successfulCount}, Failed: ${result.failedCount}`);
|
|
264
|
+
* ```
|
|
265
|
+
*/
|
|
266
|
+
multiTransferNativeTokens(fromAddress: string, recipients: Recipient[], chainId: ChainId, onProgress?: (completed: number, total: number, txHash: string) => void): Promise<MultiTransferResult>;
|
|
267
|
+
/**
|
|
268
|
+
* Transfers ERC-20/SPL tokens to multiple recipients in a single operation.
|
|
269
|
+
* Uses batch processing for optimal performance and provides progress tracking.
|
|
270
|
+
*
|
|
271
|
+
* @param fromAddress - The sender's account address
|
|
272
|
+
* @param tokenAddress - The contract address of the token to send
|
|
273
|
+
* @param recipients - Array of recipients with addresses and amounts
|
|
274
|
+
* @param chainId - The ID of the blockchain for the transaction
|
|
275
|
+
* @param onProgress - Optional callback for progress updates (completed, total, txHash)
|
|
276
|
+
* @returns Promise resolving to the multi-transfer result with success/failure details
|
|
277
|
+
* @throws Error if validation fails, insufficient balance, or transfer fails
|
|
278
|
+
*
|
|
279
|
+
* @example
|
|
280
|
+
* ```typescript
|
|
281
|
+
* const recipients = [
|
|
282
|
+
* { address: '0x1111...', amount: '100' },
|
|
283
|
+
* { address: '0x456...', amount: '200' },
|
|
284
|
+
* { address: '0x789...', amount: '50' }
|
|
285
|
+
* ];
|
|
286
|
+
*
|
|
287
|
+
* const result = await vault.multiTransferTokens(
|
|
288
|
+
* '0xmyAddress',
|
|
289
|
+
* '0xtokenContract',
|
|
290
|
+
* recipients,
|
|
291
|
+
* '1', // Ethereum
|
|
292
|
+
* (completed, total, txHash) => console.log(`Completed ${completed}/${total}: ${txHash}`)
|
|
293
|
+
* );
|
|
294
|
+
*
|
|
295
|
+
* console.log(`Success: ${result.successfulCount}, Failed: ${result.failedCount}`);
|
|
296
|
+
* ```
|
|
297
|
+
*/
|
|
298
|
+
multiTransferTokens(fromAddress: string, tokenAddress: string, recipients: Recipient[], chainId: ChainId, onProgress?: (completed: number, total: number, txHash: string) => void): Promise<MultiTransferResult>;
|
|
299
|
+
/**
|
|
300
|
+
* Estimates gas cost for a native token transfer.
|
|
301
|
+
* Useful for displaying gas costs to users before sending transactions.
|
|
302
|
+
*
|
|
303
|
+
* @param fromAddress - The sender's account address
|
|
304
|
+
* @param to - The recipient's address
|
|
305
|
+
* @param amount - The amount to send as a string (e.g., "0.1")
|
|
306
|
+
* @param chainId - The ID of the blockchain for the transaction
|
|
307
|
+
* @returns Promise resolving to the estimated gas cost as a bigint
|
|
308
|
+
* @throws Error if estimation fails or addresses are invalid
|
|
309
|
+
*
|
|
310
|
+
* @example
|
|
311
|
+
* ```typescript
|
|
312
|
+
* const gasEstimate = await vault.estimateNativeTransferGas(
|
|
313
|
+
* '0x1234...',
|
|
314
|
+
* '0x5678...',
|
|
315
|
+
* '0.01', // 0.01 ETH
|
|
316
|
+
* '1' // Ethereum
|
|
317
|
+
* );
|
|
318
|
+
*
|
|
319
|
+
* console.log('Estimated gas:', gasEstimate.toString());
|
|
320
|
+
* console.log('Estimated cost (in ETH):', ethers.formatEther(gasEstimate * gasPrice));
|
|
321
|
+
* ```
|
|
322
|
+
*/
|
|
323
|
+
estimateNativeTransferGas(fromAddress: string, to: string, amount: string, chainId: ChainId): Promise<bigint>;
|
|
324
|
+
/**
|
|
325
|
+
* Estimates gas cost for an ERC-20/SPL token transfer.
|
|
326
|
+
* Useful for displaying gas costs to users before sending token transactions.
|
|
327
|
+
*
|
|
328
|
+
* @param fromAddress - The sender's account address
|
|
329
|
+
* @param tokenAddress - The contract address of the token
|
|
330
|
+
* @param to - The recipient's address
|
|
331
|
+
* @param amount - The amount of tokens to send as a string
|
|
332
|
+
* @param chainId - The ID of the blockchain for the transaction
|
|
333
|
+
* @returns Promise resolving to the estimated gas cost as a bigint
|
|
334
|
+
* @throws Error if estimation fails, token contract is invalid, or addresses are invalid
|
|
335
|
+
*
|
|
336
|
+
* @example
|
|
337
|
+
* ```typescript
|
|
338
|
+
* const gasEstimate = await vault.estimateTokenTransferGas(
|
|
339
|
+
* '0x1234...',
|
|
340
|
+
* '0xA0b86a33E6441b8c4C8C8C8C8C8C8C8C8C8C8C8C', // USDC
|
|
341
|
+
* '0x5678...',
|
|
342
|
+
* '100', // 100 USDC
|
|
343
|
+
* '1' // Ethereum
|
|
344
|
+
* );
|
|
345
|
+
*
|
|
346
|
+
* console.log('Estimated gas for token transfer:', gasEstimate.toString());
|
|
347
|
+
* ```
|
|
348
|
+
*/
|
|
349
|
+
estimateTokenTransferGas(fromAddress: string, tokenAddress: string, to: string, amount: string, chainId: ChainId): Promise<bigint>;
|
|
350
|
+
/**
|
|
351
|
+
* Estimates gas cost for multi-transfer operations.
|
|
352
|
+
* Useful for displaying total gas costs before executing batch transfers.
|
|
353
|
+
*
|
|
354
|
+
* @param fromAddress - The sender's account address
|
|
355
|
+
* @param recipients - Array of recipients with addresses and amounts
|
|
356
|
+
* @param chainId - The ID of the blockchain for the transaction
|
|
357
|
+
* @param isNative - Whether estimating for native tokens (true) or ERC-20/SPL tokens (false)
|
|
358
|
+
* @param tokenAddress - Token contract address (required if isNative is false)
|
|
359
|
+
* @returns Promise resolving to the estimated total gas cost as a bigint
|
|
360
|
+
* @throws Error if estimation fails or parameters are invalid
|
|
361
|
+
*
|
|
362
|
+
* @example
|
|
363
|
+
* ```typescript
|
|
364
|
+
* const recipients = [
|
|
365
|
+
* { address: '0x1111...', amount: '0.01' },
|
|
366
|
+
* { address: '0x2222...', amount: '0.02' },
|
|
367
|
+
* { address: '0x3333...', amount: '0.005' }
|
|
368
|
+
* ];
|
|
369
|
+
*
|
|
370
|
+
* // Estimate for native token multi-transfer
|
|
371
|
+
* const nativeGasEstimate = await vault.estimateMultiTransferGas(
|
|
372
|
+
* '0x1234...',
|
|
373
|
+
* recipients,
|
|
374
|
+
* '1', // Ethereum
|
|
375
|
+
* true // Native tokens
|
|
376
|
+
* );
|
|
377
|
+
*
|
|
378
|
+
* // Estimate for token multi-transfer
|
|
379
|
+
* const tokenGasEstimate = await vault.estimateMultiTransferGas(
|
|
380
|
+
* '0x1234...',
|
|
381
|
+
* recipients,
|
|
382
|
+
* '1', // Ethereum
|
|
383
|
+
* false, // ERC-20 tokens
|
|
384
|
+
* '0xA0b86a33E6441b8c4C8C8C8C8C8C8C8C8C8C8C8C' // USDC
|
|
385
|
+
* );
|
|
386
|
+
*
|
|
387
|
+
* console.log('Native multi-transfer gas:', nativeGasEstimate.toString());
|
|
388
|
+
* console.log('Token multi-transfer gas:', tokenGasEstimate.toString());
|
|
389
|
+
* ```
|
|
390
|
+
*/
|
|
391
|
+
estimateMultiTransferGas(fromAddress: string, recipients: Recipient[], chainId: ChainId, isNative?: boolean, tokenAddress?: string): Promise<bigint>;
|
|
392
|
+
/**
|
|
393
|
+
* Gets all NFTs owned by an address across multiple collections.
|
|
394
|
+
* Pure blockchain implementation - reads from smart contracts.
|
|
395
|
+
*
|
|
396
|
+
* @param address - Wallet address to check
|
|
397
|
+
* @param contractAddresses - Array of NFT contract addresses to check
|
|
398
|
+
* @param options - NFT query options
|
|
399
|
+
* @returns Promise resolving to array of NFT details
|
|
400
|
+
* @throws Error if any contract query fails
|
|
401
|
+
*
|
|
402
|
+
* @example
|
|
403
|
+
* ```typescript
|
|
404
|
+
* const collections = [
|
|
405
|
+
* '0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D', // BAYC
|
|
406
|
+
* '0x60E4d786628Fea6478F785A6d7e704777c86a7c6' // MAYC
|
|
407
|
+
* ];
|
|
408
|
+
*
|
|
409
|
+
* const nfts = await vault.getOwnedNFTs(
|
|
410
|
+
* '0x1234...', // Wallet address
|
|
411
|
+
* collections,
|
|
412
|
+
* { includeMetadata: true }
|
|
413
|
+
* );
|
|
414
|
+
*
|
|
415
|
+
* console.log(`Found ${nfts.length} owned NFTs`);
|
|
416
|
+
* nfts.forEach(nft => {
|
|
417
|
+
* console.log(`${nft.name} from ${nft.contractAddress}`);
|
|
418
|
+
* });
|
|
419
|
+
* ```
|
|
420
|
+
*/
|
|
421
|
+
getOwnedNFTs(address: string, contractAddresses: string[], options?: NFTOptions): Promise<NFTDetailExtended[]>;
|
|
422
|
+
/**
|
|
423
|
+
* Transfers an NFT from one address to another.
|
|
424
|
+
* Pure blockchain implementation using smart contract calls.
|
|
425
|
+
*
|
|
426
|
+
* @param fromAddress - Sender's address
|
|
427
|
+
* @param toAddress - Recipient's address
|
|
428
|
+
* @param contractAddress - NFT contract address
|
|
429
|
+
* @param tokenId - Token ID to transfer
|
|
430
|
+
* @returns Promise resolving to transaction response
|
|
431
|
+
* @throws Error if transfer fails, insufficient permissions, or NFT not owned
|
|
432
|
+
*
|
|
433
|
+
* @example
|
|
434
|
+
* ```typescript
|
|
435
|
+
* const result = await vault.transferNFT(
|
|
436
|
+
* '0x1234...', // From address
|
|
437
|
+
* '0x5678...', // To address
|
|
438
|
+
* '0xBC4CA0EdA7647A8aB7C2061c2E118A18a936f13D', // BAYC contract
|
|
439
|
+
* '1234' // Token ID
|
|
440
|
+
* );
|
|
441
|
+
*
|
|
442
|
+
* console.log('Transfer successful:', result.hash);
|
|
443
|
+
* ```
|
|
444
|
+
*/
|
|
445
|
+
transferNFT(fromAddress: string, toAddress: string, contractAddress: string, tokenId: string): Promise<TransactionResponse>;
|
|
446
|
+
/**
|
|
447
|
+
* Imports wallet from QR code data.
|
|
448
|
+
* @param qrString - QR code string to parse
|
|
449
|
+
* @param password - Password to decrypt the mnemonic
|
|
450
|
+
* @returns Promise resolving to imported account information
|
|
451
|
+
* @throws Error if QR data is invalid or import fails
|
|
452
|
+
*
|
|
453
|
+
* @example
|
|
454
|
+
* ```typescript
|
|
455
|
+
* // Import wallet from scanned QR code
|
|
456
|
+
* const accounts = await vault.importFromQR(qrString, 'my-password');
|
|
457
|
+
* console.log('Imported accounts:', accounts);
|
|
458
|
+
* ```
|
|
459
|
+
*/
|
|
460
|
+
importFromQR(qrString: string, password: string): Promise<Account[]>;
|
|
461
|
+
/**
|
|
462
|
+
* Processes transaction from QR code data.
|
|
463
|
+
* @param qrString - QR code string to parse
|
|
464
|
+
* @param fromAddress - Sender's address
|
|
465
|
+
* @returns Promise resolving to transaction response
|
|
466
|
+
* @throws Error if QR data is invalid or transaction fails
|
|
467
|
+
*
|
|
468
|
+
* @example
|
|
469
|
+
* ```typescript
|
|
470
|
+
* // Process transaction from scanned QR code
|
|
471
|
+
* const result = await vault.processTransactionFromQR(qrString, '0x1234...');
|
|
472
|
+
* console.log('Transaction hash:', result.hash);
|
|
473
|
+
* ```
|
|
474
|
+
*/
|
|
475
|
+
processTransactionFromQR(qrString: string, fromAddress: string): Promise<TransactionResponse>;
|
|
476
|
+
/**
|
|
477
|
+
* Sends native tokens (ETH, BNB, MATIC, etc.) from a specific account to another address.
|
|
478
|
+
* @param fromAddress - The sender's account address
|
|
479
|
+
* @param to - The recipient's address
|
|
480
|
+
* @param amount - The amount to send as a string (e.g., "0.1")
|
|
481
|
+
* @param chainId - The ID of the blockchain for the transaction
|
|
482
|
+
* @returns Promise resolving to the transaction response
|
|
483
|
+
* @throws Error if insufficient balance, invalid addresses, or transaction fails
|
|
484
|
+
*
|
|
485
|
+
* @example
|
|
486
|
+
* ```typescript
|
|
487
|
+
* // Send 0.1 ETH on Ethereum mainnet
|
|
488
|
+
* const tx = await vault.sendNativeToken(from, to, '0.1', '1');
|
|
489
|
+
* console.log('Transaction hash:', tx.hash);
|
|
490
|
+
* ```
|
|
491
|
+
*/
|
|
492
|
+
sendNativeToken(fromAddress: string, to: string, amount: string, chainId: ChainId): Promise<TransactionResponse>;
|
|
493
|
+
}
|