wao 0.7.1 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/ao.js +8 -3
- package/cjs/aoconnect.js +570 -365
- package/cjs/armem.js +399 -73
- package/cjs/run.js +19 -3
- package/cjs/server.js +4 -2
- package/cjs/tao.js +3 -1
- package/cjs/tar.js +185 -103
- package/esm/ao.js +4 -1
- package/esm/aoconnect.js +60 -54
- package/esm/armem.js +94 -7
- package/esm/run.js +15 -4
- package/esm/server.js +3 -2
- package/esm/tao.js +5 -1
- package/esm/tar.js +31 -25
- package/package.json +3 -3
- package/esm/.cache/opt.json +0 -1
package/cjs/tar.js
CHANGED
|
@@ -234,7 +234,7 @@ var AR = /*#__PURE__*/function (_MAR) {
|
|
|
234
234
|
_iterator2.s();
|
|
235
235
|
case 13:
|
|
236
236
|
if ((_step2 = _iterator2.n()).done) {
|
|
237
|
-
_context4.next =
|
|
237
|
+
_context4.next = 50;
|
|
238
238
|
break;
|
|
239
239
|
}
|
|
240
240
|
di = _step2.value;
|
|
@@ -259,14 +259,13 @@ var AR = /*#__PURE__*/function (_MAR) {
|
|
|
259
259
|
return this.owner(di);
|
|
260
260
|
case 24:
|
|
261
261
|
owner = _context4.sent;
|
|
262
|
-
|
|
262
|
+
_context4.next = 27;
|
|
263
|
+
return this.mem.set({
|
|
263
264
|
key: di.owner,
|
|
264
265
|
address: owner
|
|
265
|
-
};
|
|
266
|
+
}, "addrmap", owner);
|
|
267
|
+
case 27:
|
|
266
268
|
data = di.data;
|
|
267
|
-
try {
|
|
268
|
-
//data = base64url.decode(di.data)
|
|
269
|
-
} catch (e) {}
|
|
270
269
|
_context4.t0 = {
|
|
271
270
|
size: data_size,
|
|
272
271
|
type: data_type
|
|
@@ -293,48 +292,52 @@ var AR = /*#__PURE__*/function (_MAR) {
|
|
|
293
292
|
tags: _context4.t7,
|
|
294
293
|
data: _context4.t8
|
|
295
294
|
};
|
|
296
|
-
_context4.
|
|
295
|
+
_context4.t9 = this.mem;
|
|
296
|
+
_context4.t10 = _item;
|
|
297
|
+
_context4.next = 44;
|
|
297
298
|
return di.id;
|
|
298
|
-
case
|
|
299
|
-
_context4.
|
|
300
|
-
|
|
299
|
+
case 44:
|
|
300
|
+
_context4.t11 = _context4.sent;
|
|
301
|
+
_context4.next = 47;
|
|
302
|
+
return _context4.t9.set.call(_context4.t9, _context4.t10, "txs", _context4.t11);
|
|
303
|
+
case 47:
|
|
301
304
|
_items.push(_item);
|
|
302
|
-
case
|
|
305
|
+
case 48:
|
|
303
306
|
_context4.next = 13;
|
|
304
307
|
break;
|
|
305
|
-
case
|
|
306
|
-
_context4.next =
|
|
308
|
+
case 50:
|
|
309
|
+
_context4.next = 55;
|
|
307
310
|
break;
|
|
308
|
-
case 49:
|
|
309
|
-
_context4.prev = 49;
|
|
310
|
-
_context4.t10 = _context4["catch"](11);
|
|
311
|
-
_iterator2.e(_context4.t10);
|
|
312
311
|
case 52:
|
|
313
312
|
_context4.prev = 52;
|
|
314
|
-
|
|
315
|
-
|
|
313
|
+
_context4.t12 = _context4["catch"](11);
|
|
314
|
+
_iterator2.e(_context4.t12);
|
|
316
315
|
case 55:
|
|
317
|
-
_context4.
|
|
316
|
+
_context4.prev = 55;
|
|
317
|
+
_iterator2.f();
|
|
318
|
+
return _context4.finish(55);
|
|
319
|
+
case 58:
|
|
320
|
+
_context4.next = 60;
|
|
318
321
|
return (0, _arbundles.bundleAndSignData)(items, new _arbundles.ArweaveSigner(jwk));
|
|
319
|
-
case
|
|
322
|
+
case 60:
|
|
320
323
|
bundle = _context4.sent;
|
|
321
|
-
_context4.next =
|
|
324
|
+
_context4.next = 63;
|
|
322
325
|
return this.mem.arweave.createTransaction({
|
|
323
326
|
data: bundle.binary
|
|
324
327
|
}, jwk);
|
|
325
|
-
case
|
|
328
|
+
case 63:
|
|
326
329
|
tx = _context4.sent;
|
|
327
330
|
tx.addTag("Bundle-Format", "binary");
|
|
328
331
|
tx.addTag("Bundle-Version", "2.0.0");
|
|
329
|
-
_context4.next =
|
|
332
|
+
_context4.next = 68;
|
|
330
333
|
return this.postTx(tx, jwk, _items);
|
|
331
|
-
case
|
|
334
|
+
case 68:
|
|
332
335
|
return _context4.abrupt("return", _context4.sent);
|
|
333
|
-
case
|
|
336
|
+
case 69:
|
|
334
337
|
case "end":
|
|
335
338
|
return _context4.stop();
|
|
336
339
|
}
|
|
337
|
-
}, _callee4, this, [[11,
|
|
340
|
+
}, _callee4, this, [[11, 52, 55, 58]]);
|
|
338
341
|
}));
|
|
339
342
|
function postItems(_x4, _x5) {
|
|
340
343
|
return _postItems.apply(this, arguments);
|
|
@@ -350,11 +353,13 @@ var AR = /*#__PURE__*/function (_MAR) {
|
|
|
350
353
|
err,
|
|
351
354
|
_yield$this$checkWall3,
|
|
352
355
|
res,
|
|
356
|
+
height,
|
|
353
357
|
block,
|
|
354
358
|
msg,
|
|
355
359
|
_iterator4,
|
|
356
360
|
_step4,
|
|
357
361
|
item,
|
|
362
|
+
_txs2,
|
|
358
363
|
_tags2,
|
|
359
364
|
data_type,
|
|
360
365
|
_iterator5,
|
|
@@ -365,6 +370,8 @@ var AR = /*#__PURE__*/function (_MAR) {
|
|
|
365
370
|
_step6,
|
|
366
371
|
_v,
|
|
367
372
|
__tags,
|
|
373
|
+
_txs,
|
|
374
|
+
blocks,
|
|
368
375
|
owner,
|
|
369
376
|
_args5 = arguments;
|
|
370
377
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
@@ -396,58 +403,110 @@ var AR = /*#__PURE__*/function (_MAR) {
|
|
|
396
403
|
_context5.next = 13;
|
|
397
404
|
return this.mem.arweave.transactions.sign(tx, jwk);
|
|
398
405
|
case 13:
|
|
399
|
-
|
|
406
|
+
_context5.next = 15;
|
|
407
|
+
return this.mem.get("height");
|
|
408
|
+
case 15:
|
|
409
|
+
_context5.t0 = _context5.sent;
|
|
410
|
+
height = _context5.t0 + 1;
|
|
411
|
+
_context5.next = 19;
|
|
412
|
+
return this.mem.set(height, "height");
|
|
413
|
+
case 19:
|
|
414
|
+
_context5.t1 = tx.id;
|
|
415
|
+
_context5.t2 = Date.now();
|
|
416
|
+
_context5.t3 = height;
|
|
417
|
+
_context5.t5 = _ramda.last;
|
|
418
|
+
_context5.next = 25;
|
|
419
|
+
return this.mem.get("blocks");
|
|
420
|
+
case 25:
|
|
421
|
+
_context5.t6 = _context5.sent;
|
|
422
|
+
_context5.t7 = _last = (0, _context5.t5)(_context5.t6);
|
|
423
|
+
_context5.t4 = _context5.t7 !== null;
|
|
424
|
+
if (!_context5.t4) {
|
|
425
|
+
_context5.next = 30;
|
|
426
|
+
break;
|
|
427
|
+
}
|
|
428
|
+
_context5.t4 = _last !== void 0;
|
|
429
|
+
case 30:
|
|
430
|
+
if (!_context5.t4) {
|
|
431
|
+
_context5.next = 34;
|
|
432
|
+
break;
|
|
433
|
+
}
|
|
434
|
+
_context5.t8 = _last;
|
|
435
|
+
_context5.next = 35;
|
|
436
|
+
break;
|
|
437
|
+
case 34:
|
|
438
|
+
_context5.t8 = "";
|
|
439
|
+
case 35:
|
|
440
|
+
_context5.t9 = _context5.t8;
|
|
441
|
+
_context5.t10 = [];
|
|
400
442
|
block = {
|
|
401
|
-
id:
|
|
402
|
-
timestamp:
|
|
403
|
-
height:
|
|
404
|
-
previous:
|
|
405
|
-
txs:
|
|
443
|
+
id: _context5.t1,
|
|
444
|
+
timestamp: _context5.t2,
|
|
445
|
+
height: _context5.t3,
|
|
446
|
+
previous: _context5.t9,
|
|
447
|
+
txs: _context5.t10
|
|
406
448
|
};
|
|
407
449
|
msg = null;
|
|
408
|
-
if (items) {
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
this.mem.txs[item.id].block = block.id;
|
|
444
|
-
}
|
|
445
|
-
} catch (err) {
|
|
446
|
-
_iterator4.e(err);
|
|
447
|
-
} finally {
|
|
448
|
-
_iterator4.f();
|
|
450
|
+
if (!items) {
|
|
451
|
+
_context5.next = 68;
|
|
452
|
+
break;
|
|
453
|
+
}
|
|
454
|
+
_iterator4 = _createForOfIteratorHelper(items);
|
|
455
|
+
_context5.prev = 41;
|
|
456
|
+
_iterator4.s();
|
|
457
|
+
case 43:
|
|
458
|
+
if ((_step4 = _iterator4.n()).done) {
|
|
459
|
+
_context5.next = 60;
|
|
460
|
+
break;
|
|
461
|
+
}
|
|
462
|
+
item = _step4.value;
|
|
463
|
+
_txs2 = item;
|
|
464
|
+
_txs2.parent = {
|
|
465
|
+
id: tx.id
|
|
466
|
+
};
|
|
467
|
+
_txs2.bundledIn = {
|
|
468
|
+
id: tx.id
|
|
469
|
+
};
|
|
470
|
+
_txs2.anchor = "";
|
|
471
|
+
_tags2 = (0, _utils.tags)(item.tags);
|
|
472
|
+
if ((0, _ramda.includes)(_tags2.Type, ["Message", "Process", "Module", "Scheduler-Location", "Attestation", "Available"])) {
|
|
473
|
+
msg = {
|
|
474
|
+
id: item.id,
|
|
475
|
+
type: _tags2.Type
|
|
476
|
+
};
|
|
477
|
+
if (msg.type === "Process") msg.pid = item.recipient;
|
|
478
|
+
}
|
|
479
|
+
data_type = "";
|
|
480
|
+
_iterator5 = _createForOfIteratorHelper(item.item.tags);
|
|
481
|
+
try {
|
|
482
|
+
for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
|
|
483
|
+
v = _step5.value;
|
|
484
|
+
if (v.name === "Content-Type") data_type = v.value;
|
|
449
485
|
}
|
|
486
|
+
} catch (err) {
|
|
487
|
+
_iterator5.e(err);
|
|
488
|
+
} finally {
|
|
489
|
+
_iterator5.f();
|
|
450
490
|
}
|
|
491
|
+
block.txs.push(item.id);
|
|
492
|
+
_txs2.block = block.id;
|
|
493
|
+
_context5.next = 58;
|
|
494
|
+
return this.mem.set(_txs2, "txs", item.id);
|
|
495
|
+
case 58:
|
|
496
|
+
_context5.next = 43;
|
|
497
|
+
break;
|
|
498
|
+
case 60:
|
|
499
|
+
_context5.next = 65;
|
|
500
|
+
break;
|
|
501
|
+
case 62:
|
|
502
|
+
_context5.prev = 62;
|
|
503
|
+
_context5.t11 = _context5["catch"](41);
|
|
504
|
+
_iterator4.e(_context5.t11);
|
|
505
|
+
case 65:
|
|
506
|
+
_context5.prev = 65;
|
|
507
|
+
_iterator4.f();
|
|
508
|
+
return _context5.finish(65);
|
|
509
|
+
case 68:
|
|
451
510
|
_tags = [];
|
|
452
511
|
_iterator6 = _createForOfIteratorHelper(tx.tags);
|
|
453
512
|
try {
|
|
@@ -464,37 +523,54 @@ var AR = /*#__PURE__*/function (_MAR) {
|
|
|
464
523
|
_iterator6.f();
|
|
465
524
|
}
|
|
466
525
|
__tags = (0, _utils.tags)(_tags);
|
|
467
|
-
if (__tags.Type === "Module") {
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
format: __tags["Module-Format"]
|
|
471
|
-
};
|
|
526
|
+
if (!(__tags.Type === "Module")) {
|
|
527
|
+
_context5.next = 75;
|
|
528
|
+
break;
|
|
472
529
|
}
|
|
530
|
+
_context5.next = 75;
|
|
531
|
+
return this.mem.set({
|
|
532
|
+
data: Buffer.from(tx.data, "base64"),
|
|
533
|
+
format: __tags["Module-Format"]
|
|
534
|
+
}, "wasms", tx.id);
|
|
535
|
+
case 75:
|
|
473
536
|
tx.tags = _tags;
|
|
474
|
-
_context5.next =
|
|
537
|
+
_context5.next = 78;
|
|
475
538
|
return this.arweave.wallets.jwkToAddress({
|
|
476
539
|
n: tx.owner
|
|
477
540
|
});
|
|
478
|
-
case
|
|
541
|
+
case 78:
|
|
479
542
|
tx.owner = _context5.sent;
|
|
480
|
-
|
|
543
|
+
_txs = tx;
|
|
481
544
|
block.txs.push(tx.id);
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
this.mem.
|
|
545
|
+
_txs.block = block.id;
|
|
546
|
+
_context5.next = 84;
|
|
547
|
+
return this.mem.set(_txs, "txs", tx.id);
|
|
548
|
+
case 84:
|
|
549
|
+
_context5.next = 86;
|
|
550
|
+
return this.mem.get("blocks");
|
|
551
|
+
case 86:
|
|
552
|
+
blocks = _context5.sent;
|
|
553
|
+
blocks.push(block.id);
|
|
554
|
+
_context5.next = 90;
|
|
555
|
+
return this.mem.set(blocks, "blocks");
|
|
556
|
+
case 90:
|
|
557
|
+
_context5.next = 92;
|
|
558
|
+
return this.mem.set(block, "blockmap", block.id);
|
|
559
|
+
case 92:
|
|
485
560
|
if (!jwk) {
|
|
486
|
-
_context5.next =
|
|
561
|
+
_context5.next = 98;
|
|
487
562
|
break;
|
|
488
563
|
}
|
|
489
|
-
_context5.next =
|
|
564
|
+
_context5.next = 95;
|
|
490
565
|
return this.arweave.wallets.jwkToAddress(jwk);
|
|
491
|
-
case
|
|
566
|
+
case 95:
|
|
492
567
|
owner = _context5.sent;
|
|
493
|
-
|
|
568
|
+
_context5.next = 98;
|
|
569
|
+
return this.mem.set({
|
|
494
570
|
address: owner,
|
|
495
571
|
key: jwk.n
|
|
496
|
-
};
|
|
497
|
-
case
|
|
572
|
+
}, "addrmap", owner);
|
|
573
|
+
case 98:
|
|
498
574
|
res = {
|
|
499
575
|
id: tx.id,
|
|
500
576
|
status: 200,
|
|
@@ -512,11 +588,11 @@ var AR = /*#__PURE__*/function (_MAR) {
|
|
|
512
588
|
err: err,
|
|
513
589
|
id: tx.id
|
|
514
590
|
});
|
|
515
|
-
case
|
|
591
|
+
case 101:
|
|
516
592
|
case "end":
|
|
517
593
|
return _context5.stop();
|
|
518
594
|
}
|
|
519
|
-
}, _callee5, this);
|
|
595
|
+
}, _callee5, this, [[41, 62, 65, 68]]);
|
|
520
596
|
}));
|
|
521
597
|
function postTx(_x6, _x7) {
|
|
522
598
|
return _postTx.apply(this, arguments);
|
|
@@ -530,8 +606,11 @@ var AR = /*#__PURE__*/function (_MAR) {
|
|
|
530
606
|
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
531
607
|
while (1) switch (_context6.prev = _context6.next) {
|
|
532
608
|
case 0:
|
|
533
|
-
|
|
534
|
-
|
|
609
|
+
_context6.next = 2;
|
|
610
|
+
return this.mem.get("txs", id);
|
|
611
|
+
case 2:
|
|
612
|
+
return _context6.abrupt("return", _context6.sent);
|
|
613
|
+
case 3:
|
|
535
614
|
case "end":
|
|
536
615
|
return _context6.stop();
|
|
537
616
|
}
|
|
@@ -557,7 +636,10 @@ var AR = /*#__PURE__*/function (_MAR) {
|
|
|
557
636
|
if (!(0, _ramda.isNil)(_string.decode)) decode = _string.decode;
|
|
558
637
|
if (!(0, _ramda.isNil)(_string.string)) string = _string.string;
|
|
559
638
|
}
|
|
560
|
-
|
|
639
|
+
_context7.next = 5;
|
|
640
|
+
return this.mem.get("txs", id);
|
|
641
|
+
case 5:
|
|
642
|
+
tx = _context7.sent;
|
|
561
643
|
_data = (_tx$data = tx === null || tx === void 0 ? void 0 : tx.data) !== null && _tx$data !== void 0 ? _tx$data : null;
|
|
562
644
|
if ((tx === null || tx === void 0 ? void 0 : tx.format) === 2 && _data) {
|
|
563
645
|
_data = Buffer.from(_data, "base64");
|
|
@@ -567,26 +649,26 @@ var AR = /*#__PURE__*/function (_MAR) {
|
|
|
567
649
|
isBuf = (0, _ramda.is)(Uint8Array, _data) || (0, _ramda.is)(ArrayBuffer, _data);
|
|
568
650
|
isStr = (0, _ramda.is)(String, _data);
|
|
569
651
|
if (!(decode === false)) {
|
|
570
|
-
_context7.next =
|
|
652
|
+
_context7.next = 15;
|
|
571
653
|
break;
|
|
572
654
|
}
|
|
573
655
|
if (isStr) _data = new TextEncoder().encode(_data);
|
|
574
656
|
return _context7.abrupt("return", _base64url["default"].encode(_data));
|
|
575
|
-
case
|
|
657
|
+
case 15:
|
|
576
658
|
if (!(isBuf && string)) {
|
|
577
|
-
_context7.next =
|
|
659
|
+
_context7.next = 19;
|
|
578
660
|
break;
|
|
579
661
|
}
|
|
580
662
|
return _context7.abrupt("return", _data.toString());
|
|
581
|
-
case
|
|
663
|
+
case 19:
|
|
582
664
|
if (!(isStr && string !== true)) {
|
|
583
|
-
_context7.next =
|
|
665
|
+
_context7.next = 21;
|
|
584
666
|
break;
|
|
585
667
|
}
|
|
586
668
|
return _context7.abrupt("return", new TextEncoder().encode(_data));
|
|
587
|
-
case
|
|
669
|
+
case 21:
|
|
588
670
|
return _context7.abrupt("return", _data);
|
|
589
|
-
case
|
|
671
|
+
case 22:
|
|
590
672
|
case "end":
|
|
591
673
|
return _context7.stop();
|
|
592
674
|
}
|
package/esm/ao.js
CHANGED
|
@@ -333,6 +333,7 @@ class AO {
|
|
|
333
333
|
boot,
|
|
334
334
|
module = this.module,
|
|
335
335
|
scheduler = this.scheduler,
|
|
336
|
+
memory,
|
|
336
337
|
jwk,
|
|
337
338
|
tags = {},
|
|
338
339
|
data,
|
|
@@ -348,6 +349,7 @@ class AO {
|
|
|
348
349
|
if (!tags.Authority && this.authority) tags.Authority = this.authority
|
|
349
350
|
let _tags = buildTags(null, tags)
|
|
350
351
|
pid = await this.spawn({
|
|
352
|
+
memory,
|
|
351
353
|
module,
|
|
352
354
|
scheduler,
|
|
353
355
|
signer: this.toSigner(jwk),
|
|
@@ -358,7 +360,8 @@ class AO {
|
|
|
358
360
|
console.log(e)
|
|
359
361
|
err = e
|
|
360
362
|
}
|
|
361
|
-
|
|
363
|
+
const p = pid ? this.p(pid) : null
|
|
364
|
+
return { err, pid, p }
|
|
362
365
|
}
|
|
363
366
|
|
|
364
367
|
async msg({
|