wao 0.4.11 → 0.5.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 +4 -3
- package/cjs/aoconnect.js +223 -136
- package/cjs/ar.js +299 -211
- package/cjs/armem.js +102 -41
- package/cjs/run.js +26 -0
- package/cjs/server.js +632 -0
- package/cjs/tao.js +4 -8
- package/cjs/tar.js +161 -65
- package/cjs/test.js +8 -1
- package/esm/ao.js +1 -1
- package/esm/aoconnect.js +94 -35
- package/esm/ar.js +42 -2
- package/esm/armem.js +53 -8
- package/esm/run.js +7 -0
- package/esm/server.js +375 -0
- package/esm/tao.js +2 -2
- package/esm/tar.js +56 -31
- package/esm/test.js +4 -1
- package/esm/tgql.js +0 -1
- package/package.json +19 -1
package/cjs/ar.js
CHANGED
|
@@ -17,8 +17,8 @@ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object
|
|
|
17
17
|
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; } } }; }
|
|
18
18
|
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; } }
|
|
19
19
|
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; }
|
|
20
|
-
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; }
|
|
21
20
|
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); }
|
|
21
|
+
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; }
|
|
22
22
|
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); }
|
|
23
23
|
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); }); }; }
|
|
24
24
|
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
@@ -48,6 +48,89 @@ var AR = /*#__PURE__*/function () {
|
|
|
48
48
|
this.host = _arweave.host;
|
|
49
49
|
this.protocol = _arweave.protocol;
|
|
50
50
|
this.arweave = Arweave.init(_arweave);
|
|
51
|
+
var ArweaveUtils = this.arweave.utils;
|
|
52
|
+
this.arweave.transactions.getData = /*#__PURE__*/function () {
|
|
53
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(id, options) {
|
|
54
|
+
var data, _yield$this$api$get, resData, ok, status, statusText;
|
|
55
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
56
|
+
while (1) switch (_context.prev = _context.next) {
|
|
57
|
+
case 0:
|
|
58
|
+
data = undefined;
|
|
59
|
+
_context.prev = 1;
|
|
60
|
+
_context.next = 4;
|
|
61
|
+
return this.chunks.downloadChunkedData(id);
|
|
62
|
+
case 4:
|
|
63
|
+
data = _context.sent;
|
|
64
|
+
_context.next = 9;
|
|
65
|
+
break;
|
|
66
|
+
case 7:
|
|
67
|
+
_context.prev = 7;
|
|
68
|
+
_context.t0 = _context["catch"](1);
|
|
69
|
+
case 9:
|
|
70
|
+
if (data) {
|
|
71
|
+
_context.next = 27;
|
|
72
|
+
break;
|
|
73
|
+
}
|
|
74
|
+
_context.prev = 10;
|
|
75
|
+
_context.next = 13;
|
|
76
|
+
return this.api.get("/".concat(id), {
|
|
77
|
+
responseType: "arraybuffer"
|
|
78
|
+
});
|
|
79
|
+
case 13:
|
|
80
|
+
_yield$this$api$get = _context.sent;
|
|
81
|
+
resData = _yield$this$api$get.data;
|
|
82
|
+
ok = _yield$this$api$get.ok;
|
|
83
|
+
status = _yield$this$api$get.status;
|
|
84
|
+
statusText = _yield$this$api$get.statusText;
|
|
85
|
+
if (ok) {
|
|
86
|
+
_context.next = 20;
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
throw new Error("Bad http status code", {
|
|
90
|
+
cause: {
|
|
91
|
+
status: status,
|
|
92
|
+
statusText: statusText
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
case 20:
|
|
96
|
+
data = resData;
|
|
97
|
+
_context.next = 27;
|
|
98
|
+
break;
|
|
99
|
+
case 23:
|
|
100
|
+
_context.prev = 23;
|
|
101
|
+
_context.t1 = _context["catch"](10);
|
|
102
|
+
console.error("Error while trying to download contiguous data from gateway cache for ".concat(id));
|
|
103
|
+
console.error(_context.t1);
|
|
104
|
+
case 27:
|
|
105
|
+
if (data) {
|
|
106
|
+
_context.next = 29;
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
throw new Error("".concat(id, " data was not found!"));
|
|
110
|
+
case 29:
|
|
111
|
+
if (!(options && options.decode && !options.string)) {
|
|
112
|
+
_context.next = 31;
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
return _context.abrupt("return", data);
|
|
116
|
+
case 31:
|
|
117
|
+
if (!(options && options.decode && options.string)) {
|
|
118
|
+
_context.next = 33;
|
|
119
|
+
break;
|
|
120
|
+
}
|
|
121
|
+
return _context.abrupt("return", ArweaveUtils.bufferToString(data));
|
|
122
|
+
case 33:
|
|
123
|
+
return _context.abrupt("return", ArweaveUtils.bufferTob64Url(data));
|
|
124
|
+
case 34:
|
|
125
|
+
case "end":
|
|
126
|
+
return _context.stop();
|
|
127
|
+
}
|
|
128
|
+
}, _callee, this, [[1, 7], [10, 23]]);
|
|
129
|
+
}));
|
|
130
|
+
return function (_x, _x2) {
|
|
131
|
+
return _ref2.apply(this, arguments);
|
|
132
|
+
};
|
|
133
|
+
}();
|
|
51
134
|
this.gql = new _gql["default"]({
|
|
52
135
|
url: "".concat(_arweave.protocol, "://").concat(_arweave.host, ":").concat(_arweave.port, "/graphql")
|
|
53
136
|
});
|
|
@@ -61,74 +144,74 @@ var AR = /*#__PURE__*/function () {
|
|
|
61
144
|
}, {
|
|
62
145
|
key: "init",
|
|
63
146
|
value: function () {
|
|
64
|
-
var _init = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
147
|
+
var _init = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(jwk) {
|
|
65
148
|
var isGen, _jwk, isWallet;
|
|
66
|
-
return _regeneratorRuntime().wrap(function
|
|
67
|
-
while (1) switch (
|
|
149
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
150
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
68
151
|
case 0:
|
|
69
152
|
isGen = false;
|
|
70
153
|
if (!jwk && (typeof window === "undefined" ? "undefined" : _typeof(window)) === "object") jwk = window.arweaveWallet;
|
|
71
154
|
if (jwk) {
|
|
72
|
-
|
|
155
|
+
_context2.next = 6;
|
|
73
156
|
break;
|
|
74
157
|
}
|
|
75
158
|
isGen = true;
|
|
76
|
-
|
|
159
|
+
_context2.next = 31;
|
|
77
160
|
break;
|
|
78
161
|
case 6:
|
|
79
162
|
jwk = _typeof((_jwk = jwk) === null || _jwk === void 0 ? void 0 : _jwk.jwk) === "object" ? jwk.jwk : jwk;
|
|
80
163
|
this.jwk = jwk;
|
|
81
164
|
isWallet = this.isArConnect(this.jwk);
|
|
82
165
|
if (!isWallet) {
|
|
83
|
-
|
|
166
|
+
_context2.next = 27;
|
|
84
167
|
break;
|
|
85
168
|
}
|
|
86
|
-
|
|
87
|
-
|
|
169
|
+
_context2.prev = 10;
|
|
170
|
+
_context2.next = 13;
|
|
88
171
|
return this.jwk.connect(["ACCESS_ADDRESS", "ACCESS_PUBLIC_KEY", "SIGN_TRANSACTION"]);
|
|
89
172
|
case 13:
|
|
90
|
-
|
|
173
|
+
_context2.next = 15;
|
|
91
174
|
return this.jwk.getActiveAddress();
|
|
92
175
|
case 15:
|
|
93
|
-
this.addr =
|
|
94
|
-
|
|
176
|
+
this.addr = _context2.sent;
|
|
177
|
+
_context2.next = 18;
|
|
95
178
|
return this.jwk.getActivePublicKey();
|
|
96
179
|
case 18:
|
|
97
|
-
this.pub =
|
|
180
|
+
this.pub = _context2.sent;
|
|
98
181
|
this.isWallet = true;
|
|
99
|
-
|
|
182
|
+
_context2.next = 25;
|
|
100
183
|
break;
|
|
101
184
|
case 22:
|
|
102
|
-
|
|
103
|
-
|
|
185
|
+
_context2.prev = 22;
|
|
186
|
+
_context2.t0 = _context2["catch"](10);
|
|
104
187
|
isGen = true;
|
|
105
188
|
case 25:
|
|
106
|
-
|
|
189
|
+
_context2.next = 31;
|
|
107
190
|
break;
|
|
108
191
|
case 27:
|
|
109
|
-
|
|
192
|
+
_context2.next = 29;
|
|
110
193
|
return this.toAddr(jwk);
|
|
111
194
|
case 29:
|
|
112
|
-
this.addr =
|
|
195
|
+
this.addr = _context2.sent;
|
|
113
196
|
this.pub = jwk.n;
|
|
114
197
|
case 31:
|
|
115
198
|
if (!isGen) {
|
|
116
|
-
|
|
199
|
+
_context2.next = 36;
|
|
117
200
|
break;
|
|
118
201
|
}
|
|
119
202
|
this.isWallet = false;
|
|
120
203
|
this.addr = this.pub = this.jwk = null;
|
|
121
|
-
|
|
204
|
+
_context2.next = 36;
|
|
122
205
|
return this.gen("100");
|
|
123
206
|
case 36:
|
|
124
|
-
return
|
|
207
|
+
return _context2.abrupt("return", this);
|
|
125
208
|
case 37:
|
|
126
209
|
case "end":
|
|
127
|
-
return
|
|
210
|
+
return _context2.stop();
|
|
128
211
|
}
|
|
129
|
-
},
|
|
212
|
+
}, _callee2, this, [[10, 22]]);
|
|
130
213
|
}));
|
|
131
|
-
function init(
|
|
214
|
+
function init(_x3) {
|
|
132
215
|
return _init.apply(this, arguments);
|
|
133
216
|
}
|
|
134
217
|
return init;
|
|
@@ -136,17 +219,17 @@ var AR = /*#__PURE__*/function () {
|
|
|
136
219
|
}, {
|
|
137
220
|
key: "mine",
|
|
138
221
|
value: function () {
|
|
139
|
-
var _mine = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
140
|
-
return _regeneratorRuntime().wrap(function
|
|
141
|
-
while (1) switch (
|
|
222
|
+
var _mine = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
223
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
224
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
142
225
|
case 0:
|
|
143
|
-
|
|
226
|
+
_context3.next = 2;
|
|
144
227
|
return this.arweave.api.get("/mine");
|
|
145
228
|
case 2:
|
|
146
229
|
case "end":
|
|
147
|
-
return
|
|
230
|
+
return _context3.stop();
|
|
148
231
|
}
|
|
149
|
-
},
|
|
232
|
+
}, _callee3, this);
|
|
150
233
|
}));
|
|
151
234
|
function mine() {
|
|
152
235
|
return _mine.apply(this, arguments);
|
|
@@ -156,8 +239,8 @@ var AR = /*#__PURE__*/function () {
|
|
|
156
239
|
}, {
|
|
157
240
|
key: "checkWallet",
|
|
158
241
|
value: function () {
|
|
159
|
-
var _checkWallet = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
160
|
-
var
|
|
242
|
+
var _checkWallet = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
243
|
+
var _ref3,
|
|
161
244
|
jwk,
|
|
162
245
|
start,
|
|
163
246
|
err,
|
|
@@ -167,17 +250,17 @@ var AR = /*#__PURE__*/function () {
|
|
|
167
250
|
isJwkWallet,
|
|
168
251
|
_yield$this$gen,
|
|
169
252
|
_addr,
|
|
170
|
-
|
|
171
|
-
return _regeneratorRuntime().wrap(function
|
|
172
|
-
while (1) switch (
|
|
253
|
+
_args4 = arguments;
|
|
254
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
255
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
173
256
|
case 0:
|
|
174
|
-
|
|
257
|
+
_ref3 = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : {}, jwk = _ref3.jwk;
|
|
175
258
|
start = Date.now();
|
|
176
259
|
if (!jwk) {
|
|
177
|
-
|
|
260
|
+
_context4.next = 4;
|
|
178
261
|
break;
|
|
179
262
|
}
|
|
180
|
-
return
|
|
263
|
+
return _context4.abrupt("return", {
|
|
181
264
|
err: null,
|
|
182
265
|
jwk: jwk
|
|
183
266
|
});
|
|
@@ -186,85 +269,85 @@ var AR = /*#__PURE__*/function () {
|
|
|
186
269
|
existWallet = (typeof window === "undefined" ? "undefined" : _typeof(window)) === "object" && window.arweaveWallet;
|
|
187
270
|
isJwkWallet = this.isArConnect(this.jwk);
|
|
188
271
|
if (this.jwk) {
|
|
189
|
-
|
|
272
|
+
_context4.next = 25;
|
|
190
273
|
break;
|
|
191
274
|
}
|
|
192
275
|
if (!this._jwk) {
|
|
193
|
-
|
|
276
|
+
_context4.next = 16;
|
|
194
277
|
break;
|
|
195
278
|
}
|
|
196
279
|
jwk = this._jwk;
|
|
197
280
|
pub = this._jwk.n;
|
|
198
|
-
|
|
281
|
+
_context4.next = 13;
|
|
199
282
|
return this.toAddr(jwk);
|
|
200
283
|
case 13:
|
|
201
|
-
addr =
|
|
202
|
-
|
|
284
|
+
addr = _context4.sent;
|
|
285
|
+
_context4.next = 23;
|
|
203
286
|
break;
|
|
204
287
|
case 16:
|
|
205
288
|
;
|
|
206
|
-
|
|
289
|
+
_context4.next = 19;
|
|
207
290
|
return this.gen("100", false);
|
|
208
291
|
case 19:
|
|
209
|
-
_yield$this$gen =
|
|
292
|
+
_yield$this$gen = _context4.sent;
|
|
210
293
|
jwk = _yield$this$gen.jwk;
|
|
211
294
|
addr = _yield$this$gen.addr;
|
|
212
295
|
pub = _yield$this$gen.pub;
|
|
213
296
|
case 23:
|
|
214
|
-
|
|
297
|
+
_context4.next = 53;
|
|
215
298
|
break;
|
|
216
299
|
case 25:
|
|
217
300
|
if (!(this.jwk && !isJwkWallet)) {
|
|
218
|
-
|
|
301
|
+
_context4.next = 31;
|
|
219
302
|
break;
|
|
220
303
|
}
|
|
221
304
|
jwk = this.jwk;
|
|
222
305
|
addr = this.addr;
|
|
223
306
|
pub = this.pub;
|
|
224
|
-
|
|
307
|
+
_context4.next = 53;
|
|
225
308
|
break;
|
|
226
309
|
case 31:
|
|
227
310
|
if (!existWallet) {
|
|
228
|
-
|
|
311
|
+
_context4.next = 52;
|
|
229
312
|
break;
|
|
230
313
|
}
|
|
231
|
-
|
|
314
|
+
_context4.next = 34;
|
|
232
315
|
return arweaveWallet.connect(["ACCESS_ADDRESS", "ACCESS_PUBLIC_KEY", "SIGN_TRANSACTION"]);
|
|
233
316
|
case 34:
|
|
234
|
-
|
|
317
|
+
_context4.next = 36;
|
|
235
318
|
return arweaveWallet.getActiveAddress();
|
|
236
319
|
case 36:
|
|
237
|
-
_addr =
|
|
320
|
+
_addr = _context4.sent;
|
|
238
321
|
if (!_addr) {
|
|
239
|
-
|
|
322
|
+
_context4.next = 49;
|
|
240
323
|
break;
|
|
241
324
|
}
|
|
242
325
|
if (!(this.addr && this.addr !== _addr)) {
|
|
243
|
-
|
|
326
|
+
_context4.next = 42;
|
|
244
327
|
break;
|
|
245
328
|
}
|
|
246
329
|
err = "the wrong wallet";
|
|
247
|
-
|
|
330
|
+
_context4.next = 47;
|
|
248
331
|
break;
|
|
249
332
|
case 42:
|
|
250
333
|
addr = _addr;
|
|
251
|
-
|
|
334
|
+
_context4.next = 45;
|
|
252
335
|
return arweaveWallet.getActivePublicKey();
|
|
253
336
|
case 45:
|
|
254
|
-
pub =
|
|
337
|
+
pub = _context4.sent;
|
|
255
338
|
jwk = arweaveWallet;
|
|
256
339
|
case 47:
|
|
257
|
-
|
|
340
|
+
_context4.next = 50;
|
|
258
341
|
break;
|
|
259
342
|
case 49:
|
|
260
343
|
err = "no wallet found";
|
|
261
344
|
case 50:
|
|
262
|
-
|
|
345
|
+
_context4.next = 53;
|
|
263
346
|
break;
|
|
264
347
|
case 52:
|
|
265
348
|
err = "no wallet found";
|
|
266
349
|
case 53:
|
|
267
|
-
return
|
|
350
|
+
return _context4.abrupt("return", {
|
|
268
351
|
addr: addr,
|
|
269
352
|
jwk: jwk,
|
|
270
353
|
pub: pub,
|
|
@@ -272,9 +355,9 @@ var AR = /*#__PURE__*/function () {
|
|
|
272
355
|
});
|
|
273
356
|
case 54:
|
|
274
357
|
case "end":
|
|
275
|
-
return
|
|
358
|
+
return _context4.stop();
|
|
276
359
|
}
|
|
277
|
-
},
|
|
360
|
+
}, _callee4, this);
|
|
278
361
|
}));
|
|
279
362
|
function checkWallet() {
|
|
280
363
|
return _checkWallet.apply(this, arguments);
|
|
@@ -284,36 +367,36 @@ var AR = /*#__PURE__*/function () {
|
|
|
284
367
|
}, {
|
|
285
368
|
key: "balance",
|
|
286
369
|
value: function () {
|
|
287
|
-
var _balance = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
370
|
+
var _balance = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
|
|
288
371
|
var addr,
|
|
289
372
|
_yield$this$checkWall,
|
|
290
|
-
|
|
291
|
-
return _regeneratorRuntime().wrap(function
|
|
292
|
-
while (1) switch (
|
|
373
|
+
_args5 = arguments;
|
|
374
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
375
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
293
376
|
case 0:
|
|
294
|
-
addr =
|
|
377
|
+
addr = _args5.length > 0 && _args5[0] !== undefined ? _args5[0] : this.addr;
|
|
295
378
|
if (addr) {
|
|
296
|
-
|
|
379
|
+
_context5.next = 7;
|
|
297
380
|
break;
|
|
298
381
|
}
|
|
299
382
|
;
|
|
300
|
-
|
|
383
|
+
_context5.next = 5;
|
|
301
384
|
return this.checkWallet();
|
|
302
385
|
case 5:
|
|
303
|
-
_yield$this$checkWall =
|
|
386
|
+
_yield$this$checkWall = _context5.sent;
|
|
304
387
|
addr = _yield$this$checkWall.addr;
|
|
305
388
|
case 7:
|
|
306
|
-
|
|
307
|
-
|
|
389
|
+
_context5.t0 = this;
|
|
390
|
+
_context5.next = 10;
|
|
308
391
|
return this.arweave.wallets.getBalance(addr);
|
|
309
392
|
case 10:
|
|
310
|
-
|
|
311
|
-
return
|
|
393
|
+
_context5.t1 = _context5.sent;
|
|
394
|
+
return _context5.abrupt("return", _context5.t0.toAR.call(_context5.t0, _context5.t1));
|
|
312
395
|
case 12:
|
|
313
396
|
case "end":
|
|
314
|
-
return
|
|
397
|
+
return _context5.stop();
|
|
315
398
|
}
|
|
316
|
-
},
|
|
399
|
+
}, _callee5, this);
|
|
317
400
|
}));
|
|
318
401
|
function balance() {
|
|
319
402
|
return _balance.apply(this, arguments);
|
|
@@ -323,30 +406,30 @@ var AR = /*#__PURE__*/function () {
|
|
|
323
406
|
}, {
|
|
324
407
|
key: "mint",
|
|
325
408
|
value: function () {
|
|
326
|
-
var _mint = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
409
|
+
var _mint = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6(addr) {
|
|
327
410
|
var amount,
|
|
328
|
-
|
|
329
|
-
return _regeneratorRuntime().wrap(function
|
|
330
|
-
while (1) switch (
|
|
411
|
+
_args6 = arguments;
|
|
412
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
413
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
331
414
|
case 0:
|
|
332
|
-
amount =
|
|
333
|
-
|
|
415
|
+
amount = _args6.length > 1 && _args6[1] !== undefined ? _args6[1] : "1.0";
|
|
416
|
+
_context6.next = 3;
|
|
334
417
|
return this.arweave.api.get("/mint/".concat(addr, "/").concat(this.toWinston(amount)));
|
|
335
418
|
case 3:
|
|
336
|
-
|
|
419
|
+
_context6.next = 5;
|
|
337
420
|
return this.mine();
|
|
338
421
|
case 5:
|
|
339
|
-
|
|
422
|
+
_context6.next = 7;
|
|
340
423
|
return this.balance(addr);
|
|
341
424
|
case 7:
|
|
342
|
-
return
|
|
425
|
+
return _context6.abrupt("return", _context6.sent);
|
|
343
426
|
case 8:
|
|
344
427
|
case "end":
|
|
345
|
-
return
|
|
428
|
+
return _context6.stop();
|
|
346
429
|
}
|
|
347
|
-
},
|
|
430
|
+
}, _callee6, this);
|
|
348
431
|
}));
|
|
349
|
-
function mint(
|
|
432
|
+
function mint(_x4) {
|
|
350
433
|
return _mint.apply(this, arguments);
|
|
351
434
|
}
|
|
352
435
|
return mint;
|
|
@@ -364,39 +447,39 @@ var AR = /*#__PURE__*/function () {
|
|
|
364
447
|
}, {
|
|
365
448
|
key: "toAddr",
|
|
366
449
|
value: function () {
|
|
367
|
-
var _toAddr = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
450
|
+
var _toAddr = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7(jwk) {
|
|
368
451
|
var _yield$this$checkWall2;
|
|
369
|
-
return _regeneratorRuntime().wrap(function
|
|
370
|
-
while (1) switch (
|
|
452
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
453
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
371
454
|
case 0:
|
|
372
455
|
;
|
|
373
|
-
|
|
456
|
+
_context7.next = 3;
|
|
374
457
|
return this.checkWallet({
|
|
375
458
|
jwk: jwk
|
|
376
459
|
});
|
|
377
460
|
case 3:
|
|
378
|
-
_yield$this$checkWall2 =
|
|
461
|
+
_yield$this$checkWall2 = _context7.sent;
|
|
379
462
|
jwk = _yield$this$checkWall2.jwk;
|
|
380
463
|
if (!this.isArConnect(jwk)) {
|
|
381
|
-
|
|
464
|
+
_context7.next = 11;
|
|
382
465
|
break;
|
|
383
466
|
}
|
|
384
|
-
|
|
467
|
+
_context7.next = 8;
|
|
385
468
|
return jwk.getActiveAddress();
|
|
386
469
|
case 8:
|
|
387
|
-
return
|
|
470
|
+
return _context7.abrupt("return", _context7.sent);
|
|
388
471
|
case 11:
|
|
389
|
-
|
|
472
|
+
_context7.next = 13;
|
|
390
473
|
return this.arweave.wallets.jwkToAddress(jwk);
|
|
391
474
|
case 13:
|
|
392
|
-
return
|
|
475
|
+
return _context7.abrupt("return", _context7.sent);
|
|
393
476
|
case 14:
|
|
394
477
|
case "end":
|
|
395
|
-
return
|
|
478
|
+
return _context7.stop();
|
|
396
479
|
}
|
|
397
|
-
},
|
|
480
|
+
}, _callee7, this);
|
|
398
481
|
}));
|
|
399
|
-
function toAddr(
|
|
482
|
+
function toAddr(_x5) {
|
|
400
483
|
return _toAddr.apply(this, arguments);
|
|
401
484
|
}
|
|
402
485
|
return toAddr;
|
|
@@ -404,19 +487,19 @@ var AR = /*#__PURE__*/function () {
|
|
|
404
487
|
}, {
|
|
405
488
|
key: "gen",
|
|
406
489
|
value: function () {
|
|
407
|
-
var _gen = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
490
|
+
var _gen = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee8(amount, overwrite) {
|
|
408
491
|
var jwk, addr, bal;
|
|
409
|
-
return _regeneratorRuntime().wrap(function
|
|
410
|
-
while (1) switch (
|
|
492
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
493
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
411
494
|
case 0:
|
|
412
|
-
|
|
495
|
+
_context8.next = 2;
|
|
413
496
|
return this.arweave.wallets.generate();
|
|
414
497
|
case 2:
|
|
415
|
-
jwk =
|
|
416
|
-
|
|
498
|
+
jwk = _context8.sent;
|
|
499
|
+
_context8.next = 5;
|
|
417
500
|
return this.toAddr(jwk);
|
|
418
501
|
case 5:
|
|
419
|
-
addr =
|
|
502
|
+
addr = _context8.sent;
|
|
420
503
|
if (overwrite === false) {
|
|
421
504
|
this._jwk = jwk;
|
|
422
505
|
} else if (!this.jwk || overwrite) {
|
|
@@ -427,15 +510,15 @@ var AR = /*#__PURE__*/function () {
|
|
|
427
510
|
}
|
|
428
511
|
bal = "0";
|
|
429
512
|
if (!(amount && (0, _utils.isLocalhost)(this.host))) {
|
|
430
|
-
|
|
513
|
+
_context8.next = 12;
|
|
431
514
|
break;
|
|
432
515
|
}
|
|
433
|
-
|
|
516
|
+
_context8.next = 11;
|
|
434
517
|
return this.mint(addr, amount);
|
|
435
518
|
case 11:
|
|
436
|
-
bal =
|
|
519
|
+
bal = _context8.sent;
|
|
437
520
|
case 12:
|
|
438
|
-
return
|
|
521
|
+
return _context8.abrupt("return", {
|
|
439
522
|
jwk: jwk,
|
|
440
523
|
addr: addr,
|
|
441
524
|
pub: jwk.n,
|
|
@@ -443,11 +526,11 @@ var AR = /*#__PURE__*/function () {
|
|
|
443
526
|
});
|
|
444
527
|
case 13:
|
|
445
528
|
case "end":
|
|
446
|
-
return
|
|
529
|
+
return _context8.stop();
|
|
447
530
|
}
|
|
448
|
-
},
|
|
531
|
+
}, _callee8, this);
|
|
449
532
|
}));
|
|
450
|
-
function gen(
|
|
533
|
+
function gen(_x6, _x7) {
|
|
451
534
|
return _gen.apply(this, arguments);
|
|
452
535
|
}
|
|
453
536
|
return gen;
|
|
@@ -455,46 +538,46 @@ var AR = /*#__PURE__*/function () {
|
|
|
455
538
|
}, {
|
|
456
539
|
key: "transfer",
|
|
457
540
|
value: function () {
|
|
458
|
-
var _transfer = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
541
|
+
var _transfer = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee9(ar, target, jwk) {
|
|
459
542
|
var err, _yield$this$checkWall3, tx;
|
|
460
|
-
return _regeneratorRuntime().wrap(function
|
|
461
|
-
while (1) switch (
|
|
543
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
544
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
462
545
|
case 0:
|
|
463
546
|
err = null;
|
|
464
|
-
|
|
547
|
+
_context9.next = 3;
|
|
465
548
|
return this.checkWallet({
|
|
466
549
|
jwk: jwk
|
|
467
550
|
});
|
|
468
551
|
case 3:
|
|
469
|
-
_yield$this$checkWall3 =
|
|
552
|
+
_yield$this$checkWall3 = _context9.sent;
|
|
470
553
|
jwk = _yield$this$checkWall3.jwk;
|
|
471
554
|
err = _yield$this$checkWall3.err;
|
|
472
555
|
if (!err) {
|
|
473
|
-
|
|
556
|
+
_context9.next = 10;
|
|
474
557
|
break;
|
|
475
558
|
}
|
|
476
|
-
return
|
|
559
|
+
return _context9.abrupt("return", {
|
|
477
560
|
err: err
|
|
478
561
|
});
|
|
479
562
|
case 10:
|
|
480
|
-
|
|
563
|
+
_context9.next = 12;
|
|
481
564
|
return this.arweave.createTransaction({
|
|
482
565
|
target: target,
|
|
483
566
|
quantity: this.toWinston(ar)
|
|
484
567
|
});
|
|
485
568
|
case 12:
|
|
486
|
-
tx =
|
|
487
|
-
|
|
569
|
+
tx = _context9.sent;
|
|
570
|
+
_context9.next = 15;
|
|
488
571
|
return this.postTx(tx, jwk);
|
|
489
572
|
case 15:
|
|
490
|
-
return
|
|
573
|
+
return _context9.abrupt("return", _context9.sent);
|
|
491
574
|
case 16:
|
|
492
575
|
case "end":
|
|
493
|
-
return
|
|
576
|
+
return _context9.stop();
|
|
494
577
|
}
|
|
495
|
-
},
|
|
578
|
+
}, _callee9, this);
|
|
496
579
|
}));
|
|
497
|
-
function transfer(
|
|
580
|
+
function transfer(_x8, _x9, _x10) {
|
|
498
581
|
return _transfer.apply(this, arguments);
|
|
499
582
|
}
|
|
500
583
|
return transfer;
|
|
@@ -502,25 +585,25 @@ var AR = /*#__PURE__*/function () {
|
|
|
502
585
|
}, {
|
|
503
586
|
key: "bundle",
|
|
504
587
|
value: function () {
|
|
505
|
-
var _bundle = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
588
|
+
var _bundle = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee10(_items, jwk) {
|
|
506
589
|
var err, _yield$this$checkWall4, signer, items, _bundle2, tx;
|
|
507
|
-
return _regeneratorRuntime().wrap(function
|
|
508
|
-
while (1) switch (
|
|
590
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
591
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
509
592
|
case 0:
|
|
510
593
|
err = null;
|
|
511
|
-
|
|
594
|
+
_context10.next = 3;
|
|
512
595
|
return this.checkWallet({
|
|
513
596
|
jwk: jwk
|
|
514
597
|
});
|
|
515
598
|
case 3:
|
|
516
|
-
_yield$this$checkWall4 =
|
|
599
|
+
_yield$this$checkWall4 = _context10.sent;
|
|
517
600
|
jwk = _yield$this$checkWall4.jwk;
|
|
518
601
|
err = _yield$this$checkWall4.err;
|
|
519
602
|
if (!err) {
|
|
520
|
-
|
|
603
|
+
_context10.next = 10;
|
|
521
604
|
break;
|
|
522
605
|
}
|
|
523
|
-
return
|
|
606
|
+
return _context10.abrupt("return", {
|
|
524
607
|
err: err
|
|
525
608
|
});
|
|
526
609
|
case 10:
|
|
@@ -550,18 +633,18 @@ var AR = /*#__PURE__*/function () {
|
|
|
550
633
|
tags: tags
|
|
551
634
|
}, (_v$ = v[2]) !== null && _v$ !== void 0 ? _v$ : {}));
|
|
552
635
|
});
|
|
553
|
-
|
|
636
|
+
_context10.next = 14;
|
|
554
637
|
return (0, _arbundles.bundleAndSignData)(items, signer);
|
|
555
638
|
case 14:
|
|
556
|
-
_bundle2 =
|
|
557
|
-
|
|
639
|
+
_bundle2 = _context10.sent;
|
|
640
|
+
_context10.next = 17;
|
|
558
641
|
return _bundle2.toTransaction({}, this.arweave, jwk);
|
|
559
642
|
case 17:
|
|
560
|
-
tx =
|
|
561
|
-
|
|
643
|
+
tx = _context10.sent;
|
|
644
|
+
_context10.next = 20;
|
|
562
645
|
return this.postTx(tx, jwk);
|
|
563
646
|
case 20:
|
|
564
|
-
return
|
|
647
|
+
return _context10.abrupt("return", {
|
|
565
648
|
err: err,
|
|
566
649
|
items: items,
|
|
567
650
|
tx: tx,
|
|
@@ -569,11 +652,11 @@ var AR = /*#__PURE__*/function () {
|
|
|
569
652
|
});
|
|
570
653
|
case 21:
|
|
571
654
|
case "end":
|
|
572
|
-
return
|
|
655
|
+
return _context10.stop();
|
|
573
656
|
}
|
|
574
|
-
},
|
|
657
|
+
}, _callee10, this);
|
|
575
658
|
}));
|
|
576
|
-
function bundle(
|
|
659
|
+
function bundle(_x11, _x12) {
|
|
577
660
|
return _bundle.apply(this, arguments);
|
|
578
661
|
}
|
|
579
662
|
return bundle;
|
|
@@ -581,35 +664,35 @@ var AR = /*#__PURE__*/function () {
|
|
|
581
664
|
}, {
|
|
582
665
|
key: "post",
|
|
583
666
|
value: function () {
|
|
584
|
-
var _post = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
585
|
-
var
|
|
586
|
-
return _regeneratorRuntime().wrap(function
|
|
587
|
-
while (1) switch (
|
|
667
|
+
var _post = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee11(_ref4) {
|
|
668
|
+
var _ref4$data, data, _ref4$tags, tags, jwk, err, _yield$this$checkWall5, tx, _tags, _iterator2, _step2, v;
|
|
669
|
+
return _regeneratorRuntime().wrap(function _callee11$(_context11) {
|
|
670
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
588
671
|
case 0:
|
|
589
|
-
|
|
672
|
+
_ref4$data = _ref4.data, data = _ref4$data === void 0 ? "1984" : _ref4$data, _ref4$tags = _ref4.tags, tags = _ref4$tags === void 0 ? {} : _ref4$tags, jwk = _ref4.jwk;
|
|
590
673
|
err = null;
|
|
591
|
-
|
|
674
|
+
_context11.next = 4;
|
|
592
675
|
return this.checkWallet({
|
|
593
676
|
jwk: jwk
|
|
594
677
|
});
|
|
595
678
|
case 4:
|
|
596
|
-
_yield$this$checkWall5 =
|
|
679
|
+
_yield$this$checkWall5 = _context11.sent;
|
|
597
680
|
err = _yield$this$checkWall5.err;
|
|
598
681
|
jwk = _yield$this$checkWall5.jwk;
|
|
599
682
|
if (!err) {
|
|
600
|
-
|
|
683
|
+
_context11.next = 11;
|
|
601
684
|
break;
|
|
602
685
|
}
|
|
603
|
-
return
|
|
686
|
+
return _context11.abrupt("return", {
|
|
604
687
|
err: err
|
|
605
688
|
});
|
|
606
689
|
case 11:
|
|
607
|
-
|
|
690
|
+
_context11.next = 13;
|
|
608
691
|
return this.arweave.createTransaction({
|
|
609
692
|
data: data
|
|
610
693
|
});
|
|
611
694
|
case 13:
|
|
612
|
-
tx =
|
|
695
|
+
tx = _context11.sent;
|
|
613
696
|
_tags = (0, _utils.buildTags)(null, tags);
|
|
614
697
|
_iterator2 = _createForOfIteratorHelper(_tags);
|
|
615
698
|
try {
|
|
@@ -622,14 +705,17 @@ var AR = /*#__PURE__*/function () {
|
|
|
622
705
|
} finally {
|
|
623
706
|
_iterator2.f();
|
|
624
707
|
}
|
|
625
|
-
|
|
626
|
-
|
|
708
|
+
_context11.next = 19;
|
|
709
|
+
return this.postTx(tx, jwk);
|
|
710
|
+
case 19:
|
|
711
|
+
return _context11.abrupt("return", _context11.sent);
|
|
712
|
+
case 20:
|
|
627
713
|
case "end":
|
|
628
|
-
return
|
|
714
|
+
return _context11.stop();
|
|
629
715
|
}
|
|
630
|
-
},
|
|
716
|
+
}, _callee11, this);
|
|
631
717
|
}));
|
|
632
|
-
function post(
|
|
718
|
+
function post(_x13) {
|
|
633
719
|
return _post.apply(this, arguments);
|
|
634
720
|
}
|
|
635
721
|
return post;
|
|
@@ -637,62 +723,62 @@ var AR = /*#__PURE__*/function () {
|
|
|
637
723
|
}, {
|
|
638
724
|
key: "postTx",
|
|
639
725
|
value: function () {
|
|
640
|
-
var _postTx = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
726
|
+
var _postTx = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee12(tx, jwk) {
|
|
641
727
|
var res, err, _yield$this$checkWall6;
|
|
642
|
-
return _regeneratorRuntime().wrap(function
|
|
643
|
-
while (1) switch (
|
|
728
|
+
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
729
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
644
730
|
case 0:
|
|
645
731
|
res = null, err = null;
|
|
646
|
-
|
|
732
|
+
_context12.next = 3;
|
|
647
733
|
return this.checkWallet({
|
|
648
734
|
jwk: jwk
|
|
649
735
|
});
|
|
650
736
|
case 3:
|
|
651
|
-
_yield$this$checkWall6 =
|
|
737
|
+
_yield$this$checkWall6 = _context12.sent;
|
|
652
738
|
err = _yield$this$checkWall6.err;
|
|
653
739
|
jwk = _yield$this$checkWall6.jwk;
|
|
654
740
|
if (err) {
|
|
655
|
-
|
|
741
|
+
_context12.next = 22;
|
|
656
742
|
break;
|
|
657
743
|
}
|
|
658
744
|
if (!this.isArConnect(jwk)) {
|
|
659
|
-
|
|
745
|
+
_context12.next = 13;
|
|
660
746
|
break;
|
|
661
747
|
}
|
|
662
|
-
|
|
748
|
+
_context12.next = 10;
|
|
663
749
|
return jwk.sign(tx);
|
|
664
750
|
case 10:
|
|
665
|
-
tx =
|
|
666
|
-
|
|
751
|
+
tx = _context12.sent;
|
|
752
|
+
_context12.next = 15;
|
|
667
753
|
break;
|
|
668
754
|
case 13:
|
|
669
|
-
|
|
755
|
+
_context12.next = 15;
|
|
670
756
|
return this.arweave.transactions.sign(tx, jwk);
|
|
671
757
|
case 15:
|
|
672
|
-
|
|
758
|
+
_context12.next = 17;
|
|
673
759
|
return this.arweave.transactions.post(tx);
|
|
674
760
|
case 17:
|
|
675
|
-
res =
|
|
761
|
+
res = _context12.sent;
|
|
676
762
|
if (res.status !== 200) err = res.statusText;
|
|
677
763
|
if (!(0, _utils.isLocalhost)(this.host)) {
|
|
678
|
-
|
|
764
|
+
_context12.next = 22;
|
|
679
765
|
break;
|
|
680
766
|
}
|
|
681
|
-
|
|
767
|
+
_context12.next = 22;
|
|
682
768
|
return this.mine();
|
|
683
769
|
case 22:
|
|
684
|
-
return
|
|
770
|
+
return _context12.abrupt("return", {
|
|
685
771
|
res: res,
|
|
686
772
|
err: err,
|
|
687
773
|
id: tx.id
|
|
688
774
|
});
|
|
689
775
|
case 23:
|
|
690
776
|
case "end":
|
|
691
|
-
return
|
|
777
|
+
return _context12.stop();
|
|
692
778
|
}
|
|
693
|
-
},
|
|
779
|
+
}, _callee12, this);
|
|
694
780
|
}));
|
|
695
|
-
function postTx(
|
|
781
|
+
function postTx(_x14, _x15) {
|
|
696
782
|
return _postTx.apply(this, arguments);
|
|
697
783
|
}
|
|
698
784
|
return postTx;
|
|
@@ -700,42 +786,42 @@ var AR = /*#__PURE__*/function () {
|
|
|
700
786
|
}, {
|
|
701
787
|
key: "tx",
|
|
702
788
|
value: function () {
|
|
703
|
-
var _tx = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
789
|
+
var _tx = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee13(txid) {
|
|
704
790
|
var _yield$this$gql$txs$;
|
|
705
|
-
return _regeneratorRuntime().wrap(function
|
|
706
|
-
while (1) switch (
|
|
791
|
+
return _regeneratorRuntime().wrap(function _callee13$(_context13) {
|
|
792
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
707
793
|
case 0:
|
|
708
|
-
|
|
794
|
+
_context13.next = 2;
|
|
709
795
|
return this.gql.txs({
|
|
710
796
|
id: txid
|
|
711
797
|
});
|
|
712
798
|
case 2:
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
if (!
|
|
716
|
-
|
|
799
|
+
_context13.t1 = _yield$this$gql$txs$ = _context13.sent[0];
|
|
800
|
+
_context13.t0 = _context13.t1 !== null;
|
|
801
|
+
if (!_context13.t0) {
|
|
802
|
+
_context13.next = 6;
|
|
717
803
|
break;
|
|
718
804
|
}
|
|
719
|
-
|
|
805
|
+
_context13.t0 = _yield$this$gql$txs$ !== void 0;
|
|
720
806
|
case 6:
|
|
721
|
-
if (!
|
|
722
|
-
|
|
807
|
+
if (!_context13.t0) {
|
|
808
|
+
_context13.next = 10;
|
|
723
809
|
break;
|
|
724
810
|
}
|
|
725
|
-
|
|
726
|
-
|
|
811
|
+
_context13.t2 = _yield$this$gql$txs$;
|
|
812
|
+
_context13.next = 11;
|
|
727
813
|
break;
|
|
728
814
|
case 10:
|
|
729
|
-
|
|
815
|
+
_context13.t2 = null;
|
|
730
816
|
case 11:
|
|
731
|
-
return
|
|
817
|
+
return _context13.abrupt("return", _context13.t2);
|
|
732
818
|
case 12:
|
|
733
819
|
case "end":
|
|
734
|
-
return
|
|
820
|
+
return _context13.stop();
|
|
735
821
|
}
|
|
736
|
-
},
|
|
822
|
+
}, _callee13, this);
|
|
737
823
|
}));
|
|
738
|
-
function tx(
|
|
824
|
+
function tx(_x16) {
|
|
739
825
|
return _tx.apply(this, arguments);
|
|
740
826
|
}
|
|
741
827
|
return tx;
|
|
@@ -743,28 +829,30 @@ var AR = /*#__PURE__*/function () {
|
|
|
743
829
|
}, {
|
|
744
830
|
key: "data",
|
|
745
831
|
value: function () {
|
|
746
|
-
var
|
|
832
|
+
var _data2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee14(txid) {
|
|
747
833
|
var string,
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
834
|
+
_data,
|
|
835
|
+
_args14 = arguments;
|
|
836
|
+
return _regeneratorRuntime().wrap(function _callee14$(_context14) {
|
|
837
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
751
838
|
case 0:
|
|
752
|
-
string =
|
|
753
|
-
|
|
839
|
+
string = _args14.length > 1 && _args14[1] !== undefined ? _args14[1] : false;
|
|
840
|
+
_context14.next = 3;
|
|
754
841
|
return this.arweave.transactions.getData(txid, {
|
|
755
842
|
decode: true,
|
|
756
843
|
string: string
|
|
757
844
|
});
|
|
758
845
|
case 3:
|
|
759
|
-
|
|
760
|
-
|
|
846
|
+
_data = _context14.sent;
|
|
847
|
+
return _context14.abrupt("return", _data);
|
|
848
|
+
case 5:
|
|
761
849
|
case "end":
|
|
762
|
-
return
|
|
850
|
+
return _context14.stop();
|
|
763
851
|
}
|
|
764
|
-
},
|
|
852
|
+
}, _callee14, this);
|
|
765
853
|
}));
|
|
766
|
-
function data(
|
|
767
|
-
return
|
|
854
|
+
function data(_x17) {
|
|
855
|
+
return _data2.apply(this, arguments);
|
|
768
856
|
}
|
|
769
857
|
return data;
|
|
770
858
|
}()
|