godprotocol 1.0.783 → 1.0.785

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.
@@ -1,123 +1,26 @@
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
- function _typeof(o) {
8
- "@babel/helpers - typeof";
9
- return (
10
- (_typeof =
11
- "function" == typeof Symbol && "symbol" == typeof Symbol.iterator
12
- ? function (o) {
13
- return typeof o;
14
- }
15
- : function (o) {
16
- return o &&
17
- "function" == typeof Symbol &&
18
- o.constructor === Symbol &&
19
- o !== Symbol.prototype
20
- ? "symbol"
21
- : typeof o;
22
- }),
23
- _typeof(o)
24
- );
25
- }
26
- function _toConsumableArray(r) {
27
- return (
28
- _arrayWithoutHoles(r) ||
29
- _iterableToArray(r) ||
30
- _unsupportedIterableToArray(r) ||
31
- _nonIterableSpread()
32
- );
33
- }
34
- function _nonIterableSpread() {
35
- throw new TypeError(
36
- "Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."
37
- );
38
- }
39
- function _unsupportedIterableToArray(r, a) {
40
- if (r) {
41
- if ("string" == typeof r) return _arrayLikeToArray(r, a);
42
- var t = {}.toString.call(r).slice(8, -1);
43
- return (
44
- "Object" === t && r.constructor && (t = r.constructor.name),
45
- "Map" === t || "Set" === t
46
- ? Array.from(r)
47
- : "Arguments" === t ||
48
- /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)
49
- ? _arrayLikeToArray(r, a)
50
- : void 0
51
- );
52
- }
53
- }
54
- function _iterableToArray(r) {
55
- if (
56
- ("undefined" != typeof Symbol && null != r[Symbol.iterator]) ||
57
- null != r["@@iterator"]
58
- )
59
- return Array.from(r);
60
- }
61
- function _arrayWithoutHoles(r) {
62
- if (Array.isArray(r)) return _arrayLikeToArray(r);
63
- }
64
- function _arrayLikeToArray(r, a) {
65
- (null == a || a > r.length) && (a = r.length);
66
- for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
67
- return n;
68
- }
69
- function _defineProperties(e, r) {
70
- for (var t = 0; t < r.length; t++) {
71
- var o = r[t];
72
- (o.enumerable = o.enumerable || !1),
73
- (o.configurable = !0),
74
- "value" in o && (o.writable = !0),
75
- Object.defineProperty(e, _toPropertyKey(o.key), o);
76
- }
77
- }
78
- function _createClass(e, r, t) {
79
- return (
80
- r && _defineProperties(e.prototype, r),
81
- t && _defineProperties(e, t),
82
- Object.defineProperty(e, "prototype", { writable: !1 }),
83
- e
84
- );
85
- }
86
- function _classCallCheck(a, n) {
87
- if (!(a instanceof n))
88
- throw new TypeError("Cannot call a class as a function");
89
- }
90
- function _defineProperty(e, r, t) {
91
- return (
92
- (r = _toPropertyKey(r)) in e
93
- ? Object.defineProperty(e, r, {
94
- value: t,
95
- enumerable: !0,
96
- configurable: !0,
97
- writable: !0,
98
- })
99
- : (e[r] = t),
100
- e
101
- );
102
- }
103
- function _toPropertyKey(t) {
104
- var i = _toPrimitive(t, "string");
105
- return "symbol" == _typeof(i) ? i : i + "";
106
- }
107
- function _toPrimitive(t, r) {
108
- if ("object" != _typeof(t) || !t) return t;
109
- var e = t[Symbol.toPrimitive];
110
- if (void 0 !== e) {
111
- var i = e.call(t, r || "default");
112
- if ("object" != _typeof(i)) return i;
113
- throw new TypeError("@@toPrimitive must return a primitive value.");
114
- }
115
- return ("string" === r ? String : Number)(t);
116
- }
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); }
117
20
  var num_pattern = /^[+-]?\d+(\.\d+)?$/;
118
21
  // let str_pattern = /^["'][^"']*["']$/;
119
22
  var var_pattern = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
120
- var Loader = /*#__PURE__*/ _createClass(function Loader(account) {
23
+ var Loader = /*#__PURE__*/_createClass(function Loader(account) {
121
24
  var _this = this;
122
25
  _classCallCheck(this, Loader);
123
26
  _defineProperty(this, "instruction_index", function () {
@@ -127,20 +30,18 @@ var Loader = /*#__PURE__*/ _createClass(function Loader(account) {
127
30
  return index;
128
31
  });
129
32
  _defineProperty(this, "stack_instruction", function (instruction) {
130
- if (Array.isArray(instruction))
131
- return instruction.map(function (i) {
132
- return _this.stack_instruction(i);
133
- });
33
+ if (Array.isArray(instruction)) return instruction.map(function (i) {
34
+ return _this.stack_instruction(i);
35
+ });
134
36
  _this.instruction_stacks.slice(-1)[0].push(instruction);
135
37
  });
136
38
  _defineProperty(this, "new_stack", function (addr) {
137
39
  _this.stacks.push(addr);
138
40
  });
139
41
  _defineProperty(this, "push_instruction", function (instruction) {
140
- if (Array.isArray(instruction))
141
- return instruction.map(function (i) {
142
- return _this.push_instruction(i);
143
- });
42
+ if (Array.isArray(instruction)) return instruction.map(function (i) {
43
+ return _this.push_instruction(i);
44
+ });
144
45
  if (_this.pure) {
145
46
  _this.instructions.push(instruction);
146
47
  } else {
@@ -157,17 +58,16 @@ var Loader = /*#__PURE__*/ _createClass(function Loader(account) {
157
58
  value: value,
158
59
  type: type,
159
60
  line: line_number,
160
- pos: pos,
61
+ pos: pos
161
62
  });
162
63
  };
163
64
  line = line.trim();
164
65
  while (pos < line.length) {
165
66
  var _char = line[pos].trim();
166
- if (_char === stop_char)
167
- return {
168
- tokens: tokens,
169
- pos: pos,
170
- };
67
+ if (_char === stop_char) return {
68
+ tokens: tokens,
69
+ pos: pos
70
+ };
171
71
  if (!_char) {
172
72
  pos++;
173
73
  continue;
@@ -212,10 +112,7 @@ var Loader = /*#__PURE__*/ _createClass(function Loader(account) {
212
112
  } else if (num_pattern.test(_char)) {
213
113
  var _acc2 = _char;
214
114
  pos++;
215
- while (
216
- num_pattern.test(line[pos]) ||
217
- (line[pos] === "." && !_acc2.includes(line[pos]))
218
- ) {
115
+ while (num_pattern.test(line[pos]) || line[pos] === "." && !_acc2.includes(line[pos])) {
219
116
  if (!line[pos]) break;
220
117
  _acc2 += line[pos];
221
118
  pos++;
@@ -228,83 +125,42 @@ var Loader = /*#__PURE__*/ _createClass(function Loader(account) {
228
125
  _acc3 += line[pos];
229
126
  pos++;
230
127
  }
231
- push_token(
232
- _acc3,
233
- _this.opcodes.includes(_acc3) ? "opcode" : "variable"
234
- );
128
+ push_token(_acc3, _this.opcodes.includes(_acc3) ? "opcode" : "variable");
235
129
  }
236
130
  }
237
131
  return tokens;
238
132
  });
239
133
  _defineProperty(this, "parse", function (token) {
240
134
  if (token.type === "string" || token.type === "number") {
241
- _this.push_instruction([
242
- "link ".concat(
243
- _this.account.physical_address,
244
- "/Datatypes/",
245
- "".concat(token.type[0].toUpperCase()).concat(token.type.slice(1))
246
- ),
247
- "write ".concat(token.value),
248
- "pop ".concat(token.type),
249
- ]);
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)]);
250
136
  } else if (token.type === "array") {
251
- _this.push_instruction(
252
- "link Accounts/".concat(_this.account.name, "/Datatypes/Array")
253
- );
137
+ _this.push_instruction("link Accounts/".concat(_this.account.name, "/Datatypes/Array"));
254
138
  token.value.map(function (item, i) {
255
139
  _this.parse(item);
256
- _this.push_instruction([
257
- "cursor ".concat(i),
258
- "write ".concat(
259
- _this.is_not_literal(item.type)
260
- ? "{metadata.output:-1}"
261
- : "{datapath:-1}"
262
- ),
263
- ]);
140
+ _this.push_instruction(["cursor ".concat(i), "write ".concat(_this.is_not_literal(item.type) ? "{metadata.output:-1}" : "{datapath:-1}")]);
264
141
  });
265
142
  _this.push_instruction("pop Array");
266
143
  } else if (token.type === "twain") {
267
- _this.push_instruction(
268
- "link Accounts/".concat(_this.account.name, "/Datatypes/Twain")
269
- );
144
+ _this.push_instruction("link Accounts/".concat(_this.account.name, "/Datatypes/Twain"));
270
145
  var curs = true;
271
- if (token.value)
272
- token.value.map(function (entry) {
273
- if (entry.type === "separator") {
274
- curs = false;
275
- return;
276
- }
277
- _this.parse(entry);
278
- if (curs) {
279
- {
280
- _this.push_instruction(
281
- "cursor {*".concat(
282
- _this.is_not_literal(entry.type)
283
- ? "metadata.output:-1"
284
- : "datapath:-1",
285
- "}"
286
- )
287
- );
288
- }
289
- } else {
290
- _this.push_instruction(
291
- "write ".concat(
292
- _this.is_not_literal(entry.type)
293
- ? "{metadata.output:-1}"
294
- : "{datapath:-1}"
295
- )
296
- );
297
- 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", "}"));
298
155
  }
299
- });
156
+ } else {
157
+ _this.push_instruction("write ".concat(_this.is_not_literal(entry.type) ? "{metadata.output:-1}" : "{datapath:-1}"));
158
+ curs = true;
159
+ }
160
+ });
300
161
  _this.push_instruction("pop Twain");
301
162
  } else if (token.type === "variable") {
302
- _this.push_instruction([
303
- "link ".concat(
304
- "".concat(_this.stacks.slice(-1)[0], "/").concat(token.value)
305
- ),
306
- "pop ".concat(token.value),
307
- ]);
163
+ _this.push_instruction(["link ".concat("".concat(_this.stacks.slice(-1)[0], "/").concat(token.value)), "pop ".concat(token.value)]);
308
164
  } else if (token.type === "address") _this.parse_assignment(token);
309
165
  });
310
166
  _defineProperty(this, "is_not_literal", function (type) {
@@ -314,26 +170,15 @@ var Loader = /*#__PURE__*/ _createClass(function Loader(account) {
314
170
  var tokens = linked || line.type ? line : _this.parse_tokens(line);
315
171
  var identifier = tokens[0];
316
172
  if (linked || line.type) {
317
- var line_split = (line.value || line)
318
- .slice(line.value ? null : 1)
319
- .trim()
320
- .split(" ");
173
+ var line_split = (line.value || line).slice(line.value ? null : 1).trim().split(" ");
321
174
  var path = line_split[0].split("/");
322
- _this.push_instruction(
323
- "link ".concat(_this.resolve_addr(path.join("/")))
324
- );
175
+ _this.push_instruction("link ".concat(_this.resolve_addr(path.join("/"))));
325
176
  tokens = !line.type && _this.parse_tokens(line_split.slice(1).join(" "));
326
177
  tokens.unshift && tokens.unshift(null);
327
- if (line.type === "address")
328
- return _this.push_instruction("pop ".concat(path[path.length - 1]));
178
+ if (line.type === "address") return _this.push_instruction("pop ".concat(path[path.length - 1]));
329
179
  } else {
330
180
  _this.push_instruction("chain ".concat(identifier.value));
331
- _this.stack_instruction([
332
- "link ".concat(_this.stacks.slice(-1)[0]),
333
- "chain ".concat(identifier.value),
334
- "pop ".concat(identifier.value),
335
- "pop",
336
- ]);
181
+ _this.stack_instruction(["link ".concat(_this.stacks.slice(-1)[0]), "chain ".concat(identifier.value), "pop ".concat(identifier.value), "pop"]);
337
182
  }
338
183
  var prev_token;
339
184
  if (tokens[1] && tokens[1].type === "opcode") {
@@ -346,45 +191,19 @@ var Loader = /*#__PURE__*/ _createClass(function Loader(account) {
346
191
  prev_token = tokens.slice(-1)[0];
347
192
  }
348
193
  if (tokens.length > 1) {
349
- _this.push_instruction([
350
- "cursor {output}",
351
- "write ".concat(
352
- _this.is_not_literal(prev_token && prev_token.type)
353
- ? "{metadata.output:-1}"
354
- : "{datapath:-1}"
355
- ),
356
- "pop ".concat(identifier.value),
357
- ]);
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)]);
358
195
  } else _this.push_instruction("pop ".concat(identifier.value));
359
196
  });
360
197
  _defineProperty(this, "parse_opcode", function (line) {
361
198
  var tokens = Array.isArray(line) ? line : _this.parse_tokens(line);
362
199
  var op = tokens[0];
363
200
  if (op.type !== "opcode") return _this.parse(op);
364
- _this.push_instruction([
365
- "link Accounts/".concat(_this.account.name, "/Opcodes/").concat(op.value),
366
- "link Accounts/".concat(_this.account.name, "/Datatypes/Twain"),
367
- ]);
201
+ _this.push_instruction(["link Accounts/".concat(_this.account.name, "/Opcodes/").concat(op.value), "link Accounts/".concat(_this.account.name, "/Datatypes/Twain")]);
368
202
  tokens.slice(1).map(function (tok, i) {
369
203
  _this.parse(tok);
370
- _this.push_instruction([
371
- "cursor op".concat(i),
372
- "write ".concat(
373
- _this.is_not_literal(tok.type)
374
- ? "{metadata.output:-1}"
375
- : "{datapath:-1}"
376
- ),
377
- ]);
204
+ _this.push_instruction(["cursor op".concat(i), "write ".concat(_this.is_not_literal(tok.type) ? "{metadata.output:-1}" : "{datapath:-1}")]);
378
205
  });
379
- _this.push_instruction([
380
- "pop Twain",
381
- "cursor inputs",
382
- "write {datapath:-1}",
383
- op.value,
384
- "cursor {output}",
385
- "write {datapath:-1}",
386
- "pop ".concat(op.value),
387
- ]);
206
+ _this.push_instruction(["pop Twain", "cursor inputs", "write {datapath:-1}", op.value, "cursor {output}", "write {datapath:-1}", "pop ".concat(op.value)]);
388
207
  });
389
208
  _defineProperty(this, "resolve_addr", function (addr) {
390
209
  addr = addr.split("/");
@@ -405,15 +224,11 @@ var Loader = /*#__PURE__*/ _createClass(function Loader(account) {
405
224
  _defineProperty(this, "new_stack_instructions", function (new_stack) {
406
225
  var curr_stack = _this.stacks.slice(-1)[0].split("/");
407
226
  new_stack = new_stack.split("/");
408
- if (curr_stack[1] !== new_stack[1]) {
409
- } else {
227
+ if (curr_stack[1] !== new_stack[1]) {} else {
410
228
  var i = 0;
411
229
  while (curr_stack[i] === new_stack[i]) i++;
412
- for (var j = 2; j < new_stack.length; j++)
413
- _this.stack_instruction("chain ".concat(new_stack[j]));
414
- _this.stack_instruction(
415
- "link ".concat(_this.account.physical_address, "/Datatypes/Array")
416
- );
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"));
417
232
  }
418
233
  });
419
234
  _defineProperty(this, "parse_routine", function (line) {
@@ -426,17 +241,9 @@ var Loader = /*#__PURE__*/ _createClass(function Loader(account) {
426
241
  _defineProperty(this, "pop", function () {
427
242
  var _this$instructions;
428
243
  var addr = _this.stacks.splice(-1)[0].split("/");
429
- _this.stack_instruction([
430
- "pop Array",
431
- "cursor {program}",
432
- "write {datapath:-1}",
433
- ]);
434
- for (var j = 2; j < addr.length; j++)
435
- _this.stack_instruction("pop ".concat(addr[j]));
436
- (_this$instructions = _this.instructions).push.apply(
437
- _this$instructions,
438
- _toConsumableArray(_this.instruction_stacks.splice(-1)[0])
439
- );
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]));
440
247
  _this.instruction_indexes.pop();
441
248
  });
442
249
  _defineProperty(this, "compile", function (codes) {
@@ -444,28 +251,26 @@ var Loader = /*#__PURE__*/ _createClass(function Loader(account) {
444
251
  for (var c = 0; c < code_array.length; c++) {
445
252
  var line = code_array[c].trim();
446
253
  if (!line) continue;
447
- if (line === ";") _this.pop();
448
- else if (line.startsWith("link ")) _this.parse_routine(line);
449
- else if (line.startsWith(".") || line.startsWith("@"))
450
- _this.parse_routine(line);
451
- else if (line.startsWith("//")) continue;
452
- else if (line.startsWith(">@")) _this.parse_assignment(line, true);
453
- else if (line.startsWith(">")) _this.parse_assignment(line);
454
- else _this.parse_opcode(line);
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);
455
255
  }
456
256
  });
457
- _defineProperty(this, "run", function (codes, callback) {
257
+ _defineProperty(this, "run", function (codes, cb) {
258
+ if (typeof cb === "boolean") {
259
+ _this.pure = cb;
260
+ cb = null;
261
+ }
458
262
  _this.compile(codes);
459
263
 
460
264
  // console.log(JSON.stringify(this.instructions, null, 2), "hiya");
461
265
 
462
266
  _this.account.load({
463
267
  program: {
464
- instructions: _toConsumableArray(_this.instructions),
268
+ instructions: _toConsumableArray(_this.instructions)
465
269
  },
466
- callback: callback,
270
+ callback: cb
467
271
  });
468
272
  _this.instructions = [];
273
+ _this.pure = false;
469
274
  });
470
275
  this.account = account;
471
276
  this.opcodes = new Array();
@@ -475,4 +280,4 @@ var Loader = /*#__PURE__*/ _createClass(function Loader(account) {
475
280
  this.stacks = new Array(account.physical_address);
476
281
  });
477
282
  var _default = Loader;
478
- exports["default"] = _default;
283
+ exports["default"] = _default;
@@ -1,153 +1,29 @@
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 _Index = _interopRequireDefault(require("../Index"));
7
+ var _Account = _interopRequireDefault(require("./Account"));
8
8
  var _Blockweb = _interopRequireDefault(require("./Blockweb"));
9
9
  var _Oracle = _interopRequireDefault(require("./Oracle"));
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() {
10
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
11
+ 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); }
12
+ function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
13
+ 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."); }
14
+ 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; } }
15
+ function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
16
+ function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
17
+ 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; }
18
+ 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; }
19
+ 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; }
20
+ 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); } }
21
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
22
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
23
+ 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; }
24
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
25
+ 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); }
26
+ var Manager = /*#__PURE__*/_createClass(function Manager() {
151
27
  var _this = this;
152
28
  _classCallCheck(this, Manager);
153
29
  _defineProperty(this, "start_clock", function () {
@@ -178,8 +54,10 @@ var Manager = /*#__PURE__*/ _createClass(function Manager() {
178
54
  _defineProperty(this, "add_account", function (name, meta) {
179
55
  var account = _this.get_account(name);
180
56
  if (!account) {
181
- account = (0, _Index["default"])(name, meta);
182
- _this.accounts[account.name] = account;
57
+ account = new _Account["default"](name, _objectSpread(_objectSpread({}, meta), {}, {
58
+ manager: _this
59
+ }));
60
+ _this.accounts[name] = account;
183
61
  } else if (meta && meta["private"] && !account["private"]) {
184
62
  account["private"] = true;
185
63
  }
@@ -190,10 +68,7 @@ var Manager = /*#__PURE__*/ _createClass(function Manager() {
190
68
  if (track) {
191
69
  var _track$sequence;
192
70
  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
- );
71
+ (_track$sequence = track.sequence).splice.apply(_track$sequence, [track.pointer + 1, 0].concat(_toConsumableArray(program.sequence)));
197
72
  track.pids.push(program.pid);
198
73
  if (!_this.running) {
199
74
  _this.running++;
@@ -201,15 +76,11 @@ var Manager = /*#__PURE__*/ _createClass(function Manager() {
201
76
  _this.start_clock();
202
77
  }
203
78
  } else {
204
- track = _objectSpread(
205
- _objectSpread({}, program),
206
- {},
207
- {
208
- pointer: 0,
209
- pids: [program.pid],
210
- breakpoint: new Array(),
211
- }
212
- );
79
+ track = _objectSpread(_objectSpread({}, program), {}, {
80
+ pointer: 0,
81
+ pids: [program.pid],
82
+ breakpoint: new Array()
83
+ });
213
84
  _this.tracks[track.account.name] = track;
214
85
  _this.running++;
215
86
  _this.running === 1 && _this.start_clock();
@@ -222,4 +93,4 @@ var Manager = /*#__PURE__*/ _createClass(function Manager() {
222
93
  this.oracle = new _Oracle["default"](this);
223
94
  });
224
95
  var _default = Manager;
225
- exports["default"] = _default;
96
+ exports["default"] = _default;
package/package.json CHANGED
@@ -1,14 +1,13 @@
1
1
  {
2
2
  "name": "godprotocol",
3
- "version": "1.0.783",
3
+ "version": "1.0.785",
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
- "prepack": "npmignore",
11
- "build": "babel ./Objects/Manager.js --out-dir build"
10
+ "prepack": "npmignore"
12
11
  },
13
12
  "author": "Savvy",
14
13
  "license": "ISC",
@@ -44,12 +43,9 @@
44
43
  "godprotocol"
45
44
  ],
46
45
  "dependencies": {
47
- "@babel/cli": "latest",
48
- "@babel/core": "^7.19.1",
49
46
  "crypto": "^1.0.1",
50
47
  "elliptic": "^6.5.5",
51
- "fs": "^0.0.1-security",
52
- "babel-preset-env": "^1.7.0"
48
+ "fs": "^0.0.1-security"
53
49
  },
54
50
  "publishConfig": {
55
51
  "ignore": [
@@ -4,7 +4,7 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports["default"] = exports.PORT = void 0;
7
+ exports.extension = exports["default"] = exports.PORT = void 0;
8
8
  var _http = _interopRequireDefault(require("http"));
9
9
  var _functions = require("./functions");
10
10
  var _PORT;
@@ -17,12 +17,22 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
17
17
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
18
18
  function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
19
19
  function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
20
- var PORT = process.env.PORT || 1408;
20
+ var PORT = Number(process.env.PORT) || 1408;
21
21
  exports.PORT = PORT;
22
22
  var cb = function cb(res, data) {
23
23
  if (typeof data !== "string") data = JSON.stringify(data);
24
24
  res(data);
25
25
  };
26
+ var extensions = new Object();
27
+ var extension = function extension(route, handler) {
28
+ var handlers = extensions[route];
29
+ if (!handlers) {
30
+ handlers = new Array();
31
+ extensions[route] = handlers;
32
+ }
33
+ handlers.push(handler);
34
+ };
35
+ exports.extension = extension;
26
36
  var create_server = /*#__PURE__*/function () {
27
37
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(initiator) {
28
38
  var av, server;
@@ -63,13 +73,23 @@ var create_server = /*#__PURE__*/function () {
63
73
  if (req.url === "/create_account") {
64
74
  var account = initiator.create_account(data);
65
75
  res.end(account.stringify(true));
66
- } else {
76
+ } else if (["run", "load", "parse"].includes(req.url.slice(1))) {
67
77
  var payload = _objectSpread(_objectSpread({}, data), {}, {
68
78
  callback: function callback(datagram) {
69
79
  return cb(res.end, datagram);
70
80
  }
71
81
  });
72
82
  initiator.endpoint(req.url.slice(1), payload);
83
+ } else {
84
+ var _extension = extensions[req.url.slice(1)];
85
+ if (_extension) {
86
+ _extension.map(function (ex) {
87
+ typeof ex === "function" && ex(data, {
88
+ req: req,
89
+ res: res
90
+ });
91
+ });
92
+ }
73
93
  }
74
94
  });
75
95
  req.on("error", function (e) {
package/utils/services.js CHANGED
@@ -33,7 +33,7 @@ var post_request = function post_request(payload, cb) {
33
33
  var data = "";
34
34
  res.on("data", function (chunk) {
35
35
  data += chunk;
36
- // cb && cb(chunk);
36
+ cb && cb(chunk);
37
37
  });
38
38
  res.on("end", function () {
39
39
  cb && cb(data);