godprotocol 1.0.81 → 1.0.83
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/.babelrc +3 -0
- package/Index.js +8 -19
- package/Loader_sequence/main.js +368 -234
- package/Objects/Account.js +229 -176
- package/Objects/Block.js +64 -61
- package/Objects/Blockweb.js +27 -34
- package/Objects/Chain.js +122 -118
- package/Objects/Explorer.js +30 -37
- package/Objects/Filesystem.js +96 -81
- package/Objects/Frame.js +43 -48
- package/Objects/Manager.js +60 -69
- package/Objects/Opcodes.js +39 -101
- package/Objects/Oracle.js +71 -69
- package/Objects/Virtual_machine.js +135 -132
- package/[object Object]/.GDS/godprotocol/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/0100dcacc00a6dc0263290e414f3d199b50f82b4dcbf9232b8a0bad9365d6878/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/03a089ffda6ca7be6e9327749c7417b3f759f4447de4dc1d8508c72571c8a46c/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/0ee263de3fb9e3e08e7d5abe21db8c0fe66188829979996dcddd3533d855a817/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/0ee263de3fb9e3e08e7d5abe21db8c0fe66188829979996dcddd3533d855a817/0ee263de3fb9e3e08e7d5abe21db8c0fe66188829979996dcddd3533d855a817~9wMLAwapUgr25rjl~1721561106826 +1 -0
- package/[object Object]/.GDS/godprotocol/folders/0ee263de3fb9e3e08e7d5abe21db8c0fe66188829979996dcddd3533d855a817/0ee263de3fb9e3e08e7d5abe21db8c0fe66188829979996dcddd3533d855a817~xipvdPqJsd5PneYbcFNbJ0vQxthmu~1721561134383 +1 -0
- package/[object Object]/.GDS/godprotocol/folders/0f4659b04f82c52bf8bf75ae0b4dc407574652ad35c84aa62ff4a52a868c7096/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/14fbd9082d61d0554e4917cb8e1b47966358762689a2bf021fc5e1dc38c7b239/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/221dbfff32f92e889762b6eb632423cbf51439fc16552940ee7ea7a2f92db662/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/2569577431a0c797f7526c5f2c59251343a1131adfd03f53363725951b7fd0d4/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/2743cfe8f897cdd0b22cb93cfd18fc58269705169bf0a01117edd1894cdce537/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/30dc10d3485923c0c19083559094fe636f9491bff9c997306ffdbf3e1618a402/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/30dc10d3485923c0c19083559094fe636f9491bff9c997306ffdbf3e1618a402/30dc10d3485923c0c19083559094fe636f9491bff9c997306ffdbf3e1618a402~5BrzgFCkRU4H7Cmlht1UyjorCm~1721561134375 +1 -0
- package/[object Object]/.GDS/godprotocol/folders/30dc10d3485923c0c19083559094fe636f9491bff9c997306ffdbf3e1618a402/30dc10d3485923c0c19083559094fe636f9491bff9c997306ffdbf3e1618a402~VMHaNZbDCtpoSB~1721561106813 +1 -0
- package/[object Object]/.GDS/godprotocol/folders/3ef66e0b0e059670edfa53a5c505196a5bc451d3c9e3a1b71f58519ca3c86146/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/3ff3661353ccadcaf9c6759a539d8d31e19c07ed0dd888170b9e55c7a18721da/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/3ff3661353ccadcaf9c6759a539d8d31e19c07ed0dd888170b9e55c7a18721da/3ff3661353ccadcaf9c6759a539d8d31e19c07ed0dd888170b9e55c7a18721da~GJVjeKlgSCUdKGWUJ~1721561134114 +1 -0
- package/[object Object]/.GDS/godprotocol/folders/3ff3661353ccadcaf9c6759a539d8d31e19c07ed0dd888170b9e55c7a18721da/3ff3661353ccadcaf9c6759a539d8d31e19c07ed0dd888170b9e55c7a18721da~OsMwcPCk8F5SaSUdCGmM6~1721561106561 +1 -0
- package/[object Object]/.GDS/godprotocol/folders/40149a5ceadd07e7cadcbad839efd7e1ac2a14b3d4a17dfa70aeff14778ed820/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/4503206d1cc4cdcef228061891a7a54a6a9838dce526bc4d755b0762d0da896b/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/4dc569813ce0a2f446a3eec01358f5774f8564641ef8d579ff5b6d94b4d031a7/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/4dc569813ce0a2f446a3eec01358f5774f8564641ef8d579ff5b6d94b4d031a7/4dc569813ce0a2f446a3eec01358f5774f8564641ef8d579ff5b6d94b4d031a7~8dBekgqAvRnIyZomf~1721561134269 +1 -0
- package/[object Object]/.GDS/godprotocol/folders/4dc569813ce0a2f446a3eec01358f5774f8564641ef8d579ff5b6d94b4d031a7/4dc569813ce0a2f446a3eec01358f5774f8564641ef8d579ff5b6d94b4d031a7~Zc7Fa5AIsUySTCcWEiXmmYg3~1721561106712 +1 -0
- package/[object Object]/.GDS/godprotocol/folders/54b16422271d6924c17c2abf55806035f5f36d4f4edb7f68bdd326bdb0abe500/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/57551ba66193cbc4696ca16cc27e9ccb73b79ddfae6b10fdf382747099033f3f/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/57d351527a4e63d51d13771038ac9ad59810f01960cc74b0f18158de872a20cc/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/5f87c4e573fa678825d72d8009f9aacce94d94bade4a26123db3c9e3a7488dc8/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/60fe28ac093915ec5e5cd08cb71650e3dab0e4c3644c32dd1ab13672f828f073/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/61bdf0593cd727752cb917ab968a08853d45142b8a8e4cdcd0fe03d1616f3586/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/61f3b3350c0c092e4c864b1a8c94f8b9272a132b100f8a5eb3a2e54dd20983be/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/646f04e302b372dc14871693fd87b6f80575c48f0045276f1a2b3ff999ae45fb/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/695853d02abbfe2f2a380598a871741caafa602d096a45adbe863e8f7e72f255/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/75944e73a11a149023ecf3430316a2b301a0b72c00cbd0b129f62b0f96e02f32/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/787456fe235bf126b6299374ecedb92c54e280238e67a2bed7446ff581cb6a6f/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/81e5bdff5d308919377d7d85da689f6888cbdc61b3ca73e18648fd7c365d4684/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/83e0dcafe93e39fa0973ee663d38477b5302704f4aca728b8701a919675340db/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/88f7c75e6701c06b4ffa070f7b4bab01c1aee299140234cf06fd83bf1a6af372/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/a965464a6d9f981543ce3aede226bd0fb989d9300cd8468f41cd1fc0139c8f44/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/a965464a6d9f981543ce3aede226bd0fb989d9300cd8468f41cd1fc0139c8f44/a965464a6d9f981543ce3aede226bd0fb989d9300cd8468f41cd1fc0139c8f44~2pZyTBlnZEjqeqLRX49qa~1721561134187 +1 -0
- package/[object Object]/.GDS/godprotocol/folders/a965464a6d9f981543ce3aede226bd0fb989d9300cd8468f41cd1fc0139c8f44/a965464a6d9f981543ce3aede226bd0fb989d9300cd8468f41cd1fc0139c8f44~GacmVaFxSmu5yLRhGW4kvf~1721561106631 +1 -0
- package/[object Object]/.GDS/godprotocol/folders/b15dcc79636744d7df8a3e28bfb9551bbb2f766d3e93885964ee4cda0070ec5d/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/b6d738d96a23a2b0638541041328e58895358c5ef9c21e2f8304939bff3e27f2/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/b6d738d96a23a2b0638541041328e58895358c5ef9c21e2f8304939bff3e27f2/b6d738d96a23a2b0638541041328e58895358c5ef9c21e2f8304939bff3e27f2~rB45nHr3uT34~1721561106844 +1 -0
- package/[object Object]/.GDS/godprotocol/folders/b6d738d96a23a2b0638541041328e58895358c5ef9c21e2f8304939bff3e27f2/b6d738d96a23a2b0638541041328e58895358c5ef9c21e2f8304939bff3e27f2~tmfqGhOsoJv91mdvgo5~1721561134385 +1 -0
- package/[object Object]/.GDS/godprotocol/folders/blocks/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/c9c105370802042618805ccac28f7d9aaaf49db9873e14eb7a4e74a73f3cce89/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/cac2db27e0f3f0e4c80a3c28aea1fee8b935d0a41f2384f4a90acb57a888ac22/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/cbf8ec551d71fc89a73768c65a6c0d630cd3d85fe88dcab7d6b45ea6bd6a9e33/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/d479db3b8a1efa0e6ac5106c1aba0b6b806744df0f6a4730c0b9f6a01cac8a33/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/de551b5a493859e532316cbbf1e4a14eb06e0512556b1c1295ad60ffe07c185b/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/f0ffe7cc032479994c0732c6a65b7887c09afafb1b0aa20062ccad2810d25101/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/f13022c98357d9d9da982270f21ce304af3d89fecbf9364ab0a00a87e39bde57/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/f3184b1d23adf18ef18e5d3f6e6978a77364642eef9edba0240b77d626334235/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/f8a165e3f556ca2ea189f4d4401d139b22a6f19d0b38329fe4a5f14599840634/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/f968ed8cf7958218d4604b3de0bf074f09bac7925e86f7d1f495f8b2c67f31a7/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/f968ed8cf7958218d4604b3de0bf074f09bac7925e86f7d1f495f8b2c67f31a7/f968ed8cf7958218d4604b3de0bf074f09bac7925e86f7d1f495f8b2c67f31a7~3EOv6CEb1xPUw8~1721561134016 +1 -0
- package/[object Object]/.GDS/godprotocol/folders/f968ed8cf7958218d4604b3de0bf074f09bac7925e86f7d1f495f8b2c67f31a7/f968ed8cf7958218d4604b3de0bf074f09bac7925e86f7d1f495f8b2c67f31a7~DEp3QlIt6A44WxAccRmf~1721561106464 +1 -0
- package/[object Object]/.GDS/godprotocol/folders/fcc2a595781c53a76c4cd54382d3758d15120d3c4fcfae30f86067f8e6a830a2/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/fce39acf93dd6bdd9bc2e28288fd5b1c3c3c23313fe8527ec1d4d32a0081c94f/.config +1 -0
- package/[object Object]/.GDS/godprotocol/folders/fda5b539dcb04ba96e6e929d05d8df7b42316351de91f2d33b66edb97ede4dc5/.config +1 -0
- package/build/Account.js +187 -0
- package/build/Block.js +68 -0
- package/build/Blockweb.js +36 -0
- package/build/Chain.js +119 -0
- package/build/Explorer.js +47 -0
- package/build/Filesystem.js +127 -0
- package/build/Frame.js +52 -0
- package/build/Index.js +20 -0
- package/build/Manager.js +86 -0
- package/build/Opcodes.js +109 -0
- package/build/Oracle.js +81 -0
- package/build/Virtual_machine.js +136 -0
- package/build/add.js +26 -0
- package/build/create_server.js +132 -0
- package/build/framer.js +59 -0
- package/build/functions.js +82 -0
- package/build/hash.js +14 -0
- package/build/indices.js +31 -0
- package/build/jmp.js +19 -0
- package/build/main.js +327 -0
- package/build/opcodes.js +60 -0
- package/build/privacy.js +27 -0
- package/build/services.js +50 -0
- package/build/std.js +15 -0
- package/framer.js +36 -34
- package/opcodes/add.js +9 -25
- package/opcodes/indices.js +13 -16
- package/opcodes/jmp.js +7 -12
- package/opcodes/std.js +7 -13
- package/opcodes.js +34 -42
- package/package.json +1 -1
- package/readme.md +4 -4
- package/utils/create_server.js +72 -105
- package/utils/functions.js +31 -43
- package/utils/hash.js +10 -11
- package/utils/privacy.js +10 -15
- package/utils/services.js +32 -33
package/Objects/Chain.js
CHANGED
|
@@ -1,119 +1,123 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
_this.cursor = -1;
|
|
36
|
-
});
|
|
37
|
-
_defineProperty(_assertThisInitialized(_this), "set_cursor", function (cursor) {
|
|
38
|
-
_this.cursor = cursor;
|
|
39
|
-
_this.cursors.push(cursor);
|
|
40
|
-
});
|
|
41
|
-
_defineProperty(_assertThisInitialized(_this), "get_buffer", function () {
|
|
42
|
-
_this.cursor = _this.cursors.pop();
|
|
43
|
-
return _this.buffs.slice(-1)[0];
|
|
44
|
-
});
|
|
45
|
-
_defineProperty(_assertThisInitialized(_this), "generate_hash", function () {
|
|
46
|
-
_this.hash = (0, _hash.hash)(_this.physical_address);
|
|
47
|
-
});
|
|
48
|
-
_defineProperty(_assertThisInitialized(_this), "get_block", function (index) {
|
|
49
|
-
return _this.blocks[index];
|
|
50
|
-
});
|
|
51
|
-
_defineProperty(_assertThisInitialized(_this), "add_tx", function (instruction) {
|
|
52
|
-
if (!_this.txs.length) _this.start_time = Date.now();
|
|
53
|
-
_this.txs.push(instruction);
|
|
54
|
-
});
|
|
55
|
-
_defineProperty(_assertThisInitialized(_this), "mine", function (vm, no_curs) {
|
|
56
|
-
var block = new _Block["default"](_assertThisInitialized(_this));
|
|
57
|
-
block.generate_hash();
|
|
58
|
-
_this.add_block(block);
|
|
59
|
-
block.store(no_curs);
|
|
60
|
-
block.children = _this.pending_children;
|
|
61
|
-
_this.pending_children = new Array();
|
|
62
|
-
var prev_context = vm.get_context(-2);
|
|
63
|
-
if (prev_context) {
|
|
64
|
-
prev_context.pending_children.push(block);
|
|
65
|
-
prev_context.connections.push(block);
|
|
66
|
-
}
|
|
67
|
-
_this.txs = new Array();
|
|
68
|
-
block.timelapse = Date.now() - _this.start_time;
|
|
69
|
-
return block;
|
|
70
|
-
});
|
|
71
|
-
_defineProperty(_assertThisInitialized(_this), "add_block", function (block) {
|
|
72
|
-
_this.blocks.push(block);
|
|
73
|
-
_this.height = _this.blocks.length;
|
|
74
|
-
});
|
|
75
|
-
_defineProperty(_assertThisInitialized(_this), "get_latest_block", function () {
|
|
76
|
-
return _this.blocks.slice(-1)[0];
|
|
77
|
-
});
|
|
78
|
-
_defineProperty(_assertThisInitialized(_this), "stringify", function (str) {
|
|
79
|
-
var obj = {};
|
|
80
|
-
obj.physical_address = _this.physical_address;
|
|
81
|
-
obj.height = _this.blocks.length;
|
|
82
|
-
obj.parent = _this.parent.path;
|
|
83
|
-
obj.account = _this.parent.account.name;
|
|
84
|
-
obj.name = _this.name;
|
|
85
|
-
obj.connections = _this.connections.map(function (b) {
|
|
86
|
-
return new Object({
|
|
87
|
-
chain: b.chain.hash,
|
|
88
|
-
block: b.hash
|
|
89
|
-
});
|
|
90
|
-
});
|
|
91
|
-
obj.hash = _this.hash;
|
|
92
|
-
obj.blocks = _this.blocks.map(function (blk) {
|
|
93
|
-
return blk.hash;
|
|
94
|
-
});
|
|
95
|
-
return str ? JSON.stringify(obj) : obj;
|
|
96
|
-
});
|
|
97
|
-
_defineProperty(_assertThisInitialized(_this), "add_chain", function (name) {
|
|
98
|
-
return _this.account.add_chain(name, _assertThisInitialized(_this));
|
|
99
|
-
});
|
|
100
|
-
_this.parent = parent;
|
|
101
|
-
_this.account = _this.parent.account;
|
|
102
|
-
_this.name = _name || _this.parent.name;
|
|
103
|
-
_this.physical_address = _this.parent.manager || !_name ? _this.parent.physical_address : "".concat(_this.parent.physical_address, "/").concat(_this.name);
|
|
104
|
-
_this.pending_children = new Array();
|
|
105
|
-
_this.connections = new Array();
|
|
106
|
-
_this.blocks = new Array();
|
|
107
|
-
_this.txs = new Array();
|
|
108
|
-
_this.height = 0;
|
|
109
|
-
_this.cursor = -1;
|
|
110
|
-
_this.cursors = new Array();
|
|
111
|
-
_this.buffs = new Array();
|
|
112
|
-
_this.generate_hash();
|
|
113
|
-
_this.account.set_paths(_assertThisInitialized(_this));
|
|
114
|
-
return _this;
|
|
1
|
+
import { hash } from "../utils/hash";
|
|
2
|
+
import Block from "./Block";
|
|
3
|
+
import Explorer from "./Explorer";
|
|
4
|
+
|
|
5
|
+
class Chain extends Explorer {
|
|
6
|
+
constructor(parent, name) {
|
|
7
|
+
super();
|
|
8
|
+
|
|
9
|
+
this.parent = parent;
|
|
10
|
+
this.account = this.parent.account;
|
|
11
|
+
this.name = name || this.parent.name;
|
|
12
|
+
this.physical_address =
|
|
13
|
+
this.parent.manager || !name
|
|
14
|
+
? this.parent.physical_address
|
|
15
|
+
: `${this.parent.physical_address}/${this.name}`;
|
|
16
|
+
|
|
17
|
+
this.pending_children = new Array();
|
|
18
|
+
this.connections = new Array();
|
|
19
|
+
|
|
20
|
+
this.blocks = new Array();
|
|
21
|
+
this.txs = new Array();
|
|
22
|
+
|
|
23
|
+
this.height = 0;
|
|
24
|
+
this.cursor = -1;
|
|
25
|
+
this.cursors = new Array();
|
|
26
|
+
this.buffs = new Array();
|
|
27
|
+
|
|
28
|
+
this.generate_hash();
|
|
29
|
+
|
|
30
|
+
this.folder = this.account.manager.oracle.gds.folder(this.hash);
|
|
31
|
+
|
|
32
|
+
this.manage_config();
|
|
33
|
+
|
|
34
|
+
this.account.set_paths(this);
|
|
115
35
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
36
|
+
|
|
37
|
+
manage_config = () => {};
|
|
38
|
+
|
|
39
|
+
append_buffer = () => {
|
|
40
|
+
this.buffs.push({});
|
|
41
|
+
this.cursors.push(this.cursor);
|
|
42
|
+
this.cursor = -1;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
set_cursor = (cursor) => {
|
|
46
|
+
this.cursor = cursor;
|
|
47
|
+
this.cursors.push(cursor);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
get_buffer = () => {
|
|
51
|
+
this.cursor = this.cursors.pop();
|
|
52
|
+
return this.buffs.slice(-1)[0];
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
generate_hash = () => {
|
|
56
|
+
this.hash = hash(this.physical_address);
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
get_block = (index) => {
|
|
60
|
+
return this.blocks[index];
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
add_tx = (instruction) => {
|
|
64
|
+
if (!this.txs.length) this.start_time = Date.now();
|
|
65
|
+
|
|
66
|
+
this.txs.push(instruction);
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
mine = (vm, no_curs) => {
|
|
70
|
+
let block = new Block(this);
|
|
71
|
+
|
|
72
|
+
block.generate_hash();
|
|
73
|
+
this.add_block(block);
|
|
74
|
+
|
|
75
|
+
block.store(no_curs);
|
|
76
|
+
|
|
77
|
+
block.children = this.pending_children;
|
|
78
|
+
this.pending_children = new Array();
|
|
79
|
+
|
|
80
|
+
let prev_context = vm.get_context(-2);
|
|
81
|
+
if (prev_context) {
|
|
82
|
+
prev_context.pending_children.push(block);
|
|
83
|
+
prev_context.connections.push(block);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
this.txs = new Array();
|
|
87
|
+
|
|
88
|
+
block.timelapse = Date.now() - this.start_time;
|
|
89
|
+
|
|
90
|
+
this.folder.write(block.stringify());
|
|
91
|
+
return block;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
add_block = (block) => {
|
|
95
|
+
this.blocks.push(block);
|
|
96
|
+
this.height = this.blocks.length;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
get_latest_block = () => this.blocks.slice(-1)[0];
|
|
100
|
+
|
|
101
|
+
stringify = (str) => {
|
|
102
|
+
let obj = {};
|
|
103
|
+
|
|
104
|
+
obj.physical_address = this.physical_address;
|
|
105
|
+
obj.height = this.blocks.length;
|
|
106
|
+
obj.parent = this.parent.path;
|
|
107
|
+
obj.account = this.parent.account.name;
|
|
108
|
+
obj.name = this.name;
|
|
109
|
+
obj.connections = this.connections.map(
|
|
110
|
+
(b) => new Object({ chain: b.chain.hash, block: b.hash })
|
|
111
|
+
);
|
|
112
|
+
obj.hash = this.hash;
|
|
113
|
+
obj.blocks = this.blocks.map((blk) => blk.hash);
|
|
114
|
+
|
|
115
|
+
return str ? JSON.stringify(obj) : obj;
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
add_chain = (name) => {
|
|
119
|
+
return this.account.add_chain(name, this);
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export default Chain;
|
package/Objects/Explorer.js
CHANGED
|
@@ -1,47 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
8
|
-
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
9
|
-
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
10
|
-
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
11
|
-
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
12
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
13
|
-
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
14
|
-
var Explorer = /*#__PURE__*/_createClass(function Explorer() {
|
|
15
|
-
var _this = this;
|
|
16
|
-
_classCallCheck(this, Explorer);
|
|
17
|
-
_defineProperty(this, "chain_props", ["blocks"]);
|
|
18
|
-
_defineProperty(this, "explore", function (query) {
|
|
1
|
+
class Explorer {
|
|
2
|
+
constructor() {}
|
|
3
|
+
|
|
4
|
+
chain_props = ["blocks"];
|
|
5
|
+
|
|
6
|
+
explore = (query) => {
|
|
19
7
|
if (!query) return;
|
|
8
|
+
|
|
20
9
|
if (query.startsWith("{")) query = query.slice(1, -1);
|
|
21
10
|
query = query.split(":");
|
|
11
|
+
|
|
22
12
|
query[0] = query[0].split(".");
|
|
23
|
-
|
|
13
|
+
|
|
14
|
+
let q2 = Number(query[1]),
|
|
24
15
|
prop;
|
|
25
|
-
|
|
26
|
-
|
|
16
|
+
|
|
17
|
+
if (this.chain_props.includes(query[0][0])) prop = query[0][0];
|
|
18
|
+
|
|
19
|
+
let obj;
|
|
27
20
|
if (isNaN(q2)) {
|
|
28
|
-
obj =
|
|
29
|
-
return c.hash === query[1];
|
|
30
|
-
});
|
|
21
|
+
obj = this[prop || "connections"].find((c) => c.hash === query[1]);
|
|
31
22
|
} else if (q2 >= 0) {
|
|
32
|
-
obj =
|
|
33
|
-
return q.index === q2;
|
|
34
|
-
});
|
|
23
|
+
obj = this[prop || "connections"].find((q) => q.index === q2);
|
|
35
24
|
} else {
|
|
36
|
-
obj =
|
|
37
|
-
}
|
|
38
|
-
if (!prop) for (var q = 0; q < query[0].length; q++) {
|
|
39
|
-
var que = query[0][q];
|
|
40
|
-
if (!obj) break;
|
|
41
|
-
obj = obj[que];
|
|
25
|
+
obj = this[prop || "connections"].slice(q2)[0];
|
|
42
26
|
}
|
|
27
|
+
|
|
28
|
+
if (!prop)
|
|
29
|
+
for (let q = 0; q < query[0].length; q++) {
|
|
30
|
+
let que = query[0][q];
|
|
31
|
+
|
|
32
|
+
if (!obj) break;
|
|
33
|
+
obj = obj[que];
|
|
34
|
+
}
|
|
35
|
+
|
|
43
36
|
return obj;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export default Explorer;
|
package/Objects/Filesystem.js
CHANGED
|
@@ -1,56 +1,57 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
var Filesystem = /*#__PURE__*/_createClass(function Filesystem() {
|
|
16
|
-
var _this = this;
|
|
17
|
-
_classCallCheck(this, Filesystem);
|
|
18
|
-
_defineProperty(this, "parse_path", function (path) {
|
|
19
|
-
if (!path || path && !path.includes("/")) return path;
|
|
20
|
-
return _this.read(path);
|
|
21
|
-
});
|
|
22
|
-
_defineProperty(this, "read", function (datapath) {
|
|
1
|
+
import { hash } from "../utils/hash";
|
|
2
|
+
|
|
3
|
+
class Filesystem {
|
|
4
|
+
constructor() {
|
|
5
|
+
this.base_address = process.env.BASE_ADDRESS || "Accounts";
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
parse_path = (path) => {
|
|
9
|
+
if (!path || (path && !path.includes("/"))) return path;
|
|
10
|
+
|
|
11
|
+
return this.read(path);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
read = (datapath) => {
|
|
23
15
|
if (!datapath) return null;
|
|
24
|
-
|
|
16
|
+
|
|
17
|
+
let type_folder = this.account.manager.oracle.get(datapath);
|
|
18
|
+
|
|
25
19
|
if (!type_folder) return datapath;
|
|
26
|
-
|
|
20
|
+
|
|
21
|
+
let content;
|
|
27
22
|
if (type_folder.type === "twain") {
|
|
28
23
|
content = {};
|
|
29
|
-
for (
|
|
30
|
-
|
|
31
|
-
|
|
24
|
+
for (let prop in type_folder.obj) {
|
|
25
|
+
let val = type_folder.obj[prop];
|
|
26
|
+
|
|
27
|
+
content[this.parse_path(prop)] = this.parse_path(val);
|
|
32
28
|
}
|
|
33
29
|
} else if (type_folder.type === "array") {
|
|
34
30
|
content = [];
|
|
35
|
-
type_folder.obj.map(
|
|
36
|
-
content.push(
|
|
31
|
+
type_folder.obj.map((t) => {
|
|
32
|
+
content.push(this.parse_path(t));
|
|
37
33
|
});
|
|
38
34
|
} else content = type_folder.obj;
|
|
35
|
+
|
|
39
36
|
return content;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
save = (content, chain, just_obj) => {
|
|
40
|
+
let addr, obj;
|
|
41
|
+
|
|
42
|
+
let type = typeof chain === "string" ? chain : this.get_type(chain);
|
|
43
|
+
|
|
44
44
|
if (type === "array" || type === "string") {
|
|
45
45
|
obj = [];
|
|
46
|
-
|
|
46
|
+
|
|
47
|
+
for (let curs in content)
|
|
47
48
|
obj.splice(Number(curs) || -1, 0, content[curs]);
|
|
48
|
-
|
|
49
|
+
|
|
49
50
|
if (type === "string") obj = obj.join(" ");
|
|
50
51
|
} else if (type === "twain") {
|
|
51
52
|
obj = {};
|
|
52
|
-
for (
|
|
53
|
-
obj[
|
|
53
|
+
for (let curs in content) {
|
|
54
|
+
obj[curs] = content[curs];
|
|
54
55
|
}
|
|
55
56
|
} else if (type === "number") {
|
|
56
57
|
obj = Number(content["-1"]);
|
|
@@ -58,70 +59,84 @@ var Filesystem = /*#__PURE__*/_createClass(function Filesystem() {
|
|
|
58
59
|
} else {
|
|
59
60
|
obj = null;
|
|
60
61
|
}
|
|
62
|
+
|
|
61
63
|
if (just_obj) return obj;
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
64
|
+
|
|
65
|
+
addr = `${chain.path}/${hash(JSON.stringify(obj))}`;
|
|
66
|
+
this;
|
|
67
|
+
if (obj != null) this.manager.oracle.write(addr, obj, this.account);
|
|
68
|
+
|
|
69
|
+
this.manager.oracle.set(addr, { obj, type });
|
|
70
|
+
|
|
69
71
|
return addr;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
data_addr = (type) => {
|
|
75
|
+
return `${this.physical_address}/Datatypes/${type}`;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
get_type = (chain) => {
|
|
75
79
|
switch (chain.physical_address) {
|
|
76
|
-
case
|
|
80
|
+
case this.data_addr(`Number`):
|
|
77
81
|
return "number";
|
|
78
|
-
case
|
|
82
|
+
case this.data_addr(`String`):
|
|
79
83
|
return "string";
|
|
80
|
-
case
|
|
84
|
+
case this.data_addr(`Twain`):
|
|
81
85
|
return "twain";
|
|
82
|
-
case
|
|
86
|
+
case this.data_addr(`Array`):
|
|
83
87
|
return "array";
|
|
84
|
-
case
|
|
88
|
+
case this.data_addr(`Boolean`):
|
|
85
89
|
return "boolean";
|
|
86
|
-
case
|
|
90
|
+
case this.data_addr(`Void`):
|
|
87
91
|
return "void";
|
|
88
92
|
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
write = (arg, context) => {
|
|
96
|
+
let content = context.get_buffer();
|
|
97
|
+
|
|
92
98
|
if (!content || !arg) return;
|
|
99
|
+
|
|
93
100
|
content[context.cursor] = arg;
|
|
94
101
|
// console.log(`Writing: ${arg}`);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
name_hash = () => {
|
|
105
|
+
this.hash = hash(this.name);
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
set_paths = (chain) => {
|
|
100
109
|
if (chain.parent && chain.parent.manager) {
|
|
101
110
|
chain.path = chain.parent.path;
|
|
102
111
|
return;
|
|
103
112
|
}
|
|
104
|
-
chain.path =
|
|
105
|
-
|
|
113
|
+
chain.path = `${chain.parent ? chain.parent.path : this.base_address}/${
|
|
114
|
+
chain.hash
|
|
115
|
+
}`;
|
|
116
|
+
|
|
117
|
+
let fs = this.manager.oracle.fs;
|
|
118
|
+
|
|
106
119
|
if (!fs.existsSync(chain.path)) {
|
|
107
|
-
fs.mkdirSync(chain.path, {
|
|
108
|
-
recursive: true
|
|
109
|
-
});
|
|
120
|
+
fs.mkdirSync(chain.path, { recursive: true });
|
|
110
121
|
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
add_chain = (name, parent) => {
|
|
125
|
+
let chain = this.manager.web.get(`${parent.physical_address}/${name}`);
|
|
126
|
+
if (!chain) chain = this.manager.web.set(parent, name);
|
|
127
|
+
|
|
115
128
|
return chain;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
account_chain = (account) => {
|
|
132
|
+
let chain = this.manager.web.get(account.physical_address);
|
|
133
|
+
|
|
119
134
|
if (!chain) {
|
|
120
|
-
chain =
|
|
135
|
+
chain = this.manager.web.set(account);
|
|
121
136
|
}
|
|
137
|
+
|
|
122
138
|
return chain;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
exports["default"] = _default;
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export default Filesystem;
|
package/Objects/Frame.js
CHANGED
|
@@ -1,52 +1,47 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
var Frame = /*#__PURE__*/_createClass(function Frame(_object, parent) {
|
|
22
|
-
var _this = this;
|
|
23
|
-
_classCallCheck(this, Frame);
|
|
24
|
-
_defineProperty(this, "frame", function (object) {
|
|
25
|
-
var frame = new Frame(object, _this);
|
|
26
|
-
_this.instructions.push(frame);
|
|
27
|
-
_this.children.push(frame);
|
|
1
|
+
import { array_to_nested_objects } from "../utils/functions";
|
|
2
|
+
|
|
3
|
+
class Frame {
|
|
4
|
+
constructor(object, parent) {
|
|
5
|
+
this.parent = parent;
|
|
6
|
+
|
|
7
|
+
this.object = Array.isArray(object)
|
|
8
|
+
? array_to_nested_objects(object)
|
|
9
|
+
: object;
|
|
10
|
+
|
|
11
|
+
this.children = new Array();
|
|
12
|
+
this.instructions = new Array();
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
frame = (object) => {
|
|
16
|
+
let frame = new Frame(object, this);
|
|
17
|
+
|
|
18
|
+
this.instructions.push(frame);
|
|
19
|
+
this.children.push(frame);
|
|
20
|
+
|
|
28
21
|
return frame;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
to_instruction = () => {
|
|
25
|
+
for (let prop in this.object) {
|
|
26
|
+
let val = this.object[prop];
|
|
27
|
+
this.instructions.push(`chain ${prop}`);
|
|
28
|
+
|
|
29
|
+
val && this.frame(val).to_instruction();
|
|
30
|
+
|
|
31
|
+
this.instructions.push(`pop ${prop}`);
|
|
36
32
|
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
flatten_instructions = () => {
|
|
36
|
+
let inss = new Array();
|
|
37
|
+
|
|
38
|
+
for (let i = 0; i < this.instructions.length; i++) {
|
|
39
|
+
let ins = this.instructions[i];
|
|
40
|
+
if (ins instanceof Frame) inss.push(...ins.flatten_instructions());
|
|
41
|
+
else inss.push(ins);
|
|
43
42
|
}
|
|
44
43
|
return inss;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
this.instructions = new Array();
|
|
50
|
-
});
|
|
51
|
-
var _default = Frame;
|
|
52
|
-
exports["default"] = _default;
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export default Frame;
|