@fuel-ts/account 0.75.0 → 0.77.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 (43) hide show
  1. package/dist/account.d.ts.map +1 -1
  2. package/dist/hdwallet/hdwallet.d.ts.map +1 -1
  3. package/dist/index.global.js +1002 -2498
  4. package/dist/index.global.js.map +1 -1
  5. package/dist/index.js +92 -72
  6. package/dist/index.js.map +1 -1
  7. package/dist/index.mjs +156 -140
  8. package/dist/index.mjs.map +1 -1
  9. package/dist/mnemonic/mnemonic.d.ts.map +1 -1
  10. package/dist/mnemonic/utils.d.ts.map +1 -1
  11. package/dist/predicate/predicate.d.ts +16 -15
  12. package/dist/predicate/predicate.d.ts.map +1 -1
  13. package/dist/providers/__generated__/operations.d.ts +47 -38
  14. package/dist/providers/__generated__/operations.d.ts.map +1 -1
  15. package/dist/providers/assets/index.d.ts +1 -0
  16. package/dist/providers/assets/index.d.ts.map +1 -1
  17. package/dist/providers/assets/types.d.ts +5 -5
  18. package/dist/providers/assets/types.d.ts.map +1 -1
  19. package/dist/providers/assets/utils/network.d.ts +4 -4
  20. package/dist/providers/assets/utils/network.d.ts.map +1 -1
  21. package/dist/providers/assets/utils/resolveIconPaths.d.ts +1 -1
  22. package/dist/providers/fuel-graphql-subscriber.d.ts.map +1 -1
  23. package/dist/providers/provider.d.ts +24 -15
  24. package/dist/providers/provider.d.ts.map +1 -1
  25. package/dist/providers/transaction-request/hash-transaction.d.ts.map +1 -1
  26. package/dist/providers/transaction-response/getDecodedLogs.d.ts.map +1 -1
  27. package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
  28. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts.map +1 -1
  29. package/dist/providers/transaction-summary/index.d.ts +0 -1
  30. package/dist/providers/transaction-summary/index.d.ts.map +1 -1
  31. package/dist/providers/utils/index.d.ts +0 -1
  32. package/dist/providers/utils/index.d.ts.map +1 -1
  33. package/dist/test-utils.global.js +976 -2469
  34. package/dist/test-utils.global.js.map +1 -1
  35. package/dist/test-utils.js +68 -40
  36. package/dist/test-utils.js.map +1 -1
  37. package/dist/test-utils.mjs +113 -93
  38. package/dist/test-utils.mjs.map +1 -1
  39. package/package.json +16 -16
  40. package/dist/providers/transaction-summary/date.d.ts +0 -3
  41. package/dist/providers/transaction-summary/date.d.ts.map +0 -1
  42. package/dist/providers/utils/time.d.ts +0 -40
  43. package/dist/providers/utils/time.d.ts.map +0 -1
package/dist/index.js CHANGED
@@ -112,10 +112,6 @@ __export(src_exports, {
112
112
  english: () => english,
113
113
  extractBurnedAssetsFromReceipts: () => extractBurnedAssetsFromReceipts,
114
114
  extractMintedAssetsFromReceipts: () => extractMintedAssetsFromReceipts,
115
- fromDateToTai64: () => fromDateToTai64,
116
- fromTai64ToDate: () => fromTai64ToDate,
117
- fromTai64ToUnix: () => fromTai64ToUnix,
118
- fromUnixToTai64: () => fromUnixToTai64,
119
115
  gasUsedByInputs: () => gasUsedByInputs,
120
116
  getAssetEth: () => getAssetEth,
121
117
  getAssetFuel: () => getAssetFuel,
@@ -235,7 +231,7 @@ var import_transactions17 = require("@fuel-ts/transactions");
235
231
  var import_utils22 = require("@fuel-ts/utils");
236
232
  var import_versions = require("@fuel-ts/versions");
237
233
  var import_utils23 = require("@noble/curves/abstract/utils");
238
- var import_ethers2 = require("ethers");
234
+ var import_ethers = require("ethers");
239
235
  var import_graphql_request = require("graphql-request");
240
236
  var import_ramda3 = require("ramda");
241
237
 
@@ -300,6 +296,9 @@ var TransactionStatusFragmentFragmentDoc = import_graphql_tag.default`
300
296
  time
301
297
  reason
302
298
  }
299
+ ... on SqueezedOutStatus {
300
+ reason
301
+ }
303
302
  }
304
303
  `;
305
304
  var TransactionFragmentFragmentDoc = import_graphql_tag.default`
@@ -1077,7 +1076,16 @@ var _FuelGraphqlSubscriber = class {
1077
1076
  if (!text.startsWith("data:")) {
1078
1077
  continue;
1079
1078
  }
1080
- 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
+ }
1081
1089
  if (Array.isArray(errors)) {
1082
1090
  throw new import_errors.FuelError(
1083
1091
  import_errors.FuelError.CODES.INVALID_REQUEST,
@@ -1690,10 +1698,6 @@ function sleep(time) {
1690
1698
  });
1691
1699
  }
1692
1700
 
1693
- // src/providers/utils/time.ts
1694
- var fromTai64ToUnix = (tai64Timestamp) => Number(BigInt(tai64Timestamp) - BigInt(2 ** 62) - BigInt(10));
1695
- var fromUnixToTai64 = (unixTimestampMs) => (BigInt(unixTimestampMs) + BigInt(2 ** 62) + BigInt(10)).toString();
1696
-
1697
1701
  // src/providers/transaction-request/errors.ts
1698
1702
  var ChangeOutputCollisionError = class extends Error {
1699
1703
  name = "ChangeOutputCollisionError";
@@ -1947,7 +1951,7 @@ var BaseTransactionRequest = class {
1947
1951
  txPointer: "0x00000000000000000000000000000000",
1948
1952
  witnessIndex,
1949
1953
  predicate: predicate?.bytes,
1950
- predicateData: predicate?.predicateData
1954
+ predicateData: predicate?.predicateDataBytes
1951
1955
  };
1952
1956
  this.pushInput(input);
1953
1957
  this.addChangeOutput(owner, assetId);
@@ -1980,7 +1984,7 @@ var BaseTransactionRequest = class {
1980
1984
  amount,
1981
1985
  witnessIndex,
1982
1986
  predicate: predicate?.bytes,
1983
- predicateData: predicate?.predicateData
1987
+ predicateData: predicate?.predicateDataBytes
1984
1988
  };
1985
1989
  this.pushInput(input);
1986
1990
  this.addChangeOutput(recipient, assetId);
@@ -2227,7 +2231,6 @@ var import_hasher = require("@fuel-ts/hasher");
2227
2231
  var import_math7 = require("@fuel-ts/math");
2228
2232
  var import_transactions6 = require("@fuel-ts/transactions");
2229
2233
  var import_utils11 = require("@fuel-ts/utils");
2230
- var import_ethers = require("ethers");
2231
2234
  var import_ramda2 = require("ramda");
2232
2235
  function hashTransaction(transactionRequest, chainId) {
2233
2236
  const transaction = transactionRequest.toTransaction();
@@ -2290,7 +2293,7 @@ function hashTransaction(transactionRequest, chainId) {
2290
2293
  transaction.witnesses = [];
2291
2294
  const chainIdBytes = (0, import_hasher.uint64ToBytesBE)(chainId);
2292
2295
  const concatenatedData = (0, import_utils11.concat)([chainIdBytes, new import_transactions6.TransactionCoder().encode(transaction)]);
2293
- return (0, import_ethers.sha256)(concatenatedData);
2296
+ return (0, import_hasher.sha256)(concatenatedData);
2294
2297
  }
2295
2298
 
2296
2299
  // src/providers/transaction-request/storage-slot.ts
@@ -2716,14 +2719,6 @@ var calculateTransactionFee = (params) => {
2716
2719
  };
2717
2720
  };
2718
2721
 
2719
- // src/providers/transaction-summary/date.ts
2720
- var import_tai64 = require("tai64");
2721
- var fromTai64ToDate = (tai64Timestamp) => {
2722
- const timestamp = import_tai64.TAI64.fromString(tai64Timestamp, 10).toUnix();
2723
- return new Date(timestamp * 1e3);
2724
- };
2725
- var fromDateToTai64 = (date) => import_tai64.TAI64.fromUnix(Math.floor(date.getTime() / 1e3)).toString(10);
2726
-
2727
2722
  // src/providers/transaction-summary/operations.ts
2728
2723
  var import_configs10 = require("@fuel-ts/address/configs");
2729
2724
  var import_errors10 = require("@fuel-ts/errors");
@@ -3364,7 +3359,7 @@ function assembleTransactionSummary(params) {
3364
3359
  const burnedAssets = extractBurnedAssetsFromReceipts(receipts);
3365
3360
  let date;
3366
3361
  if (time) {
3367
- date = fromTai64ToDate(time);
3362
+ date = import_utils19.DateTime.fromTai64(time);
3368
3363
  }
3369
3364
  const transactionSummary = {
3370
3365
  id,
@@ -3499,6 +3494,12 @@ var TransactionResponse = class {
3499
3494
  transactionId: this.id
3500
3495
  });
3501
3496
  for await (const { statusChange } of subscription) {
3497
+ if (statusChange.type === "SqueezedOutStatus") {
3498
+ throw new import_errors12.FuelError(
3499
+ import_errors12.ErrorCode.TRANSACTION_SQUEEZED_OUT,
3500
+ `Transaction Squeezed Out with reason: ${statusChange.reason}`
3501
+ );
3502
+ }
3502
3503
  if (statusChange.type !== "SubmittedStatus") {
3503
3504
  break;
3504
3505
  }
@@ -3545,7 +3546,9 @@ function getDecodedLogs(receipts, abiInterface) {
3545
3546
  logs.push(abiInterface.decodeLog(r.data, r.val1.toNumber(), r.id)[0]);
3546
3547
  }
3547
3548
  if (r.type === import_transactions16.ReceiptType.Log) {
3548
- logs.push(abiInterface.decodeLog(new import_abi_coder3.U64Coder().encode(r.val0), r.val1.toNumber(), r.id)[0]);
3549
+ logs.push(
3550
+ abiInterface.decodeLog(new import_abi_coder3.BigNumberCoder("u64").encode(r.val0), r.val1.toNumber(), r.id)[0]
3551
+ );
3549
3552
  }
3550
3553
  return logs;
3551
3554
  }, []);
@@ -3674,14 +3677,15 @@ var _Provider = class {
3674
3677
  }
3675
3678
  static getFetchFn(options) {
3676
3679
  const { retryOptions, timeout } = options;
3677
- return autoRetryFetch((...args) => {
3678
- if (options.fetch) {
3679
- return options.fetch(...args);
3680
- }
3680
+ return autoRetryFetch(async (...args) => {
3681
3681
  const url = args[0];
3682
3682
  const request = args[1];
3683
3683
  const signal = timeout ? AbortSignal.timeout(timeout) : void 0;
3684
- return fetch(url, { ...request, signal });
3684
+ let fullRequest = { ...request, signal };
3685
+ if (options.requestMiddleware) {
3686
+ fullRequest = await options.requestMiddleware(fullRequest);
3687
+ }
3688
+ return options.fetch ? options.fetch(url, fullRequest, options) : fetch(url, fullRequest);
3685
3689
  }, retryOptions);
3686
3690
  }
3687
3691
  /**
@@ -3815,7 +3819,7 @@ var _Provider = class {
3815
3819
  name,
3816
3820
  consensusParameters: { chainId }
3817
3821
  } = await this.getChain();
3818
- const network = new import_ethers2.Network(name, chainId.toNumber());
3822
+ const network = new import_ethers.Network(name, chainId.toNumber());
3819
3823
  return Promise.resolve(network);
3820
3824
  }
3821
3825
  /**
@@ -3887,6 +3891,12 @@ var _Provider = class {
3887
3891
  if (awaitExecution) {
3888
3892
  const subscription = this.operations.submitAndAwait({ encodedTransaction });
3889
3893
  for await (const { submitAndAwait } of subscription) {
3894
+ if (submitAndAwait.type === "SqueezedOutStatus") {
3895
+ throw new import_errors13.FuelError(
3896
+ import_errors13.ErrorCode.TRANSACTION_SQUEEZED_OUT,
3897
+ `Transaction Squeezed Out with reason: ${submitAndAwait.reason}`
3898
+ );
3899
+ }
3890
3900
  if (submitAndAwait.type !== "SubmittedStatus") {
3891
3901
  break;
3892
3902
  }
@@ -4483,13 +4493,13 @@ var _Provider = class {
4483
4493
  * Lets you produce blocks with custom timestamps and the block number of the last block produced.
4484
4494
  *
4485
4495
  * @param amount - The amount of blocks to produce
4486
- * @param startTime - The UNIX timestamp to set for the first produced block
4496
+ * @param startTime - The UNIX timestamp (milliseconds) to set for the first produced block
4487
4497
  * @returns A promise that resolves to the block number of the last produced block.
4488
4498
  */
4489
4499
  async produceBlocks(amount, startTime) {
4490
4500
  const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
4491
4501
  blocksToProduce: (0, import_math14.bn)(amount).toString(10),
4492
- startTimestamp: startTime ? fromUnixToTai64(startTime) : void 0
4502
+ startTimestamp: startTime ? import_utils22.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
4493
4503
  });
4494
4504
  return (0, import_math14.bn)(latestBlockHeight);
4495
4505
  }
@@ -4737,7 +4747,7 @@ var import_utils26 = require("@fuel-ts/utils");
4737
4747
  var asm = __toESM(require("@fuels/vm-asm"));
4738
4748
  var formatTransferToContractScriptData = (params) => {
4739
4749
  const { assetId, amountToTransfer, hexlifiedContractId } = params;
4740
- const numberCoder = new import_abi_coder4.U64Coder();
4750
+ const numberCoder = new import_abi_coder4.BigNumberCoder("u64");
4741
4751
  const encoded = numberCoder.encode(new import_math16.BN(amountToTransfer).toNumber());
4742
4752
  const scriptData = Uint8Array.from([
4743
4753
  ...(0, import_utils26.arrayify)(hexlifiedContractId),
@@ -5018,6 +5028,12 @@ var Account = class extends import_interfaces.AbstractAccount {
5018
5028
  * @returns A promise that resolves to the transaction response.
5019
5029
  */
5020
5030
  async transfer(destination, amount, assetId = import_configs11.BaseAssetId, txParams = {}) {
5031
+ if ((0, import_math17.bn)(amount).lte(0)) {
5032
+ throw new import_errors15.FuelError(
5033
+ import_errors15.ErrorCode.INVALID_TRANSFER_AMOUNT,
5034
+ "Transfer amount must be a positive number."
5035
+ );
5036
+ }
5021
5037
  const request = await this.createTransfer(destination, amount, assetId, txParams);
5022
5038
  return this.sendTransaction(request, { estimateTxDependencies: false });
5023
5039
  }
@@ -5031,6 +5047,12 @@ var Account = class extends import_interfaces.AbstractAccount {
5031
5047
  * @returns A promise that resolves to the transaction response.
5032
5048
  */
5033
5049
  async transferToContract(contractId, amount, assetId = import_configs11.BaseAssetId, txParams = {}) {
5050
+ if ((0, import_math17.bn)(amount).lte(0)) {
5051
+ throw new import_errors15.FuelError(
5052
+ import_errors15.ErrorCode.INVALID_TRANSFER_AMOUNT,
5053
+ "Transfer amount must be a positive number."
5054
+ );
5055
+ }
5034
5056
  const contractAddress = import_address4.Address.fromAddressOrString(contractId);
5035
5057
  const { minGasPrice } = this.provider.getGasConfig();
5036
5058
  const params = { gasPrice: minGasPrice, ...txParams };
@@ -5477,15 +5499,17 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
5477
5499
 
5478
5500
  // src/hdwallet/hdwallet.ts
5479
5501
  var import_errors19 = require("@fuel-ts/errors");
5502
+ var import_hasher6 = require("@fuel-ts/hasher");
5480
5503
  var import_math19 = require("@fuel-ts/math");
5481
5504
  var import_utils34 = require("@fuel-ts/utils");
5482
- var import_ethers5 = require("ethers");
5505
+ var import_ethers3 = require("ethers");
5483
5506
 
5484
5507
  // src/mnemonic/mnemonic.ts
5485
5508
  var import_crypto3 = require("@fuel-ts/crypto");
5486
5509
  var import_errors18 = require("@fuel-ts/errors");
5510
+ var import_hasher5 = require("@fuel-ts/hasher");
5487
5511
  var import_utils32 = require("@fuel-ts/utils");
5488
- var import_ethers4 = require("ethers");
5512
+ var import_ethers2 = require("ethers");
5489
5513
 
5490
5514
  // src/wordlists/words/english.ts
5491
5515
  var english = [
@@ -7547,8 +7571,8 @@ var Language = /* @__PURE__ */ ((Language2) => {
7547
7571
 
7548
7572
  // src/mnemonic/utils.ts
7549
7573
  var import_errors17 = require("@fuel-ts/errors");
7574
+ var import_hasher4 = require("@fuel-ts/hasher");
7550
7575
  var import_utils31 = require("@fuel-ts/utils");
7551
- var import_ethers3 = require("ethers");
7552
7576
  function toUtf8Bytes(stri) {
7553
7577
  const str = stri.normalize("NFKD");
7554
7578
  const result = [];
@@ -7615,7 +7639,7 @@ function entropyToMnemonicIndices(entropy) {
7615
7639
  }
7616
7640
  }
7617
7641
  const checksumBits = entropy.length / 4;
7618
- const checksum = (0, import_utils31.arrayify)((0, import_ethers3.sha256)(entropy))[0] & getUpperMask(checksumBits);
7642
+ const checksum = (0, import_utils31.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
7619
7643
  indices[indices.length - 1] <<= checksumBits;
7620
7644
  indices[indices.length - 1] |= checksum >> 8 - checksumBits;
7621
7645
  return indices;
@@ -7642,7 +7666,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
7642
7666
  const entropyBits = 32 * words.length / 3;
7643
7667
  const checksumBits = words.length / 3;
7644
7668
  const checksumMask = getUpperMask(checksumBits);
7645
- const checksum = (0, import_utils31.arrayify)((0, import_ethers3.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
7669
+ const checksum = (0, import_utils31.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
7646
7670
  if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
7647
7671
  throw new import_errors17.FuelError(
7648
7672
  import_errors17.ErrorCode.INVALID_CHECKSUM,
@@ -7739,7 +7763,7 @@ var Mnemonic = class {
7739
7763
  assertMnemonic(getWords(phrase));
7740
7764
  const phraseBytes = toUtf8Bytes(getPhrase(phrase));
7741
7765
  const salt = toUtf8Bytes(`mnemonic${passphrase}`);
7742
- return (0, import_ethers4.pbkdf2)(phraseBytes, salt, 2048, 64, "sha512");
7766
+ return (0, import_ethers2.pbkdf2)(phraseBytes, salt, 2048, 64, "sha512");
7743
7767
  }
7744
7768
  /**
7745
7769
  * @param phrase - Mnemonic phrase composed by words from the provided wordlist
@@ -7801,7 +7825,7 @@ var Mnemonic = class {
7801
7825
  `Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
7802
7826
  );
7803
7827
  }
7804
- return (0, import_utils32.arrayify)((0, import_ethers4.computeHmac)("sha512", MasterSecret, seedArray));
7828
+ return (0, import_utils32.arrayify)((0, import_ethers2.computeHmac)("sha512", MasterSecret, seedArray));
7805
7829
  }
7806
7830
  /**
7807
7831
  * Get the extendKey as defined on BIP-32 from the provided seed
@@ -7826,8 +7850,8 @@ var Mnemonic = class {
7826
7850
  chainCode,
7827
7851
  (0, import_utils32.concat)(["0x00", privateKey])
7828
7852
  ]);
7829
- const checksum = (0, import_ethers4.dataSlice)((0, import_ethers4.sha256)((0, import_ethers4.sha256)(extendedKey)), 0, 4);
7830
- return (0, import_ethers4.encodeBase58)((0, import_utils32.concat)([extendedKey, checksum]));
7853
+ const checksum = (0, import_ethers2.dataSlice)((0, import_hasher5.sha256)((0, import_hasher5.sha256)(extendedKey)), 0, 4);
7854
+ return (0, import_ethers2.encodeBase58)((0, import_utils32.concat)([extendedKey, checksum]));
7831
7855
  }
7832
7856
  /**
7833
7857
  * Create a new mnemonic using a randomly generated number as entropy.
@@ -7842,7 +7866,7 @@ var Mnemonic = class {
7842
7866
  * @returns A randomly generated mnemonic
7843
7867
  */
7844
7868
  static generate(size = 32, extraEntropy = "") {
7845
- 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);
7869
+ 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);
7846
7870
  return Mnemonic.entropyToMnemonic(entropy);
7847
7871
  }
7848
7872
  };
@@ -7855,7 +7879,7 @@ var MainnetPUB = (0, import_utils34.hexlify)("0x0488b21e");
7855
7879
  var TestnetPRV2 = (0, import_utils34.hexlify)("0x04358394");
7856
7880
  var TestnetPUB = (0, import_utils34.hexlify)("0x043587cf");
7857
7881
  function base58check(data) {
7858
- 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)]));
7882
+ 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)]));
7859
7883
  }
7860
7884
  function getExtendedKeyPrefix(isPublic = false, testnet = false) {
7861
7885
  if (isPublic) {
@@ -7911,7 +7935,7 @@ var HDWallet = class {
7911
7935
  this.publicKey = (0, import_utils34.hexlify)(config.publicKey);
7912
7936
  }
7913
7937
  this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
7914
- this.fingerprint = (0, import_ethers5.dataSlice)((0, import_ethers5.ripemd160)((0, import_ethers5.sha256)(this.publicKey)), 0, 4);
7938
+ this.fingerprint = (0, import_ethers3.dataSlice)((0, import_ethers3.ripemd160)((0, import_hasher6.sha256)(this.publicKey)), 0, 4);
7915
7939
  this.depth = config.depth || this.depth;
7916
7940
  this.index = config.index || this.index;
7917
7941
  this.chainCode = config.chainCode;
@@ -7943,7 +7967,7 @@ var HDWallet = class {
7943
7967
  data.set((0, import_utils34.arrayify)(this.publicKey));
7944
7968
  }
7945
7969
  data.set((0, import_math19.toBytes)(index, 4), 33);
7946
- const bytes = (0, import_utils34.arrayify)((0, import_ethers5.computeHmac)("sha512", chainCode, data));
7970
+ const bytes = (0, import_utils34.arrayify)((0, import_ethers3.computeHmac)("sha512", chainCode, data));
7947
7971
  const IL = bytes.slice(0, 32);
7948
7972
  const IR = bytes.slice(32);
7949
7973
  if (privateKey) {
@@ -8014,7 +8038,7 @@ var HDWallet = class {
8014
8038
  });
8015
8039
  }
8016
8040
  static fromExtendedKey(extendedKey) {
8017
- const decoded = (0, import_ethers5.toBeHex)((0, import_ethers5.decodeBase58)(extendedKey));
8041
+ const decoded = (0, import_ethers3.toBeHex)((0, import_ethers3.decodeBase58)(extendedKey));
8018
8042
  const bytes = (0, import_utils34.arrayify)(decoded);
8019
8043
  const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
8020
8044
  if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
@@ -8635,7 +8659,7 @@ var import_transactions19 = require("@fuel-ts/transactions");
8635
8659
  var import_utils36 = require("@fuel-ts/utils");
8636
8660
 
8637
8661
  // src/predicate/utils/getPredicateRoot.ts
8638
- var import_hasher4 = require("@fuel-ts/hasher");
8662
+ var import_hasher7 = require("@fuel-ts/hasher");
8639
8663
  var import_merkle = require("@fuel-ts/merkle");
8640
8664
  var import_utils35 = require("@fuel-ts/utils");
8641
8665
  var getPredicateRoot = (bytecode) => {
@@ -8643,34 +8667,44 @@ var getPredicateRoot = (bytecode) => {
8643
8667
  const bytes = (0, import_utils35.arrayify)(bytecode);
8644
8668
  const chunks = (0, import_utils35.chunkAndPadBytes)(bytes, chunkSize);
8645
8669
  const codeRoot = (0, import_merkle.calcRoot)(chunks.map((c) => (0, import_utils35.hexlify)(c)));
8646
- const predicateRoot = (0, import_hasher4.hash)((0, import_utils35.concat)(["0x4655454C", codeRoot]));
8670
+ const predicateRoot = (0, import_hasher7.hash)((0, import_utils35.concat)(["0x4655454C", codeRoot]));
8647
8671
  return predicateRoot;
8648
8672
  };
8649
8673
 
8650
8674
  // src/predicate/predicate.ts
8651
8675
  var Predicate = class extends Account {
8652
8676
  bytes;
8653
- predicateData = Uint8Array.from([]);
8654
- predicateArgs = [];
8677
+ predicateDataBytes = Uint8Array.from([]);
8678
+ predicateData = [];
8655
8679
  interface;
8656
8680
  /**
8657
8681
  * Creates an instance of the Predicate class.
8658
8682
  *
8659
- * @param bytes - The bytes of the predicate.
8683
+ * @param bytecode - The bytecode of the predicate.
8684
+ * @param abi - The JSON ABI of the predicate.
8660
8685
  * @param provider - The provider used to interact with the blockchain.
8661
- * @param jsonAbi - The JSON ABI of the predicate.
8686
+ * @param inputData - The predicate input data (optional).
8662
8687
  * @param configurableConstants - Optional configurable constants for the predicate.
8663
8688
  */
8664
- constructor(bytes, provider, jsonAbi, configurableConstants) {
8689
+ constructor({
8690
+ bytecode,
8691
+ abi,
8692
+ provider,
8693
+ inputData,
8694
+ configurableConstants
8695
+ }) {
8665
8696
  const { predicateBytes, predicateInterface } = Predicate.processPredicateData(
8666
- bytes,
8667
- jsonAbi,
8697
+ bytecode,
8698
+ abi,
8668
8699
  configurableConstants
8669
8700
  );
8670
8701
  const address = import_address10.Address.fromB256(getPredicateRoot(predicateBytes));
8671
8702
  super(address, provider);
8672
8703
  this.bytes = predicateBytes;
8673
8704
  this.interface = predicateInterface;
8705
+ if (inputData !== void 0 && inputData.length > 0) {
8706
+ this.predicateData = inputData;
8707
+ }
8674
8708
  }
8675
8709
  /**
8676
8710
  * Populates the transaction data with predicate data.
@@ -8722,18 +8756,8 @@ var Predicate = class extends Account {
8722
8756
  const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
8723
8757
  return super.simulateTransaction(transactionRequest);
8724
8758
  }
8725
- /**
8726
- * Sets data for the predicate.
8727
- *
8728
- * @param args - Arguments for the predicate function.
8729
- * @returns The Predicate instance with updated predicate data.
8730
- */
8731
- setData(...args) {
8732
- this.predicateArgs = args;
8733
- return this;
8734
- }
8735
8759
  getPredicateData(policiesLength) {
8736
- if (!this.predicateArgs.length) {
8760
+ if (!this.predicateData.length) {
8737
8761
  return new Uint8Array();
8738
8762
  }
8739
8763
  const mainFn = this.interface?.functions.main;
@@ -8742,7 +8766,7 @@ var Predicate = class extends Account {
8742
8766
  maxInputs: this.provider.getChain().consensusParameters.maxInputs.toNumber()
8743
8767
  });
8744
8768
  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;
8745
- return mainFn?.encodeArguments(this.predicateArgs, OFFSET) || new Uint8Array();
8769
+ return mainFn?.encodeArguments(this.predicateData, OFFSET) || new Uint8Array();
8746
8770
  }
8747
8771
  /**
8748
8772
  * Processes the predicate data and returns the altered bytecode and interface.
@@ -9530,10 +9554,6 @@ __publicField(Fuel, "defaultConfig", {});
9530
9554
  english,
9531
9555
  extractBurnedAssetsFromReceipts,
9532
9556
  extractMintedAssetsFromReceipts,
9533
- fromDateToTai64,
9534
- fromTai64ToDate,
9535
- fromTai64ToUnix,
9536
- fromUnixToTai64,
9537
9557
  gasUsedByInputs,
9538
9558
  getAssetEth,
9539
9559
  getAssetFuel,