jaelis-node 1.3.1 → 1.4.1
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 +72 -2
- 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 +240 -4
- package/package.json +2 -2
|
@@ -0,0 +1,378 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JAELIS UNIFIED VM
|
|
3
|
+
*
|
|
4
|
+
* TRUE cross-chain interoperability:
|
|
5
|
+
* - NO BRIDGES
|
|
6
|
+
* - NO ADAPTERS
|
|
7
|
+
* - NO TRANSLATION AT RUNTIME
|
|
8
|
+
* - ONE ABI FOR ALL
|
|
9
|
+
* - CHAIN-ID NAMESPACED STORAGE FOR UNIVERSAL SETTLEMENT
|
|
10
|
+
*
|
|
11
|
+
* Just... code that works together.
|
|
12
|
+
*
|
|
13
|
+
* @version 0.4.0
|
|
14
|
+
* @author Mario Papaleo - JAELIS Foundation
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
const { UnifiedCompiler, UNIFIED_TYPES, AST_NODES } = require('./unified-compiler');
|
|
18
|
+
const { DynamicContract, DynamicContractManager, ContractStateStore } = require('./dynamic-contracts');
|
|
19
|
+
const { JaelisABI, JaelisABIEncoder, JaelisABIDecoder, ABIConverter, JAELIS_TYPES } = require('./jaelis-abi');
|
|
20
|
+
const {
|
|
21
|
+
CrossChainStateStore,
|
|
22
|
+
CrossChainSettlementManager,
|
|
23
|
+
CrossChainExecutor,
|
|
24
|
+
LightClientInterface,
|
|
25
|
+
EVMLightClient,
|
|
26
|
+
SVMLightClient,
|
|
27
|
+
CHAIN_REGISTRY,
|
|
28
|
+
CROSS_CHAIN_OPCODES
|
|
29
|
+
} = require('./cross-chain-state');
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Unified JAELIS VM
|
|
33
|
+
*
|
|
34
|
+
* The next evolution - contracts from ALL languages
|
|
35
|
+
* running together in ONE VM, sharing state DIRECTLY.
|
|
36
|
+
*
|
|
37
|
+
* NO ADAPTERS. NO BRIDGES. ONE SYSTEM.
|
|
38
|
+
* CHAIN-ID NAMESPACED STORAGE FOR UNIVERSAL SETTLEMENT.
|
|
39
|
+
*/
|
|
40
|
+
class UnifiedJaelisVM {
|
|
41
|
+
constructor(config = {}) {
|
|
42
|
+
this.config = config;
|
|
43
|
+
|
|
44
|
+
// Unified compiler (handles ALL languages)
|
|
45
|
+
this.compiler = new UnifiedCompiler(config);
|
|
46
|
+
|
|
47
|
+
// Dynamic contract manager
|
|
48
|
+
this.contractManager = new DynamicContractManager();
|
|
49
|
+
|
|
50
|
+
// Shared state (ALL contracts share this!)
|
|
51
|
+
this.sharedState = new ContractStateStore();
|
|
52
|
+
|
|
53
|
+
// Cross-chain settlement manager (THE KEY INNOVATION!)
|
|
54
|
+
// Default to testnet (4545) since that's what's live - mainnet is 4547
|
|
55
|
+
this.crossChainManager = new CrossChainSettlementManager({
|
|
56
|
+
nativeChainId: config.chainId || CHAIN_REGISTRY.JAELIS_TESTNET.id,
|
|
57
|
+
autoRegisterLightClients: config.autoRegisterLightClients !== false
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
// JAELIS ABI (ONE ABI for all!)
|
|
61
|
+
this.abi = JaelisABI;
|
|
62
|
+
|
|
63
|
+
// Native chain ID (4545 = testnet [live], 4547 = mainnet [upcoming])
|
|
64
|
+
this.chainId = config.chainId || CHAIN_REGISTRY.JAELIS_TESTNET.id;
|
|
65
|
+
|
|
66
|
+
// Stats
|
|
67
|
+
this.stats = {
|
|
68
|
+
contractsDeployed: 0,
|
|
69
|
+
crossCalls: 0,
|
|
70
|
+
upgrades: 0,
|
|
71
|
+
crossChainSettlements: 0,
|
|
72
|
+
gasUsed: 0 // Always 0 - ZERO FEES!
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
console.log('═══════════════════════════════════════════════════════════════');
|
|
76
|
+
console.log(' JAELIS UNIFIED VM v0.4.0');
|
|
77
|
+
console.log(' TRUE CROSS-CHAIN INTEROPERABILITY');
|
|
78
|
+
console.log('═══════════════════════════════════════════════════════════════');
|
|
79
|
+
console.log(` Chain ID: ${this.chainId} (${this.getChainName(this.chainId)})`);
|
|
80
|
+
console.log(' ✓ NO BRIDGES - Direct contract-to-contract calls');
|
|
81
|
+
console.log(' ✓ NO ADAPTERS - One unified system');
|
|
82
|
+
console.log(' ✓ ONE ABI - JAELIS ABI for all languages');
|
|
83
|
+
console.log(' ✓ DYNAMIC CONTRACTS - Auto-update when VMs change');
|
|
84
|
+
console.log(' ✓ SHARED STATE - All contracts, one memory space');
|
|
85
|
+
console.log(' ✓ CHAIN-ID NAMESPACED STORAGE - Universal settlement');
|
|
86
|
+
console.log(' ✓ LIGHT CLIENT VERIFICATION - Trustless external state');
|
|
87
|
+
console.log(' ✓ ZERO FEES - Always free execution');
|
|
88
|
+
console.log('═══════════════════════════════════════════════════════════════');
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Get chain name from ID
|
|
93
|
+
*/
|
|
94
|
+
getChainName(chainId) {
|
|
95
|
+
const chain = Object.values(CHAIN_REGISTRY).find(c => c.id === chainId);
|
|
96
|
+
return chain ? chain.name : 'Unknown';
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Deploy a contract in ANY language
|
|
101
|
+
*/
|
|
102
|
+
async deploy(source, language, options = {}) {
|
|
103
|
+
const result = await this.contractManager.deploy(source, language, options);
|
|
104
|
+
this.stats.contractsDeployed++;
|
|
105
|
+
return result;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Compile multiple contracts together
|
|
110
|
+
*
|
|
111
|
+
* The magic: They can all call each other DIRECTLY
|
|
112
|
+
*/
|
|
113
|
+
async compileBundle(sources) {
|
|
114
|
+
return this.compiler.compile(sources);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Execute a function on ANY contract
|
|
119
|
+
*/
|
|
120
|
+
async execute(address, functionName, args = [], context = {}) {
|
|
121
|
+
const contract = this.contractManager.contracts.get(address);
|
|
122
|
+
if (!contract) {
|
|
123
|
+
throw new Error(`Contract not found: ${address}`);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// Get function
|
|
127
|
+
const func = contract.interface.functions.get(functionName);
|
|
128
|
+
if (!func) {
|
|
129
|
+
throw new Error(`Function not found: ${functionName}`);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
console.log(`[UnifiedVM] Executing ${address.substring(0, 10)}...::${functionName}`);
|
|
133
|
+
|
|
134
|
+
// Encode args using JAELIS ABI (ONE encoding for all!)
|
|
135
|
+
const encodedArgs = args.length > 0
|
|
136
|
+
? JaelisABI.encodeMultiple(args, func.params?.map(p => p.type) || [])
|
|
137
|
+
: Buffer.alloc(0);
|
|
138
|
+
|
|
139
|
+
// Execute (would run actual bytecode)
|
|
140
|
+
return {
|
|
141
|
+
success: true,
|
|
142
|
+
returnValue: null,
|
|
143
|
+
gasUsed: 0, // ZERO FEES!
|
|
144
|
+
logs: []
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Direct cross-contract call (NO BRIDGES! NO ADAPTERS!)
|
|
150
|
+
*
|
|
151
|
+
* This is THE key innovation - contracts talk directly
|
|
152
|
+
*/
|
|
153
|
+
async crossCall(fromAddress, toAddress, functionName, args = []) {
|
|
154
|
+
this.stats.crossCalls++;
|
|
155
|
+
|
|
156
|
+
console.log(`[UnifiedVM] Cross-call: ${fromAddress.substring(0, 10)}... → ${toAddress.substring(0, 10)}...::${functionName}`);
|
|
157
|
+
console.log(`[UnifiedVM] NO BRIDGE! NO ADAPTER! Direct execution.`);
|
|
158
|
+
|
|
159
|
+
return this.contractManager.crossContractCall(fromAddress, toAddress, functionName, args);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Encode function call using JAELIS ABI
|
|
164
|
+
*/
|
|
165
|
+
encodeCall(functionName, args, argTypes) {
|
|
166
|
+
return JaelisABI.encodeFunctionCall(functionName, args, argTypes);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Decode return value using JAELIS ABI
|
|
171
|
+
*/
|
|
172
|
+
decodeReturn(buffer) {
|
|
173
|
+
return JaelisABI.decode(buffer);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* Get function selector
|
|
178
|
+
*/
|
|
179
|
+
getSelector(functionName, argTypes = []) {
|
|
180
|
+
return JaelisABI.computeSelector(functionName, argTypes);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Update VM specs (triggers auto-upgrade of affected contracts)
|
|
185
|
+
*/
|
|
186
|
+
async upgradeVM(vm, newVersion) {
|
|
187
|
+
const affected = await this.contractManager.updateVMSpec(vm, newVersion);
|
|
188
|
+
this.stats.upgrades += affected.length;
|
|
189
|
+
return affected;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Read shared state
|
|
194
|
+
*/
|
|
195
|
+
async readState(address, slot) {
|
|
196
|
+
return this.contractManager.sharedStateRead(address, slot);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Write shared state
|
|
201
|
+
*/
|
|
202
|
+
async writeState(address, slot, value, caller) {
|
|
203
|
+
return this.contractManager.sharedStateWrite(address, slot, value, caller);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* Get all deployed contracts
|
|
208
|
+
*/
|
|
209
|
+
getContracts() {
|
|
210
|
+
return this.contractManager.getAllContracts();
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Get dependency graph
|
|
215
|
+
*/
|
|
216
|
+
getDependencyGraph() {
|
|
217
|
+
return this.contractManager.getDependencyGraph();
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Get stats
|
|
222
|
+
*/
|
|
223
|
+
getStats() {
|
|
224
|
+
return {
|
|
225
|
+
...this.stats,
|
|
226
|
+
contracts: this.contractManager.contracts.size,
|
|
227
|
+
vmSpecs: this.contractManager.vmSpecs,
|
|
228
|
+
crossChain: this.crossChainManager.getStats()
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Convert from other ABI formats to JAELIS ABI
|
|
234
|
+
*/
|
|
235
|
+
static convertABI(abi, format) {
|
|
236
|
+
switch (format) {
|
|
237
|
+
case 'solidity':
|
|
238
|
+
case 'evm':
|
|
239
|
+
return ABIConverter.fromSolidityABI(abi);
|
|
240
|
+
case 'anchor':
|
|
241
|
+
case 'solana':
|
|
242
|
+
case 'svm':
|
|
243
|
+
return ABIConverter.fromAnchorIDL(abi);
|
|
244
|
+
case 'move':
|
|
245
|
+
case 'aptos':
|
|
246
|
+
case 'sui':
|
|
247
|
+
return ABIConverter.fromMoveABI(abi);
|
|
248
|
+
default:
|
|
249
|
+
return abi;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
// ═══════════════════════════════════════════════════════════════
|
|
254
|
+
// CROSS-CHAIN SETTLEMENT API
|
|
255
|
+
// ═══════════════════════════════════════════════════════════════
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* Compute chain-namespaced storage slot
|
|
259
|
+
*
|
|
260
|
+
* Formula: sha256(chainId || contractAddress || variableName)
|
|
261
|
+
*
|
|
262
|
+
* This enables state from different chains to coexist without collision
|
|
263
|
+
*/
|
|
264
|
+
computeCrossChainSlot(chainId, contractAddress, variableName) {
|
|
265
|
+
return this.crossChainManager.computeSlot(chainId, contractAddress, variableName);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* Settle external chain state with proof
|
|
270
|
+
*
|
|
271
|
+
* This is THE KEY OPERATION for cross-chain interop:
|
|
272
|
+
* 1. User provides state proof from external chain (ETH, SOL, etc.)
|
|
273
|
+
* 2. Light client verifies the proof
|
|
274
|
+
* 3. State is written to JAELIS with chain ID namespace
|
|
275
|
+
* 4. Now JAELIS contracts can use external chain state!
|
|
276
|
+
*
|
|
277
|
+
* @param {number} chainId - External chain ID (1 for ETH, 501 for SOL, etc.)
|
|
278
|
+
* @param {string} contractAddress - Contract address on external chain
|
|
279
|
+
* @param {string} variableName - Variable/slot name
|
|
280
|
+
* @param {Buffer} value - State value
|
|
281
|
+
* @param {Buffer} proof - Merkle proof from external chain
|
|
282
|
+
*/
|
|
283
|
+
async settleExternalState(chainId, contractAddress, variableName, value, proof) {
|
|
284
|
+
const result = await this.crossChainManager.settle(chainId, contractAddress, variableName, value, proof);
|
|
285
|
+
this.stats.crossChainSettlements++;
|
|
286
|
+
return result;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* Read cross-chain state
|
|
291
|
+
*
|
|
292
|
+
* Can read state from any chain that has been settled
|
|
293
|
+
*/
|
|
294
|
+
readCrossChainState(chainId, contractAddress, variableName) {
|
|
295
|
+
return this.crossChainManager.readState(chainId, contractAddress, variableName);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* Write cross-chain state (native chain only)
|
|
300
|
+
*/
|
|
301
|
+
writeCrossChainState(contractAddress, variableName, value) {
|
|
302
|
+
return this.crossChainManager.writeState(contractAddress, variableName, value);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* Update light client for external chain
|
|
307
|
+
*
|
|
308
|
+
* Relayers call this to keep the light client up to date
|
|
309
|
+
*/
|
|
310
|
+
async updateLightClient(chainId, headers) {
|
|
311
|
+
return this.crossChainManager.updateLightClient(chainId, headers);
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* Get chain info
|
|
316
|
+
*/
|
|
317
|
+
getChainInfo(chainId) {
|
|
318
|
+
return this.crossChainManager.getChainInfo(chainId);
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* Get all registered chains
|
|
323
|
+
*/
|
|
324
|
+
getAllChains() {
|
|
325
|
+
return this.crossChainManager.getAllChains();
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* Get state diff between same contract on two chains
|
|
330
|
+
*
|
|
331
|
+
* Useful for: arbitrage detection, reconciliation, sync verification
|
|
332
|
+
*/
|
|
333
|
+
getCrossChainStateDiff(chainId1, chainId2, contractAddress, variableNames) {
|
|
334
|
+
return this.crossChainManager.stateStore.getStateDiff(chainId1, chainId2, contractAddress, variableNames);
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* Get cross-chain opcodes for compiler integration
|
|
339
|
+
*/
|
|
340
|
+
getCrossChainOpcodes() {
|
|
341
|
+
return CROSS_CHAIN_OPCODES;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* Get cross-chain executor for bytecode integration
|
|
346
|
+
*/
|
|
347
|
+
getCrossChainExecutor() {
|
|
348
|
+
return this.crossChainManager.getExecutor();
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
module.exports = {
|
|
353
|
+
UnifiedJaelisVM,
|
|
354
|
+
UnifiedCompiler,
|
|
355
|
+
DynamicContract,
|
|
356
|
+
DynamicContractManager,
|
|
357
|
+
|
|
358
|
+
// JAELIS ABI (THE unified encoding)
|
|
359
|
+
JaelisABI,
|
|
360
|
+
JaelisABIEncoder,
|
|
361
|
+
JaelisABIDecoder,
|
|
362
|
+
ABIConverter,
|
|
363
|
+
|
|
364
|
+
// Cross-Chain Settlement (THE KEY INNOVATION!)
|
|
365
|
+
CrossChainStateStore,
|
|
366
|
+
CrossChainSettlementManager,
|
|
367
|
+
CrossChainExecutor,
|
|
368
|
+
LightClientInterface,
|
|
369
|
+
EVMLightClient,
|
|
370
|
+
SVMLightClient,
|
|
371
|
+
CHAIN_REGISTRY,
|
|
372
|
+
CROSS_CHAIN_OPCODES,
|
|
373
|
+
|
|
374
|
+
// Types
|
|
375
|
+
UNIFIED_TYPES,
|
|
376
|
+
JAELIS_TYPES,
|
|
377
|
+
AST_NODES
|
|
378
|
+
};
|