@leofcoin/chain 1.5.25 → 1.5.26
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/exports/browser/chain.js +82 -63
- package/exports/browser/{index-73138caf.js → index-055d5584.js} +2 -2
- package/exports/browser/{index-329e0324-835f93a9.js → index-329e0324-f8858eb6.js} +2 -2
- package/exports/browser/{messages-000b7f84-b6b8b755.js → messages-000b7f84-2f945543.js} +2 -2
- package/exports/browser/{node-browser-19707bf6.js → node-browser-ccafb3fc.js} +6 -4
- package/exports/browser/node-browser.js +2 -2
- package/exports/browser/workers/block-worker.js +32 -28
- package/exports/browser/workers/machine-worker.js +222 -233
- package/exports/browser/workers/{worker-0f66935f.js → worker-5b02efbe.js} +2 -2
- package/exports/chain.js +71 -52
- package/exports/contract.d.ts +1 -1
- package/exports/node.js +3 -1
- package/exports/transaction.d.ts +2 -2
- package/exports/version-control.d.ts +1 -1
- package/exports/workers/block-worker.js +32 -28
- package/exports/workers/machine-worker.js +222 -233
- package/exports/workers/{worker-0f66935f.js → worker-5b02efbe.js} +2 -2
- package/package.json +2 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { E as EasyWorker, B as BigNumber, f as formatBytes, C as ContractMessage, a as BlockMessage } from './worker-
|
|
1
|
+
import { E as EasyWorker, B as BigNumber, f as formatBytes, C as ContractMessage, a as BlockMessage } from './worker-5b02efbe.js';
|
|
2
2
|
|
|
3
3
|
var contractFactory = "237,198,141,3,53,89,84,113,119,88,110,55,76,101,103,89,119,65,109,100,117,75,88,119,116,83,52,118,52,100,97,114,113,66,84,81,82,76,90,106,50,57,117,106,112,114,98,104,52,119,121,76,106,112,56,50,87,106,173,5,99,108,97,115,115,32,70,97,99,116,111,114,121,123,35,110,97,109,101,61,34,65,114,116,79,110,108,105,110,101,67,111,110,116,114,97,99,116,70,97,99,116,111,114,121,34,59,35,116,111,116,97,108,67,111,110,116,114,97,99,116,115,61,48,59,35,99,111,110,116,114,97,99,116,115,61,91,93,59,99,111,110,115,116,114,117,99,116,111,114,40,115,116,97,116,101,41,123,115,116,97,116,101,38,38,40,116,104,105,115,46,35,99,111,110,116,114,97,99,116,115,61,115,116,97,116,101,46,99,111,110,116,114,97,99,116,115,44,116,104,105,115,46,35,116,111,116,97,108,67,111,110,116,114,97,99,116,115,61,115,116,97,116,101,46,116,111,116,97,108,67,111,110,116,114,97,99,116,115,41,125,103,101,116,32,115,116,97,116,101,40,41,123,114,101,116,117,114,110,123,116,111,116,97,108,67,111,110,116,114,97,99,116,115,58,116,104,105,115,46,35,116,111,116,97,108,67,111,110,116,114,97,99,116,115,44,99,111,110,116,114,97,99,116,115,58,116,104,105,115,46,35,99,111,110,116,114,97,99,116,115,125,125,103,101,116,32,110,97,109,101,40,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,110,97,109,101,125,103,101,116,32,99,111,110,116,114,97,99,116,115,40,41,123,114,101,116,117,114,110,91,46,46,46,116,104,105,115,46,35,99,111,110,116,114,97,99,116,115,93,125,103,101,116,32,116,111,116,97,108,67,111,110,116,114,97,99,116,115,40,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,116,111,116,97,108,67,111,110,116,114,97,99,116,115,125,105,115,82,101,103,105,115,116,101,114,101,100,40,97,100,100,114,101,115,115,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,99,111,110,116,114,97,99,116,115,46,105,110,99,108,117,100,101,115,40,97,100,100,114,101,115,115,41,125,97,115,121,110,99,32,114,101,103,105,115,116,101,114,67,111,110,116,114,97,99,116,40,97,100,100,114,101,115,115,41,123,105,102,40,97,119,97,105,116,32,109,115,103,46,115,116,97,116,105,99,67,97,108,108,40,97,100,100,114,101,115,115,44,34,104,97,115,82,111,108,101,34,44,91,109,115,103,46,115,101,110,100,101,114,44,34,79,87,78,69,82,34,93,41,44,116,104,105,115,46,35,99,111,110,116,114,97,99,116,115,46,105,110,99,108,117,100,101,115,40,97,100,100,114,101,115,115,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,34,97,108,114,101,97,100,121,32,114,101,103,105,115,116,101,114,101,100,34,41,59,116,104,105,115,46,35,116,111,116,97,108,67,111,110,116,114,97,99,116,115,43,61,49,44,116,104,105,115,46,35,99,111,110,116,114,97,99,116,115,46,112,117,115,104,40,97,100,100,114,101,115,115,41,125,125,114,101,116,117,114,110,32,70,97,99,116,111,114,121,59,2,91,93";
|
|
4
4
|
var nativeToken = "237,198,141,3,53,89,84,113,119,88,110,55,76,101,103,89,119,65,109,100,117,75,88,119,116,83,52,118,52,100,97,114,113,66,84,81,82,76,90,106,50,57,117,106,112,114,98,104,52,119,121,76,106,112,56,50,87,106,163,26,99,108,97,115,115,32,82,111,108,101,115,123,35,114,111,108,101,115,61,123,79,87,78,69,82,58,91,93,44,77,73,78,84,58,91,93,44,66,85,82,78,58,91,93,125,59,99,111,110,115,116,114,117,99,116,111,114,40,114,111,108,101,115,41,123,105,102,40,114,111,108,101,115,41,123,105,102,40,33,40,114,111,108,101,115,32,105,110,115,116,97,110,99,101,111,102,32,79,98,106,101,99,116,41,41,116,104,114,111,119,32,110,101,119,32,84,121,112,101,69,114,114,111,114,40,34,101,120,112,101,99,116,101,100,32,114,111,108,101,115,32,116,111,32,98,101,32,97,110,32,111,98,106,101,99,116,34,41,59,116,104,105,115,46,35,114,111,108,101,115,61,123,46,46,46,114,111,108,101,115,44,46,46,46,116,104,105,115,46,35,114,111,108,101,115,125,125,101,108,115,101,32,116,104,105,115,46,35,103,114,97,110,116,82,111,108,101,40,109,115,103,46,115,101,110,100,101,114,44,34,79,87,78,69,82,34,41,125,103,101,116,32,115,116,97,116,101,40,41,123,114,101,116,117,114,110,123,114,111,108,101,115,58,116,104,105,115,46,114,111,108,101,115,125,125,103,101,116,32,114,111,108,101,115,40,41,123,114,101,116,117,114,110,123,46,46,46,116,104,105,115,46,35,114,111,108,101,115,125,125,104,97,115,82,111,108,101,40,97,100,100,114,101,115,115,44,114,111,108,101,41,123,114,101,116,117,114,110,33,33,116,104,105,115,46,35,114,111,108,101,115,91,114,111,108,101,93,38,38,116,104,105,115,46,35,114,111,108,101,115,91,114,111,108,101,93,46,105,110,99,108,117,100,101,115,40,97,100,100,114,101,115,115,41,125,35,103,114,97,110,116,82,111,108,101,40,97,100,100,114,101,115,115,44,114,111,108,101,41,123,105,102,40,116,104,105,115,46,104,97,115,82,111,108,101,40,97,100,100,114,101,115,115,44,114,111,108,101,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,96,36,123,114,111,108,101,125,32,114,111,108,101,32,97,108,114,101,97,100,121,32,103,114,97,110,116,101,100,32,102,111,114,32,36,123,97,100,100,114,101,115,115,125,96,41,59,116,104,105,115,46,35,114,111,108,101,115,91,114,111,108,101,93,46,112,117,115,104,40,97,100,100,114,101,115,115,41,125,35,114,101,118,111,107,101,82,111,108,101,40,97,100,100,114,101,115,115,44,114,111,108,101,41,123,105,102,40,33,116,104,105,115,46,104,97,115,82,111,108,101,40,97,100,100,114,101,115,115,44,114,111,108,101,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,96,36,123,114,111,108,101,125,32,114,111,108,101,32,97,108,114,101,97,100,121,32,114,101,118,111,107,101,100,32,102,111,114,32,36,123,97,100,100,114,101,115,115,125,96,41,59,105,102,40,34,79,87,78,69,82,34,61,61,61,114,111,108,101,38,38,49,61,61,61,116,104,105,115,46,35,114,111,108,101,115,91,114,111,108,101,93,46,108,101,110,103,116,104,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,34,97,116,108,101,97,115,116,32,111,110,101,32,111,119,110,101,114,32,105,115,32,110,101,101,100,101,100,33,34,41,59,116,104,105,115,46,35,114,111,108,101,115,91,114,111,108,101,93,46,115,112,108,105,99,101,40,116,104,105,115,46,35,114,111,108,101,115,91,114,111,108,101,93,46,105,110,100,101,120,79,102,40,97,100,100,114,101,115,115,41,41,125,103,114,97,110,116,82,111,108,101,40,97,100,100,114,101,115,115,44,114,111,108,101,41,123,105,102,40,33,116,104,105,115,46,104,97,115,82,111,108,101,40,97,100,100,114,101,115,115,44,34,79,87,78,69,82,34,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,34,78,111,116,32,97,108,108,111,119,101,100,34,41,59,116,104,105,115,46,35,103,114,97,110,116,82,111,108,101,40,97,100,100,114,101,115,115,44,114,111,108,101,41,125,114,101,118,111,107,101,82,111,108,101,40,97,100,100,114,101,115,115,44,114,111,108,101,41,123,105,102,40,33,116,104,105,115,46,104,97,115,82,111,108,101,40,97,100,100,114,101,115,115,44,34,79,87,78,69,82,34,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,34,78,111,116,32,97,108,108,111,119,101,100,34,41,59,116,104,105,115,46,35,114,101,118,111,107,101,82,111,108,101,40,97,100,100,114,101,115,115,44,114,111,108,101,41,125,125,99,108,97,115,115,32,84,111,107,101,110,32,101,120,116,101,110,100,115,32,82,111,108,101,115,123,35,110,97,109,101,59,35,115,121,109,98,111,108,59,35,104,111,108,100,101,114,115,61,48,59,35,98,97,108,97,110,99,101,115,61,123,125,59,35,97,112,112,114,111,118,97,108,115,61,123,125,59,35,100,101,99,105,109,97,108,115,61,49,56,59,35,116,111,116,97,108,83,117,112,112,108,121,61,66,105,103,78,117,109,98,101,114,46,102,114,111,109,40,48,41,59,99,111,110,115,116,114,117,99,116,111,114,40,110,97,109,101,44,115,121,109,98,111,108,44,100,101,99,105,109,97,108,115,61,49,56,44,115,116,97,116,101,41,123,105,102,40,33,110,97,109,101,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,34,110,97,109,101,32,117,110,100,101,102,105,110,101,100,34,41,59,105,102,40,33,115,121,109,98,111,108,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,34,115,121,109,98,111,108,32,117,110,100,101,102,105,110,101,100,34,41,59,115,117,112,101,114,40,115,116,97,116,101,63,46,114,111,108,101,115,41,44,116,104,105,115,46,35,110,97,109,101,61,110,97,109,101,44,116,104,105,115,46,35,115,121,109,98,111,108,61,115,121,109,98,111,108,44,116,104,105,115,46,35,100,101,99,105,109,97,108,115,61,100,101,99,105,109,97,108,115,125,103,101,116,32,115,116,97,116,101,40,41,123,114,101,116,117,114,110,123,46,46,46,115,117,112,101,114,46,115,116,97,116,101,44,104,111,108,100,101,114,115,58,116,104,105,115,46,104,111,108,100,101,114,115,44,98,97,108,97,110,99,101,115,58,116,104,105,115,46,98,97,108,97,110,99,101,115,44,97,112,112,114,111,118,97,108,115,58,123,46,46,46,116,104,105,115,46,35,97,112,112,114,111,118,97,108,115,125,44,116,111,116,97,108,83,117,112,112,108,121,58,116,104,105,115,46,116,111,116,97,108,83,117,112,112,108,121,125,125,103,101,116,32,116,111,116,97,108,83,117,112,112,108,121,40,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,116,111,116,97,108,83,117,112,112,108,121,125,103,101,116,32,110,97,109,101,40,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,110,97,109,101,125,103,101,116,32,115,121,109,98,111,108,40,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,115,121,109,98,111,108,125,103,101,116,32,104,111,108,100,101,114,115,40,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,104,111,108,100,101,114,115,125,103,101,116,32,98,97,108,97,110,99,101,115,40,41,123,114,101,116,117,114,110,123,46,46,46,116,104,105,115,46,35,98,97,108,97,110,99,101,115,125,125,109,105,110,116,40,116,111,44,97,109,111,117,110,116,41,123,105,102,40,33,116,104,105,115,46,104,97,115,82,111,108,101,40,109,115,103,46,115,101,110,100,101,114,44,34,77,73,78,84,34,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,34,110,111,116,32,97,108,108,111,119,101,100,34,41,59,116,104,105,115,46,35,116,111,116,97,108,83,117,112,112,108,121,61,116,104,105,115,46,35,116,111,116,97,108,83,117,112,112,108,121,46,97,100,100,40,97,109,111,117,110,116,41,44,116,104,105,115,46,35,105,110,99,114,101,97,115,101,66,97,108,97,110,99,101,40,116,111,44,97,109,111,117,110,116,41,125,98,117,114,110,40,102,114,111,109,44,97,109,111,117,110,116,41,123,105,102,40,33,116,104,105,115,46,104,97,115,82,111,108,101,40,109,115,103,46,115,101,110,100,101,114,44,34,66,85,82,78,34,41,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,34,110,111,116,32,97,108,108,111,119,101,100,34,41,59,116,104,105,115,46,35,116,111,116,97,108,83,117,112,112,108,121,61,116,104,105,115,46,35,116,111,116,97,108,83,117,112,112,108,121,46,115,117,98,40,97,109,111,117,110,116,41,44,116,104,105,115,46,35,100,101,99,114,101,97,115,101,66,97,108,97,110,99,101,40,102,114,111,109,44,97,109,111,117,110,116,41,125,35,98,101,102,111,114,101,84,114,97,110,115,102,101,114,40,102,114,111,109,44,116,111,44,97,109,111,117,110,116,41,123,105,102,40,33,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,102,114,111,109,93,124,124,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,102,114,111,109,93,60,97,109,111,117,110,116,41,116,104,114,111,119,32,110,101,119,32,69,114,114,111,114,40,34,97,109,111,117,110,116,32,101,120,99,101,101,100,115,32,98,97,108,97,110,99,101,34,41,125,35,117,112,100,97,116,101,72,111,108,100,101,114,115,40,97,100,100,114,101,115,115,44,112,114,101,118,105,111,117,115,66,97,108,97,110,99,101,41,123,34,48,120,48,48,34,61,61,61,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,46,116,111,72,101,120,83,116,114,105,110,103,40,41,63,116,104,105,115,46,35,104,111,108,100,101,114,115,45,61,49,58,34,48,120,48,48,34,33,61,61,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,46,116,111,72,101,120,83,116,114,105,110,103,40,41,38,38,34,48,120,48,48,34,61,61,61,112,114,101,118,105,111,117,115,66,97,108,97,110,99,101,46,116,111,72,101,120,83,116,114,105,110,103,40,41,38,38,40,116,104,105,115,46,35,104,111,108,100,101,114,115,43,61,49,41,125,35,105,110,99,114,101,97,115,101,66,97,108,97,110,99,101,40,97,100,100,114,101,115,115,44,97,109,111,117,110,116,41,123,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,124,124,40,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,61,66,105,103,78,117,109,98,101,114,46,102,114,111,109,40,48,41,41,59,99,111,110,115,116,32,112,114,101,118,105,111,117,115,66,97,108,97,110,99,101,61,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,59,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,61,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,46,97,100,100,40,97,109,111,117,110,116,41,44,116,104,105,115,46,35,117,112,100,97,116,101,72,111,108,100,101,114,115,40,97,100,100,114,101,115,115,44,112,114,101,118,105,111,117,115,66,97,108,97,110,99,101,41,125,35,100,101,99,114,101,97,115,101,66,97,108,97,110,99,101,40,97,100,100,114,101,115,115,44,97,109,111,117,110,116,41,123,99,111,110,115,116,32,112,114,101,118,105,111,117,115,66,97,108,97,110,99,101,61,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,59,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,61,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,46,115,117,98,40,97,109,111,117,110,116,41,44,116,104,105,115,46,35,117,112,100,97,116,101,72,111,108,100,101,114,115,40,97,100,100,114,101,115,115,44,112,114,101,118,105,111,117,115,66,97,108,97,110,99,101,41,125,98,97,108,97,110,99,101,79,102,40,97,100,100,114,101,115,115,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,98,97,108,97,110,99,101,115,91,97,100,100,114,101,115,115,93,125,115,101,116,65,112,112,114,111,118,97,108,40,111,112,101,114,97,116,111,114,44,97,109,111,117,110,116,41,123,99,111,110,115,116,32,111,119,110,101,114,61,109,115,103,46,115,101,110,100,101,114,59,116,104,105,115,46,35,97,112,112,114,111,118,97,108,115,91,111,119,110,101,114,93,124,124,40,116,104,105,115,46,35,97,112,112,114,111,118,97,108,115,91,111,119,110,101,114,93,61,123,125,41,44,116,104,105,115,46,35,97,112,112,114,111,118,97,108,115,91,111,119,110,101,114,93,91,111,112,101,114,97,116,111,114,93,61,97,109,111,117,110,116,125,97,112,112,114,111,118,101,100,40,111,119,110,101,114,44,111,112,101,114,97,116,111,114,44,97,109,111,117,110,116,41,123,114,101,116,117,114,110,32,116,104,105,115,46,35,97,112,112,114,111,118,97,108,115,91,111,119,110,101,114,93,91,111,112,101,114,97,116,111,114,93,61,61,61,97,109,111,117,110,116,125,116,114,97,110,115,102,101,114,40,102,114,111,109,44,116,111,44,97,109,111,117,110,116,41,123,97,109,111,117,110,116,61,66,105,103,78,117,109,98,101,114,46,102,114,111,109,40,97,109,111,117,110,116,41,44,116,104,105,115,46,35,98,101,102,111,114,101,84,114,97,110,115,102,101,114,40,102,114,111,109,44,116,111,44,97,109,111,117,110,116,41,44,116,104,105,115,46,35,100,101,99,114,101,97,115,101,66,97,108,97,110,99,101,40,102,114,111,109,44,97,109,111,117,110,116,41,44,116,104,105,115,46,35,105,110,99,114,101,97,115,101,66,97,108,97,110,99,101,40,116,111,44,97,109,111,117,110,116,41,125,125,99,108,97,115,115,32,65,114,116,79,110,108,105,110,101,32,101,120,116,101,110,100,115,32,84,111,107,101,110,123,99,111,110,115,116,114,117,99,116,111,114,40,115,116,97,116,101,41,123,115,117,112,101,114,40,34,65,114,116,79,110,108,105,110,101,34,44,34,65,82,84,34,44,49,56,44,115,116,97,116,101,41,125,125,114,101,116,117,114,110,32,65,114,116,79,110,108,105,110,101,59,2,91,93";
|
|
@@ -11,235 +11,224 @@ var bytecodes = {
|
|
|
11
11
|
validators: validators
|
|
12
12
|
};
|
|
13
13
|
|
|
14
|
-
const worker = new EasyWorker();
|
|
15
|
-
|
|
16
|
-
const contractFactoryMessage = bytecodes.contractFactory;
|
|
17
|
-
const nativeTokenMessage = bytecodes.nativeToken;
|
|
18
|
-
const nameServiceMessage = bytecodes.nameService;
|
|
19
|
-
const validatorsMessage = bytecodes.validators;
|
|
20
|
-
|
|
21
|
-
globalThis.BigNumber = BigNumber;
|
|
22
|
-
globalThis.contracts = {};
|
|
23
|
-
|
|
24
|
-
const has = address => {
|
|
25
|
-
return contracts[address] ? true : false
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
const get = (contract, method, params) => {
|
|
29
|
-
let result;
|
|
30
|
-
if (params?.length > 0) {
|
|
31
|
-
result = contracts[contract][method](...params);
|
|
32
|
-
} else {
|
|
33
|
-
result = contracts[contract][method];
|
|
34
|
-
}
|
|
35
|
-
return result
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
const runContract = async ({decoded, hash, encoded}) => {
|
|
39
|
-
const params = decoded.constructorParameters;
|
|
40
|
-
try {
|
|
41
|
-
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
`
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
//
|
|
128
|
-
//
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
//
|
|
132
|
-
//
|
|
133
|
-
//
|
|
134
|
-
//
|
|
135
|
-
//
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
worker.postMessage({
|
|
236
|
-
type: 'executionError',
|
|
237
|
-
message: e.message,
|
|
238
|
-
id
|
|
239
|
-
|
|
240
|
-
});
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
};
|
|
244
|
-
|
|
245
|
-
worker.onmessage(data => tasks(data));
|
|
14
|
+
const worker = new EasyWorker();
|
|
15
|
+
|
|
16
|
+
const contractFactoryMessage = bytecodes.contractFactory;
|
|
17
|
+
const nativeTokenMessage = bytecodes.nativeToken;
|
|
18
|
+
const nameServiceMessage = bytecodes.nameService;
|
|
19
|
+
const validatorsMessage = bytecodes.validators;
|
|
20
|
+
|
|
21
|
+
globalThis.BigNumber = BigNumber;
|
|
22
|
+
globalThis.contracts = {};
|
|
23
|
+
|
|
24
|
+
const has = (address) => {
|
|
25
|
+
return contracts[address] ? true : false
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const get = (contract, method, params) => {
|
|
29
|
+
let result;
|
|
30
|
+
if (params?.length > 0) {
|
|
31
|
+
result = contracts[contract][method](...params);
|
|
32
|
+
} else {
|
|
33
|
+
result = contracts[contract][method];
|
|
34
|
+
}
|
|
35
|
+
return result
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const runContract = async ({ decoded, hash, encoded }) => {
|
|
39
|
+
const params = decoded.constructorParameters;
|
|
40
|
+
try {
|
|
41
|
+
const func = new Function(new TextDecoder().decode(decoded.contract));
|
|
42
|
+
const Contract = func();
|
|
43
|
+
|
|
44
|
+
globalThis.msg = createMessage(decoded.creator);
|
|
45
|
+
contracts[hash] = await new Contract(...params);
|
|
46
|
+
worker.postMessage({
|
|
47
|
+
type: 'debug',
|
|
48
|
+
messages: [`loaded contract: ${hash}`, `size: ${formatBytes(encoded.length)}`]
|
|
49
|
+
});
|
|
50
|
+
} catch (e) {
|
|
51
|
+
console.log(e);
|
|
52
|
+
worker.postMessage({
|
|
53
|
+
type: 'contractError',
|
|
54
|
+
hash: await contractMessage.hash()
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const execute = async (contract, method, params) => {
|
|
60
|
+
try {
|
|
61
|
+
let result;
|
|
62
|
+
// don't execute the method on a proxy
|
|
63
|
+
if (contracts[contract].fallback) {
|
|
64
|
+
result = await contracts[contract].fallback(method, params);
|
|
65
|
+
} else {
|
|
66
|
+
result = await contracts[contract][method](...params);
|
|
67
|
+
}
|
|
68
|
+
// state.put(result)
|
|
69
|
+
return result
|
|
70
|
+
} catch (e) {
|
|
71
|
+
throw new Error(
|
|
72
|
+
`error: ${e.message}
|
|
73
|
+
contract: ${contract}
|
|
74
|
+
method: ${method}
|
|
75
|
+
params: ${JSON.stringify(params, null, '\t')}
|
|
76
|
+
`
|
|
77
|
+
)
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const createMessage = (sender = globalThis.peerid) => {
|
|
82
|
+
return {
|
|
83
|
+
sender,
|
|
84
|
+
call: execute,
|
|
85
|
+
staticCall: get
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
const _init = async ({ contracts, blocks, peerid }) => {
|
|
90
|
+
globalThis.peerid = peerid;
|
|
91
|
+
contracts = [contractFactoryMessage, nativeTokenMessage, nameServiceMessage, validatorsMessage];
|
|
92
|
+
|
|
93
|
+
contracts = await Promise.all(
|
|
94
|
+
contracts.map(async (contract) => {
|
|
95
|
+
contract = await new ContractMessage(new Uint8Array(contract.split(',')));
|
|
96
|
+
await runContract({ decoded: contract.decoded, encoded: contract.encoded, hash: await contract.hash() });
|
|
97
|
+
return contract
|
|
98
|
+
})
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
let lastBlock = { hash: '0x0' };
|
|
102
|
+
|
|
103
|
+
if (blocks?.length > 0) {
|
|
104
|
+
let pre;
|
|
105
|
+
|
|
106
|
+
try {
|
|
107
|
+
const importee = await import('url');
|
|
108
|
+
const url = importee.default;
|
|
109
|
+
if (url) pre = url.fileURLToPath(new URL('.', import.meta.url));
|
|
110
|
+
} catch {
|
|
111
|
+
// browser env
|
|
112
|
+
pre = './';
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const _worker = await new EasyWorker(pre + 'block-worker.js', {
|
|
116
|
+
serialization: 'advanced',
|
|
117
|
+
type: 'module'
|
|
118
|
+
});
|
|
119
|
+
blocks = await _worker.once([blocks[blocks.length - 1]]);
|
|
120
|
+
|
|
121
|
+
// blocks = unique(globalThis.blocks ? globalThis : [], blocks)
|
|
122
|
+
// for (let i = 0; i < blocks.length; i++) {
|
|
123
|
+
|
|
124
|
+
// }
|
|
125
|
+
// for (const block of blocks) {
|
|
126
|
+
// await Promise.all(block.decoded.transactions.map(async message => {
|
|
127
|
+
// if (!block.loaded) {
|
|
128
|
+
// const {from, to, method, params} = message;
|
|
129
|
+
// globalThis.msg = createMessage(from);
|
|
130
|
+
|
|
131
|
+
// await execute(to, method, params);
|
|
132
|
+
// block.loaded = true
|
|
133
|
+
// }
|
|
134
|
+
// }));
|
|
135
|
+
// }
|
|
136
|
+
|
|
137
|
+
if (blocks.length > 0) {
|
|
138
|
+
lastBlock = blocks[blocks.length - 1];
|
|
139
|
+
// todo blocks already loaded as blockmessage so use it!
|
|
140
|
+
lastBlock = await new BlockMessage(lastBlock);
|
|
141
|
+
|
|
142
|
+
lastBlock = {
|
|
143
|
+
...lastBlock.decoded,
|
|
144
|
+
hash: await lastBlock.hash()
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
globalThis.blocks = blocks;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
worker.postMessage({ type: 'machine-ready', lastBlock });
|
|
151
|
+
|
|
152
|
+
// worker.postMessage({blocks});
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
const tasks = async (e) => {
|
|
156
|
+
const id = e.id;
|
|
157
|
+
if (e.type === 'init') {
|
|
158
|
+
try {
|
|
159
|
+
await _init(e.input);
|
|
160
|
+
} catch (e) {
|
|
161
|
+
worker.postMessage({
|
|
162
|
+
type: 'initError',
|
|
163
|
+
message: e.message,
|
|
164
|
+
id
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
if (e.type === 'has') {
|
|
169
|
+
try {
|
|
170
|
+
const value = await has(e.input.address);
|
|
171
|
+
worker.postMessage({
|
|
172
|
+
type: 'response',
|
|
173
|
+
id,
|
|
174
|
+
value
|
|
175
|
+
});
|
|
176
|
+
} catch (error) {
|
|
177
|
+
worker.postMessage({
|
|
178
|
+
type: 'hasError',
|
|
179
|
+
message: error.message,
|
|
180
|
+
id
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
if (e.type === 'run') {
|
|
185
|
+
try {
|
|
186
|
+
const value = await runContract(e.input);
|
|
187
|
+
worker.postMessage({
|
|
188
|
+
type: 'response',
|
|
189
|
+
id,
|
|
190
|
+
value
|
|
191
|
+
});
|
|
192
|
+
} catch (e) {
|
|
193
|
+
worker.postMessage({
|
|
194
|
+
type: 'runError',
|
|
195
|
+
message: e.message,
|
|
196
|
+
id
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
if (e.type === 'get') {
|
|
201
|
+
try {
|
|
202
|
+
const value = await get(e.input.contract, e.input.method, e.input.params);
|
|
203
|
+
worker.postMessage({
|
|
204
|
+
type: 'response',
|
|
205
|
+
id,
|
|
206
|
+
value
|
|
207
|
+
});
|
|
208
|
+
} catch (e) {
|
|
209
|
+
worker.postMessage({
|
|
210
|
+
type: 'fetchError',
|
|
211
|
+
message: e.message,
|
|
212
|
+
id
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
if (e.type === 'execute') {
|
|
217
|
+
try {
|
|
218
|
+
const value = await execute(e.input.contract, e.input.method, e.input.params);
|
|
219
|
+
worker.postMessage({
|
|
220
|
+
type: 'response',
|
|
221
|
+
id,
|
|
222
|
+
value
|
|
223
|
+
});
|
|
224
|
+
} catch (e) {
|
|
225
|
+
worker.postMessage({
|
|
226
|
+
type: 'executionError',
|
|
227
|
+
message: e.message,
|
|
228
|
+
id
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
worker.onmessage((data) => tasks(data));
|
|
@@ -5570,9 +5570,9 @@ class BlockMessage extends FormatInterface {
|
|
|
5570
5570
|
encoded = encoded || this.encoded;
|
|
5571
5571
|
super.decode(encoded);
|
|
5572
5572
|
// @ts-ignore
|
|
5573
|
-
this.decoded.transactions = index$4(this.decoded.transactions).map(transaction => new TransactionMessage(transaction).decoded);
|
|
5573
|
+
this.decoded.transactions = index$4(this.decoded.transactions).map((transaction) => new TransactionMessage(transaction).decoded);
|
|
5574
5574
|
// @ts-ignore
|
|
5575
|
-
this.decoded.validators = index$4(this.decoded.validators).map(validator => new ValidatorMessage(validator).decoded);
|
|
5575
|
+
this.decoded.validators = index$4(this.decoded.validators).map((validator) => new ValidatorMessage(validator).decoded);
|
|
5576
5576
|
return this.decoded;
|
|
5577
5577
|
}
|
|
5578
5578
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leofcoin/chain",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.26",
|
|
4
4
|
"description": "Official javascript implementation",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./node": {
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
"np": "np",
|
|
31
31
|
"watch": "rollup -c -w",
|
|
32
32
|
"lint": "eslint src --fix",
|
|
33
|
+
"prettier": "prettier src --config ./../../.prettierrc --write",
|
|
33
34
|
"w": "rollup -c -w",
|
|
34
35
|
"docs": "sh ./node_modules/.bin/esdoc src/chain.js",
|
|
35
36
|
"workers": "cp ./../workers/src/** ./workers",
|