@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,80 +1 @@
1
1
  "use strict";
2
- // import { Keypair } from "@solana/web3.js";
3
- // import * as bip39 from "@scure/bip39";
4
- // import { HDKey } from "@scure/bip32"
5
- // import { Buffer } from "buffer"; // Import the polyfill
6
- // window.Buffer = Buffer; // Inject Buffer into the global scope
7
- // import { wordlist } from "@scure/bip39/wordlists/english";
8
- // import { hmac } from "@noble/hashes/hmac";
9
- // import { sha512 } from "@noble/hashes/sha2";
10
- // export function GenerateNewMnemonic() {
11
- // const mnemonic = bip39.generateMnemonic(wordlist);
12
- // return mnemonic;
13
- // }
14
- // export function ValidateMnemonic(mnemonic: string) {
15
- // const isValid = bip39.validateMnemonic(mnemonic, wordlist);
16
- // if (!isValid) {
17
- // throw new Error("Invalid mnemonic");
18
- // }
19
- // return isValid;
20
- // }
21
- // export function GenerateSeed(_mnemonic?: string) {
22
- // const mnemonic = _mnemonic || bip39.generateMnemonic(wordlist);
23
- // const seedString = bip39.mnemonicToSeedSync(mnemonic);
24
- // return seedString;
25
- // }
26
- // //EVM
27
- // export function EVMDeriveChildPrivateKey(seed: string, index: number, derivationPath: string) {
28
- // const path = `${derivationPath}${index}'`
29
- // const scureNode = HDKey.fromMasterSeed(Buffer.from(seed, "hex"))
30
- // const child = scureNode.derive(path);
31
- // const privateKey = Buffer.from(child.privateKey!).toString("hex");
32
- // const publicKey = Buffer.from(child.publicKey!).toString("hex");
33
- // return { privateKey, publicKey };
34
- // }
35
- // //SVM
36
- // export function SVMDeriveChildPrivateKey(seed: string, index: number, derivationPath: string) {
37
- // const path = `${derivationPath}${index}'`;
38
- // // Derive a seed from the given path
39
- // const derivedSeed = derivePathEclipticCurve(path, Buffer.from(seed, "hex")).key;
40
- // const derivedKeyPair = Keypair.fromSeed(derivedSeed);
41
- // return derivedKeyPair;
42
- // }
43
- // function derivePathEclipticCurve(path: string, seed: Uint8Array): { key: Uint8Array, chainCode: Uint8Array } {
44
- // const segments = path
45
- // .split("/")
46
- // .slice(1)
47
- // .map((seg) => {
48
- // if (!seg.endsWith("'")) {
49
- // throw new Error("Only hardened derivation is supported");
50
- // }
51
- // return parseInt(seg.slice(0, -1), 10) + 0x80000000;
52
- // });
53
- // // Initialize with master key derivation
54
- // let hmacResult = hmac(sha512, Buffer.from("ed25519 seed"), seed);
55
- // let key = hmacResult.slice(0, 32);
56
- // let chainCode = hmacResult.slice(32, 64);
57
- // // Derive each path segment
58
- // for (const segment of segments) {
59
- // const result = hardenedDerivation(key, chainCode, segment);
60
- // key = Buffer.from(result.key);
61
- // chainCode = Buffer.from(result.chainCode);
62
- // }
63
- // return { key, chainCode };
64
- // }
65
- // function hardenedDerivation(
66
- // parentKey: Uint8Array,
67
- // parentChainCode: Uint8Array,
68
- // index: number
69
- // ): { key: Uint8Array, chainCode: Uint8Array } {
70
- // const indexBuffer = new Uint8Array(4);
71
- // new DataView(indexBuffer.buffer).setUint32(0, index, false);
72
- // // Proper SLIP-0010 format: 0x00 + parent_key + index
73
- // const data = new Uint8Array([0x00, ...parentKey, ...indexBuffer]);
74
- // const hmacResult = hmac(sha512, parentChainCode, data);
75
- // return {
76
- // key: hmacResult.slice(0, 32), // Left 32 bytes
77
- // chainCode: hmacResult.slice(32, 64) // Right 32 bytes
78
- // };
79
- // }
80
- //# sourceMappingURL=bip32Small.js.map
package/dist/bipTest.js CHANGED
@@ -1,363 +1 @@
1
1
  "use strict";
2
- // import { mnemonicToSeedSync, generateMnemonic } from "@scure/bip39";
3
- // import { wordlist } from "@scure/bip39/wordlists/english";
4
- // import nacl from "tweetnacl";
5
- // import { hmac } from "../node_modules/@noble/hashes/hmac";
6
- // import { sha512 } from "../node_modules/@noble/hashes/sha512";
7
- // import BIP32Factory from "bip32";
8
- // import * as ecc from "tiny-secp256k1";
9
- // import { BIP32Interface } from "bip32";
10
- // import { derivePath as derivePathLib } from "ed25519-hd-key";
11
- // import { HDKey } from "@scure/bip32";
12
- // import * as bip39_impl1 from "bip39";
13
- // import * as ed25519 from "ed25519-hd-key";
14
- // import { Keypair } from "@solana/web3.js";
15
- // // Implementation 2 - Using @scure libraries with custom Ed25519
16
- // import * as bip39_impl2 from "@scure/bip39";
17
- // // === your SLIP-0010 implementation here ===
18
- // // (using your derivePath + hardenedDerivation methods)
19
- // function derivePath(path: string, seed: Uint8Array): { key: Uint8Array, chainCode: Uint8Array } {
20
- // const segments = path
21
- // .split("/")
22
- // .slice(1)
23
- // .map((seg) => {
24
- // if (!seg.endsWith("'")) {
25
- // throw new Error("Only hardened derivation is supported");
26
- // }
27
- // return parseInt(seg.slice(0, -1), 10) + 0x80000000;
28
- // });
29
- // // Initialize with master key derivation
30
- // let hmacResult = hmac(sha512, "ed25519 seed", seed);
31
- // let key = hmacResult.slice(0, 32);
32
- // let chainCode = hmacResult.slice(32, 64);
33
- // // Derive each path segment
34
- // for (const segment of segments) {
35
- // const result = hardenedDerivation(key, chainCode, segment);
36
- // key = Buffer.from(result.key);
37
- // chainCode = Buffer.from(result.chainCode);
38
- // }
39
- // return { key, chainCode };
40
- // }
41
- // function hardenedDerivation(
42
- // parentKey: Uint8Array,
43
- // parentChainCode: Uint8Array,
44
- // index: number
45
- // ): { key: Uint8Array, chainCode: Uint8Array } {
46
- // const indexBuffer = new Uint8Array(4);
47
- // new DataView(indexBuffer.buffer).setUint32(0, index, false);
48
- // // Proper SLIP-0010 format: 0x00 + parent_key + index
49
- // const data = new Uint8Array([0x00, ...parentKey, ...indexBuffer]);
50
- // const hmacResult = hmac(sha512, parentChainCode, data);
51
- // return {
52
- // key: hmacResult.slice(0, 32), // Left 32 bytes
53
- // chainCode: hmacResult.slice(32, 64) // Right 32 bytes
54
- // };
55
- // }
56
- // function hex(buf: Uint8Array) {
57
- // return Buffer.from(buf).toString("hex");
58
- // }
59
- // // --- Test Vector Check ---
60
- // const vectorTest = () => {
61
- // const seedHex = "000102030405060708090a0b0c0d0e0f";
62
- // const seed = Buffer.from(seedHex, "hex");
63
- // const { key, chainCode } = derivePath("m/0'", seed);
64
- // console.log("SLIP-0010 Test Vector:");
65
- // console.log("Derived key:", hex(key));
66
- // console.log("Expected key: 68e0fe46dfb67e368c75379acec591dad19df3cde26e63b93a8e704f1dade7a3");
67
- // console.log("Derived chainCode:", hex(chainCode));
68
- // console.log("Expected chainCode: 8b59aa11380b624e81507a27fedda59fea6d0b779a778918a2fd3590e16e9c69");
69
- // }
70
- // // --- Solana Path Check ---
71
- // const solanaPathCheck = () => {
72
- // const mnemonic = "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about";
73
- // const seed = mnemonicToSeedSync(mnemonic);
74
- // const { key } = derivePath("m/44'/501'/0'/0'", seed);
75
- // const keypair = nacl.sign.keyPair.fromSeed(key);
76
- // console.log("\nSolana Path m/44'/501'/0'/0':");
77
- // console.log("Private key seed:", hex(key));
78
- // console.log("Public key:", hex(keypair.publicKey));
79
- // }
80
- // // === Test Harness ===
81
- // const compareDerivation = () => {
82
- // const mnemonic = generateMnemonic(wordlist);
83
- // const seed = mnemonicToSeedSync(mnemonic);
84
- // const path = "m/44'/501'/0'/0'";
85
- // // Custom
86
- // const custom = derivePath(path, seed);
87
- // const customKeypair = nacl.sign.keyPair.fromSeed(custom.key);
88
- // // Library
89
- // const lib = derivePathLib(path, Buffer.from(seed).toString("hex"));
90
- // const libKeypair = nacl.sign.keyPair.fromSeed(lib.key);
91
- // console.log("=== Solana Derivation Test ===");
92
- // console.log("Path:", path);
93
- // console.log("\n-- Custom Implementation --");
94
- // console.log("Private key seed:", hex(custom.key));
95
- // console.log("Chain code:", hex(custom.chainCode));
96
- // console.log("Public key:", hex(customKeypair.publicKey));
97
- // console.log("\n-- ed25519-hd-key Library --");
98
- // console.log("Private key seed:", hex(lib.key));
99
- // console.log("Chain code:", hex(lib.chainCode));
100
- // console.log("Public key:", hex(libKeypair.publicKey));
101
- // console.log("\nMatch (private):", hex(custom.key) === hex(lib.key));
102
- // console.log("Match (chainCode):", hex(custom.chainCode) === hex(lib.chainCode));
103
- // console.log("Match (public):", hex(customKeypair.publicKey) === hex(libKeypair.publicKey));
104
- // }
105
- // const testBip32 = async () => {
106
- // const mnemonic = "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about";
107
- // const seed = mnemonicToSeedSync(mnemonic);
108
- // const derivationPath = "m/44'/0'/0'/0"; // Bitcoin account
109
- // const index = 0;
110
- // const path = `${derivationPath}/${index}`;
111
- // // --- @scure/bip32 ---
112
- // const scureNode = HDKey.fromMasterSeed(seed);
113
- // const scureChild = scureNode.derive(path);
114
- // console.log("=== @scure/bip32 ===");
115
- // console.log("Path:", path);
116
- // console.log("Private key:", hex(scureChild.privateKey!));
117
- // console.log("Public key:", hex(scureChild.publicKey!));
118
- // console.log("Chain code:", hex(scureChild.chainCode!));
119
- // // --- bip32 + tiny-secp256k1 ---
120
- // const bip32 = BIP32Factory(ecc);
121
- // const node: BIP32Interface = bip32.fromSeed(Buffer.from(seed));
122
- // const child = node.derivePath(path);
123
- // console.log("\n=== bip32 (tiny-secp256k1) ===");
124
- // console.log("Path:", path);
125
- // console.log("Private key:", hex(child.privateKey!));
126
- // console.log("Public key:", hex(child.publicKey));
127
- // console.log("Chain code:", hex(child.chainCode));
128
- // // Compare
129
- // console.log("\n=== Comparison ===");
130
- // console.log("Private keys match:", hex(scureChild.privateKey!) === hex(child.privateKey!));
131
- // console.log("Public keys match:", hex(scureChild.publicKey!) === hex(child.publicKey));
132
- // console.log("Chain codes match:", hex(scureChild.chainCode!) === hex(child.chainCode));
133
- // }
134
- // // ===== IMPLEMENTATION 1 =====
135
- // class WalletImpl1 {
136
- // static GenerateNewMnemonic(): string {
137
- // const mnemonic = bip39_impl1.generateMnemonic();
138
- // return mnemonic;
139
- // }
140
- // static ValidateMnemonic(mnemonic: string): boolean {
141
- // const isValid = bip39_impl1.validateMnemonic(mnemonic);
142
- // if (!isValid) {
143
- // throw new Error("Invalid mnemonic");
144
- // }
145
- // return isValid;
146
- // }
147
- // static GenerateSeed(_mnemonic: string): string {
148
- // const mnemonic = _mnemonic || bip39_impl1.generateMnemonic();
149
- // const seed = bip39_impl1.mnemonicToSeedSync(mnemonic);
150
- // const seedString = seed.toString("hex");
151
- // return seedString;
152
- // }
153
- // static getSeedNode(seed: string): BIP32Interface {
154
- // const bip32 = BIP32Factory(ecc);
155
- // const restoredSeedBuffer = Buffer.from(seed, "hex");
156
- // const node = bip32.fromSeed(restoredSeedBuffer);
157
- // return node;
158
- // }
159
- // static EVMDeriveChildPrivateKey(seed: string, index: number, derivationPath: string): { privateKey: string, publicKey: string } {
160
- // const node = this.getSeedNode(seed);
161
- // const child = node.derivePath(`${derivationPath}${index}'`);
162
- // const privateKey = child.privateKey!.toString("hex");
163
- // const publicKey = child.publicKey.toString("hex");
164
- // return { privateKey, publicKey };
165
- // }
166
- // static SVMDeriveChildPrivateKey(seed: string, index: number, derivationPath: string): { privateKey: string, publicKey: string, keypair: Keypair } {
167
- // const path = `${derivationPath}${index}'`;
168
- // const derivedSeed = ed25519.derivePath(path, seed).key;
169
- // const derivedKeyPair = Keypair.fromSeed(derivedSeed);
170
- // return {
171
- // privateKey: Buffer.from(derivedKeyPair.secretKey).toString("hex"),
172
- // publicKey: derivedKeyPair.publicKey.toString(),
173
- // keypair: derivedKeyPair
174
- // };
175
- // }
176
- // }
177
- // // ===== IMPLEMENTATION 2 =====
178
- // class WalletImpl2 {
179
- // static GenerateNewMnemonic(): string {
180
- // const mnemonic = bip39_impl2.generateMnemonic(wordlist);
181
- // return mnemonic;
182
- // }
183
- // static ValidateMnemonic(mnemonic: string): boolean {
184
- // const isValid = bip39_impl2.validateMnemonic(mnemonic, wordlist);
185
- // if (!isValid) {
186
- // throw new Error("Invalid mnemonic");
187
- // }
188
- // return isValid;
189
- // }
190
- // static GenerateSeed(_mnemonic: string): Uint8Array {
191
- // const mnemonic = _mnemonic || bip39_impl2.generateMnemonic(wordlist);
192
- // const seedString = bip39_impl2.mnemonicToSeedSync(mnemonic);
193
- // return seedString;
194
- // }
195
- // static EVMDeriveChildPrivateKey(seed: string, index: number, derivationPath: string): { privateKey: string, publicKey: string } {
196
- // const path = `${derivationPath}${index}'`;
197
- // const scureNode = HDKey.fromMasterSeed(Buffer.from(seed, "hex"));
198
- // const child = scureNode.derive(path);
199
- // const privateKey = Buffer.from(child.privateKey!).toString("hex");
200
- // const publicKey = Buffer.from(child.publicKey!).toString("hex");
201
- // return { privateKey, publicKey };
202
- // }
203
- // static SVMDeriveChildPrivateKey(seed: string, index: number, derivationPath: string): { privateKey: string, publicKey: string, keypair: Keypair } {
204
- // const path = `${derivationPath}${index}'`;
205
- // const derivedSeed = this.derivePathEclipticCurve(path, Buffer.from(seed, "hex")).key;
206
- // const derivedKeyPair = Keypair.fromSeed(derivedSeed);
207
- // return {
208
- // privateKey: Buffer.from(derivedKeyPair.secretKey).toString("hex"),
209
- // publicKey: derivedKeyPair.publicKey.toString(),
210
- // keypair: derivedKeyPair
211
- // };
212
- // }
213
- // static derivePathEclipticCurve(path: string, seed: Uint8Array): { key: Uint8Array, chainCode: Uint8Array } {
214
- // const segments = path
215
- // .split("/")
216
- // .slice(1)
217
- // .map((seg) => {
218
- // if (!seg.endsWith("'")) {
219
- // throw new Error("Only hardened derivation is supported");
220
- // }
221
- // return parseInt(seg.slice(0, -1), 10) + 0x80000000;
222
- // });
223
- // let hmacResult = hmac(sha512, "ed25519 seed", seed);
224
- // let key = hmacResult.slice(0, 32);
225
- // let chainCode = hmacResult.slice(32, 64);
226
- // for (const segment of segments) {
227
- // const result = this.hardenedDerivation(key, chainCode, segment);
228
- // key = Buffer.from(result.key);
229
- // chainCode = Buffer.from(result.chainCode);
230
- // }
231
- // return { key, chainCode };
232
- // }
233
- // static hardenedDerivation(
234
- // parentKey: Uint8Array,
235
- // parentChainCode: Uint8Array,
236
- // index: number
237
- // ): { key: Uint8Array, chainCode: Uint8Array } {
238
- // const indexBuffer = new Uint8Array(4);
239
- // new DataView(indexBuffer.buffer).setUint32(0, index, false);
240
- // const data = new Uint8Array([0x00, ...parentKey, ...indexBuffer]);
241
- // const hmacResult = hmac(sha512, parentChainCode, data);
242
- // return {
243
- // key: hmacResult.slice(0, 32),
244
- // chainCode: hmacResult.slice(32, 64)
245
- // };
246
- // }
247
- // }
248
- // // ===== COMPARISON SCRIPT =====
249
- // function compareImplementations() {
250
- // console.log("🔍 Comparing Wallet Implementations\n");
251
- // console.log("=".repeat(80));
252
- // // Test data
253
- // const testMnemonic = "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about";
254
- // const evmDerivationPath = "m/44'/60'/0'/0/";
255
- // const svmDerivationPath = "m/44'/501'/";
256
- // const testIndices = [0, 1, 2, 5, 10];
257
- // let allTestsPassed = true;
258
- // try {
259
- // // Test 1: Mnemonic validation
260
- // console.log("📝 Test 1: Mnemonic Validation");
261
- // const valid1 = WalletImpl1.ValidateMnemonic(testMnemonic);
262
- // const valid2 = WalletImpl2.ValidateMnemonic(testMnemonic);
263
- // console.log(` Implementation 1: ${valid1}`);
264
- // console.log(` Implementation 2: ${valid2}`);
265
- // console.log(` ✅ Match: ${valid1 === valid2}\n`);
266
- // if (valid1 !== valid2) allTestsPassed = false;
267
- // // Test 2: Seed generation
268
- // console.log("🌱 Test 2: Seed Generation");
269
- // const seed1 = WalletImpl1.GenerateSeed(testMnemonic);
270
- // const seed2 = Buffer.from(WalletImpl2.GenerateSeed(testMnemonic)).toString("hex");
271
- // console.log(` Implementation 1: ${seed1.substring(0, 32)}...`);
272
- // console.log(` Implementation 2: ${seed2.substring(0, 32)}...`);
273
- // console.log(` ✅ Match: ${seed1 === seed2}\n`);
274
- // if (seed1 !== seed2) allTestsPassed = false;
275
- // // Test 3: EVM Key Derivation
276
- // console.log("⚡ Test 3: EVM Key Derivation");
277
- // console.log(" Index | Implementation 1 Private Key | Implementation 2 Private Key | Match");
278
- // console.log(" ------|--------------------------------------------------|--------------------------------------------------|------");
279
- // let evmMatches = true;
280
- // for (const index of testIndices) {
281
- // const evm1 = WalletImpl1.EVMDeriveChildPrivateKey(seed1, index, evmDerivationPath);
282
- // const evm2 = WalletImpl2.EVMDeriveChildPrivateKey(seed1, index, evmDerivationPath);
283
- // const privateKeyMatch = evm1.privateKey === evm2.privateKey;
284
- // const publicKeyMatch = evm1.publicKey === evm2.publicKey;
285
- // const match = privateKeyMatch && publicKeyMatch;
286
- // console.log(` ${index.toString().padStart(5)} | ${evm1.privateKey.substring(0, 48)} | ${evm2.privateKey.substring(0, 48)} | ${match ? '✅' : '❌'}`);
287
- // if (!match) {
288
- // evmMatches = false;
289
- // allTestsPassed = false;
290
- // }
291
- // }
292
- // console.log(` Overall EVM Match: ${evmMatches ? '✅' : '❌'}\n`);
293
- // // Test 4: SVM Key Derivation
294
- // console.log("🌞 Test 4: SVM (Solana) Key Derivation");
295
- // console.log(" Index | Implementation 1 Private Key | Implementation 2 Private Key | Match");
296
- // console.log(" ------|--------------------------------------------------|--------------------------------------------------|------");
297
- // let svmMatches = true;
298
- // for (const index of testIndices) {
299
- // const svm1 = WalletImpl1.SVMDeriveChildPrivateKey(seed1, index, svmDerivationPath);
300
- // const svm2 = WalletImpl2.SVMDeriveChildPrivateKey(seed1, index, svmDerivationPath);
301
- // const privateKeyMatch = svm1.privateKey === svm2.privateKey;
302
- // const publicKeyMatch = svm1.publicKey === svm2.publicKey;
303
- // const match = privateKeyMatch && publicKeyMatch;
304
- // console.log(` ${index.toString().padStart(5)} | ${svm1.privateKey.substring(0, 48)} | ${svm2.privateKey.substring(0, 48)} | ${match ? '✅' : '❌'}`);
305
- // if (!match) {
306
- // svmMatches = false;
307
- // allTestsPassed = false;
308
- // // Show detailed comparison for mismatches
309
- // console.log(` 🔍 Detailed comparison for index ${index}:`);
310
- // console.log(` Impl1 Private: ${svm1.privateKey}`);
311
- // console.log(` Impl2 Private: ${svm2.privateKey}`);
312
- // console.log(` Impl1 Public: ${svm1.publicKey}`);
313
- // console.log(` Impl2 Public: ${svm2.publicKey}`);
314
- // }
315
- // }
316
- // console.log(` Overall SVM Match: ${svmMatches ? '✅' : '❌'}\n`);
317
- // // Test 5: Performance comparison
318
- // console.log("⏱️ Test 5: Performance Comparison");
319
- // const iterations = 100;
320
- // // EVM Performance
321
- // console.time(" Implementation 1 EVM");
322
- // for (let i = 0; i < iterations; i++) {
323
- // WalletImpl1.EVMDeriveChildPrivateKey(seed1, i % 10, evmDerivationPath);
324
- // }
325
- // console.timeEnd(" Implementation 1 EVM");
326
- // console.time(" Implementation 2 EVM");
327
- // for (let i = 0; i < iterations; i++) {
328
- // WalletImpl2.EVMDeriveChildPrivateKey(seed1, i % 10, evmDerivationPath);
329
- // }
330
- // console.timeEnd(" Implementation 2 EVM");
331
- // // SVM Performance
332
- // console.time(" Implementation 1 SVM");
333
- // for (let i = 0; i < iterations; i++) {
334
- // WalletImpl1.SVMDeriveChildPrivateKey(seed1, i % 10, svmDerivationPath);
335
- // }
336
- // console.timeEnd(" Implementation 1 SVM");
337
- // console.time(" Implementation 2 SVM");
338
- // for (let i = 0; i < iterations; i++) {
339
- // WalletImpl2.SVMDeriveChildPrivateKey(seed1, i % 10, svmDerivationPath);
340
- // }
341
- // console.timeEnd(" Implementation 2 SVM");
342
- // console.log("\n" + "=".repeat(80));
343
- // console.log(`🎯 Overall Result: ${allTestsPassed ? '✅ ALL TESTS PASSED' : '❌ SOME TESTS FAILED'}`);
344
- // console.log("=".repeat(80));
345
- // return {
346
- // success: allTestsPassed,
347
- // details: {
348
- // mnemonicValidation: valid1 === valid2,
349
- // seedGeneration: seed1 === seed2,
350
- // evmDerivation: evmMatches,
351
- // svmDerivation: svmMatches
352
- // }
353
- // };
354
- // } catch (error: any) {
355
- // console.error("❌ Error during comparison:", error);
356
- // return {
357
- // success: false,
358
- // error: error.message
359
- // };
360
- // }
361
- // }
362
- // compareImplementations()
363
- //# sourceMappingURL=bipTest.js.map
package/dist/constant.js CHANGED
@@ -69,20 +69,6 @@ exports.DefaultChains = [{
69
69
  logoUrl: "https://bscscan.com/assets/bsc/images/svg/logos/token-light.svg?v=25.10.5.0",
70
70
  vmType: "EVM"
71
71
  },
72
- // {
73
- // chainId: 123456791,
74
- // name: "Eclipse",
75
- // rpcUrl: "https://mainnetbeta-rpc.eclipse.xyz",
76
- // explorerUrl: "https://explorer.eclipse.xyz/",
77
- // nativeToken: {
78
- // name: "Eclipse",
79
- // symbol: "ETH",
80
- // decimals: 9,
81
- // },
82
- // testnet: false,
83
- // logoUrl: "https://raw.githubusercontent.com/hyperlane-xyz/hyperlane-registry/a86c3b432b6f9ad7272ae09859f20eb3ade3bd6e/deployments/warp_routes/ES/logo.svg",
84
- // vmType: "SVM"
85
- // },
86
72
  {
87
73
  chainId: chains_1.base.id,
88
74
  name: chains_1.base.name,
@@ -125,7 +111,6 @@ exports.DefaultChains = [{
125
111
  logoUrl: "https://optimism.io/images/optimism-logo-light.svg",
126
112
  vmType: "EVM"
127
113
  },
128
- //add for polygon
129
114
  {
130
115
  chainId: 137,
131
116
  name: "Polygon",
@@ -142,7 +127,6 @@ exports.DefaultChains = [{
142
127
  }
143
128
  ];
144
129
  exports.TRANSACTION_TYPE = {
145
- // CAPITALIZE THE VALUES
146
130
  NATIVE_TRANSFER: 'NATIVE_TRANSFER',
147
131
  TOKEN_TRANSFER: 'TOKEN_TRANSFER',
148
132
  NFT_TRANSFER: 'NFT_TRANSFER',
@@ -157,4 +141,3 @@ exports.TRANSACTION_TYPE = {
157
141
  SYSTEM: 'SYSTEM',
158
142
  UNKNOWN: 'UNKNOWN'
159
143
  };
160
- //# sourceMappingURL=constant.js.map
package/dist/english.js CHANGED
@@ -2049,4 +2049,3 @@ zebra
2049
2049
  zero
2050
2050
  zone
2051
2051
  zoo`.split('\n');
2052
- //# sourceMappingURL=english.js.map
@@ -1,8 +1,3 @@
1
- /**
2
- * Main Export File
3
- *
4
- * Easy imports for using the Account Abstraction services
5
- */
6
1
  export { AccountAbstractionService } from './services/account-abstraction';
7
2
  export type { AAServiceConfig, CreateAccountOptions, SendTransactionOptions, SendBatchTransactionOptions, WaitForReceiptOptions } from './services/account-abstraction';
8
3
  export * from './lib/type';
@@ -1,9 +1,4 @@
1
1
  "use strict";
2
- /**
3
- * Main Export File
4
- *
5
- * Easy imports for using the Account Abstraction services
6
- */
7
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
8
3
  if (k2 === undefined) k2 = k;
9
4
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -20,31 +15,25 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
20
15
  };
21
16
  Object.defineProperty(exports, "__esModule", { value: true });
22
17
  exports.adaptSessionKeyAccount = exports.adaptZeroDevAccount = exports.createETHTransferPermission = exports.createUSDCTransferPermission = exports.createSessionKeyClient = exports.deserializeSessionKey = exports.createSessionKeyApproval = exports.generateSessionKey = exports.MODULE_TYPE_IDS = exports.installMultiSigValidator = exports.revokeSessionKey = exports.createSessionKey = exports.isModuleInstalled = exports.uninstallModule = exports.installModule = exports.prepareInstallMultiSigValidator = exports.prepareRevokeSessionKey = exports.prepareInstallSessionKey = exports.prepareUninstallModule = exports.prepareInstallModule = exports.waitForKernelReceipt = exports.sendBatchTransaction = exports.sendKernelTransaction = exports.createKernelAuthorization = exports.createKernel7702Account = exports.createBundlerService = exports.createBundlerManager = exports.BundlerManager = exports.AccountAbstractionService = void 0;
23
- // Singleton Service (Primary Interface)
24
18
  var account_abstraction_1 = require("./services/account-abstraction");
25
19
  Object.defineProperty(exports, "AccountAbstractionService", { enumerable: true, get: function () { return account_abstraction_1.AccountAbstractionService; } });
26
20
  __exportStar(require("./lib/type"), exports);
27
- // Bundler Services (Advanced Usage)
28
21
  var bundler_1 = require("./services/bundler");
29
22
  Object.defineProperty(exports, "BundlerManager", { enumerable: true, get: function () { return bundler_1.BundlerManager; } });
30
23
  Object.defineProperty(exports, "createBundlerManager", { enumerable: true, get: function () { return bundler_1.createBundlerManager; } });
31
24
  Object.defineProperty(exports, "createBundlerService", { enumerable: true, get: function () { return bundler_1.createBundlerService; } });
32
- // Kernel Account Utilities (Advanced Usage)
33
25
  var kernel_account_1 = require("./lib/kernel-account");
34
26
  Object.defineProperty(exports, "createKernel7702Account", { enumerable: true, get: function () { return kernel_account_1.createKernel7702Account; } });
35
27
  Object.defineProperty(exports, "createKernelAuthorization", { enumerable: true, get: function () { return kernel_account_1.createKernelAuthorization; } });
36
28
  Object.defineProperty(exports, "sendKernelTransaction", { enumerable: true, get: function () { return kernel_account_1.sendKernelTransaction; } });
37
29
  Object.defineProperty(exports, "sendBatchTransaction", { enumerable: true, get: function () { return kernel_account_1.sendBatchTransaction; } });
38
30
  Object.defineProperty(exports, "waitForKernelReceipt", { enumerable: true, get: function () { return kernel_account_1.waitForKernelReceipt; } });
39
- // Module Management (ERC-7579)
40
31
  var kernel_modules_1 = require("./lib/kernel-modules");
41
- // Prepare functions (for batching)
42
32
  Object.defineProperty(exports, "prepareInstallModule", { enumerable: true, get: function () { return kernel_modules_1.prepareInstallModule; } });
43
33
  Object.defineProperty(exports, "prepareUninstallModule", { enumerable: true, get: function () { return kernel_modules_1.prepareUninstallModule; } });
44
34
  Object.defineProperty(exports, "prepareInstallSessionKey", { enumerable: true, get: function () { return kernel_modules_1.prepareInstallSessionKey; } });
45
35
  Object.defineProperty(exports, "prepareRevokeSessionKey", { enumerable: true, get: function () { return kernel_modules_1.prepareRevokeSessionKey; } });
46
36
  Object.defineProperty(exports, "prepareInstallMultiSigValidator", { enumerable: true, get: function () { return kernel_modules_1.prepareInstallMultiSigValidator; } });
47
- // Execute functions (immediate execution)
48
37
  Object.defineProperty(exports, "installModule", { enumerable: true, get: function () { return kernel_modules_1.installModule; } });
49
38
  Object.defineProperty(exports, "uninstallModule", { enumerable: true, get: function () { return kernel_modules_1.uninstallModule; } });
50
39
  Object.defineProperty(exports, "isModuleInstalled", { enumerable: true, get: function () { return kernel_modules_1.isModuleInstalled; } });
@@ -52,7 +41,6 @@ Object.defineProperty(exports, "createSessionKey", { enumerable: true, get: func
52
41
  Object.defineProperty(exports, "revokeSessionKey", { enumerable: true, get: function () { return kernel_modules_1.revokeSessionKey; } });
53
42
  Object.defineProperty(exports, "installMultiSigValidator", { enumerable: true, get: function () { return kernel_modules_1.installMultiSigValidator; } });
54
43
  Object.defineProperty(exports, "MODULE_TYPE_IDS", { enumerable: true, get: function () { return kernel_modules_1.MODULE_TYPE_IDS; } });
55
- // EIP-7702 Session Keys (NEW Pattern)
56
44
  var session_keys_1 = require("./lib/session-keys");
57
45
  Object.defineProperty(exports, "generateSessionKey", { enumerable: true, get: function () { return session_keys_1.generateSessionKey; } });
58
46
  Object.defineProperty(exports, "createSessionKeyApproval", { enumerable: true, get: function () { return session_keys_1.createSessionKeyApproval; } });
@@ -60,8 +48,6 @@ Object.defineProperty(exports, "deserializeSessionKey", { enumerable: true, get:
60
48
  Object.defineProperty(exports, "createSessionKeyClient", { enumerable: true, get: function () { return session_keys_1.createSessionKeyClient; } });
61
49
  Object.defineProperty(exports, "createUSDCTransferPermission", { enumerable: true, get: function () { return session_keys_1.createUSDCTransferPermission; } });
62
50
  Object.defineProperty(exports, "createETHTransferPermission", { enumerable: true, get: function () { return session_keys_1.createETHTransferPermission; } });
63
- // Account Adapters (ZeroDev Integration)
64
51
  var account_adapter_1 = require("./lib/account-adapter");
65
52
  Object.defineProperty(exports, "adaptZeroDevAccount", { enumerable: true, get: function () { return account_adapter_1.adaptZeroDevAccount; } });
66
53
  Object.defineProperty(exports, "adaptSessionKeyAccount", { enumerable: true, get: function () { return account_adapter_1.adaptSessionKeyAccount; } });
67
- //# sourceMappingURL=index.js.map
@@ -1,26 +1,4 @@
1
- /**
2
- * Account Adapter
3
- *
4
- * Adapts ZeroDev's account objects to work with our service layer.
5
- * Normalizes the interface to match KernelAccountInstance.
6
- */
7
1
  import { Chain } from 'viem';
8
2
  import { KernelAccountInstance } from './kernel-account';
9
- /**
10
- * Adapt a ZeroDev account to our KernelAccountInstance interface
11
- *
12
- * ZeroDev's createKernelAccount returns a different structure than what
13
- * our service expects. This adapter normalizes it.
14
- *
15
- * @param account - The account from createKernelAccount
16
- * @param chain - The chain the account is on
17
- * @returns Normalized account that works with our service
18
- */
19
3
  export declare function adaptZeroDevAccount(account: any, chain: Chain): KernelAccountInstance;
20
- /**
21
- * Adapt a session key account specifically
22
- *
23
- * Session key accounts need special handling to ensure all properties
24
- * are properly set for transaction execution.
25
- */
26
4
  export declare function adaptSessionKeyAccount(sessionKeyAccount: any, masterAccount: KernelAccountInstance): KernelAccountInstance;
@@ -1,24 +1,8 @@
1
1
  "use strict";
2
- /**
3
- * Account Adapter
4
- *
5
- * Adapts ZeroDev's account objects to work with our service layer.
6
- * Normalizes the interface to match KernelAccountInstance.
7
- */
8
2
  Object.defineProperty(exports, "__esModule", { value: true });
9
3
  exports.adaptZeroDevAccount = adaptZeroDevAccount;
10
4
  exports.adaptSessionKeyAccount = adaptSessionKeyAccount;
11
5
  const account_abstraction_1 = require("viem/account-abstraction");
12
- /**
13
- * Adapt a ZeroDev account to our KernelAccountInstance interface
14
- *
15
- * ZeroDev's createKernelAccount returns a different structure than what
16
- * our service expects. This adapter normalizes it.
17
- *
18
- * @param account - The account from createKernelAccount
19
- * @param chain - The chain the account is on
20
- * @returns Normalized account that works with our service
21
- */
22
6
  function adaptZeroDevAccount(account, chain) {
23
7
  return {
24
8
  ...account,
@@ -29,14 +13,7 @@ function adaptZeroDevAccount(account, chain) {
29
13
  }
30
14
  };
31
15
  }
32
- /**
33
- * Adapt a session key account specifically
34
- *
35
- * Session key accounts need special handling to ensure all properties
36
- * are properly set for transaction execution.
37
- */
38
16
  function adaptSessionKeyAccount(sessionKeyAccount, masterAccount) {
39
- // Ensure entryPoint is properly defined
40
17
  const entryPoint = sessionKeyAccount.entryPoint || masterAccount.entryPoint || {
41
18
  address: account_abstraction_1.entryPoint07Address,
42
19
  version: '0.7'
@@ -50,4 +27,3 @@ function adaptSessionKeyAccount(sessionKeyAccount, masterAccount) {
50
27
  }
51
28
  };
52
29
  }
53
- //# sourceMappingURL=account-adapter.js.map