wao 0.31.1 → 0.32.0

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/hb.js CHANGED
@@ -16,6 +16,12 @@ var _excluded = ["path"],
16
16
  _excluded2 = ["path"];
17
17
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
18
18
  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); }
19
+ function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
20
+ 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."); }
21
+ 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; } }
22
+ function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
23
+ function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
24
+ 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; }
19
25
  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; }
20
26
  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; }
21
27
  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; }
@@ -319,20 +325,19 @@ var HB = /*#__PURE__*/function () {
319
325
  _yield$this$scheduleL = _context9.sent;
320
326
  slot = _yield$this$scheduleL.slot;
321
327
  pid = _yield$this$scheduleL.pid;
322
- console.log(slot, pid, args);
323
328
  _context9.t0 = slot;
324
- _context9.next = 9;
329
+ _context9.next = 8;
325
330
  return this.computeLegacy({
326
331
  pid: pid,
327
332
  slot: slot
328
333
  });
329
- case 9:
334
+ case 8:
330
335
  _context9.t1 = _context9.sent;
331
336
  return _context9.abrupt("return", {
332
337
  slot: _context9.t0,
333
338
  res: _context9.t1
334
339
  });
335
- case 11:
340
+ case 10:
336
341
  case "end":
337
342
  return _context9.stop();
338
343
  }
@@ -462,11 +467,11 @@ var HB = /*#__PURE__*/function () {
462
467
  addr,
463
468
  _tags,
464
469
  res,
465
- _args14 = arguments;
470
+ _args15 = arguments;
466
471
  return _regeneratorRuntime().wrap(function _callee14$(_context14) {
467
472
  while (1) switch (_context14.prev = _context14.next) {
468
473
  case 0:
469
- tags = _args14.length > 0 && _args14[0] !== undefined ? _args14[0] : {};
474
+ tags = _args15.length > 0 && _args15[0] !== undefined ? _args15[0] : {};
470
475
  _context14.next = 3;
471
476
  return this.g("/~meta@1.0/info/address");
472
477
  case 3:
@@ -509,11 +514,11 @@ var HB = /*#__PURE__*/function () {
509
514
  _yield$this$schedule,
510
515
  slot,
511
516
  msgs,
512
- _args15 = arguments;
517
+ _args16 = arguments;
513
518
  return _regeneratorRuntime().wrap(function _callee15$(_context15) {
514
519
  while (1) switch (_context15.prev = _context15.next) {
515
520
  case 0:
516
- type = _args15.length > 1 && _args15[1] !== undefined ? _args15[1] : "application/lua";
521
+ type = _args16.length > 1 && _args16[1] !== undefined ? _args16[1] : "application/lua";
517
522
  if (this.cache) {
518
523
  _context15.next = 7;
519
524
  break;
@@ -631,11 +636,11 @@ var HB = /*#__PURE__*/function () {
631
636
  tags,
632
637
  data,
633
638
  scheduler,
634
- _args18 = arguments;
639
+ _args19 = arguments;
635
640
  return _regeneratorRuntime().wrap(function _callee18$(_context18) {
636
641
  while (1) switch (_context18.prev = _context18.next) {
637
642
  case 0:
638
- _ref7 = _args18.length > 0 && _args18[0] !== undefined ? _args18[0] : {}, pid = _ref7.pid, _ref7$action = _ref7.action, action = _ref7$action === void 0 ? "Eval" : _ref7$action, _ref7$tags = _ref7.tags, tags = _ref7$tags === void 0 ? {} : _ref7$tags, data = _ref7.data, scheduler = _ref7.scheduler;
643
+ _ref7 = _args19.length > 0 && _args19[0] !== undefined ? _args19[0] : {}, pid = _ref7.pid, _ref7$action = _ref7.action, action = _ref7$action === void 0 ? "Eval" : _ref7$action, _ref7$tags = _ref7.tags, tags = _ref7$tags === void 0 ? {} : _ref7$tags, data = _ref7.data, scheduler = _ref7.scheduler;
639
644
  if (action) tags.Action = action;
640
645
  _context18.next = 4;
641
646
  return this.schedule({
@@ -661,12 +666,12 @@ var HB = /*#__PURE__*/function () {
661
666
  key: "scheduleLua",
662
667
  value: function () {
663
668
  var _scheduleLua = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee19() {
664
- var _args19 = arguments;
669
+ var _args20 = arguments;
665
670
  return _regeneratorRuntime().wrap(function _callee19$(_context19) {
666
671
  while (1) switch (_context19.prev = _context19.next) {
667
672
  case 0:
668
673
  _context19.next = 2;
669
- return this.scheduleLegacy.apply(this, _args19);
674
+ return this.scheduleLegacy.apply(this, _args20);
670
675
  case 2:
671
676
  return _context19.abrupt("return", _context19.sent);
672
677
  case 3:
@@ -692,11 +697,11 @@ var HB = /*#__PURE__*/function () {
692
697
  data,
693
698
  _tags,
694
699
  res,
695
- _args20 = arguments;
700
+ _args21 = arguments;
696
701
  return _regeneratorRuntime().wrap(function _callee20$(_context20) {
697
702
  while (1) switch (_context20.prev = _context20.next) {
698
703
  case 0:
699
- _ref8 = _args20.length > 0 && _args20[0] !== undefined ? _args20[0] : {}, pid = _ref8.pid, _ref8$tags = _ref8.tags, tags = _ref8$tags === void 0 ? {} : _ref8$tags, data = _ref8.data;
704
+ _ref8 = _args21.length > 0 && _args21[0] !== undefined ? _args21[0] : {}, pid = _ref8.pid, _ref8$tags = _ref8.tags, tags = _ref8$tags === void 0 ? {} : _ref8$tags, data = _ref8.data;
700
705
  (_pid2 = pid) !== null && _pid2 !== void 0 ? _pid2 : pid = this.pid;
701
706
  _tags = (0, _ramda.mergeLeft)(tags, {
702
707
  method: "POST",
@@ -937,14 +942,13 @@ var HB = /*#__PURE__*/function () {
937
942
  pid,
938
943
  from,
939
944
  to,
940
- limit,
941
945
  params,
942
946
  res,
943
- _args26 = arguments;
947
+ _args27 = arguments;
944
948
  return _regeneratorRuntime().wrap(function _callee26$(_context26) {
945
949
  while (1) switch (_context26.prev = _context26.next) {
946
950
  case 0:
947
- _ref11 = _args26.length > 0 && _args26[0] !== undefined ? _args26[0] : {}, pid = _ref11.pid, from = _ref11.from, to = _ref11.to, limit = _ref11.limit;
951
+ _ref11 = _args27.length > 0 && _args27[0] !== undefined ? _args27[0] : {}, pid = _ref11.pid, from = _ref11.from, to = _ref11.to;
948
952
  params = "target=".concat(pid);
949
953
  if ((0, _ramda.isNotNil)(from)) params += "&from=".concat(from);
950
954
  if ((0, _ramda.isNotNil)(to)) params += "&to=".concat(to);
@@ -966,8 +970,7 @@ var HB = /*#__PURE__*/function () {
966
970
  return _this.messages({
967
971
  pid: pid,
968
972
  from: from2,
969
- to: to,
970
- limit: limit
973
+ to: to
971
974
  });
972
975
  case 3:
973
976
  return _context25.abrupt("return", _context25.sent);
@@ -1000,11 +1003,11 @@ var HB = /*#__PURE__*/function () {
1000
1003
  tags,
1001
1004
  data,
1002
1005
  t,
1003
- _args27 = arguments;
1006
+ _args28 = arguments;
1004
1007
  return _regeneratorRuntime().wrap(function _callee27$(_context27) {
1005
1008
  while (1) switch (_context27.prev = _context27.next) {
1006
1009
  case 0:
1007
- _ref13 = _args27.length > 0 && _args27[0] !== undefined ? _args27[0] : {}, module = _ref13.module, _ref13$tags = _ref13.tags, tags = _ref13$tags === void 0 ? {} : _ref13$tags, data = _ref13.data;
1010
+ _ref13 = _args28.length > 0 && _args28[0] !== undefined ? _args28[0] : {}, module = _ref13.module, _ref13$tags = _ref13.tags, tags = _ref13$tags === void 0 ? {} : _ref13$tags, data = _ref13.data;
1008
1011
  _context27.next = 3;
1009
1012
  return this.setInfo();
1010
1013
  case 3:
@@ -1056,11 +1059,11 @@ var HB = /*#__PURE__*/function () {
1056
1059
  params,
1057
1060
  addParam,
1058
1061
  res,
1059
- _args28 = arguments;
1062
+ _args29 = arguments;
1060
1063
  return _regeneratorRuntime().wrap(function _callee28$(_context28) {
1061
1064
  while (1) switch (_context28.prev = _context28.next) {
1062
1065
  case 0:
1063
- _ref14 = _args28.length > 0 && _args28[0] !== undefined ? _args28[0] : {}, process = _ref14.process, limit = _ref14.limit, _ref14$sort = _ref14.sort, sort = _ref14$sort === void 0 ? "DESC" : _ref14$sort, from = _ref14.from, to = _ref14.to;
1066
+ _ref14 = _args29.length > 0 && _args29[0] !== undefined ? _args29[0] : {}, process = _ref14.process, limit = _ref14.limit, _ref14$sort = _ref14.sort, sort = _ref14$sort === void 0 ? "DESC" : _ref14$sort, from = _ref14.from, to = _ref14.to;
1064
1067
  params = "";
1065
1068
  addParam = function addParam(key, val) {
1066
1069
  params += params === "" ? "?" : "&";
@@ -1103,11 +1106,11 @@ var HB = /*#__PURE__*/function () {
1103
1106
  data,
1104
1107
  json,
1105
1108
  res,
1106
- _args29 = arguments;
1109
+ _args30 = arguments;
1107
1110
  return _regeneratorRuntime().wrap(function _callee29$(_context29) {
1108
1111
  while (1) switch (_context29.prev = _context29.next) {
1109
1112
  case 0:
1110
- _ref15 = _args29.length > 0 && _args29[0] !== undefined ? _args29[0] : {}, _ref15$tags = _ref15.tags, tags = _ref15$tags === void 0 ? {} : _ref15$tags, pid = _ref15.pid, action = _ref15.action, data = _ref15.data;
1113
+ _ref15 = _args30.length > 0 && _args30[0] !== undefined ? _args30[0] : {}, _ref15$tags = _ref15.tags, tags = _ref15$tags === void 0 ? {} : _ref15$tags, pid = _ref15.pid, action = _ref15.action, data = _ref15.data;
1111
1114
  if (typeof action === "string") tags.Action = action;
1112
1115
  json = {
1113
1116
  Tags: (0, _utils.buildTags)(_objectSpread({}, tags)),
@@ -1187,56 +1190,58 @@ var HB = /*#__PURE__*/function () {
1187
1190
  var _len,
1188
1191
  args,
1189
1192
  _key,
1190
- _args31 = arguments;
1193
+ _args,
1194
+ _args32 = arguments;
1191
1195
  return _regeneratorRuntime().wrap(function _callee31$(_context31) {
1192
1196
  while (1) switch (_context31.prev = _context31.next) {
1193
1197
  case 0:
1194
- for (_len = _args31.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1195
- args[_key - 1] = _args31[_key];
1198
+ for (_len = _args32.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1199
+ args[_key - 1] = _args32[_key];
1196
1200
  }
1197
- (_args$_ = args[_ = 0]) !== null && _args$_ !== void 0 ? _args$_ : args[_] = {};
1198
- (_args$$path = (_args$ = args[0]).path) !== null && _args$$path !== void 0 ? _args$$path : _args$.path = path;
1199
- _context31.next = 5;
1200
- return this.post.apply(this, args);
1201
- case 5:
1201
+ _args = (0, _ramda.clone)(args);
1202
+ (_args$_ = _args[_ = 0]) !== null && _args$_ !== void 0 ? _args$_ : _args[_] = {};
1203
+ (_args$$path = (_args$ = _args[0]).path) !== null && _args$$path !== void 0 ? _args$$path : _args$.path = path;
1204
+ _context31.next = 6;
1205
+ return this.post.apply(this, _toConsumableArray(_args));
1206
+ case 6:
1202
1207
  _context31.t2 = _yield$this$post = _context31.sent;
1203
1208
  _context31.t1 = _context31.t2 === null;
1204
1209
  if (_context31.t1) {
1205
- _context31.next = 9;
1210
+ _context31.next = 10;
1206
1211
  break;
1207
1212
  }
1208
1213
  _context31.t1 = _yield$this$post === void 0;
1209
- case 9:
1214
+ case 10:
1210
1215
  if (!_context31.t1) {
1211
- _context31.next = 13;
1216
+ _context31.next = 14;
1212
1217
  break;
1213
1218
  }
1214
1219
  _context31.t3 = void 0;
1215
- _context31.next = 14;
1220
+ _context31.next = 15;
1216
1221
  break;
1217
- case 13:
1218
- _context31.t3 = _yield$this$post.out;
1219
1222
  case 14:
1223
+ _context31.t3 = _yield$this$post.out;
1224
+ case 15:
1220
1225
  _context31.t4 = _yield$this$post$out = _context31.t3;
1221
1226
  _context31.t0 = _context31.t4 !== null;
1222
1227
  if (!_context31.t0) {
1223
- _context31.next = 18;
1228
+ _context31.next = 19;
1224
1229
  break;
1225
1230
  }
1226
1231
  _context31.t0 = _yield$this$post$out !== void 0;
1227
- case 18:
1232
+ case 19:
1228
1233
  if (!_context31.t0) {
1229
- _context31.next = 22;
1234
+ _context31.next = 23;
1230
1235
  break;
1231
1236
  }
1232
1237
  _context31.t5 = _yield$this$post$out;
1233
- _context31.next = 23;
1238
+ _context31.next = 24;
1234
1239
  break;
1235
- case 22:
1236
- _context31.t5 = null;
1237
1240
  case 23:
1238
- return _context31.abrupt("return", _context31.t5);
1241
+ _context31.t5 = null;
1239
1242
  case 24:
1243
+ return _context31.abrupt("return", _context31.t5);
1244
+ case 25:
1240
1245
  case "end":
1241
1246
  return _context31.stop();
1242
1247
  }
@@ -1285,56 +1290,58 @@ var HB = /*#__PURE__*/function () {
1285
1290
  var _len2,
1286
1291
  args,
1287
1292
  _key2,
1288
- _args33 = arguments;
1293
+ _args,
1294
+ _args34 = arguments;
1289
1295
  return _regeneratorRuntime().wrap(function _callee33$(_context33) {
1290
1296
  while (1) switch (_context33.prev = _context33.next) {
1291
1297
  case 0:
1292
- for (_len2 = _args33.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
1293
- args[_key2 - 1] = _args33[_key2];
1298
+ for (_len2 = _args34.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
1299
+ args[_key2 - 1] = _args34[_key2];
1294
1300
  }
1295
- (_args$_2 = args[_2 = 0]) !== null && _args$_2 !== void 0 ? _args$_2 : args[_2] = {};
1296
- (_args$2$path = (_args$2 = args[0]).path) !== null && _args$2$path !== void 0 ? _args$2$path : _args$2.path = path;
1297
- _context33.next = 5;
1298
- return this.get.apply(this, args);
1299
- case 5:
1301
+ _args = (0, _ramda.clone)(args);
1302
+ (_args$_2 = _args[_2 = 0]) !== null && _args$_2 !== void 0 ? _args$_2 : _args[_2] = {};
1303
+ (_args$2$path = (_args$2 = _args[0]).path) !== null && _args$2$path !== void 0 ? _args$2$path : _args$2.path = path;
1304
+ _context33.next = 6;
1305
+ return this.get.apply(this, _toConsumableArray(_args));
1306
+ case 6:
1300
1307
  _context33.t2 = _yield$this$get = _context33.sent;
1301
1308
  _context33.t1 = _context33.t2 === null;
1302
1309
  if (_context33.t1) {
1303
- _context33.next = 9;
1310
+ _context33.next = 10;
1304
1311
  break;
1305
1312
  }
1306
1313
  _context33.t1 = _yield$this$get === void 0;
1307
- case 9:
1314
+ case 10:
1308
1315
  if (!_context33.t1) {
1309
- _context33.next = 13;
1316
+ _context33.next = 14;
1310
1317
  break;
1311
1318
  }
1312
1319
  _context33.t3 = void 0;
1313
- _context33.next = 14;
1320
+ _context33.next = 15;
1314
1321
  break;
1315
- case 13:
1316
- _context33.t3 = _yield$this$get.out;
1317
1322
  case 14:
1323
+ _context33.t3 = _yield$this$get.out;
1324
+ case 15:
1318
1325
  _context33.t4 = _yield$this$get$out = _context33.t3;
1319
1326
  _context33.t0 = _context33.t4 !== null;
1320
1327
  if (!_context33.t0) {
1321
- _context33.next = 18;
1328
+ _context33.next = 19;
1322
1329
  break;
1323
1330
  }
1324
1331
  _context33.t0 = _yield$this$get$out !== void 0;
1325
- case 18:
1332
+ case 19:
1326
1333
  if (!_context33.t0) {
1327
- _context33.next = 22;
1334
+ _context33.next = 23;
1328
1335
  break;
1329
1336
  }
1330
1337
  _context33.t5 = _yield$this$get$out;
1331
- _context33.next = 23;
1338
+ _context33.next = 24;
1332
1339
  break;
1333
- case 22:
1334
- _context33.t5 = null;
1335
1340
  case 23:
1336
- return _context33.abrupt("return", _context33.t5);
1341
+ _context33.t5 = null;
1337
1342
  case 24:
1343
+ return _context33.abrupt("return", _context33.t5);
1344
+ case 25:
1338
1345
  case "end":
1339
1346
  return _context33.stop();
1340
1347
  }
@@ -1360,12 +1367,12 @@ var HB = /*#__PURE__*/function () {
1360
1367
  response,
1361
1368
  headers,
1362
1369
  http,
1363
- _args34 = arguments;
1370
+ _args35 = arguments;
1364
1371
  return _regeneratorRuntime().wrap(function _callee34$(_context34) {
1365
1372
  while (1) switch (_context34.prev = _context34.next) {
1366
1373
  case 0:
1367
1374
  path = _ref16.path, params = _objectWithoutProperties(_ref16, _excluded2);
1368
- json = _args34.length > 1 && _args34[1] !== undefined ? _args34[1] : false;
1375
+ json = _args35.length > 1 && _args35[1] !== undefined ? _args35[1] : false;
1369
1376
  _json = json ? "/~json@1.0/serialize" : "";
1370
1377
  (_path = path) !== null && _path !== void 0 ? _path : path = "/~message@1.0";
1371
1378
  if (!/^\//.test(path)) path = "/" + path;
package/cjs/hyperbeam.js CHANGED
@@ -36,8 +36,6 @@ var HyperBEAM = exports["default"] = /*#__PURE__*/function () {
36
36
  var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
37
37
  _ref$port = _ref.port,
38
38
  port = _ref$port === void 0 ? 10001 : _ref$port,
39
- _ref$cu = _ref.cu,
40
- cu = _ref$cu === void 0 ? 6363 : _ref$cu,
41
39
  _ref$as = _ref.as,
42
40
  as = _ref$as === void 0 ? [] : _ref$as,
43
41
  bundler = _ref.bundler,
@@ -95,7 +93,7 @@ var HyperBEAM = exports["default"] = /*#__PURE__*/function () {
95
93
  _iterator.f();
96
94
  }
97
95
  }
98
- this.cu = cu;
96
+ //this.cu = cu
99
97
  this.store_prefix = store_prefix ? "cache-mainnet-" + Math.floor(Math.random() * 10000000) : "cache-mainnet";
100
98
  this.p4_lua = p4_lua;
101
99
  this.simple_pay = simple_pay;
@@ -1,3 +1,4 @@
1
+
1
2
  #### 1. Create an APP
2
3
 
3
4
  ```bash
@@ -17,7 +18,7 @@ Go to [the web app](https://preview.wao.eco) and open `Networks`, then click `Pr
17
18
  #### 4. Run Test
18
19
 
19
20
  ```bash
20
- yarn test test/test.js
21
+ yarn test test/hyperbeam.test.js
21
22
  ```
22
23
 
23
24
  #### 5. Deploy a Process to AO Testnet
@@ -9,6 +9,6 @@
9
9
  "deploy": "node scripts/deploy.js"
10
10
  },
11
11
  "dependencies": {
12
- "wao": "^0.31.0"
12
+ "wao": "^0.32.0"
13
13
  }
14
14
  }
@@ -1,18 +1,30 @@
1
1
  import assert from "assert"
2
2
  import { describe, it, before, after, beforeEach } from "node:test"
3
3
  import { HyperBEAM } from "wao/test"
4
- const cwd = "../../HyperBEAM"
4
+
5
+ /*
6
+ The link to your HyperBEAM node directory.
7
+ It's relative to your app root folder, not the test folder.
8
+ */
9
+ const cwd = "../HyperBEAM"
5
10
 
6
11
  describe("HyperBEAM", function () {
7
12
  let hbeam, hb
8
- before(
9
- async () => (hbeam = await new HyperBEAM({ cwd, reset: true }).ready())
10
- )
13
+
14
+ // start a hyperbeam node and wait till it's ready
15
+ before(async () => (hbeam = await new HyperBEAM({ cwd }).ready()))
16
+
11
17
  beforeEach(async () => (hb = hbeam.hb))
18
+
19
+ // kill the node after testing
12
20
  after(async () => hbeam.kill())
13
21
 
14
22
  it("should run a HyperBEAM node", async () => {
15
- const build = await hb.g("/~meta@1.0/build")
16
- assert.equal(build.node, "HyperBEAM")
23
+ // change config
24
+ await hb.post({ path: "/~meta@1.0/info", test_config: "abc" })
25
+
26
+ // get config
27
+ const { out } = await hb.get({ path: "/~meta@1.0/info" })
28
+ assert.equal(out.test_config, "abc")
17
29
  })
18
30
  })
@@ -0,0 +1,23 @@
1
+ import assert from "assert"
2
+ import { describe, it } from "node:test"
3
+ import { readFileSync } from "fs"
4
+ import { resolve } from "path"
5
+
6
+ import { AO, acc } from "wao/test" // in-memory test
7
+
8
+ const src_data = readFileSync(
9
+ resolve(import.meta.dirname, "../src/counter.lua"),
10
+ "utf8"
11
+ )
12
+
13
+ describe("WAO Legacynet", function () {
14
+ // lightning-fast testing in memory
15
+ it("should spawn a process and send messages in memory", async () => {
16
+ const ao = await new AO().init(acc[0])
17
+ const { p, pid } = await ao.deploy({ src_data, scheduler: acc[0].addr })
18
+
19
+ assert.equal(await p.d("Hello", false), "Hello, World!")
20
+ assert.equal(await p.m("Inc", false), "Incremented!")
21
+ assert.equal(await p.d("Get", false), "1")
22
+ })
23
+ })
@@ -11,17 +11,7 @@ const src_data = readFileSync(
11
11
  "utf8"
12
12
  )
13
13
 
14
- describe("WAO", function () {
15
- // lightning-fast testing in memory
16
- it("should spawn a process and send messages in memory", async () => {
17
- const ao = await new AO().init(acc[0])
18
- const { p, pid } = await ao.deploy({ src_data, scheduler: acc[0].addr })
19
-
20
- assert.equal(await p.d("Hello", false), "Hello, World!")
21
- assert.equal(await p.m("Inc", false), "Incremented!")
22
- assert.equal(await p.d("Get", false), "1")
23
- })
24
-
14
+ describe("WAO the Web", function () {
25
15
  // WAO Proxy must be running on your computer => "npx wao proxy"
26
16
  it("should spawn a process and send messages to the browser", async () => {
27
17
  // connect with 4000 - 4004 ports
package/esm/hb.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { connect, createSigner } from "@permaweb/aoconnect"
2
- import { isEmpty, last, isNotNil, mergeLeft } from "ramda"
2
+ import { isEmpty, last, isNotNil, mergeLeft, clone } from "ramda"
3
3
  import { rsaid, hmacid, toAddr, buildTags } from "./utils.js"
4
4
  import { sign, signer } from "./signer.js"
5
5
  import { send as _send } from "./send.js"
@@ -105,7 +105,6 @@ class HB {
105
105
 
106
106
  async messageLegacy(args) {
107
107
  const { slot, pid } = await this.scheduleLegacy(args)
108
- console.log(slot, pid, args)
109
108
  return { slot, res: await this.computeLegacy({ pid, slot }) }
110
109
  }
111
110
 
@@ -265,7 +264,7 @@ class HB {
265
264
  return await this.getJSON({ path: `/${pid}/slot${path}` })
266
265
  }
267
266
 
268
- async messages({ pid, from, to, limit } = {}) {
267
+ async messages({ pid, from, to } = {}) {
269
268
  let params = `target=${pid}`
270
269
  if (isNotNil(from)) params += `&from=${from}`
271
270
  if (isNotNil(to)) params += `&to=${to}`
@@ -276,7 +275,7 @@ class HB {
276
275
  if (res.page_info.has_next_page) {
277
276
  res.next = async () => {
278
277
  const from2 = last(res.edges).cursor + 1
279
- return await this.messages({ pid, from: from2, to, limit })
278
+ return await this.messages({ pid, from: from2, to })
280
279
  }
281
280
  }
282
281
  return res
@@ -360,9 +359,10 @@ class HB {
360
359
  }
361
360
 
362
361
  async p(path, ...args) {
363
- args[0] ??= {}
364
- args[0].path ??= path
365
- return (await this.post(...args))?.out ?? null
362
+ let _args = clone(args)
363
+ _args[0] ??= {}
364
+ _args[0].path ??= path
365
+ return (await this.post(..._args))?.out ?? null
366
366
  }
367
367
 
368
368
  async post(obj, json) {
@@ -372,9 +372,10 @@ class HB {
372
372
  }
373
373
 
374
374
  async g(path, ...args) {
375
- args[0] ??= {}
376
- args[0].path ??= path
377
- return (await this.get(...args))?.out ?? null
375
+ let _args = clone(args)
376
+ _args[0] ??= {}
377
+ _args[0].path ??= path
378
+ return (await this.get(..._args))?.out ?? null
378
379
  }
379
380
 
380
381
  async get({ path, ...params }, json = false) {
package/esm/hyperbeam.js CHANGED
@@ -12,7 +12,7 @@ export default class HyperBEAM {
12
12
  static OPERATOR = Symbol("operator")
13
13
  constructor({
14
14
  port = 10001,
15
- cu = 6363,
15
+ //cu = 6363,
16
16
  as = [],
17
17
  bundler,
18
18
  gateway,
@@ -52,7 +52,7 @@ export default class HyperBEAM {
52
52
  }
53
53
  }
54
54
  }
55
- this.cu = cu
55
+ //this.cu = cu
56
56
  this.store_prefix = store_prefix
57
57
  ? "cache-mainnet-" + Math.floor(Math.random() * 10000000)
58
58
  : "cache-mainnet"
@@ -1,3 +1,4 @@
1
+
1
2
  #### 1. Create an APP
2
3
 
3
4
  ```bash
@@ -17,7 +18,7 @@ Go to [the web app](https://preview.wao.eco) and open `Networks`, then click `Pr
17
18
  #### 4. Run Test
18
19
 
19
20
  ```bash
20
- yarn test test/test.js
21
+ yarn test test/hyperbeam.test.js
21
22
  ```
22
23
 
23
24
  #### 5. Deploy a Process to AO Testnet
@@ -9,6 +9,6 @@
9
9
  "deploy": "node scripts/deploy.js"
10
10
  },
11
11
  "dependencies": {
12
- "wao": "^0.31.0"
12
+ "wao": "^0.32.0"
13
13
  }
14
14
  }
@@ -1,18 +1,30 @@
1
1
  import assert from "assert"
2
2
  import { describe, it, before, after, beforeEach } from "node:test"
3
3
  import { HyperBEAM } from "wao/test"
4
- const cwd = "../../HyperBEAM"
4
+
5
+ /*
6
+ The link to your HyperBEAM node directory.
7
+ It's relative to your app root folder, not the test folder.
8
+ */
9
+ const cwd = "../HyperBEAM"
5
10
 
6
11
  describe("HyperBEAM", function () {
7
12
  let hbeam, hb
8
- before(
9
- async () => (hbeam = await new HyperBEAM({ cwd, reset: true }).ready())
10
- )
13
+
14
+ // start a hyperbeam node and wait till it's ready
15
+ before(async () => (hbeam = await new HyperBEAM({ cwd }).ready()))
16
+
11
17
  beforeEach(async () => (hb = hbeam.hb))
18
+
19
+ // kill the node after testing
12
20
  after(async () => hbeam.kill())
13
21
 
14
22
  it("should run a HyperBEAM node", async () => {
15
- const build = await hb.g("/~meta@1.0/build")
16
- assert.equal(build.node, "HyperBEAM")
23
+ // change config
24
+ await hb.post({ path: "/~meta@1.0/info", test_config: "abc" })
25
+
26
+ // get config
27
+ const { out } = await hb.get({ path: "/~meta@1.0/info" })
28
+ assert.equal(out.test_config, "abc")
17
29
  })
18
30
  })
@@ -0,0 +1,23 @@
1
+ import assert from "assert"
2
+ import { describe, it } from "node:test"
3
+ import { readFileSync } from "fs"
4
+ import { resolve } from "path"
5
+
6
+ import { AO, acc } from "wao/test" // in-memory test
7
+
8
+ const src_data = readFileSync(
9
+ resolve(import.meta.dirname, "../src/counter.lua"),
10
+ "utf8"
11
+ )
12
+
13
+ describe("WAO Legacynet", function () {
14
+ // lightning-fast testing in memory
15
+ it("should spawn a process and send messages in memory", async () => {
16
+ const ao = await new AO().init(acc[0])
17
+ const { p, pid } = await ao.deploy({ src_data, scheduler: acc[0].addr })
18
+
19
+ assert.equal(await p.d("Hello", false), "Hello, World!")
20
+ assert.equal(await p.m("Inc", false), "Incremented!")
21
+ assert.equal(await p.d("Get", false), "1")
22
+ })
23
+ })
@@ -11,17 +11,7 @@ const src_data = readFileSync(
11
11
  "utf8"
12
12
  )
13
13
 
14
- describe("WAO", function () {
15
- // lightning-fast testing in memory
16
- it("should spawn a process and send messages in memory", async () => {
17
- const ao = await new AO().init(acc[0])
18
- const { p, pid } = await ao.deploy({ src_data, scheduler: acc[0].addr })
19
-
20
- assert.equal(await p.d("Hello", false), "Hello, World!")
21
- assert.equal(await p.m("Inc", false), "Incremented!")
22
- assert.equal(await p.d("Get", false), "1")
23
- })
24
-
14
+ describe("WAO the Web", function () {
25
15
  // WAO Proxy must be running on your computer => "npx wao proxy"
26
16
  it("should spawn a process and send messages to the browser", async () => {
27
17
  // connect with 4000 - 4004 ports
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wao",
3
- "version": "0.31.1",
3
+ "version": "0.32.0",
4
4
  "bin": {
5
5
  "wao": "./cjs/cli.js",
6
6
  "wao-esm": "./esm/cli.js"