wao 0.18.3 → 0.18.5

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.
@@ -323,6 +323,7 @@ var _default = exports["default"] = function _default() {
323
323
  res,
324
324
  memory,
325
325
  p,
326
+ __msg,
326
327
  _opt$data,
327
328
  _yield$mem$get$data,
328
329
  _yield$mem$get,
@@ -508,127 +509,130 @@ var _default = exports["default"] = function _default() {
508
509
  height: 0,
509
510
  results: [id]
510
511
  };
512
+ __msg = null;
511
513
  if (!memory) {
512
- _context3.next = 89;
514
+ _context3.next = 90;
513
515
  break;
514
516
  }
515
- _context3.next = 130;
517
+ _context3.next = 132;
516
518
  break;
517
- case 89:
519
+ case 90:
518
520
  if (!(_tags["On-Boot"] || true)) {
519
- _context3.next = 129;
521
+ _context3.next = 131;
520
522
  break;
521
523
  }
522
524
  data = "";
523
525
  if (!(_tags["On-Boot"] === "Data")) {
524
- _context3.next = 95;
526
+ _context3.next = 96;
525
527
  break;
526
528
  }
527
529
  data = (_opt$data = opt.data) !== null && _opt$data !== void 0 ? _opt$data : "";
528
- _context3.next = 116;
530
+ _context3.next = 117;
529
531
  break;
530
- case 95:
531
- _context3.next = 97;
532
+ case 96:
533
+ _context3.next = 98;
532
534
  return mem.get("msgs", _tags["On-Boot"]);
533
- case 97:
535
+ case 98:
534
536
  _context3.t10 = _yield$mem$get = _context3.sent;
535
537
  _context3.t9 = _context3.t10 === null;
536
538
  if (_context3.t9) {
537
- _context3.next = 101;
539
+ _context3.next = 102;
538
540
  break;
539
541
  }
540
542
  _context3.t9 = _yield$mem$get === void 0;
541
- case 101:
543
+ case 102:
542
544
  if (!_context3.t9) {
543
- _context3.next = 105;
545
+ _context3.next = 106;
544
546
  break;
545
547
  }
546
548
  _context3.t11 = void 0;
547
- _context3.next = 106;
549
+ _context3.next = 107;
548
550
  break;
549
- case 105:
550
- _context3.t11 = _yield$mem$get.data;
551
551
  case 106:
552
+ _context3.t11 = _yield$mem$get.data;
553
+ case 107:
552
554
  _context3.t12 = _yield$mem$get$data = _context3.t11;
553
555
  _context3.t8 = _context3.t12 !== null;
554
556
  if (!_context3.t8) {
555
- _context3.next = 110;
557
+ _context3.next = 111;
556
558
  break;
557
559
  }
558
560
  _context3.t8 = _yield$mem$get$data !== void 0;
559
- case 110:
561
+ case 111:
560
562
  if (!_context3.t8) {
561
- _context3.next = 114;
563
+ _context3.next = 115;
562
564
  break;
563
565
  }
564
566
  _context3.t13 = _yield$mem$get$data;
565
- _context3.next = 115;
567
+ _context3.next = 116;
566
568
  break;
567
- case 114:
568
- _context3.t13 = "";
569
569
  case 115:
570
- data = _context3.t13;
570
+ _context3.t13 = "";
571
571
  case 116:
572
- _context3.next = 118;
572
+ data = _context3.t13;
573
+ case 117:
574
+ _context3.next = 119;
573
575
  return genMsg(id, p, data, opt.tags, owner, msg_owner, true);
574
- case 118:
576
+ case 119:
575
577
  msg = _context3.sent;
576
- _context3.next = 121;
578
+ __msg = msg;
579
+ _context3.next = 123;
577
580
  return genEnv({
578
581
  pid: p.id,
579
582
  owner: p.owner,
580
583
  module: p.module
581
584
  });
582
- case 121:
585
+ case 123:
583
586
  _env = _context3.sent;
584
- _context3.next = 124;
587
+ _context3.next = 126;
585
588
  return _module.handle(null, msg, _env);
586
- case 124:
589
+ case 126:
587
590
  res = _context3.sent;
588
591
  p.memory = res.Memory;
589
592
  delete res.Memory;
590
- _context3.next = 130;
593
+ _context3.next = 132;
591
594
  break;
592
- case 129:
595
+ case 131:
593
596
  p.height += 1;
594
- case 130:
597
+ case 132:
595
598
  _msg = _objectSpread(_objectSpread({}, (0, _ramda.o)((0, _ramda.dissoc)("signer"), (0, _ramda.dissoc)("memory"))(opt)), {}, {
596
- res: res
599
+ res: res,
600
+ msg: __msg
597
601
  });
598
- _context3.next = 133;
602
+ _context3.next = 135;
599
603
  return mem.set(_msg, "msgs", id);
600
- case 133:
604
+ case 135:
601
605
  if (!_tags["Cron-Interval"]) {
602
- _context3.next = 157;
606
+ _context3.next = 159;
603
607
  break;
604
608
  }
605
609
  _tags$CronInterval$s = _tags["Cron-Interval"].split("-"), _tags$CronInterval$s2 = _slicedToArray(_tags$CronInterval$s, 2), num = _tags$CronInterval$s2[0], unit = _tags$CronInterval$s2[1];
606
610
  _int = 0;
607
611
  _context3.t14 = unit.replace(/s$/, "");
608
- _context3.next = _context3.t14 === "millisecond" ? 139 : _context3.t14 === "second" ? 141 : _context3.t14 === "minute" ? 143 : _context3.t14 === "hour" ? 145 : _context3.t14 === "day" ? 147 : _context3.t14 === "month" ? 149 : _context3.t14 === "year" ? 151 : 153;
612
+ _context3.next = _context3.t14 === "millisecond" ? 141 : _context3.t14 === "second" ? 143 : _context3.t14 === "minute" ? 145 : _context3.t14 === "hour" ? 147 : _context3.t14 === "day" ? 149 : _context3.t14 === "month" ? 151 : _context3.t14 === "year" ? 153 : 155;
609
613
  break;
610
- case 139:
611
- _int = num;
612
- return _context3.abrupt("break", 153);
613
614
  case 141:
614
- _int = num * 1000;
615
- return _context3.abrupt("break", 153);
615
+ _int = num;
616
+ return _context3.abrupt("break", 155);
616
617
  case 143:
617
- _int = num * 1000 * 60;
618
- return _context3.abrupt("break", 153);
618
+ _int = num * 1000;
619
+ return _context3.abrupt("break", 155);
619
620
  case 145:
620
- _int = num * 1000 * 60 * 60;
621
- return _context3.abrupt("break", 153);
621
+ _int = num * 1000 * 60;
622
+ return _context3.abrupt("break", 155);
622
623
  case 147:
623
- _int = num * 1000 * 60 * 60 * 24;
624
- return _context3.abrupt("break", 153);
624
+ _int = num * 1000 * 60 * 60;
625
+ return _context3.abrupt("break", 155);
625
626
  case 149:
626
- _int = num * 1000 * 60 * 60 * 24 * 30;
627
- return _context3.abrupt("break", 153);
627
+ _int = num * 1000 * 60 * 60 * 24;
628
+ return _context3.abrupt("break", 155);
628
629
  case 151:
629
- _int = num * 1000 * 60 * 60 * 24 * 365;
630
- return _context3.abrupt("break", 153);
630
+ _int = num * 1000 * 60 * 60 * 24 * 30;
631
+ return _context3.abrupt("break", 155);
631
632
  case 153:
633
+ _int = num * 1000 * 60 * 60 * 24 * 365;
634
+ return _context3.abrupt("break", 155);
635
+ case 155:
632
636
  cronTags = [];
633
637
  for (_k in _tags) {
634
638
  if (/^Cron-Tag-/.test(_k)) {
@@ -640,13 +644,13 @@ var _default = exports["default"] = function _default() {
640
644
  }
641
645
  p.cronTags = cronTags;
642
646
  p.span = _int;
643
- case 157:
644
- _context3.next = 159;
645
- return mem.set(p, "env", id);
646
647
  case 159:
648
+ _context3.next = 161;
649
+ return mem.set(p, "env", id);
650
+ case 161:
647
651
  delete ongoing[id];
648
652
  return _context3.abrupt("return", id);
649
- case 161:
653
+ case 163:
650
654
  case "end":
651
655
  return _context3.stop();
652
656
  }
@@ -851,7 +855,8 @@ var _default = exports["default"] = function _default() {
851
855
  return mem.set(p, "env", opt.process);
852
856
  case 98:
853
857
  _msg = _objectSpread(_objectSpread({}, (0, _ramda.dissoc)("signer", _opt)), {}, {
854
- res: res
858
+ res: res,
859
+ msg: msg
855
860
  });
856
861
  _context4.next = 101;
857
862
  return mem.set(_msg, "msgs", opt.message);
@@ -1257,7 +1262,8 @@ var _default = exports["default"] = function _default() {
1257
1262
  return mem.set(p, "env", opt.process);
1258
1263
  case 135:
1259
1264
  _msg2 = _objectSpread(_objectSpread({}, (0, _ramda.dissoc)("signer", _opt)), {}, {
1260
- res: res
1265
+ res: res,
1266
+ msg: msg
1261
1267
  });
1262
1268
  _context5.next = 138;
1263
1269
  return mem.set(_msg2, "msgs", id);
package/cjs/armem-base.js CHANGED
@@ -325,7 +325,7 @@ var ArMemBase = exports["default"] = /*#__PURE__*/function () {
325
325
  key: "init",
326
326
  value: function () {
327
327
  var _init = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
328
- var _i, _arr, v, _i2, _arr2, _this$_v, _v, items, _iterator, _step, v2, key, field, v3, _i3, _arr3, _v2, _i4, _arr4, _v3;
328
+ var _i, _arr, v, val, _i2, _arr2, _this$_v, _v, items, _iterator, _step, v2, key, field, v3, _i3, _arr3, _v2, _i4, _arr4, _v3;
329
329
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
330
330
  while (1) switch (_context5.prev = _context5.next) {
331
331
  case 0:
@@ -344,128 +344,129 @@ var ArMemBase = exports["default"] = /*#__PURE__*/function () {
344
344
  return this._init();
345
345
  case 6:
346
346
  if (!this.db) {
347
- _context5.next = 57;
347
+ _context5.next = 58;
348
348
  break;
349
349
  }
350
350
  _i = 0, _arr = ["height", "blocks"];
351
351
  case 8:
352
352
  if (!(_i < _arr.length)) {
353
- _context5.next = 16;
353
+ _context5.next = 17;
354
354
  break;
355
355
  }
356
356
  v = _arr[_i];
357
357
  _context5.next = 12;
358
- return this.get(v);
358
+ return this.db.get(v);
359
359
  case 12:
360
- this[v] = _context5.sent;
361
- case 13:
360
+ val = _context5.sent;
361
+ if (val) this[v] = val;
362
+ case 14:
362
363
  _i++;
363
364
  _context5.next = 8;
364
365
  break;
365
- case 16:
366
- _i2 = 0, _arr2 = ["items", "txs", "env", "modules", "wasms", "addrmap", "blockmap", "modmap", "msgs"];
367
366
  case 17:
367
+ _i2 = 0, _arr2 = ["items", "txs", "env", "modules", "wasms", "addrmap", "blockmap", "modmap", "msgs"];
368
+ case 18:
368
369
  if (!(_i2 < _arr2.length)) {
369
- _context5.next = 55;
370
+ _context5.next = 56;
370
371
  break;
371
372
  }
372
373
  _v = _arr2[_i2];
373
374
  (_this$_v = this[_v]) !== null && _this$_v !== void 0 ? _this$_v : this[_v] = {};
374
- _context5.next = 22;
375
+ _context5.next = 23;
375
376
  return this.db.getKeys({
376
377
  start: _v,
377
378
  end: _v + "a"
378
379
  });
379
- case 22:
380
+ case 23:
380
381
  items = _context5.sent;
381
382
  _iterator = _createForOfIteratorHelper(items || []);
382
- _context5.prev = 24;
383
+ _context5.prev = 25;
383
384
  _iterator.s();
384
- case 26:
385
+ case 27:
385
386
  if ((_step = _iterator.n()).done) {
386
- _context5.next = 44;
387
+ _context5.next = 45;
387
388
  break;
388
389
  }
389
390
  v2 = _step.value;
390
391
  key = v2.split(".")[0];
391
392
  field = v2.split(".")[1];
392
393
  if (!(key === _v)) {
393
- _context5.next = 42;
394
+ _context5.next = 43;
394
395
  break;
395
396
  }
396
397
  if (!key.match(/^env/)) {
397
- _context5.next = 39;
398
+ _context5.next = 40;
398
399
  break;
399
400
  }
400
- _context5.next = 34;
401
+ _context5.next = 35;
401
402
  return this.db.get(v2);
402
- case 34:
403
+ case 35:
403
404
  v3 = _context5.sent;
404
405
  if ((0, _ramda.is)(Uint8Array, v3.memory)) {
405
406
  v3.compressed = true;
406
407
  }
407
408
  this[_v][field] = v3;
408
- _context5.next = 42;
409
+ _context5.next = 43;
409
410
  break;
410
- case 39:
411
- _context5.next = 41;
411
+ case 40:
412
+ _context5.next = 42;
412
413
  return this.db.get(v2);
413
- case 41:
414
- this[_v][field] = _context5.sent;
415
414
  case 42:
416
- _context5.next = 26;
415
+ this[_v][field] = _context5.sent;
416
+ case 43:
417
+ _context5.next = 27;
417
418
  break;
418
- case 44:
419
- _context5.next = 49;
419
+ case 45:
420
+ _context5.next = 50;
420
421
  break;
421
- case 46:
422
- _context5.prev = 46;
423
- _context5.t0 = _context5["catch"](24);
422
+ case 47:
423
+ _context5.prev = 47;
424
+ _context5.t0 = _context5["catch"](25);
424
425
  _iterator.e(_context5.t0);
425
- case 49:
426
- _context5.prev = 49;
426
+ case 50:
427
+ _context5.prev = 50;
427
428
  _iterator.f();
428
- return _context5.finish(49);
429
- case 52:
429
+ return _context5.finish(50);
430
+ case 53:
430
431
  _i2++;
431
- _context5.next = 17;
432
+ _context5.next = 18;
432
433
  break;
433
- case 55:
434
- _context5.next = 73;
434
+ case 56:
435
+ _context5.next = 74;
435
436
  break;
436
- case 57:
437
- _i3 = 0, _arr3 = ["height", "blocks"];
438
437
  case 58:
438
+ _i3 = 0, _arr3 = ["height", "blocks"];
439
+ case 59:
439
440
  if (!(_i3 < _arr3.length)) {
440
- _context5.next = 65;
441
+ _context5.next = 66;
441
442
  break;
442
443
  }
443
444
  _v2 = _arr3[_i3];
444
- _context5.next = 62;
445
+ _context5.next = 63;
445
446
  return this.set(this[_v2], _v2);
446
- case 62:
447
+ case 63:
447
448
  _i3++;
448
- _context5.next = 58;
449
+ _context5.next = 59;
449
450
  break;
450
- case 65:
451
- _i4 = 0, _arr4 = ["modules", "wasms", "addrmap", "blockmap"];
452
451
  case 66:
452
+ _i4 = 0, _arr4 = ["modules", "wasms", "addrmap", "blockmap"];
453
+ case 67:
453
454
  if (!(_i4 < _arr4.length)) {
454
- _context5.next = 73;
455
+ _context5.next = 74;
455
456
  break;
456
457
  }
457
458
  _v3 = _arr4[_i4];
458
- _context5.next = 70;
459
+ _context5.next = 71;
459
460
  return this.putAll(_v3);
460
- case 70:
461
+ case 71:
461
462
  _i4++;
462
- _context5.next = 66;
463
+ _context5.next = 67;
463
464
  break;
464
- case 73:
465
+ case 74:
465
466
  case "end":
466
467
  return _context5.stop();
467
468
  }
468
- }, _callee5, this, [[24, 46, 49, 52]]);
469
+ }, _callee5, this, [[25, 47, 50, 53]]);
469
470
  }));
470
471
  function init() {
471
472
  return _init.apply(this, arguments);
@@ -199,6 +199,7 @@ export default ({ AR, scheduler, mu, su, cu, acc, AoLoader, ArMem } = {}) => {
199
199
  height: 0,
200
200
  results: [id],
201
201
  }
202
+ let __msg = null
202
203
  if (memory) {
203
204
  // forking...
204
205
  } else if (_tags["On-Boot"] || true) {
@@ -206,6 +207,7 @@ export default ({ AR, scheduler, mu, su, cu, acc, AoLoader, ArMem } = {}) => {
206
207
  if (_tags["On-Boot"] === "Data") data = opt.data ?? ""
207
208
  else data = (await mem.get("msgs", _tags["On-Boot"]))?.data ?? ""
208
209
  let msg = await genMsg(id, p, data, opt.tags, owner, msg_owner, true)
210
+ __msg = msg
209
211
  const _env = await genEnv({
210
212
  pid: p.id,
211
213
  owner: p.owner,
@@ -217,7 +219,11 @@ export default ({ AR, scheduler, mu, su, cu, acc, AoLoader, ArMem } = {}) => {
217
219
  } else {
218
220
  p.height += 1
219
221
  }
220
- const _msg = { ...o(dissoc("signer"), dissoc("memory"))(opt), res }
222
+ const _msg = {
223
+ ...o(dissoc("signer"), dissoc("memory"))(opt),
224
+ res,
225
+ msg: __msg,
226
+ }
221
227
  await mem.set(_msg, "msgs", id)
222
228
  if (_tags["Cron-Interval"]) {
223
229
  let [num, unit] = _tags["Cron-Interval"].split("-")
@@ -349,7 +355,7 @@ export default ({ AR, scheduler, mu, su, cu, acc, AoLoader, ArMem } = {}) => {
349
355
  delete res.Memory
350
356
  p.results.push(opt.message)
351
357
  await mem.set(p, "env", opt.process)
352
- const _msg = { ...dissoc("signer", _opt), res }
358
+ const _msg = { ...dissoc("signer", _opt), res, msg }
353
359
  await mem.set(_msg, "msgs", opt.message)
354
360
  for (const v of res.Messages ?? []) {
355
361
  if (await mem.get("env", v.Target)) {
@@ -486,7 +492,7 @@ export default ({ AR, scheduler, mu, su, cu, acc, AoLoader, ArMem } = {}) => {
486
492
  delete res.Memory
487
493
  p.results.push(id)
488
494
  await mem.set(p, "env", opt.process)
489
- const _msg = { ...dissoc("signer", _opt), res }
495
+ const _msg = { ...dissoc("signer", _opt), res, msg }
490
496
  await mem.set(_msg, "msgs", id)
491
497
  } catch (e) {
492
498
  console.log(e)
package/esm/armem-base.js CHANGED
@@ -173,7 +173,10 @@ export default class ArMemBase {
173
173
  this.isInit = true
174
174
  if (typeof this._init === "function") await this._init()
175
175
  if (this.db) {
176
- for (const v of ["height", "blocks"]) this[v] = await this.get(v)
176
+ for (const v of ["height", "blocks"]) {
177
+ const val = await this.db.get(v)
178
+ if (val) this[v] = val
179
+ }
177
180
  for (const v of [
178
181
  "items",
179
182
  "txs",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wao",
3
- "version": "0.18.3",
3
+ "version": "0.18.5",
4
4
  "bin": {
5
5
  "wao": "./cjs/cli.js",
6
6
  "wao-esm": "./esm/cli.js"