@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,74 +1,11 @@
1
- /**
2
- * Smart Savings Manager
3
- *
4
- * Handles upgrading savings accounts to EIP-7702 smart accounts.
5
- * Enables advanced features like locked savings, spend & save, and periodic savings.
6
- *
7
- * Architecture:
8
- * 1. Take a basic SavingsAccount (BIP-44 derived)
9
- * 2. Create an EVMSmartWallet instance from its private key
10
- * 3. Initialize with EIP-7702 delegation
11
- * 4. Return a SmartSavingsAccount with full AA capabilities
12
- */
13
1
  import { SmartWalletOptions } from "../evm/aa-service";
14
2
  import { ChainWalletConfig } from "../types";
15
3
  import { SavingsAccount, SmartSavingsAccount } from "./types";
16
- /**
17
- * Manages EIP-7702 smart savings accounts
18
- *
19
- * This class provides:
20
- * 1. Upgrade from basic savings account to smart account
21
- * 2. Full Account Abstraction capabilities
22
- * 3. Access to Kernel modules (lock, hooks, session keys)
23
- * 4. Sponsored transactions via paymaster
24
- */
25
4
  export declare class SmartSavingsManager {
26
5
  private chainConfig;
27
6
  constructor(chainConfig: ChainWalletConfig);
28
- /**
29
- * Upgrade a savings account to a smart account with EIP-7702 delegation
30
- *
31
- * This enables advanced features:
32
- * - Lock modules for time-locked savings
33
- * - Hooks for spend & save
34
- * - Session keys for periodic savings
35
- * - Sponsored transactions via paymaster
36
- *
37
- * @param savingsAccount - The basic savings account to upgrade
38
- * @param options - Optional smart wallet configuration
39
- * @returns SmartSavingsAccount with EVMSmartWallet instance
40
- *
41
- * @example
42
- * const basicSavings = wallet.deriveSavingsAccount(1);
43
- * const smartSavings = await smartSavingsManager.upgradeSavingsToSmartAccount(basicSavings);
44
- * await smartSavings.smartWallet.installModule({ ... });
45
- */
46
7
  upgradeSavingsToSmartAccount(savingsAccount: SavingsAccount, options?: SmartWalletOptions): Promise<SmartSavingsAccount>;
47
- /**
48
- * Upgrade and initialize a savings account in one step
49
- *
50
- * This is a convenience method that both upgrades and initializes.
51
- *
52
- * @param savingsAccount - The basic savings account to upgrade
53
- * @param options - Optional smart wallet configuration
54
- * @returns Initialized SmartSavingsAccount ready for transactions
55
- *
56
- * @example
57
- * const basicSavings = wallet.deriveSavingsAccount(1);
58
- * const smartSavings = await smartSavingsManager.upgradeSavingsAndInitialize(basicSavings);
59
- * // smartSavings is now ready for smart transactions
60
- */
61
8
  upgradeSavingsAndInitialize(savingsAccount: SavingsAccount, options?: SmartWalletOptions): Promise<SmartSavingsAccount>;
62
- /**
63
- * Check if a savings account can be upgraded to smart account
64
- *
65
- * @returns true if chain supports AA and has required configuration
66
- */
67
9
  canUpgradeToSmartAccount(): boolean;
68
- /**
69
- * Get the chain configuration
70
- *
71
- * @returns ChainWalletConfig
72
- */
73
10
  getChainConfig(): ChainWalletConfig;
74
11
  }
@@ -1,36 +1,11 @@
1
1
  "use strict";
2
- /**
3
- * Smart Savings Manager
4
- *
5
- * Handles upgrading savings accounts to EIP-7702 smart accounts.
6
- * Enables advanced features like locked savings, spend & save, and periodic savings.
7
- *
8
- * Architecture:
9
- * 1. Take a basic SavingsAccount (BIP-44 derived)
10
- * 2. Create an EVMSmartWallet instance from its private key
11
- * 3. Initialize with EIP-7702 delegation
12
- * 4. Return a SmartSavingsAccount with full AA capabilities
13
- */
14
2
  Object.defineProperty(exports, "__esModule", { value: true });
15
3
  exports.SmartSavingsManager = void 0;
16
4
  const smartWallet_1 = require("../evm/smartWallet");
17
- // ============================================
18
- // SmartSavingsManager Class
19
- // ============================================
20
- /**
21
- * Manages EIP-7702 smart savings accounts
22
- *
23
- * This class provides:
24
- * 1. Upgrade from basic savings account to smart account
25
- * 2. Full Account Abstraction capabilities
26
- * 3. Access to Kernel modules (lock, hooks, session keys)
27
- * 4. Sponsored transactions via paymaster
28
- */
29
5
  class SmartSavingsManager {
30
6
  chainConfig;
31
7
  constructor(chainConfig) {
32
8
  this.chainConfig = chainConfig;
33
- // Validate AA support
34
9
  if (!chainConfig.aaSupport?.enabled) {
35
10
  throw new Error("Smart savings requires Account Abstraction (AA) support.\n" +
36
11
  "Your chain config must include aaSupport configuration with:\n" +
@@ -39,26 +14,7 @@ class SmartSavingsManager {
39
14
  "- kernelImplementations");
40
15
  }
41
16
  }
42
- /**
43
- * Upgrade a savings account to a smart account with EIP-7702 delegation
44
- *
45
- * This enables advanced features:
46
- * - Lock modules for time-locked savings
47
- * - Hooks for spend & save
48
- * - Session keys for periodic savings
49
- * - Sponsored transactions via paymaster
50
- *
51
- * @param savingsAccount - The basic savings account to upgrade
52
- * @param options - Optional smart wallet configuration
53
- * @returns SmartSavingsAccount with EVMSmartWallet instance
54
- *
55
- * @example
56
- * const basicSavings = wallet.deriveSavingsAccount(1);
57
- * const smartSavings = await smartSavingsManager.upgradeSavingsToSmartAccount(basicSavings);
58
- * await smartSavings.smartWallet.installModule({ ... });
59
- */
60
17
  async upgradeSavingsToSmartAccount(savingsAccount, options) {
61
- // Merge options with chain config
62
18
  const mergedOptions = {
63
19
  ...options,
64
20
  aaConfig: this.chainConfig.aaSupport,
@@ -66,12 +22,10 @@ class SmartSavingsManager {
66
22
  paymasterUrl: options?.paymasterUrl || this.chainConfig.aaSupport?.paymasterUrl,
67
23
  entryPointVersion: options?.entryPointVersion || this.chainConfig.aaSupport?.entryPoints?.[0]?.version
68
24
  };
69
- // Validate bundlerUrl
70
25
  if (!mergedOptions.bundlerUrl) {
71
26
  throw new Error("bundlerUrl is required for smart savings.\n" +
72
27
  "Provide it via upgradeSavingsToSmartAccount options or chain config.");
73
28
  }
74
- // Create viem chain object
75
29
  const chain = {
76
30
  id: this.chainConfig.chainId,
77
31
  name: this.chainConfig.name,
@@ -93,11 +47,7 @@ class SmartSavingsManager {
93
47
  },
94
48
  testnet: this.chainConfig.testnet || false
95
49
  };
96
- // Create EVMSmartWallet instance from savings account private key
97
50
  const smartWallet = new smartWallet_1.EVMSmartWallet(savingsAccount.privateKey, chain, mergedOptions);
98
- // Note: Initialization (createAuthorization) is optional
99
- // User can call smartWallet.initialize() separately if needed
100
- // For now, we return uninitialized smart wallet
101
51
  const isInitialized = false;
102
52
  return {
103
53
  ...savingsAccount,
@@ -105,48 +55,20 @@ class SmartSavingsManager {
105
55
  isInitialized
106
56
  };
107
57
  }
108
- /**
109
- * Upgrade and initialize a savings account in one step
110
- *
111
- * This is a convenience method that both upgrades and initializes.
112
- *
113
- * @param savingsAccount - The basic savings account to upgrade
114
- * @param options - Optional smart wallet configuration
115
- * @returns Initialized SmartSavingsAccount ready for transactions
116
- *
117
- * @example
118
- * const basicSavings = wallet.deriveSavingsAccount(1);
119
- * const smartSavings = await smartSavingsManager.upgradeSavingsAndInitialize(basicSavings);
120
- * // smartSavings is now ready for smart transactions
121
- */
122
58
  async upgradeSavingsAndInitialize(savingsAccount, options) {
123
- // First upgrade
124
59
  const smartSavings = await this.upgradeSavingsToSmartAccount(savingsAccount, options);
125
- // Then initialize
126
60
  await smartSavings.smartWallet.initialize();
127
- // Update initialization status
128
61
  smartSavings.isInitialized = true;
129
62
  return smartSavings;
130
63
  }
131
- /**
132
- * Check if a savings account can be upgraded to smart account
133
- *
134
- * @returns true if chain supports AA and has required configuration
135
- */
136
64
  canUpgradeToSmartAccount() {
137
65
  return !!(this.chainConfig.aaSupport?.enabled &&
138
66
  this.chainConfig.aaSupport?.bundlerUrl &&
139
67
  this.chainConfig.aaSupport?.entryPoints &&
140
68
  this.chainConfig.aaSupport?.entryPoints.length > 0);
141
69
  }
142
- /**
143
- * Get the chain configuration
144
- *
145
- * @returns ChainWalletConfig
146
- */
147
70
  getChainConfig() {
148
71
  return this.chainConfig;
149
72
  }
150
73
  }
151
74
  exports.SmartSavingsManager = SmartSavingsManager;
152
- //# sourceMappingURL=smart-savings.js.map
@@ -1,125 +1,56 @@
1
- /**
2
- * Savings Pocket Types
3
- *
4
- * Type definitions for the savings pocket feature that allows users to create
5
- * multiple savings accounts derived from their seed phrase using BIP-44 account indices.
6
- */
7
1
  import { Hex } from "viem";
8
2
  import { EVMSmartWallet } from "../evm/smartWallet";
9
- /**
10
- * Savings account derived from BIP-44 account index
11
- */
12
3
  export interface SavingsAccount {
13
- /** Account index used for derivation (m/44'/60'/accountIndex'/0/0) */
14
4
  accountIndex: number;
15
- /** Derived private key for this savings account */
16
5
  privateKey: Hex;
17
- /** Derived address for this savings account */
18
6
  address: Hex;
19
- /** Full BIP-44 derivation path */
20
7
  derivationPath: string;
21
8
  }
22
- /**
23
- * Savings account upgraded to EIP-7702 smart account
24
- */
25
9
  export interface SmartSavingsAccount extends SavingsAccount {
26
- /** Smart wallet instance for advanced features */
27
10
  smartWallet: EVMSmartWallet;
28
- /** Whether the account has been initialized on-chain */
29
11
  isInitialized: boolean;
30
12
  }
31
- /**
32
- * Options for transferring to savings
33
- */
34
13
  export interface TransferToSavingsOptions {
35
- /** Expected address for verification (prevents tampering) */
36
14
  expectedAddress?: Hex;
37
- /** Transaction priority for gas estimation */
38
15
  priority?: 'low' | 'medium' | 'high';
39
- /** Whether to use smart account features (requires 7702 upgrade) */
40
16
  useSmartAccount?: boolean;
41
17
  }
42
- /**
43
- * Options for withdrawing from savings
44
- */
45
18
  export interface WithdrawFromSavingsOptions {
46
- /** Expected source address for verification */
47
19
  expectedAddress?: Hex;
48
- /** Transaction priority */
49
20
  priority?: 'low' | 'medium' | 'high';
50
- /** Whether to use smart account features */
51
21
  useSmartAccount?: boolean;
52
22
  }
53
- /**
54
- * Result of address verification
55
- */
56
23
  export interface AddressVerificationResult {
57
- /** Account index that was verified */
58
24
  accountIndex: number;
59
- /** Stored address that was checked */
60
25
  storedAddress: Hex;
61
- /** Derived address from account index */
62
26
  derivedAddress: Hex;
63
- /** Whether addresses match */
64
27
  isValid: boolean;
65
- /** Error message if invalid */
66
28
  error?: string;
67
29
  }
68
- /**
69
- * Result of batch address audit
70
- */
71
30
  export interface SavingsAuditResult {
72
- /** Total number of addresses audited */
73
31
  total: number;
74
- /** Number of valid addresses */
75
32
  valid: number;
76
- /** Number of invalid addresses */
77
33
  invalid: number;
78
- /** Whether all addresses are valid */
79
34
  allValid: boolean;
80
- /** Detailed results per address */
81
35
  results: AddressVerificationResult[];
82
- /** Timestamp of audit */
83
36
  timestamp: Date;
84
37
  }
85
- /**
86
- * Lock module configuration for locked savings
87
- */
88
38
  export interface LockModuleConfig {
89
- /** Lock duration in seconds */
90
39
  lockDuration: number;
91
- /** Lock end timestamp (computed) */
92
40
  lockedUntil: number;
93
- /** Whether early withdrawal is allowed with penalty */
94
41
  allowEarlyWithdrawal?: boolean;
95
- /** Penalty percentage for early withdrawal (0-100) */
96
42
  earlyWithdrawalPenalty?: number;
97
43
  }
98
- /**
99
- * Periodic savings session configuration
100
- */
101
44
  export interface PeriodicSavingsConfig {
102
- /** Amount to save each period */
103
45
  amount: number;
104
- /** Savings frequency */
105
46
  frequency: 'daily' | 'weekly' | 'monthly';
106
- /** Destination account index */
107
47
  savingsAccountIndex: number;
108
- /** Optional end date for recurring savings */
109
48
  endDate?: Date;
110
- /** Maximum number of executions */
111
49
  maxExecutions?: number;
112
50
  }
113
- /**
114
- * Spend and save hook configuration
115
- */
116
51
  export interface SpendAndSaveConfig {
117
- /** Percentage of spending to save (0-100) */
118
52
  savePercentage: number;
119
- /** Destination savings account index */
120
53
  savingsAccountIndex: number;
121
- /** Minimum transaction amount to trigger saving */
122
54
  minTransactionAmount?: number;
123
- /** Maximum amount to save per transaction */
124
55
  maxSaveAmount?: number;
125
56
  }
@@ -1,9 +1,2 @@
1
1
  "use strict";
2
- /**
3
- * Savings Pocket Types
4
- *
5
- * Type definitions for the savings pocket feature that allows users to create
6
- * multiple savings accounts derived from their seed phrase using BIP-44 account indices.
7
- */
8
2
  Object.defineProperty(exports, "__esModule", { value: true });
9
- //# sourceMappingURL=types.js.map
@@ -0,0 +1,9 @@
1
+ export declare class SavingsValidation {
2
+ static validateAccountIndex(index: number): void;
3
+ static validateWalletIndex(index: number): void;
4
+ static validateAmount(amount: bigint, label?: string): void;
5
+ static validateAddress(address: string, label?: string): void;
6
+ static validateMnemonic(mnemonic: string): void;
7
+ static validateChainId(chainId: number): void;
8
+ static validateAmountString(amount: string, label?: string): void;
9
+ }
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SavingsValidation = void 0;
4
+ class SavingsValidation {
5
+ static validateAccountIndex(index) {
6
+ if (!Number.isInteger(index)) {
7
+ throw new Error(`Account index must be an integer, got: ${index}`);
8
+ }
9
+ if (index < 0) {
10
+ throw new Error(`Account index must be non-negative, got: ${index}`);
11
+ }
12
+ if (index > 0x7FFFFFFF) {
13
+ throw new Error(`Account index exceeds BIP-44 maximum (2147483647), got: ${index}`);
14
+ }
15
+ }
16
+ static validateWalletIndex(index) {
17
+ if (!Number.isInteger(index)) {
18
+ throw new Error(`Wallet index must be an integer, got: ${index}`);
19
+ }
20
+ if (index < 0) {
21
+ throw new Error(`Wallet index must be non-negative, got: ${index}`);
22
+ }
23
+ if (index > 0x7FFFFFFF) {
24
+ throw new Error(`Wallet index exceeds maximum (2147483647), got: ${index}`);
25
+ }
26
+ }
27
+ static validateAmount(amount, label = 'Amount') {
28
+ if (typeof amount !== 'bigint') {
29
+ throw new Error(`${label} must be a bigint, got: ${typeof amount}`);
30
+ }
31
+ if (amount <= 0n) {
32
+ throw new Error(`${label} must be positive, got: ${amount}`);
33
+ }
34
+ }
35
+ static validateAddress(address, label = 'Address') {
36
+ if (typeof address !== 'string') {
37
+ throw new Error(`${label} must be a string, got: ${typeof address}`);
38
+ }
39
+ if (!/^0x[a-fA-F0-9]{40}$/.test(address)) {
40
+ throw new Error(`${label} has invalid format. Expected 0x followed by 40 hex characters, got: ${address}`);
41
+ }
42
+ }
43
+ static validateMnemonic(mnemonic) {
44
+ if (typeof mnemonic !== 'string') {
45
+ throw new Error(`Mnemonic must be a string, got: ${typeof mnemonic}`);
46
+ }
47
+ const trimmed = mnemonic.trim();
48
+ if (trimmed.length === 0) {
49
+ throw new Error('Mnemonic cannot be empty');
50
+ }
51
+ const words = trimmed.split(/\s+/);
52
+ const validWordCounts = [12, 15, 18, 21, 24];
53
+ if (!validWordCounts.includes(words.length)) {
54
+ throw new Error(`Mnemonic must have 12, 15, 18, 21, or 24 words (BIP-39 standard), got: ${words.length} words`);
55
+ }
56
+ }
57
+ static validateChainId(chainId) {
58
+ if (!Number.isInteger(chainId)) {
59
+ throw new Error(`Chain ID must be an integer, got: ${chainId}`);
60
+ }
61
+ if (chainId <= 0) {
62
+ throw new Error(`Chain ID must be positive, got: ${chainId}`);
63
+ }
64
+ }
65
+ static validateAmountString(amount, label = 'Amount') {
66
+ if (typeof amount !== 'string') {
67
+ throw new Error(`${label} must be a string, got: ${typeof amount}`);
68
+ }
69
+ const trimmed = amount.trim();
70
+ if (trimmed.length === 0) {
71
+ throw new Error(`${label} cannot be empty`);
72
+ }
73
+ if (!/^-?\d+(\.\d+)?$/.test(trimmed)) {
74
+ throw new Error(`${label} has invalid format, got: ${amount}`);
75
+ }
76
+ const parsed = parseFloat(trimmed);
77
+ if (isNaN(parsed)) {
78
+ throw new Error(`${label} cannot be parsed as number, got: ${amount}`);
79
+ }
80
+ if (parsed <= 0) {
81
+ throw new Error(`${label} must be positive, got: ${amount}`);
82
+ }
83
+ }
84
+ }
85
+ exports.SavingsValidation = SavingsValidation;
@@ -22,4 +22,3 @@ exports.SVM_CHAIN_CONFIG = {
22
22
  rpcUrl: "https://mainnetbeta-rpc.eclipse.xyz"
23
23
  }
24
24
  };
25
- //# sourceMappingURL=constant.js.map
package/dist/svm/index.js CHANGED
@@ -15,4 +15,3 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./svm"), exports);
18
- //# sourceMappingURL=index.js.map
package/dist/svm/svm.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Connection, Keypair, PublicKey, Transaction, VersionedTransaction } from "@solana/web3.js";
2
2
  import { VM } from "../vm";
3
3
  import { ChainWallet } from "../IChainWallet";
4
- import { Balance, ChainWalletConfig, UserTokenBalance, TokenInfo, TransactionResult, NFT } from "../types";
4
+ import { Balance, ChainWalletConfig, UserTokenBalance, TokenInfo, TransactionResult, NFT, WalletDiscoveryOptions, WalletDiscoveryResult, PocketDiscoveryOptions } from "../types";
5
5
  import { JupiterQuoteResponse } from "./utils";
6
6
  import { PriceResponse } from "../price.types";
7
7
  import { SVMTransactionHistoryItem } from "./transactionParsing";
@@ -25,6 +25,16 @@ export declare class SVMVM extends VM<PublicKey, Keypair, Connection> {
25
25
  index: number;
26
26
  };
27
27
  static fromMnemonic(mnemonic: string): VM<PublicKey, Keypair, Connection>;
28
+ deriveSavingsAccount(accountIndex: number): {
29
+ privateKey: Keypair;
30
+ address: PublicKey;
31
+ derivationPath: string;
32
+ };
33
+ discoverWallets(connection: Connection, options?: WalletDiscoveryOptions): Promise<WalletDiscoveryResult>;
34
+ private checkWalletBalance;
35
+ private sleep;
36
+ discoverPockets(connection: Connection, options?: PocketDiscoveryOptions): Promise<WalletDiscoveryResult>;
37
+ private checkPocketBalance;
28
38
  }
29
39
  export declare class SVMChainWallet extends ChainWallet<PublicKey, Keypair, Connection> {
30
40
  constructor(config: ChainWalletConfig, privateKey: Keypair, index: number);