@mysten/walrus 0.0.18 → 0.0.20
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/CHANGELOG.md +18 -0
- package/README.md +1 -1
- package/dist/cjs/client.d.ts +22 -21
- package/dist/cjs/client.js +175 -156
- package/dist/cjs/client.js.map +2 -2
- package/dist/esm/client.d.ts +22 -21
- package/dist/esm/client.js +175 -156
- package/dist/esm/client.js.map +2 -2
- package/dist/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
package/dist/esm/client.js
CHANGED
|
@@ -391,47 +391,51 @@ const _WalrusClient = class _WalrusClient {
|
|
|
391
391
|
*
|
|
392
392
|
* @usage
|
|
393
393
|
* ```ts
|
|
394
|
-
* tx.transferObjects([
|
|
394
|
+
* tx.transferObjects([client.createStorage({ size: 1000, epochs: 3 })], owner);
|
|
395
395
|
* ```
|
|
396
396
|
*/
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
397
|
+
createStorage({ size, epochs, walCoin, owner }) {
|
|
398
|
+
return async (tx) => {
|
|
399
|
+
const systemObject = await this.systemObject();
|
|
400
|
+
const systemState = await this.systemState();
|
|
401
|
+
const encodedSize = encodedBlobLength(size, systemState.committee.n_shards);
|
|
402
|
+
const { storageCost } = await this.storageCost(size, epochs);
|
|
403
|
+
const systemContract = await __privateMethod(this, _WalrusClient_instances, getSystemContract_fn).call(this);
|
|
404
|
+
const subsidiesContract = __privateGet(this, _packageConfig).subsidiesObjectId ? await __privateMethod(this, _WalrusClient_instances, getSubsidiesContract_fn).call(this) : null;
|
|
405
405
|
return tx.add(
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
406
|
+
__privateMethod(this, _WalrusClient_instances, withWal_fn).call(this, storageCost, owner, walCoin ?? null, subsidiesContract !== null, (coin, tx2) => {
|
|
407
|
+
return tx2.add(
|
|
408
|
+
subsidiesContract ? subsidiesContract.reserve_space({
|
|
409
|
+
arguments: [
|
|
410
|
+
__privateGet(this, _packageConfig).subsidiesObjectId,
|
|
411
|
+
systemObject.id.id,
|
|
412
|
+
encodedSize,
|
|
413
|
+
epochs,
|
|
414
|
+
coin
|
|
415
|
+
]
|
|
416
|
+
}) : systemContract.reserve_space({
|
|
417
|
+
arguments: [systemObject.id.id, encodedSize, epochs, coin]
|
|
418
|
+
})
|
|
419
|
+
);
|
|
416
420
|
})
|
|
417
421
|
);
|
|
418
|
-
}
|
|
422
|
+
};
|
|
419
423
|
}
|
|
420
424
|
/**
|
|
421
425
|
* Create a transaction that creates a storage object
|
|
422
426
|
*
|
|
423
427
|
* @usage
|
|
424
428
|
* ```ts
|
|
425
|
-
* const tx =
|
|
429
|
+
* const tx = client.createStorageTransaction({ size: 1000, epochs: 3, owner: signer.toSuiAddress() });
|
|
426
430
|
* ```
|
|
427
431
|
*/
|
|
428
|
-
|
|
432
|
+
createStorageTransaction({
|
|
429
433
|
transaction = new Transaction(),
|
|
430
434
|
size,
|
|
431
435
|
epochs,
|
|
432
436
|
owner
|
|
433
437
|
}) {
|
|
434
|
-
transaction.transferObjects([
|
|
438
|
+
transaction.transferObjects([this.createStorage({ size, epochs, owner })], owner);
|
|
435
439
|
return transaction;
|
|
436
440
|
}
|
|
437
441
|
/**
|
|
@@ -446,7 +450,7 @@ const _WalrusClient = class _WalrusClient {
|
|
|
446
450
|
signer,
|
|
447
451
|
...options
|
|
448
452
|
}) {
|
|
449
|
-
const transaction =
|
|
453
|
+
const transaction = this.createStorageTransaction({
|
|
450
454
|
...options,
|
|
451
455
|
owner: options.transaction?.getData().sender ?? signer.toSuiAddress()
|
|
452
456
|
});
|
|
@@ -460,7 +464,9 @@ const _WalrusClient = class _WalrusClient {
|
|
|
460
464
|
(object) => !(object instanceof Error) && object.type === blobType
|
|
461
465
|
);
|
|
462
466
|
if (suiBlobObject instanceof Error || !suiBlobObject) {
|
|
463
|
-
throw new WalrusClientError(
|
|
467
|
+
throw new WalrusClientError(
|
|
468
|
+
`Storage object not found in transaction effects for transaction (${digest})`
|
|
469
|
+
);
|
|
464
470
|
}
|
|
465
471
|
return {
|
|
466
472
|
digest,
|
|
@@ -472,10 +478,10 @@ const _WalrusClient = class _WalrusClient {
|
|
|
472
478
|
*
|
|
473
479
|
* @usage
|
|
474
480
|
* ```ts
|
|
475
|
-
* tx.transferObjects([
|
|
481
|
+
* tx.transferObjects([client.registerBlob({ size: 1000, epochs: 3, blobId, rootHash, deletable: true })], owner);
|
|
476
482
|
* ```
|
|
477
483
|
*/
|
|
478
|
-
|
|
484
|
+
registerBlob({
|
|
479
485
|
size,
|
|
480
486
|
epochs,
|
|
481
487
|
blobId,
|
|
@@ -485,47 +491,52 @@ const _WalrusClient = class _WalrusClient {
|
|
|
485
491
|
owner,
|
|
486
492
|
attributes
|
|
487
493
|
}) {
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
494
|
+
return async (tx) => {
|
|
495
|
+
const { writeCost } = await this.storageCost(size, epochs);
|
|
496
|
+
const systemContract = await __privateMethod(this, _WalrusClient_instances, getSystemContract_fn).call(this);
|
|
497
|
+
return tx.add(
|
|
498
|
+
__privateMethod(this, _WalrusClient_instances, withWal_fn).call(this, writeCost, owner, walCoin ?? null, false, async (writeCoin, tx2) => {
|
|
499
|
+
const blob = tx2.add(
|
|
500
|
+
systemContract.register_blob({
|
|
501
|
+
arguments: [
|
|
502
|
+
tx2.object(__privateGet(this, _packageConfig).systemObjectId),
|
|
503
|
+
this.createStorage({ size, epochs, walCoin, owner }),
|
|
504
|
+
blobIdToInt(blobId),
|
|
505
|
+
BigInt(bcs.u256().parse(rootHash)),
|
|
506
|
+
size,
|
|
507
|
+
1,
|
|
508
|
+
deletable,
|
|
509
|
+
writeCoin
|
|
510
|
+
]
|
|
511
|
+
})
|
|
512
|
+
);
|
|
513
|
+
if (attributes) {
|
|
514
|
+
tx2.add(
|
|
515
|
+
__privateMethod(this, _WalrusClient_instances, writeBlobAttributesForRef_fn).call(this, {
|
|
516
|
+
attributes,
|
|
517
|
+
existingAttributes: null,
|
|
518
|
+
blob
|
|
519
|
+
})
|
|
520
|
+
);
|
|
521
|
+
}
|
|
522
|
+
return blob;
|
|
508
523
|
})
|
|
509
524
|
);
|
|
510
|
-
|
|
511
|
-
tx.add((tx2) => writeAttributes(tx2, blob));
|
|
512
|
-
}
|
|
513
|
-
return blob;
|
|
514
|
-
});
|
|
525
|
+
};
|
|
515
526
|
}
|
|
516
527
|
/**
|
|
517
528
|
* Create a transaction that registers a blob
|
|
518
529
|
*
|
|
519
530
|
* @usage
|
|
520
531
|
* ```ts
|
|
521
|
-
* const tx =
|
|
532
|
+
* const tx = client.registerBlobTransaction({ size: 1000, epochs: 3, blobId, rootHash, deletable: true });
|
|
522
533
|
* ```
|
|
523
534
|
*/
|
|
524
|
-
|
|
535
|
+
registerBlobTransaction({
|
|
525
536
|
transaction = new Transaction(),
|
|
526
537
|
...options
|
|
527
538
|
}) {
|
|
528
|
-
const registration = transaction.add(
|
|
539
|
+
const registration = transaction.add(this.registerBlob(options));
|
|
529
540
|
transaction.transferObjects([registration], options.owner);
|
|
530
541
|
return transaction;
|
|
531
542
|
}
|
|
@@ -541,7 +552,7 @@ const _WalrusClient = class _WalrusClient {
|
|
|
541
552
|
signer,
|
|
542
553
|
...options
|
|
543
554
|
}) {
|
|
544
|
-
const transaction =
|
|
555
|
+
const transaction = this.registerBlobTransaction({
|
|
545
556
|
...options,
|
|
546
557
|
owner: options.owner ?? options.transaction?.getData().sender ?? signer.toSuiAddress()
|
|
547
558
|
});
|
|
@@ -555,7 +566,9 @@ const _WalrusClient = class _WalrusClient {
|
|
|
555
566
|
(object) => !(object instanceof Error) && object.type === blobType
|
|
556
567
|
);
|
|
557
568
|
if (suiBlobObject instanceof Error || !suiBlobObject) {
|
|
558
|
-
throw new WalrusClientError(
|
|
569
|
+
throw new WalrusClientError(
|
|
570
|
+
`Blob object not found in transaction effects for transaction (${digest})`
|
|
571
|
+
);
|
|
559
572
|
}
|
|
560
573
|
return {
|
|
561
574
|
digest,
|
|
@@ -567,54 +580,54 @@ const _WalrusClient = class _WalrusClient {
|
|
|
567
580
|
*
|
|
568
581
|
* @usage
|
|
569
582
|
* ```ts
|
|
570
|
-
* tx.add(
|
|
583
|
+
* tx.add(client.certifyBlob({ blobId, blobObjectId, confirmations }));
|
|
571
584
|
* ```
|
|
572
585
|
*/
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
586
|
+
certifyBlob({ blobId, blobObjectId, confirmations, deletable }) {
|
|
587
|
+
return async (tx) => {
|
|
588
|
+
const systemState = await this.systemState();
|
|
589
|
+
const committee = await __privateMethod(this, _WalrusClient_instances, getActiveCommittee_fn).call(this);
|
|
590
|
+
if (confirmations.length !== systemState.committee.members.length) {
|
|
591
|
+
throw new WalrusClientError(
|
|
592
|
+
"Invalid number of confirmations. Confirmations array must contain an entry for each node"
|
|
593
|
+
);
|
|
594
|
+
}
|
|
595
|
+
const confirmationMessage = StorageConfirmation.serialize({
|
|
596
|
+
intent: IntentType.BLOB_CERT_MSG,
|
|
597
|
+
epoch: systemState.committee.epoch,
|
|
598
|
+
messageContents: {
|
|
599
|
+
blobId,
|
|
600
|
+
blobType: deletable ? {
|
|
601
|
+
Deletable: {
|
|
602
|
+
objectId: blobObjectId
|
|
603
|
+
}
|
|
604
|
+
} : {
|
|
605
|
+
Permanent: null
|
|
589
606
|
}
|
|
590
|
-
} : {
|
|
591
|
-
Permanent: null
|
|
592
607
|
}
|
|
608
|
+
}).toBase64();
|
|
609
|
+
const bindings = await __privateMethod(this, _WalrusClient_instances, wasmBindings_fn).call(this);
|
|
610
|
+
const verifySignature = bindings.getVerifySignature();
|
|
611
|
+
const filteredConfirmations = confirmations.map((confirmation, index) => {
|
|
612
|
+
const isValid = confirmation?.serializedMessage === confirmationMessage && verifySignature(
|
|
613
|
+
confirmation,
|
|
614
|
+
new Uint8Array(committee.nodes[index].info.public_key.bytes)
|
|
615
|
+
);
|
|
616
|
+
return isValid ? {
|
|
617
|
+
index,
|
|
618
|
+
...confirmation
|
|
619
|
+
} : null;
|
|
620
|
+
}).filter((confirmation) => confirmation !== null);
|
|
621
|
+
if (!isQuorum(filteredConfirmations.length, systemState.committee.members.length)) {
|
|
622
|
+
throw new NotEnoughBlobConfirmationsError(
|
|
623
|
+
`Too many invalid confirmations received for blob (${filteredConfirmations.length} of ${systemState.committee.members.length})`
|
|
624
|
+
);
|
|
593
625
|
}
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
const filteredConfirmations = confirmations.map((confirmation, index) => {
|
|
598
|
-
const isValid = confirmation?.serializedMessage === confirmationMessage && verifySignature(
|
|
599
|
-
confirmation,
|
|
600
|
-
new Uint8Array(committee.nodes[index].info.public_key.bytes)
|
|
601
|
-
);
|
|
602
|
-
return isValid ? {
|
|
603
|
-
index,
|
|
604
|
-
...confirmation
|
|
605
|
-
} : null;
|
|
606
|
-
}).filter((confirmation) => confirmation !== null);
|
|
607
|
-
if (!isQuorum(filteredConfirmations.length, systemState.committee.members.length)) {
|
|
608
|
-
throw new NotEnoughBlobConfirmationsError(
|
|
609
|
-
`Too many invalid confirmations received for blob (${filteredConfirmations.length} of ${systemState.committee.members.length})`
|
|
626
|
+
const combinedSignature = bindings.combineSignatures(
|
|
627
|
+
filteredConfirmations,
|
|
628
|
+
filteredConfirmations.map(({ index }) => index)
|
|
610
629
|
);
|
|
611
|
-
|
|
612
|
-
const combinedSignature = bindings.combineSignatures(
|
|
613
|
-
filteredConfirmations,
|
|
614
|
-
filteredConfirmations.map(({ index }) => index)
|
|
615
|
-
);
|
|
616
|
-
const systemContract = await __privateMethod(this, _WalrusClient_instances, getSystemContract_fn).call(this);
|
|
617
|
-
return (tx) => {
|
|
630
|
+
const systemContract = await __privateMethod(this, _WalrusClient_instances, getSystemContract_fn).call(this);
|
|
618
631
|
tx.add(
|
|
619
632
|
systemContract.certify_blob({
|
|
620
633
|
arguments: [
|
|
@@ -636,17 +649,17 @@ const _WalrusClient = class _WalrusClient {
|
|
|
636
649
|
*
|
|
637
650
|
* @usage
|
|
638
651
|
* ```ts
|
|
639
|
-
* const tx =
|
|
652
|
+
* const tx = client.certifyBlobTransaction({ blobId, blobObjectId, confirmations });
|
|
640
653
|
* ```
|
|
641
654
|
*/
|
|
642
|
-
|
|
655
|
+
certifyBlobTransaction({
|
|
643
656
|
transaction = new Transaction(),
|
|
644
657
|
blobId,
|
|
645
658
|
blobObjectId,
|
|
646
659
|
confirmations,
|
|
647
660
|
deletable
|
|
648
661
|
}) {
|
|
649
|
-
transaction.add(
|
|
662
|
+
transaction.add(this.certifyBlob({ blobId, blobObjectId, confirmations, deletable }));
|
|
650
663
|
return transaction;
|
|
651
664
|
}
|
|
652
665
|
/**
|
|
@@ -661,7 +674,7 @@ const _WalrusClient = class _WalrusClient {
|
|
|
661
674
|
signer,
|
|
662
675
|
...options
|
|
663
676
|
}) {
|
|
664
|
-
const transaction =
|
|
677
|
+
const transaction = this.certifyBlobTransaction(options);
|
|
665
678
|
const { digest } = await __privateMethod(this, _WalrusClient_instances, executeTransaction_fn).call(this, transaction, signer, "certify blob");
|
|
666
679
|
return { digest };
|
|
667
680
|
}
|
|
@@ -674,9 +687,9 @@ const _WalrusClient = class _WalrusClient {
|
|
|
674
687
|
* tx.transferObjects([storage], owner);
|
|
675
688
|
* ```
|
|
676
689
|
*/
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
690
|
+
deleteBlob({ blobObjectId }) {
|
|
691
|
+
return async (tx) => {
|
|
692
|
+
const systemContract = await __privateMethod(this, _WalrusClient_instances, getSystemContract_fn).call(this);
|
|
680
693
|
const storage = tx.add(
|
|
681
694
|
systemContract.delete_blob({
|
|
682
695
|
arguments: [tx.object(__privateGet(this, _packageConfig).systemObjectId), tx.object(blobObjectId)]
|
|
@@ -690,15 +703,15 @@ const _WalrusClient = class _WalrusClient {
|
|
|
690
703
|
*
|
|
691
704
|
* @usage
|
|
692
705
|
* ```ts
|
|
693
|
-
* const tx =
|
|
706
|
+
* const tx = client.deleteBlobTransaction({ blobObjectId, owner });
|
|
694
707
|
* ```
|
|
695
708
|
*/
|
|
696
|
-
|
|
709
|
+
deleteBlobTransaction({
|
|
697
710
|
owner,
|
|
698
711
|
blobObjectId,
|
|
699
712
|
transaction = new Transaction()
|
|
700
713
|
}) {
|
|
701
|
-
const storage = transaction.add(
|
|
714
|
+
const storage = transaction.add(this.deleteBlob({ blobObjectId }));
|
|
702
715
|
transaction.transferObjects([storage], owner);
|
|
703
716
|
return transaction;
|
|
704
717
|
}
|
|
@@ -715,7 +728,7 @@ const _WalrusClient = class _WalrusClient {
|
|
|
715
728
|
transaction = new Transaction(),
|
|
716
729
|
blobObjectId
|
|
717
730
|
}) {
|
|
718
|
-
const { digest } = await __privateMethod(this, _WalrusClient_instances, executeTransaction_fn).call(this,
|
|
731
|
+
const { digest } = await __privateMethod(this, _WalrusClient_instances, executeTransaction_fn).call(this, this.deleteBlobTransaction({
|
|
719
732
|
blobObjectId,
|
|
720
733
|
transaction,
|
|
721
734
|
owner: transaction.getData().sender ?? signer.toSuiAddress()
|
|
@@ -727,48 +740,51 @@ const _WalrusClient = class _WalrusClient {
|
|
|
727
740
|
*
|
|
728
741
|
* @usage
|
|
729
742
|
* ```ts
|
|
730
|
-
* const tx =
|
|
743
|
+
* const tx = client.extendBlobTransaction({ blobObjectId, epochs });
|
|
731
744
|
* ```
|
|
732
745
|
*/
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
746
|
+
extendBlob({ blobObjectId, epochs, endEpoch, walCoin, owner }) {
|
|
747
|
+
return async (tx) => {
|
|
748
|
+
const blob = await __privateGet(this, _objectLoader).load(blobObjectId, Blob());
|
|
749
|
+
const numEpochs = typeof epochs === "number" ? epochs : endEpoch - blob.storage.end_epoch;
|
|
750
|
+
if (numEpochs <= 0) {
|
|
751
|
+
return;
|
|
752
|
+
}
|
|
753
|
+
const { storageCost } = await this.storageCost(Number(blob.storage.storage_size), numEpochs);
|
|
754
|
+
const systemContract = await __privateMethod(this, _WalrusClient_instances, getSystemContract_fn).call(this);
|
|
755
|
+
const subsidiesContract = __privateGet(this, _packageConfig).subsidiesObjectId ? await __privateMethod(this, _WalrusClient_instances, getSubsidiesContract_fn).call(this) : null;
|
|
756
|
+
return tx.add(
|
|
757
|
+
__privateMethod(this, _WalrusClient_instances, withWal_fn).call(this, storageCost, owner, walCoin ?? null, subsidiesContract !== null, async (coin, tx2) => {
|
|
758
|
+
tx2.add(
|
|
759
|
+
subsidiesContract ? subsidiesContract.extend_blob({
|
|
760
|
+
arguments: [
|
|
761
|
+
__privateGet(this, _packageConfig).subsidiesObjectId,
|
|
762
|
+
__privateGet(this, _packageConfig).systemObjectId,
|
|
763
|
+
blobObjectId,
|
|
764
|
+
numEpochs,
|
|
765
|
+
coin
|
|
766
|
+
]
|
|
767
|
+
}) : systemContract.extend_blob({
|
|
768
|
+
arguments: [__privateGet(this, _packageConfig).systemObjectId, blobObjectId, numEpochs, coin]
|
|
769
|
+
})
|
|
770
|
+
);
|
|
755
771
|
})
|
|
756
772
|
);
|
|
757
|
-
}
|
|
773
|
+
};
|
|
758
774
|
}
|
|
759
775
|
/**
|
|
760
776
|
* Create a transaction that extends a blob
|
|
761
777
|
*
|
|
762
778
|
* @usage
|
|
763
779
|
* ```ts
|
|
764
|
-
* const tx =
|
|
780
|
+
* const tx = client.extendBlobTransaction({ blobObjectId, epochs });
|
|
765
781
|
* ```
|
|
766
782
|
*/
|
|
767
783
|
async extendBlobTransaction({
|
|
768
784
|
transaction = new Transaction(),
|
|
769
785
|
...options
|
|
770
786
|
}) {
|
|
771
|
-
transaction.add(
|
|
787
|
+
transaction.add(this.extendBlob(options));
|
|
772
788
|
return transaction;
|
|
773
789
|
}
|
|
774
790
|
/**
|
|
@@ -807,18 +823,20 @@ const _WalrusClient = class _WalrusClient {
|
|
|
807
823
|
*
|
|
808
824
|
* @usage
|
|
809
825
|
* ```ts
|
|
810
|
-
* tx.add(
|
|
826
|
+
* tx.add(client.writeBlobAttributes({ blobObjectId, attributes: { key: 'value', keyToRemove: null } }));
|
|
811
827
|
* ```
|
|
812
828
|
*/
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
attributes,
|
|
817
|
-
existingAttributes
|
|
818
|
-
});
|
|
819
|
-
return (tx) => {
|
|
829
|
+
writeBlobAttributes({ blobObject, blobObjectId, attributes }) {
|
|
830
|
+
return async (tx) => {
|
|
831
|
+
const existingAttributes = blobObjectId ? await this.readBlobAttributes({ blobObjectId }) : null;
|
|
820
832
|
const blob = blobObject ?? tx.object(blobObjectId);
|
|
821
|
-
tx.add(
|
|
833
|
+
tx.add(
|
|
834
|
+
__privateMethod(this, _WalrusClient_instances, writeBlobAttributesForRef_fn).call(this, {
|
|
835
|
+
attributes,
|
|
836
|
+
existingAttributes,
|
|
837
|
+
blob
|
|
838
|
+
})
|
|
839
|
+
);
|
|
822
840
|
};
|
|
823
841
|
}
|
|
824
842
|
/**
|
|
@@ -829,7 +847,7 @@ const _WalrusClient = class _WalrusClient {
|
|
|
829
847
|
*
|
|
830
848
|
* @usage
|
|
831
849
|
* ```ts
|
|
832
|
-
* const tx =
|
|
850
|
+
* const tx = client.writeBlobAttributesTransaction({ blobObjectId, attributes: { key: 'value', keyToRemove: null } });
|
|
833
851
|
* ```
|
|
834
852
|
*/
|
|
835
853
|
async writeBlobAttributesTransaction({
|
|
@@ -1250,16 +1268,16 @@ forceGetReadCommittee_fn = async function({ blobId, signal }) {
|
|
|
1250
1268
|
}
|
|
1251
1269
|
return await __privateMethod(this, _WalrusClient_instances, getActiveCommittee_fn).call(this);
|
|
1252
1270
|
};
|
|
1253
|
-
withWal_fn =
|
|
1254
|
-
|
|
1255
|
-
|
|
1271
|
+
withWal_fn = function(amount, owner, source, withSubsidies, fn) {
|
|
1272
|
+
return async (tx) => {
|
|
1273
|
+
const walType = await __privateMethod(this, _WalrusClient_instances, walType_fn).call(this);
|
|
1256
1274
|
const coin = source ? tx.splitCoins(source, [amount])[0] : tx.add(
|
|
1257
1275
|
coinWithBalance({
|
|
1258
1276
|
balance: amount,
|
|
1259
1277
|
type: walType
|
|
1260
1278
|
})
|
|
1261
1279
|
);
|
|
1262
|
-
const result = fn(coin, tx);
|
|
1280
|
+
const result = await fn(coin, tx);
|
|
1263
1281
|
if (withSubsidies) {
|
|
1264
1282
|
if (source) {
|
|
1265
1283
|
tx.mergeCoins(source, [coin]);
|
|
@@ -1276,13 +1294,14 @@ withWal_fn = async function(amount, owner, source, withSubsidies, fn) {
|
|
|
1276
1294
|
return result;
|
|
1277
1295
|
};
|
|
1278
1296
|
};
|
|
1279
|
-
writeBlobAttributesForRef_fn =
|
|
1297
|
+
writeBlobAttributesForRef_fn = function({
|
|
1280
1298
|
attributes,
|
|
1281
|
-
existingAttributes
|
|
1299
|
+
existingAttributes,
|
|
1300
|
+
blob
|
|
1282
1301
|
}) {
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1302
|
+
return async (tx) => {
|
|
1303
|
+
const blobContract = await __privateMethod(this, _WalrusClient_instances, getBlobContract_fn).call(this);
|
|
1304
|
+
const metadataContract = await __privateMethod(this, _WalrusClient_instances, getMetadataContract_fn).call(this);
|
|
1286
1305
|
if (!existingAttributes) {
|
|
1287
1306
|
tx.add(
|
|
1288
1307
|
blobContract.add_metadata({
|
|
@@ -1326,7 +1345,7 @@ executeTransaction_fn = async function(transaction, signer, action) {
|
|
|
1326
1345
|
signatures: [signature]
|
|
1327
1346
|
});
|
|
1328
1347
|
if (effects?.status.error) {
|
|
1329
|
-
throw new WalrusClientError(`Failed to ${action}: ${effects?.status.error}`);
|
|
1348
|
+
throw new WalrusClientError(`Failed to ${action} (${digest}): ${effects?.status.error}`);
|
|
1330
1349
|
}
|
|
1331
1350
|
await __privateGet(this, _suiClient).core.waitForTransaction({
|
|
1332
1351
|
digest
|