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