wao 0.6.0 → 0.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/ao.js +102 -81
- package/cjs/aoconnect.js +64 -60
- package/cjs/helpers.js +4 -12
- package/cjs/lua/weavedb_mock.lua +43 -0
- package/cjs/server.js +3 -1
- package/cjs/tao.js +3 -1
- package/cjs/utils.js +17 -1
- package/cjs/weavedb.js +447 -0
- package/cjs/weavedrive.js +240 -591
- package/esm/ao.js +25 -13
- package/esm/aoconnect.js +8 -7
- package/esm/helpers.js +4 -12
- package/esm/lua/weavedb_mock.lua +43 -0
- package/esm/server.js +1 -1
- package/esm/tao.js +1 -1
- package/esm/utils.js +14 -0
- package/esm/weavedb.js +309 -0
- package/esm/weavedrive.js +75 -309
- package/package.json +1 -1
package/cjs/weavedrive.js
CHANGED
|
@@ -5,21 +5,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports["default"] = void 0;
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
8
|
+
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; }
|
|
9
|
+
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; }
|
|
10
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
12
11
|
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
|
13
12
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
14
13
|
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
15
14
|
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
|
|
16
|
-
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; }
|
|
17
|
-
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; }
|
|
18
|
-
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
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; }
|
|
20
15
|
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; } } }; }
|
|
21
16
|
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; } }
|
|
22
17
|
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; }
|
|
18
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
23
19
|
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
24
20
|
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
25
21
|
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
@@ -35,133 +31,47 @@ var NOTIFY_SZ = 512 * MB;
|
|
|
35
31
|
var log = console.log;
|
|
36
32
|
var WeaveDrive = exports["default"] = /*#__PURE__*/_createClass(function WeaveDrive(ar) {
|
|
37
33
|
_classCallCheck(this, WeaveDrive);
|
|
38
|
-
this.
|
|
34
|
+
this.ext = function (mod, FS) {
|
|
39
35
|
return {
|
|
40
36
|
reset: function reset(fd) {
|
|
41
37
|
//console.log("WeaveDrive: Resetting fd: ", fd)
|
|
42
38
|
FS.streams[fd].node.position = 0;
|
|
43
39
|
FS.streams[fd].node.cache = new Uint8Array(0);
|
|
44
40
|
},
|
|
45
|
-
|
|
46
|
-
var url = _ref.url,
|
|
47
|
-
path = _ref.path;
|
|
48
|
-
if (!path) return url;
|
|
49
|
-
if (path.startsWith("/")) return this.joinUrl({
|
|
50
|
-
url: url,
|
|
51
|
-
path: path.slice(1)
|
|
52
|
-
});
|
|
53
|
-
url = new URL(url);
|
|
54
|
-
url.pathname += path;
|
|
55
|
-
return url.toString();
|
|
56
|
-
},
|
|
57
|
-
customFetch: function customFetch(path, options) {
|
|
41
|
+
create: function create(id) {
|
|
58
42
|
var _this = this;
|
|
59
43
|
return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
60
|
-
var urlList, p, _iterator, _step, url, res;
|
|
61
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
62
|
-
while (1) switch (_context.prev = _context.next) {
|
|
63
|
-
case 0:
|
|
64
|
-
/**
|
|
65
|
-
* mod.ARWEAVE may be a comma-delimited list of urls.
|
|
66
|
-
* So we parse it into an array that we sequentially consume
|
|
67
|
-
* using fetch, and return the first successful response.
|
|
68
|
-
*
|
|
69
|
-
* The first url is considered "primary". So if all urls fail
|
|
70
|
-
* to produce a successful response, then we return the primary's
|
|
71
|
-
* error response
|
|
72
|
-
*/
|
|
73
|
-
urlList = mod.ARWEAVE.includes(",") ? mod.ARWEAVE.split(",").map(function (url) {
|
|
74
|
-
return url.trim();
|
|
75
|
-
}) : [mod.ARWEAVE];
|
|
76
|
-
_iterator = _createForOfIteratorHelper(urlList);
|
|
77
|
-
_context.prev = 2;
|
|
78
|
-
_iterator.s();
|
|
79
|
-
case 4:
|
|
80
|
-
if ((_step = _iterator.n()).done) {
|
|
81
|
-
_context.next = 14;
|
|
82
|
-
break;
|
|
83
|
-
}
|
|
84
|
-
url = _step.value;
|
|
85
|
-
res = fetch(_this.joinUrl({
|
|
86
|
-
url: url,
|
|
87
|
-
path: path
|
|
88
|
-
}), options);
|
|
89
|
-
_context.next = 9;
|
|
90
|
-
return res.then(function (r) {
|
|
91
|
-
return r.ok;
|
|
92
|
-
})["catch"](function () {
|
|
93
|
-
return false;
|
|
94
|
-
});
|
|
95
|
-
case 9:
|
|
96
|
-
if (!_context.sent) {
|
|
97
|
-
_context.next = 11;
|
|
98
|
-
break;
|
|
99
|
-
}
|
|
100
|
-
return _context.abrupt("return", res);
|
|
101
|
-
case 11:
|
|
102
|
-
if (!p) p = res;
|
|
103
|
-
case 12:
|
|
104
|
-
_context.next = 4;
|
|
105
|
-
break;
|
|
106
|
-
case 14:
|
|
107
|
-
_context.next = 19;
|
|
108
|
-
break;
|
|
109
|
-
case 16:
|
|
110
|
-
_context.prev = 16;
|
|
111
|
-
_context.t0 = _context["catch"](2);
|
|
112
|
-
_iterator.e(_context.t0);
|
|
113
|
-
case 19:
|
|
114
|
-
_context.prev = 19;
|
|
115
|
-
_iterator.f();
|
|
116
|
-
return _context.finish(19);
|
|
117
|
-
case 22:
|
|
118
|
-
return _context.abrupt("return", p);
|
|
119
|
-
case 23:
|
|
120
|
-
case "end":
|
|
121
|
-
return _context.stop();
|
|
122
|
-
}
|
|
123
|
-
}, _callee, null, [[2, 16, 19, 22]]);
|
|
124
|
-
}))();
|
|
125
|
-
},
|
|
126
|
-
create: function create(id) {
|
|
127
|
-
var _this2 = this;
|
|
128
|
-
return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
129
44
|
var _data$length;
|
|
130
45
|
var properties, node, data, bytesLength, stream;
|
|
131
|
-
return _regeneratorRuntime().wrap(function
|
|
132
|
-
while (1) switch (
|
|
46
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
47
|
+
while (1) switch (_context.prev = _context.next) {
|
|
133
48
|
case 0:
|
|
134
49
|
properties = {
|
|
135
50
|
isDevice: false,
|
|
136
51
|
contents: null
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
return
|
|
52
|
+
}; //console.log("WeaveDrive: Arweave ID is not admissable! ", id)
|
|
53
|
+
_context.next = 3;
|
|
54
|
+
return _this.checkAdmissible(id);
|
|
140
55
|
case 3:
|
|
141
|
-
if (
|
|
142
|
-
|
|
56
|
+
if (_context.sent) {
|
|
57
|
+
_context.next = 5;
|
|
143
58
|
break;
|
|
144
59
|
}
|
|
145
|
-
return
|
|
60
|
+
return _context.abrupt("return", 0);
|
|
146
61
|
case 5:
|
|
147
62
|
// Create the file in the emscripten FS
|
|
148
63
|
|
|
149
|
-
|
|
150
|
-
// called first because were only loading Data, we needed to create
|
|
151
|
-
// the directory. See: https://github.com/permaweb/aos/issues/342
|
|
152
|
-
if (!FS.analyzePath("/data/").exists) {
|
|
153
|
-
FS.mkdir("/data/");
|
|
154
|
-
}
|
|
64
|
+
if (!FS.analyzePath("/data/").exists) FS.mkdir("/data/");
|
|
155
65
|
node = FS.createFile("/", "data/" + id, properties, true, false); // Set initial parameters
|
|
156
66
|
/*
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
67
|
+
var bytesLength = await this.customFetch(`/${id}`, {
|
|
68
|
+
method: "HEAD",
|
|
69
|
+
}).then(res => res.headers.get("Content-Length"))
|
|
160
70
|
*/
|
|
161
|
-
|
|
71
|
+
_context.next = 9;
|
|
162
72
|
return ar.data(id);
|
|
163
73
|
case 9:
|
|
164
|
-
data =
|
|
74
|
+
data = _context.sent;
|
|
165
75
|
bytesLength = (_data$length = data === null || data === void 0 ? void 0 : data.length) !== null && _data$length !== void 0 ? _data$length : 0;
|
|
166
76
|
node.total_size = Number(bytesLength);
|
|
167
77
|
node.cache = new Uint8Array(0);
|
|
@@ -178,404 +88,229 @@ var WeaveDrive = exports["default"] = /*#__PURE__*/_createClass(function WeaveDr
|
|
|
178
88
|
|
|
179
89
|
// Now we have created the file in the emscripten FS, we can open it as a stream
|
|
180
90
|
stream = FS.open("/data/" + id, "r"); //console.log("JS: Created file: ", id, " fd: ", stream.fd);
|
|
181
|
-
return
|
|
91
|
+
return _context.abrupt("return", stream);
|
|
182
92
|
case 17:
|
|
183
93
|
case "end":
|
|
184
|
-
return
|
|
94
|
+
return _context.stop();
|
|
185
95
|
}
|
|
186
|
-
},
|
|
96
|
+
}, _callee);
|
|
187
97
|
}))();
|
|
188
98
|
},
|
|
189
99
|
createBlockHeader: function createBlockHeader(id) {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
while (1) switch (_context4.prev = _context4.next) {
|
|
100
|
+
return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
101
|
+
var result, block, node, stream;
|
|
102
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
103
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
195
104
|
case 0:
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
}));
|
|
212
|
-
return _retry.apply(this, arguments);
|
|
213
|
-
};
|
|
214
|
-
retry = function _retry2(_x) {
|
|
215
|
-
return _retry.apply(this, arguments);
|
|
216
|
-
};
|
|
217
|
-
customFetch = _this3.customFetch; // todo: add a bunch of retries
|
|
218
|
-
_context4.next = 5;
|
|
219
|
-
return _this3.customFetch("/block/height/".concat(id)).then(function (res) {
|
|
220
|
-
return !res.ok ? retry(1) : res;
|
|
221
|
-
}).then(function (res) {
|
|
222
|
-
return !res.ok ? retry(2) : res;
|
|
223
|
-
}).then(function (res) {
|
|
224
|
-
return !res.ok ? retry(3) : res;
|
|
225
|
-
}).then(function (res) {
|
|
226
|
-
return !res.ok ? retry(4) : res;
|
|
227
|
-
}).then(function (res) {
|
|
228
|
-
return res.text();
|
|
229
|
-
});
|
|
230
|
-
case 5:
|
|
231
|
-
result = _context4.sent;
|
|
232
|
-
bytesLength = result.length;
|
|
105
|
+
result = "";
|
|
106
|
+
try {
|
|
107
|
+
// todo: implement indep_hash
|
|
108
|
+
// fetch(`/block/height/${id}`)
|
|
109
|
+
block = ar.mem.blockmap[ar.mem.blocks[id]];
|
|
110
|
+
if (block) {
|
|
111
|
+
result = JSON.stringify({
|
|
112
|
+
id: block.id,
|
|
113
|
+
timestamp: block.timestamp,
|
|
114
|
+
previous_block: block.previous,
|
|
115
|
+
txs: block.txs,
|
|
116
|
+
height: id
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
} catch (e) {}
|
|
233
120
|
node = FS.createDataFile("/", "block/" + id, Buffer.from(result, "utf-8"), true, false);
|
|
234
121
|
stream = FS.open("/block/" + id, "r");
|
|
235
|
-
return
|
|
236
|
-
case
|
|
122
|
+
return _context2.abrupt("return", stream);
|
|
123
|
+
case 5:
|
|
237
124
|
case "end":
|
|
238
|
-
return
|
|
125
|
+
return _context2.stop();
|
|
239
126
|
}
|
|
240
|
-
},
|
|
127
|
+
}, _callee2);
|
|
241
128
|
}))();
|
|
242
129
|
},
|
|
243
130
|
createTxHeader: function createTxHeader(id) {
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
while (1) switch (_context8.prev = _context8.next) {
|
|
131
|
+
return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
132
|
+
var result, tx, node, stream;
|
|
133
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
134
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
249
135
|
case 0:
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
return _context7.abrupt("return", new Promise(function (r) {
|
|
256
|
-
setTimeout(function () {
|
|
257
|
-
r(customFetch("/tx/".concat(id)));
|
|
258
|
-
}, x * 10000);
|
|
259
|
-
}));
|
|
260
|
-
case 1:
|
|
261
|
-
case "end":
|
|
262
|
-
return _context7.stop();
|
|
263
|
-
}
|
|
264
|
-
}, _callee7);
|
|
265
|
-
}));
|
|
266
|
-
return _retry4.apply(this, arguments);
|
|
267
|
-
};
|
|
268
|
-
retry = function _retry5(_x3) {
|
|
269
|
-
return _retry4.apply(this, arguments);
|
|
270
|
-
};
|
|
271
|
-
_toAddress = function _toAddress3() {
|
|
272
|
-
_toAddress = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6(owner) {
|
|
273
|
-
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
274
|
-
while (1) switch (_context6.prev = _context6.next) {
|
|
275
|
-
case 0:
|
|
276
|
-
_context6.t0 = _arweave["default"].utils;
|
|
277
|
-
_context6.next = 3;
|
|
278
|
-
return _arweave["default"].crypto.hash(_arweave["default"].utils.b64UrlToBuffer(owner));
|
|
279
|
-
case 3:
|
|
280
|
-
_context6.t1 = _context6.sent;
|
|
281
|
-
return _context6.abrupt("return", _context6.t0.bufferTob64Url.call(_context6.t0, _context6.t1));
|
|
282
|
-
case 5:
|
|
283
|
-
case "end":
|
|
284
|
-
return _context6.stop();
|
|
285
|
-
}
|
|
286
|
-
}, _callee6);
|
|
287
|
-
}));
|
|
288
|
-
return _toAddress.apply(this, arguments);
|
|
289
|
-
};
|
|
290
|
-
toAddress = function _toAddress2(_x2) {
|
|
291
|
-
return _toAddress.apply(this, arguments);
|
|
292
|
-
};
|
|
293
|
-
customFetch = _this4.customFetch; // todo: add a bunch of retries
|
|
294
|
-
_context8.next = 7;
|
|
295
|
-
return _this4.customFetch("/tx/".concat(id)).then(function (res) {
|
|
296
|
-
return !res.ok ? retry(1) : res;
|
|
297
|
-
}).then(function (res) {
|
|
298
|
-
return !res.ok ? retry(2) : res;
|
|
299
|
-
}).then(function (res) {
|
|
300
|
-
return !res.ok ? retry(3) : res;
|
|
301
|
-
}).then(function (res) {
|
|
302
|
-
return !res.ok ? retry(4) : res;
|
|
303
|
-
}).then(function (res) {
|
|
304
|
-
return res.json();
|
|
305
|
-
}).then(/*#__PURE__*/function () {
|
|
306
|
-
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5(entry) {
|
|
307
|
-
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
308
|
-
while (1) switch (_context5.prev = _context5.next) {
|
|
309
|
-
case 0:
|
|
310
|
-
_context5.t0 = _objectSpread;
|
|
311
|
-
_context5.t1 = _objectSpread({}, entry);
|
|
312
|
-
_context5.t2 = {};
|
|
313
|
-
_context5.next = 5;
|
|
314
|
-
return toAddress(entry.owner);
|
|
315
|
-
case 5:
|
|
316
|
-
_context5.t3 = _context5.sent;
|
|
317
|
-
_context5.t4 = {
|
|
318
|
-
ownerAddress: _context5.t3
|
|
319
|
-
};
|
|
320
|
-
return _context5.abrupt("return", (0, _context5.t0)(_context5.t1, _context5.t2, _context5.t4));
|
|
321
|
-
case 8:
|
|
322
|
-
case "end":
|
|
323
|
-
return _context5.stop();
|
|
324
|
-
}
|
|
325
|
-
}, _callee5);
|
|
326
|
-
}));
|
|
327
|
-
return function (_x4) {
|
|
328
|
-
return _ref2.apply(this, arguments);
|
|
329
|
-
};
|
|
330
|
-
}())
|
|
331
|
-
//.then(x => (console.error(x), x))
|
|
332
|
-
.then(function (x) {
|
|
333
|
-
return JSON.stringify(x);
|
|
334
|
-
});
|
|
335
|
-
case 7:
|
|
336
|
-
result = _context8.sent;
|
|
136
|
+
result = ""; // fetch(`/tx/${id}`)
|
|
137
|
+
try {
|
|
138
|
+
tx = ar.mem.txs[id];
|
|
139
|
+
if (tx) result = JSON.stringify(tx);
|
|
140
|
+
} catch (e) {}
|
|
337
141
|
node = FS.createDataFile("/", "tx/" + id, Buffer.from(result, "utf-8"), true, false);
|
|
338
142
|
stream = FS.open("/tx/" + id, "r");
|
|
339
|
-
return
|
|
340
|
-
case
|
|
143
|
+
return _context3.abrupt("return", stream);
|
|
144
|
+
case 5:
|
|
341
145
|
case "end":
|
|
342
|
-
return
|
|
146
|
+
return _context3.stop();
|
|
343
147
|
}
|
|
344
|
-
},
|
|
148
|
+
}, _callee3);
|
|
345
149
|
}))();
|
|
346
150
|
},
|
|
347
151
|
createDataItemTxHeader: function createDataItemTxHeader(id) {
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
while (1) switch (_context11.prev = _context11.next) {
|
|
152
|
+
return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
153
|
+
var result, stream;
|
|
154
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
155
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
353
156
|
case 0:
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
setTimeout(function () {
|
|
361
|
-
r(gqlQuery(GET_TRANSACTION_QUERY, variables));
|
|
362
|
-
}, x * 10000);
|
|
363
|
-
}));
|
|
364
|
-
case 1:
|
|
365
|
-
case "end":
|
|
366
|
-
return _context10.stop();
|
|
367
|
-
}
|
|
368
|
-
}, _callee10);
|
|
369
|
-
}));
|
|
370
|
-
return _retry7.apply(this, arguments);
|
|
371
|
-
};
|
|
372
|
-
retry = function _retry8(_x5) {
|
|
373
|
-
return _retry7.apply(this, arguments);
|
|
374
|
-
};
|
|
375
|
-
gqlQuery = _this5.gqlQuery;
|
|
376
|
-
GET_TRANSACTION_QUERY = "\n query GetTransactions ($transactionIds: [ID!]!) {\n transactions(ids: $transactionIds) {\n edges {\n node {\n id\n anchor\n data {\n size\n }\n signature\n recipient \n owner {\n address \n key\n }\n fee {\n ar \n winston\n }\n quantity {\n winston\n ar\n }\n tags {\n name \n value \n }\n bundledIn {\n id\n }\n block { \n id\n timestamp\n height\n previous\n }\n }\n }\n }\n }";
|
|
377
|
-
variables = {
|
|
378
|
-
transactionIds: [id]
|
|
379
|
-
};
|
|
380
|
-
_context11.next = 7;
|
|
381
|
-
return _this5.gqlExists();
|
|
382
|
-
case 7:
|
|
383
|
-
gqlExists = _context11.sent;
|
|
384
|
-
if (gqlExists) {
|
|
385
|
-
_context11.next = 10;
|
|
386
|
-
break;
|
|
387
|
-
}
|
|
388
|
-
return _context11.abrupt("return", "GQL Not Found!");
|
|
389
|
-
case 10:
|
|
390
|
-
_context11.next = 12;
|
|
391
|
-
return _this5.gqlQuery(GET_TRANSACTION_QUERY, variables).then(function (res) {
|
|
392
|
-
return !res.ok ? retry(1) : res;
|
|
393
|
-
}).then(function (res) {
|
|
394
|
-
return !res.ok ? retry(2) : res;
|
|
395
|
-
}).then(function (res) {
|
|
396
|
-
return !res.ok ? retry(3) : res;
|
|
397
|
-
}).then(function (res) {
|
|
398
|
-
return !res.ok ? retry(4) : res;
|
|
399
|
-
}).then(function (res) {
|
|
400
|
-
return res.json();
|
|
401
|
-
}).then(function (res) {
|
|
402
|
-
var _res$data;
|
|
403
|
-
return res !== null && res !== void 0 && (_res$data = res.data) !== null && _res$data !== void 0 && (_res$data = _res$data.transactions) !== null && _res$data !== void 0 && (_res$data = _res$data.edges) !== null && _res$data !== void 0 && (_res$data = _res$data[0]) !== null && _res$data !== void 0 && _res$data.node ? res.data.transactions.edges[0].node : "No results";
|
|
404
|
-
}).then(/*#__PURE__*/function () {
|
|
405
|
-
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee9(entry) {
|
|
406
|
-
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
407
|
-
while (1) switch (_context9.prev = _context9.next) {
|
|
408
|
-
case 0:
|
|
409
|
-
return _context9.abrupt("return", typeof entry == "string" ? entry : _objectSpread({
|
|
410
|
-
format: 3
|
|
411
|
-
}, entry));
|
|
412
|
-
case 1:
|
|
413
|
-
case "end":
|
|
414
|
-
return _context9.stop();
|
|
415
|
-
}
|
|
416
|
-
}, _callee9);
|
|
417
|
-
}));
|
|
418
|
-
return function (_x6) {
|
|
419
|
-
return _ref3.apply(this, arguments);
|
|
420
|
-
};
|
|
421
|
-
}()).then(function (x) {
|
|
422
|
-
return typeof x == "string" ? x : JSON.stringify(x);
|
|
157
|
+
_context4.next = 2;
|
|
158
|
+
return ar.gql.txs({
|
|
159
|
+
id: id,
|
|
160
|
+
fields: ["id", "anchor", {
|
|
161
|
+
data: ["size"]
|
|
162
|
+
}, "signature", "recipient", "owner", "fee", "quantity", "tags", "bundledIn", "block"]
|
|
423
163
|
});
|
|
424
|
-
case
|
|
425
|
-
result =
|
|
426
|
-
|
|
427
|
-
_context11.next = 15;
|
|
428
|
-
break;
|
|
429
|
-
}
|
|
430
|
-
return _context11.abrupt("return", result);
|
|
431
|
-
case 15:
|
|
164
|
+
case 2:
|
|
165
|
+
result = _context4.sent[0];
|
|
166
|
+
result = result ? JSON.stringify(result) : "No results";
|
|
432
167
|
FS.createDataFile("/", "tx2/" + id, Buffer.from(result, "utf-8"), true, false);
|
|
433
168
|
stream = FS.open("/tx2/" + id, "r");
|
|
434
|
-
return
|
|
435
|
-
case
|
|
169
|
+
return _context4.abrupt("return", stream);
|
|
170
|
+
case 7:
|
|
436
171
|
case "end":
|
|
437
|
-
return
|
|
172
|
+
return _context4.stop();
|
|
438
173
|
}
|
|
439
|
-
},
|
|
174
|
+
}, _callee4);
|
|
440
175
|
}))();
|
|
441
176
|
},
|
|
442
177
|
open: function open(filename) {
|
|
443
|
-
var
|
|
444
|
-
return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
178
|
+
var _this2 = this;
|
|
179
|
+
return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
|
|
445
180
|
var pathCategory, id, stream, _stream, _stream2, _stream3, _stream4;
|
|
446
|
-
return _regeneratorRuntime().wrap(function
|
|
447
|
-
while (1) switch (
|
|
181
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
182
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
448
183
|
case 0:
|
|
449
184
|
pathCategory = filename.split("/")[1];
|
|
450
185
|
id = filename.split("/")[2];
|
|
451
186
|
console.log("JS: Opening ID: ", id);
|
|
452
187
|
if (!(pathCategory === "tx")) {
|
|
453
|
-
|
|
188
|
+
_context5.next = 16;
|
|
454
189
|
break;
|
|
455
190
|
}
|
|
456
191
|
FS.createPath("/", "tx", true, false);
|
|
457
192
|
if (!FS.analyzePath(filename).exists) {
|
|
458
|
-
|
|
193
|
+
_context5.next = 12;
|
|
459
194
|
break;
|
|
460
195
|
}
|
|
461
196
|
stream = FS.open(filename, "r");
|
|
462
197
|
if (!stream.fd) {
|
|
463
|
-
|
|
198
|
+
_context5.next = 9;
|
|
464
199
|
break;
|
|
465
200
|
}
|
|
466
|
-
return
|
|
201
|
+
return _context5.abrupt("return", stream.fd);
|
|
467
202
|
case 9:
|
|
468
|
-
return
|
|
203
|
+
return _context5.abrupt("return", 0);
|
|
469
204
|
case 12:
|
|
470
|
-
|
|
471
|
-
return
|
|
205
|
+
_context5.next = 14;
|
|
206
|
+
return _this2.createTxHeader(id);
|
|
472
207
|
case 14:
|
|
473
|
-
_stream =
|
|
474
|
-
return
|
|
208
|
+
_stream = _context5.sent;
|
|
209
|
+
return _context5.abrupt("return", _stream.fd);
|
|
475
210
|
case 16:
|
|
476
211
|
if (!(pathCategory === "tx2")) {
|
|
477
|
-
|
|
212
|
+
_context5.next = 31;
|
|
478
213
|
break;
|
|
479
214
|
}
|
|
480
215
|
FS.createPath("/", "tx2", true, false);
|
|
481
216
|
if (!FS.analyzePath(filename).exists) {
|
|
482
|
-
|
|
217
|
+
_context5.next = 25;
|
|
483
218
|
break;
|
|
484
219
|
}
|
|
485
220
|
stream = FS.open(filename, "r");
|
|
486
221
|
if (!stream.fd) {
|
|
487
|
-
|
|
222
|
+
_context5.next = 22;
|
|
488
223
|
break;
|
|
489
224
|
}
|
|
490
|
-
return
|
|
225
|
+
return _context5.abrupt("return", stream.fd);
|
|
491
226
|
case 22:
|
|
492
|
-
return
|
|
227
|
+
return _context5.abrupt("return", 0);
|
|
493
228
|
case 25:
|
|
494
|
-
|
|
495
|
-
return
|
|
229
|
+
_context5.next = 27;
|
|
230
|
+
return _this2.createDataItemTxHeader(id);
|
|
496
231
|
case 27:
|
|
497
|
-
_stream2 =
|
|
232
|
+
_stream2 = _context5.sent;
|
|
498
233
|
if (!_stream2.fd) {
|
|
499
|
-
|
|
234
|
+
_context5.next = 30;
|
|
500
235
|
break;
|
|
501
236
|
}
|
|
502
|
-
return
|
|
237
|
+
return _context5.abrupt("return", _stream2.fd);
|
|
503
238
|
case 30:
|
|
504
|
-
return
|
|
239
|
+
return _context5.abrupt("return", 0);
|
|
505
240
|
case 31:
|
|
506
241
|
if (!(pathCategory === "block")) {
|
|
507
|
-
|
|
242
|
+
_context5.next = 44;
|
|
508
243
|
break;
|
|
509
244
|
}
|
|
510
245
|
FS.createPath("/", "block", true, false);
|
|
511
246
|
if (!FS.analyzePath(filename).exists) {
|
|
512
|
-
|
|
247
|
+
_context5.next = 40;
|
|
513
248
|
break;
|
|
514
249
|
}
|
|
515
250
|
stream = FS.open(filename, "r");
|
|
516
251
|
if (!stream.fd) {
|
|
517
|
-
|
|
252
|
+
_context5.next = 37;
|
|
518
253
|
break;
|
|
519
254
|
}
|
|
520
|
-
return
|
|
255
|
+
return _context5.abrupt("return", stream.fd);
|
|
521
256
|
case 37:
|
|
522
|
-
return
|
|
257
|
+
return _context5.abrupt("return", 0);
|
|
523
258
|
case 40:
|
|
524
|
-
|
|
525
|
-
return
|
|
259
|
+
_context5.next = 42;
|
|
260
|
+
return _this2.createBlockHeader(id);
|
|
526
261
|
case 42:
|
|
527
|
-
_stream3 =
|
|
528
|
-
return
|
|
262
|
+
_stream3 = _context5.sent;
|
|
263
|
+
return _context5.abrupt("return", _stream3.fd);
|
|
529
264
|
case 44:
|
|
530
265
|
if (!(pathCategory === "data")) {
|
|
531
|
-
|
|
266
|
+
_context5.next = 59;
|
|
532
267
|
break;
|
|
533
268
|
}
|
|
534
269
|
if (!FS.analyzePath(filename).exists) {
|
|
535
|
-
|
|
270
|
+
_context5.next = 53;
|
|
536
271
|
break;
|
|
537
272
|
}
|
|
538
273
|
stream = FS.open(filename, "r");
|
|
539
274
|
if (!stream.fd) {
|
|
540
|
-
|
|
275
|
+
_context5.next = 49;
|
|
541
276
|
break;
|
|
542
277
|
}
|
|
543
|
-
return
|
|
278
|
+
return _context5.abrupt("return", stream.fd);
|
|
544
279
|
case 49:
|
|
545
280
|
console.log("JS: File not found: ", filename);
|
|
546
|
-
return
|
|
281
|
+
return _context5.abrupt("return", 0);
|
|
547
282
|
case 53:
|
|
548
|
-
|
|
549
|
-
return
|
|
283
|
+
_context5.next = 55;
|
|
284
|
+
return _this2.create(id);
|
|
550
285
|
case 55:
|
|
551
|
-
_stream4 =
|
|
552
|
-
return
|
|
286
|
+
_stream4 = _context5.sent;
|
|
287
|
+
return _context5.abrupt("return", _stream4.fd);
|
|
553
288
|
case 57:
|
|
554
|
-
|
|
289
|
+
_context5.next = 66;
|
|
555
290
|
break;
|
|
556
291
|
case 59:
|
|
557
292
|
if (!(pathCategory === "headers")) {
|
|
558
|
-
|
|
293
|
+
_context5.next = 64;
|
|
559
294
|
break;
|
|
560
295
|
}
|
|
561
296
|
console.log("Header access not implemented yet.");
|
|
562
|
-
return
|
|
297
|
+
return _context5.abrupt("return", 0);
|
|
563
298
|
case 64:
|
|
564
299
|
console.log("JS: Invalid path category: ", pathCategory);
|
|
565
|
-
return
|
|
300
|
+
return _context5.abrupt("return", 0);
|
|
566
301
|
case 66:
|
|
567
302
|
case "end":
|
|
568
|
-
return
|
|
303
|
+
return _context5.stop();
|
|
569
304
|
}
|
|
570
|
-
},
|
|
305
|
+
}, _callee5);
|
|
571
306
|
}))();
|
|
572
307
|
},
|
|
573
308
|
read: function read(fd, raw_dst_ptr, raw_length) {
|
|
574
|
-
var
|
|
575
|
-
return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
309
|
+
var _this3 = this;
|
|
310
|
+
return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
|
|
576
311
|
var to_read, dst_ptr, stream, i, bytes_read, chunk_download_sz, to, data, start, end, chunk, response, reader, bytes_until_cache, bytes_until_notify, downloaded_bytes, cache_chunks, _yield$reader$read, done, chunk_bytes, write_length, chunk_to_cache;
|
|
577
|
-
return _regeneratorRuntime().wrap(function
|
|
578
|
-
while (1) switch (
|
|
312
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
313
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
579
314
|
case 0:
|
|
580
315
|
// Note: The length and dst_ptr are 53 bit integers in JS, so this _should_ be ok into a large memspace.
|
|
581
316
|
to_read = Number(raw_length);
|
|
@@ -588,49 +323,43 @@ var WeaveDrive = exports["default"] = /*#__PURE__*/_createClass(function WeaveDr
|
|
|
588
323
|
}
|
|
589
324
|
// read block headers
|
|
590
325
|
if (!stream.path.includes("/block")) {
|
|
591
|
-
|
|
326
|
+
_context6.next = 7;
|
|
592
327
|
break;
|
|
593
328
|
}
|
|
594
329
|
mod.HEAP8.set(stream.node.contents.subarray(0, to_read), dst_ptr);
|
|
595
|
-
return
|
|
330
|
+
return _context6.abrupt("return", to_read);
|
|
596
331
|
case 7:
|
|
597
332
|
if (!stream.path.includes("/tx")) {
|
|
598
|
-
|
|
333
|
+
_context6.next = 10;
|
|
599
334
|
break;
|
|
600
335
|
}
|
|
601
336
|
mod.HEAP8.set(stream.node.contents.subarray(0, to_read), dst_ptr);
|
|
602
|
-
return
|
|
337
|
+
return _context6.abrupt("return", to_read);
|
|
603
338
|
case 10:
|
|
604
339
|
// Satisfy what we can with the cache first
|
|
605
|
-
bytes_read =
|
|
340
|
+
bytes_read = _this3.readFromCache(stream, dst_ptr, to_read);
|
|
606
341
|
stream.position += bytes_read;
|
|
607
342
|
stream.lastReadPosition = stream.position;
|
|
608
343
|
dst_ptr += bytes_read;
|
|
609
344
|
to_read -= bytes_read;
|
|
610
345
|
|
|
611
346
|
// Return if we have satisfied the request
|
|
347
|
+
|
|
348
|
+
//console.log("WeaveDrive: Satisfied request with cache. Returning...")
|
|
612
349
|
if (!(to_read === 0)) {
|
|
613
|
-
|
|
350
|
+
_context6.next = 17;
|
|
614
351
|
break;
|
|
615
352
|
}
|
|
616
|
-
return
|
|
353
|
+
return _context6.abrupt("return", bytes_read);
|
|
617
354
|
case 17:
|
|
618
355
|
//console.log("WeaveDrive: Read from cache: ", bytes_read, " Remaining to read: ", to_read)
|
|
619
356
|
chunk_download_sz = Math.max(to_read, CACHE_SZ);
|
|
620
357
|
to = Math.min(stream.node.total_size, stream.position + chunk_download_sz); //console.log("WeaveDrive: fd: ", fd, " Read length: ", to_read, " Reading ahead:", to - to_read - stream.position)
|
|
621
|
-
//
|
|
622
|
-
|
|
623
|
-
const response = await this.customFetch(`/${stream.node.name}`, {
|
|
624
|
-
method: "GET",
|
|
625
|
-
redirect: "follow",
|
|
626
|
-
headers: { Range: `bytes=${stream.position}-${to}` },
|
|
627
|
-
})
|
|
628
|
-
const reader = response.body.getReader()
|
|
629
|
-
*/
|
|
630
|
-
_context13.next = 21;
|
|
358
|
+
// fetch(`/${stream.node.name}`)
|
|
359
|
+
_context6.next = 21;
|
|
631
360
|
return ar.data(stream.node.name);
|
|
632
361
|
case 21:
|
|
633
|
-
data =
|
|
362
|
+
data = _context6.sent;
|
|
634
363
|
// Extract the Range header to determine the start and end of the requested chunk
|
|
635
364
|
start = 0;
|
|
636
365
|
end = data.length; // Create a ReadableStream for the requested chunk
|
|
@@ -650,23 +379,23 @@ var WeaveDrive = exports["default"] = /*#__PURE__*/_createClass(function WeaveDr
|
|
|
650
379
|
bytes_until_notify = NOTIFY_SZ;
|
|
651
380
|
downloaded_bytes = 0;
|
|
652
381
|
cache_chunks = [];
|
|
653
|
-
|
|
382
|
+
_context6.prev = 31;
|
|
654
383
|
case 32:
|
|
655
384
|
if (!true) {
|
|
656
|
-
|
|
385
|
+
_context6.next = 50;
|
|
657
386
|
break;
|
|
658
387
|
}
|
|
659
|
-
|
|
388
|
+
_context6.next = 35;
|
|
660
389
|
return reader.read();
|
|
661
390
|
case 35:
|
|
662
|
-
_yield$reader$read =
|
|
391
|
+
_yield$reader$read = _context6.sent;
|
|
663
392
|
done = _yield$reader$read.done;
|
|
664
393
|
chunk_bytes = _yield$reader$read.value;
|
|
665
394
|
if (!done) {
|
|
666
|
-
|
|
395
|
+
_context6.next = 40;
|
|
667
396
|
break;
|
|
668
397
|
}
|
|
669
|
-
return
|
|
398
|
+
return _context6.abrupt("break", 50);
|
|
670
399
|
case 40:
|
|
671
400
|
// Update the number of downloaded bytes to be _all_, not just the write length
|
|
672
401
|
downloaded_bytes += chunk_bytes.length;
|
|
@@ -690,7 +419,7 @@ var WeaveDrive = exports["default"] = /*#__PURE__*/_createClass(function WeaveDr
|
|
|
690
419
|
}
|
|
691
420
|
if (bytes_until_cache <= 0) {
|
|
692
421
|
console.log("WeaveDrive: Chunk size reached. Compressing cache...");
|
|
693
|
-
stream.node.cache =
|
|
422
|
+
stream.node.cache = _this3.addChunksToCache(stream.node.cache, cache_chunks);
|
|
694
423
|
cache_chunks = [];
|
|
695
424
|
bytes_until_cache = CHUNK_SZ;
|
|
696
425
|
}
|
|
@@ -698,40 +427,38 @@ var WeaveDrive = exports["default"] = /*#__PURE__*/_createClass(function WeaveDr
|
|
|
698
427
|
console.log("WeaveDrive: Downloaded: ", downloaded_bytes / stream.node.total_size * 100, "%");
|
|
699
428
|
bytes_until_notify = NOTIFY_SZ;
|
|
700
429
|
}
|
|
701
|
-
|
|
430
|
+
_context6.next = 32;
|
|
702
431
|
break;
|
|
703
432
|
case 50:
|
|
704
|
-
|
|
433
|
+
_context6.next = 55;
|
|
705
434
|
break;
|
|
706
435
|
case 52:
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
console.error("WeaveDrive: Error reading the stream: ",
|
|
436
|
+
_context6.prev = 52;
|
|
437
|
+
_context6.t0 = _context6["catch"](31);
|
|
438
|
+
console.error("WeaveDrive: Error reading the stream: ", _context6.t0);
|
|
710
439
|
case 55:
|
|
711
|
-
|
|
440
|
+
_context6.prev = 55;
|
|
712
441
|
reader.releaseLock();
|
|
713
|
-
return
|
|
442
|
+
return _context6.finish(55);
|
|
714
443
|
case 58:
|
|
715
444
|
// If we have no cache, or we have not satisfied the full request, we need to download the rest
|
|
716
445
|
// Rebuild the cache from the new cache chunks
|
|
717
|
-
stream.node.cache =
|
|
446
|
+
stream.node.cache = _this3.addChunksToCache(stream.node.cache, cache_chunks);
|
|
718
447
|
|
|
719
448
|
// Update the last read position
|
|
720
449
|
stream.lastReadPosition = stream.position;
|
|
721
|
-
return
|
|
450
|
+
return _context6.abrupt("return", bytes_read);
|
|
722
451
|
case 61:
|
|
723
452
|
case "end":
|
|
724
|
-
return
|
|
453
|
+
return _context6.stop();
|
|
725
454
|
}
|
|
726
|
-
},
|
|
455
|
+
}, _callee6, null, [[31, 52, 55, 58]]);
|
|
727
456
|
}))();
|
|
728
457
|
},
|
|
729
458
|
close: function close(fd) {
|
|
730
459
|
var stream = 0;
|
|
731
460
|
for (var i = 0; i < FS.streams.length; i++) {
|
|
732
|
-
if (FS.streams[i].fd === fd)
|
|
733
|
-
stream = FS.streams[i];
|
|
734
|
-
}
|
|
461
|
+
if (FS.streams[i].fd === fd) stream = FS.streams[i];
|
|
735
462
|
}
|
|
736
463
|
FS.close(stream);
|
|
737
464
|
},
|
|
@@ -761,112 +488,148 @@ var WeaveDrive = exports["default"] = /*#__PURE__*/_createClass(function WeaveDr
|
|
|
761
488
|
new_cache.set(old_cache, 0);
|
|
762
489
|
// Load the cache chunks into the new cache
|
|
763
490
|
var current_offset = old_cache.length;
|
|
764
|
-
var
|
|
765
|
-
|
|
491
|
+
var _iterator = _createForOfIteratorHelper(chunks),
|
|
492
|
+
_step;
|
|
766
493
|
try {
|
|
767
|
-
for (
|
|
768
|
-
var chunk =
|
|
494
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
495
|
+
var chunk = _step.value;
|
|
769
496
|
if (current_offset < new_cache_length) {
|
|
770
497
|
new_cache.set(chunk.subarray(0, new_cache_length - current_offset), current_offset);
|
|
771
498
|
current_offset += chunk.length;
|
|
772
499
|
}
|
|
773
500
|
}
|
|
774
501
|
} catch (err) {
|
|
775
|
-
|
|
502
|
+
_iterator.e(err);
|
|
776
503
|
} finally {
|
|
777
|
-
|
|
504
|
+
_iterator.f();
|
|
778
505
|
}
|
|
779
506
|
return new_cache;
|
|
780
507
|
},
|
|
781
508
|
// General helpder functions
|
|
782
509
|
checkAdmissible: function checkAdmissible(ID) {
|
|
783
|
-
var
|
|
784
|
-
return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function
|
|
785
|
-
var bootTag, blockHeight, moduleExtensions, moduleHasWeaveDrive, processExtensions, processHasWeaveDrive, modes, moduleAvailabilityType, moduleMode, processAvailabilityType, processMode, attestors, assignmentsHaveID, individualsHaveID;
|
|
786
|
-
return _regeneratorRuntime().wrap(function
|
|
787
|
-
while (1) switch (
|
|
510
|
+
var _this4 = this;
|
|
511
|
+
return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
|
|
512
|
+
var bootTag, blockHeight, moduleExtensions, moduleHasWeaveDrive, processExtensions, processHasWeaveDrive, modes, moduleAvailabilityType, moduleMode, processAvailabilityType, processMode, attestors, exists, assignmentsHaveID, individualsHaveID;
|
|
513
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
514
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
788
515
|
case 0:
|
|
789
516
|
if (!(mod.mode && mod.mode == "test")) {
|
|
790
|
-
|
|
517
|
+
_context8.next = 2;
|
|
791
518
|
break;
|
|
792
519
|
}
|
|
793
|
-
return
|
|
520
|
+
return _context8.abrupt("return", true);
|
|
794
521
|
case 2:
|
|
795
522
|
// Check if we are attempting to load the On-Boot id, if so allow it
|
|
796
523
|
// this was added for AOP 6 Boot loader See: https://github.com/permaweb/aos/issues/342
|
|
797
|
-
bootTag =
|
|
524
|
+
bootTag = _this4.getTagValue("On-Boot", mod.spawn.tags);
|
|
798
525
|
if (!(bootTag && bootTag === ID)) {
|
|
799
|
-
|
|
526
|
+
_context8.next = 5;
|
|
800
527
|
break;
|
|
801
528
|
}
|
|
802
|
-
return
|
|
529
|
+
return _context8.abrupt("return", true);
|
|
803
530
|
case 5:
|
|
804
531
|
// Check that this module or process set the WeaveDrive tag on spawn
|
|
805
532
|
blockHeight = mod.blockHeight;
|
|
806
|
-
moduleExtensions =
|
|
533
|
+
moduleExtensions = _this4.getTagValues("Extension", mod.module.tags);
|
|
807
534
|
moduleHasWeaveDrive = moduleExtensions.includes("WeaveDrive");
|
|
808
|
-
processExtensions =
|
|
535
|
+
processExtensions = _this4.getTagValues("Extension", mod.spawn.tags);
|
|
809
536
|
processHasWeaveDrive = moduleHasWeaveDrive || processExtensions.includes("WeaveDrive");
|
|
810
537
|
if (processHasWeaveDrive) {
|
|
811
|
-
|
|
538
|
+
_context8.next = 13;
|
|
812
539
|
break;
|
|
813
540
|
}
|
|
814
541
|
console.log("WeaveDrive: Process tried to call WeaveDrive, but extension not set!");
|
|
815
|
-
return
|
|
542
|
+
return _context8.abrupt("return", false);
|
|
816
543
|
case 13:
|
|
817
544
|
modes = ["Assignments", "Individual", "Library"]; // Get the Availability-Type from the spawned process's Module or Process item
|
|
818
545
|
// First check the module for its defaults
|
|
819
|
-
moduleAvailabilityType =
|
|
546
|
+
moduleAvailabilityType = _this4.getTagValue("Availability-Type", mod.module.tags);
|
|
820
547
|
moduleMode = moduleAvailabilityType ? moduleAvailabilityType : "Assignments"; // Default to assignments
|
|
821
548
|
// Now check the process's spawn item. These settings override Module item settings.
|
|
822
|
-
processAvailabilityType =
|
|
549
|
+
processAvailabilityType = _this4.getTagValue("Availability-Type", mod.spawn.tags);
|
|
823
550
|
processMode = processAvailabilityType ? processAvailabilityType : moduleMode;
|
|
824
551
|
if (modes.includes(processMode)) {
|
|
825
|
-
|
|
552
|
+
_context8.next = 20;
|
|
826
553
|
break;
|
|
827
554
|
}
|
|
828
555
|
throw "Unsupported WeaveDrive mode: ".concat(processMode);
|
|
829
556
|
case 20:
|
|
830
|
-
attestors =
|
|
557
|
+
attestors = _this4.serializeStringArr([_this4.getTagValue("Scheduler", mod.spawn.tags)].concat(_toConsumableArray(_this4.getTagValues("Attestor", mod.spawn.tags))).filter(function (t) {
|
|
831
558
|
return !!t;
|
|
832
559
|
})); // Init a set of GraphQL queries to run in order to find a valid attestation
|
|
833
560
|
// Every WeaveDrive process has at least the "Assignments" availability check form.
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
561
|
+
exists = /*#__PURE__*/function () {
|
|
562
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7(tags) {
|
|
563
|
+
var common;
|
|
564
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
565
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
566
|
+
case 0:
|
|
567
|
+
common = {
|
|
568
|
+
owners: attestors,
|
|
569
|
+
block: [0, blockHeight],
|
|
570
|
+
fields: ["tags"]
|
|
571
|
+
};
|
|
572
|
+
_context7.next = 3;
|
|
573
|
+
return ar.gql.txs(_objectSpread(_objectSpread({}, common), {}, {
|
|
574
|
+
tags: tags
|
|
575
|
+
}));
|
|
576
|
+
case 3:
|
|
577
|
+
_context7.t0 = _context7.sent.length;
|
|
578
|
+
return _context7.abrupt("return", _context7.t0 > 0);
|
|
579
|
+
case 5:
|
|
580
|
+
case "end":
|
|
581
|
+
return _context7.stop();
|
|
582
|
+
}
|
|
583
|
+
}, _callee7);
|
|
584
|
+
}));
|
|
585
|
+
return function exists(_x) {
|
|
586
|
+
return _ref.apply(this, arguments);
|
|
587
|
+
};
|
|
588
|
+
}();
|
|
589
|
+
_context8.next = 24;
|
|
590
|
+
return exists({
|
|
591
|
+
Type: "Attestation",
|
|
592
|
+
Message: ID,
|
|
593
|
+
"Data-Protocol": "ao"
|
|
594
|
+
});
|
|
595
|
+
case 24:
|
|
596
|
+
assignmentsHaveID = _context8.sent;
|
|
838
597
|
if (!assignmentsHaveID) {
|
|
839
|
-
|
|
598
|
+
_context8.next = 27;
|
|
840
599
|
break;
|
|
841
600
|
}
|
|
842
|
-
return
|
|
843
|
-
case
|
|
601
|
+
return _context8.abrupt("return", true);
|
|
602
|
+
case 27:
|
|
844
603
|
if (!(processMode == "Individual")) {
|
|
845
|
-
|
|
604
|
+
_context8.next = 33;
|
|
846
605
|
break;
|
|
847
606
|
}
|
|
848
|
-
|
|
849
|
-
return
|
|
850
|
-
|
|
851
|
-
|
|
607
|
+
_context8.next = 30;
|
|
608
|
+
return exists({
|
|
609
|
+
Type: "Available",
|
|
610
|
+
ID: ID,
|
|
611
|
+
"Data-Protocol": "WeaveDrive"
|
|
612
|
+
});
|
|
613
|
+
case 30:
|
|
614
|
+
individualsHaveID = _context8.sent;
|
|
852
615
|
if (!individualsHaveID) {
|
|
853
|
-
|
|
616
|
+
_context8.next = 33;
|
|
854
617
|
break;
|
|
855
618
|
}
|
|
856
|
-
return
|
|
857
|
-
case
|
|
619
|
+
return _context8.abrupt("return", true);
|
|
620
|
+
case 33:
|
|
858
621
|
if (!(processMode == "Library")) {
|
|
859
|
-
|
|
622
|
+
_context8.next = 35;
|
|
860
623
|
break;
|
|
861
624
|
}
|
|
862
625
|
throw "This WeaveDrive implementation does not support Library attestations yet!";
|
|
863
|
-
case 34:
|
|
864
|
-
return _context14.abrupt("return", false);
|
|
865
626
|
case 35:
|
|
627
|
+
return _context8.abrupt("return", false);
|
|
628
|
+
case 36:
|
|
866
629
|
case "end":
|
|
867
|
-
return
|
|
630
|
+
return _context8.stop();
|
|
868
631
|
}
|
|
869
|
-
},
|
|
632
|
+
}, _callee8);
|
|
870
633
|
}))();
|
|
871
634
|
},
|
|
872
635
|
serializeStringArr: function serializeStringArr() {
|
|
@@ -878,127 +641,13 @@ var WeaveDrive = exports["default"] = /*#__PURE__*/_createClass(function WeaveDr
|
|
|
878
641
|
getTagValues: function getTagValues(key, tags) {
|
|
879
642
|
var values = [];
|
|
880
643
|
for (var i = 0; i < tags.length; i++) {
|
|
881
|
-
if (tags[i].name == key)
|
|
882
|
-
values.push(tags[i].value);
|
|
883
|
-
}
|
|
644
|
+
if (tags[i].name == key) values.push(tags[i].value);
|
|
884
645
|
}
|
|
885
646
|
return values;
|
|
886
647
|
},
|
|
887
648
|
getTagValue: function getTagValue(key, tags) {
|
|
888
649
|
var values = this.getTagValues(key, tags);
|
|
889
650
|
return values.pop();
|
|
890
|
-
},
|
|
891
|
-
queryHasResult: function queryHasResult(query, variables) {
|
|
892
|
-
var _this9 = this;
|
|
893
|
-
return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
|
|
894
|
-
var _json$data;
|
|
895
|
-
var json;
|
|
896
|
-
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
897
|
-
while (1) switch (_context15.prev = _context15.next) {
|
|
898
|
-
case 0:
|
|
899
|
-
_context15.next = 2;
|
|
900
|
-
return _this9.gqlQuery(query, variables).then(function (res) {
|
|
901
|
-
return res.json();
|
|
902
|
-
});
|
|
903
|
-
case 2:
|
|
904
|
-
json = _context15.sent;
|
|
905
|
-
return _context15.abrupt("return", !!(json !== null && json !== void 0 && (_json$data = json.data) !== null && _json$data !== void 0 && (_json$data = _json$data.transactions) !== null && _json$data !== void 0 && (_json$data = _json$data.edges) !== null && _json$data !== void 0 && _json$data.length));
|
|
906
|
-
case 4:
|
|
907
|
-
case "end":
|
|
908
|
-
return _context15.stop();
|
|
909
|
-
}
|
|
910
|
-
}, _callee15);
|
|
911
|
-
}))();
|
|
912
|
-
},
|
|
913
|
-
gqlExists: function gqlExists() {
|
|
914
|
-
var _this10 = this;
|
|
915
|
-
return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
|
|
916
|
-
var query, gqlExists;
|
|
917
|
-
return _regeneratorRuntime().wrap(function _callee16$(_context16) {
|
|
918
|
-
while (1) switch (_context16.prev = _context16.next) {
|
|
919
|
-
case 0:
|
|
920
|
-
query = "query {\n transactions(\n first: 1\n ) {\n pageInfo {\n hasNextPage\n }\n }\n }\n ";
|
|
921
|
-
_context16.next = 3;
|
|
922
|
-
return _this10.gqlQuery(query, {}).then(function (res) {
|
|
923
|
-
return res.ok;
|
|
924
|
-
});
|
|
925
|
-
case 3:
|
|
926
|
-
gqlExists = _context16.sent;
|
|
927
|
-
return _context16.abrupt("return", gqlExists);
|
|
928
|
-
case 5:
|
|
929
|
-
case "end":
|
|
930
|
-
return _context16.stop();
|
|
931
|
-
}
|
|
932
|
-
}, _callee16);
|
|
933
|
-
}))();
|
|
934
|
-
},
|
|
935
|
-
gqlQuery: function gqlQuery(query, variables) {
|
|
936
|
-
return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
|
|
937
|
-
var _json, _toGraphObj, tar, args, res2, edges;
|
|
938
|
-
return _regeneratorRuntime().wrap(function _callee17$(_context17) {
|
|
939
|
-
while (1) switch (_context17.prev = _context17.next) {
|
|
940
|
-
case 0:
|
|
941
|
-
_json = null;
|
|
942
|
-
_context17.prev = 1;
|
|
943
|
-
_toGraphObj = (0, _utils.toGraphObj)({
|
|
944
|
-
query: query,
|
|
945
|
-
variables: variables
|
|
946
|
-
}), tar = _toGraphObj.tar, args = _toGraphObj.args;
|
|
947
|
-
res2 = null;
|
|
948
|
-
if (!(tar === "transactions")) {
|
|
949
|
-
_context17.next = 10;
|
|
950
|
-
break;
|
|
951
|
-
}
|
|
952
|
-
_context17.next = 7;
|
|
953
|
-
return ar.gql.txs(_objectSpread({}, args));
|
|
954
|
-
case 7:
|
|
955
|
-
res2 = _context17.sent;
|
|
956
|
-
_context17.next = 14;
|
|
957
|
-
break;
|
|
958
|
-
case 10:
|
|
959
|
-
if (!(tar === "blocks")) {
|
|
960
|
-
_context17.next = 14;
|
|
961
|
-
break;
|
|
962
|
-
}
|
|
963
|
-
_context17.next = 13;
|
|
964
|
-
return ar.gql.blocks(_objectSpread({}, args));
|
|
965
|
-
case 13:
|
|
966
|
-
res2 = _context17.sent;
|
|
967
|
-
case 14:
|
|
968
|
-
edges = (0, _ramda.map)(function (v) {
|
|
969
|
-
return {
|
|
970
|
-
node: v,
|
|
971
|
-
cursor: v.cursor
|
|
972
|
-
};
|
|
973
|
-
}, res2);
|
|
974
|
-
_json = {
|
|
975
|
-
data: {
|
|
976
|
-
transactions: {
|
|
977
|
-
pageInfo: {
|
|
978
|
-
hasNextPage: true
|
|
979
|
-
},
|
|
980
|
-
edges: edges
|
|
981
|
-
}
|
|
982
|
-
}
|
|
983
|
-
};
|
|
984
|
-
_context17.next = 21;
|
|
985
|
-
break;
|
|
986
|
-
case 18:
|
|
987
|
-
_context17.prev = 18;
|
|
988
|
-
_context17.t0 = _context17["catch"](1);
|
|
989
|
-
log(_context17.t0);
|
|
990
|
-
case 21:
|
|
991
|
-
return _context17.abrupt("return", {
|
|
992
|
-
json: function json() {
|
|
993
|
-
return _json;
|
|
994
|
-
}
|
|
995
|
-
});
|
|
996
|
-
case 22:
|
|
997
|
-
case "end":
|
|
998
|
-
return _context17.stop();
|
|
999
|
-
}
|
|
1000
|
-
}, _callee17, null, [[1, 18]]);
|
|
1001
|
-
}))();
|
|
1002
651
|
}
|
|
1003
652
|
};
|
|
1004
653
|
};
|