godprotocol 1.0.791 → 1.0.792
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/package.json +1 -1
- package/.babelrc +0 -3
- package/build/Account.js +0 -173
- package/build/Block.js +0 -103
- package/build/Blockweb.js +0 -78
- package/build/Chain.js +0 -205
- package/build/Explorer.js +0 -85
- package/build/Filesystem.js +0 -165
- package/build/Frame.js +0 -108
- package/build/Index.js +0 -19
- package/build/Manager.js +0 -178
- package/build/Opcodes.js +0 -102
- package/build/Oracle.js +0 -84
- package/build/Virtual_machine.js +0 -128
- package/build/add.js +0 -41
- package/build/create_server.js +0 -495
- package/build/framer.js +0 -88
- package/build/functions.js +0 -127
- package/build/hash.js +0 -14
- package/build/jmp.js +0 -19
- package/build/main.js +0 -339
- package/build/opcodes.js +0 -42
- package/build/privacy.js +0 -27
- package/build/services.js +0 -96
- package/build/std.js +0 -11
package/package.json
CHANGED
package/.babelrc
DELETED
package/build/Account.js
DELETED
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = void 0;
|
|
7
|
-
var _main = _interopRequireDefault(require("../Loader_sequence/main"));
|
|
8
|
-
var _privacy = _interopRequireDefault(require("../utils/privacy"));
|
|
9
|
-
var _Filesystem2 = _interopRequireDefault(require("./Filesystem"));
|
|
10
|
-
var _Virtual_machine = _interopRequireDefault(require("./Virtual_machine"));
|
|
11
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
12
|
-
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); }
|
|
13
|
-
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); } }
|
|
14
|
-
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
15
|
-
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
16
|
-
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); }
|
|
17
|
-
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
|
|
18
|
-
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); }; }
|
|
19
|
-
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); }
|
|
20
|
-
function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
|
|
21
|
-
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
22
|
-
function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
|
|
23
|
-
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; }
|
|
24
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
25
|
-
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); }
|
|
26
|
-
var Account = /*#__PURE__*/function (_Filesystem) {
|
|
27
|
-
_inherits(Account, _Filesystem);
|
|
28
|
-
var _super = _createSuper(Account);
|
|
29
|
-
function Account(_name) {
|
|
30
|
-
var _this;
|
|
31
|
-
var _meta = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
32
|
-
_classCallCheck(this, Account);
|
|
33
|
-
_this = _super.call(this);
|
|
34
|
-
_defineProperty(_assertThisInitialized(_this), "get_account", function (name) {
|
|
35
|
-
return _this.manager.get_account(name) || _assertThisInitialized(_this);
|
|
36
|
-
});
|
|
37
|
-
_defineProperty(_assertThisInitialized(_this), "manage_buffer", function (callback) {
|
|
38
|
-
var call_session = "".concat(Date.now(), "-").concat(Math.random());
|
|
39
|
-
_this.mine_buffer[call_session] = {
|
|
40
|
-
blocks: [],
|
|
41
|
-
callback: callback
|
|
42
|
-
};
|
|
43
|
-
return call_session;
|
|
44
|
-
});
|
|
45
|
-
_defineProperty(_assertThisInitialized(_this), "buff", function (block, pid) {
|
|
46
|
-
var buffer = _this.mine_buffer[pid];
|
|
47
|
-
if (!buffer) return;
|
|
48
|
-
buffer.blocks.push(block.stringify());
|
|
49
|
-
});
|
|
50
|
-
_defineProperty(_assertThisInitialized(_this), "flush_buffer", function (pid) {
|
|
51
|
-
var buff = _this.mine_buffer[pid];
|
|
52
|
-
if (!buff) return;
|
|
53
|
-
buff.callback && _this.run_callback(buff.callback, buff.blocks);
|
|
54
|
-
delete _this.mine_buffer[pid];
|
|
55
|
-
});
|
|
56
|
-
_defineProperty(_assertThisInitialized(_this), "load", function (_ref) {
|
|
57
|
-
var program = _ref.program,
|
|
58
|
-
signature = _ref.signature,
|
|
59
|
-
callback = _ref.callback;
|
|
60
|
-
var instructions = program.instructions,
|
|
61
|
-
account = program.account;
|
|
62
|
-
account = _this.get_account(account);
|
|
63
|
-
if (!account.validate(payload, signature, callback)) return;
|
|
64
|
-
var pid = account.manage_buffer(callback);
|
|
65
|
-
_this.manager.push({
|
|
66
|
-
sequence: instructions,
|
|
67
|
-
account: account,
|
|
68
|
-
pid: pid
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
_defineProperty(_assertThisInitialized(_this), "parse", function (_ref2) {
|
|
72
|
-
var payload = _ref2.payload,
|
|
73
|
-
signature = _ref2.signature,
|
|
74
|
-
callback = _ref2.callback;
|
|
75
|
-
var physical_address = payload.physical_address,
|
|
76
|
-
account = payload.account,
|
|
77
|
-
query = payload.query;
|
|
78
|
-
account = _this.get_account(account);
|
|
79
|
-
if (!account.validate(payload, signature)) return _this.run_callback(callback, {
|
|
80
|
-
"private": account["private"],
|
|
81
|
-
error: true,
|
|
82
|
-
error_message: "Invalid signature"
|
|
83
|
-
});
|
|
84
|
-
var chain = account.manager.web.get(physical_address);
|
|
85
|
-
if (!chain) return _this.run_callback(callback, {
|
|
86
|
-
error: true,
|
|
87
|
-
error_message: "Address not found"
|
|
88
|
-
});
|
|
89
|
-
var data = query ? chain.explore(query) : chain;
|
|
90
|
-
_this.run_callback(callback, data && data.stringify());
|
|
91
|
-
});
|
|
92
|
-
_defineProperty(_assertThisInitialized(_this), "run", function (request) {
|
|
93
|
-
var payload = request.payload,
|
|
94
|
-
signature = request.signature,
|
|
95
|
-
callback = request.callback;
|
|
96
|
-
var physical_address = payload.physical_address,
|
|
97
|
-
account = payload.account,
|
|
98
|
-
query = payload.query;
|
|
99
|
-
account = _this.get_account(account);
|
|
100
|
-
if (!account.validate(payload, signature, callback)) return;
|
|
101
|
-
var pid = account.manage_buffer(callback);
|
|
102
|
-
var context = physical_address ? _this.manager.web.get(physical_address) : account.vm.get_context();
|
|
103
|
-
if (!context) return account.flush_buffer(pid);
|
|
104
|
-
var blk = query ? context.explore(query) : context.get_latest_block();
|
|
105
|
-
if (blk && blk.metadata && blk.metadata.program) {
|
|
106
|
-
var program = _this.read(blk.metadata.program);
|
|
107
|
-
account.vm.contexts.push(context);
|
|
108
|
-
program.push("pop");
|
|
109
|
-
Array.isArray(program) && program.length && _this.manager.push({
|
|
110
|
-
sequence: program,
|
|
111
|
-
account: account,
|
|
112
|
-
pid: pid
|
|
113
|
-
});
|
|
114
|
-
} else account.flush_buffer(pid);
|
|
115
|
-
});
|
|
116
|
-
_defineProperty(_assertThisInitialized(_this), "run_callback", function (callback, payload) {
|
|
117
|
-
setTimeout(function () {
|
|
118
|
-
if (!callback) return;
|
|
119
|
-
if (typeof callback === "function") return callback(payload);
|
|
120
|
-
callback.payload && callback.payload.physical_address && _this.vm.stdin(payload, function () {
|
|
121
|
-
return _this.run(callback);
|
|
122
|
-
});
|
|
123
|
-
}, 0);
|
|
124
|
-
});
|
|
125
|
-
_defineProperty(_assertThisInitialized(_this), "validate", function (payload, signature, callback) {
|
|
126
|
-
if (!_this["private"]) return true;
|
|
127
|
-
var valid = (0, _privacy["default"])(_this.name, JSON.stringify(payload), signature);
|
|
128
|
-
if (!valid) _this.run_callback(callback, {
|
|
129
|
-
"private": _this["private"],
|
|
130
|
-
error: true,
|
|
131
|
-
error_message: "Invalid signature"
|
|
132
|
-
});
|
|
133
|
-
return valid;
|
|
134
|
-
});
|
|
135
|
-
_defineProperty(_assertThisInitialized(_this), "stringify", function (str) {
|
|
136
|
-
var obj = {};
|
|
137
|
-
obj.name = _this.name;
|
|
138
|
-
obj.hash = _this.hash;
|
|
139
|
-
obj.path = _this.path;
|
|
140
|
-
obj["private"] = _this["private"];
|
|
141
|
-
obj.chain = _this.chain.stringify();
|
|
142
|
-
obj.physical_address = _this.physical_address;
|
|
143
|
-
return str ? JSON.stringify(obj) : obj;
|
|
144
|
-
});
|
|
145
|
-
_defineProperty(_assertThisInitialized(_this), "create_account", function (payload) {
|
|
146
|
-
var name = payload.name,
|
|
147
|
-
meta = payload.meta;
|
|
148
|
-
return _this.manager.add_account(name, meta);
|
|
149
|
-
});
|
|
150
|
-
_defineProperty(_assertThisInitialized(_this), "endpoint", function (endpoint, payload) {
|
|
151
|
-
var method = _this[endpoint];
|
|
152
|
-
typeof method === "function" && method(payload);
|
|
153
|
-
});
|
|
154
|
-
_meta = _meta || {};
|
|
155
|
-
_this.name = _name;
|
|
156
|
-
_this["private"] = _meta["private"];
|
|
157
|
-
_this.manager = _meta.manager;
|
|
158
|
-
_this.account = _assertThisInitialized(_this);
|
|
159
|
-
if (!_this.manager) throw new Error("Manager instance missing.");
|
|
160
|
-
_this.name_hash();
|
|
161
|
-
_this.physical_address = "".concat(_this.base_address, "/").concat(_this.name);
|
|
162
|
-
_this.set_paths(_assertThisInitialized(_this));
|
|
163
|
-
_this.assembler = new _main["default"](_assertThisInitialized(_this));
|
|
164
|
-
_this.chain = _this.account_chain(_assertThisInitialized(_this));
|
|
165
|
-
_this.vm = new _Virtual_machine["default"](_this.chain);
|
|
166
|
-
_this.mine_buffer = {};
|
|
167
|
-
console.log("Account Instance: ".concat(_this.name));
|
|
168
|
-
return _this;
|
|
169
|
-
}
|
|
170
|
-
return _createClass(Account);
|
|
171
|
-
}(_Filesystem2["default"]);
|
|
172
|
-
var _default = Account;
|
|
173
|
-
exports["default"] = _default;
|
package/build/Block.js
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
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) {
|
|
9
|
-
"@babel/helpers - typeof";
|
|
10
|
-
|
|
11
|
-
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
|
12
|
-
return typeof o;
|
|
13
|
-
} : function (o) {
|
|
14
|
-
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
15
|
-
}, _typeof(o);
|
|
16
|
-
}
|
|
17
|
-
function _defineProperties(e, r) {
|
|
18
|
-
for (var t = 0; t < r.length; t++) {
|
|
19
|
-
var o = r[t];
|
|
20
|
-
o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
function _createClass(e, r, t) {
|
|
24
|
-
return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
|
|
25
|
-
writable: !1
|
|
26
|
-
}), e;
|
|
27
|
-
}
|
|
28
|
-
function _classCallCheck(a, n) {
|
|
29
|
-
if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
|
|
30
|
-
}
|
|
31
|
-
function _defineProperty(e, r, t) {
|
|
32
|
-
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
33
|
-
value: t,
|
|
34
|
-
enumerable: !0,
|
|
35
|
-
configurable: !0,
|
|
36
|
-
writable: !0
|
|
37
|
-
}) : e[r] = t, e;
|
|
38
|
-
}
|
|
39
|
-
function _toPropertyKey(t) {
|
|
40
|
-
var i = _toPrimitive(t, "string");
|
|
41
|
-
return "symbol" == _typeof(i) ? i : i + "";
|
|
42
|
-
}
|
|
43
|
-
function _toPrimitive(t, r) {
|
|
44
|
-
if ("object" != _typeof(t) || !t) return t;
|
|
45
|
-
var e = t[Symbol.toPrimitive];
|
|
46
|
-
if (void 0 !== e) {
|
|
47
|
-
var i = e.call(t, r || "default");
|
|
48
|
-
if ("object" != _typeof(i)) return i;
|
|
49
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
50
|
-
}
|
|
51
|
-
return ("string" === r ? String : Number)(t);
|
|
52
|
-
}
|
|
53
|
-
var Block = /*#__PURE__*/_createClass(function Block(chain) {
|
|
54
|
-
var _this = this;
|
|
55
|
-
_classCallCheck(this, Block);
|
|
56
|
-
_defineProperty(this, "generate_hash", function () {
|
|
57
|
-
_this.previous_hash = _this.chain.get_latest_block();
|
|
58
|
-
if (_this.previous_hash) _this.previous_hash = _this.previous_hash.hash;
|
|
59
|
-
_this.hash = (0, _hash.hash)(JSON.stringify(_this.data));
|
|
60
|
-
});
|
|
61
|
-
_defineProperty(this, "store", function (no_curs) {
|
|
62
|
-
var content = _this.chain.buffs.splice(-1)[0];
|
|
63
|
-
if (!no_curs) _this.cursor = _this.chain.cursors.splice(-1)[0];
|
|
64
|
-
if (!content) return;
|
|
65
|
-
var cursors = Object.keys(content).filter(function (c) {
|
|
66
|
-
return c.startsWith("{") && c.endsWith("}");
|
|
67
|
-
});
|
|
68
|
-
for (var c = 0; c < cursors.length; c++) {
|
|
69
|
-
var curs = cursors[c];
|
|
70
|
-
_this.metadata[curs.slice(1, -1)] = content[curs];
|
|
71
|
-
delete content[curs];
|
|
72
|
-
}
|
|
73
|
-
var datapath = _this.chain.account.save(content, _this.chain);
|
|
74
|
-
_this.datapath = datapath;
|
|
75
|
-
});
|
|
76
|
-
_defineProperty(this, "stringify", function (str) {
|
|
77
|
-
var obj = {};
|
|
78
|
-
obj.metadata = _this.metadata;
|
|
79
|
-
obj.datapath = _this.datapath;
|
|
80
|
-
obj.timelapse = _this.timelapse;
|
|
81
|
-
obj.index = _this.index;
|
|
82
|
-
obj.hash = _this.hash;
|
|
83
|
-
obj.data = _this.data;
|
|
84
|
-
obj.children = _this.children.map(function (ch) {
|
|
85
|
-
return new Object({
|
|
86
|
-
hash: ch.hash,
|
|
87
|
-
chain: ch.chain.hash
|
|
88
|
-
});
|
|
89
|
-
});
|
|
90
|
-
obj.chain = {
|
|
91
|
-
hash: _this.chain.hash,
|
|
92
|
-
physical_address: _this.chain.physical_address
|
|
93
|
-
};
|
|
94
|
-
return str ? JSON.stringify(obj) : obj;
|
|
95
|
-
});
|
|
96
|
-
this.chain = chain;
|
|
97
|
-
this.data = this.chain.txs;
|
|
98
|
-
this.metadata = {};
|
|
99
|
-
this.children = new Array();
|
|
100
|
-
this.index = this.chain.blocks.length;
|
|
101
|
-
});
|
|
102
|
-
var _default = Block;
|
|
103
|
-
exports["default"] = _default;
|
package/build/Blockweb.js
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
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) {
|
|
9
|
-
return e && e.__esModule ? e : {
|
|
10
|
-
"default": e
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
function _typeof(o) {
|
|
14
|
-
"@babel/helpers - typeof";
|
|
15
|
-
|
|
16
|
-
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
|
17
|
-
return typeof o;
|
|
18
|
-
} : function (o) {
|
|
19
|
-
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
20
|
-
}, _typeof(o);
|
|
21
|
-
}
|
|
22
|
-
function _defineProperties(e, r) {
|
|
23
|
-
for (var t = 0; t < r.length; t++) {
|
|
24
|
-
var o = r[t];
|
|
25
|
-
o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
function _createClass(e, r, t) {
|
|
29
|
-
return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
|
|
30
|
-
writable: !1
|
|
31
|
-
}), e;
|
|
32
|
-
}
|
|
33
|
-
function _classCallCheck(a, n) {
|
|
34
|
-
if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
|
|
35
|
-
}
|
|
36
|
-
function _defineProperty(e, r, t) {
|
|
37
|
-
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
38
|
-
value: t,
|
|
39
|
-
enumerable: !0,
|
|
40
|
-
configurable: !0,
|
|
41
|
-
writable: !0
|
|
42
|
-
}) : e[r] = t, e;
|
|
43
|
-
}
|
|
44
|
-
function _toPropertyKey(t) {
|
|
45
|
-
var i = _toPrimitive(t, "string");
|
|
46
|
-
return "symbol" == _typeof(i) ? i : i + "";
|
|
47
|
-
}
|
|
48
|
-
function _toPrimitive(t, r) {
|
|
49
|
-
if ("object" != _typeof(t) || !t) return t;
|
|
50
|
-
var e = t[Symbol.toPrimitive];
|
|
51
|
-
if (void 0 !== e) {
|
|
52
|
-
var i = e.call(t, r || "default");
|
|
53
|
-
if ("object" != _typeof(i)) return i;
|
|
54
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
55
|
-
}
|
|
56
|
-
return ("string" === r ? String : Number)(t);
|
|
57
|
-
}
|
|
58
|
-
var Blockweb = /*#__PURE__*/_createClass(function Blockweb(mgr) {
|
|
59
|
-
var _this = this;
|
|
60
|
-
_classCallCheck(this, Blockweb);
|
|
61
|
-
_defineProperty(this, "get", function (addr) {
|
|
62
|
-
var hash = _this.physical_addresses[addr];
|
|
63
|
-
var chain = _this.chains[hash];
|
|
64
|
-
return chain;
|
|
65
|
-
});
|
|
66
|
-
_defineProperty(this, "set", function (parent, name) {
|
|
67
|
-
var chain = new _Chain["default"](parent, name);
|
|
68
|
-
_this.chains[chain.hash] = chain;
|
|
69
|
-
_this.physical_addresses[chain.physical_address] = chain.hash;
|
|
70
|
-
_this.chains[chain.hash] = chain;
|
|
71
|
-
return chain;
|
|
72
|
-
});
|
|
73
|
-
this.mgr = mgr;
|
|
74
|
-
this.physical_addresses = new Object();
|
|
75
|
-
this.chains = new Object();
|
|
76
|
-
});
|
|
77
|
-
var _default = Blockweb;
|
|
78
|
-
exports["default"] = _default;
|
package/build/Chain.js
DELETED
|
@@ -1,205 +0,0 @@
|
|
|
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) {
|
|
11
|
-
return e && e.__esModule ? e : {
|
|
12
|
-
"default": e
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
function _typeof(o) {
|
|
16
|
-
"@babel/helpers - typeof";
|
|
17
|
-
|
|
18
|
-
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
|
19
|
-
return typeof o;
|
|
20
|
-
} : function (o) {
|
|
21
|
-
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
22
|
-
}, _typeof(o);
|
|
23
|
-
}
|
|
24
|
-
function _defineProperties(e, r) {
|
|
25
|
-
for (var t = 0; t < r.length; t++) {
|
|
26
|
-
var o = r[t];
|
|
27
|
-
o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
function _createClass(e, r, t) {
|
|
31
|
-
return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
|
|
32
|
-
writable: !1
|
|
33
|
-
}), e;
|
|
34
|
-
}
|
|
35
|
-
function _classCallCheck(a, n) {
|
|
36
|
-
if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
|
|
37
|
-
}
|
|
38
|
-
function _inherits(t, e) {
|
|
39
|
-
if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function");
|
|
40
|
-
t.prototype = Object.create(e && e.prototype, {
|
|
41
|
-
constructor: {
|
|
42
|
-
value: t,
|
|
43
|
-
writable: !0,
|
|
44
|
-
configurable: !0
|
|
45
|
-
}
|
|
46
|
-
}), Object.defineProperty(t, "prototype", {
|
|
47
|
-
writable: !1
|
|
48
|
-
}), e && _setPrototypeOf(t, e);
|
|
49
|
-
}
|
|
50
|
-
function _setPrototypeOf(t, e) {
|
|
51
|
-
return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {
|
|
52
|
-
return t.__proto__ = e, t;
|
|
53
|
-
}, _setPrototypeOf(t, e);
|
|
54
|
-
}
|
|
55
|
-
function _createSuper(t) {
|
|
56
|
-
var r = _isNativeReflectConstruct();
|
|
57
|
-
return function () {
|
|
58
|
-
var e,
|
|
59
|
-
o = _getPrototypeOf(t);
|
|
60
|
-
if (r) {
|
|
61
|
-
var s = _getPrototypeOf(this).constructor;
|
|
62
|
-
e = Reflect.construct(o, arguments, s);
|
|
63
|
-
} else e = o.apply(this, arguments);
|
|
64
|
-
return _possibleConstructorReturn(this, e);
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
function _possibleConstructorReturn(t, e) {
|
|
68
|
-
if (e && ("object" == _typeof(e) || "function" == typeof e)) return e;
|
|
69
|
-
if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined");
|
|
70
|
-
return _assertThisInitialized(t);
|
|
71
|
-
}
|
|
72
|
-
function _assertThisInitialized(e) {
|
|
73
|
-
if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
74
|
-
return e;
|
|
75
|
-
}
|
|
76
|
-
function _isNativeReflectConstruct() {
|
|
77
|
-
try {
|
|
78
|
-
var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
|
|
79
|
-
} catch (t) {}
|
|
80
|
-
return (_isNativeReflectConstruct = function _isNativeReflectConstruct() {
|
|
81
|
-
return !!t;
|
|
82
|
-
})();
|
|
83
|
-
}
|
|
84
|
-
function _getPrototypeOf(t) {
|
|
85
|
-
return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {
|
|
86
|
-
return t.__proto__ || Object.getPrototypeOf(t);
|
|
87
|
-
}, _getPrototypeOf(t);
|
|
88
|
-
}
|
|
89
|
-
function _defineProperty(e, r, t) {
|
|
90
|
-
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
91
|
-
value: t,
|
|
92
|
-
enumerable: !0,
|
|
93
|
-
configurable: !0,
|
|
94
|
-
writable: !0
|
|
95
|
-
}) : e[r] = t, e;
|
|
96
|
-
}
|
|
97
|
-
function _toPropertyKey(t) {
|
|
98
|
-
var i = _toPrimitive(t, "string");
|
|
99
|
-
return "symbol" == _typeof(i) ? i : i + "";
|
|
100
|
-
}
|
|
101
|
-
function _toPrimitive(t, r) {
|
|
102
|
-
if ("object" != _typeof(t) || !t) return t;
|
|
103
|
-
var e = t[Symbol.toPrimitive];
|
|
104
|
-
if (void 0 !== e) {
|
|
105
|
-
var i = e.call(t, r || "default");
|
|
106
|
-
if ("object" != _typeof(i)) return i;
|
|
107
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
108
|
-
}
|
|
109
|
-
return ("string" === r ? String : Number)(t);
|
|
110
|
-
}
|
|
111
|
-
var Chain = /*#__PURE__*/function (_Explorer) {
|
|
112
|
-
_inherits(Chain, _Explorer);
|
|
113
|
-
var _super = _createSuper(Chain);
|
|
114
|
-
function Chain(parent, _name) {
|
|
115
|
-
var _this;
|
|
116
|
-
_classCallCheck(this, Chain);
|
|
117
|
-
_this = _super.call(this);
|
|
118
|
-
_defineProperty(_assertThisInitialized(_this), "append_buffer", function () {
|
|
119
|
-
_this.buffs.push({});
|
|
120
|
-
_this.cursors.push(_this.cursor);
|
|
121
|
-
_this.cursor = -1;
|
|
122
|
-
});
|
|
123
|
-
_defineProperty(_assertThisInitialized(_this), "set_cursor", function (cursor) {
|
|
124
|
-
_this.cursor = cursor;
|
|
125
|
-
_this.cursors.push(cursor);
|
|
126
|
-
});
|
|
127
|
-
_defineProperty(_assertThisInitialized(_this), "get_buffer", function () {
|
|
128
|
-
_this.cursor = _this.cursors.pop();
|
|
129
|
-
return _this.buffs.slice(-1)[0];
|
|
130
|
-
});
|
|
131
|
-
_defineProperty(_assertThisInitialized(_this), "generate_hash", function () {
|
|
132
|
-
_this.hash = (0, _hash.hash)(_this.physical_address);
|
|
133
|
-
});
|
|
134
|
-
_defineProperty(_assertThisInitialized(_this), "get_block", function (index) {
|
|
135
|
-
return _this.blocks[index];
|
|
136
|
-
});
|
|
137
|
-
_defineProperty(_assertThisInitialized(_this), "add_tx", function (instruction) {
|
|
138
|
-
if (!_this.txs.length) _this.start_time = Date.now();
|
|
139
|
-
_this.txs.push(instruction);
|
|
140
|
-
});
|
|
141
|
-
_defineProperty(_assertThisInitialized(_this), "mine", function (vm, no_curs) {
|
|
142
|
-
var block = new _Block["default"](_assertThisInitialized(_this));
|
|
143
|
-
block.generate_hash();
|
|
144
|
-
_this.add_block(block);
|
|
145
|
-
block.store(no_curs);
|
|
146
|
-
block.children = _this.pending_children;
|
|
147
|
-
_this.pending_children = new Array();
|
|
148
|
-
var prev_context = vm.get_context(-2);
|
|
149
|
-
if (prev_context) {
|
|
150
|
-
prev_context.pending_children.push(block);
|
|
151
|
-
prev_context.connections.push(block);
|
|
152
|
-
}
|
|
153
|
-
_this.txs = new Array();
|
|
154
|
-
block.timelapse = Date.now() - _this.start_time;
|
|
155
|
-
return block;
|
|
156
|
-
});
|
|
157
|
-
_defineProperty(_assertThisInitialized(_this), "add_block", function (block) {
|
|
158
|
-
_this.blocks.push(block);
|
|
159
|
-
_this.height = _this.blocks.length;
|
|
160
|
-
});
|
|
161
|
-
_defineProperty(_assertThisInitialized(_this), "get_latest_block", function () {
|
|
162
|
-
return _this.blocks.slice(-1)[0];
|
|
163
|
-
});
|
|
164
|
-
_defineProperty(_assertThisInitialized(_this), "stringify", function (str) {
|
|
165
|
-
var obj = {};
|
|
166
|
-
obj.physical_address = _this.physical_address;
|
|
167
|
-
obj.height = _this.blocks.length;
|
|
168
|
-
obj.parent = _this.parent.path;
|
|
169
|
-
obj.account = _this.parent.account.name;
|
|
170
|
-
obj.name = _this.name;
|
|
171
|
-
obj.connections = _this.connections.map(function (b) {
|
|
172
|
-
return new Object({
|
|
173
|
-
chain: b.chain.hash,
|
|
174
|
-
block: b.hash
|
|
175
|
-
});
|
|
176
|
-
});
|
|
177
|
-
obj.hash = _this.hash;
|
|
178
|
-
obj.blocks = _this.blocks.map(function (blk) {
|
|
179
|
-
return blk.hash;
|
|
180
|
-
});
|
|
181
|
-
return str ? JSON.stringify(obj) : obj;
|
|
182
|
-
});
|
|
183
|
-
_defineProperty(_assertThisInitialized(_this), "add_chain", function (name) {
|
|
184
|
-
return _this.account.add_chain(name, _assertThisInitialized(_this));
|
|
185
|
-
});
|
|
186
|
-
_this.parent = parent;
|
|
187
|
-
_this.account = _this.parent.account;
|
|
188
|
-
_this.name = _name || _this.parent.name;
|
|
189
|
-
_this.physical_address = _this.parent.manager || !_name ? _this.parent.physical_address : "".concat(_this.parent.physical_address, "/").concat(_this.name);
|
|
190
|
-
_this.pending_children = new Array();
|
|
191
|
-
_this.connections = new Array();
|
|
192
|
-
_this.blocks = new Array();
|
|
193
|
-
_this.txs = new Array();
|
|
194
|
-
_this.height = 0;
|
|
195
|
-
_this.cursor = -1;
|
|
196
|
-
_this.cursors = new Array();
|
|
197
|
-
_this.buffs = new Array();
|
|
198
|
-
_this.generate_hash();
|
|
199
|
-
_this.account.set_paths(_assertThisInitialized(_this));
|
|
200
|
-
return _this;
|
|
201
|
-
}
|
|
202
|
-
return _createClass(Chain);
|
|
203
|
-
}(_Explorer2["default"]);
|
|
204
|
-
var _default = Chain;
|
|
205
|
-
exports["default"] = _default;
|
package/build/Explorer.js
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = void 0;
|
|
7
|
-
function _typeof(o) {
|
|
8
|
-
"@babel/helpers - typeof";
|
|
9
|
-
|
|
10
|
-
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
|
11
|
-
return typeof o;
|
|
12
|
-
} : function (o) {
|
|
13
|
-
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
14
|
-
}, _typeof(o);
|
|
15
|
-
}
|
|
16
|
-
function _defineProperties(e, r) {
|
|
17
|
-
for (var t = 0; t < r.length; t++) {
|
|
18
|
-
var o = r[t];
|
|
19
|
-
o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
function _createClass(e, r, t) {
|
|
23
|
-
return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
|
|
24
|
-
writable: !1
|
|
25
|
-
}), e;
|
|
26
|
-
}
|
|
27
|
-
function _classCallCheck(a, n) {
|
|
28
|
-
if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
|
|
29
|
-
}
|
|
30
|
-
function _defineProperty(e, r, t) {
|
|
31
|
-
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
32
|
-
value: t,
|
|
33
|
-
enumerable: !0,
|
|
34
|
-
configurable: !0,
|
|
35
|
-
writable: !0
|
|
36
|
-
}) : e[r] = t, e;
|
|
37
|
-
}
|
|
38
|
-
function _toPropertyKey(t) {
|
|
39
|
-
var i = _toPrimitive(t, "string");
|
|
40
|
-
return "symbol" == _typeof(i) ? i : i + "";
|
|
41
|
-
}
|
|
42
|
-
function _toPrimitive(t, r) {
|
|
43
|
-
if ("object" != _typeof(t) || !t) return t;
|
|
44
|
-
var e = t[Symbol.toPrimitive];
|
|
45
|
-
if (void 0 !== e) {
|
|
46
|
-
var i = e.call(t, r || "default");
|
|
47
|
-
if ("object" != _typeof(i)) return i;
|
|
48
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
49
|
-
}
|
|
50
|
-
return ("string" === r ? String : Number)(t);
|
|
51
|
-
}
|
|
52
|
-
var Explorer = /*#__PURE__*/_createClass(function Explorer() {
|
|
53
|
-
var _this = this;
|
|
54
|
-
_classCallCheck(this, Explorer);
|
|
55
|
-
_defineProperty(this, "chain_props", ["blocks"]);
|
|
56
|
-
_defineProperty(this, "explore", function (query) {
|
|
57
|
-
if (!query) return;
|
|
58
|
-
if (query.startsWith("{")) query = query.slice(1, -1);
|
|
59
|
-
query = query.split(":");
|
|
60
|
-
query[0] = query[0].split(".");
|
|
61
|
-
var q2 = Number(query[1]),
|
|
62
|
-
prop;
|
|
63
|
-
if (_this.chain_props.includes(query[0][0])) prop = query[0][0];
|
|
64
|
-
var obj;
|
|
65
|
-
if (isNaN(q2)) {
|
|
66
|
-
obj = _this[prop || "connections"].find(function (c) {
|
|
67
|
-
return c.hash === query[1];
|
|
68
|
-
});
|
|
69
|
-
} else if (q2 >= 0) {
|
|
70
|
-
obj = _this[prop || "connections"].find(function (q) {
|
|
71
|
-
return q.index === q2;
|
|
72
|
-
});
|
|
73
|
-
} else {
|
|
74
|
-
obj = _this[prop || "connections"].slice(q2)[0];
|
|
75
|
-
}
|
|
76
|
-
if (!prop) for (var q = 0; q < query[0].length; q++) {
|
|
77
|
-
var que = query[0][q];
|
|
78
|
-
if (!obj) break;
|
|
79
|
-
obj = obj[que];
|
|
80
|
-
}
|
|
81
|
-
return obj;
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
var _default = Explorer;
|
|
85
|
-
exports["default"] = _default;
|