@deserialize/multi-vm-wallet 1.3.4 → 1.4.1

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 (42) hide show
  1. package/dist/IChainWallet.d.ts +1 -0
  2. package/dist/IChainWallet.js.map +1 -1
  3. package/dist/evm/evm.d.ts +12 -174
  4. package/dist/evm/evm.js +33 -506
  5. package/dist/evm/evm.js.map +1 -1
  6. package/dist/evm/transaction.utils.d.ts +3 -3
  7. package/dist/evm/utils.d.ts +115 -80
  8. package/dist/evm/utils.js +272 -497
  9. package/dist/evm/utils.js.map +1 -1
  10. package/dist/helpers/index.d.ts +1 -0
  11. package/dist/helpers/index.js +5 -0
  12. package/dist/helpers/index.js.map +1 -1
  13. package/dist/savings/index.d.ts +0 -0
  14. package/dist/savings/index.js +3 -0
  15. package/dist/savings/index.js.map +1 -0
  16. package/dist/savings/saving-actions.d.ts +0 -0
  17. package/dist/savings/saving-actions.js +78 -0
  18. package/dist/savings/saving-actions.js.map +1 -0
  19. package/dist/savings/savings-manager.d.ts +1 -1
  20. package/dist/savings/savings-manager.js +3 -3
  21. package/dist/savings/savings-manager.js.map +1 -1
  22. package/dist/svm/svm.d.ts +2 -0
  23. package/dist/svm/svm.js +6 -0
  24. package/dist/svm/svm.js.map +1 -1
  25. package/dist/test.js +7 -7
  26. package/dist/test.js.map +1 -1
  27. package/dist/utils.d.ts +2 -1
  28. package/dist/utils.js +20 -0
  29. package/dist/utils.js.map +1 -1
  30. package/dist/vm.js.map +1 -1
  31. package/package.json +1 -1
  32. package/utils/IChainWallet.ts +2 -0
  33. package/utils/evm/evm.ts +321 -683
  34. package/utils/evm/utils.ts +438 -662
  35. package/utils/helpers/index.ts +6 -0
  36. package/utils/savings/index.ts +1 -0
  37. package/utils/savings/saving-actions.ts +92 -0
  38. package/utils/savings/savings-manager.ts +1 -1
  39. package/utils/svm/svm.ts +8 -0
  40. package/utils/test.ts +11 -3
  41. package/utils/utils.ts +19 -2
  42. package/utils/vm.ts +1 -0
@@ -21,4 +21,5 @@ export declare abstract class ChainWallet<AddressType, PrivateKeyType, Connectio
21
21
  abstract getPrices(tokenAddresses: string[]): Promise<PriceResponse>;
22
22
  getAddress(): AddressType;
23
23
  getChainWalletConfig(): ChainWalletConfig;
24
+ abstract convertFromEntropyToPrivateKey(entropy: string): PrivateKeyType;
24
25
  }
@@ -1 +1 @@
1
- {"version":3,"file":"IChainWallet.js","sourceRoot":"","sources":["../utils/IChainWallet.ts"],"names":[],"mappings":";;;AAKA,MAAsB,WAAW;IACnB,UAAU,CAAiB;IACrC,MAAM,CAAoB;IAC1B,OAAO,CAAc;IACrB,KAAK,CAAoB;IACzB,UAAU,CAA4B;IAEtC,YAAY,MAAyB,EAAE,UAA0B,EAAE,KAAc;QAC7E,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC;QAChD,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IAEvB,CAAC;IAYD,+GAA+G;IAC/G,mEAAmE;IACnE,mFAAmF;IACnF,oDAAoD;IAEpD,UAAU;QACN,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IACD,oBAAoB;QAChB,OAAO,IAAI,CAAC,MAAM,CAAC;IACvB,CAAC;CAEJ;AArCD,kCAqCC"}
1
+ {"version":3,"file":"IChainWallet.js","sourceRoot":"","sources":["../utils/IChainWallet.ts"],"names":[],"mappings":";;;AAKA,MAAsB,WAAW;IACnB,UAAU,CAAiB;IACrC,MAAM,CAAoB;IAC1B,OAAO,CAAc;IACrB,KAAK,CAAoB;IACzB,UAAU,CAA4B;IAEtC,YAAY,MAAyB,EAAE,UAA0B,EAAE,KAAc;QAC7E,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC;QAChD,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IAEvB,CAAC;IAYD,+GAA+G;IAC/G,mEAAmE;IACnE,mFAAmF;IACnF,oDAAoD;IAEpD,UAAU;QACN,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IACD,oBAAoB;QAChB,OAAO,IAAI,CAAC,MAAM,CAAC;IACvB,CAAC;CAIJ;AAvCD,kCAuCC"}
package/dist/evm/evm.d.ts CHANGED
@@ -6,18 +6,16 @@
6
6
  import { ChainWallet } from "../IChainWallet";
7
7
  import { Balance, ChainWalletConfig, UserTokenBalance, TokenInfo, TransactionResult, NFT } from "../types";
8
8
  import { VM } from "../vm";
9
- import { JsonRpcProvider, Wallet } from "ethers";
10
9
  import { EVMTransactionHistoryItem } from "./transactionParsing";
11
- import { Hex, PublicClient } from "viem";
10
+ import { Hex, WalletClient, PublicClient } from "viem";
12
11
  import { EVMSmartWallet } from "./smartWallet";
13
12
  import { SmartWalletOptions } from "./aa-service";
14
- import { SavingsAccount, SmartSavingsAccount, AddressVerificationResult, SavingsAuditResult, TransferToSavingsOptions, WithdrawFromSavingsOptions } from "../savings/types";
15
13
  import { PriceResponse } from "../price.types";
16
- export declare class EVMVM extends VM<string, string, JsonRpcProvider> {
14
+ export declare class EVMVM extends VM<string, string, PublicClient> {
17
15
  derivationPath: string;
18
16
  constructor(seed: string);
19
- getTokenInfo: (tokenAddress: string, provider: JsonRpcProvider) => Promise<TokenInfo>;
20
- static getTokenInfo: (tokenAddress: string, provider: JsonRpcProvider) => Promise<TokenInfo>;
17
+ getTokenInfo: (tokenAddress: Hex, client: PublicClient) => Promise<TokenInfo>;
18
+ static getTokenInfo: (tokenAddress: Hex, client: PublicClient) => Promise<TokenInfo>;
21
19
  generatePrivateKey(index: number, seed?: string, mnemonic?: string, derivationPath?: string): {
22
20
  privateKey: string;
23
21
  index: number;
@@ -38,23 +36,22 @@ export declare class EVMVM extends VM<string, string, JsonRpcProvider> {
38
36
  address: string;
39
37
  derivationPath: string;
40
38
  };
41
- static fromMnemonic(mnemonic: string): VM<string, string, JsonRpcProvider>;
39
+ static fromMnemonic(mnemonic: string): VM<string, string, PublicClient>;
42
40
  static validateAddress(address: string): boolean;
43
- static getNativeBalance(address: string, connection: JsonRpcProvider): Promise<Balance>;
44
- static getTokenBalance(address: string, tokenAddress: string, connection: JsonRpcProvider): Promise<Balance>;
41
+ static getNativeBalance(address: string, connection: PublicClient): Promise<Balance>;
42
+ static getTokenBalance(address: string, tokenAddress: string, connection: PublicClient): Promise<Balance>;
43
+ static convertFromEntropyToPrivateKey: (entropy: string) => string;
45
44
  }
46
- export declare class EVMChainWallet extends ChainWallet<string, string, JsonRpcProvider> {
47
- client: PublicClient;
48
- wallet: Wallet;
45
+ export declare class EVMChainWallet extends ChainWallet<string, string, PublicClient> {
46
+ wallet: WalletClient;
49
47
  private smartWallet?;
50
- private savingsManager?;
51
- private smartSavingsManager?;
52
48
  constructor(config: ChainWalletConfig, privateKey: string, index: number);
53
49
  /**
54
50
  * Check if Account Abstraction is supported on this chain
55
51
  * @returns true if aaSupport is enabled in config
56
52
  */
57
53
  private isAASupportedByChain;
54
+ convertFromEntropyToPrivateKey: (entropy: string) => string;
58
55
  /**
59
56
  * Check if smart wallet is initialized and ready for AA operations
60
57
  * @returns true if extend() has been called and smart wallet exists
@@ -101,7 +98,7 @@ export declare class EVMChainWallet extends ChainWallet<string, string, JsonRpcP
101
98
  * @returns Smart wallet address or undefined
102
99
  */
103
100
  getSmartWalletAddress(): string | undefined;
104
- getWallet(): Wallet;
101
+ getWallet(): WalletClient;
105
102
  generateAddress(): string;
106
103
  getNativeBalance(): Promise<Balance>;
107
104
  getTokenBalance(tokenAddress: string): Promise<Balance>;
@@ -113,16 +110,7 @@ export declare class EVMChainWallet extends ChainWallet<string, string, JsonRpcP
113
110
  getTransactionHistory(): Promise<EVMTransactionHistoryItem[]>;
114
111
  getPrices(tokenAddresses: string[]): Promise<PriceResponse>;
115
112
  swap(tokenAddress: TokenInfo, to: string, amount: number, slippage?: number): Promise<TransactionResult>;
116
- performCompleteSwap(tokenIn: TokenInfo, tokenOut: TokenInfo, amount: number, slippage?: number, recipient?: string, deadline?: number): Promise<TransactionResult>;
117
- private performDebonkSwap;
118
113
  private fail;
119
- private performKyberSwap;
120
- getSwapQuote(tokenIn: TokenInfo, tokenOut: TokenInfo, amount: number): Promise<{
121
- amountOut: string;
122
- priceImpact: string;
123
- gasEstimate: string;
124
- route: string[];
125
- }>;
126
114
  approveToken(params: {
127
115
  tokenAddress: string;
128
116
  spender: string;
@@ -130,155 +118,5 @@ export declare class EVMChainWallet extends ChainWallet<string, string, JsonRpcP
130
118
  confirmations?: number;
131
119
  gasLimit?: string | bigint;
132
120
  }): Promise<TransactionResult>;
133
- executeContractMethod(params: {
134
- contractAddress: string;
135
- abi: any[];
136
- methodName: string;
137
- methodParams?: any[];
138
- value?: string | bigint;
139
- gasLimit?: string | bigint;
140
- confirmations?: number;
141
- }): Promise<TransactionResult>;
142
121
  signMessage(message: string): Promise<string>;
143
- /**
144
- * Get or create the SavingsManager instance (lazy initialization)
145
- * @private
146
- */
147
- private getSavingsManager;
148
- /**
149
- * Initialize savings functionality with a seed phrase
150
- *
151
- * This must be called before using any savings methods.
152
- * The seed is used to derive savings accounts using BIP-44.
153
- *
154
- * @param seed - The wallet seed (hex string)
155
- *
156
- * @example
157
- * const seed = VM.mnemonicToSeed(mnemonic);
158
- * wallet.initializeSavings(seed);
159
- */
160
- initializeSavings(seed: string): void;
161
- /**
162
- * Derive a new savings account from BIP-44 account index
163
- *
164
- * @param accountIndex - The BIP-44 account index (1+ for savings, 0 is main wallet)
165
- * @returns SavingsAccount with derived address and private key
166
- *
167
- * @example
168
- * const savingsAccount1 = wallet.deriveSavingsAccount(1); // m/44'/60'/1'/0/0
169
- * const savingsAccount2 = wallet.deriveSavingsAccount(2); // m/44'/60'/2'/0/0
170
- */
171
- deriveSavingsAccount(accountIndex: number): SavingsAccount;
172
- /**
173
- * Transfer native tokens to a savings account
174
- *
175
- * Security: Always derives the destination address from accountIndex.
176
- *
177
- * @param accountIndex - Savings account index to deposit to
178
- * @param amount - Amount in ether units (e.g., "1.5" for 1.5 ETH)
179
- * @param options - Optional security and priority settings
180
- * @returns Transaction result
181
- *
182
- * @example
183
- * const result = await wallet.transferToSavings(1, "1.5"); // Send 1.5 ETH to savings account 1
184
- */
185
- transferToSavings(accountIndex: number, amount: string, options?: TransferToSavingsOptions): Promise<TransactionResult>;
186
- /**
187
- * Withdraw native tokens from a savings account
188
- *
189
- * Security: Uses the derived private key for signing.
190
- *
191
- * @param accountIndex - Savings account index to withdraw from
192
- * @param to - Destination address
193
- * @param amount - Amount in ether units (e.g., "0.5" for 0.5 ETH)
194
- * @param options - Optional security and priority settings
195
- * @returns Transaction result
196
- *
197
- * @example
198
- * const result = await wallet.withdrawFromSavings(1, destinationAddress, "0.5");
199
- */
200
- withdrawFromSavings(accountIndex: number, to: string, amount: string, options?: WithdrawFromSavingsOptions): Promise<TransactionResult>;
201
- /**
202
- * Verify a stored savings address matches the derived address
203
- *
204
- * Security: Prevents database tampering attacks.
205
- *
206
- * @param accountIndex - The account index to verify
207
- * @param storedAddress - The address from storage/database
208
- * @returns Verification result
209
- *
210
- * @example
211
- * const result = wallet.verifySavingsAddress(1, storedAddress);
212
- * if (!result.isValid) {
213
- * console.error("Security alert: Address tampering detected!");
214
- * }
215
- */
216
- verifySavingsAddress(accountIndex: number, storedAddress: Hex): AddressVerificationResult;
217
- /**
218
- * Audit multiple savings addresses at once
219
- *
220
- * @param addresses - Map of accountIndex to stored address
221
- * @returns Audit result with summary and details
222
- *
223
- * @example
224
- * const addresses = new Map([[1, "0xabc..."], [2, "0xdef..."]]);
225
- * const audit = wallet.auditSavingsAddresses(addresses);
226
- * console.log(`Valid: ${audit.valid}/${audit.total}`);
227
- */
228
- auditSavingsAddresses(addresses: Map<number, Hex>): SavingsAuditResult;
229
- /**
230
- * Get savings account information without exposing private key
231
- *
232
- * @param accountIndex - The account index
233
- * @returns Public account information (address and derivation path)
234
- *
235
- * @example
236
- * const info = wallet.getSavingsAccountInfo(1);
237
- * console.log(`Address: ${info.address}`);
238
- * console.log(`Path: ${info.derivationPath}`); // m/44'/60'/1'/0/0
239
- */
240
- getSavingsAccountInfo(accountIndex: number): Omit<SavingsAccount, 'privateKey'>;
241
- /**
242
- * Get or create the SmartSavingsManager instance (lazy initialization)
243
- * @private
244
- */
245
- private getSmartSavingsManager;
246
- /**
247
- * Upgrade a savings account to a smart account with EIP-7702 delegation
248
- *
249
- * This enables advanced features:
250
- * - Lock modules for time-locked savings
251
- * - Hooks for spend & save
252
- * - Session keys for periodic savings
253
- * - Sponsored transactions via paymaster
254
- *
255
- * @param accountIndex - The savings account index to upgrade
256
- * @param options - Optional smart wallet configuration
257
- * @param autoInitialize - Whether to initialize the smart wallet (default: false)
258
- * @returns SmartSavingsAccount with EVMSmartWallet instance
259
- *
260
- * @example
261
- * // Upgrade without initialization
262
- * const smartSavings = await wallet.upgradeSavingsToSmartAccount(1);
263
- * await smartSavings.smartWallet.initialize(); // Initialize separately
264
- *
265
- * @example
266
- * // Upgrade and initialize in one step
267
- * const smartSavings = await wallet.upgradeSavingsToSmartAccount(1, {}, true);
268
- * // Ready to use immediately
269
- */
270
- upgradeSavingsToSmartAccount(accountIndex: number, options?: SmartWalletOptions, autoInitialize?: boolean): Promise<SmartSavingsAccount>;
271
- /**
272
- * Check if smart savings is supported on this chain
273
- *
274
- * @returns true if chain supports Account Abstraction
275
- *
276
- * @example
277
- * if (wallet.isSmartSavingsSupported()) {
278
- * const smartSavings = await wallet.upgradeSavingsToSmartAccount(1);
279
- * } else {
280
- * console.log("This chain doesn't support smart savings");
281
- * }
282
- */
283
- isSmartSavingsSupported(): boolean;
284
122
  }