wao 0.40.2 → 0.41.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/accounts-web.js +25 -0
- package/cjs/accounts.js +38 -0
- package/cjs/adaptor-base.js +504 -287
- package/cjs/adaptor-cf.js +42 -0
- package/cjs/ao-loader.js +1 -1
- package/cjs/ao.js +18 -6
- package/cjs/aoconnect-base.js +1017 -546
- package/cjs/aoconnect-cf.js +24 -0
- package/cjs/ar-remote.js +277 -0
- package/cjs/armem-base.js +822 -211
- package/cjs/armem-cf.js +128 -0
- package/cjs/armem.js +11 -5
- package/cjs/bar.js +511 -173
- package/cjs/car.js +37 -0
- package/cjs/cf-env.js +54 -0
- package/cjs/cf.js +76 -0
- package/cjs/cli.js +12 -6
- package/cjs/create.js +1 -1
- package/cjs/devs.js +53 -0
- package/cjs/dodb.js +116 -0
- package/cjs/hb.js +136 -53
- package/cjs/hyperbeam.js +85 -44
- package/cjs/keygen.js +94 -0
- package/cjs/run.js +4 -1
- package/cjs/server.js +40 -9
- package/cjs/storage-multi.js +525 -0
- package/cjs/tgql-d1.js +664 -0
- package/cjs/tgql.js +293 -172
- package/cjs/workspace/.claude/agents/tester.md +2 -2
- package/cjs/workspace/.claude/skills/build/SKILL.md +2 -2
- package/cjs/workspace/.claude/skills/test/SKILL.md +3 -2
- package/cjs/workspace/CLAUDE.md +2 -2
- package/cjs/workspace/README.md +1 -1
- package/cjs/workspace/docs/debug.md +9 -4
- package/cjs/workspace/docs/hyperbeam-devices.md +50 -1
- package/cjs/workspace/package.json +3 -3
- package/esm/accounts-web.js +14 -0
- package/esm/accounts.js +27 -0
- package/esm/adaptor-base.js +129 -31
- package/esm/adaptor-cf.js +11 -0
- package/esm/ao-loader.js +1 -1
- package/esm/ao.js +21 -2
- package/esm/aoconnect-base.js +255 -7
- package/esm/aoconnect-cf.js +9 -0
- package/esm/ar-remote.js +87 -0
- package/esm/armem-base.js +304 -53
- package/esm/armem-cf.js +67 -0
- package/esm/armem.js +7 -2
- package/esm/bar.js +126 -16
- package/esm/car.js +10 -0
- package/esm/cf-env.js +29 -0
- package/esm/cf.js +11 -0
- package/esm/cli.js +6 -2
- package/esm/create.js +1 -1
- package/esm/devs.js +15 -0
- package/esm/dodb.js +26 -0
- package/esm/hb.js +93 -16
- package/esm/hyperbeam.js +68 -30
- package/esm/keygen.js +47 -0
- package/esm/run.js +4 -1
- package/esm/server.js +29 -9
- package/esm/storage-multi.js +183 -0
- package/esm/tgql-d1.js +407 -0
- package/esm/tgql.js +29 -10
- package/esm/workspace/.claude/agents/tester.md +2 -2
- package/esm/workspace/.claude/skills/build/SKILL.md +2 -2
- package/esm/workspace/.claude/skills/test/SKILL.md +3 -2
- package/esm/workspace/CLAUDE.md +2 -2
- package/esm/workspace/README.md +1 -1
- package/esm/workspace/docs/debug.md +9 -4
- package/esm/workspace/docs/hyperbeam-devices.md +50 -1
- package/esm/workspace/package.json +3 -3
- package/package.json +10 -3
- package/postinstall.cjs +84 -0
- package/wao-0.41.1.tgz +0 -0
package/cjs/bar.js
CHANGED
|
@@ -12,8 +12,12 @@ var _base64url = _interopRequireDefault(require("base64url"));
|
|
|
12
12
|
var _tgql = _interopRequireDefault(require("./tgql.js"));
|
|
13
13
|
var _ramda = require("ramda");
|
|
14
14
|
var _WarpArBundles$defaul;
|
|
15
|
-
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var
|
|
15
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t31 in e) "default" !== _t31 && {}.hasOwnProperty.call(e, _t31) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t31)) && (i.get || i.set) ? o(f, _t31, i) : f[_t31] = e[_t31]); return f; })(e, t); }
|
|
16
16
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
17
|
+
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
|
18
|
+
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."); }
|
|
19
|
+
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
20
|
+
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
|
|
17
21
|
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
|
|
18
22
|
function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
|
|
19
23
|
function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
|
|
@@ -63,7 +67,7 @@ function parseSignatureInput(input) {
|
|
|
63
67
|
}
|
|
64
68
|
var AR = /*#__PURE__*/function (_MAR) {
|
|
65
69
|
function AR() {
|
|
66
|
-
var _opt$mem;
|
|
70
|
+
var _opt$mem, _opt$batchWindow;
|
|
67
71
|
var _this;
|
|
68
72
|
var opt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
69
73
|
_classCallCheck(this, AR);
|
|
@@ -77,6 +81,10 @@ var AR = /*#__PURE__*/function (_MAR) {
|
|
|
77
81
|
mem: _this.mem
|
|
78
82
|
});
|
|
79
83
|
_this.arweave = _this.mem.arweave;
|
|
84
|
+
// Block batching (DB path only)
|
|
85
|
+
_this._pendingBatch = [];
|
|
86
|
+
_this._flushTimer = null;
|
|
87
|
+
_this._batchWindow = (_opt$batchWindow = opt.batchWindow) !== null && _opt$batchWindow !== void 0 ? _opt$batchWindow : 0; // ms, 0 = disabled
|
|
80
88
|
return _this;
|
|
81
89
|
}
|
|
82
90
|
_inherits(AR, _MAR);
|
|
@@ -270,41 +278,84 @@ var AR = /*#__PURE__*/function (_MAR) {
|
|
|
270
278
|
key: "postItems",
|
|
271
279
|
value: function () {
|
|
272
280
|
var _postItems = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(items, jwk) {
|
|
273
|
-
var
|
|
281
|
+
var _err, _yield$this$checkWall2, _bundle, _tx, err, _yield$this$checkWall3, _items, _iterator2, _step2, _this$mem$db, _this$mem$db2, di, data_size, data_type, _iterator3, _step3, _t8, owner, _item, bundle, tx, _t9, _t0, _t1, _t10, _t11, _t12, _t13, _t14, _t15, _t16, _t17, _t18, _t19;
|
|
274
282
|
return _regenerator().w(function (_context5) {
|
|
275
283
|
while (1) switch (_context5.p = _context5.n) {
|
|
276
284
|
case 0:
|
|
277
|
-
|
|
285
|
+
if (!this.mem._remote) {
|
|
286
|
+
_context5.n = 6;
|
|
287
|
+
break;
|
|
288
|
+
}
|
|
289
|
+
_err = null;
|
|
278
290
|
_context5.n = 1;
|
|
279
291
|
return this.checkWallet({
|
|
280
292
|
jwk: jwk
|
|
281
293
|
});
|
|
282
294
|
case 1:
|
|
283
295
|
_yield$this$checkWall2 = _context5.v;
|
|
284
|
-
|
|
296
|
+
_err = _yield$this$checkWall2.err;
|
|
285
297
|
jwk = _yield$this$checkWall2.jwk;
|
|
286
|
-
if (!
|
|
298
|
+
if (!_err) {
|
|
287
299
|
_context5.n = 2;
|
|
288
300
|
break;
|
|
289
301
|
}
|
|
290
302
|
return _context5.a(2, {
|
|
291
|
-
err:
|
|
303
|
+
err: _err
|
|
292
304
|
});
|
|
293
305
|
case 2:
|
|
306
|
+
if (!(0, _ramda.is)(Array, items)) items = [items];
|
|
307
|
+
_context5.n = 3;
|
|
308
|
+
return (0, _arbundles.bundleAndSignData)(items, new _arbundles.ArweaveSigner(jwk));
|
|
309
|
+
case 3:
|
|
310
|
+
_bundle = _context5.v;
|
|
311
|
+
_context5.n = 4;
|
|
312
|
+
return this.mem.arweave.createTransaction({
|
|
313
|
+
data: _bundle.binary
|
|
314
|
+
}, jwk);
|
|
315
|
+
case 4:
|
|
316
|
+
_tx = _context5.v;
|
|
317
|
+
_tx.addTag("Bundle-Format", "binary");
|
|
318
|
+
_tx.addTag("Bundle-Version", "2.0.0");
|
|
319
|
+
_context5.n = 5;
|
|
320
|
+
return this.postTx(_tx, jwk, items.map(function (i) {
|
|
321
|
+
return {
|
|
322
|
+
id: i.id
|
|
323
|
+
};
|
|
324
|
+
}));
|
|
325
|
+
case 5:
|
|
326
|
+
return _context5.a(2, _context5.v);
|
|
327
|
+
case 6:
|
|
328
|
+
err = null;
|
|
329
|
+
_context5.n = 7;
|
|
330
|
+
return this.checkWallet({
|
|
331
|
+
jwk: jwk
|
|
332
|
+
});
|
|
333
|
+
case 7:
|
|
334
|
+
_yield$this$checkWall3 = _context5.v;
|
|
335
|
+
err = _yield$this$checkWall3.err;
|
|
336
|
+
jwk = _yield$this$checkWall3.jwk;
|
|
337
|
+
if (!err) {
|
|
338
|
+
_context5.n = 8;
|
|
339
|
+
break;
|
|
340
|
+
}
|
|
341
|
+
return _context5.a(2, {
|
|
342
|
+
err: err
|
|
343
|
+
});
|
|
344
|
+
case 8:
|
|
294
345
|
if (!(0, _ramda.is)(Array, items)) items = [items];
|
|
295
346
|
_items = [];
|
|
296
347
|
_iterator2 = _createForOfIteratorHelper(items);
|
|
297
|
-
_context5.p =
|
|
348
|
+
_context5.p = 9;
|
|
298
349
|
_iterator2.s();
|
|
299
|
-
case
|
|
350
|
+
case 10:
|
|
300
351
|
if ((_step2 = _iterator2.n()).done) {
|
|
301
|
-
_context5.n =
|
|
352
|
+
_context5.n = 24;
|
|
302
353
|
break;
|
|
303
354
|
}
|
|
304
355
|
di = _step2.value;
|
|
305
|
-
_context5.n =
|
|
356
|
+
_context5.n = 11;
|
|
306
357
|
return di.id;
|
|
307
|
-
case
|
|
358
|
+
case 11:
|
|
308
359
|
di._id = _context5.v;
|
|
309
360
|
data_size = Buffer.byteLength(di.rawData).toString();
|
|
310
361
|
data_type = "";
|
|
@@ -319,84 +370,111 @@ var AR = /*#__PURE__*/function (_MAR) {
|
|
|
319
370
|
} finally {
|
|
320
371
|
_iterator3.f();
|
|
321
372
|
}
|
|
322
|
-
_context5.n =
|
|
373
|
+
_context5.n = 12;
|
|
323
374
|
return this.owner(di);
|
|
324
|
-
case
|
|
375
|
+
case 12:
|
|
325
376
|
owner = _context5.v;
|
|
326
|
-
_context5.n =
|
|
377
|
+
_context5.n = 13;
|
|
327
378
|
return this.mem.set({
|
|
328
379
|
key: di.owner,
|
|
329
380
|
address: owner
|
|
330
381
|
}, "addrmap", owner);
|
|
331
|
-
case
|
|
332
|
-
|
|
382
|
+
case 13:
|
|
383
|
+
if (!((_this$mem$db = this.mem.db) !== null && _this$mem$db !== void 0 && _this$mem$db.d1WriteAddrmap)) {
|
|
384
|
+
_context5.n = 17;
|
|
385
|
+
break;
|
|
386
|
+
}
|
|
387
|
+
_context5.p = 14;
|
|
388
|
+
_context5.n = 15;
|
|
389
|
+
return this.mem.db.d1WriteAddrmap(owner, {
|
|
390
|
+
key: di.owner,
|
|
391
|
+
address: owner
|
|
392
|
+
});
|
|
393
|
+
case 15:
|
|
394
|
+
_context5.n = 17;
|
|
395
|
+
break;
|
|
396
|
+
case 16:
|
|
397
|
+
_context5.p = 16;
|
|
398
|
+
_t9 = _context5.v;
|
|
399
|
+
case 17:
|
|
400
|
+
_t0 = {
|
|
333
401
|
size: data_size,
|
|
334
402
|
type: data_type
|
|
335
403
|
};
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
_context5.n =
|
|
404
|
+
_t1 = di.anchor;
|
|
405
|
+
_t10 = di.signature;
|
|
406
|
+
_t11 = di.target;
|
|
407
|
+
_context5.n = 18;
|
|
340
408
|
return di.id;
|
|
341
|
-
case
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
409
|
+
case 18:
|
|
410
|
+
_t12 = _context5.v;
|
|
411
|
+
_t13 = di;
|
|
412
|
+
_t14 = owner;
|
|
413
|
+
_t15 = di.tags;
|
|
414
|
+
_t16 = di.data;
|
|
347
415
|
_item = {
|
|
348
|
-
_data:
|
|
349
|
-
anchor:
|
|
350
|
-
signature:
|
|
351
|
-
recipient:
|
|
352
|
-
id:
|
|
353
|
-
item:
|
|
354
|
-
owner:
|
|
355
|
-
tags:
|
|
356
|
-
data:
|
|
416
|
+
_data: _t0,
|
|
417
|
+
anchor: _t1,
|
|
418
|
+
signature: _t10,
|
|
419
|
+
recipient: _t11,
|
|
420
|
+
id: _t12,
|
|
421
|
+
item: _t13,
|
|
422
|
+
owner: _t14,
|
|
423
|
+
tags: _t15,
|
|
424
|
+
data: _t16
|
|
357
425
|
};
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
426
|
+
if (!(_item.data && (_this$mem$db2 = this.mem.db) !== null && _this$mem$db2 !== void 0 && _this$mem$db2.r2PutTxData)) {
|
|
427
|
+
_context5.n = 20;
|
|
428
|
+
break;
|
|
429
|
+
}
|
|
430
|
+
_context5.n = 19;
|
|
431
|
+
return this.mem.db.r2PutTxData(_item.id, _item.data);
|
|
432
|
+
case 19:
|
|
433
|
+
_item._r2_data = true;
|
|
434
|
+
_item.data = "";
|
|
435
|
+
case 20:
|
|
436
|
+
_t17 = this.mem;
|
|
437
|
+
_t18 = _item;
|
|
438
|
+
_context5.n = 21;
|
|
361
439
|
return di.id;
|
|
362
|
-
case
|
|
363
|
-
_context5.n =
|
|
364
|
-
return
|
|
365
|
-
case
|
|
440
|
+
case 21:
|
|
441
|
+
_context5.n = 22;
|
|
442
|
+
return _t17.set.call(_t17, _t18, "txs", _context5.v);
|
|
443
|
+
case 22:
|
|
366
444
|
_items.push(_item);
|
|
367
|
-
case
|
|
368
|
-
_context5.n =
|
|
445
|
+
case 23:
|
|
446
|
+
_context5.n = 10;
|
|
369
447
|
break;
|
|
370
|
-
case
|
|
371
|
-
_context5.n =
|
|
448
|
+
case 24:
|
|
449
|
+
_context5.n = 26;
|
|
372
450
|
break;
|
|
373
|
-
case
|
|
374
|
-
_context5.p =
|
|
375
|
-
|
|
376
|
-
_iterator2.e(
|
|
377
|
-
case
|
|
378
|
-
_context5.p =
|
|
451
|
+
case 25:
|
|
452
|
+
_context5.p = 25;
|
|
453
|
+
_t19 = _context5.v;
|
|
454
|
+
_iterator2.e(_t19);
|
|
455
|
+
case 26:
|
|
456
|
+
_context5.p = 26;
|
|
379
457
|
_iterator2.f();
|
|
380
|
-
return _context5.f(
|
|
381
|
-
case
|
|
382
|
-
_context5.n =
|
|
458
|
+
return _context5.f(26);
|
|
459
|
+
case 27:
|
|
460
|
+
_context5.n = 28;
|
|
383
461
|
return (0, _arbundles.bundleAndSignData)(items, new _arbundles.ArweaveSigner(jwk));
|
|
384
|
-
case
|
|
462
|
+
case 28:
|
|
385
463
|
bundle = _context5.v;
|
|
386
|
-
_context5.n =
|
|
464
|
+
_context5.n = 29;
|
|
387
465
|
return this.mem.arweave.createTransaction({
|
|
388
466
|
data: bundle.binary
|
|
389
467
|
}, jwk);
|
|
390
|
-
case
|
|
468
|
+
case 29:
|
|
391
469
|
tx = _context5.v;
|
|
392
470
|
tx.addTag("Bundle-Format", "binary");
|
|
393
471
|
tx.addTag("Bundle-Version", "2.0.0");
|
|
394
|
-
_context5.n =
|
|
472
|
+
_context5.n = 30;
|
|
395
473
|
return this.postTx(tx, jwk, _items);
|
|
396
|
-
case
|
|
474
|
+
case 30:
|
|
397
475
|
return _context5.a(2, _context5.v);
|
|
398
476
|
}
|
|
399
|
-
}, _callee5, this, [[
|
|
477
|
+
}, _callee5, this, [[14, 16], [9, 25, 26, 27]]);
|
|
400
478
|
}));
|
|
401
479
|
function postItems(_x5, _x6) {
|
|
402
480
|
return _postItems.apply(this, arguments);
|
|
@@ -407,12 +485,22 @@ var AR = /*#__PURE__*/function (_MAR) {
|
|
|
407
485
|
key: "postTx",
|
|
408
486
|
value: function () {
|
|
409
487
|
var _postTx = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(tx, jwk) {
|
|
410
|
-
var _last
|
|
488
|
+
var _last,
|
|
489
|
+
_this$mem$db3,
|
|
490
|
+
_this$mem,
|
|
491
|
+
_this$mem$blocks,
|
|
492
|
+
_this$mem$db5,
|
|
493
|
+
_this2 = this;
|
|
411
494
|
var items,
|
|
495
|
+
_err2,
|
|
496
|
+
_yield$this$checkWall4,
|
|
497
|
+
_res,
|
|
412
498
|
err,
|
|
413
|
-
_yield$this$
|
|
499
|
+
_yield$this$checkWall5,
|
|
414
500
|
res,
|
|
415
501
|
height,
|
|
502
|
+
_this$mem$height,
|
|
503
|
+
previous,
|
|
416
504
|
block,
|
|
417
505
|
msg,
|
|
418
506
|
_iterator4,
|
|
@@ -424,16 +512,20 @@ var AR = /*#__PURE__*/function (_MAR) {
|
|
|
424
512
|
_iterator5,
|
|
425
513
|
_step5,
|
|
426
514
|
v,
|
|
515
|
+
slim,
|
|
427
516
|
_tags,
|
|
428
517
|
_iterator6,
|
|
429
518
|
_step6,
|
|
430
519
|
_v,
|
|
431
520
|
__tags,
|
|
432
521
|
_txs,
|
|
433
|
-
|
|
522
|
+
_this$mem$db4,
|
|
434
523
|
owner,
|
|
524
|
+
mainTx,
|
|
525
|
+
_iterator7,
|
|
526
|
+
_step7,
|
|
527
|
+
_item2,
|
|
435
528
|
_args6 = arguments,
|
|
436
|
-
_t19,
|
|
437
529
|
_t20,
|
|
438
530
|
_t21,
|
|
439
531
|
_t22,
|
|
@@ -442,30 +534,32 @@ var AR = /*#__PURE__*/function (_MAR) {
|
|
|
442
534
|
_t25,
|
|
443
535
|
_t26,
|
|
444
536
|
_t27,
|
|
445
|
-
_t28
|
|
446
|
-
_t29;
|
|
537
|
+
_t28;
|
|
447
538
|
return _regenerator().w(function (_context6) {
|
|
448
539
|
while (1) switch (_context6.p = _context6.n) {
|
|
449
540
|
case 0:
|
|
450
541
|
items = _args6.length > 2 && _args6[2] !== undefined ? _args6[2] : [];
|
|
451
|
-
|
|
542
|
+
if (!this.mem._remote) {
|
|
543
|
+
_context6.n = 5;
|
|
544
|
+
break;
|
|
545
|
+
}
|
|
546
|
+
_err2 = null;
|
|
452
547
|
_context6.n = 1;
|
|
453
548
|
return this.checkWallet({
|
|
454
549
|
jwk: jwk
|
|
455
550
|
});
|
|
456
551
|
case 1:
|
|
457
|
-
_yield$this$
|
|
458
|
-
|
|
459
|
-
jwk = _yield$this$
|
|
460
|
-
if (!
|
|
552
|
+
_yield$this$checkWall4 = _context6.v;
|
|
553
|
+
_err2 = _yield$this$checkWall4.err;
|
|
554
|
+
jwk = _yield$this$checkWall4.jwk;
|
|
555
|
+
if (!_err2) {
|
|
461
556
|
_context6.n = 2;
|
|
462
557
|
break;
|
|
463
558
|
}
|
|
464
559
|
return _context6.a(2, {
|
|
465
|
-
err:
|
|
560
|
+
err: _err2
|
|
466
561
|
});
|
|
467
562
|
case 2:
|
|
468
|
-
res = null;
|
|
469
563
|
if (tx.id) {
|
|
470
564
|
_context6.n = 3;
|
|
471
565
|
break;
|
|
@@ -474,58 +568,119 @@ var AR = /*#__PURE__*/function (_MAR) {
|
|
|
474
568
|
return this.mem.arweave.transactions.sign(tx, jwk);
|
|
475
569
|
case 3:
|
|
476
570
|
_context6.n = 4;
|
|
477
|
-
return this.mem.
|
|
571
|
+
return this.mem._remote.postTx(tx);
|
|
478
572
|
case 4:
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
573
|
+
_res = _context6.v;
|
|
574
|
+
return _context6.a(2, {
|
|
575
|
+
res: {
|
|
576
|
+
id: tx.id,
|
|
577
|
+
status: 200
|
|
578
|
+
},
|
|
579
|
+
err: null,
|
|
580
|
+
id: tx.id
|
|
581
|
+
});
|
|
483
582
|
case 5:
|
|
484
|
-
|
|
485
|
-
_t21 = Date.now();
|
|
486
|
-
_t22 = height;
|
|
487
|
-
_t24 = _ramda.last;
|
|
583
|
+
err = null;
|
|
488
584
|
_context6.n = 6;
|
|
489
|
-
return this.
|
|
585
|
+
return this.checkWallet({
|
|
586
|
+
jwk: jwk
|
|
587
|
+
});
|
|
490
588
|
case 6:
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
589
|
+
_yield$this$checkWall5 = _context6.v;
|
|
590
|
+
err = _yield$this$checkWall5.err;
|
|
591
|
+
jwk = _yield$this$checkWall5.jwk;
|
|
592
|
+
if (!err) {
|
|
494
593
|
_context6.n = 7;
|
|
495
594
|
break;
|
|
496
595
|
}
|
|
497
|
-
|
|
596
|
+
return _context6.a(2, {
|
|
597
|
+
err: err
|
|
598
|
+
});
|
|
498
599
|
case 7:
|
|
499
|
-
|
|
600
|
+
res = null;
|
|
601
|
+
if (tx.id) {
|
|
500
602
|
_context6.n = 8;
|
|
501
603
|
break;
|
|
502
604
|
}
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
break;
|
|
605
|
+
_context6.n = 8;
|
|
606
|
+
return this.mem.arweave.transactions.sign(tx, jwk);
|
|
506
607
|
case 8:
|
|
507
|
-
|
|
608
|
+
if (!this.mem._d1Ready) {
|
|
609
|
+
_context6.n = 10;
|
|
610
|
+
break;
|
|
611
|
+
}
|
|
612
|
+
// D1 ready: increment in-memory, flush every 10 txs
|
|
613
|
+
this.mem.height = ((_this$mem$height = this.mem.height) !== null && _this$mem$height !== void 0 ? _this$mem$height : 0) + 1;
|
|
614
|
+
height = this.mem.height;
|
|
615
|
+
if (!(height % 10 === 0)) {
|
|
616
|
+
_context6.n = 9;
|
|
617
|
+
break;
|
|
618
|
+
}
|
|
619
|
+
_context6.n = 9;
|
|
620
|
+
return this.mem.set(height, "height");
|
|
508
621
|
case 9:
|
|
509
|
-
|
|
510
|
-
|
|
622
|
+
_context6.n = 12;
|
|
623
|
+
break;
|
|
624
|
+
case 10:
|
|
625
|
+
_context6.n = 11;
|
|
626
|
+
return this.mem.get("height");
|
|
627
|
+
case 11:
|
|
628
|
+
_t20 = _context6.v;
|
|
629
|
+
height = _t20 + 1;
|
|
630
|
+
_context6.n = 12;
|
|
631
|
+
return this.mem.set(height, "height");
|
|
632
|
+
case 12:
|
|
633
|
+
if (!this.mem._d1Ready) {
|
|
634
|
+
_context6.n = 13;
|
|
635
|
+
break;
|
|
636
|
+
}
|
|
637
|
+
_t21 = this.mem.lastBlockId || "";
|
|
638
|
+
_context6.n = 18;
|
|
639
|
+
break;
|
|
640
|
+
case 13:
|
|
641
|
+
_t23 = _ramda.last;
|
|
642
|
+
_context6.n = 14;
|
|
643
|
+
return this.mem.get("blocks");
|
|
644
|
+
case 14:
|
|
645
|
+
_t24 = _last = _t23(_context6.v);
|
|
646
|
+
_t22 = _t24 !== null;
|
|
647
|
+
if (!_t22) {
|
|
648
|
+
_context6.n = 15;
|
|
649
|
+
break;
|
|
650
|
+
}
|
|
651
|
+
_t22 = _last !== void 0;
|
|
652
|
+
case 15:
|
|
653
|
+
if (!_t22) {
|
|
654
|
+
_context6.n = 16;
|
|
655
|
+
break;
|
|
656
|
+
}
|
|
657
|
+
_t25 = _last;
|
|
658
|
+
_context6.n = 17;
|
|
659
|
+
break;
|
|
660
|
+
case 16:
|
|
661
|
+
_t25 = "";
|
|
662
|
+
case 17:
|
|
663
|
+
_t21 = _t25;
|
|
664
|
+
case 18:
|
|
665
|
+
previous = _t21;
|
|
511
666
|
block = {
|
|
512
|
-
id:
|
|
513
|
-
timestamp:
|
|
514
|
-
height:
|
|
515
|
-
previous:
|
|
516
|
-
txs:
|
|
667
|
+
id: tx.id,
|
|
668
|
+
timestamp: Date.now(),
|
|
669
|
+
height: height,
|
|
670
|
+
previous: previous,
|
|
671
|
+
txs: []
|
|
517
672
|
};
|
|
518
673
|
msg = null;
|
|
519
674
|
if (!items) {
|
|
520
|
-
_context6.n =
|
|
675
|
+
_context6.n = 25;
|
|
521
676
|
break;
|
|
522
677
|
}
|
|
523
678
|
_iterator4 = _createForOfIteratorHelper(items);
|
|
524
|
-
_context6.p =
|
|
679
|
+
_context6.p = 19;
|
|
525
680
|
_iterator4.s();
|
|
526
|
-
case
|
|
681
|
+
case 20:
|
|
527
682
|
if ((_step4 = _iterator4.n()).done) {
|
|
528
|
-
_context6.n =
|
|
683
|
+
_context6.n = 22;
|
|
529
684
|
break;
|
|
530
685
|
}
|
|
531
686
|
item = _step4.value;
|
|
@@ -538,7 +693,7 @@ var AR = /*#__PURE__*/function (_MAR) {
|
|
|
538
693
|
};
|
|
539
694
|
_txs2.anchor = "";
|
|
540
695
|
_tags2 = (0, _utils.tags)(item.tags);
|
|
541
|
-
if ((0, _ramda.includes)(_tags2.Type, ["Message", "Process", "Module", "Scheduler-Location", "Attestation", "Available"])) {
|
|
696
|
+
if ((0, _ramda.includes)(_tags2.Type, ["Message", "Process", "Module", "Scheduler-Location", "Scheduler-Transfer", "Attestation", "Available"])) {
|
|
542
697
|
msg = {
|
|
543
698
|
id: item.id,
|
|
544
699
|
type: _tags2.Type
|
|
@@ -559,25 +714,30 @@ var AR = /*#__PURE__*/function (_MAR) {
|
|
|
559
714
|
}
|
|
560
715
|
block.txs.push(item.id);
|
|
561
716
|
_txs2.block = block.id;
|
|
562
|
-
|
|
563
|
-
|
|
717
|
+
// Re-store item with parent/bundledIn/block, but drop the raw
|
|
718
|
+
// DataItem binary (item.item) to save space — data is in R2 or
|
|
719
|
+
// can be reconstructed from the wrapper bundle tx.
|
|
720
|
+
slim = _objectSpread(_objectSpread({}, _txs2), {}, {
|
|
564
721
|
bundle: tx.id
|
|
565
|
-
}
|
|
566
|
-
|
|
567
|
-
_context6.n =
|
|
722
|
+
});
|
|
723
|
+
delete slim.item;
|
|
724
|
+
_context6.n = 21;
|
|
725
|
+
return this.mem.set(slim, "txs", item.id);
|
|
726
|
+
case 21:
|
|
727
|
+
_context6.n = 20;
|
|
568
728
|
break;
|
|
569
|
-
case
|
|
570
|
-
_context6.n =
|
|
729
|
+
case 22:
|
|
730
|
+
_context6.n = 24;
|
|
571
731
|
break;
|
|
572
|
-
case
|
|
573
|
-
_context6.p =
|
|
574
|
-
|
|
575
|
-
_iterator4.e(
|
|
576
|
-
case
|
|
577
|
-
_context6.p =
|
|
732
|
+
case 23:
|
|
733
|
+
_context6.p = 23;
|
|
734
|
+
_t26 = _context6.v;
|
|
735
|
+
_iterator4.e(_t26);
|
|
736
|
+
case 24:
|
|
737
|
+
_context6.p = 24;
|
|
578
738
|
_iterator4.f();
|
|
579
|
-
return _context6.f(
|
|
580
|
-
case
|
|
739
|
+
return _context6.f(24);
|
|
740
|
+
case 25:
|
|
581
741
|
_tags = [];
|
|
582
742
|
_iterator6 = _createForOfIteratorHelper(tx.tags);
|
|
583
743
|
try {
|
|
@@ -595,53 +755,155 @@ var AR = /*#__PURE__*/function (_MAR) {
|
|
|
595
755
|
}
|
|
596
756
|
__tags = (0, _utils.tags)(_tags);
|
|
597
757
|
if (!(__tags.Type === "Module")) {
|
|
598
|
-
_context6.n =
|
|
758
|
+
_context6.n = 26;
|
|
599
759
|
break;
|
|
600
760
|
}
|
|
601
|
-
_context6.n =
|
|
761
|
+
_context6.n = 26;
|
|
602
762
|
return this.mem.set({
|
|
603
763
|
data: Buffer.from(tx.data, "base64"),
|
|
604
764
|
format: __tags["Module-Format"]
|
|
605
765
|
}, "wasms", tx.id);
|
|
606
|
-
case
|
|
766
|
+
case 26:
|
|
607
767
|
tx.tags = _tags;
|
|
608
|
-
_context6.n =
|
|
768
|
+
_context6.n = 27;
|
|
609
769
|
return this.arweave.wallets.jwkToAddress({
|
|
610
770
|
n: tx.owner
|
|
611
771
|
});
|
|
612
|
-
case
|
|
772
|
+
case 27:
|
|
613
773
|
tx.owner = _context6.v;
|
|
774
|
+
tx.recipient = tx.target || "";
|
|
614
775
|
_txs = tx;
|
|
615
776
|
block.txs.push(tx.id);
|
|
616
777
|
_txs.block = block.id;
|
|
617
|
-
|
|
778
|
+
// Extract raw data to R2
|
|
779
|
+
if (!(_txs.data && (_this$mem$db3 = this.mem.db) !== null && _this$mem$db3 !== void 0 && _this$mem$db3.r2PutTxData)) {
|
|
780
|
+
_context6.n = 29;
|
|
781
|
+
break;
|
|
782
|
+
}
|
|
783
|
+
_context6.n = 28;
|
|
784
|
+
return this.mem.db.r2PutTxData(tx.id, _txs.data);
|
|
785
|
+
case 28:
|
|
786
|
+
_txs._r2_data = true;
|
|
787
|
+
_txs.data = "";
|
|
788
|
+
case 29:
|
|
789
|
+
_context6.n = 30;
|
|
618
790
|
return this.mem.set(_txs, "txs", tx.id);
|
|
619
|
-
case
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
791
|
+
case 30:
|
|
792
|
+
if (!this.mem._d1Ready) {
|
|
793
|
+
_context6.n = 32;
|
|
794
|
+
break;
|
|
795
|
+
}
|
|
796
|
+
_context6.n = 31;
|
|
797
|
+
return this.mem.set(block.id, "lastBlockId");
|
|
798
|
+
case 31:
|
|
799
|
+
this.mem.lastBlockId = block.id;
|
|
800
|
+
case 32:
|
|
801
|
+
(_this$mem$blocks = (_this$mem = this.mem).blocks) !== null && _this$mem$blocks !== void 0 ? _this$mem$blocks : _this$mem.blocks = [];
|
|
802
|
+
this.mem.blocks.push(block.id);
|
|
803
|
+
_context6.n = 33;
|
|
804
|
+
return this.mem.set(this.mem.blocks, "blocks");
|
|
805
|
+
case 33:
|
|
806
|
+
_context6.n = 34;
|
|
629
807
|
return this.mem.set(block, "blockmap", block.id);
|
|
630
|
-
case
|
|
808
|
+
case 34:
|
|
631
809
|
if (!jwk) {
|
|
632
|
-
_context6.n =
|
|
810
|
+
_context6.n = 40;
|
|
633
811
|
break;
|
|
634
812
|
}
|
|
635
|
-
_context6.n =
|
|
813
|
+
_context6.n = 35;
|
|
636
814
|
return this.arweave.wallets.jwkToAddress(jwk);
|
|
637
|
-
case
|
|
815
|
+
case 35:
|
|
638
816
|
owner = _context6.v;
|
|
639
|
-
_context6.n =
|
|
817
|
+
_context6.n = 36;
|
|
640
818
|
return this.mem.set({
|
|
641
819
|
address: owner,
|
|
642
820
|
key: jwk.n
|
|
643
821
|
}, "addrmap", owner);
|
|
644
|
-
case
|
|
822
|
+
case 36:
|
|
823
|
+
if (!((_this$mem$db4 = this.mem.db) !== null && _this$mem$db4 !== void 0 && _this$mem$db4.d1WriteAddrmap)) {
|
|
824
|
+
_context6.n = 40;
|
|
825
|
+
break;
|
|
826
|
+
}
|
|
827
|
+
_context6.p = 37;
|
|
828
|
+
_context6.n = 38;
|
|
829
|
+
return this.mem.db.d1WriteAddrmap(owner, {
|
|
830
|
+
address: owner,
|
|
831
|
+
key: jwk.n
|
|
832
|
+
});
|
|
833
|
+
case 38:
|
|
834
|
+
_context6.n = 40;
|
|
835
|
+
break;
|
|
836
|
+
case 39:
|
|
837
|
+
_context6.p = 39;
|
|
838
|
+
_t27 = _context6.v;
|
|
839
|
+
case 40:
|
|
840
|
+
if (!(this.mem._d1Ready && (_this$mem$db5 = this.mem.db) !== null && _this$mem$db5 !== void 0 && _this$mem$db5.d1WriteBlock)) {
|
|
841
|
+
_context6.n = 50;
|
|
842
|
+
break;
|
|
843
|
+
}
|
|
844
|
+
mainTx = {
|
|
845
|
+
id: tx.id,
|
|
846
|
+
owner: tx.owner,
|
|
847
|
+
recipient: tx.recipient || "",
|
|
848
|
+
anchor: tx.anchor || "",
|
|
849
|
+
signature: tx.signature || "",
|
|
850
|
+
tags: _tags,
|
|
851
|
+
_data: tx._data || {
|
|
852
|
+
size: tx.data ? String(tx.data.length) : "0",
|
|
853
|
+
type: ""
|
|
854
|
+
},
|
|
855
|
+
bundledIn: tx.bundledIn,
|
|
856
|
+
parent: tx.parent
|
|
857
|
+
};
|
|
858
|
+
if (!(this._batchWindow > 0)) {
|
|
859
|
+
_context6.n = 41;
|
|
860
|
+
break;
|
|
861
|
+
}
|
|
862
|
+
this._pendingBatch.push({
|
|
863
|
+
block: block,
|
|
864
|
+
mainTx: mainTx,
|
|
865
|
+
items: _toConsumableArray(items)
|
|
866
|
+
});
|
|
867
|
+
if (!this._flushTimer) {
|
|
868
|
+
this._flushTimer = setTimeout(function () {
|
|
869
|
+
return _this2._flushBatch();
|
|
870
|
+
}, this._batchWindow);
|
|
871
|
+
}
|
|
872
|
+
_context6.n = 50;
|
|
873
|
+
break;
|
|
874
|
+
case 41:
|
|
875
|
+
_context6.n = 42;
|
|
876
|
+
return this.mem.db.d1WriteBlock(block);
|
|
877
|
+
case 42:
|
|
878
|
+
_context6.n = 43;
|
|
879
|
+
return this.mem.db.d1WriteTx(mainTx, block.id, block.height);
|
|
880
|
+
case 43:
|
|
881
|
+
_iterator7 = _createForOfIteratorHelper(items);
|
|
882
|
+
_context6.p = 44;
|
|
883
|
+
_iterator7.s();
|
|
884
|
+
case 45:
|
|
885
|
+
if ((_step7 = _iterator7.n()).done) {
|
|
886
|
+
_context6.n = 47;
|
|
887
|
+
break;
|
|
888
|
+
}
|
|
889
|
+
_item2 = _step7.value;
|
|
890
|
+
_context6.n = 46;
|
|
891
|
+
return this.mem.db.d1WriteTx(_item2, block.id, block.height);
|
|
892
|
+
case 46:
|
|
893
|
+
_context6.n = 45;
|
|
894
|
+
break;
|
|
895
|
+
case 47:
|
|
896
|
+
_context6.n = 49;
|
|
897
|
+
break;
|
|
898
|
+
case 48:
|
|
899
|
+
_context6.p = 48;
|
|
900
|
+
_t28 = _context6.v;
|
|
901
|
+
_iterator7.e(_t28);
|
|
902
|
+
case 49:
|
|
903
|
+
_context6.p = 49;
|
|
904
|
+
_iterator7.f();
|
|
905
|
+
return _context6.f(49);
|
|
906
|
+
case 50:
|
|
645
907
|
res = {
|
|
646
908
|
id: tx.id,
|
|
647
909
|
status: 200,
|
|
@@ -660,7 +922,7 @@ var AR = /*#__PURE__*/function (_MAR) {
|
|
|
660
922
|
id: tx.id
|
|
661
923
|
});
|
|
662
924
|
}
|
|
663
|
-
}, _callee6, this, [[
|
|
925
|
+
}, _callee6, this, [[44, 48, 49, 50], [37, 39], [19, 23, 24, 25]]);
|
|
664
926
|
}));
|
|
665
927
|
function postTx(_x7, _x8) {
|
|
666
928
|
return _postTx.apply(this, arguments);
|
|
@@ -668,32 +930,115 @@ var AR = /*#__PURE__*/function (_MAR) {
|
|
|
668
930
|
return postTx;
|
|
669
931
|
}()
|
|
670
932
|
}, {
|
|
671
|
-
key: "
|
|
933
|
+
key: "_flushBatch",
|
|
672
934
|
value: function () {
|
|
673
|
-
var
|
|
935
|
+
var _flushBatch2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7() {
|
|
936
|
+
var batch, _iterator8, _step8, _step8$value, block, mainTx, items, _iterator9, _step9, item, _t29, _t30;
|
|
674
937
|
return _regenerator().w(function (_context7) {
|
|
675
|
-
while (1) switch (_context7.n) {
|
|
938
|
+
while (1) switch (_context7.p = _context7.n) {
|
|
939
|
+
case 0:
|
|
940
|
+
this._flushTimer = null;
|
|
941
|
+
if (this._pendingBatch.length) {
|
|
942
|
+
_context7.n = 1;
|
|
943
|
+
break;
|
|
944
|
+
}
|
|
945
|
+
return _context7.a(2);
|
|
946
|
+
case 1:
|
|
947
|
+
batch = this._pendingBatch.splice(0);
|
|
948
|
+
_iterator8 = _createForOfIteratorHelper(batch);
|
|
949
|
+
_context7.p = 2;
|
|
950
|
+
_iterator8.s();
|
|
951
|
+
case 3:
|
|
952
|
+
if ((_step8 = _iterator8.n()).done) {
|
|
953
|
+
_context7.n = 13;
|
|
954
|
+
break;
|
|
955
|
+
}
|
|
956
|
+
_step8$value = _step8.value, block = _step8$value.block, mainTx = _step8$value.mainTx, items = _step8$value.items;
|
|
957
|
+
_context7.n = 4;
|
|
958
|
+
return this.mem.db.d1WriteBlock(block);
|
|
959
|
+
case 4:
|
|
960
|
+
_context7.n = 5;
|
|
961
|
+
return this.mem.db.d1WriteTx(mainTx, block.id, block.height);
|
|
962
|
+
case 5:
|
|
963
|
+
_iterator9 = _createForOfIteratorHelper(items);
|
|
964
|
+
_context7.p = 6;
|
|
965
|
+
_iterator9.s();
|
|
966
|
+
case 7:
|
|
967
|
+
if ((_step9 = _iterator9.n()).done) {
|
|
968
|
+
_context7.n = 9;
|
|
969
|
+
break;
|
|
970
|
+
}
|
|
971
|
+
item = _step9.value;
|
|
972
|
+
_context7.n = 8;
|
|
973
|
+
return this.mem.db.d1WriteTx(item, block.id, block.height);
|
|
974
|
+
case 8:
|
|
975
|
+
_context7.n = 7;
|
|
976
|
+
break;
|
|
977
|
+
case 9:
|
|
978
|
+
_context7.n = 11;
|
|
979
|
+
break;
|
|
980
|
+
case 10:
|
|
981
|
+
_context7.p = 10;
|
|
982
|
+
_t29 = _context7.v;
|
|
983
|
+
_iterator9.e(_t29);
|
|
984
|
+
case 11:
|
|
985
|
+
_context7.p = 11;
|
|
986
|
+
_iterator9.f();
|
|
987
|
+
return _context7.f(11);
|
|
988
|
+
case 12:
|
|
989
|
+
_context7.n = 3;
|
|
990
|
+
break;
|
|
991
|
+
case 13:
|
|
992
|
+
_context7.n = 15;
|
|
993
|
+
break;
|
|
994
|
+
case 14:
|
|
995
|
+
_context7.p = 14;
|
|
996
|
+
_t30 = _context7.v;
|
|
997
|
+
_iterator8.e(_t30);
|
|
998
|
+
case 15:
|
|
999
|
+
_context7.p = 15;
|
|
1000
|
+
_iterator8.f();
|
|
1001
|
+
return _context7.f(15);
|
|
1002
|
+
case 16:
|
|
1003
|
+
_context7.n = 17;
|
|
1004
|
+
return this.mem.set(this.mem.height, "height");
|
|
1005
|
+
case 17:
|
|
1006
|
+
return _context7.a(2);
|
|
1007
|
+
}
|
|
1008
|
+
}, _callee7, this, [[6, 10, 11, 12], [2, 14, 15, 16]]);
|
|
1009
|
+
}));
|
|
1010
|
+
function _flushBatch() {
|
|
1011
|
+
return _flushBatch2.apply(this, arguments);
|
|
1012
|
+
}
|
|
1013
|
+
return _flushBatch;
|
|
1014
|
+
}()
|
|
1015
|
+
}, {
|
|
1016
|
+
key: "tx",
|
|
1017
|
+
value: function () {
|
|
1018
|
+
var _tx2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8(id) {
|
|
1019
|
+
return _regenerator().w(function (_context8) {
|
|
1020
|
+
while (1) switch (_context8.n) {
|
|
676
1021
|
case 0:
|
|
677
|
-
|
|
1022
|
+
_context8.n = 1;
|
|
678
1023
|
return this.mem.getTx(id);
|
|
679
1024
|
case 1:
|
|
680
|
-
return
|
|
1025
|
+
return _context8.a(2, _context8.v);
|
|
681
1026
|
}
|
|
682
|
-
},
|
|
1027
|
+
}, _callee8, this);
|
|
683
1028
|
}));
|
|
684
1029
|
function tx(_x9) {
|
|
685
|
-
return
|
|
1030
|
+
return _tx2.apply(this, arguments);
|
|
686
1031
|
}
|
|
687
1032
|
return tx;
|
|
688
1033
|
}()
|
|
689
1034
|
}, {
|
|
690
1035
|
key: "data",
|
|
691
1036
|
value: function () {
|
|
692
|
-
var _data2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function
|
|
1037
|
+
var _data2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(id, _string, log) {
|
|
693
1038
|
var _tx$data;
|
|
694
1039
|
var decode, string, tx, _data, isBuf, isStr;
|
|
695
|
-
return _regenerator().w(function (
|
|
696
|
-
while (1) switch (
|
|
1040
|
+
return _regenerator().w(function (_context9) {
|
|
1041
|
+
while (1) switch (_context9.n) {
|
|
697
1042
|
case 0:
|
|
698
1043
|
decode = true;
|
|
699
1044
|
string = _string;
|
|
@@ -701,45 +1046,38 @@ var AR = /*#__PURE__*/function (_MAR) {
|
|
|
701
1046
|
if (!(0, _ramda.isNil)(_string.decode)) decode = _string.decode;
|
|
702
1047
|
if (!(0, _ramda.isNil)(_string.string)) string = _string.string;
|
|
703
1048
|
}
|
|
704
|
-
|
|
1049
|
+
_context9.n = 1;
|
|
705
1050
|
return this.mem.getTx(id);
|
|
706
1051
|
case 1:
|
|
707
|
-
tx =
|
|
1052
|
+
tx = _context9.v;
|
|
708
1053
|
_data = (_tx$data = tx === null || tx === void 0 ? void 0 : tx.data) !== null && _tx$data !== void 0 ? _tx$data : null;
|
|
709
|
-
if (
|
|
710
|
-
_data =
|
|
711
|
-
} else if (_data) {
|
|
712
|
-
// need to check production
|
|
713
|
-
if (tx._data.type === "") {
|
|
714
|
-
_data = tobuff(_data);
|
|
715
|
-
} else {
|
|
716
|
-
_data = Buffer.from(_base64url["default"].decode(_data));
|
|
717
|
-
}
|
|
1054
|
+
if (_data && (0, _ramda.is)(String, _data)) {
|
|
1055
|
+
_data = tobuff(_data);
|
|
718
1056
|
}
|
|
719
1057
|
isBuf = (0, _ramda.is)(Uint8Array, _data) || (0, _ramda.is)(ArrayBuffer, _data);
|
|
720
1058
|
isStr = (0, _ramda.is)(String, _data);
|
|
721
1059
|
if (!(decode === false)) {
|
|
722
|
-
|
|
1060
|
+
_context9.n = 2;
|
|
723
1061
|
break;
|
|
724
1062
|
}
|
|
725
1063
|
if (isStr) _data = new TextEncoder().encode(_data);
|
|
726
|
-
return
|
|
1064
|
+
return _context9.a(2, _base64url["default"].encode(_data));
|
|
727
1065
|
case 2:
|
|
728
1066
|
if (!(isBuf && string)) {
|
|
729
|
-
|
|
1067
|
+
_context9.n = 3;
|
|
730
1068
|
break;
|
|
731
1069
|
}
|
|
732
|
-
return
|
|
1070
|
+
return _context9.a(2, _data.toString());
|
|
733
1071
|
case 3:
|
|
734
1072
|
if (!(isStr && string !== true)) {
|
|
735
|
-
|
|
1073
|
+
_context9.n = 4;
|
|
736
1074
|
break;
|
|
737
1075
|
}
|
|
738
|
-
return
|
|
1076
|
+
return _context9.a(2, new TextEncoder().encode(_data));
|
|
739
1077
|
case 4:
|
|
740
|
-
return
|
|
1078
|
+
return _context9.a(2, _data);
|
|
741
1079
|
}
|
|
742
|
-
},
|
|
1080
|
+
}, _callee9, this);
|
|
743
1081
|
}));
|
|
744
1082
|
function data(_x0, _x1, _x10) {
|
|
745
1083
|
return _data2.apply(this, arguments);
|