@fuel-ts/account 0.0.0-rc-2130-20240422142413 → 0.0.0-rc-2037-20240422145740

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.

Files changed (39) hide show
  1. package/dist/hdwallet/hdwallet.d.ts.map +1 -1
  2. package/dist/index.global.js +2583 -1402
  3. package/dist/index.global.js.map +1 -1
  4. package/dist/index.js +230 -154
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.mjs +140 -70
  7. package/dist/index.mjs.map +1 -1
  8. package/dist/mnemonic/mnemonic.d.ts.map +1 -1
  9. package/dist/predicate/predicate.d.ts +17 -2
  10. package/dist/predicate/predicate.d.ts.map +1 -1
  11. package/dist/providers/coin.d.ts +2 -1
  12. package/dist/providers/coin.d.ts.map +1 -1
  13. package/dist/providers/message.d.ts +1 -0
  14. package/dist/providers/message.d.ts.map +1 -1
  15. package/dist/providers/provider.d.ts +9 -0
  16. package/dist/providers/provider.d.ts.map +1 -1
  17. package/dist/providers/transaction-request/helpers.d.ts +10 -0
  18. package/dist/providers/transaction-request/helpers.d.ts.map +1 -0
  19. package/dist/providers/transaction-request/index.d.ts +1 -0
  20. package/dist/providers/transaction-request/index.d.ts.map +1 -1
  21. package/dist/providers/transaction-request/transaction-request.d.ts +4 -20
  22. package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
  23. package/dist/test-utils/index.d.ts +1 -0
  24. package/dist/test-utils/index.d.ts.map +1 -1
  25. package/dist/test-utils/resources.d.ts +4 -0
  26. package/dist/test-utils/resources.d.ts.map +1 -0
  27. package/dist/test-utils/seedTestWallet.d.ts +1 -1
  28. package/dist/test-utils/seedTestWallet.d.ts.map +1 -1
  29. package/dist/test-utils/transactionRequest.d.ts +5 -0
  30. package/dist/test-utils/transactionRequest.d.ts.map +1 -0
  31. package/dist/test-utils.global.js +2609 -1451
  32. package/dist/test-utils.global.js.map +1 -1
  33. package/dist/test-utils.js +203 -149
  34. package/dist/test-utils.js.map +1 -1
  35. package/dist/test-utils.mjs +121 -70
  36. package/dist/test-utils.mjs.map +1 -1
  37. package/dist/wallet/base-wallet-unlocked.d.ts +2 -2
  38. package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
  39. package/package.json +16 -15
package/dist/index.mjs CHANGED
@@ -76,7 +76,7 @@ import { Address as Address2 } from "@fuel-ts/address";
76
76
  import { ErrorCode as ErrorCode13, FuelError as FuelError13 } from "@fuel-ts/errors";
77
77
  import { BN, bn as bn15, max } from "@fuel-ts/math";
78
78
  import {
79
- InputType as InputType6,
79
+ InputType as InputType7,
80
80
  TransactionType as TransactionType8,
81
81
  InputMessageCoder,
82
82
  TransactionCoder as TransactionCoder5
@@ -84,6 +84,7 @@ import {
84
84
  import { arrayify as arrayify11, hexlify as hexlify12, DateTime as DateTime2 } from "@fuel-ts/utils";
85
85
  import { checkFuelCoreVersionCompatibility } from "@fuel-ts/versions";
86
86
  import { equalBytes } from "@noble/curves/abstract/utils";
87
+ import { Network } from "ethers";
87
88
  import { GraphQLClient } from "graphql-request";
88
89
  import { clone as clone3 } from "ramda";
89
90
 
@@ -1172,7 +1173,7 @@ import { bn as bn7 } from "@fuel-ts/math";
1172
1173
  import {
1173
1174
  PolicyType,
1174
1175
  TransactionCoder,
1175
- InputType as InputType2,
1176
+ InputType as InputType3,
1176
1177
  OutputType as OutputType2,
1177
1178
  TransactionType
1178
1179
  } from "@fuel-ts/transactions";
@@ -1675,6 +1676,28 @@ var NoWitnessByOwnerError = class extends Error {
1675
1676
  name = "NoWitnessByOwnerError";
1676
1677
  };
1677
1678
 
1679
+ // src/providers/transaction-request/helpers.ts
1680
+ import { InputType as InputType2 } from "@fuel-ts/transactions";
1681
+ var isRequestInputCoin = (input) => input.type === InputType2.Coin;
1682
+ var isRequestInputMessage = (input) => input.type === InputType2.Message;
1683
+ var isRequestInputResource = (input) => isRequestInputCoin(input) || isRequestInputMessage(input);
1684
+ var getRequestInputResourceOwner = (input) => isRequestInputCoin(input) ? input.owner : input.recipient;
1685
+ var isRequestInputResourceFromOwner = (input, owner) => getRequestInputResourceOwner(input) === owner.toB256();
1686
+ var cacheResources = (resources) => resources.reduce(
1687
+ (cache2, resource) => {
1688
+ if (isCoin(resource)) {
1689
+ cache2.utxos.push(resource.id);
1690
+ } else {
1691
+ cache2.messages.push(resource.nonce);
1692
+ }
1693
+ return cache2;
1694
+ },
1695
+ {
1696
+ utxos: [],
1697
+ messages: []
1698
+ }
1699
+ );
1700
+
1678
1701
  // src/providers/transaction-request/witness.ts
1679
1702
  import { arrayify as arrayify4, hexlify as hexlify6 } from "@fuel-ts/utils";
1680
1703
  var witnessify = (value) => {
@@ -1865,7 +1888,7 @@ var BaseTransactionRequest = class {
1865
1888
  */
1866
1889
  getCoinInputs() {
1867
1890
  return this.inputs.filter(
1868
- (input) => input.type === InputType2.Coin
1891
+ (input) => input.type === InputType3.Coin
1869
1892
  );
1870
1893
  }
1871
1894
  /**
@@ -1897,9 +1920,9 @@ var BaseTransactionRequest = class {
1897
1920
  const ownerAddress = addressify(owner);
1898
1921
  const found = this.inputs.find((input) => {
1899
1922
  switch (input.type) {
1900
- case InputType2.Coin:
1923
+ case InputType3.Coin:
1901
1924
  return hexlify7(input.owner) === ownerAddress.toB256();
1902
- case InputType2.Message:
1925
+ case InputType3.Message:
1903
1926
  return hexlify7(input.recipient) === ownerAddress.toB256();
1904
1927
  default:
1905
1928
  return false;
@@ -1915,8 +1938,8 @@ var BaseTransactionRequest = class {
1915
1938
  * @param predicate - Predicate bytes.
1916
1939
  * @param predicateData - Predicate data bytes.
1917
1940
  */
1918
- addCoinInput(coin, predicate) {
1919
- const { assetId, owner, amount } = coin;
1941
+ addCoinInput(coin) {
1942
+ const { assetId, owner, amount, id, predicate } = coin;
1920
1943
  let witnessIndex;
1921
1944
  if (predicate) {
1922
1945
  witnessIndex = 0;
@@ -1927,14 +1950,14 @@ var BaseTransactionRequest = class {
1927
1950
  }
1928
1951
  }
1929
1952
  const input = {
1930
- ...coin,
1931
- type: InputType2.Coin,
1953
+ id,
1954
+ type: InputType3.Coin,
1932
1955
  owner: owner.toB256(),
1933
1956
  amount,
1934
1957
  assetId,
1935
1958
  txPointer: "0x00000000000000000000000000000000",
1936
1959
  witnessIndex,
1937
- predicate: predicate?.bytes
1960
+ predicate
1938
1961
  };
1939
1962
  this.pushInput(input);
1940
1963
  this.addChangeOutput(owner, assetId);
@@ -1947,8 +1970,8 @@ var BaseTransactionRequest = class {
1947
1970
  * @param predicate - Predicate bytes.
1948
1971
  * @param predicateData - Predicate data bytes.
1949
1972
  */
1950
- addMessageInput(message, predicate) {
1951
- const { recipient, sender, amount } = message;
1973
+ addMessageInput(message) {
1974
+ const { recipient, sender, amount, predicate, nonce } = message;
1952
1975
  const assetId = BaseAssetId2;
1953
1976
  let witnessIndex;
1954
1977
  if (predicate) {
@@ -1960,13 +1983,13 @@ var BaseTransactionRequest = class {
1960
1983
  }
1961
1984
  }
1962
1985
  const input = {
1963
- ...message,
1964
- type: InputType2.Message,
1986
+ nonce,
1987
+ type: InputType3.Message,
1965
1988
  sender: sender.toB256(),
1966
1989
  recipient: recipient.toB256(),
1967
1990
  amount,
1968
1991
  witnessIndex,
1969
- predicate: predicate?.bytes
1992
+ predicate
1970
1993
  };
1971
1994
  this.pushInput(input);
1972
1995
  this.addChangeOutput(recipient, assetId);
@@ -1997,32 +2020,6 @@ var BaseTransactionRequest = class {
1997
2020
  resources.forEach((resource) => this.addResource(resource));
1998
2021
  return this;
1999
2022
  }
2000
- /**
2001
- * Adds multiple resources to the transaction by adding coin/message inputs and change
2002
- * outputs from the related assetIds.
2003
- *
2004
- * @param resources - The resources to add.
2005
- * @returns This transaction.
2006
- */
2007
- addPredicateResource(resource, predicate) {
2008
- if (isCoin(resource)) {
2009
- this.addCoinInput(resource, predicate);
2010
- } else {
2011
- this.addMessageInput(resource, predicate);
2012
- }
2013
- return this;
2014
- }
2015
- /**
2016
- * Adds multiple predicate coin/message inputs to the transaction and change outputs
2017
- * from the related assetIds.
2018
- *
2019
- * @param resources - The resources to add.
2020
- * @returns This transaction.
2021
- */
2022
- addPredicateResources(resources, predicate) {
2023
- resources.forEach((resource) => this.addPredicateResource(resource, predicate));
2024
- return this;
2025
- }
2026
2023
  /**
2027
2024
  * Adds a coin output to the transaction.
2028
2025
  *
@@ -2171,16 +2168,20 @@ var BaseTransactionRequest = class {
2171
2168
  toJSON() {
2172
2169
  return normalizeJSON(this);
2173
2170
  }
2171
+ removeWitness(index) {
2172
+ this.witnesses.splice(index, 1);
2173
+ this.adjustWitnessIndexes(index);
2174
+ }
2174
2175
  updatePredicateInputs(inputs) {
2175
2176
  this.inputs.forEach((i) => {
2176
2177
  let correspondingInput;
2177
2178
  switch (i.type) {
2178
- case InputType2.Coin:
2179
- correspondingInput = inputs.find((x) => x.type === InputType2.Coin && x.owner === i.owner);
2179
+ case InputType3.Coin:
2180
+ correspondingInput = inputs.find((x) => x.type === InputType3.Coin && x.owner === i.owner);
2180
2181
  break;
2181
- case InputType2.Message:
2182
+ case InputType3.Message:
2182
2183
  correspondingInput = inputs.find(
2183
- (x) => x.type === InputType2.Message && x.sender === i.sender
2184
+ (x) => x.type === InputType3.Message && x.sender === i.sender
2184
2185
  );
2185
2186
  break;
2186
2187
  default:
@@ -2193,6 +2194,13 @@ var BaseTransactionRequest = class {
2193
2194
  }
2194
2195
  });
2195
2196
  }
2197
+ adjustWitnessIndexes(removedIndex) {
2198
+ this.inputs.filter(isRequestInputResource).forEach((input) => {
2199
+ if (input.witnessIndex > removedIndex) {
2200
+ input.witnessIndex -= 1;
2201
+ }
2202
+ });
2203
+ }
2196
2204
  };
2197
2205
 
2198
2206
  // src/providers/transaction-request/create-transaction-request.ts
@@ -2205,7 +2213,7 @@ import { arrayify as arrayify6, hexlify as hexlify9 } from "@fuel-ts/utils";
2205
2213
  import { ZeroBytes32 as ZeroBytes325 } from "@fuel-ts/address/configs";
2206
2214
  import { uint64ToBytesBE, sha256 } from "@fuel-ts/hasher";
2207
2215
  import { bn as bn8 } from "@fuel-ts/math";
2208
- import { TransactionType as TransactionType2, InputType as InputType3, OutputType as OutputType3, TransactionCoder as TransactionCoder2 } from "@fuel-ts/transactions";
2216
+ import { TransactionType as TransactionType2, InputType as InputType4, OutputType as OutputType3, TransactionCoder as TransactionCoder2 } from "@fuel-ts/transactions";
2209
2217
  import { concat as concat2 } from "@fuel-ts/utils";
2210
2218
  import { clone as clone2 } from "ramda";
2211
2219
  function hashTransaction(transactionRequest, chainId) {
@@ -2216,7 +2224,7 @@ function hashTransaction(transactionRequest, chainId) {
2216
2224
  transaction.inputs = transaction.inputs.map((input) => {
2217
2225
  const inputClone = clone2(input);
2218
2226
  switch (inputClone.type) {
2219
- case InputType3.Coin: {
2227
+ case InputType4.Coin: {
2220
2228
  inputClone.txPointer = {
2221
2229
  blockHeight: 0,
2222
2230
  txIndex: 0
@@ -2224,11 +2232,11 @@ function hashTransaction(transactionRequest, chainId) {
2224
2232
  inputClone.predicateGasUsed = bn8(0);
2225
2233
  return inputClone;
2226
2234
  }
2227
- case InputType3.Message: {
2235
+ case InputType4.Message: {
2228
2236
  inputClone.predicateGasUsed = bn8(0);
2229
2237
  return inputClone;
2230
2238
  }
2231
- case InputType3.Contract: {
2239
+ case InputType4.Contract: {
2232
2240
  inputClone.txPointer = {
2233
2241
  blockHeight: 0,
2234
2242
  txIndex: 0
@@ -2394,7 +2402,7 @@ import { Interface } from "@fuel-ts/abi-coder";
2394
2402
  import { addressify as addressify2 } from "@fuel-ts/address";
2395
2403
  import { ZeroBytes32 as ZeroBytes327 } from "@fuel-ts/address/configs";
2396
2404
  import { bn as bn10 } from "@fuel-ts/math";
2397
- import { InputType as InputType4, OutputType as OutputType5, TransactionType as TransactionType4 } from "@fuel-ts/transactions";
2405
+ import { InputType as InputType5, OutputType as OutputType5, TransactionType as TransactionType4 } from "@fuel-ts/transactions";
2398
2406
  import { arrayify as arrayify8, hexlify as hexlify10 } from "@fuel-ts/utils";
2399
2407
 
2400
2408
  // src/providers/transaction-request/scripts.ts
@@ -2478,7 +2486,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2478
2486
  */
2479
2487
  getContractInputs() {
2480
2488
  return this.inputs.filter(
2481
- (input) => input.type === InputType4.Contract
2489
+ (input) => input.type === InputType5.Contract
2482
2490
  );
2483
2491
  }
2484
2492
  /**
@@ -2554,7 +2562,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2554
2562
  return this;
2555
2563
  }
2556
2564
  const inputIndex = super.pushInput({
2557
- type: InputType4.Contract,
2565
+ type: InputType5.Contract,
2558
2566
  contractId: contractAddress.toB256(),
2559
2567
  txPointer: "0x00000000000000000000000000000000"
2560
2568
  });
@@ -2749,7 +2757,7 @@ var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
2749
2757
 
2750
2758
  // src/providers/transaction-summary/input.ts
2751
2759
  import { ErrorCode as ErrorCode9, FuelError as FuelError9 } from "@fuel-ts/errors";
2752
- import { InputType as InputType5 } from "@fuel-ts/transactions";
2760
+ import { InputType as InputType6 } from "@fuel-ts/transactions";
2753
2761
  function getInputsByTypes(inputs, types) {
2754
2762
  return inputs.filter((i) => types.includes(i.type));
2755
2763
  }
@@ -2757,16 +2765,16 @@ function getInputsByType(inputs, type) {
2757
2765
  return inputs.filter((i) => i.type === type);
2758
2766
  }
2759
2767
  function getInputsCoin(inputs) {
2760
- return getInputsByType(inputs, InputType5.Coin);
2768
+ return getInputsByType(inputs, InputType6.Coin);
2761
2769
  }
2762
2770
  function getInputsMessage(inputs) {
2763
- return getInputsByType(inputs, InputType5.Message);
2771
+ return getInputsByType(inputs, InputType6.Message);
2764
2772
  }
2765
2773
  function getInputsCoinAndMessage(inputs) {
2766
- return getInputsByTypes(inputs, [InputType5.Coin, InputType5.Message]);
2774
+ return getInputsByTypes(inputs, [InputType6.Coin, InputType6.Message]);
2767
2775
  }
2768
2776
  function getInputsContract(inputs) {
2769
- return getInputsByType(inputs, InputType5.Contract);
2777
+ return getInputsByType(inputs, InputType6.Contract);
2770
2778
  }
2771
2779
  function getInputFromAssetId(inputs, assetId) {
2772
2780
  const coinInputs = getInputsCoin(inputs);
@@ -2785,7 +2793,7 @@ function getInputContractFromIndex(inputs, inputIndex) {
2785
2793
  if (!contractInput) {
2786
2794
  return void 0;
2787
2795
  }
2788
- if (contractInput.type !== InputType5.Contract) {
2796
+ if (contractInput.type !== InputType6.Contract) {
2789
2797
  throw new FuelError9(
2790
2798
  ErrorCode9.INVALID_TRANSACTION_INPUT,
2791
2799
  `Contract input should be of type 'contract'.`
@@ -2794,10 +2802,10 @@ function getInputContractFromIndex(inputs, inputIndex) {
2794
2802
  return contractInput;
2795
2803
  }
2796
2804
  function getInputAccountAddress(input) {
2797
- if (input.type === InputType5.Coin) {
2805
+ if (input.type === InputType6.Coin) {
2798
2806
  return input.owner.toString();
2799
2807
  }
2800
- if (input.type === InputType5.Message) {
2808
+ if (input.type === InputType6.Message) {
2801
2809
  return input.recipient.toString();
2802
2810
  }
2803
2811
  return "";
@@ -3798,6 +3806,21 @@ var _Provider = class {
3798
3806
  } = await this.operations.getVersion();
3799
3807
  return nodeVersion;
3800
3808
  }
3809
+ /**
3810
+ * @hidden
3811
+ *
3812
+ * Returns the network configuration of the connected Fuel node.
3813
+ *
3814
+ * @returns A promise that resolves to the network configuration object
3815
+ */
3816
+ async getNetwork() {
3817
+ const {
3818
+ name,
3819
+ consensusParameters: { chainId }
3820
+ } = await this.getChain();
3821
+ const network = new Network(name, chainId.toNumber());
3822
+ return Promise.resolve(network);
3823
+ }
3801
3824
  /**
3802
3825
  * Returns the block number.
3803
3826
  *
@@ -4526,7 +4549,7 @@ cacheInputs_fn = function(inputs) {
4526
4549
  return;
4527
4550
  }
4528
4551
  inputs.forEach((input) => {
4529
- if (input.type === InputType6.Coin) {
4552
+ if (input.type === InputType7.Coin) {
4530
4553
  this.cache?.set(input.id);
4531
4554
  }
4532
4555
  });
@@ -5532,17 +5555,18 @@ var BaseWalletUnlocked = class extends Account {
5532
5555
  __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
5533
5556
 
5534
5557
  // src/hdwallet/hdwallet.ts
5535
- import { computeHmac as computeHmac2, ripemd160 } from "@fuel-ts/crypto";
5536
5558
  import { ErrorCode as ErrorCode19, FuelError as FuelError19 } from "@fuel-ts/errors";
5537
5559
  import { sha256 as sha2564 } from "@fuel-ts/hasher";
5538
5560
  import { bn as bn18, toBytes as toBytes2, toHex } from "@fuel-ts/math";
5539
- import { arrayify as arrayify18, hexlify as hexlify17, concat as concat5, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58 } from "@fuel-ts/utils";
5561
+ import { arrayify as arrayify18, hexlify as hexlify17, concat as concat5 } from "@fuel-ts/utils";
5562
+ import { toBeHex, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58, computeHmac as computeHmac2, ripemd160 } from "ethers";
5540
5563
 
5541
5564
  // src/mnemonic/mnemonic.ts
5542
- import { randomBytes as randomBytes4, pbkdf2, computeHmac } from "@fuel-ts/crypto";
5565
+ import { randomBytes as randomBytes4 } from "@fuel-ts/crypto";
5543
5566
  import { ErrorCode as ErrorCode18, FuelError as FuelError18 } from "@fuel-ts/errors";
5544
5567
  import { sha256 as sha2563 } from "@fuel-ts/hasher";
5545
- import { arrayify as arrayify17, hexlify as hexlify16, concat as concat4, dataSlice, encodeBase58 } from "@fuel-ts/utils";
5568
+ import { arrayify as arrayify17, hexlify as hexlify16, concat as concat4 } from "@fuel-ts/utils";
5569
+ import { dataSlice, pbkdf2, computeHmac, encodeBase58 } from "ethers";
5546
5570
 
5547
5571
  // src/wordlists/words/english.ts
5548
5572
  var english = [
@@ -8071,8 +8095,7 @@ var HDWallet = class {
8071
8095
  });
8072
8096
  }
8073
8097
  static fromExtendedKey(extendedKey) {
8074
- let decoded = toHex(decodeBase58(extendedKey));
8075
- decoded = `${decoded.substring(0, 2)}0${decoded.substring(2)}`;
8098
+ const decoded = toBeHex(decodeBase58(extendedKey));
8076
8099
  const bytes = arrayify18(decoded);
8077
8100
  const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
8078
8101
  if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
@@ -8695,7 +8718,7 @@ import {
8695
8718
  import { Address as Address9 } from "@fuel-ts/address";
8696
8719
  import { BaseAssetId as BaseAssetId4 } from "@fuel-ts/address/configs";
8697
8720
  import { ErrorCode as ErrorCode24, FuelError as FuelError24 } from "@fuel-ts/errors";
8698
- import { ByteArrayCoder, InputType as InputType7 } from "@fuel-ts/transactions";
8721
+ import { ByteArrayCoder } from "@fuel-ts/transactions";
8699
8722
  import { arrayify as arrayify20, hexlify as hexlify19 } from "@fuel-ts/utils";
8700
8723
 
8701
8724
  // src/predicate/utils/getPredicateRoot.ts
@@ -8754,10 +8777,15 @@ var Predicate = class extends Account {
8754
8777
  populateTransactionPredicateData(transactionRequestLike) {
8755
8778
  const request = transactionRequestify(transactionRequestLike);
8756
8779
  const { policies } = BaseTransactionRequest.getPolicyMeta(request);
8757
- request.inputs?.forEach((input) => {
8758
- if (input.type === InputType7.Coin && hexlify19(input.owner) === this.address.toB256()) {
8780
+ const placeholderIndex = this.getIndexFromPlaceholderWitness(request);
8781
+ if (placeholderIndex !== -1) {
8782
+ request.removeWitness(placeholderIndex);
8783
+ }
8784
+ request.inputs.filter(isRequestInputResource).forEach((input) => {
8785
+ if (isRequestInputResourceFromOwner(input, this.address)) {
8759
8786
  input.predicate = this.bytes;
8760
8787
  input.predicateData = this.getPredicateData(policies.length);
8788
+ input.witnessIndex = 0;
8761
8789
  }
8762
8790
  });
8763
8791
  return request;
@@ -8795,6 +8823,20 @@ var Predicate = class extends Account {
8795
8823
  const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
8796
8824
  return super.simulateTransaction(transactionRequest);
8797
8825
  }
8826
+ /**
8827
+ * Retrieves resources satisfying the spend query for the account.
8828
+ *
8829
+ * @param quantities - Coins to retrieve.
8830
+ * @param excludedIds - IDs of resources to be excluded from the query.
8831
+ * @returns A promise that resolves to an array of Resources.
8832
+ */
8833
+ async getResourcesToSpend(quantities, excludedIds) {
8834
+ const resources = await super.getResourcesToSpend(quantities, excludedIds);
8835
+ return resources.map((resource) => ({
8836
+ ...resource,
8837
+ predicate: hexlify19(this.bytes)
8838
+ }));
8839
+ }
8798
8840
  getPredicateData(policiesLength) {
8799
8841
  if (!this.predicateData.length) {
8800
8842
  return new Uint8Array();
@@ -8874,6 +8916,28 @@ var Predicate = class extends Account {
8874
8916
  }
8875
8917
  return mutatedBytes;
8876
8918
  }
8919
+ /**
8920
+ * Returns the index of the witness placeholder that was added to this predicate.
8921
+ * If no witness placeholder was added, it returns -1.
8922
+ * @param request - The transaction request.
8923
+ * @returns The index of the witness placeholder, or -1 if there is no witness placeholder.
8924
+ */
8925
+ getIndexFromPlaceholderWitness(request) {
8926
+ const predicateInputs = request.inputs.filter(isRequestInputResource).filter((input) => isRequestInputResourceFromOwner(input, this.address));
8927
+ let index = -1;
8928
+ const hasEmptyPredicateInputs = predicateInputs.find((input) => !input.predicate);
8929
+ if (hasEmptyPredicateInputs) {
8930
+ index = hasEmptyPredicateInputs.witnessIndex;
8931
+ const allInputsAreEmpty = predicateInputs.every((input) => !input.predicate);
8932
+ if (!allInputsAreEmpty) {
8933
+ const wasFilledInputAddedFirst = !!predicateInputs[0]?.predicate;
8934
+ if (wasFilledInputAddedFirst) {
8935
+ index = -1;
8936
+ }
8937
+ }
8938
+ }
8939
+ return index;
8940
+ }
8877
8941
  };
8878
8942
 
8879
8943
  // src/connectors/fuel.ts
@@ -9596,6 +9660,7 @@ export {
9596
9660
  assets,
9597
9661
  buildBlockExplorerUrl,
9598
9662
  cacheFor,
9663
+ cacheResources,
9599
9664
  calculateMetadataGasForTxCreate,
9600
9665
  calculateMetadataGasForTxScript,
9601
9666
  calculatePriceWithFactor,
@@ -9642,6 +9707,7 @@ export {
9642
9707
  getReceiptsMessageOut,
9643
9708
  getReceiptsTransferOut,
9644
9709
  getReceiptsWithMissingData,
9710
+ getRequestInputResourceOwner,
9645
9711
  getTransactionStatusName,
9646
9712
  getTransactionSummary,
9647
9713
  getTransactionSummaryFromRequest,
@@ -9655,6 +9721,10 @@ export {
9655
9721
  isMessage,
9656
9722
  isRawCoin,
9657
9723
  isRawMessage,
9724
+ isRequestInputCoin,
9725
+ isRequestInputMessage,
9726
+ isRequestInputResource,
9727
+ isRequestInputResourceFromOwner,
9658
9728
  isType,
9659
9729
  isTypeCreate,
9660
9730
  isTypeMint,