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/Manager.js
CHANGED
|
@@ -1,86 +1,77 @@
|
|
|
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
|
-
_defineProperty(this, "start_clock", function () {
|
|
26
|
-
var frequency = Number(process.env.HERTS) || 10;
|
|
27
|
-
_this.clock = setInterval(function () {
|
|
28
|
-
for (var account in _this.tracks) {
|
|
29
|
-
var track = _this.tracks[account];
|
|
30
|
-
var program = track.slice(-1)[0];
|
|
31
|
-
var instruction = program.sequence[program.pointer];
|
|
1
|
+
import framer from "../framer";
|
|
2
|
+
import opcodes from "../opcodes";
|
|
3
|
+
import Account from "./Account";
|
|
4
|
+
import Blockweb from "./Blockweb";
|
|
5
|
+
import Oracle from "./Oracle";
|
|
6
|
+
|
|
7
|
+
class Manager {
|
|
8
|
+
constructor() {
|
|
9
|
+
this.accounts = new Object();
|
|
10
|
+
this.running = 0;
|
|
11
|
+
this.tracks = new Object();
|
|
12
|
+
this.web = new Blockweb(this);
|
|
13
|
+
this.oracle = new Oracle(this);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
start_clock = () => {
|
|
17
|
+
let frequency = Number(process.env.HERTS) || 10;
|
|
18
|
+
this.clock = setInterval(() => {
|
|
19
|
+
for (let account in this.tracks) {
|
|
20
|
+
let track = this.tracks[account];
|
|
21
|
+
let program = track.slice(-1)[0];
|
|
22
|
+
|
|
23
|
+
let instruction = program.sequence[program.pointer];
|
|
24
|
+
|
|
32
25
|
program.account.vm.execute(instruction, program);
|
|
33
26
|
program.pointer++;
|
|
27
|
+
|
|
34
28
|
if (program.pointer === program.sequence.length) {
|
|
35
29
|
program.account.flush_buffer(program.pid);
|
|
30
|
+
|
|
36
31
|
track.pop();
|
|
37
32
|
}
|
|
38
33
|
if (!track.length) {
|
|
39
|
-
|
|
40
|
-
delete
|
|
34
|
+
this.running -= 1;
|
|
35
|
+
delete this.tracks[account];
|
|
41
36
|
program.account.chain.mine(program.account.vm);
|
|
42
37
|
}
|
|
43
38
|
}
|
|
44
|
-
|
|
39
|
+
|
|
40
|
+
!this.running && clearInterval(this.clock);
|
|
45
41
|
}, frequency);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
get_account = (name) => this.accounts[name];
|
|
45
|
+
|
|
46
|
+
add_account = (name, meta) => {
|
|
47
|
+
let account = this.get_account(name);
|
|
48
|
+
|
|
52
49
|
if (!account) {
|
|
53
|
-
account = new
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
account["private"] = true;
|
|
50
|
+
account = new Account(name, { ...meta, manager: this });
|
|
51
|
+
opcodes(account);
|
|
52
|
+
framer(account);
|
|
53
|
+
|
|
54
|
+
this.accounts[account.name] = account;
|
|
55
|
+
} else if (meta && meta.private && !account.private) {
|
|
56
|
+
account.private = true;
|
|
61
57
|
}
|
|
58
|
+
|
|
62
59
|
return account;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
push = (program) => {
|
|
63
|
+
let track = this.tracks[program.account.name];
|
|
64
|
+
|
|
66
65
|
if (track) {
|
|
67
|
-
track.push(
|
|
68
|
-
pointer: 0
|
|
69
|
-
}));
|
|
66
|
+
track.push({ ...program, pointer: 0 });
|
|
70
67
|
} else {
|
|
71
|
-
track = [
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
_this.running === 1 && _this.start_clock();
|
|
68
|
+
track = [{ ...program, pointer: 0 }];
|
|
69
|
+
this.tracks[program.account.name] = track;
|
|
70
|
+
|
|
71
|
+
this.running++;
|
|
72
|
+
this.running === 1 && this.start_clock();
|
|
77
73
|
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
this.web = new _Blockweb["default"](this);
|
|
83
|
-
this.oracle = new _Oracle["default"](this);
|
|
84
|
-
});
|
|
85
|
-
var _default = Manager;
|
|
86
|
-
exports["default"] = _default;
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export default Manager;
|
package/Objects/Opcodes.js
CHANGED
|
@@ -1,108 +1,46 @@
|
|
|
1
|
-
|
|
1
|
+
import { obj } from "../framer";
|
|
2
|
+
import { transpile_object } from "../utils/functions";
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
exports["default"] = void 0;
|
|
7
|
-
var _framer = require("../framer");
|
|
8
|
-
function _typeof(o) {
|
|
9
|
-
"@babel/helpers - typeof";
|
|
10
|
-
return (
|
|
11
|
-
(_typeof =
|
|
12
|
-
"function" == typeof Symbol && "symbol" == typeof Symbol.iterator
|
|
13
|
-
? function (o) {
|
|
14
|
-
return typeof o;
|
|
15
|
-
}
|
|
16
|
-
: function (o) {
|
|
17
|
-
return o &&
|
|
18
|
-
"function" == typeof Symbol &&
|
|
19
|
-
o.constructor === Symbol &&
|
|
20
|
-
o !== Symbol.prototype
|
|
21
|
-
? "symbol"
|
|
22
|
-
: typeof o;
|
|
23
|
-
}),
|
|
24
|
-
_typeof(o)
|
|
25
|
-
);
|
|
26
|
-
}
|
|
27
|
-
function _defineProperties(e, r) {
|
|
28
|
-
for (var t = 0; t < r.length; t++) {
|
|
29
|
-
var o = r[t];
|
|
30
|
-
(o.enumerable = o.enumerable || !1),
|
|
31
|
-
(o.configurable = !0),
|
|
32
|
-
"value" in o && (o.writable = !0),
|
|
33
|
-
Object.defineProperty(e, _toPropertyKey(o.key), o);
|
|
4
|
+
class Opcodes {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.opcodes = new Object();
|
|
34
7
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
throw new TypeError("Cannot call a class as a function");
|
|
47
|
-
}
|
|
48
|
-
function _defineProperty(e, r, t) {
|
|
49
|
-
return (
|
|
50
|
-
(r = _toPropertyKey(r)) in e
|
|
51
|
-
? Object.defineProperty(e, r, {
|
|
52
|
-
value: t,
|
|
53
|
-
enumerable: !0,
|
|
54
|
-
configurable: !0,
|
|
55
|
-
writable: !0,
|
|
56
|
-
})
|
|
57
|
-
: (e[r] = t),
|
|
58
|
-
e
|
|
59
|
-
);
|
|
60
|
-
}
|
|
61
|
-
function _toPropertyKey(t) {
|
|
62
|
-
var i = _toPrimitive(t, "string");
|
|
63
|
-
return "symbol" == _typeof(i) ? i : i + "";
|
|
64
|
-
}
|
|
65
|
-
function _toPrimitive(t, r) {
|
|
66
|
-
if ("object" != _typeof(t) || !t) return t;
|
|
67
|
-
var e = t[Symbol.toPrimitive];
|
|
68
|
-
if (void 0 !== e) {
|
|
69
|
-
var i = e.call(t, r || "default");
|
|
70
|
-
if ("object" != _typeof(i)) return i;
|
|
71
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
72
|
-
}
|
|
73
|
-
return ("string" === r ? String : Number)(t);
|
|
74
|
-
}
|
|
75
|
-
var Opcodes = /*#__PURE__*/ _createClass(function Opcodes() {
|
|
76
|
-
var _this = this;
|
|
77
|
-
_classCallCheck(this, Opcodes);
|
|
78
|
-
_defineProperty(this, "set", function (opcode, circuit) {
|
|
79
|
-
_this.opcodes[opcode] = circuit;
|
|
80
|
-
_framer.obj.Opcodes[opcode] = null;
|
|
81
|
-
_this.account.assembler.opcodes.push(opcode);
|
|
82
|
-
});
|
|
83
|
-
_defineProperty(this, "prepare_operation", function (opcode, context) {
|
|
84
|
-
var circ = _this.opcodes[opcode];
|
|
8
|
+
|
|
9
|
+
set = (opcode, circuit) => {
|
|
10
|
+
this.opcodes[opcode] = circuit;
|
|
11
|
+
obj.Opcodes[opcode] = null;
|
|
12
|
+
|
|
13
|
+
this.account.assembler.opcodes.push(opcode);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
prepare_operation = (opcode, context) => {
|
|
17
|
+
let circ = this.opcodes[opcode];
|
|
18
|
+
|
|
85
19
|
if (typeof circ !== "function") return;
|
|
86
|
-
|
|
87
|
-
|
|
20
|
+
|
|
21
|
+
let buf = context.get_buffer();
|
|
22
|
+
|
|
23
|
+
let args =
|
|
88
24
|
context.account.read(buf && buf.inputs) ||
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
25
|
+
this.account.stdin.splice(-1)[0];
|
|
26
|
+
|
|
27
|
+
let res = circ(args, this);
|
|
28
|
+
|
|
29
|
+
this.stdin(res);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
stdin = (object, cb) => {
|
|
94
33
|
if (object == null) return;
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
34
|
+
|
|
35
|
+
this.flags.zero = !object;
|
|
36
|
+
if (typeof object === "number") this.flags.neg = object < 0;
|
|
37
|
+
|
|
38
|
+
let code_string =
|
|
98
39
|
typeof object !== "string" ? JSON.stringify(object) : object;
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
pure: true,
|
|
102
|
-
});
|
|
40
|
+
|
|
41
|
+
this.account.assembler.run(code_string, { cb, pure: true });
|
|
103
42
|
// console.log(`Writing in: ${code_string}`);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
exports["default"] = _default;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export default Opcodes;
|
package/Objects/Oracle.js
CHANGED
|
@@ -1,81 +1,83 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
_defineProperty(this, "set", function (path, _ref) {
|
|
22
|
-
var type = _ref.type,
|
|
23
|
-
obj = _ref.obj;
|
|
24
|
-
_this.datapaths[path] = {
|
|
25
|
-
obj: obj,
|
|
26
|
-
type: type
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import GDS from "generalised-datastore";
|
|
3
|
+
import { hash } from "../utils/hash";
|
|
4
|
+
|
|
5
|
+
class Oracle {
|
|
6
|
+
constructor(mgr) {
|
|
7
|
+
this.fs = fs;
|
|
8
|
+
this.mgr = mgr;
|
|
9
|
+
this.datapaths = new Object();
|
|
10
|
+
this.gds = new GDS(process.env.DATASTORE || "godprotocol").sync();
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
get_folder = (physical_address) => {
|
|
14
|
+
return this.gds.folder(this.hash(physical_address));
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
set = (path, { type, obj }) => {
|
|
18
|
+
this.datapaths[path] = {
|
|
19
|
+
obj,
|
|
20
|
+
type,
|
|
27
21
|
};
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
get = (path) => {
|
|
25
|
+
let obj = this.datapaths[path];
|
|
26
|
+
|
|
27
|
+
if (!obj) {
|
|
28
|
+
try {
|
|
29
|
+
obj = this.fs.readFileSync(path);
|
|
30
|
+
obj = JSON.parse(obj).data;
|
|
31
|
+
let type = typeof obj.data;
|
|
32
|
+
type =
|
|
33
|
+
type === "object" ? (Array.isArray(obj) ? "array" : "twain") : type;
|
|
34
|
+
|
|
35
|
+
obj = { type, obj };
|
|
36
|
+
this.set(path, obj);
|
|
37
|
+
} catch (e) {}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return obj;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
hash = (data) => {
|
|
44
|
+
data = typeof data !== "string" ? JSON.stringify(data) : data;
|
|
45
|
+
return hash(data);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
write = (addr, data) => {
|
|
49
|
+
data = JSON.stringify({ data });
|
|
50
|
+
|
|
51
|
+
this.fs.writeFileSync(addr, data, { encoding: "utf-8" });
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
fetch = (payload, callback) => {
|
|
55
|
+
let { physical_address, query, account, signature } = payload,
|
|
51
56
|
result;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
query
|
|
56
|
-
|
|
57
|
+
|
|
58
|
+
account = this.mgr.get_account(account);
|
|
59
|
+
if (account && account.private)
|
|
60
|
+
if (!account.validate({ physical_address, query }, signature, callback))
|
|
61
|
+
return;
|
|
62
|
+
|
|
57
63
|
try {
|
|
58
|
-
|
|
64
|
+
let operation = this.gds.folder(this.hash(physical_address))[
|
|
65
|
+
query.operation
|
|
66
|
+
];
|
|
67
|
+
|
|
59
68
|
result = operation && operation(query.query, query.options);
|
|
69
|
+
|
|
60
70
|
if (result) {
|
|
61
71
|
if (account) {
|
|
62
|
-
|
|
72
|
+
let content = account.read(result.data);
|
|
63
73
|
if (content != null) result.content = content;
|
|
64
74
|
}
|
|
65
75
|
}
|
|
66
76
|
} catch (e) {
|
|
67
|
-
result = {
|
|
68
|
-
error: true,
|
|
69
|
-
message: e.message,
|
|
70
|
-
payload: payload
|
|
71
|
-
};
|
|
77
|
+
result = { error: true, message: e.message, payload };
|
|
72
78
|
}
|
|
73
79
|
typeof callback === "function" && callback(result);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
this.gds = new _generalisedDatastore["default"]("godprotocol").sync();
|
|
79
|
-
});
|
|
80
|
-
var _default = Oracle;
|
|
81
|
-
exports["default"] = _default;
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export default Oracle;
|