wao 0.13.0 → 0.13.2

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/bao.js CHANGED
@@ -71,10 +71,12 @@ var AO = /*#__PURE__*/function (_MAO) {
71
71
  })]);
72
72
  _this.in_memory = true;
73
73
  _this.createDataItemSigner = (_opt$createDataItemSi = opt.createDataItemSigner) !== null && _opt$createDataItemSi !== void 0 ? _opt$createDataItemSi : _aoconnect.createDataItemSigner;
74
+ _this.hb = opt.hb;
74
75
  var _opt$connect = opt.connect(opt.mem, {
75
76
  extensions: opt.extensions,
76
77
  cache: opt.cache,
77
- reset: opt.reset
78
+ reset: opt.reset,
79
+ hb: _this.hb
78
80
  }),
79
81
  modules = _opt$connect.modules,
80
82
  results = _opt$connect.results,
@@ -85,7 +87,9 @@ var AO = /*#__PURE__*/function (_MAO) {
85
87
  dryrun = _opt$connect.dryrun,
86
88
  monitor = _opt$connect.monitor,
87
89
  unmonitor = _opt$connect.unmonitor,
90
+ recover = _opt$connect.recover,
88
91
  mem = _opt$connect.mem;
92
+ _this.recover = recover;
89
93
  _this.assign = assign;
90
94
  _this.result = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
91
95
  var res,
@@ -168,8 +172,15 @@ var AO = /*#__PURE__*/function (_MAO) {
168
172
  _context4.next = 3;
169
173
  return this.ar.init(jwk);
170
174
  case 3:
175
+ if (!this.hb) {
176
+ _context4.next = 6;
177
+ break;
178
+ }
179
+ _context4.next = 6;
180
+ return this.hb.init(jwk);
181
+ case 6:
171
182
  return _context4.abrupt("return", this);
172
- case 4:
183
+ case 7:
173
184
  case "end":
174
185
  return _context4.stop();
175
186
  }
package/cjs/bar.js CHANGED
@@ -93,32 +93,41 @@ var AR = /*#__PURE__*/function (_MAR) {
93
93
  key: "httpmsg",
94
94
  value: function () {
95
95
  var _httpmsg = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(msg) {
96
- var tags, _parseSignatureInput, n, owner;
96
+ var tags, owner, _parseSignatureInput, n, _tags$Owner;
97
97
  return _regeneratorRuntime().wrap(function _callee$(_context) {
98
98
  while (1) switch (_context.prev = _context.next) {
99
99
  case 0:
100
100
  tags = (0, _utils.tags)(msg.tags);
101
+ owner = null;
102
+ _context.prev = 2;
101
103
  _parseSignatureInput = parseSignatureInput(tags["signature-input"]), n = _parseSignatureInput.keyid;
102
- _context.next = 4;
104
+ _context.next = 6;
103
105
  return this.arweave.wallets.jwkToAddress({
104
106
  n: n
105
107
  });
106
- case 4:
108
+ case 6:
107
109
  owner = _context.sent;
108
- _context.next = 7;
110
+ _context.next = 12;
111
+ break;
112
+ case 9:
113
+ _context.prev = 9;
114
+ _context.t0 = _context["catch"](2);
115
+ owner = (_tags$Owner = tags.Owner) !== null && _tags$Owner !== void 0 ? _tags$Owner : null;
116
+ case 12:
117
+ _context.next = 14;
109
118
  return this.mem.set(msg, "txs", msg.id);
110
- case 7:
119
+ case 14:
111
120
  return _context.abrupt("return", {
112
121
  item: msg,
113
122
  id: tags.id,
114
123
  tags: tags,
115
124
  owner: owner
116
125
  });
117
- case 8:
126
+ case 15:
118
127
  case "end":
119
128
  return _context.stop();
120
129
  }
121
- }, _callee, this);
130
+ }, _callee, this, [[2, 9]]);
122
131
  }));
123
132
  function httpmsg(_x) {
124
133
  return _httpmsg.apply(this, arguments);
package/cjs/hb.js CHANGED
@@ -43,7 +43,7 @@ var HB = /*#__PURE__*/function () {
43
43
  while (1) switch (_context.prev = _context.next) {
44
44
  case 0:
45
45
  _context.next = 2;
46
- return fetch("".concat(this.url, "/metrics")).then(function (r) {
46
+ return fetch("".concat(this.url, "/~hyperbuddy@1.0/metrics")).then(function (r) {
47
47
  return r.text();
48
48
  });
49
49
  case 2:
@@ -176,19 +176,80 @@ var HB = /*#__PURE__*/function () {
176
176
  return init;
177
177
  }()
178
178
  }, {
179
- key: "process",
179
+ key: "messages",
180
180
  value: function () {
181
- var _process = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
181
+ var _messages = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
182
+ var _this = this;
182
183
  var _ref2,
183
- _ref2$tags,
184
+ target,
185
+ from,
186
+ to,
187
+ limit,
188
+ params,
189
+ res,
190
+ _args5 = arguments;
191
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
192
+ while (1) switch (_context5.prev = _context5.next) {
193
+ case 0:
194
+ _ref2 = _args5.length > 0 && _args5[0] !== undefined ? _args5[0] : {}, target = _ref2.target, from = _ref2.from, to = _ref2.to, limit = _ref2.limit;
195
+ params = "target=".concat(target);
196
+ if ((0, _ramda.isNotNil)(from)) params += "&from=".concat(from);
197
+ if ((0, _ramda.isNotNil)(to)) params += "&to=".concat(to);
198
+ params += "&accept=application/aos-2";
199
+ _context5.next = 7;
200
+ return fetch("".concat(this.url, "/~scheduler@1.0/schedule?").concat(params)).then(function (r) {
201
+ return r.json();
202
+ });
203
+ case 7:
204
+ res = _context5.sent;
205
+ if (res.page_info.has_next_page) {
206
+ res.next = /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
207
+ var from2;
208
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
209
+ while (1) switch (_context4.prev = _context4.next) {
210
+ case 0:
211
+ from2 = (0, _ramda.last)(res.edges).cursor + 1;
212
+ _context4.next = 3;
213
+ return _this.message({
214
+ target: target,
215
+ from2: from2,
216
+ to: to
217
+ });
218
+ case 3:
219
+ return _context4.abrupt("return", _context4.sent);
220
+ case 4:
221
+ case "end":
222
+ return _context4.stop();
223
+ }
224
+ }, _callee4);
225
+ }));
226
+ }
227
+ return _context5.abrupt("return", res);
228
+ case 10:
229
+ case "end":
230
+ return _context5.stop();
231
+ }
232
+ }, _callee5, this);
233
+ }));
234
+ function messages() {
235
+ return _messages.apply(this, arguments);
236
+ }
237
+ return messages;
238
+ }()
239
+ }, {
240
+ key: "process",
241
+ value: function () {
242
+ var _process = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
243
+ var _ref4,
244
+ _ref4$tags,
184
245
  tags,
185
- _ref2$data,
186
246
  data,
187
- _args4 = arguments;
188
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
189
- while (1) switch (_context4.prev = _context4.next) {
247
+ res,
248
+ _args6 = arguments;
249
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
250
+ while (1) switch (_context6.prev = _context6.next) {
190
251
  case 0:
191
- _ref2 = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : {}, _ref2$tags = _ref2.tags, tags = _ref2$tags === void 0 ? {} : _ref2$tags, _ref2$data = _ref2.data, data = _ref2$data === void 0 ? "1984" : _ref2$data;
252
+ _ref4 = _args6.length > 0 && _args6[0] !== undefined ? _args6[0] : {}, _ref4$tags = _ref4.tags, tags = _ref4$tags === void 0 ? {} : _ref4$tags, data = _ref4.data;
192
253
  tags = (0, _ramda.mergeLeft)(tags, {
193
254
  data: data,
194
255
  Type: "Process",
@@ -203,17 +264,21 @@ var HB = /*#__PURE__*/function () {
203
264
  "scheduler-device": "scheduler@1.0",
204
265
  "execution-device": "genesis-wasm@1.0"
205
266
  });
206
- _context4.next = 4;
267
+ _context6.next = 4;
207
268
  return this.post({
208
269
  tags: tags
209
270
  });
210
271
  case 4:
211
- return _context4.abrupt("return", _context4.sent);
212
- case 5:
272
+ res = _context6.sent;
273
+ _context6.next = 7;
274
+ return res.process.text();
275
+ case 7:
276
+ return _context6.abrupt("return", _context6.sent);
277
+ case 8:
213
278
  case "end":
214
- return _context4.stop();
279
+ return _context6.stop();
215
280
  }
216
- }, _callee4, this);
281
+ }, _callee6, this);
217
282
  }));
218
283
  function process() {
219
284
  return _process.apply(this, arguments);
@@ -223,19 +288,19 @@ var HB = /*#__PURE__*/function () {
223
288
  }, {
224
289
  key: "schedule",
225
290
  value: function () {
226
- var _schedule = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
227
- var _ref3,
228
- _ref3$tags,
291
+ var _schedule = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
292
+ var _ref5,
293
+ _ref5$tags,
229
294
  tags,
230
295
  data,
231
296
  process,
232
- _ref3$action,
297
+ _ref5$action,
233
298
  action,
234
- _args5 = arguments;
235
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
236
- while (1) switch (_context5.prev = _context5.next) {
299
+ _args7 = arguments;
300
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
301
+ while (1) switch (_context7.prev = _context7.next) {
237
302
  case 0:
238
- _ref3 = _args5.length > 0 && _args5[0] !== undefined ? _args5[0] : {}, _ref3$tags = _ref3.tags, tags = _ref3$tags === void 0 ? {} : _ref3$tags, data = _ref3.data, process = _ref3.process, _ref3$action = _ref3.action, action = _ref3$action === void 0 ? "Eval" : _ref3$action;
303
+ _ref5 = _args7.length > 0 && _args7[0] !== undefined ? _args7[0] : {}, _ref5$tags = _ref5.tags, tags = _ref5$tags === void 0 ? {} : _ref5$tags, data = _ref5.data, process = _ref5.process, _ref5$action = _ref5.action, action = _ref5$action === void 0 ? "Eval" : _ref5$action;
239
304
  tags = (0, _ramda.mergeLeft)(tags, {
240
305
  path: "".concat(process, "/schedule"),
241
306
  type: "Message",
@@ -244,17 +309,17 @@ var HB = /*#__PURE__*/function () {
244
309
  "Data-Protocol": "ao",
245
310
  Variant: "ao.N.1"
246
311
  });
247
- _context5.next = 4;
312
+ _context7.next = 4;
248
313
  return this.post({
249
314
  tags: tags
250
315
  });
251
316
  case 4:
252
- return _context5.abrupt("return", _context5.sent.slot.text());
317
+ return _context7.abrupt("return", _context7.sent.slot.text());
253
318
  case 5:
254
319
  case "end":
255
- return _context5.stop();
320
+ return _context7.stop();
256
321
  }
257
- }, _callee5, this);
322
+ }, _callee7, this);
258
323
  }));
259
324
  function schedule() {
260
325
  return _schedule.apply(this, arguments);
@@ -264,29 +329,29 @@ var HB = /*#__PURE__*/function () {
264
329
  }, {
265
330
  key: "compute",
266
331
  value: function () {
267
- var _compute = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
268
- var _ref4,
269
- _ref4$tags,
332
+ var _compute = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
333
+ var _ref6,
334
+ _ref6$tags,
270
335
  tags,
271
336
  process,
272
337
  slot,
273
- _args6 = arguments;
274
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
275
- while (1) switch (_context6.prev = _context6.next) {
338
+ _args8 = arguments;
339
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
340
+ while (1) switch (_context8.prev = _context8.next) {
276
341
  case 0:
277
- _ref4 = _args6.length > 0 && _args6[0] !== undefined ? _args6[0] : {}, _ref4$tags = _ref4.tags, tags = _ref4$tags === void 0 ? {} : _ref4$tags, process = _ref4.process, slot = _ref4.slot;
278
- _context6.next = 3;
342
+ _ref6 = _args8.length > 0 && _args8[0] !== undefined ? _args8[0] : {}, _ref6$tags = _ref6.tags, tags = _ref6$tags === void 0 ? {} : _ref6$tags, process = _ref6.process, slot = _ref6.slot;
343
+ _context8.next = 3;
279
344
  return this.request({
280
345
  method: "GET",
281
346
  path: "/".concat(process, "/compute&slot+integer=").concat(slot, "/results/json")
282
347
  });
283
348
  case 3:
284
- return _context6.abrupt("return", _context6.sent);
349
+ return _context8.abrupt("return", _context8.sent);
285
350
  case 4:
286
351
  case "end":
287
- return _context6.stop();
352
+ return _context8.stop();
288
353
  }
289
- }, _callee6, this);
354
+ }, _callee8, this);
290
355
  }));
291
356
  function compute() {
292
357
  return _compute.apply(this, arguments);
@@ -296,31 +361,35 @@ var HB = /*#__PURE__*/function () {
296
361
  }, {
297
362
  key: "dryrun",
298
363
  value: function () {
299
- var _dryrun = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7() {
300
- var _ref5,
301
- _ref5$tags,
364
+ var _dryrun = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee9() {
365
+ var _ref7,
366
+ _ref7$tags,
302
367
  tags,
303
368
  process,
304
369
  action,
305
- _args7 = arguments;
306
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
307
- while (1) switch (_context7.prev = _context7.next) {
370
+ data,
371
+ json,
372
+ _args9 = arguments;
373
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
374
+ while (1) switch (_context9.prev = _context9.next) {
308
375
  case 0:
309
- _ref5 = _args7.length > 0 && _args7[0] !== undefined ? _args7[0] : {}, _ref5$tags = _ref5.tags, tags = _ref5$tags === void 0 ? {} : _ref5$tags, process = _ref5.process, action = _ref5.action;
376
+ _ref7 = _args9.length > 0 && _args9[0] !== undefined ? _args9[0] : {}, _ref7$tags = _ref7.tags, tags = _ref7$tags === void 0 ? {} : _ref7$tags, process = _ref7.process, action = _ref7.action, data = _ref7.data;
310
377
  if (typeof action === "string") tags.Action = action;
311
- _context7.next = 4;
312
- return fetch("".concat(this.url, "/~relay@1.0/call?relay-method=POST&relay-path=/dry-run?process-id=").concat(process, "/&content-type=application/json&body=").concat(JSON.stringify({
378
+ json = {
313
379
  Tags: (0, _utils.buildTags)(tags)
314
- }))).then(function (r) {
380
+ };
381
+ if (data) json.Data = data;
382
+ _context9.next = 6;
383
+ return fetch("".concat(this.url, "/~relay@1.0/call?relay-method=POST&relay-path=/dry-run?process-id=").concat(process, "/&content-type=application/json&body=").concat(JSON.stringify(json))).then(function (r) {
315
384
  return r.json();
316
385
  });
317
- case 4:
318
- return _context7.abrupt("return", _context7.sent);
319
- case 5:
386
+ case 6:
387
+ return _context9.abrupt("return", _context9.sent);
388
+ case 7:
320
389
  case "end":
321
- return _context7.stop();
390
+ return _context9.stop();
322
391
  }
323
- }, _callee7, this);
392
+ }, _callee9, this);
324
393
  }));
325
394
  function dryrun() {
326
395
  return _dryrun.apply(this, arguments);
@@ -330,25 +399,25 @@ var HB = /*#__PURE__*/function () {
330
399
  }, {
331
400
  key: "get",
332
401
  value: function () {
333
- var _get = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee8(_ref6) {
334
- var device, _ref6$path, path;
335
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
336
- while (1) switch (_context8.prev = _context8.next) {
402
+ var _get = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee10(_ref8) {
403
+ var device, _ref8$path, path;
404
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
405
+ while (1) switch (_context10.prev = _context10.next) {
337
406
  case 0:
338
- device = _ref6.device, _ref6$path = _ref6.path, path = _ref6$path === void 0 ? "~meta@1.0/info" : _ref6$path;
339
- _context8.next = 3;
407
+ device = _ref8.device, _ref8$path = _ref8.path, path = _ref8$path === void 0 ? "~meta@1.0/info" : _ref8$path;
408
+ _context10.next = 3;
340
409
  return this.request({
341
410
  device: device,
342
411
  path: path,
343
412
  method: "GET"
344
413
  });
345
414
  case 3:
346
- return _context8.abrupt("return", _context8.sent.body);
415
+ return _context10.abrupt("return", _context10.sent.body);
347
416
  case 4:
348
417
  case "end":
349
- return _context8.stop();
418
+ return _context10.stop();
350
419
  }
351
- }, _callee8, this);
420
+ }, _callee10, this);
352
421
  }));
353
422
  function get(_x2) {
354
423
  return _get.apply(this, arguments);
@@ -358,13 +427,13 @@ var HB = /*#__PURE__*/function () {
358
427
  }, {
359
428
  key: "post",
360
429
  value: function () {
361
- var _post = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee9(_ref7) {
362
- var device, tags, _ref7$path, path;
363
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
364
- while (1) switch (_context9.prev = _context9.next) {
430
+ var _post = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee11(_ref9) {
431
+ var device, tags, _ref9$path, path;
432
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
433
+ while (1) switch (_context11.prev = _context11.next) {
365
434
  case 0:
366
- device = _ref7.device, tags = _ref7.tags, _ref7$path = _ref7.path, path = _ref7$path === void 0 ? "/schedule" : _ref7$path;
367
- _context9.next = 3;
435
+ device = _ref9.device, tags = _ref9.tags, _ref9$path = _ref9.path, path = _ref9$path === void 0 ? "/schedule" : _ref9$path;
436
+ _context11.next = 3;
368
437
  return this.request({
369
438
  tags: tags,
370
439
  device: device,
@@ -372,12 +441,12 @@ var HB = /*#__PURE__*/function () {
372
441
  method: "POST"
373
442
  });
374
443
  case 3:
375
- return _context9.abrupt("return", _context9.sent);
444
+ return _context11.abrupt("return", _context11.sent);
376
445
  case 4:
377
446
  case "end":
378
- return _context9.stop();
447
+ return _context11.stop();
379
448
  }
380
- }, _callee9, this);
449
+ }, _callee11, this);
381
450
  }));
382
451
  function post(_x3) {
383
452
  return _post.apply(this, arguments);
@@ -387,26 +456,26 @@ var HB = /*#__PURE__*/function () {
387
456
  }, {
388
457
  key: "request",
389
458
  value: function () {
390
- var _request = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee10(_ref8) {
391
- var device, tags, _ref8$method, method, _ref8$path, path, _tags;
392
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
393
- while (1) switch (_context10.prev = _context10.next) {
459
+ var _request = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee12(_ref10) {
460
+ var device, tags, _ref10$method, method, _ref10$path, path, _tags;
461
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
462
+ while (1) switch (_context12.prev = _context12.next) {
394
463
  case 0:
395
- device = _ref8.device, tags = _ref8.tags, _ref8$method = _ref8.method, method = _ref8$method === void 0 ? "POST" : _ref8$method, _ref8$path = _ref8.path, path = _ref8$path === void 0 ? "/schedule" : _ref8$path;
464
+ device = _ref10.device, tags = _ref10.tags, _ref10$method = _ref10.method, method = _ref10$method === void 0 ? "POST" : _ref10$method, _ref10$path = _ref10.path, path = _ref10$path === void 0 ? "/schedule" : _ref10$path;
396
465
  _tags = (0, _ramda.mergeLeft)(tags, {
397
466
  path: path,
398
467
  method: method
399
468
  });
400
469
  if (device) _tags.device = device;
401
- _context10.next = 5;
470
+ _context12.next = 5;
402
471
  return this._request(_tags);
403
472
  case 5:
404
- return _context10.abrupt("return", _context10.sent);
473
+ return _context12.abrupt("return", _context12.sent);
405
474
  case 6:
406
475
  case "end":
407
- return _context10.stop();
476
+ return _context12.stop();
408
477
  }
409
- }, _callee10, this);
478
+ }, _callee12, this);
410
479
  }));
411
480
  function request(_x4) {
412
481
  return _request.apply(this, arguments);
package/cjs/run.js CHANGED
@@ -18,7 +18,8 @@ var _yargs$argv = (0, _yargs["default"])(process.argv.slice(2)).argv,
18
18
  _yargs$argv$port = _yargs$argv.port,
19
19
  port = _yargs$argv$port === void 0 ? 4000 : _yargs$argv$port,
20
20
  _yargs$argv$db = _yargs$argv.db,
21
- db = _yargs$argv$db === void 0 ? ".cache" : _yargs$argv$db;
21
+ db = _yargs$argv$db === void 0 ? ".cache" : _yargs$argv$db,
22
+ hb = _yargs$argv.hb;
22
23
  db = memory ? null : (0, _path.resolve)(process.cwd(), db);
23
24
  if (reset) {
24
25
  try {
@@ -33,7 +34,8 @@ var main = /*#__PURE__*/function () {
33
34
  return _context.abrupt("return", new _server["default"]({
34
35
  log: true,
35
36
  port: port,
36
- db: db
37
+ db: db,
38
+ hb_url: hb
37
39
  }));
38
40
  case 1:
39
41
  case "end":