godprotocol 1.0.839 → 1.0.841
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/Index.js +17 -15
- package/Loader_sequence/main.js +292 -439
- package/Loader_sequence/repository.js +44 -27
- package/Objects/Account.js +237 -262
- package/Objects/Block.js +76 -77
- package/Objects/Blockweb.js +40 -36
- package/Objects/Chain.js +157 -162
- package/Objects/Explorer.js +47 -30
- package/Objects/Filesystem.js +82 -98
- package/Objects/Frame.js +48 -43
- package/Objects/Manager.js +108 -112
- package/Objects/Opcodes.js +44 -44
- package/Objects/Oracle.js +131 -91
- package/Objects/Virtual_machine.js +145 -145
- package/framer.js +35 -42
- package/opcodes/add.js +25 -9
- package/opcodes/indices.js +14 -15
- package/opcodes/jmp.js +12 -7
- package/opcodes/std.js +13 -7
- package/opcodes.js +58 -41
- package/package.json +3 -2
- package/utils/create_server.js +106 -71
- package/utils/functions.js +43 -31
- package/utils/hash.js +11 -10
- package/utils/privacy.js +15 -10
- package/utils/services.js +33 -32
|
@@ -1,150 +1,150 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = void 0;
|
|
7
|
+
var _Opcodes2 = _interopRequireDefault(require("./Opcodes"));
|
|
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 _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); }
|
|
14
|
+
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
|
|
15
|
+
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); }; }
|
|
16
|
+
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); }
|
|
17
|
+
function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
|
|
18
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
19
|
+
function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
|
|
20
|
+
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; }
|
|
21
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
22
|
+
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); }
|
|
23
|
+
var Virtual_machine = /*#__PURE__*/function (_Opcodes) {
|
|
24
|
+
_inherits(Virtual_machine, _Opcodes);
|
|
25
|
+
var _super = _createSuper(Virtual_machine);
|
|
26
|
+
function Virtual_machine(_context) {
|
|
27
|
+
var _this;
|
|
28
|
+
_classCallCheck(this, Virtual_machine);
|
|
29
|
+
_this = _super.call(this);
|
|
30
|
+
_defineProperty(_assertThisInitialized(_this), "get_context", function (index) {
|
|
31
|
+
return _this.contexts.slice(index == null ? -1 : index)[0];
|
|
32
|
+
});
|
|
33
|
+
_defineProperty(_assertThisInitialized(_this), "parse_arg", function (arg, is_cursor) {
|
|
34
|
+
var context = _this.get_context();
|
|
35
|
+
var args = arg.split("/"),
|
|
36
|
+
i = 0;
|
|
37
|
+
while (args[0] === "..") {
|
|
38
|
+
i++;
|
|
39
|
+
args.splice(0, 1);
|
|
40
|
+
}
|
|
41
|
+
i = (i + 1) * -1;
|
|
42
|
+
context = i ? _this.get_context(i) : context;
|
|
43
|
+
arg = args.join("/");
|
|
44
|
+
while (arg.includes("^")) {
|
|
45
|
+
var blk = context.connections.slice(-1)[0];
|
|
46
|
+
if (!blk) break;
|
|
47
|
+
context = blk.chain;
|
|
48
|
+
var _i = arg.indexOf("^");
|
|
49
|
+
arg = "".concat(arg.slice(0, _i)).concat(arg.slice(_i + 1));
|
|
50
|
+
}
|
|
51
|
+
if (arg.startsWith("{*") && is_cursor) {
|
|
52
|
+
arg = context.explore(arg.slice(2, -1));
|
|
53
|
+
} else if (arg.startsWith("{") && !is_cursor) {
|
|
54
|
+
arg = context.explore(arg.slice(1, -1));
|
|
55
|
+
}
|
|
56
|
+
return arg;
|
|
57
|
+
});
|
|
58
|
+
_defineProperty(_assertThisInitialized(_this), "split_instruction", function (instruction) {
|
|
59
|
+
var split = instruction.split(" ");
|
|
60
|
+
var opcode = split[0],
|
|
61
|
+
args = split.slice(1).join(" ");
|
|
62
|
+
return {
|
|
63
|
+
opcode: opcode,
|
|
64
|
+
args: args
|
|
65
|
+
};
|
|
66
|
+
});
|
|
67
|
+
_defineProperty(_assertThisInitialized(_this), "execute", function (instruction, track) {
|
|
68
|
+
_this.track = track;
|
|
69
|
+
if (!instruction) return;
|
|
70
|
+
var _this$split_instructi = _this.split_instruction(instruction),
|
|
71
|
+
opcode = _this$split_instructi.opcode,
|
|
72
|
+
args = _this$split_instructi.args;
|
|
73
|
+
var context = _this.get_context();
|
|
74
|
+
if (!context) return;
|
|
75
|
+
context.add_tx(instruction);
|
|
76
|
+
|
|
77
|
+
// console.log(instruction);
|
|
78
|
+
|
|
79
|
+
var chain;
|
|
80
|
+
args = _this.parse_arg(args, opcode === "cursor");
|
|
81
|
+
switch (opcode) {
|
|
82
|
+
case "chain":
|
|
83
|
+
chain = context.account.add_chain(args, context);
|
|
84
|
+
_this.contexts.push(chain);
|
|
85
|
+
var dim = context.folder.config.dimensions;
|
|
86
|
+
if (!dim) {
|
|
87
|
+
dim = [];
|
|
88
|
+
context.folder.config.dimensions = dim;
|
|
89
|
+
}
|
|
90
|
+
!dim.find(function (d) {
|
|
91
|
+
return d === args;
|
|
92
|
+
}) && dim.push(args);
|
|
93
|
+
chain.append_buffer();
|
|
94
|
+
break;
|
|
95
|
+
case "link":
|
|
96
|
+
chain = context.account.manager.web.get(args);
|
|
97
|
+
if (!chain) {
|
|
98
|
+
_this.account.flush_buffer(_this.track.pid, {
|
|
99
|
+
error: true,
|
|
100
|
+
error_message: "LINKing Failed. - ".concat(args)
|
|
101
|
+
});
|
|
102
|
+
_this.track.pointer = _this.track.sequence.length;
|
|
103
|
+
console.log("LINKing Failed. - ".concat(args));
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
chain.append_buffer();
|
|
107
|
+
_this.contexts.push(chain);
|
|
108
|
+
break;
|
|
109
|
+
case "mine":
|
|
110
|
+
var bloc = context.mine(_assertThisInitialized(_this), true);
|
|
111
|
+
_this.account.buff(bloc, _this.track.pid);
|
|
112
|
+
break;
|
|
113
|
+
case "pop":
|
|
114
|
+
var blk;
|
|
115
|
+
if (context.txs.length > 1) {
|
|
116
|
+
blk = context.mine(_assertThisInitialized(_this));
|
|
117
|
+
} else {
|
|
118
|
+
blk = context.get_latest_block();
|
|
119
|
+
if (blk) _this.get_context(-2).connections.push(blk);
|
|
120
|
+
context.txs = [];
|
|
121
|
+
}
|
|
122
|
+
blk && _this.account.buff(blk, _this.track.pid);
|
|
123
|
+
_this.contexts.pop();
|
|
124
|
+
break;
|
|
125
|
+
case "cursor":
|
|
126
|
+
context.set_cursor(args);
|
|
127
|
+
break;
|
|
128
|
+
case "write":
|
|
129
|
+
context.account.write(args, context);
|
|
130
|
+
break;
|
|
131
|
+
default:
|
|
132
|
+
_this.prepare_operation(opcode, context);
|
|
133
|
+
break;
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
_this.account = _context.account;
|
|
137
|
+
_this.contexts = [_context];
|
|
138
|
+
_this.stack = new Array();
|
|
139
|
+
_this.flags = {
|
|
11
140
|
neg: false,
|
|
12
141
|
equal: false,
|
|
13
142
|
zero: false,
|
|
14
|
-
void: false
|
|
143
|
+
"void": false
|
|
15
144
|
};
|
|
145
|
+
return _this;
|
|
16
146
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
parse_arg = (arg, is_cursor) => {
|
|
23
|
-
let context = this.get_context();
|
|
24
|
-
|
|
25
|
-
let args = arg.split("/"),
|
|
26
|
-
i = 0;
|
|
27
|
-
|
|
28
|
-
while (args[0] === "..") {
|
|
29
|
-
i++;
|
|
30
|
-
|
|
31
|
-
args.splice(0, 1);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
i = (i + 1) * -1;
|
|
35
|
-
context = i ? this.get_context(i) : context;
|
|
36
|
-
|
|
37
|
-
arg = args.join("/");
|
|
38
|
-
|
|
39
|
-
while (arg.includes("^")) {
|
|
40
|
-
let blk = context.connections.slice(-1)[0];
|
|
41
|
-
if (!blk) break;
|
|
42
|
-
context = blk.chain;
|
|
43
|
-
let i = arg.indexOf("^");
|
|
44
|
-
arg = `${arg.slice(0, i)}${arg.slice(i + 1)}`;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
if (arg.startsWith("{*") && is_cursor) {
|
|
48
|
-
arg = context.explore(arg.slice(2, -1));
|
|
49
|
-
} else if (arg.startsWith("{") && !is_cursor) {
|
|
50
|
-
arg = context.explore(arg.slice(1, -1));
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return arg;
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
split_instruction = (instruction) => {
|
|
57
|
-
let split = instruction.split(" ");
|
|
58
|
-
let opcode = split[0],
|
|
59
|
-
args = split.slice(1).join(" ");
|
|
60
|
-
|
|
61
|
-
return { opcode, args };
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
execute = (instruction, track) => {
|
|
65
|
-
this.track = track;
|
|
66
|
-
|
|
67
|
-
if (!instruction) return;
|
|
68
|
-
|
|
69
|
-
let { opcode, args } = this.split_instruction(instruction);
|
|
70
|
-
|
|
71
|
-
let context = this.get_context();
|
|
72
|
-
|
|
73
|
-
if (!context) return;
|
|
74
|
-
|
|
75
|
-
context.add_tx(instruction);
|
|
76
|
-
|
|
77
|
-
// console.log(instruction);
|
|
78
|
-
|
|
79
|
-
let chain;
|
|
80
|
-
|
|
81
|
-
args = this.parse_arg(args, opcode === "cursor");
|
|
82
|
-
|
|
83
|
-
switch (opcode) {
|
|
84
|
-
case "chain":
|
|
85
|
-
chain = context.account.add_chain(args, context);
|
|
86
|
-
this.contexts.push(chain);
|
|
87
|
-
|
|
88
|
-
let dim = context.folder.config.dimensions;
|
|
89
|
-
if (!dim) {
|
|
90
|
-
dim = [];
|
|
91
|
-
context.folder.config.dimensions = dim;
|
|
92
|
-
}
|
|
93
|
-
!dim.find((d) => d === args) && dim.push(args);
|
|
94
|
-
|
|
95
|
-
chain.append_buffer();
|
|
96
|
-
|
|
97
|
-
break;
|
|
98
|
-
case "link":
|
|
99
|
-
chain = context.account.manager.web.get(args);
|
|
100
|
-
|
|
101
|
-
if (!chain) {
|
|
102
|
-
this.account.flush_buffer(this.track.pid, {
|
|
103
|
-
error: true,
|
|
104
|
-
error_message: `LINKing Failed. - ${args}`,
|
|
105
|
-
});
|
|
106
|
-
this.track.pointer = this.track.sequence.length;
|
|
107
|
-
|
|
108
|
-
console.log(`LINKing Failed. - ${args}`);
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
chain.append_buffer();
|
|
113
|
-
|
|
114
|
-
this.contexts.push(chain);
|
|
115
|
-
|
|
116
|
-
break;
|
|
117
|
-
case "mine":
|
|
118
|
-
let bloc = context.mine(this, true);
|
|
119
|
-
|
|
120
|
-
this.account.buff(bloc, this.track.pid);
|
|
121
|
-
|
|
122
|
-
break;
|
|
123
|
-
case "pop":
|
|
124
|
-
let blk;
|
|
125
|
-
if (context.txs.length > 1) {
|
|
126
|
-
blk = context.mine(this);
|
|
127
|
-
} else {
|
|
128
|
-
blk = context.get_latest_block();
|
|
129
|
-
if (blk) this.get_context(-2).connections.push(blk);
|
|
130
|
-
|
|
131
|
-
context.txs = [];
|
|
132
|
-
}
|
|
133
|
-
blk && this.account.buff(blk, this.track.pid);
|
|
134
|
-
|
|
135
|
-
this.contexts.pop();
|
|
136
|
-
break;
|
|
137
|
-
case "cursor":
|
|
138
|
-
context.set_cursor(args);
|
|
139
|
-
break;
|
|
140
|
-
case "write":
|
|
141
|
-
context.account.write(args, context);
|
|
142
|
-
break;
|
|
143
|
-
default:
|
|
144
|
-
this.prepare_operation(opcode, context);
|
|
145
|
-
break;
|
|
146
|
-
}
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
export default Virtual_machine;
|
|
147
|
+
return _createClass(Virtual_machine);
|
|
148
|
+
}(_Opcodes2["default"]);
|
|
149
|
+
var _default = Virtual_machine;
|
|
150
|
+
exports["default"] = _default;
|
package/framer.js
CHANGED
|
@@ -1,71 +1,64 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.obj = exports["default"] = void 0;
|
|
7
|
+
var _Frame = _interopRequireDefault(require("./Objects/Frame"));
|
|
8
|
+
var _Opcodes;
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
10
|
+
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); }
|
|
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 obj = {
|
|
15
|
+
Opcodes: (_Opcodes = {
|
|
5
16
|
add: null,
|
|
6
17
|
equal: null,
|
|
7
18
|
multiply: null,
|
|
8
19
|
subtract: null,
|
|
9
20
|
divide: null,
|
|
10
|
-
exp: null
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
send: null,
|
|
14
|
-
readonly: null,
|
|
15
|
-
socket_send: null,
|
|
16
|
-
|
|
17
|
-
jmp: null,
|
|
18
|
-
|
|
19
|
-
stdout: null,
|
|
20
|
-
stdin: null,
|
|
21
|
-
|
|
22
|
-
run: null,
|
|
23
|
-
load: null,
|
|
24
|
-
parse: null,
|
|
25
|
-
create_account: null,
|
|
26
|
-
},
|
|
21
|
+
exp: null
|
|
22
|
+
}, _defineProperty(_Opcodes, "equal", null), _defineProperty(_Opcodes, "send", null), _defineProperty(_Opcodes, "readonly", null), _defineProperty(_Opcodes, "socket_send", null), _defineProperty(_Opcodes, "jmp", null), _defineProperty(_Opcodes, "stdout", null), _defineProperty(_Opcodes, "stdin", null), _defineProperty(_Opcodes, "run", null), _defineProperty(_Opcodes, "load", null), _defineProperty(_Opcodes, "parse", null), _defineProperty(_Opcodes, "create_account", null), _Opcodes),
|
|
27
23
|
Datatypes: {
|
|
28
24
|
Number: null,
|
|
29
25
|
String: null,
|
|
30
26
|
Twain: null,
|
|
31
|
-
Array: null
|
|
27
|
+
Array: null
|
|
32
28
|
},
|
|
33
29
|
Objects: {
|
|
34
30
|
Blockchain: {
|
|
35
31
|
Chain: null,
|
|
36
|
-
Block: null
|
|
32
|
+
Block: null
|
|
37
33
|
},
|
|
38
34
|
Folder: {
|
|
39
35
|
active_file: null,
|
|
40
36
|
folder: null,
|
|
41
|
-
file: null
|
|
37
|
+
file: null
|
|
42
38
|
},
|
|
43
39
|
File: {
|
|
44
40
|
row: null,
|
|
45
41
|
parse: null,
|
|
46
42
|
column: null,
|
|
47
|
-
write: null
|
|
48
|
-
}
|
|
49
|
-
}
|
|
43
|
+
write: null
|
|
44
|
+
}
|
|
45
|
+
}
|
|
50
46
|
};
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
47
|
+
exports.obj = obj;
|
|
48
|
+
var framer = function framer(initiator, cb) {
|
|
49
|
+
var frame = new _Frame["default"](obj);
|
|
54
50
|
frame.to_instruction();
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
let start = Date.now();
|
|
51
|
+
var instructions = frame.flatten_instructions();
|
|
52
|
+
var start = Date.now();
|
|
58
53
|
initiator.load({
|
|
59
|
-
program: {
|
|
60
|
-
|
|
61
|
-
console.log(
|
|
62
|
-
`Account:${initiator.name} is ready in ${Date.now() - start}ms.`
|
|
63
|
-
);
|
|
64
|
-
|
|
65
|
-
cb && cb(blks);
|
|
54
|
+
program: {
|
|
55
|
+
instructions: instructions
|
|
66
56
|
},
|
|
57
|
+
callback: function callback(blks) {
|
|
58
|
+
console.log("Account:".concat(initiator.name, " is ready in ").concat(Date.now() - start, "ms."));
|
|
59
|
+
cb && cb(blks);
|
|
60
|
+
}
|
|
67
61
|
});
|
|
68
62
|
};
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
export { obj };
|
|
63
|
+
var _default = framer;
|
|
64
|
+
exports["default"] = _default;
|
package/opcodes/add.js
CHANGED
|
@@ -1,10 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
{ name: "add", sign: "+" },
|
|
3
|
-
{ name: "multiply", sign: "*" },
|
|
4
|
-
{ name: "subtract", sign: "-" },
|
|
5
|
-
{ name: "divide", sign: "/" },
|
|
6
|
-
{ name: "exp", sign: "**" },
|
|
7
|
-
{ name: "equal", sign: "==" },
|
|
8
|
-
];
|
|
1
|
+
"use strict";
|
|
9
2
|
|
|
10
|
-
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ops = void 0;
|
|
7
|
+
var ops = [{
|
|
8
|
+
name: "add",
|
|
9
|
+
sign: "+"
|
|
10
|
+
}, {
|
|
11
|
+
name: "multiply",
|
|
12
|
+
sign: "*"
|
|
13
|
+
}, {
|
|
14
|
+
name: "subtract",
|
|
15
|
+
sign: "-"
|
|
16
|
+
}, {
|
|
17
|
+
name: "divide",
|
|
18
|
+
sign: "/"
|
|
19
|
+
}, {
|
|
20
|
+
name: "exp",
|
|
21
|
+
sign: "**"
|
|
22
|
+
}, {
|
|
23
|
+
name: "equal",
|
|
24
|
+
sign: "=="
|
|
25
|
+
}];
|
|
26
|
+
exports.ops = ops;
|
package/opcodes/indices.js
CHANGED
|
@@ -1,28 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
let base = args.op0;
|
|
3
|
-
if (typeof base === "number") return base;
|
|
1
|
+
"use strict";
|
|
4
2
|
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.setter = exports.getter = void 0;
|
|
7
|
+
var getter = function getter(args) {
|
|
8
|
+
var base = args.op0;
|
|
9
|
+
if (typeof base === "number") return base;
|
|
5
10
|
if (typeof base === "string") return base[args.op1];
|
|
6
|
-
|
|
7
11
|
if (Array.isArray(base)) return base.slice(args.op1)[0];
|
|
8
|
-
|
|
9
12
|
return base[args.op1];
|
|
10
13
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
exports.getter = getter;
|
|
15
|
+
var setter = function setter(args) {
|
|
16
|
+
var base = args.op0;
|
|
14
17
|
if (typeof base === "number") return base;
|
|
15
|
-
|
|
16
18
|
if (typeof base === "string") {
|
|
17
|
-
base =
|
|
19
|
+
base = "".concat(base.slice(0, args.op2)).concat(args.op1).concat(base.slice(args.op2 + 1));
|
|
18
20
|
} else {
|
|
19
21
|
if (Array.isArray(base)) {
|
|
20
|
-
if (args.op2 == null || args.op2 >= base.length) base.push(args.op1);
|
|
21
|
-
else base[args.op2] = args.op1;
|
|
22
|
+
if (args.op2 == null || args.op2 >= base.length) base.push(args.op1);else base[args.op2] = args.op1;
|
|
22
23
|
} else base[args.op2] = args.op1;
|
|
23
24
|
}
|
|
24
|
-
|
|
25
25
|
return base;
|
|
26
26
|
};
|
|
27
|
-
|
|
28
|
-
export { setter, getter };
|
|
27
|
+
exports.setter = setter;
|
package/opcodes/jmp.js
CHANGED
|
@@ -1,14 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
meta = meta || {};
|
|
3
|
-
let { flag, inverse } = meta;
|
|
1
|
+
"use strict";
|
|
4
2
|
|
|
5
|
-
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.jmp = void 0;
|
|
7
|
+
var jmp = function jmp(args, vm, meta) {
|
|
8
|
+
meta = meta || {};
|
|
9
|
+
var _meta = meta,
|
|
10
|
+
flag = _meta.flag,
|
|
11
|
+
inverse = _meta.inverse;
|
|
12
|
+
var condition;
|
|
6
13
|
if (flag) condition = vm.flags[flag];
|
|
7
14
|
if (inverse) condition = !!!condition;
|
|
8
|
-
|
|
9
15
|
if ((condition || !flag) && typeof args.op0 === "number") {
|
|
10
16
|
vm.track.pointer = args.op0;
|
|
11
17
|
}
|
|
12
18
|
};
|
|
13
|
-
|
|
14
|
-
export { jmp };
|
|
19
|
+
exports.jmp = jmp;
|
package/opcodes/std.js
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
if (!args) return;
|
|
3
|
-
|
|
4
|
-
vm.account.stdout.push({ data: args, pid: vm.track.pid });
|
|
1
|
+
"use strict";
|
|
5
2
|
|
|
6
|
-
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.stdout = void 0;
|
|
7
|
+
var stdout = function stdout(args, vm) {
|
|
8
|
+
if (!args) return;
|
|
9
|
+
vm.account.stdout.push({
|
|
10
|
+
data: args,
|
|
11
|
+
pid: vm.track.pid
|
|
12
|
+
});
|
|
13
|
+
for (var v in args) console.log(args[v]);
|
|
7
14
|
};
|
|
8
|
-
|
|
9
|
-
export { stdout };
|
|
15
|
+
exports.stdout = stdout;
|
package/opcodes.js
CHANGED
|
@@ -1,58 +1,75 @@
|
|
|
1
|
-
|
|
2
|
-
import { ops } from "./opcodes/add";
|
|
3
|
-
import { getter, setter } from "./opcodes/indices";
|
|
4
|
-
import { jmp } from "./opcodes/jmp";
|
|
5
|
-
import { stdout } from "./opcodes/std";
|
|
6
|
-
import { post_request } from "./utils/services";
|
|
1
|
+
"use strict";
|
|
7
2
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = void 0;
|
|
7
|
+
var _add = require("./opcodes/add");
|
|
8
|
+
var _indices = require("./opcodes/indices");
|
|
9
|
+
var _jmp = require("./opcodes/jmp");
|
|
10
|
+
var _std = require("./opcodes/std");
|
|
11
|
+
var _services = require("./utils/services");
|
|
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 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; }
|
|
14
|
+
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; }
|
|
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); } // import { socket_send } from "./Socket";
|
|
18
|
+
var opcodes = function opcodes(account) {
|
|
19
|
+
var set = account.vm.set;
|
|
20
|
+
_add.ops.map(function (op) {
|
|
21
|
+
set(op.name, function (args) {
|
|
13
22
|
if (!args) return;
|
|
14
|
-
|
|
15
23
|
try {
|
|
16
|
-
|
|
24
|
+
var result = eval("".concat(args.op0, " ").concat(op.sign, " ").concat(args.op1));
|
|
17
25
|
if (op.sign === "==") {
|
|
18
26
|
account.vm.flags.equal = !!result;
|
|
19
27
|
return;
|
|
20
28
|
}
|
|
21
|
-
|
|
22
29
|
return result;
|
|
23
30
|
} catch (e) {
|
|
24
31
|
console.log(e.message);
|
|
25
32
|
}
|
|
26
33
|
});
|
|
27
34
|
});
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
);
|
|
35
|
+
Object.keys(account.vm.flags).map(function (flag) {
|
|
36
|
+
set("jmp_".concat(flag), function (args, vm) {
|
|
37
|
+
return (0, _jmp.jmp)(args, vm, {
|
|
38
|
+
flag: flag
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
set("jmp_not_".concat(flag), function (args, vm) {
|
|
42
|
+
return (0, _jmp.jmp)(args, vm, {
|
|
43
|
+
flag: flag,
|
|
44
|
+
inverse: true
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
set("jmp", _jmp.jmp);
|
|
49
|
+
set("setter", _indices.setter);
|
|
50
|
+
set("getter", _indices.getter);
|
|
51
|
+
set("send", function (data) {
|
|
52
|
+
return (0, _services.post_request)(data, account.vm.stdin);
|
|
34
53
|
});
|
|
35
|
-
set("jmp", jmp);
|
|
36
|
-
|
|
37
|
-
set("setter", setter);
|
|
38
|
-
set("getter", getter);
|
|
39
|
-
|
|
40
|
-
set("send", (data) => post_request(data, account.vm.stdin));
|
|
41
54
|
// set("socket_send", socket_send);
|
|
42
55
|
|
|
43
|
-
set("stdout", stdout);
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
set("add_server", (args)
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
)
|
|
56
|
+
set("stdout", _std.stdout);
|
|
57
|
+
set("hold", function (arg) {
|
|
58
|
+
return vm.track.hold = !!arg.op0;
|
|
59
|
+
});
|
|
60
|
+
set("add_server", function (args) {
|
|
61
|
+
return account.add_server(args && args.op0);
|
|
62
|
+
});
|
|
63
|
+
["run", "load", "parse"].map(function (op) {
|
|
64
|
+
return set(op, function (arg) {
|
|
65
|
+
return arg && arg.op0 && manager.endpoint(op, arg && arg.op0);
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
set("add_account", function (arg) {
|
|
69
|
+
return manager.add_account(_objectSpread(_objectSpread({}, arg.op0), {}, {
|
|
70
|
+
string: true
|
|
71
|
+
}));
|
|
72
|
+
});
|
|
56
73
|
};
|
|
57
|
-
|
|
58
|
-
|
|
74
|
+
var _default = opcodes;
|
|
75
|
+
exports["default"] = _default;
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "godprotocol",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.841",
|
|
4
4
|
"description": "A data mediator.",
|
|
5
5
|
"main": "Index.js",
|
|
6
6
|
"types": "types/index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
9
9
|
"start": "nodemon -r esm Index.js",
|
|
10
|
+
"build": "babel ./Loader_sequence/main.js ./Loader_sequence/repository.js ./Objects/Block.js ./Objects/Account.js ./Objects/Blockweb.js ./Objects/Chain.js ./Objects/Frame.js ./Objects/Manager.js ./Objects/Explorer.js ./Objects/Virtual_machine.js ./Objects/Oracle.js ./Objects/Filesystem.js ./Objects/Opcodes.js ./utils/create_server.js ./utils/functions.js ./utils/hash.js ./utils/privacy.js ./utils/services.js ./opcodes/add.js ./opcodes/indices.js ./opcodes/jmp.js ./opcodes/std.js ./framer.js ./opcodes.js ./Index.js -d build",
|
|
10
11
|
"prepack": "npmignore"
|
|
11
12
|
},
|
|
12
13
|
"author": "Savvy",
|
|
@@ -46,7 +47,7 @@
|
|
|
46
47
|
"crypto": "^1.0.1",
|
|
47
48
|
"elliptic": "^6.5.5",
|
|
48
49
|
"fs": "^0.0.1-security",
|
|
49
|
-
"generalised-datastore": "^2.0.
|
|
50
|
+
"generalised-datastore": "^2.0.12"
|
|
50
51
|
},
|
|
51
52
|
"publishConfig": {
|
|
52
53
|
"ignore": [
|