@deserialize/multi-vm-wallet 1.4.2 → 1.5.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.
Files changed (186) hide show
  1. package/.claude/settings.local.json +7 -1
  2. package/BUILD_OPTIMIZATION_PLAN.md +640 -0
  3. package/BUILD_RESULTS.md +282 -0
  4. package/BUN_MIGRATION.md +415 -0
  5. package/CHANGELOG_SECURITY.md +573 -0
  6. package/IMPLEMENTATION_SUMMARY.md +494 -0
  7. package/SECURITY_AUDIT.md +1124 -0
  8. package/bun.lock +553 -0
  9. package/dist/IChainWallet.js +0 -5
  10. package/dist/bip32Old.js +0 -885
  11. package/dist/bip32Small.js +0 -79
  12. package/dist/bipTest.js +0 -362
  13. package/dist/constant.js +0 -17
  14. package/dist/english.js +0 -1
  15. package/dist/evm/aa-service/index.d.ts +0 -5
  16. package/dist/evm/aa-service/index.js +0 -14
  17. package/dist/evm/aa-service/lib/account-adapter.d.ts +0 -22
  18. package/dist/evm/aa-service/lib/account-adapter.js +0 -24
  19. package/dist/evm/aa-service/lib/kernel-account.d.ts +0 -30
  20. package/dist/evm/aa-service/lib/kernel-account.js +2 -67
  21. package/dist/evm/aa-service/lib/kernel-modules.d.ts +0 -177
  22. package/dist/evm/aa-service/lib/kernel-modules.js +4 -202
  23. package/dist/evm/aa-service/lib/session-keys.d.ts +0 -118
  24. package/dist/evm/aa-service/lib/session-keys.js +7 -151
  25. package/dist/evm/aa-service/lib/type.d.ts +0 -55
  26. package/dist/evm/aa-service/lib/type.js +0 -10
  27. package/dist/evm/aa-service/services/account-abstraction.d.ts +0 -426
  28. package/dist/evm/aa-service/services/account-abstraction.js +0 -461
  29. package/dist/evm/aa-service/services/bundler.d.ts +0 -6
  30. package/dist/evm/aa-service/services/bundler.js +0 -54
  31. package/dist/evm/evm.d.ts +9 -51
  32. package/dist/evm/evm.js +338 -76
  33. package/dist/evm/index.js +0 -3
  34. package/dist/evm/script.js +3 -17
  35. package/dist/evm/smartWallet.d.ts +0 -173
  36. package/dist/evm/smartWallet.js +0 -206
  37. package/dist/evm/smartWallet.types.d.ts +0 -6
  38. package/dist/evm/smartWallet.types.js +0 -8
  39. package/dist/evm/transaction.utils.d.ts +0 -242
  40. package/dist/evm/transaction.utils.js +4 -320
  41. package/dist/evm/transactionParsing.d.ts +0 -11
  42. package/dist/evm/transactionParsing.js +28 -147
  43. package/dist/evm/utils.d.ts +0 -46
  44. package/dist/evm/utils.js +1 -57
  45. package/dist/helpers/index.d.ts +0 -4
  46. package/dist/helpers/index.js +8 -44
  47. package/dist/helpers/routeScan.js +0 -1
  48. package/dist/index.js +0 -1
  49. package/dist/old.js +0 -884
  50. package/dist/price.js +0 -1
  51. package/dist/price.types.js +0 -2
  52. package/dist/rate-limiter.d.ts +28 -0
  53. package/dist/rate-limiter.js +95 -0
  54. package/dist/retry-logic.d.ts +14 -0
  55. package/dist/retry-logic.js +120 -0
  56. package/dist/savings/index.js +0 -1
  57. package/dist/savings/saving-manager.d.ts +10 -11
  58. package/dist/savings/saving-manager.js +79 -22
  59. package/dist/savings/savings-operations.d.ts +39 -0
  60. package/dist/savings/savings-operations.js +141 -0
  61. package/dist/savings/smart-savings.d.ts +0 -63
  62. package/dist/savings/smart-savings.js +0 -78
  63. package/dist/savings/types.d.ts +0 -69
  64. package/dist/savings/types.js +0 -7
  65. package/dist/savings/validation.d.ts +9 -0
  66. package/dist/savings/validation.js +85 -0
  67. package/dist/svm/constant.js +0 -1
  68. package/dist/svm/index.js +0 -1
  69. package/dist/svm/svm.d.ts +11 -1
  70. package/dist/svm/svm.js +267 -27
  71. package/dist/svm/transactionParsing.d.ts +0 -7
  72. package/dist/svm/transactionParsing.js +3 -41
  73. package/dist/svm/transactionSender.js +0 -9
  74. package/dist/svm/utils.d.ts +0 -12
  75. package/dist/svm/utils.js +9 -60
  76. package/dist/test.d.ts +0 -4
  77. package/dist/test.js +6 -98
  78. package/dist/transaction-utils.d.ts +38 -0
  79. package/dist/transaction-utils.js +168 -0
  80. package/dist/types.d.ts +36 -0
  81. package/dist/types.js +0 -1
  82. package/dist/utils.js +0 -1
  83. package/dist/vm-validation.d.ts +11 -0
  84. package/dist/vm-validation.js +151 -0
  85. package/dist/vm.d.ts +12 -2
  86. package/dist/vm.js +61 -16
  87. package/dist/walletBip32.js +15 -70
  88. package/package.json +9 -4
  89. package/test-discovery.ts +235 -0
  90. package/test-pocket-discovery.ts +84 -0
  91. package/tsconfig.json +18 -11
  92. package/tsconfig.prod.json +10 -0
  93. package/utils/evm/evm.ts +554 -8
  94. package/utils/rate-limiter.ts +179 -0
  95. package/utils/retry-logic.ts +271 -0
  96. package/utils/savings/EXAMPLES.md +883 -0
  97. package/utils/savings/SECURITY.md +731 -0
  98. package/utils/savings/saving-manager.ts +526 -16
  99. package/utils/savings/savings-operations.ts +509 -0
  100. package/utils/savings/validation.ts +187 -0
  101. package/utils/svm/svm.ts +476 -5
  102. package/utils/test.ts +2 -2
  103. package/utils/transaction-utils.ts +394 -0
  104. package/utils/types.ts +100 -0
  105. package/utils/vm-validation.ts +280 -0
  106. package/utils/vm.ts +197 -10
  107. package/utils/walletBip32.ts +39 -3
  108. package/dist/IChainWallet.js.map +0 -1
  109. package/dist/bip32.d.ts +0 -9
  110. package/dist/bip32.js +0 -172
  111. package/dist/bip32.js.map +0 -1
  112. package/dist/bip32Old.js.map +0 -1
  113. package/dist/bip32Small.js.map +0 -1
  114. package/dist/bipTest.js.map +0 -1
  115. package/dist/constant.js.map +0 -1
  116. package/dist/english.js.map +0 -1
  117. package/dist/evm/SMART_WALLET_EXAMPLES.d.ts +0 -20
  118. package/dist/evm/SMART_WALLET_EXAMPLES.js +0 -451
  119. package/dist/evm/SMART_WALLET_EXAMPLES.js.map +0 -1
  120. package/dist/evm/aa-service/index.js.map +0 -1
  121. package/dist/evm/aa-service/lib/account-adapter.js.map +0 -1
  122. package/dist/evm/aa-service/lib/kernel-account.js.map +0 -1
  123. package/dist/evm/aa-service/lib/kernel-modules.js.map +0 -1
  124. package/dist/evm/aa-service/lib/session-keys.js.map +0 -1
  125. package/dist/evm/aa-service/lib/type.js.map +0 -1
  126. package/dist/evm/aa-service/services/account-abstraction.js.map +0 -1
  127. package/dist/evm/aa-service/services/bundler.js.map +0 -1
  128. package/dist/evm/evm.js.map +0 -1
  129. package/dist/evm/index.js.map +0 -1
  130. package/dist/evm/script.js.map +0 -1
  131. package/dist/evm/smartWallet.js.map +0 -1
  132. package/dist/evm/smartWallet.types.js.map +0 -1
  133. package/dist/evm/transaction.utils.js.map +0 -1
  134. package/dist/evm/transactionParsing.js.map +0 -1
  135. package/dist/evm/utils.js.map +0 -1
  136. package/dist/helpers/index.js.map +0 -1
  137. package/dist/helpers/routeScan.js.map +0 -1
  138. package/dist/index.js.map +0 -1
  139. package/dist/old.js.map +0 -1
  140. package/dist/price.js.map +0 -1
  141. package/dist/price.types.js.map +0 -1
  142. package/dist/privacy/artifact-manager.d.ts +0 -117
  143. package/dist/privacy/artifact-manager.js +0 -251
  144. package/dist/privacy/artifact-manager.js.map +0 -1
  145. package/dist/privacy/broadcaster-client.d.ts +0 -166
  146. package/dist/privacy/broadcaster-client.js +0 -261
  147. package/dist/privacy/broadcaster-client.js.map +0 -1
  148. package/dist/privacy/index.d.ts +0 -34
  149. package/dist/privacy/index.js +0 -56
  150. package/dist/privacy/index.js.map +0 -1
  151. package/dist/privacy/network-config.d.ts +0 -57
  152. package/dist/privacy/network-config.js +0 -118
  153. package/dist/privacy/network-config.js.map +0 -1
  154. package/dist/privacy/poi-helper.d.ts +0 -161
  155. package/dist/privacy/poi-helper.js +0 -249
  156. package/dist/privacy/poi-helper.js.map +0 -1
  157. package/dist/privacy/railgun-engine.d.ts +0 -135
  158. package/dist/privacy/railgun-engine.js +0 -205
  159. package/dist/privacy/railgun-engine.js.map +0 -1
  160. package/dist/privacy/railgun-privacy-wallet.d.ts +0 -288
  161. package/dist/privacy/railgun-privacy-wallet.js +0 -539
  162. package/dist/privacy/railgun-privacy-wallet.js.map +0 -1
  163. package/dist/privacy/types.d.ts +0 -229
  164. package/dist/privacy/types.js +0 -26
  165. package/dist/privacy/types.js.map +0 -1
  166. package/dist/savings/index.js.map +0 -1
  167. package/dist/savings/saving-actions.d.ts +0 -0
  168. package/dist/savings/saving-actions.js +0 -78
  169. package/dist/savings/saving-actions.js.map +0 -1
  170. package/dist/savings/saving-manager.js.map +0 -1
  171. package/dist/savings/savings-manager.d.ts +0 -126
  172. package/dist/savings/savings-manager.js +0 -234
  173. package/dist/savings/savings-manager.js.map +0 -1
  174. package/dist/savings/smart-savings.js.map +0 -1
  175. package/dist/savings/types.js.map +0 -1
  176. package/dist/svm/constant.js.map +0 -1
  177. package/dist/svm/index.js.map +0 -1
  178. package/dist/svm/svm.js.map +0 -1
  179. package/dist/svm/transactionParsing.js.map +0 -1
  180. package/dist/svm/transactionSender.js.map +0 -1
  181. package/dist/svm/utils.js.map +0 -1
  182. package/dist/test.js.map +0 -1
  183. package/dist/types.js.map +0 -1
  184. package/dist/utils.js.map +0 -1
  185. package/dist/vm.js.map +0 -1
  186. package/dist/walletBip32.js.map +0 -1
@@ -1,26 +1,8 @@
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
1
  import { Chain, Hex } from "viem";
8
2
  import { Balance } from "../types";
9
3
  import { SmartWalletOptions, SmartWalletTransactionResult, Call, SessionKeyInfo, SessionKeyPermissionRule, SessionKeyApprovalOptions, ModuleInstallOptions, ModuleUninstallOptions, MultiSigConfig, SmartAccountInfo, ModuleType } from "./smartWallet.types";
10
4
  import { AccountAbstractionService } from "./aa-service/services/account-abstraction";
11
5
  import type { KernelAccountInstance } from "./aa-service/lib/kernel-account";
12
- /**
13
- * EVMSmartWallet - Smart wallet capabilities for EVM chains
14
- *
15
- * Provides:
16
- * - EIP-7702 account delegation
17
- * - Batch transactions (pay gas once for multiple operations)
18
- * - Session keys with granular permissions
19
- * - Module management (validators, hooks, executors)
20
- * - Gas sponsorship (paymasters)
21
- * - Multi-signature support
22
- * - Account recovery
23
- */
24
6
  export declare class EVMSmartWallet {
25
7
  aaService: AccountAbstractionService | null;
26
8
  private kernelAccount;
@@ -29,186 +11,31 @@ export declare class EVMSmartWallet {
29
11
  private options;
30
12
  private paymasterConfig;
31
13
  constructor(privateKey: string, chain: Chain, options?: SmartWalletOptions);
32
- /**
33
- * Initialize the smart wallet
34
- * Creates the Kernel account and sets up delegation if needed
35
- */
36
14
  initialize(): Promise<EVMSmartWallet>;
37
- /**
38
- * Get the smart account address
39
- */
40
15
  getAddress(): Hex;
41
- /**
42
- * Get smart account information
43
- */
44
16
  getAccountInfo(): Promise<SmartAccountInfo>;
45
- /**
46
- * Get smart account balance
47
- */
48
17
  getBalance(): Promise<Balance>;
49
- /**
50
- * Check if account is delegated
51
- */
52
18
  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
19
  sendTransaction(to: Hex, value?: bigint, data?: Hex, options?: {
69
20
  sessionAccount: Omit<KernelAccountInstance, 'owner' | 'entryPoint' | 'chain'>;
70
21
  }): Promise<SmartWalletTransactionResult>;
71
- /**
72
- * Send multiple transactions in a single UserOperation
73
- * This is one of the main advantages of smart accounts - pay gas ONLY ONCE!
74
- *
75
- * @param calls - Array of calls to execute
76
- * @returns Transaction result
77
- *
78
- * @example
79
- * await smartWallet.sendBatchTransaction([
80
- * { to: recipient1, value: parseEther('0.1'), data: '0x' },
81
- * { to: recipient2, value: parseEther('0.2'), data: '0x' },
82
- * { to: usdcAddress, value: 0n, data: transferCalldata }
83
- * ]);
84
- */
85
22
  sendBatchTransaction(calls: Call[], options?: {
86
23
  sessionAccount: KernelAccountInstance;
87
24
  }): Promise<SmartWalletTransactionResult>;
88
- /**
89
- * Prepare a call for batching
90
- * Helper method to create Call objects
91
- */
92
25
  prepareCall(to: Hex, value?: bigint, data?: Hex): Call;
93
- /**
94
- * Generate a new session key
95
- * The private key should be stored securely by the agent
96
- *
97
- * @returns Session key info with private key, address, and signer
98
- *
99
- * @example
100
- * const sessionKey = await smartWallet.generateSessionKey();
101
- * console.log('Address:', sessionKey.address);
102
- * // Store sessionKey.privateKey securely
103
- */
104
26
  generateSessionKey(): Promise<SessionKeyInfo>;
105
- /**
106
- * Create session key approval (Owner side)
107
- * Owner approves a session key with specific permissions
108
- *
109
- * @param options - Approval options with session key address and permissions
110
- * @returns Serialized approval string to share with agent
111
- *
112
- * @example
113
- * const approval = await smartWallet.approveSessionKey({
114
- * sessionKeyAddress: '0x...',
115
- * permissions: [
116
- * smartWallet.createUSDCPermission(USDC_ADDRESS, '100')
117
- * ]
118
- * });
119
- */
120
27
  approveSessionKey(options: SessionKeyApprovalOptions): Promise<string>;
121
- /**
122
- * Create USDC transfer permission
123
- *
124
- * @param usdcAddress - USDC contract address
125
- * @param maxAmount - Maximum USDC amount (in USDC units, e.g., "10" for 10 USDC)
126
- * @returns Permission rule
127
- */
128
28
  createUSDCPermission(usdcAddress: Hex, maxAmount: string, destinationAddress: Hex): SessionKeyPermissionRule;
129
- /**
130
- * Create ETH transfer permission
131
- *
132
- * @param maxValue - Maximum ETH value (in ether units, e.g., "0.1" for 0.1 ETH)
133
- * @returns Permission rule
134
- */
135
29
  createETHPermission(maxValue: string): SessionKeyPermissionRule;
136
- /**
137
- * Install a module on the smart account
138
- *
139
- * @param options - Module installation options
140
- * @returns Transaction result
141
- *
142
- * @example
143
- * await smartWallet.installModule({
144
- * moduleType: 'validator',
145
- * moduleAddress: '0x...',
146
- * initData: '0x...'
147
- * });
148
- */
149
30
  installModule(options: ModuleInstallOptions): Promise<SmartWalletTransactionResult>;
150
- /**
151
- * Uninstall a module from the smart account
152
- *
153
- * @param options - Module uninstallation options
154
- * @returns Transaction result
155
- */
156
31
  uninstallModule(options: ModuleUninstallOptions): Promise<SmartWalletTransactionResult>;
157
- /**
158
- * Check if a module is installed
159
- *
160
- * @param moduleType - Type of module
161
- * @param moduleAddress - Module contract address
162
- * @returns Whether the module is installed
163
- */
164
32
  isModuleInstalled(moduleType: ModuleType, moduleAddress: Hex): Promise<boolean>;
165
- /**
166
- * Prepare module installation call (for batching)
167
- *
168
- * @param options - Module installation options
169
- * @returns Call object for batch transaction
170
- */
171
33
  prepareInstallModule(options: ModuleInstallOptions): Call;
172
- /**
173
- * Prepare module uninstallation call (for batching)
174
- *
175
- * @param options - Module uninstallation options
176
- * @returns Call object for batch transaction
177
- */
178
34
  prepareUninstallModule(options: ModuleUninstallOptions): Call;
179
- /**
180
- * Enable multi-signature validation
181
- *
182
- * @param config - Multi-sig configuration with owners and threshold
183
- * @returns Transaction result
184
- *
185
- * @example
186
- * await smartWallet.enableMultiSig({
187
- * owners: [owner1, owner2, owner3],
188
- * threshold: 2 // 2 of 3 required
189
- * });
190
- */
191
35
  enableMultiSig(config: MultiSigConfig): Promise<SmartWalletTransactionResult>;
192
- /**
193
- * Set paymaster for gas sponsorship
194
- *
195
- * @param paymasterUrl - Paymaster service URL
196
- *
197
- * @example
198
- * smartWallet.setPaymaster('https://api.pimlico.io/v2/sepolia/paymaster');
199
- */
200
36
  setPaymaster(paymasterUrl: string, context?: any): void;
201
- /**
202
- * Clear paymaster (user pays gas)
203
- */
204
37
  clearPaymaster(): void;
205
- /**
206
- * Check if paymaster is configured
207
- */
208
38
  hasPaymaster(): boolean;
209
- /**
210
- * Get bundler information
211
- */
212
39
  getBundlerInfo(): {
213
40
  provider: string;
214
41
  url: string;
@@ -1,10 +1,4 @@
1
1
  "use strict";
2
- /**
3
- * EVM Smart Wallet Implementation
4
- *
5
- * Provides Account Abstraction (EIP-4337) and EIP-7702 capabilities to EVMChainWallet.
6
- * This class wraps the AA service and provides a clean API for smart wallet features.
7
- */
8
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
3
  if (k2 === undefined) k2 = k;
10
4
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -42,20 +36,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
42
36
  exports.EVMSmartWallet = void 0;
43
37
  const accounts_1 = require("viem/accounts");
44
38
  const smartWallet_types_1 = require("./smartWallet.types");
45
- // Import AA service from local aa-service
46
39
  const account_abstraction_1 = require("./aa-service/services/account-abstraction");
47
- /**
48
- * EVMSmartWallet - Smart wallet capabilities for EVM chains
49
- *
50
- * Provides:
51
- * - EIP-7702 account delegation
52
- * - Batch transactions (pay gas once for multiple operations)
53
- * - Session keys with granular permissions
54
- * - Module management (validators, hooks, executors)
55
- * - Gas sponsorship (paymasters)
56
- * - Multi-signature support
57
- * - Account recovery
58
- */
59
40
  class EVMSmartWallet {
60
41
  aaService = null;
61
42
  kernelAccount = null;
@@ -71,29 +52,19 @@ class EVMSmartWallet {
71
52
  autoInitialize: true,
72
53
  ...options
73
54
  };
74
- // Set paymaster if provided
75
55
  if (options.paymasterUrl) {
76
56
  this.paymasterConfig = {
77
57
  paymasterUrl: options.paymasterUrl
78
58
  };
79
59
  }
80
60
  }
81
- // ============================================
82
- // Core Methods
83
- // ============================================
84
- /**
85
- * Initialize the smart wallet
86
- * Creates the Kernel account and sets up delegation if needed
87
- */
88
61
  async initialize() {
89
62
  try {
90
- // Initialize AA service singleton with AA config
91
63
  this.aaService = account_abstraction_1.AccountAbstractionService.getInstance({
92
64
  bundlerProvider: 'pimlico',
93
65
  customBundlerUrl: this.options.bundlerUrl,
94
66
  aaConfig: this.options.aaConfig
95
67
  });
96
- // Create Kernel account
97
68
  this.kernelAccount = await this.aaService.createAccount({
98
69
  chain: this.chain,
99
70
  owner: this.ownerAccount,
@@ -107,18 +78,12 @@ class EVMSmartWallet {
107
78
  throw new smartWallet_types_1.SmartWalletError(`Failed to initialize smart wallet: ${error instanceof Error ? error.message : 'Unknown error'}`, 'INIT_ERROR');
108
79
  }
109
80
  }
110
- /**
111
- * Get the smart account address
112
- */
113
81
  getAddress() {
114
82
  if (!this.kernelAccount) {
115
83
  throw new smartWallet_types_1.SmartWalletError('Smart wallet not initialized', 'NOT_INITIALIZED');
116
84
  }
117
85
  return this.kernelAccount.address;
118
86
  }
119
- /**
120
- * Get smart account information
121
- */
122
87
  async getAccountInfo() {
123
88
  if (!this.kernelAccount || !this.aaService) {
124
89
  throw new smartWallet_types_1.SmartWalletError('Smart wallet not initialized', 'NOT_INITIALIZED');
@@ -134,9 +99,6 @@ class EVMSmartWallet {
134
99
  balance: BigInt(balance.balance.toString())
135
100
  };
136
101
  }
137
- /**
138
- * Get smart account balance
139
- */
140
102
  async getBalance() {
141
103
  if (!this.kernelAccount || !this.aaService) {
142
104
  throw new smartWallet_types_1.SmartWalletError('Smart wallet not initialized', 'NOT_INITIALIZED');
@@ -148,48 +110,24 @@ class EVMSmartWallet {
148
110
  formatted: Number(balance) / 1e18
149
111
  };
150
112
  }
151
- /**
152
- * Check if account is delegated
153
- */
154
113
  async isAccountDelegated() {
155
114
  if (!this.aaService) {
156
115
  throw new smartWallet_types_1.SmartWalletError('Smart wallet not initialized', 'NOT_INITIALIZED');
157
116
  }
158
117
  return await this.aaService.isAccountDelegated(this.ownerAccount, this.chain);
159
118
  }
160
- // ============================================
161
- // Transaction Methods
162
- // ============================================
163
- /**
164
- * Send a single transaction via UserOperation
165
- *
166
- * @param to - Recipient address
167
- * @param value - ETH value in wei
168
- * @param data - Optional calldata
169
- * @returns Transaction result with UserOp hash
170
- *
171
- * @example
172
- * await smartWallet.sendTransaction(
173
- * '0xRecipient',
174
- * parseEther('0.1'),
175
- * '0x'
176
- * );
177
- */
178
119
  async sendTransaction(to, value = 0n, data = '0x', options) {
179
120
  if (!this.kernelAccount || !this.aaService) {
180
121
  throw new smartWallet_types_1.SmartWalletError('Smart wallet not initialized', 'NOT_INITIALIZED');
181
122
  }
182
123
  try {
183
- // Use session account if available and requested
184
124
  if (options?.sessionAccount) {
185
- // Session keys use kernel account client, not bundler client
186
125
  const { createSessionKeyClient } = await Promise.resolve().then(() => __importStar(require('./aa-service/lib/session-keys')));
187
126
  const kernelClient = createSessionKeyClient({
188
127
  account: options.sessionAccount.account,
189
128
  chain: this.chain,
190
129
  bundlerUrl: this.options.bundlerUrl,
191
130
  });
192
- // Use kernel client to send transaction
193
131
  const userOpHash = await kernelClient.sendUserOperation({
194
132
  callData: await options.sessionAccount.account.encodeCalls([{
195
133
  to,
@@ -197,7 +135,6 @@ class EVMSmartWallet {
197
135
  data
198
136
  }])
199
137
  });
200
- // Wait for receipt
201
138
  const receipt = await kernelClient.waitForUserOperationReceipt({
202
139
  hash: userOpHash
203
140
  });
@@ -208,14 +145,12 @@ class EVMSmartWallet {
208
145
  };
209
146
  }
210
147
  else {
211
- // Use regular kernel account with AA service
212
148
  const userOpHash = await this.aaService.sendTransaction({
213
149
  account: this.kernelAccount,
214
150
  to,
215
151
  value,
216
152
  data
217
153
  });
218
- // Wait for receipt
219
154
  const receipt = await this.aaService.waitForReceipt({
220
155
  userOpHash,
221
156
  chain: this.chain
@@ -237,20 +172,6 @@ class EVMSmartWallet {
237
172
  };
238
173
  }
239
174
  }
240
- /**
241
- * Send multiple transactions in a single UserOperation
242
- * This is one of the main advantages of smart accounts - pay gas ONLY ONCE!
243
- *
244
- * @param calls - Array of calls to execute
245
- * @returns Transaction result
246
- *
247
- * @example
248
- * await smartWallet.sendBatchTransaction([
249
- * { to: recipient1, value: parseEther('0.1'), data: '0x' },
250
- * { to: recipient2, value: parseEther('0.2'), data: '0x' },
251
- * { to: usdcAddress, value: 0n, data: transferCalldata }
252
- * ]);
253
- */
254
175
  async sendBatchTransaction(calls, options) {
255
176
  if (!this.kernelAccount || !this.aaService) {
256
177
  throw new smartWallet_types_1.SmartWalletError('Smart wallet not initialized', 'NOT_INITIALIZED');
@@ -259,15 +180,12 @@ class EVMSmartWallet {
259
180
  throw new smartWallet_types_1.TransactionError('Batch transaction must have at least one call');
260
181
  }
261
182
  try {
262
- // Convert to proper Call format
263
183
  const normalizedCalls = calls.map(call => ({
264
184
  to: call.to,
265
185
  value: call.value ?? 0n,
266
186
  data: call.data ?? '0x'
267
187
  }));
268
- // Use session account if available
269
188
  if (options?.sessionAccount) {
270
- // Session keys use kernel account client
271
189
  const { createSessionKeyClient } = await Promise.resolve().then(() => __importStar(require('./aa-service/lib/session-keys')));
272
190
  const kernelClient = createSessionKeyClient({
273
191
  account: options.sessionAccount.account,
@@ -275,11 +193,9 @@ class EVMSmartWallet {
275
193
  bundlerUrl: this.options.bundlerUrl,
276
194
  entryPoint: options.sessionAccount.entryPoint
277
195
  });
278
- // Use kernel client to send batch transaction
279
196
  const userOpHash = await kernelClient.sendUserOperation({
280
197
  callData: await options.sessionAccount.account.encodeCalls(normalizedCalls)
281
198
  });
282
- // Wait for receipt
283
199
  const receipt = await kernelClient.waitForUserOperationReceipt({
284
200
  hash: userOpHash
285
201
  });
@@ -290,7 +206,6 @@ class EVMSmartWallet {
290
206
  };
291
207
  }
292
208
  else {
293
- // Use regular kernel account with AA service
294
209
  const aaCalls = normalizedCalls.map(call => ({
295
210
  to: call.to,
296
211
  value: call.value,
@@ -300,7 +215,6 @@ class EVMSmartWallet {
300
215
  account: this.kernelAccount,
301
216
  calls: aaCalls
302
217
  });
303
- // Wait for receipt
304
218
  const receipt = await this.aaService.waitForReceipt({
305
219
  userOpHash,
306
220
  chain: this.chain
@@ -321,27 +235,9 @@ class EVMSmartWallet {
321
235
  };
322
236
  }
323
237
  }
324
- /**
325
- * Prepare a call for batching
326
- * Helper method to create Call objects
327
- */
328
238
  prepareCall(to, value = 0n, data = '0x') {
329
239
  return { to, value, data };
330
240
  }
331
- // ============================================
332
- // Session Key Methods
333
- // ============================================
334
- /**
335
- * Generate a new session key
336
- * The private key should be stored securely by the agent
337
- *
338
- * @returns Session key info with private key, address, and signer
339
- *
340
- * @example
341
- * const sessionKey = await smartWallet.generateSessionKey();
342
- * console.log('Address:', sessionKey.address);
343
- * // Store sessionKey.privateKey securely
344
- */
345
241
  async generateSessionKey() {
346
242
  if (!this.aaService) {
347
243
  throw new smartWallet_types_1.SmartWalletError('Smart wallet not initialized', 'NOT_INITIALIZED');
@@ -353,21 +249,6 @@ class EVMSmartWallet {
353
249
  throw new smartWallet_types_1.SessionKeyError(`Failed to generate session key: ${error instanceof Error ? error.message : 'Unknown error'}`);
354
250
  }
355
251
  }
356
- /**
357
- * Create session key approval (Owner side)
358
- * Owner approves a session key with specific permissions
359
- *
360
- * @param options - Approval options with session key address and permissions
361
- * @returns Serialized approval string to share with agent
362
- *
363
- * @example
364
- * const approval = await smartWallet.approveSessionKey({
365
- * sessionKeyAddress: '0x...',
366
- * permissions: [
367
- * smartWallet.createUSDCPermission(USDC_ADDRESS, '100')
368
- * ]
369
- * });
370
- */
371
252
  async approveSessionKey(options) {
372
253
  if (!this.aaService) {
373
254
  throw new smartWallet_types_1.SmartWalletError('Smart wallet not initialized', 'NOT_INITIALIZED');
@@ -387,47 +268,18 @@ class EVMSmartWallet {
387
268
  throw new smartWallet_types_1.SessionKeyError(`Failed to approve session key: ${error instanceof Error ? error.message : 'Unknown error'}`);
388
269
  }
389
270
  }
390
- /**
391
- * Create USDC transfer permission
392
- *
393
- * @param usdcAddress - USDC contract address
394
- * @param maxAmount - Maximum USDC amount (in USDC units, e.g., "10" for 10 USDC)
395
- * @returns Permission rule
396
- */
397
271
  createUSDCPermission(usdcAddress, maxAmount, destinationAddress) {
398
272
  if (!this.aaService) {
399
273
  throw new smartWallet_types_1.SmartWalletError('Smart wallet not initialized', 'NOT_INITIALIZED');
400
274
  }
401
275
  return this.aaService.createUSDCTransferPermission(usdcAddress, maxAmount, destinationAddress);
402
276
  }
403
- /**
404
- * Create ETH transfer permission
405
- *
406
- * @param maxValue - Maximum ETH value (in ether units, e.g., "0.1" for 0.1 ETH)
407
- * @returns Permission rule
408
- */
409
277
  createETHPermission(maxValue) {
410
278
  if (!this.aaService) {
411
279
  throw new smartWallet_types_1.SmartWalletError('Smart wallet not initialized', 'NOT_INITIALIZED');
412
280
  }
413
281
  return this.aaService.createETHTransferPermission(maxValue);
414
282
  }
415
- // ============================================
416
- // Module Management Methods
417
- // ============================================
418
- /**
419
- * Install a module on the smart account
420
- *
421
- * @param options - Module installation options
422
- * @returns Transaction result
423
- *
424
- * @example
425
- * await smartWallet.installModule({
426
- * moduleType: 'validator',
427
- * moduleAddress: '0x...',
428
- * initData: '0x...'
429
- * });
430
- */
431
283
  async installModule(options) {
432
284
  if (!this.kernelAccount || !this.aaService) {
433
285
  throw new smartWallet_types_1.SmartWalletError('Smart wallet not initialized', 'NOT_INITIALIZED');
@@ -454,12 +306,6 @@ class EVMSmartWallet {
454
306
  throw new smartWallet_types_1.ModuleError(`Failed to install module: ${errorMsg}`);
455
307
  }
456
308
  }
457
- /**
458
- * Uninstall a module from the smart account
459
- *
460
- * @param options - Module uninstallation options
461
- * @returns Transaction result
462
- */
463
309
  async uninstallModule(options) {
464
310
  if (!this.kernelAccount || !this.aaService) {
465
311
  throw new smartWallet_types_1.SmartWalletError('Smart wallet not initialized', 'NOT_INITIALIZED');
@@ -486,13 +332,6 @@ class EVMSmartWallet {
486
332
  throw new smartWallet_types_1.ModuleError(`Failed to uninstall module: ${errorMsg}`);
487
333
  }
488
334
  }
489
- /**
490
- * Check if a module is installed
491
- *
492
- * @param moduleType - Type of module
493
- * @param moduleAddress - Module contract address
494
- * @returns Whether the module is installed
495
- */
496
335
  async isModuleInstalled(moduleType, moduleAddress) {
497
336
  if (!this.kernelAccount || !this.aaService) {
498
337
  throw new smartWallet_types_1.SmartWalletError('Smart wallet not initialized', 'NOT_INITIALIZED');
@@ -508,12 +347,6 @@ class EVMSmartWallet {
508
347
  return false;
509
348
  }
510
349
  }
511
- /**
512
- * Prepare module installation call (for batching)
513
- *
514
- * @param options - Module installation options
515
- * @returns Call object for batch transaction
516
- */
517
350
  prepareInstallModule(options) {
518
351
  if (!this.kernelAccount || !this.aaService) {
519
352
  throw new smartWallet_types_1.SmartWalletError('Smart wallet not initialized', 'NOT_INITIALIZED');
@@ -530,12 +363,6 @@ class EVMSmartWallet {
530
363
  data: aaCall.data
531
364
  };
532
365
  }
533
- /**
534
- * Prepare module uninstallation call (for batching)
535
- *
536
- * @param options - Module uninstallation options
537
- * @returns Call object for batch transaction
538
- */
539
366
  prepareUninstallModule(options) {
540
367
  if (!this.kernelAccount || !this.aaService) {
541
368
  throw new smartWallet_types_1.SmartWalletError('Smart wallet not initialized', 'NOT_INITIALIZED');
@@ -552,21 +379,6 @@ class EVMSmartWallet {
552
379
  data: aaCall.data
553
380
  };
554
381
  }
555
- // ============================================
556
- // Advanced Features
557
- // ============================================
558
- /**
559
- * Enable multi-signature validation
560
- *
561
- * @param config - Multi-sig configuration with owners and threshold
562
- * @returns Transaction result
563
- *
564
- * @example
565
- * await smartWallet.enableMultiSig({
566
- * owners: [owner1, owner2, owner3],
567
- * threshold: 2 // 2 of 3 required
568
- * });
569
- */
570
382
  async enableMultiSig(config) {
571
383
  if (!this.kernelAccount || !this.aaService) {
572
384
  throw new smartWallet_types_1.SmartWalletError('Smart wallet not initialized', 'NOT_INITIALIZED');
@@ -592,35 +404,18 @@ class EVMSmartWallet {
592
404
  throw new smartWallet_types_1.SmartWalletError(`Failed to enable multi-sig: ${errorMsg}`, 'MULTISIG_ERROR');
593
405
  }
594
406
  }
595
- /**
596
- * Set paymaster for gas sponsorship
597
- *
598
- * @param paymasterUrl - Paymaster service URL
599
- *
600
- * @example
601
- * smartWallet.setPaymaster('https://api.pimlico.io/v2/sepolia/paymaster');
602
- */
603
407
  setPaymaster(paymasterUrl, context) {
604
408
  this.paymasterConfig = {
605
409
  paymasterUrl,
606
410
  context
607
411
  };
608
412
  }
609
- /**
610
- * Clear paymaster (user pays gas)
611
- */
612
413
  clearPaymaster() {
613
414
  this.paymasterConfig = null;
614
415
  }
615
- /**
616
- * Check if paymaster is configured
617
- */
618
416
  hasPaymaster() {
619
417
  return this.paymasterConfig !== null;
620
418
  }
621
- /**
622
- * Get bundler information
623
- */
624
419
  getBundlerInfo() {
625
420
  if (!this.aaService) {
626
421
  return {
@@ -632,4 +427,3 @@ class EVMSmartWallet {
632
427
  }
633
428
  }
634
429
  exports.EVMSmartWallet = EVMSmartWallet;
635
- //# sourceMappingURL=smartWallet.js.map
@@ -1,9 +1,3 @@
1
- /**
2
- * Smart Wallet Types (Re-exports from aa-service)
3
- *
4
- * This file re-exports types from the AA service for backwards compatibility
5
- * and cleaner imports in smartWallet.ts
6
- */
7
1
  export type { SmartWalletOptions, SmartWalletTransactionResult, Call, SessionKeyApprovalOptions, SessionKeyUsageOptions, ModuleInstallOptions, ModuleUninstallOptions, MultiSigConfig, RecoveryConfig, PaymasterConfig, SmartAccountInfo, EntryPointVersion, KernelVersion } from './aa-service/lib/type';
8
2
  export { SmartWalletError, SessionKeyError, ModuleError, TransactionError } from './aa-service/lib/type';
9
3
  export type { ModuleType } from './aa-service/lib/kernel-modules';
@@ -1,16 +1,8 @@
1
1
  "use strict";
2
- /**
3
- * Smart Wallet Types (Re-exports from aa-service)
4
- *
5
- * This file re-exports types from the AA service for backwards compatibility
6
- * and cleaner imports in smartWallet.ts
7
- */
8
2
  Object.defineProperty(exports, "__esModule", { value: true });
9
3
  exports.TransactionError = exports.ModuleError = exports.SessionKeyError = exports.SmartWalletError = void 0;
10
- // Export error classes (not as types, as actual classes)
11
4
  var type_1 = require("./aa-service/lib/type");
12
5
  Object.defineProperty(exports, "SmartWalletError", { enumerable: true, get: function () { return type_1.SmartWalletError; } });
13
6
  Object.defineProperty(exports, "SessionKeyError", { enumerable: true, get: function () { return type_1.SessionKeyError; } });
14
7
  Object.defineProperty(exports, "ModuleError", { enumerable: true, get: function () { return type_1.ModuleError; } });
15
8
  Object.defineProperty(exports, "TransactionError", { enumerable: true, get: function () { return type_1.TransactionError; } });
16
- //# sourceMappingURL=smartWallet.types.js.map