godprotocol 1.0.771 → 1.0.783
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 +0 -3
- package/Loader_sequence/main.js +460 -65
- package/Objects/Account.js +23 -20
- package/Objects/Block.js +4 -1
- package/Objects/Chain.js +8 -1
- package/Objects/Filesystem.js +11 -15
- package/Objects/Manager.js +174 -37
- package/Objects/Opcodes.js +5 -3
- package/Objects/Oracle.js +10 -0
- package/Objects/Virtual_machine.js +1 -7
- package/framer.js +2 -4
- package/opcodes/std.js +2 -1
- package/opcodes.js +6 -4
- package/package.json +7 -4
- package/readme.md +1 -1
- package/utils/services.js +1 -1
- package/Loader_sequence/functions/parse_expression.js +0 -107
- package/Loader_sequence/functions/parse_to_obj.js +0 -38
- package/Loader_sequence/functions/parse_variable.js +0 -38
- package/Loader_sequence/functions/tokenise.js +0 -135
- package/Loader_sequence/functions/utils.js +0 -14
- package/Loader_sequence/keywords/parse.js +0 -23
- package/Loader_sequence/native_classes/Variable.js +0 -49
- package/Loader_sequence/native_classes/datatypes/Array.js +0 -56
- package/Loader_sequence/native_classes/datatypes/Boolean.js +0 -42
- package/Loader_sequence/native_classes/datatypes/Number.js +0 -42
- package/Loader_sequence/native_classes/datatypes/String.js +0 -42
- package/Loader_sequence/native_classes/datatypes/Twain.js +0 -65
- package/Loader_sequence/native_classes/datatypes/Void.js +0 -42
- package/Loader_sequence/native_classes/global.js +0 -48
- package/Loader_sequence/native_classes/native.js +0 -63
- package/Loader_sequence/native_classes/operators.js +0 -64
- package/Loader_sequence/native_classes/parse.js +0 -54
- package/Loader_sequence/utils/format_instructions.js +0 -52
package/Objects/Filesystem.js
CHANGED
|
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = void 0;
|
|
7
|
-
var _fs = _interopRequireDefault(require("fs"));
|
|
8
7
|
var _hash = require("../utils/hash");
|
|
9
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
10
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); }
|
|
11
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); } }
|
|
12
10
|
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
@@ -25,7 +23,6 @@ var Filesystem = /*#__PURE__*/_createClass(function Filesystem() {
|
|
|
25
23
|
if (!datapath) return null;
|
|
26
24
|
var type_folder = _this.account.manager.oracle.get(datapath);
|
|
27
25
|
if (!type_folder) return datapath;
|
|
28
|
-
type_folder.obj = JSON.parse(type_folder.obj);
|
|
29
26
|
var content;
|
|
30
27
|
if (type_folder.type === "twain") {
|
|
31
28
|
content = {};
|
|
@@ -36,7 +33,7 @@ var Filesystem = /*#__PURE__*/_createClass(function Filesystem() {
|
|
|
36
33
|
} else if (type_folder.type === "array") {
|
|
37
34
|
content = [];
|
|
38
35
|
type_folder.obj.map(function (t) {
|
|
39
|
-
content.push(
|
|
36
|
+
content.push(_this.parse_path(t));
|
|
40
37
|
});
|
|
41
38
|
} else content = type_folder.obj;
|
|
42
39
|
return content;
|
|
@@ -56,17 +53,15 @@ var Filesystem = /*#__PURE__*/_createClass(function Filesystem() {
|
|
|
56
53
|
obj[_curs] = content[_curs];
|
|
57
54
|
}
|
|
58
55
|
} else if (type === "number") {
|
|
59
|
-
obj = Number(content["-1"])
|
|
56
|
+
obj = Number(content["-1"]);
|
|
57
|
+
if (isNaN(obj)) obj = -1;
|
|
60
58
|
} else {
|
|
61
|
-
|
|
62
|
-
if (content === "True") obj = true;else if (content === "False") obj = false;else obj = null;
|
|
59
|
+
obj = null;
|
|
63
60
|
}
|
|
64
61
|
if (just_obj) return obj;
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
encoding: "utf-8"
|
|
69
|
-
});
|
|
62
|
+
addr = "".concat(chain.path, "/").concat((0, _hash.hash)(JSON.stringify(obj)));
|
|
63
|
+
_this;
|
|
64
|
+
if (obj != null) _this.manager.oracle.write(addr, obj);
|
|
70
65
|
_this.manager.oracle.set(addr, {
|
|
71
66
|
obj: obj,
|
|
72
67
|
type: type
|
|
@@ -96,7 +91,7 @@ var Filesystem = /*#__PURE__*/_createClass(function Filesystem() {
|
|
|
96
91
|
var content = context.get_buffer();
|
|
97
92
|
if (!content || !arg) return;
|
|
98
93
|
content[context.cursor] = arg;
|
|
99
|
-
//
|
|
94
|
+
// console.log(`Writing: ${arg}`);
|
|
100
95
|
});
|
|
101
96
|
_defineProperty(this, "name_hash", function () {
|
|
102
97
|
_this.hash = (0, _hash.hash)(_this.name);
|
|
@@ -107,8 +102,9 @@ var Filesystem = /*#__PURE__*/_createClass(function Filesystem() {
|
|
|
107
102
|
return;
|
|
108
103
|
}
|
|
109
104
|
chain.path = "".concat(chain.parent ? chain.parent.path : _this.base_address, "/").concat(chain.hash);
|
|
110
|
-
|
|
111
|
-
|
|
105
|
+
var fs = _this.manager.oracle.fs;
|
|
106
|
+
if (!fs.existsSync(chain.path)) {
|
|
107
|
+
fs.mkdirSync(chain.path, {
|
|
112
108
|
recursive: true
|
|
113
109
|
});
|
|
114
110
|
}
|
package/Objects/Manager.js
CHANGED
|
@@ -1,49 +1,176 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
4
|
+
value: true,
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = void 0;
|
|
7
|
-
var
|
|
7
|
+
var _Index = _interopRequireDefault(require("../Index"));
|
|
8
8
|
var _Blockweb = _interopRequireDefault(require("./Blockweb"));
|
|
9
9
|
var _Oracle = _interopRequireDefault(require("./Oracle"));
|
|
10
|
-
function _interopRequireDefault(e) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
function
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
function
|
|
18
|
-
function
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
function
|
|
22
|
-
|
|
23
|
-
function
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
10
|
+
function _interopRequireDefault(e) {
|
|
11
|
+
return e && e.__esModule ? e : { default: e };
|
|
12
|
+
}
|
|
13
|
+
function _typeof(o) {
|
|
14
|
+
"@babel/helpers - typeof";
|
|
15
|
+
return (
|
|
16
|
+
(_typeof =
|
|
17
|
+
"function" == typeof Symbol && "symbol" == typeof Symbol.iterator
|
|
18
|
+
? function (o) {
|
|
19
|
+
return typeof o;
|
|
20
|
+
}
|
|
21
|
+
: function (o) {
|
|
22
|
+
return o &&
|
|
23
|
+
"function" == typeof Symbol &&
|
|
24
|
+
o.constructor === Symbol &&
|
|
25
|
+
o !== Symbol.prototype
|
|
26
|
+
? "symbol"
|
|
27
|
+
: typeof o;
|
|
28
|
+
}),
|
|
29
|
+
_typeof(o)
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
function ownKeys(e, r) {
|
|
33
|
+
var t = Object.keys(e);
|
|
34
|
+
if (Object.getOwnPropertySymbols) {
|
|
35
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
36
|
+
r &&
|
|
37
|
+
(o = o.filter(function (r) {
|
|
38
|
+
return Object.getOwnPropertyDescriptor(e, r).enumerable;
|
|
39
|
+
})),
|
|
40
|
+
t.push.apply(t, o);
|
|
41
|
+
}
|
|
42
|
+
return t;
|
|
43
|
+
}
|
|
44
|
+
function _objectSpread(e) {
|
|
45
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
46
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
47
|
+
r % 2
|
|
48
|
+
? ownKeys(Object(t), !0).forEach(function (r) {
|
|
49
|
+
_defineProperty(e, r, t[r]);
|
|
50
|
+
})
|
|
51
|
+
: Object.getOwnPropertyDescriptors
|
|
52
|
+
? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t))
|
|
53
|
+
: ownKeys(Object(t)).forEach(function (r) {
|
|
54
|
+
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
return e;
|
|
58
|
+
}
|
|
59
|
+
function _toConsumableArray(r) {
|
|
60
|
+
return (
|
|
61
|
+
_arrayWithoutHoles(r) ||
|
|
62
|
+
_iterableToArray(r) ||
|
|
63
|
+
_unsupportedIterableToArray(r) ||
|
|
64
|
+
_nonIterableSpread()
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
function _nonIterableSpread() {
|
|
68
|
+
throw new TypeError(
|
|
69
|
+
"Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
function _unsupportedIterableToArray(r, a) {
|
|
73
|
+
if (r) {
|
|
74
|
+
if ("string" == typeof r) return _arrayLikeToArray(r, a);
|
|
75
|
+
var t = {}.toString.call(r).slice(8, -1);
|
|
76
|
+
return (
|
|
77
|
+
"Object" === t && r.constructor && (t = r.constructor.name),
|
|
78
|
+
"Map" === t || "Set" === t
|
|
79
|
+
? Array.from(r)
|
|
80
|
+
: "Arguments" === t ||
|
|
81
|
+
/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)
|
|
82
|
+
? _arrayLikeToArray(r, a)
|
|
83
|
+
: void 0
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
function _iterableToArray(r) {
|
|
88
|
+
if (
|
|
89
|
+
("undefined" != typeof Symbol && null != r[Symbol.iterator]) ||
|
|
90
|
+
null != r["@@iterator"]
|
|
91
|
+
)
|
|
92
|
+
return Array.from(r);
|
|
93
|
+
}
|
|
94
|
+
function _arrayWithoutHoles(r) {
|
|
95
|
+
if (Array.isArray(r)) return _arrayLikeToArray(r);
|
|
96
|
+
}
|
|
97
|
+
function _arrayLikeToArray(r, a) {
|
|
98
|
+
(null == a || a > r.length) && (a = r.length);
|
|
99
|
+
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
100
|
+
return n;
|
|
101
|
+
}
|
|
102
|
+
function _defineProperties(e, r) {
|
|
103
|
+
for (var t = 0; t < r.length; t++) {
|
|
104
|
+
var o = r[t];
|
|
105
|
+
(o.enumerable = o.enumerable || !1),
|
|
106
|
+
(o.configurable = !0),
|
|
107
|
+
"value" in o && (o.writable = !0),
|
|
108
|
+
Object.defineProperty(e, _toPropertyKey(o.key), o);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
function _createClass(e, r, t) {
|
|
112
|
+
return (
|
|
113
|
+
r && _defineProperties(e.prototype, r),
|
|
114
|
+
t && _defineProperties(e, t),
|
|
115
|
+
Object.defineProperty(e, "prototype", { writable: !1 }),
|
|
116
|
+
e
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
function _classCallCheck(a, n) {
|
|
120
|
+
if (!(a instanceof n))
|
|
121
|
+
throw new TypeError("Cannot call a class as a function");
|
|
122
|
+
}
|
|
123
|
+
function _defineProperty(e, r, t) {
|
|
124
|
+
return (
|
|
125
|
+
(r = _toPropertyKey(r)) in e
|
|
126
|
+
? Object.defineProperty(e, r, {
|
|
127
|
+
value: t,
|
|
128
|
+
enumerable: !0,
|
|
129
|
+
configurable: !0,
|
|
130
|
+
writable: !0,
|
|
131
|
+
})
|
|
132
|
+
: (e[r] = t),
|
|
133
|
+
e
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
function _toPropertyKey(t) {
|
|
137
|
+
var i = _toPrimitive(t, "string");
|
|
138
|
+
return "symbol" == _typeof(i) ? i : i + "";
|
|
139
|
+
}
|
|
140
|
+
function _toPrimitive(t, r) {
|
|
141
|
+
if ("object" != _typeof(t) || !t) return t;
|
|
142
|
+
var e = t[Symbol.toPrimitive];
|
|
143
|
+
if (void 0 !== e) {
|
|
144
|
+
var i = e.call(t, r || "default");
|
|
145
|
+
if ("object" != _typeof(i)) return i;
|
|
146
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
147
|
+
}
|
|
148
|
+
return ("string" === r ? String : Number)(t);
|
|
149
|
+
}
|
|
150
|
+
var Manager = /*#__PURE__*/ _createClass(function Manager() {
|
|
27
151
|
var _this = this;
|
|
28
152
|
_classCallCheck(this, Manager);
|
|
29
153
|
_defineProperty(this, "start_clock", function () {
|
|
30
|
-
|
|
154
|
+
var frequency = Number(process.env.HERTS) || 10;
|
|
155
|
+
_this.clock = setInterval(function () {
|
|
31
156
|
for (var account in _this.tracks) {
|
|
32
157
|
var track = _this.tracks[account];
|
|
33
158
|
var instruction = track.sequence[track.pointer];
|
|
34
159
|
track.account.vm.execute(instruction, track);
|
|
35
160
|
track.pointer++;
|
|
36
|
-
if (track.breakpoint.slice(-1)[0] === track.pointer) {
|
|
37
|
-
track.account.flush_buffer(track.pid);
|
|
38
|
-
track.pid = track.pids.splice(-1)[0];
|
|
39
|
-
}
|
|
40
161
|
if (track.pointer === track.sequence.length) {
|
|
41
162
|
_this.running--;
|
|
163
|
+
track.account.chain.mine(track.account.vm);
|
|
164
|
+
track.account.flush_buffer(track.pids.splice(-1)[0]);
|
|
42
165
|
delete _this.tracks[account];
|
|
43
166
|
}
|
|
167
|
+
if (track.breakpoint.slice(-1)[0] === track.pointer) {
|
|
168
|
+
track.account.flush_buffer(track.pids.slice(-1));
|
|
169
|
+
track.pid = track.pids.splice(-1)[0];
|
|
170
|
+
}
|
|
44
171
|
}
|
|
45
172
|
!_this.running && clearInterval(_this.clock);
|
|
46
|
-
},
|
|
173
|
+
}, frequency);
|
|
47
174
|
});
|
|
48
175
|
_defineProperty(this, "get_account", function (name) {
|
|
49
176
|
return _this.accounts[name];
|
|
@@ -51,10 +178,8 @@ var Manager = /*#__PURE__*/_createClass(function Manager() {
|
|
|
51
178
|
_defineProperty(this, "add_account", function (name, meta) {
|
|
52
179
|
var account = _this.get_account(name);
|
|
53
180
|
if (!account) {
|
|
54
|
-
account =
|
|
55
|
-
|
|
56
|
-
}));
|
|
57
|
-
_this.accounts[name] = account;
|
|
181
|
+
account = (0, _Index["default"])(name, meta);
|
|
182
|
+
_this.accounts[account.name] = account;
|
|
58
183
|
} else if (meta && meta["private"] && !account["private"]) {
|
|
59
184
|
account["private"] = true;
|
|
60
185
|
}
|
|
@@ -64,15 +189,27 @@ var Manager = /*#__PURE__*/_createClass(function Manager() {
|
|
|
64
189
|
var track = _this.tracks[program.account.name];
|
|
65
190
|
if (track) {
|
|
66
191
|
var _track$sequence;
|
|
67
|
-
track.breakpoint.push(track.pointer
|
|
68
|
-
(_track$sequence = track.sequence).splice.apply(
|
|
192
|
+
track.breakpoint.push(track.pointer);
|
|
193
|
+
(_track$sequence = track.sequence).splice.apply(
|
|
194
|
+
_track$sequence,
|
|
195
|
+
[track.pointer + 1, 0].concat(_toConsumableArray(program.sequence))
|
|
196
|
+
);
|
|
69
197
|
track.pids.push(program.pid);
|
|
198
|
+
if (!_this.running) {
|
|
199
|
+
_this.running++;
|
|
200
|
+
_this.tracks[program.account.name] = track;
|
|
201
|
+
_this.start_clock();
|
|
202
|
+
}
|
|
70
203
|
} else {
|
|
71
|
-
track = _objectSpread(
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
204
|
+
track = _objectSpread(
|
|
205
|
+
_objectSpread({}, program),
|
|
206
|
+
{},
|
|
207
|
+
{
|
|
208
|
+
pointer: 0,
|
|
209
|
+
pids: [program.pid],
|
|
210
|
+
breakpoint: new Array(),
|
|
211
|
+
}
|
|
212
|
+
);
|
|
76
213
|
_this.tracks[track.account.name] = track;
|
|
77
214
|
_this.running++;
|
|
78
215
|
_this.running === 1 && _this.start_clock();
|
|
@@ -85,4 +222,4 @@ var Manager = /*#__PURE__*/_createClass(function Manager() {
|
|
|
85
222
|
this.oracle = new _Oracle["default"](this);
|
|
86
223
|
});
|
|
87
224
|
var _default = Manager;
|
|
88
|
-
exports["default"] = _default;
|
|
225
|
+
exports["default"] = _default;
|
package/Objects/Opcodes.js
CHANGED
|
@@ -17,18 +17,20 @@ var Opcodes = /*#__PURE__*/_createClass(function Opcodes() {
|
|
|
17
17
|
_classCallCheck(this, Opcodes);
|
|
18
18
|
_defineProperty(this, "set", function (opcode, circuit) {
|
|
19
19
|
_this.opcodes[opcode] = circuit;
|
|
20
|
+
_this.account.compiler.opcodes.push(opcode);
|
|
20
21
|
});
|
|
21
22
|
_defineProperty(this, "prepare_operation", function (opcode, context) {
|
|
22
23
|
var circ = _this.opcodes[opcode];
|
|
23
24
|
if (typeof circ !== "function") return;
|
|
24
25
|
var buf = context.get_buffer();
|
|
25
|
-
var
|
|
26
|
+
var args = buf && context.account.read(buf.inputs);
|
|
27
|
+
var res = circ(args);
|
|
26
28
|
_this.stdin(res);
|
|
27
29
|
});
|
|
28
30
|
_defineProperty(this, "stdin", function (object) {
|
|
29
|
-
if (
|
|
31
|
+
if (object == null) return;
|
|
30
32
|
var code_string = (0, _functions.transpile_object)(object);
|
|
31
|
-
_this.account.compiler.run(code_string);
|
|
33
|
+
_this.account.compiler.run(code_string, true);
|
|
32
34
|
// console.log(`Writing in: ${code_string}`);
|
|
33
35
|
});
|
|
34
36
|
this.opcodes = new Object();
|
package/Objects/Oracle.js
CHANGED
|
@@ -4,6 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = void 0;
|
|
7
|
+
var _fs = _interopRequireDefault(require("fs"));
|
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
7
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); }
|
|
8
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); } }
|
|
9
11
|
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
@@ -25,6 +27,14 @@ var Oracle = /*#__PURE__*/_createClass(function Oracle(mgr) {
|
|
|
25
27
|
_defineProperty(this, "get", function (path) {
|
|
26
28
|
return _this.datapaths[path];
|
|
27
29
|
});
|
|
30
|
+
_defineProperty(this, "write", function (addr, data) {
|
|
31
|
+
var meta = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
|
|
32
|
+
encoding: "utf-8"
|
|
33
|
+
};
|
|
34
|
+
if (typeof data !== "string") data = JSON.stringify(data);
|
|
35
|
+
_this.fs.writeFileSync(addr, data, meta);
|
|
36
|
+
});
|
|
37
|
+
this.fs = _fs["default"];
|
|
28
38
|
this.mgr = mgr;
|
|
29
39
|
this.datapaths = new Object();
|
|
30
40
|
});
|
|
@@ -64,9 +64,6 @@ var Virtual_machine = /*#__PURE__*/function (_Opcodes) {
|
|
|
64
64
|
args: args
|
|
65
65
|
};
|
|
66
66
|
});
|
|
67
|
-
_defineProperty(_assertThisInitialized(_this), "run_traverse", function () {
|
|
68
|
-
if (!_this.running) return;
|
|
69
|
-
});
|
|
70
67
|
_defineProperty(_assertThisInitialized(_this), "execute", function (instruction, track) {
|
|
71
68
|
_this.track = track;
|
|
72
69
|
if (!instruction) return;
|
|
@@ -82,19 +79,16 @@ var Virtual_machine = /*#__PURE__*/function (_Opcodes) {
|
|
|
82
79
|
case "chain":
|
|
83
80
|
chain = context.account.add_chain(args, context);
|
|
84
81
|
_this.contexts.push(chain);
|
|
85
|
-
_this.run_traverse();
|
|
86
82
|
chain.append_buffer();
|
|
87
83
|
break;
|
|
88
84
|
case "link":
|
|
89
85
|
chain = context.account.manager.web.get(args);
|
|
90
|
-
var k = Object.keys(context.account.manager.web.physical_addresses);
|
|
91
86
|
if (!chain) {
|
|
92
87
|
console.log("LINKing Failed. - ".concat(args));
|
|
93
88
|
return;
|
|
94
89
|
}
|
|
95
90
|
chain.append_buffer();
|
|
96
91
|
_this.contexts.push(chain);
|
|
97
|
-
_this.run_traverse();
|
|
98
92
|
break;
|
|
99
93
|
case "mine":
|
|
100
94
|
var bloc = context.mine(_assertThisInitialized(_this), true);
|
|
@@ -113,7 +107,7 @@ var Virtual_machine = /*#__PURE__*/function (_Opcodes) {
|
|
|
113
107
|
_this.contexts.pop();
|
|
114
108
|
break;
|
|
115
109
|
case "cursor":
|
|
116
|
-
context.
|
|
110
|
+
context.set_cursor(args);
|
|
117
111
|
break;
|
|
118
112
|
case "write":
|
|
119
113
|
context.account.write(args, context);
|
package/framer.js
CHANGED
|
@@ -20,14 +20,12 @@ var framer = function framer(initiator) {
|
|
|
20
20
|
subtract: null,
|
|
21
21
|
divide: null,
|
|
22
22
|
exp: null
|
|
23
|
-
}, _defineProperty(_Opcodes, "equal", null), _defineProperty(_Opcodes, "not_equal", null), _defineProperty(_Opcodes, "greater_than", null), _defineProperty(_Opcodes, "less_than", null), _defineProperty(_Opcodes, "gte", null), _defineProperty(_Opcodes, "lte", null), _defineProperty(_Opcodes, "send", null), _defineProperty(_Opcodes, "readonly", null), _defineProperty(_Opcodes, "socket_send", null), _defineProperty(_Opcodes, "jmp", null), _defineProperty(_Opcodes, "jmp_if", null), _defineProperty(_Opcodes, "hold", null), _defineProperty(_Opcodes, "stdout", null), _defineProperty(_Opcodes, "stdin", null), _Opcodes),
|
|
23
|
+
}, _defineProperty(_Opcodes, "equal", null), _defineProperty(_Opcodes, "not_equal", null), _defineProperty(_Opcodes, "greater_than", null), _defineProperty(_Opcodes, "less_than", null), _defineProperty(_Opcodes, "gte", null), _defineProperty(_Opcodes, "lte", null), _defineProperty(_Opcodes, "send", null), _defineProperty(_Opcodes, "readonly", null), _defineProperty(_Opcodes, "socket_send", null), _defineProperty(_Opcodes, "jmp", null), _defineProperty(_Opcodes, "jmp_if", null), _defineProperty(_Opcodes, "hold", 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),
|
|
24
24
|
Datatypes: {
|
|
25
25
|
Number: null,
|
|
26
26
|
String: null,
|
|
27
27
|
Twain: null,
|
|
28
|
-
Array: null
|
|
29
|
-
Void: null,
|
|
30
|
-
Boolean: null
|
|
28
|
+
Array: null
|
|
31
29
|
},
|
|
32
30
|
Objects: {
|
|
33
31
|
Blockchain: {
|
package/opcodes/std.js
CHANGED
package/opcodes.js
CHANGED
|
@@ -14,6 +14,7 @@ var opcodes = function opcodes(account) {
|
|
|
14
14
|
var set = account.vm.set;
|
|
15
15
|
_add.ops.map(function (op) {
|
|
16
16
|
set(op.name, function (args) {
|
|
17
|
+
if (!args) return;
|
|
17
18
|
try {
|
|
18
19
|
var result = eval("".concat(args.op0, " ").concat(op.sign, " ").concat(args.op1));
|
|
19
20
|
return result;
|
|
@@ -31,10 +32,11 @@ var opcodes = function opcodes(account) {
|
|
|
31
32
|
// set("socket_send", socket_send);
|
|
32
33
|
|
|
33
34
|
set("stdout", _std.stdout);
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
["run", "load", "parse", "create_account"].map(function (op) {
|
|
36
|
+
return set(op, function (arg) {
|
|
37
|
+
return arg && arg.op0 && account[op](arg && arg.op0);
|
|
38
|
+
});
|
|
39
|
+
});
|
|
38
40
|
};
|
|
39
41
|
var _default = opcodes;
|
|
40
42
|
exports["default"] = _default;
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "godprotocol",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.783",
|
|
4
4
|
"description": "A data mediator.",
|
|
5
5
|
"main": "Index.js",
|
|
6
6
|
"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
|
-
"
|
|
11
|
-
"
|
|
10
|
+
"prepack": "npmignore",
|
|
11
|
+
"build": "babel ./Objects/Manager.js --out-dir build"
|
|
12
12
|
},
|
|
13
13
|
"author": "Savvy",
|
|
14
14
|
"license": "ISC",
|
|
@@ -44,9 +44,12 @@
|
|
|
44
44
|
"godprotocol"
|
|
45
45
|
],
|
|
46
46
|
"dependencies": {
|
|
47
|
+
"@babel/cli": "latest",
|
|
48
|
+
"@babel/core": "^7.19.1",
|
|
47
49
|
"crypto": "^1.0.1",
|
|
48
50
|
"elliptic": "^6.5.5",
|
|
49
|
-
"fs": "^0.0.1-security"
|
|
51
|
+
"fs": "^0.0.1-security",
|
|
52
|
+
"babel-preset-env": "^1.7.0"
|
|
50
53
|
},
|
|
51
54
|
"publishConfig": {
|
|
52
55
|
"ignore": [
|
package/readme.md
CHANGED
|
@@ -30,7 +30,7 @@ let initiator = start(`name`, { private: true || false });
|
|
|
30
30
|
|
|
31
31
|
| `Parameters` | Type | Description |
|
|
32
32
|
| ------------ | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
33
|
-
| `name` | string | Account names can be any valid variable string. Such as a
|
|
33
|
+
| `name` | string | Account names can be any valid variable string. Such as a Public Key |
|
|
34
34
|
| `private` | object:boolean | default `false`, if set to true, then any payloads sent to the account must be signed using the private key belonging to the account `name` |
|
|
35
35
|
|
|
36
36
|
## Load Instructions
|
package/utils/services.js
CHANGED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.parse_expression = void 0;
|
|
7
|
-
var _parse_to_obj = _interopRequireDefault(require("./parse_to_obj"));
|
|
8
|
-
var _utils = require("./utils");
|
|
9
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
10
|
-
var capture_token = function capture_token(tokens) {
|
|
11
|
-
var token,
|
|
12
|
-
pos = 0;
|
|
13
|
-
token = tokens[pos];
|
|
14
|
-
pos++;
|
|
15
|
-
return {
|
|
16
|
-
token: token,
|
|
17
|
-
pos: pos
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
var slice_expression = function slice_expression(tokens, pos, parent) {
|
|
21
|
-
var expr = [];
|
|
22
|
-
if (parent.token.compiler.expr_types.includes(parent.token.type)) {
|
|
23
|
-
expr.push(parent.token);
|
|
24
|
-
}
|
|
25
|
-
while (pos < tokens.length) {
|
|
26
|
-
var _capture_token = capture_token(tokens.slice(pos)),
|
|
27
|
-
token = _capture_token.token,
|
|
28
|
-
pos_ = _capture_token.pos;
|
|
29
|
-
pos += pos_;
|
|
30
|
-
if (token.compiler.expr_types.includes(token.type)) {
|
|
31
|
-
if (expr.length && expr.slice(-1)[0].type !== "operator") break;
|
|
32
|
-
expr.push(token);
|
|
33
|
-
} else if (token.type === "operator") {
|
|
34
|
-
if (expr.length && !token.compiler.expr_types.includes(expr.slice(-1)[0].type)) break;
|
|
35
|
-
expr.push(token);
|
|
36
|
-
} else {
|
|
37
|
-
break;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
return {
|
|
41
|
-
expr: expr,
|
|
42
|
-
pos: pos
|
|
43
|
-
};
|
|
44
|
-
};
|
|
45
|
-
var op_precedence = ["(", ">", "<", "<=", ">=", "==", "**", "/", "*", "+", "-", "~/", "~*", "~+", "~-"];
|
|
46
|
-
var has_op = function has_op(expr, op) {
|
|
47
|
-
var found = null;
|
|
48
|
-
for (var e = 0; e < expr.length; e++) {
|
|
49
|
-
var x = expr[e];
|
|
50
|
-
if (x.value === op) {
|
|
51
|
-
found = e;
|
|
52
|
-
break;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
return found;
|
|
56
|
-
};
|
|
57
|
-
var resolve_expression = function resolve_expression(expr, parent, params) {
|
|
58
|
-
if (expr.length === 1) {
|
|
59
|
-
expr[0] = (0, _parse_to_obj["default"])(expr[0], parent, {
|
|
60
|
-
is_expr: !params
|
|
61
|
-
});
|
|
62
|
-
} else {
|
|
63
|
-
while (expr.length > 1) {
|
|
64
|
-
for (var i = 0; i < op_precedence.length; i++) {
|
|
65
|
-
var op = op_precedence[i];
|
|
66
|
-
var e = has_op(expr, op);
|
|
67
|
-
while (e != null) {
|
|
68
|
-
var tok_obj = (0, _parse_to_obj["default"])(expr[e], parent);
|
|
69
|
-
tok_obj.push((0, _parse_to_obj["default"])(expr[e - 1], parent, {
|
|
70
|
-
is_expr: !params && tok_obj.token.value !== "="
|
|
71
|
-
}));
|
|
72
|
-
tok_obj.push((0, _parse_to_obj["default"])(expr[e + 1], parent, {
|
|
73
|
-
is_expr: !params
|
|
74
|
-
}));
|
|
75
|
-
expr.splice(e - 1, 3, tok_obj);
|
|
76
|
-
e = has_op(expr, op);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
return expr[0];
|
|
82
|
-
};
|
|
83
|
-
var parse_expression = function parse_expression(tokens, parent, no_one, params) {
|
|
84
|
-
var pos = 0,
|
|
85
|
-
obj;
|
|
86
|
-
var _slice_expression = slice_expression(tokens, pos, parent),
|
|
87
|
-
expr = _slice_expression.expr,
|
|
88
|
-
pos_ = _slice_expression.pos;
|
|
89
|
-
if (expr.length <= 1 && no_one) return {
|
|
90
|
-
obj: parent,
|
|
91
|
-
pos: pos_ + 1
|
|
92
|
-
};
|
|
93
|
-
var assign = expr.find(function (ex) {
|
|
94
|
-
return (0, _utils.is_token_value)(ex, "=", "operator");
|
|
95
|
-
});
|
|
96
|
-
if (assign) {
|
|
97
|
-
obj = resolve_expression(expr.slice(2), parent);
|
|
98
|
-
parent.assign(obj);
|
|
99
|
-
obj = parent;
|
|
100
|
-
} else obj = resolve_expression(expr, parent, params);
|
|
101
|
-
pos = pos_;
|
|
102
|
-
return {
|
|
103
|
-
pos: pos,
|
|
104
|
-
obj: obj
|
|
105
|
-
};
|
|
106
|
-
};
|
|
107
|
-
exports.parse_expression = parse_expression;
|