godprotocol 1.0.841 → 1.0.842
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 +15 -17
- package/Loader_sequence/main.js +447 -292
- package/Loader_sequence/repository.js +27 -43
- package/Objects/Account.js +262 -237
- package/Objects/Block.js +78 -76
- package/Objects/Blockweb.js +36 -40
- package/Objects/Chain.js +164 -157
- package/Objects/Explorer.js +36 -39
- package/Objects/Filesystem.js +99 -82
- package/Objects/Frame.js +43 -48
- package/Objects/Manager.js +115 -108
- package/Objects/Opcodes.js +44 -44
- package/Objects/Oracle.js +93 -129
- package/Objects/Virtual_machine.js +145 -145
- package/framer.js +42 -35
- package/opcodes/add.js +9 -25
- package/opcodes/indices.js +15 -14
- package/opcodes/jmp.js +7 -12
- package/opcodes/std.js +7 -13
- package/opcodes.js +41 -58
- package/package.json +2 -3
- package/utils/create_server.js +71 -106
- package/utils/functions.js +31 -43
- package/utils/hash.js +10 -11
- package/utils/privacy.js +10 -15
- package/utils/services.js +32 -33
|
@@ -1,150 +1,150 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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 = {
|
|
1
|
+
import Opcodes from "./Opcodes";
|
|
2
|
+
|
|
3
|
+
class Virtual_machine extends Opcodes {
|
|
4
|
+
constructor(context) {
|
|
5
|
+
super();
|
|
6
|
+
|
|
7
|
+
this.account = context.account;
|
|
8
|
+
this.contexts = [context];
|
|
9
|
+
this.stack = new Array();
|
|
10
|
+
this.flags = {
|
|
140
11
|
neg: false,
|
|
141
12
|
equal: false,
|
|
142
13
|
zero: false,
|
|
143
|
-
|
|
14
|
+
void: false,
|
|
144
15
|
};
|
|
145
|
-
return _this;
|
|
146
16
|
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
17
|
+
|
|
18
|
+
get_context = (index) => {
|
|
19
|
+
return this.contexts.slice(index == null ? -1 : index)[0];
|
|
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;
|
package/framer.js
CHANGED
|
@@ -1,64 +1,71 @@
|
|
|
1
|
-
|
|
1
|
+
import Frame from "./Objects/Frame";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
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 = {
|
|
3
|
+
let obj = {
|
|
4
|
+
Opcodes: {
|
|
16
5
|
add: null,
|
|
17
6
|
equal: null,
|
|
18
7
|
multiply: null,
|
|
19
8
|
subtract: null,
|
|
20
9
|
divide: null,
|
|
21
|
-
exp: null
|
|
22
|
-
|
|
10
|
+
exp: null,
|
|
11
|
+
equal: null,
|
|
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
|
+
},
|
|
23
27
|
Datatypes: {
|
|
24
28
|
Number: null,
|
|
25
29
|
String: null,
|
|
26
30
|
Twain: null,
|
|
27
|
-
Array: null
|
|
31
|
+
Array: null,
|
|
28
32
|
},
|
|
29
33
|
Objects: {
|
|
30
34
|
Blockchain: {
|
|
31
35
|
Chain: null,
|
|
32
|
-
Block: null
|
|
36
|
+
Block: null,
|
|
33
37
|
},
|
|
34
38
|
Folder: {
|
|
35
39
|
active_file: null,
|
|
36
40
|
folder: null,
|
|
37
|
-
file: null
|
|
41
|
+
file: null,
|
|
38
42
|
},
|
|
39
43
|
File: {
|
|
40
44
|
row: null,
|
|
41
45
|
parse: null,
|
|
42
46
|
column: null,
|
|
43
|
-
write: null
|
|
44
|
-
}
|
|
45
|
-
}
|
|
47
|
+
write: null,
|
|
48
|
+
},
|
|
49
|
+
},
|
|
46
50
|
};
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
51
|
+
|
|
52
|
+
const framer = (initiator, cb) => {
|
|
53
|
+
let frame = new Frame(obj);
|
|
50
54
|
frame.to_instruction();
|
|
51
|
-
|
|
52
|
-
|
|
55
|
+
let instructions = frame.flatten_instructions();
|
|
56
|
+
|
|
57
|
+
let start = Date.now();
|
|
53
58
|
initiator.load({
|
|
54
|
-
program: {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
+
program: { instructions },
|
|
60
|
+
callback: (blks) => {
|
|
61
|
+
console.log(
|
|
62
|
+
`Account:${initiator.name} is ready in ${Date.now() - start}ms.`
|
|
63
|
+
);
|
|
64
|
+
|
|
59
65
|
cb && cb(blks);
|
|
60
|
-
}
|
|
66
|
+
},
|
|
61
67
|
});
|
|
62
68
|
};
|
|
63
|
-
|
|
64
|
-
|
|
69
|
+
|
|
70
|
+
export default framer;
|
|
71
|
+
export { obj };
|
package/opcodes/add.js
CHANGED
|
@@ -1,26 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
let ops = [
|
|
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
|
+
];
|
|
2
9
|
|
|
3
|
-
|
|
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;
|
|
10
|
+
export { ops };
|
package/opcodes/indices.js
CHANGED
|
@@ -1,27 +1,28 @@
|
|
|
1
|
-
|
|
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;
|
|
1
|
+
const getter = (args) => {
|
|
2
|
+
let base = args.op0;
|
|
9
3
|
if (typeof base === "number") return base;
|
|
4
|
+
|
|
10
5
|
if (typeof base === "string") return base[args.op1];
|
|
6
|
+
|
|
11
7
|
if (Array.isArray(base)) return base.slice(args.op1)[0];
|
|
8
|
+
|
|
12
9
|
return base[args.op1];
|
|
13
10
|
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
|
|
12
|
+
const setter = (args) => {
|
|
13
|
+
let base = args.op0;
|
|
17
14
|
if (typeof base === "number") return base;
|
|
15
|
+
|
|
18
16
|
if (typeof base === "string") {
|
|
19
|
-
base =
|
|
17
|
+
base = `${base.slice(0, args.op2)}${args.op1}${base.slice(args.op2 + 1)}`;
|
|
20
18
|
} else {
|
|
21
19
|
if (Array.isArray(base)) {
|
|
22
|
-
if (args.op2 == null || args.op2 >= base.length) base.push(args.op1);
|
|
20
|
+
if (args.op2 == null || args.op2 >= base.length) base.push(args.op1);
|
|
21
|
+
else base[args.op2] = args.op1;
|
|
23
22
|
} else base[args.op2] = args.op1;
|
|
24
23
|
}
|
|
24
|
+
|
|
25
25
|
return base;
|
|
26
26
|
};
|
|
27
|
-
|
|
27
|
+
|
|
28
|
+
export { setter, getter };
|
package/opcodes/jmp.js
CHANGED
|
@@ -1,19 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.jmp = void 0;
|
|
7
|
-
var jmp = function jmp(args, vm, meta) {
|
|
1
|
+
const jmp = (args, vm, meta) => {
|
|
8
2
|
meta = meta || {};
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var condition;
|
|
3
|
+
let { flag, inverse } = meta;
|
|
4
|
+
|
|
5
|
+
let condition;
|
|
13
6
|
if (flag) condition = vm.flags[flag];
|
|
14
7
|
if (inverse) condition = !!!condition;
|
|
8
|
+
|
|
15
9
|
if ((condition || !flag) && typeof args.op0 === "number") {
|
|
16
10
|
vm.track.pointer = args.op0;
|
|
17
11
|
}
|
|
18
12
|
};
|
|
19
|
-
|
|
13
|
+
|
|
14
|
+
export { jmp };
|
package/opcodes/std.js
CHANGED
|
@@ -1,15 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.stdout = void 0;
|
|
7
|
-
var stdout = function stdout(args, vm) {
|
|
1
|
+
const stdout = (args, vm) => {
|
|
8
2
|
if (!args) return;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
for (var v in args) console.log(args[v]);
|
|
3
|
+
|
|
4
|
+
vm.account.stdout.push({ data: args, pid: vm.track.pid });
|
|
5
|
+
|
|
6
|
+
for (let v in args) console.log(args[v]);
|
|
14
7
|
};
|
|
15
|
-
|
|
8
|
+
|
|
9
|
+
export { stdout };
|
package/opcodes.js
CHANGED
|
@@ -1,75 +1,58 @@
|
|
|
1
|
-
|
|
1
|
+
// import { socket_send } from "./Socket";
|
|
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";
|
|
2
7
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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) {
|
|
8
|
+
const opcodes = (account) => {
|
|
9
|
+
let set = account.vm.set;
|
|
10
|
+
|
|
11
|
+
ops.map((op) => {
|
|
12
|
+
set(op.name, (args) => {
|
|
22
13
|
if (!args) return;
|
|
14
|
+
|
|
23
15
|
try {
|
|
24
|
-
|
|
16
|
+
let result = eval(`${args.op0} ${op.sign} ${args.op1}`);
|
|
25
17
|
if (op.sign === "==") {
|
|
26
18
|
account.vm.flags.equal = !!result;
|
|
27
19
|
return;
|
|
28
20
|
}
|
|
21
|
+
|
|
29
22
|
return result;
|
|
30
23
|
} catch (e) {
|
|
31
24
|
console.log(e.message);
|
|
32
25
|
}
|
|
33
26
|
});
|
|
34
27
|
});
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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);
|
|
28
|
+
|
|
29
|
+
Object.keys(account.vm.flags).map((flag) => {
|
|
30
|
+
set(`jmp_${flag}`, (args, vm) => jmp(args, vm, { flag }));
|
|
31
|
+
set(`jmp_not_${flag}`, (args, vm) =>
|
|
32
|
+
jmp(args, vm, { flag, inverse: true })
|
|
33
|
+
);
|
|
53
34
|
});
|
|
35
|
+
set("jmp", jmp);
|
|
36
|
+
|
|
37
|
+
set("setter", setter);
|
|
38
|
+
set("getter", getter);
|
|
39
|
+
|
|
40
|
+
set("send", (data) => post_request(data, account.vm.stdin));
|
|
54
41
|
// set("socket_send", socket_send);
|
|
55
42
|
|
|
56
|
-
set("stdout",
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
set("add_server",
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
return manager.add_account(_objectSpread(_objectSpread({}, arg.op0), {}, {
|
|
70
|
-
string: true
|
|
71
|
-
}));
|
|
72
|
-
});
|
|
43
|
+
set("stdout", stdout);
|
|
44
|
+
|
|
45
|
+
set("hold", (arg) => (vm.track.hold = !!arg.op0));
|
|
46
|
+
|
|
47
|
+
set("add_server", (args) => account.add_server(args && args.op0));
|
|
48
|
+
|
|
49
|
+
["run", "load", "parse"].map((op) =>
|
|
50
|
+
set(op, (arg) => arg && arg.op0 && manager.endpoint(op, arg && arg.op0))
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
set("add_account", (arg) =>
|
|
54
|
+
manager.add_account({ ...arg.op0, string: true })
|
|
55
|
+
);
|
|
73
56
|
};
|
|
74
|
-
|
|
75
|
-
|
|
57
|
+
|
|
58
|
+
export default opcodes;
|
package/package.json
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "godprotocol",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.842",
|
|
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",
|
|
11
10
|
"prepack": "npmignore"
|
|
12
11
|
},
|
|
13
12
|
"author": "Savvy",
|
|
@@ -47,7 +46,7 @@
|
|
|
47
46
|
"crypto": "^1.0.1",
|
|
48
47
|
"elliptic": "^6.5.5",
|
|
49
48
|
"fs": "^0.0.1-security",
|
|
50
|
-
"generalised-datastore": "^2.0.
|
|
49
|
+
"generalised-datastore": "^2.0.13"
|
|
51
50
|
},
|
|
52
51
|
"publishConfig": {
|
|
53
52
|
"ignore": [
|