@fuel-ts/account 0.0.0-rc-2037-20240411163513 → 0.0.0-rc-2045-20240411194225

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.

package/dist/index.js CHANGED
@@ -2038,8 +2038,8 @@ var BaseTransactionRequest = class {
2038
2038
  * @param predicate - Predicate bytes.
2039
2039
  * @param predicateData - Predicate data bytes.
2040
2040
  */
2041
- addCoinInput(coin) {
2042
- const { assetId, owner, amount, id, predicate } = coin;
2041
+ addCoinInput(coin, predicate) {
2042
+ const { assetId, owner, amount } = coin;
2043
2043
  let witnessIndex;
2044
2044
  if (predicate) {
2045
2045
  witnessIndex = 0;
@@ -2050,14 +2050,14 @@ var BaseTransactionRequest = class {
2050
2050
  }
2051
2051
  }
2052
2052
  const input = {
2053
- id,
2053
+ ...coin,
2054
2054
  type: import_transactions6.InputType.Coin,
2055
2055
  owner: owner.toB256(),
2056
2056
  amount,
2057
2057
  assetId,
2058
2058
  txPointer: "0x00000000000000000000000000000000",
2059
2059
  witnessIndex,
2060
- predicate
2060
+ predicate: predicate?.bytes
2061
2061
  };
2062
2062
  this.pushInput(input);
2063
2063
  this.addChangeOutput(owner, assetId);
@@ -2070,8 +2070,8 @@ var BaseTransactionRequest = class {
2070
2070
  * @param predicate - Predicate bytes.
2071
2071
  * @param predicateData - Predicate data bytes.
2072
2072
  */
2073
- addMessageInput(message) {
2074
- const { recipient, sender, amount, predicate, nonce } = message;
2073
+ addMessageInput(message, predicate) {
2074
+ const { recipient, sender, amount } = message;
2075
2075
  const assetId = import_configs7.BaseAssetId;
2076
2076
  let witnessIndex;
2077
2077
  if (predicate) {
@@ -2083,13 +2083,13 @@ var BaseTransactionRequest = class {
2083
2083
  }
2084
2084
  }
2085
2085
  const input = {
2086
- nonce,
2086
+ ...message,
2087
2087
  type: import_transactions6.InputType.Message,
2088
2088
  sender: sender.toB256(),
2089
2089
  recipient: recipient.toB256(),
2090
2090
  amount,
2091
2091
  witnessIndex,
2092
- predicate
2092
+ predicate: predicate?.bytes
2093
2093
  };
2094
2094
  this.pushInput(input);
2095
2095
  this.addChangeOutput(recipient, assetId);
@@ -2120,6 +2120,32 @@ var BaseTransactionRequest = class {
2120
2120
  resources.forEach((resource) => this.addResource(resource));
2121
2121
  return this;
2122
2122
  }
2123
+ /**
2124
+ * Adds multiple resources to the transaction by adding coin/message inputs and change
2125
+ * outputs from the related assetIds.
2126
+ *
2127
+ * @param resources - The resources to add.
2128
+ * @returns This transaction.
2129
+ */
2130
+ addPredicateResource(resource, predicate) {
2131
+ if (isCoin(resource)) {
2132
+ this.addCoinInput(resource, predicate);
2133
+ } else {
2134
+ this.addMessageInput(resource, predicate);
2135
+ }
2136
+ return this;
2137
+ }
2138
+ /**
2139
+ * Adds multiple predicate coin/message inputs to the transaction and change outputs
2140
+ * from the related assetIds.
2141
+ *
2142
+ * @param resources - The resources to add.
2143
+ * @returns This transaction.
2144
+ */
2145
+ addPredicateResources(resources, predicate) {
2146
+ resources.forEach((resource) => this.addPredicateResource(resource, predicate));
2147
+ return this;
2148
+ }
2123
2149
  /**
2124
2150
  * Adds a coin output to the transaction.
2125
2151
  *
@@ -8856,7 +8882,6 @@ var Predicate = class extends Account {
8856
8882
  if (input.type === import_transactions20.InputType.Coin && (0, import_utils37.hexlify)(input.owner) === this.address.toB256()) {
8857
8883
  input.predicate = this.bytes;
8858
8884
  input.predicateData = this.getPredicateData(policies.length);
8859
- input.witnessIndex = 0;
8860
8885
  }
8861
8886
  });
8862
8887
  return request;
@@ -8894,20 +8919,6 @@ var Predicate = class extends Account {
8894
8919
  const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
8895
8920
  return super.simulateTransaction(transactionRequest);
8896
8921
  }
8897
- /**
8898
- * Retrieves resources satisfying the spend query for the account.
8899
- *
8900
- * @param quantities - IDs of coins to exclude.
8901
- * @param excludedIds - IDs of resources to be excluded from the query.
8902
- * @returns A promise that resolves to an array of Resources.
8903
- */
8904
- async getResourcesToSpend(quantities, excludedIds) {
8905
- const resources = await super.getResourcesToSpend(quantities, excludedIds);
8906
- return resources.map((resource) => ({
8907
- ...resource,
8908
- predicate: (0, import_utils37.hexlify)(this.bytes)
8909
- }));
8910
- }
8911
8922
  getPredicateData(policiesLength) {
8912
8923
  if (!this.predicateData.length) {
8913
8924
  return new Uint8Array();