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/build/framer.js DELETED
@@ -1,88 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
7
- var _Frame = _interopRequireDefault(require("./Objects/Frame"));
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 _defineProperty(e, r, t) {
23
- return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
24
- value: t,
25
- enumerable: !0,
26
- configurable: !0,
27
- writable: !0
28
- }) : e[r] = t, e;
29
- }
30
- function _toPropertyKey(t) {
31
- var i = _toPrimitive(t, "string");
32
- return "symbol" == _typeof(i) ? i : i + "";
33
- }
34
- function _toPrimitive(t, r) {
35
- if ("object" != _typeof(t) || !t) return t;
36
- var e = t[Symbol.toPrimitive];
37
- if (void 0 !== e) {
38
- var i = e.call(t, r || "default");
39
- if ("object" != _typeof(i)) return i;
40
- throw new TypeError("@@toPrimitive must return a primitive value.");
41
- }
42
- return ("string" === r ? String : Number)(t);
43
- }
44
- var framer = function framer(initiator) {
45
- var _Opcodes;
46
- var frame = new _Frame["default"]({
47
- Opcodes: (_Opcodes = {
48
- add: null,
49
- equal: null,
50
- multiply: null,
51
- subtract: null,
52
- divide: null,
53
- exp: null
54
- }, _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),
55
- Datatypes: {
56
- Number: null,
57
- String: null,
58
- Twain: null,
59
- Array: null
60
- },
61
- Objects: {
62
- Blockchain: {
63
- Chain: null,
64
- Block: null
65
- },
66
- Folder: {
67
- active_file: null,
68
- folder: null,
69
- file: null
70
- },
71
- File: {
72
- row: null,
73
- parse: null,
74
- column: null,
75
- write: null
76
- }
77
- }
78
- });
79
- frame.to_instruction();
80
- var instructions = frame.flatten_instructions();
81
- initiator.load({
82
- program: {
83
- instructions: instructions
84
- }
85
- });
86
- };
87
- var _default = framer;
88
- exports["default"] = _default;
@@ -1,127 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.array_to_nested_objects = void 0;
7
- exports.is_port_available = is_port_available;
8
- exports.transpile_object = void 0;
9
- function _typeof(o) {
10
- "@babel/helpers - typeof";
11
-
12
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
13
- return typeof o;
14
- } : function (o) {
15
- return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
16
- }, _typeof(o);
17
- }
18
- function _defineProperty(e, r, t) {
19
- return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
20
- value: t,
21
- enumerable: !0,
22
- configurable: !0,
23
- writable: !0
24
- }) : e[r] = t, e;
25
- }
26
- function _toPropertyKey(t) {
27
- var i = _toPrimitive(t, "string");
28
- return "symbol" == _typeof(i) ? i : i + "";
29
- }
30
- function _toPrimitive(t, r) {
31
- if ("object" != _typeof(t) || !t) return t;
32
- var e = t[Symbol.toPrimitive];
33
- if (void 0 !== e) {
34
- var i = e.call(t, r || "default");
35
- if ("object" != _typeof(i)) return i;
36
- throw new TypeError("@@toPrimitive must return a primitive value.");
37
- }
38
- return ("string" === r ? String : Number)(t);
39
- }
40
- function _toArray(r) {
41
- return _arrayWithHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableRest();
42
- }
43
- function _nonIterableRest() {
44
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
45
- }
46
- function _unsupportedIterableToArray(r, a) {
47
- if (r) {
48
- if ("string" == typeof r) return _arrayLikeToArray(r, a);
49
- var t = {}.toString.call(r).slice(8, -1);
50
- return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
51
- }
52
- }
53
- function _arrayLikeToArray(r, a) {
54
- (null == a || a > r.length) && (a = r.length);
55
- for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
56
- return n;
57
- }
58
- function _iterableToArray(r) {
59
- if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
60
- }
61
- function _arrayWithHoles(r) {
62
- if (Array.isArray(r)) return r;
63
- }
64
- var array_to_nested_objects = function array_to_nested_objects(arr) {
65
- if (arr.length === 0) return null;
66
- var _arr = _toArray(arr),
67
- first = _arr[0],
68
- rest = _arr.slice(1);
69
- return _defineProperty({}, first, array_to_nested_objects(rest));
70
- };
71
- exports.array_to_nested_objects = array_to_nested_objects;
72
- var transpile_object = function transpile_object(object) {
73
- var code_string = "",
74
- type = _typeof(object);
75
- if (type === "object") {
76
- if (Array.isArray(object)) {
77
- code_string += "arr(";
78
- object.map(function (o) {
79
- code_string += "".concat(transpile_object(o), ",");
80
- });
81
- code_string = code_string.slice(0, -1);
82
- code_string += ")";
83
- } else {
84
- if (!object) code_string = "Void";else {
85
- code_string = "twain(";
86
- for (var prop in object) {
87
- var val = object[prop];
88
- code_string += "".concat(transpile_object(prop), ":").concat(transpile_object(val), ",");
89
- }
90
- code_string = code_string.slice(0, -1);
91
- code_string += ")";
92
- }
93
- }
94
- } else if (type === "string") {
95
- code_string = "\"".concat(object, "\"");
96
- } else if (type === "number") {
97
- code_string = "".concat(object);
98
- } else if (type === "boolean") {
99
- code_string = "".concat(object);
100
- }
101
- return code_string;
102
- };
103
- exports.transpile_object = transpile_object;
104
- var net = require("net");
105
-
106
- /**
107
- * Check if a port is available
108
- * @param {number} port - The port to check
109
- * @returns {Promise<boolean>} - Resolves to true if the port is available, false otherwise
110
- */
111
- function is_port_available(port) {
112
- return new Promise(function (resolve, reject) {
113
- var server = net.createServer();
114
- server.once("error", function (err) {
115
- if (err.code === "EADDRINUSE") {
116
- resolve(false); // Port is in use
117
- } else {
118
- reject(err); // Some other error
119
- }
120
- });
121
- server.once("listening", function () {
122
- server.close();
123
- resolve(true); // Port is available
124
- });
125
- server.listen(port);
126
- });
127
- }
package/build/hash.js DELETED
@@ -1,14 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.hash = void 0;
7
- var crypto = require("crypto");
8
- var hash = function hash(data) {
9
- var hash = crypto.createHash("sha256");
10
- hash.update(data);
11
- var result = hash.digest("hex");
12
- return result;
13
- };
14
- exports.hash = hash;
package/build/jmp.js DELETED
@@ -1,19 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.jmp_if = exports.jmp = exports.hold = void 0;
7
- var jmp = function jmp(args, vm) {
8
- vm.account.manager.tracker[vm.mgr_index].pointer += args.index;
9
- };
10
- exports.jmp = jmp;
11
- var jmp_if = function jmp_if(args, vm) {
12
- if (args.passed) vm.account.manager.tracker[vm.mgr_index].pointer += args.index;
13
- };
14
- exports.jmp_if = jmp_if;
15
- var hold = function hold(args, vm) {
16
- var track = vm.account.manager.tracker[vm.mgr_index];
17
- track.hold = args.hold;
18
- };
19
- exports.hold = hold;
package/build/main.js DELETED
@@ -1,339 +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 _toConsumableArray(r) {
17
- return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
18
- }
19
- function _nonIterableSpread() {
20
- throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
21
- }
22
- function _unsupportedIterableToArray(r, a) {
23
- if (r) {
24
- if ("string" == typeof r) return _arrayLikeToArray(r, a);
25
- var t = {}.toString.call(r).slice(8, -1);
26
- return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
27
- }
28
- }
29
- function _iterableToArray(r) {
30
- if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
31
- }
32
- function _arrayWithoutHoles(r) {
33
- if (Array.isArray(r)) return _arrayLikeToArray(r);
34
- }
35
- function _arrayLikeToArray(r, a) {
36
- (null == a || a > r.length) && (a = r.length);
37
- for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
38
- return n;
39
- }
40
- function _defineProperties(e, r) {
41
- for (var t = 0; t < r.length; t++) {
42
- var o = r[t];
43
- o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o);
44
- }
45
- }
46
- function _createClass(e, r, t) {
47
- return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
48
- writable: !1
49
- }), e;
50
- }
51
- function _classCallCheck(a, n) {
52
- if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
53
- }
54
- function _defineProperty(e, r, t) {
55
- return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
56
- value: t,
57
- enumerable: !0,
58
- configurable: !0,
59
- writable: !0
60
- }) : e[r] = t, e;
61
- }
62
- function _toPropertyKey(t) {
63
- var i = _toPrimitive(t, "string");
64
- return "symbol" == _typeof(i) ? i : i + "";
65
- }
66
- function _toPrimitive(t, r) {
67
- if ("object" != _typeof(t) || !t) return t;
68
- var e = t[Symbol.toPrimitive];
69
- if (void 0 !== e) {
70
- var i = e.call(t, r || "default");
71
- if ("object" != _typeof(i)) return i;
72
- throw new TypeError("@@toPrimitive must return a primitive value.");
73
- }
74
- return ("string" === r ? String : Number)(t);
75
- }
76
- var num_pattern = /^[+-]?\d+(\.\d+)?$/;
77
- // let str_pattern = /^["'][^"']*["']$/;
78
- var var_pattern = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
79
- var Loader = /*#__PURE__*/_createClass(function Loader(account) {
80
- var _this = this;
81
- _classCallCheck(this, Loader);
82
- _defineProperty(this, "instruction_index", function () {
83
- var index = _this.instruction_indexes.slice(-1);
84
- index++;
85
- _this.instruction_indexes.splice(-1, 1, index);
86
- return index;
87
- });
88
- _defineProperty(this, "stack_instruction", function (instruction) {
89
- if (Array.isArray(instruction)) return instruction.map(function (i) {
90
- return _this.stack_instruction(i);
91
- });
92
- _this.instruction_stacks.slice(-1)[0].push(instruction);
93
- });
94
- _defineProperty(this, "new_stack", function (addr) {
95
- _this.stacks.push(addr);
96
- });
97
- _defineProperty(this, "push_instruction", function (instruction) {
98
- if (Array.isArray(instruction)) return instruction.map(function (i) {
99
- return _this.push_instruction(i);
100
- });
101
- if (_this.pure) {
102
- _this.instructions.push(instruction);
103
- } else {
104
- _this.stack_instruction("cursor ".concat(_this.instruction_index()));
105
- _this.stack_instruction("write ".concat(instruction));
106
- }
107
- });
108
- _defineProperty(this, "parse_tokens", function (line, stop_char) {
109
- var tokens = new Array();
110
- var pos = 0,
111
- line_number = 0;
112
- var push_token = function push_token(value, type) {
113
- return tokens.push({
114
- value: value,
115
- type: type,
116
- line: line_number,
117
- pos: pos
118
- });
119
- };
120
- line = line.trim();
121
- while (pos < line.length) {
122
- var _char = line[pos].trim();
123
- if (_char === stop_char) return {
124
- tokens: tokens,
125
- pos: pos
126
- };
127
- if (!_char) {
128
- pos++;
129
- continue;
130
- }
131
- if (_char === "\n") {
132
- line_number++;
133
- pos++;
134
- } else if (_char === "@") {
135
- var acc = "";
136
- while (line[pos] && line[pos].trim()) {
137
- acc += line[pos];
138
- pos++;
139
- }
140
- push_token(acc, "address");
141
- } else if (_char === ",") {
142
- pos++;
143
- } else if (_char === ":") {
144
- push_token(_char, "separator");
145
- pos++;
146
- } else if (_char === "[") {
147
- pos++;
148
- var toks = _this.parse_tokens(line.slice(pos), "]");
149
- push_token(toks.tokens, "array");
150
- pos += toks.pos + 1;
151
- } else if (_char === "{") {
152
- pos++;
153
- var _toks = _this.parse_tokens(line.slice(pos), "}");
154
- push_token(_toks.tokens, "twain");
155
- pos += _toks.pos + 1;
156
- } else if (_char === ">") {
157
- pos++;
158
- } else if (_char === "'" || _char === '"') {
159
- var _acc = "";
160
- pos++;
161
- while (line[pos] !== _char) {
162
- if (!line[pos]) break;
163
- _acc += line[pos];
164
- pos++;
165
- }
166
- pos++;
167
- push_token(_acc, "string");
168
- } else if (num_pattern.test(_char)) {
169
- var _acc2 = _char;
170
- pos++;
171
- while (num_pattern.test(line[pos]) || line[pos] === "." && !_acc2.includes(line[pos])) {
172
- if (!line[pos]) break;
173
- _acc2 += line[pos];
174
- pos++;
175
- }
176
- push_token(_acc2, "number");
177
- } else if (var_pattern.test(_char)) {
178
- var _acc3 = _char;
179
- pos++;
180
- while (line[pos] && var_pattern.test("".concat(line[pos].trim()))) {
181
- _acc3 += line[pos];
182
- pos++;
183
- }
184
- push_token(_acc3, _this.opcodes.includes(_acc3) ? "opcode" : "variable");
185
- }
186
- }
187
- return tokens;
188
- });
189
- _defineProperty(this, "parse", function (token) {
190
- if (token.type === "string" || token.type === "number") {
191
- _this.push_instruction(["link ".concat(_this.account.physical_address, "/Datatypes/", "".concat(token.type[0].toUpperCase()).concat(token.type.slice(1))), "write ".concat(token.value), "pop ".concat(token.type)]);
192
- } else if (token.type === "array") {
193
- _this.push_instruction("link Accounts/".concat(_this.account.name, "/Datatypes/Array"));
194
- token.value.map(function (item, i) {
195
- _this.parse(item);
196
- _this.push_instruction(["cursor ".concat(i), "write ".concat(_this.is_not_literal(item.type) ? "{metadata.output:-1}" : "{datapath:-1}")]);
197
- });
198
- _this.push_instruction("pop Array");
199
- } else if (token.type === "twain") {
200
- _this.push_instruction("link Accounts/".concat(_this.account.name, "/Datatypes/Twain"));
201
- var curs = true;
202
- if (token.value) token.value.map(function (entry) {
203
- if (entry.type === "separator") {
204
- curs = false;
205
- return;
206
- }
207
- _this.parse(entry);
208
- if (curs) {
209
- {
210
- _this.push_instruction("cursor {*".concat(_this.is_not_literal(entry.type) ? "metadata.output:-1" : "datapath:-1", "}"));
211
- }
212
- } else {
213
- _this.push_instruction("write ".concat(_this.is_not_literal(entry.type) ? "{metadata.output:-1}" : "{datapath:-1}"));
214
- curs = true;
215
- }
216
- });
217
- _this.push_instruction("pop Twain");
218
- } else if (token.type === "variable") {
219
- _this.push_instruction(["link ".concat("".concat(_this.stacks.slice(-1)[0], "/").concat(token.value)), "pop ".concat(token.value)]);
220
- } else if (token.type === "address") _this.parse_assignment(token);
221
- });
222
- _defineProperty(this, "is_not_literal", function (type) {
223
- return !type || ["variable", "opcode", "address"].includes(type);
224
- });
225
- _defineProperty(this, "parse_assignment", function (line, linked) {
226
- var tokens = linked || line.type ? line : _this.parse_tokens(line);
227
- var identifier = tokens[0];
228
- if (linked || line.type) {
229
- var line_split = (line.value || line).slice(line.value ? null : 1).trim().split(" ");
230
- var path = line_split[0].split("/");
231
- _this.push_instruction("link ".concat(_this.resolve_addr(path.join("/"))));
232
- tokens = !line.type && _this.parse_tokens(line_split.slice(1).join(" "));
233
- tokens.unshift && tokens.unshift(null);
234
- if (line.type === "address") return _this.push_instruction("pop ".concat(path[path.length - 1]));
235
- } else {
236
- _this.push_instruction("chain ".concat(identifier.value));
237
- _this.stack_instruction(["link ".concat(_this.stacks.slice(-1)[0]), "chain ".concat(identifier.value), "pop ".concat(identifier.value), "pop"]);
238
- }
239
- var prev_token;
240
- if (tokens[1] && tokens[1].type === "opcode") {
241
- _this.parse_opcode(tokens.slice(1));
242
- prev_token = tokens[1];
243
- } else {
244
- tokens.slice(1).map(function (tok) {
245
- _this.parse(tok);
246
- });
247
- prev_token = tokens.slice(-1)[0];
248
- }
249
- if (tokens.length > 1) {
250
- _this.push_instruction(["cursor {output}", "write ".concat(_this.is_not_literal(prev_token && prev_token.type) ? "{metadata.output:-1}" : "{datapath:-1}"), "pop ".concat(identifier.value)]);
251
- } else _this.push_instruction("pop ".concat(identifier.value));
252
- });
253
- _defineProperty(this, "parse_opcode", function (line) {
254
- var tokens = Array.isArray(line) ? line : _this.parse_tokens(line);
255
- var op = tokens[0];
256
- if (op.type !== "opcode") return _this.parse(op);
257
- _this.push_instruction(["link Accounts/".concat(_this.account.name, "/Opcodes/").concat(op.value), "link Accounts/".concat(_this.account.name, "/Datatypes/Twain")]);
258
- tokens.slice(1).map(function (tok, i) {
259
- _this.parse(tok);
260
- _this.push_instruction(["cursor op".concat(i), "write ".concat(_this.is_not_literal(tok.type) ? "{metadata.output:-1}" : "{datapath:-1}")]);
261
- });
262
- _this.push_instruction(["pop Twain", "cursor inputs", "write {datapath:-1}", op.value, "cursor {output}", "write {datapath:-1}", "pop ".concat(op.value)]);
263
- });
264
- _defineProperty(this, "resolve_addr", function (addr) {
265
- addr = addr.split("/");
266
- var real_addr = "";
267
- if (addr[0] === "@") {
268
- addr[0] = _this.account.physical_address;
269
- real_addr = addr.join("/");
270
- } else if (addr[0] === ".." || addr[0] === ".") {
271
- var curr_addr = _this.stacks.slice(-1)[0].split("/");
272
- while (addr[0] === ".." || addr[0] === ".") {
273
- if (addr[0] === "..") curr_addr.splice(-1);
274
- delete addr[0];
275
- }
276
- real_addr = curr_addr.join("/") + "".concat(addr.join("/"));
277
- }
278
- return real_addr;
279
- });
280
- _defineProperty(this, "new_stack_instructions", function (new_stack) {
281
- var curr_stack = _this.stacks.slice(-1)[0].split("/");
282
- new_stack = new_stack.split("/");
283
- if (curr_stack[1] !== new_stack[1]) {} else {
284
- var i = 0;
285
- while (curr_stack[i] === new_stack[i]) i++;
286
- for (var j = 2; j < new_stack.length; j++) _this.stack_instruction("chain ".concat(new_stack[j]));
287
- _this.stack_instruction("link ".concat(_this.account.physical_address, "/Datatypes/Array"));
288
- }
289
- });
290
- _defineProperty(this, "parse_routine", function (line) {
291
- var addr = _this.resolve_addr(line);
292
- _this.instruction_stacks.push([]);
293
- _this.new_stack_instructions(addr);
294
- _this.new_stack(addr);
295
- _this.instruction_indexes.push(-1);
296
- });
297
- _defineProperty(this, "pop", function () {
298
- var _this$instructions;
299
- var addr = _this.stacks.splice(-1)[0].split("/");
300
- _this.stack_instruction(["pop Array", "cursor {program}", "write {datapath:-1}"]);
301
- for (var j = 2; j < addr.length; j++) _this.stack_instruction("pop ".concat(addr[j]));
302
- (_this$instructions = _this.instructions).push.apply(_this$instructions, _toConsumableArray(_this.instruction_stacks.splice(-1)[0]));
303
- _this.instruction_indexes.pop();
304
- });
305
- _defineProperty(this, "compile", function (codes) {
306
- var code_array = codes.split("\n");
307
- for (var c = 0; c < code_array.length; c++) {
308
- var line = code_array[c].trim();
309
- if (!line) continue;
310
- if (line === ";") _this.pop();else if (line.startsWith("link ")) _this.parse_routine(line);else if (line.startsWith(".") || line.startsWith("@")) _this.parse_routine(line);else if (line.startsWith("//")) continue;else if (line.startsWith(">@")) _this.parse_assignment(line, true);else if (line.startsWith(">")) _this.parse_assignment(line);else _this.parse_opcode(line);
311
- }
312
- });
313
- _defineProperty(this, "run", function (codes, cb) {
314
- if (typeof cb === "boolean") {
315
- _this.pure = cb;
316
- cb = null;
317
- }
318
- _this.compile(codes);
319
-
320
- // console.log(JSON.stringify(this.instructions, null, 2), "hiya");
321
-
322
- _this.account.load({
323
- program: {
324
- instructions: _toConsumableArray(_this.instructions)
325
- },
326
- callback: cb
327
- });
328
- _this.instructions = [];
329
- _this.pure = false;
330
- });
331
- this.account = account;
332
- this.opcodes = new Array();
333
- this.instructions = new Array();
334
- this.instruction_indexes = new Array();
335
- this.instruction_stacks = [[]];
336
- this.stacks = new Array(account.physical_address);
337
- });
338
- var _default = Loader;
339
- exports["default"] = _default;
package/build/opcodes.js DELETED
@@ -1,42 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
7
- var _add = require("./opcodes/add");
8
- var _jmp = require("./opcodes/jmp");
9
- var _std = require("./opcodes/std");
10
- var _services = require("./utils/services");
11
- // import { socket_send } from "./Socket";
12
-
13
- var opcodes = function opcodes(account) {
14
- var set = account.vm.set;
15
- _add.ops.map(function (op) {
16
- set(op.name, function (args) {
17
- if (!args) return;
18
- try {
19
- var result = eval("".concat(args.op0, " ").concat(op.sign, " ").concat(args.op1));
20
- return result;
21
- } catch (e) {
22
- console.log(e.message);
23
- }
24
- });
25
- });
26
- set("hold", _jmp.hold);
27
- set("jmp", _jmp.jmp);
28
- set("jmp_if", _jmp.jmp_if);
29
- set("send", function (data) {
30
- return (0, _services.post_request)(data, account.vm.stdin);
31
- });
32
- // set("socket_send", socket_send);
33
-
34
- set("stdout", _std.stdout);
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
- });
40
- };
41
- var _default = opcodes;
42
- exports["default"] = _default;
package/build/privacy.js DELETED
@@ -1,27 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
7
- var EC = require("elliptic").ec;
8
- var ec = new EC("secp256k1"); // You can use other curves like 'ed25519' based on your requirements
9
-
10
- /**
11
- * Function to validate a signature using elliptic
12
- * @param {string} public_key - The public key of the user
13
- * @param {string} message - The original message that was signed
14
- * @param {string} signature - The signature to be validated
15
- * @returns {boolean} - True if the signature is valid, false otherwise
16
- */
17
- var validate_signature = function validate_signature(public_key, message, signature) {
18
- var key = ec.keyFromPublic(public_key, "hex");
19
- var hash = ec.hash().update(message).digest("hex");
20
- var sig = {
21
- r: signature.slice(0, 64),
22
- s: signature.slice(64, 128)
23
- };
24
- return key.verify(hash, sig);
25
- };
26
- var _default = validate_signature;
27
- exports["default"] = _default;