wao 0.9.1 → 0.9.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/aoconnect-base.js +1332 -0
- package/cjs/aoconnect-web.js +15 -1317
- package/cjs/aoconnect.js +15 -1317
- package/cjs/ar-base.js +683 -0
- package/cjs/armem-base.js +438 -0
- package/cjs/armem-web.js +29 -560
- package/cjs/armem.js +30 -402
- package/cjs/bao.js +248 -0
- package/cjs/lfdb.js +165 -0
- package/cjs/tao.js +10 -222
- package/cjs/tar.js +8 -655
- package/cjs/wao.js +10 -222
- package/cjs/war.js +8 -655
- package/esm/aoconnect-base.js +482 -0
- package/esm/aoconnect-web.js +6 -482
- package/esm/aoconnect.js +6 -483
- package/esm/ar-base.js +215 -0
- package/esm/armem-base.js +172 -0
- package/esm/armem-web.js +8 -232
- package/esm/armem.js +7 -163
- package/esm/bao.js +125 -0
- package/esm/lfdb.js +68 -0
- package/esm/tao.js +4 -121
- package/esm/tar.js +3 -209
- package/esm/wao.js +4 -121
- package/esm/war.js +3 -209
- package/esm/web.js +0 -1
- package/package.json +1 -1
package/cjs/ar-base.js
ADDED
|
@@ -0,0 +1,683 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
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); }
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports["default"] = void 0;
|
|
8
|
+
var _ar = _interopRequireDefault(require("./ar.js"));
|
|
9
|
+
var _utils = require("./utils.js");
|
|
10
|
+
var WarpArBundles = _interopRequireWildcard(require("warp-arbundles"));
|
|
11
|
+
var _arbundles = require("arbundles");
|
|
12
|
+
var _base64url = _interopRequireDefault(require("base64url"));
|
|
13
|
+
var _tgql = _interopRequireDefault(require("./tgql.js"));
|
|
14
|
+
var _ramda = require("ramda");
|
|
15
|
+
var _WarpArBundles$defaul;
|
|
16
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
17
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
|
18
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
19
|
+
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
|
|
20
|
+
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; } }
|
|
21
|
+
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; }
|
|
22
|
+
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; }
|
|
23
|
+
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); }
|
|
24
|
+
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); }); }; }
|
|
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; }
|
|
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; }
|
|
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; }
|
|
28
|
+
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
29
|
+
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
30
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
31
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
32
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
33
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
34
|
+
function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
|
|
35
|
+
function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
|
|
36
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
37
|
+
function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
|
|
38
|
+
function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
|
|
39
|
+
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
|
|
40
|
+
var pkg = (_WarpArBundles$defaul = WarpArBundles["default"]) !== null && _WarpArBundles$defaul !== void 0 ? _WarpArBundles$defaul : WarpArBundles;
|
|
41
|
+
var DataItem = pkg.DataItem;
|
|
42
|
+
var AR = /*#__PURE__*/function (_MAR) {
|
|
43
|
+
function AR() {
|
|
44
|
+
var _opt$mem;
|
|
45
|
+
var _this;
|
|
46
|
+
var opt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
47
|
+
_classCallCheck(this, AR);
|
|
48
|
+
_this = _callSuper(this, AR, [_objectSpread(_objectSpread({}, opt), {}, {
|
|
49
|
+
in_memory: true
|
|
50
|
+
})]);
|
|
51
|
+
_this.log = opt.log === true;
|
|
52
|
+
_this.in_memory = true;
|
|
53
|
+
_this.mem = (_opt$mem = opt.mem) !== null && _opt$mem !== void 0 ? _opt$mem : new opt.ArMem();
|
|
54
|
+
_this.gql = new _tgql["default"]({
|
|
55
|
+
mem: _this.mem
|
|
56
|
+
});
|
|
57
|
+
_this.arweave = _this.mem.arweave;
|
|
58
|
+
return _this;
|
|
59
|
+
}
|
|
60
|
+
_inherits(AR, _MAR);
|
|
61
|
+
return _createClass(AR, [{
|
|
62
|
+
key: "owner",
|
|
63
|
+
value: function () {
|
|
64
|
+
var _owner = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(di) {
|
|
65
|
+
var raw_owner, hashBuffer;
|
|
66
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
67
|
+
while (1) switch (_context.prev = _context.next) {
|
|
68
|
+
case 0:
|
|
69
|
+
raw_owner = di.rawOwner;
|
|
70
|
+
_context.t0 = Buffer;
|
|
71
|
+
_context.next = 4;
|
|
72
|
+
return crypto.subtle.digest("SHA-256", raw_owner);
|
|
73
|
+
case 4:
|
|
74
|
+
_context.t1 = _context.sent;
|
|
75
|
+
hashBuffer = _context.t0.from.call(_context.t0, _context.t1);
|
|
76
|
+
return _context.abrupt("return", _base64url["default"].encode(hashBuffer));
|
|
77
|
+
case 7:
|
|
78
|
+
case "end":
|
|
79
|
+
return _context.stop();
|
|
80
|
+
}
|
|
81
|
+
}, _callee);
|
|
82
|
+
}));
|
|
83
|
+
function owner(_x) {
|
|
84
|
+
return _owner.apply(this, arguments);
|
|
85
|
+
}
|
|
86
|
+
return owner;
|
|
87
|
+
}()
|
|
88
|
+
}, {
|
|
89
|
+
key: "dataitem",
|
|
90
|
+
value: function () {
|
|
91
|
+
var _dataitem = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref) {
|
|
92
|
+
var _ref$target, target, _ref$data, data, _ref$tags, tags, signer, item, di, _tags, _item, owner;
|
|
93
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
94
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
95
|
+
case 0:
|
|
96
|
+
_ref$target = _ref.target, target = _ref$target === void 0 ? "" : _ref$target, _ref$data = _ref.data, data = _ref$data === void 0 ? "1984" : _ref$data, _ref$tags = _ref.tags, tags = _ref$tags === void 0 ? {} : _ref$tags, signer = _ref.signer, item = _ref.item;
|
|
97
|
+
di = item;
|
|
98
|
+
if (di) {
|
|
99
|
+
_context2.next = 10;
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
102
|
+
_tags = (0, _utils.buildTags)(tags);
|
|
103
|
+
_context2.next = 6;
|
|
104
|
+
return signer({
|
|
105
|
+
data: data,
|
|
106
|
+
tags: _tags,
|
|
107
|
+
target: target
|
|
108
|
+
});
|
|
109
|
+
case 6:
|
|
110
|
+
_item = _context2.sent;
|
|
111
|
+
di = new DataItem(_item.raw);
|
|
112
|
+
_context2.next = 11;
|
|
113
|
+
break;
|
|
114
|
+
case 10:
|
|
115
|
+
tags = (0, _utils.tags)(di.tags);
|
|
116
|
+
case 11:
|
|
117
|
+
_context2.next = 13;
|
|
118
|
+
return this.owner(di);
|
|
119
|
+
case 13:
|
|
120
|
+
owner = _context2.sent;
|
|
121
|
+
_context2.next = 16;
|
|
122
|
+
return di.id;
|
|
123
|
+
case 16:
|
|
124
|
+
_context2.t0 = _context2.sent;
|
|
125
|
+
_context2.t1 = owner;
|
|
126
|
+
_context2.t2 = di;
|
|
127
|
+
_context2.t3 = tags;
|
|
128
|
+
return _context2.abrupt("return", {
|
|
129
|
+
id: _context2.t0,
|
|
130
|
+
owner: _context2.t1,
|
|
131
|
+
item: _context2.t2,
|
|
132
|
+
tags: _context2.t3
|
|
133
|
+
});
|
|
134
|
+
case 21:
|
|
135
|
+
case "end":
|
|
136
|
+
return _context2.stop();
|
|
137
|
+
}
|
|
138
|
+
}, _callee2, this);
|
|
139
|
+
}));
|
|
140
|
+
function dataitem(_x2) {
|
|
141
|
+
return _dataitem.apply(this, arguments);
|
|
142
|
+
}
|
|
143
|
+
return dataitem;
|
|
144
|
+
}()
|
|
145
|
+
}, {
|
|
146
|
+
key: "post",
|
|
147
|
+
value: function () {
|
|
148
|
+
var _post = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref2) {
|
|
149
|
+
var _ref2$data, data, _ref2$tags, tags, jwk, err, _yield$this$checkWall, tx, _tags, _iterator, _step, v;
|
|
150
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
151
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
152
|
+
case 0:
|
|
153
|
+
_ref2$data = _ref2.data, data = _ref2$data === void 0 ? "1984" : _ref2$data, _ref2$tags = _ref2.tags, tags = _ref2$tags === void 0 ? {} : _ref2$tags, jwk = _ref2.jwk;
|
|
154
|
+
err = null;
|
|
155
|
+
_context3.next = 4;
|
|
156
|
+
return this.checkWallet({
|
|
157
|
+
jwk: jwk
|
|
158
|
+
});
|
|
159
|
+
case 4:
|
|
160
|
+
_yield$this$checkWall = _context3.sent;
|
|
161
|
+
err = _yield$this$checkWall.err;
|
|
162
|
+
jwk = _yield$this$checkWall.jwk;
|
|
163
|
+
if (!err) {
|
|
164
|
+
_context3.next = 9;
|
|
165
|
+
break;
|
|
166
|
+
}
|
|
167
|
+
return _context3.abrupt("return", {
|
|
168
|
+
err: err
|
|
169
|
+
});
|
|
170
|
+
case 9:
|
|
171
|
+
_context3.next = 11;
|
|
172
|
+
return this.arweave.createTransaction({
|
|
173
|
+
data: data
|
|
174
|
+
});
|
|
175
|
+
case 11:
|
|
176
|
+
tx = _context3.sent;
|
|
177
|
+
_tags = (0, _utils.buildTags)(null, tags);
|
|
178
|
+
_iterator = _createForOfIteratorHelper(_tags);
|
|
179
|
+
try {
|
|
180
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
181
|
+
v = _step.value;
|
|
182
|
+
tx.addTag(v.name, v.value);
|
|
183
|
+
}
|
|
184
|
+
} catch (err) {
|
|
185
|
+
_iterator.e(err);
|
|
186
|
+
} finally {
|
|
187
|
+
_iterator.f();
|
|
188
|
+
}
|
|
189
|
+
_context3.next = 17;
|
|
190
|
+
return this.postTx(tx, jwk);
|
|
191
|
+
case 17:
|
|
192
|
+
return _context3.abrupt("return", _context3.sent);
|
|
193
|
+
case 18:
|
|
194
|
+
case "end":
|
|
195
|
+
return _context3.stop();
|
|
196
|
+
}
|
|
197
|
+
}, _callee3, this);
|
|
198
|
+
}));
|
|
199
|
+
function post(_x3) {
|
|
200
|
+
return _post.apply(this, arguments);
|
|
201
|
+
}
|
|
202
|
+
return post;
|
|
203
|
+
}()
|
|
204
|
+
}, {
|
|
205
|
+
key: "postItems",
|
|
206
|
+
value: function () {
|
|
207
|
+
var _postItems = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4(items, jwk) {
|
|
208
|
+
var err, _yield$this$checkWall2, _items, _iterator2, _step2, di, data_size, data_type, _iterator3, _step3, _t, owner, data, _item, bundle, tx;
|
|
209
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
210
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
211
|
+
case 0:
|
|
212
|
+
err = null;
|
|
213
|
+
_context4.next = 3;
|
|
214
|
+
return this.checkWallet({
|
|
215
|
+
jwk: jwk
|
|
216
|
+
});
|
|
217
|
+
case 3:
|
|
218
|
+
_yield$this$checkWall2 = _context4.sent;
|
|
219
|
+
err = _yield$this$checkWall2.err;
|
|
220
|
+
jwk = _yield$this$checkWall2.jwk;
|
|
221
|
+
if (!err) {
|
|
222
|
+
_context4.next = 8;
|
|
223
|
+
break;
|
|
224
|
+
}
|
|
225
|
+
return _context4.abrupt("return", {
|
|
226
|
+
err: err
|
|
227
|
+
});
|
|
228
|
+
case 8:
|
|
229
|
+
if (!(0, _ramda.is)(Array, items)) items = [items];
|
|
230
|
+
_items = [];
|
|
231
|
+
_iterator2 = _createForOfIteratorHelper(items);
|
|
232
|
+
_context4.prev = 11;
|
|
233
|
+
_iterator2.s();
|
|
234
|
+
case 13:
|
|
235
|
+
if ((_step2 = _iterator2.n()).done) {
|
|
236
|
+
_context4.next = 50;
|
|
237
|
+
break;
|
|
238
|
+
}
|
|
239
|
+
di = _step2.value;
|
|
240
|
+
_context4.next = 17;
|
|
241
|
+
return di.id;
|
|
242
|
+
case 17:
|
|
243
|
+
di._id = _context4.sent;
|
|
244
|
+
data_size = Buffer.byteLength(di.rawData).toString();
|
|
245
|
+
data_type = "";
|
|
246
|
+
_iterator3 = _createForOfIteratorHelper(di.tags);
|
|
247
|
+
try {
|
|
248
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
249
|
+
_t = _step3.value;
|
|
250
|
+
if (_t.name === "Content-Type") data_type = _t.value;
|
|
251
|
+
}
|
|
252
|
+
} catch (err) {
|
|
253
|
+
_iterator3.e(err);
|
|
254
|
+
} finally {
|
|
255
|
+
_iterator3.f();
|
|
256
|
+
}
|
|
257
|
+
_context4.next = 24;
|
|
258
|
+
return this.owner(di);
|
|
259
|
+
case 24:
|
|
260
|
+
owner = _context4.sent;
|
|
261
|
+
_context4.next = 27;
|
|
262
|
+
return this.mem.set({
|
|
263
|
+
key: di.owner,
|
|
264
|
+
address: owner
|
|
265
|
+
}, "addrmap", owner);
|
|
266
|
+
case 27:
|
|
267
|
+
data = di.data;
|
|
268
|
+
_context4.t0 = {
|
|
269
|
+
size: data_size,
|
|
270
|
+
type: data_type
|
|
271
|
+
};
|
|
272
|
+
_context4.t1 = di.anchor;
|
|
273
|
+
_context4.t2 = di.signature;
|
|
274
|
+
_context4.t3 = di.target;
|
|
275
|
+
_context4.next = 34;
|
|
276
|
+
return di.id;
|
|
277
|
+
case 34:
|
|
278
|
+
_context4.t4 = _context4.sent;
|
|
279
|
+
_context4.t5 = di;
|
|
280
|
+
_context4.t6 = owner;
|
|
281
|
+
_context4.t7 = di.tags;
|
|
282
|
+
_context4.t8 = data;
|
|
283
|
+
_item = {
|
|
284
|
+
_data: _context4.t0,
|
|
285
|
+
anchor: _context4.t1,
|
|
286
|
+
signature: _context4.t2,
|
|
287
|
+
recipient: _context4.t3,
|
|
288
|
+
id: _context4.t4,
|
|
289
|
+
item: _context4.t5,
|
|
290
|
+
owner: _context4.t6,
|
|
291
|
+
tags: _context4.t7,
|
|
292
|
+
data: _context4.t8
|
|
293
|
+
};
|
|
294
|
+
_context4.t9 = this.mem;
|
|
295
|
+
_context4.t10 = _item;
|
|
296
|
+
_context4.next = 44;
|
|
297
|
+
return di.id;
|
|
298
|
+
case 44:
|
|
299
|
+
_context4.t11 = _context4.sent;
|
|
300
|
+
_context4.next = 47;
|
|
301
|
+
return _context4.t9.set.call(_context4.t9, _context4.t10, "txs", _context4.t11);
|
|
302
|
+
case 47:
|
|
303
|
+
_items.push(_item);
|
|
304
|
+
case 48:
|
|
305
|
+
_context4.next = 13;
|
|
306
|
+
break;
|
|
307
|
+
case 50:
|
|
308
|
+
_context4.next = 55;
|
|
309
|
+
break;
|
|
310
|
+
case 52:
|
|
311
|
+
_context4.prev = 52;
|
|
312
|
+
_context4.t12 = _context4["catch"](11);
|
|
313
|
+
_iterator2.e(_context4.t12);
|
|
314
|
+
case 55:
|
|
315
|
+
_context4.prev = 55;
|
|
316
|
+
_iterator2.f();
|
|
317
|
+
return _context4.finish(55);
|
|
318
|
+
case 58:
|
|
319
|
+
_context4.next = 60;
|
|
320
|
+
return (0, _arbundles.bundleAndSignData)(items, new _arbundles.ArweaveSigner(jwk));
|
|
321
|
+
case 60:
|
|
322
|
+
bundle = _context4.sent;
|
|
323
|
+
_context4.next = 63;
|
|
324
|
+
return this.mem.arweave.createTransaction({
|
|
325
|
+
data: bundle.binary
|
|
326
|
+
}, jwk);
|
|
327
|
+
case 63:
|
|
328
|
+
tx = _context4.sent;
|
|
329
|
+
tx.addTag("Bundle-Format", "binary");
|
|
330
|
+
tx.addTag("Bundle-Version", "2.0.0");
|
|
331
|
+
_context4.next = 68;
|
|
332
|
+
return this.postTx(tx, jwk, _items);
|
|
333
|
+
case 68:
|
|
334
|
+
return _context4.abrupt("return", _context4.sent);
|
|
335
|
+
case 69:
|
|
336
|
+
case "end":
|
|
337
|
+
return _context4.stop();
|
|
338
|
+
}
|
|
339
|
+
}, _callee4, this, [[11, 52, 55, 58]]);
|
|
340
|
+
}));
|
|
341
|
+
function postItems(_x4, _x5) {
|
|
342
|
+
return _postItems.apply(this, arguments);
|
|
343
|
+
}
|
|
344
|
+
return postItems;
|
|
345
|
+
}()
|
|
346
|
+
}, {
|
|
347
|
+
key: "postTx",
|
|
348
|
+
value: function () {
|
|
349
|
+
var _postTx = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5(tx, jwk) {
|
|
350
|
+
var _last;
|
|
351
|
+
var items,
|
|
352
|
+
err,
|
|
353
|
+
_yield$this$checkWall3,
|
|
354
|
+
res,
|
|
355
|
+
height,
|
|
356
|
+
block,
|
|
357
|
+
msg,
|
|
358
|
+
_iterator4,
|
|
359
|
+
_step4,
|
|
360
|
+
item,
|
|
361
|
+
_txs2,
|
|
362
|
+
_tags2,
|
|
363
|
+
data_type,
|
|
364
|
+
_iterator5,
|
|
365
|
+
_step5,
|
|
366
|
+
v,
|
|
367
|
+
_tags,
|
|
368
|
+
_iterator6,
|
|
369
|
+
_step6,
|
|
370
|
+
_v,
|
|
371
|
+
__tags,
|
|
372
|
+
_txs,
|
|
373
|
+
blocks,
|
|
374
|
+
owner,
|
|
375
|
+
_args5 = arguments;
|
|
376
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
377
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
378
|
+
case 0:
|
|
379
|
+
items = _args5.length > 2 && _args5[2] !== undefined ? _args5[2] : [];
|
|
380
|
+
err = null;
|
|
381
|
+
_context5.next = 4;
|
|
382
|
+
return this.checkWallet({
|
|
383
|
+
jwk: jwk
|
|
384
|
+
});
|
|
385
|
+
case 4:
|
|
386
|
+
_yield$this$checkWall3 = _context5.sent;
|
|
387
|
+
err = _yield$this$checkWall3.err;
|
|
388
|
+
jwk = _yield$this$checkWall3.jwk;
|
|
389
|
+
if (!err) {
|
|
390
|
+
_context5.next = 9;
|
|
391
|
+
break;
|
|
392
|
+
}
|
|
393
|
+
return _context5.abrupt("return", {
|
|
394
|
+
err: err
|
|
395
|
+
});
|
|
396
|
+
case 9:
|
|
397
|
+
res = null;
|
|
398
|
+
if (tx.id) {
|
|
399
|
+
_context5.next = 13;
|
|
400
|
+
break;
|
|
401
|
+
}
|
|
402
|
+
_context5.next = 13;
|
|
403
|
+
return this.mem.arweave.transactions.sign(tx, jwk);
|
|
404
|
+
case 13:
|
|
405
|
+
_context5.next = 15;
|
|
406
|
+
return this.mem.get("height");
|
|
407
|
+
case 15:
|
|
408
|
+
_context5.t0 = _context5.sent;
|
|
409
|
+
height = _context5.t0 + 1;
|
|
410
|
+
_context5.next = 19;
|
|
411
|
+
return this.mem.set(height, "height");
|
|
412
|
+
case 19:
|
|
413
|
+
_context5.t1 = tx.id;
|
|
414
|
+
_context5.t2 = Date.now();
|
|
415
|
+
_context5.t3 = height;
|
|
416
|
+
_context5.t5 = _ramda.last;
|
|
417
|
+
_context5.next = 25;
|
|
418
|
+
return this.mem.get("blocks");
|
|
419
|
+
case 25:
|
|
420
|
+
_context5.t6 = _context5.sent;
|
|
421
|
+
_context5.t7 = _last = (0, _context5.t5)(_context5.t6);
|
|
422
|
+
_context5.t4 = _context5.t7 !== null;
|
|
423
|
+
if (!_context5.t4) {
|
|
424
|
+
_context5.next = 30;
|
|
425
|
+
break;
|
|
426
|
+
}
|
|
427
|
+
_context5.t4 = _last !== void 0;
|
|
428
|
+
case 30:
|
|
429
|
+
if (!_context5.t4) {
|
|
430
|
+
_context5.next = 34;
|
|
431
|
+
break;
|
|
432
|
+
}
|
|
433
|
+
_context5.t8 = _last;
|
|
434
|
+
_context5.next = 35;
|
|
435
|
+
break;
|
|
436
|
+
case 34:
|
|
437
|
+
_context5.t8 = "";
|
|
438
|
+
case 35:
|
|
439
|
+
_context5.t9 = _context5.t8;
|
|
440
|
+
_context5.t10 = [];
|
|
441
|
+
block = {
|
|
442
|
+
id: _context5.t1,
|
|
443
|
+
timestamp: _context5.t2,
|
|
444
|
+
height: _context5.t3,
|
|
445
|
+
previous: _context5.t9,
|
|
446
|
+
txs: _context5.t10
|
|
447
|
+
};
|
|
448
|
+
msg = null;
|
|
449
|
+
if (!items) {
|
|
450
|
+
_context5.next = 68;
|
|
451
|
+
break;
|
|
452
|
+
}
|
|
453
|
+
_iterator4 = _createForOfIteratorHelper(items);
|
|
454
|
+
_context5.prev = 41;
|
|
455
|
+
_iterator4.s();
|
|
456
|
+
case 43:
|
|
457
|
+
if ((_step4 = _iterator4.n()).done) {
|
|
458
|
+
_context5.next = 60;
|
|
459
|
+
break;
|
|
460
|
+
}
|
|
461
|
+
item = _step4.value;
|
|
462
|
+
_txs2 = item;
|
|
463
|
+
_txs2.parent = {
|
|
464
|
+
id: tx.id
|
|
465
|
+
};
|
|
466
|
+
_txs2.bundledIn = {
|
|
467
|
+
id: tx.id
|
|
468
|
+
};
|
|
469
|
+
_txs2.anchor = "";
|
|
470
|
+
_tags2 = (0, _utils.tags)(item.tags);
|
|
471
|
+
if ((0, _ramda.includes)(_tags2.Type, ["Message", "Process", "Module", "Scheduler-Location", "Attestation", "Available"])) {
|
|
472
|
+
msg = {
|
|
473
|
+
id: item.id,
|
|
474
|
+
type: _tags2.Type
|
|
475
|
+
};
|
|
476
|
+
if (msg.type === "Process") msg.pid = item.recipient;
|
|
477
|
+
}
|
|
478
|
+
data_type = "";
|
|
479
|
+
_iterator5 = _createForOfIteratorHelper(item.item.tags);
|
|
480
|
+
try {
|
|
481
|
+
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
482
|
+
v = _step5.value;
|
|
483
|
+
if (v.name === "Content-Type") data_type = v.value;
|
|
484
|
+
}
|
|
485
|
+
} catch (err) {
|
|
486
|
+
_iterator5.e(err);
|
|
487
|
+
} finally {
|
|
488
|
+
_iterator5.f();
|
|
489
|
+
}
|
|
490
|
+
block.txs.push(item.id);
|
|
491
|
+
_txs2.block = block.id;
|
|
492
|
+
_context5.next = 58;
|
|
493
|
+
return this.mem.set(_txs2, "txs", item.id);
|
|
494
|
+
case 58:
|
|
495
|
+
_context5.next = 43;
|
|
496
|
+
break;
|
|
497
|
+
case 60:
|
|
498
|
+
_context5.next = 65;
|
|
499
|
+
break;
|
|
500
|
+
case 62:
|
|
501
|
+
_context5.prev = 62;
|
|
502
|
+
_context5.t11 = _context5["catch"](41);
|
|
503
|
+
_iterator4.e(_context5.t11);
|
|
504
|
+
case 65:
|
|
505
|
+
_context5.prev = 65;
|
|
506
|
+
_iterator4.f();
|
|
507
|
+
return _context5.finish(65);
|
|
508
|
+
case 68:
|
|
509
|
+
_tags = [];
|
|
510
|
+
_iterator6 = _createForOfIteratorHelper(tx.tags);
|
|
511
|
+
try {
|
|
512
|
+
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
513
|
+
_v = _step6.value;
|
|
514
|
+
_tags.push({
|
|
515
|
+
name: _base64url["default"].decode(_v.name),
|
|
516
|
+
value: _base64url["default"].decode(_v.value)
|
|
517
|
+
});
|
|
518
|
+
}
|
|
519
|
+
} catch (err) {
|
|
520
|
+
_iterator6.e(err);
|
|
521
|
+
} finally {
|
|
522
|
+
_iterator6.f();
|
|
523
|
+
}
|
|
524
|
+
__tags = (0, _utils.tags)(_tags);
|
|
525
|
+
if (!(__tags.Type === "Module")) {
|
|
526
|
+
_context5.next = 75;
|
|
527
|
+
break;
|
|
528
|
+
}
|
|
529
|
+
_context5.next = 75;
|
|
530
|
+
return this.mem.set({
|
|
531
|
+
data: Buffer.from(tx.data, "base64"),
|
|
532
|
+
format: __tags["Module-Format"]
|
|
533
|
+
}, "wasms", tx.id);
|
|
534
|
+
case 75:
|
|
535
|
+
tx.tags = _tags;
|
|
536
|
+
_context5.next = 78;
|
|
537
|
+
return this.arweave.wallets.jwkToAddress({
|
|
538
|
+
n: tx.owner
|
|
539
|
+
});
|
|
540
|
+
case 78:
|
|
541
|
+
tx.owner = _context5.sent;
|
|
542
|
+
_txs = tx;
|
|
543
|
+
block.txs.push(tx.id);
|
|
544
|
+
_txs.block = block.id;
|
|
545
|
+
_context5.next = 84;
|
|
546
|
+
return this.mem.set(_txs, "txs", tx.id);
|
|
547
|
+
case 84:
|
|
548
|
+
_context5.next = 86;
|
|
549
|
+
return this.mem.get("blocks");
|
|
550
|
+
case 86:
|
|
551
|
+
blocks = _context5.sent;
|
|
552
|
+
blocks.push(block.id);
|
|
553
|
+
_context5.next = 90;
|
|
554
|
+
return this.mem.set(blocks, "blocks");
|
|
555
|
+
case 90:
|
|
556
|
+
_context5.next = 92;
|
|
557
|
+
return this.mem.set(block, "blockmap", block.id);
|
|
558
|
+
case 92:
|
|
559
|
+
if (!jwk) {
|
|
560
|
+
_context5.next = 98;
|
|
561
|
+
break;
|
|
562
|
+
}
|
|
563
|
+
_context5.next = 95;
|
|
564
|
+
return this.arweave.wallets.jwkToAddress(jwk);
|
|
565
|
+
case 95:
|
|
566
|
+
owner = _context5.sent;
|
|
567
|
+
_context5.next = 98;
|
|
568
|
+
return this.mem.set({
|
|
569
|
+
address: owner,
|
|
570
|
+
key: jwk.n
|
|
571
|
+
}, "addrmap", owner);
|
|
572
|
+
case 98:
|
|
573
|
+
res = {
|
|
574
|
+
id: tx.id,
|
|
575
|
+
status: 200,
|
|
576
|
+
statusText: "200"
|
|
577
|
+
};
|
|
578
|
+
if (this.log) {
|
|
579
|
+
if (msg) {
|
|
580
|
+
console.log("New ".concat(msg.type, ":\t").concat(msg.id).concat(msg.pid ? " > ".concat(msg.pid) : ""));
|
|
581
|
+
} else {
|
|
582
|
+
console.log("New Post:\t".concat(tx.id));
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
return _context5.abrupt("return", {
|
|
586
|
+
res: res,
|
|
587
|
+
err: err,
|
|
588
|
+
id: tx.id
|
|
589
|
+
});
|
|
590
|
+
case 101:
|
|
591
|
+
case "end":
|
|
592
|
+
return _context5.stop();
|
|
593
|
+
}
|
|
594
|
+
}, _callee5, this, [[41, 62, 65, 68]]);
|
|
595
|
+
}));
|
|
596
|
+
function postTx(_x6, _x7) {
|
|
597
|
+
return _postTx.apply(this, arguments);
|
|
598
|
+
}
|
|
599
|
+
return postTx;
|
|
600
|
+
}()
|
|
601
|
+
}, {
|
|
602
|
+
key: "tx",
|
|
603
|
+
value: function () {
|
|
604
|
+
var _tx = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6(id) {
|
|
605
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
606
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
607
|
+
case 0:
|
|
608
|
+
_context6.next = 2;
|
|
609
|
+
return this.mem.get("txs", id);
|
|
610
|
+
case 2:
|
|
611
|
+
return _context6.abrupt("return", _context6.sent);
|
|
612
|
+
case 3:
|
|
613
|
+
case "end":
|
|
614
|
+
return _context6.stop();
|
|
615
|
+
}
|
|
616
|
+
}, _callee6, this);
|
|
617
|
+
}));
|
|
618
|
+
function tx(_x8) {
|
|
619
|
+
return _tx.apply(this, arguments);
|
|
620
|
+
}
|
|
621
|
+
return tx;
|
|
622
|
+
}()
|
|
623
|
+
}, {
|
|
624
|
+
key: "data",
|
|
625
|
+
value: function () {
|
|
626
|
+
var _data2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7(id, _string, log) {
|
|
627
|
+
var _tx$data;
|
|
628
|
+
var decode, string, tx, _data, isBuf, isStr;
|
|
629
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
630
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
631
|
+
case 0:
|
|
632
|
+
decode = true;
|
|
633
|
+
string = _string;
|
|
634
|
+
if ((0, _ramda.is)(Object, _string)) {
|
|
635
|
+
if (!(0, _ramda.isNil)(_string.decode)) decode = _string.decode;
|
|
636
|
+
if (!(0, _ramda.isNil)(_string.string)) string = _string.string;
|
|
637
|
+
}
|
|
638
|
+
_context7.next = 5;
|
|
639
|
+
return this.mem.get("txs", id);
|
|
640
|
+
case 5:
|
|
641
|
+
tx = _context7.sent;
|
|
642
|
+
_data = (_tx$data = tx === null || tx === void 0 ? void 0 : tx.data) !== null && _tx$data !== void 0 ? _tx$data : null;
|
|
643
|
+
if ((tx === null || tx === void 0 ? void 0 : tx.format) === 2 && _data) {
|
|
644
|
+
_data = Buffer.from(_data, "base64");
|
|
645
|
+
} else if (_data) {
|
|
646
|
+
_data = Buffer.from(_base64url["default"].decode(_data));
|
|
647
|
+
}
|
|
648
|
+
isBuf = (0, _ramda.is)(Uint8Array, _data) || (0, _ramda.is)(ArrayBuffer, _data);
|
|
649
|
+
isStr = (0, _ramda.is)(String, _data);
|
|
650
|
+
if (!(decode === false)) {
|
|
651
|
+
_context7.next = 15;
|
|
652
|
+
break;
|
|
653
|
+
}
|
|
654
|
+
if (isStr) _data = new TextEncoder().encode(_data);
|
|
655
|
+
return _context7.abrupt("return", _base64url["default"].encode(_data));
|
|
656
|
+
case 15:
|
|
657
|
+
if (!(isBuf && string)) {
|
|
658
|
+
_context7.next = 19;
|
|
659
|
+
break;
|
|
660
|
+
}
|
|
661
|
+
return _context7.abrupt("return", _data.toString());
|
|
662
|
+
case 19:
|
|
663
|
+
if (!(isStr && string !== true)) {
|
|
664
|
+
_context7.next = 21;
|
|
665
|
+
break;
|
|
666
|
+
}
|
|
667
|
+
return _context7.abrupt("return", new TextEncoder().encode(_data));
|
|
668
|
+
case 21:
|
|
669
|
+
return _context7.abrupt("return", _data);
|
|
670
|
+
case 22:
|
|
671
|
+
case "end":
|
|
672
|
+
return _context7.stop();
|
|
673
|
+
}
|
|
674
|
+
}, _callee7, this);
|
|
675
|
+
}));
|
|
676
|
+
function data(_x9, _x10, _x11) {
|
|
677
|
+
return _data2.apply(this, arguments);
|
|
678
|
+
}
|
|
679
|
+
return data;
|
|
680
|
+
}()
|
|
681
|
+
}]);
|
|
682
|
+
}(_ar["default"]);
|
|
683
|
+
var _default = exports["default"] = AR;
|