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.
- package/README.md +97 -8
- package/lib/JAELIS-VM/lib/adapters/evm-adapter.js +454 -0
- package/lib/JAELIS-VM/lib/adapters/index.js +411 -0
- package/lib/JAELIS-VM/lib/adapters/svm-adapter.js +457 -0
- package/lib/JAELIS-VM/lib/compiler/jir-compiler.js +1097 -0
- package/lib/JAELIS-VM/lib/execution/engine.js +1183 -0
- package/lib/JAELIS-VM/lib/index.js +440 -0
- package/lib/JAELIS-VM/lib/integration/jaelis-integration.js +543 -0
- package/lib/JAELIS-VM/lib/serialization/serializer.js +819 -0
- package/lib/JAELIS-VM/lib/state/state-manager.js +1116 -0
- package/lib/JAELIS-VM/lib/translator/bytecode-translator.js +1222 -0
- package/lib/JAELIS-VM/lib/unified/cross-chain-state.js +836 -0
- package/lib/JAELIS-VM/lib/unified/dynamic-contracts.js +1127 -0
- package/lib/JAELIS-VM/lib/unified/index.js +378 -0
- package/lib/JAELIS-VM/lib/unified/jaelis-abi.js +1150 -0
- package/lib/JAELIS-VM/lib/unified/unified-compiler.js +1350 -0
- package/lib/JAELIS-VM/node_modules/.bin/download-cbor-prebuilds +12 -0
- package/lib/JAELIS-VM/node_modules/.bin/download-cbor-prebuilds.cmd +17 -0
- package/lib/JAELIS-VM/node_modules/.bin/download-cbor-prebuilds.ps1 +28 -0
- package/lib/JAELIS-VM/node_modules/.bin/download-msgpackr-prebuilds +12 -0
- package/lib/JAELIS-VM/node_modules/.bin/download-msgpackr-prebuilds.cmd +17 -0
- package/lib/JAELIS-VM/node_modules/.bin/download-msgpackr-prebuilds.ps1 +28 -0
- package/lib/JAELIS-VM/node_modules/.bin/node-gyp-build-optional-packages +12 -0
- package/lib/JAELIS-VM/node_modules/.bin/node-gyp-build-optional-packages-optional +12 -0
- package/lib/JAELIS-VM/node_modules/.bin/node-gyp-build-optional-packages-optional.cmd +17 -0
- package/lib/JAELIS-VM/node_modules/.bin/node-gyp-build-optional-packages-optional.ps1 +28 -0
- package/lib/JAELIS-VM/node_modules/.bin/node-gyp-build-optional-packages-test +12 -0
- package/lib/JAELIS-VM/node_modules/.bin/node-gyp-build-optional-packages-test.cmd +17 -0
- package/lib/JAELIS-VM/node_modules/.bin/node-gyp-build-optional-packages-test.ps1 +28 -0
- package/lib/JAELIS-VM/node_modules/.bin/node-gyp-build-optional-packages.cmd +17 -0
- package/lib/JAELIS-VM/node_modules/.bin/node-gyp-build-optional-packages.ps1 +28 -0
- package/lib/JAELIS-VM/node_modules/.package-lock.json +127 -0
- package/lib/JAELIS-VM/node_modules/@cbor-extract/cbor-extract-win32-x64/README.md +1 -0
- package/lib/JAELIS-VM/node_modules/@cbor-extract/cbor-extract-win32-x64/index.js +0 -0
- package/lib/JAELIS-VM/node_modules/@cbor-extract/cbor-extract-win32-x64/node.abi115.node +0 -0
- package/lib/JAELIS-VM/node_modules/@cbor-extract/cbor-extract-win32-x64/node.napi.node +0 -0
- package/lib/JAELIS-VM/node_modules/@cbor-extract/cbor-extract-win32-x64/package.json +17 -0
- package/lib/JAELIS-VM/node_modules/@msgpackr-extract/msgpackr-extract-win32-x64/README.md +1 -0
- package/lib/JAELIS-VM/node_modules/@msgpackr-extract/msgpackr-extract-win32-x64/index.js +0 -0
- package/lib/JAELIS-VM/node_modules/@msgpackr-extract/msgpackr-extract-win32-x64/node.abi115.node +0 -0
- package/lib/JAELIS-VM/node_modules/@msgpackr-extract/msgpackr-extract-win32-x64/node.napi.node +0 -0
- package/lib/JAELIS-VM/node_modules/@msgpackr-extract/msgpackr-extract-win32-x64/package.json +17 -0
- package/lib/JAELIS-VM/node_modules/cbor-extract/LICENSE +21 -0
- package/lib/JAELIS-VM/node_modules/cbor-extract/README.md +5 -0
- package/lib/JAELIS-VM/node_modules/cbor-extract/bin/download-prebuilds.js +11 -0
- package/lib/JAELIS-VM/node_modules/cbor-extract/binding.gyp +60 -0
- package/lib/JAELIS-VM/node_modules/cbor-extract/index.js +1 -0
- package/lib/JAELIS-VM/node_modules/cbor-extract/package.json +50 -0
- package/lib/JAELIS-VM/node_modules/cbor-extract/src/extract.cpp +198 -0
- package/lib/JAELIS-VM/node_modules/cbor-x/LICENSE +21 -0
- package/lib/JAELIS-VM/node_modules/cbor-x/README.md +380 -0
- package/lib/JAELIS-VM/node_modules/cbor-x/SECURITY.md +11 -0
- package/lib/JAELIS-VM/node_modules/cbor-x/benchmark.md +73 -0
- package/lib/JAELIS-VM/node_modules/cbor-x/browser.js +11 -0
- package/lib/JAELIS-VM/node_modules/cbor-x/decode.d.ts +2 -0
- package/lib/JAELIS-VM/node_modules/cbor-x/decode.js +1300 -0
- package/lib/JAELIS-VM/node_modules/cbor-x/dist/decode-no-eval.cjs +1244 -0
- package/lib/JAELIS-VM/node_modules/cbor-x/dist/decode-no-eval.cjs.map +1 -0
- package/lib/JAELIS-VM/node_modules/cbor-x/dist/index-no-eval.cjs +2509 -0
- package/lib/JAELIS-VM/node_modules/cbor-x/dist/index-no-eval.cjs.map +1 -0
- package/lib/JAELIS-VM/node_modules/cbor-x/dist/index-no-eval.min.js +2 -0
- package/lib/JAELIS-VM/node_modules/cbor-x/dist/index-no-eval.min.js.map +1 -0
- package/lib/JAELIS-VM/node_modules/cbor-x/dist/index.js +2508 -0
- package/lib/JAELIS-VM/node_modules/cbor-x/dist/index.js.map +1 -0
- package/lib/JAELIS-VM/node_modules/cbor-x/dist/index.min.js +2 -0
- package/lib/JAELIS-VM/node_modules/cbor-x/dist/index.min.js.map +1 -0
- package/lib/JAELIS-VM/node_modules/cbor-x/dist/node.cjs +2629 -0
- package/lib/JAELIS-VM/node_modules/cbor-x/dist/node.cjs.map +1 -0
- package/lib/JAELIS-VM/node_modules/cbor-x/dist/test.js +3343 -0
- package/lib/JAELIS-VM/node_modules/cbor-x/dist/test.js.map +1 -0
- package/lib/JAELIS-VM/node_modules/cbor-x/encode.d.ts +1 -0
- package/lib/JAELIS-VM/node_modules/cbor-x/encode.js +1231 -0
- package/lib/JAELIS-VM/node_modules/cbor-x/index.d.ts +79 -0
- package/lib/JAELIS-VM/node_modules/cbor-x/index.js +3 -0
- package/lib/JAELIS-VM/node_modules/cbor-x/iterators.js +85 -0
- package/lib/JAELIS-VM/node_modules/cbor-x/node-index.js +24 -0
- package/lib/JAELIS-VM/node_modules/cbor-x/package.json +94 -0
- package/lib/JAELIS-VM/node_modules/cbor-x/rollup.config.js +88 -0
- package/lib/JAELIS-VM/node_modules/cbor-x/stream.js +61 -0
- package/lib/JAELIS-VM/node_modules/cbor-x/webpack.config.js +19 -0
- package/lib/JAELIS-VM/node_modules/detect-libc/LICENSE +201 -0
- package/lib/JAELIS-VM/node_modules/detect-libc/README.md +163 -0
- package/lib/JAELIS-VM/node_modules/detect-libc/index.d.ts +14 -0
- package/lib/JAELIS-VM/node_modules/detect-libc/lib/detect-libc.js +313 -0
- package/lib/JAELIS-VM/node_modules/detect-libc/lib/elf.js +39 -0
- package/lib/JAELIS-VM/node_modules/detect-libc/lib/filesystem.js +51 -0
- package/lib/JAELIS-VM/node_modules/detect-libc/lib/process.js +24 -0
- package/lib/JAELIS-VM/node_modules/detect-libc/package.json +44 -0
- package/lib/JAELIS-VM/node_modules/msgpackr/LICENSE +21 -0
- package/lib/JAELIS-VM/node_modules/msgpackr/README.md +372 -0
- package/lib/JAELIS-VM/node_modules/msgpackr/SECURITY.md +11 -0
- package/lib/JAELIS-VM/node_modules/msgpackr/benchmark.md +67 -0
- package/lib/JAELIS-VM/node_modules/msgpackr/dist/index-no-eval.cjs +2407 -0
- package/lib/JAELIS-VM/node_modules/msgpackr/dist/index-no-eval.cjs.map +1 -0
- package/lib/JAELIS-VM/node_modules/msgpackr/dist/index-no-eval.min.js +2 -0
- package/lib/JAELIS-VM/node_modules/msgpackr/dist/index-no-eval.min.js.map +1 -0
- package/lib/JAELIS-VM/node_modules/msgpackr/dist/index.js +2406 -0
- package/lib/JAELIS-VM/node_modules/msgpackr/dist/index.js.map +1 -0
- package/lib/JAELIS-VM/node_modules/msgpackr/dist/index.min.js +2 -0
- package/lib/JAELIS-VM/node_modules/msgpackr/dist/index.min.js.map +1 -0
- package/lib/JAELIS-VM/node_modules/msgpackr/dist/node.cjs +3320 -0
- package/lib/JAELIS-VM/node_modules/msgpackr/dist/node.cjs.map +1 -0
- package/lib/JAELIS-VM/node_modules/msgpackr/dist/test.js +4540 -0
- package/lib/JAELIS-VM/node_modules/msgpackr/dist/test.js.map +1 -0
- package/lib/JAELIS-VM/node_modules/msgpackr/dist/unpack-no-eval.cjs +1250 -0
- package/lib/JAELIS-VM/node_modules/msgpackr/dist/unpack-no-eval.cjs.map +1 -0
- package/lib/JAELIS-VM/node_modules/msgpackr/index.d.cts +91 -0
- package/lib/JAELIS-VM/node_modules/msgpackr/index.d.ts +91 -0
- package/lib/JAELIS-VM/node_modules/msgpackr/index.js +5 -0
- package/lib/JAELIS-VM/node_modules/msgpackr/iterators.js +87 -0
- package/lib/JAELIS-VM/node_modules/msgpackr/node-index.js +25 -0
- package/lib/JAELIS-VM/node_modules/msgpackr/pack.d.cts +1 -0
- package/lib/JAELIS-VM/node_modules/msgpackr/pack.d.ts +1 -0
- package/lib/JAELIS-VM/node_modules/msgpackr/pack.js +1141 -0
- package/lib/JAELIS-VM/node_modules/msgpackr/package.json +104 -0
- package/lib/JAELIS-VM/node_modules/msgpackr/rollup.config.js +88 -0
- package/lib/JAELIS-VM/node_modules/msgpackr/stream.js +57 -0
- package/lib/JAELIS-VM/node_modules/msgpackr/struct.js +815 -0
- package/lib/JAELIS-VM/node_modules/msgpackr/test-worker.js +3 -0
- package/lib/JAELIS-VM/node_modules/msgpackr/unpack.d.cts +2 -0
- package/lib/JAELIS-VM/node_modules/msgpackr/unpack.d.ts +2 -0
- package/lib/JAELIS-VM/node_modules/msgpackr/unpack.js +1221 -0
- package/lib/JAELIS-VM/node_modules/msgpackr-extract/LICENSE +21 -0
- package/lib/JAELIS-VM/node_modules/msgpackr-extract/README.md +5 -0
- package/lib/JAELIS-VM/node_modules/msgpackr-extract/bin/download-prebuilds.js +13 -0
- package/lib/JAELIS-VM/node_modules/msgpackr-extract/binding.gyp +63 -0
- package/lib/JAELIS-VM/node_modules/msgpackr-extract/index.js +1 -0
- package/lib/JAELIS-VM/node_modules/msgpackr-extract/node_modules/.bin/node-gyp-build-optional-packages +12 -0
- package/lib/JAELIS-VM/node_modules/msgpackr-extract/node_modules/.bin/node-gyp-build-optional-packages-optional +12 -0
- package/lib/JAELIS-VM/node_modules/msgpackr-extract/node_modules/.bin/node-gyp-build-optional-packages-optional.cmd +17 -0
- package/lib/JAELIS-VM/node_modules/msgpackr-extract/node_modules/.bin/node-gyp-build-optional-packages-optional.ps1 +28 -0
- package/lib/JAELIS-VM/node_modules/msgpackr-extract/node_modules/.bin/node-gyp-build-optional-packages-test +12 -0
- package/lib/JAELIS-VM/node_modules/msgpackr-extract/node_modules/.bin/node-gyp-build-optional-packages-test.cmd +17 -0
- package/lib/JAELIS-VM/node_modules/msgpackr-extract/node_modules/.bin/node-gyp-build-optional-packages-test.ps1 +28 -0
- package/lib/JAELIS-VM/node_modules/msgpackr-extract/node_modules/.bin/node-gyp-build-optional-packages.cmd +17 -0
- package/lib/JAELIS-VM/node_modules/msgpackr-extract/node_modules/.bin/node-gyp-build-optional-packages.ps1 +28 -0
- package/lib/JAELIS-VM/node_modules/msgpackr-extract/node_modules/node-gyp-build-optional-packages/LICENSE +21 -0
- package/lib/JAELIS-VM/node_modules/msgpackr-extract/node_modules/node-gyp-build-optional-packages/README.md +58 -0
- package/lib/JAELIS-VM/node_modules/msgpackr-extract/node_modules/node-gyp-build-optional-packages/bin.js +82 -0
- package/lib/JAELIS-VM/node_modules/msgpackr-extract/node_modules/node-gyp-build-optional-packages/build-test.js +19 -0
- package/lib/JAELIS-VM/node_modules/msgpackr-extract/node_modules/node-gyp-build-optional-packages/index.js +6 -0
- package/lib/JAELIS-VM/node_modules/msgpackr-extract/node_modules/node-gyp-build-optional-packages/node-gyp-build.js +236 -0
- package/lib/JAELIS-VM/node_modules/msgpackr-extract/node_modules/node-gyp-build-optional-packages/optional.js +7 -0
- package/lib/JAELIS-VM/node_modules/msgpackr-extract/node_modules/node-gyp-build-optional-packages/package.json +32 -0
- package/lib/JAELIS-VM/node_modules/msgpackr-extract/package.json +50 -0
- package/lib/JAELIS-VM/node_modules/msgpackr-extract/src/extract.cpp +274 -0
- package/lib/JAELIS-VM/node_modules/node-gyp-build-optional-packages/LICENSE +21 -0
- package/lib/JAELIS-VM/node_modules/node-gyp-build-optional-packages/README.md +58 -0
- package/lib/JAELIS-VM/node_modules/node-gyp-build-optional-packages/bin.js +77 -0
- package/lib/JAELIS-VM/node_modules/node-gyp-build-optional-packages/build-test.js +19 -0
- package/lib/JAELIS-VM/node_modules/node-gyp-build-optional-packages/index.js +224 -0
- package/lib/JAELIS-VM/node_modules/node-gyp-build-optional-packages/optional.js +7 -0
- package/lib/JAELIS-VM/node_modules/node-gyp-build-optional-packages/package.json +32 -0
- package/lib/JAELIS-VM/package-lock.json +284 -0
- package/lib/JAELIS-VM/package.json +38 -0
- package/lib/JAELIS-VM/test/comprehensive.test.js +267 -0
- package/lib/JAELIS-VM/test/cross-chain-test.js +470 -0
- package/lib/JAELIS-VM/test/unified-vm-test.js +459 -0
- package/lib/JAELIS-VM/test/unified.test.js +166 -0
- package/lib/JAELIS-VM/test/vm.test.js +599 -0
- package/lib/index.js +310 -4
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -13,7 +13,36 @@ JAELIS is a next-generation blockchain with a **Universal Virtual Machine** that
|
|
|
13
13
|
|
|
14
14
|
## Universal VM - Core Innovation
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
JAELIS provides **TWO deployment systems** for maximum flexibility:
|
|
17
|
+
|
|
18
|
+
### Option 1: Unified VM (Cross-Language Magic)
|
|
19
|
+
|
|
20
|
+
Compile **MULTIPLE contracts from MULTIPLE languages** into **ONE unified bytecode bundle** with **ONE ABI**:
|
|
21
|
+
|
|
22
|
+
```javascript
|
|
23
|
+
// Deploy unified bundle - ALL languages compile to ONE bytecode!
|
|
24
|
+
const result = await jaelis.deployUnified({
|
|
25
|
+
from: '0x...',
|
|
26
|
+
sources: [
|
|
27
|
+
{ code: solidityCode, language: 'solidity', name: 'Token' },
|
|
28
|
+
{ code: rustCode, language: 'rust', name: 'DeFi' },
|
|
29
|
+
{ code: moveCode, language: 'move', name: 'NFT' }
|
|
30
|
+
]
|
|
31
|
+
});
|
|
32
|
+
// ALL contracts share memory and can call each other DIRECTLY!
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Option 2: Multi-VM (Native Compatibility)
|
|
36
|
+
|
|
37
|
+
Deploy to **native VMs** for exact compatibility with original chain behavior:
|
|
38
|
+
|
|
39
|
+
```javascript
|
|
40
|
+
await jaelis.deploySolanaProgram({ bytecode, programId, owner }); // → SVM
|
|
41
|
+
await jaelis.deployMoveModule({ bytecode, moduleName, owner }); // → MoveVM
|
|
42
|
+
await jaelis.deployTonContract({ code, data, owner }); // → TVM
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Language Support Matrix
|
|
17
46
|
|
|
18
47
|
| Language | Ecosystem | Status |
|
|
19
48
|
|----------|-----------|--------|
|
|
@@ -24,12 +53,10 @@ The JAELIS Universal VM executes contracts from multiple ecosystems natively:
|
|
|
24
53
|
| **Cairo** | StarkNet | Production |
|
|
25
54
|
| **Vyper** | Ethereum (Python-like) | Production |
|
|
26
55
|
|
|
27
|
-
### Cross-Language Contract Calls
|
|
28
|
-
|
|
29
|
-
A Solidity contract can call a Rust contract. A Move module can interact with FunC. All native, all on-chain:
|
|
56
|
+
### Cross-Language Contract Calls (NO BRIDGES!)
|
|
30
57
|
|
|
31
58
|
```javascript
|
|
32
|
-
// Solidity
|
|
59
|
+
// Solidity → Rust call - DIRECT, no bridges needed!
|
|
33
60
|
await jaelis.crossContractCall({
|
|
34
61
|
from: solidityContract,
|
|
35
62
|
to: rustProgram,
|
|
@@ -148,9 +175,10 @@ Your node exposes standard JSON-RPC plus JAELIS-specific methods:
|
|
|
148
175
|
| Method | Description |
|
|
149
176
|
|--------|-------------|
|
|
150
177
|
| `jaelis_getSupportedLanguages` | Returns: `['solidity', 'rust', 'move', 'func', 'cairo', 'vyper']` |
|
|
151
|
-
| `
|
|
178
|
+
| `jaelis_deployUnified` | Deploy unified bundle (multiple languages → ONE bytecode!) |
|
|
179
|
+
| `jaelis_deployContract` | Deploy single contract in any supported language |
|
|
152
180
|
| `jaelis_executeContract` | Execute contract method |
|
|
153
|
-
| `jaelis_crossContractCall` | Call between contracts of different languages |
|
|
181
|
+
| `jaelis_crossContractCall` | Call between contracts of different languages (NO BRIDGES!) |
|
|
154
182
|
|
|
155
183
|
### Cross-Chain Settlement Methods
|
|
156
184
|
| Method | Description |
|
|
@@ -172,7 +200,11 @@ Your node exposes standard JSON-RPC plus JAELIS-specific methods:
|
|
|
172
200
|
| `jaelis_validateAddressSafety` | Anti-phishing check |
|
|
173
201
|
| `jaelis_checkDustAttacks` | Detect address poisoning |
|
|
174
202
|
|
|
175
|
-
###
|
|
203
|
+
### Multi-Ecosystem Compatibility Layers
|
|
204
|
+
|
|
205
|
+
JAELIS nodes support RPC methods from **every major blockchain ecosystem**. Developers can use their familiar method names - they all proxy to native `jaelis_*` methods under the hood.
|
|
206
|
+
|
|
207
|
+
#### Ethereum (eth_*)
|
|
176
208
|
| Method | Description |
|
|
177
209
|
|--------|-------------|
|
|
178
210
|
| `eth_blockNumber` | Get latest block number |
|
|
@@ -181,6 +213,58 @@ Your node exposes standard JSON-RPC plus JAELIS-specific methods:
|
|
|
181
213
|
| `eth_call` | Call contract (read-only) |
|
|
182
214
|
| `eth_getTransactionReceipt` | Get transaction receipt |
|
|
183
215
|
|
|
216
|
+
#### Solana (solana_*)
|
|
217
|
+
| Method | Description |
|
|
218
|
+
|--------|-------------|
|
|
219
|
+
| `solana_getBalance` | Get account balance (lamports format) |
|
|
220
|
+
| `solana_getSlot` | Get current slot (block height) |
|
|
221
|
+
| `solana_getLatestBlockhash` | Get recent blockhash |
|
|
222
|
+
| `solana_getHealth` | Check node health |
|
|
223
|
+
|
|
224
|
+
#### Bitcoin (btc_*)
|
|
225
|
+
| Method | Description |
|
|
226
|
+
|--------|-------------|
|
|
227
|
+
| `btc_getbalance` | Get balance (BTC decimals) |
|
|
228
|
+
| `btc_getblockcount` | Get block height |
|
|
229
|
+
| `btc_getblock` | Get block by hash |
|
|
230
|
+
| `btc_gettransaction` | Get transaction |
|
|
231
|
+
| `btc_getblockchaininfo` | Chain info |
|
|
232
|
+
| `btc_estimatesmartfee` | Returns 0 (zero fees!) |
|
|
233
|
+
|
|
234
|
+
#### Move/Aptos/Sui (move_*)
|
|
235
|
+
| Method | Description |
|
|
236
|
+
|--------|-------------|
|
|
237
|
+
| `move_getLedgerInfo` | Get ledger info |
|
|
238
|
+
| `move_getAccountResource` | Get account resource |
|
|
239
|
+
| `move_getAccountModule` | Get account module |
|
|
240
|
+
|
|
241
|
+
#### TON/Telegram (ton_*)
|
|
242
|
+
| Method | Description |
|
|
243
|
+
|--------|-------------|
|
|
244
|
+
| `ton_getAddressBalance` | Get balance |
|
|
245
|
+
| `ton_getMasterchainInfo` | Get masterchain info |
|
|
246
|
+
| `ton_getAccountState` | Get account state |
|
|
247
|
+
| `ton_runGetMethod` | Run get method |
|
|
248
|
+
|
|
249
|
+
#### WASM/CosmWasm (wasm_*)
|
|
250
|
+
| Method | Description |
|
|
251
|
+
|--------|-------------|
|
|
252
|
+
| `wasm_call` | Call contract |
|
|
253
|
+
| `wasm_query` | Query contract state |
|
|
254
|
+
| `wasm_deploy` | Deploy WASM contract |
|
|
255
|
+
| `wasm_execute` | Execute contract |
|
|
256
|
+
| `wasm_getCode` | Get contract code |
|
|
257
|
+
|
|
258
|
+
#### StarkNet/Cairo (starknet_*)
|
|
259
|
+
| Method | Description |
|
|
260
|
+
|--------|-------------|
|
|
261
|
+
| `starknet_chainId` | Get chain ID |
|
|
262
|
+
| `starknet_blockNumber` | Get block number |
|
|
263
|
+
| `starknet_call` | Call contract |
|
|
264
|
+
| `starknet_estimateFee` | Returns 0 (zero fees!) |
|
|
265
|
+
| `starknet_getTransactionByHash` | Get transaction |
|
|
266
|
+
| `starknet_addInvokeTransaction` | Send invoke transaction |
|
|
267
|
+
|
|
184
268
|
## Programmatic Usage
|
|
185
269
|
|
|
186
270
|
```javascript
|
|
@@ -258,6 +342,9 @@ jaelis-node status
|
|
|
258
342
|
```
|
|
259
343
|
jaelis-data/
|
|
260
344
|
├── blockchain/ # Block and state data (LevelDB)
|
|
345
|
+
│ ├── state/ # Account states, contract storage
|
|
346
|
+
│ ├── blocks/ # Block headers and transactions
|
|
347
|
+
│ └── index/ # Chain indexes
|
|
261
348
|
├── node-registry/ # Node tracking and statistics
|
|
262
349
|
├── wallet-config/ # Wallet configuration
|
|
263
350
|
├── peers/ # Peer database
|
|
@@ -265,6 +352,8 @@ jaelis-data/
|
|
|
265
352
|
└── logs/ # Node logs
|
|
266
353
|
```
|
|
267
354
|
|
|
355
|
+
**State Persistence:** All VM state (accounts, contracts, storage) persists to LevelDB. Your node's state survives restarts - no data loss.
|
|
356
|
+
|
|
268
357
|
## Environment Variables
|
|
269
358
|
|
|
270
359
|
| Variable | Description | Default |
|
|
@@ -0,0 +1,454 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EVM ADAPTER
|
|
3
|
+
*
|
|
4
|
+
* Provides EVM-compatible interface for JAELIS Universal VM
|
|
5
|
+
* Supports: Ethereum, BSC, Polygon, Arbitrum, Optimism, Base, Avalanche
|
|
6
|
+
*
|
|
7
|
+
* Features:
|
|
8
|
+
* - Solidity ABI encoding/decoding
|
|
9
|
+
* - EIP-2718 transaction types
|
|
10
|
+
* - EIP-1559 gas pricing
|
|
11
|
+
* - Precompiled contracts
|
|
12
|
+
*
|
|
13
|
+
* @version 0.1.0
|
|
14
|
+
* @author Mario Papaleo - JAELIS Foundation
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
const crypto = require('crypto');
|
|
18
|
+
|
|
19
|
+
// Solidity ABI type encodings
|
|
20
|
+
const ABI_TYPES = {
|
|
21
|
+
uint256: { size: 32, dynamic: false },
|
|
22
|
+
int256: { size: 32, dynamic: false },
|
|
23
|
+
address: { size: 32, dynamic: false },
|
|
24
|
+
bool: { size: 32, dynamic: false },
|
|
25
|
+
bytes32: { size: 32, dynamic: false },
|
|
26
|
+
bytes: { size: null, dynamic: true },
|
|
27
|
+
string: { size: null, dynamic: true },
|
|
28
|
+
'uint256[]': { size: null, dynamic: true },
|
|
29
|
+
'address[]': { size: null, dynamic: true }
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
// EVM Precompiled contract addresses
|
|
33
|
+
const PRECOMPILES = {
|
|
34
|
+
'0x0000000000000000000000000000000000000001': 'ecrecover',
|
|
35
|
+
'0x0000000000000000000000000000000000000002': 'sha256',
|
|
36
|
+
'0x0000000000000000000000000000000000000003': 'ripemd160',
|
|
37
|
+
'0x0000000000000000000000000000000000000004': 'identity',
|
|
38
|
+
'0x0000000000000000000000000000000000000005': 'modexp',
|
|
39
|
+
'0x0000000000000000000000000000000000000006': 'ecadd',
|
|
40
|
+
'0x0000000000000000000000000000000000000007': 'ecmul',
|
|
41
|
+
'0x0000000000000000000000000000000000000008': 'ecpairing',
|
|
42
|
+
'0x0000000000000000000000000000000000000009': 'blake2f'
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
class EVMAdapter {
|
|
46
|
+
constructor(vm) {
|
|
47
|
+
this.vm = vm;
|
|
48
|
+
this.chainId = 4545; // JAELIS testnet
|
|
49
|
+
|
|
50
|
+
// Function signature cache
|
|
51
|
+
this.signatureCache = new Map();
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Deploy EVM contract
|
|
56
|
+
*/
|
|
57
|
+
async deploy(bytecode, constructorArgs = [], options = {}) {
|
|
58
|
+
// Encode constructor arguments
|
|
59
|
+
const encodedArgs = this.encodeParameters(
|
|
60
|
+
options.constructorTypes || [],
|
|
61
|
+
constructorArgs
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
const deployBytecode = Buffer.concat([
|
|
65
|
+
Buffer.from(bytecode.replace('0x', ''), 'hex'),
|
|
66
|
+
encodedArgs
|
|
67
|
+
]);
|
|
68
|
+
|
|
69
|
+
return this.vm.deployBytecode(deployBytecode, 'evm', options);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Call EVM contract function
|
|
74
|
+
*/
|
|
75
|
+
async call(address, functionSignature, args = [], options = {}) {
|
|
76
|
+
// Parse function signature
|
|
77
|
+
const { name, types } = this.parseFunctionSignature(functionSignature);
|
|
78
|
+
|
|
79
|
+
// Encode function call
|
|
80
|
+
const selector = this.getFunctionSelector(functionSignature);
|
|
81
|
+
const encodedArgs = this.encodeParameters(types, args);
|
|
82
|
+
|
|
83
|
+
const callData = Buffer.concat([selector, encodedArgs]);
|
|
84
|
+
|
|
85
|
+
// Execute
|
|
86
|
+
const result = await this.vm.execute(address, name, callData, {
|
|
87
|
+
...options,
|
|
88
|
+
callData
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
// Decode result if return types specified
|
|
92
|
+
if (options.returnTypes) {
|
|
93
|
+
result.decoded = this.decodeParameters(options.returnTypes, result.returnValue);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return result;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Get function selector (4 bytes)
|
|
101
|
+
*/
|
|
102
|
+
getFunctionSelector(signature) {
|
|
103
|
+
// Check cache
|
|
104
|
+
if (this.signatureCache.has(signature)) {
|
|
105
|
+
return this.signatureCache.get(signature);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// Normalize signature
|
|
109
|
+
const normalized = signature.replace(/\s/g, '');
|
|
110
|
+
|
|
111
|
+
// Keccak256 hash and take first 4 bytes
|
|
112
|
+
const hash = this.keccak256(Buffer.from(normalized));
|
|
113
|
+
const selector = hash.slice(0, 4);
|
|
114
|
+
|
|
115
|
+
this.signatureCache.set(signature, selector);
|
|
116
|
+
return selector;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Parse function signature
|
|
121
|
+
*/
|
|
122
|
+
parseFunctionSignature(signature) {
|
|
123
|
+
const match = signature.match(/^(\w+)\((.*)\)$/);
|
|
124
|
+
if (!match) {
|
|
125
|
+
throw new Error(`Invalid function signature: ${signature}`);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const name = match[1];
|
|
129
|
+
const types = match[2] ? match[2].split(',').map(t => t.trim()) : [];
|
|
130
|
+
|
|
131
|
+
return { name, types };
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Encode function parameters (ABI encoding)
|
|
136
|
+
*/
|
|
137
|
+
encodeParameters(types, values) {
|
|
138
|
+
if (types.length !== values.length) {
|
|
139
|
+
throw new Error('Types and values length mismatch');
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const heads = [];
|
|
143
|
+
const tails = [];
|
|
144
|
+
let tailOffset = types.length * 32; // Start of dynamic data
|
|
145
|
+
|
|
146
|
+
for (let i = 0; i < types.length; i++) {
|
|
147
|
+
const type = types[i];
|
|
148
|
+
const value = values[i];
|
|
149
|
+
const typeInfo = ABI_TYPES[type];
|
|
150
|
+
|
|
151
|
+
if (!typeInfo || !typeInfo.dynamic) {
|
|
152
|
+
// Static type - encode directly in head
|
|
153
|
+
heads.push(this.encodeValue(type, value));
|
|
154
|
+
} else {
|
|
155
|
+
// Dynamic type - encode offset in head, data in tail
|
|
156
|
+
heads.push(this.encodeUint256(tailOffset));
|
|
157
|
+
const encoded = this.encodeValue(type, value);
|
|
158
|
+
tails.push(encoded);
|
|
159
|
+
tailOffset += encoded.length;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
return Buffer.concat([...heads, ...tails]);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Decode function parameters
|
|
168
|
+
*/
|
|
169
|
+
decodeParameters(types, data) {
|
|
170
|
+
const results = [];
|
|
171
|
+
let offset = 0;
|
|
172
|
+
|
|
173
|
+
for (const type of types) {
|
|
174
|
+
const typeInfo = ABI_TYPES[type];
|
|
175
|
+
|
|
176
|
+
if (!typeInfo || !typeInfo.dynamic) {
|
|
177
|
+
// Static type
|
|
178
|
+
results.push(this.decodeValue(type, data, offset));
|
|
179
|
+
offset += 32;
|
|
180
|
+
} else {
|
|
181
|
+
// Dynamic type - read offset first
|
|
182
|
+
const dataOffset = Number(this.decodeUint256(data, offset));
|
|
183
|
+
results.push(this.decodeValue(type, data, dataOffset));
|
|
184
|
+
offset += 32;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
return results;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Encode a single value
|
|
193
|
+
*/
|
|
194
|
+
encodeValue(type, value) {
|
|
195
|
+
switch (type) {
|
|
196
|
+
case 'uint256':
|
|
197
|
+
case 'int256':
|
|
198
|
+
return this.encodeUint256(value);
|
|
199
|
+
|
|
200
|
+
case 'address':
|
|
201
|
+
return this.encodeAddress(value);
|
|
202
|
+
|
|
203
|
+
case 'bool':
|
|
204
|
+
return this.encodeUint256(value ? 1 : 0);
|
|
205
|
+
|
|
206
|
+
case 'bytes32':
|
|
207
|
+
return this.encodeBytes32(value);
|
|
208
|
+
|
|
209
|
+
case 'bytes':
|
|
210
|
+
return this.encodeBytes(value);
|
|
211
|
+
|
|
212
|
+
case 'string':
|
|
213
|
+
return this.encodeString(value);
|
|
214
|
+
|
|
215
|
+
case 'uint256[]':
|
|
216
|
+
case 'address[]':
|
|
217
|
+
return this.encodeArray(type.replace('[]', ''), value);
|
|
218
|
+
|
|
219
|
+
default:
|
|
220
|
+
throw new Error(`Unsupported type: ${type}`);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Decode a single value
|
|
226
|
+
*/
|
|
227
|
+
decodeValue(type, data, offset) {
|
|
228
|
+
switch (type) {
|
|
229
|
+
case 'uint256':
|
|
230
|
+
return this.decodeUint256(data, offset);
|
|
231
|
+
|
|
232
|
+
case 'int256':
|
|
233
|
+
return this.decodeInt256(data, offset);
|
|
234
|
+
|
|
235
|
+
case 'address':
|
|
236
|
+
return this.decodeAddress(data, offset);
|
|
237
|
+
|
|
238
|
+
case 'bool':
|
|
239
|
+
return this.decodeUint256(data, offset) !== 0n;
|
|
240
|
+
|
|
241
|
+
case 'bytes32':
|
|
242
|
+
return '0x' + data.slice(offset, offset + 32).toString('hex');
|
|
243
|
+
|
|
244
|
+
case 'bytes':
|
|
245
|
+
return this.decodeBytes(data, offset);
|
|
246
|
+
|
|
247
|
+
case 'string':
|
|
248
|
+
return this.decodeString(data, offset);
|
|
249
|
+
|
|
250
|
+
default:
|
|
251
|
+
throw new Error(`Unsupported type: ${type}`);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
// ═══════════════════════════════════════════════════════════════
|
|
256
|
+
// ENCODING HELPERS
|
|
257
|
+
// ═══════════════════════════════════════════════════════════════
|
|
258
|
+
|
|
259
|
+
encodeUint256(value) {
|
|
260
|
+
const buf = Buffer.alloc(32);
|
|
261
|
+
let v = BigInt(value);
|
|
262
|
+
for (let i = 31; i >= 0 && v > 0n; i--) {
|
|
263
|
+
buf[i] = Number(v & 0xffn);
|
|
264
|
+
v >>= 8n;
|
|
265
|
+
}
|
|
266
|
+
return buf;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
decodeUint256(data, offset = 0) {
|
|
270
|
+
let result = 0n;
|
|
271
|
+
for (let i = 0; i < 32; i++) {
|
|
272
|
+
result = (result << 8n) | BigInt(data[offset + i] || 0);
|
|
273
|
+
}
|
|
274
|
+
return result;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
decodeInt256(data, offset = 0) {
|
|
278
|
+
const unsigned = this.decodeUint256(data, offset);
|
|
279
|
+
// Check sign bit
|
|
280
|
+
if (unsigned >= 2n ** 255n) {
|
|
281
|
+
return unsigned - 2n ** 256n;
|
|
282
|
+
}
|
|
283
|
+
return unsigned;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
encodeAddress(address) {
|
|
287
|
+
const buf = Buffer.alloc(32);
|
|
288
|
+
const hex = address.startsWith('0x') ? address.slice(2) : address;
|
|
289
|
+
Buffer.from(hex.padStart(40, '0'), 'hex').copy(buf, 12);
|
|
290
|
+
return buf;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
decodeAddress(data, offset = 0) {
|
|
294
|
+
return '0x' + data.slice(offset + 12, offset + 32).toString('hex');
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
encodeBytes32(value) {
|
|
298
|
+
const buf = Buffer.alloc(32);
|
|
299
|
+
const hex = value.startsWith('0x') ? value.slice(2) : value;
|
|
300
|
+
Buffer.from(hex.padEnd(64, '0'), 'hex').copy(buf);
|
|
301
|
+
return buf;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
encodeBytes(value) {
|
|
305
|
+
const data = Buffer.isBuffer(value) ? value : Buffer.from(value.replace('0x', ''), 'hex');
|
|
306
|
+
const length = this.encodeUint256(data.length);
|
|
307
|
+
|
|
308
|
+
// Pad to 32-byte boundary
|
|
309
|
+
const padded = Buffer.alloc(Math.ceil(data.length / 32) * 32);
|
|
310
|
+
data.copy(padded);
|
|
311
|
+
|
|
312
|
+
return Buffer.concat([length, padded]);
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
decodeBytes(data, offset = 0) {
|
|
316
|
+
const length = Number(this.decodeUint256(data, offset));
|
|
317
|
+
return data.slice(offset + 32, offset + 32 + length);
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
encodeString(value) {
|
|
321
|
+
return this.encodeBytes(Buffer.from(value, 'utf8'));
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
decodeString(data, offset = 0) {
|
|
325
|
+
return this.decodeBytes(data, offset).toString('utf8');
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
encodeArray(elementType, values) {
|
|
329
|
+
const length = this.encodeUint256(values.length);
|
|
330
|
+
const elements = values.map(v => this.encodeValue(elementType, v));
|
|
331
|
+
return Buffer.concat([length, ...elements]);
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
// ═══════════════════════════════════════════════════════════════
|
|
335
|
+
// CRYPTO
|
|
336
|
+
// ═══════════════════════════════════════════════════════════════
|
|
337
|
+
|
|
338
|
+
keccak256(data) {
|
|
339
|
+
// Using sha3-256 as approximation
|
|
340
|
+
// Real implementation would use keccak
|
|
341
|
+
return crypto.createHash('sha3-256').update(data).digest();
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
// ═══════════════════════════════════════════════════════════════
|
|
345
|
+
// TRANSACTION ENCODING (EIP-2718, EIP-1559)
|
|
346
|
+
// ═══════════════════════════════════════════════════════════════
|
|
347
|
+
|
|
348
|
+
encodeTransaction(tx) {
|
|
349
|
+
// EIP-1559 transaction
|
|
350
|
+
const fields = [
|
|
351
|
+
tx.chainId || this.chainId,
|
|
352
|
+
tx.nonce || 0,
|
|
353
|
+
tx.maxPriorityFeePerGas || 0,
|
|
354
|
+
tx.maxFeePerGas || 0,
|
|
355
|
+
tx.gasLimit || 21000,
|
|
356
|
+
tx.to || '',
|
|
357
|
+
tx.value || 0,
|
|
358
|
+
tx.data || Buffer.alloc(0),
|
|
359
|
+
tx.accessList || []
|
|
360
|
+
];
|
|
361
|
+
|
|
362
|
+
// RLP encode (simplified)
|
|
363
|
+
const encoded = this.rlpEncode(fields);
|
|
364
|
+
|
|
365
|
+
// Prepend transaction type (0x02 for EIP-1559)
|
|
366
|
+
return Buffer.concat([Buffer.from([0x02]), encoded]);
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
rlpEncode(input) {
|
|
370
|
+
if (Array.isArray(input)) {
|
|
371
|
+
const encoded = input.map(item => this.rlpEncode(item));
|
|
372
|
+
const concat = Buffer.concat(encoded);
|
|
373
|
+
return Buffer.concat([this.rlpEncodeLength(concat.length, 0xc0), concat]);
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
if (Buffer.isBuffer(input)) {
|
|
377
|
+
if (input.length === 1 && input[0] < 0x80) {
|
|
378
|
+
return input;
|
|
379
|
+
}
|
|
380
|
+
return Buffer.concat([this.rlpEncodeLength(input.length, 0x80), input]);
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
if (typeof input === 'number' || typeof input === 'bigint') {
|
|
384
|
+
if (input === 0 || input === 0n) {
|
|
385
|
+
return Buffer.from([0x80]);
|
|
386
|
+
}
|
|
387
|
+
const hex = input.toString(16);
|
|
388
|
+
const buf = Buffer.from(hex.length % 2 ? '0' + hex : hex, 'hex');
|
|
389
|
+
return this.rlpEncode(buf);
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
if (typeof input === 'string') {
|
|
393
|
+
if (input.startsWith('0x')) {
|
|
394
|
+
return this.rlpEncode(Buffer.from(input.slice(2), 'hex'));
|
|
395
|
+
}
|
|
396
|
+
return this.rlpEncode(Buffer.from(input));
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
return Buffer.from([0x80]);
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
rlpEncodeLength(length, offset) {
|
|
403
|
+
if (length < 56) {
|
|
404
|
+
return Buffer.from([offset + length]);
|
|
405
|
+
}
|
|
406
|
+
const hexLength = length.toString(16);
|
|
407
|
+
const lenOfLen = Math.ceil(hexLength.length / 2);
|
|
408
|
+
return Buffer.concat([
|
|
409
|
+
Buffer.from([offset + 55 + lenOfLen]),
|
|
410
|
+
Buffer.from(hexLength.padStart(lenOfLen * 2, '0'), 'hex')
|
|
411
|
+
]);
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
// ═══════════════════════════════════════════════════════════════
|
|
415
|
+
// PRECOMPILES
|
|
416
|
+
// ═══════════════════════════════════════════════════════════════
|
|
417
|
+
|
|
418
|
+
async executePrecompile(address, input) {
|
|
419
|
+
const name = PRECOMPILES[address.toLowerCase()];
|
|
420
|
+
if (!name) {
|
|
421
|
+
throw new Error(`Unknown precompile: ${address}`);
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
switch (name) {
|
|
425
|
+
case 'ecrecover':
|
|
426
|
+
return this._ecrecover(input);
|
|
427
|
+
case 'sha256':
|
|
428
|
+
return crypto.createHash('sha256').update(input).digest();
|
|
429
|
+
case 'ripemd160':
|
|
430
|
+
const ripemd = crypto.createHash('ripemd160').update(input).digest();
|
|
431
|
+
return Buffer.concat([Buffer.alloc(12), ripemd]);
|
|
432
|
+
case 'identity':
|
|
433
|
+
return input;
|
|
434
|
+
case 'modexp':
|
|
435
|
+
return this._modexp(input);
|
|
436
|
+
default:
|
|
437
|
+
throw new Error(`Precompile not implemented: ${name}`);
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
_ecrecover(input) {
|
|
442
|
+
// Extract components from input
|
|
443
|
+
// Would need actual EC recovery implementation
|
|
444
|
+
return Buffer.alloc(32);
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
_modexp(input) {
|
|
448
|
+
// Modular exponentiation
|
|
449
|
+
// Would need big integer implementation
|
|
450
|
+
return Buffer.alloc(32);
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
module.exports = EVMAdapter;
|