godprotocol 1.0.81 → 1.0.82

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.
Files changed (51) hide show
  1. package/.babelrc +3 -0
  2. package/Index.js +8 -19
  3. package/Loader_sequence/main.js +368 -234
  4. package/Objects/Account.js +187 -178
  5. package/Objects/Block.js +60 -61
  6. package/Objects/Blockweb.js +27 -34
  7. package/Objects/Chain.js +115 -118
  8. package/Objects/Explorer.js +30 -37
  9. package/Objects/Filesystem.js +95 -80
  10. package/Objects/Frame.js +43 -48
  11. package/Objects/Manager.js +60 -69
  12. package/Objects/Opcodes.js +39 -101
  13. package/Objects/Oracle.js +50 -66
  14. package/Objects/Virtual_machine.js +132 -132
  15. package/build/Account.js +187 -0
  16. package/build/Block.js +68 -0
  17. package/build/Blockweb.js +36 -0
  18. package/build/Chain.js +119 -0
  19. package/build/Explorer.js +47 -0
  20. package/build/Filesystem.js +127 -0
  21. package/build/Frame.js +52 -0
  22. package/build/Index.js +20 -0
  23. package/build/Manager.js +86 -0
  24. package/build/Opcodes.js +109 -0
  25. package/build/Oracle.js +81 -0
  26. package/build/Virtual_machine.js +136 -0
  27. package/build/add.js +26 -0
  28. package/build/create_server.js +132 -0
  29. package/build/framer.js +59 -0
  30. package/build/functions.js +82 -0
  31. package/build/hash.js +14 -0
  32. package/build/indices.js +31 -0
  33. package/build/jmp.js +19 -0
  34. package/build/main.js +327 -0
  35. package/build/opcodes.js +60 -0
  36. package/build/privacy.js +27 -0
  37. package/build/services.js +50 -0
  38. package/build/std.js +15 -0
  39. package/framer.js +36 -34
  40. package/opcodes/add.js +9 -25
  41. package/opcodes/indices.js +13 -16
  42. package/opcodes/jmp.js +7 -12
  43. package/opcodes/std.js +7 -13
  44. package/opcodes.js +32 -42
  45. package/package.json +1 -1
  46. package/readme.md +4 -4
  47. package/utils/create_server.js +72 -105
  48. package/utils/functions.js +31 -43
  49. package/utils/hash.js +10 -11
  50. package/utils/privacy.js +10 -15
  51. package/utils/services.js +32 -33
package/build/main.js ADDED
@@ -0,0 +1,327 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+ 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
+ function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
9
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
10
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); 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; } }
11
+ function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
12
+ function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
13
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
14
+ 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); } }
15
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
16
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
17
+ 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; }
18
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
19
+ 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); }
20
+ var num_pattern = /^[+-]?\d+(\.\d+)?$/;
21
+ // let str_pattern = /^["'][^"']*["']$/;
22
+ var var_pattern = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
23
+ var Loader = /*#__PURE__*/_createClass(function Loader(account) {
24
+ var _this = this;
25
+ _classCallCheck(this, Loader);
26
+ _defineProperty(this, "instruction_index", function () {
27
+ var index = _this.instruction_indexes.slice(-1);
28
+ index++;
29
+ _this.instruction_indexes.splice(-1, 1, index);
30
+ return index;
31
+ });
32
+ _defineProperty(this, "stack_instruction", function (instruction) {
33
+ if (Array.isArray(instruction)) return instruction.map(function (i) {
34
+ return _this.stack_instruction(i);
35
+ });
36
+ _this.instruction_stacks.slice(-1)[0].push(instruction);
37
+ });
38
+ _defineProperty(this, "new_stack", function (addr) {
39
+ _this.stacks.push(addr);
40
+ });
41
+ _defineProperty(this, "push_instruction", function (instruction) {
42
+ if (Array.isArray(instruction)) return instruction.map(function (i) {
43
+ return _this.push_instruction(i);
44
+ });
45
+ if (_this.pure) {
46
+ _this.instructions.push(instruction);
47
+ } else {
48
+ _this.stack_instruction("cursor ".concat(_this.instruction_index()));
49
+ _this.stack_instruction("write ".concat(instruction));
50
+ }
51
+ });
52
+ _defineProperty(this, "parse_tokens", function (line, stop_char) {
53
+ var tokens = new Array();
54
+ var pos = 0,
55
+ line_number = 0;
56
+ var push_token = function push_token(value, type) {
57
+ return tokens.push({
58
+ value: value,
59
+ type: type,
60
+ line: line_number,
61
+ pos: pos
62
+ });
63
+ };
64
+ line = line.trim();
65
+ while (pos < line.length) {
66
+ var _char = line[pos].trim();
67
+ if (_char === stop_char) return {
68
+ tokens: tokens,
69
+ pos: pos
70
+ };
71
+ if (!_char) {
72
+ pos++;
73
+ continue;
74
+ }
75
+ if (_char === "\n") {
76
+ line_number++;
77
+ pos++;
78
+ } else if (_char === "@") {
79
+ var acc = "";
80
+ while (line[pos] && line[pos].trim()) {
81
+ acc += line[pos];
82
+ pos++;
83
+ }
84
+ push_token(acc, "address");
85
+ } else if (_char === ",") {
86
+ pos++;
87
+ } else if (_char === ":") {
88
+ push_token(_char, "separator");
89
+ pos++;
90
+ } else if (_char === "[") {
91
+ pos++;
92
+ var toks = _this.parse_tokens(line.slice(pos), "]");
93
+ push_token(toks.tokens, "array");
94
+ pos += toks.pos + 1;
95
+ } else if (_char === "{") {
96
+ pos++;
97
+ var _toks = _this.parse_tokens(line.slice(pos), "}");
98
+ push_token(_toks.tokens, "twain");
99
+ pos += _toks.pos + 1;
100
+ } else if (_char === ">") {
101
+ pos++;
102
+ } else if (_char === "'" || _char === '"') {
103
+ var _acc = "";
104
+ pos++;
105
+ while (line[pos] !== _char) {
106
+ if (!line[pos]) break;
107
+ _acc += line[pos];
108
+ pos++;
109
+ }
110
+ pos++;
111
+ push_token(_acc, "string");
112
+ } else if (num_pattern.test(_char)) {
113
+ var _acc2 = _char;
114
+ pos++;
115
+ while (num_pattern.test(line[pos]) || line[pos] === "." && !_acc2.includes(line[pos])) {
116
+ if (!line[pos]) break;
117
+ _acc2 += line[pos];
118
+ pos++;
119
+ }
120
+ push_token(_acc2, "number");
121
+ } else if (var_pattern.test(_char)) {
122
+ var _acc3 = _char;
123
+ pos++;
124
+ while (line[pos] && var_pattern.test("".concat(line[pos].trim()))) {
125
+ _acc3 += line[pos];
126
+ pos++;
127
+ }
128
+ push_token(_acc3, _this.opcodes.includes(_acc3) ? "opcode" : "variable");
129
+ }
130
+ }
131
+ return tokens;
132
+ });
133
+ _defineProperty(this, "parse", function (token) {
134
+ if (token.type === "string" || token.type === "number") {
135
+ _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)]);
136
+ } else if (token.type === "array") {
137
+ _this.push_instruction("link Accounts/".concat(_this.account.name, "/Datatypes/Array"));
138
+ token.value.map(function (item, i) {
139
+ _this.parse(item);
140
+ _this.push_instruction(["cursor ".concat(i), "write ".concat(_this.is_not_literal(item.type) ? "{metadata.output:-1}" : "{datapath:-1}")]);
141
+ });
142
+ _this.push_instruction("pop Array");
143
+ } else if (token.type === "twain") {
144
+ _this.push_instruction("link Accounts/".concat(_this.account.name, "/Datatypes/Twain"));
145
+ var curs = true;
146
+ if (token.value) token.value.map(function (entry) {
147
+ if (entry.type === "separator") {
148
+ curs = false;
149
+ return;
150
+ }
151
+ _this.parse(entry);
152
+ if (curs) {
153
+ {
154
+ _this.push_instruction("cursor {*".concat(_this.is_not_literal(entry.type) ? "metadata.output:-1" : "datapath:-1", "}"));
155
+ }
156
+ } else {
157
+ _this.push_instruction("write ".concat(_this.is_not_literal(entry.type) ? "{metadata.output:-1}" : "{datapath:-1}"));
158
+ curs = true;
159
+ }
160
+ });
161
+ _this.push_instruction("pop Twain");
162
+ } else if (token.type === "variable") {
163
+ _this.push_instruction(["link ".concat("".concat(_this.stacks.slice(-1)[0], "/").concat(token.value)), "pop ".concat(token.value)]);
164
+ } else if (token.type === "address") _this.parse_assignment(token);
165
+ });
166
+ _defineProperty(this, "is_not_literal", function (type) {
167
+ return !type || ["variable", "opcode", "address"].includes(type);
168
+ });
169
+ _defineProperty(this, "parse_assignment", function (line, linked) {
170
+ var tokens = linked || line.type ? line : _this.parse_tokens(line);
171
+ var identifier = tokens[0];
172
+ if (linked || line.type) {
173
+ var line_split = (line.value || line).slice(line.value ? null : 1).trim().split(" ");
174
+ var path = line_split[0].split("/");
175
+ _this.push_instruction("link ".concat(_this.resolve_addr(path.join("/"))));
176
+ tokens = !line.type && _this.parse_tokens(line_split.slice(1).join(" "));
177
+ tokens.unshift && tokens.unshift(null);
178
+ if (line.type === "address") return _this.push_instruction("pop ".concat(path[path.length - 1]));
179
+ } else {
180
+ _this.push_instruction("chain ".concat(identifier.value));
181
+ _this.stack_instruction(["link ".concat(_this.stacks.slice(-1)[0]), "chain ".concat(identifier.value), "pop ".concat(identifier.value), "pop"]);
182
+ }
183
+ var prev_token;
184
+ if (tokens[1] && tokens[1].type === "opcode") {
185
+ _this.parse_opcode(tokens.slice(1));
186
+ prev_token = tokens[1];
187
+ } else {
188
+ tokens.slice(1).map(function (tok) {
189
+ _this.parse(tok);
190
+ });
191
+ prev_token = tokens.slice(-1)[0];
192
+ }
193
+ if (tokens.length > 1) {
194
+ _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)]);
195
+ } else _this.push_instruction("pop ".concat(identifier.value));
196
+ });
197
+ _defineProperty(this, "marker_pattern", /@[a-zA-Z_][a-zA-Z0-9_]*/);
198
+ _defineProperty(this, "parse_opcode", function (line) {
199
+ var tokens = Array.isArray(line) ? line : _this.parse_tokens(line);
200
+ var op = tokens[0];
201
+ if (op.type !== "opcode") return _this.parse(op);
202
+ _this.push_instruction(["link Accounts/".concat(_this.account.name, "/Opcodes/").concat(op.value), "link Accounts/".concat(_this.account.name, "/Datatypes/Twain")]);
203
+ tokens.slice(1).map(function (tok, i) {
204
+ if (tok.type === "address" && tok.value.match(_this.marker_pattern)) {
205
+ _this.push_instruction(["link ".concat(_this.account.physical_address, "/Datatypes/Number"), "write ".concat(tok.value), "pop Number"]);
206
+ } else _this.parse(tok);
207
+ _this.push_instruction(["cursor op".concat(i), "write ".concat(_this.is_not_literal(tok.type) && !(tok.type === "address" && tok.value.match(_this.marker_pattern)) ? "{metadata.output:-1}" : "{datapath:-1}")]);
208
+ });
209
+ _this.push_instruction(["pop Twain", "cursor inputs", "write {datapath:-1}", op.value, "cursor {output}", "write {datapath:-1}", "pop ".concat(op.value)]);
210
+ });
211
+ _defineProperty(this, "resolve_addr", function (addr) {
212
+ addr = addr.split("/");
213
+ var real_addr = "";
214
+ if (addr[0] === "@") {
215
+ addr[0] = _this.account.physical_address;
216
+ real_addr = addr.join("/");
217
+ } else if (addr[0] === ".." || addr[0] === ".") {
218
+ var curr_addr = _this.stacks.slice(-1)[0].split("/");
219
+ while (addr[0] === ".." || addr[0] === ".") {
220
+ if (addr[0] === "..") curr_addr.splice(-1);
221
+ delete addr[0];
222
+ }
223
+ real_addr = curr_addr.join("/") + "".concat(addr.join("/"));
224
+ }
225
+ return real_addr;
226
+ });
227
+ _defineProperty(this, "new_stack_instructions", function (new_stack) {
228
+ var curr_stack = _this.stacks.slice(-1)[0].split("/");
229
+ new_stack = new_stack.split("/");
230
+ if (curr_stack[1] !== new_stack[1]) {} else {
231
+ var i = 0;
232
+ while (curr_stack[i] === new_stack[i]) i++;
233
+ for (var j = 2; j < new_stack.length; j++) _this.stack_instruction("chain ".concat(new_stack[j]));
234
+ _this.stack_instruction("link ".concat(_this.account.physical_address, "/Datatypes/Array"));
235
+ }
236
+ });
237
+ _defineProperty(this, "parse_routine", function (line) {
238
+ var addr = _this.resolve_addr(line);
239
+ _this.instruction_stacks.push([]);
240
+ _this.new_stack_instructions(addr);
241
+ _this.new_stack(addr);
242
+ _this.instruction_indexes.push(-1);
243
+ });
244
+ _defineProperty(this, "pop", function () {
245
+ var _this$instructions;
246
+ var addr = _this.stacks.splice(-1)[0].split("/");
247
+ _this.stack_instruction(["pop Array", "cursor {program}", "write {datapath:-1}"]);
248
+ for (var j = 2; j < addr.length; j++) _this.stack_instruction("pop ".concat(addr[j]));
249
+ (_this$instructions = _this.instructions).push.apply(_this$instructions, _toConsumableArray(_this.instruction_stacks.splice(-1)[0]));
250
+ _this.instruction_indexes.pop();
251
+ });
252
+ _defineProperty(this, "revamp_marks", function () {
253
+ var instruction_stack = _this.instruction_stacks.slice(-1)[0];
254
+ instruction_stack = instruction_stack.map(function (ins) {
255
+ return _this.resolve_offset(ins, true);
256
+ });
257
+ _this.instruction_stacks[_this.instruction_stacks.length - 1] = instruction_stack;
258
+ });
259
+ _defineProperty(this, "handle_marker", function (line) {
260
+ var splits = line.slice(1).split(" ");
261
+ var name = splits[0];
262
+ var curr_stack = _this.stacks.slice(-1)[0];
263
+ var markers = _this.markers[curr_stack];
264
+ if (!markers) {
265
+ markers = new Object();
266
+ _this.markers[curr_stack] = markers;
267
+ }
268
+ markers[name] = _this.instruction_index();
269
+ _this.revamp_marks();
270
+ return splits.slice(1).join(" ");
271
+ });
272
+ _defineProperty(this, "resolve_offset", function (line, revamping) {
273
+ var matches = line.match(_this.marker_pattern),
274
+ value;
275
+ if (matches) {
276
+ var match = matches[0].slice(1);
277
+ var curr_stack = _this.stacks.slice(-1)[0];
278
+ var markers = _this.markers[curr_stack];
279
+ if (!markers) {
280
+ markers = new Object();
281
+ _this.markers[curr_stack] = markers;
282
+ }
283
+ value = markers[match];
284
+ }
285
+ if (typeof value === "number") line = line.replace(_this.marker_pattern, (revamping && value > 0 ? value - 1 : value).toString());
286
+ return line;
287
+ });
288
+ _defineProperty(this, "compile", function (codes) {
289
+ var code_array = codes.split("\n");
290
+ for (var c = 0; c < code_array.length; c++) {
291
+ var line = code_array[c].trim();
292
+ if (!line) continue;
293
+ if (line.startsWith(":")) {
294
+ line = _this.handle_marker(line);
295
+ if (!line) continue;
296
+ }
297
+ line = _this.resolve_offset(line);
298
+ if (line === ";") _this.pop();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);
299
+ }
300
+ });
301
+ _defineProperty(this, "run", function (codes, meta) {
302
+ if (!meta) meta = {};
303
+ _this.pure = meta && meta.pure;
304
+ var cb = meta && meta.cb;
305
+ _this.compile(codes);
306
+
307
+ // console.log(JSON.stringify(this.instructions, null, 2), "hiya");
308
+
309
+ _this.account.load({
310
+ program: {
311
+ instructions: _toConsumableArray(_this.instructions)
312
+ },
313
+ callback: cb
314
+ });
315
+ _this.instructions = [];
316
+ _this.pure = false;
317
+ });
318
+ this.account = account;
319
+ this.opcodes = new Array();
320
+ this.instructions = new Array();
321
+ this.instruction_indexes = new Array();
322
+ this.instruction_stacks = [[]];
323
+ this.stacks = new Array(account.physical_address);
324
+ this.markers = new Array();
325
+ });
326
+ var _default = Loader;
327
+ exports["default"] = _default;
@@ -0,0 +1,60 @@
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 _indices = require("./opcodes/indices");
9
+ var _jmp = require("./opcodes/jmp");
10
+ var _std = require("./opcodes/std");
11
+ var _services = require("./utils/services");
12
+ // import { socket_send } from "./Socket";
13
+
14
+ var opcodes = function opcodes(account) {
15
+ var set = account.vm.set;
16
+ _add.ops.map(function (op) {
17
+ set(op.name, function (args) {
18
+ if (!args) return;
19
+ try {
20
+ var result = eval("".concat(args.op0, " ").concat(op.sign, " ").concat(args.op1));
21
+ if (op.sign === "==") {
22
+ account.vm.flags.equal = !!result;
23
+ return;
24
+ }
25
+ return result;
26
+ } catch (e) {
27
+ console.log(e.message);
28
+ }
29
+ });
30
+ });
31
+ Object.keys(account.vm.flags).map(function (flag) {
32
+ set("jmp_".concat(flag), function (args, vm) {
33
+ return (0, _jmp.jmp)(args, vm, {
34
+ flag: flag
35
+ });
36
+ });
37
+ set("jmp_not_".concat(flag), function (args, vm) {
38
+ return (0, _jmp.jmp)(args, vm, {
39
+ flag: flag,
40
+ inverse: true
41
+ });
42
+ });
43
+ });
44
+ set("jmp", _jmp.jmp);
45
+ set("setter", _indices.setter);
46
+ set("getter", _indices.getter);
47
+ set("send", function (data) {
48
+ return (0, _services.post_request)(data, account.vm.stdin);
49
+ });
50
+ // set("socket_send", socket_send);
51
+
52
+ set("stdout", _std.stdout);
53
+ ["run", "load", "parse", "create_account"].map(function (op) {
54
+ return set(op, function (arg) {
55
+ return arg && arg.op0 && account[op](arg && arg.op0);
56
+ });
57
+ });
58
+ };
59
+ var _default = opcodes;
60
+ exports["default"] = _default;
@@ -0,0 +1,27 @@
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;
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.post_request = void 0;
7
+ 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
+ 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; }
9
+ 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; }
10
+ 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; }
11
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
12
+ 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); }
13
+ var http = require("http");
14
+ var post_request = function post_request(payload, cb) {
15
+ // let options = {
16
+ // hostname: 'example.com',
17
+ // port: 80,
18
+ // path: '/api/users',
19
+ // method: 'POST',
20
+ // headers: {
21
+ // 'Content-Type': 'application/json',
22
+ // 'Content-Length': Buffer.byteLength(postData),
23
+ // },
24
+ // };
25
+
26
+ var req = http.request(_objectSpread(_objectSpread({}, payload.options), {}, {
27
+ method: "POST",
28
+ headers: {
29
+ "Content-Type": "application/json",
30
+ "Content-Length": Buffer.byteLength(payload.data)
31
+ }
32
+ }), function (res) {
33
+ var data = "";
34
+ res.on("data", function (chunk) {
35
+ data += chunk;
36
+ cb && cb(chunk);
37
+ });
38
+ res.on("end", function () {
39
+ cb && cb(data);
40
+ // console.log("Response:", data);
41
+ });
42
+ });
43
+ req.on("error", function (e) {
44
+ cb(e.message);
45
+ console.error("Problem with request: ".concat(e.message));
46
+ });
47
+ req.write(payload.data);
48
+ req.end();
49
+ };
50
+ exports.post_request = post_request;
package/build/std.js ADDED
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
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]);
14
+ };
15
+ exports.stdout = stdout;
package/framer.js CHANGED
@@ -1,59 +1,61 @@
1
- "use strict";
2
-
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 = {
1
+ import Frame from "./Objects/Frame";
2
+
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
- }, _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),
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
- exports.obj = obj;
48
- var framer = function framer(initiator) {
49
- var frame = new _Frame["default"](obj);
51
+
52
+ const framer = (initiator) => {
53
+ let frame = new Frame(obj);
50
54
  frame.to_instruction();
51
- var instructions = frame.flatten_instructions();
52
- initiator.load({
53
- program: {
54
- instructions: instructions
55
- }
56
- });
55
+ let instructions = frame.flatten_instructions();
56
+
57
+ initiator.load({ program: { instructions } });
57
58
  };
58
- var _default = framer;
59
- exports["default"] = _default;
59
+
60
+ export default framer;
61
+ export { obj };
package/opcodes/add.js CHANGED
@@ -1,26 +1,10 @@
1
- "use strict";
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
- 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;
10
+ export { ops };
@@ -1,31 +1,28 @@
1
- "use strict";
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
- exports.getter = getter;
15
- var setter = function setter(args) {
16
- var base = args.op0;
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 = ""
20
- .concat(base.slice(0, args.op2))
21
- .concat(args.op1)
22
- .concat(base.slice(args.op2 + 1));
17
+ base = `${base.slice(0, args.op2)}${args.op1}${base.slice(args.op2 + 1)}`;
23
18
  } else {
24
19
  if (Array.isArray(base)) {
25
20
  if (args.op2 == null || args.op2 >= base.length) base.push(args.op1);
26
21
  else base[args.op2] = args.op1;
27
22
  } else base[args.op2] = args.op1;
28
23
  }
24
+
29
25
  return base;
30
26
  };
31
- exports.setter = setter;
27
+
28
+ export { setter, getter };