wao 0.9.0 → 0.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/aoconnect-base.js +1332 -0
- package/cjs/aoconnect-web.js +15 -1317
- package/cjs/aoconnect.js +15 -1317
- package/cjs/ar-base.js +683 -0
- package/cjs/armem-base.js +438 -0
- package/cjs/armem-web.js +25 -409
- package/cjs/armem.js +30 -402
- package/cjs/bao.js +248 -0
- package/cjs/lfdb.js +165 -0
- package/cjs/tao.js +10 -222
- package/cjs/tar.js +8 -655
- package/cjs/wao.js +10 -222
- package/cjs/war.js +8 -655
- package/esm/aoconnect-base.js +482 -0
- package/esm/aoconnect-web.js +6 -482
- package/esm/aoconnect.js +6 -483
- package/esm/ar-base.js +215 -0
- package/esm/armem-base.js +172 -0
- package/esm/armem-web.js +9 -169
- package/esm/armem.js +7 -163
- package/esm/bao.js +125 -0
- package/esm/lfdb.js +68 -0
- package/esm/tao.js +4 -121
- package/esm/tar.js +3 -209
- package/esm/wao.js +4 -121
- package/esm/war.js +3 -209
- package/esm/web.js +0 -1
- package/package.json +2 -1
|
@@ -0,0 +1,438 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports["default"] = void 0;
|
|
8
|
+
var _arweave = _interopRequireDefault(require("arweave"));
|
|
9
|
+
var _ramda = require("ramda");
|
|
10
|
+
var _utils = require("./utils.js");
|
|
11
|
+
var _Arweave$default;
|
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
13
|
+
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; } } }; }
|
|
14
|
+
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; } }
|
|
15
|
+
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; }
|
|
16
|
+
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; }
|
|
17
|
+
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); }
|
|
18
|
+
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); }); }; }
|
|
19
|
+
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
20
|
+
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
21
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
22
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
23
|
+
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); }
|
|
24
|
+
var Arweave = (_Arweave$default = _arweave["default"]["default"]) !== null && _Arweave$default !== void 0 ? _Arweave$default : _arweave["default"];
|
|
25
|
+
var ArMemBase = exports["default"] = /*#__PURE__*/function () {
|
|
26
|
+
function ArMemBase() {
|
|
27
|
+
var _this = this;
|
|
28
|
+
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
29
|
+
MU_URL = _ref.MU_URL,
|
|
30
|
+
CU_URL = _ref.CU_URL,
|
|
31
|
+
SU_URL = _ref.SU_URL,
|
|
32
|
+
GATEWAY_URL = _ref.GATEWAY_URL,
|
|
33
|
+
scheduler = _ref.scheduler,
|
|
34
|
+
cache = _ref.cache;
|
|
35
|
+
_classCallCheck(this, ArMemBase);
|
|
36
|
+
this.__type__ = "mem";
|
|
37
|
+
this.isInit = false;
|
|
38
|
+
this.keyInit = false;
|
|
39
|
+
this.keys = {};
|
|
40
|
+
this.arweave = Arweave.init();
|
|
41
|
+
this.arweave.transactions.getTransactionAnchor = function () {
|
|
42
|
+
return _this.getAnchor();
|
|
43
|
+
};
|
|
44
|
+
this.arweave.transactions.getPrice = function () {
|
|
45
|
+
return 0;
|
|
46
|
+
};
|
|
47
|
+
this.scheduler = scheduler;
|
|
48
|
+
this.SU_URL = SU_URL;
|
|
49
|
+
}
|
|
50
|
+
return _createClass(ArMemBase, [{
|
|
51
|
+
key: "getAnchor",
|
|
52
|
+
value: function getAnchor() {
|
|
53
|
+
return this.blocks.length === 0 ? "Do_Uc2Sju_ffp6Ev0AnLVdPtot15rvMjP-a9VVaA5fM" : (0, _ramda.last)(this.blockmap[(0, _ramda.last)(this.blocks)].txs);
|
|
54
|
+
}
|
|
55
|
+
}, {
|
|
56
|
+
key: "get",
|
|
57
|
+
value: function () {
|
|
58
|
+
var _get = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(key, field) {
|
|
59
|
+
var _this$key;
|
|
60
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
61
|
+
while (1) switch (_context.prev = _context.next) {
|
|
62
|
+
case 0:
|
|
63
|
+
_context.next = 2;
|
|
64
|
+
return this.init();
|
|
65
|
+
case 2:
|
|
66
|
+
if (field) {
|
|
67
|
+
_context.next = 4;
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
return _context.abrupt("return", this[key]);
|
|
71
|
+
case 4:
|
|
72
|
+
return _context.abrupt("return", (_this$key = this[key]) === null || _this$key === void 0 ? void 0 : _this$key[field]);
|
|
73
|
+
case 5:
|
|
74
|
+
case "end":
|
|
75
|
+
return _context.stop();
|
|
76
|
+
}
|
|
77
|
+
}, _callee, this);
|
|
78
|
+
}));
|
|
79
|
+
function get(_x, _x2) {
|
|
80
|
+
return _get.apply(this, arguments);
|
|
81
|
+
}
|
|
82
|
+
return get;
|
|
83
|
+
}()
|
|
84
|
+
}, {
|
|
85
|
+
key: "set",
|
|
86
|
+
value: function () {
|
|
87
|
+
var _set = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(val, key, field) {
|
|
88
|
+
var _this$key2;
|
|
89
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
90
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
91
|
+
case 0:
|
|
92
|
+
_context2.next = 2;
|
|
93
|
+
return this.init();
|
|
94
|
+
case 2:
|
|
95
|
+
if (field) {
|
|
96
|
+
_context2.next = 9;
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
this[key] = val;
|
|
100
|
+
if (!this.db) {
|
|
101
|
+
_context2.next = 7;
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
_context2.next = 7;
|
|
105
|
+
return this.db.put("".concat(key), this[key]);
|
|
106
|
+
case 7:
|
|
107
|
+
_context2.next = 14;
|
|
108
|
+
break;
|
|
109
|
+
case 9:
|
|
110
|
+
(_this$key2 = this[key]) !== null && _this$key2 !== void 0 ? _this$key2 : this[key] = {};
|
|
111
|
+
this[key][field] = val;
|
|
112
|
+
if (!this.db) {
|
|
113
|
+
_context2.next = 14;
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
116
|
+
_context2.next = 14;
|
|
117
|
+
return this.db.put("".concat(key, ".").concat(field), this[key][field]);
|
|
118
|
+
case 14:
|
|
119
|
+
case "end":
|
|
120
|
+
return _context2.stop();
|
|
121
|
+
}
|
|
122
|
+
}, _callee2, this);
|
|
123
|
+
}));
|
|
124
|
+
function set(_x3, _x4, _x5) {
|
|
125
|
+
return _set.apply(this, arguments);
|
|
126
|
+
}
|
|
127
|
+
return set;
|
|
128
|
+
}()
|
|
129
|
+
}, {
|
|
130
|
+
key: "initSync",
|
|
131
|
+
value: function initSync() {
|
|
132
|
+
this.addrmap = {};
|
|
133
|
+
this.txs = {};
|
|
134
|
+
this.jwks = {};
|
|
135
|
+
this.blocks = [];
|
|
136
|
+
this.blockmap = {};
|
|
137
|
+
this.env = {};
|
|
138
|
+
this.modules = {
|
|
139
|
+
aos2_0_1: "Do_Uc2Sju_ffp6Ev0AnLVdPtot15rvMjP-a9VVaA5fM",
|
|
140
|
+
aos1: "cNlipBptaF9JeFAf4wUmpi43EojNanIBos3EfNrEOWo",
|
|
141
|
+
sqlite: "ghSkge2sIUD_F00ym5sEimC63BDBuBrq4b5OcwxOjiw"
|
|
142
|
+
};
|
|
143
|
+
this.modmap = {};
|
|
144
|
+
this.msgs = {};
|
|
145
|
+
this.wasms = {
|
|
146
|
+
"Do_Uc2Sju_ffp6Ev0AnLVdPtot15rvMjP-a9VVaA5fM": {
|
|
147
|
+
file: "aos2_0_1",
|
|
148
|
+
format: "wasm64-unknown-emscripten-draft_2024_02_15"
|
|
149
|
+
},
|
|
150
|
+
cNlipBptaF9JeFAf4wUmpi43EojNanIBos3EfNrEOWo: {
|
|
151
|
+
file: "aos_1",
|
|
152
|
+
format: "wasm64-unknown-emscripten-draft_2024_02_15"
|
|
153
|
+
},
|
|
154
|
+
ghSkge2sIUD_F00ym5sEimC63BDBuBrq4b5OcwxOjiw: {
|
|
155
|
+
file: "sqlite",
|
|
156
|
+
format: "wasm64-unknown-emscripten-draft_2024_02_15"
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
var txs = [];
|
|
160
|
+
for (var k in this.modules) {
|
|
161
|
+
var key = this.modules[k];
|
|
162
|
+
txs.push(key);
|
|
163
|
+
this.txs[key] = {
|
|
164
|
+
id: key,
|
|
165
|
+
block: 0,
|
|
166
|
+
tags: (0, _utils.buildTags)(null, {
|
|
167
|
+
"Data-Protocol": "ao",
|
|
168
|
+
Variant: "ao.TN.1",
|
|
169
|
+
Type: "Module",
|
|
170
|
+
"Module-Format": "wasm64-unknown-emscripten-draft_2024_02_15",
|
|
171
|
+
"Input-Encoding": "JSON-V1",
|
|
172
|
+
"Output-Encoding": "JSON-V1",
|
|
173
|
+
"Memory-Limit": "1-gb",
|
|
174
|
+
"Compute-Limit": "9000000000000",
|
|
175
|
+
Extension: "WeaveDrive"
|
|
176
|
+
})
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
if (this.scheduler && this.SU_URL) {
|
|
180
|
+
var _key = this.scheduler;
|
|
181
|
+
txs.push(_key);
|
|
182
|
+
this.addrmap[this.scheduler] = {
|
|
183
|
+
address: this.scheduler
|
|
184
|
+
};
|
|
185
|
+
this.txs[_key] = {
|
|
186
|
+
id: _key,
|
|
187
|
+
block: 0,
|
|
188
|
+
owner: this.scheduler,
|
|
189
|
+
tags: (0, _utils.buildTags)(null, {
|
|
190
|
+
"Data-Protocol": "ao",
|
|
191
|
+
Variant: "ao.TN.1",
|
|
192
|
+
Type: "Scheduler-Location",
|
|
193
|
+
Url: this.SU_URL,
|
|
194
|
+
"Time-To-Live": 1000 * 60 * 60 * 24 * 365 * 10
|
|
195
|
+
})
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
this.blockmap["0"] = {
|
|
199
|
+
txs: txs,
|
|
200
|
+
timestamp: Date.now(),
|
|
201
|
+
height: 0,
|
|
202
|
+
previous: "",
|
|
203
|
+
id: "0"
|
|
204
|
+
};
|
|
205
|
+
this.blocks.push("0");
|
|
206
|
+
this.height = 1;
|
|
207
|
+
}
|
|
208
|
+
}, {
|
|
209
|
+
key: "putAll",
|
|
210
|
+
value: function () {
|
|
211
|
+
var _putAll = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(key) {
|
|
212
|
+
var k;
|
|
213
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
214
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
215
|
+
case 0:
|
|
216
|
+
_context3.t0 = _regeneratorRuntime().keys(this[key]);
|
|
217
|
+
case 1:
|
|
218
|
+
if ((_context3.t1 = _context3.t0()).done) {
|
|
219
|
+
_context3.next = 7;
|
|
220
|
+
break;
|
|
221
|
+
}
|
|
222
|
+
k = _context3.t1.value;
|
|
223
|
+
_context3.next = 5;
|
|
224
|
+
return this.set(this[key][k], key, k);
|
|
225
|
+
case 5:
|
|
226
|
+
_context3.next = 1;
|
|
227
|
+
break;
|
|
228
|
+
case 7:
|
|
229
|
+
case "end":
|
|
230
|
+
return _context3.stop();
|
|
231
|
+
}
|
|
232
|
+
}, _callee3, this);
|
|
233
|
+
}));
|
|
234
|
+
function putAll(_x6) {
|
|
235
|
+
return _putAll.apply(this, arguments);
|
|
236
|
+
}
|
|
237
|
+
return putAll;
|
|
238
|
+
}()
|
|
239
|
+
}, {
|
|
240
|
+
key: "init",
|
|
241
|
+
value: function () {
|
|
242
|
+
var _init = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
243
|
+
var _i, _arr, v, _i2, _arr2, _this$_v, _v, items, _iterator, _step, v2, key, field, _i3, _arr3, _v2, _i4, _arr4, _v3;
|
|
244
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
245
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
246
|
+
case 0:
|
|
247
|
+
if (!this.isInit) {
|
|
248
|
+
_context4.next = 2;
|
|
249
|
+
break;
|
|
250
|
+
}
|
|
251
|
+
return _context4.abrupt("return");
|
|
252
|
+
case 2:
|
|
253
|
+
this.isInit = true;
|
|
254
|
+
if (!this.db) {
|
|
255
|
+
_context4.next = 46;
|
|
256
|
+
break;
|
|
257
|
+
}
|
|
258
|
+
_i = 0, _arr = ["height", "blocks"];
|
|
259
|
+
case 5:
|
|
260
|
+
if (!(_i < _arr.length)) {
|
|
261
|
+
_context4.next = 13;
|
|
262
|
+
break;
|
|
263
|
+
}
|
|
264
|
+
v = _arr[_i];
|
|
265
|
+
_context4.next = 9;
|
|
266
|
+
return this.get(v);
|
|
267
|
+
case 9:
|
|
268
|
+
this[v] = _context4.sent;
|
|
269
|
+
case 10:
|
|
270
|
+
_i++;
|
|
271
|
+
_context4.next = 5;
|
|
272
|
+
break;
|
|
273
|
+
case 13:
|
|
274
|
+
_i2 = 0, _arr2 = ["txs", "jwks", "env", "modules", "wasms", "addrmap", "blockmap", "modmap", "msgs"];
|
|
275
|
+
case 14:
|
|
276
|
+
if (!(_i2 < _arr2.length)) {
|
|
277
|
+
_context4.next = 44;
|
|
278
|
+
break;
|
|
279
|
+
}
|
|
280
|
+
_v = _arr2[_i2];
|
|
281
|
+
(_this$_v = this[_v]) !== null && _this$_v !== void 0 ? _this$_v : this[_v] = {};
|
|
282
|
+
_context4.next = 19;
|
|
283
|
+
return this.db.getKeys({
|
|
284
|
+
start: _v,
|
|
285
|
+
end: _v + "a"
|
|
286
|
+
});
|
|
287
|
+
case 19:
|
|
288
|
+
items = _context4.sent;
|
|
289
|
+
_iterator = _createForOfIteratorHelper(items || []);
|
|
290
|
+
_context4.prev = 21;
|
|
291
|
+
_iterator.s();
|
|
292
|
+
case 23:
|
|
293
|
+
if ((_step = _iterator.n()).done) {
|
|
294
|
+
_context4.next = 33;
|
|
295
|
+
break;
|
|
296
|
+
}
|
|
297
|
+
v2 = _step.value;
|
|
298
|
+
key = v2.split(".")[0];
|
|
299
|
+
field = v2.split(".")[1];
|
|
300
|
+
if (!(key === _v)) {
|
|
301
|
+
_context4.next = 31;
|
|
302
|
+
break;
|
|
303
|
+
}
|
|
304
|
+
_context4.next = 30;
|
|
305
|
+
return this.db.get(v2);
|
|
306
|
+
case 30:
|
|
307
|
+
this[_v][field] = _context4.sent;
|
|
308
|
+
case 31:
|
|
309
|
+
_context4.next = 23;
|
|
310
|
+
break;
|
|
311
|
+
case 33:
|
|
312
|
+
_context4.next = 38;
|
|
313
|
+
break;
|
|
314
|
+
case 35:
|
|
315
|
+
_context4.prev = 35;
|
|
316
|
+
_context4.t0 = _context4["catch"](21);
|
|
317
|
+
_iterator.e(_context4.t0);
|
|
318
|
+
case 38:
|
|
319
|
+
_context4.prev = 38;
|
|
320
|
+
_iterator.f();
|
|
321
|
+
return _context4.finish(38);
|
|
322
|
+
case 41:
|
|
323
|
+
_i2++;
|
|
324
|
+
_context4.next = 14;
|
|
325
|
+
break;
|
|
326
|
+
case 44:
|
|
327
|
+
_context4.next = 62;
|
|
328
|
+
break;
|
|
329
|
+
case 46:
|
|
330
|
+
_i3 = 0, _arr3 = ["height", "blocks"];
|
|
331
|
+
case 47:
|
|
332
|
+
if (!(_i3 < _arr3.length)) {
|
|
333
|
+
_context4.next = 54;
|
|
334
|
+
break;
|
|
335
|
+
}
|
|
336
|
+
_v2 = _arr3[_i3];
|
|
337
|
+
_context4.next = 51;
|
|
338
|
+
return this.set(this[_v2], _v2);
|
|
339
|
+
case 51:
|
|
340
|
+
_i3++;
|
|
341
|
+
_context4.next = 47;
|
|
342
|
+
break;
|
|
343
|
+
case 54:
|
|
344
|
+
_i4 = 0, _arr4 = ["modules", "wasms", "addrmap", "blockmap"];
|
|
345
|
+
case 55:
|
|
346
|
+
if (!(_i4 < _arr4.length)) {
|
|
347
|
+
_context4.next = 62;
|
|
348
|
+
break;
|
|
349
|
+
}
|
|
350
|
+
_v3 = _arr4[_i4];
|
|
351
|
+
_context4.next = 59;
|
|
352
|
+
return this.putAll(_v3);
|
|
353
|
+
case 59:
|
|
354
|
+
_i4++;
|
|
355
|
+
_context4.next = 55;
|
|
356
|
+
break;
|
|
357
|
+
case 62:
|
|
358
|
+
case "end":
|
|
359
|
+
return _context4.stop();
|
|
360
|
+
}
|
|
361
|
+
}, _callee4, this, [[21, 35, 38, 41]]);
|
|
362
|
+
}));
|
|
363
|
+
function init() {
|
|
364
|
+
return _init.apply(this, arguments);
|
|
365
|
+
}
|
|
366
|
+
return init;
|
|
367
|
+
}()
|
|
368
|
+
}, {
|
|
369
|
+
key: "getWasm",
|
|
370
|
+
value: function () {
|
|
371
|
+
var _getWasm = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5(module) {
|
|
372
|
+
var _format;
|
|
373
|
+
var mod, format, _wasm, wasm, tx;
|
|
374
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
375
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
376
|
+
case 0:
|
|
377
|
+
mod = module !== null && module !== void 0 ? module : this.modules.aos2_0_1;
|
|
378
|
+
if (mod) {
|
|
379
|
+
_context5.next = 3;
|
|
380
|
+
break;
|
|
381
|
+
}
|
|
382
|
+
throw Error("module not found");
|
|
383
|
+
case 3:
|
|
384
|
+
format = null;
|
|
385
|
+
_context5.next = 6;
|
|
386
|
+
return this.wasms[mod];
|
|
387
|
+
case 6:
|
|
388
|
+
_wasm = _context5.sent;
|
|
389
|
+
wasm = _wasm === null || _wasm === void 0 ? void 0 : _wasm.data;
|
|
390
|
+
if (wasm) {
|
|
391
|
+
_context5.next = 22;
|
|
392
|
+
break;
|
|
393
|
+
}
|
|
394
|
+
if (!(_wasm !== null && _wasm !== void 0 && _wasm.file)) {
|
|
395
|
+
_context5.next = 16;
|
|
396
|
+
break;
|
|
397
|
+
}
|
|
398
|
+
_context5.next = 12;
|
|
399
|
+
return this._getWasm(this.wasms[mod].file);
|
|
400
|
+
case 12:
|
|
401
|
+
wasm = _context5.sent;
|
|
402
|
+
format = _wasm.format;
|
|
403
|
+
_context5.next = 20;
|
|
404
|
+
break;
|
|
405
|
+
case 16:
|
|
406
|
+
_context5.next = 18;
|
|
407
|
+
return this.get("txs", mod);
|
|
408
|
+
case 18:
|
|
409
|
+
tx = _context5.sent;
|
|
410
|
+
if (tx) {
|
|
411
|
+
wasm = Buffer.from(tx.data, "base64");
|
|
412
|
+
format = (0, _utils.tags)(tx.tags)["Module-Format"];
|
|
413
|
+
}
|
|
414
|
+
case 20:
|
|
415
|
+
_context5.next = 23;
|
|
416
|
+
break;
|
|
417
|
+
case 22:
|
|
418
|
+
format = _wasm.format;
|
|
419
|
+
case 23:
|
|
420
|
+
(_format = format) !== null && _format !== void 0 ? _format : format = "wasm64-unknown-emscripten-draft_2024_02_15";
|
|
421
|
+
return _context5.abrupt("return", {
|
|
422
|
+
format: format,
|
|
423
|
+
mod: mod,
|
|
424
|
+
wasm: wasm
|
|
425
|
+
});
|
|
426
|
+
case 25:
|
|
427
|
+
case "end":
|
|
428
|
+
return _context5.stop();
|
|
429
|
+
}
|
|
430
|
+
}, _callee5, this);
|
|
431
|
+
}));
|
|
432
|
+
function getWasm(_x7) {
|
|
433
|
+
return _getWasm.apply(this, arguments);
|
|
434
|
+
}
|
|
435
|
+
return getWasm;
|
|
436
|
+
}()
|
|
437
|
+
}]);
|
|
438
|
+
}();
|