wao 0.4.0 → 0.4.1
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/ao.js +6 -1
- package/cjs/aoconnect.js +7 -3
- package/cjs/ar.js +38 -64
- package/cjs/armem.js +3 -1
- package/cjs/tar.js +112 -111
- package/cjs/tgql.js +733 -0
- package/cjs/utils.js +1 -7
- package/esm/ao.js +4 -1
- package/esm/aoconnect.js +3 -2
- package/esm/ar.js +7 -23
- package/esm/armem.js +5 -1
- package/esm/gql.js +1 -0
- package/esm/tar.js +34 -26
- package/esm/tgql.js +282 -0
- package/esm/utils.js +0 -14
- package/package.json +1 -1
package/cjs/ao.js
CHANGED
|
@@ -658,7 +658,12 @@ var AO = /*#__PURE__*/function () {
|
|
|
658
658
|
return (0, _utils.wait)(1000);
|
|
659
659
|
case 6:
|
|
660
660
|
_context9.next = 8;
|
|
661
|
-
return _this3.ar.txs(
|
|
661
|
+
return _this3.ar.gql.txs({
|
|
662
|
+
recipient: pid,
|
|
663
|
+
fields: ["id", "recipient", "tags", {
|
|
664
|
+
owner: ["address"]
|
|
665
|
+
}]
|
|
666
|
+
});
|
|
662
667
|
case 8:
|
|
663
668
|
txs = _context9.sent;
|
|
664
669
|
ex = exRef(ref, txs);
|
package/cjs/aoconnect.js
CHANGED
|
@@ -405,7 +405,8 @@ var connect = exports.connect = function connect(mem) {
|
|
|
405
405
|
return ar.dataitem({
|
|
406
406
|
data: _opt.data,
|
|
407
407
|
signer: _opt.signer,
|
|
408
|
-
tags: (0, _utils.tags)(_opt.tags)
|
|
408
|
+
tags: (0, _utils.tags)(_opt.tags),
|
|
409
|
+
target: opt.process
|
|
409
410
|
});
|
|
410
411
|
case 4:
|
|
411
412
|
_yield$ar$dataitem3 = _context3.sent;
|
|
@@ -515,7 +516,8 @@ var connect = exports.connect = function connect(mem) {
|
|
|
515
516
|
return ar.dataitem({
|
|
516
517
|
data: opt.data,
|
|
517
518
|
signer: opt.signer,
|
|
518
|
-
tags: (0, _utils.tags)(opt.tags)
|
|
519
|
+
tags: (0, _utils.tags)(opt.tags),
|
|
520
|
+
target: opt.process
|
|
519
521
|
});
|
|
520
522
|
case 7:
|
|
521
523
|
_yield$ar$dataitem4 = _context4.sent;
|
|
@@ -844,7 +846,9 @@ var connect = exports.connect = function connect(mem) {
|
|
|
844
846
|
case 0:
|
|
845
847
|
p = mem.env[opt.process];
|
|
846
848
|
_context10.next = 3;
|
|
847
|
-
return ar.dataitem(opt)
|
|
849
|
+
return ar.dataitem(_objectSpread(_objectSpread({}, opt), {}, {
|
|
850
|
+
target: opt.process
|
|
851
|
+
}));
|
|
848
852
|
case 3:
|
|
849
853
|
_yield$ar$dataitem5 = _context10.sent;
|
|
850
854
|
id = _yield$ar$dataitem5.id;
|
package/cjs/ar.js
CHANGED
|
@@ -8,6 +8,7 @@ var _arweave2 = _interopRequireDefault(require("arweave"));
|
|
|
8
8
|
var _arbundles = require("arbundles");
|
|
9
9
|
var _utils = require("./utils.js");
|
|
10
10
|
var _ramda = require("ramda");
|
|
11
|
+
var _gql = _interopRequireDefault(require("./gql.js"));
|
|
11
12
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
12
13
|
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; }
|
|
13
14
|
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; }
|
|
@@ -38,13 +39,16 @@ var AR = /*#__PURE__*/function () {
|
|
|
38
39
|
port: port,
|
|
39
40
|
protocol: protocol
|
|
40
41
|
};
|
|
41
|
-
if (!_arweave.host) _arweave.host = port === 443 ? "arweave.net" : "
|
|
42
|
+
if (!_arweave.host) _arweave.host = port === 443 ? "arweave.net" : "localhost";
|
|
42
43
|
if (!_arweave.protocol) _arweave.protocol = (0, _utils.isLocalhost)(_arweave.host) ? "http" : "https";
|
|
43
44
|
if (!_arweave.port) _arweave.port = (0, _utils.isLocalhost)(_arweave.host) ? 1984 : 443;
|
|
44
45
|
this.port = _arweave.port;
|
|
45
46
|
this.host = _arweave.host;
|
|
46
47
|
this.protocol = _arweave.protocol;
|
|
47
48
|
this.arweave = _arweave2["default"].init(_arweave);
|
|
49
|
+
this.gql = new _gql["default"]({
|
|
50
|
+
url: "".concat(_arweave.protocol, "://").concat(_arweave.host, ":").concat(_arweave.port, "/graphql")
|
|
51
|
+
});
|
|
48
52
|
}
|
|
49
53
|
return _createClass(AR, [{
|
|
50
54
|
key: "isArConnect",
|
|
@@ -695,29 +699,35 @@ var AR = /*#__PURE__*/function () {
|
|
|
695
699
|
key: "tx",
|
|
696
700
|
value: function () {
|
|
697
701
|
var _tx = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee12(txid) {
|
|
698
|
-
var
|
|
699
|
-
var json;
|
|
702
|
+
var _yield$this$gql$txs$;
|
|
700
703
|
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
701
704
|
while (1) switch (_context12.prev = _context12.next) {
|
|
702
705
|
case 0:
|
|
703
706
|
_context12.next = 2;
|
|
704
|
-
return
|
|
705
|
-
|
|
706
|
-
headers: {
|
|
707
|
-
"Content-Type": "application/json"
|
|
708
|
-
},
|
|
709
|
-
body: JSON.stringify({
|
|
710
|
-
query: (0, _utils.query)(txid)
|
|
711
|
-
})
|
|
712
|
-
}).then(function (r) {
|
|
713
|
-
return r.json();
|
|
707
|
+
return this.gql.txs({
|
|
708
|
+
id: txid
|
|
714
709
|
});
|
|
715
710
|
case 2:
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
711
|
+
_context12.t1 = _yield$this$gql$txs$ = _context12.sent[0];
|
|
712
|
+
_context12.t0 = _context12.t1 !== null;
|
|
713
|
+
if (!_context12.t0) {
|
|
714
|
+
_context12.next = 6;
|
|
715
|
+
break;
|
|
716
|
+
}
|
|
717
|
+
_context12.t0 = _yield$this$gql$txs$ !== void 0;
|
|
718
|
+
case 6:
|
|
719
|
+
if (!_context12.t0) {
|
|
720
|
+
_context12.next = 10;
|
|
721
|
+
break;
|
|
722
|
+
}
|
|
723
|
+
_context12.t2 = _yield$this$gql$txs$;
|
|
724
|
+
_context12.next = 11;
|
|
725
|
+
break;
|
|
726
|
+
case 10:
|
|
727
|
+
_context12.t2 = null;
|
|
728
|
+
case 11:
|
|
729
|
+
return _context12.abrupt("return", _context12.t2);
|
|
730
|
+
case 12:
|
|
721
731
|
case "end":
|
|
722
732
|
return _context12.stop();
|
|
723
733
|
}
|
|
@@ -728,66 +738,30 @@ var AR = /*#__PURE__*/function () {
|
|
|
728
738
|
}
|
|
729
739
|
return tx;
|
|
730
740
|
}()
|
|
731
|
-
}, {
|
|
732
|
-
key: "txs",
|
|
733
|
-
value: function () {
|
|
734
|
-
var _txs = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee13(to) {
|
|
735
|
-
var json;
|
|
736
|
-
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
737
|
-
while (1) switch (_context13.prev = _context13.next) {
|
|
738
|
-
case 0:
|
|
739
|
-
_context13.next = 2;
|
|
740
|
-
return fetch("".concat(this.protocol, "://").concat(this.host, ":").concat(this.port, "/graphql"), {
|
|
741
|
-
method: "POST",
|
|
742
|
-
headers: {
|
|
743
|
-
"Content-Type": "application/json"
|
|
744
|
-
},
|
|
745
|
-
body: JSON.stringify({
|
|
746
|
-
query: (0, _utils.queries)(to)
|
|
747
|
-
})
|
|
748
|
-
}).then(function (r) {
|
|
749
|
-
return r.json();
|
|
750
|
-
});
|
|
751
|
-
case 2:
|
|
752
|
-
json = _context13.sent;
|
|
753
|
-
return _context13.abrupt("return", json.data.transactions.edges.map(function (v) {
|
|
754
|
-
return v.node;
|
|
755
|
-
}));
|
|
756
|
-
case 4:
|
|
757
|
-
case "end":
|
|
758
|
-
return _context13.stop();
|
|
759
|
-
}
|
|
760
|
-
}, _callee13, this);
|
|
761
|
-
}));
|
|
762
|
-
function txs(_x15) {
|
|
763
|
-
return _txs.apply(this, arguments);
|
|
764
|
-
}
|
|
765
|
-
return txs;
|
|
766
|
-
}()
|
|
767
741
|
}, {
|
|
768
742
|
key: "data",
|
|
769
743
|
value: function () {
|
|
770
|
-
var _data = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
744
|
+
var _data = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee13(txid) {
|
|
771
745
|
var string,
|
|
772
|
-
|
|
773
|
-
return _regeneratorRuntime().wrap(function
|
|
774
|
-
while (1) switch (
|
|
746
|
+
_args13 = arguments;
|
|
747
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
748
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
775
749
|
case 0:
|
|
776
|
-
string =
|
|
777
|
-
|
|
750
|
+
string = _args13.length > 1 && _args13[1] !== undefined ? _args13[1] : false;
|
|
751
|
+
_context13.next = 3;
|
|
778
752
|
return this.arweave.transactions.getData(txid, {
|
|
779
753
|
decode: true,
|
|
780
754
|
string: string
|
|
781
755
|
});
|
|
782
756
|
case 3:
|
|
783
|
-
return
|
|
757
|
+
return _context13.abrupt("return", _context13.sent);
|
|
784
758
|
case 4:
|
|
785
759
|
case "end":
|
|
786
|
-
return
|
|
760
|
+
return _context13.stop();
|
|
787
761
|
}
|
|
788
|
-
},
|
|
762
|
+
}, _callee13, this);
|
|
789
763
|
}));
|
|
790
|
-
function data(
|
|
764
|
+
function data(_x15) {
|
|
791
765
|
return _data.apply(this, arguments);
|
|
792
766
|
}
|
|
793
767
|
return data;
|
package/cjs/armem.js
CHANGED
|
@@ -19,14 +19,16 @@ var ArMem = exports["default"] = /*#__PURE__*/_createClass(function ArMem() {
|
|
|
19
19
|
this.__type__ = "mem";
|
|
20
20
|
this.arweave = _arweave["default"].init();
|
|
21
21
|
this.arweave.transactions.getTransactionAnchor = function () {
|
|
22
|
-
return _this.blocks.length === 0 ? "" : (0, _ramda.last)(_this.blocks);
|
|
22
|
+
return _this.blocks.length === 0 ? "" : (0, _ramda.last)(_this.blockmap[(0, _ramda.last)(_this.blocks)].txs);
|
|
23
23
|
};
|
|
24
24
|
this.arweave.transactions.getPrice = function () {
|
|
25
25
|
return 0;
|
|
26
26
|
};
|
|
27
27
|
this.txs = {};
|
|
28
|
+
this.jwks = {};
|
|
28
29
|
this.height = 0;
|
|
29
30
|
this.blocks = [];
|
|
31
|
+
this.blockmap = {};
|
|
30
32
|
this.env = {};
|
|
31
33
|
this.modules = {
|
|
32
34
|
aos2_0_1: "Do_Uc2Sju_ffp6Ev0AnLVdPtot15rvMjP-a9VVaA5fM",
|
package/cjs/tar.js
CHANGED
|
@@ -10,11 +10,13 @@ var _utils = require("./utils.js");
|
|
|
10
10
|
var _warpArbundles = require("warp-arbundles");
|
|
11
11
|
var _base64url = _interopRequireDefault(require("base64url"));
|
|
12
12
|
var _armem = _interopRequireDefault(require("./armem.js"));
|
|
13
|
+
var _tgql = _interopRequireDefault(require("./tgql.js"));
|
|
14
|
+
var _ramda = require("ramda");
|
|
13
15
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
14
|
-
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; }
|
|
15
16
|
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; } } }; }
|
|
16
17
|
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; } }
|
|
17
18
|
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
|
+
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; }
|
|
18
20
|
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); }
|
|
19
21
|
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); }); }; }
|
|
20
22
|
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; }
|
|
@@ -43,82 +45,52 @@ var AR = /*#__PURE__*/function (_MAR) {
|
|
|
43
45
|
})]);
|
|
44
46
|
_this.in_memory = true;
|
|
45
47
|
_this.mem = (_opt$mem = opt.mem) !== null && _opt$mem !== void 0 ? _opt$mem : new _armem["default"]();
|
|
48
|
+
_this.gql = new _tgql["default"]({
|
|
49
|
+
mem: _this.mem
|
|
50
|
+
});
|
|
51
|
+
_this.arweave = _this.mem.arweave;
|
|
46
52
|
return _this;
|
|
47
53
|
}
|
|
48
54
|
_inherits(AR, _MAR);
|
|
49
55
|
return _createClass(AR, [{
|
|
50
|
-
key: "
|
|
56
|
+
key: "dataitem",
|
|
51
57
|
value: function () {
|
|
52
|
-
var
|
|
53
|
-
var
|
|
58
|
+
var _dataitem = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
|
|
59
|
+
var _ref$target, target, _ref$data, data, _ref$tags, tags, signer, _tags, item, di, raw_owner, hashBuffer, owner;
|
|
54
60
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
55
61
|
while (1) switch (_context.prev = _context.next) {
|
|
56
62
|
case 0:
|
|
57
|
-
|
|
58
|
-
_iterator = _createForOfIteratorHelper(this.mem.env[pid].txs);
|
|
59
|
-
try {
|
|
60
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
61
|
-
v = _step.value;
|
|
62
|
-
_txs.push({
|
|
63
|
-
tags: v.tags,
|
|
64
|
-
id: v.id
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
} catch (err) {
|
|
68
|
-
_iterator.e(err);
|
|
69
|
-
} finally {
|
|
70
|
-
_iterator.f();
|
|
71
|
-
}
|
|
72
|
-
return _context.abrupt("return", _txs);
|
|
73
|
-
case 4:
|
|
74
|
-
case "end":
|
|
75
|
-
return _context.stop();
|
|
76
|
-
}
|
|
77
|
-
}, _callee, this);
|
|
78
|
-
}));
|
|
79
|
-
function txs(_x) {
|
|
80
|
-
return _txs2.apply(this, arguments);
|
|
81
|
-
}
|
|
82
|
-
return txs;
|
|
83
|
-
}()
|
|
84
|
-
}, {
|
|
85
|
-
key: "dataitem",
|
|
86
|
-
value: function () {
|
|
87
|
-
var _dataitem = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref) {
|
|
88
|
-
var _ref$data, data, _ref$tags, tags, signer, _tags, item, di, raw_owner, hashBuffer, owner;
|
|
89
|
-
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
90
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
91
|
-
case 0:
|
|
92
|
-
_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;
|
|
63
|
+
_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;
|
|
93
64
|
_tags = (0, _utils.buildTags)(tags);
|
|
94
|
-
|
|
65
|
+
_context.next = 4;
|
|
95
66
|
return signer({
|
|
96
67
|
data: data,
|
|
97
|
-
tags: _tags
|
|
68
|
+
tags: _tags,
|
|
69
|
+
target: target
|
|
98
70
|
});
|
|
99
71
|
case 4:
|
|
100
|
-
item =
|
|
72
|
+
item = _context.sent;
|
|
101
73
|
di = new _warpArbundles.DataItem(item.raw);
|
|
102
74
|
raw_owner = di.rawOwner;
|
|
103
|
-
|
|
104
|
-
|
|
75
|
+
_context.t0 = Buffer;
|
|
76
|
+
_context.next = 10;
|
|
105
77
|
return crypto.subtle.digest("SHA-256", raw_owner);
|
|
106
78
|
case 10:
|
|
107
|
-
|
|
108
|
-
hashBuffer =
|
|
79
|
+
_context.t1 = _context.sent;
|
|
80
|
+
hashBuffer = _context.t0.from.call(_context.t0, _context.t1);
|
|
109
81
|
owner = _base64url["default"].encode(hashBuffer);
|
|
110
|
-
return
|
|
82
|
+
return _context.abrupt("return", {
|
|
111
83
|
id: item.id,
|
|
112
84
|
owner: owner,
|
|
113
85
|
item: item
|
|
114
86
|
});
|
|
115
87
|
case 14:
|
|
116
88
|
case "end":
|
|
117
|
-
return
|
|
89
|
+
return _context.stop();
|
|
118
90
|
}
|
|
119
|
-
},
|
|
91
|
+
}, _callee);
|
|
120
92
|
}));
|
|
121
|
-
function dataitem(
|
|
93
|
+
function dataitem(_x) {
|
|
122
94
|
return _dataitem.apply(this, arguments);
|
|
123
95
|
}
|
|
124
96
|
return dataitem;
|
|
@@ -126,46 +98,56 @@ var AR = /*#__PURE__*/function (_MAR) {
|
|
|
126
98
|
}, {
|
|
127
99
|
key: "post",
|
|
128
100
|
value: function () {
|
|
129
|
-
var _post = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
130
|
-
var _ref2$data, data, _ref2$tags, tags, jwk, tx, _tags,
|
|
131
|
-
return _regeneratorRuntime().wrap(function
|
|
132
|
-
while (1) switch (
|
|
101
|
+
var _post = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref2) {
|
|
102
|
+
var _ref2$data, data, _ref2$tags, tags, jwk, tx, _tags, _iterator, _step, v;
|
|
103
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
104
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
133
105
|
case 0:
|
|
134
106
|
_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;
|
|
135
|
-
|
|
107
|
+
_context2.next = 3;
|
|
136
108
|
return this.arweave.createTransaction({
|
|
137
109
|
data: data
|
|
138
110
|
});
|
|
139
111
|
case 3:
|
|
140
|
-
tx =
|
|
112
|
+
tx = _context2.sent;
|
|
141
113
|
_tags = (0, _utils.buildTags)(null, tags);
|
|
142
|
-
|
|
114
|
+
_iterator = _createForOfIteratorHelper(_tags);
|
|
143
115
|
try {
|
|
144
|
-
for (
|
|
145
|
-
v =
|
|
116
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
117
|
+
v = _step.value;
|
|
146
118
|
tx.addTag(v.name, v.value);
|
|
147
119
|
}
|
|
148
120
|
} catch (err) {
|
|
149
|
-
|
|
121
|
+
_iterator.e(err);
|
|
150
122
|
} finally {
|
|
151
|
-
|
|
123
|
+
_iterator.f();
|
|
152
124
|
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
case
|
|
161
|
-
|
|
162
|
-
|
|
125
|
+
_context2.t0 = this;
|
|
126
|
+
_context2.t1 = tx;
|
|
127
|
+
_context2.t2 = jwk;
|
|
128
|
+
_context2.t3 = _tags;
|
|
129
|
+
_context2.t4 = data;
|
|
130
|
+
_context2.next = 14;
|
|
131
|
+
return this.arweave.wallets.jwkToAddress(jwk);
|
|
132
|
+
case 14:
|
|
133
|
+
_context2.t5 = _context2.sent;
|
|
134
|
+
_context2.t6 = {
|
|
135
|
+
recipient: "",
|
|
136
|
+
tags: _context2.t3,
|
|
137
|
+
data: _context2.t4,
|
|
138
|
+
owner: _context2.t5
|
|
139
|
+
};
|
|
140
|
+
_context2.next = 18;
|
|
141
|
+
return _context2.t0.postTx.call(_context2.t0, _context2.t1, _context2.t2, _context2.t6);
|
|
142
|
+
case 18:
|
|
143
|
+
return _context2.abrupt("return", _context2.sent);
|
|
144
|
+
case 19:
|
|
163
145
|
case "end":
|
|
164
|
-
return
|
|
146
|
+
return _context2.stop();
|
|
165
147
|
}
|
|
166
|
-
},
|
|
148
|
+
}, _callee2, this);
|
|
167
149
|
}));
|
|
168
|
-
function post(
|
|
150
|
+
function post(_x2) {
|
|
169
151
|
return _post.apply(this, arguments);
|
|
170
152
|
}
|
|
171
153
|
return post;
|
|
@@ -173,53 +155,52 @@ var AR = /*#__PURE__*/function (_MAR) {
|
|
|
173
155
|
}, {
|
|
174
156
|
key: "postItem",
|
|
175
157
|
value: function () {
|
|
176
|
-
var _postItem = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
177
|
-
var tx, di, rowner, hashBuffer, owner, data;
|
|
178
|
-
return _regeneratorRuntime().wrap(function
|
|
179
|
-
while (1) switch (
|
|
158
|
+
var _postItem = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(item, jwk) {
|
|
159
|
+
var tx, di, rowner, hashBuffer, owner, data, _item;
|
|
160
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
161
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
180
162
|
case 0:
|
|
181
|
-
|
|
163
|
+
_context3.next = 2;
|
|
182
164
|
return this.mem.arweave.createTransaction({
|
|
183
165
|
data: item.raw
|
|
184
|
-
});
|
|
166
|
+
}, jwk);
|
|
185
167
|
case 2:
|
|
186
|
-
tx =
|
|
168
|
+
tx = _context3.sent;
|
|
187
169
|
tx.addTag("Bundle-Format", "binary");
|
|
188
170
|
tx.addTag("Bundle-Version", "2.0.0");
|
|
189
171
|
di = new _warpArbundles.DataItem(item.raw);
|
|
190
172
|
rowner = di.rawOwner;
|
|
191
|
-
|
|
192
|
-
|
|
173
|
+
_context3.t0 = Buffer;
|
|
174
|
+
_context3.next = 10;
|
|
193
175
|
return crypto.subtle.digest("SHA-256", rowner);
|
|
194
176
|
case 10:
|
|
195
|
-
|
|
196
|
-
hashBuffer =
|
|
177
|
+
_context3.t1 = _context3.sent;
|
|
178
|
+
hashBuffer = _context3.t0.from.call(_context3.t0, _context3.t1);
|
|
197
179
|
owner = _base64url["default"].encode(hashBuffer);
|
|
198
|
-
this.mem.height += 1;
|
|
199
180
|
data = di.data;
|
|
200
181
|
try {
|
|
201
182
|
data = _base64url["default"].decode(di.data);
|
|
202
183
|
} catch (e) {}
|
|
203
|
-
|
|
184
|
+
_item = {
|
|
185
|
+
recipient: di.target,
|
|
204
186
|
id: item.id,
|
|
205
187
|
item: di,
|
|
206
188
|
owner: owner,
|
|
207
|
-
height: this.mem.height,
|
|
208
189
|
tags: di.tags,
|
|
209
190
|
data: data
|
|
210
191
|
};
|
|
211
|
-
this.mem.
|
|
212
|
-
|
|
213
|
-
return this.postTx(tx, jwk);
|
|
192
|
+
this.mem.txs[item.id] = _item;
|
|
193
|
+
_context3.next = 19;
|
|
194
|
+
return this.postTx(tx, jwk, _item);
|
|
195
|
+
case 19:
|
|
196
|
+
return _context3.abrupt("return", _context3.sent);
|
|
214
197
|
case 20:
|
|
215
|
-
return _context4.abrupt("return", _context4.sent);
|
|
216
|
-
case 21:
|
|
217
198
|
case "end":
|
|
218
|
-
return
|
|
199
|
+
return _context3.stop();
|
|
219
200
|
}
|
|
220
|
-
},
|
|
201
|
+
}, _callee3, this);
|
|
221
202
|
}));
|
|
222
|
-
function postItem(
|
|
203
|
+
function postItem(_x3, _x4) {
|
|
223
204
|
return _postItem.apply(this, arguments);
|
|
224
205
|
}
|
|
225
206
|
return postItem;
|
|
@@ -227,39 +208,59 @@ var AR = /*#__PURE__*/function (_MAR) {
|
|
|
227
208
|
}, {
|
|
228
209
|
key: "postTx",
|
|
229
210
|
value: function () {
|
|
230
|
-
var _postTx = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
231
|
-
var res, err;
|
|
232
|
-
return _regeneratorRuntime().wrap(function
|
|
233
|
-
while (1) switch (
|
|
211
|
+
var _postTx = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4(tx, jwk, item) {
|
|
212
|
+
var res, err, _last, block;
|
|
213
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
214
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
234
215
|
case 0:
|
|
235
216
|
res = null, err = null;
|
|
236
|
-
|
|
217
|
+
_context4.next = 3;
|
|
237
218
|
return this.mem.arweave.transactions.sign(tx, jwk);
|
|
238
219
|
case 3:
|
|
239
220
|
if (item) {
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
221
|
+
this.mem.height += 1;
|
|
222
|
+
block = {
|
|
223
|
+
id: tx.id,
|
|
224
|
+
timestamp: Date.now(),
|
|
225
|
+
height: this.mem.height,
|
|
226
|
+
previous: (_last = (0, _ramda.last)(this.mem.blocks)) !== null && _last !== void 0 ? _last : ""
|
|
227
|
+
};
|
|
228
|
+
if (!item.id) {
|
|
229
|
+
item.id = tx.id;
|
|
230
|
+
this.mem.txs[item.id] = item;
|
|
231
|
+
this.mem.txs[item.id].parent = {
|
|
232
|
+
id: block.id
|
|
233
|
+
};
|
|
234
|
+
} else {
|
|
235
|
+
this.mem.txs[item.id].parent = {
|
|
236
|
+
id: ""
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
block.txs = [item.id];
|
|
240
|
+
this.mem.txs[item.id].block = block.id;
|
|
241
|
+
this.mem.txs[item.id].parent = {
|
|
242
|
+
id: block.id
|
|
243
|
+
};
|
|
244
|
+
this.mem.blocks.push(block.id);
|
|
245
|
+
this.mem.blockmap[block.id] = block;
|
|
243
246
|
}
|
|
244
247
|
res = {
|
|
245
248
|
id: tx.id,
|
|
246
249
|
status: 200,
|
|
247
250
|
statusText: "200"
|
|
248
251
|
};
|
|
249
|
-
|
|
250
|
-
//if (res.status !== 200) err = res.statusText
|
|
251
|
-
return _context5.abrupt("return", {
|
|
252
|
+
return _context4.abrupt("return", {
|
|
252
253
|
res: res,
|
|
253
254
|
err: err,
|
|
254
255
|
id: tx.id
|
|
255
256
|
});
|
|
256
257
|
case 6:
|
|
257
258
|
case "end":
|
|
258
|
-
return
|
|
259
|
+
return _context4.stop();
|
|
259
260
|
}
|
|
260
|
-
},
|
|
261
|
+
}, _callee4, this);
|
|
261
262
|
}));
|
|
262
|
-
function postTx(_x6, _x7
|
|
263
|
+
function postTx(_x5, _x6, _x7) {
|
|
263
264
|
return _postTx.apply(this, arguments);
|
|
264
265
|
}
|
|
265
266
|
return postTx;
|