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.
Files changed (111) hide show
  1. package/.babelrc +3 -0
  2. package/Index.js +8 -19
  3. package/Loader_sequence/main.js +368 -234
  4. package/Objects/Account.js +229 -176
  5. package/Objects/Block.js +64 -61
  6. package/Objects/Blockweb.js +27 -34
  7. package/Objects/Chain.js +122 -118
  8. package/Objects/Explorer.js +30 -37
  9. package/Objects/Filesystem.js +96 -81
  10. package/Objects/Frame.js +43 -48
  11. package/Objects/Manager.js +60 -69
  12. package/Objects/Opcodes.js +39 -101
  13. package/Objects/Oracle.js +71 -69
  14. package/Objects/Virtual_machine.js +135 -132
  15. package/[object Object]/.GDS/godprotocol/.config +1 -0
  16. package/[object Object]/.GDS/godprotocol/folders/0100dcacc00a6dc0263290e414f3d199b50f82b4dcbf9232b8a0bad9365d6878/.config +1 -0
  17. package/[object Object]/.GDS/godprotocol/folders/03a089ffda6ca7be6e9327749c7417b3f759f4447de4dc1d8508c72571c8a46c/.config +1 -0
  18. package/[object Object]/.GDS/godprotocol/folders/0ee263de3fb9e3e08e7d5abe21db8c0fe66188829979996dcddd3533d855a817/.config +1 -0
  19. package/[object Object]/.GDS/godprotocol/folders/0ee263de3fb9e3e08e7d5abe21db8c0fe66188829979996dcddd3533d855a817/0ee263de3fb9e3e08e7d5abe21db8c0fe66188829979996dcddd3533d855a817~9wMLAwapUgr25rjl~1721561106826 +1 -0
  20. package/[object Object]/.GDS/godprotocol/folders/0ee263de3fb9e3e08e7d5abe21db8c0fe66188829979996dcddd3533d855a817/0ee263de3fb9e3e08e7d5abe21db8c0fe66188829979996dcddd3533d855a817~xipvdPqJsd5PneYbcFNbJ0vQxthmu~1721561134383 +1 -0
  21. package/[object Object]/.GDS/godprotocol/folders/0f4659b04f82c52bf8bf75ae0b4dc407574652ad35c84aa62ff4a52a868c7096/.config +1 -0
  22. package/[object Object]/.GDS/godprotocol/folders/14fbd9082d61d0554e4917cb8e1b47966358762689a2bf021fc5e1dc38c7b239/.config +1 -0
  23. package/[object Object]/.GDS/godprotocol/folders/221dbfff32f92e889762b6eb632423cbf51439fc16552940ee7ea7a2f92db662/.config +1 -0
  24. package/[object Object]/.GDS/godprotocol/folders/2569577431a0c797f7526c5f2c59251343a1131adfd03f53363725951b7fd0d4/.config +1 -0
  25. package/[object Object]/.GDS/godprotocol/folders/2743cfe8f897cdd0b22cb93cfd18fc58269705169bf0a01117edd1894cdce537/.config +1 -0
  26. package/[object Object]/.GDS/godprotocol/folders/30dc10d3485923c0c19083559094fe636f9491bff9c997306ffdbf3e1618a402/.config +1 -0
  27. package/[object Object]/.GDS/godprotocol/folders/30dc10d3485923c0c19083559094fe636f9491bff9c997306ffdbf3e1618a402/30dc10d3485923c0c19083559094fe636f9491bff9c997306ffdbf3e1618a402~5BrzgFCkRU4H7Cmlht1UyjorCm~1721561134375 +1 -0
  28. package/[object Object]/.GDS/godprotocol/folders/30dc10d3485923c0c19083559094fe636f9491bff9c997306ffdbf3e1618a402/30dc10d3485923c0c19083559094fe636f9491bff9c997306ffdbf3e1618a402~VMHaNZbDCtpoSB~1721561106813 +1 -0
  29. package/[object Object]/.GDS/godprotocol/folders/3ef66e0b0e059670edfa53a5c505196a5bc451d3c9e3a1b71f58519ca3c86146/.config +1 -0
  30. package/[object Object]/.GDS/godprotocol/folders/3ff3661353ccadcaf9c6759a539d8d31e19c07ed0dd888170b9e55c7a18721da/.config +1 -0
  31. package/[object Object]/.GDS/godprotocol/folders/3ff3661353ccadcaf9c6759a539d8d31e19c07ed0dd888170b9e55c7a18721da/3ff3661353ccadcaf9c6759a539d8d31e19c07ed0dd888170b9e55c7a18721da~GJVjeKlgSCUdKGWUJ~1721561134114 +1 -0
  32. package/[object Object]/.GDS/godprotocol/folders/3ff3661353ccadcaf9c6759a539d8d31e19c07ed0dd888170b9e55c7a18721da/3ff3661353ccadcaf9c6759a539d8d31e19c07ed0dd888170b9e55c7a18721da~OsMwcPCk8F5SaSUdCGmM6~1721561106561 +1 -0
  33. package/[object Object]/.GDS/godprotocol/folders/40149a5ceadd07e7cadcbad839efd7e1ac2a14b3d4a17dfa70aeff14778ed820/.config +1 -0
  34. package/[object Object]/.GDS/godprotocol/folders/4503206d1cc4cdcef228061891a7a54a6a9838dce526bc4d755b0762d0da896b/.config +1 -0
  35. package/[object Object]/.GDS/godprotocol/folders/4dc569813ce0a2f446a3eec01358f5774f8564641ef8d579ff5b6d94b4d031a7/.config +1 -0
  36. package/[object Object]/.GDS/godprotocol/folders/4dc569813ce0a2f446a3eec01358f5774f8564641ef8d579ff5b6d94b4d031a7/4dc569813ce0a2f446a3eec01358f5774f8564641ef8d579ff5b6d94b4d031a7~8dBekgqAvRnIyZomf~1721561134269 +1 -0
  37. package/[object Object]/.GDS/godprotocol/folders/4dc569813ce0a2f446a3eec01358f5774f8564641ef8d579ff5b6d94b4d031a7/4dc569813ce0a2f446a3eec01358f5774f8564641ef8d579ff5b6d94b4d031a7~Zc7Fa5AIsUySTCcWEiXmmYg3~1721561106712 +1 -0
  38. package/[object Object]/.GDS/godprotocol/folders/54b16422271d6924c17c2abf55806035f5f36d4f4edb7f68bdd326bdb0abe500/.config +1 -0
  39. package/[object Object]/.GDS/godprotocol/folders/57551ba66193cbc4696ca16cc27e9ccb73b79ddfae6b10fdf382747099033f3f/.config +1 -0
  40. package/[object Object]/.GDS/godprotocol/folders/57d351527a4e63d51d13771038ac9ad59810f01960cc74b0f18158de872a20cc/.config +1 -0
  41. package/[object Object]/.GDS/godprotocol/folders/5f87c4e573fa678825d72d8009f9aacce94d94bade4a26123db3c9e3a7488dc8/.config +1 -0
  42. package/[object Object]/.GDS/godprotocol/folders/60fe28ac093915ec5e5cd08cb71650e3dab0e4c3644c32dd1ab13672f828f073/.config +1 -0
  43. package/[object Object]/.GDS/godprotocol/folders/61bdf0593cd727752cb917ab968a08853d45142b8a8e4cdcd0fe03d1616f3586/.config +1 -0
  44. package/[object Object]/.GDS/godprotocol/folders/61f3b3350c0c092e4c864b1a8c94f8b9272a132b100f8a5eb3a2e54dd20983be/.config +1 -0
  45. package/[object Object]/.GDS/godprotocol/folders/646f04e302b372dc14871693fd87b6f80575c48f0045276f1a2b3ff999ae45fb/.config +1 -0
  46. package/[object Object]/.GDS/godprotocol/folders/695853d02abbfe2f2a380598a871741caafa602d096a45adbe863e8f7e72f255/.config +1 -0
  47. package/[object Object]/.GDS/godprotocol/folders/75944e73a11a149023ecf3430316a2b301a0b72c00cbd0b129f62b0f96e02f32/.config +1 -0
  48. package/[object Object]/.GDS/godprotocol/folders/787456fe235bf126b6299374ecedb92c54e280238e67a2bed7446ff581cb6a6f/.config +1 -0
  49. package/[object Object]/.GDS/godprotocol/folders/81e5bdff5d308919377d7d85da689f6888cbdc61b3ca73e18648fd7c365d4684/.config +1 -0
  50. package/[object Object]/.GDS/godprotocol/folders/83e0dcafe93e39fa0973ee663d38477b5302704f4aca728b8701a919675340db/.config +1 -0
  51. package/[object Object]/.GDS/godprotocol/folders/88f7c75e6701c06b4ffa070f7b4bab01c1aee299140234cf06fd83bf1a6af372/.config +1 -0
  52. package/[object Object]/.GDS/godprotocol/folders/a965464a6d9f981543ce3aede226bd0fb989d9300cd8468f41cd1fc0139c8f44/.config +1 -0
  53. package/[object Object]/.GDS/godprotocol/folders/a965464a6d9f981543ce3aede226bd0fb989d9300cd8468f41cd1fc0139c8f44/a965464a6d9f981543ce3aede226bd0fb989d9300cd8468f41cd1fc0139c8f44~2pZyTBlnZEjqeqLRX49qa~1721561134187 +1 -0
  54. package/[object Object]/.GDS/godprotocol/folders/a965464a6d9f981543ce3aede226bd0fb989d9300cd8468f41cd1fc0139c8f44/a965464a6d9f981543ce3aede226bd0fb989d9300cd8468f41cd1fc0139c8f44~GacmVaFxSmu5yLRhGW4kvf~1721561106631 +1 -0
  55. package/[object Object]/.GDS/godprotocol/folders/b15dcc79636744d7df8a3e28bfb9551bbb2f766d3e93885964ee4cda0070ec5d/.config +1 -0
  56. package/[object Object]/.GDS/godprotocol/folders/b6d738d96a23a2b0638541041328e58895358c5ef9c21e2f8304939bff3e27f2/.config +1 -0
  57. package/[object Object]/.GDS/godprotocol/folders/b6d738d96a23a2b0638541041328e58895358c5ef9c21e2f8304939bff3e27f2/b6d738d96a23a2b0638541041328e58895358c5ef9c21e2f8304939bff3e27f2~rB45nHr3uT34~1721561106844 +1 -0
  58. package/[object Object]/.GDS/godprotocol/folders/b6d738d96a23a2b0638541041328e58895358c5ef9c21e2f8304939bff3e27f2/b6d738d96a23a2b0638541041328e58895358c5ef9c21e2f8304939bff3e27f2~tmfqGhOsoJv91mdvgo5~1721561134385 +1 -0
  59. package/[object Object]/.GDS/godprotocol/folders/blocks/.config +1 -0
  60. package/[object Object]/.GDS/godprotocol/folders/c9c105370802042618805ccac28f7d9aaaf49db9873e14eb7a4e74a73f3cce89/.config +1 -0
  61. package/[object Object]/.GDS/godprotocol/folders/cac2db27e0f3f0e4c80a3c28aea1fee8b935d0a41f2384f4a90acb57a888ac22/.config +1 -0
  62. package/[object Object]/.GDS/godprotocol/folders/cbf8ec551d71fc89a73768c65a6c0d630cd3d85fe88dcab7d6b45ea6bd6a9e33/.config +1 -0
  63. package/[object Object]/.GDS/godprotocol/folders/d479db3b8a1efa0e6ac5106c1aba0b6b806744df0f6a4730c0b9f6a01cac8a33/.config +1 -0
  64. package/[object Object]/.GDS/godprotocol/folders/de551b5a493859e532316cbbf1e4a14eb06e0512556b1c1295ad60ffe07c185b/.config +1 -0
  65. package/[object Object]/.GDS/godprotocol/folders/f0ffe7cc032479994c0732c6a65b7887c09afafb1b0aa20062ccad2810d25101/.config +1 -0
  66. package/[object Object]/.GDS/godprotocol/folders/f13022c98357d9d9da982270f21ce304af3d89fecbf9364ab0a00a87e39bde57/.config +1 -0
  67. package/[object Object]/.GDS/godprotocol/folders/f3184b1d23adf18ef18e5d3f6e6978a77364642eef9edba0240b77d626334235/.config +1 -0
  68. package/[object Object]/.GDS/godprotocol/folders/f8a165e3f556ca2ea189f4d4401d139b22a6f19d0b38329fe4a5f14599840634/.config +1 -0
  69. package/[object Object]/.GDS/godprotocol/folders/f968ed8cf7958218d4604b3de0bf074f09bac7925e86f7d1f495f8b2c67f31a7/.config +1 -0
  70. package/[object Object]/.GDS/godprotocol/folders/f968ed8cf7958218d4604b3de0bf074f09bac7925e86f7d1f495f8b2c67f31a7/f968ed8cf7958218d4604b3de0bf074f09bac7925e86f7d1f495f8b2c67f31a7~3EOv6CEb1xPUw8~1721561134016 +1 -0
  71. package/[object Object]/.GDS/godprotocol/folders/f968ed8cf7958218d4604b3de0bf074f09bac7925e86f7d1f495f8b2c67f31a7/f968ed8cf7958218d4604b3de0bf074f09bac7925e86f7d1f495f8b2c67f31a7~DEp3QlIt6A44WxAccRmf~1721561106464 +1 -0
  72. package/[object Object]/.GDS/godprotocol/folders/fcc2a595781c53a76c4cd54382d3758d15120d3c4fcfae30f86067f8e6a830a2/.config +1 -0
  73. package/[object Object]/.GDS/godprotocol/folders/fce39acf93dd6bdd9bc2e28288fd5b1c3c3c23313fe8527ec1d4d32a0081c94f/.config +1 -0
  74. package/[object Object]/.GDS/godprotocol/folders/fda5b539dcb04ba96e6e929d05d8df7b42316351de91f2d33b66edb97ede4dc5/.config +1 -0
  75. package/build/Account.js +187 -0
  76. package/build/Block.js +68 -0
  77. package/build/Blockweb.js +36 -0
  78. package/build/Chain.js +119 -0
  79. package/build/Explorer.js +47 -0
  80. package/build/Filesystem.js +127 -0
  81. package/build/Frame.js +52 -0
  82. package/build/Index.js +20 -0
  83. package/build/Manager.js +86 -0
  84. package/build/Opcodes.js +109 -0
  85. package/build/Oracle.js +81 -0
  86. package/build/Virtual_machine.js +136 -0
  87. package/build/add.js +26 -0
  88. package/build/create_server.js +132 -0
  89. package/build/framer.js +59 -0
  90. package/build/functions.js +82 -0
  91. package/build/hash.js +14 -0
  92. package/build/indices.js +31 -0
  93. package/build/jmp.js +19 -0
  94. package/build/main.js +327 -0
  95. package/build/opcodes.js +60 -0
  96. package/build/privacy.js +27 -0
  97. package/build/services.js +50 -0
  98. package/build/std.js +15 -0
  99. package/framer.js +36 -34
  100. package/opcodes/add.js +9 -25
  101. package/opcodes/indices.js +13 -16
  102. package/opcodes/jmp.js +7 -12
  103. package/opcodes/std.js +7 -13
  104. package/opcodes.js +34 -42
  105. package/package.json +1 -1
  106. package/readme.md +4 -4
  107. package/utils/create_server.js +72 -105
  108. package/utils/functions.js +31 -43
  109. package/utils/hash.js +10 -11
  110. package/utils/privacy.js +10 -15
  111. package/utils/services.js +32 -33
@@ -1,86 +1,77 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
7
- var _framer = _interopRequireDefault(require("../framer"));
8
- var _opcodes = _interopRequireDefault(require("../opcodes"));
9
- var _Account = _interopRequireDefault(require("./Account"));
10
- var _Blockweb = _interopRequireDefault(require("./Blockweb"));
11
- var _Oracle = _interopRequireDefault(require("./Oracle"));
12
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
13
- 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); }
14
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
15
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
16
- 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); } }
17
- function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
18
- function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
19
- 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; }
20
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
21
- 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); }
22
- var Manager = /*#__PURE__*/_createClass(function Manager() {
23
- var _this = this;
24
- _classCallCheck(this, Manager);
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
- _this.running -= 1;
40
- delete _this.tracks[account];
34
+ this.running -= 1;
35
+ delete this.tracks[account];
41
36
  program.account.chain.mine(program.account.vm);
42
37
  }
43
38
  }
44
- !_this.running && clearInterval(_this.clock);
39
+
40
+ !this.running && clearInterval(this.clock);
45
41
  }, frequency);
46
- });
47
- _defineProperty(this, "get_account", function (name) {
48
- return _this.accounts[name];
49
- });
50
- _defineProperty(this, "add_account", function (name, meta) {
51
- var account = _this.get_account(name);
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 _Account["default"](name, _objectSpread(_objectSpread({}, meta), {}, {
54
- manager: _this
55
- }));
56
- (0, _opcodes["default"])(account);
57
- (0, _framer["default"])(account);
58
- _this.accounts[account.name] = account;
59
- } else if (meta && meta["private"] && !account["private"]) {
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
- _defineProperty(this, "push", function (program) {
65
- var track = _this.tracks[program.account.name];
60
+ };
61
+
62
+ push = (program) => {
63
+ let track = this.tracks[program.account.name];
64
+
66
65
  if (track) {
67
- track.push(_objectSpread(_objectSpread({}, program), {}, {
68
- pointer: 0
69
- }));
66
+ track.push({ ...program, pointer: 0 });
70
67
  } else {
71
- track = [_objectSpread(_objectSpread({}, program), {}, {
72
- pointer: 0
73
- })];
74
- _this.tracks[program.account.name] = track;
75
- _this.running++;
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
- this.accounts = new Object();
80
- this.running = 0;
81
- this.tracks = new Object();
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;
@@ -1,108 +1,46 @@
1
- "use strict";
1
+ import { obj } from "../framer";
2
+ import { transpile_object } from "../utils/functions";
2
3
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true,
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
- function _createClass(e, r, t) {
37
- return (
38
- r && _defineProperties(e.prototype, r),
39
- t && _defineProperties(e, t),
40
- Object.defineProperty(e, "prototype", { writable: !1 }),
41
- e
42
- );
43
- }
44
- function _classCallCheck(a, n) {
45
- if (!(a instanceof n))
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
- var buf = context.get_buffer();
87
- var args =
20
+
21
+ let buf = context.get_buffer();
22
+
23
+ let args =
88
24
  context.account.read(buf && buf.inputs) ||
89
- _this.account.stdin.splice(-1)[0];
90
- var res = circ(args, _this);
91
- _this.stdin(res);
92
- });
93
- _defineProperty(this, "stdin", function (object, cb) {
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
- _this.flags.zero = !object;
96
- if (typeof object === "number") _this.flags.neg = object < 0;
97
- var code_string =
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
- _this.account.assembler.run(code_string, {
100
- cb: cb,
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
- this.opcodes = new Object();
106
- });
107
- var _default = Opcodes;
108
- exports["default"] = _default;
43
+ };
44
+ }
45
+
46
+ export default Opcodes;
package/Objects/Oracle.js CHANGED
@@ -1,81 +1,83 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
7
- var _fs = _interopRequireDefault(require("fs"));
8
- var _generalisedDatastore = _interopRequireDefault(require("generalised-datastore"));
9
- var _hash = require("../utils/hash");
10
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
11
- 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); }
12
- 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); } }
13
- function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
14
- function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
15
- 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; }
16
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
17
- 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); }
18
- var Oracle = /*#__PURE__*/_createClass(function Oracle(mgr) {
19
- var _this = this;
20
- _classCallCheck(this, Oracle);
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
- _defineProperty(this, "get", function (path) {
30
- return _this.datapaths[path];
31
- });
32
- _defineProperty(this, "hash", function (data) {
33
- data = JSON.stringify(data);
34
- return (0, _hash.hash)(_hash.hash);
35
- });
36
- _defineProperty(this, "write", function (addr, data, account) {
37
- if (typeof data !== "string") data = JSON.stringify(data);
38
- var folder = _this.gds.folder((0, _hash.hash)(account.vm.get_context().physical_address));
39
- folder.write({
40
- data: addr
41
- });
42
- _this.fs.writeFileSync(addr, data, {
43
- encoding: "utf-8"
44
- });
45
- });
46
- _defineProperty(this, "fetch", function (payload, callback) {
47
- var physical_address = payload.physical_address,
48
- query = payload.query,
49
- account = payload.account,
50
- signature = payload.signature,
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
- account = _this.mgr.get_account(account);
53
- if (account && account["private"]) if (!account.validate({
54
- physical_address: physical_address,
55
- query: query
56
- }, signature, callback)) return;
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
- var operation = _this.gds.folder((0, _hash.hash)(physical_address))[query.operation];
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
- var content = account.read(result.data);
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
- this.fs = _fs["default"];
76
- this.mgr = mgr;
77
- this.datapaths = new Object();
78
- this.gds = new _generalisedDatastore["default"]("godprotocol").sync();
79
- });
80
- var _default = Oracle;
81
- exports["default"] = _default;
80
+ };
81
+ }
82
+
83
+ export default Oracle;