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