godprotocol 1.0.797 → 1.0.799

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 (62) hide show
  1. package/.babelrc +3 -0
  2. package/Index.js +8 -21
  3. package/Loader_sequence/main.js +259 -358
  4. package/Objects/Account.js +178 -337
  5. package/Objects/Block.js +53 -58
  6. package/Objects/Blockweb.js +27 -34
  7. package/Objects/Chain.js +115 -118
  8. package/Objects/Explorer.js +30 -37
  9. package/Objects/Filesystem.js +95 -80
  10. package/Objects/Frame.js +43 -48
  11. package/Objects/Manager.js +68 -77
  12. package/Objects/Opcodes.js +32 -97
  13. package/Objects/Oracle.js +23 -39
  14. package/Objects/Virtual_machine.js +125 -261
  15. package/build/Account.js +162 -0
  16. package/build/Block.js +65 -0
  17. package/build/Blockweb.js +36 -0
  18. package/build/Chain.js +119 -0
  19. package/build/Explorer.js +47 -0
  20. package/build/Filesystem.js +127 -0
  21. package/build/Frame.js +52 -0
  22. package/build/Index.js +15 -0
  23. package/build/Manager.js +99 -0
  24. package/build/Opcodes.js +39 -0
  25. package/build/Oracle.js +42 -0
  26. package/build/Virtual_machine.js +128 -0
  27. package/build/add.js +41 -0
  28. package/build/create_server.js +119 -0
  29. package/build/framer.js +57 -0
  30. package/build/functions.js +82 -0
  31. package/build/hash.js +14 -0
  32. package/build/jmp.js +19 -0
  33. package/build/main.js +283 -0
  34. package/build/opcodes.js +42 -0
  35. package/build/privacy.js +27 -0
  36. package/build/services.js +50 -0
  37. package/build/std.js +11 -0
  38. package/framer.js +39 -31
  39. package/opcodes/add.js +14 -40
  40. package/opcodes/jmp.js +10 -14
  41. package/opcodes/std.js +5 -9
  42. package/opcodes.js +25 -29
  43. package/package.json +3 -3
  44. package/readme.md +71 -95
  45. package/tsconfig.json +8 -0
  46. package/types/Account.d.ts +73 -0
  47. package/types/Block.d.ts +22 -0
  48. package/types/Blockweb.d.ts +14 -0
  49. package/types/Chain.d.ts +35 -0
  50. package/types/Explorer.d.ts +9 -0
  51. package/types/Filesystem.d.ts +23 -0
  52. package/types/Frame.d.ts +14 -0
  53. package/types/Manager.d.ts +21 -0
  54. package/types/Opcodes.d.ts +11 -0
  55. package/types/Oracle.d.ts +17 -0
  56. package/types/Virtual_machine.d.ts +20 -0
  57. package/types/index.d.ts +4 -0
  58. package/utils/create_server.js +65 -626
  59. package/utils/functions.js +31 -43
  60. package/utils/hash.js +10 -11
  61. package/utils/privacy.js +10 -15
  62. package/utils/services.js +32 -33
@@ -1,36 +1,29 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
7
- var _Chain = _interopRequireDefault(require("./Chain"));
8
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
9
- 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); }
10
- 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); } }
11
- function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
12
- function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
13
- 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; }
14
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
15
- 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); }
16
- var Blockweb = /*#__PURE__*/_createClass(function Blockweb(mgr) {
17
- var _this = this;
18
- _classCallCheck(this, Blockweb);
19
- _defineProperty(this, "get", function (addr) {
20
- var hash = _this.physical_addresses[addr];
21
- var chain = _this.chains[hash];
1
+ import Chain from "./Chain";
2
+
3
+ class Blockweb {
4
+ constructor(mgr) {
5
+ this.mgr = mgr;
6
+ this.physical_addresses = new Object();
7
+ this.chains = new Object();
8
+ }
9
+
10
+ get = (addr) => {
11
+ let hash = this.physical_addresses[addr];
12
+
13
+ let chain = this.chains[hash];
14
+
22
15
  return chain;
23
- });
24
- _defineProperty(this, "set", function (parent, name) {
25
- var chain = new _Chain["default"](parent, name);
26
- _this.chains[chain.hash] = chain;
27
- _this.physical_addresses[chain.physical_address] = chain.hash;
28
- _this.chains[chain.hash] = chain;
16
+ };
17
+
18
+ set = (parent, name) => {
19
+ let chain = new Chain(parent, name);
20
+ this.chains[chain.hash] = chain;
21
+
22
+ this.physical_addresses[chain.physical_address] = chain.hash;
23
+ this.chains[chain.hash] = chain;
24
+
29
25
  return chain;
30
- });
31
- this.mgr = mgr;
32
- this.physical_addresses = new Object();
33
- this.chains = new Object();
34
- });
35
- var _default = Blockweb;
36
- exports["default"] = _default;
26
+ };
27
+ }
28
+
29
+ export default Blockweb;
package/Objects/Chain.js CHANGED
@@ -1,119 +1,116 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
7
- var _hash = require("../utils/hash");
8
- var _Block = _interopRequireDefault(require("./Block"));
9
- var _Explorer2 = _interopRequireDefault(require("./Explorer"));
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 _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
16
- function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
17
- function _createSuper(t) { var r = _isNativeReflectConstruct(); return function () { var e, o = _getPrototypeOf(t); if (r) { var s = _getPrototypeOf(this).constructor; e = Reflect.construct(o, arguments, s); } else e = o.apply(this, arguments); return _possibleConstructorReturn(this, e); }; }
18
- function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
19
- function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
20
- function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
21
- function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
22
- 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; }
23
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
24
- 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); }
25
- var Chain = /*#__PURE__*/function (_Explorer) {
26
- _inherits(Chain, _Explorer);
27
- var _super = _createSuper(Chain);
28
- function Chain(parent, _name) {
29
- var _this;
30
- _classCallCheck(this, Chain);
31
- _this = _super.call(this);
32
- _defineProperty(_assertThisInitialized(_this), "append_buffer", function () {
33
- _this.buffs.push({});
34
- _this.cursors.push(_this.cursor);
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.account.set_paths(this);
115
31
  }
116
- return _createClass(Chain);
117
- }(_Explorer2["default"]);
118
- var _default = Chain;
119
- exports["default"] = _default;
32
+
33
+ append_buffer = () => {
34
+ this.buffs.push({});
35
+ this.cursors.push(this.cursor);
36
+ this.cursor = -1;
37
+ };
38
+
39
+ set_cursor = (cursor) => {
40
+ this.cursor = cursor;
41
+ this.cursors.push(cursor);
42
+ };
43
+
44
+ get_buffer = () => {
45
+ this.cursor = this.cursors.pop();
46
+ return this.buffs.slice(-1)[0];
47
+ };
48
+
49
+ generate_hash = () => {
50
+ this.hash = hash(this.physical_address);
51
+ };
52
+
53
+ get_block = (index) => {
54
+ return this.blocks[index];
55
+ };
56
+
57
+ add_tx = (instruction) => {
58
+ if (!this.txs.length) this.start_time = Date.now();
59
+
60
+ this.txs.push(instruction);
61
+ };
62
+
63
+ mine = (vm, no_curs) => {
64
+ let block = new Block(this);
65
+
66
+ block.generate_hash();
67
+ this.add_block(block);
68
+
69
+ block.store(no_curs);
70
+
71
+ block.children = this.pending_children;
72
+ this.pending_children = new Array();
73
+
74
+ let prev_context = vm.get_context(-2);
75
+ if (prev_context) {
76
+ prev_context.pending_children.push(block);
77
+ prev_context.connections.push(block);
78
+ }
79
+
80
+ this.txs = new Array();
81
+
82
+ block.timelapse = Date.now() - this.start_time;
83
+
84
+ return block;
85
+ };
86
+
87
+ add_block = (block) => {
88
+ this.blocks.push(block);
89
+ this.height = this.blocks.length;
90
+ };
91
+
92
+ get_latest_block = () => this.blocks.slice(-1)[0];
93
+
94
+ stringify = (str) => {
95
+ let obj = {};
96
+
97
+ obj.physical_address = this.physical_address;
98
+ obj.height = this.blocks.length;
99
+ obj.parent = this.parent.path;
100
+ obj.account = this.parent.account.name;
101
+ obj.name = this.name;
102
+ obj.connections = this.connections.map(
103
+ (b) => new Object({ chain: b.chain.hash, block: b.hash })
104
+ );
105
+ obj.hash = this.hash;
106
+ obj.blocks = this.blocks.map((blk) => blk.hash);
107
+
108
+ return str ? JSON.stringify(obj) : obj;
109
+ };
110
+
111
+ add_chain = (name) => {
112
+ return this.account.add_chain(name, this);
113
+ };
114
+ }
115
+
116
+ export default Chain;
@@ -1,47 +1,40 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
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
- var q2 = Number(query[1]),
13
+
14
+ let q2 = Number(query[1]),
24
15
  prop;
25
- if (_this.chain_props.includes(query[0][0])) prop = query[0][0];
26
- var obj;
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 = _this[prop || "connections"].find(function (c) {
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 = _this[prop || "connections"].find(function (q) {
33
- return q.index === q2;
34
- });
23
+ obj = this[prop || "connections"].find((q) => q.index === q2);
35
24
  } else {
36
- obj = _this[prop || "connections"].slice(q2)[0];
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
- var _default = Explorer;
47
- exports["default"] = _default;
37
+ };
38
+ }
39
+
40
+ export default Explorer;
@@ -1,56 +1,57 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
7
- var _hash = require("../utils/hash");
8
- 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); }
9
- 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); } }
10
- function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
11
- function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
12
- 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; }
13
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
14
- 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); }
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
- var type_folder = _this.account.manager.oracle.get(datapath);
16
+
17
+ let type_folder = this.account.manager.oracle.get(datapath);
18
+
25
19
  if (!type_folder) return datapath;
26
- var content;
20
+
21
+ let content;
27
22
  if (type_folder.type === "twain") {
28
23
  content = {};
29
- for (var prop in type_folder.obj) {
30
- var val = type_folder.obj[prop];
31
- content[_this.parse_path(prop)] = _this.parse_path(val);
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(function (t) {
36
- content.push(_this.parse_path(t));
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
- _defineProperty(this, "save", function (content, chain, just_obj) {
42
- var addr, obj;
43
- var type = _this.get_type(chain);
37
+ };
38
+
39
+ save = (content, chain, just_obj) => {
40
+ let addr, obj;
41
+
42
+ let type = this.get_type(chain);
43
+
44
44
  if (type === "array" || type === "string") {
45
45
  obj = [];
46
- for (var curs in content) {
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 (var _curs in content) {
53
- obj[_curs] = content[_curs];
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
- addr = "".concat(chain.path, "/").concat((0, _hash.hash)(JSON.stringify(obj)));
63
- _this;
64
- if (obj != null) _this.manager.oracle.write(addr, obj);
65
- _this.manager.oracle.set(addr, {
66
- obj: obj,
67
- type: type
68
- });
64
+
65
+ addr = `${chain.path}/${hash(JSON.stringify(obj))}`;
66
+ this;
67
+ if (obj != null) this.manager.oracle.write(addr, obj);
68
+
69
+ this.manager.oracle.set(addr, { obj, type });
70
+
69
71
  return addr;
70
- });
71
- _defineProperty(this, "data_addr", function (type) {
72
- return "".concat(_this.physical_address, "/Datatypes/").concat(type);
73
- });
74
- _defineProperty(this, "get_type", function (chain) {
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 _this.data_addr("Number"):
80
+ case this.data_addr(`Number`):
77
81
  return "number";
78
- case _this.data_addr("String"):
82
+ case this.data_addr(`String`):
79
83
  return "string";
80
- case _this.data_addr("Twain"):
84
+ case this.data_addr(`Twain`):
81
85
  return "twain";
82
- case _this.data_addr("Array"):
86
+ case this.data_addr(`Array`):
83
87
  return "array";
84
- case _this.data_addr("Boolean"):
88
+ case this.data_addr(`Boolean`):
85
89
  return "boolean";
86
- case _this.data_addr("Void"):
90
+ case this.data_addr(`Void`):
87
91
  return "void";
88
92
  }
89
- });
90
- _defineProperty(this, "write", function (arg, context) {
91
- var content = context.get_buffer();
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
- _defineProperty(this, "name_hash", function () {
97
- _this.hash = (0, _hash.hash)(_this.name);
98
- });
99
- _defineProperty(this, "set_paths", function (chain) {
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 = "".concat(chain.parent ? chain.parent.path : _this.base_address, "/").concat(chain.hash);
105
- var fs = _this.manager.oracle.fs;
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
- _defineProperty(this, "add_chain", function (name, parent) {
113
- var chain = _this.manager.web.get("".concat(parent.physical_address, "/").concat(name));
114
- if (!chain) chain = _this.manager.web.set(parent, name);
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
- _defineProperty(this, "account_chain", function (account) {
118
- var chain = _this.manager.web.get(account.physical_address);
129
+ };
130
+
131
+ account_chain = (account) => {
132
+ let chain = this.manager.web.get(account.physical_address);
133
+
119
134
  if (!chain) {
120
- chain = _this.manager.web.set(account);
135
+ chain = this.manager.web.set(account);
121
136
  }
137
+
122
138
  return chain;
123
- });
124
- this.base_address = process.env.BASE_ADDRESS || "Accounts";
125
- });
126
- var _default = Filesystem;
127
- exports["default"] = _default;
139
+ };
140
+ }
141
+
142
+ export default Filesystem;