wao 0.7.2 → 0.8.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/run.js CHANGED
@@ -3,13 +3,28 @@
3
3
 
4
4
  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); }
5
5
  var _yargs = _interopRequireDefault(require("yargs"));
6
+ var _path = require("path");
7
+ var _fs = require("fs");
6
8
  var _server = _interopRequireDefault(require("./server.js"));
7
9
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
8
10
  function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
9
11
  function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
10
12
  function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
11
- var _yargs$argv$port = (0, _yargs["default"])(process.argv.slice(2)).argv.port,
12
- port = _yargs$argv$port === void 0 ? 4000 : _yargs$argv$port;
13
+ var _yargs$argv = (0, _yargs["default"])(process.argv.slice(2)).argv,
14
+ _yargs$argv$reset = _yargs$argv.reset,
15
+ reset = _yargs$argv$reset === void 0 ? false : _yargs$argv$reset,
16
+ _yargs$argv$memory = _yargs$argv.memory,
17
+ memory = _yargs$argv$memory === void 0 ? false : _yargs$argv$memory,
18
+ _yargs$argv$port = _yargs$argv.port,
19
+ port = _yargs$argv$port === void 0 ? 4000 : _yargs$argv$port,
20
+ _yargs$argv$db = _yargs$argv.db,
21
+ db = _yargs$argv$db === void 0 ? ".cache" : _yargs$argv$db;
22
+ db = memory ? null : (0, _path.resolve)(process.cwd(), db);
23
+ if (reset) {
24
+ try {
25
+ (0, _fs.unlinkSync)(db);
26
+ } catch (e) {}
27
+ }
13
28
  var main = /*#__PURE__*/function () {
14
29
  var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
15
30
  return _regeneratorRuntime().wrap(function _callee$(_context) {
@@ -17,7 +32,8 @@ var main = /*#__PURE__*/function () {
17
32
  case 0:
18
33
  return _context.abrupt("return", new _server["default"]({
19
34
  log: true,
20
- port: port
35
+ port: port,
36
+ db: db
21
37
  }));
22
38
  case 1:
23
39
  case "end":
package/cjs/server.js CHANGED
@@ -43,6 +43,7 @@ var Server = /*#__PURE__*/function () {
43
43
  aoconnect = _ref.aoconnect,
44
44
  _ref$log = _ref.log,
45
45
  log = _ref$log === void 0 ? false : _ref$log,
46
+ db = _ref.db,
46
47
  port = _ref.port;
47
48
  _classCallCheck(this, Server);
48
49
  if (port) {
@@ -53,7 +54,8 @@ var Server = /*#__PURE__*/function () {
53
54
  aoconnect = (0, _utils.optAO)(5000);
54
55
  }
55
56
  var _connect = (0, _aoconnect.connect)(aoconnect, {
56
- log: log
57
+ log: log,
58
+ cache: db
57
59
  }),
58
60
  _ar = _connect.ar,
59
61
  message = _connect.message,
@@ -632,7 +634,7 @@ var Server = /*#__PURE__*/function () {
632
634
  v.close(function () {
633
635
  count += 1;
634
636
  if (count >= 4) {
635
- console.log("servers closed!", count);
637
+ console.log("servers closed!");
636
638
  res();
637
639
  }
638
640
  });
package/cjs/tao.js CHANGED
@@ -73,7 +73,9 @@ var AO = /*#__PURE__*/function (_MAO) {
73
73
  })]);
74
74
  _this.in_memory = true;
75
75
  var _connect = (0, _aoconnect2.connect)(opt.mem, {
76
- extensions: opt.extensions
76
+ extensions: opt.extensions,
77
+ cache: opt.cache,
78
+ reset: opt.reset
77
79
  }),
78
80
  modules = _connect.modules,
79
81
  results = _connect.results,
package/cjs/tar.js CHANGED
@@ -234,7 +234,7 @@ var AR = /*#__PURE__*/function (_MAR) {
234
234
  _iterator2.s();
235
235
  case 13:
236
236
  if ((_step2 = _iterator2.n()).done) {
237
- _context4.next = 47;
237
+ _context4.next = 50;
238
238
  break;
239
239
  }
240
240
  di = _step2.value;
@@ -259,14 +259,13 @@ var AR = /*#__PURE__*/function (_MAR) {
259
259
  return this.owner(di);
260
260
  case 24:
261
261
  owner = _context4.sent;
262
- this.mem.addrmap[owner] = {
262
+ _context4.next = 27;
263
+ return this.mem.set({
263
264
  key: di.owner,
264
265
  address: owner
265
- };
266
+ }, "addrmap", owner);
267
+ case 27:
266
268
  data = di.data;
267
- try {
268
- //data = base64url.decode(di.data)
269
- } catch (e) {}
270
269
  _context4.t0 = {
271
270
  size: data_size,
272
271
  type: data_type
@@ -293,48 +292,52 @@ var AR = /*#__PURE__*/function (_MAR) {
293
292
  tags: _context4.t7,
294
293
  data: _context4.t8
295
294
  };
296
- _context4.next = 42;
295
+ _context4.t9 = this.mem;
296
+ _context4.t10 = _item;
297
+ _context4.next = 44;
297
298
  return di.id;
298
- case 42:
299
- _context4.t9 = _context4.sent;
300
- this.mem.txs[_context4.t9] = _item;
299
+ case 44:
300
+ _context4.t11 = _context4.sent;
301
+ _context4.next = 47;
302
+ return _context4.t9.set.call(_context4.t9, _context4.t10, "txs", _context4.t11);
303
+ case 47:
301
304
  _items.push(_item);
302
- case 45:
305
+ case 48:
303
306
  _context4.next = 13;
304
307
  break;
305
- case 47:
306
- _context4.next = 52;
308
+ case 50:
309
+ _context4.next = 55;
307
310
  break;
308
- case 49:
309
- _context4.prev = 49;
310
- _context4.t10 = _context4["catch"](11);
311
- _iterator2.e(_context4.t10);
312
311
  case 52:
313
312
  _context4.prev = 52;
314
- _iterator2.f();
315
- return _context4.finish(52);
313
+ _context4.t12 = _context4["catch"](11);
314
+ _iterator2.e(_context4.t12);
316
315
  case 55:
317
- _context4.next = 57;
316
+ _context4.prev = 55;
317
+ _iterator2.f();
318
+ return _context4.finish(55);
319
+ case 58:
320
+ _context4.next = 60;
318
321
  return (0, _arbundles.bundleAndSignData)(items, new _arbundles.ArweaveSigner(jwk));
319
- case 57:
322
+ case 60:
320
323
  bundle = _context4.sent;
321
- _context4.next = 60;
324
+ _context4.next = 63;
322
325
  return this.mem.arweave.createTransaction({
323
326
  data: bundle.binary
324
327
  }, jwk);
325
- case 60:
328
+ case 63:
326
329
  tx = _context4.sent;
327
330
  tx.addTag("Bundle-Format", "binary");
328
331
  tx.addTag("Bundle-Version", "2.0.0");
329
- _context4.next = 65;
332
+ _context4.next = 68;
330
333
  return this.postTx(tx, jwk, _items);
331
- case 65:
334
+ case 68:
332
335
  return _context4.abrupt("return", _context4.sent);
333
- case 66:
336
+ case 69:
334
337
  case "end":
335
338
  return _context4.stop();
336
339
  }
337
- }, _callee4, this, [[11, 49, 52, 55]]);
340
+ }, _callee4, this, [[11, 52, 55, 58]]);
338
341
  }));
339
342
  function postItems(_x4, _x5) {
340
343
  return _postItems.apply(this, arguments);
@@ -350,11 +353,13 @@ var AR = /*#__PURE__*/function (_MAR) {
350
353
  err,
351
354
  _yield$this$checkWall3,
352
355
  res,
356
+ height,
353
357
  block,
354
358
  msg,
355
359
  _iterator4,
356
360
  _step4,
357
361
  item,
362
+ _txs2,
358
363
  _tags2,
359
364
  data_type,
360
365
  _iterator5,
@@ -365,6 +370,8 @@ var AR = /*#__PURE__*/function (_MAR) {
365
370
  _step6,
366
371
  _v,
367
372
  __tags,
373
+ _txs,
374
+ blocks,
368
375
  owner,
369
376
  _args5 = arguments;
370
377
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
@@ -396,58 +403,110 @@ var AR = /*#__PURE__*/function (_MAR) {
396
403
  _context5.next = 13;
397
404
  return this.mem.arweave.transactions.sign(tx, jwk);
398
405
  case 13:
399
- this.mem.height += 1;
406
+ _context5.next = 15;
407
+ return this.mem.get("height");
408
+ case 15:
409
+ _context5.t0 = _context5.sent;
410
+ height = _context5.t0 + 1;
411
+ _context5.next = 19;
412
+ return this.mem.set(height, "height");
413
+ case 19:
414
+ _context5.t1 = tx.id;
415
+ _context5.t2 = Date.now();
416
+ _context5.t3 = height;
417
+ _context5.t5 = _ramda.last;
418
+ _context5.next = 25;
419
+ return this.mem.get("blocks");
420
+ case 25:
421
+ _context5.t6 = _context5.sent;
422
+ _context5.t7 = _last = (0, _context5.t5)(_context5.t6);
423
+ _context5.t4 = _context5.t7 !== null;
424
+ if (!_context5.t4) {
425
+ _context5.next = 30;
426
+ break;
427
+ }
428
+ _context5.t4 = _last !== void 0;
429
+ case 30:
430
+ if (!_context5.t4) {
431
+ _context5.next = 34;
432
+ break;
433
+ }
434
+ _context5.t8 = _last;
435
+ _context5.next = 35;
436
+ break;
437
+ case 34:
438
+ _context5.t8 = "";
439
+ case 35:
440
+ _context5.t9 = _context5.t8;
441
+ _context5.t10 = [];
400
442
  block = {
401
- id: tx.id,
402
- timestamp: Date.now(),
403
- height: this.mem.height,
404
- previous: (_last = (0, _ramda.last)(this.mem.blocks)) !== null && _last !== void 0 ? _last : "",
405
- txs: []
443
+ id: _context5.t1,
444
+ timestamp: _context5.t2,
445
+ height: _context5.t3,
446
+ previous: _context5.t9,
447
+ txs: _context5.t10
406
448
  };
407
449
  msg = null;
408
- if (items) {
409
- _iterator4 = _createForOfIteratorHelper(items);
410
- try {
411
- for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
412
- item = _step4.value;
413
- this.mem.txs[item.id] = item;
414
- this.mem.txs[item.id].parent = {
415
- id: tx.id
416
- };
417
- this.mem.txs[item.id].bundledIn = {
418
- id: tx.id
419
- };
420
- this.mem.txs[item.id].anchor = "";
421
- _tags2 = (0, _utils.tags)(item.tags);
422
- if ((0, _ramda.includes)(_tags2.Type, ["Message", "Process", "Module", "Scheduler-Location", "Attestation", "Available"])) {
423
- msg = {
424
- id: item.id,
425
- type: _tags2.Type
426
- };
427
- if (msg.type === "Process") msg.pid = item.recipient;
428
- }
429
- data_type = "";
430
- _iterator5 = _createForOfIteratorHelper(item.item.tags);
431
- try {
432
- for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
433
- v = _step5.value;
434
- if (v.name === "Content-Type") data_type = v.value;
435
- }
436
- //this.mem.txs[tx.id]._data = { size: tx.data_size, type: data_type }
437
- } catch (err) {
438
- _iterator5.e(err);
439
- } finally {
440
- _iterator5.f();
441
- }
442
- block.txs.push(item.id);
443
- this.mem.txs[item.id].block = block.id;
444
- }
445
- } catch (err) {
446
- _iterator4.e(err);
447
- } finally {
448
- _iterator4.f();
450
+ if (!items) {
451
+ _context5.next = 68;
452
+ break;
453
+ }
454
+ _iterator4 = _createForOfIteratorHelper(items);
455
+ _context5.prev = 41;
456
+ _iterator4.s();
457
+ case 43:
458
+ if ((_step4 = _iterator4.n()).done) {
459
+ _context5.next = 60;
460
+ break;
461
+ }
462
+ item = _step4.value;
463
+ _txs2 = item;
464
+ _txs2.parent = {
465
+ id: tx.id
466
+ };
467
+ _txs2.bundledIn = {
468
+ id: tx.id
469
+ };
470
+ _txs2.anchor = "";
471
+ _tags2 = (0, _utils.tags)(item.tags);
472
+ if ((0, _ramda.includes)(_tags2.Type, ["Message", "Process", "Module", "Scheduler-Location", "Attestation", "Available"])) {
473
+ msg = {
474
+ id: item.id,
475
+ type: _tags2.Type
476
+ };
477
+ if (msg.type === "Process") msg.pid = item.recipient;
478
+ }
479
+ data_type = "";
480
+ _iterator5 = _createForOfIteratorHelper(item.item.tags);
481
+ try {
482
+ for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
483
+ v = _step5.value;
484
+ if (v.name === "Content-Type") data_type = v.value;
449
485
  }
486
+ } catch (err) {
487
+ _iterator5.e(err);
488
+ } finally {
489
+ _iterator5.f();
450
490
  }
491
+ block.txs.push(item.id);
492
+ _txs2.block = block.id;
493
+ _context5.next = 58;
494
+ return this.mem.set(_txs2, "txs", item.id);
495
+ case 58:
496
+ _context5.next = 43;
497
+ break;
498
+ case 60:
499
+ _context5.next = 65;
500
+ break;
501
+ case 62:
502
+ _context5.prev = 62;
503
+ _context5.t11 = _context5["catch"](41);
504
+ _iterator4.e(_context5.t11);
505
+ case 65:
506
+ _context5.prev = 65;
507
+ _iterator4.f();
508
+ return _context5.finish(65);
509
+ case 68:
451
510
  _tags = [];
452
511
  _iterator6 = _createForOfIteratorHelper(tx.tags);
453
512
  try {
@@ -464,37 +523,54 @@ var AR = /*#__PURE__*/function (_MAR) {
464
523
  _iterator6.f();
465
524
  }
466
525
  __tags = (0, _utils.tags)(_tags);
467
- if (__tags.Type === "Module") {
468
- this.mem.wasms[tx.id] = {
469
- data: Buffer.from(tx.data, "base64"),
470
- format: __tags["Module-Format"]
471
- };
526
+ if (!(__tags.Type === "Module")) {
527
+ _context5.next = 75;
528
+ break;
472
529
  }
530
+ _context5.next = 75;
531
+ return this.mem.set({
532
+ data: Buffer.from(tx.data, "base64"),
533
+ format: __tags["Module-Format"]
534
+ }, "wasms", tx.id);
535
+ case 75:
473
536
  tx.tags = _tags;
474
- _context5.next = 25;
537
+ _context5.next = 78;
475
538
  return this.arweave.wallets.jwkToAddress({
476
539
  n: tx.owner
477
540
  });
478
- case 25:
541
+ case 78:
479
542
  tx.owner = _context5.sent;
480
- this.mem.txs[tx.id] = tx;
543
+ _txs = tx;
481
544
  block.txs.push(tx.id);
482
- this.mem.txs[tx.id].block = block.id;
483
- this.mem.blocks.push(block.id);
484
- this.mem.blockmap[block.id] = block;
545
+ _txs.block = block.id;
546
+ _context5.next = 84;
547
+ return this.mem.set(_txs, "txs", tx.id);
548
+ case 84:
549
+ _context5.next = 86;
550
+ return this.mem.get("blocks");
551
+ case 86:
552
+ blocks = _context5.sent;
553
+ blocks.push(block.id);
554
+ _context5.next = 90;
555
+ return this.mem.set(blocks, "blocks");
556
+ case 90:
557
+ _context5.next = 92;
558
+ return this.mem.set(block, "blockmap", block.id);
559
+ case 92:
485
560
  if (!jwk) {
486
- _context5.next = 36;
561
+ _context5.next = 98;
487
562
  break;
488
563
  }
489
- _context5.next = 34;
564
+ _context5.next = 95;
490
565
  return this.arweave.wallets.jwkToAddress(jwk);
491
- case 34:
566
+ case 95:
492
567
  owner = _context5.sent;
493
- this.mem.addrmap[owner] = {
568
+ _context5.next = 98;
569
+ return this.mem.set({
494
570
  address: owner,
495
571
  key: jwk.n
496
- };
497
- case 36:
572
+ }, "addrmap", owner);
573
+ case 98:
498
574
  res = {
499
575
  id: tx.id,
500
576
  status: 200,
@@ -512,11 +588,11 @@ var AR = /*#__PURE__*/function (_MAR) {
512
588
  err: err,
513
589
  id: tx.id
514
590
  });
515
- case 39:
591
+ case 101:
516
592
  case "end":
517
593
  return _context5.stop();
518
594
  }
519
- }, _callee5, this);
595
+ }, _callee5, this, [[41, 62, 65, 68]]);
520
596
  }));
521
597
  function postTx(_x6, _x7) {
522
598
  return _postTx.apply(this, arguments);
@@ -530,8 +606,11 @@ var AR = /*#__PURE__*/function (_MAR) {
530
606
  return _regeneratorRuntime().wrap(function _callee6$(_context6) {
531
607
  while (1) switch (_context6.prev = _context6.next) {
532
608
  case 0:
533
- return _context6.abrupt("return", this.mem.txs[id]);
534
- case 1:
609
+ _context6.next = 2;
610
+ return this.mem.get("txs", id);
611
+ case 2:
612
+ return _context6.abrupt("return", _context6.sent);
613
+ case 3:
535
614
  case "end":
536
615
  return _context6.stop();
537
616
  }
@@ -557,7 +636,10 @@ var AR = /*#__PURE__*/function (_MAR) {
557
636
  if (!(0, _ramda.isNil)(_string.decode)) decode = _string.decode;
558
637
  if (!(0, _ramda.isNil)(_string.string)) string = _string.string;
559
638
  }
560
- tx = this.mem.txs[id];
639
+ _context7.next = 5;
640
+ return this.mem.get("txs", id);
641
+ case 5:
642
+ tx = _context7.sent;
561
643
  _data = (_tx$data = tx === null || tx === void 0 ? void 0 : tx.data) !== null && _tx$data !== void 0 ? _tx$data : null;
562
644
  if ((tx === null || tx === void 0 ? void 0 : tx.format) === 2 && _data) {
563
645
  _data = Buffer.from(_data, "base64");
@@ -567,26 +649,26 @@ var AR = /*#__PURE__*/function (_MAR) {
567
649
  isBuf = (0, _ramda.is)(Uint8Array, _data) || (0, _ramda.is)(ArrayBuffer, _data);
568
650
  isStr = (0, _ramda.is)(String, _data);
569
651
  if (!(decode === false)) {
570
- _context7.next = 13;
652
+ _context7.next = 15;
571
653
  break;
572
654
  }
573
655
  if (isStr) _data = new TextEncoder().encode(_data);
574
656
  return _context7.abrupt("return", _base64url["default"].encode(_data));
575
- case 13:
657
+ case 15:
576
658
  if (!(isBuf && string)) {
577
- _context7.next = 17;
659
+ _context7.next = 19;
578
660
  break;
579
661
  }
580
662
  return _context7.abrupt("return", _data.toString());
581
- case 17:
663
+ case 19:
582
664
  if (!(isStr && string !== true)) {
583
- _context7.next = 19;
665
+ _context7.next = 21;
584
666
  break;
585
667
  }
586
668
  return _context7.abrupt("return", new TextEncoder().encode(_data));
587
- case 19:
669
+ case 21:
588
670
  return _context7.abrupt("return", _data);
589
- case 20:
671
+ case 22:
590
672
  case "end":
591
673
  return _context7.stop();
592
674
  }
Binary file
Binary file