@deserialize/multi-vm-wallet 1.2.441 → 1.3.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/.claude/settings.local.json +12 -0
- package/SMART_WALLET_GUIDE.md +746 -0
- package/SMART_WALLET_IMPLEMENTATION.md +460 -0
- package/dist/IChainWallet.d.ts +3 -3
- package/dist/IChainWallet.js +5 -0
- package/dist/IChainWallet.js.map +1 -1
- package/dist/evm/SMART_WALLET_EXAMPLES.d.ts +20 -0
- package/dist/evm/SMART_WALLET_EXAMPLES.js +451 -0
- package/dist/evm/SMART_WALLET_EXAMPLES.js.map +1 -0
- package/dist/evm/aa-service/index.d.ts +16 -0
- package/dist/evm/aa-service/index.js +69 -0
- package/dist/evm/aa-service/index.js.map +1 -0
- package/dist/evm/aa-service/lib/account-adapter.d.ts +26 -0
- package/dist/evm/aa-service/lib/account-adapter.js +53 -0
- package/dist/evm/aa-service/lib/account-adapter.js.map +1 -0
- package/dist/evm/aa-service/lib/kernel-account.d.ts +91 -0
- package/dist/evm/aa-service/lib/kernel-account.js +251 -0
- package/dist/evm/aa-service/lib/kernel-account.js.map +1 -0
- package/dist/evm/aa-service/lib/kernel-modules.d.ts +240 -0
- package/dist/evm/aa-service/lib/kernel-modules.js +409 -0
- package/dist/evm/aa-service/lib/kernel-modules.js.map +1 -0
- package/dist/evm/aa-service/lib/session-keys.d.ts +170 -0
- package/dist/evm/aa-service/lib/session-keys.js +297 -0
- package/dist/evm/aa-service/lib/session-keys.js.map +1 -0
- package/dist/evm/aa-service/lib/type.d.ts +167 -0
- package/dist/evm/aa-service/lib/type.js +43 -0
- package/dist/evm/aa-service/lib/type.js.map +1 -0
- package/dist/evm/aa-service/services/account-abstraction.d.ts +614 -0
- package/dist/evm/aa-service/services/account-abstraction.js +754 -0
- package/dist/evm/aa-service/services/account-abstraction.js.map +1 -0
- package/dist/evm/aa-service/services/bundler.d.ts +29 -0
- package/dist/evm/aa-service/services/bundler.js +168 -0
- package/dist/evm/aa-service/services/bundler.js.map +1 -0
- package/dist/evm/evm.d.ts +67 -3
- package/dist/evm/evm.js +212 -7
- package/dist/evm/evm.js.map +1 -1
- package/dist/evm/index.d.ts +1 -0
- package/dist/evm/index.js +3 -0
- package/dist/evm/index.js.map +1 -1
- package/dist/evm/smartWallet.d.ts +265 -0
- package/dist/evm/smartWallet.js +675 -0
- package/dist/evm/smartWallet.js.map +1 -0
- package/dist/evm/smartWallet.types.d.ts +10 -0
- package/dist/evm/smartWallet.types.js +16 -0
- package/dist/evm/smartWallet.types.js.map +1 -0
- package/dist/evm/transaction.utils.d.ts +10 -10
- package/dist/evm/transaction.utils.js +12 -8
- package/dist/evm/transaction.utils.js.map +1 -1
- package/dist/evm/transactionParsing.js +77 -1
- package/dist/evm/transactionParsing.js.map +1 -1
- package/dist/helpers/index.d.ts +1 -0
- package/dist/helpers/index.js +15 -0
- package/dist/helpers/index.js.map +1 -1
- package/dist/helpers/routeScan.d.ts +191 -0
- package/dist/helpers/routeScan.js +114 -0
- package/dist/helpers/routeScan.js.map +1 -0
- package/dist/index.d.ts +0 -2
- package/dist/index.js +0 -2
- package/dist/index.js.map +1 -1
- package/dist/svm/svm.d.ts +4 -3
- package/dist/svm/svm.js +29 -18
- package/dist/svm/svm.js.map +1 -1
- package/dist/svm/transactionSender.js +2 -2
- package/dist/svm/transactionSender.js.map +1 -1
- package/dist/svm/utils.d.ts +4 -3
- package/dist/svm/utils.js +19 -6
- package/dist/svm/utils.js.map +1 -1
- package/dist/test.js +7 -0
- package/dist/test.js.map +1 -1
- package/dist/types.d.ts +19 -2
- package/dist/types.js.map +1 -1
- package/dist/vm.js +9 -7
- package/dist/vm.js.map +1 -1
- package/package.json +2 -2
- package/tsconfig.json +4 -3
- package/utils/IChainWallet.ts +3 -3
- package/utils/evm/SMART_WALLET_EXAMPLES.ts.bak +591 -0
- package/utils/evm/aa-service/index.ts +85 -0
- package/utils/evm/aa-service/lib/account-adapter.ts +60 -0
- package/utils/evm/aa-service/lib/kernel-account.ts +367 -0
- package/utils/evm/aa-service/lib/kernel-modules.ts +598 -0
- package/utils/evm/aa-service/lib/session-keys.ts +389 -0
- package/utils/evm/aa-service/lib/type.ts +236 -0
- package/utils/evm/aa-service/services/account-abstraction.ts +1015 -0
- package/utils/evm/aa-service/services/bundler.ts +217 -0
- package/utils/evm/evm.ts +268 -11
- package/utils/evm/index.ts +5 -1
- package/utils/evm/smartWallet.ts +797 -0
- package/utils/evm/smartWallet.types.ts +33 -0
- package/utils/evm/transaction.utils.ts +12 -10
- package/utils/evm/transactionParsing.ts +100 -14
- package/utils/helpers/index.ts +1 -0
- package/utils/helpers/routeScan.ts +397 -0
- package/utils/index.ts +0 -2
- package/utils/svm/svm.ts +50 -9
- package/utils/svm/utils.ts +52 -7
- package/utils/test.ts +7 -0
- package/utils/types.ts +24 -2
package/dist/evm/index.js
CHANGED
|
@@ -16,4 +16,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./evm"), exports);
|
|
18
18
|
__exportStar(require("./utils"), exports);
|
|
19
|
+
__exportStar(require("./smartWallet"), exports);
|
|
20
|
+
// Note: AA service types are re-exported through smartWallet.types.ts
|
|
21
|
+
// Direct AA service exports would cause duplicate export errors
|
|
19
22
|
//# sourceMappingURL=index.js.map
|
package/dist/evm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../utils/evm/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wCAAqB;AACrB,0CAAuB"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../utils/evm/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wCAAqB;AACrB,0CAAuB;AACvB,gDAA6B;AAE7B,sEAAsE;AACtE,gEAAgE"}
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EVM Smart Wallet Implementation
|
|
3
|
+
*
|
|
4
|
+
* Provides Account Abstraction (EIP-4337) and EIP-7702 capabilities to EVMChainWallet.
|
|
5
|
+
* This class wraps the AA service and provides a clean API for smart wallet features.
|
|
6
|
+
*/
|
|
7
|
+
import { Chain, Hex } from "viem";
|
|
8
|
+
import { Balance } from "../types";
|
|
9
|
+
import { SmartWalletOptions, SmartWalletTransactionResult, Call, SessionKeyInfo, SessionKeyPermissionRule, SessionKeyApprovalOptions, SessionKeyUsageOptions, ModuleInstallOptions, ModuleUninstallOptions, MultiSigConfig, SmartAccountInfo, ModuleType } from "./smartWallet.types";
|
|
10
|
+
/**
|
|
11
|
+
* EVMSmartWallet - Smart wallet capabilities for EVM chains
|
|
12
|
+
*
|
|
13
|
+
* Provides:
|
|
14
|
+
* - EIP-7702 account delegation
|
|
15
|
+
* - Batch transactions (pay gas once for multiple operations)
|
|
16
|
+
* - Session keys with granular permissions
|
|
17
|
+
* - Module management (validators, hooks, executors)
|
|
18
|
+
* - Gas sponsorship (paymasters)
|
|
19
|
+
* - Multi-signature support
|
|
20
|
+
* - Account recovery
|
|
21
|
+
*/
|
|
22
|
+
export declare class EVMSmartWallet {
|
|
23
|
+
private aaService;
|
|
24
|
+
private kernelAccount;
|
|
25
|
+
private ownerAccount;
|
|
26
|
+
private chain;
|
|
27
|
+
private options;
|
|
28
|
+
private sessionAccount;
|
|
29
|
+
private paymasterConfig;
|
|
30
|
+
private bundlerUrl;
|
|
31
|
+
constructor(privateKey: string, chain: Chain, bundlerUrl: string, options?: SmartWalletOptions);
|
|
32
|
+
/**
|
|
33
|
+
* Initialize the smart wallet
|
|
34
|
+
* Creates the Kernel account and sets up delegation if needed
|
|
35
|
+
*/
|
|
36
|
+
initialize(): Promise<void>;
|
|
37
|
+
/**
|
|
38
|
+
* Get the smart account address
|
|
39
|
+
*/
|
|
40
|
+
getAddress(): Hex;
|
|
41
|
+
/**
|
|
42
|
+
* Get smart account information
|
|
43
|
+
*/
|
|
44
|
+
getAccountInfo(): Promise<SmartAccountInfo>;
|
|
45
|
+
/**
|
|
46
|
+
* Get smart account balance
|
|
47
|
+
*/
|
|
48
|
+
getBalance(): Promise<Balance>;
|
|
49
|
+
/**
|
|
50
|
+
* Check if account is delegated
|
|
51
|
+
*/
|
|
52
|
+
isAccountDelegated(): Promise<boolean>;
|
|
53
|
+
/**
|
|
54
|
+
* Send a single transaction via UserOperation
|
|
55
|
+
*
|
|
56
|
+
* @param to - Recipient address
|
|
57
|
+
* @param value - ETH value in wei
|
|
58
|
+
* @param data - Optional calldata
|
|
59
|
+
* @returns Transaction result with UserOp hash
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* await smartWallet.sendTransaction(
|
|
63
|
+
* '0xRecipient',
|
|
64
|
+
* parseEther('0.1'),
|
|
65
|
+
* '0x'
|
|
66
|
+
* );
|
|
67
|
+
*/
|
|
68
|
+
sendTransaction(to: Hex, value?: bigint, data?: Hex): Promise<SmartWalletTransactionResult>;
|
|
69
|
+
/**
|
|
70
|
+
* Send multiple transactions in a single UserOperation
|
|
71
|
+
* This is one of the main advantages of smart accounts - pay gas ONLY ONCE!
|
|
72
|
+
*
|
|
73
|
+
* @param calls - Array of calls to execute
|
|
74
|
+
* @returns Transaction result
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* await smartWallet.sendBatchTransaction([
|
|
78
|
+
* { to: recipient1, value: parseEther('0.1'), data: '0x' },
|
|
79
|
+
* { to: recipient2, value: parseEther('0.2'), data: '0x' },
|
|
80
|
+
* { to: usdcAddress, value: 0n, data: transferCalldata }
|
|
81
|
+
* ]);
|
|
82
|
+
*/
|
|
83
|
+
sendBatchTransaction(calls: Call[]): Promise<SmartWalletTransactionResult>;
|
|
84
|
+
/**
|
|
85
|
+
* Prepare a call for batching
|
|
86
|
+
* Helper method to create Call objects
|
|
87
|
+
*/
|
|
88
|
+
prepareCall(to: Hex, value?: bigint, data?: Hex): Call;
|
|
89
|
+
/**
|
|
90
|
+
* Generate a new session key
|
|
91
|
+
* The private key should be stored securely by the agent
|
|
92
|
+
*
|
|
93
|
+
* @returns Session key info with private key, address, and signer
|
|
94
|
+
*
|
|
95
|
+
* @example
|
|
96
|
+
* const sessionKey = await smartWallet.generateSessionKey();
|
|
97
|
+
* console.log('Address:', sessionKey.address);
|
|
98
|
+
* // Store sessionKey.privateKey securely
|
|
99
|
+
*/
|
|
100
|
+
generateSessionKey(): Promise<SessionKeyInfo>;
|
|
101
|
+
/**
|
|
102
|
+
* Recreate session key from stored private key
|
|
103
|
+
*
|
|
104
|
+
* @param privateKey - Session key private key
|
|
105
|
+
* @returns Session key info
|
|
106
|
+
*
|
|
107
|
+
* @example
|
|
108
|
+
* const sessionKey = await smartWallet.recreateSessionKey(storedPrivateKey);
|
|
109
|
+
*/
|
|
110
|
+
recreateSessionKey(privateKey: Hex): Promise<SessionKeyInfo>;
|
|
111
|
+
/**
|
|
112
|
+
* Create session key approval (Owner side)
|
|
113
|
+
* Owner approves a session key with specific permissions
|
|
114
|
+
*
|
|
115
|
+
* @param options - Approval options with session key address and permissions
|
|
116
|
+
* @returns Serialized approval string to share with agent
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* const approval = await smartWallet.approveSessionKey({
|
|
120
|
+
* sessionKeyAddress: '0x...',
|
|
121
|
+
* permissions: [
|
|
122
|
+
* smartWallet.createUSDCPermission(USDC_ADDRESS, '100')
|
|
123
|
+
* ]
|
|
124
|
+
* });
|
|
125
|
+
*/
|
|
126
|
+
approveSessionKey(options: SessionKeyApprovalOptions): Promise<string>;
|
|
127
|
+
/**
|
|
128
|
+
* Use session key for transactions (Agent side)
|
|
129
|
+
* Agent deserializes the approval and can send transactions with session key
|
|
130
|
+
*
|
|
131
|
+
* @param options - Session key usage options with approval and signer
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* const sessionKey = await smartWallet.recreateSessionKey(privateKey);
|
|
135
|
+
* await smartWallet.useSessionKey({
|
|
136
|
+
* approval,
|
|
137
|
+
* sessionKeySigner: sessionKey.signer
|
|
138
|
+
* });
|
|
139
|
+
* // Now can send transactions with session key permissions
|
|
140
|
+
*/
|
|
141
|
+
useSessionKey(options: SessionKeyUsageOptions): Promise<void>;
|
|
142
|
+
/**
|
|
143
|
+
* Clear session key (revert to owner account)
|
|
144
|
+
*/
|
|
145
|
+
clearSessionKey(): void;
|
|
146
|
+
/**
|
|
147
|
+
* Check if using session key
|
|
148
|
+
*/
|
|
149
|
+
isUsingSessionKey(): boolean;
|
|
150
|
+
/**
|
|
151
|
+
* Create USDC transfer permission
|
|
152
|
+
*
|
|
153
|
+
* @param usdcAddress - USDC contract address
|
|
154
|
+
* @param maxAmount - Maximum USDC amount (in USDC units, e.g., "10" for 10 USDC)
|
|
155
|
+
* @returns Permission rule
|
|
156
|
+
*/
|
|
157
|
+
createUSDCPermission(usdcAddress: Hex, maxAmount: string): SessionKeyPermissionRule;
|
|
158
|
+
/**
|
|
159
|
+
* Create ETH transfer permission
|
|
160
|
+
*
|
|
161
|
+
* @param maxValue - Maximum ETH value (in ether units, e.g., "0.1" for 0.1 ETH)
|
|
162
|
+
* @returns Permission rule
|
|
163
|
+
*/
|
|
164
|
+
createETHPermission(maxValue: string): SessionKeyPermissionRule;
|
|
165
|
+
/**
|
|
166
|
+
* Install a module on the smart account
|
|
167
|
+
*
|
|
168
|
+
* @param options - Module installation options
|
|
169
|
+
* @returns Transaction result
|
|
170
|
+
*
|
|
171
|
+
* @example
|
|
172
|
+
* await smartWallet.installModule({
|
|
173
|
+
* moduleType: 'validator',
|
|
174
|
+
* moduleAddress: '0x...',
|
|
175
|
+
* initData: '0x...'
|
|
176
|
+
* });
|
|
177
|
+
*/
|
|
178
|
+
installModule(options: ModuleInstallOptions): Promise<SmartWalletTransactionResult>;
|
|
179
|
+
/**
|
|
180
|
+
* Uninstall a module from the smart account
|
|
181
|
+
*
|
|
182
|
+
* @param options - Module uninstallation options
|
|
183
|
+
* @returns Transaction result
|
|
184
|
+
*/
|
|
185
|
+
uninstallModule(options: ModuleUninstallOptions): Promise<SmartWalletTransactionResult>;
|
|
186
|
+
/**
|
|
187
|
+
* Check if a module is installed
|
|
188
|
+
*
|
|
189
|
+
* @param moduleType - Type of module
|
|
190
|
+
* @param moduleAddress - Module contract address
|
|
191
|
+
* @returns Whether the module is installed
|
|
192
|
+
*/
|
|
193
|
+
isModuleInstalled(moduleType: ModuleType, moduleAddress: Hex): Promise<boolean>;
|
|
194
|
+
/**
|
|
195
|
+
* Prepare module installation call (for batching)
|
|
196
|
+
*
|
|
197
|
+
* @param options - Module installation options
|
|
198
|
+
* @returns Call object for batch transaction
|
|
199
|
+
*/
|
|
200
|
+
prepareInstallModule(options: ModuleInstallOptions): Call;
|
|
201
|
+
/**
|
|
202
|
+
* Prepare module uninstallation call (for batching)
|
|
203
|
+
*
|
|
204
|
+
* @param options - Module uninstallation options
|
|
205
|
+
* @returns Call object for batch transaction
|
|
206
|
+
*/
|
|
207
|
+
prepareUninstallModule(options: ModuleUninstallOptions): Call;
|
|
208
|
+
/**
|
|
209
|
+
* Enable multi-signature validation
|
|
210
|
+
*
|
|
211
|
+
* @param config - Multi-sig configuration with owners and threshold
|
|
212
|
+
* @returns Transaction result
|
|
213
|
+
*
|
|
214
|
+
* @example
|
|
215
|
+
* await smartWallet.enableMultiSig({
|
|
216
|
+
* owners: [owner1, owner2, owner3],
|
|
217
|
+
* threshold: 2 // 2 of 3 required
|
|
218
|
+
* });
|
|
219
|
+
*/
|
|
220
|
+
enableMultiSig(config: MultiSigConfig): Promise<SmartWalletTransactionResult>;
|
|
221
|
+
/**
|
|
222
|
+
* Set paymaster for gas sponsorship
|
|
223
|
+
*
|
|
224
|
+
* @param paymasterUrl - Paymaster service URL
|
|
225
|
+
*
|
|
226
|
+
* @example
|
|
227
|
+
* smartWallet.setPaymaster('https://api.pimlico.io/v2/sepolia/paymaster');
|
|
228
|
+
*/
|
|
229
|
+
setPaymaster(paymasterUrl: string, context?: any): void;
|
|
230
|
+
/**
|
|
231
|
+
* Clear paymaster (user pays gas)
|
|
232
|
+
*/
|
|
233
|
+
clearPaymaster(): void;
|
|
234
|
+
/**
|
|
235
|
+
* Check if paymaster is configured
|
|
236
|
+
*/
|
|
237
|
+
hasPaymaster(): boolean;
|
|
238
|
+
/**
|
|
239
|
+
* Get bundler information
|
|
240
|
+
*/
|
|
241
|
+
getBundlerInfo(): {
|
|
242
|
+
provider: string;
|
|
243
|
+
url: string;
|
|
244
|
+
};
|
|
245
|
+
/**
|
|
246
|
+
* Send sponsored batch transaction where another wallet pays gas fees
|
|
247
|
+
* Requires smart wallet to be initialized
|
|
248
|
+
*
|
|
249
|
+
* @param calls - Array of calls to execute
|
|
250
|
+
* @param feePayerPrivateKey - Private key of the wallet paying gas fees
|
|
251
|
+
* @returns Transaction result with userOpHash and transactionHash
|
|
252
|
+
*
|
|
253
|
+
* @example
|
|
254
|
+
* // Send ETH transfer with sponsor paying gas
|
|
255
|
+
* const result = await smartWallet.sendSponsoredBatchTransaction(
|
|
256
|
+
* [{ to: recipient, value: parseEther('0.1') }],
|
|
257
|
+
* sponsorPrivateKey
|
|
258
|
+
* );
|
|
259
|
+
*/
|
|
260
|
+
sendSponsoredBatchTransaction(calls: Call[], feePayerPrivateKey: Hex): Promise<SmartWalletTransactionResult>;
|
|
261
|
+
/**
|
|
262
|
+
* Clear all caches
|
|
263
|
+
*/
|
|
264
|
+
clearCache(): void;
|
|
265
|
+
}
|