wao 0.2.3 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/cjs/aoconnect.js CHANGED
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.mu = exports.connect = exports.acc = void 0;
7
+ var _arweave = _interopRequireDefault(require("arweave"));
7
8
  var _warpArbundles = require("warp-arbundles");
8
9
  var _base64url = _interopRequireDefault(require("base64url"));
9
10
  var _aoLoader = _interopRequireDefault(require("@permaweb/ao-loader"));
@@ -13,24 +14,952 @@ var _ramda = require("ramda");
13
14
  var _accounts = _interopRequireDefault(require("./accounts.js"));
14
15
  var _utils = require("./utils.js");
15
16
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
17
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
18
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
19
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
20
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
21
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
22
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
23
+ 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); }
24
+ function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
25
+ 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."); }
26
+ function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
27
+ function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
16
28
  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
29
  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
30
  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
31
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
20
32
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
33
+ function _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
34
  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; } } }; }
22
- function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
23
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
24
35
  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; } }
25
36
  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; }
26
- function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
27
- function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
28
- 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; }
29
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
30
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
31
37
  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); }
32
38
  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); }); }; }
33
- 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); }
39
+ var _txs = {};
40
+ var KB = 1024;
41
+ var MB = KB * 1024;
42
+ var CACHE_SZ = 32 * KB;
43
+ var CHUNK_SZ = 128 * MB;
44
+ var NOTIFY_SZ = 512 * MB;
45
+ function WeaveDrive(mod, FS) {
46
+ return {
47
+ reset: function reset(fd) {
48
+ //console.log("WeaveDrive: Resetting fd: ", fd)
49
+ FS.streams[fd].node.position = 0;
50
+ FS.streams[fd].node.cache = new Uint8Array(0);
51
+ },
52
+ joinUrl: function joinUrl(_ref) {
53
+ var url = _ref.url,
54
+ path = _ref.path;
55
+ if (!path) return url;
56
+ if (path.startsWith("/")) return this.joinUrl({
57
+ url: url,
58
+ path: path.slice(1)
59
+ });
60
+ url = new URL(url);
61
+ url.pathname += path;
62
+ return url.toString();
63
+ },
64
+ customFetch: function customFetch(path, options) {
65
+ var _this = this;
66
+ return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
67
+ var urlList, p, _iterator, _step, url, res;
68
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
69
+ while (1) switch (_context.prev = _context.next) {
70
+ case 0:
71
+ txs[path] = true;
72
+ /**
73
+ * mod.ARWEAVE may be a comma-delimited list of urls.
74
+ * So we parse it into an array that we sequentially consume
75
+ * using fetch, and return the first successful response.
76
+ *
77
+ * The first url is considered "primary". So if all urls fail
78
+ * to produce a successful response, then we return the primary's
79
+ * error response
80
+ */
81
+ urlList = mod.ARWEAVE.includes(",") ? mod.ARWEAVE.split(",").map(function (url) {
82
+ return url.trim();
83
+ }) : [mod.ARWEAVE];
84
+ _iterator = _createForOfIteratorHelper(urlList);
85
+ _context.prev = 3;
86
+ _iterator.s();
87
+ case 5:
88
+ if ((_step = _iterator.n()).done) {
89
+ _context.next = 15;
90
+ break;
91
+ }
92
+ url = _step.value;
93
+ //txs[this.joinUrl({ url, path })] = true
94
+ res = fetch(_this.joinUrl({
95
+ url: url,
96
+ path: path
97
+ }), options);
98
+ _context.next = 10;
99
+ return res.then(function (r) {
100
+ return r.ok;
101
+ })["catch"](function () {
102
+ return false;
103
+ });
104
+ case 10:
105
+ if (!_context.sent) {
106
+ _context.next = 12;
107
+ break;
108
+ }
109
+ return _context.abrupt("return", res);
110
+ case 12:
111
+ if (!p) p = res;
112
+ case 13:
113
+ _context.next = 5;
114
+ break;
115
+ case 15:
116
+ _context.next = 20;
117
+ break;
118
+ case 17:
119
+ _context.prev = 17;
120
+ _context.t0 = _context["catch"](3);
121
+ _iterator.e(_context.t0);
122
+ case 20:
123
+ _context.prev = 20;
124
+ _iterator.f();
125
+ return _context.finish(20);
126
+ case 23:
127
+ return _context.abrupt("return", p);
128
+ case 24:
129
+ case "end":
130
+ return _context.stop();
131
+ }
132
+ }, _callee, null, [[3, 17, 20, 23]]);
133
+ }))();
134
+ },
135
+ create: function create(id) {
136
+ var _this2 = this;
137
+ return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
138
+ var properties, node, bytesLength, stream;
139
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
140
+ while (1) switch (_context2.prev = _context2.next) {
141
+ case 0:
142
+ properties = {
143
+ isDevice: false,
144
+ contents: null
145
+ };
146
+ _context2.next = 3;
147
+ return _this2.checkAdmissible(id);
148
+ case 3:
149
+ if (_context2.sent) {
150
+ _context2.next = 5;
151
+ break;
152
+ }
153
+ return _context2.abrupt("return", 0);
154
+ case 5:
155
+ // Create the file in the emscripten FS
156
+
157
+ // This check/mkdir was added for AOP 6 Boot loader because create is
158
+ // called first because were only loading Data, we needed to create
159
+ // the directory. See: https://github.com/permaweb/aos/issues/342
160
+ if (!FS.analyzePath("/data/").exists) {
161
+ FS.mkdir("/data/");
162
+ }
163
+ node = FS.createFile("/", "data/" + id, properties, true, false); // Set initial parameters
164
+ /*
165
+ var bytesLength = await this.customFetch(`/${id}`, {
166
+ method: "HEAD",
167
+ }).then(res => res.headers.get("Content-Length"))
168
+ */
169
+ bytesLength = _txs[id] ? new TextEncoder().encode(_txs[id]).length : 100;
170
+ node.total_size = Number(bytesLength);
171
+ node.cache = new Uint8Array(0);
172
+ node.position = 0;
173
+
174
+ // Add a function that defers querying the file size until it is asked the first time.
175
+ Object.defineProperties(node, {
176
+ usedBytes: {
177
+ get: function get() {
178
+ return bytesLength;
179
+ }
180
+ }
181
+ });
182
+
183
+ // Now we have created the file in the emscripten FS, we can open it as a stream
184
+ stream = FS.open("/data/" + id, "r"); //console.log("JS: Created file: ", id, " fd: ", stream.fd);
185
+ return _context2.abrupt("return", stream);
186
+ case 14:
187
+ case "end":
188
+ return _context2.stop();
189
+ }
190
+ }, _callee2);
191
+ }))();
192
+ },
193
+ createBlockHeader: function createBlockHeader(id) {
194
+ var _this3 = this;
195
+ return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
196
+ var customFetch, retry, _retry, result, bytesLength, node, stream;
197
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
198
+ while (1) switch (_context4.prev = _context4.next) {
199
+ case 0:
200
+ _retry = function _retry3() {
201
+ _retry = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(x) {
202
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
203
+ while (1) switch (_context3.prev = _context3.next) {
204
+ case 0:
205
+ return _context3.abrupt("return", new Promise(function (r) {
206
+ setTimeout(function () {
207
+ r(customFetch("/block/height/".concat(id)));
208
+ }, x * 10000);
209
+ }));
210
+ case 1:
211
+ case "end":
212
+ return _context3.stop();
213
+ }
214
+ }, _callee3);
215
+ }));
216
+ return _retry.apply(this, arguments);
217
+ };
218
+ retry = function _retry2(_x) {
219
+ return _retry.apply(this, arguments);
220
+ };
221
+ customFetch = _this3.customFetch; // todo: add a bunch of retries
222
+ _context4.next = 5;
223
+ return _this3.customFetch("/block/height/".concat(id)).then(function (res) {
224
+ return !res.ok ? retry(1) : res;
225
+ }).then(function (res) {
226
+ return !res.ok ? retry(2) : res;
227
+ }).then(function (res) {
228
+ return !res.ok ? retry(3) : res;
229
+ }).then(function (res) {
230
+ return !res.ok ? retry(4) : res;
231
+ }).then(function (res) {
232
+ return res.text();
233
+ });
234
+ case 5:
235
+ result = _context4.sent;
236
+ bytesLength = result.length;
237
+ node = FS.createDataFile("/", "block/" + id, Buffer.from(result, "utf-8"), true, false);
238
+ stream = FS.open("/block/" + id, "r");
239
+ return _context4.abrupt("return", stream);
240
+ case 10:
241
+ case "end":
242
+ return _context4.stop();
243
+ }
244
+ }, _callee4);
245
+ }))();
246
+ },
247
+ createTxHeader: function createTxHeader(id) {
248
+ var _this4 = this;
249
+ return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
250
+ var customFetch, toAddress, _toAddress, retry, _retry4, result, node, stream;
251
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
252
+ while (1) switch (_context8.prev = _context8.next) {
253
+ case 0:
254
+ _retry4 = function _retry6() {
255
+ _retry4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7(x) {
256
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
257
+ while (1) switch (_context7.prev = _context7.next) {
258
+ case 0:
259
+ return _context7.abrupt("return", new Promise(function (r) {
260
+ setTimeout(function () {
261
+ r(customFetch("/tx/".concat(id)));
262
+ }, x * 10000);
263
+ }));
264
+ case 1:
265
+ case "end":
266
+ return _context7.stop();
267
+ }
268
+ }, _callee7);
269
+ }));
270
+ return _retry4.apply(this, arguments);
271
+ };
272
+ retry = function _retry5(_x3) {
273
+ return _retry4.apply(this, arguments);
274
+ };
275
+ _toAddress = function _toAddress3() {
276
+ _toAddress = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6(owner) {
277
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
278
+ while (1) switch (_context6.prev = _context6.next) {
279
+ case 0:
280
+ _context6.t0 = _arweave["default"].utils;
281
+ _context6.next = 3;
282
+ return _arweave["default"].crypto.hash(_arweave["default"].utils.b64UrlToBuffer(owner));
283
+ case 3:
284
+ _context6.t1 = _context6.sent;
285
+ return _context6.abrupt("return", _context6.t0.bufferTob64Url.call(_context6.t0, _context6.t1));
286
+ case 5:
287
+ case "end":
288
+ return _context6.stop();
289
+ }
290
+ }, _callee6);
291
+ }));
292
+ return _toAddress.apply(this, arguments);
293
+ };
294
+ toAddress = function _toAddress2(_x2) {
295
+ return _toAddress.apply(this, arguments);
296
+ };
297
+ customFetch = _this4.customFetch; // todo: add a bunch of retries
298
+ _context8.next = 7;
299
+ return _this4.customFetch("/tx/".concat(id)).then(function (res) {
300
+ return !res.ok ? retry(1) : res;
301
+ }).then(function (res) {
302
+ return !res.ok ? retry(2) : res;
303
+ }).then(function (res) {
304
+ return !res.ok ? retry(3) : res;
305
+ }).then(function (res) {
306
+ return !res.ok ? retry(4) : res;
307
+ }).then(function (res) {
308
+ return res.json();
309
+ }).then(/*#__PURE__*/function () {
310
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5(entry) {
311
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
312
+ while (1) switch (_context5.prev = _context5.next) {
313
+ case 0:
314
+ _context5.t0 = _objectSpread;
315
+ _context5.t1 = _objectSpread({}, entry);
316
+ _context5.t2 = {};
317
+ _context5.next = 5;
318
+ return toAddress(entry.owner);
319
+ case 5:
320
+ _context5.t3 = _context5.sent;
321
+ _context5.t4 = {
322
+ ownerAddress: _context5.t3
323
+ };
324
+ return _context5.abrupt("return", (0, _context5.t0)(_context5.t1, _context5.t2, _context5.t4));
325
+ case 8:
326
+ case "end":
327
+ return _context5.stop();
328
+ }
329
+ }, _callee5);
330
+ }));
331
+ return function (_x4) {
332
+ return _ref2.apply(this, arguments);
333
+ };
334
+ }())
335
+ //.then(x => (console.error(x), x))
336
+ .then(function (x) {
337
+ return JSON.stringify(x);
338
+ });
339
+ case 7:
340
+ result = _context8.sent;
341
+ node = FS.createDataFile("/", "tx/" + id, Buffer.from(result, "utf-8"), true, false);
342
+ stream = FS.open("/tx/" + id, "r");
343
+ return _context8.abrupt("return", stream);
344
+ case 11:
345
+ case "end":
346
+ return _context8.stop();
347
+ }
348
+ }, _callee8);
349
+ }))();
350
+ },
351
+ createDataItemTxHeader: function createDataItemTxHeader(id) {
352
+ var _this5 = this;
353
+ return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
354
+ var gqlQuery, GET_TRANSACTION_QUERY, variables, retry, _retry7, gqlExists, result, stream;
355
+ return _regeneratorRuntime().wrap(function _callee11$(_context11) {
356
+ while (1) switch (_context11.prev = _context11.next) {
357
+ case 0:
358
+ _retry7 = function _retry9() {
359
+ _retry7 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee10(x) {
360
+ return _regeneratorRuntime().wrap(function _callee10$(_context10) {
361
+ while (1) switch (_context10.prev = _context10.next) {
362
+ case 0:
363
+ return _context10.abrupt("return", new Promise(function (r) {
364
+ setTimeout(function () {
365
+ r(gqlQuery(GET_TRANSACTION_QUERY, variables));
366
+ }, x * 10000);
367
+ }));
368
+ case 1:
369
+ case "end":
370
+ return _context10.stop();
371
+ }
372
+ }, _callee10);
373
+ }));
374
+ return _retry7.apply(this, arguments);
375
+ };
376
+ retry = function _retry8(_x5) {
377
+ return _retry7.apply(this, arguments);
378
+ };
379
+ gqlQuery = _this5.gqlQuery;
380
+ 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 }";
381
+ variables = {
382
+ transactionIds: [id]
383
+ };
384
+ _context11.next = 7;
385
+ return _this5.gqlExists();
386
+ case 7:
387
+ gqlExists = _context11.sent;
388
+ if (gqlExists) {
389
+ _context11.next = 10;
390
+ break;
391
+ }
392
+ return _context11.abrupt("return", "GQL Not Found!");
393
+ case 10:
394
+ _context11.next = 12;
395
+ return _this5.gqlQuery(GET_TRANSACTION_QUERY, variables).then(function (res) {
396
+ return !res.ok ? retry(1) : res;
397
+ }).then(function (res) {
398
+ return !res.ok ? retry(2) : res;
399
+ }).then(function (res) {
400
+ return !res.ok ? retry(3) : res;
401
+ }).then(function (res) {
402
+ return !res.ok ? retry(4) : res;
403
+ }).then(function (res) {
404
+ return res.json();
405
+ }).then(function (res) {
406
+ var _res$data;
407
+ 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";
408
+ }).then(/*#__PURE__*/function () {
409
+ var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee9(entry) {
410
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
411
+ while (1) switch (_context9.prev = _context9.next) {
412
+ case 0:
413
+ return _context9.abrupt("return", typeof entry == "string" ? entry : _objectSpread({
414
+ format: 3
415
+ }, entry));
416
+ case 1:
417
+ case "end":
418
+ return _context9.stop();
419
+ }
420
+ }, _callee9);
421
+ }));
422
+ return function (_x6) {
423
+ return _ref3.apply(this, arguments);
424
+ };
425
+ }()).then(function (x) {
426
+ return typeof x == "string" ? x : JSON.stringify(x);
427
+ });
428
+ case 12:
429
+ result = _context11.sent;
430
+ if (!(result === "No results")) {
431
+ _context11.next = 15;
432
+ break;
433
+ }
434
+ return _context11.abrupt("return", result);
435
+ case 15:
436
+ FS.createDataFile("/", "tx2/" + id, Buffer.from(result, "utf-8"), true, false);
437
+ stream = FS.open("/tx2/" + id, "r");
438
+ return _context11.abrupt("return", stream);
439
+ case 18:
440
+ case "end":
441
+ return _context11.stop();
442
+ }
443
+ }, _callee11);
444
+ }))();
445
+ },
446
+ open: function open(filename) {
447
+ var _this6 = this;
448
+ return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee12() {
449
+ var pathCategory, id, stream, _stream, _stream2, _stream3, _stream4;
450
+ return _regeneratorRuntime().wrap(function _callee12$(_context12) {
451
+ while (1) switch (_context12.prev = _context12.next) {
452
+ case 0:
453
+ pathCategory = filename.split("/")[1];
454
+ id = filename.split("/")[2];
455
+ console.log("JS: Opening ID: ", id);
456
+ if (!(pathCategory === "tx")) {
457
+ _context12.next = 16;
458
+ break;
459
+ }
460
+ FS.createPath("/", "tx", true, false);
461
+ if (!FS.analyzePath(filename).exists) {
462
+ _context12.next = 12;
463
+ break;
464
+ }
465
+ stream = FS.open(filename, "r");
466
+ if (!stream.fd) {
467
+ _context12.next = 9;
468
+ break;
469
+ }
470
+ return _context12.abrupt("return", stream.fd);
471
+ case 9:
472
+ return _context12.abrupt("return", 0);
473
+ case 12:
474
+ _context12.next = 14;
475
+ return _this6.createTxHeader(id);
476
+ case 14:
477
+ _stream = _context12.sent;
478
+ return _context12.abrupt("return", _stream.fd);
479
+ case 16:
480
+ if (!(pathCategory === "tx2")) {
481
+ _context12.next = 31;
482
+ break;
483
+ }
484
+ FS.createPath("/", "tx2", true, false);
485
+ if (!FS.analyzePath(filename).exists) {
486
+ _context12.next = 25;
487
+ break;
488
+ }
489
+ stream = FS.open(filename, "r");
490
+ if (!stream.fd) {
491
+ _context12.next = 22;
492
+ break;
493
+ }
494
+ return _context12.abrupt("return", stream.fd);
495
+ case 22:
496
+ return _context12.abrupt("return", 0);
497
+ case 25:
498
+ _context12.next = 27;
499
+ return _this6.createDataItemTxHeader(id);
500
+ case 27:
501
+ _stream2 = _context12.sent;
502
+ if (!_stream2.fd) {
503
+ _context12.next = 30;
504
+ break;
505
+ }
506
+ return _context12.abrupt("return", _stream2.fd);
507
+ case 30:
508
+ return _context12.abrupt("return", 0);
509
+ case 31:
510
+ if (!(pathCategory === "block")) {
511
+ _context12.next = 44;
512
+ break;
513
+ }
514
+ FS.createPath("/", "block", true, false);
515
+ if (!FS.analyzePath(filename).exists) {
516
+ _context12.next = 40;
517
+ break;
518
+ }
519
+ stream = FS.open(filename, "r");
520
+ if (!stream.fd) {
521
+ _context12.next = 37;
522
+ break;
523
+ }
524
+ return _context12.abrupt("return", stream.fd);
525
+ case 37:
526
+ return _context12.abrupt("return", 0);
527
+ case 40:
528
+ _context12.next = 42;
529
+ return _this6.createBlockHeader(id);
530
+ case 42:
531
+ _stream3 = _context12.sent;
532
+ return _context12.abrupt("return", _stream3.fd);
533
+ case 44:
534
+ if (!(pathCategory === "data")) {
535
+ _context12.next = 59;
536
+ break;
537
+ }
538
+ if (!FS.analyzePath(filename).exists) {
539
+ _context12.next = 53;
540
+ break;
541
+ }
542
+ stream = FS.open(filename, "r");
543
+ if (!stream.fd) {
544
+ _context12.next = 49;
545
+ break;
546
+ }
547
+ return _context12.abrupt("return", stream.fd);
548
+ case 49:
549
+ console.log("JS: File not found: ", filename);
550
+ return _context12.abrupt("return", 0);
551
+ case 53:
552
+ _context12.next = 55;
553
+ return _this6.create(id);
554
+ case 55:
555
+ _stream4 = _context12.sent;
556
+ return _context12.abrupt("return", _stream4.fd);
557
+ case 57:
558
+ _context12.next = 66;
559
+ break;
560
+ case 59:
561
+ if (!(pathCategory === "headers")) {
562
+ _context12.next = 64;
563
+ break;
564
+ }
565
+ console.log("Header access not implemented yet.");
566
+ return _context12.abrupt("return", 0);
567
+ case 64:
568
+ console.log("JS: Invalid path category: ", pathCategory);
569
+ return _context12.abrupt("return", 0);
570
+ case 66:
571
+ case "end":
572
+ return _context12.stop();
573
+ }
574
+ }, _callee12);
575
+ }))();
576
+ },
577
+ read: function read(fd, raw_dst_ptr, raw_length) {
578
+ var _this7 = this;
579
+ return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee13() {
580
+ var _txs$stream$node$name;
581
+ 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;
582
+ return _regeneratorRuntime().wrap(function _callee13$(_context13) {
583
+ while (1) switch (_context13.prev = _context13.next) {
584
+ case 0:
585
+ // Note: The length and dst_ptr are 53 bit integers in JS, so this _should_ be ok into a large memspace.
586
+ to_read = Number(raw_length);
587
+ dst_ptr = Number(raw_dst_ptr);
588
+ stream = 0;
589
+ for (i = 0; i < FS.streams.length; i++) {
590
+ if (FS.streams[i].fd === fd) {
591
+ stream = FS.streams[i];
592
+ }
593
+ }
594
+ // read block headers
595
+ if (!stream.path.includes("/block")) {
596
+ _context13.next = 7;
597
+ break;
598
+ }
599
+ mod.HEAP8.set(stream.node.contents.subarray(0, to_read), dst_ptr);
600
+ return _context13.abrupt("return", to_read);
601
+ case 7:
602
+ if (!stream.path.includes("/tx")) {
603
+ _context13.next = 10;
604
+ break;
605
+ }
606
+ mod.HEAP8.set(stream.node.contents.subarray(0, to_read), dst_ptr);
607
+ return _context13.abrupt("return", to_read);
608
+ case 10:
609
+ // Satisfy what we can with the cache first
610
+ bytes_read = _this7.readFromCache(stream, dst_ptr, to_read);
611
+ stream.position += bytes_read;
612
+ stream.lastReadPosition = stream.position;
613
+ dst_ptr += bytes_read;
614
+ to_read -= bytes_read;
615
+
616
+ // Return if we have satisfied the request
617
+ if (!(to_read === 0)) {
618
+ _context13.next = 17;
619
+ break;
620
+ }
621
+ return _context13.abrupt("return", bytes_read);
622
+ case 17:
623
+ //console.log("WeaveDrive: Read from cache: ", bytes_read, " Remaining to read: ", to_read)
624
+ chunk_download_sz = Math.max(to_read, CACHE_SZ);
625
+ 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)
626
+ // Fetch with streaming
627
+ /*
628
+ const response = await this.customFetch(`/${stream.node.name}`, {
629
+ method: "GET",
630
+ redirect: "follow",
631
+ headers: { Range: `bytes=${stream.position}-${to}` },
632
+ })
633
+ const reader = response.body.getReader()
634
+ */
635
+ data = new TextEncoder().encode((_txs$stream$node$name = _txs[stream.node.name]) !== null && _txs$stream$node$name !== void 0 ? _txs$stream$node$name : ""); // Extract the Range header to determine the start and end of the requested chunk
636
+ start = 0;
637
+ end = data.length; // Create a ReadableStream for the requested chunk
638
+ chunk = data.subarray(start, end);
639
+ response = new Response(new ReadableStream({
640
+ start: function start(controller) {
641
+ controller.enqueue(chunk); // Push the chunk to the stream
642
+ controller.close(); // Close the stream when done
643
+ }
644
+ }), {
645
+ headers: {
646
+ "Content-Length": chunk.length.toString()
647
+ }
648
+ });
649
+ reader = response.body.getReader();
650
+ bytes_until_cache = CHUNK_SZ;
651
+ bytes_until_notify = NOTIFY_SZ;
652
+ downloaded_bytes = 0;
653
+ cache_chunks = [];
654
+ _context13.prev = 29;
655
+ case 30:
656
+ if (!true) {
657
+ _context13.next = 48;
658
+ break;
659
+ }
660
+ _context13.next = 33;
661
+ return reader.read();
662
+ case 33:
663
+ _yield$reader$read = _context13.sent;
664
+ done = _yield$reader$read.done;
665
+ chunk_bytes = _yield$reader$read.value;
666
+ if (!done) {
667
+ _context13.next = 38;
668
+ break;
669
+ }
670
+ return _context13.abrupt("break", 48);
671
+ case 38:
672
+ // Update the number of downloaded bytes to be _all_, not just the write length
673
+ downloaded_bytes += chunk_bytes.length;
674
+ bytes_until_cache -= chunk_bytes.length;
675
+ bytes_until_notify -= chunk_bytes.length;
676
+
677
+ // Write bytes from the chunk and update the pointer if necessary
678
+ write_length = Math.min(chunk_bytes.length, to_read);
679
+ if (write_length > 0) {
680
+ //console.log("WeaveDrive: Writing: ", write_length, " bytes to: ", dst_ptr)
681
+ mod.HEAP8.set(chunk_bytes.subarray(0, write_length), dst_ptr);
682
+ dst_ptr += write_length;
683
+ bytes_read += write_length;
684
+ stream.position += write_length;
685
+ to_read -= write_length;
686
+ }
687
+ if (to_read == 0) {
688
+ // Add excess bytes to our cache
689
+ chunk_to_cache = chunk_bytes.subarray(write_length); //console.log("WeaveDrive: Cacheing excess: ", chunk_to_cache.length)
690
+ cache_chunks.push(chunk_to_cache);
691
+ }
692
+ if (bytes_until_cache <= 0) {
693
+ console.log("WeaveDrive: Chunk size reached. Compressing cache...");
694
+ stream.node.cache = _this7.addChunksToCache(stream.node.cache, cache_chunks);
695
+ cache_chunks = [];
696
+ bytes_until_cache = CHUNK_SZ;
697
+ }
698
+ if (bytes_until_notify <= 0) {
699
+ console.log("WeaveDrive: Downloaded: ", downloaded_bytes / stream.node.total_size * 100, "%");
700
+ bytes_until_notify = NOTIFY_SZ;
701
+ }
702
+ _context13.next = 30;
703
+ break;
704
+ case 48:
705
+ _context13.next = 53;
706
+ break;
707
+ case 50:
708
+ _context13.prev = 50;
709
+ _context13.t0 = _context13["catch"](29);
710
+ console.error("WeaveDrive: Error reading the stream: ", _context13.t0);
711
+ case 53:
712
+ _context13.prev = 53;
713
+ reader.releaseLock();
714
+ return _context13.finish(53);
715
+ case 56:
716
+ // If we have no cache, or we have not satisfied the full request, we need to download the rest
717
+ // Rebuild the cache from the new cache chunks
718
+ stream.node.cache = _this7.addChunksToCache(stream.node.cache, cache_chunks);
719
+
720
+ // Update the last read position
721
+ stream.lastReadPosition = stream.position;
722
+ return _context13.abrupt("return", bytes_read);
723
+ case 59:
724
+ case "end":
725
+ return _context13.stop();
726
+ }
727
+ }, _callee13, null, [[29, 50, 53, 56]]);
728
+ }))();
729
+ },
730
+ close: function close(fd) {
731
+ var stream = 0;
732
+ for (var i = 0; i < FS.streams.length; i++) {
733
+ if (FS.streams[i].fd === fd) {
734
+ stream = FS.streams[i];
735
+ }
736
+ }
737
+ FS.close(stream);
738
+ },
739
+ // Readahead cache functions
740
+ readFromCache: function readFromCache(stream, dst_ptr, length) {
741
+ // Check if the cache has been invalidated by a seek
742
+ if (stream.lastReadPosition !== stream.position) {
743
+ //console.log("WeaveDrive: Invalidating cache for fd: ", stream.fd, " Current pos: ", stream.position, " Last read pos: ", stream.lastReadPosition)
744
+ stream.node.cache = new Uint8Array(0);
745
+ return 0;
746
+ }
747
+ // Calculate the bytes of the request that can be satisfied with the cache
748
+ var cache_part_length = Math.min(length, stream.node.cache.length);
749
+ var cache_part = stream.node.cache.subarray(0, cache_part_length);
750
+ mod.HEAP8.set(cache_part, dst_ptr);
751
+ // Set the new cache to the remainder of the unused cache and update pointers
752
+ stream.node.cache = stream.node.cache.subarray(cache_part_length);
753
+ return cache_part_length;
754
+ },
755
+ addChunksToCache: function addChunksToCache(old_cache, chunks) {
756
+ // Make a new cache array of the old cache length + the sum of the chunk lengths, capped by the max cache size
757
+ var new_cache_length = Math.min(old_cache.length + chunks.reduce(function (acc, chunk) {
758
+ return acc + chunk.length;
759
+ }, 0), CACHE_SZ);
760
+ var new_cache = new Uint8Array(new_cache_length);
761
+ // Copy the old cache to the new cache
762
+ new_cache.set(old_cache, 0);
763
+ // Load the cache chunks into the new cache
764
+ var current_offset = old_cache.length;
765
+ var _iterator2 = _createForOfIteratorHelper(chunks),
766
+ _step2;
767
+ try {
768
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
769
+ var chunk = _step2.value;
770
+ if (current_offset < new_cache_length) {
771
+ new_cache.set(chunk.subarray(0, new_cache_length - current_offset), current_offset);
772
+ current_offset += chunk.length;
773
+ }
774
+ }
775
+ } catch (err) {
776
+ _iterator2.e(err);
777
+ } finally {
778
+ _iterator2.f();
779
+ }
780
+ return new_cache;
781
+ },
782
+ // General helpder functions
783
+ checkAdmissible: function checkAdmissible(ID) {
784
+ var _this8 = this;
785
+ return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee14() {
786
+ var bootTag, blockHeight, moduleExtensions, moduleHasWeaveDrive, processExtensions, processHasWeaveDrive, modes, moduleAvailabilityType, moduleMode, processAvailabilityType, processMode, attestors, assignmentsHaveID, individualsHaveID;
787
+ return _regeneratorRuntime().wrap(function _callee14$(_context14) {
788
+ while (1) switch (_context14.prev = _context14.next) {
789
+ case 0:
790
+ if (!(mod.mode && mod.mode == "test")) {
791
+ _context14.next = 2;
792
+ break;
793
+ }
794
+ return _context14.abrupt("return", true);
795
+ case 2:
796
+ // Check if we are attempting to load the On-Boot id, if so allow it
797
+ // this was added for AOP 6 Boot loader See: https://github.com/permaweb/aos/issues/342
798
+ bootTag = _this8.getTagValue("On-Boot", mod.spawn.tags);
799
+ if (!(bootTag && bootTag === ID)) {
800
+ _context14.next = 5;
801
+ break;
802
+ }
803
+ return _context14.abrupt("return", true);
804
+ case 5:
805
+ // Check that this module or process set the WeaveDrive tag on spawn
806
+ blockHeight = mod.blockHeight;
807
+ moduleExtensions = _this8.getTagValues("Extension", mod.module.tags);
808
+ moduleHasWeaveDrive = moduleExtensions.includes("WeaveDrive");
809
+ processExtensions = _this8.getTagValues("Extension", mod.spawn.tags);
810
+ processHasWeaveDrive = moduleHasWeaveDrive || processExtensions.includes("WeaveDrive");
811
+ if (processHasWeaveDrive) {
812
+ _context14.next = 13;
813
+ break;
814
+ }
815
+ console.log("WeaveDrive: Process tried to call WeaveDrive, but extension not set!");
816
+ return _context14.abrupt("return", false);
817
+ case 13:
818
+ modes = ["Assignments", "Individual", "Library"]; // Get the Availability-Type from the spawned process's Module or Process item
819
+ // First check the module for its defaults
820
+ moduleAvailabilityType = _this8.getTagValue("Availability-Type", mod.module.tags);
821
+ moduleMode = moduleAvailabilityType ? moduleAvailabilityType : "Assignments"; // Default to assignments
822
+ // Now check the process's spawn item. These settings override Module item settings.
823
+ processAvailabilityType = _this8.getTagValue("Availability-Type", mod.spawn.tags);
824
+ processMode = processAvailabilityType ? processAvailabilityType : moduleMode;
825
+ if (modes.includes(processMode)) {
826
+ _context14.next = 20;
827
+ break;
828
+ }
829
+ throw "Unsupported WeaveDrive mode: ".concat(processMode);
830
+ case 20:
831
+ attestors = _this8.serializeStringArr([_this8.getTagValue("Scheduler", mod.spawn.tags)].concat(_toConsumableArray(_this8.getTagValues("Attestor", mod.spawn.tags))).filter(function (t) {
832
+ return !!t;
833
+ })); // Init a set of GraphQL queries to run in order to find a valid attestation
834
+ // Every WeaveDrive process has at least the "Assignments" availability check form.
835
+ _context14.next = 23;
836
+ return _this8.queryHasResult("query {\n transactions(\n owners: ".concat(attestors, ",\n block: {min: 0, max: ").concat(blockHeight, "},\n tags: [\n { name: \"Type\", values: [\"Attestation\"] },\n { name: \"Message\", values: [\"").concat(ID, "\"]}\n { name: \"Data-Protocol\", values: [\"ao\"] },\n ]\n ) \n {\n edges {\n node {\n tags {\n name\n value\n }\n }\n }\n }\n }"));
837
+ case 23:
838
+ assignmentsHaveID = _context14.sent;
839
+ if (!assignmentsHaveID) {
840
+ _context14.next = 26;
841
+ break;
842
+ }
843
+ return _context14.abrupt("return", true);
844
+ case 26:
845
+ if (!(processMode == "Individual")) {
846
+ _context14.next = 32;
847
+ break;
848
+ }
849
+ _context14.next = 29;
850
+ return _this8.queryHasResult("query {\n transactions(\n owners: ".concat(attestors, ",\n block: {min: 0, max: ").concat(blockHeight, "},\n tags: [\n { name: \"Type\", values: [\"Available\"]},\n { name: \"ID\", values: [\"").concat(ID, "\"]}\n { name: \"Data-Protocol\", values: [\"WeaveDrive\"] },\n ]\n ) \n {\n edges {\n node {\n tags {\n name\n value\n }\n }\n }\n }\n }"));
851
+ case 29:
852
+ individualsHaveID = _context14.sent;
853
+ if (!individualsHaveID) {
854
+ _context14.next = 32;
855
+ break;
856
+ }
857
+ return _context14.abrupt("return", true);
858
+ case 32:
859
+ if (!(processMode == "Library")) {
860
+ _context14.next = 34;
861
+ break;
862
+ }
863
+ throw "This WeaveDrive implementation does not support Library attestations yet!";
864
+ case 34:
865
+ return _context14.abrupt("return", false);
866
+ case 35:
867
+ case "end":
868
+ return _context14.stop();
869
+ }
870
+ }, _callee14);
871
+ }))();
872
+ },
873
+ serializeStringArr: function serializeStringArr() {
874
+ var arr = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
875
+ return "[".concat(arr.map(function (s) {
876
+ return "\"".concat(s, "\"");
877
+ }).join(", "), "]");
878
+ },
879
+ getTagValues: function getTagValues(key, tags) {
880
+ var values = [];
881
+ for (i = 0; i < tags.length; i++) {
882
+ if (tags[i].name == key) {
883
+ values.push(tags[i].value);
884
+ }
885
+ }
886
+ return values;
887
+ },
888
+ getTagValue: function getTagValue(key, tags) {
889
+ var values = this.getTagValues(key, tags);
890
+ return values.pop();
891
+ },
892
+ queryHasResult: function queryHasResult(query, variables) {
893
+ var _this9 = this;
894
+ return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee15() {
895
+ var _json$data;
896
+ var json;
897
+ return _regeneratorRuntime().wrap(function _callee15$(_context15) {
898
+ while (1) switch (_context15.prev = _context15.next) {
899
+ case 0:
900
+ _context15.next = 2;
901
+ return _this9.gqlQuery(query, variables).then(function (res) {
902
+ return res.json();
903
+ });
904
+ case 2:
905
+ json = _context15.sent;
906
+ 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));
907
+ case 4:
908
+ case "end":
909
+ return _context15.stop();
910
+ }
911
+ }, _callee15);
912
+ }))();
913
+ },
914
+ gqlExists: function gqlExists() {
915
+ var _this10 = this;
916
+ return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee16() {
917
+ var query, gqlExists;
918
+ return _regeneratorRuntime().wrap(function _callee16$(_context16) {
919
+ while (1) switch (_context16.prev = _context16.next) {
920
+ case 0:
921
+ query = "query {\n transactions(\n first: 1\n ) {\n pageInfo {\n hasNextPage\n }\n }\n }\n ";
922
+ _context16.next = 3;
923
+ return _this10.gqlQuery(query, {}).then(function (res) {
924
+ return res.ok;
925
+ });
926
+ case 3:
927
+ gqlExists = _context16.sent;
928
+ return _context16.abrupt("return", gqlExists);
929
+ case 5:
930
+ case "end":
931
+ return _context16.stop();
932
+ }
933
+ }, _callee16);
934
+ }))();
935
+ },
936
+ gqlQuery: function gqlQuery(query, variables) {
937
+ var _this11 = this;
938
+ return _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee17() {
939
+ var options;
940
+ return _regeneratorRuntime().wrap(function _callee17$(_context17) {
941
+ while (1) switch (_context17.prev = _context17.next) {
942
+ case 0:
943
+ options = {
944
+ method: "POST",
945
+ body: JSON.stringify({
946
+ query: query,
947
+ variables: variables
948
+ }),
949
+ headers: {
950
+ "Content-Type": "application/json"
951
+ }
952
+ };
953
+ return _context17.abrupt("return", _this11.customFetch("graphql", options));
954
+ case 2:
955
+ case "end":
956
+ return _context17.stop();
957
+ }
958
+ }, _callee17);
959
+ }))();
960
+ }
961
+ };
962
+ }
34
963
  function isJSON(obj) {
35
964
  if (obj === null || obj === undefined) return false;
36
965
  if (_typeof(obj) !== "object" || obj instanceof Buffer || obj instanceof ArrayBuffer || Array.isArray(obj)) {
@@ -49,38 +978,40 @@ var jsonToStr = function jsonToStr(obj) {
49
978
  return isJSON(obj) || ((0, _ramda.is)(Number, obj) ? Number(obj).toString() : obj);
50
979
  };
51
980
  var dirname = /*#__PURE__*/function () {
52
- var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
53
- return _regeneratorRuntime().wrap(function _callee$(_context) {
54
- while (1) switch (_context.prev = _context.next) {
981
+ var _ref4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee18() {
982
+ return _regeneratorRuntime().wrap(function _callee18$(_context18) {
983
+ while (1) switch (_context18.prev = _context18.next) {
55
984
  case 0:
56
985
  if (!(typeof __dirname != "undefined")) {
57
- _context.next = 4;
986
+ _context18.next = 4;
58
987
  break;
59
988
  }
60
- _context.t0 = __dirname;
61
- _context.next = 7;
989
+ _context18.t0 = __dirname;
990
+ _context18.next = 7;
62
991
  break;
63
992
  case 4:
64
- _context.next = 6;
993
+ _context18.next = 6;
65
994
  return Promise.resolve().then(function () {
66
995
  return _interopRequireWildcard(require("./dirname.js"));
67
996
  });
68
997
  case 6:
69
- _context.t0 = _context.sent["default"];
998
+ _context18.t0 = _context18.sent["default"];
70
999
  case 7:
71
- return _context.abrupt("return", _context.t0);
1000
+ return _context18.abrupt("return", _context18.t0);
72
1001
  case 8:
73
1002
  case "end":
74
- return _context.stop();
1003
+ return _context18.stop();
75
1004
  }
76
- }, _callee);
1005
+ }, _callee18);
77
1006
  }));
78
1007
  return function dirname() {
79
- return _ref.apply(this, arguments);
1008
+ return _ref4.apply(this, arguments);
80
1009
  };
81
1010
  }();
82
1011
  var acc = exports.acc = _accounts["default"].users;
83
1012
  var mu = exports.mu = _accounts["default"].mu;
1013
+ var scheduler = "GQ33BkPtZrqxA84vM8Zk-N2aO0toNNu_C-l-rawrBA";
1014
+ var env = {};
84
1015
  var connect = exports.connect = function connect() {
85
1016
  var wasms = {
86
1017
  "Do_Uc2Sju_ffp6Ev0AnLVdPtot15rvMjP-a9VVaA5fM": {
@@ -97,24 +1028,22 @@ var connect = exports.connect = function connect() {
97
1028
  }
98
1029
  };
99
1030
  var modules = {
100
- aos_2_0_1: "Do_Uc2Sju_ffp6Ev0AnLVdPtot15rvMjP-a9VVaA5fM",
101
- aos_1: "cNlipBptaF9JeFAf4wUmpi43EojNanIBos3EfNrEOWo",
1031
+ aos2_0_1: "Do_Uc2Sju_ffp6Ev0AnLVdPtot15rvMjP-a9VVaA5fM",
1032
+ aos1: "cNlipBptaF9JeFAf4wUmpi43EojNanIBos3EfNrEOWo",
102
1033
  sqlite: "ghSkge2sIUD_F00ym5sEimC63BDBuBrq4b5OcwxOjiw"
103
1034
  };
104
1035
  var modmap = {};
105
- var env = {
106
- msgs: {}
107
- };
1036
+ var msgs = {};
108
1037
  var transform = function transform(input) {
109
1038
  var _input$Tags;
110
1039
  var output = {
111
1040
  Tags: []
112
1041
  };
113
1042
  if (input.Data) output.Data = input.Data;
114
- Object.entries(input).forEach(function (_ref2) {
115
- var _ref3 = _slicedToArray(_ref2, 2),
116
- key = _ref3[0],
117
- value = _ref3[1];
1043
+ Object.entries(input).forEach(function (_ref5) {
1044
+ var _ref6 = _slicedToArray(_ref5, 2),
1045
+ key = _ref6[0],
1046
+ value = _ref6[1];
118
1047
  if (key !== "Data" && key !== "Tags" && typeof value === "string") {
119
1048
  output.Tags.push({
120
1049
  name: key,
@@ -150,14 +1079,14 @@ var connect = exports.connect = function connect() {
150
1079
  Tags: Tags !== null && Tags !== void 0 && Tags.length ? Tags : []
151
1080
  };
152
1081
  };
153
- var genEnv = function genEnv(_ref4) {
154
- var pid = _ref4.pid,
155
- _ref4$owner = _ref4.owner,
156
- owner = _ref4$owner === void 0 ? "" : _ref4$owner,
157
- _ref4$module = _ref4.module,
158
- module = _ref4$module === void 0 ? "" : _ref4$module,
159
- _ref4$auth = _ref4.auth,
160
- auth = _ref4$auth === void 0 ? "" : _ref4$auth;
1082
+ var genEnv = function genEnv(_ref7) {
1083
+ var pid = _ref7.pid,
1084
+ _ref7$owner = _ref7.owner,
1085
+ owner = _ref7$owner === void 0 ? "" : _ref7$owner,
1086
+ _ref7$module = _ref7.module,
1087
+ module = _ref7$module === void 0 ? "" : _ref7$module,
1088
+ _ref7$auth = _ref7.auth,
1089
+ auth = _ref7$auth === void 0 ? "" : _ref7$auth;
161
1090
  return {
162
1091
  Process: {
163
1092
  Id: pid,
@@ -192,48 +1121,48 @@ var connect = exports.connect = function connect() {
192
1121
  };
193
1122
  };
194
1123
  var parse = /*#__PURE__*/function () {
195
- var _ref5 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(opt) {
1124
+ var _ref8 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee19(opt) {
196
1125
  var _opt$data;
197
1126
  var item, rowner, hashBuffer, owner;
198
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
199
- while (1) switch (_context2.prev = _context2.next) {
1127
+ return _regeneratorRuntime().wrap(function _callee19$(_context19) {
1128
+ while (1) switch (_context19.prev = _context19.next) {
200
1129
  case 0:
201
- _context2.next = 2;
1130
+ _context19.next = 2;
202
1131
  return opt.signer({
203
1132
  data: (_opt$data = opt.data) !== null && _opt$data !== void 0 ? _opt$data : "",
204
1133
  tags: opt.tags
205
1134
  });
206
1135
  case 2:
207
- item = _context2.sent;
1136
+ item = _context19.sent;
208
1137
  rowner = new _warpArbundles.DataItem(item.raw).rawOwner;
209
- _context2.t0 = Buffer;
210
- _context2.next = 7;
1138
+ _context19.t0 = Buffer;
1139
+ _context19.next = 7;
211
1140
  return crypto.subtle.digest("SHA-256", rowner);
212
1141
  case 7:
213
- _context2.t1 = _context2.sent;
214
- hashBuffer = _context2.t0.from.call(_context2.t0, _context2.t1);
1142
+ _context19.t1 = _context19.sent;
1143
+ hashBuffer = _context19.t0.from.call(_context19.t0, _context19.t1);
215
1144
  owner = _base64url["default"].encode(hashBuffer);
216
- return _context2.abrupt("return", {
1145
+ return _context19.abrupt("return", {
217
1146
  id: item.id,
218
1147
  owner: owner
219
1148
  });
220
1149
  case 11:
221
1150
  case "end":
222
- return _context2.stop();
1151
+ return _context19.stop();
223
1152
  }
224
- }, _callee2);
1153
+ }, _callee19);
225
1154
  }));
226
- return function parse(_x) {
227
- return _ref5.apply(this, arguments);
1155
+ return function parse(_x7) {
1156
+ return _ref8.apply(this, arguments);
228
1157
  };
229
1158
  }();
230
1159
  var postModule = /*#__PURE__*/function () {
231
- var _ref7 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref6) {
232
- var data, _ref6$tags, tags, signer, t, _tags, _yield$parse, id, owner, handle;
233
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
234
- while (1) switch (_context3.prev = _context3.next) {
1160
+ var _ref10 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee20(_ref9) {
1161
+ var data, _ref9$tags, tags, signer, t, _tags, _yield$parse, id, owner, handle;
1162
+ return _regeneratorRuntime().wrap(function _callee20$(_context20) {
1163
+ while (1) switch (_context20.prev = _context20.next) {
235
1164
  case 0:
236
- data = _ref6.data, _ref6$tags = _ref6.tags, tags = _ref6$tags === void 0 ? {} : _ref6$tags, signer = _ref6.signer;
1165
+ data = _ref9.data, _ref9$tags = _ref9.tags, tags = _ref9$tags === void 0 ? {} : _ref9$tags, signer = _ref9.signer;
237
1166
  t = (0, _ramda.mergeLeft)(tags, {
238
1167
  "Data-Protocol": "ao",
239
1168
  Variant: "ao.TN.1",
@@ -245,100 +1174,289 @@ var connect = exports.connect = function connect() {
245
1174
  "Compute-Limit": "9000000000000"
246
1175
  });
247
1176
  _tags = (0, _utils.buildTags)(t);
248
- _context3.next = 5;
1177
+ _context20.next = 5;
249
1178
  return parse({
250
1179
  tags: _tags,
251
1180
  data: data,
252
1181
  signer: signer
253
1182
  });
254
1183
  case 5:
255
- _yield$parse = _context3.sent;
1184
+ _yield$parse = _context20.sent;
256
1185
  id = _yield$parse.id;
257
1186
  owner = _yield$parse.owner;
258
- _context3.next = 10;
1187
+ _context20.next = 10;
259
1188
  return (0, _aoLoader["default"])(data, {
260
- format: t["Module-Format"]
1189
+ format: t["Module-Format"],
1190
+ mode: "test",
1191
+ WeaveDrive: WeaveDrive
261
1192
  });
262
1193
  case 10:
263
- handle = _context3.sent;
1194
+ handle = _context20.sent;
264
1195
  modmap[id] = {
265
1196
  handle: handle,
266
1197
  id: id
267
1198
  };
268
- return _context3.abrupt("return", id);
1199
+ return _context20.abrupt("return", id);
269
1200
  case 13:
270
1201
  case "end":
271
- return _context3.stop();
1202
+ return _context20.stop();
272
1203
  }
273
- }, _callee3);
1204
+ }, _callee20);
274
1205
  }));
275
- return function postModule(_x2) {
276
- return _ref7.apply(this, arguments);
1206
+ return function postModule(_x8) {
1207
+ return _ref10.apply(this, arguments);
277
1208
  };
278
1209
  }();
279
- var _message = /*#__PURE__*/function () {
280
- var _ref8 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4(opt) {
281
- var p, ex, _iterator, _step, _v, _yield$parse2, id, owner, _opt$data2, _opt$from, _res$Messages, msg, _env, res, _iterator2, _step2, v;
282
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
283
- while (1) switch (_context4.prev = _context4.next) {
1210
+ var spawn = /*#__PURE__*/function () {
1211
+ var _ref11 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee21() {
1212
+ var _opt$module, _opt$tags, _opt$data2;
1213
+ var opt,
1214
+ mod,
1215
+ _dirname,
1216
+ wasm,
1217
+ handle,
1218
+ _module,
1219
+ ex,
1220
+ _iterator3,
1221
+ _step3,
1222
+ v,
1223
+ _yield$parse2,
1224
+ id,
1225
+ owner,
1226
+ _tags,
1227
+ res,
1228
+ memory,
1229
+ p,
1230
+ _opt$data3,
1231
+ _msgs$_tags$OnBoot$d,
1232
+ _msgs$_tags$OnBoot,
1233
+ data,
1234
+ msg,
1235
+ _env,
1236
+ _t,
1237
+ _tags$CronInterval$s,
1238
+ _tags$CronInterval$s2,
1239
+ num,
1240
+ unit,
1241
+ _int,
1242
+ cronTags,
1243
+ k,
1244
+ _args21 = arguments;
1245
+ return _regeneratorRuntime().wrap(function _callee21$(_context21) {
1246
+ while (1) switch (_context21.prev = _context21.next) {
284
1247
  case 0:
285
- p = env[opt.process];
1248
+ opt = _args21.length > 0 && _args21[0] !== undefined ? _args21[0] : {};
1249
+ if (opt.module) {
1250
+ _context21.next = 3;
1251
+ break;
1252
+ }
1253
+ throw Error("module missing");
1254
+ case 3:
1255
+ if (opt.scheduler) {
1256
+ _context21.next = 5;
1257
+ break;
1258
+ }
1259
+ throw Error("scheduler missing");
1260
+ case 5:
1261
+ mod = (_opt$module = opt.module) !== null && _opt$module !== void 0 ? _opt$module : modules["aos2_0_1"];
1262
+ if (!(!modmap[mod] && wasms[mod])) {
1263
+ _context21.next = 15;
1264
+ break;
1265
+ }
1266
+ _context21.next = 9;
1267
+ return dirname();
1268
+ case 9:
1269
+ _dirname = _context21.sent;
1270
+ wasm = (0, _fs.readFileSync)((0, _path.resolve)(_dirname, "lua/".concat(wasms[mod].file, ".wasm")));
1271
+ _context21.next = 13;
1272
+ return (0, _aoLoader["default"])(wasm, {
1273
+ format: wasms[mod].format,
1274
+ mode: "test",
1275
+ WeaveDrive: WeaveDrive
1276
+ });
1277
+ case 13:
1278
+ handle = _context21.sent;
1279
+ modmap[mod] = {
1280
+ handle: handle,
1281
+ id: mod
1282
+ };
1283
+ case 15:
1284
+ if (mod) {
1285
+ _context21.next = 17;
1286
+ break;
1287
+ }
1288
+ throw Error("module not found");
1289
+ case 17:
1290
+ _module = modmap[mod];
286
1291
  ex = false;
287
- _iterator = _createForOfIteratorHelper(opt.tags);
1292
+ (_opt$tags = opt.tags) !== null && _opt$tags !== void 0 ? _opt$tags : opt.tags = [];
1293
+ _iterator3 = _createForOfIteratorHelper(opt.tags);
288
1294
  try {
289
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
290
- _v = _step.value;
291
- if (_v.name === "Type") ex = true;
1295
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
1296
+ v = _step3.value;
1297
+ if (v.name === "Type") ex = true;
292
1298
  }
293
1299
  } catch (err) {
294
- _iterator.e(err);
1300
+ _iterator3.e(err);
295
1301
  } finally {
296
- _iterator.f();
1302
+ _iterator3.f();
297
1303
  }
298
1304
  if (!ex) opt.tags.push({
299
1305
  name: "Type",
300
- value: "Message"
1306
+ value: "Process"
301
1307
  });
302
- _context4.next = 7;
1308
+ _context21.next = 25;
303
1309
  return parse(opt);
304
- case 7:
305
- _yield$parse2 = _context4.sent;
1310
+ case 25:
1311
+ _yield$parse2 = _context21.sent;
306
1312
  id = _yield$parse2.id;
307
1313
  owner = _yield$parse2.owner;
308
- _context4.prev = 10;
309
- msg = genMsg(p, (_opt$data2 = opt.data) !== null && _opt$data2 !== void 0 ? _opt$data2 : "", opt.tags, (_opt$from = opt.from) !== null && _opt$from !== void 0 ? _opt$from : owner, mu.addr);
1314
+ _tags = (0, _utils.tags)(opt.tags);
1315
+ _txs[id] = (_opt$data2 = opt.data) !== null && _opt$data2 !== void 0 ? _opt$data2 : null;
1316
+ res = null;
1317
+ memory = null;
1318
+ p = {
1319
+ id: id,
1320
+ handle: _module.handle,
1321
+ module: _module.id,
1322
+ memory: memory,
1323
+ owner: owner,
1324
+ height: 0,
1325
+ res: _defineProperty({}, id, res),
1326
+ results: [id],
1327
+ txs: [],
1328
+ opt: opt
1329
+ };
1330
+ if (!_tags["On-Boot"]) {
1331
+ _context21.next = 47;
1332
+ break;
1333
+ }
1334
+ data = "";
1335
+ if (_tags["On-Boot"] === "Data") data = (_opt$data3 = opt.data) !== null && _opt$data3 !== void 0 ? _opt$data3 : "";else data = (_msgs$_tags$OnBoot$d = (_msgs$_tags$OnBoot = msgs[_tags["On-Boot"]]) === null || _msgs$_tags$OnBoot === void 0 ? void 0 : _msgs$_tags$OnBoot.data) !== null && _msgs$_tags$OnBoot$d !== void 0 ? _msgs$_tags$OnBoot$d : "";
1336
+ msg = genMsg(p, data, opt.tags, owner, mu.addr, true);
310
1337
  _env = genEnv({
311
1338
  pid: p.id,
312
1339
  owner: p.owner,
313
1340
  module: p.module,
314
1341
  auth: mu.addr
315
1342
  });
316
- _context4.next = 15;
1343
+ _t = (0, _utils.tags)(msg.Tags);
1344
+ _context21.next = 41;
1345
+ return _module.handle(null, msg, _env);
1346
+ case 41:
1347
+ res = _context21.sent;
1348
+ p.memory = res.Memory;
1349
+ delete res.Memory;
1350
+ p.res[id] = res;
1351
+ _context21.next = 48;
1352
+ break;
1353
+ case 47:
1354
+ p.height += 1;
1355
+ case 48:
1356
+ msgs[id] = opt;
1357
+ env[id] = p;
1358
+ if (!_tags["Cron-Interval"]) {
1359
+ _context21.next = 74;
1360
+ break;
1361
+ }
1362
+ _tags$CronInterval$s = _tags["Cron-Interval"].split("-"), _tags$CronInterval$s2 = _slicedToArray(_tags$CronInterval$s, 2), num = _tags$CronInterval$s2[0], unit = _tags$CronInterval$s2[1];
1363
+ _int = 0;
1364
+ _context21.t0 = unit.replace(/s$/, "");
1365
+ _context21.next = _context21.t0 === "millisecond" ? 56 : _context21.t0 === "second" ? 58 : _context21.t0 === "minute" ? 60 : _context21.t0 === "hour" ? 62 : _context21.t0 === "day" ? 64 : _context21.t0 === "month" ? 66 : _context21.t0 === "year" ? 68 : 70;
1366
+ break;
1367
+ case 56:
1368
+ _int = num;
1369
+ return _context21.abrupt("break", 70);
1370
+ case 58:
1371
+ _int = num * 1000;
1372
+ return _context21.abrupt("break", 70);
1373
+ case 60:
1374
+ _int = num * 1000 * 60;
1375
+ return _context21.abrupt("break", 70);
1376
+ case 62:
1377
+ _int = num * 1000 * 60 * 60;
1378
+ return _context21.abrupt("break", 70);
1379
+ case 64:
1380
+ _int = num * 1000 * 60 * 60 * 24;
1381
+ return _context21.abrupt("break", 70);
1382
+ case 66:
1383
+ _int = num * 1000 * 60 * 60 * 24 * 30;
1384
+ return _context21.abrupt("break", 70);
1385
+ case 68:
1386
+ _int = num * 1000 * 60 * 60 * 24 * 365;
1387
+ return _context21.abrupt("break", 70);
1388
+ case 70:
1389
+ cronTags = [];
1390
+ for (k in _tags) {
1391
+ if (/^Cron-Tag-/.test(k)) {
1392
+ cronTags.push({
1393
+ name: k.replace(/Cron-Tag-/, ""),
1394
+ value: _tags[k]
1395
+ });
1396
+ }
1397
+ }
1398
+ env[id].cronTags = cronTags;
1399
+ env[id].span = _int;
1400
+ case 74:
1401
+ return _context21.abrupt("return", id);
1402
+ case 75:
1403
+ case "end":
1404
+ return _context21.stop();
1405
+ }
1406
+ }, _callee21);
1407
+ }));
1408
+ return function spawn() {
1409
+ return _ref11.apply(this, arguments);
1410
+ };
1411
+ }();
1412
+ var assign = /*#__PURE__*/function () {
1413
+ var _ref12 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee22(opt) {
1414
+ var p, _opt, _yield$parse3, id, owner, _opt$data4, _opt$from, _res$Messages, msg, _env, res, _iterator4, _step4, v;
1415
+ return _regeneratorRuntime().wrap(function _callee22$(_context22) {
1416
+ while (1) switch (_context22.prev = _context22.next) {
1417
+ case 0:
1418
+ p = env[opt.process];
1419
+ _opt = (0, _ramda.clone)(msgs[opt.message]);
1420
+ _context22.next = 4;
1421
+ return parse(_opt);
1422
+ case 4:
1423
+ _yield$parse3 = _context22.sent;
1424
+ id = _yield$parse3.id;
1425
+ owner = _yield$parse3.owner;
1426
+ _context22.prev = 7;
1427
+ msg = genMsg(p, (_opt$data4 = _opt.data) !== null && _opt$data4 !== void 0 ? _opt$data4 : "", _opt.tags, (_opt$from = _opt.from) !== null && _opt$from !== void 0 ? _opt$from : owner, mu.addr);
1428
+ _env = genEnv({
1429
+ pid: p.id,
1430
+ owner: p.owner,
1431
+ module: p.module,
1432
+ auth: mu.addr
1433
+ });
1434
+ _context22.next = 12;
317
1435
  return p.handle(p.memory, msg, _env);
318
- case 15:
319
- res = _context4.sent;
1436
+ case 12:
1437
+ res = _context22.sent;
320
1438
  p.memory = res.Memory;
321
1439
  delete res.Memory;
322
1440
  p.res[id] = res;
323
1441
  p.results.push(id);
324
1442
  p.txs.unshift(_objectSpread({
325
1443
  id: id
326
- }, opt));
327
- env.msgs[id] = opt;
328
- _iterator2 = _createForOfIteratorHelper((_res$Messages = res.Messages) !== null && _res$Messages !== void 0 ? _res$Messages : []);
329
- _context4.prev = 23;
330
- _iterator2.s();
331
- case 25:
332
- if ((_step2 = _iterator2.n()).done) {
333
- _context4.next = 32;
1444
+ }, _opt));
1445
+ msgs[id] = _opt;
1446
+ _iterator4 = _createForOfIteratorHelper((_res$Messages = res.Messages) !== null && _res$Messages !== void 0 ? _res$Messages : []);
1447
+ _context22.prev = 20;
1448
+ _iterator4.s();
1449
+ case 22:
1450
+ if ((_step4 = _iterator4.n()).done) {
1451
+ _context22.next = 29;
334
1452
  break;
335
1453
  }
336
- v = _step2.value;
1454
+ v = _step4.value;
337
1455
  if (!env[v.Target]) {
338
- _context4.next = 30;
1456
+ _context22.next = 27;
339
1457
  break;
340
1458
  }
341
- _context4.next = 30;
1459
+ _context22.next = 27;
342
1460
  return _message({
343
1461
  process: v.Target,
344
1462
  tags: v.Tags,
@@ -346,440 +1464,461 @@ var connect = exports.connect = function connect() {
346
1464
  signer: mu.signer,
347
1465
  from: opt.process
348
1466
  });
349
- case 30:
350
- _context4.next = 25;
1467
+ case 27:
1468
+ _context22.next = 22;
351
1469
  break;
352
- case 32:
353
- _context4.next = 37;
1470
+ case 29:
1471
+ _context22.next = 34;
354
1472
  break;
1473
+ case 31:
1474
+ _context22.prev = 31;
1475
+ _context22.t0 = _context22["catch"](20);
1476
+ _iterator4.e(_context22.t0);
355
1477
  case 34:
356
- _context4.prev = 34;
357
- _context4.t0 = _context4["catch"](23);
358
- _iterator2.e(_context4.t0);
1478
+ _context22.prev = 34;
1479
+ _iterator4.f();
1480
+ return _context22.finish(34);
359
1481
  case 37:
360
- _context4.prev = 37;
361
- _iterator2.f();
362
- return _context4.finish(37);
1482
+ return _context22.abrupt("return", id);
363
1483
  case 40:
364
- return _context4.abrupt("return", id);
1484
+ _context22.prev = 40;
1485
+ _context22.t1 = _context22["catch"](7);
1486
+ console.log(_context22.t1);
365
1487
  case 43:
366
- _context4.prev = 43;
367
- _context4.t1 = _context4["catch"](10);
368
- console.log(_context4.t1);
369
- case 46:
370
- return _context4.abrupt("return", null);
371
- case 47:
1488
+ return _context22.abrupt("return", null);
1489
+ case 44:
372
1490
  case "end":
373
- return _context4.stop();
1491
+ return _context22.stop();
374
1492
  }
375
- }, _callee4, null, [[10, 43], [23, 34, 37, 40]]);
1493
+ }, _callee22, null, [[7, 40], [20, 31, 34, 37]]);
376
1494
  }));
377
- return function message(_x3) {
378
- return _ref8.apply(this, arguments);
1495
+ return function assign(_x9) {
1496
+ return _ref12.apply(this, arguments);
1497
+ };
1498
+ }();
1499
+ var _message = /*#__PURE__*/function () {
1500
+ var _ref13 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee23(opt) {
1501
+ var p, ex, _iterator5, _step5, _v3, _yield$parse4, id, owner, _opt$data5, _opt$from2, _opt$data6, _res$Messages2, _res$Spawns, _res$Assignments, msg, _env, res, _iterator6, _step6, v, _iterator7, _step7, _v, _tags, _iterator8, _step8, _v2, _iterator9, _step9, v2;
1502
+ return _regeneratorRuntime().wrap(function _callee23$(_context23) {
1503
+ while (1) switch (_context23.prev = _context23.next) {
1504
+ case 0:
1505
+ p = env[opt.process];
1506
+ ex = false;
1507
+ _iterator5 = _createForOfIteratorHelper(opt.tags);
1508
+ try {
1509
+ for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
1510
+ _v3 = _step5.value;
1511
+ if (_v3.name === "Type") ex = true;
1512
+ }
1513
+ } catch (err) {
1514
+ _iterator5.e(err);
1515
+ } finally {
1516
+ _iterator5.f();
1517
+ }
1518
+ if (!ex) opt.tags.push({
1519
+ name: "Type",
1520
+ value: "Message"
1521
+ });
1522
+ _context23.next = 7;
1523
+ return parse(opt);
1524
+ case 7:
1525
+ _yield$parse4 = _context23.sent;
1526
+ id = _yield$parse4.id;
1527
+ owner = _yield$parse4.owner;
1528
+ _context23.prev = 10;
1529
+ msg = genMsg(p, (_opt$data5 = opt.data) !== null && _opt$data5 !== void 0 ? _opt$data5 : "", opt.tags, (_opt$from2 = opt.from) !== null && _opt$from2 !== void 0 ? _opt$from2 : owner, mu.addr);
1530
+ _env = genEnv({
1531
+ pid: p.id,
1532
+ owner: p.owner,
1533
+ module: p.module,
1534
+ auth: mu.addr
1535
+ });
1536
+ _context23.next = 15;
1537
+ return p.handle(p.memory, msg, _env);
1538
+ case 15:
1539
+ res = _context23.sent;
1540
+ _txs[id] = (_opt$data6 = opt.data) !== null && _opt$data6 !== void 0 ? _opt$data6 : null;
1541
+ p.memory = res.Memory;
1542
+ delete res.Memory;
1543
+ p.res[id] = res;
1544
+ p.results.push(id);
1545
+ p.txs.unshift(_objectSpread({
1546
+ id: id
1547
+ }, opt));
1548
+ msgs[id] = opt;
1549
+ _iterator6 = _createForOfIteratorHelper((_res$Messages2 = res.Messages) !== null && _res$Messages2 !== void 0 ? _res$Messages2 : []);
1550
+ _context23.prev = 24;
1551
+ _iterator6.s();
1552
+ case 26:
1553
+ if ((_step6 = _iterator6.n()).done) {
1554
+ _context23.next = 33;
1555
+ break;
1556
+ }
1557
+ v = _step6.value;
1558
+ if (!env[v.Target]) {
1559
+ _context23.next = 31;
1560
+ break;
1561
+ }
1562
+ _context23.next = 31;
1563
+ return _message({
1564
+ process: v.Target,
1565
+ tags: v.Tags,
1566
+ data: v.Data,
1567
+ signer: mu.signer,
1568
+ from: opt.process
1569
+ });
1570
+ case 31:
1571
+ _context23.next = 26;
1572
+ break;
1573
+ case 33:
1574
+ _context23.next = 38;
1575
+ break;
1576
+ case 35:
1577
+ _context23.prev = 35;
1578
+ _context23.t0 = _context23["catch"](24);
1579
+ _iterator6.e(_context23.t0);
1580
+ case 38:
1581
+ _context23.prev = 38;
1582
+ _iterator6.f();
1583
+ return _context23.finish(38);
1584
+ case 41:
1585
+ _iterator7 = _createForOfIteratorHelper((_res$Spawns = res.Spawns) !== null && _res$Spawns !== void 0 ? _res$Spawns : []);
1586
+ _context23.prev = 42;
1587
+ _iterator7.s();
1588
+ case 44:
1589
+ if ((_step7 = _iterator7.n()).done) {
1590
+ _context23.next = 51;
1591
+ break;
1592
+ }
1593
+ _v = _step7.value;
1594
+ _tags = (0, _utils.tags)(_v.Tags);
1595
+ _context23.next = 49;
1596
+ return spawn({
1597
+ module: _tags.Module,
1598
+ scheduler: scheduler,
1599
+ tags: _v.Tags,
1600
+ data: _v.Data,
1601
+ from: _tags["From-Process"],
1602
+ signer: mu.signer
1603
+ });
1604
+ case 49:
1605
+ _context23.next = 44;
1606
+ break;
1607
+ case 51:
1608
+ _context23.next = 56;
1609
+ break;
1610
+ case 53:
1611
+ _context23.prev = 53;
1612
+ _context23.t1 = _context23["catch"](42);
1613
+ _iterator7.e(_context23.t1);
1614
+ case 56:
1615
+ _context23.prev = 56;
1616
+ _iterator7.f();
1617
+ return _context23.finish(56);
1618
+ case 59:
1619
+ _iterator8 = _createForOfIteratorHelper((_res$Assignments = res.Assignments) !== null && _res$Assignments !== void 0 ? _res$Assignments : []);
1620
+ _context23.prev = 60;
1621
+ _iterator8.s();
1622
+ case 62:
1623
+ if ((_step8 = _iterator8.n()).done) {
1624
+ _context23.next = 83;
1625
+ break;
1626
+ }
1627
+ _v2 = _step8.value;
1628
+ _iterator9 = _createForOfIteratorHelper(_v2.Processes);
1629
+ _context23.prev = 65;
1630
+ _iterator9.s();
1631
+ case 67:
1632
+ if ((_step9 = _iterator9.n()).done) {
1633
+ _context23.next = 73;
1634
+ break;
1635
+ }
1636
+ v2 = _step9.value;
1637
+ _context23.next = 71;
1638
+ return assign({
1639
+ message: _v2.Message,
1640
+ process: v2,
1641
+ from: opt.process,
1642
+ signer: mu.signer
1643
+ });
1644
+ case 71:
1645
+ _context23.next = 67;
1646
+ break;
1647
+ case 73:
1648
+ _context23.next = 78;
1649
+ break;
1650
+ case 75:
1651
+ _context23.prev = 75;
1652
+ _context23.t2 = _context23["catch"](65);
1653
+ _iterator9.e(_context23.t2);
1654
+ case 78:
1655
+ _context23.prev = 78;
1656
+ _iterator9.f();
1657
+ return _context23.finish(78);
1658
+ case 81:
1659
+ _context23.next = 62;
1660
+ break;
1661
+ case 83:
1662
+ _context23.next = 88;
1663
+ break;
1664
+ case 85:
1665
+ _context23.prev = 85;
1666
+ _context23.t3 = _context23["catch"](60);
1667
+ _iterator8.e(_context23.t3);
1668
+ case 88:
1669
+ _context23.prev = 88;
1670
+ _iterator8.f();
1671
+ return _context23.finish(88);
1672
+ case 91:
1673
+ return _context23.abrupt("return", id);
1674
+ case 94:
1675
+ _context23.prev = 94;
1676
+ _context23.t4 = _context23["catch"](10);
1677
+ console.log(_context23.t4);
1678
+ case 97:
1679
+ return _context23.abrupt("return", null);
1680
+ case 98:
1681
+ case "end":
1682
+ return _context23.stop();
1683
+ }
1684
+ }, _callee23, null, [[10, 94], [24, 35, 38, 41], [42, 53, 56, 59], [60, 85, 88, 91], [65, 75, 78, 81]]);
1685
+ }));
1686
+ return function message(_x10) {
1687
+ return _ref13.apply(this, arguments);
379
1688
  };
380
1689
  }();
381
1690
  return {
382
- scheduler: "GQ33BkPtZrqxA84vM8Zk-N2aO0toNNu_C-l-rawrBA",
1691
+ scheduler: scheduler,
383
1692
  modules: modules,
384
1693
  accounts: acc,
1694
+ mu: mu,
385
1695
  message: _message,
386
- txs: function () {
387
- var _txs2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5(pid) {
388
- var _txs, _iterator3, _step3, v;
389
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
390
- while (1) switch (_context5.prev = _context5.next) {
1696
+ unmonitor: function () {
1697
+ var _unmonitor = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee24(opt) {
1698
+ var p;
1699
+ return _regeneratorRuntime().wrap(function _callee24$(_context24) {
1700
+ while (1) switch (_context24.prev = _context24.next) {
391
1701
  case 0:
392
- _txs = [];
393
- _iterator3 = _createForOfIteratorHelper(env[pid].txs);
1702
+ p = env[opt.process];
394
1703
  try {
395
- for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
396
- v = _step3.value;
397
- _txs.push({
398
- tags: v.tags,
399
- id: v.id
400
- });
401
- }
402
- } catch (err) {
403
- _iterator3.e(err);
404
- } finally {
405
- _iterator3.f();
406
- }
407
- return _context5.abrupt("return", _txs);
408
- case 4:
1704
+ clearInterval(p.cron);
1705
+ p.cron = null;
1706
+ } catch (e) {}
1707
+ case 2:
409
1708
  case "end":
410
- return _context5.stop();
1709
+ return _context24.stop();
411
1710
  }
412
- }, _callee5);
1711
+ }, _callee24);
413
1712
  }));
414
- function txs(_x4) {
415
- return _txs2.apply(this, arguments);
1713
+ function unmonitor(_x11) {
1714
+ return _unmonitor.apply(this, arguments);
416
1715
  }
417
- return txs;
1716
+ return unmonitor;
418
1717
  }(),
419
- spawn: function () {
420
- var _spawn = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
421
- var _opt$module, _opt$tags;
422
- var opt,
423
- mod,
424
- _dirname,
425
- wasm,
426
- handle,
427
- _module,
428
- ex,
429
- _iterator4,
430
- _step4,
431
- v,
432
- _yield$parse3,
433
- id,
434
- owner,
435
- _tags,
436
- res,
437
- memory,
438
- p,
439
- _opt$data3,
440
- _env$msgs$_tags$OnBo,
441
- _env$msgs$_tags$OnBo2,
442
- data,
443
- msg,
444
- _env,
445
- _args6 = arguments;
446
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
447
- while (1) switch (_context6.prev = _context6.next) {
1718
+ monitor: function () {
1719
+ var _monitor = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee26(opt) {
1720
+ var p;
1721
+ return _regeneratorRuntime().wrap(function _callee26$(_context26) {
1722
+ while (1) switch (_context26.prev = _context26.next) {
448
1723
  case 0:
449
- opt = _args6.length > 0 && _args6[0] !== undefined ? _args6[0] : {};
450
- if (opt.module) {
451
- _context6.next = 3;
452
- break;
453
- }
454
- throw Error("module.missing");
455
- case 3:
456
- if (opt.scheduler) {
457
- _context6.next = 5;
458
- break;
459
- }
460
- throw Error("scheduler.missing");
461
- case 5:
462
- mod = (_opt$module = opt.module) !== null && _opt$module !== void 0 ? _opt$module : modules["aos_2_0_1"];
463
- if (!(!modmap[mod] && wasms[mod])) {
464
- _context6.next = 15;
465
- break;
466
- }
467
- _context6.next = 9;
468
- return dirname();
469
- case 9:
470
- _dirname = _context6.sent;
471
- wasm = (0, _fs.readFileSync)((0, _path.resolve)(_dirname, "lua/".concat(wasms[mod].file, ".wasm")));
472
- _context6.next = 13;
473
- return (0, _aoLoader["default"])(wasm, {
474
- format: wasms[mod].format
475
- });
476
- case 13:
477
- handle = _context6.sent;
478
- modmap[mod] = {
479
- handle: handle,
480
- id: mod
481
- };
482
- case 15:
483
- if (mod) {
484
- _context6.next = 17;
485
- break;
486
- }
487
- throw Error("module not found");
488
- case 17:
489
- _module = modmap[mod];
490
- ex = false;
491
- (_opt$tags = opt.tags) !== null && _opt$tags !== void 0 ? _opt$tags : opt.tags = [];
492
- _iterator4 = _createForOfIteratorHelper(opt.tags);
493
- try {
494
- for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
495
- v = _step4.value;
496
- if (v.name === "Type") ex = true;
497
- }
498
- } catch (err) {
499
- _iterator4.e(err);
500
- } finally {
501
- _iterator4.f();
502
- }
503
- if (!ex) opt.tags.push({
504
- name: "Type",
505
- value: "Process"
506
- });
507
- _context6.next = 25;
508
- return parse(opt);
509
- case 25:
510
- _yield$parse3 = _context6.sent;
511
- id = _yield$parse3.id;
512
- owner = _yield$parse3.owner;
513
- _tags = (0, _utils.tags)(opt.tags);
514
- res = null;
515
- memory = null;
516
- p = {
517
- id: id,
518
- handle: _module.handle,
519
- module: _module.id,
520
- memory: memory,
521
- owner: owner,
522
- height: 0,
523
- res: _defineProperty({}, id, res),
524
- results: [id],
525
- txs: []
526
- };
527
- if (!_tags["On-Boot"]) {
528
- _context6.next = 45;
529
- break;
1724
+ p = env[opt.process];
1725
+ if ((0, _ramda.isNil)(p.cron)) {
1726
+ p.cron = setInterval(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee25() {
1727
+ return _regeneratorRuntime().wrap(function _callee25$(_context25) {
1728
+ while (1) switch (_context25.prev = _context25.next) {
1729
+ case 0:
1730
+ _context25.next = 2;
1731
+ return _message({
1732
+ tags: p.cronTags,
1733
+ process: opt.process,
1734
+ signer: mu.signer,
1735
+ from: mu.addr
1736
+ });
1737
+ case 2:
1738
+ case "end":
1739
+ return _context25.stop();
1740
+ }
1741
+ }, _callee25);
1742
+ })), p.span);
530
1743
  }
531
- data = "";
532
- if (_tags["On-Boot"] === "Data") data = (_opt$data3 = opt.data) !== null && _opt$data3 !== void 0 ? _opt$data3 : "";else data = (_env$msgs$_tags$OnBo = (_env$msgs$_tags$OnBo2 = env.msgs[_tags["On-Boot"]]) === null || _env$msgs$_tags$OnBo2 === void 0 ? void 0 : _env$msgs$_tags$OnBo2.data) !== null && _env$msgs$_tags$OnBo !== void 0 ? _env$msgs$_tags$OnBo : "";
533
- msg = genMsg(p, data, opt.tags, owner, mu.addr, true);
534
- _env = genEnv({
535
- pid: p.id,
536
- owner: p.owner,
537
- module: p.module,
538
- auth: mu.addr
539
- });
540
- _context6.next = 39;
541
- return _module.handle(null, msg, _env);
542
- case 39:
543
- res = _context6.sent;
544
- memory = res.Memory;
545
- delete res.Memory;
546
- p.res[id] = res;
547
- _context6.next = 46;
548
- break;
549
- case 45:
550
- p.height += 1;
551
- case 46:
552
- env.msgs[id] = opt;
553
- env[id] = p;
554
- return _context6.abrupt("return", id);
555
- case 49:
1744
+ case 2:
556
1745
  case "end":
557
- return _context6.stop();
1746
+ return _context26.stop();
558
1747
  }
559
- }, _callee6);
1748
+ }, _callee26);
560
1749
  }));
561
- function spawn() {
562
- return _spawn.apply(this, arguments);
1750
+ function monitor(_x12) {
1751
+ return _monitor.apply(this, arguments);
563
1752
  }
564
- return spawn;
1753
+ return monitor;
565
1754
  }(),
566
- assign: function () {
567
- var _assign = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7(opt) {
568
- var p, _opt, _yield$parse4, id, owner, _opt$data4, _opt$from2, _res$Messages2, msg, _env, res, _iterator5, _step5, v;
569
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
570
- while (1) switch (_context7.prev = _context7.next) {
1755
+ txs: function () {
1756
+ var _txs2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee27(pid) {
1757
+ var _txs, _iterator10, _step10, v;
1758
+ return _regeneratorRuntime().wrap(function _callee27$(_context27) {
1759
+ while (1) switch (_context27.prev = _context27.next) {
571
1760
  case 0:
572
- p = env[opt.process];
573
- _opt = (0, _ramda.clone)(env.msgs[opt.message]);
574
- _context7.next = 4;
575
- return parse(_opt);
576
- case 4:
577
- _yield$parse4 = _context7.sent;
578
- id = _yield$parse4.id;
579
- owner = _yield$parse4.owner;
580
- _context7.prev = 7;
581
- msg = genMsg(p, (_opt$data4 = _opt.data) !== null && _opt$data4 !== void 0 ? _opt$data4 : "", _opt.tags, (_opt$from2 = _opt.from) !== null && _opt$from2 !== void 0 ? _opt$from2 : owner, mu.addr);
582
- _env = genEnv({
583
- pid: p.id,
584
- owner: p.owner,
585
- module: p.module,
586
- auth: mu.addr
587
- });
588
- _context7.next = 12;
589
- return p.handle(p.memory, msg, _env);
590
- case 12:
591
- res = _context7.sent;
592
- p.memory = res.Memory;
593
- delete res.Memory;
594
- p.res[id] = res;
595
- p.results.push(id);
596
- p.txs.unshift(_objectSpread({
597
- id: id
598
- }, _opt));
599
- env.msgs[id] = _opt;
600
- _iterator5 = _createForOfIteratorHelper((_res$Messages2 = res.Messages) !== null && _res$Messages2 !== void 0 ? _res$Messages2 : []);
601
- _context7.prev = 20;
602
- _iterator5.s();
603
- case 22:
604
- if ((_step5 = _iterator5.n()).done) {
605
- _context7.next = 29;
606
- break;
607
- }
608
- v = _step5.value;
609
- if (!env[v.Target]) {
610
- _context7.next = 27;
611
- break;
1761
+ _txs = [];
1762
+ _iterator10 = _createForOfIteratorHelper(env[pid].txs);
1763
+ try {
1764
+ for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
1765
+ v = _step10.value;
1766
+ _txs.push({
1767
+ tags: v.tags,
1768
+ id: v.id
1769
+ });
1770
+ }
1771
+ } catch (err) {
1772
+ _iterator10.e(err);
1773
+ } finally {
1774
+ _iterator10.f();
612
1775
  }
613
- _context7.next = 27;
614
- return _message({
615
- process: v.Target,
616
- tags: v.Tags,
617
- data: v.Data,
618
- signer: mu.signer,
619
- from: opt.process
620
- });
621
- case 27:
622
- _context7.next = 22;
623
- break;
624
- case 29:
625
- _context7.next = 34;
626
- break;
627
- case 31:
628
- _context7.prev = 31;
629
- _context7.t0 = _context7["catch"](20);
630
- _iterator5.e(_context7.t0);
631
- case 34:
632
- _context7.prev = 34;
633
- _iterator5.f();
634
- return _context7.finish(34);
635
- case 37:
636
- return _context7.abrupt("return", id);
637
- case 40:
638
- _context7.prev = 40;
639
- _context7.t1 = _context7["catch"](7);
640
- console.log(_context7.t1);
641
- case 43:
642
- return _context7.abrupt("return", null);
643
- case 44:
1776
+ return _context27.abrupt("return", _txs);
1777
+ case 4:
644
1778
  case "end":
645
- return _context7.stop();
1779
+ return _context27.stop();
646
1780
  }
647
- }, _callee7, null, [[7, 40], [20, 31, 34, 37]]);
1781
+ }, _callee27);
648
1782
  }));
649
- function assign(_x5) {
650
- return _assign.apply(this, arguments);
1783
+ function txs(_x13) {
1784
+ return _txs2.apply(this, arguments);
651
1785
  }
652
- return assign;
1786
+ return txs;
653
1787
  }(),
1788
+ spawn: spawn,
1789
+ assign: assign,
654
1790
  result: function () {
655
- var _result = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee8(opt) {
656
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
657
- while (1) switch (_context8.prev = _context8.next) {
1791
+ var _result = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee28(opt) {
1792
+ return _regeneratorRuntime().wrap(function _callee28$(_context28) {
1793
+ while (1) switch (_context28.prev = _context28.next) {
658
1794
  case 0:
659
- return _context8.abrupt("return", env[opt.process].res[opt.message]);
1795
+ return _context28.abrupt("return", env[opt.process].res[opt.message]);
660
1796
  case 1:
661
1797
  case "end":
662
- return _context8.stop();
1798
+ return _context28.stop();
663
1799
  }
664
- }, _callee8);
1800
+ }, _callee28);
665
1801
  }));
666
- function result(_x6) {
1802
+ function result(_x14) {
667
1803
  return _result.apply(this, arguments);
668
1804
  }
669
1805
  return result;
670
1806
  }(),
671
1807
  results: function () {
672
- var _results = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee9(opt) {
1808
+ var _results = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee29(opt) {
673
1809
  var _opt$limit;
674
- var p, results, limit, i, _i;
675
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
676
- while (1) switch (_context9.prev = _context9.next) {
1810
+ var p, results, limit, _i, _i2;
1811
+ return _regeneratorRuntime().wrap(function _callee29$(_context29) {
1812
+ while (1) switch (_context29.prev = _context29.next) {
677
1813
  case 0:
678
1814
  p = env[opt.process];
679
1815
  results = [];
680
1816
  limit = (_opt$limit = opt.limit) !== null && _opt$limit !== void 0 ? _opt$limit : 25;
681
1817
  if (!(opt.sort === "DESC")) {
682
- _context9.next = 14;
1818
+ _context29.next = 14;
683
1819
  break;
684
1820
  }
685
- i = p.results.length - 1;
1821
+ _i = p.results.length - 1;
686
1822
  case 5:
687
- if (!(0 < i)) {
688
- _context9.next = 12;
1823
+ if (!(0 < _i)) {
1824
+ _context29.next = 12;
689
1825
  break;
690
1826
  }
691
1827
  results.push({
692
- cursor: p.results[i],
693
- node: p.res[p.results[i]]
1828
+ cursor: p.results[_i],
1829
+ node: p.res[p.results[_i]]
694
1830
  });
695
1831
  if (!(results.length >= limit)) {
696
- _context9.next = 9;
1832
+ _context29.next = 9;
697
1833
  break;
698
1834
  }
699
- return _context9.abrupt("break", 12);
1835
+ return _context29.abrupt("break", 12);
700
1836
  case 9:
701
- i--;
702
- _context9.next = 5;
1837
+ _i--;
1838
+ _context29.next = 5;
703
1839
  break;
704
1840
  case 12:
705
- _context9.next = 22;
1841
+ _context29.next = 22;
706
1842
  break;
707
1843
  case 14:
708
- _i = 0;
1844
+ _i2 = 0;
709
1845
  case 15:
710
- if (!(_i < p.results.length)) {
711
- _context9.next = 22;
1846
+ if (!(_i2 < p.results.length)) {
1847
+ _context29.next = 22;
712
1848
  break;
713
1849
  }
714
1850
  results.push({
715
- node: p.res[p.results[_i]]
1851
+ node: p.res[p.results[_i2]]
716
1852
  });
717
1853
  if (!(results.length >= limit)) {
718
- _context9.next = 19;
1854
+ _context29.next = 19;
719
1855
  break;
720
1856
  }
721
- return _context9.abrupt("break", 22);
1857
+ return _context29.abrupt("break", 22);
722
1858
  case 19:
723
- _i++;
724
- _context9.next = 15;
1859
+ _i2++;
1860
+ _context29.next = 15;
725
1861
  break;
726
1862
  case 22:
727
- return _context9.abrupt("return", {
1863
+ return _context29.abrupt("return", {
728
1864
  edges: results
729
1865
  });
730
1866
  case 23:
731
1867
  case "end":
732
- return _context9.stop();
1868
+ return _context29.stop();
733
1869
  }
734
- }, _callee9);
1870
+ }, _callee29);
735
1871
  }));
736
- function results(_x7) {
1872
+ function results(_x15) {
737
1873
  return _results.apply(this, arguments);
738
1874
  }
739
1875
  return results;
740
1876
  }(),
741
1877
  dryrun: function () {
742
- var _dryrun = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee10(opt) {
743
- var p, _yield$parse5, id, owner, _opt$data5, msg, _env, res;
744
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
745
- while (1) switch (_context10.prev = _context10.next) {
1878
+ var _dryrun = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee30(opt) {
1879
+ var p, _yield$parse5, id, owner, _opt$data7, msg, _env, res;
1880
+ return _regeneratorRuntime().wrap(function _callee30$(_context30) {
1881
+ while (1) switch (_context30.prev = _context30.next) {
746
1882
  case 0:
747
1883
  p = env[opt.process];
748
- _context10.next = 3;
1884
+ _context30.next = 3;
749
1885
  return parse(opt);
750
1886
  case 3:
751
- _yield$parse5 = _context10.sent;
1887
+ _yield$parse5 = _context30.sent;
752
1888
  id = _yield$parse5.id;
753
1889
  owner = _yield$parse5.owner;
754
- _context10.prev = 6;
755
- msg = genMsg(p, (_opt$data5 = opt.data) !== null && _opt$data5 !== void 0 ? _opt$data5 : "", opt.tags, owner, mu.addr, true);
1890
+ _context30.prev = 6;
1891
+ msg = genMsg(p, (_opt$data7 = opt.data) !== null && _opt$data7 !== void 0 ? _opt$data7 : "", opt.tags, owner, mu.addr, true);
756
1892
  _env = genEnv({
757
1893
  pid: p.id,
758
1894
  owner: p.owner,
759
1895
  module: p.module,
760
1896
  auth: mu.addr
761
1897
  });
762
- _context10.next = 11;
1898
+ _context30.next = 11;
763
1899
  return p.handle(p.memory, msg, _env);
764
1900
  case 11:
765
- res = _context10.sent;
766
- return _context10.abrupt("return", res);
1901
+ res = _context30.sent;
1902
+ return _context30.abrupt("return", res);
767
1903
  case 15:
768
- _context10.prev = 15;
769
- _context10.t0 = _context10["catch"](6);
770
- console.log(_context10.t0);
1904
+ _context30.prev = 15;
1905
+ _context30.t0 = _context30["catch"](6);
1906
+ console.log(_context30.t0);
771
1907
  case 18:
772
- return _context10.abrupt("return", null);
1908
+ return _context30.abrupt("return", null);
773
1909
  case 19:
774
1910
  case "end":
775
- return _context10.stop();
1911
+ return _context30.stop();
776
1912
  }
777
- }, _callee10, null, [[6, 15]]);
1913
+ }, _callee30, null, [[6, 15]]);
778
1914
  }));
779
- function dryrun(_x8) {
1915
+ function dryrun(_x16) {
780
1916
  return _dryrun.apply(this, arguments);
781
1917
  }
782
1918
  return dryrun;
783
- }()
1919
+ }(),
1920
+ getProcesses: function getProcesses() {
1921
+ return env;
1922
+ }
784
1923
  };
785
1924
  };