@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
@@ -12,7 +12,13 @@
12
12
  "Bash(wait)",
13
13
  "WebSearch",
14
14
  "WebFetch(domain:docs.pimlico.io)",
15
- "WebFetch(domain:docs.railgun.org)"
15
+ "WebFetch(domain:docs.railgun.org)",
16
+ "Bash(time npm run build:*)",
17
+ "Bash(curl:*)",
18
+ "Bash(bash)",
19
+ "Bash(bun:*)",
20
+ "Bash(time bun install:*)",
21
+ "Bash(time bun run build:*)"
16
22
  ],
17
23
  "deny": [],
18
24
  "ask": []
@@ -0,0 +1,640 @@
1
+ # Build Time Optimization Plan
2
+
3
+ **Current Build Time**: 1 minute 51 seconds (111s)
4
+ **Target Build Time**: <10 seconds
5
+ **Files**: 49 TypeScript files
6
+ **Dependencies**: 187MB node_modules
7
+
8
+ ## 🎯 Performance Analysis
9
+
10
+ ### Current Bottlenecks
11
+ 1. **TypeScript Compilation**: 110.24s user time (96% of total)
12
+ 2. **Source Maps**: Enabled (adds overhead)
13
+ 3. **Strict Mode**: All strict checks enabled (slower compilation)
14
+ 4. **Declaration Files**: Generating .d.ts for all files
15
+ 5. **No Incremental Builds**: Rebuilds everything every time
16
+ 6. **Package Manager**: npm (slower than alternatives)
17
+
18
+ ### Quick Wins vs Long-term Solutions
19
+
20
+ | Solution | Time Savings | Effort | Compatibility |
21
+ |----------|--------------|--------|---------------|
22
+ | **Incremental Builds** | 80-90% (after first) | Low | ✅ Perfect |
23
+ | **Switch to pnpm** | 20-30% | Low | ✅ Perfect |
24
+ | **Switch to Bun** | 50-70% | Low | ⚠️ Good |
25
+ | **SWC Instead of TSC** | 40-60% | Medium | ⚠️ Good |
26
+ | **Project References** | 30-50% | High | ✅ Perfect |
27
+ | **Disable Source Maps** | 10-20% | Low | ✅ Perfect |
28
+
29
+ ---
30
+
31
+ ## 🚀 TIER 1: Quick Wins (Implement Immediately)
32
+
33
+ ### 1. Enable TypeScript Incremental Builds
34
+
35
+ **Impact**: 🔥🔥🔥 **80-90% faster rebuilds** (after first build)
36
+ **Effort**: ⭐ **5 minutes**
37
+
38
+ **Implementation**:
39
+
40
+ ```json
41
+ // tsconfig.json
42
+ {
43
+ "compilerOptions": {
44
+ "target": "ES2022",
45
+ "module": "commonjs",
46
+ "declaration": true,
47
+ "outDir": "./dist",
48
+ "strict": true,
49
+ "esModuleInterop": true,
50
+ "skipLibCheck": true,
51
+ "forceConsistentCasingInFileNames": true,
52
+ "sourceMap": true,
53
+
54
+ // ✅ Add these for incremental builds
55
+ "incremental": true,
56
+ "tsBuildInfoFile": "./dist/.tsbuildinfo"
57
+ },
58
+ "include": ["utils/**/*"],
59
+ "exclude": ["node_modules", "**/*.spec.ts", "**/*.bak"]
60
+ }
61
+ ```
62
+
63
+ **Expected Result**:
64
+ - First build: ~111s (same)
65
+ - Subsequent builds: ~10-15s (90% faster!)
66
+
67
+ **Git Ignore**:
68
+ ```bash
69
+ # Add to .gitignore
70
+ dist/.tsbuildinfo
71
+ ```
72
+
73
+ ---
74
+
75
+ ### 2. Switch to pnpm (npm Alternative)
76
+
77
+ **Impact**: 🔥🔥 **20-30% faster installs and builds**
78
+ **Effort**: ⭐ **10 minutes**
79
+
80
+ **Why pnpm?**
81
+ - 2-3x faster than npm
82
+ - Efficient disk space usage (symlinks)
83
+ - Strict dependency resolution
84
+ - Drop-in npm replacement
85
+
86
+ **Installation**:
87
+ ```bash
88
+ # Install pnpm globally
89
+ npm install -g pnpm
90
+
91
+ # Or via Homebrew (macOS)
92
+ brew install pnpm
93
+ ```
94
+
95
+ **Migration**:
96
+ ```bash
97
+ # 1. Remove npm artifacts
98
+ rm -rf node_modules package-lock.json
99
+
100
+ # 2. Install with pnpm
101
+ pnpm install
102
+
103
+ # 3. Update scripts (optional - pnpm understands npm scripts)
104
+ # No changes needed to package.json!
105
+
106
+ # 4. Build with pnpm
107
+ pnpm run build
108
+ ```
109
+
110
+ **Update package.json** (optional):
111
+ ```json
112
+ {
113
+ "scripts": {
114
+ "build": "tsc -p tsconfig.json",
115
+ "build:fast": "tsc -p tsconfig.json --incremental"
116
+ },
117
+ "packageManager": "pnpm@9.0.0"
118
+ }
119
+ ```
120
+
121
+ **Expected Result**:
122
+ - Install time: 45s → 15s
123
+ - Build time: 111s → 75-85s
124
+
125
+ ---
126
+
127
+ ### 3. Optimize TypeScript Compiler Options
128
+
129
+ **Impact**: 🔥 **10-20% faster**
130
+ **Effort**: ⭐ **2 minutes**
131
+
132
+ ```json
133
+ // tsconfig.json - Production optimizations
134
+ {
135
+ "compilerOptions": {
136
+ "target": "ES2022",
137
+ "module": "commonjs",
138
+ "declaration": true,
139
+ "outDir": "./dist",
140
+ "esModuleInterop": true,
141
+ "forceConsistentCasingInFileNames": true,
142
+
143
+ // ✅ Performance optimizations
144
+ "incremental": true,
145
+ "tsBuildInfoFile": "./dist/.tsbuildinfo",
146
+ "skipLibCheck": true, // ✅ Already enabled
147
+ "skipDefaultLibCheck": true, // ✅ Add this
148
+
149
+ // ✅ Conditional strict mode (dev vs prod)
150
+ "strict": true,
151
+
152
+ // ⚠️ Optional: Disable source maps for production
153
+ // "sourceMap": false, // Uncomment for 10-15% speed boost
154
+ "sourceMap": true, // Keep for development
155
+
156
+ // ✅ Faster module resolution
157
+ "moduleResolution": "node",
158
+ "resolveJsonModule": true,
159
+
160
+ "lib": ["ES2022", "DOM"]
161
+ },
162
+ "include": ["utils/**/*"],
163
+ "exclude": ["node_modules", "**/*.spec.ts", "**/*.bak", "**/*.test.ts"]
164
+ }
165
+ ```
166
+
167
+ **Create Separate Configs**:
168
+
169
+ ```json
170
+ // tsconfig.prod.json - Fast production builds
171
+ {
172
+ "extends": "./tsconfig.json",
173
+ "compilerOptions": {
174
+ "sourceMap": false, // No source maps
175
+ "removeComments": true, // Strip comments
176
+ "declaration": true, // Keep .d.ts files
177
+ "declarationMap": false // No .d.ts.map files
178
+ }
179
+ }
180
+ ```
181
+
182
+ ```json
183
+ // tsconfig.dev.json - Development with all features
184
+ {
185
+ "extends": "./tsconfig.json",
186
+ "compilerOptions": {
187
+ "sourceMap": true,
188
+ "removeComments": false,
189
+ "declaration": true,
190
+ "declarationMap": true
191
+ }
192
+ }
193
+ ```
194
+
195
+ **Update package.json**:
196
+ ```json
197
+ {
198
+ "scripts": {
199
+ "build": "tsc -p tsconfig.prod.json",
200
+ "build:dev": "tsc -p tsconfig.dev.json",
201
+ "build:watch": "tsc -p tsconfig.dev.json --watch"
202
+ }
203
+ }
204
+ ```
205
+
206
+ ---
207
+
208
+ ## 🔥 TIER 2: Moderate Improvements (Implement This Week)
209
+
210
+ ### 4. Switch to Bun Runtime (Fastest Option)
211
+
212
+ **Impact**: 🔥🔥🔥 **50-70% faster than npm**
213
+ **Effort**: ⭐⭐ **15 minutes**
214
+ **Compatibility**: ⚠️ **95% (minor edge cases)**
215
+
216
+ **Why Bun?**
217
+ - 10-100x faster than npm/pnpm
218
+ - Built-in TypeScript support
219
+ - Drop-in Node.js replacement
220
+ - Ultra-fast package manager
221
+
222
+ **Installation**:
223
+ ```bash
224
+ # macOS/Linux
225
+ curl -fsSL https://bun.sh/install | bash
226
+
227
+ # Or via Homebrew
228
+ brew install oven-sh/bun/bun
229
+ ```
230
+
231
+ **Migration**:
232
+ ```bash
233
+ # 1. Remove existing artifacts
234
+ rm -rf node_modules package-lock.json pnpm-lock.yaml
235
+
236
+ # 2. Install with Bun
237
+ bun install
238
+
239
+ # 3. Build with Bun
240
+ bun run build
241
+
242
+ # Or use Bun's native TypeScript compilation (even faster!)
243
+ bun build utils/index.ts --outdir dist --target node
244
+ ```
245
+
246
+ **Update package.json for Bun**:
247
+ ```json
248
+ {
249
+ "scripts": {
250
+ "build": "tsc -p tsconfig.prod.json",
251
+ "build:bun": "bun build utils/index.ts --outdir dist --target node --format cjs --sourcemap",
252
+ "build:fast": "bun run build",
253
+ "dev": "bun --watch utils/index.ts"
254
+ },
255
+ "packageManager": "bun@1.0.0"
256
+ }
257
+ ```
258
+
259
+ **Expected Result**:
260
+ - Install time: 45s → 3-5s (10x faster!)
261
+ - Build time: 111s → 30-45s (2-3x faster!)
262
+
263
+ **Compatibility Notes**:
264
+ - ✅ Works with TypeScript
265
+ - ✅ Works with viem, ethers, Solana
266
+ - ⚠️ Some native modules may need Node.js
267
+ - ⚠️ Test thoroughly before production
268
+
269
+ ---
270
+
271
+ ### 5. Use SWC Instead of TypeScript Compiler
272
+
273
+ **Impact**: 🔥🔥🔥 **40-60% faster compilation**
274
+ **Effort**: ⭐⭐ **20 minutes**
275
+
276
+ **Why SWC?**
277
+ - 20-70x faster than tsc (written in Rust)
278
+ - Drop-in TypeScript compiler replacement
279
+ - Used by Next.js, Vite, etc.
280
+
281
+ **Installation**:
282
+ ```bash
283
+ pnpm add -D @swc/core @swc/cli
284
+ ```
285
+
286
+ **Configuration**:
287
+ ```json
288
+ // .swcrc
289
+ {
290
+ "jsc": {
291
+ "parser": {
292
+ "syntax": "typescript",
293
+ "tsx": false,
294
+ "decorators": false,
295
+ "dynamicImport": true
296
+ },
297
+ "target": "es2022",
298
+ "loose": false,
299
+ "externalHelpers": false,
300
+ "keepClassNames": true
301
+ },
302
+ "module": {
303
+ "type": "commonjs",
304
+ "strict": false,
305
+ "strictMode": true,
306
+ "lazy": false,
307
+ "noInterop": false
308
+ },
309
+ "sourceMaps": true
310
+ }
311
+ ```
312
+
313
+ **Update package.json**:
314
+ ```json
315
+ {
316
+ "scripts": {
317
+ "build": "tsc -p tsconfig.prod.json",
318
+ "build:swc": "swc utils -d dist --config-file .swcrc && tsc --emitDeclarationOnly",
319
+ "build:fast": "pnpm run build:swc"
320
+ }
321
+ }
322
+ ```
323
+
324
+ **Expected Result**:
325
+ - Build time: 111s → 40-60s (2x faster!)
326
+
327
+ **Trade-offs**:
328
+ - ⚠️ Still need tsc for .d.ts files
329
+ - ⚠️ Different error messages
330
+ - ✅ Production builds are identical
331
+
332
+ ---
333
+
334
+ ### 6. Implement Build Caching
335
+
336
+ **Impact**: 🔥🔥 **30-50% faster CI/CD builds**
337
+ **Effort**: ⭐⭐ **15 minutes**
338
+
339
+ **For Local Development**:
340
+ ```bash
341
+ # Install turbo (build system with caching)
342
+ pnpm add -D turbo
343
+ ```
344
+
345
+ ```json
346
+ // turbo.json
347
+ {
348
+ "$schema": "https://turbo.build/schema.json",
349
+ "pipeline": {
350
+ "build": {
351
+ "outputs": ["dist/**"],
352
+ "cache": true
353
+ }
354
+ }
355
+ }
356
+ ```
357
+
358
+ **Update package.json**:
359
+ ```json
360
+ {
361
+ "scripts": {
362
+ "build": "turbo run build",
363
+ "build:nocache": "turbo run build --force"
364
+ }
365
+ }
366
+ ```
367
+
368
+ **For GitHub Actions**:
369
+ ```yaml
370
+ # .github/workflows/build.yml
371
+ - name: Cache TypeScript build
372
+ uses: actions/cache@v3
373
+ with:
374
+ path: |
375
+ dist
376
+ .tsbuildinfo
377
+ key: ${{ runner.os }}-build-${{ hashFiles('utils/**/*.ts') }}
378
+ restore-keys: |
379
+ ${{ runner.os }}-build-
380
+ ```
381
+
382
+ ---
383
+
384
+ ## 🎯 TIER 3: Advanced Optimizations (Long-term)
385
+
386
+ ### 7. TypeScript Project References
387
+
388
+ **Impact**: 🔥🔥 **30-50% faster for large projects**
389
+ **Effort**: ⭐⭐⭐ **2 hours**
390
+ **Best For**: Monorepos or modular projects
391
+
392
+ **Split into Multiple Projects**:
393
+
394
+ ```
395
+ packages/
396
+ ├── core/
397
+ │ ├── tsconfig.json
398
+ │ └── utils/
399
+ ├── evm/
400
+ │ ├── tsconfig.json
401
+ │ └── utils/
402
+ ├── svm/
403
+ │ ├── tsconfig.json
404
+ │ └── utils/
405
+ └── tsconfig.json (root)
406
+ ```
407
+
408
+ ```json
409
+ // Root tsconfig.json
410
+ {
411
+ "files": [],
412
+ "references": [
413
+ { "path": "./core" },
414
+ { "path": "./evm" },
415
+ { "path": "./svm" }
416
+ ]
417
+ }
418
+ ```
419
+
420
+ ```json
421
+ // packages/core/tsconfig.json
422
+ {
423
+ "compilerOptions": {
424
+ "composite": true,
425
+ "outDir": "dist",
426
+ "rootDir": "utils"
427
+ }
428
+ }
429
+ ```
430
+
431
+ **Build**:
432
+ ```bash
433
+ tsc --build tsconfig.json
434
+ ```
435
+
436
+ **Benefits**:
437
+ - Parallel compilation
438
+ - Only rebuilds changed projects
439
+ - Better dependency management
440
+
441
+ ---
442
+
443
+ ### 8. Parallelize TypeScript Compilation
444
+
445
+ **Impact**: 🔥 **15-25% faster on multi-core systems**
446
+ **Effort**: ⭐⭐ **10 minutes**
447
+
448
+ ```bash
449
+ # Install fork-ts-checker-webpack-plugin alternative
450
+ pnpm add -D concurrently npm-run-all
451
+ ```
452
+
453
+ **Split Compilation**:
454
+ ```json
455
+ // package.json
456
+ {
457
+ "scripts": {
458
+ "build:core": "tsc -p tsconfig.core.json",
459
+ "build:evm": "tsc -p tsconfig.evm.json",
460
+ "build:svm": "tsc -p tsconfig.svm.json",
461
+ "build": "run-p build:*" // Parallel execution
462
+ }
463
+ }
464
+ ```
465
+
466
+ ---
467
+
468
+ ### 9. Use esbuild for Development
469
+
470
+ **Impact**: 🔥🔥🔥 **10-100x faster dev builds**
471
+ **Effort**: ⭐⭐ **20 minutes**
472
+ **Best For**: Development only (still use tsc for production)
473
+
474
+ ```bash
475
+ pnpm add -D esbuild esbuild-register
476
+ ```
477
+
478
+ ```json
479
+ // package.json
480
+ {
481
+ "scripts": {
482
+ "build": "tsc -p tsconfig.prod.json",
483
+ "build:dev": "esbuild utils/index.ts --bundle --platform=node --outfile=dist/index.js --sourcemap",
484
+ "dev": "esbuild utils/index.ts --bundle --platform=node --outfile=dist/index.js --watch"
485
+ }
486
+ }
487
+ ```
488
+
489
+ **Expected Result**:
490
+ - Dev build: 111s → 2-5s (20-50x faster!)
491
+ - Production: Still use tsc for type checking
492
+
493
+ ---
494
+
495
+ ## 📊 RECOMMENDED IMPLEMENTATION PLAN
496
+
497
+ ### Week 1 - Quick Wins (Immediate 80% improvement)
498
+
499
+ ```bash
500
+ # Day 1 - Enable incremental builds (5 min)
501
+ # Update tsconfig.json with incremental: true
502
+ git add tsconfig.json && git commit -m "feat: enable incremental builds"
503
+
504
+ # Day 1 - Switch to pnpm (10 min)
505
+ npm install -g pnpm
506
+ rm -rf node_modules package-lock.json
507
+ pnpm install
508
+ git add pnpm-lock.yaml && git commit -m "feat: migrate to pnpm"
509
+
510
+ # Day 2 - Optimize compiler options (5 min)
511
+ # Create tsconfig.prod.json
512
+ git add tsconfig.prod.json && git commit -m "feat: optimize prod build config"
513
+ ```
514
+
515
+ **Expected Results**:
516
+ - First build: ~111s
517
+ - Incremental builds: ~10-15s
518
+ - Install time: ~15s
519
+
520
+ ### Week 2 - Moderate Improvements (Additional 50% improvement)
521
+
522
+ ```bash
523
+ # Option A: Try Bun (fastest)
524
+ brew install oven-sh/bun/bun
525
+ bun install
526
+ bun run build
527
+
528
+ # Option B: Try SWC (most compatible)
529
+ pnpm add -D @swc/core @swc/cli
530
+ # Create .swcrc
531
+ pnpm run build:swc
532
+ ```
533
+
534
+ **Expected Results**:
535
+ - Bun: 30-45s total build time
536
+ - SWC: 40-60s total build time
537
+
538
+ ### Week 3+ - Advanced (If needed)
539
+
540
+ - Implement project references
541
+ - Add build caching for CI/CD
542
+ - Consider esbuild for development
543
+
544
+ ---
545
+
546
+ ## 🎯 TARGET BENCHMARKS
547
+
548
+ | Scenario | Current | Target | Method |
549
+ |----------|---------|--------|--------|
550
+ | **Clean Build** | 111s | 40-60s | pnpm + SWC |
551
+ | **Incremental Build** | 111s | 5-10s | incremental: true |
552
+ | **Install** | 45s | 5-10s | pnpm or Bun |
553
+ | **Dev Build** | 111s | 2-5s | esbuild |
554
+ | **CI/CD Build** | 111s | 30s | Cache + pnpm + SWC |
555
+
556
+ ---
557
+
558
+ ## 💡 IMMEDIATE ACTION ITEMS
559
+
560
+ ### Implement Right Now (< 10 minutes):
561
+
562
+ 1. **Enable Incremental Builds**:
563
+ ```bash
564
+ # Add to tsconfig.json:
565
+ "incremental": true,
566
+ "tsBuildInfoFile": "./dist/.tsbuildinfo"
567
+ ```
568
+
569
+ 2. **Switch to pnpm**:
570
+ ```bash
571
+ npm install -g pnpm
572
+ rm -rf node_modules package-lock.json
573
+ pnpm install
574
+ ```
575
+
576
+ 3. **Create Optimized Config**:
577
+ ```bash
578
+ # Copy tsconfig.json to tsconfig.prod.json
579
+ # Set sourceMap: false in prod config
580
+ # Update build script to use tsconfig.prod.json
581
+ ```
582
+
583
+ **After these 3 changes**:
584
+ - First build: ~80-90s (20% faster)
585
+ - Incremental builds: ~8-12s (90% faster!)
586
+ - This solves 95% of the problem for daily development
587
+
588
+ ---
589
+
590
+ ## 🔬 TESTING & VERIFICATION
591
+
592
+ ```bash
593
+ # Benchmark current build
594
+ time npm run build
595
+
596
+ # After implementing changes
597
+ time pnpm run build
598
+
599
+ # Test incremental build
600
+ touch utils/vm.ts
601
+ time pnpm run build # Should be ~10s
602
+
603
+ # Verify output
604
+ npm run build && node -e "require('./dist/index.js')"
605
+ ```
606
+
607
+ ---
608
+
609
+ ## 📝 NOTES
610
+
611
+ ### Don't Do This:
612
+ - ❌ Disable strict mode (loses type safety)
613
+ - ❌ Remove all source maps (makes debugging impossible)
614
+ - ❌ Skip type checking completely (defeats purpose of TypeScript)
615
+
616
+ ### Do This Instead:
617
+ - ✅ Use incremental builds
618
+ - ✅ Optimize for development vs production
619
+ - ✅ Cache aggressively
620
+ - ✅ Use faster tools (pnpm, Bun, SWC)
621
+
622
+ ---
623
+
624
+ ## 🎓 SUMMARY
625
+
626
+ **Best Bang for Buck** (Implement first):
627
+ 1. ⭐⭐⭐ Incremental builds (90% faster rebuilds)
628
+ 2. ⭐⭐⭐ Switch to pnpm (30% faster overall)
629
+ 3. ⭐⭐ Optimize compiler options (15% faster)
630
+
631
+ **For Maximum Speed** (If build time is critical):
632
+ 4. ⭐⭐⭐ Switch to Bun (70% faster than npm)
633
+ 5. ⭐⭐⭐ Use SWC instead of tsc (50% faster compilation)
634
+
635
+ **Expected Final Results**:
636
+ - Clean build: 40-60s (50% improvement)
637
+ - Incremental build: 5-10s (95% improvement)
638
+ - Daily development: Much faster!
639
+
640
+ Start with the Quick Wins (Week 1), measure improvements, then decide if you need more optimization.