@fuel-ts/account 0.79.0 → 0.81.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 (34) hide show
  1. package/dist/configs.d.ts +1 -0
  2. package/dist/configs.d.ts.map +1 -1
  3. package/dist/configs.global.js +1 -0
  4. package/dist/configs.global.js.map +1 -1
  5. package/dist/configs.js +3 -0
  6. package/dist/configs.js.map +1 -1
  7. package/dist/configs.mjs +2 -0
  8. package/dist/configs.mjs.map +1 -1
  9. package/dist/index.global.js +382 -192
  10. package/dist/index.global.js.map +1 -1
  11. package/dist/index.js +667 -554
  12. package/dist/index.js.map +1 -1
  13. package/dist/index.mjs +416 -298
  14. package/dist/index.mjs.map +1 -1
  15. package/dist/predicate/predicate.d.ts +0 -1
  16. package/dist/predicate/predicate.d.ts.map +1 -1
  17. package/dist/providers/fuel-graphql-subscriber.d.ts +2 -0
  18. package/dist/providers/fuel-graphql-subscriber.d.ts.map +1 -1
  19. package/dist/providers/provider.d.ts +13 -2
  20. package/dist/providers/provider.d.ts.map +1 -1
  21. package/dist/providers/transaction-request/input.d.ts.map +1 -1
  22. package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
  23. package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
  24. package/dist/providers/utils/extract-tx-error.d.ts +36 -0
  25. package/dist/providers/utils/extract-tx-error.d.ts.map +1 -0
  26. package/dist/providers/utils/index.d.ts +1 -0
  27. package/dist/providers/utils/index.d.ts.map +1 -1
  28. package/dist/test-utils.global.js +384 -193
  29. package/dist/test-utils.global.js.map +1 -1
  30. package/dist/test-utils.js +624 -516
  31. package/dist/test-utils.js.map +1 -1
  32. package/dist/test-utils.mjs +388 -272
  33. package/dist/test-utils.mjs.map +1 -1
  34. package/package.json +21 -26
@@ -58,15 +58,15 @@ module.exports = __toCommonJS(test_utils_exports);
58
58
 
59
59
  // src/wallet/base-wallet-unlocked.ts
60
60
  var import_hasher3 = require("@fuel-ts/hasher");
61
- var import_utils30 = require("@fuel-ts/utils");
61
+ var import_utils31 = require("@fuel-ts/utils");
62
62
 
63
63
  // src/account.ts
64
64
  var import_address4 = require("@fuel-ts/address");
65
- var import_configs11 = require("@fuel-ts/address/configs");
66
- var import_errors15 = require("@fuel-ts/errors");
65
+ var import_configs12 = require("@fuel-ts/address/configs");
66
+ var import_errors16 = require("@fuel-ts/errors");
67
67
  var import_interfaces = require("@fuel-ts/interfaces");
68
- var import_math17 = require("@fuel-ts/math");
69
- var import_utils27 = require("@fuel-ts/utils");
68
+ var import_math18 = require("@fuel-ts/math");
69
+ var import_utils28 = require("@fuel-ts/utils");
70
70
 
71
71
  // src/providers/coin-quantity.ts
72
72
  var import_configs = require("@fuel-ts/address/configs");
@@ -106,12 +106,12 @@ var addAmountToAsset = (params) => {
106
106
 
107
107
  // src/providers/provider.ts
108
108
  var import_address3 = require("@fuel-ts/address");
109
- var import_errors13 = require("@fuel-ts/errors");
110
- var import_math14 = require("@fuel-ts/math");
111
- var import_transactions17 = require("@fuel-ts/transactions");
112
- var import_utils22 = require("@fuel-ts/utils");
109
+ var import_errors14 = require("@fuel-ts/errors");
110
+ var import_math15 = require("@fuel-ts/math");
111
+ var import_transactions18 = require("@fuel-ts/transactions");
112
+ var import_utils23 = require("@fuel-ts/utils");
113
113
  var import_versions = require("@fuel-ts/versions");
114
- var import_utils23 = require("@noble/curves/abstract/utils");
114
+ var import_utils24 = require("@noble/curves/abstract/utils");
115
115
  var import_ethers = require("ethers");
116
116
  var import_graphql_request = require("graphql-request");
117
117
  var import_ramda3 = require("ramda");
@@ -944,36 +944,45 @@ var _FuelGraphqlSubscriber = class {
944
944
  });
945
945
  this.stream = response.body.getReader();
946
946
  }
947
+ events = [];
948
+ parsingLeftover = "";
947
949
  async next() {
948
950
  if (!this.stream) {
949
951
  await this.setStream();
950
952
  }
951
953
  while (true) {
954
+ if (this.events.length > 0) {
955
+ const { data, errors } = this.events.shift();
956
+ if (Array.isArray(errors)) {
957
+ throw new import_errors.FuelError(
958
+ import_errors.FuelError.CODES.INVALID_REQUEST,
959
+ errors.map((err) => err.message).join("\n\n")
960
+ );
961
+ }
962
+ return { value: data, done: false };
963
+ }
952
964
  const { value, done } = await this.stream.read();
953
965
  if (done) {
954
966
  return { value, done };
955
967
  }
956
- const text = _FuelGraphqlSubscriber.textDecoder.decode(value);
957
- if (!text.startsWith("data:")) {
968
+ const decoded = _FuelGraphqlSubscriber.textDecoder.decode(value).replace(":keep-alive-text\n\n", "");
969
+ if (decoded === "") {
958
970
  continue;
959
971
  }
960
- let data;
961
- let errors;
962
- try {
963
- ({ data, errors } = JSON.parse(text.replace(/^data:/, "")));
964
- } catch (e) {
965
- throw new import_errors.FuelError(
966
- import_errors.ErrorCode.STREAM_PARSING_ERROR,
967
- `Error while parsing stream data response: ${text}`
968
- );
969
- }
970
- if (Array.isArray(errors)) {
971
- throw new import_errors.FuelError(
972
- import_errors.FuelError.CODES.INVALID_REQUEST,
973
- errors.map((err) => err.message).join("\n\n")
974
- );
975
- }
976
- return { value: data, done: false };
972
+ const text = `${this.parsingLeftover}${decoded}`;
973
+ const regex = /data:.*\n\n/g;
974
+ const matches = [...text.matchAll(regex)].flatMap((match) => match);
975
+ matches.forEach((match) => {
976
+ try {
977
+ this.events.push(JSON.parse(match.replace(/^data:/, "")));
978
+ } catch (e) {
979
+ throw new import_errors.FuelError(
980
+ import_errors.ErrorCode.STREAM_PARSING_ERROR,
981
+ `Error while parsing stream data response: ${text}`
982
+ );
983
+ }
984
+ });
985
+ this.parsingLeftover = text.replace(matches.join(), "");
977
986
  }
978
987
  }
979
988
  /**
@@ -1051,6 +1060,7 @@ var MemoryCache = class {
1051
1060
  };
1052
1061
 
1053
1062
  // src/providers/transaction-request/input.ts
1063
+ var import_abi_coder = require("@fuel-ts/abi-coder");
1054
1064
  var import_configs2 = require("@fuel-ts/address/configs");
1055
1065
  var import_errors3 = require("@fuel-ts/errors");
1056
1066
  var import_math2 = require("@fuel-ts/math");
@@ -1064,8 +1074,8 @@ var inputify = (value) => {
1064
1074
  const predicateData = (0, import_utils3.arrayify)(value.predicateData ?? "0x");
1065
1075
  return {
1066
1076
  type: import_transactions.InputType.Coin,
1067
- txID: (0, import_utils3.hexlify)((0, import_utils3.arrayify)(value.id).slice(0, 32)),
1068
- outputIndex: (0, import_utils3.arrayify)(value.id)[32],
1077
+ txID: (0, import_utils3.hexlify)((0, import_utils3.arrayify)(value.id).slice(0, import_abi_coder.BYTES_32)),
1078
+ outputIndex: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.id).slice(import_abi_coder.BYTES_32, import_abi_coder.UTXO_ID_LEN)),
1069
1079
  owner: (0, import_utils3.hexlify)(value.owner),
1070
1080
  amount: (0, import_math2.bn)(value.amount),
1071
1081
  assetId: (0, import_utils3.hexlify)(value.assetId),
@@ -1183,10 +1193,12 @@ var outputify = (value) => {
1183
1193
  };
1184
1194
 
1185
1195
  // src/providers/transaction-request/transaction-request.ts
1196
+ var import_abi_coder2 = require("@fuel-ts/abi-coder");
1186
1197
  var import_address = require("@fuel-ts/address");
1187
- var import_configs6 = require("@fuel-ts/address/configs");
1188
- var import_math6 = require("@fuel-ts/math");
1189
- var import_transactions5 = require("@fuel-ts/transactions");
1198
+ var import_configs7 = require("@fuel-ts/address/configs");
1199
+ var import_crypto = require("@fuel-ts/crypto");
1200
+ var import_math7 = require("@fuel-ts/math");
1201
+ var import_transactions6 = require("@fuel-ts/transactions");
1190
1202
  var import_utils9 = require("@fuel-ts/utils");
1191
1203
 
1192
1204
  // src/providers/resource.ts
@@ -1517,6 +1529,78 @@ function sleep(time) {
1517
1529
  });
1518
1530
  }
1519
1531
 
1532
+ // src/providers/utils/extract-tx-error.ts
1533
+ var import_errors7 = require("@fuel-ts/errors");
1534
+ var import_math6 = require("@fuel-ts/math");
1535
+ var import_transactions5 = require("@fuel-ts/transactions");
1536
+ var import_configs6 = require("@fuel-ts/transactions/configs");
1537
+ var assemblePanicError = (status) => {
1538
+ let errorMessage = `The transaction reverted with reason: "${status.reason}".`;
1539
+ const reason = status.reason;
1540
+ if (import_configs6.PANIC_REASONS.includes(status.reason)) {
1541
+ errorMessage = `${errorMessage}
1542
+
1543
+ You can read more about this error at:
1544
+
1545
+ ${import_configs6.PANIC_DOC_URL}#variant.${status.reason}`;
1546
+ }
1547
+ return { errorMessage, reason };
1548
+ };
1549
+ var stringify = (obj) => JSON.stringify(obj, null, 2);
1550
+ var assembleRevertError = (receipts, logs) => {
1551
+ let errorMessage = "The transaction reverted with an unknown reason.";
1552
+ const revertReceipt = receipts.find(({ type }) => type === import_transactions5.ReceiptType.Revert);
1553
+ let reason = "";
1554
+ if (revertReceipt) {
1555
+ const reasonHex = (0, import_math6.bn)(revertReceipt.val).toHex();
1556
+ switch (reasonHex) {
1557
+ case import_configs6.FAILED_REQUIRE_SIGNAL: {
1558
+ reason = "require";
1559
+ errorMessage = `The transaction reverted because a "require" statement has thrown ${logs.length ? stringify(logs[0]) : "an error."}.`;
1560
+ break;
1561
+ }
1562
+ case import_configs6.FAILED_ASSERT_EQ_SIGNAL: {
1563
+ const sufix = logs.length >= 2 ? ` comparing ${stringify(logs[1])} and ${stringify(logs[0])}.` : ".";
1564
+ reason = "assert_eq";
1565
+ errorMessage = `The transaction reverted because of an "assert_eq" statement${sufix}`;
1566
+ break;
1567
+ }
1568
+ case import_configs6.FAILED_ASSERT_NE_SIGNAL: {
1569
+ const sufix = logs.length >= 2 ? ` comparing ${stringify(logs[1])} and ${stringify(logs[0])}.` : ".";
1570
+ reason = "assert_ne";
1571
+ errorMessage = `The transaction reverted because of an "assert_ne" statement${sufix}`;
1572
+ break;
1573
+ }
1574
+ case import_configs6.FAILED_ASSERT_SIGNAL:
1575
+ reason = "assert";
1576
+ errorMessage = `The transaction reverted because an "assert" statement failed to evaluate to true.`;
1577
+ break;
1578
+ case import_configs6.FAILED_TRANSFER_TO_ADDRESS_SIGNAL:
1579
+ reason = "MissingOutputChange";
1580
+ errorMessage = `The transaction reverted because it's missing an "OutputChange".`;
1581
+ break;
1582
+ default:
1583
+ reason = "unknown";
1584
+ errorMessage = `The transaction reverted with an unknown reason: ${revertReceipt.val}`;
1585
+ }
1586
+ }
1587
+ return { errorMessage, reason };
1588
+ };
1589
+ var extractTxError = (params) => {
1590
+ const { receipts, status, logs } = params;
1591
+ const isPanic = receipts.some(({ type }) => type === import_transactions5.ReceiptType.Panic);
1592
+ const isRevert = receipts.some(({ type }) => type === import_transactions5.ReceiptType.Revert);
1593
+ const { errorMessage, reason } = status?.type === "FailureStatus" && isPanic ? assemblePanicError(status) : assembleRevertError(receipts, logs);
1594
+ const metadata = {
1595
+ logs,
1596
+ receipts,
1597
+ panic: isPanic,
1598
+ revert: isRevert,
1599
+ reason
1600
+ };
1601
+ return new import_errors7.FuelError(import_errors7.ErrorCode.SCRIPT_REVERTED, errorMessage, metadata);
1602
+ };
1603
+
1520
1604
  // src/providers/transaction-request/errors.ts
1521
1605
  var NoWitnessAtIndexError = class extends Error {
1522
1606
  constructor(index) {
@@ -1567,10 +1651,10 @@ var BaseTransactionRequest = class {
1567
1651
  outputs,
1568
1652
  witnesses
1569
1653
  } = {}) {
1570
- this.gasPrice = (0, import_math6.bn)(gasPrice);
1654
+ this.gasPrice = (0, import_math7.bn)(gasPrice);
1571
1655
  this.maturity = maturity ?? 0;
1572
- this.witnessLimit = witnessLimit ? (0, import_math6.bn)(witnessLimit) : void 0;
1573
- this.maxFee = maxFee ? (0, import_math6.bn)(maxFee) : void 0;
1656
+ this.witnessLimit = witnessLimit ? (0, import_math7.bn)(witnessLimit) : void 0;
1657
+ this.maxFee = maxFee ? (0, import_math7.bn)(maxFee) : void 0;
1574
1658
  this.inputs = inputs ?? [];
1575
1659
  this.outputs = outputs ?? [];
1576
1660
  this.witnesses = witnesses ?? [];
@@ -1579,20 +1663,20 @@ var BaseTransactionRequest = class {
1579
1663
  let policyTypes = 0;
1580
1664
  const policies = [];
1581
1665
  if (req.gasPrice) {
1582
- policyTypes += import_transactions5.PolicyType.GasPrice;
1583
- policies.push({ data: req.gasPrice, type: import_transactions5.PolicyType.GasPrice });
1666
+ policyTypes += import_transactions6.PolicyType.GasPrice;
1667
+ policies.push({ data: req.gasPrice, type: import_transactions6.PolicyType.GasPrice });
1584
1668
  }
1585
1669
  if (req.witnessLimit) {
1586
- policyTypes += import_transactions5.PolicyType.WitnessLimit;
1587
- policies.push({ data: req.witnessLimit, type: import_transactions5.PolicyType.WitnessLimit });
1670
+ policyTypes += import_transactions6.PolicyType.WitnessLimit;
1671
+ policies.push({ data: req.witnessLimit, type: import_transactions6.PolicyType.WitnessLimit });
1588
1672
  }
1589
1673
  if (req.maturity > 0) {
1590
- policyTypes += import_transactions5.PolicyType.Maturity;
1591
- policies.push({ data: req.maturity, type: import_transactions5.PolicyType.Maturity });
1674
+ policyTypes += import_transactions6.PolicyType.Maturity;
1675
+ policies.push({ data: req.maturity, type: import_transactions6.PolicyType.Maturity });
1592
1676
  }
1593
1677
  if (req.maxFee) {
1594
- policyTypes += import_transactions5.PolicyType.MaxFee;
1595
- policies.push({ data: req.maxFee, type: import_transactions5.PolicyType.MaxFee });
1678
+ policyTypes += import_transactions6.PolicyType.MaxFee;
1679
+ policies.push({ data: req.maxFee, type: import_transactions6.PolicyType.MaxFee });
1596
1680
  }
1597
1681
  return {
1598
1682
  policyTypes,
@@ -1626,7 +1710,7 @@ var BaseTransactionRequest = class {
1626
1710
  * @returns The transaction bytes.
1627
1711
  */
1628
1712
  toTransactionBytes() {
1629
- return new import_transactions5.TransactionCoder().encode(this.toTransaction());
1713
+ return new import_transactions6.TransactionCoder().encode(this.toTransaction());
1630
1714
  }
1631
1715
  /**
1632
1716
  * @hidden
@@ -1666,7 +1750,7 @@ var BaseTransactionRequest = class {
1666
1750
  * @returns The index of the created witness.
1667
1751
  */
1668
1752
  addEmptyWitness() {
1669
- this.addWitness((0, import_utils9.concat)([import_configs6.ZeroBytes32, import_configs6.ZeroBytes32]));
1753
+ this.addWitness((0, import_utils9.concat)([import_configs7.ZeroBytes32, import_configs7.ZeroBytes32]));
1670
1754
  return this.witnesses.length - 1;
1671
1755
  }
1672
1756
  /**
@@ -1717,7 +1801,7 @@ var BaseTransactionRequest = class {
1717
1801
  */
1718
1802
  getCoinInputs() {
1719
1803
  return this.inputs.filter(
1720
- (input) => input.type === import_transactions5.InputType.Coin
1804
+ (input) => input.type === import_transactions6.InputType.Coin
1721
1805
  );
1722
1806
  }
1723
1807
  /**
@@ -1727,7 +1811,7 @@ var BaseTransactionRequest = class {
1727
1811
  */
1728
1812
  getCoinOutputs() {
1729
1813
  return this.outputs.filter(
1730
- (output) => output.type === import_transactions5.OutputType.Coin
1814
+ (output) => output.type === import_transactions6.OutputType.Coin
1731
1815
  );
1732
1816
  }
1733
1817
  /**
@@ -1737,7 +1821,7 @@ var BaseTransactionRequest = class {
1737
1821
  */
1738
1822
  getChangeOutputs() {
1739
1823
  return this.outputs.filter(
1740
- (output) => output.type === import_transactions5.OutputType.Change
1824
+ (output) => output.type === import_transactions6.OutputType.Change
1741
1825
  );
1742
1826
  }
1743
1827
  /**
@@ -1749,9 +1833,9 @@ var BaseTransactionRequest = class {
1749
1833
  const ownerAddress = (0, import_address.addressify)(owner);
1750
1834
  const found = this.inputs.find((input) => {
1751
1835
  switch (input.type) {
1752
- case import_transactions5.InputType.Coin:
1836
+ case import_transactions6.InputType.Coin:
1753
1837
  return (0, import_utils9.hexlify)(input.owner) === ownerAddress.toB256();
1754
- case import_transactions5.InputType.Message:
1838
+ case import_transactions6.InputType.Message:
1755
1839
  return (0, import_utils9.hexlify)(input.recipient) === ownerAddress.toB256();
1756
1840
  default:
1757
1841
  return false;
@@ -1780,14 +1864,13 @@ var BaseTransactionRequest = class {
1780
1864
  }
1781
1865
  const input = {
1782
1866
  ...coin,
1783
- type: import_transactions5.InputType.Coin,
1867
+ type: import_transactions6.InputType.Coin,
1784
1868
  owner: owner.toB256(),
1785
1869
  amount,
1786
1870
  assetId,
1787
1871
  txPointer: "0x00000000000000000000000000000000",
1788
1872
  witnessIndex,
1789
- predicate: predicate?.bytes,
1790
- predicateData: predicate?.predicateDataBytes
1873
+ predicate: predicate?.bytes
1791
1874
  };
1792
1875
  this.pushInput(input);
1793
1876
  this.addChangeOutput(owner, assetId);
@@ -1802,7 +1885,7 @@ var BaseTransactionRequest = class {
1802
1885
  */
1803
1886
  addMessageInput(message, predicate) {
1804
1887
  const { recipient, sender, amount } = message;
1805
- const assetId = import_configs6.BaseAssetId;
1888
+ const assetId = import_configs7.BaseAssetId;
1806
1889
  let witnessIndex;
1807
1890
  if (predicate) {
1808
1891
  witnessIndex = 0;
@@ -1814,13 +1897,12 @@ var BaseTransactionRequest = class {
1814
1897
  }
1815
1898
  const input = {
1816
1899
  ...message,
1817
- type: import_transactions5.InputType.Message,
1900
+ type: import_transactions6.InputType.Message,
1818
1901
  sender: sender.toB256(),
1819
1902
  recipient: recipient.toB256(),
1820
1903
  amount,
1821
1904
  witnessIndex,
1822
- predicate: predicate?.bytes,
1823
- predicateData: predicate?.predicateDataBytes
1905
+ predicate: predicate?.bytes
1824
1906
  };
1825
1907
  this.pushInput(input);
1826
1908
  this.addChangeOutput(recipient, assetId);
@@ -1884,9 +1966,9 @@ var BaseTransactionRequest = class {
1884
1966
  * @param amount - Amount of coin.
1885
1967
  * @param assetId - Asset ID of coin.
1886
1968
  */
1887
- addCoinOutput(to, amount, assetId = import_configs6.BaseAssetId) {
1969
+ addCoinOutput(to, amount, assetId = import_configs7.BaseAssetId) {
1888
1970
  this.pushOutput({
1889
- type: import_transactions5.OutputType.Coin,
1971
+ type: import_transactions6.OutputType.Coin,
1890
1972
  to: (0, import_address.addressify)(to).toB256(),
1891
1973
  amount,
1892
1974
  assetId
@@ -1902,7 +1984,7 @@ var BaseTransactionRequest = class {
1902
1984
  addCoinOutputs(to, quantities) {
1903
1985
  quantities.map(coinQuantityfy).forEach((quantity) => {
1904
1986
  this.pushOutput({
1905
- type: import_transactions5.OutputType.Coin,
1987
+ type: import_transactions6.OutputType.Coin,
1906
1988
  to: (0, import_address.addressify)(to).toB256(),
1907
1989
  amount: quantity.amount,
1908
1990
  assetId: quantity.assetId
@@ -1916,13 +1998,13 @@ var BaseTransactionRequest = class {
1916
1998
  * @param to - Address of the owner.
1917
1999
  * @param assetId - Asset ID of coin.
1918
2000
  */
1919
- addChangeOutput(to, assetId = import_configs6.BaseAssetId) {
2001
+ addChangeOutput(to, assetId = import_configs7.BaseAssetId) {
1920
2002
  const changeOutput = this.getChangeOutputs().find(
1921
2003
  (output) => (0, import_utils9.hexlify)(output.assetId) === assetId
1922
2004
  );
1923
2005
  if (!changeOutput) {
1924
2006
  this.pushOutput({
1925
- type: import_transactions5.OutputType.Change,
2007
+ type: import_transactions6.OutputType.Change,
1926
2008
  to: (0, import_address.addressify)(to).toB256(),
1927
2009
  assetId
1928
2010
  });
@@ -1975,12 +2057,6 @@ var BaseTransactionRequest = class {
1975
2057
  * @param quantities - CoinQuantity Array.
1976
2058
  */
1977
2059
  fundWithFakeUtxos(quantities, resourcesOwner) {
1978
- let idCounter = 0;
1979
- const generateId = () => {
1980
- const counterString = String(idCounter++);
1981
- const id = import_configs6.ZeroBytes32.slice(0, -counterString.length).concat(counterString);
1982
- return id;
1983
- };
1984
2060
  const findAssetInput = (assetId) => this.inputs.find((input) => {
1985
2061
  if ("assetId" in input) {
1986
2062
  return input.assetId === assetId;
@@ -1990,23 +2066,23 @@ var BaseTransactionRequest = class {
1990
2066
  const updateAssetInput = (assetId, quantity) => {
1991
2067
  const assetInput = findAssetInput(assetId);
1992
2068
  if (assetInput && "assetId" in assetInput) {
1993
- assetInput.id = generateId();
2069
+ assetInput.id = (0, import_utils9.hexlify)((0, import_crypto.randomBytes)(import_abi_coder2.UTXO_ID_LEN));
1994
2070
  assetInput.amount = quantity;
1995
2071
  } else {
1996
2072
  this.addResources([
1997
2073
  {
1998
- id: generateId(),
2074
+ id: (0, import_utils9.hexlify)((0, import_crypto.randomBytes)(import_abi_coder2.UTXO_ID_LEN)),
1999
2075
  amount: quantity,
2000
2076
  assetId,
2001
2077
  owner: resourcesOwner || import_address.Address.fromRandom(),
2002
2078
  maturity: 0,
2003
- blockCreated: (0, import_math6.bn)(1),
2004
- txCreatedIdx: (0, import_math6.bn)(1)
2079
+ blockCreated: (0, import_math7.bn)(1),
2080
+ txCreatedIdx: (0, import_math7.bn)(1)
2005
2081
  }
2006
2082
  ]);
2007
2083
  }
2008
2084
  };
2009
- updateAssetInput(import_configs6.BaseAssetId, (0, import_math6.bn)(1e11));
2085
+ updateAssetInput(import_configs7.BaseAssetId, (0, import_math7.bn)(1e11));
2010
2086
  quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
2011
2087
  }
2012
2088
  /**
@@ -2017,7 +2093,7 @@ var BaseTransactionRequest = class {
2017
2093
  */
2018
2094
  getCoinOutputsQuantities() {
2019
2095
  const coinsQuantities = this.getCoinOutputs().map(({ amount, assetId }) => ({
2020
- amount: (0, import_math6.bn)(amount),
2096
+ amount: (0, import_math7.bn)(amount),
2021
2097
  assetId: assetId.toString()
2022
2098
  }));
2023
2099
  return coinsQuantities;
@@ -2035,18 +2111,18 @@ var BaseTransactionRequest = class {
2035
2111
  this.inputs.forEach((i) => {
2036
2112
  let correspondingInput;
2037
2113
  switch (i.type) {
2038
- case import_transactions5.InputType.Coin:
2039
- correspondingInput = inputs.find((x) => x.type === import_transactions5.InputType.Coin && x.owner === i.owner);
2114
+ case import_transactions6.InputType.Coin:
2115
+ correspondingInput = inputs.find((x) => x.type === import_transactions6.InputType.Coin && x.owner === i.owner);
2040
2116
  break;
2041
- case import_transactions5.InputType.Message:
2117
+ case import_transactions6.InputType.Message:
2042
2118
  correspondingInput = inputs.find(
2043
- (x) => x.type === import_transactions5.InputType.Message && x.sender === i.sender
2119
+ (x) => x.type === import_transactions6.InputType.Message && x.sender === i.sender
2044
2120
  );
2045
2121
  break;
2046
2122
  default:
2047
2123
  return;
2048
2124
  }
2049
- if (correspondingInput && "predicateGasUsed" in correspondingInput && (0, import_math6.bn)(correspondingInput.predicateGasUsed).gt(0)) {
2125
+ if (correspondingInput && "predicateGasUsed" in correspondingInput && (0, import_math7.bn)(correspondingInput.predicateGasUsed).gt(0)) {
2050
2126
  i.predicate = correspondingInput.predicate;
2051
2127
  i.predicateData = correspondingInput.predicateData;
2052
2128
  i.predicateGasUsed = correspondingInput.predicateGasUsed;
@@ -2056,47 +2132,47 @@ var BaseTransactionRequest = class {
2056
2132
  };
2057
2133
 
2058
2134
  // src/providers/transaction-request/create-transaction-request.ts
2059
- var import_configs8 = require("@fuel-ts/address/configs");
2060
- var import_math8 = require("@fuel-ts/math");
2061
- var import_transactions7 = require("@fuel-ts/transactions");
2135
+ var import_configs9 = require("@fuel-ts/address/configs");
2136
+ var import_math9 = require("@fuel-ts/math");
2137
+ var import_transactions8 = require("@fuel-ts/transactions");
2062
2138
  var import_utils13 = require("@fuel-ts/utils");
2063
2139
 
2064
2140
  // src/providers/transaction-request/hash-transaction.ts
2065
- var import_configs7 = require("@fuel-ts/address/configs");
2141
+ var import_configs8 = require("@fuel-ts/address/configs");
2066
2142
  var import_hasher = require("@fuel-ts/hasher");
2067
- var import_math7 = require("@fuel-ts/math");
2068
- var import_transactions6 = require("@fuel-ts/transactions");
2143
+ var import_math8 = require("@fuel-ts/math");
2144
+ var import_transactions7 = require("@fuel-ts/transactions");
2069
2145
  var import_utils11 = require("@fuel-ts/utils");
2070
2146
  var import_ramda2 = require("ramda");
2071
2147
  function hashTransaction(transactionRequest, chainId) {
2072
2148
  const transaction = transactionRequest.toTransaction();
2073
- if (transaction.type === import_transactions6.TransactionType.Script) {
2074
- transaction.receiptsRoot = import_configs7.ZeroBytes32;
2149
+ if (transaction.type === import_transactions7.TransactionType.Script) {
2150
+ transaction.receiptsRoot = import_configs8.ZeroBytes32;
2075
2151
  }
2076
2152
  transaction.inputs = transaction.inputs.map((input) => {
2077
2153
  const inputClone = (0, import_ramda2.clone)(input);
2078
2154
  switch (inputClone.type) {
2079
- case import_transactions6.InputType.Coin: {
2155
+ case import_transactions7.InputType.Coin: {
2080
2156
  inputClone.txPointer = {
2081
2157
  blockHeight: 0,
2082
2158
  txIndex: 0
2083
2159
  };
2084
- inputClone.predicateGasUsed = (0, import_math7.bn)(0);
2160
+ inputClone.predicateGasUsed = (0, import_math8.bn)(0);
2085
2161
  return inputClone;
2086
2162
  }
2087
- case import_transactions6.InputType.Message: {
2088
- inputClone.predicateGasUsed = (0, import_math7.bn)(0);
2163
+ case import_transactions7.InputType.Message: {
2164
+ inputClone.predicateGasUsed = (0, import_math8.bn)(0);
2089
2165
  return inputClone;
2090
2166
  }
2091
- case import_transactions6.InputType.Contract: {
2167
+ case import_transactions7.InputType.Contract: {
2092
2168
  inputClone.txPointer = {
2093
2169
  blockHeight: 0,
2094
2170
  txIndex: 0
2095
2171
  };
2096
- inputClone.txID = import_configs7.ZeroBytes32;
2172
+ inputClone.txID = import_configs8.ZeroBytes32;
2097
2173
  inputClone.outputIndex = 0;
2098
- inputClone.balanceRoot = import_configs7.ZeroBytes32;
2099
- inputClone.stateRoot = import_configs7.ZeroBytes32;
2174
+ inputClone.balanceRoot = import_configs8.ZeroBytes32;
2175
+ inputClone.stateRoot = import_configs8.ZeroBytes32;
2100
2176
  return inputClone;
2101
2177
  }
2102
2178
  default:
@@ -2106,19 +2182,19 @@ function hashTransaction(transactionRequest, chainId) {
2106
2182
  transaction.outputs = transaction.outputs.map((output) => {
2107
2183
  const outputClone = (0, import_ramda2.clone)(output);
2108
2184
  switch (outputClone.type) {
2109
- case import_transactions6.OutputType.Contract: {
2110
- outputClone.balanceRoot = import_configs7.ZeroBytes32;
2111
- outputClone.stateRoot = import_configs7.ZeroBytes32;
2185
+ case import_transactions7.OutputType.Contract: {
2186
+ outputClone.balanceRoot = import_configs8.ZeroBytes32;
2187
+ outputClone.stateRoot = import_configs8.ZeroBytes32;
2112
2188
  return outputClone;
2113
2189
  }
2114
- case import_transactions6.OutputType.Change: {
2115
- outputClone.amount = (0, import_math7.bn)(0);
2190
+ case import_transactions7.OutputType.Change: {
2191
+ outputClone.amount = (0, import_math8.bn)(0);
2116
2192
  return outputClone;
2117
2193
  }
2118
- case import_transactions6.OutputType.Variable: {
2119
- outputClone.to = import_configs7.ZeroBytes32;
2120
- outputClone.amount = (0, import_math7.bn)(0);
2121
- outputClone.assetId = import_configs7.ZeroBytes32;
2194
+ case import_transactions7.OutputType.Variable: {
2195
+ outputClone.to = import_configs8.ZeroBytes32;
2196
+ outputClone.amount = (0, import_math8.bn)(0);
2197
+ outputClone.assetId = import_configs8.ZeroBytes32;
2122
2198
  return outputClone;
2123
2199
  }
2124
2200
  default:
@@ -2128,7 +2204,7 @@ function hashTransaction(transactionRequest, chainId) {
2128
2204
  transaction.witnessesCount = 0;
2129
2205
  transaction.witnesses = [];
2130
2206
  const chainIdBytes = (0, import_hasher.uint64ToBytesBE)(chainId);
2131
- const concatenatedData = (0, import_utils11.concat)([chainIdBytes, new import_transactions6.TransactionCoder().encode(transaction)]);
2207
+ const concatenatedData = (0, import_utils11.concat)([chainIdBytes, new import_transactions7.TransactionCoder().encode(transaction)]);
2132
2208
  return (0, import_hasher.sha256)(concatenatedData);
2133
2209
  }
2134
2210
 
@@ -2164,7 +2240,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2164
2240
  return new this(obj);
2165
2241
  }
2166
2242
  /** Type of the transaction */
2167
- type = import_transactions7.TransactionType.Create;
2243
+ type = import_transactions8.TransactionType.Create;
2168
2244
  /** Witness index of contract bytecode to create */
2169
2245
  bytecodeWitnessIndex;
2170
2246
  /** Salt */
@@ -2184,7 +2260,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2184
2260
  } = {}) {
2185
2261
  super(rest);
2186
2262
  this.bytecodeWitnessIndex = bytecodeWitnessIndex ?? 0;
2187
- this.salt = (0, import_utils13.hexlify)(salt ?? import_configs8.ZeroBytes32);
2263
+ this.salt = (0, import_utils13.hexlify)(salt ?? import_configs9.ZeroBytes32);
2188
2264
  this.storageSlots = [...storageSlots ?? []];
2189
2265
  }
2190
2266
  /**
@@ -2197,12 +2273,12 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2197
2273
  const bytecodeWitnessIndex = this.bytecodeWitnessIndex;
2198
2274
  const storageSlots = this.storageSlots?.map(storageSlotify) ?? [];
2199
2275
  return {
2200
- type: import_transactions7.TransactionType.Create,
2276
+ type: import_transactions8.TransactionType.Create,
2201
2277
  ...baseTransaction,
2202
2278
  bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
2203
2279
  bytecodeWitnessIndex,
2204
2280
  storageSlotsCount: storageSlots.length,
2205
- salt: this.salt ? (0, import_utils13.hexlify)(this.salt) : import_configs8.ZeroBytes32,
2281
+ salt: this.salt ? (0, import_utils13.hexlify)(this.salt) : import_configs9.ZeroBytes32,
2206
2282
  storageSlots
2207
2283
  };
2208
2284
  }
@@ -2213,7 +2289,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2213
2289
  */
2214
2290
  getContractCreatedOutputs() {
2215
2291
  return this.outputs.filter(
2216
- (output) => output.type === import_transactions7.OutputType.ContractCreated
2292
+ (output) => output.type === import_transactions8.OutputType.ContractCreated
2217
2293
  );
2218
2294
  }
2219
2295
  /**
@@ -2234,14 +2310,14 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2234
2310
  */
2235
2311
  addContractCreatedOutput(contractId, stateRoot) {
2236
2312
  this.pushOutput({
2237
- type: import_transactions7.OutputType.ContractCreated,
2313
+ type: import_transactions8.OutputType.ContractCreated,
2238
2314
  contractId,
2239
2315
  stateRoot
2240
2316
  });
2241
2317
  }
2242
2318
  metadataGas(gasCosts) {
2243
2319
  return calculateMetadataGasForTxCreate({
2244
- contractBytesSize: (0, import_math8.bn)((0, import_utils13.arrayify)(this.witnesses[this.bytecodeWitnessIndex] || "0x").length),
2320
+ contractBytesSize: (0, import_math9.bn)((0, import_utils13.arrayify)(this.witnesses[this.bytecodeWitnessIndex] || "0x").length),
2245
2321
  gasCosts,
2246
2322
  stateRootSize: this.storageSlots.length,
2247
2323
  txBytesSize: this.byteSize()
@@ -2250,11 +2326,11 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2250
2326
  };
2251
2327
 
2252
2328
  // src/providers/transaction-request/script-transaction-request.ts
2253
- var import_abi_coder = require("@fuel-ts/abi-coder");
2329
+ var import_abi_coder3 = require("@fuel-ts/abi-coder");
2254
2330
  var import_address2 = require("@fuel-ts/address");
2255
- var import_configs9 = require("@fuel-ts/address/configs");
2256
- var import_math9 = require("@fuel-ts/math");
2257
- var import_transactions8 = require("@fuel-ts/transactions");
2331
+ var import_configs10 = require("@fuel-ts/address/configs");
2332
+ var import_math10 = require("@fuel-ts/math");
2333
+ var import_transactions9 = require("@fuel-ts/transactions");
2258
2334
  var import_utils15 = require("@fuel-ts/utils");
2259
2335
 
2260
2336
  // src/providers/transaction-request/scripts.ts
@@ -2292,7 +2368,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2292
2368
  return new this(obj);
2293
2369
  }
2294
2370
  /** Type of the transaction */
2295
- type = import_transactions8.TransactionType.Script;
2371
+ type = import_transactions9.TransactionType.Script;
2296
2372
  /** Gas limit for transaction */
2297
2373
  gasLimit;
2298
2374
  /** Script to execute */
@@ -2307,7 +2383,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2307
2383
  */
2308
2384
  constructor({ script, scriptData, gasLimit, ...rest } = {}) {
2309
2385
  super(rest);
2310
- this.gasLimit = (0, import_math9.bn)(gasLimit);
2386
+ this.gasLimit = (0, import_math10.bn)(gasLimit);
2311
2387
  this.script = (0, import_utils15.arrayify)(script ?? returnZeroScript.bytes);
2312
2388
  this.scriptData = (0, import_utils15.arrayify)(scriptData ?? returnZeroScript.encodeScriptData());
2313
2389
  this.abis = rest.abis;
@@ -2321,12 +2397,12 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2321
2397
  const script = (0, import_utils15.arrayify)(this.script ?? "0x");
2322
2398
  const scriptData = (0, import_utils15.arrayify)(this.scriptData ?? "0x");
2323
2399
  return {
2324
- type: import_transactions8.TransactionType.Script,
2400
+ type: import_transactions9.TransactionType.Script,
2325
2401
  scriptGasLimit: this.gasLimit,
2326
2402
  ...super.getBaseTransaction(),
2327
2403
  scriptLength: script.length,
2328
2404
  scriptDataLength: scriptData.length,
2329
- receiptsRoot: import_configs9.ZeroBytes32,
2405
+ receiptsRoot: import_configs10.ZeroBytes32,
2330
2406
  script: (0, import_utils15.hexlify)(script),
2331
2407
  scriptData: (0, import_utils15.hexlify)(scriptData)
2332
2408
  };
@@ -2338,7 +2414,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2338
2414
  */
2339
2415
  getContractInputs() {
2340
2416
  return this.inputs.filter(
2341
- (input) => input.type === import_transactions8.InputType.Contract
2417
+ (input) => input.type === import_transactions9.InputType.Contract
2342
2418
  );
2343
2419
  }
2344
2420
  /**
@@ -2348,7 +2424,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2348
2424
  */
2349
2425
  getContractOutputs() {
2350
2426
  return this.outputs.filter(
2351
- (output) => output.type === import_transactions8.OutputType.Contract
2427
+ (output) => output.type === import_transactions9.OutputType.Contract
2352
2428
  );
2353
2429
  }
2354
2430
  /**
@@ -2358,7 +2434,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2358
2434
  */
2359
2435
  getVariableOutputs() {
2360
2436
  return this.outputs.filter(
2361
- (output) => output.type === import_transactions8.OutputType.Variable
2437
+ (output) => output.type === import_transactions9.OutputType.Variable
2362
2438
  );
2363
2439
  }
2364
2440
  /**
@@ -2381,7 +2457,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2381
2457
  let outputsNumber = numberOfVariables;
2382
2458
  while (outputsNumber) {
2383
2459
  this.pushOutput({
2384
- type: import_transactions8.OutputType.Variable
2460
+ type: import_transactions9.OutputType.Variable
2385
2461
  });
2386
2462
  outputsNumber -= 1;
2387
2463
  }
@@ -2414,12 +2490,12 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2414
2490
  return this;
2415
2491
  }
2416
2492
  const inputIndex = super.pushInput({
2417
- type: import_transactions8.InputType.Contract,
2493
+ type: import_transactions9.InputType.Contract,
2418
2494
  contractId: contractAddress.toB256(),
2419
2495
  txPointer: "0x00000000000000000000000000000000"
2420
2496
  });
2421
2497
  this.pushOutput({
2422
- type: import_transactions8.OutputType.Contract,
2498
+ type: import_transactions9.OutputType.Contract,
2423
2499
  inputIndex
2424
2500
  });
2425
2501
  return this;
@@ -2442,7 +2518,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2442
2518
  * @returns The current instance of the `ScriptTransactionRequest`.
2443
2519
  */
2444
2520
  setData(abi, args) {
2445
- const abiInterface = new import_abi_coder.Interface(abi);
2521
+ const abiInterface = new import_abi_coder3.Interface(abi);
2446
2522
  this.scriptData = abiInterface.functions.main.encodeArguments(args);
2447
2523
  return this;
2448
2524
  }
@@ -2455,38 +2531,38 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2455
2531
  };
2456
2532
 
2457
2533
  // src/providers/transaction-request/utils.ts
2458
- var import_errors8 = require("@fuel-ts/errors");
2459
- var import_transactions9 = require("@fuel-ts/transactions");
2534
+ var import_errors9 = require("@fuel-ts/errors");
2535
+ var import_transactions10 = require("@fuel-ts/transactions");
2460
2536
  var transactionRequestify = (obj) => {
2461
2537
  if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest) {
2462
2538
  return obj;
2463
2539
  }
2464
2540
  const { type } = obj;
2465
2541
  switch (obj.type) {
2466
- case import_transactions9.TransactionType.Script: {
2542
+ case import_transactions10.TransactionType.Script: {
2467
2543
  return ScriptTransactionRequest.from(obj);
2468
2544
  }
2469
- case import_transactions9.TransactionType.Create: {
2545
+ case import_transactions10.TransactionType.Create: {
2470
2546
  return CreateTransactionRequest.from(obj);
2471
2547
  }
2472
2548
  default: {
2473
- throw new import_errors8.FuelError(import_errors8.ErrorCode.INVALID_TRANSACTION_TYPE, `Invalid transaction type: ${type}.`);
2549
+ throw new import_errors9.FuelError(import_errors9.ErrorCode.INVALID_TRANSACTION_TYPE, `Invalid transaction type: ${type}.`);
2474
2550
  }
2475
2551
  }
2476
2552
  };
2477
2553
 
2478
2554
  // src/providers/transaction-response/transaction-response.ts
2479
- var import_errors12 = require("@fuel-ts/errors");
2480
- var import_math13 = require("@fuel-ts/math");
2481
- var import_transactions16 = require("@fuel-ts/transactions");
2555
+ var import_errors13 = require("@fuel-ts/errors");
2556
+ var import_math14 = require("@fuel-ts/math");
2557
+ var import_transactions17 = require("@fuel-ts/transactions");
2482
2558
  var import_utils21 = require("@fuel-ts/utils");
2483
2559
 
2484
2560
  // src/providers/transaction-summary/assemble-transaction-summary.ts
2485
2561
  var import_utils19 = require("@fuel-ts/utils");
2486
2562
 
2487
2563
  // src/providers/transaction-summary/calculate-transaction-fee.ts
2488
- var import_math10 = require("@fuel-ts/math");
2489
- var import_transactions10 = require("@fuel-ts/transactions");
2564
+ var import_math11 = require("@fuel-ts/math");
2565
+ var import_transactions11 = require("@fuel-ts/transactions");
2490
2566
  var import_utils16 = require("@fuel-ts/utils");
2491
2567
  var calculateTransactionFee = (params) => {
2492
2568
  const {
@@ -2494,24 +2570,24 @@ var calculateTransactionFee = (params) => {
2494
2570
  rawPayload,
2495
2571
  consensusParameters: { gasCosts, feeParams }
2496
2572
  } = params;
2497
- const gasPerByte = (0, import_math10.bn)(feeParams.gasPerByte);
2498
- const gasPriceFactor = (0, import_math10.bn)(feeParams.gasPriceFactor);
2573
+ const gasPerByte = (0, import_math11.bn)(feeParams.gasPerByte);
2574
+ const gasPriceFactor = (0, import_math11.bn)(feeParams.gasPriceFactor);
2499
2575
  const transactionBytes = (0, import_utils16.arrayify)(rawPayload);
2500
- const [transaction] = new import_transactions10.TransactionCoder().decode(transactionBytes, 0);
2501
- if (transaction.type === import_transactions10.TransactionType.Mint) {
2576
+ const [transaction] = new import_transactions11.TransactionCoder().decode(transactionBytes, 0);
2577
+ if (transaction.type === import_transactions11.TransactionType.Mint) {
2502
2578
  return {
2503
- fee: (0, import_math10.bn)(0),
2504
- minFee: (0, import_math10.bn)(0),
2505
- maxFee: (0, import_math10.bn)(0),
2506
- feeFromGasUsed: (0, import_math10.bn)(0)
2579
+ fee: (0, import_math11.bn)(0),
2580
+ minFee: (0, import_math11.bn)(0),
2581
+ maxFee: (0, import_math11.bn)(0),
2582
+ feeFromGasUsed: (0, import_math11.bn)(0)
2507
2583
  };
2508
2584
  }
2509
2585
  const { type, witnesses, inputs, policies } = transaction;
2510
- let metadataGas = (0, import_math10.bn)(0);
2511
- let gasLimit = (0, import_math10.bn)(0);
2512
- if (type === import_transactions10.TransactionType.Create) {
2586
+ let metadataGas = (0, import_math11.bn)(0);
2587
+ let gasLimit = (0, import_math11.bn)(0);
2588
+ if (type === import_transactions11.TransactionType.Create) {
2513
2589
  const { bytecodeWitnessIndex, storageSlots } = transaction;
2514
- const contractBytesSize = (0, import_math10.bn)((0, import_utils16.arrayify)(witnesses[bytecodeWitnessIndex].data).length);
2590
+ const contractBytesSize = (0, import_math11.bn)((0, import_utils16.arrayify)(witnesses[bytecodeWitnessIndex].data).length);
2515
2591
  metadataGas = calculateMetadataGasForTxCreate({
2516
2592
  contractBytesSize,
2517
2593
  gasCosts,
@@ -2530,13 +2606,13 @@ var calculateTransactionFee = (params) => {
2530
2606
  }
2531
2607
  const minGas = getMinGas({
2532
2608
  gasCosts,
2533
- gasPerByte: (0, import_math10.bn)(gasPerByte),
2609
+ gasPerByte: (0, import_math11.bn)(gasPerByte),
2534
2610
  inputs,
2535
2611
  metadataGas,
2536
2612
  txBytesSize: transactionBytes.length
2537
2613
  });
2538
- const gasPrice = (0, import_math10.bn)(policies.find((policy) => policy.type === import_transactions10.PolicyType.GasPrice)?.data);
2539
- const witnessLimit = policies.find((policy) => policy.type === import_transactions10.PolicyType.WitnessLimit)?.data;
2614
+ const gasPrice = (0, import_math11.bn)(policies.find((policy) => policy.type === import_transactions11.PolicyType.GasPrice)?.data);
2615
+ const witnessLimit = policies.find((policy) => policy.type === import_transactions11.PolicyType.WitnessLimit)?.data;
2540
2616
  const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
2541
2617
  const maxGas = getMaxGas({
2542
2618
  gasPerByte,
@@ -2558,23 +2634,23 @@ var calculateTransactionFee = (params) => {
2558
2634
  };
2559
2635
 
2560
2636
  // src/providers/transaction-summary/operations.ts
2561
- var import_configs10 = require("@fuel-ts/address/configs");
2562
- var import_errors10 = require("@fuel-ts/errors");
2563
- var import_math12 = require("@fuel-ts/math");
2564
- var import_transactions13 = require("@fuel-ts/transactions");
2637
+ var import_configs11 = require("@fuel-ts/address/configs");
2638
+ var import_errors11 = require("@fuel-ts/errors");
2639
+ var import_math13 = require("@fuel-ts/math");
2640
+ var import_transactions14 = require("@fuel-ts/transactions");
2565
2641
 
2566
2642
  // src/providers/transaction-summary/call.ts
2567
- var import_abi_coder2 = require("@fuel-ts/abi-coder");
2568
- var import_math11 = require("@fuel-ts/math");
2643
+ var import_abi_coder4 = require("@fuel-ts/abi-coder");
2644
+ var import_math12 = require("@fuel-ts/math");
2569
2645
  var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
2570
- const abiInterface = new import_abi_coder2.Interface(abi);
2646
+ const abiInterface = new import_abi_coder4.Interface(abi);
2571
2647
  const callFunctionSelector = receipt.param1.toHex(8);
2572
2648
  const functionFragment = abiInterface.getFunction(callFunctionSelector);
2573
2649
  const inputs = functionFragment.jsonFn.inputs;
2574
2650
  let encodedArgs;
2575
2651
  if (functionFragment.isInputDataPointer) {
2576
2652
  if (rawPayload) {
2577
- const argsOffset = (0, import_math11.bn)(receipt.param2).sub((0, import_abi_coder2.calculateVmTxMemory)({ maxInputs: maxInputs.toNumber() })).toNumber();
2653
+ const argsOffset = (0, import_math12.bn)(receipt.param2).sub((0, import_abi_coder4.calculateVmTxMemory)({ maxInputs: maxInputs.toNumber() })).toNumber();
2578
2654
  encodedArgs = `0x${rawPayload.slice(2).slice(argsOffset * 2)}`;
2579
2655
  }
2580
2656
  } else {
@@ -2608,8 +2684,8 @@ var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
2608
2684
  };
2609
2685
 
2610
2686
  // src/providers/transaction-summary/input.ts
2611
- var import_errors9 = require("@fuel-ts/errors");
2612
- var import_transactions11 = require("@fuel-ts/transactions");
2687
+ var import_errors10 = require("@fuel-ts/errors");
2688
+ var import_transactions12 = require("@fuel-ts/transactions");
2613
2689
  function getInputsByTypes(inputs, types) {
2614
2690
  return inputs.filter((i) => types.includes(i.type));
2615
2691
  }
@@ -2617,16 +2693,16 @@ function getInputsByType(inputs, type) {
2617
2693
  return inputs.filter((i) => i.type === type);
2618
2694
  }
2619
2695
  function getInputsCoin(inputs) {
2620
- return getInputsByType(inputs, import_transactions11.InputType.Coin);
2696
+ return getInputsByType(inputs, import_transactions12.InputType.Coin);
2621
2697
  }
2622
2698
  function getInputsMessage(inputs) {
2623
- return getInputsByType(inputs, import_transactions11.InputType.Message);
2699
+ return getInputsByType(inputs, import_transactions12.InputType.Message);
2624
2700
  }
2625
2701
  function getInputsCoinAndMessage(inputs) {
2626
- return getInputsByTypes(inputs, [import_transactions11.InputType.Coin, import_transactions11.InputType.Message]);
2702
+ return getInputsByTypes(inputs, [import_transactions12.InputType.Coin, import_transactions12.InputType.Message]);
2627
2703
  }
2628
2704
  function getInputsContract(inputs) {
2629
- return getInputsByType(inputs, import_transactions11.InputType.Contract);
2705
+ return getInputsByType(inputs, import_transactions12.InputType.Contract);
2630
2706
  }
2631
2707
  function getInputFromAssetId(inputs, assetId) {
2632
2708
  const coinInputs = getInputsCoin(inputs);
@@ -2645,40 +2721,40 @@ function getInputContractFromIndex(inputs, inputIndex) {
2645
2721
  if (!contractInput) {
2646
2722
  return void 0;
2647
2723
  }
2648
- if (contractInput.type !== import_transactions11.InputType.Contract) {
2649
- throw new import_errors9.FuelError(
2650
- import_errors9.ErrorCode.INVALID_TRANSACTION_INPUT,
2724
+ if (contractInput.type !== import_transactions12.InputType.Contract) {
2725
+ throw new import_errors10.FuelError(
2726
+ import_errors10.ErrorCode.INVALID_TRANSACTION_INPUT,
2651
2727
  `Contract input should be of type 'contract'.`
2652
2728
  );
2653
2729
  }
2654
2730
  return contractInput;
2655
2731
  }
2656
2732
  function getInputAccountAddress(input) {
2657
- if (input.type === import_transactions11.InputType.Coin) {
2733
+ if (input.type === import_transactions12.InputType.Coin) {
2658
2734
  return input.owner.toString();
2659
2735
  }
2660
- if (input.type === import_transactions11.InputType.Message) {
2736
+ if (input.type === import_transactions12.InputType.Message) {
2661
2737
  return input.recipient.toString();
2662
2738
  }
2663
2739
  return "";
2664
2740
  }
2665
2741
 
2666
2742
  // src/providers/transaction-summary/output.ts
2667
- var import_transactions12 = require("@fuel-ts/transactions");
2743
+ var import_transactions13 = require("@fuel-ts/transactions");
2668
2744
  function getOutputsByType(outputs, type) {
2669
2745
  return outputs.filter((o) => o.type === type);
2670
2746
  }
2671
2747
  function getOutputsContractCreated(outputs) {
2672
- return getOutputsByType(outputs, import_transactions12.OutputType.ContractCreated);
2748
+ return getOutputsByType(outputs, import_transactions13.OutputType.ContractCreated);
2673
2749
  }
2674
2750
  function getOutputsCoin(outputs) {
2675
- return getOutputsByType(outputs, import_transactions12.OutputType.Coin);
2751
+ return getOutputsByType(outputs, import_transactions13.OutputType.Coin);
2676
2752
  }
2677
2753
  function getOutputsChange(outputs) {
2678
- return getOutputsByType(outputs, import_transactions12.OutputType.Change);
2754
+ return getOutputsByType(outputs, import_transactions13.OutputType.Change);
2679
2755
  }
2680
2756
  function getOutputsContract(outputs) {
2681
- return getOutputsByType(outputs, import_transactions12.OutputType.Contract);
2757
+ return getOutputsByType(outputs, import_transactions13.OutputType.Contract);
2682
2758
  }
2683
2759
 
2684
2760
  // src/providers/transaction-summary/operations.ts
@@ -2687,15 +2763,15 @@ function getReceiptsByType(receipts, type) {
2687
2763
  }
2688
2764
  function getTransactionTypeName(transactionType) {
2689
2765
  switch (transactionType) {
2690
- case import_transactions13.TransactionType.Mint:
2766
+ case import_transactions14.TransactionType.Mint:
2691
2767
  return "Mint" /* Mint */;
2692
- case import_transactions13.TransactionType.Create:
2768
+ case import_transactions14.TransactionType.Create:
2693
2769
  return "Create" /* Create */;
2694
- case import_transactions13.TransactionType.Script:
2770
+ case import_transactions14.TransactionType.Script:
2695
2771
  return "Script" /* Script */;
2696
2772
  default:
2697
- throw new import_errors10.FuelError(
2698
- import_errors10.ErrorCode.INVALID_TRANSACTION_TYPE,
2773
+ throw new import_errors11.FuelError(
2774
+ import_errors11.ErrorCode.INVALID_TRANSACTION_TYPE,
2699
2775
  `Invalid transaction type: ${transactionType}.`
2700
2776
  );
2701
2777
  }
@@ -2714,10 +2790,10 @@ function isTypeScript(transactionType) {
2714
2790
  return isType(transactionType, "Script" /* Script */);
2715
2791
  }
2716
2792
  function getReceiptsCall(receipts) {
2717
- return getReceiptsByType(receipts, import_transactions13.ReceiptType.Call);
2793
+ return getReceiptsByType(receipts, import_transactions14.ReceiptType.Call);
2718
2794
  }
2719
2795
  function getReceiptsMessageOut(receipts) {
2720
- return getReceiptsByType(receipts, import_transactions13.ReceiptType.MessageOut);
2796
+ return getReceiptsByType(receipts, import_transactions14.ReceiptType.MessageOut);
2721
2797
  }
2722
2798
  var mergeAssets = (op1, op2) => {
2723
2799
  const assets1 = op1.assetsSent || [];
@@ -2730,7 +2806,7 @@ var mergeAssets = (op1, op2) => {
2730
2806
  if (!matchingAsset) {
2731
2807
  return asset1;
2732
2808
  }
2733
- const mergedAmount = (0, import_math12.bn)(asset1.amount).add(matchingAsset.amount);
2809
+ const mergedAmount = (0, import_math13.bn)(asset1.amount).add(matchingAsset.amount);
2734
2810
  return { ...asset1, amount: mergedAmount };
2735
2811
  });
2736
2812
  return mergedAssets.concat(filteredAssets);
@@ -2856,7 +2932,7 @@ function extractTransferOperationFromReceipt(receipt, contractInputs, changeOutp
2856
2932
  const { to: toAddress, assetId, amount } = receipt;
2857
2933
  let { from: fromAddress } = receipt;
2858
2934
  const toType = contractInputs.some((input) => input.contractID === toAddress) ? 0 /* contract */ : 1 /* account */;
2859
- if (import_configs10.ZeroBytes32 === fromAddress) {
2935
+ if (import_configs11.ZeroBytes32 === fromAddress) {
2860
2936
  const change = changeOutputs.find((output) => output.assetId === assetId);
2861
2937
  fromAddress = change?.to || fromAddress;
2862
2938
  }
@@ -2913,11 +2989,11 @@ function getTransferOperations({
2913
2989
  });
2914
2990
  const transferReceipts = getReceiptsByType(
2915
2991
  receipts,
2916
- import_transactions13.ReceiptType.Transfer
2992
+ import_transactions14.ReceiptType.Transfer
2917
2993
  );
2918
2994
  const transferOutReceipts = getReceiptsByType(
2919
2995
  receipts,
2920
- import_transactions13.ReceiptType.TransferOut
2996
+ import_transactions14.ReceiptType.TransferOut
2921
2997
  );
2922
2998
  [...transferReceipts, ...transferOutReceipts].forEach((receipt) => {
2923
2999
  const operation = extractTransferOperationFromReceipt(receipt, contractInputs, changeOutputs);
@@ -3002,17 +3078,17 @@ function getOperations({
3002
3078
  }
3003
3079
 
3004
3080
  // src/providers/transaction-summary/receipt.ts
3005
- var import_transactions14 = require("@fuel-ts/transactions");
3081
+ var import_transactions15 = require("@fuel-ts/transactions");
3006
3082
  var processGqlReceipt = (gqlReceipt) => {
3007
3083
  const receipt = assembleReceiptByType(gqlReceipt);
3008
3084
  switch (receipt.type) {
3009
- case import_transactions14.ReceiptType.ReturnData: {
3085
+ case import_transactions15.ReceiptType.ReturnData: {
3010
3086
  return {
3011
3087
  ...receipt,
3012
3088
  data: gqlReceipt.data || "0x"
3013
3089
  };
3014
3090
  }
3015
- case import_transactions14.ReceiptType.LogData: {
3091
+ case import_transactions15.ReceiptType.LogData: {
3016
3092
  return {
3017
3093
  ...receipt,
3018
3094
  data: gqlReceipt.data || "0x"
@@ -3025,7 +3101,7 @@ var processGqlReceipt = (gqlReceipt) => {
3025
3101
  var extractMintedAssetsFromReceipts = (receipts) => {
3026
3102
  const mintedAssets = [];
3027
3103
  receipts.forEach((receipt) => {
3028
- if (receipt.type === import_transactions14.ReceiptType.Mint) {
3104
+ if (receipt.type === import_transactions15.ReceiptType.Mint) {
3029
3105
  mintedAssets.push({
3030
3106
  subId: receipt.subId,
3031
3107
  contractId: receipt.contractId,
@@ -3039,7 +3115,7 @@ var extractMintedAssetsFromReceipts = (receipts) => {
3039
3115
  var extractBurnedAssetsFromReceipts = (receipts) => {
3040
3116
  const burnedAssets = [];
3041
3117
  receipts.forEach((receipt) => {
3042
- if (receipt.type === import_transactions14.ReceiptType.Burn) {
3118
+ if (receipt.type === import_transactions15.ReceiptType.Burn) {
3043
3119
  burnedAssets.push({
3044
3120
  subId: receipt.subId,
3045
3121
  contractId: receipt.contractId,
@@ -3052,7 +3128,7 @@ var extractBurnedAssetsFromReceipts = (receipts) => {
3052
3128
  };
3053
3129
 
3054
3130
  // src/providers/transaction-summary/status.ts
3055
- var import_errors11 = require("@fuel-ts/errors");
3131
+ var import_errors12 = require("@fuel-ts/errors");
3056
3132
  var getTransactionStatusName = (gqlStatus) => {
3057
3133
  switch (gqlStatus) {
3058
3134
  case "FailureStatus":
@@ -3064,8 +3140,8 @@ var getTransactionStatusName = (gqlStatus) => {
3064
3140
  case "SqueezedOutStatus":
3065
3141
  return "squeezedout" /* squeezedout */;
3066
3142
  default:
3067
- throw new import_errors11.FuelError(
3068
- import_errors11.ErrorCode.INVALID_TRANSACTION_STATUS,
3143
+ throw new import_errors12.FuelError(
3144
+ import_errors12.ErrorCode.INVALID_TRANSACTION_STATUS,
3069
3145
  `Invalid transaction status: ${gqlStatus}.`
3070
3146
  );
3071
3147
  }
@@ -3177,13 +3253,13 @@ function assembleTransactionSummary(params) {
3177
3253
  }
3178
3254
 
3179
3255
  // src/providers/transaction-response/getDecodedLogs.ts
3180
- var import_abi_coder3 = require("@fuel-ts/abi-coder");
3181
- var import_transactions15 = require("@fuel-ts/transactions");
3256
+ var import_abi_coder5 = require("@fuel-ts/abi-coder");
3257
+ var import_transactions16 = require("@fuel-ts/transactions");
3182
3258
  function getDecodedLogs(receipts, mainAbi, externalAbis = {}) {
3183
3259
  return receipts.reduce((logs, receipt) => {
3184
- if (receipt.type === import_transactions15.ReceiptType.LogData || receipt.type === import_transactions15.ReceiptType.Log) {
3185
- const interfaceToUse = new import_abi_coder3.Interface(externalAbis[receipt.id] || mainAbi);
3186
- const data = receipt.type === import_transactions15.ReceiptType.Log ? new import_abi_coder3.BigNumberCoder("u64").encode(receipt.val0) : receipt.data;
3260
+ if (receipt.type === import_transactions16.ReceiptType.LogData || receipt.type === import_transactions16.ReceiptType.Log) {
3261
+ const interfaceToUse = new import_abi_coder5.Interface(externalAbis[receipt.id] || mainAbi);
3262
+ const data = receipt.type === import_transactions16.ReceiptType.Log ? new import_abi_coder5.BigNumberCoder("u64").encode(receipt.val0) : receipt.data;
3187
3263
  const [decodedLog] = interfaceToUse.decodeLog(data, receipt.val1.toNumber());
3188
3264
  logs.push(decodedLog);
3189
3265
  }
@@ -3198,7 +3274,7 @@ var TransactionResponse = class {
3198
3274
  /** Current provider */
3199
3275
  provider;
3200
3276
  /** Gas used on the transaction */
3201
- gasUsed = (0, import_math13.bn)(0);
3277
+ gasUsed = (0, import_math14.bn)(0);
3202
3278
  /** The graphql Transaction with receipts object. */
3203
3279
  gqlTransaction;
3204
3280
  abis;
@@ -3256,7 +3332,7 @@ var TransactionResponse = class {
3256
3332
  * @returns The decoded transaction.
3257
3333
  */
3258
3334
  decodeTransaction(transactionWithReceipts) {
3259
- return new import_transactions16.TransactionCoder().decode(
3335
+ return new import_transactions17.TransactionCoder().decode(
3260
3336
  (0, import_utils21.arrayify)(transactionWithReceipts.rawPayload),
3261
3337
  0
3262
3338
  )?.[0];
@@ -3303,8 +3379,8 @@ var TransactionResponse = class {
3303
3379
  });
3304
3380
  for await (const { statusChange } of subscription) {
3305
3381
  if (statusChange.type === "SqueezedOutStatus") {
3306
- throw new import_errors12.FuelError(
3307
- import_errors12.ErrorCode.TRANSACTION_SQUEEZED_OUT,
3382
+ throw new import_errors13.FuelError(
3383
+ import_errors13.ErrorCode.TRANSACTION_SQUEEZED_OUT,
3308
3384
  `Transaction Squeezed Out with reason: ${statusChange.reason}`
3309
3385
  );
3310
3386
  }
@@ -3326,14 +3402,26 @@ var TransactionResponse = class {
3326
3402
  gqlTransaction: this.gqlTransaction,
3327
3403
  ...transactionSummary
3328
3404
  };
3405
+ let logs = [];
3329
3406
  if (this.abis) {
3330
- const logs = getDecodedLogs(
3407
+ logs = getDecodedLogs(
3331
3408
  transactionSummary.receipts,
3332
3409
  this.abis.main,
3333
3410
  this.abis.otherContractsAbis
3334
3411
  );
3335
3412
  transactionResult.logs = logs;
3336
3413
  }
3414
+ if (transactionResult.isStatusFailure) {
3415
+ const {
3416
+ receipts,
3417
+ gqlTransaction: { status }
3418
+ } = transactionResult;
3419
+ throw extractTxError({
3420
+ receipts,
3421
+ status,
3422
+ logs
3423
+ });
3424
+ }
3337
3425
  return transactionResult;
3338
3426
  }
3339
3427
  /**
@@ -3342,14 +3430,7 @@ var TransactionResponse = class {
3342
3430
  * @param contractsAbiMap - The contracts ABI map.
3343
3431
  */
3344
3432
  async wait(contractsAbiMap) {
3345
- const result = await this.waitForResult(contractsAbiMap);
3346
- if (result.isStatusFailure) {
3347
- throw new import_errors12.FuelError(
3348
- import_errors12.ErrorCode.TRANSACTION_FAILED,
3349
- `Transaction failed: ${result.gqlTransaction.status.reason}`
3350
- );
3351
- }
3352
- return result;
3433
+ return this.waitForResult(contractsAbiMap);
3353
3434
  }
3354
3435
  };
3355
3436
 
@@ -3411,29 +3492,29 @@ var processGqlChain = (chain) => {
3411
3492
  const { contractParams, feeParams, predicateParams, scriptParams, txParams, gasCosts } = consensusParameters;
3412
3493
  return {
3413
3494
  name,
3414
- baseChainHeight: (0, import_math14.bn)(daHeight),
3495
+ baseChainHeight: (0, import_math15.bn)(daHeight),
3415
3496
  consensusParameters: {
3416
- contractMaxSize: (0, import_math14.bn)(contractParams.contractMaxSize),
3417
- maxInputs: (0, import_math14.bn)(txParams.maxInputs),
3418
- maxOutputs: (0, import_math14.bn)(txParams.maxOutputs),
3419
- maxWitnesses: (0, import_math14.bn)(txParams.maxWitnesses),
3420
- maxGasPerTx: (0, import_math14.bn)(txParams.maxGasPerTx),
3421
- maxScriptLength: (0, import_math14.bn)(scriptParams.maxScriptLength),
3422
- maxScriptDataLength: (0, import_math14.bn)(scriptParams.maxScriptDataLength),
3423
- maxStorageSlots: (0, import_math14.bn)(contractParams.maxStorageSlots),
3424
- maxPredicateLength: (0, import_math14.bn)(predicateParams.maxPredicateLength),
3425
- maxPredicateDataLength: (0, import_math14.bn)(predicateParams.maxPredicateDataLength),
3426
- maxGasPerPredicate: (0, import_math14.bn)(predicateParams.maxGasPerPredicate),
3427
- gasPriceFactor: (0, import_math14.bn)(feeParams.gasPriceFactor),
3428
- gasPerByte: (0, import_math14.bn)(feeParams.gasPerByte),
3429
- maxMessageDataLength: (0, import_math14.bn)(predicateParams.maxMessageDataLength),
3430
- chainId: (0, import_math14.bn)(consensusParameters.chainId),
3497
+ contractMaxSize: (0, import_math15.bn)(contractParams.contractMaxSize),
3498
+ maxInputs: (0, import_math15.bn)(txParams.maxInputs),
3499
+ maxOutputs: (0, import_math15.bn)(txParams.maxOutputs),
3500
+ maxWitnesses: (0, import_math15.bn)(txParams.maxWitnesses),
3501
+ maxGasPerTx: (0, import_math15.bn)(txParams.maxGasPerTx),
3502
+ maxScriptLength: (0, import_math15.bn)(scriptParams.maxScriptLength),
3503
+ maxScriptDataLength: (0, import_math15.bn)(scriptParams.maxScriptDataLength),
3504
+ maxStorageSlots: (0, import_math15.bn)(contractParams.maxStorageSlots),
3505
+ maxPredicateLength: (0, import_math15.bn)(predicateParams.maxPredicateLength),
3506
+ maxPredicateDataLength: (0, import_math15.bn)(predicateParams.maxPredicateDataLength),
3507
+ maxGasPerPredicate: (0, import_math15.bn)(predicateParams.maxGasPerPredicate),
3508
+ gasPriceFactor: (0, import_math15.bn)(feeParams.gasPriceFactor),
3509
+ gasPerByte: (0, import_math15.bn)(feeParams.gasPerByte),
3510
+ maxMessageDataLength: (0, import_math15.bn)(predicateParams.maxMessageDataLength),
3511
+ chainId: (0, import_math15.bn)(consensusParameters.chainId),
3431
3512
  gasCosts
3432
3513
  },
3433
3514
  gasCosts,
3434
3515
  latestBlock: {
3435
3516
  id: latestBlock.id,
3436
- height: (0, import_math14.bn)(latestBlock.header.height),
3517
+ height: (0, import_math15.bn)(latestBlock.header.height),
3437
3518
  time: latestBlock.header.time,
3438
3519
  transactions: latestBlock.transactions.map((i) => ({
3439
3520
  id: i.id
@@ -3503,8 +3584,8 @@ var _Provider = class {
3503
3584
  getChain() {
3504
3585
  const chain = _Provider.chainInfoCache[this.url];
3505
3586
  if (!chain) {
3506
- throw new import_errors13.FuelError(
3507
- import_errors13.ErrorCode.CHAIN_INFO_CACHE_EMPTY,
3587
+ throw new import_errors14.FuelError(
3588
+ import_errors14.ErrorCode.CHAIN_INFO_CACHE_EMPTY,
3508
3589
  "Chain info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
3509
3590
  );
3510
3591
  }
@@ -3516,8 +3597,8 @@ var _Provider = class {
3516
3597
  getNode() {
3517
3598
  const node = _Provider.nodeInfoCache[this.url];
3518
3599
  if (!node) {
3519
- throw new import_errors13.FuelError(
3520
- import_errors13.ErrorCode.NODE_INFO_CACHE_EMPTY,
3600
+ throw new import_errors14.FuelError(
3601
+ import_errors14.ErrorCode.NODE_INFO_CACHE_EMPTY,
3521
3602
  "Node info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
3522
3603
  );
3523
3604
  }
@@ -3564,8 +3645,8 @@ var _Provider = class {
3564
3645
  static ensureClientVersionIsSupported(nodeInfo) {
3565
3646
  const { isMajorSupported, isMinorSupported, supportedVersion } = (0, import_versions.checkFuelCoreVersionCompatibility)(nodeInfo.nodeVersion);
3566
3647
  if (!isMajorSupported || !isMinorSupported) {
3567
- throw new import_errors13.FuelError(
3568
- import_errors13.FuelError.CODES.UNSUPPORTED_FUEL_CLIENT_VERSION,
3648
+ throw new import_errors14.FuelError(
3649
+ import_errors14.FuelError.CODES.UNSUPPORTED_FUEL_CLIENT_VERSION,
3569
3650
  `Fuel client version: ${nodeInfo.nodeVersion}, Supported version: ${supportedVersion}`
3570
3651
  );
3571
3652
  }
@@ -3628,7 +3709,7 @@ var _Provider = class {
3628
3709
  */
3629
3710
  async getBlockNumber() {
3630
3711
  const { chain } = await this.operations.getChain();
3631
- return (0, import_math14.bn)(chain.latestBlock.header.height, 10);
3712
+ return (0, import_math15.bn)(chain.latestBlock.header.height, 10);
3632
3713
  }
3633
3714
  /**
3634
3715
  * Returns the chain information.
@@ -3638,9 +3719,9 @@ var _Provider = class {
3638
3719
  async fetchNode() {
3639
3720
  const { nodeInfo } = await this.operations.getNodeInfo();
3640
3721
  const processedNodeInfo = {
3641
- maxDepth: (0, import_math14.bn)(nodeInfo.maxDepth),
3642
- maxTx: (0, import_math14.bn)(nodeInfo.maxTx),
3643
- minGasPrice: (0, import_math14.bn)(nodeInfo.minGasPrice),
3722
+ maxDepth: (0, import_math15.bn)(nodeInfo.maxDepth),
3723
+ maxTx: (0, import_math15.bn)(nodeInfo.maxTx),
3724
+ minGasPrice: (0, import_math15.bn)(nodeInfo.minGasPrice),
3644
3725
  nodeVersion: nodeInfo.nodeVersion,
3645
3726
  utxoValidation: nodeInfo.utxoValidation,
3646
3727
  vmBacktrace: nodeInfo.vmBacktrace,
@@ -3686,17 +3767,17 @@ var _Provider = class {
3686
3767
  if (estimateTxDependencies) {
3687
3768
  await this.estimateTxDependencies(transactionRequest);
3688
3769
  }
3689
- const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
3770
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
3690
3771
  let abis;
3691
- if (transactionRequest.type === import_transactions17.TransactionType.Script) {
3772
+ if (transactionRequest.type === import_transactions18.TransactionType.Script) {
3692
3773
  abis = transactionRequest.abis;
3693
3774
  }
3694
3775
  if (awaitExecution) {
3695
3776
  const subscription = this.operations.submitAndAwait({ encodedTransaction });
3696
3777
  for await (const { submitAndAwait } of subscription) {
3697
3778
  if (submitAndAwait.type === "SqueezedOutStatus") {
3698
- throw new import_errors13.FuelError(
3699
- import_errors13.ErrorCode.TRANSACTION_SQUEEZED_OUT,
3779
+ throw new import_errors14.FuelError(
3780
+ import_errors14.ErrorCode.TRANSACTION_SQUEEZED_OUT,
3700
3781
  `Transaction Squeezed Out with reason: ${submitAndAwait.reason}`
3701
3782
  );
3702
3783
  }
@@ -3729,7 +3810,7 @@ var _Provider = class {
3729
3810
  if (estimateTxDependencies) {
3730
3811
  return this.estimateTxDependencies(transactionRequest);
3731
3812
  }
3732
- const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
3813
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
3733
3814
  const { dryRun: gqlReceipts } = await this.operations.dryRun({
3734
3815
  encodedTransaction,
3735
3816
  utxoValidation: utxoValidation || false
@@ -3748,13 +3829,13 @@ var _Provider = class {
3748
3829
  async estimatePredicates(transactionRequest) {
3749
3830
  const shouldEstimatePredicates = Boolean(
3750
3831
  transactionRequest.inputs.find(
3751
- (input) => "predicate" in input && input.predicate && !(0, import_utils23.equalBytes)((0, import_utils22.arrayify)(input.predicate), (0, import_utils22.arrayify)("0x")) && new import_math14.BN(input.predicateGasUsed).isZero()
3832
+ (input) => "predicate" in input && input.predicate && !(0, import_utils24.equalBytes)((0, import_utils23.arrayify)(input.predicate), (0, import_utils23.arrayify)("0x")) && new import_math15.BN(input.predicateGasUsed).isZero()
3752
3833
  )
3753
3834
  );
3754
3835
  if (!shouldEstimatePredicates) {
3755
3836
  return transactionRequest;
3756
3837
  }
3757
- const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
3838
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
3758
3839
  const response = await this.operations.estimatePredicates({
3759
3840
  encodedTransaction
3760
3841
  });
@@ -3763,7 +3844,7 @@ var _Provider = class {
3763
3844
  } = response;
3764
3845
  if (inputs) {
3765
3846
  inputs.forEach((input, index) => {
3766
- if ("predicateGasUsed" in input && (0, import_math14.bn)(input.predicateGasUsed).gt(0)) {
3847
+ if ("predicateGasUsed" in input && (0, import_math15.bn)(input.predicateGasUsed).gt(0)) {
3767
3848
  transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
3768
3849
  }
3769
3850
  });
@@ -3784,7 +3865,7 @@ var _Provider = class {
3784
3865
  * @returns A promise.
3785
3866
  */
3786
3867
  async estimateTxDependencies(transactionRequest) {
3787
- if (transactionRequest.type === import_transactions17.TransactionType.Create) {
3868
+ if (transactionRequest.type === import_transactions18.TransactionType.Create) {
3788
3869
  return {
3789
3870
  receipts: [],
3790
3871
  outputVariables: 0,
@@ -3797,7 +3878,7 @@ var _Provider = class {
3797
3878
  let outputVariables = 0;
3798
3879
  for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
3799
3880
  const { dryRun: gqlReceipts } = await this.operations.dryRun({
3800
- encodedTransaction: (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes()),
3881
+ encodedTransaction: (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes()),
3801
3882
  utxoValidation: false
3802
3883
  });
3803
3884
  receipts = gqlReceipts.map(processGqlReceipt);
@@ -3820,6 +3901,36 @@ var _Provider = class {
3820
3901
  missingContractIds
3821
3902
  };
3822
3903
  }
3904
+ /**
3905
+ * Estimates the transaction gas and fee based on the provided transaction request.
3906
+ * @param transactionRequest - The transaction request object.
3907
+ * @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
3908
+ */
3909
+ estimateTxGasAndFee(params) {
3910
+ const { transactionRequest } = params;
3911
+ const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
3912
+ const chainInfo = this.getChain();
3913
+ const gasPrice = transactionRequest.gasPrice.eq(0) ? minGasPrice : transactionRequest.gasPrice;
3914
+ transactionRequest.gasPrice = gasPrice;
3915
+ const minGas = transactionRequest.calculateMinGas(chainInfo);
3916
+ const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
3917
+ if (transactionRequest.type === import_transactions18.TransactionType.Script) {
3918
+ if (transactionRequest.gasLimit.eq(0)) {
3919
+ transactionRequest.gasLimit = minGas;
3920
+ transactionRequest.gasLimit = maxGasPerTx.sub(
3921
+ transactionRequest.calculateMaxGas(chainInfo, minGas)
3922
+ );
3923
+ }
3924
+ }
3925
+ const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
3926
+ const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
3927
+ return {
3928
+ minGas,
3929
+ minFee,
3930
+ maxGas,
3931
+ maxFee
3932
+ };
3933
+ }
3823
3934
  /**
3824
3935
  * Executes a signed transaction without applying the states changes
3825
3936
  * on the chain.
@@ -3835,7 +3946,7 @@ var _Provider = class {
3835
3946
  if (estimateTxDependencies) {
3836
3947
  return this.estimateTxDependencies(transactionRequest);
3837
3948
  }
3838
- const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
3949
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
3839
3950
  const { dryRun: gqlReceipts } = await this.operations.dryRun({
3840
3951
  encodedTransaction,
3841
3952
  utxoValidation: true
@@ -3867,17 +3978,16 @@ var _Provider = class {
3867
3978
  signatureCallback
3868
3979
  } = {}) {
3869
3980
  const txRequestClone = (0, import_ramda3.clone)(transactionRequestify(transactionRequestLike));
3870
- const chainInfo = this.getChain();
3871
- const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
3872
- const gasPrice = (0, import_math14.max)(txRequestClone.gasPrice, minGasPrice);
3873
- const isScriptTransaction = txRequestClone.type === import_transactions17.TransactionType.Script;
3981
+ const { minGasPrice } = this.getGasConfig();
3982
+ const setGasPrice = (0, import_math15.max)(txRequestClone.gasPrice, minGasPrice);
3983
+ const isScriptTransaction = txRequestClone.type === import_transactions18.TransactionType.Script;
3874
3984
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
3875
3985
  const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
3876
3986
  txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
3987
+ if (isScriptTransaction) {
3988
+ txRequestClone.gasLimit = (0, import_math15.bn)(0);
3989
+ }
3877
3990
  if (estimatePredicates) {
3878
- if (isScriptTransaction) {
3879
- txRequestClone.gasLimit = (0, import_math14.bn)(0);
3880
- }
3881
3991
  if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
3882
3992
  resourcesOwner.populateTransactionPredicateData(txRequestClone);
3883
3993
  }
@@ -3886,36 +3996,34 @@ var _Provider = class {
3886
3996
  if (signatureCallback && isScriptTransaction) {
3887
3997
  await signatureCallback(txRequestClone);
3888
3998
  }
3889
- const minGas = txRequestClone.calculateMinGas(chainInfo);
3890
- const maxGas = txRequestClone.calculateMaxGas(chainInfo, minGas);
3999
+ let { maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
4000
+ transactionRequest: txRequestClone
4001
+ });
3891
4002
  let receipts = [];
3892
4003
  let missingContractIds = [];
3893
4004
  let outputVariables = 0;
4005
+ let gasUsed = (0, import_math15.bn)(0);
3894
4006
  if (isScriptTransaction && estimateTxDependencies) {
3895
- txRequestClone.gasPrice = (0, import_math14.bn)(0);
3896
- txRequestClone.gasLimit = (0, import_math14.bn)(maxGasPerTx.sub(maxGas).toNumber() * 0.9);
4007
+ txRequestClone.gasPrice = (0, import_math15.bn)(0);
3897
4008
  const result = await this.estimateTxDependencies(txRequestClone);
3898
4009
  receipts = result.receipts;
3899
4010
  outputVariables = result.outputVariables;
3900
4011
  missingContractIds = result.missingContractIds;
4012
+ gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
4013
+ txRequestClone.gasLimit = gasUsed;
4014
+ txRequestClone.gasPrice = setGasPrice;
4015
+ ({ maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
4016
+ transactionRequest: txRequestClone
4017
+ }));
3901
4018
  }
3902
- const gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : minGas;
3903
- const usedFee = calculatePriceWithFactor(
3904
- gasUsed,
3905
- gasPrice,
3906
- gasPriceFactor
3907
- ).normalizeZeroToOne();
3908
- const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
3909
- const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
3910
4019
  return {
3911
4020
  requiredQuantities: allQuantities,
3912
4021
  receipts,
3913
4022
  gasUsed,
3914
4023
  minGasPrice,
3915
- gasPrice,
4024
+ gasPrice: setGasPrice,
3916
4025
  minGas,
3917
4026
  maxGas,
3918
- usedFee,
3919
4027
  minFee,
3920
4028
  maxFee,
3921
4029
  estimatedInputs: txRequestClone.inputs,
@@ -3949,17 +4057,17 @@ var _Provider = class {
3949
4057
  const result = await this.operations.getCoins({
3950
4058
  first: 10,
3951
4059
  ...paginationArgs,
3952
- filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils22.hexlify)(assetId) }
4060
+ filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils23.hexlify)(assetId) }
3953
4061
  });
3954
4062
  const coins = result.coins.edges.map((edge) => edge.node);
3955
4063
  return coins.map((coin) => ({
3956
4064
  id: coin.utxoId,
3957
4065
  assetId: coin.assetId,
3958
- amount: (0, import_math14.bn)(coin.amount),
4066
+ amount: (0, import_math15.bn)(coin.amount),
3959
4067
  owner: import_address3.Address.fromAddressOrString(coin.owner),
3960
- maturity: (0, import_math14.bn)(coin.maturity).toNumber(),
3961
- blockCreated: (0, import_math14.bn)(coin.blockCreated),
3962
- txCreatedIdx: (0, import_math14.bn)(coin.txCreatedIdx)
4068
+ maturity: (0, import_math15.bn)(coin.maturity).toNumber(),
4069
+ blockCreated: (0, import_math15.bn)(coin.blockCreated),
4070
+ txCreatedIdx: (0, import_math15.bn)(coin.txCreatedIdx)
3963
4071
  }));
3964
4072
  }
3965
4073
  /**
@@ -3973,19 +4081,19 @@ var _Provider = class {
3973
4081
  async getResourcesToSpend(owner, quantities, excludedIds) {
3974
4082
  const ownerAddress = import_address3.Address.fromAddressOrString(owner);
3975
4083
  const excludeInput = {
3976
- messages: excludedIds?.messages?.map((nonce) => (0, import_utils22.hexlify)(nonce)) || [],
3977
- utxos: excludedIds?.utxos?.map((id) => (0, import_utils22.hexlify)(id)) || []
4084
+ messages: excludedIds?.messages?.map((nonce) => (0, import_utils23.hexlify)(nonce)) || [],
4085
+ utxos: excludedIds?.utxos?.map((id) => (0, import_utils23.hexlify)(id)) || []
3978
4086
  };
3979
4087
  if (this.cache) {
3980
4088
  const uniqueUtxos = new Set(
3981
- excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0, import_utils22.hexlify)(id)))
4089
+ excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0, import_utils23.hexlify)(id)))
3982
4090
  );
3983
4091
  excludeInput.utxos = Array.from(uniqueUtxos);
3984
4092
  }
3985
4093
  const coinsQuery = {
3986
4094
  owner: ownerAddress.toB256(),
3987
4095
  queryPerAsset: quantities.map(coinQuantityfy).map(({ assetId, amount, max: maxPerAsset }) => ({
3988
- assetId: (0, import_utils22.hexlify)(assetId),
4096
+ assetId: (0, import_utils23.hexlify)(assetId),
3989
4097
  amount: amount.toString(10),
3990
4098
  max: maxPerAsset ? maxPerAsset.toString(10) : void 0
3991
4099
  })),
@@ -3996,9 +4104,9 @@ var _Provider = class {
3996
4104
  switch (coin.__typename) {
3997
4105
  case "MessageCoin":
3998
4106
  return {
3999
- amount: (0, import_math14.bn)(coin.amount),
4107
+ amount: (0, import_math15.bn)(coin.amount),
4000
4108
  assetId: coin.assetId,
4001
- daHeight: (0, import_math14.bn)(coin.daHeight),
4109
+ daHeight: (0, import_math15.bn)(coin.daHeight),
4002
4110
  sender: import_address3.Address.fromAddressOrString(coin.sender),
4003
4111
  recipient: import_address3.Address.fromAddressOrString(coin.recipient),
4004
4112
  nonce: coin.nonce
@@ -4006,12 +4114,12 @@ var _Provider = class {
4006
4114
  case "Coin":
4007
4115
  return {
4008
4116
  id: coin.utxoId,
4009
- amount: (0, import_math14.bn)(coin.amount),
4117
+ amount: (0, import_math15.bn)(coin.amount),
4010
4118
  assetId: coin.assetId,
4011
4119
  owner: import_address3.Address.fromAddressOrString(coin.owner),
4012
- maturity: (0, import_math14.bn)(coin.maturity).toNumber(),
4013
- blockCreated: (0, import_math14.bn)(coin.blockCreated),
4014
- txCreatedIdx: (0, import_math14.bn)(coin.txCreatedIdx)
4120
+ maturity: (0, import_math15.bn)(coin.maturity).toNumber(),
4121
+ blockCreated: (0, import_math15.bn)(coin.blockCreated),
4122
+ txCreatedIdx: (0, import_math15.bn)(coin.txCreatedIdx)
4015
4123
  };
4016
4124
  default:
4017
4125
  return null;
@@ -4028,13 +4136,13 @@ var _Provider = class {
4028
4136
  async getBlock(idOrHeight) {
4029
4137
  let variables;
4030
4138
  if (typeof idOrHeight === "number") {
4031
- variables = { height: (0, import_math14.bn)(idOrHeight).toString(10) };
4139
+ variables = { height: (0, import_math15.bn)(idOrHeight).toString(10) };
4032
4140
  } else if (idOrHeight === "latest") {
4033
4141
  variables = { height: (await this.getBlockNumber()).toString(10) };
4034
4142
  } else if (idOrHeight.length === 66) {
4035
4143
  variables = { blockId: idOrHeight };
4036
4144
  } else {
4037
- variables = { blockId: (0, import_math14.bn)(idOrHeight).toString(10) };
4145
+ variables = { blockId: (0, import_math15.bn)(idOrHeight).toString(10) };
4038
4146
  }
4039
4147
  const { block } = await this.operations.getBlock(variables);
4040
4148
  if (!block) {
@@ -4042,7 +4150,7 @@ var _Provider = class {
4042
4150
  }
4043
4151
  return {
4044
4152
  id: block.id,
4045
- height: (0, import_math14.bn)(block.header.height),
4153
+ height: (0, import_math15.bn)(block.header.height),
4046
4154
  time: block.header.time,
4047
4155
  transactionIds: block.transactions.map((tx) => tx.id)
4048
4156
  };
@@ -4057,7 +4165,7 @@ var _Provider = class {
4057
4165
  const { blocks: fetchedData } = await this.operations.getBlocks(params);
4058
4166
  const blocks = fetchedData.edges.map(({ node: block }) => ({
4059
4167
  id: block.id,
4060
- height: (0, import_math14.bn)(block.header.height),
4168
+ height: (0, import_math15.bn)(block.header.height),
4061
4169
  time: block.header.time,
4062
4170
  transactionIds: block.transactions.map((tx) => tx.id)
4063
4171
  }));
@@ -4072,7 +4180,7 @@ var _Provider = class {
4072
4180
  async getBlockWithTransactions(idOrHeight) {
4073
4181
  let variables;
4074
4182
  if (typeof idOrHeight === "number") {
4075
- variables = { blockHeight: (0, import_math14.bn)(idOrHeight).toString(10) };
4183
+ variables = { blockHeight: (0, import_math15.bn)(idOrHeight).toString(10) };
4076
4184
  } else if (idOrHeight === "latest") {
4077
4185
  variables = { blockHeight: (await this.getBlockNumber()).toString() };
4078
4186
  } else {
@@ -4084,11 +4192,11 @@ var _Provider = class {
4084
4192
  }
4085
4193
  return {
4086
4194
  id: block.id,
4087
- height: (0, import_math14.bn)(block.header.height, 10),
4195
+ height: (0, import_math15.bn)(block.header.height, 10),
4088
4196
  time: block.header.time,
4089
4197
  transactionIds: block.transactions.map((tx) => tx.id),
4090
4198
  transactions: block.transactions.map(
4091
- (tx) => new import_transactions17.TransactionCoder().decode((0, import_utils22.arrayify)(tx.rawPayload), 0)?.[0]
4199
+ (tx) => new import_transactions18.TransactionCoder().decode((0, import_utils23.arrayify)(tx.rawPayload), 0)?.[0]
4092
4200
  )
4093
4201
  };
4094
4202
  }
@@ -4103,8 +4211,8 @@ var _Provider = class {
4103
4211
  if (!transaction) {
4104
4212
  return null;
4105
4213
  }
4106
- return new import_transactions17.TransactionCoder().decode(
4107
- (0, import_utils22.arrayify)(transaction.rawPayload),
4214
+ return new import_transactions18.TransactionCoder().decode(
4215
+ (0, import_utils23.arrayify)(transaction.rawPayload),
4108
4216
  0
4109
4217
  )?.[0];
4110
4218
  }
@@ -4131,9 +4239,9 @@ var _Provider = class {
4131
4239
  async getContractBalance(contractId, assetId) {
4132
4240
  const { contractBalance } = await this.operations.getContractBalance({
4133
4241
  contract: import_address3.Address.fromAddressOrString(contractId).toB256(),
4134
- asset: (0, import_utils22.hexlify)(assetId)
4242
+ asset: (0, import_utils23.hexlify)(assetId)
4135
4243
  });
4136
- return (0, import_math14.bn)(contractBalance.amount, 10);
4244
+ return (0, import_math15.bn)(contractBalance.amount, 10);
4137
4245
  }
4138
4246
  /**
4139
4247
  * Returns the balance for the given owner for the given asset ID.
@@ -4145,9 +4253,9 @@ var _Provider = class {
4145
4253
  async getBalance(owner, assetId) {
4146
4254
  const { balance } = await this.operations.getBalance({
4147
4255
  owner: import_address3.Address.fromAddressOrString(owner).toB256(),
4148
- assetId: (0, import_utils22.hexlify)(assetId)
4256
+ assetId: (0, import_utils23.hexlify)(assetId)
4149
4257
  });
4150
- return (0, import_math14.bn)(balance.amount, 10);
4258
+ return (0, import_math15.bn)(balance.amount, 10);
4151
4259
  }
4152
4260
  /**
4153
4261
  * Returns balances for the given owner.
@@ -4165,7 +4273,7 @@ var _Provider = class {
4165
4273
  const balances = result.balances.edges.map((edge) => edge.node);
4166
4274
  return balances.map((balance) => ({
4167
4275
  assetId: balance.assetId,
4168
- amount: (0, import_math14.bn)(balance.amount)
4276
+ amount: (0, import_math15.bn)(balance.amount)
4169
4277
  }));
4170
4278
  }
4171
4279
  /**
@@ -4183,19 +4291,19 @@ var _Provider = class {
4183
4291
  });
4184
4292
  const messages = result.messages.edges.map((edge) => edge.node);
4185
4293
  return messages.map((message) => ({
4186
- messageId: import_transactions17.InputMessageCoder.getMessageId({
4294
+ messageId: import_transactions18.InputMessageCoder.getMessageId({
4187
4295
  sender: message.sender,
4188
4296
  recipient: message.recipient,
4189
4297
  nonce: message.nonce,
4190
- amount: (0, import_math14.bn)(message.amount),
4298
+ amount: (0, import_math15.bn)(message.amount),
4191
4299
  data: message.data
4192
4300
  }),
4193
4301
  sender: import_address3.Address.fromAddressOrString(message.sender),
4194
4302
  recipient: import_address3.Address.fromAddressOrString(message.recipient),
4195
4303
  nonce: message.nonce,
4196
- amount: (0, import_math14.bn)(message.amount),
4197
- data: import_transactions17.InputMessageCoder.decodeData(message.data),
4198
- daHeight: (0, import_math14.bn)(message.daHeight)
4304
+ amount: (0, import_math15.bn)(message.amount),
4305
+ data: import_transactions18.InputMessageCoder.decodeData(message.data),
4306
+ daHeight: (0, import_math15.bn)(message.daHeight)
4199
4307
  }));
4200
4308
  }
4201
4309
  /**
@@ -4213,8 +4321,8 @@ var _Provider = class {
4213
4321
  nonce
4214
4322
  };
4215
4323
  if (commitBlockId && commitBlockHeight) {
4216
- throw new import_errors13.FuelError(
4217
- import_errors13.ErrorCode.INVALID_INPUT_PARAMETERS,
4324
+ throw new import_errors14.FuelError(
4325
+ import_errors14.ErrorCode.INVALID_INPUT_PARAMETERS,
4218
4326
  "commitBlockId and commitBlockHeight cannot be used together"
4219
4327
  );
4220
4328
  }
@@ -4248,41 +4356,41 @@ var _Provider = class {
4248
4356
  } = result.messageProof;
4249
4357
  return {
4250
4358
  messageProof: {
4251
- proofIndex: (0, import_math14.bn)(messageProof.proofIndex),
4359
+ proofIndex: (0, import_math15.bn)(messageProof.proofIndex),
4252
4360
  proofSet: messageProof.proofSet
4253
4361
  },
4254
4362
  blockProof: {
4255
- proofIndex: (0, import_math14.bn)(blockProof.proofIndex),
4363
+ proofIndex: (0, import_math15.bn)(blockProof.proofIndex),
4256
4364
  proofSet: blockProof.proofSet
4257
4365
  },
4258
4366
  messageBlockHeader: {
4259
4367
  id: messageBlockHeader.id,
4260
- daHeight: (0, import_math14.bn)(messageBlockHeader.daHeight),
4261
- transactionsCount: (0, import_math14.bn)(messageBlockHeader.transactionsCount),
4368
+ daHeight: (0, import_math15.bn)(messageBlockHeader.daHeight),
4369
+ transactionsCount: (0, import_math15.bn)(messageBlockHeader.transactionsCount),
4262
4370
  transactionsRoot: messageBlockHeader.transactionsRoot,
4263
- height: (0, import_math14.bn)(messageBlockHeader.height),
4371
+ height: (0, import_math15.bn)(messageBlockHeader.height),
4264
4372
  prevRoot: messageBlockHeader.prevRoot,
4265
4373
  time: messageBlockHeader.time,
4266
4374
  applicationHash: messageBlockHeader.applicationHash,
4267
4375
  messageReceiptRoot: messageBlockHeader.messageReceiptRoot,
4268
- messageReceiptCount: (0, import_math14.bn)(messageBlockHeader.messageReceiptCount)
4376
+ messageReceiptCount: (0, import_math15.bn)(messageBlockHeader.messageReceiptCount)
4269
4377
  },
4270
4378
  commitBlockHeader: {
4271
4379
  id: commitBlockHeader.id,
4272
- daHeight: (0, import_math14.bn)(commitBlockHeader.daHeight),
4273
- transactionsCount: (0, import_math14.bn)(commitBlockHeader.transactionsCount),
4380
+ daHeight: (0, import_math15.bn)(commitBlockHeader.daHeight),
4381
+ transactionsCount: (0, import_math15.bn)(commitBlockHeader.transactionsCount),
4274
4382
  transactionsRoot: commitBlockHeader.transactionsRoot,
4275
- height: (0, import_math14.bn)(commitBlockHeader.height),
4383
+ height: (0, import_math15.bn)(commitBlockHeader.height),
4276
4384
  prevRoot: commitBlockHeader.prevRoot,
4277
4385
  time: commitBlockHeader.time,
4278
4386
  applicationHash: commitBlockHeader.applicationHash,
4279
4387
  messageReceiptRoot: commitBlockHeader.messageReceiptRoot,
4280
- messageReceiptCount: (0, import_math14.bn)(commitBlockHeader.messageReceiptCount)
4388
+ messageReceiptCount: (0, import_math15.bn)(commitBlockHeader.messageReceiptCount)
4281
4389
  },
4282
4390
  sender: import_address3.Address.fromAddressOrString(sender),
4283
4391
  recipient: import_address3.Address.fromAddressOrString(recipient),
4284
4392
  nonce,
4285
- amount: (0, import_math14.bn)(amount),
4393
+ amount: (0, import_math15.bn)(amount),
4286
4394
  data
4287
4395
  };
4288
4396
  }
@@ -4305,10 +4413,10 @@ var _Provider = class {
4305
4413
  */
4306
4414
  async produceBlocks(amount, startTime) {
4307
4415
  const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
4308
- blocksToProduce: (0, import_math14.bn)(amount).toString(10),
4309
- startTimestamp: startTime ? import_utils22.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
4416
+ blocksToProduce: (0, import_math15.bn)(amount).toString(10),
4417
+ startTimestamp: startTime ? import_utils23.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
4310
4418
  });
4311
- return (0, import_math14.bn)(latestBlockHeight);
4419
+ return (0, import_math15.bn)(latestBlockHeight);
4312
4420
  }
4313
4421
  // eslint-disable-next-line @typescript-eslint/require-await
4314
4422
  async getTransactionResponse(transactionId) {
@@ -4322,7 +4430,7 @@ cacheInputs_fn = function(inputs) {
4322
4430
  return;
4323
4431
  }
4324
4432
  inputs.forEach((input) => {
4325
- if (input.type === import_transactions17.InputType.Coin) {
4433
+ if (input.type === import_transactions18.InputType.Coin) {
4326
4434
  this.cache?.set(input.id);
4327
4435
  }
4328
4436
  });
@@ -4331,10 +4439,10 @@ __publicField(Provider, "chainInfoCache", {});
4331
4439
  __publicField(Provider, "nodeInfoCache", {});
4332
4440
 
4333
4441
  // src/providers/transaction-summary/get-transaction-summary.ts
4334
- var import_errors14 = require("@fuel-ts/errors");
4335
- var import_math15 = require("@fuel-ts/math");
4336
- var import_transactions18 = require("@fuel-ts/transactions");
4337
- var import_utils25 = require("@fuel-ts/utils");
4442
+ var import_errors15 = require("@fuel-ts/errors");
4443
+ var import_math16 = require("@fuel-ts/math");
4444
+ var import_transactions19 = require("@fuel-ts/transactions");
4445
+ var import_utils26 = require("@fuel-ts/utils");
4338
4446
 
4339
4447
  // src/providers/chains.ts
4340
4448
  var CHAIN_IDS = {
@@ -4382,18 +4490,18 @@ var assets = [
4382
4490
  ];
4383
4491
 
4384
4492
  // src/utils/formatTransferToContractScriptData.ts
4385
- var import_abi_coder4 = require("@fuel-ts/abi-coder");
4386
- var import_math16 = require("@fuel-ts/math");
4387
- var import_utils26 = require("@fuel-ts/utils");
4493
+ var import_abi_coder6 = require("@fuel-ts/abi-coder");
4494
+ var import_math17 = require("@fuel-ts/math");
4495
+ var import_utils27 = require("@fuel-ts/utils");
4388
4496
  var asm = __toESM(require("@fuels/vm-asm"));
4389
4497
  var formatTransferToContractScriptData = (params) => {
4390
4498
  const { assetId, amountToTransfer, hexlifiedContractId } = params;
4391
- const numberCoder = new import_abi_coder4.BigNumberCoder("u64");
4392
- const encoded = numberCoder.encode(new import_math16.BN(amountToTransfer).toNumber());
4499
+ const numberCoder = new import_abi_coder6.BigNumberCoder("u64");
4500
+ const encoded = numberCoder.encode(new import_math17.BN(amountToTransfer).toNumber());
4393
4501
  const scriptData = Uint8Array.from([
4394
- ...(0, import_utils26.arrayify)(hexlifiedContractId),
4502
+ ...(0, import_utils27.arrayify)(hexlifiedContractId),
4395
4503
  ...encoded,
4396
- ...(0, import_utils26.arrayify)(assetId)
4504
+ ...(0, import_utils27.arrayify)(assetId)
4397
4505
  ]);
4398
4506
  return scriptData;
4399
4507
  };
@@ -4449,7 +4557,7 @@ var Account = class extends import_interfaces.AbstractAccount {
4449
4557
  */
4450
4558
  get provider() {
4451
4559
  if (!this._provider) {
4452
- throw new import_errors15.FuelError(import_errors15.ErrorCode.MISSING_PROVIDER, "Provider not set");
4560
+ throw new import_errors16.FuelError(import_errors16.ErrorCode.MISSING_PROVIDER, "Provider not set");
4453
4561
  }
4454
4562
  return this._provider;
4455
4563
  }
@@ -4501,8 +4609,8 @@ var Account = class extends import_interfaces.AbstractAccount {
4501
4609
  if (!hasNextPage) {
4502
4610
  break;
4503
4611
  }
4504
- throw new import_errors15.FuelError(
4505
- import_errors15.ErrorCode.NOT_SUPPORTED,
4612
+ throw new import_errors16.FuelError(
4613
+ import_errors16.ErrorCode.NOT_SUPPORTED,
4506
4614
  `Wallets containing more than ${pageSize} coins exceed the current supported limit.`
4507
4615
  );
4508
4616
  }
@@ -4527,8 +4635,8 @@ var Account = class extends import_interfaces.AbstractAccount {
4527
4635
  if (!hasNextPage) {
4528
4636
  break;
4529
4637
  }
4530
- throw new import_errors15.FuelError(
4531
- import_errors15.ErrorCode.NOT_SUPPORTED,
4638
+ throw new import_errors16.FuelError(
4639
+ import_errors16.ErrorCode.NOT_SUPPORTED,
4532
4640
  `Wallets containing more than ${pageSize} messages exceed the current supported limit.`
4533
4641
  );
4534
4642
  }
@@ -4540,7 +4648,7 @@ var Account = class extends import_interfaces.AbstractAccount {
4540
4648
  * @param assetId - The asset ID to check the balance for.
4541
4649
  * @returns A promise that resolves to the balance amount.
4542
4650
  */
4543
- async getBalance(assetId = import_configs11.BaseAssetId) {
4651
+ async getBalance(assetId = import_configs12.BaseAssetId) {
4544
4652
  const amount = await this.provider.getBalance(this.address, assetId);
4545
4653
  return amount;
4546
4654
  }
@@ -4563,8 +4671,8 @@ var Account = class extends import_interfaces.AbstractAccount {
4563
4671
  if (!hasNextPage) {
4564
4672
  break;
4565
4673
  }
4566
- throw new import_errors15.FuelError(
4567
- import_errors15.ErrorCode.NOT_SUPPORTED,
4674
+ throw new import_errors16.FuelError(
4675
+ import_errors16.ErrorCode.NOT_SUPPORTED,
4568
4676
  `Wallets containing more than ${pageSize} balances exceed the current supported limit.`
4569
4677
  );
4570
4678
  }
@@ -4580,15 +4688,15 @@ var Account = class extends import_interfaces.AbstractAccount {
4580
4688
  */
4581
4689
  async fund(request, coinQuantities, fee) {
4582
4690
  const updatedQuantities = addAmountToAsset({
4583
- amount: (0, import_math17.bn)(fee),
4584
- assetId: import_configs11.BaseAssetId,
4691
+ amount: (0, import_math18.bn)(fee),
4692
+ assetId: import_configs12.BaseAssetId,
4585
4693
  coinQuantities
4586
4694
  });
4587
4695
  const quantitiesDict = {};
4588
4696
  updatedQuantities.forEach(({ amount, assetId }) => {
4589
4697
  quantitiesDict[assetId] = {
4590
4698
  required: amount,
4591
- owned: (0, import_math17.bn)(0)
4699
+ owned: (0, import_math18.bn)(0)
4592
4700
  };
4593
4701
  });
4594
4702
  const cachedUtxos = [];
@@ -4601,12 +4709,12 @@ var Account = class extends import_interfaces.AbstractAccount {
4601
4709
  if (isCoin2) {
4602
4710
  const assetId = String(input.assetId);
4603
4711
  if (input.owner === owner && quantitiesDict[assetId]) {
4604
- const amount = (0, import_math17.bn)(input.amount);
4712
+ const amount = (0, import_math18.bn)(input.amount);
4605
4713
  quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
4606
4714
  cachedUtxos.push(input.id);
4607
4715
  }
4608
- } else if (input.recipient === owner && input.amount && quantitiesDict[import_configs11.BaseAssetId]) {
4609
- quantitiesDict[import_configs11.BaseAssetId].owned = quantitiesDict[import_configs11.BaseAssetId].owned.add(input.amount);
4716
+ } else if (input.recipient === owner && input.amount && quantitiesDict[import_configs12.BaseAssetId]) {
4717
+ quantitiesDict[import_configs12.BaseAssetId].owned = quantitiesDict[import_configs12.BaseAssetId].owned.add(input.amount);
4610
4718
  cachedMessages.push(input.nonce);
4611
4719
  }
4612
4720
  }
@@ -4638,7 +4746,7 @@ var Account = class extends import_interfaces.AbstractAccount {
4638
4746
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
4639
4747
  * @returns A promise that resolves to the prepared transaction request.
4640
4748
  */
4641
- async createTransfer(destination, amount, assetId = import_configs11.BaseAssetId, txParams = {}) {
4749
+ async createTransfer(destination, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
4642
4750
  const { minGasPrice } = this.provider.getGasConfig();
4643
4751
  const params = { gasPrice: minGasPrice, ...txParams };
4644
4752
  const request = new ScriptTransactionRequest(params);
@@ -4647,8 +4755,8 @@ var Account = class extends import_interfaces.AbstractAccount {
4647
4755
  estimateTxDependencies: true,
4648
4756
  resourcesOwner: this
4649
4757
  });
4650
- request.gasPrice = (0, import_math17.bn)(txParams.gasPrice ?? minGasPrice);
4651
- request.gasLimit = (0, import_math17.bn)(txParams.gasLimit ?? gasUsed);
4758
+ request.gasPrice = (0, import_math18.bn)(txParams.gasPrice ?? minGasPrice);
4759
+ request.gasLimit = (0, import_math18.bn)(txParams.gasLimit ?? gasUsed);
4652
4760
  this.validateGas({
4653
4761
  gasUsed,
4654
4762
  gasPrice: request.gasPrice,
@@ -4668,10 +4776,10 @@ var Account = class extends import_interfaces.AbstractAccount {
4668
4776
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
4669
4777
  * @returns A promise that resolves to the transaction response.
4670
4778
  */
4671
- async transfer(destination, amount, assetId = import_configs11.BaseAssetId, txParams = {}) {
4672
- if ((0, import_math17.bn)(amount).lte(0)) {
4673
- throw new import_errors15.FuelError(
4674
- import_errors15.ErrorCode.INVALID_TRANSFER_AMOUNT,
4779
+ async transfer(destination, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
4780
+ if ((0, import_math18.bn)(amount).lte(0)) {
4781
+ throw new import_errors16.FuelError(
4782
+ import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
4675
4783
  "Transfer amount must be a positive number."
4676
4784
  );
4677
4785
  }
@@ -4687,10 +4795,10 @@ var Account = class extends import_interfaces.AbstractAccount {
4687
4795
  * @param txParams - The optional transaction parameters.
4688
4796
  * @returns A promise that resolves to the transaction response.
4689
4797
  */
4690
- async transferToContract(contractId, amount, assetId = import_configs11.BaseAssetId, txParams = {}) {
4691
- if ((0, import_math17.bn)(amount).lte(0)) {
4692
- throw new import_errors15.FuelError(
4693
- import_errors15.ErrorCode.INVALID_TRANSFER_AMOUNT,
4798
+ async transferToContract(contractId, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
4799
+ if ((0, import_math18.bn)(amount).lte(0)) {
4800
+ throw new import_errors16.FuelError(
4801
+ import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
4694
4802
  "Transfer amount must be a positive number."
4695
4803
  );
4696
4804
  }
@@ -4699,7 +4807,7 @@ var Account = class extends import_interfaces.AbstractAccount {
4699
4807
  const params = { gasPrice: minGasPrice, ...txParams };
4700
4808
  const { script, scriptData } = await assembleTransferToContractScript({
4701
4809
  hexlifiedContractId: contractAddress.toB256(),
4702
- amountToTransfer: (0, import_math17.bn)(amount),
4810
+ amountToTransfer: (0, import_math18.bn)(amount),
4703
4811
  assetId
4704
4812
  });
4705
4813
  const request = new ScriptTransactionRequest({
@@ -4710,9 +4818,9 @@ var Account = class extends import_interfaces.AbstractAccount {
4710
4818
  request.addContractInputAndOutput(contractAddress);
4711
4819
  const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
4712
4820
  request,
4713
- [{ amount: (0, import_math17.bn)(amount), assetId: String(assetId) }]
4821
+ [{ amount: (0, import_math18.bn)(amount), assetId: String(assetId) }]
4714
4822
  );
4715
- request.gasLimit = (0, import_math17.bn)(params.gasLimit ?? gasUsed);
4823
+ request.gasLimit = (0, import_math18.bn)(params.gasLimit ?? gasUsed);
4716
4824
  this.validateGas({
4717
4825
  gasUsed,
4718
4826
  gasPrice: request.gasPrice,
@@ -4733,25 +4841,25 @@ var Account = class extends import_interfaces.AbstractAccount {
4733
4841
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
4734
4842
  const { minGasPrice } = this.provider.getGasConfig();
4735
4843
  const recipientAddress = import_address4.Address.fromAddressOrString(recipient);
4736
- const recipientDataArray = (0, import_utils27.arrayify)(
4844
+ const recipientDataArray = (0, import_utils28.arrayify)(
4737
4845
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
4738
4846
  );
4739
- const amountDataArray = (0, import_utils27.arrayify)(
4740
- "0x".concat((0, import_math17.bn)(amount).toHex().substring(2).padStart(16, "0"))
4847
+ const amountDataArray = (0, import_utils28.arrayify)(
4848
+ "0x".concat((0, import_math18.bn)(amount).toHex().substring(2).padStart(16, "0"))
4741
4849
  );
4742
4850
  const script = new Uint8Array([
4743
- ...(0, import_utils27.arrayify)(withdrawScript.bytes),
4851
+ ...(0, import_utils28.arrayify)(withdrawScript.bytes),
4744
4852
  ...recipientDataArray,
4745
4853
  ...amountDataArray
4746
4854
  ]);
4747
4855
  const params = { script, gasPrice: minGasPrice, ...txParams };
4748
4856
  const request = new ScriptTransactionRequest(params);
4749
- const forwardingQuantities = [{ amount: (0, import_math17.bn)(amount), assetId: import_configs11.BaseAssetId }];
4857
+ const forwardingQuantities = [{ amount: (0, import_math18.bn)(amount), assetId: import_configs12.BaseAssetId }];
4750
4858
  const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
4751
4859
  request,
4752
4860
  forwardingQuantities
4753
4861
  );
4754
- request.gasLimit = (0, import_math17.bn)(params.gasLimit ?? gasUsed);
4862
+ request.gasLimit = (0, import_math18.bn)(params.gasLimit ?? gasUsed);
4755
4863
  this.validateGas({
4756
4864
  gasUsed,
4757
4865
  gasPrice: request.gasPrice,
@@ -4763,7 +4871,7 @@ var Account = class extends import_interfaces.AbstractAccount {
4763
4871
  }
4764
4872
  async signMessage(message) {
4765
4873
  if (!this._connector) {
4766
- throw new import_errors15.FuelError(import_errors15.ErrorCode.MISSING_CONNECTOR, "A connector is required to sign messages.");
4874
+ throw new import_errors16.FuelError(import_errors16.ErrorCode.MISSING_CONNECTOR, "A connector is required to sign messages.");
4767
4875
  }
4768
4876
  return this._connector.signMessage(this.address.toString(), message);
4769
4877
  }
@@ -4775,8 +4883,8 @@ var Account = class extends import_interfaces.AbstractAccount {
4775
4883
  */
4776
4884
  async signTransaction(transactionRequestLike) {
4777
4885
  if (!this._connector) {
4778
- throw new import_errors15.FuelError(
4779
- import_errors15.ErrorCode.MISSING_CONNECTOR,
4886
+ throw new import_errors16.FuelError(
4887
+ import_errors16.ErrorCode.MISSING_CONNECTOR,
4780
4888
  "A connector is required to sign transactions."
4781
4889
  );
4782
4890
  }
@@ -4823,14 +4931,14 @@ var Account = class extends import_interfaces.AbstractAccount {
4823
4931
  minGasPrice
4824
4932
  }) {
4825
4933
  if (minGasPrice.gt(gasPrice)) {
4826
- throw new import_errors15.FuelError(
4827
- import_errors15.ErrorCode.GAS_PRICE_TOO_LOW,
4934
+ throw new import_errors16.FuelError(
4935
+ import_errors16.ErrorCode.GAS_PRICE_TOO_LOW,
4828
4936
  `Gas price '${gasPrice}' is lower than the required: '${minGasPrice}'.`
4829
4937
  );
4830
4938
  }
4831
4939
  if (gasUsed.gt(gasLimit)) {
4832
- throw new import_errors15.FuelError(
4833
- import_errors15.ErrorCode.GAS_LIMIT_TOO_LOW,
4940
+ throw new import_errors16.FuelError(
4941
+ import_errors16.ErrorCode.GAS_LIMIT_TOO_LOW,
4834
4942
  `Gas limit '${gasLimit}' is lower than the required: '${gasUsed}'.`
4835
4943
  );
4836
4944
  }
@@ -4839,10 +4947,10 @@ var Account = class extends import_interfaces.AbstractAccount {
4839
4947
 
4840
4948
  // src/signer/signer.ts
4841
4949
  var import_address5 = require("@fuel-ts/address");
4842
- var import_crypto = require("@fuel-ts/crypto");
4950
+ var import_crypto2 = require("@fuel-ts/crypto");
4843
4951
  var import_hasher2 = require("@fuel-ts/hasher");
4844
- var import_math18 = require("@fuel-ts/math");
4845
- var import_utils28 = require("@fuel-ts/utils");
4952
+ var import_math19 = require("@fuel-ts/math");
4953
+ var import_utils29 = require("@fuel-ts/utils");
4846
4954
  var import_secp256k1 = require("@noble/curves/secp256k1");
4847
4955
  var Signer = class {
4848
4956
  address;
@@ -4861,10 +4969,10 @@ var Signer = class {
4861
4969
  privateKey = `0x${privateKey}`;
4862
4970
  }
4863
4971
  }
4864
- const privateKeyBytes = (0, import_math18.toBytes)(privateKey, 32);
4865
- this.privateKey = (0, import_utils28.hexlify)(privateKeyBytes);
4866
- this.publicKey = (0, import_utils28.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
4867
- this.compressedPublicKey = (0, import_utils28.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
4972
+ const privateKeyBytes = (0, import_math19.toBytes)(privateKey, 32);
4973
+ this.privateKey = (0, import_utils29.hexlify)(privateKeyBytes);
4974
+ this.publicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
4975
+ this.compressedPublicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
4868
4976
  this.address = import_address5.Address.fromPublicKey(this.publicKey);
4869
4977
  }
4870
4978
  /**
@@ -4878,11 +4986,11 @@ var Signer = class {
4878
4986
  * @returns hashed signature
4879
4987
  */
4880
4988
  sign(data) {
4881
- const signature = import_secp256k1.secp256k1.sign((0, import_utils28.arrayify)(data), (0, import_utils28.arrayify)(this.privateKey));
4882
- const r = (0, import_math18.toBytes)(`0x${signature.r.toString(16)}`, 32);
4883
- const s = (0, import_math18.toBytes)(`0x${signature.s.toString(16)}`, 32);
4989
+ const signature = import_secp256k1.secp256k1.sign((0, import_utils29.arrayify)(data), (0, import_utils29.arrayify)(this.privateKey));
4990
+ const r = (0, import_math19.toBytes)(`0x${signature.r.toString(16)}`, 32);
4991
+ const s = (0, import_math19.toBytes)(`0x${signature.s.toString(16)}`, 32);
4884
4992
  s[0] |= (signature.recovery || 0) << 7;
4885
- return (0, import_utils28.hexlify)((0, import_utils28.concat)([r, s]));
4993
+ return (0, import_utils29.hexlify)((0, import_utils29.concat)([r, s]));
4886
4994
  }
4887
4995
  /**
4888
4996
  * Add point on the current elliptic curve
@@ -4891,8 +4999,8 @@ var Signer = class {
4891
4999
  * @returns compressed point on the curve
4892
5000
  */
4893
5001
  addPoint(point) {
4894
- const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(this.compressedPublicKey));
4895
- const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(point));
5002
+ const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(this.compressedPublicKey));
5003
+ const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(point));
4896
5004
  const result = p0.add(p1);
4897
5005
  return `0x${result.toHex(true)}`;
4898
5006
  }
@@ -4904,16 +5012,16 @@ var Signer = class {
4904
5012
  * @returns public key from signature from the
4905
5013
  */
4906
5014
  static recoverPublicKey(data, signature) {
4907
- const signedMessageBytes = (0, import_utils28.arrayify)(signature);
5015
+ const signedMessageBytes = (0, import_utils29.arrayify)(signature);
4908
5016
  const r = signedMessageBytes.slice(0, 32);
4909
5017
  const s = signedMessageBytes.slice(32, 64);
4910
5018
  const recoveryParam = (s[0] & 128) >> 7;
4911
5019
  s[0] &= 127;
4912
- const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils28.hexlify)(r)), BigInt((0, import_utils28.hexlify)(s))).addRecoveryBit(
5020
+ const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils29.hexlify)(r)), BigInt((0, import_utils29.hexlify)(s))).addRecoveryBit(
4913
5021
  recoveryParam
4914
5022
  );
4915
- const publicKey = sig.recoverPublicKey((0, import_utils28.arrayify)(data)).toRawBytes(false).slice(1);
4916
- return (0, import_utils28.hexlify)(publicKey);
5023
+ const publicKey = sig.recoverPublicKey((0, import_utils29.arrayify)(data)).toRawBytes(false).slice(1);
5024
+ return (0, import_utils29.hexlify)(publicKey);
4917
5025
  }
4918
5026
  /**
4919
5027
  * Recover the address from a signature performed with [`sign`](#sign).
@@ -4932,7 +5040,7 @@ var Signer = class {
4932
5040
  * @returns random 32-byte hashed
4933
5041
  */
4934
5042
  static generatePrivateKey(entropy) {
4935
- return entropy ? (0, import_hasher2.hash)((0, import_utils28.concat)([(0, import_crypto.randomBytes)(32), (0, import_utils28.arrayify)(entropy)])) : (0, import_crypto.randomBytes)(32);
5043
+ return entropy ? (0, import_hasher2.hash)((0, import_utils29.concat)([(0, import_crypto2.randomBytes)(32), (0, import_utils29.arrayify)(entropy)])) : (0, import_crypto2.randomBytes)(32);
4936
5044
  }
4937
5045
  /**
4938
5046
  * Extended publicKey from a compact publicKey
@@ -4941,16 +5049,16 @@ var Signer = class {
4941
5049
  * @returns extended publicKey
4942
5050
  */
4943
5051
  static extendPublicKey(publicKey) {
4944
- const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(publicKey));
4945
- return (0, import_utils28.hexlify)(point.toRawBytes(false).slice(1));
5052
+ const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(publicKey));
5053
+ return (0, import_utils29.hexlify)(point.toRawBytes(false).slice(1));
4946
5054
  }
4947
5055
  };
4948
5056
 
4949
5057
  // src/wallet/keystore-wallet.ts
4950
5058
  var import_address6 = require("@fuel-ts/address");
4951
- var import_crypto2 = require("@fuel-ts/crypto");
4952
- var import_errors16 = require("@fuel-ts/errors");
4953
- var import_utils29 = require("@fuel-ts/utils");
5059
+ var import_crypto3 = require("@fuel-ts/crypto");
5060
+ var import_errors17 = require("@fuel-ts/errors");
5061
+ var import_utils30 = require("@fuel-ts/utils");
4954
5062
  var import_uuid = require("uuid");
4955
5063
  var DEFAULT_KDF_PARAMS_LOG_N = 13;
4956
5064
  var DEFAULT_KDF_PARAMS_R = 8;
@@ -4964,22 +5072,22 @@ var removeHexPrefix = (hexString) => {
4964
5072
  return hexString;
4965
5073
  };
4966
5074
  async function encryptKeystoreWallet(privateKey, address, password) {
4967
- const privateKeyBuffer = (0, import_crypto2.bufferFromString)(removeHexPrefix(privateKey), "hex");
5075
+ const privateKeyBuffer = (0, import_crypto3.bufferFromString)(removeHexPrefix(privateKey), "hex");
4968
5076
  const ownerAddress = import_address6.Address.fromAddressOrString(address);
4969
- const salt = (0, import_crypto2.randomBytes)(DEFAULT_KEY_SIZE);
4970
- const key = (0, import_crypto2.scrypt)({
4971
- password: (0, import_crypto2.bufferFromString)(password),
5077
+ const salt = (0, import_crypto3.randomBytes)(DEFAULT_KEY_SIZE);
5078
+ const key = (0, import_crypto3.scrypt)({
5079
+ password: (0, import_crypto3.bufferFromString)(password),
4972
5080
  salt,
4973
5081
  dklen: DEFAULT_KEY_SIZE,
4974
5082
  n: 2 ** DEFAULT_KDF_PARAMS_LOG_N,
4975
5083
  r: DEFAULT_KDF_PARAMS_R,
4976
5084
  p: DEFAULT_KDF_PARAMS_P
4977
5085
  });
4978
- const iv = (0, import_crypto2.randomBytes)(DEFAULT_IV_SIZE);
4979
- const ciphertext = await (0, import_crypto2.encryptJsonWalletData)(privateKeyBuffer, key, iv);
5086
+ const iv = (0, import_crypto3.randomBytes)(DEFAULT_IV_SIZE);
5087
+ const ciphertext = await (0, import_crypto3.encryptJsonWalletData)(privateKeyBuffer, key, iv);
4980
5088
  const data = Uint8Array.from([...key.subarray(16, 32), ...ciphertext]);
4981
- const macHashUint8Array = (0, import_crypto2.keccak256)(data);
4982
- const mac = (0, import_crypto2.stringFromBuffer)(macHashUint8Array, "hex");
5089
+ const macHashUint8Array = (0, import_crypto3.keccak256)(data);
5090
+ const mac = (0, import_crypto3.stringFromBuffer)(macHashUint8Array, "hex");
4983
5091
  const keystore = {
4984
5092
  id: (0, import_uuid.v4)(),
4985
5093
  version: 3,
@@ -4987,15 +5095,15 @@ async function encryptKeystoreWallet(privateKey, address, password) {
4987
5095
  crypto: {
4988
5096
  cipher: "aes-128-ctr",
4989
5097
  mac,
4990
- cipherparams: { iv: (0, import_crypto2.stringFromBuffer)(iv, "hex") },
4991
- ciphertext: (0, import_crypto2.stringFromBuffer)(ciphertext, "hex"),
5098
+ cipherparams: { iv: (0, import_crypto3.stringFromBuffer)(iv, "hex") },
5099
+ ciphertext: (0, import_crypto3.stringFromBuffer)(ciphertext, "hex"),
4992
5100
  kdf: "scrypt",
4993
5101
  kdfparams: {
4994
5102
  dklen: DEFAULT_KEY_SIZE,
4995
5103
  n: 2 ** DEFAULT_KDF_PARAMS_LOG_N,
4996
5104
  p: DEFAULT_KDF_PARAMS_P,
4997
5105
  r: DEFAULT_KDF_PARAMS_R,
4998
- salt: (0, import_crypto2.stringFromBuffer)(salt, "hex")
5106
+ salt: (0, import_crypto3.stringFromBuffer)(salt, "hex")
4999
5107
  }
5000
5108
  }
5001
5109
  };
@@ -5011,11 +5119,11 @@ async function decryptKeystoreWallet(jsonWallet, password) {
5011
5119
  kdfparams: { dklen, n, r, p, salt }
5012
5120
  }
5013
5121
  } = keystoreWallet;
5014
- const ciphertextBuffer = (0, import_crypto2.bufferFromString)(ciphertext, "hex");
5015
- const ivBuffer = (0, import_crypto2.bufferFromString)(iv, "hex");
5016
- const saltBuffer = (0, import_crypto2.bufferFromString)(salt, "hex");
5017
- const passwordBuffer = (0, import_crypto2.bufferFromString)(password);
5018
- const key = (0, import_crypto2.scrypt)({
5122
+ const ciphertextBuffer = (0, import_crypto3.bufferFromString)(ciphertext, "hex");
5123
+ const ivBuffer = (0, import_crypto3.bufferFromString)(iv, "hex");
5124
+ const saltBuffer = (0, import_crypto3.bufferFromString)(salt, "hex");
5125
+ const passwordBuffer = (0, import_crypto3.bufferFromString)(password);
5126
+ const key = (0, import_crypto3.scrypt)({
5019
5127
  password: passwordBuffer,
5020
5128
  salt: saltBuffer,
5021
5129
  n,
@@ -5024,16 +5132,16 @@ async function decryptKeystoreWallet(jsonWallet, password) {
5024
5132
  dklen
5025
5133
  });
5026
5134
  const data = Uint8Array.from([...key.subarray(16, 32), ...ciphertextBuffer]);
5027
- const macHashUint8Array = (0, import_crypto2.keccak256)(data);
5028
- const macHash = (0, import_crypto2.stringFromBuffer)(macHashUint8Array, "hex");
5135
+ const macHashUint8Array = (0, import_crypto3.keccak256)(data);
5136
+ const macHash = (0, import_crypto3.stringFromBuffer)(macHashUint8Array, "hex");
5029
5137
  if (mac !== macHash) {
5030
- throw new import_errors16.FuelError(
5031
- import_errors16.ErrorCode.INVALID_PASSWORD,
5138
+ throw new import_errors17.FuelError(
5139
+ import_errors17.ErrorCode.INVALID_PASSWORD,
5032
5140
  "Failed to decrypt the keystore wallet, the provided password is incorrect."
5033
5141
  );
5034
5142
  }
5035
- const buffer = await (0, import_crypto2.decryptJsonWalletData)(ciphertextBuffer, key, ivBuffer);
5036
- const privateKey = (0, import_utils29.hexlify)(buffer);
5143
+ const buffer = await (0, import_crypto3.decryptJsonWalletData)(ciphertextBuffer, key, ivBuffer);
5144
+ const privateKey = (0, import_utils30.hexlify)(buffer);
5037
5145
  return privateKey;
5038
5146
  }
5039
5147
 
@@ -5078,7 +5186,7 @@ var BaseWalletUnlocked = class extends Account {
5078
5186
  */
5079
5187
  async signMessage(message) {
5080
5188
  const signedMessage = await this.signer().sign((0, import_hasher3.hashMessage)(message));
5081
- return (0, import_utils30.hexlify)(signedMessage);
5189
+ return (0, import_utils31.hexlify)(signedMessage);
5082
5190
  }
5083
5191
  /**
5084
5192
  * Signs a transaction with the wallet's private key.
@@ -5091,7 +5199,7 @@ var BaseWalletUnlocked = class extends Account {
5091
5199
  const chainId = this.provider.getChainId();
5092
5200
  const hashedTransaction = transactionRequest.getTransactionId(chainId);
5093
5201
  const signature = await this.signer().sign(hashedTransaction);
5094
- return (0, import_utils30.hexlify)(signature);
5202
+ return (0, import_utils31.hexlify)(signature);
5095
5203
  }
5096
5204
  /**
5097
5205
  * Populates a transaction with the witnesses signature.
@@ -5150,17 +5258,17 @@ var BaseWalletUnlocked = class extends Account {
5150
5258
  __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
5151
5259
 
5152
5260
  // src/hdwallet/hdwallet.ts
5153
- var import_errors19 = require("@fuel-ts/errors");
5261
+ var import_errors20 = require("@fuel-ts/errors");
5154
5262
  var import_hasher6 = require("@fuel-ts/hasher");
5155
- var import_math19 = require("@fuel-ts/math");
5156
- var import_utils34 = require("@fuel-ts/utils");
5263
+ var import_math20 = require("@fuel-ts/math");
5264
+ var import_utils35 = require("@fuel-ts/utils");
5157
5265
  var import_ethers3 = require("ethers");
5158
5266
 
5159
5267
  // src/mnemonic/mnemonic.ts
5160
- var import_crypto3 = require("@fuel-ts/crypto");
5161
- var import_errors18 = require("@fuel-ts/errors");
5268
+ var import_crypto4 = require("@fuel-ts/crypto");
5269
+ var import_errors19 = require("@fuel-ts/errors");
5162
5270
  var import_hasher5 = require("@fuel-ts/hasher");
5163
- var import_utils32 = require("@fuel-ts/utils");
5271
+ var import_utils33 = require("@fuel-ts/utils");
5164
5272
  var import_ethers2 = require("ethers");
5165
5273
 
5166
5274
  // src/wordlists/words/english.ts
@@ -7216,9 +7324,9 @@ var english = [
7216
7324
  ];
7217
7325
 
7218
7326
  // src/mnemonic/utils.ts
7219
- var import_errors17 = require("@fuel-ts/errors");
7327
+ var import_errors18 = require("@fuel-ts/errors");
7220
7328
  var import_hasher4 = require("@fuel-ts/hasher");
7221
- var import_utils31 = require("@fuel-ts/utils");
7329
+ var import_utils32 = require("@fuel-ts/utils");
7222
7330
  function toUtf8Bytes(stri) {
7223
7331
  const str = stri.normalize("NFKD");
7224
7332
  const result = [];
@@ -7233,8 +7341,8 @@ function toUtf8Bytes(stri) {
7233
7341
  i += 1;
7234
7342
  const c2 = str.charCodeAt(i);
7235
7343
  if (i >= str.length || (c2 & 64512) !== 56320) {
7236
- throw new import_errors17.FuelError(
7237
- import_errors17.ErrorCode.INVALID_INPUT_PARAMETERS,
7344
+ throw new import_errors18.FuelError(
7345
+ import_errors18.ErrorCode.INVALID_INPUT_PARAMETERS,
7238
7346
  "Invalid UTF-8 in the input string."
7239
7347
  );
7240
7348
  }
@@ -7285,20 +7393,20 @@ function entropyToMnemonicIndices(entropy) {
7285
7393
  }
7286
7394
  }
7287
7395
  const checksumBits = entropy.length / 4;
7288
- const checksum = (0, import_utils31.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
7396
+ const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
7289
7397
  indices[indices.length - 1] <<= checksumBits;
7290
7398
  indices[indices.length - 1] |= checksum >> 8 - checksumBits;
7291
7399
  return indices;
7292
7400
  }
7293
7401
  function mnemonicWordsToEntropy(words, wordlist) {
7294
7402
  const size = Math.ceil(11 * words.length / 8);
7295
- const entropy = (0, import_utils31.arrayify)(new Uint8Array(size));
7403
+ const entropy = (0, import_utils32.arrayify)(new Uint8Array(size));
7296
7404
  let offset = 0;
7297
7405
  for (let i = 0; i < words.length; i += 1) {
7298
7406
  const index = wordlist.indexOf(words[i].normalize("NFKD"));
7299
7407
  if (index === -1) {
7300
- throw new import_errors17.FuelError(
7301
- import_errors17.ErrorCode.INVALID_MNEMONIC,
7408
+ throw new import_errors18.FuelError(
7409
+ import_errors18.ErrorCode.INVALID_MNEMONIC,
7302
7410
  `Invalid mnemonic: the word '${words[i]}' is not found in the provided wordlist.`
7303
7411
  );
7304
7412
  }
@@ -7312,10 +7420,10 @@ function mnemonicWordsToEntropy(words, wordlist) {
7312
7420
  const entropyBits = 32 * words.length / 3;
7313
7421
  const checksumBits = words.length / 3;
7314
7422
  const checksumMask = getUpperMask(checksumBits);
7315
- const checksum = (0, import_utils31.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
7423
+ const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
7316
7424
  if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
7317
- throw new import_errors17.FuelError(
7318
- import_errors17.ErrorCode.INVALID_CHECKSUM,
7425
+ throw new import_errors18.FuelError(
7426
+ import_errors18.ErrorCode.INVALID_CHECKSUM,
7319
7427
  "Checksum validation failed for the provided mnemonic."
7320
7428
  );
7321
7429
  }
@@ -7329,16 +7437,16 @@ var TestnetPRV = "0x04358394";
7329
7437
  var MNEMONIC_SIZES = [12, 15, 18, 21, 24];
7330
7438
  function assertWordList(wordlist) {
7331
7439
  if (wordlist.length !== 2048) {
7332
- throw new import_errors18.FuelError(
7333
- import_errors18.ErrorCode.INVALID_WORD_LIST,
7440
+ throw new import_errors19.FuelError(
7441
+ import_errors19.ErrorCode.INVALID_WORD_LIST,
7334
7442
  `Expected word list length of 2048, but got ${wordlist.length}.`
7335
7443
  );
7336
7444
  }
7337
7445
  }
7338
7446
  function assertEntropy(entropy) {
7339
7447
  if (entropy.length % 4 !== 0 || entropy.length < 16 || entropy.length > 32) {
7340
- throw new import_errors18.FuelError(
7341
- import_errors18.ErrorCode.INVALID_ENTROPY,
7448
+ throw new import_errors19.FuelError(
7449
+ import_errors19.ErrorCode.INVALID_ENTROPY,
7342
7450
  `Entropy should be between 16 and 32 bytes and a multiple of 4, but got ${entropy.length} bytes.`
7343
7451
  );
7344
7452
  }
@@ -7348,7 +7456,7 @@ function assertMnemonic(words) {
7348
7456
  const errorMsg = `Invalid mnemonic size. Expected one of [${MNEMONIC_SIZES.join(
7349
7457
  ", "
7350
7458
  )}] words, but got ${words.length}.`;
7351
- throw new import_errors18.FuelError(import_errors18.ErrorCode.INVALID_MNEMONIC, errorMsg);
7459
+ throw new import_errors19.FuelError(import_errors19.ErrorCode.INVALID_MNEMONIC, errorMsg);
7352
7460
  }
7353
7461
  }
7354
7462
  var Mnemonic = class {
@@ -7387,7 +7495,7 @@ var Mnemonic = class {
7387
7495
  static mnemonicToEntropy(phrase, wordlist = english) {
7388
7496
  const words = getWords(phrase);
7389
7497
  assertMnemonic(words);
7390
- return (0, import_utils32.hexlify)(mnemonicWordsToEntropy(words, wordlist));
7498
+ return (0, import_utils33.hexlify)(mnemonicWordsToEntropy(words, wordlist));
7391
7499
  }
7392
7500
  /**
7393
7501
  * @param entropy - Entropy source to the mnemonic phrase.
@@ -7395,7 +7503,7 @@ var Mnemonic = class {
7395
7503
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
7396
7504
  */
7397
7505
  static entropyToMnemonic(entropy, wordlist = english) {
7398
- const entropyBytes = (0, import_utils32.arrayify)(entropy);
7506
+ const entropyBytes = (0, import_utils33.arrayify)(entropy);
7399
7507
  assertWordList(wordlist);
7400
7508
  assertEntropy(entropyBytes);
7401
7509
  return entropyToMnemonicIndices(entropyBytes).map((i) => wordlist[i]).join(" ");
@@ -7464,14 +7572,14 @@ var Mnemonic = class {
7464
7572
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
7465
7573
  */
7466
7574
  static masterKeysFromSeed(seed) {
7467
- const seedArray = (0, import_utils32.arrayify)(seed);
7575
+ const seedArray = (0, import_utils33.arrayify)(seed);
7468
7576
  if (seedArray.length < 16 || seedArray.length > 64) {
7469
- throw new import_errors18.FuelError(
7470
- import_errors18.ErrorCode.INVALID_SEED,
7577
+ throw new import_errors19.FuelError(
7578
+ import_errors19.ErrorCode.INVALID_SEED,
7471
7579
  `Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
7472
7580
  );
7473
7581
  }
7474
- return (0, import_utils32.arrayify)((0, import_ethers2.computeHmac)("sha512", MasterSecret, seedArray));
7582
+ return (0, import_utils33.arrayify)((0, import_ethers2.computeHmac)("sha512", MasterSecret, seedArray));
7475
7583
  }
7476
7584
  /**
7477
7585
  * Get the extendKey as defined on BIP-32 from the provided seed
@@ -7482,22 +7590,22 @@ var Mnemonic = class {
7482
7590
  */
7483
7591
  static seedToExtendedKey(seed, testnet = false) {
7484
7592
  const masterKey = Mnemonic.masterKeysFromSeed(seed);
7485
- const prefix = (0, import_utils32.arrayify)(testnet ? TestnetPRV : MainnetPRV);
7593
+ const prefix = (0, import_utils33.arrayify)(testnet ? TestnetPRV : MainnetPRV);
7486
7594
  const depth = "0x00";
7487
7595
  const fingerprint = "0x00000000";
7488
7596
  const index = "0x00000000";
7489
7597
  const chainCode = masterKey.slice(32);
7490
7598
  const privateKey = masterKey.slice(0, 32);
7491
- const extendedKey = (0, import_utils32.concat)([
7599
+ const extendedKey = (0, import_utils33.concat)([
7492
7600
  prefix,
7493
7601
  depth,
7494
7602
  fingerprint,
7495
7603
  index,
7496
7604
  chainCode,
7497
- (0, import_utils32.concat)(["0x00", privateKey])
7605
+ (0, import_utils33.concat)(["0x00", privateKey])
7498
7606
  ]);
7499
7607
  const checksum = (0, import_ethers2.dataSlice)((0, import_hasher5.sha256)((0, import_hasher5.sha256)(extendedKey)), 0, 4);
7500
- return (0, import_ethers2.encodeBase58)((0, import_utils32.concat)([extendedKey, checksum]));
7608
+ return (0, import_ethers2.encodeBase58)((0, import_utils33.concat)([extendedKey, checksum]));
7501
7609
  }
7502
7610
  /**
7503
7611
  * Create a new mnemonic using a randomly generated number as entropy.
@@ -7512,7 +7620,7 @@ var Mnemonic = class {
7512
7620
  * @returns A randomly generated mnemonic
7513
7621
  */
7514
7622
  static generate(size = 32, extraEntropy = "") {
7515
- 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);
7623
+ const entropy = extraEntropy ? (0, import_hasher5.sha256)((0, import_utils33.concat)([(0, import_crypto4.randomBytes)(size), (0, import_utils33.arrayify)(extraEntropy)])) : (0, import_crypto4.randomBytes)(size);
7516
7624
  return Mnemonic.entropyToMnemonic(entropy);
7517
7625
  }
7518
7626
  };
@@ -7520,12 +7628,12 @@ var mnemonic_default = Mnemonic;
7520
7628
 
7521
7629
  // src/hdwallet/hdwallet.ts
7522
7630
  var HARDENED_INDEX = 2147483648;
7523
- var MainnetPRV2 = (0, import_utils34.hexlify)("0x0488ade4");
7524
- var MainnetPUB = (0, import_utils34.hexlify)("0x0488b21e");
7525
- var TestnetPRV2 = (0, import_utils34.hexlify)("0x04358394");
7526
- var TestnetPUB = (0, import_utils34.hexlify)("0x043587cf");
7631
+ var MainnetPRV2 = (0, import_utils35.hexlify)("0x0488ade4");
7632
+ var MainnetPUB = (0, import_utils35.hexlify)("0x0488b21e");
7633
+ var TestnetPRV2 = (0, import_utils35.hexlify)("0x04358394");
7634
+ var TestnetPUB = (0, import_utils35.hexlify)("0x043587cf");
7527
7635
  function base58check(data) {
7528
- 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)]));
7636
+ return (0, import_ethers3.encodeBase58)((0, import_utils35.concat)([data, (0, import_ethers3.dataSlice)((0, import_hasher6.sha256)((0, import_hasher6.sha256)(data)), 0, 4)]));
7529
7637
  }
7530
7638
  function getExtendedKeyPrefix(isPublic = false, testnet = false) {
7531
7639
  if (isPublic) {
@@ -7534,17 +7642,17 @@ function getExtendedKeyPrefix(isPublic = false, testnet = false) {
7534
7642
  return testnet ? TestnetPRV2 : MainnetPRV2;
7535
7643
  }
7536
7644
  function isPublicExtendedKey(extendedKey) {
7537
- return [MainnetPUB, TestnetPUB].includes((0, import_utils34.hexlify)(extendedKey.slice(0, 4)));
7645
+ return [MainnetPUB, TestnetPUB].includes((0, import_utils35.hexlify)(extendedKey.slice(0, 4)));
7538
7646
  }
7539
7647
  function isValidExtendedKey(extendedKey) {
7540
7648
  return [MainnetPRV2, TestnetPRV2, MainnetPUB, TestnetPUB].includes(
7541
- (0, import_utils34.hexlify)(extendedKey.slice(0, 4))
7649
+ (0, import_utils35.hexlify)(extendedKey.slice(0, 4))
7542
7650
  );
7543
7651
  }
7544
7652
  function parsePath(path2, depth = 0) {
7545
7653
  const components = path2.split("/");
7546
7654
  if (components.length === 0 || components[0] === "m" && depth !== 0) {
7547
- throw new import_errors19.FuelError(import_errors19.ErrorCode.HD_WALLET_ERROR, `invalid path - ${path2}`);
7655
+ throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, `invalid path - ${path2}`);
7548
7656
  }
7549
7657
  if (components[0] === "m") {
7550
7658
  components.shift();
@@ -7556,8 +7664,8 @@ function parsePath(path2, depth = 0) {
7556
7664
  var HDWallet = class {
7557
7665
  depth = 0;
7558
7666
  index = 0;
7559
- fingerprint = (0, import_utils34.hexlify)("0x00000000");
7560
- parentFingerprint = (0, import_utils34.hexlify)("0x00000000");
7667
+ fingerprint = (0, import_utils35.hexlify)("0x00000000");
7668
+ parentFingerprint = (0, import_utils35.hexlify)("0x00000000");
7561
7669
  privateKey;
7562
7670
  publicKey;
7563
7671
  chainCode;
@@ -7569,16 +7677,16 @@ var HDWallet = class {
7569
7677
  constructor(config) {
7570
7678
  if (config.privateKey) {
7571
7679
  const signer = new Signer(config.privateKey);
7572
- this.publicKey = (0, import_utils34.hexlify)(signer.compressedPublicKey);
7573
- this.privateKey = (0, import_utils34.hexlify)(config.privateKey);
7680
+ this.publicKey = (0, import_utils35.hexlify)(signer.compressedPublicKey);
7681
+ this.privateKey = (0, import_utils35.hexlify)(config.privateKey);
7574
7682
  } else {
7575
7683
  if (!config.publicKey) {
7576
- throw new import_errors19.FuelError(
7577
- import_errors19.ErrorCode.HD_WALLET_ERROR,
7684
+ throw new import_errors20.FuelError(
7685
+ import_errors20.ErrorCode.HD_WALLET_ERROR,
7578
7686
  "Both public and private Key cannot be missing. At least one should be provided."
7579
7687
  );
7580
7688
  }
7581
- this.publicKey = (0, import_utils34.hexlify)(config.publicKey);
7689
+ this.publicKey = (0, import_utils35.hexlify)(config.publicKey);
7582
7690
  }
7583
7691
  this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
7584
7692
  this.fingerprint = (0, import_ethers3.dataSlice)((0, import_ethers3.ripemd160)((0, import_hasher6.sha256)(this.publicKey)), 0, 4);
@@ -7597,28 +7705,28 @@ var HDWallet = class {
7597
7705
  * @returns A new instance of HDWallet on the derived index
7598
7706
  */
7599
7707
  deriveIndex(index) {
7600
- const privateKey = this.privateKey && (0, import_utils34.arrayify)(this.privateKey);
7601
- const publicKey = (0, import_utils34.arrayify)(this.publicKey);
7602
- const chainCode = (0, import_utils34.arrayify)(this.chainCode);
7708
+ const privateKey = this.privateKey && (0, import_utils35.arrayify)(this.privateKey);
7709
+ const publicKey = (0, import_utils35.arrayify)(this.publicKey);
7710
+ const chainCode = (0, import_utils35.arrayify)(this.chainCode);
7603
7711
  const data = new Uint8Array(37);
7604
7712
  if (index & HARDENED_INDEX) {
7605
7713
  if (!privateKey) {
7606
- throw new import_errors19.FuelError(
7607
- import_errors19.ErrorCode.HD_WALLET_ERROR,
7714
+ throw new import_errors20.FuelError(
7715
+ import_errors20.ErrorCode.HD_WALLET_ERROR,
7608
7716
  "Cannot derive a hardened index without a private Key."
7609
7717
  );
7610
7718
  }
7611
7719
  data.set(privateKey, 1);
7612
7720
  } else {
7613
- data.set((0, import_utils34.arrayify)(this.publicKey));
7721
+ data.set((0, import_utils35.arrayify)(this.publicKey));
7614
7722
  }
7615
- data.set((0, import_math19.toBytes)(index, 4), 33);
7616
- const bytes = (0, import_utils34.arrayify)((0, import_ethers3.computeHmac)("sha512", chainCode, data));
7723
+ data.set((0, import_math20.toBytes)(index, 4), 33);
7724
+ const bytes = (0, import_utils35.arrayify)((0, import_ethers3.computeHmac)("sha512", chainCode, data));
7617
7725
  const IL = bytes.slice(0, 32);
7618
7726
  const IR = bytes.slice(32);
7619
7727
  if (privateKey) {
7620
7728
  const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
7621
- const ki = (0, import_math19.bn)(IL).add(privateKey).mod(N).toBytes(32);
7729
+ const ki = (0, import_math20.bn)(IL).add(privateKey).mod(N).toBytes(32);
7622
7730
  return new HDWallet({
7623
7731
  privateKey: ki,
7624
7732
  chainCode: IR,
@@ -7627,7 +7735,7 @@ var HDWallet = class {
7627
7735
  parentFingerprint: this.fingerprint
7628
7736
  });
7629
7737
  }
7630
- const signer = new Signer((0, import_utils34.hexlify)(IL));
7738
+ const signer = new Signer((0, import_utils35.hexlify)(IL));
7631
7739
  const Ki = signer.addPoint(publicKey);
7632
7740
  return new HDWallet({
7633
7741
  publicKey: Ki,
@@ -7656,18 +7764,18 @@ var HDWallet = class {
7656
7764
  */
7657
7765
  toExtendedKey(isPublic = false, testnet = false) {
7658
7766
  if (this.depth >= 256) {
7659
- throw new import_errors19.FuelError(
7660
- import_errors19.ErrorCode.HD_WALLET_ERROR,
7767
+ throw new import_errors20.FuelError(
7768
+ import_errors20.ErrorCode.HD_WALLET_ERROR,
7661
7769
  `Exceeded max depth of 255. Current depth: ${this.depth}.`
7662
7770
  );
7663
7771
  }
7664
7772
  const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
7665
- const depth = (0, import_utils34.hexlify)(Uint8Array.from([this.depth]));
7773
+ const depth = (0, import_utils35.hexlify)(Uint8Array.from([this.depth]));
7666
7774
  const parentFingerprint = this.parentFingerprint;
7667
- const index = (0, import_math19.toHex)(this.index, 4);
7775
+ const index = (0, import_math20.toHex)(this.index, 4);
7668
7776
  const chainCode = this.chainCode;
7669
- const key = this.privateKey != null && !isPublic ? (0, import_utils34.concat)(["0x00", this.privateKey]) : this.publicKey;
7670
- const extendedKey = (0, import_utils34.arrayify)((0, import_utils34.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
7777
+ const key = this.privateKey != null && !isPublic ? (0, import_utils35.concat)(["0x00", this.privateKey]) : this.publicKey;
7778
+ const extendedKey = (0, import_utils35.arrayify)((0, import_utils35.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
7671
7779
  return base58check(extendedKey);
7672
7780
  }
7673
7781
  /**
@@ -7679,34 +7787,34 @@ var HDWallet = class {
7679
7787
  static fromSeed(seed) {
7680
7788
  const masterKey = mnemonic_default.masterKeysFromSeed(seed);
7681
7789
  return new HDWallet({
7682
- chainCode: (0, import_utils34.arrayify)(masterKey.slice(32)),
7683
- privateKey: (0, import_utils34.arrayify)(masterKey.slice(0, 32))
7790
+ chainCode: (0, import_utils35.arrayify)(masterKey.slice(32)),
7791
+ privateKey: (0, import_utils35.arrayify)(masterKey.slice(0, 32))
7684
7792
  });
7685
7793
  }
7686
7794
  static fromExtendedKey(extendedKey) {
7687
7795
  const decoded = (0, import_ethers3.toBeHex)((0, import_ethers3.decodeBase58)(extendedKey));
7688
- const bytes = (0, import_utils34.arrayify)(decoded);
7796
+ const bytes = (0, import_utils35.arrayify)(decoded);
7689
7797
  const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
7690
7798
  if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
7691
- throw new import_errors19.FuelError(import_errors19.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
7799
+ throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
7692
7800
  }
7693
7801
  if (!validChecksum) {
7694
- throw new import_errors19.FuelError(import_errors19.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
7802
+ throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
7695
7803
  }
7696
7804
  const depth = bytes[4];
7697
- const parentFingerprint = (0, import_utils34.hexlify)(bytes.slice(5, 9));
7698
- const index = parseInt((0, import_utils34.hexlify)(bytes.slice(9, 13)).substring(2), 16);
7699
- const chainCode = (0, import_utils34.hexlify)(bytes.slice(13, 45));
7805
+ const parentFingerprint = (0, import_utils35.hexlify)(bytes.slice(5, 9));
7806
+ const index = parseInt((0, import_utils35.hexlify)(bytes.slice(9, 13)).substring(2), 16);
7807
+ const chainCode = (0, import_utils35.hexlify)(bytes.slice(13, 45));
7700
7808
  const key = bytes.slice(45, 78);
7701
7809
  if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
7702
- throw new import_errors19.FuelError(
7703
- import_errors19.ErrorCode.HD_WALLET_ERROR,
7810
+ throw new import_errors20.FuelError(
7811
+ import_errors20.ErrorCode.HD_WALLET_ERROR,
7704
7812
  "Inconsistency detected: Depth is zero but fingerprint/index is non-zero."
7705
7813
  );
7706
7814
  }
7707
7815
  if (isPublicExtendedKey(bytes)) {
7708
7816
  if (key[0] !== 3) {
7709
- throw new import_errors19.FuelError(import_errors19.ErrorCode.HD_WALLET_ERROR, "Invalid public extended key.");
7817
+ throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Invalid public extended key.");
7710
7818
  }
7711
7819
  return new HDWallet({
7712
7820
  publicKey: key,
@@ -7717,7 +7825,7 @@ var HDWallet = class {
7717
7825
  });
7718
7826
  }
7719
7827
  if (key[0] !== 0) {
7720
- throw new import_errors19.FuelError(import_errors19.ErrorCode.HD_WALLET_ERROR, "Invalid private extended key.");
7828
+ throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Invalid private extended key.");
7721
7829
  }
7722
7830
  return new HDWallet({
7723
7831
  privateKey: key.slice(1),
@@ -7883,10 +7991,10 @@ __publicField(Wallet, "fromExtendedKey", WalletUnlocked.fromExtendedKey);
7883
7991
  __publicField(Wallet, "fromEncryptedJson", WalletUnlocked.fromEncryptedJson);
7884
7992
 
7885
7993
  // src/test-utils/seedTestWallet.ts
7886
- var import_crypto4 = require("@fuel-ts/crypto");
7994
+ var import_crypto5 = require("@fuel-ts/crypto");
7887
7995
  var seedTestWallet = async (wallet, quantities) => {
7888
7996
  const genesisWallet = new WalletUnlocked(
7889
- process.env.GENESIS_SECRET || (0, import_crypto4.randomBytes)(32),
7997
+ process.env.GENESIS_SECRET || (0, import_crypto5.randomBytes)(32),
7890
7998
  wallet.provider
7891
7999
  );
7892
8000
  const resources = await genesisWallet.getResourcesToSpend(quantities);
@@ -7910,12 +8018,12 @@ var generateTestWallet = async (provider, quantities) => {
7910
8018
  };
7911
8019
 
7912
8020
  // src/test-utils/launchNode.ts
7913
- var import_configs12 = require("@fuel-ts/address/configs");
7914
- var import_math20 = require("@fuel-ts/math");
7915
- var import_utils35 = require("@fuel-ts/utils");
8021
+ var import_configs13 = require("@fuel-ts/address/configs");
8022
+ var import_math21 = require("@fuel-ts/math");
8023
+ var import_utils36 = require("@fuel-ts/utils");
7916
8024
  var import_cli_utils = require("@fuel-ts/utils/cli-utils");
7917
8025
  var import_child_process = require("child_process");
7918
- var import_crypto5 = require("crypto");
8026
+ var import_crypto6 = require("crypto");
7919
8027
  var import_fs = require("fs");
7920
8028
  var import_os = __toESM(require("os"));
7921
8029
  var import_path = __toESM(require("path"));
@@ -7970,7 +8078,7 @@ var launchNode = async ({
7970
8078
  "--poa-instant"
7971
8079
  ]);
7972
8080
  const chainConfigPath = getFlagValueFromArgs(args, "--chain");
7973
- const consensusKey = getFlagValueFromArgs(args, "--consensus-key") || import_utils35.defaultConsensusKey;
8081
+ const consensusKey = getFlagValueFromArgs(args, "--consensus-key") || import_utils36.defaultConsensusKey;
7974
8082
  const dbTypeFlagValue = getFlagValueFromArgs(args, "--db-type");
7975
8083
  const useInMemoryDb = dbTypeFlagValue === "in-memory" || dbTypeFlagValue === void 0;
7976
8084
  const poaInstantFlagValue = getFlagValueFromArgs(args, "--poa-instant");
@@ -7987,7 +8095,7 @@ var launchNode = async ({
7987
8095
  })).toString();
7988
8096
  let chainConfigPathToUse;
7989
8097
  const prefix = basePath || import_os.default.tmpdir();
7990
- const suffix = basePath ? "" : (0, import_crypto5.randomUUID)();
8098
+ const suffix = basePath ? "" : (0, import_crypto6.randomUUID)();
7991
8099
  const tempDirPath = import_path.default.join(prefix, ".fuels", suffix);
7992
8100
  if (chainConfigPath) {
7993
8101
  chainConfigPathToUse = chainConfigPath;
@@ -7996,21 +8104,21 @@ var launchNode = async ({
7996
8104
  (0, import_fs.mkdirSync)(tempDirPath, { recursive: true });
7997
8105
  }
7998
8106
  const tempChainConfigFilePath = import_path.default.join(tempDirPath, "chainConfig.json");
7999
- let chainConfig = import_utils35.defaultChainConfig;
8107
+ let chainConfig = import_utils36.defaultChainConfig;
8000
8108
  if (!process.env.GENESIS_SECRET) {
8001
8109
  const pk = Signer.generatePrivateKey();
8002
8110
  const signer = new Signer(pk);
8003
- process.env.GENESIS_SECRET = (0, import_utils35.hexlify)(pk);
8111
+ process.env.GENESIS_SECRET = (0, import_utils36.hexlify)(pk);
8004
8112
  chainConfig = {
8005
- ...import_utils35.defaultChainConfig,
8113
+ ...import_utils36.defaultChainConfig,
8006
8114
  initial_state: {
8007
- ...import_utils35.defaultChainConfig.initial_state,
8115
+ ...import_utils36.defaultChainConfig.initial_state,
8008
8116
  coins: [
8009
- ...import_utils35.defaultChainConfig.initial_state.coins,
8117
+ ...import_utils36.defaultChainConfig.initial_state.coins,
8010
8118
  {
8011
8119
  owner: signer.address.toHexString(),
8012
- amount: (0, import_math20.toHex)(1e9),
8013
- asset_id: import_configs12.BaseAssetId
8120
+ amount: (0, import_math21.toHex)(1e9),
8121
+ asset_id: import_configs13.BaseAssetId
8014
8122
  }
8015
8123
  ]
8016
8124
  }
@@ -8078,7 +8186,7 @@ var launchNode = async ({
8078
8186
  var generateWallets = async (count, provider) => {
8079
8187
  const wallets = [];
8080
8188
  for (let i = 0; i < count; i += 1) {
8081
- const wallet = await generateTestWallet(provider, [[1e3, import_configs12.BaseAssetId]]);
8189
+ const wallet = await generateTestWallet(provider, [[1e3, import_configs13.BaseAssetId]]);
8082
8190
  wallets.push(wallet);
8083
8191
  }
8084
8192
  return wallets;