wao 0.5.4 → 0.5.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.
package/cjs/ao.js CHANGED
@@ -683,7 +683,7 @@ var AO = /*#__PURE__*/function () {
683
683
  _context9.next = 15;
684
684
  return (0, _utils.wait)(1);
685
685
  case 15:
686
- if (!(Date.now() - start < (_this3.local ? timeout / 1000 : timeout))) {
686
+ if (!(Date.now() - start < timeout)) {
687
687
  _context9.next = 21;
688
688
  break;
689
689
  }
package/cjs/aoconnect.js CHANGED
@@ -150,6 +150,7 @@ var connect = exports.connect = function connect(mem) {
150
150
  format,
151
151
  wasm,
152
152
  _mem$wasms$mod2,
153
+ now,
153
154
  handle,
154
155
  ex,
155
156
  _iterator,
@@ -215,24 +216,26 @@ var connect = exports.connect = function connect(mem) {
215
216
  format = mem.wasms[mod].format;
216
217
  }
217
218
  (_format = format) !== null && _format !== void 0 ? _format : format = "wasm64-unknown-emscripten-draft_2024_02_15";
218
- _context.next = 16;
219
+ now = Date.now;
220
+ _context.next = 17;
219
221
  return (0, _aoLoader["default"])(wasm, {
220
222
  format: format,
221
223
  mode: "test",
222
224
  WeaveDrive: WeaveDrive
223
225
  });
224
- case 16:
226
+ case 17:
225
227
  handle = _context.sent;
228
+ Date.now = now;
226
229
  _module = {
227
230
  handle: handle,
228
231
  id: mod
229
232
  };
230
233
  if (mod) {
231
- _context.next = 20;
234
+ _context.next = 22;
232
235
  break;
233
236
  }
234
237
  throw Error("module not found");
235
- case 20:
238
+ case 22:
236
239
  opt.tags = (0, _utils.buildTags)(null, (0, _ramda.mergeLeft)((0, _utils.tags)((_opt$tags = opt.tags) !== null && _opt$tags !== void 0 ? _opt$tags : []), {
237
240
  "Data-Protocol": "ao",
238
241
  Variant: "ao.TN.1",
@@ -259,14 +262,14 @@ var connect = exports.connect = function connect(mem) {
259
262
  name: "Type",
260
263
  value: "Process"
261
264
  });
262
- _context.next = 28;
265
+ _context.next = 30;
263
266
  return ar.dataitem({
264
267
  item: opt.item,
265
268
  data: opt.data,
266
269
  signer: opt.signer,
267
270
  tags: (0, _utils.tags)(opt.tags)
268
271
  });
269
- case 28:
272
+ case 30:
270
273
  _yield$ar$dataitem = _context.sent;
271
274
  id = _yield$ar$dataitem.id;
272
275
  owner = _yield$ar$dataitem.owner;
@@ -274,9 +277,9 @@ var connect = exports.connect = function connect(mem) {
274
277
  __tags = _yield$ar$dataitem.tags;
275
278
  opt.tags = (0, _utils.buildTags)(null, __tags);
276
279
  if (opt.item) opt.data = _base64url["default"].decode(item.data);
277
- _context.next = 37;
280
+ _context.next = 39;
278
281
  return ar.postItem(item, _test.su.jwk);
279
- case 37:
282
+ case 39:
280
283
  _tags = (0, _utils.tags)(opt.tags);
281
284
  res = null;
282
285
  memory = null;
@@ -295,7 +298,7 @@ var connect = exports.connect = function connect(mem) {
295
298
  opt: opt
296
299
  };
297
300
  if (!(_tags["On-Boot"] || true)) {
298
- _context.next = 55;
301
+ _context.next = 57;
299
302
  break;
300
303
  }
301
304
  data = "";
@@ -308,51 +311,51 @@ var connect = exports.connect = function connect(mem) {
308
311
  auth: _test.mu.addr
309
312
  });
310
313
  _t = (0, _utils.tags)(msg.Tags);
311
- _context.next = 49;
314
+ _context.next = 51;
312
315
  return _module.handle(null, msg, _env);
313
- case 49:
316
+ case 51:
314
317
  res = _context.sent;
315
318
  p.memory = res.Memory;
316
319
  delete res.Memory;
317
320
  p.res[id] = res;
318
- _context.next = 56;
321
+ _context.next = 58;
319
322
  break;
320
- case 55:
323
+ case 57:
321
324
  p.height += 1;
322
- case 56:
325
+ case 58:
323
326
  mem.msgs[id] = opt;
324
327
  mem.env[id] = p;
325
328
  if (!_tags["Cron-Interval"]) {
326
- _context.next = 82;
329
+ _context.next = 84;
327
330
  break;
328
331
  }
329
332
  _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];
330
333
  _int = 0;
331
334
  _context.t0 = unit.replace(/s$/, "");
332
- _context.next = _context.t0 === "millisecond" ? 64 : _context.t0 === "second" ? 66 : _context.t0 === "minute" ? 68 : _context.t0 === "hour" ? 70 : _context.t0 === "day" ? 72 : _context.t0 === "month" ? 74 : _context.t0 === "year" ? 76 : 78;
335
+ _context.next = _context.t0 === "millisecond" ? 66 : _context.t0 === "second" ? 68 : _context.t0 === "minute" ? 70 : _context.t0 === "hour" ? 72 : _context.t0 === "day" ? 74 : _context.t0 === "month" ? 76 : _context.t0 === "year" ? 78 : 80;
333
336
  break;
334
- case 64:
335
- _int = num;
336
- return _context.abrupt("break", 78);
337
337
  case 66:
338
- _int = num * 1000;
339
- return _context.abrupt("break", 78);
338
+ _int = num;
339
+ return _context.abrupt("break", 80);
340
340
  case 68:
341
- _int = num * 1000 * 60;
342
- return _context.abrupt("break", 78);
341
+ _int = num * 1000;
342
+ return _context.abrupt("break", 80);
343
343
  case 70:
344
- _int = num * 1000 * 60 * 60;
345
- return _context.abrupt("break", 78);
344
+ _int = num * 1000 * 60;
345
+ return _context.abrupt("break", 80);
346
346
  case 72:
347
- _int = num * 1000 * 60 * 60 * 24;
348
- return _context.abrupt("break", 78);
347
+ _int = num * 1000 * 60 * 60;
348
+ return _context.abrupt("break", 80);
349
349
  case 74:
350
- _int = num * 1000 * 60 * 60 * 24 * 30;
351
- return _context.abrupt("break", 78);
350
+ _int = num * 1000 * 60 * 60 * 24;
351
+ return _context.abrupt("break", 80);
352
352
  case 76:
353
- _int = num * 1000 * 60 * 60 * 24 * 365;
354
- return _context.abrupt("break", 78);
353
+ _int = num * 1000 * 60 * 60 * 24 * 30;
354
+ return _context.abrupt("break", 80);
355
355
  case 78:
356
+ _int = num * 1000 * 60 * 60 * 24 * 365;
357
+ return _context.abrupt("break", 80);
358
+ case 80:
356
359
  cronTags = [];
357
360
  for (k in _tags) {
358
361
  if (/^Cron-Tag-/.test(k)) {
@@ -364,9 +367,9 @@ var connect = exports.connect = function connect(mem) {
364
367
  }
365
368
  mem.env[id].cronTags = cronTags;
366
369
  mem.env[id].span = _int;
367
- case 82:
370
+ case 84:
368
371
  return _context.abrupt("return", id);
369
- case 83:
372
+ case 85:
370
373
  case "end":
371
374
  return _context.stop();
372
375
  }
@@ -393,6 +396,12 @@ var connect = exports.connect = function connect(mem) {
393
396
  while (1) switch (_context2.prev = _context2.next) {
394
397
  case 0:
395
398
  p = mem.env[opt.process];
399
+ if (p) {
400
+ _context2.next = 3;
401
+ break;
402
+ }
403
+ return _context2.abrupt("return", null);
404
+ case 3:
396
405
  _opt = mem.msgs[opt.message];
397
406
  hash = genHashChain(p.hash, opt.message);
398
407
  p.hash = hash;
@@ -410,52 +419,52 @@ var connect = exports.connect = function connect(mem) {
410
419
  "Hash-Chain": hash
411
420
  }));
412
421
  p.epochs.push([opt.message]);
413
- _context2.next = 8;
422
+ _context2.next = 10;
414
423
  return ar.dataitem({
415
424
  data: opt.data,
416
425
  signer: opt.signer,
417
426
  tags: (0, _utils.tags)(opt.tags),
418
427
  target: opt.process
419
428
  });
420
- case 8:
429
+ case 10:
421
430
  _yield$ar$dataitem2 = _context2.sent;
422
431
  id = _yield$ar$dataitem2.id;
423
432
  owner = _yield$ar$dataitem2.owner;
424
433
  item = _yield$ar$dataitem2.item;
425
- _context2.next = 14;
434
+ _context2.next = 16;
426
435
  return ar.postItem(item, _test.su.jwk);
427
- case 14:
428
- _context2.prev = 14;
436
+ case 16:
437
+ _context2.prev = 16;
429
438
  data = (_opt$data2 = _opt.data) !== null && _opt$data2 !== void 0 ? _opt$data2 : "";
430
439
  _tags = _opt.tags;
431
440
  from = (_ref6 = (_opt$from = _opt.from) !== null && _opt$from !== void 0 ? _opt$from : opt.from) !== null && _ref6 !== void 0 ? _ref6 : owner;
432
441
  if (!_opt.item) {
433
- _context2.next = 35;
442
+ _context2.next = 37;
434
443
  break;
435
444
  }
436
- _context2.prev = 19;
445
+ _context2.prev = 21;
437
446
  data = _base64url["default"].decode(_opt.item.data);
438
447
  _tags = _opt.item.tags;
439
448
  if (from) {
440
- _context2.next = 30;
449
+ _context2.next = 32;
441
450
  break;
442
451
  }
443
452
  raw_owner = _opt.item.rawOwner;
444
453
  _context2.t0 = Buffer;
445
- _context2.next = 27;
454
+ _context2.next = 29;
446
455
  return _crypto["default"].subtle.digest("SHA-256", raw_owner);
447
- case 27:
456
+ case 29:
448
457
  _context2.t1 = _context2.sent;
449
458
  hashBuffer = _context2.t0.from.call(_context2.t0, _context2.t1);
450
459
  from = _base64url["default"].encode(hashBuffer);
451
- case 30:
452
- _context2.next = 35;
453
- break;
454
460
  case 32:
455
- _context2.prev = 32;
456
- _context2.t2 = _context2["catch"](19);
461
+ _context2.next = 37;
462
+ break;
463
+ case 34:
464
+ _context2.prev = 34;
465
+ _context2.t2 = _context2["catch"](21);
457
466
  console.log(_context2.t2);
458
- case 35:
467
+ case 37:
459
468
  // check: is owner=mu.addr right?
460
469
  msg = genMsg(opt.message, p, data, _tags, from, _test.mu.addr);
461
470
  _env = genEnv({
@@ -464,32 +473,32 @@ var connect = exports.connect = function connect(mem) {
464
473
  module: p.module,
465
474
  auth: _test.mu.addr
466
475
  });
467
- _context2.next = 39;
476
+ _context2.next = 41;
468
477
  return p.handle(p.memory, msg, _env);
469
- case 39:
478
+ case 41:
470
479
  res = _context2.sent;
471
480
  p.memory = res.Memory;
472
481
  delete res.Memory;
473
482
  p.res[opt.message] = res;
474
483
  p.results.push(opt.message);
475
484
  p.txs.unshift(_objectSpread({
476
- id: opt.message
485
+ id: id
477
486
  }, opt));
478
487
  mem.msgs[opt.message] = _opt;
479
488
  _iterator2 = _createForOfIteratorHelper((_res$Messages = res.Messages) !== null && _res$Messages !== void 0 ? _res$Messages : []);
480
- _context2.prev = 47;
489
+ _context2.prev = 49;
481
490
  _iterator2.s();
482
- case 49:
491
+ case 51:
483
492
  if ((_step2 = _iterator2.n()).done) {
484
- _context2.next = 56;
493
+ _context2.next = 58;
485
494
  break;
486
495
  }
487
496
  v = _step2.value;
488
497
  if (!mem.env[v.Target]) {
489
- _context2.next = 54;
498
+ _context2.next = 56;
490
499
  break;
491
500
  }
492
- _context2.next = 54;
501
+ _context2.next = 56;
493
502
  return message({
494
503
  process: v.Target,
495
504
  tags: v.Tags,
@@ -497,32 +506,32 @@ var connect = exports.connect = function connect(mem) {
497
506
  signer: _test.mu.signer,
498
507
  from: opt.process
499
508
  });
500
- case 54:
501
- _context2.next = 49;
502
- break;
503
509
  case 56:
504
- _context2.next = 61;
510
+ _context2.next = 51;
505
511
  break;
506
512
  case 58:
507
- _context2.prev = 58;
508
- _context2.t3 = _context2["catch"](47);
513
+ _context2.next = 63;
514
+ break;
515
+ case 60:
516
+ _context2.prev = 60;
517
+ _context2.t3 = _context2["catch"](49);
509
518
  _iterator2.e(_context2.t3);
510
- case 61:
511
- _context2.prev = 61;
519
+ case 63:
520
+ _context2.prev = 63;
512
521
  _iterator2.f();
513
- return _context2.finish(61);
514
- case 64:
522
+ return _context2.finish(63);
523
+ case 66:
515
524
  _iterator3 = _createForOfIteratorHelper((_res$Spawns = res.Spawns) !== null && _res$Spawns !== void 0 ? _res$Spawns : []);
516
- _context2.prev = 65;
525
+ _context2.prev = 67;
517
526
  _iterator3.s();
518
- case 67:
527
+ case 69:
519
528
  if ((_step3 = _iterator3.n()).done) {
520
- _context2.next = 74;
529
+ _context2.next = 76;
521
530
  break;
522
531
  }
523
532
  _v = _step3.value;
524
533
  __tags = (0, _utils.tags)(_v.Tags);
525
- _context2.next = 72;
534
+ _context2.next = 74;
526
535
  return spawn({
527
536
  module: __tags.Module,
528
537
  scheduler: _test.scheduler,
@@ -531,87 +540,87 @@ var connect = exports.connect = function connect(mem) {
531
540
  from: __tags["From-Process"],
532
541
  signer: _test.mu.signer
533
542
  });
534
- case 72:
535
- _context2.next = 67;
536
- break;
537
543
  case 74:
538
- _context2.next = 79;
544
+ _context2.next = 69;
539
545
  break;
540
546
  case 76:
541
- _context2.prev = 76;
542
- _context2.t4 = _context2["catch"](65);
547
+ _context2.next = 81;
548
+ break;
549
+ case 78:
550
+ _context2.prev = 78;
551
+ _context2.t4 = _context2["catch"](67);
543
552
  _iterator3.e(_context2.t4);
544
- case 79:
545
- _context2.prev = 79;
553
+ case 81:
554
+ _context2.prev = 81;
546
555
  _iterator3.f();
547
- return _context2.finish(79);
548
- case 82:
556
+ return _context2.finish(81);
557
+ case 84:
549
558
  _iterator4 = _createForOfIteratorHelper((_res$Assignments = res.Assignments) !== null && _res$Assignments !== void 0 ? _res$Assignments : []);
550
- _context2.prev = 83;
559
+ _context2.prev = 85;
551
560
  _iterator4.s();
552
- case 85:
561
+ case 87:
553
562
  if ((_step4 = _iterator4.n()).done) {
554
- _context2.next = 106;
563
+ _context2.next = 108;
555
564
  break;
556
565
  }
557
566
  _v2 = _step4.value;
558
567
  _iterator5 = _createForOfIteratorHelper(_v2.Processes);
559
- _context2.prev = 88;
568
+ _context2.prev = 90;
560
569
  _iterator5.s();
561
- case 90:
570
+ case 92:
562
571
  if ((_step5 = _iterator5.n()).done) {
563
- _context2.next = 96;
572
+ _context2.next = 98;
564
573
  break;
565
574
  }
566
575
  v2 = _step5.value;
567
- _context2.next = 94;
576
+ _context2.next = 96;
568
577
  return _assign({
569
578
  message: _v2.Message,
570
579
  process: v2,
571
580
  from: opt.process,
572
581
  signer: _test.mu.signer
573
582
  });
574
- case 94:
575
- _context2.next = 90;
576
- break;
577
583
  case 96:
578
- _context2.next = 101;
584
+ _context2.next = 92;
579
585
  break;
580
586
  case 98:
581
- _context2.prev = 98;
582
- _context2.t5 = _context2["catch"](88);
587
+ _context2.next = 103;
588
+ break;
589
+ case 100:
590
+ _context2.prev = 100;
591
+ _context2.t5 = _context2["catch"](90);
583
592
  _iterator5.e(_context2.t5);
584
- case 101:
585
- _context2.prev = 101;
593
+ case 103:
594
+ _context2.prev = 103;
586
595
  _iterator5.f();
587
- return _context2.finish(101);
588
- case 104:
589
- _context2.next = 85;
590
- break;
596
+ return _context2.finish(103);
591
597
  case 106:
592
- _context2.next = 111;
598
+ _context2.next = 87;
593
599
  break;
594
600
  case 108:
595
- _context2.prev = 108;
596
- _context2.t6 = _context2["catch"](83);
601
+ _context2.next = 113;
602
+ break;
603
+ case 110:
604
+ _context2.prev = 110;
605
+ _context2.t6 = _context2["catch"](85);
597
606
  _iterator4.e(_context2.t6);
598
- case 111:
599
- _context2.prev = 111;
607
+ case 113:
608
+ _context2.prev = 113;
600
609
  _iterator4.f();
601
- return _context2.finish(111);
602
- case 114:
610
+ return _context2.finish(113);
611
+ case 116:
603
612
  return _context2.abrupt("return", id);
604
- case 117:
605
- _context2.prev = 117;
606
- _context2.t7 = _context2["catch"](14);
613
+ case 119:
614
+ _context2.prev = 119;
615
+ _context2.t7 = _context2["catch"](16);
607
616
  console.log(_context2.t7);
608
- case 120:
617
+ case 122:
609
618
  return _context2.abrupt("return", null);
610
- case 121:
619
+ case 123:
611
620
  case "end":
612
621
  return _context2.stop();
613
622
  }
614
- }, _callee2, null, [[14, 117], [19, 32], [47, 58, 61, 64], [65, 76, 79, 82], [83, 108, 111, 114], [88, 98, 101, 104]]);
623
+ }, _callee2, null, [[16, 119], [21, 34], [49, 60, 63, 66], [67, 78, 81, 84], [85, 110, 113, 116], [90, 100, 103, 106]]);
615
624
  }));
616
625
  return function assign(_x) {
617
626
  return _ref5.apply(this, arguments);
@@ -625,12 +634,18 @@ var connect = exports.connect = function connect(mem) {
625
634
  while (1) switch (_context3.prev = _context3.next) {
626
635
  case 0:
627
636
  p = mem.env[opt.process];
637
+ if (p) {
638
+ _context3.next = 3;
639
+ break;
640
+ }
641
+ return _context3.abrupt("return", null);
642
+ case 3:
628
643
  ex = false;
629
644
  id = (_opt$item$id = opt === null || opt === void 0 || (_opt$item = opt.item) === null || _opt$item === void 0 ? void 0 : _opt$item.id) !== null && _opt$item$id !== void 0 ? _opt$item$id : "";
630
645
  owner = (_opt$owner = opt.owner) !== null && _opt$owner !== void 0 ? _opt$owner : "";
631
646
  item = opt.item;
632
647
  if (!(!opt.item && opt.signer)) {
633
- _context3.next = 15;
648
+ _context3.next = 17;
634
649
  break;
635
650
  }
636
651
  _iterator6 = _createForOfIteratorHelper(opt.tags);
@@ -650,33 +665,33 @@ var connect = exports.connect = function connect(mem) {
650
665
  Type: "Message",
651
666
  SDK: "aoconnect"
652
667
  }));
653
- _context3.next = 11;
668
+ _context3.next = 13;
654
669
  return ar.dataitem({
655
670
  data: opt.data,
656
671
  signer: opt.signer,
657
672
  tags: (0, _utils.tags)(opt.tags),
658
673
  target: opt.process
659
674
  });
660
- case 11:
675
+ case 13:
661
676
  _yield$ar$dataitem3 = _context3.sent;
662
677
  item = _yield$ar$dataitem3.item;
663
678
  id = _yield$ar$dataitem3.id;
664
679
  owner = _yield$ar$dataitem3.owner;
665
- case 15:
666
- _context3.next = 17;
667
- return ar.postItem(item, _test.su.jwk);
668
680
  case 17:
681
+ _context3.next = 19;
682
+ return ar.postItem(item, _test.su.jwk);
683
+ case 19:
669
684
  mem.msgs[id] = opt;
670
- _context3.next = 20;
685
+ _context3.next = 22;
671
686
  return _assign({
672
687
  message: id,
673
688
  process: opt.process,
674
689
  from: owner,
675
690
  signer: _test.mu.signer
676
691
  });
677
- case 20:
692
+ case 22:
678
693
  return _context3.abrupt("return", id);
679
- case 21:
694
+ case 23:
680
695
  case "end":
681
696
  return _context3.stop();
682
697
  }
@@ -845,23 +860,29 @@ var connect = exports.connect = function connect(mem) {
845
860
  while (1) switch (_context9.prev = _context9.next) {
846
861
  case 0:
847
862
  p = mem.env[opt.process];
863
+ if (p) {
864
+ _context9.next = 3;
865
+ break;
866
+ }
867
+ return _context9.abrupt("return", null);
868
+ case 3:
848
869
  id = (_opt$id = opt.id) !== null && _opt$id !== void 0 ? _opt$id : "";
849
870
  owner = (_opt$owner2 = opt.owner) !== null && _opt$owner2 !== void 0 ? _opt$owner2 : "";
850
871
  if (!(!opt.id && opt.signer)) {
851
- _context9.next = 10;
872
+ _context9.next = 12;
852
873
  break;
853
874
  }
854
875
  ;
855
- _context9.next = 7;
876
+ _context9.next = 9;
856
877
  return ar.dataitem(_objectSpread(_objectSpread({}, opt), {}, {
857
878
  target: opt.process
858
879
  }));
859
- case 7:
880
+ case 9:
860
881
  _yield$ar$dataitem4 = _context9.sent;
861
882
  id = _yield$ar$dataitem4.id;
862
883
  owner = _yield$ar$dataitem4.owner;
863
- case 10:
864
- _context9.prev = 10;
884
+ case 12:
885
+ _context9.prev = 12;
865
886
  cloneMemory = function cloneMemory(memory) {
866
887
  var buffer = memory.buffer.slice(0); // Clone the ArrayBuffer
867
888
  return new WebAssembly.Memory({
@@ -878,22 +899,22 @@ var connect = exports.connect = function connect(mem) {
878
899
  module: p.module,
879
900
  auth: _test.mu.addr
880
901
  });
881
- _context9.next = 16;
902
+ _context9.next = 18;
882
903
  return p.handle(p.memory, msg, _env);
883
- case 16:
904
+ case 18:
884
905
  res = _context9.sent;
885
906
  return _context9.abrupt("return", res);
886
- case 20:
887
- _context9.prev = 20;
888
- _context9.t0 = _context9["catch"](10);
907
+ case 22:
908
+ _context9.prev = 22;
909
+ _context9.t0 = _context9["catch"](12);
889
910
  console.log(_context9.t0);
890
- case 23:
911
+ case 25:
891
912
  return _context9.abrupt("return", null);
892
- case 24:
913
+ case 26:
893
914
  case "end":
894
915
  return _context9.stop();
895
916
  }
896
- }, _callee9, null, [[10, 20]]);
917
+ }, _callee9, null, [[12, 22]]);
897
918
  }));
898
919
  function dryrun(_x7) {
899
920
  return _dryrun.apply(this, arguments);
package/cjs/helpers.js CHANGED
@@ -80,7 +80,6 @@ var Src = exports.Src = /*#__PURE__*/function () {
80
80
  key: "data",
81
81
  value: function data(file) {
82
82
  var ext = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "lua";
83
- console.log(this.dir);
84
83
  return (0, _fs.readFileSync)("".concat(this.dir, "/").concat(file, ".").concat(ext), ext === "wasm" ? null : "utf8");
85
84
  }
86
85
  }, {