@fuel-ts/account 0.79.0 → 0.80.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.

@@ -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");
@@ -1051,6 +1051,7 @@ var MemoryCache = class {
1051
1051
  };
1052
1052
 
1053
1053
  // src/providers/transaction-request/input.ts
1054
+ var import_abi_coder = require("@fuel-ts/abi-coder");
1054
1055
  var import_configs2 = require("@fuel-ts/address/configs");
1055
1056
  var import_errors3 = require("@fuel-ts/errors");
1056
1057
  var import_math2 = require("@fuel-ts/math");
@@ -1064,8 +1065,8 @@ var inputify = (value) => {
1064
1065
  const predicateData = (0, import_utils3.arrayify)(value.predicateData ?? "0x");
1065
1066
  return {
1066
1067
  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],
1068
+ txID: (0, import_utils3.hexlify)((0, import_utils3.arrayify)(value.id).slice(0, import_abi_coder.BYTES_32)),
1069
+ outputIndex: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.id).slice(import_abi_coder.BYTES_32, import_abi_coder.UTXO_ID_LEN)),
1069
1070
  owner: (0, import_utils3.hexlify)(value.owner),
1070
1071
  amount: (0, import_math2.bn)(value.amount),
1071
1072
  assetId: (0, import_utils3.hexlify)(value.assetId),
@@ -1183,10 +1184,12 @@ var outputify = (value) => {
1183
1184
  };
1184
1185
 
1185
1186
  // src/providers/transaction-request/transaction-request.ts
1187
+ var import_abi_coder2 = require("@fuel-ts/abi-coder");
1186
1188
  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");
1189
+ var import_configs7 = require("@fuel-ts/address/configs");
1190
+ var import_crypto = require("@fuel-ts/crypto");
1191
+ var import_math7 = require("@fuel-ts/math");
1192
+ var import_transactions6 = require("@fuel-ts/transactions");
1190
1193
  var import_utils9 = require("@fuel-ts/utils");
1191
1194
 
1192
1195
  // src/providers/resource.ts
@@ -1517,6 +1520,78 @@ function sleep(time) {
1517
1520
  });
1518
1521
  }
1519
1522
 
1523
+ // src/providers/utils/extract-tx-error.ts
1524
+ var import_errors7 = require("@fuel-ts/errors");
1525
+ var import_math6 = require("@fuel-ts/math");
1526
+ var import_transactions5 = require("@fuel-ts/transactions");
1527
+ var import_configs6 = require("@fuel-ts/transactions/configs");
1528
+ var assemblePanicError = (status) => {
1529
+ let errorMessage = `The transaction reverted with reason: "${status.reason}".`;
1530
+ const reason = status.reason;
1531
+ if (import_configs6.PANIC_REASONS.includes(status.reason)) {
1532
+ errorMessage = `${errorMessage}
1533
+
1534
+ You can read more about this error at:
1535
+
1536
+ ${import_configs6.PANIC_DOC_URL}#variant.${status.reason}`;
1537
+ }
1538
+ return { errorMessage, reason };
1539
+ };
1540
+ var stringify = (obj) => JSON.stringify(obj, null, 2);
1541
+ var assembleRevertError = (receipts, logs) => {
1542
+ let errorMessage = "The transaction reverted with an unknown reason.";
1543
+ const revertReceipt = receipts.find(({ type }) => type === import_transactions5.ReceiptType.Revert);
1544
+ let reason = "";
1545
+ if (revertReceipt) {
1546
+ const reasonHex = (0, import_math6.bn)(revertReceipt.val).toHex();
1547
+ switch (reasonHex) {
1548
+ case import_configs6.FAILED_REQUIRE_SIGNAL: {
1549
+ reason = "require";
1550
+ errorMessage = `The transaction reverted because a "require" statement has thrown ${logs.length ? stringify(logs[0]) : "an error."}.`;
1551
+ break;
1552
+ }
1553
+ case import_configs6.FAILED_ASSERT_EQ_SIGNAL: {
1554
+ const sufix = logs.length >= 2 ? ` comparing ${stringify(logs[1])} and ${stringify(logs[0])}.` : ".";
1555
+ reason = "assert_eq";
1556
+ errorMessage = `The transaction reverted because of an "assert_eq" statement${sufix}`;
1557
+ break;
1558
+ }
1559
+ case import_configs6.FAILED_ASSERT_NE_SIGNAL: {
1560
+ const sufix = logs.length >= 2 ? ` comparing ${stringify(logs[1])} and ${stringify(logs[0])}.` : ".";
1561
+ reason = "assert_ne";
1562
+ errorMessage = `The transaction reverted because of an "assert_ne" statement${sufix}`;
1563
+ break;
1564
+ }
1565
+ case import_configs6.FAILED_ASSERT_SIGNAL:
1566
+ reason = "assert";
1567
+ errorMessage = `The transaction reverted because an "assert" statement failed to evaluate to true.`;
1568
+ break;
1569
+ case import_configs6.FAILED_TRANSFER_TO_ADDRESS_SIGNAL:
1570
+ reason = "MissingOutputChange";
1571
+ errorMessage = `The transaction reverted because it's missing an "OutputChange".`;
1572
+ break;
1573
+ default:
1574
+ reason = "unknown";
1575
+ errorMessage = `The transaction reverted with an unknown reason: ${revertReceipt.val}`;
1576
+ }
1577
+ }
1578
+ return { errorMessage, reason };
1579
+ };
1580
+ var extractTxError = (params) => {
1581
+ const { receipts, status, logs } = params;
1582
+ const isPanic = receipts.some(({ type }) => type === import_transactions5.ReceiptType.Panic);
1583
+ const isRevert = receipts.some(({ type }) => type === import_transactions5.ReceiptType.Revert);
1584
+ const { errorMessage, reason } = status?.type === "FailureStatus" && isPanic ? assemblePanicError(status) : assembleRevertError(receipts, logs);
1585
+ const metadata = {
1586
+ logs,
1587
+ receipts,
1588
+ panic: isPanic,
1589
+ revert: isRevert,
1590
+ reason
1591
+ };
1592
+ return new import_errors7.FuelError(import_errors7.ErrorCode.SCRIPT_REVERTED, errorMessage, metadata);
1593
+ };
1594
+
1520
1595
  // src/providers/transaction-request/errors.ts
1521
1596
  var NoWitnessAtIndexError = class extends Error {
1522
1597
  constructor(index) {
@@ -1567,10 +1642,10 @@ var BaseTransactionRequest = class {
1567
1642
  outputs,
1568
1643
  witnesses
1569
1644
  } = {}) {
1570
- this.gasPrice = (0, import_math6.bn)(gasPrice);
1645
+ this.gasPrice = (0, import_math7.bn)(gasPrice);
1571
1646
  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;
1647
+ this.witnessLimit = witnessLimit ? (0, import_math7.bn)(witnessLimit) : void 0;
1648
+ this.maxFee = maxFee ? (0, import_math7.bn)(maxFee) : void 0;
1574
1649
  this.inputs = inputs ?? [];
1575
1650
  this.outputs = outputs ?? [];
1576
1651
  this.witnesses = witnesses ?? [];
@@ -1579,20 +1654,20 @@ var BaseTransactionRequest = class {
1579
1654
  let policyTypes = 0;
1580
1655
  const policies = [];
1581
1656
  if (req.gasPrice) {
1582
- policyTypes += import_transactions5.PolicyType.GasPrice;
1583
- policies.push({ data: req.gasPrice, type: import_transactions5.PolicyType.GasPrice });
1657
+ policyTypes += import_transactions6.PolicyType.GasPrice;
1658
+ policies.push({ data: req.gasPrice, type: import_transactions6.PolicyType.GasPrice });
1584
1659
  }
1585
1660
  if (req.witnessLimit) {
1586
- policyTypes += import_transactions5.PolicyType.WitnessLimit;
1587
- policies.push({ data: req.witnessLimit, type: import_transactions5.PolicyType.WitnessLimit });
1661
+ policyTypes += import_transactions6.PolicyType.WitnessLimit;
1662
+ policies.push({ data: req.witnessLimit, type: import_transactions6.PolicyType.WitnessLimit });
1588
1663
  }
1589
1664
  if (req.maturity > 0) {
1590
- policyTypes += import_transactions5.PolicyType.Maturity;
1591
- policies.push({ data: req.maturity, type: import_transactions5.PolicyType.Maturity });
1665
+ policyTypes += import_transactions6.PolicyType.Maturity;
1666
+ policies.push({ data: req.maturity, type: import_transactions6.PolicyType.Maturity });
1592
1667
  }
1593
1668
  if (req.maxFee) {
1594
- policyTypes += import_transactions5.PolicyType.MaxFee;
1595
- policies.push({ data: req.maxFee, type: import_transactions5.PolicyType.MaxFee });
1669
+ policyTypes += import_transactions6.PolicyType.MaxFee;
1670
+ policies.push({ data: req.maxFee, type: import_transactions6.PolicyType.MaxFee });
1596
1671
  }
1597
1672
  return {
1598
1673
  policyTypes,
@@ -1626,7 +1701,7 @@ var BaseTransactionRequest = class {
1626
1701
  * @returns The transaction bytes.
1627
1702
  */
1628
1703
  toTransactionBytes() {
1629
- return new import_transactions5.TransactionCoder().encode(this.toTransaction());
1704
+ return new import_transactions6.TransactionCoder().encode(this.toTransaction());
1630
1705
  }
1631
1706
  /**
1632
1707
  * @hidden
@@ -1666,7 +1741,7 @@ var BaseTransactionRequest = class {
1666
1741
  * @returns The index of the created witness.
1667
1742
  */
1668
1743
  addEmptyWitness() {
1669
- this.addWitness((0, import_utils9.concat)([import_configs6.ZeroBytes32, import_configs6.ZeroBytes32]));
1744
+ this.addWitness((0, import_utils9.concat)([import_configs7.ZeroBytes32, import_configs7.ZeroBytes32]));
1670
1745
  return this.witnesses.length - 1;
1671
1746
  }
1672
1747
  /**
@@ -1717,7 +1792,7 @@ var BaseTransactionRequest = class {
1717
1792
  */
1718
1793
  getCoinInputs() {
1719
1794
  return this.inputs.filter(
1720
- (input) => input.type === import_transactions5.InputType.Coin
1795
+ (input) => input.type === import_transactions6.InputType.Coin
1721
1796
  );
1722
1797
  }
1723
1798
  /**
@@ -1727,7 +1802,7 @@ var BaseTransactionRequest = class {
1727
1802
  */
1728
1803
  getCoinOutputs() {
1729
1804
  return this.outputs.filter(
1730
- (output) => output.type === import_transactions5.OutputType.Coin
1805
+ (output) => output.type === import_transactions6.OutputType.Coin
1731
1806
  );
1732
1807
  }
1733
1808
  /**
@@ -1737,7 +1812,7 @@ var BaseTransactionRequest = class {
1737
1812
  */
1738
1813
  getChangeOutputs() {
1739
1814
  return this.outputs.filter(
1740
- (output) => output.type === import_transactions5.OutputType.Change
1815
+ (output) => output.type === import_transactions6.OutputType.Change
1741
1816
  );
1742
1817
  }
1743
1818
  /**
@@ -1749,9 +1824,9 @@ var BaseTransactionRequest = class {
1749
1824
  const ownerAddress = (0, import_address.addressify)(owner);
1750
1825
  const found = this.inputs.find((input) => {
1751
1826
  switch (input.type) {
1752
- case import_transactions5.InputType.Coin:
1827
+ case import_transactions6.InputType.Coin:
1753
1828
  return (0, import_utils9.hexlify)(input.owner) === ownerAddress.toB256();
1754
- case import_transactions5.InputType.Message:
1829
+ case import_transactions6.InputType.Message:
1755
1830
  return (0, import_utils9.hexlify)(input.recipient) === ownerAddress.toB256();
1756
1831
  default:
1757
1832
  return false;
@@ -1780,14 +1855,13 @@ var BaseTransactionRequest = class {
1780
1855
  }
1781
1856
  const input = {
1782
1857
  ...coin,
1783
- type: import_transactions5.InputType.Coin,
1858
+ type: import_transactions6.InputType.Coin,
1784
1859
  owner: owner.toB256(),
1785
1860
  amount,
1786
1861
  assetId,
1787
1862
  txPointer: "0x00000000000000000000000000000000",
1788
1863
  witnessIndex,
1789
- predicate: predicate?.bytes,
1790
- predicateData: predicate?.predicateDataBytes
1864
+ predicate: predicate?.bytes
1791
1865
  };
1792
1866
  this.pushInput(input);
1793
1867
  this.addChangeOutput(owner, assetId);
@@ -1802,7 +1876,7 @@ var BaseTransactionRequest = class {
1802
1876
  */
1803
1877
  addMessageInput(message, predicate) {
1804
1878
  const { recipient, sender, amount } = message;
1805
- const assetId = import_configs6.BaseAssetId;
1879
+ const assetId = import_configs7.BaseAssetId;
1806
1880
  let witnessIndex;
1807
1881
  if (predicate) {
1808
1882
  witnessIndex = 0;
@@ -1814,13 +1888,12 @@ var BaseTransactionRequest = class {
1814
1888
  }
1815
1889
  const input = {
1816
1890
  ...message,
1817
- type: import_transactions5.InputType.Message,
1891
+ type: import_transactions6.InputType.Message,
1818
1892
  sender: sender.toB256(),
1819
1893
  recipient: recipient.toB256(),
1820
1894
  amount,
1821
1895
  witnessIndex,
1822
- predicate: predicate?.bytes,
1823
- predicateData: predicate?.predicateDataBytes
1896
+ predicate: predicate?.bytes
1824
1897
  };
1825
1898
  this.pushInput(input);
1826
1899
  this.addChangeOutput(recipient, assetId);
@@ -1884,9 +1957,9 @@ var BaseTransactionRequest = class {
1884
1957
  * @param amount - Amount of coin.
1885
1958
  * @param assetId - Asset ID of coin.
1886
1959
  */
1887
- addCoinOutput(to, amount, assetId = import_configs6.BaseAssetId) {
1960
+ addCoinOutput(to, amount, assetId = import_configs7.BaseAssetId) {
1888
1961
  this.pushOutput({
1889
- type: import_transactions5.OutputType.Coin,
1962
+ type: import_transactions6.OutputType.Coin,
1890
1963
  to: (0, import_address.addressify)(to).toB256(),
1891
1964
  amount,
1892
1965
  assetId
@@ -1902,7 +1975,7 @@ var BaseTransactionRequest = class {
1902
1975
  addCoinOutputs(to, quantities) {
1903
1976
  quantities.map(coinQuantityfy).forEach((quantity) => {
1904
1977
  this.pushOutput({
1905
- type: import_transactions5.OutputType.Coin,
1978
+ type: import_transactions6.OutputType.Coin,
1906
1979
  to: (0, import_address.addressify)(to).toB256(),
1907
1980
  amount: quantity.amount,
1908
1981
  assetId: quantity.assetId
@@ -1916,13 +1989,13 @@ var BaseTransactionRequest = class {
1916
1989
  * @param to - Address of the owner.
1917
1990
  * @param assetId - Asset ID of coin.
1918
1991
  */
1919
- addChangeOutput(to, assetId = import_configs6.BaseAssetId) {
1992
+ addChangeOutput(to, assetId = import_configs7.BaseAssetId) {
1920
1993
  const changeOutput = this.getChangeOutputs().find(
1921
1994
  (output) => (0, import_utils9.hexlify)(output.assetId) === assetId
1922
1995
  );
1923
1996
  if (!changeOutput) {
1924
1997
  this.pushOutput({
1925
- type: import_transactions5.OutputType.Change,
1998
+ type: import_transactions6.OutputType.Change,
1926
1999
  to: (0, import_address.addressify)(to).toB256(),
1927
2000
  assetId
1928
2001
  });
@@ -1975,12 +2048,6 @@ var BaseTransactionRequest = class {
1975
2048
  * @param quantities - CoinQuantity Array.
1976
2049
  */
1977
2050
  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
2051
  const findAssetInput = (assetId) => this.inputs.find((input) => {
1985
2052
  if ("assetId" in input) {
1986
2053
  return input.assetId === assetId;
@@ -1990,23 +2057,23 @@ var BaseTransactionRequest = class {
1990
2057
  const updateAssetInput = (assetId, quantity) => {
1991
2058
  const assetInput = findAssetInput(assetId);
1992
2059
  if (assetInput && "assetId" in assetInput) {
1993
- assetInput.id = generateId();
2060
+ assetInput.id = (0, import_utils9.hexlify)((0, import_crypto.randomBytes)(import_abi_coder2.UTXO_ID_LEN));
1994
2061
  assetInput.amount = quantity;
1995
2062
  } else {
1996
2063
  this.addResources([
1997
2064
  {
1998
- id: generateId(),
2065
+ id: (0, import_utils9.hexlify)((0, import_crypto.randomBytes)(import_abi_coder2.UTXO_ID_LEN)),
1999
2066
  amount: quantity,
2000
2067
  assetId,
2001
2068
  owner: resourcesOwner || import_address.Address.fromRandom(),
2002
2069
  maturity: 0,
2003
- blockCreated: (0, import_math6.bn)(1),
2004
- txCreatedIdx: (0, import_math6.bn)(1)
2070
+ blockCreated: (0, import_math7.bn)(1),
2071
+ txCreatedIdx: (0, import_math7.bn)(1)
2005
2072
  }
2006
2073
  ]);
2007
2074
  }
2008
2075
  };
2009
- updateAssetInput(import_configs6.BaseAssetId, (0, import_math6.bn)(1e11));
2076
+ updateAssetInput(import_configs7.BaseAssetId, (0, import_math7.bn)(1e11));
2010
2077
  quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
2011
2078
  }
2012
2079
  /**
@@ -2017,7 +2084,7 @@ var BaseTransactionRequest = class {
2017
2084
  */
2018
2085
  getCoinOutputsQuantities() {
2019
2086
  const coinsQuantities = this.getCoinOutputs().map(({ amount, assetId }) => ({
2020
- amount: (0, import_math6.bn)(amount),
2087
+ amount: (0, import_math7.bn)(amount),
2021
2088
  assetId: assetId.toString()
2022
2089
  }));
2023
2090
  return coinsQuantities;
@@ -2035,18 +2102,18 @@ var BaseTransactionRequest = class {
2035
2102
  this.inputs.forEach((i) => {
2036
2103
  let correspondingInput;
2037
2104
  switch (i.type) {
2038
- case import_transactions5.InputType.Coin:
2039
- correspondingInput = inputs.find((x) => x.type === import_transactions5.InputType.Coin && x.owner === i.owner);
2105
+ case import_transactions6.InputType.Coin:
2106
+ correspondingInput = inputs.find((x) => x.type === import_transactions6.InputType.Coin && x.owner === i.owner);
2040
2107
  break;
2041
- case import_transactions5.InputType.Message:
2108
+ case import_transactions6.InputType.Message:
2042
2109
  correspondingInput = inputs.find(
2043
- (x) => x.type === import_transactions5.InputType.Message && x.sender === i.sender
2110
+ (x) => x.type === import_transactions6.InputType.Message && x.sender === i.sender
2044
2111
  );
2045
2112
  break;
2046
2113
  default:
2047
2114
  return;
2048
2115
  }
2049
- if (correspondingInput && "predicateGasUsed" in correspondingInput && (0, import_math6.bn)(correspondingInput.predicateGasUsed).gt(0)) {
2116
+ if (correspondingInput && "predicateGasUsed" in correspondingInput && (0, import_math7.bn)(correspondingInput.predicateGasUsed).gt(0)) {
2050
2117
  i.predicate = correspondingInput.predicate;
2051
2118
  i.predicateData = correspondingInput.predicateData;
2052
2119
  i.predicateGasUsed = correspondingInput.predicateGasUsed;
@@ -2056,47 +2123,47 @@ var BaseTransactionRequest = class {
2056
2123
  };
2057
2124
 
2058
2125
  // 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");
2126
+ var import_configs9 = require("@fuel-ts/address/configs");
2127
+ var import_math9 = require("@fuel-ts/math");
2128
+ var import_transactions8 = require("@fuel-ts/transactions");
2062
2129
  var import_utils13 = require("@fuel-ts/utils");
2063
2130
 
2064
2131
  // src/providers/transaction-request/hash-transaction.ts
2065
- var import_configs7 = require("@fuel-ts/address/configs");
2132
+ var import_configs8 = require("@fuel-ts/address/configs");
2066
2133
  var import_hasher = require("@fuel-ts/hasher");
2067
- var import_math7 = require("@fuel-ts/math");
2068
- var import_transactions6 = require("@fuel-ts/transactions");
2134
+ var import_math8 = require("@fuel-ts/math");
2135
+ var import_transactions7 = require("@fuel-ts/transactions");
2069
2136
  var import_utils11 = require("@fuel-ts/utils");
2070
2137
  var import_ramda2 = require("ramda");
2071
2138
  function hashTransaction(transactionRequest, chainId) {
2072
2139
  const transaction = transactionRequest.toTransaction();
2073
- if (transaction.type === import_transactions6.TransactionType.Script) {
2074
- transaction.receiptsRoot = import_configs7.ZeroBytes32;
2140
+ if (transaction.type === import_transactions7.TransactionType.Script) {
2141
+ transaction.receiptsRoot = import_configs8.ZeroBytes32;
2075
2142
  }
2076
2143
  transaction.inputs = transaction.inputs.map((input) => {
2077
2144
  const inputClone = (0, import_ramda2.clone)(input);
2078
2145
  switch (inputClone.type) {
2079
- case import_transactions6.InputType.Coin: {
2146
+ case import_transactions7.InputType.Coin: {
2080
2147
  inputClone.txPointer = {
2081
2148
  blockHeight: 0,
2082
2149
  txIndex: 0
2083
2150
  };
2084
- inputClone.predicateGasUsed = (0, import_math7.bn)(0);
2151
+ inputClone.predicateGasUsed = (0, import_math8.bn)(0);
2085
2152
  return inputClone;
2086
2153
  }
2087
- case import_transactions6.InputType.Message: {
2088
- inputClone.predicateGasUsed = (0, import_math7.bn)(0);
2154
+ case import_transactions7.InputType.Message: {
2155
+ inputClone.predicateGasUsed = (0, import_math8.bn)(0);
2089
2156
  return inputClone;
2090
2157
  }
2091
- case import_transactions6.InputType.Contract: {
2158
+ case import_transactions7.InputType.Contract: {
2092
2159
  inputClone.txPointer = {
2093
2160
  blockHeight: 0,
2094
2161
  txIndex: 0
2095
2162
  };
2096
- inputClone.txID = import_configs7.ZeroBytes32;
2163
+ inputClone.txID = import_configs8.ZeroBytes32;
2097
2164
  inputClone.outputIndex = 0;
2098
- inputClone.balanceRoot = import_configs7.ZeroBytes32;
2099
- inputClone.stateRoot = import_configs7.ZeroBytes32;
2165
+ inputClone.balanceRoot = import_configs8.ZeroBytes32;
2166
+ inputClone.stateRoot = import_configs8.ZeroBytes32;
2100
2167
  return inputClone;
2101
2168
  }
2102
2169
  default:
@@ -2106,19 +2173,19 @@ function hashTransaction(transactionRequest, chainId) {
2106
2173
  transaction.outputs = transaction.outputs.map((output) => {
2107
2174
  const outputClone = (0, import_ramda2.clone)(output);
2108
2175
  switch (outputClone.type) {
2109
- case import_transactions6.OutputType.Contract: {
2110
- outputClone.balanceRoot = import_configs7.ZeroBytes32;
2111
- outputClone.stateRoot = import_configs7.ZeroBytes32;
2176
+ case import_transactions7.OutputType.Contract: {
2177
+ outputClone.balanceRoot = import_configs8.ZeroBytes32;
2178
+ outputClone.stateRoot = import_configs8.ZeroBytes32;
2112
2179
  return outputClone;
2113
2180
  }
2114
- case import_transactions6.OutputType.Change: {
2115
- outputClone.amount = (0, import_math7.bn)(0);
2181
+ case import_transactions7.OutputType.Change: {
2182
+ outputClone.amount = (0, import_math8.bn)(0);
2116
2183
  return outputClone;
2117
2184
  }
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;
2185
+ case import_transactions7.OutputType.Variable: {
2186
+ outputClone.to = import_configs8.ZeroBytes32;
2187
+ outputClone.amount = (0, import_math8.bn)(0);
2188
+ outputClone.assetId = import_configs8.ZeroBytes32;
2122
2189
  return outputClone;
2123
2190
  }
2124
2191
  default:
@@ -2128,7 +2195,7 @@ function hashTransaction(transactionRequest, chainId) {
2128
2195
  transaction.witnessesCount = 0;
2129
2196
  transaction.witnesses = [];
2130
2197
  const chainIdBytes = (0, import_hasher.uint64ToBytesBE)(chainId);
2131
- const concatenatedData = (0, import_utils11.concat)([chainIdBytes, new import_transactions6.TransactionCoder().encode(transaction)]);
2198
+ const concatenatedData = (0, import_utils11.concat)([chainIdBytes, new import_transactions7.TransactionCoder().encode(transaction)]);
2132
2199
  return (0, import_hasher.sha256)(concatenatedData);
2133
2200
  }
2134
2201
 
@@ -2164,7 +2231,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2164
2231
  return new this(obj);
2165
2232
  }
2166
2233
  /** Type of the transaction */
2167
- type = import_transactions7.TransactionType.Create;
2234
+ type = import_transactions8.TransactionType.Create;
2168
2235
  /** Witness index of contract bytecode to create */
2169
2236
  bytecodeWitnessIndex;
2170
2237
  /** Salt */
@@ -2184,7 +2251,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2184
2251
  } = {}) {
2185
2252
  super(rest);
2186
2253
  this.bytecodeWitnessIndex = bytecodeWitnessIndex ?? 0;
2187
- this.salt = (0, import_utils13.hexlify)(salt ?? import_configs8.ZeroBytes32);
2254
+ this.salt = (0, import_utils13.hexlify)(salt ?? import_configs9.ZeroBytes32);
2188
2255
  this.storageSlots = [...storageSlots ?? []];
2189
2256
  }
2190
2257
  /**
@@ -2197,12 +2264,12 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2197
2264
  const bytecodeWitnessIndex = this.bytecodeWitnessIndex;
2198
2265
  const storageSlots = this.storageSlots?.map(storageSlotify) ?? [];
2199
2266
  return {
2200
- type: import_transactions7.TransactionType.Create,
2267
+ type: import_transactions8.TransactionType.Create,
2201
2268
  ...baseTransaction,
2202
2269
  bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
2203
2270
  bytecodeWitnessIndex,
2204
2271
  storageSlotsCount: storageSlots.length,
2205
- salt: this.salt ? (0, import_utils13.hexlify)(this.salt) : import_configs8.ZeroBytes32,
2272
+ salt: this.salt ? (0, import_utils13.hexlify)(this.salt) : import_configs9.ZeroBytes32,
2206
2273
  storageSlots
2207
2274
  };
2208
2275
  }
@@ -2213,7 +2280,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2213
2280
  */
2214
2281
  getContractCreatedOutputs() {
2215
2282
  return this.outputs.filter(
2216
- (output) => output.type === import_transactions7.OutputType.ContractCreated
2283
+ (output) => output.type === import_transactions8.OutputType.ContractCreated
2217
2284
  );
2218
2285
  }
2219
2286
  /**
@@ -2234,14 +2301,14 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2234
2301
  */
2235
2302
  addContractCreatedOutput(contractId, stateRoot) {
2236
2303
  this.pushOutput({
2237
- type: import_transactions7.OutputType.ContractCreated,
2304
+ type: import_transactions8.OutputType.ContractCreated,
2238
2305
  contractId,
2239
2306
  stateRoot
2240
2307
  });
2241
2308
  }
2242
2309
  metadataGas(gasCosts) {
2243
2310
  return calculateMetadataGasForTxCreate({
2244
- contractBytesSize: (0, import_math8.bn)((0, import_utils13.arrayify)(this.witnesses[this.bytecodeWitnessIndex] || "0x").length),
2311
+ contractBytesSize: (0, import_math9.bn)((0, import_utils13.arrayify)(this.witnesses[this.bytecodeWitnessIndex] || "0x").length),
2245
2312
  gasCosts,
2246
2313
  stateRootSize: this.storageSlots.length,
2247
2314
  txBytesSize: this.byteSize()
@@ -2250,11 +2317,11 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2250
2317
  };
2251
2318
 
2252
2319
  // src/providers/transaction-request/script-transaction-request.ts
2253
- var import_abi_coder = require("@fuel-ts/abi-coder");
2320
+ var import_abi_coder3 = require("@fuel-ts/abi-coder");
2254
2321
  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");
2322
+ var import_configs10 = require("@fuel-ts/address/configs");
2323
+ var import_math10 = require("@fuel-ts/math");
2324
+ var import_transactions9 = require("@fuel-ts/transactions");
2258
2325
  var import_utils15 = require("@fuel-ts/utils");
2259
2326
 
2260
2327
  // src/providers/transaction-request/scripts.ts
@@ -2292,7 +2359,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2292
2359
  return new this(obj);
2293
2360
  }
2294
2361
  /** Type of the transaction */
2295
- type = import_transactions8.TransactionType.Script;
2362
+ type = import_transactions9.TransactionType.Script;
2296
2363
  /** Gas limit for transaction */
2297
2364
  gasLimit;
2298
2365
  /** Script to execute */
@@ -2307,7 +2374,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2307
2374
  */
2308
2375
  constructor({ script, scriptData, gasLimit, ...rest } = {}) {
2309
2376
  super(rest);
2310
- this.gasLimit = (0, import_math9.bn)(gasLimit);
2377
+ this.gasLimit = (0, import_math10.bn)(gasLimit);
2311
2378
  this.script = (0, import_utils15.arrayify)(script ?? returnZeroScript.bytes);
2312
2379
  this.scriptData = (0, import_utils15.arrayify)(scriptData ?? returnZeroScript.encodeScriptData());
2313
2380
  this.abis = rest.abis;
@@ -2321,12 +2388,12 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2321
2388
  const script = (0, import_utils15.arrayify)(this.script ?? "0x");
2322
2389
  const scriptData = (0, import_utils15.arrayify)(this.scriptData ?? "0x");
2323
2390
  return {
2324
- type: import_transactions8.TransactionType.Script,
2391
+ type: import_transactions9.TransactionType.Script,
2325
2392
  scriptGasLimit: this.gasLimit,
2326
2393
  ...super.getBaseTransaction(),
2327
2394
  scriptLength: script.length,
2328
2395
  scriptDataLength: scriptData.length,
2329
- receiptsRoot: import_configs9.ZeroBytes32,
2396
+ receiptsRoot: import_configs10.ZeroBytes32,
2330
2397
  script: (0, import_utils15.hexlify)(script),
2331
2398
  scriptData: (0, import_utils15.hexlify)(scriptData)
2332
2399
  };
@@ -2338,7 +2405,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2338
2405
  */
2339
2406
  getContractInputs() {
2340
2407
  return this.inputs.filter(
2341
- (input) => input.type === import_transactions8.InputType.Contract
2408
+ (input) => input.type === import_transactions9.InputType.Contract
2342
2409
  );
2343
2410
  }
2344
2411
  /**
@@ -2348,7 +2415,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2348
2415
  */
2349
2416
  getContractOutputs() {
2350
2417
  return this.outputs.filter(
2351
- (output) => output.type === import_transactions8.OutputType.Contract
2418
+ (output) => output.type === import_transactions9.OutputType.Contract
2352
2419
  );
2353
2420
  }
2354
2421
  /**
@@ -2358,7 +2425,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2358
2425
  */
2359
2426
  getVariableOutputs() {
2360
2427
  return this.outputs.filter(
2361
- (output) => output.type === import_transactions8.OutputType.Variable
2428
+ (output) => output.type === import_transactions9.OutputType.Variable
2362
2429
  );
2363
2430
  }
2364
2431
  /**
@@ -2381,7 +2448,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2381
2448
  let outputsNumber = numberOfVariables;
2382
2449
  while (outputsNumber) {
2383
2450
  this.pushOutput({
2384
- type: import_transactions8.OutputType.Variable
2451
+ type: import_transactions9.OutputType.Variable
2385
2452
  });
2386
2453
  outputsNumber -= 1;
2387
2454
  }
@@ -2414,12 +2481,12 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2414
2481
  return this;
2415
2482
  }
2416
2483
  const inputIndex = super.pushInput({
2417
- type: import_transactions8.InputType.Contract,
2484
+ type: import_transactions9.InputType.Contract,
2418
2485
  contractId: contractAddress.toB256(),
2419
2486
  txPointer: "0x00000000000000000000000000000000"
2420
2487
  });
2421
2488
  this.pushOutput({
2422
- type: import_transactions8.OutputType.Contract,
2489
+ type: import_transactions9.OutputType.Contract,
2423
2490
  inputIndex
2424
2491
  });
2425
2492
  return this;
@@ -2442,7 +2509,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2442
2509
  * @returns The current instance of the `ScriptTransactionRequest`.
2443
2510
  */
2444
2511
  setData(abi, args) {
2445
- const abiInterface = new import_abi_coder.Interface(abi);
2512
+ const abiInterface = new import_abi_coder3.Interface(abi);
2446
2513
  this.scriptData = abiInterface.functions.main.encodeArguments(args);
2447
2514
  return this;
2448
2515
  }
@@ -2455,38 +2522,38 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2455
2522
  };
2456
2523
 
2457
2524
  // src/providers/transaction-request/utils.ts
2458
- var import_errors8 = require("@fuel-ts/errors");
2459
- var import_transactions9 = require("@fuel-ts/transactions");
2525
+ var import_errors9 = require("@fuel-ts/errors");
2526
+ var import_transactions10 = require("@fuel-ts/transactions");
2460
2527
  var transactionRequestify = (obj) => {
2461
2528
  if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest) {
2462
2529
  return obj;
2463
2530
  }
2464
2531
  const { type } = obj;
2465
2532
  switch (obj.type) {
2466
- case import_transactions9.TransactionType.Script: {
2533
+ case import_transactions10.TransactionType.Script: {
2467
2534
  return ScriptTransactionRequest.from(obj);
2468
2535
  }
2469
- case import_transactions9.TransactionType.Create: {
2536
+ case import_transactions10.TransactionType.Create: {
2470
2537
  return CreateTransactionRequest.from(obj);
2471
2538
  }
2472
2539
  default: {
2473
- throw new import_errors8.FuelError(import_errors8.ErrorCode.INVALID_TRANSACTION_TYPE, `Invalid transaction type: ${type}.`);
2540
+ throw new import_errors9.FuelError(import_errors9.ErrorCode.INVALID_TRANSACTION_TYPE, `Invalid transaction type: ${type}.`);
2474
2541
  }
2475
2542
  }
2476
2543
  };
2477
2544
 
2478
2545
  // 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");
2546
+ var import_errors13 = require("@fuel-ts/errors");
2547
+ var import_math14 = require("@fuel-ts/math");
2548
+ var import_transactions17 = require("@fuel-ts/transactions");
2482
2549
  var import_utils21 = require("@fuel-ts/utils");
2483
2550
 
2484
2551
  // src/providers/transaction-summary/assemble-transaction-summary.ts
2485
2552
  var import_utils19 = require("@fuel-ts/utils");
2486
2553
 
2487
2554
  // src/providers/transaction-summary/calculate-transaction-fee.ts
2488
- var import_math10 = require("@fuel-ts/math");
2489
- var import_transactions10 = require("@fuel-ts/transactions");
2555
+ var import_math11 = require("@fuel-ts/math");
2556
+ var import_transactions11 = require("@fuel-ts/transactions");
2490
2557
  var import_utils16 = require("@fuel-ts/utils");
2491
2558
  var calculateTransactionFee = (params) => {
2492
2559
  const {
@@ -2494,24 +2561,24 @@ var calculateTransactionFee = (params) => {
2494
2561
  rawPayload,
2495
2562
  consensusParameters: { gasCosts, feeParams }
2496
2563
  } = params;
2497
- const gasPerByte = (0, import_math10.bn)(feeParams.gasPerByte);
2498
- const gasPriceFactor = (0, import_math10.bn)(feeParams.gasPriceFactor);
2564
+ const gasPerByte = (0, import_math11.bn)(feeParams.gasPerByte);
2565
+ const gasPriceFactor = (0, import_math11.bn)(feeParams.gasPriceFactor);
2499
2566
  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) {
2567
+ const [transaction] = new import_transactions11.TransactionCoder().decode(transactionBytes, 0);
2568
+ if (transaction.type === import_transactions11.TransactionType.Mint) {
2502
2569
  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)
2570
+ fee: (0, import_math11.bn)(0),
2571
+ minFee: (0, import_math11.bn)(0),
2572
+ maxFee: (0, import_math11.bn)(0),
2573
+ feeFromGasUsed: (0, import_math11.bn)(0)
2507
2574
  };
2508
2575
  }
2509
2576
  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) {
2577
+ let metadataGas = (0, import_math11.bn)(0);
2578
+ let gasLimit = (0, import_math11.bn)(0);
2579
+ if (type === import_transactions11.TransactionType.Create) {
2513
2580
  const { bytecodeWitnessIndex, storageSlots } = transaction;
2514
- const contractBytesSize = (0, import_math10.bn)((0, import_utils16.arrayify)(witnesses[bytecodeWitnessIndex].data).length);
2581
+ const contractBytesSize = (0, import_math11.bn)((0, import_utils16.arrayify)(witnesses[bytecodeWitnessIndex].data).length);
2515
2582
  metadataGas = calculateMetadataGasForTxCreate({
2516
2583
  contractBytesSize,
2517
2584
  gasCosts,
@@ -2530,13 +2597,13 @@ var calculateTransactionFee = (params) => {
2530
2597
  }
2531
2598
  const minGas = getMinGas({
2532
2599
  gasCosts,
2533
- gasPerByte: (0, import_math10.bn)(gasPerByte),
2600
+ gasPerByte: (0, import_math11.bn)(gasPerByte),
2534
2601
  inputs,
2535
2602
  metadataGas,
2536
2603
  txBytesSize: transactionBytes.length
2537
2604
  });
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;
2605
+ const gasPrice = (0, import_math11.bn)(policies.find((policy) => policy.type === import_transactions11.PolicyType.GasPrice)?.data);
2606
+ const witnessLimit = policies.find((policy) => policy.type === import_transactions11.PolicyType.WitnessLimit)?.data;
2540
2607
  const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
2541
2608
  const maxGas = getMaxGas({
2542
2609
  gasPerByte,
@@ -2558,23 +2625,23 @@ var calculateTransactionFee = (params) => {
2558
2625
  };
2559
2626
 
2560
2627
  // 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");
2628
+ var import_configs11 = require("@fuel-ts/address/configs");
2629
+ var import_errors11 = require("@fuel-ts/errors");
2630
+ var import_math13 = require("@fuel-ts/math");
2631
+ var import_transactions14 = require("@fuel-ts/transactions");
2565
2632
 
2566
2633
  // src/providers/transaction-summary/call.ts
2567
- var import_abi_coder2 = require("@fuel-ts/abi-coder");
2568
- var import_math11 = require("@fuel-ts/math");
2634
+ var import_abi_coder4 = require("@fuel-ts/abi-coder");
2635
+ var import_math12 = require("@fuel-ts/math");
2569
2636
  var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
2570
- const abiInterface = new import_abi_coder2.Interface(abi);
2637
+ const abiInterface = new import_abi_coder4.Interface(abi);
2571
2638
  const callFunctionSelector = receipt.param1.toHex(8);
2572
2639
  const functionFragment = abiInterface.getFunction(callFunctionSelector);
2573
2640
  const inputs = functionFragment.jsonFn.inputs;
2574
2641
  let encodedArgs;
2575
2642
  if (functionFragment.isInputDataPointer) {
2576
2643
  if (rawPayload) {
2577
- const argsOffset = (0, import_math11.bn)(receipt.param2).sub((0, import_abi_coder2.calculateVmTxMemory)({ maxInputs: maxInputs.toNumber() })).toNumber();
2644
+ const argsOffset = (0, import_math12.bn)(receipt.param2).sub((0, import_abi_coder4.calculateVmTxMemory)({ maxInputs: maxInputs.toNumber() })).toNumber();
2578
2645
  encodedArgs = `0x${rawPayload.slice(2).slice(argsOffset * 2)}`;
2579
2646
  }
2580
2647
  } else {
@@ -2608,8 +2675,8 @@ var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
2608
2675
  };
2609
2676
 
2610
2677
  // src/providers/transaction-summary/input.ts
2611
- var import_errors9 = require("@fuel-ts/errors");
2612
- var import_transactions11 = require("@fuel-ts/transactions");
2678
+ var import_errors10 = require("@fuel-ts/errors");
2679
+ var import_transactions12 = require("@fuel-ts/transactions");
2613
2680
  function getInputsByTypes(inputs, types) {
2614
2681
  return inputs.filter((i) => types.includes(i.type));
2615
2682
  }
@@ -2617,16 +2684,16 @@ function getInputsByType(inputs, type) {
2617
2684
  return inputs.filter((i) => i.type === type);
2618
2685
  }
2619
2686
  function getInputsCoin(inputs) {
2620
- return getInputsByType(inputs, import_transactions11.InputType.Coin);
2687
+ return getInputsByType(inputs, import_transactions12.InputType.Coin);
2621
2688
  }
2622
2689
  function getInputsMessage(inputs) {
2623
- return getInputsByType(inputs, import_transactions11.InputType.Message);
2690
+ return getInputsByType(inputs, import_transactions12.InputType.Message);
2624
2691
  }
2625
2692
  function getInputsCoinAndMessage(inputs) {
2626
- return getInputsByTypes(inputs, [import_transactions11.InputType.Coin, import_transactions11.InputType.Message]);
2693
+ return getInputsByTypes(inputs, [import_transactions12.InputType.Coin, import_transactions12.InputType.Message]);
2627
2694
  }
2628
2695
  function getInputsContract(inputs) {
2629
- return getInputsByType(inputs, import_transactions11.InputType.Contract);
2696
+ return getInputsByType(inputs, import_transactions12.InputType.Contract);
2630
2697
  }
2631
2698
  function getInputFromAssetId(inputs, assetId) {
2632
2699
  const coinInputs = getInputsCoin(inputs);
@@ -2645,40 +2712,40 @@ function getInputContractFromIndex(inputs, inputIndex) {
2645
2712
  if (!contractInput) {
2646
2713
  return void 0;
2647
2714
  }
2648
- if (contractInput.type !== import_transactions11.InputType.Contract) {
2649
- throw new import_errors9.FuelError(
2650
- import_errors9.ErrorCode.INVALID_TRANSACTION_INPUT,
2715
+ if (contractInput.type !== import_transactions12.InputType.Contract) {
2716
+ throw new import_errors10.FuelError(
2717
+ import_errors10.ErrorCode.INVALID_TRANSACTION_INPUT,
2651
2718
  `Contract input should be of type 'contract'.`
2652
2719
  );
2653
2720
  }
2654
2721
  return contractInput;
2655
2722
  }
2656
2723
  function getInputAccountAddress(input) {
2657
- if (input.type === import_transactions11.InputType.Coin) {
2724
+ if (input.type === import_transactions12.InputType.Coin) {
2658
2725
  return input.owner.toString();
2659
2726
  }
2660
- if (input.type === import_transactions11.InputType.Message) {
2727
+ if (input.type === import_transactions12.InputType.Message) {
2661
2728
  return input.recipient.toString();
2662
2729
  }
2663
2730
  return "";
2664
2731
  }
2665
2732
 
2666
2733
  // src/providers/transaction-summary/output.ts
2667
- var import_transactions12 = require("@fuel-ts/transactions");
2734
+ var import_transactions13 = require("@fuel-ts/transactions");
2668
2735
  function getOutputsByType(outputs, type) {
2669
2736
  return outputs.filter((o) => o.type === type);
2670
2737
  }
2671
2738
  function getOutputsContractCreated(outputs) {
2672
- return getOutputsByType(outputs, import_transactions12.OutputType.ContractCreated);
2739
+ return getOutputsByType(outputs, import_transactions13.OutputType.ContractCreated);
2673
2740
  }
2674
2741
  function getOutputsCoin(outputs) {
2675
- return getOutputsByType(outputs, import_transactions12.OutputType.Coin);
2742
+ return getOutputsByType(outputs, import_transactions13.OutputType.Coin);
2676
2743
  }
2677
2744
  function getOutputsChange(outputs) {
2678
- return getOutputsByType(outputs, import_transactions12.OutputType.Change);
2745
+ return getOutputsByType(outputs, import_transactions13.OutputType.Change);
2679
2746
  }
2680
2747
  function getOutputsContract(outputs) {
2681
- return getOutputsByType(outputs, import_transactions12.OutputType.Contract);
2748
+ return getOutputsByType(outputs, import_transactions13.OutputType.Contract);
2682
2749
  }
2683
2750
 
2684
2751
  // src/providers/transaction-summary/operations.ts
@@ -2687,15 +2754,15 @@ function getReceiptsByType(receipts, type) {
2687
2754
  }
2688
2755
  function getTransactionTypeName(transactionType) {
2689
2756
  switch (transactionType) {
2690
- case import_transactions13.TransactionType.Mint:
2757
+ case import_transactions14.TransactionType.Mint:
2691
2758
  return "Mint" /* Mint */;
2692
- case import_transactions13.TransactionType.Create:
2759
+ case import_transactions14.TransactionType.Create:
2693
2760
  return "Create" /* Create */;
2694
- case import_transactions13.TransactionType.Script:
2761
+ case import_transactions14.TransactionType.Script:
2695
2762
  return "Script" /* Script */;
2696
2763
  default:
2697
- throw new import_errors10.FuelError(
2698
- import_errors10.ErrorCode.INVALID_TRANSACTION_TYPE,
2764
+ throw new import_errors11.FuelError(
2765
+ import_errors11.ErrorCode.INVALID_TRANSACTION_TYPE,
2699
2766
  `Invalid transaction type: ${transactionType}.`
2700
2767
  );
2701
2768
  }
@@ -2714,10 +2781,10 @@ function isTypeScript(transactionType) {
2714
2781
  return isType(transactionType, "Script" /* Script */);
2715
2782
  }
2716
2783
  function getReceiptsCall(receipts) {
2717
- return getReceiptsByType(receipts, import_transactions13.ReceiptType.Call);
2784
+ return getReceiptsByType(receipts, import_transactions14.ReceiptType.Call);
2718
2785
  }
2719
2786
  function getReceiptsMessageOut(receipts) {
2720
- return getReceiptsByType(receipts, import_transactions13.ReceiptType.MessageOut);
2787
+ return getReceiptsByType(receipts, import_transactions14.ReceiptType.MessageOut);
2721
2788
  }
2722
2789
  var mergeAssets = (op1, op2) => {
2723
2790
  const assets1 = op1.assetsSent || [];
@@ -2730,7 +2797,7 @@ var mergeAssets = (op1, op2) => {
2730
2797
  if (!matchingAsset) {
2731
2798
  return asset1;
2732
2799
  }
2733
- const mergedAmount = (0, import_math12.bn)(asset1.amount).add(matchingAsset.amount);
2800
+ const mergedAmount = (0, import_math13.bn)(asset1.amount).add(matchingAsset.amount);
2734
2801
  return { ...asset1, amount: mergedAmount };
2735
2802
  });
2736
2803
  return mergedAssets.concat(filteredAssets);
@@ -2856,7 +2923,7 @@ function extractTransferOperationFromReceipt(receipt, contractInputs, changeOutp
2856
2923
  const { to: toAddress, assetId, amount } = receipt;
2857
2924
  let { from: fromAddress } = receipt;
2858
2925
  const toType = contractInputs.some((input) => input.contractID === toAddress) ? 0 /* contract */ : 1 /* account */;
2859
- if (import_configs10.ZeroBytes32 === fromAddress) {
2926
+ if (import_configs11.ZeroBytes32 === fromAddress) {
2860
2927
  const change = changeOutputs.find((output) => output.assetId === assetId);
2861
2928
  fromAddress = change?.to || fromAddress;
2862
2929
  }
@@ -2913,11 +2980,11 @@ function getTransferOperations({
2913
2980
  });
2914
2981
  const transferReceipts = getReceiptsByType(
2915
2982
  receipts,
2916
- import_transactions13.ReceiptType.Transfer
2983
+ import_transactions14.ReceiptType.Transfer
2917
2984
  );
2918
2985
  const transferOutReceipts = getReceiptsByType(
2919
2986
  receipts,
2920
- import_transactions13.ReceiptType.TransferOut
2987
+ import_transactions14.ReceiptType.TransferOut
2921
2988
  );
2922
2989
  [...transferReceipts, ...transferOutReceipts].forEach((receipt) => {
2923
2990
  const operation = extractTransferOperationFromReceipt(receipt, contractInputs, changeOutputs);
@@ -3002,17 +3069,17 @@ function getOperations({
3002
3069
  }
3003
3070
 
3004
3071
  // src/providers/transaction-summary/receipt.ts
3005
- var import_transactions14 = require("@fuel-ts/transactions");
3072
+ var import_transactions15 = require("@fuel-ts/transactions");
3006
3073
  var processGqlReceipt = (gqlReceipt) => {
3007
3074
  const receipt = assembleReceiptByType(gqlReceipt);
3008
3075
  switch (receipt.type) {
3009
- case import_transactions14.ReceiptType.ReturnData: {
3076
+ case import_transactions15.ReceiptType.ReturnData: {
3010
3077
  return {
3011
3078
  ...receipt,
3012
3079
  data: gqlReceipt.data || "0x"
3013
3080
  };
3014
3081
  }
3015
- case import_transactions14.ReceiptType.LogData: {
3082
+ case import_transactions15.ReceiptType.LogData: {
3016
3083
  return {
3017
3084
  ...receipt,
3018
3085
  data: gqlReceipt.data || "0x"
@@ -3025,7 +3092,7 @@ var processGqlReceipt = (gqlReceipt) => {
3025
3092
  var extractMintedAssetsFromReceipts = (receipts) => {
3026
3093
  const mintedAssets = [];
3027
3094
  receipts.forEach((receipt) => {
3028
- if (receipt.type === import_transactions14.ReceiptType.Mint) {
3095
+ if (receipt.type === import_transactions15.ReceiptType.Mint) {
3029
3096
  mintedAssets.push({
3030
3097
  subId: receipt.subId,
3031
3098
  contractId: receipt.contractId,
@@ -3039,7 +3106,7 @@ var extractMintedAssetsFromReceipts = (receipts) => {
3039
3106
  var extractBurnedAssetsFromReceipts = (receipts) => {
3040
3107
  const burnedAssets = [];
3041
3108
  receipts.forEach((receipt) => {
3042
- if (receipt.type === import_transactions14.ReceiptType.Burn) {
3109
+ if (receipt.type === import_transactions15.ReceiptType.Burn) {
3043
3110
  burnedAssets.push({
3044
3111
  subId: receipt.subId,
3045
3112
  contractId: receipt.contractId,
@@ -3052,7 +3119,7 @@ var extractBurnedAssetsFromReceipts = (receipts) => {
3052
3119
  };
3053
3120
 
3054
3121
  // src/providers/transaction-summary/status.ts
3055
- var import_errors11 = require("@fuel-ts/errors");
3122
+ var import_errors12 = require("@fuel-ts/errors");
3056
3123
  var getTransactionStatusName = (gqlStatus) => {
3057
3124
  switch (gqlStatus) {
3058
3125
  case "FailureStatus":
@@ -3064,8 +3131,8 @@ var getTransactionStatusName = (gqlStatus) => {
3064
3131
  case "SqueezedOutStatus":
3065
3132
  return "squeezedout" /* squeezedout */;
3066
3133
  default:
3067
- throw new import_errors11.FuelError(
3068
- import_errors11.ErrorCode.INVALID_TRANSACTION_STATUS,
3134
+ throw new import_errors12.FuelError(
3135
+ import_errors12.ErrorCode.INVALID_TRANSACTION_STATUS,
3069
3136
  `Invalid transaction status: ${gqlStatus}.`
3070
3137
  );
3071
3138
  }
@@ -3177,13 +3244,13 @@ function assembleTransactionSummary(params) {
3177
3244
  }
3178
3245
 
3179
3246
  // src/providers/transaction-response/getDecodedLogs.ts
3180
- var import_abi_coder3 = require("@fuel-ts/abi-coder");
3181
- var import_transactions15 = require("@fuel-ts/transactions");
3247
+ var import_abi_coder5 = require("@fuel-ts/abi-coder");
3248
+ var import_transactions16 = require("@fuel-ts/transactions");
3182
3249
  function getDecodedLogs(receipts, mainAbi, externalAbis = {}) {
3183
3250
  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;
3251
+ if (receipt.type === import_transactions16.ReceiptType.LogData || receipt.type === import_transactions16.ReceiptType.Log) {
3252
+ const interfaceToUse = new import_abi_coder5.Interface(externalAbis[receipt.id] || mainAbi);
3253
+ const data = receipt.type === import_transactions16.ReceiptType.Log ? new import_abi_coder5.BigNumberCoder("u64").encode(receipt.val0) : receipt.data;
3187
3254
  const [decodedLog] = interfaceToUse.decodeLog(data, receipt.val1.toNumber());
3188
3255
  logs.push(decodedLog);
3189
3256
  }
@@ -3198,7 +3265,7 @@ var TransactionResponse = class {
3198
3265
  /** Current provider */
3199
3266
  provider;
3200
3267
  /** Gas used on the transaction */
3201
- gasUsed = (0, import_math13.bn)(0);
3268
+ gasUsed = (0, import_math14.bn)(0);
3202
3269
  /** The graphql Transaction with receipts object. */
3203
3270
  gqlTransaction;
3204
3271
  abis;
@@ -3256,7 +3323,7 @@ var TransactionResponse = class {
3256
3323
  * @returns The decoded transaction.
3257
3324
  */
3258
3325
  decodeTransaction(transactionWithReceipts) {
3259
- return new import_transactions16.TransactionCoder().decode(
3326
+ return new import_transactions17.TransactionCoder().decode(
3260
3327
  (0, import_utils21.arrayify)(transactionWithReceipts.rawPayload),
3261
3328
  0
3262
3329
  )?.[0];
@@ -3303,8 +3370,8 @@ var TransactionResponse = class {
3303
3370
  });
3304
3371
  for await (const { statusChange } of subscription) {
3305
3372
  if (statusChange.type === "SqueezedOutStatus") {
3306
- throw new import_errors12.FuelError(
3307
- import_errors12.ErrorCode.TRANSACTION_SQUEEZED_OUT,
3373
+ throw new import_errors13.FuelError(
3374
+ import_errors13.ErrorCode.TRANSACTION_SQUEEZED_OUT,
3308
3375
  `Transaction Squeezed Out with reason: ${statusChange.reason}`
3309
3376
  );
3310
3377
  }
@@ -3326,14 +3393,26 @@ var TransactionResponse = class {
3326
3393
  gqlTransaction: this.gqlTransaction,
3327
3394
  ...transactionSummary
3328
3395
  };
3396
+ let logs = [];
3329
3397
  if (this.abis) {
3330
- const logs = getDecodedLogs(
3398
+ logs = getDecodedLogs(
3331
3399
  transactionSummary.receipts,
3332
3400
  this.abis.main,
3333
3401
  this.abis.otherContractsAbis
3334
3402
  );
3335
3403
  transactionResult.logs = logs;
3336
3404
  }
3405
+ if (transactionResult.isStatusFailure) {
3406
+ const {
3407
+ receipts,
3408
+ gqlTransaction: { status }
3409
+ } = transactionResult;
3410
+ throw extractTxError({
3411
+ receipts,
3412
+ status,
3413
+ logs
3414
+ });
3415
+ }
3337
3416
  return transactionResult;
3338
3417
  }
3339
3418
  /**
@@ -3342,14 +3421,7 @@ var TransactionResponse = class {
3342
3421
  * @param contractsAbiMap - The contracts ABI map.
3343
3422
  */
3344
3423
  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;
3424
+ return this.waitForResult(contractsAbiMap);
3353
3425
  }
3354
3426
  };
3355
3427
 
@@ -3411,29 +3483,29 @@ var processGqlChain = (chain) => {
3411
3483
  const { contractParams, feeParams, predicateParams, scriptParams, txParams, gasCosts } = consensusParameters;
3412
3484
  return {
3413
3485
  name,
3414
- baseChainHeight: (0, import_math14.bn)(daHeight),
3486
+ baseChainHeight: (0, import_math15.bn)(daHeight),
3415
3487
  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),
3488
+ contractMaxSize: (0, import_math15.bn)(contractParams.contractMaxSize),
3489
+ maxInputs: (0, import_math15.bn)(txParams.maxInputs),
3490
+ maxOutputs: (0, import_math15.bn)(txParams.maxOutputs),
3491
+ maxWitnesses: (0, import_math15.bn)(txParams.maxWitnesses),
3492
+ maxGasPerTx: (0, import_math15.bn)(txParams.maxGasPerTx),
3493
+ maxScriptLength: (0, import_math15.bn)(scriptParams.maxScriptLength),
3494
+ maxScriptDataLength: (0, import_math15.bn)(scriptParams.maxScriptDataLength),
3495
+ maxStorageSlots: (0, import_math15.bn)(contractParams.maxStorageSlots),
3496
+ maxPredicateLength: (0, import_math15.bn)(predicateParams.maxPredicateLength),
3497
+ maxPredicateDataLength: (0, import_math15.bn)(predicateParams.maxPredicateDataLength),
3498
+ maxGasPerPredicate: (0, import_math15.bn)(predicateParams.maxGasPerPredicate),
3499
+ gasPriceFactor: (0, import_math15.bn)(feeParams.gasPriceFactor),
3500
+ gasPerByte: (0, import_math15.bn)(feeParams.gasPerByte),
3501
+ maxMessageDataLength: (0, import_math15.bn)(predicateParams.maxMessageDataLength),
3502
+ chainId: (0, import_math15.bn)(consensusParameters.chainId),
3431
3503
  gasCosts
3432
3504
  },
3433
3505
  gasCosts,
3434
3506
  latestBlock: {
3435
3507
  id: latestBlock.id,
3436
- height: (0, import_math14.bn)(latestBlock.header.height),
3508
+ height: (0, import_math15.bn)(latestBlock.header.height),
3437
3509
  time: latestBlock.header.time,
3438
3510
  transactions: latestBlock.transactions.map((i) => ({
3439
3511
  id: i.id
@@ -3503,8 +3575,8 @@ var _Provider = class {
3503
3575
  getChain() {
3504
3576
  const chain = _Provider.chainInfoCache[this.url];
3505
3577
  if (!chain) {
3506
- throw new import_errors13.FuelError(
3507
- import_errors13.ErrorCode.CHAIN_INFO_CACHE_EMPTY,
3578
+ throw new import_errors14.FuelError(
3579
+ import_errors14.ErrorCode.CHAIN_INFO_CACHE_EMPTY,
3508
3580
  "Chain info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
3509
3581
  );
3510
3582
  }
@@ -3516,8 +3588,8 @@ var _Provider = class {
3516
3588
  getNode() {
3517
3589
  const node = _Provider.nodeInfoCache[this.url];
3518
3590
  if (!node) {
3519
- throw new import_errors13.FuelError(
3520
- import_errors13.ErrorCode.NODE_INFO_CACHE_EMPTY,
3591
+ throw new import_errors14.FuelError(
3592
+ import_errors14.ErrorCode.NODE_INFO_CACHE_EMPTY,
3521
3593
  "Node info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
3522
3594
  );
3523
3595
  }
@@ -3564,8 +3636,8 @@ var _Provider = class {
3564
3636
  static ensureClientVersionIsSupported(nodeInfo) {
3565
3637
  const { isMajorSupported, isMinorSupported, supportedVersion } = (0, import_versions.checkFuelCoreVersionCompatibility)(nodeInfo.nodeVersion);
3566
3638
  if (!isMajorSupported || !isMinorSupported) {
3567
- throw new import_errors13.FuelError(
3568
- import_errors13.FuelError.CODES.UNSUPPORTED_FUEL_CLIENT_VERSION,
3639
+ throw new import_errors14.FuelError(
3640
+ import_errors14.FuelError.CODES.UNSUPPORTED_FUEL_CLIENT_VERSION,
3569
3641
  `Fuel client version: ${nodeInfo.nodeVersion}, Supported version: ${supportedVersion}`
3570
3642
  );
3571
3643
  }
@@ -3628,7 +3700,7 @@ var _Provider = class {
3628
3700
  */
3629
3701
  async getBlockNumber() {
3630
3702
  const { chain } = await this.operations.getChain();
3631
- return (0, import_math14.bn)(chain.latestBlock.header.height, 10);
3703
+ return (0, import_math15.bn)(chain.latestBlock.header.height, 10);
3632
3704
  }
3633
3705
  /**
3634
3706
  * Returns the chain information.
@@ -3638,9 +3710,9 @@ var _Provider = class {
3638
3710
  async fetchNode() {
3639
3711
  const { nodeInfo } = await this.operations.getNodeInfo();
3640
3712
  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),
3713
+ maxDepth: (0, import_math15.bn)(nodeInfo.maxDepth),
3714
+ maxTx: (0, import_math15.bn)(nodeInfo.maxTx),
3715
+ minGasPrice: (0, import_math15.bn)(nodeInfo.minGasPrice),
3644
3716
  nodeVersion: nodeInfo.nodeVersion,
3645
3717
  utxoValidation: nodeInfo.utxoValidation,
3646
3718
  vmBacktrace: nodeInfo.vmBacktrace,
@@ -3686,17 +3758,17 @@ var _Provider = class {
3686
3758
  if (estimateTxDependencies) {
3687
3759
  await this.estimateTxDependencies(transactionRequest);
3688
3760
  }
3689
- const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
3761
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
3690
3762
  let abis;
3691
- if (transactionRequest.type === import_transactions17.TransactionType.Script) {
3763
+ if (transactionRequest.type === import_transactions18.TransactionType.Script) {
3692
3764
  abis = transactionRequest.abis;
3693
3765
  }
3694
3766
  if (awaitExecution) {
3695
3767
  const subscription = this.operations.submitAndAwait({ encodedTransaction });
3696
3768
  for await (const { submitAndAwait } of subscription) {
3697
3769
  if (submitAndAwait.type === "SqueezedOutStatus") {
3698
- throw new import_errors13.FuelError(
3699
- import_errors13.ErrorCode.TRANSACTION_SQUEEZED_OUT,
3770
+ throw new import_errors14.FuelError(
3771
+ import_errors14.ErrorCode.TRANSACTION_SQUEEZED_OUT,
3700
3772
  `Transaction Squeezed Out with reason: ${submitAndAwait.reason}`
3701
3773
  );
3702
3774
  }
@@ -3729,7 +3801,7 @@ var _Provider = class {
3729
3801
  if (estimateTxDependencies) {
3730
3802
  return this.estimateTxDependencies(transactionRequest);
3731
3803
  }
3732
- const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
3804
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
3733
3805
  const { dryRun: gqlReceipts } = await this.operations.dryRun({
3734
3806
  encodedTransaction,
3735
3807
  utxoValidation: utxoValidation || false
@@ -3748,13 +3820,13 @@ var _Provider = class {
3748
3820
  async estimatePredicates(transactionRequest) {
3749
3821
  const shouldEstimatePredicates = Boolean(
3750
3822
  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()
3823
+ (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
3824
  )
3753
3825
  );
3754
3826
  if (!shouldEstimatePredicates) {
3755
3827
  return transactionRequest;
3756
3828
  }
3757
- const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
3829
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
3758
3830
  const response = await this.operations.estimatePredicates({
3759
3831
  encodedTransaction
3760
3832
  });
@@ -3763,7 +3835,7 @@ var _Provider = class {
3763
3835
  } = response;
3764
3836
  if (inputs) {
3765
3837
  inputs.forEach((input, index) => {
3766
- if ("predicateGasUsed" in input && (0, import_math14.bn)(input.predicateGasUsed).gt(0)) {
3838
+ if ("predicateGasUsed" in input && (0, import_math15.bn)(input.predicateGasUsed).gt(0)) {
3767
3839
  transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
3768
3840
  }
3769
3841
  });
@@ -3784,7 +3856,7 @@ var _Provider = class {
3784
3856
  * @returns A promise.
3785
3857
  */
3786
3858
  async estimateTxDependencies(transactionRequest) {
3787
- if (transactionRequest.type === import_transactions17.TransactionType.Create) {
3859
+ if (transactionRequest.type === import_transactions18.TransactionType.Create) {
3788
3860
  return {
3789
3861
  receipts: [],
3790
3862
  outputVariables: 0,
@@ -3797,7 +3869,7 @@ var _Provider = class {
3797
3869
  let outputVariables = 0;
3798
3870
  for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
3799
3871
  const { dryRun: gqlReceipts } = await this.operations.dryRun({
3800
- encodedTransaction: (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes()),
3872
+ encodedTransaction: (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes()),
3801
3873
  utxoValidation: false
3802
3874
  });
3803
3875
  receipts = gqlReceipts.map(processGqlReceipt);
@@ -3820,6 +3892,36 @@ var _Provider = class {
3820
3892
  missingContractIds
3821
3893
  };
3822
3894
  }
3895
+ /**
3896
+ * Estimates the transaction gas and fee based on the provided transaction request.
3897
+ * @param transactionRequest - The transaction request object.
3898
+ * @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
3899
+ */
3900
+ estimateTxGasAndFee(params) {
3901
+ const { transactionRequest } = params;
3902
+ const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
3903
+ const chainInfo = this.getChain();
3904
+ const gasPrice = transactionRequest.gasPrice.eq(0) ? minGasPrice : transactionRequest.gasPrice;
3905
+ transactionRequest.gasPrice = gasPrice;
3906
+ const minGas = transactionRequest.calculateMinGas(chainInfo);
3907
+ const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
3908
+ if (transactionRequest.type === import_transactions18.TransactionType.Script) {
3909
+ if (transactionRequest.gasLimit.eq(0)) {
3910
+ transactionRequest.gasLimit = minGas;
3911
+ transactionRequest.gasLimit = maxGasPerTx.sub(
3912
+ transactionRequest.calculateMaxGas(chainInfo, minGas)
3913
+ );
3914
+ }
3915
+ }
3916
+ const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
3917
+ const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
3918
+ return {
3919
+ minGas,
3920
+ minFee,
3921
+ maxGas,
3922
+ maxFee
3923
+ };
3924
+ }
3823
3925
  /**
3824
3926
  * Executes a signed transaction without applying the states changes
3825
3927
  * on the chain.
@@ -3835,7 +3937,7 @@ var _Provider = class {
3835
3937
  if (estimateTxDependencies) {
3836
3938
  return this.estimateTxDependencies(transactionRequest);
3837
3939
  }
3838
- const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
3940
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
3839
3941
  const { dryRun: gqlReceipts } = await this.operations.dryRun({
3840
3942
  encodedTransaction,
3841
3943
  utxoValidation: true
@@ -3867,17 +3969,16 @@ var _Provider = class {
3867
3969
  signatureCallback
3868
3970
  } = {}) {
3869
3971
  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;
3972
+ const { minGasPrice } = this.getGasConfig();
3973
+ const setGasPrice = (0, import_math15.max)(txRequestClone.gasPrice, minGasPrice);
3974
+ const isScriptTransaction = txRequestClone.type === import_transactions18.TransactionType.Script;
3874
3975
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
3875
3976
  const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
3876
3977
  txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
3978
+ if (isScriptTransaction) {
3979
+ txRequestClone.gasLimit = (0, import_math15.bn)(0);
3980
+ }
3877
3981
  if (estimatePredicates) {
3878
- if (isScriptTransaction) {
3879
- txRequestClone.gasLimit = (0, import_math14.bn)(0);
3880
- }
3881
3982
  if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
3882
3983
  resourcesOwner.populateTransactionPredicateData(txRequestClone);
3883
3984
  }
@@ -3886,36 +3987,34 @@ var _Provider = class {
3886
3987
  if (signatureCallback && isScriptTransaction) {
3887
3988
  await signatureCallback(txRequestClone);
3888
3989
  }
3889
- const minGas = txRequestClone.calculateMinGas(chainInfo);
3890
- const maxGas = txRequestClone.calculateMaxGas(chainInfo, minGas);
3990
+ let { maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
3991
+ transactionRequest: txRequestClone
3992
+ });
3891
3993
  let receipts = [];
3892
3994
  let missingContractIds = [];
3893
3995
  let outputVariables = 0;
3996
+ let gasUsed = (0, import_math15.bn)(0);
3894
3997
  if (isScriptTransaction && estimateTxDependencies) {
3895
- txRequestClone.gasPrice = (0, import_math14.bn)(0);
3896
- txRequestClone.gasLimit = (0, import_math14.bn)(maxGasPerTx.sub(maxGas).toNumber() * 0.9);
3998
+ txRequestClone.gasPrice = (0, import_math15.bn)(0);
3897
3999
  const result = await this.estimateTxDependencies(txRequestClone);
3898
4000
  receipts = result.receipts;
3899
4001
  outputVariables = result.outputVariables;
3900
4002
  missingContractIds = result.missingContractIds;
4003
+ gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
4004
+ txRequestClone.gasLimit = gasUsed;
4005
+ txRequestClone.gasPrice = setGasPrice;
4006
+ ({ maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
4007
+ transactionRequest: txRequestClone
4008
+ }));
3901
4009
  }
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
4010
  return {
3911
4011
  requiredQuantities: allQuantities,
3912
4012
  receipts,
3913
4013
  gasUsed,
3914
4014
  minGasPrice,
3915
- gasPrice,
4015
+ gasPrice: setGasPrice,
3916
4016
  minGas,
3917
4017
  maxGas,
3918
- usedFee,
3919
4018
  minFee,
3920
4019
  maxFee,
3921
4020
  estimatedInputs: txRequestClone.inputs,
@@ -3949,17 +4048,17 @@ var _Provider = class {
3949
4048
  const result = await this.operations.getCoins({
3950
4049
  first: 10,
3951
4050
  ...paginationArgs,
3952
- filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils22.hexlify)(assetId) }
4051
+ filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils23.hexlify)(assetId) }
3953
4052
  });
3954
4053
  const coins = result.coins.edges.map((edge) => edge.node);
3955
4054
  return coins.map((coin) => ({
3956
4055
  id: coin.utxoId,
3957
4056
  assetId: coin.assetId,
3958
- amount: (0, import_math14.bn)(coin.amount),
4057
+ amount: (0, import_math15.bn)(coin.amount),
3959
4058
  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)
4059
+ maturity: (0, import_math15.bn)(coin.maturity).toNumber(),
4060
+ blockCreated: (0, import_math15.bn)(coin.blockCreated),
4061
+ txCreatedIdx: (0, import_math15.bn)(coin.txCreatedIdx)
3963
4062
  }));
3964
4063
  }
3965
4064
  /**
@@ -3973,19 +4072,19 @@ var _Provider = class {
3973
4072
  async getResourcesToSpend(owner, quantities, excludedIds) {
3974
4073
  const ownerAddress = import_address3.Address.fromAddressOrString(owner);
3975
4074
  const excludeInput = {
3976
- messages: excludedIds?.messages?.map((nonce) => (0, import_utils22.hexlify)(nonce)) || [],
3977
- utxos: excludedIds?.utxos?.map((id) => (0, import_utils22.hexlify)(id)) || []
4075
+ messages: excludedIds?.messages?.map((nonce) => (0, import_utils23.hexlify)(nonce)) || [],
4076
+ utxos: excludedIds?.utxos?.map((id) => (0, import_utils23.hexlify)(id)) || []
3978
4077
  };
3979
4078
  if (this.cache) {
3980
4079
  const uniqueUtxos = new Set(
3981
- excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0, import_utils22.hexlify)(id)))
4080
+ excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0, import_utils23.hexlify)(id)))
3982
4081
  );
3983
4082
  excludeInput.utxos = Array.from(uniqueUtxos);
3984
4083
  }
3985
4084
  const coinsQuery = {
3986
4085
  owner: ownerAddress.toB256(),
3987
4086
  queryPerAsset: quantities.map(coinQuantityfy).map(({ assetId, amount, max: maxPerAsset }) => ({
3988
- assetId: (0, import_utils22.hexlify)(assetId),
4087
+ assetId: (0, import_utils23.hexlify)(assetId),
3989
4088
  amount: amount.toString(10),
3990
4089
  max: maxPerAsset ? maxPerAsset.toString(10) : void 0
3991
4090
  })),
@@ -3996,9 +4095,9 @@ var _Provider = class {
3996
4095
  switch (coin.__typename) {
3997
4096
  case "MessageCoin":
3998
4097
  return {
3999
- amount: (0, import_math14.bn)(coin.amount),
4098
+ amount: (0, import_math15.bn)(coin.amount),
4000
4099
  assetId: coin.assetId,
4001
- daHeight: (0, import_math14.bn)(coin.daHeight),
4100
+ daHeight: (0, import_math15.bn)(coin.daHeight),
4002
4101
  sender: import_address3.Address.fromAddressOrString(coin.sender),
4003
4102
  recipient: import_address3.Address.fromAddressOrString(coin.recipient),
4004
4103
  nonce: coin.nonce
@@ -4006,12 +4105,12 @@ var _Provider = class {
4006
4105
  case "Coin":
4007
4106
  return {
4008
4107
  id: coin.utxoId,
4009
- amount: (0, import_math14.bn)(coin.amount),
4108
+ amount: (0, import_math15.bn)(coin.amount),
4010
4109
  assetId: coin.assetId,
4011
4110
  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)
4111
+ maturity: (0, import_math15.bn)(coin.maturity).toNumber(),
4112
+ blockCreated: (0, import_math15.bn)(coin.blockCreated),
4113
+ txCreatedIdx: (0, import_math15.bn)(coin.txCreatedIdx)
4015
4114
  };
4016
4115
  default:
4017
4116
  return null;
@@ -4028,13 +4127,13 @@ var _Provider = class {
4028
4127
  async getBlock(idOrHeight) {
4029
4128
  let variables;
4030
4129
  if (typeof idOrHeight === "number") {
4031
- variables = { height: (0, import_math14.bn)(idOrHeight).toString(10) };
4130
+ variables = { height: (0, import_math15.bn)(idOrHeight).toString(10) };
4032
4131
  } else if (idOrHeight === "latest") {
4033
4132
  variables = { height: (await this.getBlockNumber()).toString(10) };
4034
4133
  } else if (idOrHeight.length === 66) {
4035
4134
  variables = { blockId: idOrHeight };
4036
4135
  } else {
4037
- variables = { blockId: (0, import_math14.bn)(idOrHeight).toString(10) };
4136
+ variables = { blockId: (0, import_math15.bn)(idOrHeight).toString(10) };
4038
4137
  }
4039
4138
  const { block } = await this.operations.getBlock(variables);
4040
4139
  if (!block) {
@@ -4042,7 +4141,7 @@ var _Provider = class {
4042
4141
  }
4043
4142
  return {
4044
4143
  id: block.id,
4045
- height: (0, import_math14.bn)(block.header.height),
4144
+ height: (0, import_math15.bn)(block.header.height),
4046
4145
  time: block.header.time,
4047
4146
  transactionIds: block.transactions.map((tx) => tx.id)
4048
4147
  };
@@ -4057,7 +4156,7 @@ var _Provider = class {
4057
4156
  const { blocks: fetchedData } = await this.operations.getBlocks(params);
4058
4157
  const blocks = fetchedData.edges.map(({ node: block }) => ({
4059
4158
  id: block.id,
4060
- height: (0, import_math14.bn)(block.header.height),
4159
+ height: (0, import_math15.bn)(block.header.height),
4061
4160
  time: block.header.time,
4062
4161
  transactionIds: block.transactions.map((tx) => tx.id)
4063
4162
  }));
@@ -4072,7 +4171,7 @@ var _Provider = class {
4072
4171
  async getBlockWithTransactions(idOrHeight) {
4073
4172
  let variables;
4074
4173
  if (typeof idOrHeight === "number") {
4075
- variables = { blockHeight: (0, import_math14.bn)(idOrHeight).toString(10) };
4174
+ variables = { blockHeight: (0, import_math15.bn)(idOrHeight).toString(10) };
4076
4175
  } else if (idOrHeight === "latest") {
4077
4176
  variables = { blockHeight: (await this.getBlockNumber()).toString() };
4078
4177
  } else {
@@ -4084,11 +4183,11 @@ var _Provider = class {
4084
4183
  }
4085
4184
  return {
4086
4185
  id: block.id,
4087
- height: (0, import_math14.bn)(block.header.height, 10),
4186
+ height: (0, import_math15.bn)(block.header.height, 10),
4088
4187
  time: block.header.time,
4089
4188
  transactionIds: block.transactions.map((tx) => tx.id),
4090
4189
  transactions: block.transactions.map(
4091
- (tx) => new import_transactions17.TransactionCoder().decode((0, import_utils22.arrayify)(tx.rawPayload), 0)?.[0]
4190
+ (tx) => new import_transactions18.TransactionCoder().decode((0, import_utils23.arrayify)(tx.rawPayload), 0)?.[0]
4092
4191
  )
4093
4192
  };
4094
4193
  }
@@ -4103,8 +4202,8 @@ var _Provider = class {
4103
4202
  if (!transaction) {
4104
4203
  return null;
4105
4204
  }
4106
- return new import_transactions17.TransactionCoder().decode(
4107
- (0, import_utils22.arrayify)(transaction.rawPayload),
4205
+ return new import_transactions18.TransactionCoder().decode(
4206
+ (0, import_utils23.arrayify)(transaction.rawPayload),
4108
4207
  0
4109
4208
  )?.[0];
4110
4209
  }
@@ -4131,9 +4230,9 @@ var _Provider = class {
4131
4230
  async getContractBalance(contractId, assetId) {
4132
4231
  const { contractBalance } = await this.operations.getContractBalance({
4133
4232
  contract: import_address3.Address.fromAddressOrString(contractId).toB256(),
4134
- asset: (0, import_utils22.hexlify)(assetId)
4233
+ asset: (0, import_utils23.hexlify)(assetId)
4135
4234
  });
4136
- return (0, import_math14.bn)(contractBalance.amount, 10);
4235
+ return (0, import_math15.bn)(contractBalance.amount, 10);
4137
4236
  }
4138
4237
  /**
4139
4238
  * Returns the balance for the given owner for the given asset ID.
@@ -4145,9 +4244,9 @@ var _Provider = class {
4145
4244
  async getBalance(owner, assetId) {
4146
4245
  const { balance } = await this.operations.getBalance({
4147
4246
  owner: import_address3.Address.fromAddressOrString(owner).toB256(),
4148
- assetId: (0, import_utils22.hexlify)(assetId)
4247
+ assetId: (0, import_utils23.hexlify)(assetId)
4149
4248
  });
4150
- return (0, import_math14.bn)(balance.amount, 10);
4249
+ return (0, import_math15.bn)(balance.amount, 10);
4151
4250
  }
4152
4251
  /**
4153
4252
  * Returns balances for the given owner.
@@ -4165,7 +4264,7 @@ var _Provider = class {
4165
4264
  const balances = result.balances.edges.map((edge) => edge.node);
4166
4265
  return balances.map((balance) => ({
4167
4266
  assetId: balance.assetId,
4168
- amount: (0, import_math14.bn)(balance.amount)
4267
+ amount: (0, import_math15.bn)(balance.amount)
4169
4268
  }));
4170
4269
  }
4171
4270
  /**
@@ -4183,19 +4282,19 @@ var _Provider = class {
4183
4282
  });
4184
4283
  const messages = result.messages.edges.map((edge) => edge.node);
4185
4284
  return messages.map((message) => ({
4186
- messageId: import_transactions17.InputMessageCoder.getMessageId({
4285
+ messageId: import_transactions18.InputMessageCoder.getMessageId({
4187
4286
  sender: message.sender,
4188
4287
  recipient: message.recipient,
4189
4288
  nonce: message.nonce,
4190
- amount: (0, import_math14.bn)(message.amount),
4289
+ amount: (0, import_math15.bn)(message.amount),
4191
4290
  data: message.data
4192
4291
  }),
4193
4292
  sender: import_address3.Address.fromAddressOrString(message.sender),
4194
4293
  recipient: import_address3.Address.fromAddressOrString(message.recipient),
4195
4294
  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)
4295
+ amount: (0, import_math15.bn)(message.amount),
4296
+ data: import_transactions18.InputMessageCoder.decodeData(message.data),
4297
+ daHeight: (0, import_math15.bn)(message.daHeight)
4199
4298
  }));
4200
4299
  }
4201
4300
  /**
@@ -4213,8 +4312,8 @@ var _Provider = class {
4213
4312
  nonce
4214
4313
  };
4215
4314
  if (commitBlockId && commitBlockHeight) {
4216
- throw new import_errors13.FuelError(
4217
- import_errors13.ErrorCode.INVALID_INPUT_PARAMETERS,
4315
+ throw new import_errors14.FuelError(
4316
+ import_errors14.ErrorCode.INVALID_INPUT_PARAMETERS,
4218
4317
  "commitBlockId and commitBlockHeight cannot be used together"
4219
4318
  );
4220
4319
  }
@@ -4248,41 +4347,41 @@ var _Provider = class {
4248
4347
  } = result.messageProof;
4249
4348
  return {
4250
4349
  messageProof: {
4251
- proofIndex: (0, import_math14.bn)(messageProof.proofIndex),
4350
+ proofIndex: (0, import_math15.bn)(messageProof.proofIndex),
4252
4351
  proofSet: messageProof.proofSet
4253
4352
  },
4254
4353
  blockProof: {
4255
- proofIndex: (0, import_math14.bn)(blockProof.proofIndex),
4354
+ proofIndex: (0, import_math15.bn)(blockProof.proofIndex),
4256
4355
  proofSet: blockProof.proofSet
4257
4356
  },
4258
4357
  messageBlockHeader: {
4259
4358
  id: messageBlockHeader.id,
4260
- daHeight: (0, import_math14.bn)(messageBlockHeader.daHeight),
4261
- transactionsCount: (0, import_math14.bn)(messageBlockHeader.transactionsCount),
4359
+ daHeight: (0, import_math15.bn)(messageBlockHeader.daHeight),
4360
+ transactionsCount: (0, import_math15.bn)(messageBlockHeader.transactionsCount),
4262
4361
  transactionsRoot: messageBlockHeader.transactionsRoot,
4263
- height: (0, import_math14.bn)(messageBlockHeader.height),
4362
+ height: (0, import_math15.bn)(messageBlockHeader.height),
4264
4363
  prevRoot: messageBlockHeader.prevRoot,
4265
4364
  time: messageBlockHeader.time,
4266
4365
  applicationHash: messageBlockHeader.applicationHash,
4267
4366
  messageReceiptRoot: messageBlockHeader.messageReceiptRoot,
4268
- messageReceiptCount: (0, import_math14.bn)(messageBlockHeader.messageReceiptCount)
4367
+ messageReceiptCount: (0, import_math15.bn)(messageBlockHeader.messageReceiptCount)
4269
4368
  },
4270
4369
  commitBlockHeader: {
4271
4370
  id: commitBlockHeader.id,
4272
- daHeight: (0, import_math14.bn)(commitBlockHeader.daHeight),
4273
- transactionsCount: (0, import_math14.bn)(commitBlockHeader.transactionsCount),
4371
+ daHeight: (0, import_math15.bn)(commitBlockHeader.daHeight),
4372
+ transactionsCount: (0, import_math15.bn)(commitBlockHeader.transactionsCount),
4274
4373
  transactionsRoot: commitBlockHeader.transactionsRoot,
4275
- height: (0, import_math14.bn)(commitBlockHeader.height),
4374
+ height: (0, import_math15.bn)(commitBlockHeader.height),
4276
4375
  prevRoot: commitBlockHeader.prevRoot,
4277
4376
  time: commitBlockHeader.time,
4278
4377
  applicationHash: commitBlockHeader.applicationHash,
4279
4378
  messageReceiptRoot: commitBlockHeader.messageReceiptRoot,
4280
- messageReceiptCount: (0, import_math14.bn)(commitBlockHeader.messageReceiptCount)
4379
+ messageReceiptCount: (0, import_math15.bn)(commitBlockHeader.messageReceiptCount)
4281
4380
  },
4282
4381
  sender: import_address3.Address.fromAddressOrString(sender),
4283
4382
  recipient: import_address3.Address.fromAddressOrString(recipient),
4284
4383
  nonce,
4285
- amount: (0, import_math14.bn)(amount),
4384
+ amount: (0, import_math15.bn)(amount),
4286
4385
  data
4287
4386
  };
4288
4387
  }
@@ -4305,10 +4404,10 @@ var _Provider = class {
4305
4404
  */
4306
4405
  async produceBlocks(amount, startTime) {
4307
4406
  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
4407
+ blocksToProduce: (0, import_math15.bn)(amount).toString(10),
4408
+ startTimestamp: startTime ? import_utils23.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
4310
4409
  });
4311
- return (0, import_math14.bn)(latestBlockHeight);
4410
+ return (0, import_math15.bn)(latestBlockHeight);
4312
4411
  }
4313
4412
  // eslint-disable-next-line @typescript-eslint/require-await
4314
4413
  async getTransactionResponse(transactionId) {
@@ -4322,7 +4421,7 @@ cacheInputs_fn = function(inputs) {
4322
4421
  return;
4323
4422
  }
4324
4423
  inputs.forEach((input) => {
4325
- if (input.type === import_transactions17.InputType.Coin) {
4424
+ if (input.type === import_transactions18.InputType.Coin) {
4326
4425
  this.cache?.set(input.id);
4327
4426
  }
4328
4427
  });
@@ -4331,10 +4430,10 @@ __publicField(Provider, "chainInfoCache", {});
4331
4430
  __publicField(Provider, "nodeInfoCache", {});
4332
4431
 
4333
4432
  // 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");
4433
+ var import_errors15 = require("@fuel-ts/errors");
4434
+ var import_math16 = require("@fuel-ts/math");
4435
+ var import_transactions19 = require("@fuel-ts/transactions");
4436
+ var import_utils26 = require("@fuel-ts/utils");
4338
4437
 
4339
4438
  // src/providers/chains.ts
4340
4439
  var CHAIN_IDS = {
@@ -4382,18 +4481,18 @@ var assets = [
4382
4481
  ];
4383
4482
 
4384
4483
  // 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");
4484
+ var import_abi_coder6 = require("@fuel-ts/abi-coder");
4485
+ var import_math17 = require("@fuel-ts/math");
4486
+ var import_utils27 = require("@fuel-ts/utils");
4388
4487
  var asm = __toESM(require("@fuels/vm-asm"));
4389
4488
  var formatTransferToContractScriptData = (params) => {
4390
4489
  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());
4490
+ const numberCoder = new import_abi_coder6.BigNumberCoder("u64");
4491
+ const encoded = numberCoder.encode(new import_math17.BN(amountToTransfer).toNumber());
4393
4492
  const scriptData = Uint8Array.from([
4394
- ...(0, import_utils26.arrayify)(hexlifiedContractId),
4493
+ ...(0, import_utils27.arrayify)(hexlifiedContractId),
4395
4494
  ...encoded,
4396
- ...(0, import_utils26.arrayify)(assetId)
4495
+ ...(0, import_utils27.arrayify)(assetId)
4397
4496
  ]);
4398
4497
  return scriptData;
4399
4498
  };
@@ -4449,7 +4548,7 @@ var Account = class extends import_interfaces.AbstractAccount {
4449
4548
  */
4450
4549
  get provider() {
4451
4550
  if (!this._provider) {
4452
- throw new import_errors15.FuelError(import_errors15.ErrorCode.MISSING_PROVIDER, "Provider not set");
4551
+ throw new import_errors16.FuelError(import_errors16.ErrorCode.MISSING_PROVIDER, "Provider not set");
4453
4552
  }
4454
4553
  return this._provider;
4455
4554
  }
@@ -4501,8 +4600,8 @@ var Account = class extends import_interfaces.AbstractAccount {
4501
4600
  if (!hasNextPage) {
4502
4601
  break;
4503
4602
  }
4504
- throw new import_errors15.FuelError(
4505
- import_errors15.ErrorCode.NOT_SUPPORTED,
4603
+ throw new import_errors16.FuelError(
4604
+ import_errors16.ErrorCode.NOT_SUPPORTED,
4506
4605
  `Wallets containing more than ${pageSize} coins exceed the current supported limit.`
4507
4606
  );
4508
4607
  }
@@ -4527,8 +4626,8 @@ var Account = class extends import_interfaces.AbstractAccount {
4527
4626
  if (!hasNextPage) {
4528
4627
  break;
4529
4628
  }
4530
- throw new import_errors15.FuelError(
4531
- import_errors15.ErrorCode.NOT_SUPPORTED,
4629
+ throw new import_errors16.FuelError(
4630
+ import_errors16.ErrorCode.NOT_SUPPORTED,
4532
4631
  `Wallets containing more than ${pageSize} messages exceed the current supported limit.`
4533
4632
  );
4534
4633
  }
@@ -4540,7 +4639,7 @@ var Account = class extends import_interfaces.AbstractAccount {
4540
4639
  * @param assetId - The asset ID to check the balance for.
4541
4640
  * @returns A promise that resolves to the balance amount.
4542
4641
  */
4543
- async getBalance(assetId = import_configs11.BaseAssetId) {
4642
+ async getBalance(assetId = import_configs12.BaseAssetId) {
4544
4643
  const amount = await this.provider.getBalance(this.address, assetId);
4545
4644
  return amount;
4546
4645
  }
@@ -4563,8 +4662,8 @@ var Account = class extends import_interfaces.AbstractAccount {
4563
4662
  if (!hasNextPage) {
4564
4663
  break;
4565
4664
  }
4566
- throw new import_errors15.FuelError(
4567
- import_errors15.ErrorCode.NOT_SUPPORTED,
4665
+ throw new import_errors16.FuelError(
4666
+ import_errors16.ErrorCode.NOT_SUPPORTED,
4568
4667
  `Wallets containing more than ${pageSize} balances exceed the current supported limit.`
4569
4668
  );
4570
4669
  }
@@ -4580,15 +4679,15 @@ var Account = class extends import_interfaces.AbstractAccount {
4580
4679
  */
4581
4680
  async fund(request, coinQuantities, fee) {
4582
4681
  const updatedQuantities = addAmountToAsset({
4583
- amount: (0, import_math17.bn)(fee),
4584
- assetId: import_configs11.BaseAssetId,
4682
+ amount: (0, import_math18.bn)(fee),
4683
+ assetId: import_configs12.BaseAssetId,
4585
4684
  coinQuantities
4586
4685
  });
4587
4686
  const quantitiesDict = {};
4588
4687
  updatedQuantities.forEach(({ amount, assetId }) => {
4589
4688
  quantitiesDict[assetId] = {
4590
4689
  required: amount,
4591
- owned: (0, import_math17.bn)(0)
4690
+ owned: (0, import_math18.bn)(0)
4592
4691
  };
4593
4692
  });
4594
4693
  const cachedUtxos = [];
@@ -4601,12 +4700,12 @@ var Account = class extends import_interfaces.AbstractAccount {
4601
4700
  if (isCoin2) {
4602
4701
  const assetId = String(input.assetId);
4603
4702
  if (input.owner === owner && quantitiesDict[assetId]) {
4604
- const amount = (0, import_math17.bn)(input.amount);
4703
+ const amount = (0, import_math18.bn)(input.amount);
4605
4704
  quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
4606
4705
  cachedUtxos.push(input.id);
4607
4706
  }
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);
4707
+ } else if (input.recipient === owner && input.amount && quantitiesDict[import_configs12.BaseAssetId]) {
4708
+ quantitiesDict[import_configs12.BaseAssetId].owned = quantitiesDict[import_configs12.BaseAssetId].owned.add(input.amount);
4610
4709
  cachedMessages.push(input.nonce);
4611
4710
  }
4612
4711
  }
@@ -4638,7 +4737,7 @@ var Account = class extends import_interfaces.AbstractAccount {
4638
4737
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
4639
4738
  * @returns A promise that resolves to the prepared transaction request.
4640
4739
  */
4641
- async createTransfer(destination, amount, assetId = import_configs11.BaseAssetId, txParams = {}) {
4740
+ async createTransfer(destination, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
4642
4741
  const { minGasPrice } = this.provider.getGasConfig();
4643
4742
  const params = { gasPrice: minGasPrice, ...txParams };
4644
4743
  const request = new ScriptTransactionRequest(params);
@@ -4647,8 +4746,8 @@ var Account = class extends import_interfaces.AbstractAccount {
4647
4746
  estimateTxDependencies: true,
4648
4747
  resourcesOwner: this
4649
4748
  });
4650
- request.gasPrice = (0, import_math17.bn)(txParams.gasPrice ?? minGasPrice);
4651
- request.gasLimit = (0, import_math17.bn)(txParams.gasLimit ?? gasUsed);
4749
+ request.gasPrice = (0, import_math18.bn)(txParams.gasPrice ?? minGasPrice);
4750
+ request.gasLimit = (0, import_math18.bn)(txParams.gasLimit ?? gasUsed);
4652
4751
  this.validateGas({
4653
4752
  gasUsed,
4654
4753
  gasPrice: request.gasPrice,
@@ -4668,10 +4767,10 @@ var Account = class extends import_interfaces.AbstractAccount {
4668
4767
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
4669
4768
  * @returns A promise that resolves to the transaction response.
4670
4769
  */
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,
4770
+ async transfer(destination, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
4771
+ if ((0, import_math18.bn)(amount).lte(0)) {
4772
+ throw new import_errors16.FuelError(
4773
+ import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
4675
4774
  "Transfer amount must be a positive number."
4676
4775
  );
4677
4776
  }
@@ -4687,10 +4786,10 @@ var Account = class extends import_interfaces.AbstractAccount {
4687
4786
  * @param txParams - The optional transaction parameters.
4688
4787
  * @returns A promise that resolves to the transaction response.
4689
4788
  */
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,
4789
+ async transferToContract(contractId, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
4790
+ if ((0, import_math18.bn)(amount).lte(0)) {
4791
+ throw new import_errors16.FuelError(
4792
+ import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
4694
4793
  "Transfer amount must be a positive number."
4695
4794
  );
4696
4795
  }
@@ -4699,7 +4798,7 @@ var Account = class extends import_interfaces.AbstractAccount {
4699
4798
  const params = { gasPrice: minGasPrice, ...txParams };
4700
4799
  const { script, scriptData } = await assembleTransferToContractScript({
4701
4800
  hexlifiedContractId: contractAddress.toB256(),
4702
- amountToTransfer: (0, import_math17.bn)(amount),
4801
+ amountToTransfer: (0, import_math18.bn)(amount),
4703
4802
  assetId
4704
4803
  });
4705
4804
  const request = new ScriptTransactionRequest({
@@ -4710,9 +4809,9 @@ var Account = class extends import_interfaces.AbstractAccount {
4710
4809
  request.addContractInputAndOutput(contractAddress);
4711
4810
  const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
4712
4811
  request,
4713
- [{ amount: (0, import_math17.bn)(amount), assetId: String(assetId) }]
4812
+ [{ amount: (0, import_math18.bn)(amount), assetId: String(assetId) }]
4714
4813
  );
4715
- request.gasLimit = (0, import_math17.bn)(params.gasLimit ?? gasUsed);
4814
+ request.gasLimit = (0, import_math18.bn)(params.gasLimit ?? gasUsed);
4716
4815
  this.validateGas({
4717
4816
  gasUsed,
4718
4817
  gasPrice: request.gasPrice,
@@ -4733,25 +4832,25 @@ var Account = class extends import_interfaces.AbstractAccount {
4733
4832
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
4734
4833
  const { minGasPrice } = this.provider.getGasConfig();
4735
4834
  const recipientAddress = import_address4.Address.fromAddressOrString(recipient);
4736
- const recipientDataArray = (0, import_utils27.arrayify)(
4835
+ const recipientDataArray = (0, import_utils28.arrayify)(
4737
4836
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
4738
4837
  );
4739
- const amountDataArray = (0, import_utils27.arrayify)(
4740
- "0x".concat((0, import_math17.bn)(amount).toHex().substring(2).padStart(16, "0"))
4838
+ const amountDataArray = (0, import_utils28.arrayify)(
4839
+ "0x".concat((0, import_math18.bn)(amount).toHex().substring(2).padStart(16, "0"))
4741
4840
  );
4742
4841
  const script = new Uint8Array([
4743
- ...(0, import_utils27.arrayify)(withdrawScript.bytes),
4842
+ ...(0, import_utils28.arrayify)(withdrawScript.bytes),
4744
4843
  ...recipientDataArray,
4745
4844
  ...amountDataArray
4746
4845
  ]);
4747
4846
  const params = { script, gasPrice: minGasPrice, ...txParams };
4748
4847
  const request = new ScriptTransactionRequest(params);
4749
- const forwardingQuantities = [{ amount: (0, import_math17.bn)(amount), assetId: import_configs11.BaseAssetId }];
4848
+ const forwardingQuantities = [{ amount: (0, import_math18.bn)(amount), assetId: import_configs12.BaseAssetId }];
4750
4849
  const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
4751
4850
  request,
4752
4851
  forwardingQuantities
4753
4852
  );
4754
- request.gasLimit = (0, import_math17.bn)(params.gasLimit ?? gasUsed);
4853
+ request.gasLimit = (0, import_math18.bn)(params.gasLimit ?? gasUsed);
4755
4854
  this.validateGas({
4756
4855
  gasUsed,
4757
4856
  gasPrice: request.gasPrice,
@@ -4763,7 +4862,7 @@ var Account = class extends import_interfaces.AbstractAccount {
4763
4862
  }
4764
4863
  async signMessage(message) {
4765
4864
  if (!this._connector) {
4766
- throw new import_errors15.FuelError(import_errors15.ErrorCode.MISSING_CONNECTOR, "A connector is required to sign messages.");
4865
+ throw new import_errors16.FuelError(import_errors16.ErrorCode.MISSING_CONNECTOR, "A connector is required to sign messages.");
4767
4866
  }
4768
4867
  return this._connector.signMessage(this.address.toString(), message);
4769
4868
  }
@@ -4775,8 +4874,8 @@ var Account = class extends import_interfaces.AbstractAccount {
4775
4874
  */
4776
4875
  async signTransaction(transactionRequestLike) {
4777
4876
  if (!this._connector) {
4778
- throw new import_errors15.FuelError(
4779
- import_errors15.ErrorCode.MISSING_CONNECTOR,
4877
+ throw new import_errors16.FuelError(
4878
+ import_errors16.ErrorCode.MISSING_CONNECTOR,
4780
4879
  "A connector is required to sign transactions."
4781
4880
  );
4782
4881
  }
@@ -4823,14 +4922,14 @@ var Account = class extends import_interfaces.AbstractAccount {
4823
4922
  minGasPrice
4824
4923
  }) {
4825
4924
  if (minGasPrice.gt(gasPrice)) {
4826
- throw new import_errors15.FuelError(
4827
- import_errors15.ErrorCode.GAS_PRICE_TOO_LOW,
4925
+ throw new import_errors16.FuelError(
4926
+ import_errors16.ErrorCode.GAS_PRICE_TOO_LOW,
4828
4927
  `Gas price '${gasPrice}' is lower than the required: '${minGasPrice}'.`
4829
4928
  );
4830
4929
  }
4831
4930
  if (gasUsed.gt(gasLimit)) {
4832
- throw new import_errors15.FuelError(
4833
- import_errors15.ErrorCode.GAS_LIMIT_TOO_LOW,
4931
+ throw new import_errors16.FuelError(
4932
+ import_errors16.ErrorCode.GAS_LIMIT_TOO_LOW,
4834
4933
  `Gas limit '${gasLimit}' is lower than the required: '${gasUsed}'.`
4835
4934
  );
4836
4935
  }
@@ -4839,10 +4938,10 @@ var Account = class extends import_interfaces.AbstractAccount {
4839
4938
 
4840
4939
  // src/signer/signer.ts
4841
4940
  var import_address5 = require("@fuel-ts/address");
4842
- var import_crypto = require("@fuel-ts/crypto");
4941
+ var import_crypto2 = require("@fuel-ts/crypto");
4843
4942
  var import_hasher2 = require("@fuel-ts/hasher");
4844
- var import_math18 = require("@fuel-ts/math");
4845
- var import_utils28 = require("@fuel-ts/utils");
4943
+ var import_math19 = require("@fuel-ts/math");
4944
+ var import_utils29 = require("@fuel-ts/utils");
4846
4945
  var import_secp256k1 = require("@noble/curves/secp256k1");
4847
4946
  var Signer = class {
4848
4947
  address;
@@ -4861,10 +4960,10 @@ var Signer = class {
4861
4960
  privateKey = `0x${privateKey}`;
4862
4961
  }
4863
4962
  }
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));
4963
+ const privateKeyBytes = (0, import_math19.toBytes)(privateKey, 32);
4964
+ this.privateKey = (0, import_utils29.hexlify)(privateKeyBytes);
4965
+ this.publicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
4966
+ this.compressedPublicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
4868
4967
  this.address = import_address5.Address.fromPublicKey(this.publicKey);
4869
4968
  }
4870
4969
  /**
@@ -4878,11 +4977,11 @@ var Signer = class {
4878
4977
  * @returns hashed signature
4879
4978
  */
4880
4979
  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);
4980
+ const signature = import_secp256k1.secp256k1.sign((0, import_utils29.arrayify)(data), (0, import_utils29.arrayify)(this.privateKey));
4981
+ const r = (0, import_math19.toBytes)(`0x${signature.r.toString(16)}`, 32);
4982
+ const s = (0, import_math19.toBytes)(`0x${signature.s.toString(16)}`, 32);
4884
4983
  s[0] |= (signature.recovery || 0) << 7;
4885
- return (0, import_utils28.hexlify)((0, import_utils28.concat)([r, s]));
4984
+ return (0, import_utils29.hexlify)((0, import_utils29.concat)([r, s]));
4886
4985
  }
4887
4986
  /**
4888
4987
  * Add point on the current elliptic curve
@@ -4891,8 +4990,8 @@ var Signer = class {
4891
4990
  * @returns compressed point on the curve
4892
4991
  */
4893
4992
  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));
4993
+ const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(this.compressedPublicKey));
4994
+ const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(point));
4896
4995
  const result = p0.add(p1);
4897
4996
  return `0x${result.toHex(true)}`;
4898
4997
  }
@@ -4904,16 +5003,16 @@ var Signer = class {
4904
5003
  * @returns public key from signature from the
4905
5004
  */
4906
5005
  static recoverPublicKey(data, signature) {
4907
- const signedMessageBytes = (0, import_utils28.arrayify)(signature);
5006
+ const signedMessageBytes = (0, import_utils29.arrayify)(signature);
4908
5007
  const r = signedMessageBytes.slice(0, 32);
4909
5008
  const s = signedMessageBytes.slice(32, 64);
4910
5009
  const recoveryParam = (s[0] & 128) >> 7;
4911
5010
  s[0] &= 127;
4912
- const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils28.hexlify)(r)), BigInt((0, import_utils28.hexlify)(s))).addRecoveryBit(
5011
+ const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils29.hexlify)(r)), BigInt((0, import_utils29.hexlify)(s))).addRecoveryBit(
4913
5012
  recoveryParam
4914
5013
  );
4915
- const publicKey = sig.recoverPublicKey((0, import_utils28.arrayify)(data)).toRawBytes(false).slice(1);
4916
- return (0, import_utils28.hexlify)(publicKey);
5014
+ const publicKey = sig.recoverPublicKey((0, import_utils29.arrayify)(data)).toRawBytes(false).slice(1);
5015
+ return (0, import_utils29.hexlify)(publicKey);
4917
5016
  }
4918
5017
  /**
4919
5018
  * Recover the address from a signature performed with [`sign`](#sign).
@@ -4932,7 +5031,7 @@ var Signer = class {
4932
5031
  * @returns random 32-byte hashed
4933
5032
  */
4934
5033
  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);
5034
+ 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
5035
  }
4937
5036
  /**
4938
5037
  * Extended publicKey from a compact publicKey
@@ -4941,16 +5040,16 @@ var Signer = class {
4941
5040
  * @returns extended publicKey
4942
5041
  */
4943
5042
  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));
5043
+ const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(publicKey));
5044
+ return (0, import_utils29.hexlify)(point.toRawBytes(false).slice(1));
4946
5045
  }
4947
5046
  };
4948
5047
 
4949
5048
  // src/wallet/keystore-wallet.ts
4950
5049
  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");
5050
+ var import_crypto3 = require("@fuel-ts/crypto");
5051
+ var import_errors17 = require("@fuel-ts/errors");
5052
+ var import_utils30 = require("@fuel-ts/utils");
4954
5053
  var import_uuid = require("uuid");
4955
5054
  var DEFAULT_KDF_PARAMS_LOG_N = 13;
4956
5055
  var DEFAULT_KDF_PARAMS_R = 8;
@@ -4964,22 +5063,22 @@ var removeHexPrefix = (hexString) => {
4964
5063
  return hexString;
4965
5064
  };
4966
5065
  async function encryptKeystoreWallet(privateKey, address, password) {
4967
- const privateKeyBuffer = (0, import_crypto2.bufferFromString)(removeHexPrefix(privateKey), "hex");
5066
+ const privateKeyBuffer = (0, import_crypto3.bufferFromString)(removeHexPrefix(privateKey), "hex");
4968
5067
  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),
5068
+ const salt = (0, import_crypto3.randomBytes)(DEFAULT_KEY_SIZE);
5069
+ const key = (0, import_crypto3.scrypt)({
5070
+ password: (0, import_crypto3.bufferFromString)(password),
4972
5071
  salt,
4973
5072
  dklen: DEFAULT_KEY_SIZE,
4974
5073
  n: 2 ** DEFAULT_KDF_PARAMS_LOG_N,
4975
5074
  r: DEFAULT_KDF_PARAMS_R,
4976
5075
  p: DEFAULT_KDF_PARAMS_P
4977
5076
  });
4978
- const iv = (0, import_crypto2.randomBytes)(DEFAULT_IV_SIZE);
4979
- const ciphertext = await (0, import_crypto2.encryptJsonWalletData)(privateKeyBuffer, key, iv);
5077
+ const iv = (0, import_crypto3.randomBytes)(DEFAULT_IV_SIZE);
5078
+ const ciphertext = await (0, import_crypto3.encryptJsonWalletData)(privateKeyBuffer, key, iv);
4980
5079
  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");
5080
+ const macHashUint8Array = (0, import_crypto3.keccak256)(data);
5081
+ const mac = (0, import_crypto3.stringFromBuffer)(macHashUint8Array, "hex");
4983
5082
  const keystore = {
4984
5083
  id: (0, import_uuid.v4)(),
4985
5084
  version: 3,
@@ -4987,15 +5086,15 @@ async function encryptKeystoreWallet(privateKey, address, password) {
4987
5086
  crypto: {
4988
5087
  cipher: "aes-128-ctr",
4989
5088
  mac,
4990
- cipherparams: { iv: (0, import_crypto2.stringFromBuffer)(iv, "hex") },
4991
- ciphertext: (0, import_crypto2.stringFromBuffer)(ciphertext, "hex"),
5089
+ cipherparams: { iv: (0, import_crypto3.stringFromBuffer)(iv, "hex") },
5090
+ ciphertext: (0, import_crypto3.stringFromBuffer)(ciphertext, "hex"),
4992
5091
  kdf: "scrypt",
4993
5092
  kdfparams: {
4994
5093
  dklen: DEFAULT_KEY_SIZE,
4995
5094
  n: 2 ** DEFAULT_KDF_PARAMS_LOG_N,
4996
5095
  p: DEFAULT_KDF_PARAMS_P,
4997
5096
  r: DEFAULT_KDF_PARAMS_R,
4998
- salt: (0, import_crypto2.stringFromBuffer)(salt, "hex")
5097
+ salt: (0, import_crypto3.stringFromBuffer)(salt, "hex")
4999
5098
  }
5000
5099
  }
5001
5100
  };
@@ -5011,11 +5110,11 @@ async function decryptKeystoreWallet(jsonWallet, password) {
5011
5110
  kdfparams: { dklen, n, r, p, salt }
5012
5111
  }
5013
5112
  } = 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)({
5113
+ const ciphertextBuffer = (0, import_crypto3.bufferFromString)(ciphertext, "hex");
5114
+ const ivBuffer = (0, import_crypto3.bufferFromString)(iv, "hex");
5115
+ const saltBuffer = (0, import_crypto3.bufferFromString)(salt, "hex");
5116
+ const passwordBuffer = (0, import_crypto3.bufferFromString)(password);
5117
+ const key = (0, import_crypto3.scrypt)({
5019
5118
  password: passwordBuffer,
5020
5119
  salt: saltBuffer,
5021
5120
  n,
@@ -5024,16 +5123,16 @@ async function decryptKeystoreWallet(jsonWallet, password) {
5024
5123
  dklen
5025
5124
  });
5026
5125
  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");
5126
+ const macHashUint8Array = (0, import_crypto3.keccak256)(data);
5127
+ const macHash = (0, import_crypto3.stringFromBuffer)(macHashUint8Array, "hex");
5029
5128
  if (mac !== macHash) {
5030
- throw new import_errors16.FuelError(
5031
- import_errors16.ErrorCode.INVALID_PASSWORD,
5129
+ throw new import_errors17.FuelError(
5130
+ import_errors17.ErrorCode.INVALID_PASSWORD,
5032
5131
  "Failed to decrypt the keystore wallet, the provided password is incorrect."
5033
5132
  );
5034
5133
  }
5035
- const buffer = await (0, import_crypto2.decryptJsonWalletData)(ciphertextBuffer, key, ivBuffer);
5036
- const privateKey = (0, import_utils29.hexlify)(buffer);
5134
+ const buffer = await (0, import_crypto3.decryptJsonWalletData)(ciphertextBuffer, key, ivBuffer);
5135
+ const privateKey = (0, import_utils30.hexlify)(buffer);
5037
5136
  return privateKey;
5038
5137
  }
5039
5138
 
@@ -5078,7 +5177,7 @@ var BaseWalletUnlocked = class extends Account {
5078
5177
  */
5079
5178
  async signMessage(message) {
5080
5179
  const signedMessage = await this.signer().sign((0, import_hasher3.hashMessage)(message));
5081
- return (0, import_utils30.hexlify)(signedMessage);
5180
+ return (0, import_utils31.hexlify)(signedMessage);
5082
5181
  }
5083
5182
  /**
5084
5183
  * Signs a transaction with the wallet's private key.
@@ -5091,7 +5190,7 @@ var BaseWalletUnlocked = class extends Account {
5091
5190
  const chainId = this.provider.getChainId();
5092
5191
  const hashedTransaction = transactionRequest.getTransactionId(chainId);
5093
5192
  const signature = await this.signer().sign(hashedTransaction);
5094
- return (0, import_utils30.hexlify)(signature);
5193
+ return (0, import_utils31.hexlify)(signature);
5095
5194
  }
5096
5195
  /**
5097
5196
  * Populates a transaction with the witnesses signature.
@@ -5150,17 +5249,17 @@ var BaseWalletUnlocked = class extends Account {
5150
5249
  __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
5151
5250
 
5152
5251
  // src/hdwallet/hdwallet.ts
5153
- var import_errors19 = require("@fuel-ts/errors");
5252
+ var import_errors20 = require("@fuel-ts/errors");
5154
5253
  var import_hasher6 = require("@fuel-ts/hasher");
5155
- var import_math19 = require("@fuel-ts/math");
5156
- var import_utils34 = require("@fuel-ts/utils");
5254
+ var import_math20 = require("@fuel-ts/math");
5255
+ var import_utils35 = require("@fuel-ts/utils");
5157
5256
  var import_ethers3 = require("ethers");
5158
5257
 
5159
5258
  // src/mnemonic/mnemonic.ts
5160
- var import_crypto3 = require("@fuel-ts/crypto");
5161
- var import_errors18 = require("@fuel-ts/errors");
5259
+ var import_crypto4 = require("@fuel-ts/crypto");
5260
+ var import_errors19 = require("@fuel-ts/errors");
5162
5261
  var import_hasher5 = require("@fuel-ts/hasher");
5163
- var import_utils32 = require("@fuel-ts/utils");
5262
+ var import_utils33 = require("@fuel-ts/utils");
5164
5263
  var import_ethers2 = require("ethers");
5165
5264
 
5166
5265
  // src/wordlists/words/english.ts
@@ -7216,9 +7315,9 @@ var english = [
7216
7315
  ];
7217
7316
 
7218
7317
  // src/mnemonic/utils.ts
7219
- var import_errors17 = require("@fuel-ts/errors");
7318
+ var import_errors18 = require("@fuel-ts/errors");
7220
7319
  var import_hasher4 = require("@fuel-ts/hasher");
7221
- var import_utils31 = require("@fuel-ts/utils");
7320
+ var import_utils32 = require("@fuel-ts/utils");
7222
7321
  function toUtf8Bytes(stri) {
7223
7322
  const str = stri.normalize("NFKD");
7224
7323
  const result = [];
@@ -7233,8 +7332,8 @@ function toUtf8Bytes(stri) {
7233
7332
  i += 1;
7234
7333
  const c2 = str.charCodeAt(i);
7235
7334
  if (i >= str.length || (c2 & 64512) !== 56320) {
7236
- throw new import_errors17.FuelError(
7237
- import_errors17.ErrorCode.INVALID_INPUT_PARAMETERS,
7335
+ throw new import_errors18.FuelError(
7336
+ import_errors18.ErrorCode.INVALID_INPUT_PARAMETERS,
7238
7337
  "Invalid UTF-8 in the input string."
7239
7338
  );
7240
7339
  }
@@ -7285,20 +7384,20 @@ function entropyToMnemonicIndices(entropy) {
7285
7384
  }
7286
7385
  }
7287
7386
  const checksumBits = entropy.length / 4;
7288
- const checksum = (0, import_utils31.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
7387
+ const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
7289
7388
  indices[indices.length - 1] <<= checksumBits;
7290
7389
  indices[indices.length - 1] |= checksum >> 8 - checksumBits;
7291
7390
  return indices;
7292
7391
  }
7293
7392
  function mnemonicWordsToEntropy(words, wordlist) {
7294
7393
  const size = Math.ceil(11 * words.length / 8);
7295
- const entropy = (0, import_utils31.arrayify)(new Uint8Array(size));
7394
+ const entropy = (0, import_utils32.arrayify)(new Uint8Array(size));
7296
7395
  let offset = 0;
7297
7396
  for (let i = 0; i < words.length; i += 1) {
7298
7397
  const index = wordlist.indexOf(words[i].normalize("NFKD"));
7299
7398
  if (index === -1) {
7300
- throw new import_errors17.FuelError(
7301
- import_errors17.ErrorCode.INVALID_MNEMONIC,
7399
+ throw new import_errors18.FuelError(
7400
+ import_errors18.ErrorCode.INVALID_MNEMONIC,
7302
7401
  `Invalid mnemonic: the word '${words[i]}' is not found in the provided wordlist.`
7303
7402
  );
7304
7403
  }
@@ -7312,10 +7411,10 @@ function mnemonicWordsToEntropy(words, wordlist) {
7312
7411
  const entropyBits = 32 * words.length / 3;
7313
7412
  const checksumBits = words.length / 3;
7314
7413
  const checksumMask = getUpperMask(checksumBits);
7315
- const checksum = (0, import_utils31.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
7414
+ const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
7316
7415
  if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
7317
- throw new import_errors17.FuelError(
7318
- import_errors17.ErrorCode.INVALID_CHECKSUM,
7416
+ throw new import_errors18.FuelError(
7417
+ import_errors18.ErrorCode.INVALID_CHECKSUM,
7319
7418
  "Checksum validation failed for the provided mnemonic."
7320
7419
  );
7321
7420
  }
@@ -7329,16 +7428,16 @@ var TestnetPRV = "0x04358394";
7329
7428
  var MNEMONIC_SIZES = [12, 15, 18, 21, 24];
7330
7429
  function assertWordList(wordlist) {
7331
7430
  if (wordlist.length !== 2048) {
7332
- throw new import_errors18.FuelError(
7333
- import_errors18.ErrorCode.INVALID_WORD_LIST,
7431
+ throw new import_errors19.FuelError(
7432
+ import_errors19.ErrorCode.INVALID_WORD_LIST,
7334
7433
  `Expected word list length of 2048, but got ${wordlist.length}.`
7335
7434
  );
7336
7435
  }
7337
7436
  }
7338
7437
  function assertEntropy(entropy) {
7339
7438
  if (entropy.length % 4 !== 0 || entropy.length < 16 || entropy.length > 32) {
7340
- throw new import_errors18.FuelError(
7341
- import_errors18.ErrorCode.INVALID_ENTROPY,
7439
+ throw new import_errors19.FuelError(
7440
+ import_errors19.ErrorCode.INVALID_ENTROPY,
7342
7441
  `Entropy should be between 16 and 32 bytes and a multiple of 4, but got ${entropy.length} bytes.`
7343
7442
  );
7344
7443
  }
@@ -7348,7 +7447,7 @@ function assertMnemonic(words) {
7348
7447
  const errorMsg = `Invalid mnemonic size. Expected one of [${MNEMONIC_SIZES.join(
7349
7448
  ", "
7350
7449
  )}] words, but got ${words.length}.`;
7351
- throw new import_errors18.FuelError(import_errors18.ErrorCode.INVALID_MNEMONIC, errorMsg);
7450
+ throw new import_errors19.FuelError(import_errors19.ErrorCode.INVALID_MNEMONIC, errorMsg);
7352
7451
  }
7353
7452
  }
7354
7453
  var Mnemonic = class {
@@ -7387,7 +7486,7 @@ var Mnemonic = class {
7387
7486
  static mnemonicToEntropy(phrase, wordlist = english) {
7388
7487
  const words = getWords(phrase);
7389
7488
  assertMnemonic(words);
7390
- return (0, import_utils32.hexlify)(mnemonicWordsToEntropy(words, wordlist));
7489
+ return (0, import_utils33.hexlify)(mnemonicWordsToEntropy(words, wordlist));
7391
7490
  }
7392
7491
  /**
7393
7492
  * @param entropy - Entropy source to the mnemonic phrase.
@@ -7395,7 +7494,7 @@ var Mnemonic = class {
7395
7494
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
7396
7495
  */
7397
7496
  static entropyToMnemonic(entropy, wordlist = english) {
7398
- const entropyBytes = (0, import_utils32.arrayify)(entropy);
7497
+ const entropyBytes = (0, import_utils33.arrayify)(entropy);
7399
7498
  assertWordList(wordlist);
7400
7499
  assertEntropy(entropyBytes);
7401
7500
  return entropyToMnemonicIndices(entropyBytes).map((i) => wordlist[i]).join(" ");
@@ -7464,14 +7563,14 @@ var Mnemonic = class {
7464
7563
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
7465
7564
  */
7466
7565
  static masterKeysFromSeed(seed) {
7467
- const seedArray = (0, import_utils32.arrayify)(seed);
7566
+ const seedArray = (0, import_utils33.arrayify)(seed);
7468
7567
  if (seedArray.length < 16 || seedArray.length > 64) {
7469
- throw new import_errors18.FuelError(
7470
- import_errors18.ErrorCode.INVALID_SEED,
7568
+ throw new import_errors19.FuelError(
7569
+ import_errors19.ErrorCode.INVALID_SEED,
7471
7570
  `Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
7472
7571
  );
7473
7572
  }
7474
- return (0, import_utils32.arrayify)((0, import_ethers2.computeHmac)("sha512", MasterSecret, seedArray));
7573
+ return (0, import_utils33.arrayify)((0, import_ethers2.computeHmac)("sha512", MasterSecret, seedArray));
7475
7574
  }
7476
7575
  /**
7477
7576
  * Get the extendKey as defined on BIP-32 from the provided seed
@@ -7482,22 +7581,22 @@ var Mnemonic = class {
7482
7581
  */
7483
7582
  static seedToExtendedKey(seed, testnet = false) {
7484
7583
  const masterKey = Mnemonic.masterKeysFromSeed(seed);
7485
- const prefix = (0, import_utils32.arrayify)(testnet ? TestnetPRV : MainnetPRV);
7584
+ const prefix = (0, import_utils33.arrayify)(testnet ? TestnetPRV : MainnetPRV);
7486
7585
  const depth = "0x00";
7487
7586
  const fingerprint = "0x00000000";
7488
7587
  const index = "0x00000000";
7489
7588
  const chainCode = masterKey.slice(32);
7490
7589
  const privateKey = masterKey.slice(0, 32);
7491
- const extendedKey = (0, import_utils32.concat)([
7590
+ const extendedKey = (0, import_utils33.concat)([
7492
7591
  prefix,
7493
7592
  depth,
7494
7593
  fingerprint,
7495
7594
  index,
7496
7595
  chainCode,
7497
- (0, import_utils32.concat)(["0x00", privateKey])
7596
+ (0, import_utils33.concat)(["0x00", privateKey])
7498
7597
  ]);
7499
7598
  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]));
7599
+ return (0, import_ethers2.encodeBase58)((0, import_utils33.concat)([extendedKey, checksum]));
7501
7600
  }
7502
7601
  /**
7503
7602
  * Create a new mnemonic using a randomly generated number as entropy.
@@ -7512,7 +7611,7 @@ var Mnemonic = class {
7512
7611
  * @returns A randomly generated mnemonic
7513
7612
  */
7514
7613
  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);
7614
+ 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
7615
  return Mnemonic.entropyToMnemonic(entropy);
7517
7616
  }
7518
7617
  };
@@ -7520,12 +7619,12 @@ var mnemonic_default = Mnemonic;
7520
7619
 
7521
7620
  // src/hdwallet/hdwallet.ts
7522
7621
  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");
7622
+ var MainnetPRV2 = (0, import_utils35.hexlify)("0x0488ade4");
7623
+ var MainnetPUB = (0, import_utils35.hexlify)("0x0488b21e");
7624
+ var TestnetPRV2 = (0, import_utils35.hexlify)("0x04358394");
7625
+ var TestnetPUB = (0, import_utils35.hexlify)("0x043587cf");
7527
7626
  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)]));
7627
+ 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
7628
  }
7530
7629
  function getExtendedKeyPrefix(isPublic = false, testnet = false) {
7531
7630
  if (isPublic) {
@@ -7534,17 +7633,17 @@ function getExtendedKeyPrefix(isPublic = false, testnet = false) {
7534
7633
  return testnet ? TestnetPRV2 : MainnetPRV2;
7535
7634
  }
7536
7635
  function isPublicExtendedKey(extendedKey) {
7537
- return [MainnetPUB, TestnetPUB].includes((0, import_utils34.hexlify)(extendedKey.slice(0, 4)));
7636
+ return [MainnetPUB, TestnetPUB].includes((0, import_utils35.hexlify)(extendedKey.slice(0, 4)));
7538
7637
  }
7539
7638
  function isValidExtendedKey(extendedKey) {
7540
7639
  return [MainnetPRV2, TestnetPRV2, MainnetPUB, TestnetPUB].includes(
7541
- (0, import_utils34.hexlify)(extendedKey.slice(0, 4))
7640
+ (0, import_utils35.hexlify)(extendedKey.slice(0, 4))
7542
7641
  );
7543
7642
  }
7544
7643
  function parsePath(path2, depth = 0) {
7545
7644
  const components = path2.split("/");
7546
7645
  if (components.length === 0 || components[0] === "m" && depth !== 0) {
7547
- throw new import_errors19.FuelError(import_errors19.ErrorCode.HD_WALLET_ERROR, `invalid path - ${path2}`);
7646
+ throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, `invalid path - ${path2}`);
7548
7647
  }
7549
7648
  if (components[0] === "m") {
7550
7649
  components.shift();
@@ -7556,8 +7655,8 @@ function parsePath(path2, depth = 0) {
7556
7655
  var HDWallet = class {
7557
7656
  depth = 0;
7558
7657
  index = 0;
7559
- fingerprint = (0, import_utils34.hexlify)("0x00000000");
7560
- parentFingerprint = (0, import_utils34.hexlify)("0x00000000");
7658
+ fingerprint = (0, import_utils35.hexlify)("0x00000000");
7659
+ parentFingerprint = (0, import_utils35.hexlify)("0x00000000");
7561
7660
  privateKey;
7562
7661
  publicKey;
7563
7662
  chainCode;
@@ -7569,16 +7668,16 @@ var HDWallet = class {
7569
7668
  constructor(config) {
7570
7669
  if (config.privateKey) {
7571
7670
  const signer = new Signer(config.privateKey);
7572
- this.publicKey = (0, import_utils34.hexlify)(signer.compressedPublicKey);
7573
- this.privateKey = (0, import_utils34.hexlify)(config.privateKey);
7671
+ this.publicKey = (0, import_utils35.hexlify)(signer.compressedPublicKey);
7672
+ this.privateKey = (0, import_utils35.hexlify)(config.privateKey);
7574
7673
  } else {
7575
7674
  if (!config.publicKey) {
7576
- throw new import_errors19.FuelError(
7577
- import_errors19.ErrorCode.HD_WALLET_ERROR,
7675
+ throw new import_errors20.FuelError(
7676
+ import_errors20.ErrorCode.HD_WALLET_ERROR,
7578
7677
  "Both public and private Key cannot be missing. At least one should be provided."
7579
7678
  );
7580
7679
  }
7581
- this.publicKey = (0, import_utils34.hexlify)(config.publicKey);
7680
+ this.publicKey = (0, import_utils35.hexlify)(config.publicKey);
7582
7681
  }
7583
7682
  this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
7584
7683
  this.fingerprint = (0, import_ethers3.dataSlice)((0, import_ethers3.ripemd160)((0, import_hasher6.sha256)(this.publicKey)), 0, 4);
@@ -7597,28 +7696,28 @@ var HDWallet = class {
7597
7696
  * @returns A new instance of HDWallet on the derived index
7598
7697
  */
7599
7698
  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);
7699
+ const privateKey = this.privateKey && (0, import_utils35.arrayify)(this.privateKey);
7700
+ const publicKey = (0, import_utils35.arrayify)(this.publicKey);
7701
+ const chainCode = (0, import_utils35.arrayify)(this.chainCode);
7603
7702
  const data = new Uint8Array(37);
7604
7703
  if (index & HARDENED_INDEX) {
7605
7704
  if (!privateKey) {
7606
- throw new import_errors19.FuelError(
7607
- import_errors19.ErrorCode.HD_WALLET_ERROR,
7705
+ throw new import_errors20.FuelError(
7706
+ import_errors20.ErrorCode.HD_WALLET_ERROR,
7608
7707
  "Cannot derive a hardened index without a private Key."
7609
7708
  );
7610
7709
  }
7611
7710
  data.set(privateKey, 1);
7612
7711
  } else {
7613
- data.set((0, import_utils34.arrayify)(this.publicKey));
7712
+ data.set((0, import_utils35.arrayify)(this.publicKey));
7614
7713
  }
7615
- data.set((0, import_math19.toBytes)(index, 4), 33);
7616
- const bytes = (0, import_utils34.arrayify)((0, import_ethers3.computeHmac)("sha512", chainCode, data));
7714
+ data.set((0, import_math20.toBytes)(index, 4), 33);
7715
+ const bytes = (0, import_utils35.arrayify)((0, import_ethers3.computeHmac)("sha512", chainCode, data));
7617
7716
  const IL = bytes.slice(0, 32);
7618
7717
  const IR = bytes.slice(32);
7619
7718
  if (privateKey) {
7620
7719
  const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
7621
- const ki = (0, import_math19.bn)(IL).add(privateKey).mod(N).toBytes(32);
7720
+ const ki = (0, import_math20.bn)(IL).add(privateKey).mod(N).toBytes(32);
7622
7721
  return new HDWallet({
7623
7722
  privateKey: ki,
7624
7723
  chainCode: IR,
@@ -7627,7 +7726,7 @@ var HDWallet = class {
7627
7726
  parentFingerprint: this.fingerprint
7628
7727
  });
7629
7728
  }
7630
- const signer = new Signer((0, import_utils34.hexlify)(IL));
7729
+ const signer = new Signer((0, import_utils35.hexlify)(IL));
7631
7730
  const Ki = signer.addPoint(publicKey);
7632
7731
  return new HDWallet({
7633
7732
  publicKey: Ki,
@@ -7656,18 +7755,18 @@ var HDWallet = class {
7656
7755
  */
7657
7756
  toExtendedKey(isPublic = false, testnet = false) {
7658
7757
  if (this.depth >= 256) {
7659
- throw new import_errors19.FuelError(
7660
- import_errors19.ErrorCode.HD_WALLET_ERROR,
7758
+ throw new import_errors20.FuelError(
7759
+ import_errors20.ErrorCode.HD_WALLET_ERROR,
7661
7760
  `Exceeded max depth of 255. Current depth: ${this.depth}.`
7662
7761
  );
7663
7762
  }
7664
7763
  const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
7665
- const depth = (0, import_utils34.hexlify)(Uint8Array.from([this.depth]));
7764
+ const depth = (0, import_utils35.hexlify)(Uint8Array.from([this.depth]));
7666
7765
  const parentFingerprint = this.parentFingerprint;
7667
- const index = (0, import_math19.toHex)(this.index, 4);
7766
+ const index = (0, import_math20.toHex)(this.index, 4);
7668
7767
  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]));
7768
+ const key = this.privateKey != null && !isPublic ? (0, import_utils35.concat)(["0x00", this.privateKey]) : this.publicKey;
7769
+ const extendedKey = (0, import_utils35.arrayify)((0, import_utils35.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
7671
7770
  return base58check(extendedKey);
7672
7771
  }
7673
7772
  /**
@@ -7679,34 +7778,34 @@ var HDWallet = class {
7679
7778
  static fromSeed(seed) {
7680
7779
  const masterKey = mnemonic_default.masterKeysFromSeed(seed);
7681
7780
  return new HDWallet({
7682
- chainCode: (0, import_utils34.arrayify)(masterKey.slice(32)),
7683
- privateKey: (0, import_utils34.arrayify)(masterKey.slice(0, 32))
7781
+ chainCode: (0, import_utils35.arrayify)(masterKey.slice(32)),
7782
+ privateKey: (0, import_utils35.arrayify)(masterKey.slice(0, 32))
7684
7783
  });
7685
7784
  }
7686
7785
  static fromExtendedKey(extendedKey) {
7687
7786
  const decoded = (0, import_ethers3.toBeHex)((0, import_ethers3.decodeBase58)(extendedKey));
7688
- const bytes = (0, import_utils34.arrayify)(decoded);
7787
+ const bytes = (0, import_utils35.arrayify)(decoded);
7689
7788
  const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
7690
7789
  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.");
7790
+ throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
7692
7791
  }
7693
7792
  if (!validChecksum) {
7694
- throw new import_errors19.FuelError(import_errors19.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
7793
+ throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
7695
7794
  }
7696
7795
  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));
7796
+ const parentFingerprint = (0, import_utils35.hexlify)(bytes.slice(5, 9));
7797
+ const index = parseInt((0, import_utils35.hexlify)(bytes.slice(9, 13)).substring(2), 16);
7798
+ const chainCode = (0, import_utils35.hexlify)(bytes.slice(13, 45));
7700
7799
  const key = bytes.slice(45, 78);
7701
7800
  if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
7702
- throw new import_errors19.FuelError(
7703
- import_errors19.ErrorCode.HD_WALLET_ERROR,
7801
+ throw new import_errors20.FuelError(
7802
+ import_errors20.ErrorCode.HD_WALLET_ERROR,
7704
7803
  "Inconsistency detected: Depth is zero but fingerprint/index is non-zero."
7705
7804
  );
7706
7805
  }
7707
7806
  if (isPublicExtendedKey(bytes)) {
7708
7807
  if (key[0] !== 3) {
7709
- throw new import_errors19.FuelError(import_errors19.ErrorCode.HD_WALLET_ERROR, "Invalid public extended key.");
7808
+ throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Invalid public extended key.");
7710
7809
  }
7711
7810
  return new HDWallet({
7712
7811
  publicKey: key,
@@ -7717,7 +7816,7 @@ var HDWallet = class {
7717
7816
  });
7718
7817
  }
7719
7818
  if (key[0] !== 0) {
7720
- throw new import_errors19.FuelError(import_errors19.ErrorCode.HD_WALLET_ERROR, "Invalid private extended key.");
7819
+ throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Invalid private extended key.");
7721
7820
  }
7722
7821
  return new HDWallet({
7723
7822
  privateKey: key.slice(1),
@@ -7883,10 +7982,10 @@ __publicField(Wallet, "fromExtendedKey", WalletUnlocked.fromExtendedKey);
7883
7982
  __publicField(Wallet, "fromEncryptedJson", WalletUnlocked.fromEncryptedJson);
7884
7983
 
7885
7984
  // src/test-utils/seedTestWallet.ts
7886
- var import_crypto4 = require("@fuel-ts/crypto");
7985
+ var import_crypto5 = require("@fuel-ts/crypto");
7887
7986
  var seedTestWallet = async (wallet, quantities) => {
7888
7987
  const genesisWallet = new WalletUnlocked(
7889
- process.env.GENESIS_SECRET || (0, import_crypto4.randomBytes)(32),
7988
+ process.env.GENESIS_SECRET || (0, import_crypto5.randomBytes)(32),
7890
7989
  wallet.provider
7891
7990
  );
7892
7991
  const resources = await genesisWallet.getResourcesToSpend(quantities);
@@ -7910,12 +8009,12 @@ var generateTestWallet = async (provider, quantities) => {
7910
8009
  };
7911
8010
 
7912
8011
  // 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");
8012
+ var import_configs13 = require("@fuel-ts/address/configs");
8013
+ var import_math21 = require("@fuel-ts/math");
8014
+ var import_utils36 = require("@fuel-ts/utils");
7916
8015
  var import_cli_utils = require("@fuel-ts/utils/cli-utils");
7917
8016
  var import_child_process = require("child_process");
7918
- var import_crypto5 = require("crypto");
8017
+ var import_crypto6 = require("crypto");
7919
8018
  var import_fs = require("fs");
7920
8019
  var import_os = __toESM(require("os"));
7921
8020
  var import_path = __toESM(require("path"));
@@ -7970,7 +8069,7 @@ var launchNode = async ({
7970
8069
  "--poa-instant"
7971
8070
  ]);
7972
8071
  const chainConfigPath = getFlagValueFromArgs(args, "--chain");
7973
- const consensusKey = getFlagValueFromArgs(args, "--consensus-key") || import_utils35.defaultConsensusKey;
8072
+ const consensusKey = getFlagValueFromArgs(args, "--consensus-key") || import_utils36.defaultConsensusKey;
7974
8073
  const dbTypeFlagValue = getFlagValueFromArgs(args, "--db-type");
7975
8074
  const useInMemoryDb = dbTypeFlagValue === "in-memory" || dbTypeFlagValue === void 0;
7976
8075
  const poaInstantFlagValue = getFlagValueFromArgs(args, "--poa-instant");
@@ -7987,7 +8086,7 @@ var launchNode = async ({
7987
8086
  })).toString();
7988
8087
  let chainConfigPathToUse;
7989
8088
  const prefix = basePath || import_os.default.tmpdir();
7990
- const suffix = basePath ? "" : (0, import_crypto5.randomUUID)();
8089
+ const suffix = basePath ? "" : (0, import_crypto6.randomUUID)();
7991
8090
  const tempDirPath = import_path.default.join(prefix, ".fuels", suffix);
7992
8091
  if (chainConfigPath) {
7993
8092
  chainConfigPathToUse = chainConfigPath;
@@ -7996,21 +8095,21 @@ var launchNode = async ({
7996
8095
  (0, import_fs.mkdirSync)(tempDirPath, { recursive: true });
7997
8096
  }
7998
8097
  const tempChainConfigFilePath = import_path.default.join(tempDirPath, "chainConfig.json");
7999
- let chainConfig = import_utils35.defaultChainConfig;
8098
+ let chainConfig = import_utils36.defaultChainConfig;
8000
8099
  if (!process.env.GENESIS_SECRET) {
8001
8100
  const pk = Signer.generatePrivateKey();
8002
8101
  const signer = new Signer(pk);
8003
- process.env.GENESIS_SECRET = (0, import_utils35.hexlify)(pk);
8102
+ process.env.GENESIS_SECRET = (0, import_utils36.hexlify)(pk);
8004
8103
  chainConfig = {
8005
- ...import_utils35.defaultChainConfig,
8104
+ ...import_utils36.defaultChainConfig,
8006
8105
  initial_state: {
8007
- ...import_utils35.defaultChainConfig.initial_state,
8106
+ ...import_utils36.defaultChainConfig.initial_state,
8008
8107
  coins: [
8009
- ...import_utils35.defaultChainConfig.initial_state.coins,
8108
+ ...import_utils36.defaultChainConfig.initial_state.coins,
8010
8109
  {
8011
8110
  owner: signer.address.toHexString(),
8012
- amount: (0, import_math20.toHex)(1e9),
8013
- asset_id: import_configs12.BaseAssetId
8111
+ amount: (0, import_math21.toHex)(1e9),
8112
+ asset_id: import_configs13.BaseAssetId
8014
8113
  }
8015
8114
  ]
8016
8115
  }
@@ -8078,7 +8177,7 @@ var launchNode = async ({
8078
8177
  var generateWallets = async (count, provider) => {
8079
8178
  const wallets = [];
8080
8179
  for (let i = 0; i < count; i += 1) {
8081
- const wallet = await generateTestWallet(provider, [[1e3, import_configs12.BaseAssetId]]);
8180
+ const wallet = await generateTestWallet(provider, [[1e3, import_configs13.BaseAssetId]]);
8082
8181
  wallets.push(wallet);
8083
8182
  }
8084
8183
  return wallets;