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.
Files changed (46) hide show
  1. package/README.md +2062 -0
  2. package/dist/Vault.d.ts +493 -0
  3. package/dist/Vault.js +1090 -0
  4. package/dist/chain/ChainService.d.ts +84 -0
  5. package/dist/chain/ChainService.js +136 -0
  6. package/dist/chain/SolanaChainService.d.ts +94 -0
  7. package/dist/chain/SolanaChainService.js +167 -0
  8. package/dist/config/chains.d.ts +233 -0
  9. package/dist/config/chains.js +285 -0
  10. package/dist/config/constants.d.ts +102 -0
  11. package/dist/config/constants.js +109 -0
  12. package/dist/config/environment.d.ts +46 -0
  13. package/dist/config/environment.js +114 -0
  14. package/dist/config/gas.d.ts +107 -0
  15. package/dist/config/gas.js +123 -0
  16. package/dist/crypto/EncryptionService.d.ts +74 -0
  17. package/dist/crypto/EncryptionService.js +178 -0
  18. package/dist/index.d.ts +22 -0
  19. package/dist/index.js +96 -0
  20. package/dist/keyrings/HDKeyring.d.ts +72 -0
  21. package/dist/keyrings/HDKeyring.js +156 -0
  22. package/dist/keyrings/SimpleKeyring.d.ts +31 -0
  23. package/dist/keyrings/SimpleKeyring.js +49 -0
  24. package/dist/keyrings/SolanaKeyring.d.ts +71 -0
  25. package/dist/keyrings/SolanaKeyring.js +159 -0
  26. package/dist/services/BatchProcessor.d.ts +42 -0
  27. package/dist/services/BatchProcessor.js +188 -0
  28. package/dist/services/MultiTransferService.d.ts +78 -0
  29. package/dist/services/MultiTransferService.js +252 -0
  30. package/dist/services/QRCodeService.d.ts +193 -0
  31. package/dist/services/QRCodeService.js +299 -0
  32. package/dist/services/TokenUtils.d.ts +307 -0
  33. package/dist/services/TokenUtils.js +429 -0
  34. package/dist/services/nft/MetadataResolver.d.ts +57 -0
  35. package/dist/services/nft/MetadataResolver.js +162 -0
  36. package/dist/services/nft/NFTAPIService.d.ts +53 -0
  37. package/dist/services/nft/NFTAPIService.js +122 -0
  38. package/dist/services/nft/NFTService.d.ts +241 -0
  39. package/dist/services/nft/NFTService.js +910 -0
  40. package/dist/types/multiTransfer.d.ts +68 -0
  41. package/dist/types/multiTransfer.js +2 -0
  42. package/dist/types/nft/index.d.ts +68 -0
  43. package/dist/types/nft/index.js +2 -0
  44. package/dist/types/nft.d.ts +265 -0
  45. package/dist/types/nft.js +6 -0
  46. package/package.json +70 -0
@@ -0,0 +1,299 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.QRCodeService = void 0;
4
+ const EncryptionService_1 = require("../crypto/EncryptionService");
5
+ /**
6
+ * Service for generating and scanning QR codes for wallet operations.
7
+ * Supports address sharing, mnemonic backup, and transaction signing.
8
+ */
9
+ class QRCodeService {
10
+ /**
11
+ * Generates QR code data for a wallet address
12
+ * @param address - The wallet address to encode
13
+ * @param label - Optional label for the address
14
+ * @returns QR code data string
15
+ */
16
+ static generateAddressQR(address, label) {
17
+ const qrData = {
18
+ type: 'address',
19
+ data: {
20
+ address: address,
21
+ label: label || '',
22
+ },
23
+ timestamp: Date.now(),
24
+ version: this.QR_VERSION,
25
+ };
26
+ return JSON.stringify(qrData);
27
+ }
28
+ /**
29
+ * Generates QR code data for encrypted mnemonic backup
30
+ * @param mnemonic - The mnemonic phrase to encrypt
31
+ * @param password - Password for encryption
32
+ * @param chainType - Type of blockchain (evm, solana, etc.)
33
+ * @param accountCount - Number of accounts to import
34
+ * @returns Promise resolving to QR code data string
35
+ * @throws Error if encryption fails
36
+ */
37
+ static async generateMnemonicQR(mnemonic, password, chainType = 'evm', accountCount = 1) {
38
+ // Encrypt the mnemonic
39
+ const encryptedMnemonic = await EncryptionService_1.EncryptionService.encrypt(mnemonic, password);
40
+ const walletImportData = {
41
+ encryptedMnemonic,
42
+ chainType,
43
+ accountCount,
44
+ };
45
+ const qrData = {
46
+ type: 'wallet-import',
47
+ data: walletImportData,
48
+ timestamp: Date.now(),
49
+ version: this.QR_VERSION,
50
+ };
51
+ return JSON.stringify(qrData);
52
+ }
53
+ /**
54
+ * Generates QR code data for transaction signing
55
+ * @param transactionData - Transaction details
56
+ * @returns QR code data string
57
+ */
58
+ static generateTransactionQR(transactionData) {
59
+ const qrData = {
60
+ type: 'transaction',
61
+ data: transactionData,
62
+ timestamp: Date.now(),
63
+ version: this.QR_VERSION,
64
+ };
65
+ return JSON.stringify(qrData);
66
+ }
67
+ /**
68
+ * Parses QR code data and validates its structure
69
+ * @param qrString - The QR code string to parse
70
+ * @returns Parsed QR code data
71
+ * @throws Error if QR data is invalid or unsupported
72
+ */
73
+ static parseQRData(qrString) {
74
+ try {
75
+ const qrData = JSON.parse(qrString);
76
+ // Validate required fields
77
+ if (!qrData.type || !qrData.data || !qrData.timestamp || !qrData.version) {
78
+ throw new Error('Invalid QR code format: missing required fields');
79
+ }
80
+ // Validate type
81
+ const validTypes = ['address', 'mnemonic', 'transaction', 'wallet-import'];
82
+ if (!validTypes.includes(qrData.type)) {
83
+ throw new Error(`Unsupported QR code type: ${qrData.type}`);
84
+ }
85
+ // Validate timestamp (not too old, not in future)
86
+ const now = Date.now();
87
+ const maxAge = 24 * 60 * 60 * 1000; // 24 hours
88
+ if (qrData.timestamp > now || qrData.timestamp < now - maxAge) {
89
+ throw new Error('QR code is too old or has invalid timestamp');
90
+ }
91
+ return qrData;
92
+ }
93
+ catch (error) {
94
+ if (error instanceof SyntaxError) {
95
+ throw new Error('Invalid QR code: not a valid JSON');
96
+ }
97
+ throw error;
98
+ }
99
+ }
100
+ /**
101
+ * Extracts wallet address from QR code data
102
+ * @param qrString - The QR code string
103
+ * @returns The wallet address
104
+ * @throws Error if QR code doesn't contain address data
105
+ */
106
+ static extractAddress(qrString) {
107
+ const qrData = this.parseQRData(qrString);
108
+ if (qrData.type !== 'address') {
109
+ throw new Error('QR code does not contain address data');
110
+ }
111
+ const address = qrData.data.address;
112
+ if (!address || typeof address !== 'string') {
113
+ throw new Error('Invalid address in QR code');
114
+ }
115
+ return address;
116
+ }
117
+ /**
118
+ * Extracts wallet import data from QR code
119
+ * @param qrString - The QR code string
120
+ * @returns Wallet import data
121
+ * @throws Error if QR code doesn't contain wallet import data
122
+ */
123
+ static extractWalletImportData(qrString) {
124
+ const qrData = this.parseQRData(qrString);
125
+ if (qrData.type !== 'wallet-import') {
126
+ throw new Error('QR code does not contain wallet import data');
127
+ }
128
+ const importData = qrData.data;
129
+ // Validate required fields
130
+ if (!importData.encryptedMnemonic || !importData.chainType) {
131
+ throw new Error('Invalid wallet import data in QR code');
132
+ }
133
+ return importData;
134
+ }
135
+ /**
136
+ * Extracts transaction data from QR code
137
+ * @param qrString - The QR code string
138
+ * @returns Transaction data
139
+ * @throws Error if QR code doesn't contain transaction data
140
+ */
141
+ static extractTransactionData(qrString) {
142
+ const qrData = this.parseQRData(qrString);
143
+ if (qrData.type !== 'transaction') {
144
+ throw new Error('QR code does not contain transaction data');
145
+ }
146
+ const txData = qrData.data;
147
+ // Validate required fields
148
+ if (!txData.txType || !txData.chainId || !txData.to || !txData.amount) {
149
+ throw new Error('Invalid transaction data in QR code');
150
+ }
151
+ return txData;
152
+ }
153
+ /**
154
+ * Validates if a string is a valid Ethereum address
155
+ * @param address - Address to validate
156
+ * @returns True if valid Ethereum address
157
+ */
158
+ static isValidEthereumAddress(address) {
159
+ return /^0x[a-fA-F0-9]{40}$/.test(address);
160
+ }
161
+ /**
162
+ * Validates if a string is a valid Solana address
163
+ * @param address - Address to validate
164
+ * @returns True if valid Solana address
165
+ */
166
+ static isValidSolanaAddress(address) {
167
+ return /^[1-9A-HJ-NP-Za-km-z]{32,44}$/.test(address);
168
+ }
169
+ /**
170
+ * Gets the address type based on format
171
+ * @param address - Address to check
172
+ * @returns 'ethereum', 'solana', or 'unknown'
173
+ */
174
+ static getAddressType(address) {
175
+ if (this.isValidEthereumAddress(address)) {
176
+ return 'ethereum';
177
+ }
178
+ if (this.isValidSolanaAddress(address)) {
179
+ return 'solana';
180
+ }
181
+ return 'unknown';
182
+ }
183
+ /**
184
+ * Clears sensitive data from memory
185
+ * @param data - Sensitive data to clear
186
+ */
187
+ static clearSensitiveData(data) {
188
+ // Overwrite the string with zeros (as much as possible in JS)
189
+ if (typeof data === 'string') {
190
+ // Note: JavaScript strings are immutable, so we can't directly clear them
191
+ // But we can help the garbage collector by removing references
192
+ setTimeout(() => {
193
+ // This helps reduce the time sensitive data stays in memory
194
+ }, 0);
195
+ }
196
+ }
197
+ // --- Utility Functions for External Use ---
198
+ /**
199
+ * Generates QR code data for a wallet address from Vault.
200
+ * Utility function to be used outside of Vault class.
201
+ * @param vault - The vault instance
202
+ * @param accountIndex - Index of the account to generate QR for (default: 0)
203
+ * @param label - Optional label for the address
204
+ * @returns QR code data string
205
+ * @throws Error if account index is invalid
206
+ *
207
+ * @example
208
+ * ```typescript
209
+ * import { QRCodeService, Vault } from 'pwc-wallet-sdk';
210
+ *
211
+ * // Generate QR for first account
212
+ * const qrData = QRCodeService.generateAddressQRFromVault(vault, 0, 'My Wallet');
213
+ * ```
214
+ */
215
+ static generateAddressQRFromVault(vault, accountIndex = 0, label) {
216
+ const accounts = vault.getAccounts();
217
+ if (accountIndex < 0 || accountIndex >= accounts.length) {
218
+ throw new Error(`Invalid account index: ${accountIndex}. Available accounts: ${accounts.length}`);
219
+ }
220
+ const account = accounts[accountIndex];
221
+ return this.generateAddressQR(account.address, label || account.name);
222
+ }
223
+ /**
224
+ * Generates QR code data for encrypted mnemonic backup from Vault.
225
+ * Utility function to be used outside of Vault class.
226
+ * @param vault - The vault instance
227
+ * @param password - Password for encryption
228
+ * @param accountCount - Number of accounts to import (default: 1)
229
+ * @returns Promise resolving to QR code data string
230
+ * @throws Error if encryption fails or no HD keyring available
231
+ *
232
+ * @example
233
+ * ```typescript
234
+ * import { QRCodeService, Vault } from 'pwc-wallet-sdk';
235
+ *
236
+ * // Generate backup QR with password
237
+ * const qrData = await QRCodeService.generateMnemonicQRFromVault(vault, 'my-secure-password', 3);
238
+ * ```
239
+ */
240
+ static async generateMnemonicQRFromVault(vault, password, accountCount = 1) {
241
+ const hdKeyring = vault.keyrings.find((k) => k.type === 'HD');
242
+ if (!hdKeyring) {
243
+ throw new Error('No HD keyring available. Cannot generate mnemonic QR.');
244
+ }
245
+ // Get the mnemonic from the HD keyring
246
+ const mnemonic = hdKeyring.getMnemonic();
247
+ if (!mnemonic) {
248
+ throw new Error('Mnemonic not available in HD keyring.');
249
+ }
250
+ const chainType = vault.chainId === 'solana' ? 'solana' : 'evm';
251
+ return this.generateMnemonicQR(mnemonic, password, chainType, accountCount);
252
+ }
253
+ /**
254
+ * Validates QR code data without processing it.
255
+ * @param qrString - QR code string to validate
256
+ * @returns Object containing validation result and data type
257
+ *
258
+ * @example
259
+ * ```typescript
260
+ * // Validate QR code before processing
261
+ * const validation = QRCodeService.validateQRCode(qrString);
262
+ * console.log('QR type:', validation.type);
263
+ * console.log('Is valid:', validation.isValid);
264
+ * ```
265
+ */
266
+ static validateQRCode(qrString) {
267
+ try {
268
+ const qrData = this.parseQRData(qrString);
269
+ return {
270
+ isValid: true,
271
+ type: qrData.type,
272
+ data: qrData.data
273
+ };
274
+ }
275
+ catch (error) {
276
+ return {
277
+ isValid: false,
278
+ type: 'unknown',
279
+ data: null
280
+ };
281
+ }
282
+ }
283
+ /**
284
+ * Generates an EIP-681 compatible QR string for wallet address.
285
+ * This format is compatible with Metamask, Binance, Trust Wallet, etc.
286
+ * @param address - The wallet address to encode
287
+ * @returns EIP-681 URI string (e.g., 'ethereum:0x1234...')
288
+ * @example
289
+ * ```typescript
290
+ * const qrString = QRCodeService.generateEIP681AddressQR('0x1234...');
291
+ * // Use this string with a QR code generator for maximum wallet compatibility
292
+ * ```
293
+ */
294
+ static generateEIP681AddressQR(address) {
295
+ return `ethereum:${address}`;
296
+ }
297
+ }
298
+ exports.QRCodeService = QRCodeService;
299
+ QRCodeService.QR_VERSION = '1.0';
@@ -0,0 +1,307 @@
1
+ import { ethers, TransactionRequest } from 'ethers';
2
+ import { ChainId } from '../config/chains';
3
+ import { Vault } from '../Vault';
4
+ /**
5
+ * Gets or creates a cached provider for the specified chain.
6
+ * @param chainId - The chain ID (e.g., '1' for Ethereum, '56' for BSC)
7
+ * @returns Cached ethers provider for the chain
8
+ */
9
+ export declare function getProviderAuto(chainId: ChainId): ethers.JsonRpcProvider;
10
+ /**
11
+ * Gets the token balance for a specific account.
12
+ * @param tokenAddress - The ERC-20 token contract address
13
+ * @param account - The account address to check balance for
14
+ * @param chainId - The chain ID (e.g., '1' for Ethereum, '56' for BSC)
15
+ * @returns Promise resolving to the token balance as bigint
16
+ * @example
17
+ * ```typescript
18
+ * const balance = await getTokenBalance('0xToken...', '0xAccount...', '1');
19
+ * console.log('Balance:', ethers.formatUnits(balance, 18));
20
+ * ```
21
+ */
22
+ export declare function getTokenBalance(tokenAddress: string, account: string, chainId: ChainId): Promise<bigint>;
23
+ /**
24
+ * Gets comprehensive information about an ERC-20 token.
25
+ * @param tokenAddress - The ERC-20 token contract address
26
+ * @param chainId - The chain ID (e.g., '1' for Ethereum, '56' for BSC)
27
+ * @returns Promise resolving to token information including name, symbol, decimals, total supply
28
+ * @example
29
+ * ```typescript
30
+ * const info = await getTokenInfo('0xToken...', '1');
31
+ * console.log('Token:', info.name, '(', info.symbol, ')');
32
+ * ```
33
+ */
34
+ export declare function getTokenInfo(tokenAddress: string, chainId: ChainId): Promise<{
35
+ name: string;
36
+ symbol: string;
37
+ decimals: number;
38
+ totalSupply: bigint;
39
+ address: string;
40
+ }>;
41
+ /**
42
+ * Gets the native token balance (ETH, BNB, MATIC, etc.) for an account.
43
+ * @param account - The account address to check balance for
44
+ * @param chainId - The chain ID (e.g., '1' for Ethereum, '56' for BSC)
45
+ * @returns Promise resolving to the native token balance as bigint
46
+ * @example
47
+ * ```typescript
48
+ * const balance = await getNativeBalance('0xAccount...', '1');
49
+ * console.log('ETH Balance:', ethers.formatEther(balance));
50
+ * ```
51
+ */
52
+ export declare function getNativeBalance(account: string, chainId: ChainId): Promise<bigint>;
53
+ /**
54
+ * Checks the allowance granted by an owner to a spender for a specific token.
55
+ * @param tokenAddress - The ERC-20 token contract address
56
+ * @param owner - The token owner's address
57
+ * @param spender - The spender's address (e.g., DEX contract address)
58
+ * @param chainId - The chain ID (e.g., '1' for Ethereum, '56' for BSC)
59
+ * @returns Promise resolving to the allowance amount as bigint
60
+ * @example
61
+ * ```typescript
62
+ * const allowance = await checkAllowance('0xToken...', '0xOwner...', '0xSpender...', '1');
63
+ * console.log('Allowance:', ethers.formatUnits(allowance, 18));
64
+ * ```
65
+ */
66
+ export declare function checkAllowance(tokenAddress: string, owner: string, spender: string, chainId: ChainId): Promise<bigint>;
67
+ /**
68
+ * Builds a generic transaction for any contract method.
69
+ * @param contractAddress - The contract address to interact with
70
+ * @param abi - The contract ABI array
71
+ * @param method - The method name to call
72
+ * @param args - Arguments to pass to the method (default: [])
73
+ * @param value - Native token value to send with transaction (default: undefined)
74
+ * @param chainId - The chain ID (e.g., '1' for Ethereum, '56' for BSC)
75
+ * @returns Promise resolving to the unsigned transaction object
76
+ * @example
77
+ * ```typescript
78
+ * const tx = await buildTransaction({
79
+ * contractAddress: '0xContract...',
80
+ * abi: [...],
81
+ * method: 'transfer',
82
+ * args: ['0xTo...', '1000000000000000000'],
83
+ * chainId: '1'
84
+ * });
85
+ * ```
86
+ */
87
+ export declare function buildTransaction({ contractAddress, abi, method, args, value, chainId }: {
88
+ contractAddress: string;
89
+ abi: any[];
90
+ method: string;
91
+ args?: any[];
92
+ value?: bigint;
93
+ chainId: ChainId;
94
+ }): Promise<ethers.TransactionRequest>;
95
+ /**
96
+ * Signs an unsigned transaction using Vault (RECOMMENDED).
97
+ * @param unsignedTx - The unsigned transaction object
98
+ * @param vault - The vault instance containing the account
99
+ * @param fromAddress - The sender's address
100
+ * @param chainId - The chain ID (e.g., '1' for Ethereum, '56' for BSC)
101
+ * @returns Promise resolving to the signed transaction as hex string
102
+ * @example
103
+ * ```typescript
104
+ * const signedTx = await signTransactionWithVault(unsignedTx, vault, '0xYourAddress', '1');
105
+ * ```
106
+ */
107
+ export declare function signTransactionWithVault(unsignedTx: TransactionRequest, vault: Vault, fromAddress: string, chainId: ChainId): Promise<string>;
108
+ /**
109
+ * Approves a spender to spend tokens on behalf of the owner using Vault (RECOMMENDED).
110
+ * @param vault - The vault instance containing the owner's account
111
+ * @param fromAddress - The owner's address
112
+ * @param tokenAddress - The ERC-20 token contract address
113
+ * @param spender - The spender's address (e.g., DEX contract address)
114
+ * @param amount - The amount to approve (string or bigint)
115
+ * @param chainId - The chain ID (e.g., '1' for Ethereum, '56' for BSC)
116
+ * @returns Promise resolving to the transaction response
117
+ * @example
118
+ * ```typescript
119
+ * const receipt = await approveTokenWithVault(vault, '0xOwner...', '0xToken...', '0xSpender...', '1000', '1');
120
+ * ```
121
+ */
122
+ export declare function approveTokenWithVault(vault: Vault, fromAddress: string, tokenAddress: string, spender: string, amount: string | bigint, chainId: ChainId): Promise<ethers.TransactionResponse>;
123
+ /**
124
+ * Broadcasts a signed transaction to the network.
125
+ * @param signedTx - The signed transaction as hex string
126
+ * @param chainId - The chain ID (e.g., '1' for Ethereum, '56' for BSC)
127
+ * @returns Promise resolving to the transaction response
128
+ * @example
129
+ * ```typescript
130
+ * const txResponse = await sendTransaction(signedTx, '1');
131
+ * console.log('Transaction hash:', txResponse.hash);
132
+ * ```
133
+ */
134
+ export declare function sendTransaction(signedTx: string, chainId: ChainId): Promise<ethers.TransactionResponse>;
135
+ /**
136
+ * Tracks the status of a transaction with polling and callback notifications.
137
+ * @param txHash - The transaction hash to track
138
+ * @param chainId - The chain ID (e.g., '1' for Ethereum, '56' for BSC)
139
+ * @param callback - Function called with status updates ('pending', 'confirmed', 'failed')
140
+ * @param pollInterval - Polling interval in milliseconds (default: 3000)
141
+ * @example
142
+ * ```typescript
143
+ * trackTxStatus('0xTxHash...', '1', (status, receipt) => {
144
+ * if (status === 'confirmed') {
145
+ * console.log('Transaction confirmed!');
146
+ * }
147
+ * });
148
+ * ```
149
+ */
150
+ export declare function trackTxStatus(txHash: string, chainId: ChainId, callback: (status: 'pending' | 'confirmed' | 'failed', receipt?: any) => void, pollInterval?: number): Promise<void>;
151
+ /**
152
+ * Gets the transaction count (nonce) for an address.
153
+ * This is useful for message signing with nonce and transaction building.
154
+ * @param address - The address to get nonce for
155
+ * @param chainId - The chain ID (e.g., '1' for Ethereum, '56' for BSC)
156
+ * @returns Promise resolving to the nonce as number
157
+ * @example
158
+ * ```typescript
159
+ * const nonce = await getNonce('0xYourAddress', '1');
160
+ * console.log('Current nonce:', nonce);
161
+ * ```
162
+ */
163
+ export declare function getNonce(address: string, chainId: ChainId): Promise<number>;
164
+ /**
165
+ * Signs a message using Vault (RECOMMENDED).
166
+ * This is equivalent to MetaMask's personal_sign method.
167
+ * @param message - The message to sign (string or hex string)
168
+ * @param vault - The vault instance containing the account
169
+ * @param fromAddress - The signer's address
170
+ * @returns Promise resolving to the signature as hex string
171
+ * @example
172
+ * ```typescript
173
+ * const signature = await signMessageWithVault('Hello World', vault, '0xYourAddress');
174
+ * console.log('Signature:', signature);
175
+ * ```
176
+ */
177
+ export declare function signMessageWithVault(message: string, vault: Vault, fromAddress: string): Promise<string>;
178
+ /**
179
+ * Signs a message using private key (DEPRECATED).
180
+ * ⚠️ **DEPRECATED**: Use signMessageWithVault instead for better security.
181
+ * @param message - The message to sign (string or hex string)
182
+ * @param privateKey - The private key to sign with (without 0x prefix)
183
+ * @returns Promise resolving to the signature as hex string
184
+ * @example
185
+ * ```typescript
186
+ * const signature = await signMessage('Hello World', 'your-private-key');
187
+ * console.log('Signature:', signature);
188
+ * ```
189
+ */
190
+ export declare function signMessage(message: string, privateKey: string): Promise<string>;
191
+ /**
192
+ * Verifies a message signature and returns the signer's address.
193
+ * @param message - The original message that was signed
194
+ * @param signature - The signature to verify
195
+ * @returns Promise resolving to the signer's address
196
+ * @example
197
+ * ```typescript
198
+ * const signerAddress = await verifyMessage('Hello World', '0xSignature...');
199
+ * console.log('Message was signed by:', signerAddress);
200
+ * ```
201
+ */
202
+ export declare function verifyMessage(message: string, signature: string): Promise<string>;
203
+ /**
204
+ * Signs a typed data message using Vault (RECOMMENDED).
205
+ * This is equivalent to MetaMask's eth_signTypedData method.
206
+ * @param typedData - The typed data object to sign
207
+ * @param vault - The vault instance containing the account
208
+ * @param fromAddress - The signer's address
209
+ * @returns Promise resolving to the signature as hex string
210
+ * @example
211
+ * ```typescript
212
+ * const typedData = {
213
+ * types: {
214
+ * Person: [
215
+ * { name: 'name', type: 'string' },
216
+ * { name: 'wallet', type: 'address' }
217
+ * ]
218
+ * },
219
+ * primaryType: 'Person',
220
+ * domain: { name: 'MyApp', version: '1' },
221
+ * message: { name: 'Alice', wallet: '0x123...' }
222
+ * };
223
+ * const signature = await signTypedDataWithVault(typedData, vault, '0xYourAddress');
224
+ * ```
225
+ */
226
+ export declare function signTypedDataWithVault(typedData: any, vault: Vault, fromAddress: string): Promise<string>;
227
+ /**
228
+ * Signs a typed data message using private key (DEPRECATED).
229
+ * ⚠️ **DEPRECATED**: Use signTypedDataWithVault instead for better security.
230
+ * @param typedData - The typed data object to sign
231
+ * @param privateKey - The private key to sign with (without 0x prefix)
232
+ * @returns Promise resolving to the signature as hex string
233
+ * @example
234
+ * ```typescript
235
+ * const typedData = {
236
+ * types: { Person: [{ name: 'name', type: 'string' }] },
237
+ * primaryType: 'Person',
238
+ * domain: { name: 'MyApp' },
239
+ * message: { name: 'Alice' }
240
+ * };
241
+ * const signature = await signTypedData(typedData, 'your-private-key');
242
+ * ```
243
+ */
244
+ export declare function signTypedData(typedData: any, privateKey: string): Promise<string>;
245
+ /**
246
+ * Verifies a typed data signature and returns the signer's address.
247
+ * @param typedData - The original typed data that was signed
248
+ * @param signature - The signature to verify
249
+ * @returns Promise resolving to the signer's address
250
+ * @example
251
+ * ```typescript
252
+ * const signerAddress = await verifyTypedData(typedData, '0xSignature...');
253
+ * console.log('Typed data was signed by:', signerAddress);
254
+ * ```
255
+ */
256
+ export declare function verifyTypedData(typedData: any, signature: string): Promise<string>;
257
+ /**
258
+ * Signs a message with nonce using Vault (RECOMMENDED).
259
+ * This includes nonce in the message to prevent replay attacks.
260
+ * @param message - The message to sign (string or hex string)
261
+ * @param vault - The vault instance containing the account
262
+ * @param fromAddress - The signer's address
263
+ * @param chainId - The chain ID (e.g., '1' for Ethereum, '56' for BSC)
264
+ * @returns Promise resolving to an object containing signature and nonce
265
+ * @example
266
+ * ```typescript
267
+ * const result = await signMessageWithNonce('Hello World', vault, '0xYourAddress', '1');
268
+ * console.log('Signature:', result.signature);
269
+ * console.log('Nonce:', result.nonce);
270
+ * ```
271
+ */
272
+ export declare function signMessageWithNonce(message: string, vault: Vault, fromAddress: string, chainId: ChainId): Promise<{
273
+ signature: string;
274
+ nonce: number;
275
+ }>;
276
+ /**
277
+ * Signs a message with nonce using private key (DEPRECATED).
278
+ * ⚠️ **DEPRECATED**: Use signMessageWithNonceWithVault instead for better security.
279
+ * @param message - The message to sign (string or hex string)
280
+ * @param privateKey - The private key to sign with (without 0x prefix)
281
+ * @param address - The signer's address (needed to get nonce)
282
+ * @param chainId - The chain ID (e.g., '1' for Ethereum, '56' for BSC)
283
+ * @returns Promise resolving to an object containing signature and nonce
284
+ * @example
285
+ * ```typescript
286
+ * const result = await signMessageWithNoncePrivateKey('Hello World', 'your-private-key', '0xYourAddress', '1');
287
+ * console.log('Signature:', result.signature);
288
+ * console.log('Nonce:', result.nonce);
289
+ * ```
290
+ */
291
+ export declare function signMessageWithNoncePrivateKey(message: string, privateKey: string, address: string, chainId: ChainId): Promise<{
292
+ signature: string;
293
+ nonce: number;
294
+ }>;
295
+ /**
296
+ * Verifies a message signature with nonce and returns the signer's address.
297
+ * @param message - The original message that was signed (without nonce)
298
+ * @param signature - The signature to verify
299
+ * @param nonce - The nonce that was used in signing
300
+ * @returns Promise resolving to the signer's address
301
+ * @example
302
+ * ```typescript
303
+ * const signerAddress = await verifyMessageWithNonce('Hello World', '0xSignature...', 5);
304
+ * console.log('Message was signed by:', signerAddress);
305
+ * ```
306
+ */
307
+ export declare function verifyMessageWithNonce(message: string, signature: string, nonce: number): Promise<string>;