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