wao 0.18.6 → 0.18.8

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.
@@ -866,7 +866,7 @@ var _default = exports["default"] = function _default() {
866
866
  _iterator3.s();
867
867
  case 104:
868
868
  if ((_step3 = _iterator3.n()).done) {
869
- _context4.next = 113;
869
+ _context4.next = 117;
870
870
  break;
871
871
  }
872
872
  v = _step3.value;
@@ -874,7 +874,7 @@ var _default = exports["default"] = function _default() {
874
874
  return mem.get("env", v.Target);
875
875
  case 108:
876
876
  if (!_context4.sent) {
877
- _context4.next = 111;
877
+ _context4.next = 113;
878
878
  break;
879
879
  }
880
880
  _context4.next = 111;
@@ -884,34 +884,48 @@ var _default = exports["default"] = function _default() {
884
884
  tags: v.Tags,
885
885
  data: v.Data,
886
886
  signer: mu.signer,
887
- from: opt.process
887
+ from: opt.process,
888
+ target: v.Target
888
889
  });
889
890
  case 111:
890
- _context4.next = 104;
891
+ _context4.next = 115;
891
892
  break;
892
893
  case 113:
893
- _context4.next = 118;
894
- break;
894
+ _context4.next = 115;
895
+ return record({
896
+ "for": opt.message,
897
+ tags: v.Tags,
898
+ data: v.Data,
899
+ signer: mu.signer,
900
+ from: opt.process,
901
+ target: v.Target
902
+ });
895
903
  case 115:
896
- _context4.prev = 115;
904
+ _context4.next = 104;
905
+ break;
906
+ case 117:
907
+ _context4.next = 122;
908
+ break;
909
+ case 119:
910
+ _context4.prev = 119;
897
911
  _context4.t22 = _context4["catch"](102);
898
912
  _iterator3.e(_context4.t22);
899
- case 118:
900
- _context4.prev = 118;
913
+ case 122:
914
+ _context4.prev = 122;
901
915
  _iterator3.f();
902
- return _context4.finish(118);
903
- case 121:
916
+ return _context4.finish(122);
917
+ case 125:
904
918
  _iterator4 = _createForOfIteratorHelper((_res$Spawns = res.Spawns) !== null && _res$Spawns !== void 0 ? _res$Spawns : []);
905
- _context4.prev = 122;
919
+ _context4.prev = 126;
906
920
  _iterator4.s();
907
- case 124:
921
+ case 128:
908
922
  if ((_step4 = _iterator4.n()).done) {
909
- _context4.next = 131;
923
+ _context4.next = 135;
910
924
  break;
911
925
  }
912
926
  _v = _step4.value;
913
927
  __tags = (0, _utils.tags)(_v.Tags);
914
- _context4.next = 129;
928
+ _context4.next = 133;
915
929
  return spawn({
916
930
  "for": opt.message,
917
931
  module: __tags.Module,
@@ -921,87 +935,87 @@ var _default = exports["default"] = function _default() {
921
935
  from: __tags["From-Process"],
922
936
  signer: mu.signer
923
937
  });
924
- case 129:
925
- _context4.next = 124;
938
+ case 133:
939
+ _context4.next = 128;
926
940
  break;
927
- case 131:
928
- _context4.next = 136;
941
+ case 135:
942
+ _context4.next = 140;
929
943
  break;
930
- case 133:
931
- _context4.prev = 133;
932
- _context4.t23 = _context4["catch"](122);
944
+ case 137:
945
+ _context4.prev = 137;
946
+ _context4.t23 = _context4["catch"](126);
933
947
  _iterator4.e(_context4.t23);
934
- case 136:
935
- _context4.prev = 136;
948
+ case 140:
949
+ _context4.prev = 140;
936
950
  _iterator4.f();
937
- return _context4.finish(136);
938
- case 139:
951
+ return _context4.finish(140);
952
+ case 143:
939
953
  _iterator5 = _createForOfIteratorHelper((_res$Assignments = res.Assignments) !== null && _res$Assignments !== void 0 ? _res$Assignments : []);
940
- _context4.prev = 140;
954
+ _context4.prev = 144;
941
955
  _iterator5.s();
942
- case 142:
956
+ case 146:
943
957
  if ((_step5 = _iterator5.n()).done) {
944
- _context4.next = 163;
958
+ _context4.next = 167;
945
959
  break;
946
960
  }
947
961
  _v2 = _step5.value;
948
962
  _iterator6 = _createForOfIteratorHelper(_v2.Processes);
949
- _context4.prev = 145;
963
+ _context4.prev = 149;
950
964
  _iterator6.s();
951
- case 147:
965
+ case 151:
952
966
  if ((_step6 = _iterator6.n()).done) {
953
- _context4.next = 153;
967
+ _context4.next = 157;
954
968
  break;
955
969
  }
956
970
  v2 = _step6.value;
957
- _context4.next = 151;
971
+ _context4.next = 155;
958
972
  return _assign({
959
973
  message: _v2.Message,
960
974
  process: v2,
961
975
  from: opt.process,
962
976
  signer: mu.signer
963
977
  });
964
- case 151:
965
- _context4.next = 147;
978
+ case 155:
979
+ _context4.next = 151;
966
980
  break;
967
- case 153:
968
- _context4.next = 158;
981
+ case 157:
982
+ _context4.next = 162;
969
983
  break;
970
- case 155:
971
- _context4.prev = 155;
972
- _context4.t24 = _context4["catch"](145);
984
+ case 159:
985
+ _context4.prev = 159;
986
+ _context4.t24 = _context4["catch"](149);
973
987
  _iterator6.e(_context4.t24);
974
- case 158:
975
- _context4.prev = 158;
988
+ case 162:
989
+ _context4.prev = 162;
976
990
  _iterator6.f();
977
- return _context4.finish(158);
978
- case 161:
979
- _context4.next = 142;
991
+ return _context4.finish(162);
992
+ case 165:
993
+ _context4.next = 146;
980
994
  break;
981
- case 163:
982
- _context4.next = 168;
995
+ case 167:
996
+ _context4.next = 172;
983
997
  break;
984
- case 165:
985
- _context4.prev = 165;
986
- _context4.t25 = _context4["catch"](140);
998
+ case 169:
999
+ _context4.prev = 169;
1000
+ _context4.t25 = _context4["catch"](144);
987
1001
  _iterator5.e(_context4.t25);
988
- case 168:
989
- _context4.prev = 168;
1002
+ case 172:
1003
+ _context4.prev = 172;
990
1004
  _iterator5.f();
991
- return _context4.finish(168);
992
- case 171:
1005
+ return _context4.finish(172);
1006
+ case 175:
993
1007
  return _context4.abrupt("return", id);
994
- case 174:
995
- _context4.prev = 174;
1008
+ case 178:
1009
+ _context4.prev = 178;
996
1010
  _context4.t26 = _context4["catch"](40);
997
1011
  console.log(_context4.t26);
998
- case 177:
1012
+ case 181:
999
1013
  return _context4.abrupt("return", null);
1000
- case 178:
1014
+ case 182:
1001
1015
  case "end":
1002
1016
  return _context4.stop();
1003
1017
  }
1004
- }, _callee4, null, [[40, 174], [102, 115, 118, 121], [122, 133, 136, 139], [140, 165, 168, 171], [145, 155, 158, 161]]);
1018
+ }, _callee4, null, [[40, 178], [102, 119, 122, 125], [126, 137, 140, 143], [144, 169, 172, 175], [149, 159, 162, 165]]);
1005
1019
  }));
1006
1020
  return function assign(_x8) {
1007
1021
  return _ref9.apply(this, arguments);
@@ -1300,86 +1314,188 @@ var _default = exports["default"] = function _default() {
1300
1314
  return _ref11.apply(this, arguments);
1301
1315
  };
1302
1316
  }();
1303
- var _recover = /*#__PURE__*/function () {
1304
- var _ref13 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6(pid, next) {
1305
- var count, success, _success, i, p, from, msgs, _iterator7, _step7, v, item, _k2, _tags;
1317
+ var record = /*#__PURE__*/function () {
1318
+ var _ref13 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6(opt) {
1319
+ var _opt$item$id2, _opt$item2, _opt$owner2, _opt$tags4;
1320
+ var id, owner, item, _yield$mem$getTx$tags4, _yield$mem$getTx6, pr, module, _yield$ar$dataitem4, _msg;
1306
1321
  return _regeneratorRuntime().wrap(function _callee6$(_context6) {
1307
1322
  while (1) switch (_context6.prev = _context6.next) {
1323
+ case 0:
1324
+ id = (_opt$item$id2 = opt === null || opt === void 0 || (_opt$item2 = opt.item) === null || _opt$item2 === void 0 ? void 0 : _opt$item2.id) !== null && _opt$item$id2 !== void 0 ? _opt$item$id2 : "";
1325
+ owner = (_opt$owner2 = opt.owner) !== null && _opt$owner2 !== void 0 ? _opt$owner2 : "";
1326
+ item = opt.item;
1327
+ opt.tags = (0, _utils.buildTags)(null, (0, _ramda.mergeLeft)((0, _utils.tags)((_opt$tags4 = opt.tags) !== null && _opt$tags4 !== void 0 ? _opt$tags4 : []), {
1328
+ "Data-Protocol": "ao",
1329
+ Variant: variant !== null && variant !== void 0 ? variant : "ao.TN.1",
1330
+ Type: "Message"
1331
+ }));
1332
+ if (!opt["for"]) {
1333
+ _context6.next = 30;
1334
+ break;
1335
+ }
1336
+ opt.tags.push({
1337
+ name: "Pushed-For",
1338
+ value: opt["for"]
1339
+ });
1340
+ opt.tags.push({
1341
+ name: "From-Process",
1342
+ value: opt.from
1343
+ });
1344
+ _context6.next = 9;
1345
+ return mem.getTx(opt.from);
1346
+ case 9:
1347
+ _context6.t2 = _yield$mem$getTx6 = _context6.sent;
1348
+ _context6.t1 = _context6.t2 === null;
1349
+ if (_context6.t1) {
1350
+ _context6.next = 13;
1351
+ break;
1352
+ }
1353
+ _context6.t1 = _yield$mem$getTx6 === void 0;
1354
+ case 13:
1355
+ if (!_context6.t1) {
1356
+ _context6.next = 17;
1357
+ break;
1358
+ }
1359
+ _context6.t3 = void 0;
1360
+ _context6.next = 18;
1361
+ break;
1362
+ case 17:
1363
+ _context6.t3 = _yield$mem$getTx6.tags;
1364
+ case 18:
1365
+ _context6.t4 = _yield$mem$getTx$tags4 = _context6.t3;
1366
+ _context6.t0 = _context6.t4 !== null;
1367
+ if (!_context6.t0) {
1368
+ _context6.next = 22;
1369
+ break;
1370
+ }
1371
+ _context6.t0 = _yield$mem$getTx$tags4 !== void 0;
1372
+ case 22:
1373
+ if (!_context6.t0) {
1374
+ _context6.next = 26;
1375
+ break;
1376
+ }
1377
+ _context6.t5 = _yield$mem$getTx$tags4;
1378
+ _context6.next = 27;
1379
+ break;
1380
+ case 26:
1381
+ _context6.t5 = [];
1382
+ case 27:
1383
+ pr = _context6.t5;
1384
+ module = (0, _utils.tags)(pr).Module;
1385
+ if (module) opt.tags.push({
1386
+ name: "From-Module",
1387
+ value: module
1388
+ });
1389
+ case 30:
1390
+ ;
1391
+ _context6.next = 33;
1392
+ return ar.dataitem({
1393
+ data: opt.data,
1394
+ signer: opt.signer,
1395
+ tags: (0, _utils.tags)(opt.tags),
1396
+ target: opt.process
1397
+ });
1398
+ case 33:
1399
+ _yield$ar$dataitem4 = _context6.sent;
1400
+ item = _yield$ar$dataitem4.item;
1401
+ id = _yield$ar$dataitem4.id;
1402
+ owner = _yield$ar$dataitem4.owner;
1403
+ _msg = (0, _ramda.dissoc)("signer", opt);
1404
+ _context6.next = 40;
1405
+ return mem.set(_msg, "msgs", id);
1406
+ case 40:
1407
+ _context6.next = 42;
1408
+ return ar.postItems(item, su.jwk);
1409
+ case 42:
1410
+ case "end":
1411
+ return _context6.stop();
1412
+ }
1413
+ }, _callee6);
1414
+ }));
1415
+ return function record(_x10) {
1416
+ return _ref13.apply(this, arguments);
1417
+ };
1418
+ }();
1419
+ var _recover = /*#__PURE__*/function () {
1420
+ var _ref14 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7(pid, next) {
1421
+ var count, success, _success, i, p, from, msgs, _iterator7, _step7, v, item, _k2, _tags;
1422
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
1423
+ while (1) switch (_context7.prev = _context7.next) {
1308
1424
  case 0:
1309
1425
  count = 0;
1310
1426
  success = false;
1311
1427
  if (!hb) {
1312
- _context6.next = 77;
1428
+ _context7.next = 77;
1313
1429
  break;
1314
1430
  }
1315
1431
  if (!onRecovery[pid]) {
1316
- _context6.next = 20;
1432
+ _context7.next = 20;
1317
1433
  break;
1318
1434
  }
1319
1435
  _success = false;
1320
1436
  i = 0;
1321
1437
  case 6:
1322
1438
  if (!true) {
1323
- _context6.next = 17;
1439
+ _context7.next = 17;
1324
1440
  break;
1325
1441
  }
1326
- _context6.next = 9;
1442
+ _context7.next = 9;
1327
1443
  return (0, _utils.wait)(1000);
1328
1444
  case 9:
1329
1445
  if (onRecovery[pid]) {
1330
- _context6.next = 12;
1446
+ _context7.next = 12;
1331
1447
  break;
1332
1448
  }
1333
1449
  _success = true;
1334
- return _context6.abrupt("break", 17);
1450
+ return _context7.abrupt("break", 17);
1335
1451
  case 12:
1336
1452
  if (!(i > 10)) {
1337
- _context6.next = 14;
1453
+ _context7.next = 14;
1338
1454
  break;
1339
1455
  }
1340
- return _context6.abrupt("break", 17);
1456
+ return _context7.abrupt("break", 17);
1341
1457
  case 14:
1342
1458
  i++;
1343
- _context6.next = 6;
1459
+ _context7.next = 6;
1344
1460
  break;
1345
1461
  case 17:
1346
- return _context6.abrupt("return", {
1462
+ return _context7.abrupt("return", {
1347
1463
  success: _success
1348
1464
  });
1349
1465
  case 20:
1350
1466
  onRecovery[pid] = true;
1351
- _context6.prev = 21;
1352
- _context6.next = 24;
1467
+ _context7.prev = 21;
1468
+ _context7.next = 24;
1353
1469
  return mem.get("env", pid);
1354
1470
  case 24:
1355
- p = _context6.sent;
1471
+ p = _context7.sent;
1356
1472
  from = p ? p.results.length : 0;
1357
1473
  if (!next) {
1358
- _context6.next = 32;
1474
+ _context7.next = 32;
1359
1475
  break;
1360
1476
  }
1361
- _context6.next = 29;
1477
+ _context7.next = 29;
1362
1478
  return next();
1363
1479
  case 29:
1364
- _context6.t0 = _context6.sent;
1365
- _context6.next = 35;
1480
+ _context7.t0 = _context7.sent;
1481
+ _context7.next = 35;
1366
1482
  break;
1367
1483
  case 32:
1368
- _context6.next = 34;
1484
+ _context7.next = 34;
1369
1485
  return hb.messages({
1370
1486
  target: pid,
1371
1487
  from: from
1372
1488
  });
1373
1489
  case 34:
1374
- _context6.t0 = _context6.sent;
1490
+ _context7.t0 = _context7.sent;
1375
1491
  case 35:
1376
- msgs = _context6.t0;
1492
+ msgs = _context7.t0;
1377
1493
  _iterator7 = _createForOfIteratorHelper(msgs.edges);
1378
- _context6.prev = 37;
1494
+ _context7.prev = 37;
1379
1495
  _iterator7.s();
1380
1496
  case 39:
1381
1497
  if ((_step7 = _iterator7.n()).done) {
1382
- _context6.next = 59;
1498
+ _context7.next = 59;
1383
1499
  break;
1384
1500
  }
1385
1501
  v = _step7.value;
@@ -1407,10 +1523,10 @@ var _default = exports["default"] = function _default() {
1407
1523
  item.target = pid;
1408
1524
  _tags = (0, _utils.tags)(item.tags);
1409
1525
  if (!(_tags.Type === "Process")) {
1410
- _context6.next = 54;
1526
+ _context7.next = 54;
1411
1527
  break;
1412
1528
  }
1413
- _context6.next = 52;
1529
+ _context7.next = 52;
1414
1530
  return spawn({
1415
1531
  id: v.node.message.Id,
1416
1532
  http_msg: item,
@@ -1420,10 +1536,10 @@ var _default = exports["default"] = function _default() {
1420
1536
  recovery: true
1421
1537
  });
1422
1538
  case 52:
1423
- _context6.next = 56;
1539
+ _context7.next = 56;
1424
1540
  break;
1425
1541
  case 54:
1426
- _context6.next = 56;
1542
+ _context7.next = 56;
1427
1543
  return message({
1428
1544
  id: v.node.message.Id,
1429
1545
  process: pid,
@@ -1434,134 +1550,134 @@ var _default = exports["default"] = function _default() {
1434
1550
  case 56:
1435
1551
  count++;
1436
1552
  case 57:
1437
- _context6.next = 39;
1553
+ _context7.next = 39;
1438
1554
  break;
1439
1555
  case 59:
1440
- _context6.next = 64;
1556
+ _context7.next = 64;
1441
1557
  break;
1442
1558
  case 61:
1443
- _context6.prev = 61;
1444
- _context6.t1 = _context6["catch"](37);
1445
- _iterator7.e(_context6.t1);
1559
+ _context7.prev = 61;
1560
+ _context7.t1 = _context7["catch"](37);
1561
+ _iterator7.e(_context7.t1);
1446
1562
  case 64:
1447
- _context6.prev = 64;
1563
+ _context7.prev = 64;
1448
1564
  _iterator7.f();
1449
- return _context6.finish(64);
1565
+ return _context7.finish(64);
1450
1566
  case 67:
1451
1567
  if (!msgs.next) {
1452
- _context6.next = 70;
1568
+ _context7.next = 70;
1453
1569
  break;
1454
1570
  }
1455
- _context6.next = 70;
1571
+ _context7.next = 70;
1456
1572
  return _recover(pid, msgs.next);
1457
1573
  case 70:
1458
- _context6.next = 75;
1574
+ _context7.next = 75;
1459
1575
  break;
1460
1576
  case 72:
1461
- _context6.prev = 72;
1462
- _context6.t2 = _context6["catch"](21);
1463
- console.log(_context6.t2);
1577
+ _context7.prev = 72;
1578
+ _context7.t2 = _context7["catch"](21);
1579
+ console.log(_context7.t2);
1464
1580
  case 75:
1465
1581
  delete onRecovery[pid];
1466
1582
  case 76:
1467
1583
  success = true;
1468
1584
  case 77:
1469
- return _context6.abrupt("return", {
1585
+ return _context7.abrupt("return", {
1470
1586
  recovered: count,
1471
1587
  pid: pid,
1472
1588
  success: success
1473
1589
  });
1474
1590
  case 78:
1475
1591
  case "end":
1476
- return _context6.stop();
1592
+ return _context7.stop();
1477
1593
  }
1478
- }, _callee6, null, [[21, 72], [37, 61, 64, 67]]);
1594
+ }, _callee7, null, [[21, 72], [37, 61, 64, 67]]);
1479
1595
  }));
1480
- return function recover(_x10, _x11) {
1481
- return _ref13.apply(this, arguments);
1596
+ return function recover(_x11, _x12) {
1597
+ return _ref14.apply(this, arguments);
1482
1598
  };
1483
1599
  }();
1484
1600
  var result = /*#__PURE__*/function () {
1485
- var _ref14 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7(opt) {
1601
+ var _ref15 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee8(opt) {
1486
1602
  var _yield$mem$get2;
1487
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
1488
- while (1) switch (_context7.prev = _context7.next) {
1603
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
1604
+ while (1) switch (_context8.prev = _context8.next) {
1489
1605
  case 0:
1490
- _context7.next = 2;
1606
+ _context8.next = 2;
1491
1607
  return mem.get("msgs", opt.message);
1492
1608
  case 2:
1493
- _context7.t1 = _yield$mem$get2 = _context7.sent;
1494
- _context7.t0 = _context7.t1 === null;
1495
- if (_context7.t0) {
1496
- _context7.next = 6;
1609
+ _context8.t1 = _yield$mem$get2 = _context8.sent;
1610
+ _context8.t0 = _context8.t1 === null;
1611
+ if (_context8.t0) {
1612
+ _context8.next = 6;
1497
1613
  break;
1498
1614
  }
1499
- _context7.t0 = _yield$mem$get2 === void 0;
1615
+ _context8.t0 = _yield$mem$get2 === void 0;
1500
1616
  case 6:
1501
- if (!_context7.t0) {
1502
- _context7.next = 10;
1617
+ if (!_context8.t0) {
1618
+ _context8.next = 10;
1503
1619
  break;
1504
1620
  }
1505
- _context7.t2 = void 0;
1506
- _context7.next = 11;
1621
+ _context8.t2 = void 0;
1622
+ _context8.next = 11;
1507
1623
  break;
1508
1624
  case 10:
1509
- _context7.t2 = _yield$mem$get2.res;
1625
+ _context8.t2 = _yield$mem$get2.res;
1510
1626
  case 11:
1511
- return _context7.abrupt("return", _context7.t2);
1627
+ return _context8.abrupt("return", _context8.t2);
1512
1628
  case 12:
1513
1629
  case "end":
1514
- return _context7.stop();
1630
+ return _context8.stop();
1515
1631
  }
1516
- }, _callee7);
1632
+ }, _callee8);
1517
1633
  }));
1518
- return function result(_x12) {
1519
- return _ref14.apply(this, arguments);
1634
+ return function result(_x13) {
1635
+ return _ref15.apply(this, arguments);
1520
1636
  };
1521
1637
  }();
1522
1638
  return {
1523
1639
  message: message,
1524
1640
  unmonitor: function () {
1525
- var _unmonitor = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee8(opt) {
1641
+ var _unmonitor = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee9(opt) {
1526
1642
  var p;
1527
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
1528
- while (1) switch (_context8.prev = _context8.next) {
1643
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
1644
+ while (1) switch (_context9.prev = _context9.next) {
1529
1645
  case 0:
1530
- _context8.next = 2;
1646
+ _context9.next = 2;
1531
1647
  return mem.get("env", opt.process);
1532
1648
  case 2:
1533
- p = _context8.sent;
1649
+ p = _context9.sent;
1534
1650
  try {
1535
1651
  clearInterval(p.cron);
1536
1652
  p.cron = null;
1537
1653
  } catch (e) {}
1538
1654
  case 4:
1539
1655
  case "end":
1540
- return _context8.stop();
1656
+ return _context9.stop();
1541
1657
  }
1542
- }, _callee8);
1658
+ }, _callee9);
1543
1659
  }));
1544
- function unmonitor(_x13) {
1660
+ function unmonitor(_x14) {
1545
1661
  return _unmonitor.apply(this, arguments);
1546
1662
  }
1547
1663
  return unmonitor;
1548
1664
  }(),
1549
1665
  monitor: function () {
1550
- var _monitor = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee10(opt) {
1666
+ var _monitor = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee11(opt) {
1551
1667
  var p;
1552
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
1553
- while (1) switch (_context10.prev = _context10.next) {
1668
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
1669
+ while (1) switch (_context11.prev = _context11.next) {
1554
1670
  case 0:
1555
- _context10.next = 2;
1671
+ _context11.next = 2;
1556
1672
  return mem.get("env", opt.process);
1557
1673
  case 2:
1558
- p = _context10.sent;
1674
+ p = _context11.sent;
1559
1675
  if ((0, _ramda.isNil)(p.cron)) {
1560
- p.cron = setInterval(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
1561
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
1562
- while (1) switch (_context9.prev = _context9.next) {
1676
+ p.cron = setInterval(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
1677
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
1678
+ while (1) switch (_context10.prev = _context10.next) {
1563
1679
  case 0:
1564
- _context9.next = 2;
1680
+ _context10.next = 2;
1565
1681
  return message({
1566
1682
  tags: p.cronTags,
1567
1683
  process: opt.process,
@@ -1570,18 +1686,18 @@ var _default = exports["default"] = function _default() {
1570
1686
  });
1571
1687
  case 2:
1572
1688
  case "end":
1573
- return _context9.stop();
1689
+ return _context10.stop();
1574
1690
  }
1575
- }, _callee9);
1691
+ }, _callee10);
1576
1692
  })), p.span);
1577
1693
  }
1578
1694
  case 4:
1579
1695
  case "end":
1580
- return _context10.stop();
1696
+ return _context11.stop();
1581
1697
  }
1582
- }, _callee10);
1698
+ }, _callee11);
1583
1699
  }));
1584
- function monitor(_x14) {
1700
+ function monitor(_x15) {
1585
1701
  return _monitor.apply(this, arguments);
1586
1702
  }
1587
1703
  return monitor;
@@ -1591,135 +1707,135 @@ var _default = exports["default"] = function _default() {
1591
1707
  ar: ar,
1592
1708
  result: result,
1593
1709
  results: function () {
1594
- var _results = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee11(opt) {
1595
- var p, results, _ref16, _ref16$from, from, _ref16$to, to, _ref16$sort, sort, _ref16$limit, limit, _res, count, started, _iterator8, _step8, v;
1596
- return _regeneratorRuntime().wrap(function _callee11$(_context11) {
1597
- while (1) switch (_context11.prev = _context11.next) {
1710
+ var _results = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee12(opt) {
1711
+ var p, results, _ref17, _ref17$from, from, _ref17$to, to, _ref17$sort, sort, _ref17$limit, limit, _res, count, started, _iterator8, _step8, v;
1712
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
1713
+ while (1) switch (_context12.prev = _context12.next) {
1598
1714
  case 0:
1599
- _context11.next = 2;
1715
+ _context12.next = 2;
1600
1716
  return mem.get("env", opt.process);
1601
1717
  case 2:
1602
- p = _context11.sent;
1718
+ p = _context12.sent;
1603
1719
  if (p) {
1604
- _context11.next = 5;
1720
+ _context12.next = 5;
1605
1721
  break;
1606
1722
  }
1607
- return _context11.abrupt("return", {
1723
+ return _context12.abrupt("return", {
1608
1724
  edges: []
1609
1725
  });
1610
1726
  case 5:
1611
1727
  results = (p === null || p === void 0 ? void 0 : p.results) || [];
1612
- _ref16 = opt || {}, _ref16$from = _ref16.from, from = _ref16$from === void 0 ? null : _ref16$from, _ref16$to = _ref16.to, to = _ref16$to === void 0 ? null : _ref16$to, _ref16$sort = _ref16.sort, sort = _ref16$sort === void 0 ? "ASC" : _ref16$sort, _ref16$limit = _ref16.limit, limit = _ref16$limit === void 0 ? 25 : _ref16$limit;
1728
+ _ref17 = opt || {}, _ref17$from = _ref17.from, from = _ref17$from === void 0 ? null : _ref17$from, _ref17$to = _ref17.to, to = _ref17$to === void 0 ? null : _ref17$to, _ref17$sort = _ref17.sort, sort = _ref17$sort === void 0 ? "ASC" : _ref17$sort, _ref17$limit = _ref17.limit, limit = _ref17$limit === void 0 ? 25 : _ref17$limit;
1613
1729
  if (sort === "DESC") results = (0, _ramda.reverse)(results);
1614
1730
  _res = [];
1615
1731
  count = 0;
1616
1732
  started = (0, _ramda.isNil)(from);
1617
1733
  _iterator8 = _createForOfIteratorHelper(results);
1618
- _context11.prev = 12;
1734
+ _context12.prev = 12;
1619
1735
  _iterator8.s();
1620
1736
  case 14:
1621
1737
  if ((_step8 = _iterator8.n()).done) {
1622
- _context11.next = 34;
1738
+ _context12.next = 34;
1623
1739
  break;
1624
1740
  }
1625
1741
  v = _step8.value;
1626
1742
  if (!started) {
1627
- _context11.next = 31;
1743
+ _context12.next = 31;
1628
1744
  break;
1629
1745
  }
1630
- _context11.t0 = _res;
1631
- _context11.t1 = v;
1632
- _context11.next = 21;
1746
+ _context12.t0 = _res;
1747
+ _context12.t1 = v;
1748
+ _context12.next = 21;
1633
1749
  return result({
1634
1750
  message: v
1635
1751
  });
1636
1752
  case 21:
1637
- _context11.t2 = _context11.sent;
1638
- _context11.t3 = {
1639
- cursor: _context11.t1,
1640
- node: _context11.t2
1753
+ _context12.t2 = _context12.sent;
1754
+ _context12.t3 = {
1755
+ cursor: _context12.t1,
1756
+ node: _context12.t2
1641
1757
  };
1642
- _context11.t0.push.call(_context11.t0, _context11.t3);
1758
+ _context12.t0.push.call(_context12.t0, _context12.t3);
1643
1759
  count++;
1644
1760
  if (!(!(0, _ramda.isNil)(to) && v === to)) {
1645
- _context11.next = 27;
1761
+ _context12.next = 27;
1646
1762
  break;
1647
1763
  }
1648
- return _context11.abrupt("break", 34);
1764
+ return _context12.abrupt("break", 34);
1649
1765
  case 27:
1650
1766
  if (!(limit <= count)) {
1651
- _context11.next = 29;
1767
+ _context12.next = 29;
1652
1768
  break;
1653
1769
  }
1654
- return _context11.abrupt("break", 34);
1770
+ return _context12.abrupt("break", 34);
1655
1771
  case 29:
1656
- _context11.next = 32;
1772
+ _context12.next = 32;
1657
1773
  break;
1658
1774
  case 31:
1659
1775
  if (from === v) started = true;
1660
1776
  case 32:
1661
- _context11.next = 14;
1777
+ _context12.next = 14;
1662
1778
  break;
1663
1779
  case 34:
1664
- _context11.next = 39;
1780
+ _context12.next = 39;
1665
1781
  break;
1666
1782
  case 36:
1667
- _context11.prev = 36;
1668
- _context11.t4 = _context11["catch"](12);
1669
- _iterator8.e(_context11.t4);
1783
+ _context12.prev = 36;
1784
+ _context12.t4 = _context12["catch"](12);
1785
+ _iterator8.e(_context12.t4);
1670
1786
  case 39:
1671
- _context11.prev = 39;
1787
+ _context12.prev = 39;
1672
1788
  _iterator8.f();
1673
- return _context11.finish(39);
1789
+ return _context12.finish(39);
1674
1790
  case 42:
1675
- return _context11.abrupt("return", {
1791
+ return _context12.abrupt("return", {
1676
1792
  edges: _res
1677
1793
  });
1678
1794
  case 43:
1679
1795
  case "end":
1680
- return _context11.stop();
1796
+ return _context12.stop();
1681
1797
  }
1682
- }, _callee11, null, [[12, 36, 39, 42]]);
1798
+ }, _callee12, null, [[12, 36, 39, 42]]);
1683
1799
  }));
1684
- function results(_x15) {
1800
+ function results(_x16) {
1685
1801
  return _results.apply(this, arguments);
1686
1802
  }
1687
1803
  return results;
1688
1804
  }(),
1689
1805
  dryrun: function () {
1690
- var _dryrun = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee12(opt) {
1691
- var _opt$id3, _opt$owner2;
1692
- var p, id, owner, _yield$ar$dataitem4, _opt$data3, cloneMemory, msg, _env, _yield$mem$getWasm4, format, mod, wasm, wdrive, start, res;
1693
- return _regeneratorRuntime().wrap(function _callee12$(_context12) {
1694
- while (1) switch (_context12.prev = _context12.next) {
1806
+ var _dryrun = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee13(opt) {
1807
+ var _opt$id3, _opt$owner3;
1808
+ var p, id, owner, _yield$ar$dataitem5, _opt$data3, cloneMemory, msg, _env, _yield$mem$getWasm4, format, mod, wasm, wdrive, start, res;
1809
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
1810
+ while (1) switch (_context13.prev = _context13.next) {
1695
1811
  case 0:
1696
- _context12.next = 2;
1812
+ _context13.next = 2;
1697
1813
  return mem.get("env", opt.process);
1698
1814
  case 2:
1699
- p = _context12.sent;
1815
+ p = _context13.sent;
1700
1816
  if (p) {
1701
- _context12.next = 5;
1817
+ _context13.next = 5;
1702
1818
  break;
1703
1819
  }
1704
- return _context12.abrupt("return", null);
1820
+ return _context13.abrupt("return", null);
1705
1821
  case 5:
1706
1822
  id = (_opt$id3 = opt.id) !== null && _opt$id3 !== void 0 ? _opt$id3 : "";
1707
- owner = (_opt$owner2 = opt.owner) !== null && _opt$owner2 !== void 0 ? _opt$owner2 : mu.addr;
1823
+ owner = (_opt$owner3 = opt.owner) !== null && _opt$owner3 !== void 0 ? _opt$owner3 : mu.addr;
1708
1824
  if (!(!opt.id && opt.signer)) {
1709
- _context12.next = 14;
1825
+ _context13.next = 14;
1710
1826
  break;
1711
1827
  }
1712
1828
  ;
1713
- _context12.next = 11;
1829
+ _context13.next = 11;
1714
1830
  return ar.dataitem(_objectSpread(_objectSpread({}, opt), {}, {
1715
1831
  target: opt.process
1716
1832
  }));
1717
1833
  case 11:
1718
- _yield$ar$dataitem4 = _context12.sent;
1719
- id = _yield$ar$dataitem4.id;
1720
- owner = _yield$ar$dataitem4.owner;
1834
+ _yield$ar$dataitem5 = _context13.sent;
1835
+ id = _yield$ar$dataitem5.id;
1836
+ owner = _yield$ar$dataitem5.owner;
1721
1837
  case 14:
1722
- _context12.prev = 14;
1838
+ _context13.prev = 14;
1723
1839
  cloneMemory = function cloneMemory(memory) {
1724
1840
  var buffer = memory.buffer.slice(0);
1725
1841
  return new WebAssembly.Memory({
@@ -1728,52 +1844,52 @@ var _default = exports["default"] = function _default() {
1728
1844
  shared: memory.shared || false
1729
1845
  });
1730
1846
  };
1731
- _context12.next = 18;
1847
+ _context13.next = 18;
1732
1848
  return genMsg(id, p, (_opt$data3 = opt.data) !== null && _opt$data3 !== void 0 ? _opt$data3 : "", opt.tags, owner, owner, true);
1733
1849
  case 18:
1734
- msg = _context12.sent;
1735
- _context12.next = 21;
1850
+ msg = _context13.sent;
1851
+ _context13.next = 21;
1736
1852
  return genEnv({
1737
1853
  pid: p.id,
1738
1854
  owner: p.owner,
1739
1855
  module: p.module
1740
1856
  });
1741
1857
  case 21:
1742
- _env = _context12.sent;
1858
+ _env = _context13.sent;
1743
1859
  if (p.handle) {
1744
- _context12.next = 45;
1860
+ _context13.next = 45;
1745
1861
  break;
1746
1862
  }
1747
- _context12.next = 25;
1863
+ _context13.next = 25;
1748
1864
  return mem.getWasm(p.module);
1749
1865
  case 25:
1750
- _yield$mem$getWasm4 = _context12.sent;
1866
+ _yield$mem$getWasm4 = _context13.sent;
1751
1867
  format = _yield$mem$getWasm4.format;
1752
1868
  mod = _yield$mem$getWasm4.mod;
1753
1869
  wasm = _yield$mem$getWasm4.wasm;
1754
1870
  wdrive = extensions[p.extention];
1755
- _context12.t0 = AoLoader;
1756
- _context12.t1 = wasm;
1757
- _context12.t2 = format;
1758
- _context12.t3 = wdrive;
1759
- _context12.next = 36;
1871
+ _context13.t0 = AoLoader;
1872
+ _context13.t1 = wasm;
1873
+ _context13.t2 = format;
1874
+ _context13.t3 = wdrive;
1875
+ _context13.next = 36;
1760
1876
  return mem.getTx(p.id);
1761
1877
  case 36:
1762
- _context12.t4 = _context12.sent.item;
1763
- _context12.next = 39;
1878
+ _context13.t4 = _context13.sent.item;
1879
+ _context13.next = 39;
1764
1880
  return mem.getTx(mod);
1765
1881
  case 39:
1766
- _context12.t5 = _context12.sent;
1767
- _context12.t6 = {
1768
- format: _context12.t2,
1769
- WeaveDrive: _context12.t3,
1770
- spawn: _context12.t4,
1771
- module: _context12.t5
1882
+ _context13.t5 = _context13.sent;
1883
+ _context13.t6 = {
1884
+ format: _context13.t2,
1885
+ WeaveDrive: _context13.t3,
1886
+ spawn: _context13.t4,
1887
+ module: _context13.t5
1772
1888
  };
1773
- _context12.next = 43;
1774
- return (0, _context12.t0)(_context12.t1, _context12.t6);
1889
+ _context13.next = 43;
1890
+ return (0, _context13.t0)(_context13.t1, _context13.t6);
1775
1891
  case 43:
1776
- p.handle = _context12.sent;
1892
+ p.handle = _context13.sent;
1777
1893
  mem.env[opt.process].handle = p.handle;
1778
1894
  case 45:
1779
1895
  if (p.compressed) {
@@ -1781,25 +1897,25 @@ var _default = exports["default"] = function _default() {
1781
1897
  p.memory = mem.decompress(p.memory, p.original_size);
1782
1898
  p.compressed = false;
1783
1899
  }
1784
- _context12.next = 48;
1900
+ _context13.next = 48;
1785
1901
  return p.handle(p.memory, msg, _env);
1786
1902
  case 48:
1787
- res = _context12.sent;
1903
+ res = _context13.sent;
1788
1904
  delete res.Memory;
1789
- return _context12.abrupt("return", res);
1905
+ return _context13.abrupt("return", res);
1790
1906
  case 53:
1791
- _context12.prev = 53;
1792
- _context12.t7 = _context12["catch"](14);
1793
- console.log(_context12.t7);
1907
+ _context13.prev = 53;
1908
+ _context13.t7 = _context13["catch"](14);
1909
+ console.log(_context13.t7);
1794
1910
  case 56:
1795
- return _context12.abrupt("return", null);
1911
+ return _context13.abrupt("return", null);
1796
1912
  case 57:
1797
1913
  case "end":
1798
- return _context12.stop();
1914
+ return _context13.stop();
1799
1915
  }
1800
- }, _callee12, null, [[14, 53]]);
1916
+ }, _callee13, null, [[14, 53]]);
1801
1917
  }));
1802
- function dryrun(_x16) {
1918
+ function dryrun(_x17) {
1803
1919
  return _dryrun.apply(this, arguments);
1804
1920
  }
1805
1921
  return dryrun;
@@ -366,6 +366,16 @@ export default ({ AR, scheduler, mu, su, cu, acc, AoLoader, ArMem } = {}) => {
366
366
  data: v.Data,
367
367
  signer: mu.signer,
368
368
  from: opt.process,
369
+ target: v.Target,
370
+ })
371
+ } else {
372
+ await record({
373
+ for: opt.message,
374
+ tags: v.Tags,
375
+ data: v.Data,
376
+ signer: mu.signer,
377
+ from: opt.process,
378
+ target: v.Target,
369
379
  })
370
380
  }
371
381
  }
@@ -510,6 +520,35 @@ export default ({ AR, scheduler, mu, su, cu, acc, AoLoader, ArMem } = {}) => {
510
520
  delete ongoing[key]
511
521
  return id
512
522
  }
523
+ const record = async opt => {
524
+ let id = opt?.item?.id ?? ""
525
+ let owner = opt.owner ?? ""
526
+ let item = opt.item
527
+ opt.tags = buildTags(
528
+ null,
529
+ mergeLeft(tags(opt.tags ?? []), {
530
+ "Data-Protocol": "ao",
531
+ Variant: variant ?? "ao.TN.1",
532
+ Type: "Message",
533
+ })
534
+ )
535
+ if (opt.for) {
536
+ opt.tags.push({ name: "Pushed-For", value: opt.for })
537
+ opt.tags.push({ name: "From-Process", value: opt.from })
538
+ const pr = (await mem.getTx(opt.from))?.tags ?? []
539
+ const module = tags(pr).Module
540
+ if (module) opt.tags.push({ name: "From-Module", value: module })
541
+ }
542
+ ;({ item, id, owner } = await ar.dataitem({
543
+ data: opt.data,
544
+ signer: opt.signer,
545
+ tags: tags(opt.tags),
546
+ target: opt.process,
547
+ }))
548
+ const _msg = dissoc("signer", opt)
549
+ await mem.set(_msg, "msgs", id)
550
+ await ar.postItems(item, su.jwk)
551
+ }
513
552
  const recover = async (pid, next) => {
514
553
  let count = 0
515
554
  let success = false
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wao",
3
- "version": "0.18.6",
3
+ "version": "0.18.8",
4
4
  "bin": {
5
5
  "wao": "./cjs/cli.js",
6
6
  "wao-esm": "./esm/cli.js"