jaelis-node 1.10.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 +146 -445
  2. package/bin/jaelis-node.js +79 -504
  3. package/lib/index.js +31 -2840
  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,459 +0,0 @@
1
- /**
2
- * JAELIS UNIFIED VM - Integration Test Suite
3
- *
4
- * Tests all critical components:
5
- * - Unified Compiler (all 6 languages)
6
- * - Bytecode generation
7
- * - Cross-contract execution
8
- * - JAELIS ABI encoding/decoding
9
- * - State access control
10
- * - VM spec updates
11
- *
12
- * Run: node test/unified-vm-test.js
13
- */
14
-
15
- const { UnifiedJaelisVM, JaelisABI, JAELIS_TYPES } = require('../lib/unified');
16
-
17
- console.log('═══════════════════════════════════════════════════════════════');
18
- console.log(' JAELIS UNIFIED VM - INTEGRATION TESTS');
19
- console.log('═══════════════════════════════════════════════════════════════');
20
-
21
- let passed = 0;
22
- let failed = 0;
23
-
24
- function test(name, fn) {
25
- try {
26
- fn();
27
- console.log(`βœ“ ${name}`);
28
- passed++;
29
- } catch (error) {
30
- console.log(`βœ— ${name}`);
31
- console.log(` Error: ${error.message}`);
32
- failed++;
33
- }
34
- }
35
-
36
- async function asyncTest(name, fn) {
37
- try {
38
- await fn();
39
- console.log(`βœ“ ${name}`);
40
- passed++;
41
- } catch (error) {
42
- console.log(`βœ— ${name}`);
43
- console.log(` Error: ${error.message}`);
44
- failed++;
45
- }
46
- }
47
-
48
- function assert(condition, message) {
49
- if (!condition) {
50
- throw new Error(message || 'Assertion failed');
51
- }
52
- }
53
-
54
- // ═══════════════════════════════════════════════════════════════
55
- // TEST 1: JAELIS ABI ENCODING/DECODING
56
- // ═══════════════════════════════════════════════════════════════
57
-
58
- console.log('\n--- JAELIS ABI Tests ---');
59
-
60
- test('ABI: Encode/decode U8', () => {
61
- const encoded = JaelisABI.encode(42, 'U8');
62
- const decoded = JaelisABI.decode(encoded);
63
- assert(decoded.value === 42, `Expected 42, got ${decoded.value}`);
64
- assert(decoded.type === 'U8', `Expected U8, got ${decoded.type}`);
65
- });
66
-
67
- test('ABI: Encode/decode U256', () => {
68
- const value = 12345678901234567890n;
69
- const encoded = JaelisABI.encode(value, 'U256');
70
- const decoded = JaelisABI.decode(encoded);
71
- assert(decoded.value === value, `Expected ${value}, got ${decoded.value}`);
72
- });
73
-
74
- test('ABI: Encode/decode I128 (positive)', () => {
75
- const value = 170141183460469231731687303715884105727n; // Max I128
76
- const encoded = JaelisABI.encode(value, 'I128');
77
- const decoded = JaelisABI.decode(encoded);
78
- assert(decoded.value === value, `Expected ${value}, got ${decoded.value}`);
79
- });
80
-
81
- test('ABI: Encode/decode I128 (negative)', () => {
82
- const value = -170141183460469231731687303715884105728n; // Min I128
83
- const encoded = JaelisABI.encode(value, 'I128');
84
- const decoded = JaelisABI.decode(encoded);
85
- assert(decoded.value === value, `Expected ${value}, got ${decoded.value}`);
86
- });
87
-
88
- test('ABI: Encode/decode BOOL', () => {
89
- const encodedTrue = JaelisABI.encode(true, 'BOOL');
90
- const decodedTrue = JaelisABI.decode(encodedTrue);
91
- assert(decodedTrue.value === true, 'Expected true');
92
-
93
- const encodedFalse = JaelisABI.encode(false, 'BOOL');
94
- const decodedFalse = JaelisABI.decode(encodedFalse);
95
- assert(decodedFalse.value === false, 'Expected false');
96
- });
97
-
98
- test('ABI: Encode/decode STRING', () => {
99
- const value = 'Hello, JAELIS!';
100
- const encoded = JaelisABI.encode(value, 'STRING');
101
- const decoded = JaelisABI.decode(encoded);
102
- assert(decoded.value === value, `Expected "${value}", got "${decoded.value}"`);
103
- });
104
-
105
- test('ABI: Encode/decode ADDRESS', () => {
106
- const value = '0x1234567890abcdef1234567890abcdef12345678';
107
- const encoded = JaelisABI.encode(value, 'ADDRESS');
108
- const decoded = JaelisABI.decode(encoded);
109
- assert(decoded.value.toLowerCase().includes('1234567890abcdef'), 'Address not preserved');
110
- });
111
-
112
- test('ABI: Encode/decode F64', () => {
113
- const value = 3.141592653589793;
114
- const encoded = JaelisABI.encode(value, 'F64');
115
- const decoded = JaelisABI.decode(encoded);
116
- assert(Math.abs(decoded.value - value) < 0.0001, `Expected ${value}, got ${decoded.value}`);
117
- });
118
-
119
- test('ABI: Function selector computation', () => {
120
- const selector = JaelisABI.computeSelector('transfer', ['ADDRESS', 'U256']);
121
- assert(Buffer.isBuffer(selector), 'Selector should be a buffer');
122
- assert(selector.length === 4, 'Selector should be 4 bytes');
123
- });
124
-
125
- // ═══════════════════════════════════════════════════════════════
126
- // TEST 2: UNIFIED COMPILER
127
- // ═══════════════════════════════════════════════════════════════
128
-
129
- console.log('\n--- Unified Compiler Tests ---');
130
-
131
- asyncTest('Compiler: Parse Solidity contract', async () => {
132
- const vm = new UnifiedJaelisVM();
133
-
134
- const solidityCode = `
135
- pragma solidity ^0.8.0;
136
-
137
- contract SimpleToken {
138
- mapping(address => uint256) public balances;
139
-
140
- function transfer(address to, uint256 amount) public returns (bool) {
141
- balances[msg.sender] -= amount;
142
- balances[to] += amount;
143
- return true;
144
- }
145
-
146
- function balanceOf(address account) public view returns (uint256) {
147
- return balances[account];
148
- }
149
- }
150
- `;
151
-
152
- const result = await vm.compileBundle([{
153
- name: 'SimpleToken',
154
- code: solidityCode,
155
- language: 'solidity'
156
- }]);
157
-
158
- assert(result.bytecode.length > 10, 'Bytecode should be generated');
159
- assert(result.asts.length === 1, 'Should have 1 AST');
160
- });
161
-
162
- asyncTest('Compiler: Parse Rust/Anchor contract', async () => {
163
- const vm = new UnifiedJaelisVM();
164
-
165
- const rustCode = `
166
- use anchor_lang::prelude::*;
167
-
168
- #[program]
169
- pub mod token_program {
170
- pub fn initialize(ctx: Context<Initialize>) -> Result<()> {
171
- Ok(())
172
- }
173
-
174
- pub fn transfer(ctx: Context<Transfer>, amount: u64) -> Result<()> {
175
- Ok(())
176
- }
177
- }
178
- `;
179
-
180
- const result = await vm.compileBundle([{
181
- name: 'TokenProgram',
182
- code: rustCode,
183
- language: 'rust'
184
- }]);
185
-
186
- assert(result.bytecode.length > 10, 'Bytecode should be generated');
187
- });
188
-
189
- asyncTest('Compiler: Parse Move module', async () => {
190
- const vm = new UnifiedJaelisVM();
191
-
192
- const moveCode = `
193
- module 0x1::token {
194
- struct Token has key, store {
195
- value: u64
196
- }
197
-
198
- public fun mint(amount: u64): Token {
199
- Token { value: amount }
200
- }
201
-
202
- public fun transfer(from: &mut Token, to: &mut Token, amount: u64) {
203
- from.value = from.value - amount;
204
- to.value = to.value + amount;
205
- }
206
- }
207
- `;
208
-
209
- const result = await vm.compileBundle([{
210
- name: 'MoveToken',
211
- code: moveCode,
212
- language: 'move'
213
- }]);
214
-
215
- assert(result.bytecode.length > 10, 'Bytecode should be generated');
216
- });
217
-
218
- asyncTest('Compiler: Parse FunC contract', async () => {
219
- const vm = new UnifiedJaelisVM();
220
-
221
- const funcCode = `
222
- () recv_internal(int msg_value, cell in_msg_cell) impure {
223
- ;; Handle internal message
224
- }
225
-
226
- int get_balance() method_id {
227
- return 1000;
228
- }
229
- `;
230
-
231
- const result = await vm.compileBundle([{
232
- name: 'TonContract',
233
- code: funcCode,
234
- language: 'func'
235
- }]);
236
-
237
- assert(result.bytecode.length > 10, 'Bytecode should be generated');
238
- });
239
-
240
- asyncTest('Compiler: Parse Cairo contract', async () => {
241
- const vm = new UnifiedJaelisVM();
242
-
243
- const cairoCode = `
244
- #[contract]
245
- mod simple_storage {
246
- #[external]
247
- fn store(value: felt252) {
248
- }
249
-
250
- #[view]
251
- fn get() -> felt252 {
252
- return 0;
253
- }
254
- }
255
- `;
256
-
257
- const result = await vm.compileBundle([{
258
- name: 'CairoStorage',
259
- code: cairoCode,
260
- language: 'cairo'
261
- }]);
262
-
263
- assert(result.bytecode.length > 10, 'Bytecode should be generated');
264
- });
265
-
266
- asyncTest('Compiler: Parse Vyper contract', async () => {
267
- const vm = new UnifiedJaelisVM();
268
-
269
- const vyperCode = `
270
- # @version ^0.3.7
271
-
272
- balances: HashMap[address, uint256]
273
-
274
- @external
275
- def transfer(to: address, amount: uint256) -> bool:
276
- self.balances[msg.sender] -= amount
277
- self.balances[to] += amount
278
- return True
279
-
280
- @view
281
- @external
282
- def balanceOf(account: address) -> uint256:
283
- return self.balances[account]
284
- `;
285
-
286
- const result = await vm.compileBundle([{
287
- name: 'VyperToken',
288
- code: vyperCode,
289
- language: 'vyper'
290
- }]);
291
-
292
- assert(result.bytecode.length > 10, 'Bytecode should be generated');
293
- });
294
-
295
- // ═══════════════════════════════════════════════════════════════
296
- // TEST 3: CONTRACT DEPLOYMENT & EXECUTION
297
- // ═══════════════════════════════════════════════════════════════
298
-
299
- console.log('\n--- Contract Deployment Tests ---');
300
-
301
- asyncTest('Deploy: Deploy Solidity contract', async () => {
302
- const vm = new UnifiedJaelisVM();
303
-
304
- const code = `
305
- contract Counter {
306
- uint256 public count;
307
- function increment() public { count++; }
308
- }
309
- `;
310
-
311
- const result = await vm.deploy(code, 'solidity');
312
- assert(result.address, 'Contract should have address');
313
- assert(result.bytecode, 'Contract should have bytecode');
314
- assert(result.abi.length > 0, 'Contract should have ABI');
315
- });
316
-
317
- asyncTest('Deploy: Deploy multiple languages', async () => {
318
- const vm = new UnifiedJaelisVM();
319
-
320
- // Deploy Solidity
321
- const sol = await vm.deploy(`contract A { function foo() public {} }`, 'solidity');
322
-
323
- // Deploy Rust
324
- const rust = await vm.deploy(`
325
- #[program]
326
- pub mod b {
327
- pub fn bar() -> Result<()> { Ok(()) }
328
- }
329
- `, 'rust');
330
-
331
- // Check both deployed
332
- const contracts = vm.getContracts();
333
- assert(contracts.length === 2, `Expected 2 contracts, got ${contracts.length}`);
334
- });
335
-
336
- // ═══════════════════════════════════════════════════════════════
337
- // TEST 4: CROSS-CONTRACT CALLS (NO BRIDGES!)
338
- // ═══════════════════════════════════════════════════════════════
339
-
340
- console.log('\n--- Cross-Contract Call Tests ---');
341
-
342
- asyncTest('CrossCall: Direct call between contracts', async () => {
343
- const vm = new UnifiedJaelisVM();
344
-
345
- // Deploy two contracts
346
- const contractA = await vm.deploy(`
347
- contract TokenA {
348
- function getValue() public view returns (uint256) { return 100; }
349
- }
350
- `, 'solidity');
351
-
352
- const contractB = await vm.deploy(`
353
- contract TokenB {
354
- function getDoubleValue() public view returns (uint256) { return 200; }
355
- }
356
- `, 'solidity');
357
-
358
- // Cross-call from A to B
359
- const result = await vm.crossCall(
360
- contractA.address,
361
- contractB.address,
362
- 'getDoubleValue',
363
- []
364
- );
365
-
366
- assert(result.success, 'Cross-call should succeed');
367
- assert(vm.getStats().crossCalls >= 1, 'Cross-call should be recorded');
368
- });
369
-
370
- // ═══════════════════════════════════════════════════════════════
371
- // TEST 5: VM SPEC UPDATES
372
- // ═══════════════════════════════════════════════════════════════
373
-
374
- console.log('\n--- VM Spec Update Tests ---');
375
-
376
- asyncTest('VMUpdate: Update triggers contract recompile', async () => {
377
- const vm = new UnifiedJaelisVM();
378
-
379
- // Deploy a contract
380
- const contract = await vm.deploy(`
381
- contract Upgradeable {
382
- function version() public pure returns (uint256) { return 1; }
383
- }
384
- `, 'solidity');
385
-
386
- const initialVersion = vm.contractManager.contracts.get(contract.address).version;
387
-
388
- // Update VM spec
389
- const affected = await vm.upgradeVM('evm', '0.8.25');
390
-
391
- // Contract should be in affected list
392
- assert(affected.includes(contract.address), 'Contract should be affected by upgrade');
393
- });
394
-
395
- // ═══════════════════════════════════════════════════════════════
396
- // TEST 6: STATE ACCESS CONTROL
397
- // ═══════════════════════════════════════════════════════════════
398
-
399
- console.log('\n--- State Access Control Tests ---');
400
-
401
- asyncTest('StateAccess: Self-access always allowed', async () => {
402
- const vm = new UnifiedJaelisVM();
403
-
404
- const contract = await vm.deploy(`contract A {}`, 'solidity');
405
- const slot = Buffer.alloc(32);
406
-
407
- // Write should succeed
408
- await vm.writeState(contract.address, slot, Buffer.from('test'));
409
-
410
- // Read should succeed
411
- const value = await vm.readState(contract.address, slot);
412
- assert(value, 'Should be able to read own state');
413
- });
414
-
415
- asyncTest('StateAccess: Cross-contract write denied by default', async () => {
416
- const vm = new UnifiedJaelisVM();
417
-
418
- const contractA = await vm.deploy(`contract A {}`, 'solidity');
419
- const contractB = await vm.deploy(`contract B {}`, 'solidity');
420
-
421
- const slot = Buffer.alloc(32);
422
-
423
- // Try to write to A's state from B - should fail
424
- try {
425
- await vm.contractManager.sharedStateWrite(
426
- contractA.address,
427
- slot,
428
- Buffer.from('hack'),
429
- contractB.address
430
- );
431
- assert(false, 'Should have thrown');
432
- } catch (error) {
433
- assert(error.message.includes('Access denied'), 'Should deny access');
434
- }
435
- });
436
-
437
- // ═══════════════════════════════════════════════════════════════
438
- // SUMMARY
439
- // ═══════════════════════════════════════════════════════════════
440
-
441
- // Run async tests
442
- (async () => {
443
- // Wait for all async tests
444
- await new Promise(resolve => setTimeout(resolve, 2000));
445
-
446
- console.log('\n═══════════════════════════════════════════════════════════════');
447
- console.log(` RESULTS: ${passed} passed, ${failed} failed`);
448
- console.log('═══════════════════════════════════════════════════════════════');
449
-
450
- if (failed === 0) {
451
- console.log('\n βœ“ ALL TESTS PASSED - UNIFIED VM IS OPERATIONAL!');
452
- console.log(' βœ“ NO BRIDGES. NO ADAPTERS. ONE SYSTEM.');
453
- console.log(' βœ“ Ready for production deployment.');
454
- } else {
455
- console.log('\n βœ— Some tests failed. Review output above.');
456
- }
457
-
458
- console.log('\n');
459
- })();
@@ -1,166 +0,0 @@
1
- /**
2
- * JAELIS UNIFIED VM TEST
3
- *
4
- * Testing TRUE cross-chain interop - NO BRIDGES!
5
- */
6
-
7
- const { UnifiedJaelisVM } = require('../lib');
8
-
9
- async function testUnifiedVM() {
10
- console.log('═══════════════════════════════════════════════════════════════');
11
- console.log(' UNIFIED VM TEST - NO BRIDGES, NO ADAPTERS!');
12
- console.log('═══════════════════════════════════════════════════════════════\n');
13
-
14
- const vm = new UnifiedJaelisVM();
15
-
16
- // Test 1: Deploy a Solidity contract
17
- console.log('\nπŸ“¦ Test 1: Deploy Solidity Contract');
18
- console.log('─'.repeat(50));
19
-
20
- const solidityCode = `
21
- contract TokenSwap {
22
- mapping(address => uint256) public balances;
23
-
24
- function deposit() public payable {
25
- balances[msg.sender] += msg.value;
26
- }
27
-
28
- function swap(address token, uint256 amount) public returns (bool) {
29
- require(balances[msg.sender] >= amount, "Insufficient balance");
30
- balances[msg.sender] -= amount;
31
- return true;
32
- }
33
-
34
- function getBalance(address user) public view returns (uint256) {
35
- return balances[user];
36
- }
37
- }
38
- `;
39
-
40
- const evmContract = await vm.deploy(solidityCode, 'solidity');
41
- console.log(` βœ“ Deployed Solidity contract: ${evmContract.address.substring(0, 20)}...`);
42
- console.log(` Version: ${evmContract.contract.version}`);
43
- console.log(` Functions: ${evmContract.abi.length}`);
44
-
45
- // Test 2: Deploy a Rust/Anchor contract
46
- console.log('\nπŸ“¦ Test 2: Deploy Rust/Anchor Contract');
47
- console.log('─'.repeat(50));
48
-
49
- const rustCode = `
50
- #[program]
51
- pub mod liquidity_pool {
52
- use super::*;
53
-
54
- pub fn initialize(ctx: Context<Initialize>) -> Result<()> {
55
- let pool = &mut ctx.accounts.pool;
56
- pool.total_liquidity = 0;
57
- Ok(())
58
- }
59
-
60
- pub fn add_liquidity(ctx: Context<AddLiquidity>, amount: u64) -> Result<()> {
61
- let pool = &mut ctx.accounts.pool;
62
- pool.total_liquidity += amount;
63
- Ok(())
64
- }
65
-
66
- pub fn get_price(ctx: Context<GetPrice>, token_a: Pubkey, token_b: Pubkey) -> Result<u64> {
67
- // Calculate price
68
- Ok(1000)
69
- }
70
- }
71
- `;
72
-
73
- const svmContract = await vm.deploy(rustCode, 'rust');
74
- console.log(` βœ“ Deployed Rust/Anchor contract: ${svmContract.address.substring(0, 20)}...`);
75
- console.log(` Version: ${svmContract.contract.version}`);
76
-
77
- // Test 3: Deploy a Move contract
78
- console.log('\nπŸ“¦ Test 3: Deploy Move Contract');
79
- console.log('─'.repeat(50));
80
-
81
- const moveCode = `
82
- module 0x1::oracle {
83
- struct PriceFeed has key {
84
- price: u64,
85
- timestamp: u64
86
- }
87
-
88
- public fun get_price(): u64 {
89
- 1500
90
- }
91
-
92
- public fun update_price(new_price: u64) {
93
- // Update price
94
- }
95
- }
96
- `;
97
-
98
- const moveContract = await vm.deploy(moveCode, 'move');
99
- console.log(` βœ“ Deployed Move contract: ${moveContract.address.substring(0, 20)}...`);
100
-
101
- // Test 4: Cross-contract call (Solidity β†’ Rust) - NO BRIDGE!
102
- console.log('\nπŸ”— Test 4: Cross-Contract Call (Solidity β†’ Rust)');
103
- console.log('─'.repeat(50));
104
-
105
- const crossResult = await vm.crossCall(
106
- evmContract.address,
107
- svmContract.address,
108
- 'get_price',
109
- []
110
- );
111
-
112
- console.log(` βœ“ Direct cross-call completed!`);
113
- console.log(` From: Solidity (EVM)`);
114
- console.log(` To: Rust (Solana)`);
115
- console.log(` NO BRIDGE USED!`);
116
-
117
- // Test 5: VM Upgrade (contracts auto-update!)
118
- console.log('\n⬆️ Test 5: VM Upgrade (Auto-Update Contracts)');
119
- console.log('─'.repeat(50));
120
-
121
- console.log(' Simulating Solana VM upgrade: 1.18.0 β†’ 1.19.0');
122
- const affected = await vm.upgradeVM('svm', '1.19.0');
123
- console.log(` βœ“ ${affected.length} contracts auto-upgraded!`);
124
- console.log(` Rust contract new version: ${svmContract.contract.version}`);
125
-
126
- // Test 6: Get all contracts
127
- console.log('\nπŸ“‹ Test 6: All Deployed Contracts');
128
- console.log('─'.repeat(50));
129
-
130
- const contracts = vm.getContracts();
131
- console.log(` Total: ${contracts.length} contracts`);
132
- for (const c of contracts) {
133
- console.log(` β€’ ${c.address.substring(0, 16)}... (${c.language}) v${c.version}`);
134
- }
135
-
136
- // Test 7: Dependency graph
137
- console.log('\nπŸ•ΈοΈ Test 7: Dependency Graph');
138
- console.log('─'.repeat(50));
139
-
140
- const graph = vm.getDependencyGraph();
141
- console.log(` Nodes: ${graph.nodes.length}`);
142
- console.log(` Edges: ${graph.edges.length}`);
143
-
144
- // Final stats
145
- console.log('\nπŸ“Š Final Stats');
146
- console.log('─'.repeat(50));
147
-
148
- const stats = vm.getStats();
149
- console.log(` Contracts Deployed: ${stats.contractsDeployed}`);
150
- console.log(` Cross-Calls: ${stats.crossCalls}`);
151
- console.log(` Upgrades: ${stats.upgrades}`);
152
- console.log(` Gas Used: ${stats.gasUsed} (ZERO FEES!)`);
153
-
154
- console.log('\n═══════════════════════════════════════════════════════════════');
155
- console.log(' ALL TESTS PASSED - TRUE CROSS-CHAIN INTEROP!');
156
- console.log('═══════════════════════════════════════════════════════════════');
157
- console.log('\n Key Achievements:');
158
- console.log(' βœ“ Solidity, Rust, and Move contracts deployed to SAME VM');
159
- console.log(' βœ“ Direct cross-contract calls (NO BRIDGES!)');
160
- console.log(' βœ“ Auto-upgrade when VM specs change');
161
- console.log(' βœ“ Shared state between all contracts');
162
- console.log(' βœ“ ZERO FEES on all operations');
163
- console.log('\n');
164
- }
165
-
166
- testUnifiedVM().catch(console.error);