@fuel-ts/account 0.0.0-rc-2037-20240411020051 → 0.0.0-rc-2040-20240411095959

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.

Potentially problematic release.


This version of @fuel-ts/account might be problematic. Click here for more details.

@@ -33229,6 +33229,15 @@ This unreleased fuel-core build may include features and updates not yet support
33229
33229
  });
33230
33230
  return coder.decode(bytes3, 0);
33231
33231
  }
33232
+ /**
33233
+ * Checks if the function is read-only i.e. it only reads from storage, does not write to it.
33234
+ *
33235
+ * @returns True if the function is read-only or pure, false otherwise.
33236
+ */
33237
+ isReadOnly() {
33238
+ const storageAttribute = this.attributes.find((attr) => attr.name === "storage");
33239
+ return !storageAttribute?.arguments.includes("write");
33240
+ }
33232
33241
  };
33233
33242
  var Interface = class {
33234
33243
  functions;
@@ -33291,8 +33300,7 @@ This unreleased fuel-core build may include features and updates not yet support
33291
33300
  );
33292
33301
  }
33293
33302
  return AbiCoder.encode(this.jsonAbi, configurable.configurableType, value, {
33294
- isRightPadded: true,
33295
- encoding: this.jsonAbi.encoding
33303
+ isRightPadded: true
33296
33304
  });
33297
33305
  }
33298
33306
  getTypeById(typeId) {
@@ -39744,8 +39752,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39744
39752
  * @param predicate - Predicate bytes.
39745
39753
  * @param predicateData - Predicate data bytes.
39746
39754
  */
39747
- addCoinInput(coin) {
39748
- const { assetId, owner, amount, id, predicate } = coin;
39755
+ addCoinInput(coin, predicate) {
39756
+ const { assetId, owner, amount } = coin;
39749
39757
  let witnessIndex;
39750
39758
  if (predicate) {
39751
39759
  witnessIndex = 0;
@@ -39756,14 +39764,14 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39756
39764
  }
39757
39765
  }
39758
39766
  const input = {
39759
- id,
39767
+ ...coin,
39760
39768
  type: InputType.Coin,
39761
39769
  owner: owner.toB256(),
39762
39770
  amount,
39763
39771
  assetId,
39764
39772
  txPointer: "0x00000000000000000000000000000000",
39765
39773
  witnessIndex,
39766
- predicate
39774
+ predicate: predicate?.bytes
39767
39775
  };
39768
39776
  this.pushInput(input);
39769
39777
  this.addChangeOutput(owner, assetId);
@@ -39776,8 +39784,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39776
39784
  * @param predicate - Predicate bytes.
39777
39785
  * @param predicateData - Predicate data bytes.
39778
39786
  */
39779
- addMessageInput(message) {
39780
- const { recipient, sender, amount, predicate, nonce } = message;
39787
+ addMessageInput(message, predicate) {
39788
+ const { recipient, sender, amount } = message;
39781
39789
  const assetId = BaseAssetId;
39782
39790
  let witnessIndex;
39783
39791
  if (predicate) {
@@ -39789,13 +39797,13 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39789
39797
  }
39790
39798
  }
39791
39799
  const input = {
39792
- nonce,
39800
+ ...message,
39793
39801
  type: InputType.Message,
39794
39802
  sender: sender.toB256(),
39795
39803
  recipient: recipient.toB256(),
39796
39804
  amount,
39797
39805
  witnessIndex,
39798
- predicate
39806
+ predicate: predicate?.bytes
39799
39807
  };
39800
39808
  this.pushInput(input);
39801
39809
  this.addChangeOutput(recipient, assetId);
@@ -39826,6 +39834,32 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
39826
39834
  resources.forEach((resource) => this.addResource(resource));
39827
39835
  return this;
39828
39836
  }
39837
+ /**
39838
+ * Adds multiple resources to the transaction by adding coin/message inputs and change
39839
+ * outputs from the related assetIds.
39840
+ *
39841
+ * @param resources - The resources to add.
39842
+ * @returns This transaction.
39843
+ */
39844
+ addPredicateResource(resource, predicate) {
39845
+ if (isCoin(resource)) {
39846
+ this.addCoinInput(resource, predicate);
39847
+ } else {
39848
+ this.addMessageInput(resource, predicate);
39849
+ }
39850
+ return this;
39851
+ }
39852
+ /**
39853
+ * Adds multiple predicate coin/message inputs to the transaction and change outputs
39854
+ * from the related assetIds.
39855
+ *
39856
+ * @param resources - The resources to add.
39857
+ * @returns This transaction.
39858
+ */
39859
+ addPredicateResources(resources, predicate) {
39860
+ resources.forEach((resource) => this.addPredicateResource(resource, predicate));
39861
+ return this;
39862
+ }
39829
39863
  /**
39830
39864
  * Adds a coin output to the transaction.
39831
39865
  *
@@ -47805,7 +47839,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
47805
47839
  if (input.type === InputType.Coin && hexlify(input.owner) === this.address.toB256()) {
47806
47840
  input.predicate = this.bytes;
47807
47841
  input.predicateData = this.getPredicateData(policies.length);
47808
- input.witnessIndex = 0;
47809
47842
  }
47810
47843
  });
47811
47844
  return request;
@@ -47843,20 +47876,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
47843
47876
  const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
47844
47877
  return super.simulateTransaction(transactionRequest);
47845
47878
  }
47846
- /**
47847
- * Retrieves resources satisfying the spend query for the account.
47848
- *
47849
- * @param quantities - IDs of coins to exclude.
47850
- * @param excludedIds - IDs of resources to be excluded from the query.
47851
- * @returns A promise that resolves to an array of Resources.
47852
- */
47853
- async getResourcesToSpend(quantities, excludedIds) {
47854
- const resources = await super.getResourcesToSpend(quantities, excludedIds);
47855
- return resources.map((resource) => ({
47856
- ...resource,
47857
- predicate: hexlify(this.bytes)
47858
- }));
47859
- }
47860
47879
  getPredicateData(policiesLength) {
47861
47880
  if (!this.predicateData.length) {
47862
47881
  return new Uint8Array();