jaelis-node 1.3.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 (162) hide show
  1. package/README.md +97 -8
  2. package/lib/JAELIS-VM/lib/adapters/evm-adapter.js +454 -0
  3. package/lib/JAELIS-VM/lib/adapters/index.js +411 -0
  4. package/lib/JAELIS-VM/lib/adapters/svm-adapter.js +457 -0
  5. package/lib/JAELIS-VM/lib/compiler/jir-compiler.js +1097 -0
  6. package/lib/JAELIS-VM/lib/execution/engine.js +1183 -0
  7. package/lib/JAELIS-VM/lib/index.js +440 -0
  8. package/lib/JAELIS-VM/lib/integration/jaelis-integration.js +543 -0
  9. package/lib/JAELIS-VM/lib/serialization/serializer.js +819 -0
  10. package/lib/JAELIS-VM/lib/state/state-manager.js +1116 -0
  11. package/lib/JAELIS-VM/lib/translator/bytecode-translator.js +1222 -0
  12. package/lib/JAELIS-VM/lib/unified/cross-chain-state.js +836 -0
  13. package/lib/JAELIS-VM/lib/unified/dynamic-contracts.js +1127 -0
  14. package/lib/JAELIS-VM/lib/unified/index.js +378 -0
  15. package/lib/JAELIS-VM/lib/unified/jaelis-abi.js +1150 -0
  16. package/lib/JAELIS-VM/lib/unified/unified-compiler.js +1350 -0
  17. package/lib/JAELIS-VM/node_modules/.bin/download-cbor-prebuilds +12 -0
  18. package/lib/JAELIS-VM/node_modules/.bin/download-cbor-prebuilds.cmd +17 -0
  19. package/lib/JAELIS-VM/node_modules/.bin/download-cbor-prebuilds.ps1 +28 -0
  20. package/lib/JAELIS-VM/node_modules/.bin/download-msgpackr-prebuilds +12 -0
  21. package/lib/JAELIS-VM/node_modules/.bin/download-msgpackr-prebuilds.cmd +17 -0
  22. package/lib/JAELIS-VM/node_modules/.bin/download-msgpackr-prebuilds.ps1 +28 -0
  23. package/lib/JAELIS-VM/node_modules/.bin/node-gyp-build-optional-packages +12 -0
  24. package/lib/JAELIS-VM/node_modules/.bin/node-gyp-build-optional-packages-optional +12 -0
  25. package/lib/JAELIS-VM/node_modules/.bin/node-gyp-build-optional-packages-optional.cmd +17 -0
  26. package/lib/JAELIS-VM/node_modules/.bin/node-gyp-build-optional-packages-optional.ps1 +28 -0
  27. package/lib/JAELIS-VM/node_modules/.bin/node-gyp-build-optional-packages-test +12 -0
  28. package/lib/JAELIS-VM/node_modules/.bin/node-gyp-build-optional-packages-test.cmd +17 -0
  29. package/lib/JAELIS-VM/node_modules/.bin/node-gyp-build-optional-packages-test.ps1 +28 -0
  30. package/lib/JAELIS-VM/node_modules/.bin/node-gyp-build-optional-packages.cmd +17 -0
  31. package/lib/JAELIS-VM/node_modules/.bin/node-gyp-build-optional-packages.ps1 +28 -0
  32. package/lib/JAELIS-VM/node_modules/.package-lock.json +127 -0
  33. package/lib/JAELIS-VM/node_modules/@cbor-extract/cbor-extract-win32-x64/README.md +1 -0
  34. package/lib/JAELIS-VM/node_modules/@cbor-extract/cbor-extract-win32-x64/index.js +0 -0
  35. package/lib/JAELIS-VM/node_modules/@cbor-extract/cbor-extract-win32-x64/node.abi115.node +0 -0
  36. package/lib/JAELIS-VM/node_modules/@cbor-extract/cbor-extract-win32-x64/node.napi.node +0 -0
  37. package/lib/JAELIS-VM/node_modules/@cbor-extract/cbor-extract-win32-x64/package.json +17 -0
  38. package/lib/JAELIS-VM/node_modules/@msgpackr-extract/msgpackr-extract-win32-x64/README.md +1 -0
  39. package/lib/JAELIS-VM/node_modules/@msgpackr-extract/msgpackr-extract-win32-x64/index.js +0 -0
  40. package/lib/JAELIS-VM/node_modules/@msgpackr-extract/msgpackr-extract-win32-x64/node.abi115.node +0 -0
  41. package/lib/JAELIS-VM/node_modules/@msgpackr-extract/msgpackr-extract-win32-x64/node.napi.node +0 -0
  42. package/lib/JAELIS-VM/node_modules/@msgpackr-extract/msgpackr-extract-win32-x64/package.json +17 -0
  43. package/lib/JAELIS-VM/node_modules/cbor-extract/LICENSE +21 -0
  44. package/lib/JAELIS-VM/node_modules/cbor-extract/README.md +5 -0
  45. package/lib/JAELIS-VM/node_modules/cbor-extract/bin/download-prebuilds.js +11 -0
  46. package/lib/JAELIS-VM/node_modules/cbor-extract/binding.gyp +60 -0
  47. package/lib/JAELIS-VM/node_modules/cbor-extract/index.js +1 -0
  48. package/lib/JAELIS-VM/node_modules/cbor-extract/package.json +50 -0
  49. package/lib/JAELIS-VM/node_modules/cbor-extract/src/extract.cpp +198 -0
  50. package/lib/JAELIS-VM/node_modules/cbor-x/LICENSE +21 -0
  51. package/lib/JAELIS-VM/node_modules/cbor-x/README.md +380 -0
  52. package/lib/JAELIS-VM/node_modules/cbor-x/SECURITY.md +11 -0
  53. package/lib/JAELIS-VM/node_modules/cbor-x/benchmark.md +73 -0
  54. package/lib/JAELIS-VM/node_modules/cbor-x/browser.js +11 -0
  55. package/lib/JAELIS-VM/node_modules/cbor-x/decode.d.ts +2 -0
  56. package/lib/JAELIS-VM/node_modules/cbor-x/decode.js +1300 -0
  57. package/lib/JAELIS-VM/node_modules/cbor-x/dist/decode-no-eval.cjs +1244 -0
  58. package/lib/JAELIS-VM/node_modules/cbor-x/dist/decode-no-eval.cjs.map +1 -0
  59. package/lib/JAELIS-VM/node_modules/cbor-x/dist/index-no-eval.cjs +2509 -0
  60. package/lib/JAELIS-VM/node_modules/cbor-x/dist/index-no-eval.cjs.map +1 -0
  61. package/lib/JAELIS-VM/node_modules/cbor-x/dist/index-no-eval.min.js +2 -0
  62. package/lib/JAELIS-VM/node_modules/cbor-x/dist/index-no-eval.min.js.map +1 -0
  63. package/lib/JAELIS-VM/node_modules/cbor-x/dist/index.js +2508 -0
  64. package/lib/JAELIS-VM/node_modules/cbor-x/dist/index.js.map +1 -0
  65. package/lib/JAELIS-VM/node_modules/cbor-x/dist/index.min.js +2 -0
  66. package/lib/JAELIS-VM/node_modules/cbor-x/dist/index.min.js.map +1 -0
  67. package/lib/JAELIS-VM/node_modules/cbor-x/dist/node.cjs +2629 -0
  68. package/lib/JAELIS-VM/node_modules/cbor-x/dist/node.cjs.map +1 -0
  69. package/lib/JAELIS-VM/node_modules/cbor-x/dist/test.js +3343 -0
  70. package/lib/JAELIS-VM/node_modules/cbor-x/dist/test.js.map +1 -0
  71. package/lib/JAELIS-VM/node_modules/cbor-x/encode.d.ts +1 -0
  72. package/lib/JAELIS-VM/node_modules/cbor-x/encode.js +1231 -0
  73. package/lib/JAELIS-VM/node_modules/cbor-x/index.d.ts +79 -0
  74. package/lib/JAELIS-VM/node_modules/cbor-x/index.js +3 -0
  75. package/lib/JAELIS-VM/node_modules/cbor-x/iterators.js +85 -0
  76. package/lib/JAELIS-VM/node_modules/cbor-x/node-index.js +24 -0
  77. package/lib/JAELIS-VM/node_modules/cbor-x/package.json +94 -0
  78. package/lib/JAELIS-VM/node_modules/cbor-x/rollup.config.js +88 -0
  79. package/lib/JAELIS-VM/node_modules/cbor-x/stream.js +61 -0
  80. package/lib/JAELIS-VM/node_modules/cbor-x/webpack.config.js +19 -0
  81. package/lib/JAELIS-VM/node_modules/detect-libc/LICENSE +201 -0
  82. package/lib/JAELIS-VM/node_modules/detect-libc/README.md +163 -0
  83. package/lib/JAELIS-VM/node_modules/detect-libc/index.d.ts +14 -0
  84. package/lib/JAELIS-VM/node_modules/detect-libc/lib/detect-libc.js +313 -0
  85. package/lib/JAELIS-VM/node_modules/detect-libc/lib/elf.js +39 -0
  86. package/lib/JAELIS-VM/node_modules/detect-libc/lib/filesystem.js +51 -0
  87. package/lib/JAELIS-VM/node_modules/detect-libc/lib/process.js +24 -0
  88. package/lib/JAELIS-VM/node_modules/detect-libc/package.json +44 -0
  89. package/lib/JAELIS-VM/node_modules/msgpackr/LICENSE +21 -0
  90. package/lib/JAELIS-VM/node_modules/msgpackr/README.md +372 -0
  91. package/lib/JAELIS-VM/node_modules/msgpackr/SECURITY.md +11 -0
  92. package/lib/JAELIS-VM/node_modules/msgpackr/benchmark.md +67 -0
  93. package/lib/JAELIS-VM/node_modules/msgpackr/dist/index-no-eval.cjs +2407 -0
  94. package/lib/JAELIS-VM/node_modules/msgpackr/dist/index-no-eval.cjs.map +1 -0
  95. package/lib/JAELIS-VM/node_modules/msgpackr/dist/index-no-eval.min.js +2 -0
  96. package/lib/JAELIS-VM/node_modules/msgpackr/dist/index-no-eval.min.js.map +1 -0
  97. package/lib/JAELIS-VM/node_modules/msgpackr/dist/index.js +2406 -0
  98. package/lib/JAELIS-VM/node_modules/msgpackr/dist/index.js.map +1 -0
  99. package/lib/JAELIS-VM/node_modules/msgpackr/dist/index.min.js +2 -0
  100. package/lib/JAELIS-VM/node_modules/msgpackr/dist/index.min.js.map +1 -0
  101. package/lib/JAELIS-VM/node_modules/msgpackr/dist/node.cjs +3320 -0
  102. package/lib/JAELIS-VM/node_modules/msgpackr/dist/node.cjs.map +1 -0
  103. package/lib/JAELIS-VM/node_modules/msgpackr/dist/test.js +4540 -0
  104. package/lib/JAELIS-VM/node_modules/msgpackr/dist/test.js.map +1 -0
  105. package/lib/JAELIS-VM/node_modules/msgpackr/dist/unpack-no-eval.cjs +1250 -0
  106. package/lib/JAELIS-VM/node_modules/msgpackr/dist/unpack-no-eval.cjs.map +1 -0
  107. package/lib/JAELIS-VM/node_modules/msgpackr/index.d.cts +91 -0
  108. package/lib/JAELIS-VM/node_modules/msgpackr/index.d.ts +91 -0
  109. package/lib/JAELIS-VM/node_modules/msgpackr/index.js +5 -0
  110. package/lib/JAELIS-VM/node_modules/msgpackr/iterators.js +87 -0
  111. package/lib/JAELIS-VM/node_modules/msgpackr/node-index.js +25 -0
  112. package/lib/JAELIS-VM/node_modules/msgpackr/pack.d.cts +1 -0
  113. package/lib/JAELIS-VM/node_modules/msgpackr/pack.d.ts +1 -0
  114. package/lib/JAELIS-VM/node_modules/msgpackr/pack.js +1141 -0
  115. package/lib/JAELIS-VM/node_modules/msgpackr/package.json +104 -0
  116. package/lib/JAELIS-VM/node_modules/msgpackr/rollup.config.js +88 -0
  117. package/lib/JAELIS-VM/node_modules/msgpackr/stream.js +57 -0
  118. package/lib/JAELIS-VM/node_modules/msgpackr/struct.js +815 -0
  119. package/lib/JAELIS-VM/node_modules/msgpackr/test-worker.js +3 -0
  120. package/lib/JAELIS-VM/node_modules/msgpackr/unpack.d.cts +2 -0
  121. package/lib/JAELIS-VM/node_modules/msgpackr/unpack.d.ts +2 -0
  122. package/lib/JAELIS-VM/node_modules/msgpackr/unpack.js +1221 -0
  123. package/lib/JAELIS-VM/node_modules/msgpackr-extract/LICENSE +21 -0
  124. package/lib/JAELIS-VM/node_modules/msgpackr-extract/README.md +5 -0
  125. package/lib/JAELIS-VM/node_modules/msgpackr-extract/bin/download-prebuilds.js +13 -0
  126. package/lib/JAELIS-VM/node_modules/msgpackr-extract/binding.gyp +63 -0
  127. package/lib/JAELIS-VM/node_modules/msgpackr-extract/index.js +1 -0
  128. package/lib/JAELIS-VM/node_modules/msgpackr-extract/node_modules/.bin/node-gyp-build-optional-packages +12 -0
  129. package/lib/JAELIS-VM/node_modules/msgpackr-extract/node_modules/.bin/node-gyp-build-optional-packages-optional +12 -0
  130. package/lib/JAELIS-VM/node_modules/msgpackr-extract/node_modules/.bin/node-gyp-build-optional-packages-optional.cmd +17 -0
  131. package/lib/JAELIS-VM/node_modules/msgpackr-extract/node_modules/.bin/node-gyp-build-optional-packages-optional.ps1 +28 -0
  132. package/lib/JAELIS-VM/node_modules/msgpackr-extract/node_modules/.bin/node-gyp-build-optional-packages-test +12 -0
  133. package/lib/JAELIS-VM/node_modules/msgpackr-extract/node_modules/.bin/node-gyp-build-optional-packages-test.cmd +17 -0
  134. package/lib/JAELIS-VM/node_modules/msgpackr-extract/node_modules/.bin/node-gyp-build-optional-packages-test.ps1 +28 -0
  135. package/lib/JAELIS-VM/node_modules/msgpackr-extract/node_modules/.bin/node-gyp-build-optional-packages.cmd +17 -0
  136. package/lib/JAELIS-VM/node_modules/msgpackr-extract/node_modules/.bin/node-gyp-build-optional-packages.ps1 +28 -0
  137. package/lib/JAELIS-VM/node_modules/msgpackr-extract/node_modules/node-gyp-build-optional-packages/LICENSE +21 -0
  138. package/lib/JAELIS-VM/node_modules/msgpackr-extract/node_modules/node-gyp-build-optional-packages/README.md +58 -0
  139. package/lib/JAELIS-VM/node_modules/msgpackr-extract/node_modules/node-gyp-build-optional-packages/bin.js +82 -0
  140. package/lib/JAELIS-VM/node_modules/msgpackr-extract/node_modules/node-gyp-build-optional-packages/build-test.js +19 -0
  141. package/lib/JAELIS-VM/node_modules/msgpackr-extract/node_modules/node-gyp-build-optional-packages/index.js +6 -0
  142. package/lib/JAELIS-VM/node_modules/msgpackr-extract/node_modules/node-gyp-build-optional-packages/node-gyp-build.js +236 -0
  143. package/lib/JAELIS-VM/node_modules/msgpackr-extract/node_modules/node-gyp-build-optional-packages/optional.js +7 -0
  144. package/lib/JAELIS-VM/node_modules/msgpackr-extract/node_modules/node-gyp-build-optional-packages/package.json +32 -0
  145. package/lib/JAELIS-VM/node_modules/msgpackr-extract/package.json +50 -0
  146. package/lib/JAELIS-VM/node_modules/msgpackr-extract/src/extract.cpp +274 -0
  147. package/lib/JAELIS-VM/node_modules/node-gyp-build-optional-packages/LICENSE +21 -0
  148. package/lib/JAELIS-VM/node_modules/node-gyp-build-optional-packages/README.md +58 -0
  149. package/lib/JAELIS-VM/node_modules/node-gyp-build-optional-packages/bin.js +77 -0
  150. package/lib/JAELIS-VM/node_modules/node-gyp-build-optional-packages/build-test.js +19 -0
  151. package/lib/JAELIS-VM/node_modules/node-gyp-build-optional-packages/index.js +224 -0
  152. package/lib/JAELIS-VM/node_modules/node-gyp-build-optional-packages/optional.js +7 -0
  153. package/lib/JAELIS-VM/node_modules/node-gyp-build-optional-packages/package.json +32 -0
  154. package/lib/JAELIS-VM/package-lock.json +284 -0
  155. package/lib/JAELIS-VM/package.json +38 -0
  156. package/lib/JAELIS-VM/test/comprehensive.test.js +267 -0
  157. package/lib/JAELIS-VM/test/cross-chain-test.js +470 -0
  158. package/lib/JAELIS-VM/test/unified-vm-test.js +459 -0
  159. package/lib/JAELIS-VM/test/unified.test.js +166 -0
  160. package/lib/JAELIS-VM/test/vm.test.js +599 -0
  161. package/lib/index.js +310 -4
  162. package/package.json +2 -2
package/lib/index.js CHANGED
@@ -5,7 +5,24 @@
5
5
  * This module provides the JaelisNode class which wraps the core blockchain
6
6
  * implementation for easy deployment as a standalone node.
7
7
  *
8
- * @version 1.0.0
8
+ * ═══════════════════════════════════════════════════════════════════════════════
9
+ * RPC ARCHITECTURE (v1.4.0+)
10
+ * ═══════════════════════════════════════════════════════════════════════════════
11
+ *
12
+ * LAYER 1 - NATIVE JAELIS (PRIMARY):
13
+ * jaelis_* Native JAELIS methods - rich responses, zero-gas semantics
14
+ *
15
+ * LAYER 2 - COMPATIBILITY (PROXIES):
16
+ * eth_* Ethereum JSON-RPC compat (MetaMask, ethers.js, web3.js)
17
+ * solana_* Solana-compatible methods (Rust/SPL developers)
18
+ * move_* Move-compatible methods (Aptos/Sui developers)
19
+ * ton_* TON-compatible methods (FunC/Telegram developers)
20
+ *
21
+ * All compatibility methods PROXY to native jaelis_* implementations.
22
+ * This follows Solana/Cosmos/Polkadot patterns for multi-ecosystem support.
23
+ * ═══════════════════════════════════════════════════════════════════════════════
24
+ *
25
+ * @version 1.4.0
9
26
  * @author JAELIS Foundation
10
27
  */
11
28
 
@@ -1217,15 +1234,23 @@ class EmbeddedRpcServer {
1217
1234
  async _handleMethod(method, params) {
1218
1235
  switch (method) {
1219
1236
  // ═══════════════════════════════════════════════════════════════
1220
- // STANDARD ETHEREUM-COMPATIBLE METHODS
1237
+ // LAYER 1: NATIVE JAELIS METHODS (PRIMARY)
1221
1238
  // ═══════════════════════════════════════════════════════════════
1222
- case 'eth_chainId':
1239
+ case 'jaelis_chainId':
1223
1240
  return '0x' + (this.blockchain?.chainId || 4545).toString(16);
1224
1241
 
1225
- case 'eth_blockNumber':
1226
1242
  case 'jaelis_blockNumber':
1227
1243
  return '0x' + (this.blockchain?.getHeight?.() || 0).toString(16);
1228
1244
 
1245
+ // ═══════════════════════════════════════════════════════════════
1246
+ // LAYER 2: ETHEREUM COMPATIBILITY (PROXIES → jaelis_*)
1247
+ // ═══════════════════════════════════════════════════════════════
1248
+ case 'eth_chainId':
1249
+ return this._handleMethod('jaelis_chainId', params);
1250
+
1251
+ case 'eth_blockNumber':
1252
+ return this._handleMethod('jaelis_blockNumber', params);
1253
+
1229
1254
  case 'eth_getBlockByNumber':
1230
1255
  const blockNum = parseInt(params[0], 16);
1231
1256
  return this.blockchain?.getBlock?.(blockNum) || null;
@@ -1251,11 +1276,18 @@ class EmbeddedRpcServer {
1251
1276
  vmActive: !!this.blockchain?.vmExecutor
1252
1277
  };
1253
1278
 
1279
+ case 'jaelis_deploy':
1254
1280
  case 'jaelis_deployContract':
1255
1281
  // Deploy contract in ANY language!
1256
1282
  // params: [source, language, options]
1257
1283
  return this._deployContract(params[0], params[1], params[2] || {});
1258
1284
 
1285
+ case 'jaelis_deployUnified':
1286
+ // THE KEY INNOVATION: Deploy unified contract bundle!
1287
+ // Compile MULTIPLE contracts from MULTIPLE languages into ONE bytecode!
1288
+ // params: [{ from, sources: [{ code, language, name }...] }]
1289
+ return this._deployUnified(params[0]);
1290
+
1259
1291
  case 'jaelis_executeContract':
1260
1292
  // Execute contract call
1261
1293
  // params: [to, functionName, args, options]
@@ -1320,6 +1352,217 @@ class EmbeddedRpcServer {
1320
1352
  // Get cross-chain stats
1321
1353
  return this._getCrossChainStats();
1322
1354
 
1355
+ // ═══════════════════════════════════════════════════════════════
1356
+ // LAYER 2: SOLANA COMPATIBILITY (PROXIES → jaelis_*)
1357
+ // For Rust/SPL developers familiar with Solana RPC
1358
+ // ═══════════════════════════════════════════════════════════════
1359
+ case 'solana_getBalance':
1360
+ // Convert to JAELIS format then back to Solana format
1361
+ const jaelisBalance = await this._handleMethod('jaelis_getBalance', params);
1362
+ return { value: BigInt(jaelisBalance || '0').toString() };
1363
+
1364
+ case 'solana_getHealth':
1365
+ return this._handleMethod('jaelis_getHealth', params);
1366
+
1367
+ case 'solana_getSlot':
1368
+ return this.blockchain?.getHeight?.() || 0;
1369
+
1370
+ case 'solana_getBlockHeight':
1371
+ return this.blockchain?.getHeight?.() || 0;
1372
+
1373
+ case 'solana_getVersion':
1374
+ return { 'solana-core': '1.17.0', 'feature-set': 4545 };
1375
+
1376
+ case 'solana_getLatestBlockhash':
1377
+ const block = this.blockchain?.getLatestBlock?.();
1378
+ return { blockhash: block?.hash || '0x0', lastValidBlockHeight: block?.number || 0 };
1379
+
1380
+ // ═══════════════════════════════════════════════════════════════
1381
+ // LAYER 2: MOVE COMPATIBILITY (PROXIES → jaelis_*)
1382
+ // For Aptos/Sui developers familiar with Move
1383
+ // ═══════════════════════════════════════════════════════════════
1384
+ case 'move_getLedgerInfo':
1385
+ const height = this.blockchain?.getHeight?.() || 0;
1386
+ return {
1387
+ chain_id: this.blockchain?.chainId || 4545,
1388
+ ledger_version: height.toString(),
1389
+ block_height: height.toString()
1390
+ };
1391
+
1392
+ case 'move_getAccountResource':
1393
+ return this._handleMethod('jaelis_getMoveResource', params);
1394
+
1395
+ case 'move_getAccountModule':
1396
+ return this._handleMethod('jaelis_getMoveModule', params);
1397
+
1398
+ // ═══════════════════════════════════════════════════════════════
1399
+ // LAYER 2: TON COMPATIBILITY (PROXIES → jaelis_*)
1400
+ // For FunC/Telegram developers (900M+ users!)
1401
+ // ═══════════════════════════════════════════════════════════════
1402
+ case 'ton_getAddressBalance':
1403
+ const tonBalance = await this._handleMethod('jaelis_getBalance', params);
1404
+ return { balance: tonBalance || '0' };
1405
+
1406
+ case 'ton_getMasterchainInfo':
1407
+ const tonBlock = this.blockchain?.getLatestBlock?.();
1408
+ return {
1409
+ last: {
1410
+ workchain: 0,
1411
+ seqno: tonBlock?.number || 0,
1412
+ root_hash: tonBlock?.hash || '0x0'
1413
+ }
1414
+ };
1415
+
1416
+ case 'ton_getAccountState':
1417
+ return this._handleMethod('jaelis_getTonAccount', params);
1418
+
1419
+ case 'ton_runGetMethod':
1420
+ return this._handleMethod('jaelis_callTonMethod', params);
1421
+
1422
+ // ═══════════════════════════════════════════════════════════════
1423
+ // LAYER 2: BITCOIN COMPATIBILITY (PROXIES → jaelis_*)
1424
+ // For Bitcoin developers - familiar Bitcoin Core RPC methods
1425
+ // ═══════════════════════════════════════════════════════════════
1426
+ case 'btc_getbalance':
1427
+ const btcBal = await this._handleMethod('jaelis_getBalance', params);
1428
+ const satoshis = BigInt(btcBal?.jaelis || '0') / BigInt(10 ** 10);
1429
+ return Number(satoshis) / 100000000;
1430
+
1431
+ case 'btc_getblockcount':
1432
+ return this.blockchain?.getHeight?.() || 0;
1433
+
1434
+ case 'btc_getblockhash':
1435
+ const btcBlock = this.blockchain?.getBlock?.(params[0]);
1436
+ return btcBlock?.hash || null;
1437
+
1438
+ case 'btc_getblock':
1439
+ const blk = this.blockchain?.getBlockByHash?.(params[0]);
1440
+ if (!blk) return null;
1441
+ return {
1442
+ hash: blk.hash,
1443
+ confirmations: 1,
1444
+ height: blk.number,
1445
+ version: 1,
1446
+ time: blk.timestamp,
1447
+ tx: blk.transactions?.map(t => t.hash || t) || [],
1448
+ previousblockhash: blk.parentHash
1449
+ };
1450
+
1451
+ case 'btc_gettransaction':
1452
+ return this._handleMethod('jaelis_getTransactionByHash', params);
1453
+
1454
+ case 'btc_sendrawtransaction':
1455
+ return this._handleMethod('jaelis_sendRawTransaction', params);
1456
+
1457
+ case 'btc_getblockchaininfo':
1458
+ const btcHeight = this.blockchain?.getHeight?.() || 0;
1459
+ return {
1460
+ chain: (this.blockchain?.chainId || 4545) === 4545 ? 'test' : 'main',
1461
+ blocks: btcHeight,
1462
+ headers: btcHeight,
1463
+ bestblockhash: this.blockchain?.getLatestBlock?.()?.hash,
1464
+ difficulty: 1,
1465
+ warnings: 'JAELIS Bitcoin compatibility - zero gas fees!'
1466
+ };
1467
+
1468
+ case 'btc_getnetworkinfo':
1469
+ return {
1470
+ version: 250000,
1471
+ subversion: '/JAELIS:1.0.0/',
1472
+ protocolversion: 70016,
1473
+ warnings: 'JAELIS Bitcoin compatibility layer'
1474
+ };
1475
+
1476
+ case 'btc_getmempoolinfo':
1477
+ return { loaded: true, size: 0, mempoolminfee: 0 };
1478
+
1479
+ case 'btc_estimatesmartfee':
1480
+ return { feerate: 0, blocks: params[0] || 1 }; // Zero fees!
1481
+
1482
+ // ═══════════════════════════════════════════════════════════════
1483
+ // LAYER 2: WASM COMPATIBILITY (PROXIES → jaelis_*)
1484
+ // For CosmWasm/NEAR/Polkadot WASM developers
1485
+ // ═══════════════════════════════════════════════════════════════
1486
+ case 'wasm_call':
1487
+ return this._handleMethod('jaelis_call', [{ to: params[0], data: JSON.stringify({ method: params[1], args: params[2] }) }]);
1488
+
1489
+ case 'wasm_query':
1490
+ return this._handleMethod('jaelis_call', [{ to: params[0], data: JSON.stringify(params[1]) }]);
1491
+
1492
+ case 'wasm_deploy':
1493
+ return this._handleMethod('jaelis_deployWasmContract', params);
1494
+
1495
+ case 'wasm_instantiate':
1496
+ return this._handleMethod('jaelis_deployWasmContract', [{ codeId: params[0], initMsg: params[1], label: params[2] }]);
1497
+
1498
+ case 'wasm_execute':
1499
+ return this._handleMethod('jaelis_sendTransaction', [{ to: params[0], data: JSON.stringify(params[1]), value: params[2] || '0x0' }]);
1500
+
1501
+ case 'wasm_getCode':
1502
+ return this._handleMethod('jaelis_getCode', params);
1503
+
1504
+ case 'wasm_getContractInfo':
1505
+ const wasmCode = await this._handleMethod('jaelis_getCode', params);
1506
+ return { address: params[0], has_code: wasmCode && wasmCode !== '0x' };
1507
+
1508
+ case 'wasm_getContractState':
1509
+ return this._handleMethod('jaelis_getStorageAt', [params[0], params[1] || '0x0', 'latest']);
1510
+
1511
+ // ═══════════════════════════════════════════════════════════════
1512
+ // LAYER 2: STARKNET/CAIRO COMPATIBILITY (PROXIES → jaelis_*)
1513
+ // For StarkNet/Cairo developers
1514
+ // ═══════════════════════════════════════════════════════════════
1515
+ case 'starknet_chainId':
1516
+ return this._handleMethod('jaelis_chainId', params);
1517
+
1518
+ case 'starknet_blockNumber':
1519
+ return this.blockchain?.getHeight?.() || 0;
1520
+
1521
+ case 'starknet_getBlockWithTxHashes':
1522
+ const snBlock = this.blockchain?.getBlock?.(params[0]?.block_number || 'latest');
1523
+ if (!snBlock) return null;
1524
+ return {
1525
+ block_hash: snBlock.hash,
1526
+ parent_hash: snBlock.parentHash,
1527
+ block_number: snBlock.number,
1528
+ transactions: snBlock.transactions || [],
1529
+ status: 'ACCEPTED_ON_L1'
1530
+ };
1531
+
1532
+ case 'starknet_getBlockWithTxs':
1533
+ return this._handleMethod('starknet_getBlockWithTxHashes', params);
1534
+
1535
+ case 'starknet_getTransactionByHash':
1536
+ const snTx = await this._handleMethod('jaelis_getTransactionByHash', params);
1537
+ if (!snTx) return null;
1538
+ return { transaction_hash: snTx.hash, type: 'INVOKE', sender_address: snTx.from };
1539
+
1540
+ case 'starknet_getTransactionReceipt':
1541
+ const snReceipt = await this._handleMethod('jaelis_getTransactionReceipt', params);
1542
+ if (!snReceipt) return null;
1543
+ return {
1544
+ transaction_hash: snReceipt.transactionHash,
1545
+ actual_fee: '0x0',
1546
+ status: snReceipt.status === '0x1' ? 'ACCEPTED_ON_L1' : 'REJECTED'
1547
+ };
1548
+
1549
+ case 'starknet_call':
1550
+ return this._handleMethod('jaelis_call', [{ to: params[0]?.contract_address, data: '0x' }]);
1551
+
1552
+ case 'starknet_estimateFee':
1553
+ return { gas_consumed: '0x0', gas_price: '0x0', overall_fee: '0x0' }; // Zero fees!
1554
+
1555
+ case 'starknet_addInvokeTransaction':
1556
+ return this._handleMethod('jaelis_sendTransaction', [{ from: params[0]?.sender_address, to: params[0]?.calldata?.[0], data: '0x' }]);
1557
+
1558
+ case 'starknet_addDeclareTransaction':
1559
+ return this._handleMethod('jaelis_deploy', [{ data: params[0]?.contract_class, from: params[0]?.sender_address }]);
1560
+
1561
+ case 'starknet_getClass':
1562
+ case 'starknet_getClassAt':
1563
+ const cairoCode = await this._handleMethod('jaelis_getCode', [params[1] || params[0]]);
1564
+ return { program: cairoCode, entry_points_by_type: { CONSTRUCTOR: [], EXTERNAL: [], L1_HANDLER: [] } };
1565
+
1323
1566
  default:
1324
1567
  throw new Error(`Method not found: ${method}`);
1325
1568
  }
@@ -1353,6 +1596,69 @@ class EmbeddedRpcServer {
1353
1596
  };
1354
1597
  }
1355
1598
 
1599
+ /**
1600
+ * Deploy unified contract bundle (THE KEY INNOVATION!)
1601
+ *
1602
+ * Compiles MULTIPLE contracts from MULTIPLE languages into ONE bytecode bundle.
1603
+ * All contracts share memory and can call each other DIRECTLY - no bridges!
1604
+ *
1605
+ * @param {Object} params - { from, sources: [{ code, language, name }...] }
1606
+ */
1607
+ async _deployUnified(params) {
1608
+ if (!this.blockchain) throw new Error('Blockchain not available');
1609
+ if (!this.blockchain.unifiedVM) throw new Error('Unified VM not available');
1610
+
1611
+ const { from, sources } = params;
1612
+
1613
+ if (!sources || !Array.isArray(sources) || sources.length === 0) {
1614
+ throw new Error('sources array is required for unified deployment');
1615
+ }
1616
+
1617
+ console.log(`[RPC] Deploying unified bundle with ${sources.length} contracts...`);
1618
+ console.log(`[RPC] Languages: ${[...new Set(sources.map(s => s.language))].join(', ')}`);
1619
+
1620
+ // Compile all sources together using the Unified Compiler
1621
+ const compiled = await this.blockchain.unifiedVM.compileBundle(sources);
1622
+
1623
+ // Deploy the unified bytecode
1624
+ const address = '0x' + require('crypto').randomBytes(20).toString('hex');
1625
+
1626
+ // Store the unified contract
1627
+ if (this.blockchain.contracts) {
1628
+ this.blockchain.contracts.set(address, {
1629
+ bytecode: compiled.bytecode,
1630
+ abi: compiled.abi || [],
1631
+ sources: sources.map(s => s.name),
1632
+ languages: [...new Set(sources.map(s => s.language))],
1633
+ deployedAt: Date.now(),
1634
+ deployer: from
1635
+ });
1636
+ }
1637
+
1638
+ console.log(`[RPC] Unified bundle deployed at ${address}`);
1639
+ console.log(`[RPC] Bytecode: ${compiled.bytecode?.length || 0} bytes`);
1640
+ console.log(`[RPC] Cross-references: ${compiled.crossReferences?.size || 0}`);
1641
+
1642
+ // Build contracts map for response
1643
+ const contractsMap = {};
1644
+ for (const source of sources) {
1645
+ contractsMap[source.name] = {
1646
+ address: address, // All share the same bundle address
1647
+ language: source.language,
1648
+ name: source.name
1649
+ };
1650
+ }
1651
+
1652
+ return {
1653
+ address,
1654
+ bytecode: compiled.bytecode?.toString('hex'),
1655
+ abi: compiled.abi || [],
1656
+ contracts: contractsMap,
1657
+ metadata: compiled.metadata,
1658
+ gasUsed: 0 // ZERO FEES!
1659
+ };
1660
+ }
1661
+
1356
1662
  async _executeContract(to, functionName, args, options) {
1357
1663
  if (!this.blockchain) throw new Error('Blockchain not available');
1358
1664
  return this.blockchain.executeContract(to, functionName, args, options);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "jaelis-node",
3
- "version": "1.3.2",
4
- "description": "Official JAELIS Blockchain Node - Run a full node, validator, or bootstrap node with Cross-Chain Settlement (30+ chains!), ERC-5792 wallet capabilities, EIP-7702 account abstraction",
3
+ "version": "1.5.0",
4
+ "description": "Official JAELIS Blockchain Node - Universal VM (6 languages), LevelDB state persistence, native jaelis_* RPC, multi-ecosystem compatibility (eth/solana/move/ton/btc/wasm/starknet), Cross-Chain Settlement (30+ chains!)",
5
5
  "main": "lib/index.js",
6
6
  "bin": {
7
7
  "jaelis-node": "./bin/jaelis-node.js"