godprotocol 1.0.796 → 1.0.798

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 (61) hide show
  1. package/.babelrc +3 -0
  2. package/Index.js +8 -21
  3. package/Loader_sequence/main.js +259 -358
  4. package/Objects/Account.js +178 -337
  5. package/Objects/Block.js +53 -58
  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 +68 -77
  12. package/Objects/Opcodes.js +32 -97
  13. package/Objects/Oracle.js +23 -39
  14. package/Objects/Virtual_machine.js +125 -261
  15. package/build/Account.js +162 -0
  16. package/build/Block.js +65 -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 +15 -0
  23. package/build/Manager.js +99 -0
  24. package/build/Opcodes.js +39 -0
  25. package/build/Oracle.js +42 -0
  26. package/build/Virtual_machine.js +128 -0
  27. package/build/add.js +41 -0
  28. package/build/create_server.js +119 -0
  29. package/build/framer.js +57 -0
  30. package/build/functions.js +82 -0
  31. package/build/hash.js +14 -0
  32. package/build/jmp.js +19 -0
  33. package/build/main.js +283 -0
  34. package/build/opcodes.js +42 -0
  35. package/build/privacy.js +27 -0
  36. package/build/services.js +50 -0
  37. package/build/std.js +11 -0
  38. package/framer.js +39 -31
  39. package/opcodes/add.js +14 -40
  40. package/opcodes/jmp.js +10 -14
  41. package/opcodes/std.js +5 -9
  42. package/opcodes.js +25 -29
  43. package/package.json +3 -3
  44. package/readme.md +71 -95
  45. package/types/Account.d.ts +73 -0
  46. package/types/Block.d.ts +22 -0
  47. package/types/Blockweb.d.ts +14 -0
  48. package/types/Chain.d.ts +35 -0
  49. package/types/Explorer.d.ts +9 -0
  50. package/types/Filesystem.d.ts +23 -0
  51. package/types/Frame.d.ts +14 -0
  52. package/types/Manager.d.ts +21 -0
  53. package/types/Opcodes.d.ts +11 -0
  54. package/types/Oracle.d.ts +17 -0
  55. package/types/Virtual_machine.d.ts +20 -0
  56. package/types/index.d.ts +4 -0
  57. package/utils/create_server.js +65 -622
  58. package/utils/functions.js +31 -43
  59. package/utils/hash.js +10 -11
  60. package/utils/privacy.js +10 -15
  61. package/utils/services.js +32 -33
package/build/main.js ADDED
@@ -0,0 +1,283 @@
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, "parse_opcode", function (line) {
198
+ var tokens = Array.isArray(line) ? line : _this.parse_tokens(line);
199
+ var op = tokens[0];
200
+ if (op.type !== "opcode") return _this.parse(op);
201
+ _this.push_instruction(["link Accounts/".concat(_this.account.name, "/Opcodes/").concat(op.value), "link Accounts/".concat(_this.account.name, "/Datatypes/Twain")]);
202
+ tokens.slice(1).map(function (tok, i) {
203
+ _this.parse(tok);
204
+ _this.push_instruction(["cursor op".concat(i), "write ".concat(_this.is_not_literal(tok.type) ? "{metadata.output:-1}" : "{datapath:-1}")]);
205
+ });
206
+ _this.push_instruction(["pop Twain", "cursor inputs", "write {datapath:-1}", op.value, "cursor {output}", "write {datapath:-1}", "pop ".concat(op.value)]);
207
+ });
208
+ _defineProperty(this, "resolve_addr", function (addr) {
209
+ addr = addr.split("/");
210
+ var real_addr = "";
211
+ if (addr[0] === "@") {
212
+ addr[0] = _this.account.physical_address;
213
+ real_addr = addr.join("/");
214
+ } else if (addr[0] === ".." || addr[0] === ".") {
215
+ var curr_addr = _this.stacks.slice(-1)[0].split("/");
216
+ while (addr[0] === ".." || addr[0] === ".") {
217
+ if (addr[0] === "..") curr_addr.splice(-1);
218
+ delete addr[0];
219
+ }
220
+ real_addr = curr_addr.join("/") + "".concat(addr.join("/"));
221
+ }
222
+ return real_addr;
223
+ });
224
+ _defineProperty(this, "new_stack_instructions", function (new_stack) {
225
+ var curr_stack = _this.stacks.slice(-1)[0].split("/");
226
+ new_stack = new_stack.split("/");
227
+ if (curr_stack[1] !== new_stack[1]) {} else {
228
+ var i = 0;
229
+ while (curr_stack[i] === new_stack[i]) i++;
230
+ for (var j = 2; j < new_stack.length; j++) _this.stack_instruction("chain ".concat(new_stack[j]));
231
+ _this.stack_instruction("link ".concat(_this.account.physical_address, "/Datatypes/Array"));
232
+ }
233
+ });
234
+ _defineProperty(this, "parse_routine", function (line) {
235
+ var addr = _this.resolve_addr(line);
236
+ _this.instruction_stacks.push([]);
237
+ _this.new_stack_instructions(addr);
238
+ _this.new_stack(addr);
239
+ _this.instruction_indexes.push(-1);
240
+ });
241
+ _defineProperty(this, "pop", function () {
242
+ var _this$instructions;
243
+ var addr = _this.stacks.splice(-1)[0].split("/");
244
+ _this.stack_instruction(["pop Array", "cursor {program}", "write {datapath:-1}"]);
245
+ for (var j = 2; j < addr.length; j++) _this.stack_instruction("pop ".concat(addr[j]));
246
+ (_this$instructions = _this.instructions).push.apply(_this$instructions, _toConsumableArray(_this.instruction_stacks.splice(-1)[0]));
247
+ _this.instruction_indexes.pop();
248
+ });
249
+ _defineProperty(this, "compile", function (codes) {
250
+ var code_array = codes.split("\n");
251
+ for (var c = 0; c < code_array.length; c++) {
252
+ var line = code_array[c].trim();
253
+ if (!line) continue;
254
+ 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);
255
+ }
256
+ });
257
+ _defineProperty(this, "run", function (codes, cb) {
258
+ if (typeof cb === "boolean") {
259
+ _this.pure = cb;
260
+ cb = null;
261
+ }
262
+ _this.compile(codes);
263
+
264
+ // console.log(JSON.stringify(this.instructions, null, 2), "hiya");
265
+
266
+ _this.account.load({
267
+ program: {
268
+ instructions: _toConsumableArray(_this.instructions)
269
+ },
270
+ callback: cb
271
+ });
272
+ _this.instructions = [];
273
+ _this.pure = false;
274
+ });
275
+ this.account = account;
276
+ this.opcodes = new Array();
277
+ this.instructions = new Array();
278
+ this.instruction_indexes = new Array();
279
+ this.instruction_stacks = [[]];
280
+ this.stacks = new Array(account.physical_address);
281
+ });
282
+ var _default = Loader;
283
+ exports["default"] = _default;
@@ -0,0 +1,42 @@
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;
@@ -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,11 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.stdout = void 0;
7
+ var stdout = function stdout(args) {
8
+ if (!args) return;
9
+ for (var v in args) console.log(args[v]);
10
+ };
11
+ exports.stdout = stdout;
package/framer.js CHANGED
@@ -1,57 +1,65 @@
1
- "use strict";
1
+ import Frame from "./Objects/Frame";
2
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) { return e && e.__esModule ? e : { "default": e }; }
9
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
10
- function _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 framer = function framer(initiator) {
14
- var _Opcodes;
15
- var frame = new _Frame["default"]({
16
- Opcodes: (_Opcodes = {
3
+ const framer = (initiator) => {
4
+ let frame = new Frame({
5
+ Opcodes: {
17
6
  add: null,
18
7
  equal: null,
19
8
  multiply: null,
20
9
  subtract: null,
21
10
  divide: null,
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), _defineProperty(_Opcodes, "run", null), _defineProperty(_Opcodes, "load", null), _defineProperty(_Opcodes, "parse", null), _defineProperty(_Opcodes, "create_account", null), _Opcodes),
11
+ exp: null,
12
+ equal: null,
13
+ not_equal: null,
14
+ greater_than: null,
15
+ less_than: null,
16
+ gte: null,
17
+ lte: null,
18
+
19
+ send: null,
20
+ readonly: null,
21
+ socket_send: null,
22
+
23
+ jmp: null,
24
+ jmp_if: null,
25
+ hold: null,
26
+
27
+ stdout: null,
28
+ stdin: null,
29
+
30
+ run: null,
31
+ load: null,
32
+ parse: null,
33
+ create_account: null,
34
+ },
24
35
  Datatypes: {
25
36
  Number: null,
26
37
  String: null,
27
38
  Twain: null,
28
- Array: null
39
+ Array: null,
29
40
  },
30
41
  Objects: {
31
42
  Blockchain: {
32
43
  Chain: null,
33
- Block: null
44
+ Block: null,
34
45
  },
35
46
  Folder: {
36
47
  active_file: null,
37
48
  folder: null,
38
- file: null
49
+ file: null,
39
50
  },
40
51
  File: {
41
52
  row: null,
42
53
  parse: null,
43
54
  column: null,
44
- write: null
45
- }
46
- }
55
+ write: null,
56
+ },
57
+ },
47
58
  });
48
59
  frame.to_instruction();
49
- var instructions = frame.flatten_instructions();
50
- initiator.load({
51
- program: {
52
- instructions: instructions
53
- }
54
- });
60
+ let instructions = frame.flatten_instructions();
61
+
62
+ initiator.load({ program: { instructions } });
55
63
  };
56
- var _default = framer;
57
- exports["default"] = _default;
64
+
65
+ export default framer;
package/opcodes/add.js CHANGED
@@ -1,41 +1,15 @@
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
+ { name: "not_equal", sign: "!=" },
9
+ { name: "greater_than", sign: ">" },
10
+ { name: "less_than", sign: "<" },
11
+ { name: "gte", sign: ">=" },
12
+ { name: "lte", sign: "<=" },
13
+ ];
2
14
 
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
- name: "not_equal",
27
- sign: "!="
28
- }, {
29
- name: "greater_than",
30
- sign: ">"
31
- }, {
32
- name: "less_than",
33
- sign: "<"
34
- }, {
35
- name: "gte",
36
- sign: ">="
37
- }, {
38
- name: "lte",
39
- sign: "<="
40
- }];
41
- exports.ops = ops;
15
+ export { ops };
package/opcodes/jmp.js CHANGED
@@ -1,19 +1,15 @@
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) {
1
+ const jmp = (args, vm) => {
8
2
  vm.account.manager.tracker[vm.mgr_index].pointer += args.index;
9
3
  };
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;
4
+
5
+ const jmp_if = (args, vm) => {
6
+ if (args.passed)
7
+ vm.account.manager.tracker[vm.mgr_index].pointer += args.index;
13
8
  };
14
- exports.jmp_if = jmp_if;
15
- var hold = function hold(args, vm) {
16
- var track = vm.account.manager.tracker[vm.mgr_index];
9
+
10
+ const hold = (args, vm) => {
11
+ let track = vm.account.manager.tracker[vm.mgr_index];
17
12
  track.hold = args.hold;
18
13
  };
19
- exports.hold = hold;
14
+
15
+ export { jmp, jmp_if, hold };
package/opcodes/std.js CHANGED
@@ -1,11 +1,7 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.stdout = void 0;
7
- var stdout = function stdout(args) {
1
+ const stdout = (args) => {
8
2
  if (!args) return;
9
- for (var v in args) console.log(args[v]);
3
+
4
+ for (let v in args) console.log(args[v]);
10
5
  };
11
- exports.stdout = stdout;
6
+
7
+ export { stdout };