@fuel-ts/account 0.76.3 → 0.78.0

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/account.d.ts +7 -0
  2. package/dist/account.d.ts.map +1 -1
  3. package/dist/connectors/fuel-connector.d.ts +10 -0
  4. package/dist/connectors/fuel-connector.d.ts.map +1 -1
  5. package/dist/hdwallet/hdwallet.d.ts.map +1 -1
  6. package/dist/index.global.js +906 -1340
  7. package/dist/index.global.js.map +1 -1
  8. package/dist/index.js +151 -53
  9. package/dist/index.js.map +1 -1
  10. package/dist/index.mjs +211 -121
  11. package/dist/index.mjs.map +1 -1
  12. package/dist/mnemonic/mnemonic.d.ts.map +1 -1
  13. package/dist/mnemonic/utils.d.ts.map +1 -1
  14. package/dist/predicate/predicate.d.ts +16 -15
  15. package/dist/predicate/predicate.d.ts.map +1 -1
  16. package/dist/providers/__generated__/operations.d.ts +9 -0
  17. package/dist/providers/__generated__/operations.d.ts.map +1 -1
  18. package/dist/providers/assets/index.d.ts +1 -0
  19. package/dist/providers/assets/index.d.ts.map +1 -1
  20. package/dist/providers/assets/types.d.ts +5 -5
  21. package/dist/providers/assets/types.d.ts.map +1 -1
  22. package/dist/providers/assets/utils/network.d.ts +4 -4
  23. package/dist/providers/assets/utils/network.d.ts.map +1 -1
  24. package/dist/providers/assets/utils/resolveIconPaths.d.ts +1 -1
  25. package/dist/providers/fuel-graphql-subscriber.d.ts.map +1 -1
  26. package/dist/providers/provider.d.ts +25 -15
  27. package/dist/providers/provider.d.ts.map +1 -1
  28. package/dist/providers/transaction-request/hash-transaction.d.ts.map +1 -1
  29. package/dist/providers/transaction-request/transaction-request.d.ts +20 -1
  30. package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
  31. package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
  32. package/dist/test-utils.global.js +871 -1314
  33. package/dist/test-utils.global.js.map +1 -1
  34. package/dist/test-utils.js +118 -32
  35. package/dist/test-utils.js.map +1 -1
  36. package/dist/test-utils.mjs +159 -81
  37. package/dist/test-utils.mjs.map +1 -1
  38. package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
  39. package/package.json +16 -16
package/dist/index.js CHANGED
@@ -231,7 +231,7 @@ var import_transactions17 = require("@fuel-ts/transactions");
231
231
  var import_utils22 = require("@fuel-ts/utils");
232
232
  var import_versions = require("@fuel-ts/versions");
233
233
  var import_utils23 = require("@noble/curves/abstract/utils");
234
- var import_ethers2 = require("ethers");
234
+ var import_ethers = require("ethers");
235
235
  var import_graphql_request = require("graphql-request");
236
236
  var import_ramda3 = require("ramda");
237
237
 
@@ -296,6 +296,9 @@ var TransactionStatusFragmentFragmentDoc = import_graphql_tag.default`
296
296
  time
297
297
  reason
298
298
  }
299
+ ... on SqueezedOutStatus {
300
+ reason
301
+ }
299
302
  }
300
303
  `;
301
304
  var TransactionFragmentFragmentDoc = import_graphql_tag.default`
@@ -1073,7 +1076,16 @@ var _FuelGraphqlSubscriber = class {
1073
1076
  if (!text.startsWith("data:")) {
1074
1077
  continue;
1075
1078
  }
1076
- const { data, errors } = JSON.parse(text.split("data:")[1]);
1079
+ let data;
1080
+ let errors;
1081
+ try {
1082
+ ({ data, errors } = JSON.parse(text.replace(/^data:/, "")));
1083
+ } catch (e) {
1084
+ throw new import_errors.FuelError(
1085
+ import_errors.ErrorCode.STREAM_PARSING_ERROR,
1086
+ `Error while parsing stream data response: ${text}`
1087
+ );
1088
+ }
1077
1089
  if (Array.isArray(errors)) {
1078
1090
  throw new import_errors.FuelError(
1079
1091
  import_errors.FuelError.CODES.INVALID_REQUEST,
@@ -1827,13 +1839,27 @@ var BaseTransactionRequest = class {
1827
1839
  this.outputs.push(output);
1828
1840
  return this.outputs.length - 1;
1829
1841
  }
1842
+ /**
1843
+ * @hidden
1844
+ *
1845
+ * Pushes a witness to the list and returns the index
1846
+ *
1847
+ * @param signature - The signature to add to the witness.
1848
+ * @returns The index of the created witness.
1849
+ */
1850
+ addWitness(signature) {
1851
+ this.witnesses.push(signature);
1852
+ return this.witnesses.length - 1;
1853
+ }
1830
1854
  /**
1831
1855
  * @hidden
1832
1856
  *
1833
1857
  * Creates an empty witness without any side effects and returns the index
1858
+ *
1859
+ * @returns The index of the created witness.
1834
1860
  */
1835
- createWitness() {
1836
- this.witnesses.push((0, import_utils9.concat)([import_configs6.ZeroBytes32, import_configs6.ZeroBytes32]));
1861
+ addEmptyWitness() {
1862
+ this.addWitness((0, import_utils9.concat)([import_configs6.ZeroBytes32, import_configs6.ZeroBytes32]));
1837
1863
  return this.witnesses.length - 1;
1838
1864
  }
1839
1865
  /**
@@ -1862,6 +1888,21 @@ var BaseTransactionRequest = class {
1862
1888
  }
1863
1889
  this.witnesses[index] = witness;
1864
1890
  }
1891
+ /**
1892
+ * Helper function to add an external signature to the transaction.
1893
+ *
1894
+ * @param account - The account/s to sign to the transaction.
1895
+ * @returns The transaction with the signature witness added.
1896
+ */
1897
+ async addAccountWitnesses(account) {
1898
+ const accounts = Array.isArray(account) ? account : [account];
1899
+ await Promise.all(
1900
+ accounts.map(async (acc) => {
1901
+ this.addWitness(await acc.signTransaction(this));
1902
+ })
1903
+ );
1904
+ return this;
1905
+ }
1865
1906
  /**
1866
1907
  * Gets the coin inputs for a transaction.
1867
1908
  *
@@ -1927,7 +1968,7 @@ var BaseTransactionRequest = class {
1927
1968
  } else {
1928
1969
  witnessIndex = this.getCoinInputWitnessIndexByOwner(owner);
1929
1970
  if (typeof witnessIndex !== "number") {
1930
- witnessIndex = this.createWitness();
1971
+ witnessIndex = this.addEmptyWitness();
1931
1972
  }
1932
1973
  }
1933
1974
  const input = {
@@ -1939,7 +1980,7 @@ var BaseTransactionRequest = class {
1939
1980
  txPointer: "0x00000000000000000000000000000000",
1940
1981
  witnessIndex,
1941
1982
  predicate: predicate?.bytes,
1942
- predicateData: predicate?.predicateData
1983
+ predicateData: predicate?.predicateDataBytes
1943
1984
  };
1944
1985
  this.pushInput(input);
1945
1986
  this.addChangeOutput(owner, assetId);
@@ -1961,7 +2002,7 @@ var BaseTransactionRequest = class {
1961
2002
  } else {
1962
2003
  witnessIndex = this.getCoinInputWitnessIndexByOwner(recipient);
1963
2004
  if (typeof witnessIndex !== "number") {
1964
- witnessIndex = this.createWitness();
2005
+ witnessIndex = this.addEmptyWitness();
1965
2006
  }
1966
2007
  }
1967
2008
  const input = {
@@ -1972,7 +2013,7 @@ var BaseTransactionRequest = class {
1972
2013
  amount,
1973
2014
  witnessIndex,
1974
2015
  predicate: predicate?.bytes,
1975
- predicateData: predicate?.predicateData
2016
+ predicateData: predicate?.predicateDataBytes
1976
2017
  };
1977
2018
  this.pushInput(input);
1978
2019
  this.addChangeOutput(recipient, assetId);
@@ -2219,7 +2260,6 @@ var import_hasher = require("@fuel-ts/hasher");
2219
2260
  var import_math7 = require("@fuel-ts/math");
2220
2261
  var import_transactions6 = require("@fuel-ts/transactions");
2221
2262
  var import_utils11 = require("@fuel-ts/utils");
2222
- var import_ethers = require("ethers");
2223
2263
  var import_ramda2 = require("ramda");
2224
2264
  function hashTransaction(transactionRequest, chainId) {
2225
2265
  const transaction = transactionRequest.toTransaction();
@@ -2282,7 +2322,7 @@ function hashTransaction(transactionRequest, chainId) {
2282
2322
  transaction.witnesses = [];
2283
2323
  const chainIdBytes = (0, import_hasher.uint64ToBytesBE)(chainId);
2284
2324
  const concatenatedData = (0, import_utils11.concat)([chainIdBytes, new import_transactions6.TransactionCoder().encode(transaction)]);
2285
- return (0, import_ethers.sha256)(concatenatedData);
2325
+ return (0, import_hasher.sha256)(concatenatedData);
2286
2326
  }
2287
2327
 
2288
2328
  // src/providers/transaction-request/storage-slot.ts
@@ -3483,6 +3523,12 @@ var TransactionResponse = class {
3483
3523
  transactionId: this.id
3484
3524
  });
3485
3525
  for await (const { statusChange } of subscription) {
3526
+ if (statusChange.type === "SqueezedOutStatus") {
3527
+ throw new import_errors12.FuelError(
3528
+ import_errors12.ErrorCode.TRANSACTION_SQUEEZED_OUT,
3529
+ `Transaction Squeezed Out with reason: ${statusChange.reason}`
3530
+ );
3531
+ }
3486
3532
  if (statusChange.type !== "SubmittedStatus") {
3487
3533
  break;
3488
3534
  }
@@ -3660,14 +3706,15 @@ var _Provider = class {
3660
3706
  }
3661
3707
  static getFetchFn(options) {
3662
3708
  const { retryOptions, timeout } = options;
3663
- return autoRetryFetch((...args) => {
3664
- if (options.fetch) {
3665
- return options.fetch(...args);
3666
- }
3709
+ return autoRetryFetch(async (...args) => {
3667
3710
  const url = args[0];
3668
3711
  const request = args[1];
3669
3712
  const signal = timeout ? AbortSignal.timeout(timeout) : void 0;
3670
- return fetch(url, { ...request, signal });
3713
+ let fullRequest = { ...request, signal };
3714
+ if (options.requestMiddleware) {
3715
+ fullRequest = await options.requestMiddleware(fullRequest);
3716
+ }
3717
+ return options.fetch ? options.fetch(url, fullRequest, options) : fetch(url, fullRequest);
3671
3718
  }, retryOptions);
3672
3719
  }
3673
3720
  /**
@@ -3801,7 +3848,7 @@ var _Provider = class {
3801
3848
  name,
3802
3849
  consensusParameters: { chainId }
3803
3850
  } = await this.getChain();
3804
- const network = new import_ethers2.Network(name, chainId.toNumber());
3851
+ const network = new import_ethers.Network(name, chainId.toNumber());
3805
3852
  return Promise.resolve(network);
3806
3853
  }
3807
3854
  /**
@@ -3873,6 +3920,12 @@ var _Provider = class {
3873
3920
  if (awaitExecution) {
3874
3921
  const subscription = this.operations.submitAndAwait({ encodedTransaction });
3875
3922
  for await (const { submitAndAwait } of subscription) {
3923
+ if (submitAndAwait.type === "SqueezedOutStatus") {
3924
+ throw new import_errors13.FuelError(
3925
+ import_errors13.ErrorCode.TRANSACTION_SQUEEZED_OUT,
3926
+ `Transaction Squeezed Out with reason: ${submitAndAwait.reason}`
3927
+ );
3928
+ }
3876
3929
  if (submitAndAwait.type !== "SubmittedStatus") {
3877
3930
  break;
3878
3931
  }
@@ -4036,7 +4089,8 @@ var _Provider = class {
4036
4089
  async getTransactionCost(transactionRequestLike, forwardingQuantities = [], {
4037
4090
  estimateTxDependencies = true,
4038
4091
  estimatePredicates = true,
4039
- resourcesOwner
4092
+ resourcesOwner,
4093
+ signatureCallback
4040
4094
  } = {}) {
4041
4095
  const txRequestClone = (0, import_ramda3.clone)(transactionRequestify(transactionRequestLike));
4042
4096
  const chainInfo = this.getChain();
@@ -4055,6 +4109,9 @@ var _Provider = class {
4055
4109
  }
4056
4110
  await this.estimatePredicates(txRequestClone);
4057
4111
  }
4112
+ if (signatureCallback && isScriptTransaction) {
4113
+ await signatureCallback(txRequestClone);
4114
+ }
4058
4115
  const minGas = txRequestClone.calculateMinGas(chainInfo);
4059
4116
  const maxGas = txRequestClone.calculateMaxGas(chainInfo, minGas);
4060
4117
  let receipts = [];
@@ -5004,6 +5061,12 @@ var Account = class extends import_interfaces.AbstractAccount {
5004
5061
  * @returns A promise that resolves to the transaction response.
5005
5062
  */
5006
5063
  async transfer(destination, amount, assetId = import_configs11.BaseAssetId, txParams = {}) {
5064
+ if ((0, import_math17.bn)(amount).lte(0)) {
5065
+ throw new import_errors15.FuelError(
5066
+ import_errors15.ErrorCode.INVALID_TRANSFER_AMOUNT,
5067
+ "Transfer amount must be a positive number."
5068
+ );
5069
+ }
5007
5070
  const request = await this.createTransfer(destination, amount, assetId, txParams);
5008
5071
  return this.sendTransaction(request, { estimateTxDependencies: false });
5009
5072
  }
@@ -5017,6 +5080,12 @@ var Account = class extends import_interfaces.AbstractAccount {
5017
5080
  * @returns A promise that resolves to the transaction response.
5018
5081
  */
5019
5082
  async transferToContract(contractId, amount, assetId = import_configs11.BaseAssetId, txParams = {}) {
5083
+ if ((0, import_math17.bn)(amount).lte(0)) {
5084
+ throw new import_errors15.FuelError(
5085
+ import_errors15.ErrorCode.INVALID_TRANSFER_AMOUNT,
5086
+ "Transfer amount must be a positive number."
5087
+ );
5088
+ }
5020
5089
  const contractAddress = import_address4.Address.fromAddressOrString(contractId);
5021
5090
  const { minGasPrice } = this.provider.getGasConfig();
5022
5091
  const params = { gasPrice: minGasPrice, ...txParams };
@@ -5090,6 +5159,21 @@ var Account = class extends import_interfaces.AbstractAccount {
5090
5159
  }
5091
5160
  return this._connector.signMessage(this.address.toString(), message);
5092
5161
  }
5162
+ /**
5163
+ * Signs a transaction with the wallet's private key.
5164
+ *
5165
+ * @param transactionRequestLike - The transaction request to sign.
5166
+ * @returns A promise that resolves to the signature of the transaction.
5167
+ */
5168
+ async signTransaction(transactionRequestLike) {
5169
+ if (!this._connector) {
5170
+ throw new import_errors15.FuelError(
5171
+ import_errors15.ErrorCode.MISSING_CONNECTOR,
5172
+ "A connector is required to sign transactions."
5173
+ );
5174
+ }
5175
+ return this._connector.signTransaction(this.address.toString(), transactionRequestLike);
5176
+ }
5093
5177
  /**
5094
5178
  * Sends a transaction to the network.
5095
5179
  *
@@ -5400,7 +5484,7 @@ var BaseWalletUnlocked = class extends Account {
5400
5484
  */
5401
5485
  async signTransaction(transactionRequestLike) {
5402
5486
  const transactionRequest = transactionRequestify(transactionRequestLike);
5403
- const chainId = this.provider.getChain().consensusParameters.chainId.toNumber();
5487
+ const chainId = this.provider.getChainId();
5404
5488
  const hashedTransaction = transactionRequest.getTransactionId(chainId);
5405
5489
  const signature = await this.signer().sign(hashedTransaction);
5406
5490
  return (0, import_utils30.hexlify)(signature);
@@ -5463,15 +5547,17 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
5463
5547
 
5464
5548
  // src/hdwallet/hdwallet.ts
5465
5549
  var import_errors19 = require("@fuel-ts/errors");
5550
+ var import_hasher6 = require("@fuel-ts/hasher");
5466
5551
  var import_math19 = require("@fuel-ts/math");
5467
5552
  var import_utils34 = require("@fuel-ts/utils");
5468
- var import_ethers5 = require("ethers");
5553
+ var import_ethers3 = require("ethers");
5469
5554
 
5470
5555
  // src/mnemonic/mnemonic.ts
5471
5556
  var import_crypto3 = require("@fuel-ts/crypto");
5472
5557
  var import_errors18 = require("@fuel-ts/errors");
5558
+ var import_hasher5 = require("@fuel-ts/hasher");
5473
5559
  var import_utils32 = require("@fuel-ts/utils");
5474
- var import_ethers4 = require("ethers");
5560
+ var import_ethers2 = require("ethers");
5475
5561
 
5476
5562
  // src/wordlists/words/english.ts
5477
5563
  var english = [
@@ -7533,8 +7619,8 @@ var Language = /* @__PURE__ */ ((Language2) => {
7533
7619
 
7534
7620
  // src/mnemonic/utils.ts
7535
7621
  var import_errors17 = require("@fuel-ts/errors");
7622
+ var import_hasher4 = require("@fuel-ts/hasher");
7536
7623
  var import_utils31 = require("@fuel-ts/utils");
7537
- var import_ethers3 = require("ethers");
7538
7624
  function toUtf8Bytes(stri) {
7539
7625
  const str = stri.normalize("NFKD");
7540
7626
  const result = [];
@@ -7601,7 +7687,7 @@ function entropyToMnemonicIndices(entropy) {
7601
7687
  }
7602
7688
  }
7603
7689
  const checksumBits = entropy.length / 4;
7604
- const checksum = (0, import_utils31.arrayify)((0, import_ethers3.sha256)(entropy))[0] & getUpperMask(checksumBits);
7690
+ const checksum = (0, import_utils31.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
7605
7691
  indices[indices.length - 1] <<= checksumBits;
7606
7692
  indices[indices.length - 1] |= checksum >> 8 - checksumBits;
7607
7693
  return indices;
@@ -7628,7 +7714,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
7628
7714
  const entropyBits = 32 * words.length / 3;
7629
7715
  const checksumBits = words.length / 3;
7630
7716
  const checksumMask = getUpperMask(checksumBits);
7631
- const checksum = (0, import_utils31.arrayify)((0, import_ethers3.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
7717
+ const checksum = (0, import_utils31.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
7632
7718
  if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
7633
7719
  throw new import_errors17.FuelError(
7634
7720
  import_errors17.ErrorCode.INVALID_CHECKSUM,
@@ -7725,7 +7811,7 @@ var Mnemonic = class {
7725
7811
  assertMnemonic(getWords(phrase));
7726
7812
  const phraseBytes = toUtf8Bytes(getPhrase(phrase));
7727
7813
  const salt = toUtf8Bytes(`mnemonic${passphrase}`);
7728
- return (0, import_ethers4.pbkdf2)(phraseBytes, salt, 2048, 64, "sha512");
7814
+ return (0, import_ethers2.pbkdf2)(phraseBytes, salt, 2048, 64, "sha512");
7729
7815
  }
7730
7816
  /**
7731
7817
  * @param phrase - Mnemonic phrase composed by words from the provided wordlist
@@ -7787,7 +7873,7 @@ var Mnemonic = class {
7787
7873
  `Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
7788
7874
  );
7789
7875
  }
7790
- return (0, import_utils32.arrayify)((0, import_ethers4.computeHmac)("sha512", MasterSecret, seedArray));
7876
+ return (0, import_utils32.arrayify)((0, import_ethers2.computeHmac)("sha512", MasterSecret, seedArray));
7791
7877
  }
7792
7878
  /**
7793
7879
  * Get the extendKey as defined on BIP-32 from the provided seed
@@ -7812,8 +7898,8 @@ var Mnemonic = class {
7812
7898
  chainCode,
7813
7899
  (0, import_utils32.concat)(["0x00", privateKey])
7814
7900
  ]);
7815
- const checksum = (0, import_ethers4.dataSlice)((0, import_ethers4.sha256)((0, import_ethers4.sha256)(extendedKey)), 0, 4);
7816
- return (0, import_ethers4.encodeBase58)((0, import_utils32.concat)([extendedKey, checksum]));
7901
+ const checksum = (0, import_ethers2.dataSlice)((0, import_hasher5.sha256)((0, import_hasher5.sha256)(extendedKey)), 0, 4);
7902
+ return (0, import_ethers2.encodeBase58)((0, import_utils32.concat)([extendedKey, checksum]));
7817
7903
  }
7818
7904
  /**
7819
7905
  * Create a new mnemonic using a randomly generated number as entropy.
@@ -7828,7 +7914,7 @@ var Mnemonic = class {
7828
7914
  * @returns A randomly generated mnemonic
7829
7915
  */
7830
7916
  static generate(size = 32, extraEntropy = "") {
7831
- const entropy = extraEntropy ? (0, import_ethers4.sha256)((0, import_utils32.concat)([(0, import_crypto3.randomBytes)(size), (0, import_utils32.arrayify)(extraEntropy)])) : (0, import_crypto3.randomBytes)(size);
7917
+ const entropy = extraEntropy ? (0, import_hasher5.sha256)((0, import_utils32.concat)([(0, import_crypto3.randomBytes)(size), (0, import_utils32.arrayify)(extraEntropy)])) : (0, import_crypto3.randomBytes)(size);
7832
7918
  return Mnemonic.entropyToMnemonic(entropy);
7833
7919
  }
7834
7920
  };
@@ -7841,7 +7927,7 @@ var MainnetPUB = (0, import_utils34.hexlify)("0x0488b21e");
7841
7927
  var TestnetPRV2 = (0, import_utils34.hexlify)("0x04358394");
7842
7928
  var TestnetPUB = (0, import_utils34.hexlify)("0x043587cf");
7843
7929
  function base58check(data) {
7844
- return (0, import_ethers5.encodeBase58)((0, import_utils34.concat)([data, (0, import_ethers5.dataSlice)((0, import_ethers5.sha256)((0, import_ethers5.sha256)(data)), 0, 4)]));
7930
+ return (0, import_ethers3.encodeBase58)((0, import_utils34.concat)([data, (0, import_ethers3.dataSlice)((0, import_hasher6.sha256)((0, import_hasher6.sha256)(data)), 0, 4)]));
7845
7931
  }
7846
7932
  function getExtendedKeyPrefix(isPublic = false, testnet = false) {
7847
7933
  if (isPublic) {
@@ -7897,7 +7983,7 @@ var HDWallet = class {
7897
7983
  this.publicKey = (0, import_utils34.hexlify)(config.publicKey);
7898
7984
  }
7899
7985
  this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
7900
- this.fingerprint = (0, import_ethers5.dataSlice)((0, import_ethers5.ripemd160)((0, import_ethers5.sha256)(this.publicKey)), 0, 4);
7986
+ this.fingerprint = (0, import_ethers3.dataSlice)((0, import_ethers3.ripemd160)((0, import_hasher6.sha256)(this.publicKey)), 0, 4);
7901
7987
  this.depth = config.depth || this.depth;
7902
7988
  this.index = config.index || this.index;
7903
7989
  this.chainCode = config.chainCode;
@@ -7929,7 +8015,7 @@ var HDWallet = class {
7929
8015
  data.set((0, import_utils34.arrayify)(this.publicKey));
7930
8016
  }
7931
8017
  data.set((0, import_math19.toBytes)(index, 4), 33);
7932
- const bytes = (0, import_utils34.arrayify)((0, import_ethers5.computeHmac)("sha512", chainCode, data));
8018
+ const bytes = (0, import_utils34.arrayify)((0, import_ethers3.computeHmac)("sha512", chainCode, data));
7933
8019
  const IL = bytes.slice(0, 32);
7934
8020
  const IR = bytes.slice(32);
7935
8021
  if (privateKey) {
@@ -8000,7 +8086,7 @@ var HDWallet = class {
8000
8086
  });
8001
8087
  }
8002
8088
  static fromExtendedKey(extendedKey) {
8003
- const decoded = (0, import_ethers5.toBeHex)((0, import_ethers5.decodeBase58)(extendedKey));
8089
+ const decoded = (0, import_ethers3.toBeHex)((0, import_ethers3.decodeBase58)(extendedKey));
8004
8090
  const bytes = (0, import_utils34.arrayify)(decoded);
8005
8091
  const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
8006
8092
  if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
@@ -8621,7 +8707,7 @@ var import_transactions19 = require("@fuel-ts/transactions");
8621
8707
  var import_utils36 = require("@fuel-ts/utils");
8622
8708
 
8623
8709
  // src/predicate/utils/getPredicateRoot.ts
8624
- var import_hasher4 = require("@fuel-ts/hasher");
8710
+ var import_hasher7 = require("@fuel-ts/hasher");
8625
8711
  var import_merkle = require("@fuel-ts/merkle");
8626
8712
  var import_utils35 = require("@fuel-ts/utils");
8627
8713
  var getPredicateRoot = (bytecode) => {
@@ -8629,34 +8715,44 @@ var getPredicateRoot = (bytecode) => {
8629
8715
  const bytes = (0, import_utils35.arrayify)(bytecode);
8630
8716
  const chunks = (0, import_utils35.chunkAndPadBytes)(bytes, chunkSize);
8631
8717
  const codeRoot = (0, import_merkle.calcRoot)(chunks.map((c) => (0, import_utils35.hexlify)(c)));
8632
- const predicateRoot = (0, import_hasher4.hash)((0, import_utils35.concat)(["0x4655454C", codeRoot]));
8718
+ const predicateRoot = (0, import_hasher7.hash)((0, import_utils35.concat)(["0x4655454C", codeRoot]));
8633
8719
  return predicateRoot;
8634
8720
  };
8635
8721
 
8636
8722
  // src/predicate/predicate.ts
8637
8723
  var Predicate = class extends Account {
8638
8724
  bytes;
8639
- predicateData = Uint8Array.from([]);
8640
- predicateArgs = [];
8725
+ predicateDataBytes = Uint8Array.from([]);
8726
+ predicateData = [];
8641
8727
  interface;
8642
8728
  /**
8643
8729
  * Creates an instance of the Predicate class.
8644
8730
  *
8645
- * @param bytes - The bytes of the predicate.
8731
+ * @param bytecode - The bytecode of the predicate.
8732
+ * @param abi - The JSON ABI of the predicate.
8646
8733
  * @param provider - The provider used to interact with the blockchain.
8647
- * @param jsonAbi - The JSON ABI of the predicate.
8734
+ * @param inputData - The predicate input data (optional).
8648
8735
  * @param configurableConstants - Optional configurable constants for the predicate.
8649
8736
  */
8650
- constructor(bytes, provider, jsonAbi, configurableConstants) {
8737
+ constructor({
8738
+ bytecode,
8739
+ abi,
8740
+ provider,
8741
+ inputData,
8742
+ configurableConstants
8743
+ }) {
8651
8744
  const { predicateBytes, predicateInterface } = Predicate.processPredicateData(
8652
- bytes,
8653
- jsonAbi,
8745
+ bytecode,
8746
+ abi,
8654
8747
  configurableConstants
8655
8748
  );
8656
8749
  const address = import_address10.Address.fromB256(getPredicateRoot(predicateBytes));
8657
8750
  super(address, provider);
8658
8751
  this.bytes = predicateBytes;
8659
8752
  this.interface = predicateInterface;
8753
+ if (inputData !== void 0 && inputData.length > 0) {
8754
+ this.predicateData = inputData;
8755
+ }
8660
8756
  }
8661
8757
  /**
8662
8758
  * Populates the transaction data with predicate data.
@@ -8708,18 +8804,8 @@ var Predicate = class extends Account {
8708
8804
  const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
8709
8805
  return super.simulateTransaction(transactionRequest);
8710
8806
  }
8711
- /**
8712
- * Sets data for the predicate.
8713
- *
8714
- * @param args - Arguments for the predicate function.
8715
- * @returns The Predicate instance with updated predicate data.
8716
- */
8717
- setData(...args) {
8718
- this.predicateArgs = args;
8719
- return this;
8720
- }
8721
8807
  getPredicateData(policiesLength) {
8722
- if (!this.predicateArgs.length) {
8808
+ if (!this.predicateData.length) {
8723
8809
  return new Uint8Array();
8724
8810
  }
8725
8811
  const mainFn = this.interface?.functions.main;
@@ -8728,7 +8814,7 @@ var Predicate = class extends Account {
8728
8814
  maxInputs: this.provider.getChain().consensusParameters.maxInputs.toNumber()
8729
8815
  });
8730
8816
  const OFFSET = VM_TX_MEMORY + import_abi_coder5.SCRIPT_FIXED_SIZE + import_abi_coder5.INPUT_COIN_FIXED_SIZE + import_abi_coder5.WORD_SIZE + paddedCode.byteLength + policiesLength * import_abi_coder5.WORD_SIZE;
8731
- return mainFn?.encodeArguments(this.predicateArgs, OFFSET) || new Uint8Array();
8817
+ return mainFn?.encodeArguments(this.predicateData, OFFSET) || new Uint8Array();
8732
8818
  }
8733
8819
  /**
8734
8820
  * Processes the predicate data and returns the altered bytecode and interface.
@@ -8939,6 +9025,18 @@ var FuelConnector = class extends import_events2.EventEmitter {
8939
9025
  async signMessage(_address, _message) {
8940
9026
  throw new Error("Method not implemented.");
8941
9027
  }
9028
+ /**
9029
+ * Should start the sign transaction process and return
9030
+ * the signed transaction.
9031
+ *
9032
+ * @param address - The address to sign the transaction
9033
+ * @param transaction - The transaction to sign
9034
+ *
9035
+ * @returns Transaction signature
9036
+ */
9037
+ async signTransaction(_address, _transaction) {
9038
+ throw new Error("Method not implemented.");
9039
+ }
8942
9040
  /**
8943
9041
  * Should start the send transaction process and return
8944
9042
  * the transaction id submitted to the network.