jaelis-node 1.9.0 → 2.0.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 (173) hide show
  1. package/README.md +147 -433
  2. package/bin/jaelis-node.js +79 -504
  3. package/lib/index.js +31 -2740
  4. package/lib/node.js +271 -0
  5. package/lib/rpc.js +315 -0
  6. package/lib/storage.js +198 -0
  7. package/lib/sync.js +366 -0
  8. package/package.json +19 -53
  9. package/config/default.json +0 -74
  10. package/config/mainnet.json +0 -30
  11. package/config/testnet.json +0 -26
  12. package/lib/JAELIS-VM/lib/adapters/evm-adapter.js +0 -454
  13. package/lib/JAELIS-VM/lib/adapters/index.js +0 -411
  14. package/lib/JAELIS-VM/lib/adapters/svm-adapter.js +0 -457
  15. package/lib/JAELIS-VM/lib/compiler/jir-compiler.js +0 -1097
  16. package/lib/JAELIS-VM/lib/execution/engine.js +0 -1183
  17. package/lib/JAELIS-VM/lib/index.js +0 -440
  18. package/lib/JAELIS-VM/lib/integration/jaelis-integration.js +0 -543
  19. package/lib/JAELIS-VM/lib/serialization/serializer.js +0 -819
  20. package/lib/JAELIS-VM/lib/state/state-manager.js +0 -1116
  21. package/lib/JAELIS-VM/lib/translator/bytecode-translator.js +0 -1222
  22. package/lib/JAELIS-VM/lib/unified/cross-chain-deploy.js +0 -1678
  23. package/lib/JAELIS-VM/lib/unified/cross-chain-state.js +0 -836
  24. package/lib/JAELIS-VM/lib/unified/dynamic-contracts.js +0 -1127
  25. package/lib/JAELIS-VM/lib/unified/index.js +0 -456
  26. package/lib/JAELIS-VM/lib/unified/jaelis-abi.js +0 -1150
  27. package/lib/JAELIS-VM/lib/unified/unified-compiler.js +0 -1350
  28. package/lib/JAELIS-VM/node_modules/.bin/download-cbor-prebuilds +0 -12
  29. package/lib/JAELIS-VM/node_modules/.bin/download-cbor-prebuilds.cmd +0 -17
  30. package/lib/JAELIS-VM/node_modules/.bin/download-cbor-prebuilds.ps1 +0 -28
  31. package/lib/JAELIS-VM/node_modules/.bin/download-msgpackr-prebuilds +0 -12
  32. package/lib/JAELIS-VM/node_modules/.bin/download-msgpackr-prebuilds.cmd +0 -17
  33. package/lib/JAELIS-VM/node_modules/.bin/download-msgpackr-prebuilds.ps1 +0 -28
  34. package/lib/JAELIS-VM/node_modules/.bin/node-gyp-build-optional-packages +0 -12
  35. package/lib/JAELIS-VM/node_modules/.bin/node-gyp-build-optional-packages-optional +0 -12
  36. package/lib/JAELIS-VM/node_modules/.bin/node-gyp-build-optional-packages-optional.cmd +0 -17
  37. package/lib/JAELIS-VM/node_modules/.bin/node-gyp-build-optional-packages-optional.ps1 +0 -28
  38. package/lib/JAELIS-VM/node_modules/.bin/node-gyp-build-optional-packages-test +0 -12
  39. package/lib/JAELIS-VM/node_modules/.bin/node-gyp-build-optional-packages-test.cmd +0 -17
  40. package/lib/JAELIS-VM/node_modules/.bin/node-gyp-build-optional-packages-test.ps1 +0 -28
  41. package/lib/JAELIS-VM/node_modules/.bin/node-gyp-build-optional-packages.cmd +0 -17
  42. package/lib/JAELIS-VM/node_modules/.bin/node-gyp-build-optional-packages.ps1 +0 -28
  43. package/lib/JAELIS-VM/node_modules/.package-lock.json +0 -127
  44. package/lib/JAELIS-VM/node_modules/@cbor-extract/cbor-extract-win32-x64/README.md +0 -1
  45. package/lib/JAELIS-VM/node_modules/@cbor-extract/cbor-extract-win32-x64/index.js +0 -0
  46. package/lib/JAELIS-VM/node_modules/@cbor-extract/cbor-extract-win32-x64/node.abi115.node +0 -0
  47. package/lib/JAELIS-VM/node_modules/@cbor-extract/cbor-extract-win32-x64/node.napi.node +0 -0
  48. package/lib/JAELIS-VM/node_modules/@cbor-extract/cbor-extract-win32-x64/package.json +0 -17
  49. package/lib/JAELIS-VM/node_modules/@msgpackr-extract/msgpackr-extract-win32-x64/README.md +0 -1
  50. package/lib/JAELIS-VM/node_modules/@msgpackr-extract/msgpackr-extract-win32-x64/index.js +0 -0
  51. package/lib/JAELIS-VM/node_modules/@msgpackr-extract/msgpackr-extract-win32-x64/node.abi115.node +0 -0
  52. package/lib/JAELIS-VM/node_modules/@msgpackr-extract/msgpackr-extract-win32-x64/node.napi.node +0 -0
  53. package/lib/JAELIS-VM/node_modules/@msgpackr-extract/msgpackr-extract-win32-x64/package.json +0 -17
  54. package/lib/JAELIS-VM/node_modules/cbor-extract/LICENSE +0 -21
  55. package/lib/JAELIS-VM/node_modules/cbor-extract/README.md +0 -5
  56. package/lib/JAELIS-VM/node_modules/cbor-extract/bin/download-prebuilds.js +0 -11
  57. package/lib/JAELIS-VM/node_modules/cbor-extract/binding.gyp +0 -60
  58. package/lib/JAELIS-VM/node_modules/cbor-extract/index.js +0 -1
  59. package/lib/JAELIS-VM/node_modules/cbor-extract/package.json +0 -50
  60. package/lib/JAELIS-VM/node_modules/cbor-extract/src/extract.cpp +0 -198
  61. package/lib/JAELIS-VM/node_modules/cbor-x/LICENSE +0 -21
  62. package/lib/JAELIS-VM/node_modules/cbor-x/README.md +0 -380
  63. package/lib/JAELIS-VM/node_modules/cbor-x/SECURITY.md +0 -11
  64. package/lib/JAELIS-VM/node_modules/cbor-x/benchmark.md +0 -73
  65. package/lib/JAELIS-VM/node_modules/cbor-x/browser.js +0 -11
  66. package/lib/JAELIS-VM/node_modules/cbor-x/decode.d.ts +0 -2
  67. package/lib/JAELIS-VM/node_modules/cbor-x/decode.js +0 -1300
  68. package/lib/JAELIS-VM/node_modules/cbor-x/dist/decode-no-eval.cjs +0 -1244
  69. package/lib/JAELIS-VM/node_modules/cbor-x/dist/decode-no-eval.cjs.map +0 -1
  70. package/lib/JAELIS-VM/node_modules/cbor-x/dist/index-no-eval.cjs +0 -2509
  71. package/lib/JAELIS-VM/node_modules/cbor-x/dist/index-no-eval.cjs.map +0 -1
  72. package/lib/JAELIS-VM/node_modules/cbor-x/dist/index-no-eval.min.js +0 -2
  73. package/lib/JAELIS-VM/node_modules/cbor-x/dist/index-no-eval.min.js.map +0 -1
  74. package/lib/JAELIS-VM/node_modules/cbor-x/dist/index.js +0 -2508
  75. package/lib/JAELIS-VM/node_modules/cbor-x/dist/index.js.map +0 -1
  76. package/lib/JAELIS-VM/node_modules/cbor-x/dist/index.min.js +0 -2
  77. package/lib/JAELIS-VM/node_modules/cbor-x/dist/index.min.js.map +0 -1
  78. package/lib/JAELIS-VM/node_modules/cbor-x/dist/node.cjs +0 -2629
  79. package/lib/JAELIS-VM/node_modules/cbor-x/dist/node.cjs.map +0 -1
  80. package/lib/JAELIS-VM/node_modules/cbor-x/dist/test.js +0 -3343
  81. package/lib/JAELIS-VM/node_modules/cbor-x/dist/test.js.map +0 -1
  82. package/lib/JAELIS-VM/node_modules/cbor-x/encode.d.ts +0 -1
  83. package/lib/JAELIS-VM/node_modules/cbor-x/encode.js +0 -1231
  84. package/lib/JAELIS-VM/node_modules/cbor-x/index.d.ts +0 -79
  85. package/lib/JAELIS-VM/node_modules/cbor-x/index.js +0 -3
  86. package/lib/JAELIS-VM/node_modules/cbor-x/iterators.js +0 -85
  87. package/lib/JAELIS-VM/node_modules/cbor-x/node-index.js +0 -24
  88. package/lib/JAELIS-VM/node_modules/cbor-x/package.json +0 -94
  89. package/lib/JAELIS-VM/node_modules/cbor-x/rollup.config.js +0 -88
  90. package/lib/JAELIS-VM/node_modules/cbor-x/stream.js +0 -61
  91. package/lib/JAELIS-VM/node_modules/cbor-x/webpack.config.js +0 -19
  92. package/lib/JAELIS-VM/node_modules/detect-libc/LICENSE +0 -201
  93. package/lib/JAELIS-VM/node_modules/detect-libc/README.md +0 -163
  94. package/lib/JAELIS-VM/node_modules/detect-libc/index.d.ts +0 -14
  95. package/lib/JAELIS-VM/node_modules/detect-libc/lib/detect-libc.js +0 -313
  96. package/lib/JAELIS-VM/node_modules/detect-libc/lib/elf.js +0 -39
  97. package/lib/JAELIS-VM/node_modules/detect-libc/lib/filesystem.js +0 -51
  98. package/lib/JAELIS-VM/node_modules/detect-libc/lib/process.js +0 -24
  99. package/lib/JAELIS-VM/node_modules/detect-libc/package.json +0 -44
  100. package/lib/JAELIS-VM/node_modules/msgpackr/LICENSE +0 -21
  101. package/lib/JAELIS-VM/node_modules/msgpackr/README.md +0 -372
  102. package/lib/JAELIS-VM/node_modules/msgpackr/SECURITY.md +0 -11
  103. package/lib/JAELIS-VM/node_modules/msgpackr/benchmark.md +0 -67
  104. package/lib/JAELIS-VM/node_modules/msgpackr/dist/index-no-eval.cjs +0 -2407
  105. package/lib/JAELIS-VM/node_modules/msgpackr/dist/index-no-eval.cjs.map +0 -1
  106. package/lib/JAELIS-VM/node_modules/msgpackr/dist/index-no-eval.min.js +0 -2
  107. package/lib/JAELIS-VM/node_modules/msgpackr/dist/index-no-eval.min.js.map +0 -1
  108. package/lib/JAELIS-VM/node_modules/msgpackr/dist/index.js +0 -2406
  109. package/lib/JAELIS-VM/node_modules/msgpackr/dist/index.js.map +0 -1
  110. package/lib/JAELIS-VM/node_modules/msgpackr/dist/index.min.js +0 -2
  111. package/lib/JAELIS-VM/node_modules/msgpackr/dist/index.min.js.map +0 -1
  112. package/lib/JAELIS-VM/node_modules/msgpackr/dist/node.cjs +0 -3320
  113. package/lib/JAELIS-VM/node_modules/msgpackr/dist/node.cjs.map +0 -1
  114. package/lib/JAELIS-VM/node_modules/msgpackr/dist/test.js +0 -4540
  115. package/lib/JAELIS-VM/node_modules/msgpackr/dist/test.js.map +0 -1
  116. package/lib/JAELIS-VM/node_modules/msgpackr/dist/unpack-no-eval.cjs +0 -1250
  117. package/lib/JAELIS-VM/node_modules/msgpackr/dist/unpack-no-eval.cjs.map +0 -1
  118. package/lib/JAELIS-VM/node_modules/msgpackr/index.d.cts +0 -91
  119. package/lib/JAELIS-VM/node_modules/msgpackr/index.d.ts +0 -91
  120. package/lib/JAELIS-VM/node_modules/msgpackr/index.js +0 -5
  121. package/lib/JAELIS-VM/node_modules/msgpackr/iterators.js +0 -87
  122. package/lib/JAELIS-VM/node_modules/msgpackr/node-index.js +0 -25
  123. package/lib/JAELIS-VM/node_modules/msgpackr/pack.d.cts +0 -1
  124. package/lib/JAELIS-VM/node_modules/msgpackr/pack.d.ts +0 -1
  125. package/lib/JAELIS-VM/node_modules/msgpackr/pack.js +0 -1141
  126. package/lib/JAELIS-VM/node_modules/msgpackr/package.json +0 -104
  127. package/lib/JAELIS-VM/node_modules/msgpackr/rollup.config.js +0 -88
  128. package/lib/JAELIS-VM/node_modules/msgpackr/stream.js +0 -57
  129. package/lib/JAELIS-VM/node_modules/msgpackr/struct.js +0 -815
  130. package/lib/JAELIS-VM/node_modules/msgpackr/test-worker.js +0 -3
  131. package/lib/JAELIS-VM/node_modules/msgpackr/unpack.d.cts +0 -2
  132. package/lib/JAELIS-VM/node_modules/msgpackr/unpack.d.ts +0 -2
  133. package/lib/JAELIS-VM/node_modules/msgpackr/unpack.js +0 -1221
  134. package/lib/JAELIS-VM/node_modules/msgpackr-extract/LICENSE +0 -21
  135. package/lib/JAELIS-VM/node_modules/msgpackr-extract/README.md +0 -5
  136. package/lib/JAELIS-VM/node_modules/msgpackr-extract/bin/download-prebuilds.js +0 -13
  137. package/lib/JAELIS-VM/node_modules/msgpackr-extract/binding.gyp +0 -63
  138. package/lib/JAELIS-VM/node_modules/msgpackr-extract/index.js +0 -1
  139. package/lib/JAELIS-VM/node_modules/msgpackr-extract/node_modules/.bin/node-gyp-build-optional-packages +0 -12
  140. package/lib/JAELIS-VM/node_modules/msgpackr-extract/node_modules/.bin/node-gyp-build-optional-packages-optional +0 -12
  141. package/lib/JAELIS-VM/node_modules/msgpackr-extract/node_modules/.bin/node-gyp-build-optional-packages-optional.cmd +0 -17
  142. package/lib/JAELIS-VM/node_modules/msgpackr-extract/node_modules/.bin/node-gyp-build-optional-packages-optional.ps1 +0 -28
  143. package/lib/JAELIS-VM/node_modules/msgpackr-extract/node_modules/.bin/node-gyp-build-optional-packages-test +0 -12
  144. package/lib/JAELIS-VM/node_modules/msgpackr-extract/node_modules/.bin/node-gyp-build-optional-packages-test.cmd +0 -17
  145. package/lib/JAELIS-VM/node_modules/msgpackr-extract/node_modules/.bin/node-gyp-build-optional-packages-test.ps1 +0 -28
  146. package/lib/JAELIS-VM/node_modules/msgpackr-extract/node_modules/.bin/node-gyp-build-optional-packages.cmd +0 -17
  147. package/lib/JAELIS-VM/node_modules/msgpackr-extract/node_modules/.bin/node-gyp-build-optional-packages.ps1 +0 -28
  148. package/lib/JAELIS-VM/node_modules/msgpackr-extract/node_modules/node-gyp-build-optional-packages/LICENSE +0 -21
  149. package/lib/JAELIS-VM/node_modules/msgpackr-extract/node_modules/node-gyp-build-optional-packages/README.md +0 -58
  150. package/lib/JAELIS-VM/node_modules/msgpackr-extract/node_modules/node-gyp-build-optional-packages/bin.js +0 -82
  151. package/lib/JAELIS-VM/node_modules/msgpackr-extract/node_modules/node-gyp-build-optional-packages/build-test.js +0 -19
  152. package/lib/JAELIS-VM/node_modules/msgpackr-extract/node_modules/node-gyp-build-optional-packages/index.js +0 -6
  153. package/lib/JAELIS-VM/node_modules/msgpackr-extract/node_modules/node-gyp-build-optional-packages/node-gyp-build.js +0 -236
  154. package/lib/JAELIS-VM/node_modules/msgpackr-extract/node_modules/node-gyp-build-optional-packages/optional.js +0 -7
  155. package/lib/JAELIS-VM/node_modules/msgpackr-extract/node_modules/node-gyp-build-optional-packages/package.json +0 -32
  156. package/lib/JAELIS-VM/node_modules/msgpackr-extract/package.json +0 -50
  157. package/lib/JAELIS-VM/node_modules/msgpackr-extract/src/extract.cpp +0 -274
  158. package/lib/JAELIS-VM/node_modules/node-gyp-build-optional-packages/LICENSE +0 -21
  159. package/lib/JAELIS-VM/node_modules/node-gyp-build-optional-packages/README.md +0 -58
  160. package/lib/JAELIS-VM/node_modules/node-gyp-build-optional-packages/bin.js +0 -77
  161. package/lib/JAELIS-VM/node_modules/node-gyp-build-optional-packages/build-test.js +0 -19
  162. package/lib/JAELIS-VM/node_modules/node-gyp-build-optional-packages/index.js +0 -224
  163. package/lib/JAELIS-VM/node_modules/node-gyp-build-optional-packages/optional.js +0 -7
  164. package/lib/JAELIS-VM/node_modules/node-gyp-build-optional-packages/package.json +0 -32
  165. package/lib/JAELIS-VM/package-lock.json +0 -284
  166. package/lib/JAELIS-VM/package.json +0 -38
  167. package/lib/JAELIS-VM/test/comprehensive.test.js +0 -267
  168. package/lib/JAELIS-VM/test/cross-chain-test.js +0 -470
  169. package/lib/JAELIS-VM/test/unified-vm-test.js +0 -459
  170. package/lib/JAELIS-VM/test/unified.test.js +0 -166
  171. package/lib/JAELIS-VM/test/vm.test.js +0 -599
  172. package/lib/settlement-server.js +0 -999
  173. package/lib/vm/index.js +0 -397
@@ -1,456 +0,0 @@
1
- /**
2
- * JAELIS UNIFIED VM
3
- *
4
- * TRUE cross-chain interoperability:
5
- * - NO BRIDGES
6
- * - NO ADAPTERS
7
- * - NO TRANSLATION AT RUNTIME
8
- * - ONE ABI FOR ALL
9
- * - CHAIN-ID NAMESPACED STORAGE FOR UNIVERSAL SETTLEMENT
10
- *
11
- * Just... code that works together.
12
- *
13
- * @version 0.4.0
14
- * @author Mario Papaleo - JAELIS Foundation
15
- */
16
-
17
- const { UnifiedCompiler, UNIFIED_TYPES, AST_NODES } = require('./unified-compiler');
18
- const { DynamicContract, DynamicContractManager, ContractStateStore } = require('./dynamic-contracts');
19
- const { JaelisABI, JaelisABIEncoder, JaelisABIDecoder, ABIConverter, JAELIS_TYPES } = require('./jaelis-abi');
20
- const {
21
- CrossChainStateStore,
22
- CrossChainSettlementManager,
23
- CrossChainExecutor,
24
- LightClientInterface,
25
- EVMLightClient,
26
- SVMLightClient,
27
- CHAIN_REGISTRY,
28
- CROSS_CHAIN_OPCODES
29
- } = require('./cross-chain-state');
30
-
31
- // Cross-Chain Deployment Manager (OUTBOUND propagation!)
32
- const { CrossChainDeployManager } = require('./cross-chain-deploy');
33
-
34
- /**
35
- * Unified JAELIS VM
36
- *
37
- * The next evolution - contracts from ALL languages
38
- * running together in ONE VM, sharing state DIRECTLY.
39
- *
40
- * NO ADAPTERS. NO BRIDGES. ONE SYSTEM.
41
- * CHAIN-ID NAMESPACED STORAGE FOR UNIVERSAL SETTLEMENT.
42
- */
43
- class UnifiedJaelisVM {
44
- constructor(config = {}) {
45
- this.config = config;
46
-
47
- // Unified compiler (handles ALL languages)
48
- this.compiler = new UnifiedCompiler(config);
49
-
50
- // Dynamic contract manager
51
- this.contractManager = new DynamicContractManager();
52
-
53
- // Shared state (ALL contracts share this!)
54
- this.sharedState = new ContractStateStore();
55
-
56
- // Cross-chain settlement manager (THE KEY INNOVATION!)
57
- // Default to testnet (4545) since that's what's live - mainnet is 4547
58
- this.crossChainManager = new CrossChainSettlementManager({
59
- nativeChainId: config.chainId || CHAIN_REGISTRY.JAELIS_TESTNET.id,
60
- autoRegisterLightClients: config.autoRegisterLightClients !== false
61
- });
62
-
63
- // Cross-chain deployment manager (OUTBOUND propagation!)
64
- // When you deploy on JAELIS, contracts appear on ETH/SOL/etc explorers!
65
- this.deployManager = new CrossChainDeployManager({
66
- nativeChainId: config.chainId || CHAIN_REGISTRY.JAELIS_TESTNET.id,
67
- lightClients: this.crossChainManager.stateStore.lightClients
68
- });
69
-
70
- // JAELIS ABI (ONE ABI for all!)
71
- this.abi = JaelisABI;
72
-
73
- // Native chain ID (4545 = testnet [live], 4547 = mainnet [upcoming])
74
- this.chainId = config.chainId || CHAIN_REGISTRY.JAELIS_TESTNET.id;
75
-
76
- // Stats
77
- this.stats = {
78
- contractsDeployed: 0,
79
- crossCalls: 0,
80
- upgrades: 0,
81
- crossChainSettlements: 0,
82
- gasUsed: 0 // Always 0 - ZERO FEES!
83
- };
84
-
85
- console.log('═══════════════════════════════════════════════════════════════');
86
- console.log(' JAELIS UNIFIED VM v0.4.0');
87
- console.log(' TRUE CROSS-CHAIN INTEROPERABILITY');
88
- console.log('═══════════════════════════════════════════════════════════════');
89
- console.log(` Chain ID: ${this.chainId} (${this.getChainName(this.chainId)})`);
90
- console.log(' ✓ NO BRIDGES - Direct contract-to-contract calls');
91
- console.log(' ✓ NO ADAPTERS - One unified system');
92
- console.log(' ✓ ONE ABI - JAELIS ABI for all languages');
93
- console.log(' ✓ DYNAMIC CONTRACTS - Auto-update when VMs change');
94
- console.log(' ✓ SHARED STATE - All contracts, one memory space');
95
- console.log(' ✓ CHAIN-ID NAMESPACED STORAGE - Universal settlement');
96
- console.log(' ✓ LIGHT CLIENT VERIFICATION - Trustless external state');
97
- console.log(' ✓ ZERO FEES - Always free execution');
98
- console.log(' ✓ CROSS-CHAIN DEPLOY - Contracts appear on ALL explorers!');
99
- console.log('═══════════════════════════════════════════════════════════════');
100
- }
101
-
102
- /**
103
- * Get chain name from ID
104
- */
105
- getChainName(chainId) {
106
- const chain = Object.values(CHAIN_REGISTRY).find(c => c.id === chainId);
107
- return chain ? chain.name : 'Unknown';
108
- }
109
-
110
- /**
111
- * Deploy a contract in ANY language
112
- */
113
- async deploy(source, language, options = {}) {
114
- const result = await this.contractManager.deploy(source, language, options);
115
- this.stats.contractsDeployed++;
116
- return result;
117
- }
118
-
119
- /**
120
- * Compile multiple contracts together
121
- *
122
- * The magic: They can all call each other DIRECTLY
123
- */
124
- async compileBundle(sources) {
125
- return this.compiler.compile(sources);
126
- }
127
-
128
- /**
129
- * Deploy unified contract with cross-chain propagation
130
- *
131
- * THE FULL FLOW:
132
- * 1. Compile all sources into unified JIR bytecode
133
- * 2. Deploy to JAELIS (native)
134
- * 3. Propagate to target chains (ETH, SOL, etc.)
135
- * 4. Return deployment info with explorer URLs
136
- *
137
- * @param {Object} params - Deployment parameters
138
- * @param {string} params.from - Deployer address
139
- * @param {Array} params.sources - [{ code, language, name }...]
140
- * @param {Array<number>} params.targetChains - Chain IDs to deploy to
141
- */
142
- async deployUnifiedWithPropagation(params) {
143
- const { from, sources, targetChains } = params;
144
-
145
- console.log(`[UnifiedVM] Deploying unified bundle with propagation...`);
146
- console.log(`[UnifiedVM] Sources: ${sources.length} contracts`);
147
- console.log(`[UnifiedVM] Languages: ${[...new Set(sources.map(s => s.language))].join(', ')}`);
148
- console.log(`[UnifiedVM] Target chains: ${targetChains?.length || 0}`);
149
-
150
- // Step 1: Compile all sources
151
- const compiled = await this.compileBundle(sources);
152
-
153
- // Step 2: Deploy with cross-chain propagation
154
- const deployment = await this.deployManager.deployToChains({
155
- from,
156
- bytecode: compiled.bytecode,
157
- abi: compiled.abi || [],
158
- targetChains: targetChains || [],
159
- metadata: {
160
- sources: sources.map(s => ({ name: s.name, language: s.language })),
161
- compiledAt: Date.now(),
162
- version: '1.0.0'
163
- }
164
- });
165
-
166
- this.stats.contractsDeployed++;
167
-
168
- // Build explorer URLs for each chain
169
- const explorerUrls = {};
170
- for (const chainDeploy of deployment.deployments) {
171
- const url = this.deployManager.getExplorerUrl(chainDeploy.chainId, chainDeploy.address);
172
- if (url) {
173
- explorerUrls[chainDeploy.chainId] = url;
174
- }
175
- }
176
-
177
- console.log(`[UnifiedVM] Deployment complete!`);
178
- console.log(`[UnifiedVM] JAELIS address: ${deployment.jaelisAddress}`);
179
- console.log(`[UnifiedVM] Chain deployments: ${deployment.deployments.length}`);
180
-
181
- return {
182
- address: deployment.jaelisAddress,
183
- bytecode: compiled.bytecode?.toString('hex'),
184
- abi: compiled.abi || [],
185
- deployments: deployment.deployments,
186
- explorerUrls,
187
- metadata: deployment.metadata,
188
- gasUsed: 0 // ZERO FEES!
189
- };
190
- }
191
-
192
- /**
193
- * Execute a function on ANY contract
194
- */
195
- async execute(address, functionName, args = [], context = {}) {
196
- const contract = this.contractManager.contracts.get(address);
197
- if (!contract) {
198
- throw new Error(`Contract not found: ${address}`);
199
- }
200
-
201
- // Get function
202
- const func = contract.interface.functions.get(functionName);
203
- if (!func) {
204
- throw new Error(`Function not found: ${functionName}`);
205
- }
206
-
207
- console.log(`[UnifiedVM] Executing ${address.substring(0, 10)}...::${functionName}`);
208
-
209
- // Encode args using JAELIS ABI (ONE encoding for all!)
210
- const encodedArgs = args.length > 0
211
- ? JaelisABI.encodeMultiple(args, func.params?.map(p => p.type) || [])
212
- : Buffer.alloc(0);
213
-
214
- // Execute (would run actual bytecode)
215
- return {
216
- success: true,
217
- returnValue: null,
218
- gasUsed: 0, // ZERO FEES!
219
- logs: []
220
- };
221
- }
222
-
223
- /**
224
- * Direct cross-contract call (NO BRIDGES! NO ADAPTERS!)
225
- *
226
- * This is THE key innovation - contracts talk directly
227
- */
228
- async crossCall(fromAddress, toAddress, functionName, args = []) {
229
- this.stats.crossCalls++;
230
-
231
- console.log(`[UnifiedVM] Cross-call: ${fromAddress.substring(0, 10)}... → ${toAddress.substring(0, 10)}...::${functionName}`);
232
- console.log(`[UnifiedVM] NO BRIDGE! NO ADAPTER! Direct execution.`);
233
-
234
- return this.contractManager.crossContractCall(fromAddress, toAddress, functionName, args);
235
- }
236
-
237
- /**
238
- * Encode function call using JAELIS ABI
239
- */
240
- encodeCall(functionName, args, argTypes) {
241
- return JaelisABI.encodeFunctionCall(functionName, args, argTypes);
242
- }
243
-
244
- /**
245
- * Decode return value using JAELIS ABI
246
- */
247
- decodeReturn(buffer) {
248
- return JaelisABI.decode(buffer);
249
- }
250
-
251
- /**
252
- * Get function selector
253
- */
254
- getSelector(functionName, argTypes = []) {
255
- return JaelisABI.computeSelector(functionName, argTypes);
256
- }
257
-
258
- /**
259
- * Update VM specs (triggers auto-upgrade of affected contracts)
260
- */
261
- async upgradeVM(vm, newVersion) {
262
- const affected = await this.contractManager.updateVMSpec(vm, newVersion);
263
- this.stats.upgrades += affected.length;
264
- return affected;
265
- }
266
-
267
- /**
268
- * Read shared state
269
- */
270
- async readState(address, slot) {
271
- return this.contractManager.sharedStateRead(address, slot);
272
- }
273
-
274
- /**
275
- * Write shared state
276
- */
277
- async writeState(address, slot, value, caller) {
278
- return this.contractManager.sharedStateWrite(address, slot, value, caller);
279
- }
280
-
281
- /**
282
- * Get all deployed contracts
283
- */
284
- getContracts() {
285
- return this.contractManager.getAllContracts();
286
- }
287
-
288
- /**
289
- * Get dependency graph
290
- */
291
- getDependencyGraph() {
292
- return this.contractManager.getDependencyGraph();
293
- }
294
-
295
- /**
296
- * Get stats
297
- */
298
- getStats() {
299
- return {
300
- ...this.stats,
301
- contracts: this.contractManager.contracts.size,
302
- vmSpecs: this.contractManager.vmSpecs,
303
- crossChain: this.crossChainManager.getStats()
304
- };
305
- }
306
-
307
- /**
308
- * Convert from other ABI formats to JAELIS ABI
309
- */
310
- static convertABI(abi, format) {
311
- switch (format) {
312
- case 'solidity':
313
- case 'evm':
314
- return ABIConverter.fromSolidityABI(abi);
315
- case 'anchor':
316
- case 'solana':
317
- case 'svm':
318
- return ABIConverter.fromAnchorIDL(abi);
319
- case 'move':
320
- case 'aptos':
321
- case 'sui':
322
- return ABIConverter.fromMoveABI(abi);
323
- default:
324
- return abi;
325
- }
326
- }
327
-
328
- // ═══════════════════════════════════════════════════════════════
329
- // CROSS-CHAIN SETTLEMENT API
330
- // ═══════════════════════════════════════════════════════════════
331
-
332
- /**
333
- * Compute chain-namespaced storage slot
334
- *
335
- * Formula: sha256(chainId || contractAddress || variableName)
336
- *
337
- * This enables state from different chains to coexist without collision
338
- */
339
- computeCrossChainSlot(chainId, contractAddress, variableName) {
340
- return this.crossChainManager.computeSlot(chainId, contractAddress, variableName);
341
- }
342
-
343
- /**
344
- * Settle external chain state with proof
345
- *
346
- * This is THE KEY OPERATION for cross-chain interop:
347
- * 1. User provides state proof from external chain (ETH, SOL, etc.)
348
- * 2. Light client verifies the proof
349
- * 3. State is written to JAELIS with chain ID namespace
350
- * 4. Now JAELIS contracts can use external chain state!
351
- *
352
- * @param {number} chainId - External chain ID (1 for ETH, 501 for SOL, etc.)
353
- * @param {string} contractAddress - Contract address on external chain
354
- * @param {string} variableName - Variable/slot name
355
- * @param {Buffer} value - State value
356
- * @param {Buffer} proof - Merkle proof from external chain
357
- */
358
- async settleExternalState(chainId, contractAddress, variableName, value, proof) {
359
- const result = await this.crossChainManager.settle(chainId, contractAddress, variableName, value, proof);
360
- this.stats.crossChainSettlements++;
361
- return result;
362
- }
363
-
364
- /**
365
- * Read cross-chain state
366
- *
367
- * Can read state from any chain that has been settled
368
- */
369
- readCrossChainState(chainId, contractAddress, variableName) {
370
- return this.crossChainManager.readState(chainId, contractAddress, variableName);
371
- }
372
-
373
- /**
374
- * Write cross-chain state (native chain only)
375
- */
376
- writeCrossChainState(contractAddress, variableName, value) {
377
- return this.crossChainManager.writeState(contractAddress, variableName, value);
378
- }
379
-
380
- /**
381
- * Update light client for external chain
382
- *
383
- * Relayers call this to keep the light client up to date
384
- */
385
- async updateLightClient(chainId, headers) {
386
- return this.crossChainManager.updateLightClient(chainId, headers);
387
- }
388
-
389
- /**
390
- * Get chain info
391
- */
392
- getChainInfo(chainId) {
393
- return this.crossChainManager.getChainInfo(chainId);
394
- }
395
-
396
- /**
397
- * Get all registered chains
398
- */
399
- getAllChains() {
400
- return this.crossChainManager.getAllChains();
401
- }
402
-
403
- /**
404
- * Get state diff between same contract on two chains
405
- *
406
- * Useful for: arbitrage detection, reconciliation, sync verification
407
- */
408
- getCrossChainStateDiff(chainId1, chainId2, contractAddress, variableNames) {
409
- return this.crossChainManager.stateStore.getStateDiff(chainId1, chainId2, contractAddress, variableNames);
410
- }
411
-
412
- /**
413
- * Get cross-chain opcodes for compiler integration
414
- */
415
- getCrossChainOpcodes() {
416
- return CROSS_CHAIN_OPCODES;
417
- }
418
-
419
- /**
420
- * Get cross-chain executor for bytecode integration
421
- */
422
- getCrossChainExecutor() {
423
- return this.crossChainManager.getExecutor();
424
- }
425
- }
426
-
427
- module.exports = {
428
- UnifiedJaelisVM,
429
- UnifiedCompiler,
430
- DynamicContract,
431
- DynamicContractManager,
432
-
433
- // JAELIS ABI (THE unified encoding)
434
- JaelisABI,
435
- JaelisABIEncoder,
436
- JaelisABIDecoder,
437
- ABIConverter,
438
-
439
- // Cross-Chain Settlement (INBOUND - reading external state)
440
- CrossChainStateStore,
441
- CrossChainSettlementManager,
442
- CrossChainExecutor,
443
- LightClientInterface,
444
- EVMLightClient,
445
- SVMLightClient,
446
- CHAIN_REGISTRY,
447
- CROSS_CHAIN_OPCODES,
448
-
449
- // Cross-Chain Deployment (OUTBOUND - propagating to external chains!)
450
- CrossChainDeployManager,
451
-
452
- // Types
453
- UNIFIED_TYPES,
454
- JAELIS_TYPES,
455
- AST_NODES
456
- };