@fuel-ts/account 0.78.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.

Files changed (39) hide show
  1. package/dist/configs.d.ts +1 -0
  2. package/dist/configs.d.ts.map +1 -1
  3. package/dist/configs.global.js +1 -0
  4. package/dist/configs.global.js.map +1 -1
  5. package/dist/configs.js +3 -0
  6. package/dist/configs.js.map +1 -1
  7. package/dist/configs.mjs +2 -0
  8. package/dist/configs.mjs.map +1 -1
  9. package/dist/index.global.js +388 -210
  10. package/dist/index.global.js.map +1 -1
  11. package/dist/index.js +668 -550
  12. package/dist/index.js.map +1 -1
  13. package/dist/index.mjs +422 -299
  14. package/dist/index.mjs.map +1 -1
  15. package/dist/predicate/predicate.d.ts +0 -1
  16. package/dist/predicate/predicate.d.ts.map +1 -1
  17. package/dist/providers/provider.d.ts +13 -2
  18. package/dist/providers/provider.d.ts.map +1 -1
  19. package/dist/providers/transaction-request/input.d.ts.map +1 -1
  20. package/dist/providers/transaction-request/script-transaction-request.d.ts +3 -0
  21. package/dist/providers/transaction-request/script-transaction-request.d.ts.map +1 -1
  22. package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
  23. package/dist/providers/transaction-request/types.d.ts +5 -0
  24. package/dist/providers/transaction-request/types.d.ts.map +1 -1
  25. package/dist/providers/transaction-response/getDecodedLogs.d.ts +2 -2
  26. package/dist/providers/transaction-response/getDecodedLogs.d.ts.map +1 -1
  27. package/dist/providers/transaction-response/transaction-response.d.ts +5 -2
  28. package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
  29. package/dist/providers/utils/extract-tx-error.d.ts +36 -0
  30. package/dist/providers/utils/extract-tx-error.d.ts.map +1 -0
  31. package/dist/providers/utils/index.d.ts +1 -0
  32. package/dist/providers/utils/index.d.ts.map +1 -1
  33. package/dist/test-utils.global.js +390 -196
  34. package/dist/test-utils.global.js.map +1 -1
  35. package/dist/test-utils.js +625 -499
  36. package/dist/test-utils.js.map +1 -1
  37. package/dist/test-utils.mjs +392 -258
  38. package/dist/test-utils.mjs.map +1 -1
  39. package/package.json +16 -16
package/dist/index.js CHANGED
@@ -88,7 +88,7 @@ __export(src_exports, {
88
88
  StorageAbstract: () => StorageAbstract,
89
89
  TransactionResponse: () => TransactionResponse,
90
90
  TransactionStatus: () => TransactionStatus,
91
- TransactionType: () => import_transactions5.TransactionType,
91
+ TransactionType: () => import_transactions6.TransactionType,
92
92
  TransactionTypeName: () => TransactionTypeName,
93
93
  Vault: () => Vault,
94
94
  Wallet: () => Wallet,
@@ -97,7 +97,9 @@ __export(src_exports, {
97
97
  WalletUnlocked: () => WalletUnlocked,
98
98
  addAmountToAsset: () => addAmountToAsset,
99
99
  addOperation: () => addOperation,
100
+ assemblePanicError: () => assemblePanicError,
100
101
  assembleReceiptByType: () => assembleReceiptByType,
102
+ assembleRevertError: () => assembleRevertError,
101
103
  assembleTransactionSummary: () => assembleTransactionSummary,
102
104
  assets: () => assets,
103
105
  buildBlockExplorerUrl: () => buildBlockExplorerUrl,
@@ -112,6 +114,7 @@ __export(src_exports, {
112
114
  english: () => english,
113
115
  extractBurnedAssetsFromReceipts: () => extractBurnedAssetsFromReceipts,
114
116
  extractMintedAssetsFromReceipts: () => extractMintedAssetsFromReceipts,
117
+ extractTxError: () => extractTxError,
115
118
  gasUsedByInputs: () => gasUsedByInputs,
116
119
  getAssetEth: () => getAssetEth,
117
120
  getAssetFuel: () => getAssetFuel,
@@ -181,11 +184,11 @@ module.exports = __toCommonJS(src_exports);
181
184
 
182
185
  // src/account.ts
183
186
  var import_address4 = require("@fuel-ts/address");
184
- var import_configs11 = require("@fuel-ts/address/configs");
185
- var import_errors15 = require("@fuel-ts/errors");
187
+ var import_configs12 = require("@fuel-ts/address/configs");
188
+ var import_errors16 = require("@fuel-ts/errors");
186
189
  var import_interfaces = require("@fuel-ts/interfaces");
187
- var import_math17 = require("@fuel-ts/math");
188
- var import_utils27 = require("@fuel-ts/utils");
190
+ var import_math18 = require("@fuel-ts/math");
191
+ var import_utils28 = require("@fuel-ts/utils");
189
192
 
190
193
  // src/providers/coin-quantity.ts
191
194
  var import_configs = require("@fuel-ts/address/configs");
@@ -225,12 +228,12 @@ var addAmountToAsset = (params) => {
225
228
 
226
229
  // src/providers/provider.ts
227
230
  var import_address3 = require("@fuel-ts/address");
228
- var import_errors13 = require("@fuel-ts/errors");
229
- var import_math14 = require("@fuel-ts/math");
230
- var import_transactions17 = require("@fuel-ts/transactions");
231
- var import_utils22 = require("@fuel-ts/utils");
231
+ var import_errors14 = require("@fuel-ts/errors");
232
+ var import_math15 = require("@fuel-ts/math");
233
+ var import_transactions18 = require("@fuel-ts/transactions");
234
+ var import_utils23 = require("@fuel-ts/utils");
232
235
  var import_versions = require("@fuel-ts/versions");
233
- var import_utils23 = require("@noble/curves/abstract/utils");
236
+ var import_utils24 = require("@noble/curves/abstract/utils");
234
237
  var import_ethers = require("ethers");
235
238
  var import_graphql_request = require("graphql-request");
236
239
  var import_ramda3 = require("ramda");
@@ -1170,6 +1173,7 @@ var MemoryCache = class {
1170
1173
  };
1171
1174
 
1172
1175
  // src/providers/transaction-request/input.ts
1176
+ var import_abi_coder = require("@fuel-ts/abi-coder");
1173
1177
  var import_configs2 = require("@fuel-ts/address/configs");
1174
1178
  var import_errors3 = require("@fuel-ts/errors");
1175
1179
  var import_math2 = require("@fuel-ts/math");
@@ -1183,8 +1187,8 @@ var inputify = (value) => {
1183
1187
  const predicateData = (0, import_utils3.arrayify)(value.predicateData ?? "0x");
1184
1188
  return {
1185
1189
  type: import_transactions.InputType.Coin,
1186
- txID: (0, import_utils3.hexlify)((0, import_utils3.arrayify)(value.id).slice(0, 32)),
1187
- outputIndex: (0, import_utils3.arrayify)(value.id)[32],
1190
+ txID: (0, import_utils3.hexlify)((0, import_utils3.arrayify)(value.id).slice(0, import_abi_coder.BYTES_32)),
1191
+ outputIndex: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.id).slice(import_abi_coder.BYTES_32, import_abi_coder.UTXO_ID_LEN)),
1188
1192
  owner: (0, import_utils3.hexlify)(value.owner),
1189
1193
  amount: (0, import_math2.bn)(value.amount),
1190
1194
  assetId: (0, import_utils3.hexlify)(value.assetId),
@@ -1302,10 +1306,12 @@ var outputify = (value) => {
1302
1306
  };
1303
1307
 
1304
1308
  // src/providers/transaction-request/transaction-request.ts
1309
+ var import_abi_coder2 = require("@fuel-ts/abi-coder");
1305
1310
  var import_address = require("@fuel-ts/address");
1306
- var import_configs6 = require("@fuel-ts/address/configs");
1307
- var import_math6 = require("@fuel-ts/math");
1308
- var import_transactions5 = require("@fuel-ts/transactions");
1311
+ var import_configs7 = require("@fuel-ts/address/configs");
1312
+ var import_crypto = require("@fuel-ts/crypto");
1313
+ var import_math7 = require("@fuel-ts/math");
1314
+ var import_transactions6 = require("@fuel-ts/transactions");
1309
1315
  var import_utils9 = require("@fuel-ts/utils");
1310
1316
 
1311
1317
  // src/providers/resource.ts
@@ -1698,6 +1704,78 @@ function sleep(time) {
1698
1704
  });
1699
1705
  }
1700
1706
 
1707
+ // src/providers/utils/extract-tx-error.ts
1708
+ var import_errors7 = require("@fuel-ts/errors");
1709
+ var import_math6 = require("@fuel-ts/math");
1710
+ var import_transactions5 = require("@fuel-ts/transactions");
1711
+ var import_configs6 = require("@fuel-ts/transactions/configs");
1712
+ var assemblePanicError = (status) => {
1713
+ let errorMessage = `The transaction reverted with reason: "${status.reason}".`;
1714
+ const reason = status.reason;
1715
+ if (import_configs6.PANIC_REASONS.includes(status.reason)) {
1716
+ errorMessage = `${errorMessage}
1717
+
1718
+ You can read more about this error at:
1719
+
1720
+ ${import_configs6.PANIC_DOC_URL}#variant.${status.reason}`;
1721
+ }
1722
+ return { errorMessage, reason };
1723
+ };
1724
+ var stringify = (obj) => JSON.stringify(obj, null, 2);
1725
+ var assembleRevertError = (receipts, logs) => {
1726
+ let errorMessage = "The transaction reverted with an unknown reason.";
1727
+ const revertReceipt = receipts.find(({ type }) => type === import_transactions5.ReceiptType.Revert);
1728
+ let reason = "";
1729
+ if (revertReceipt) {
1730
+ const reasonHex = (0, import_math6.bn)(revertReceipt.val).toHex();
1731
+ switch (reasonHex) {
1732
+ case import_configs6.FAILED_REQUIRE_SIGNAL: {
1733
+ reason = "require";
1734
+ errorMessage = `The transaction reverted because a "require" statement has thrown ${logs.length ? stringify(logs[0]) : "an error."}.`;
1735
+ break;
1736
+ }
1737
+ case import_configs6.FAILED_ASSERT_EQ_SIGNAL: {
1738
+ const sufix = logs.length >= 2 ? ` comparing ${stringify(logs[1])} and ${stringify(logs[0])}.` : ".";
1739
+ reason = "assert_eq";
1740
+ errorMessage = `The transaction reverted because of an "assert_eq" statement${sufix}`;
1741
+ break;
1742
+ }
1743
+ case import_configs6.FAILED_ASSERT_NE_SIGNAL: {
1744
+ const sufix = logs.length >= 2 ? ` comparing ${stringify(logs[1])} and ${stringify(logs[0])}.` : ".";
1745
+ reason = "assert_ne";
1746
+ errorMessage = `The transaction reverted because of an "assert_ne" statement${sufix}`;
1747
+ break;
1748
+ }
1749
+ case import_configs6.FAILED_ASSERT_SIGNAL:
1750
+ reason = "assert";
1751
+ errorMessage = `The transaction reverted because an "assert" statement failed to evaluate to true.`;
1752
+ break;
1753
+ case import_configs6.FAILED_TRANSFER_TO_ADDRESS_SIGNAL:
1754
+ reason = "MissingOutputChange";
1755
+ errorMessage = `The transaction reverted because it's missing an "OutputChange".`;
1756
+ break;
1757
+ default:
1758
+ reason = "unknown";
1759
+ errorMessage = `The transaction reverted with an unknown reason: ${revertReceipt.val}`;
1760
+ }
1761
+ }
1762
+ return { errorMessage, reason };
1763
+ };
1764
+ var extractTxError = (params) => {
1765
+ const { receipts, status, logs } = params;
1766
+ const isPanic = receipts.some(({ type }) => type === import_transactions5.ReceiptType.Panic);
1767
+ const isRevert = receipts.some(({ type }) => type === import_transactions5.ReceiptType.Revert);
1768
+ const { errorMessage, reason } = status?.type === "FailureStatus" && isPanic ? assemblePanicError(status) : assembleRevertError(receipts, logs);
1769
+ const metadata = {
1770
+ logs,
1771
+ receipts,
1772
+ panic: isPanic,
1773
+ revert: isRevert,
1774
+ reason
1775
+ };
1776
+ return new import_errors7.FuelError(import_errors7.ErrorCode.SCRIPT_REVERTED, errorMessage, metadata);
1777
+ };
1778
+
1701
1779
  // src/providers/transaction-request/errors.ts
1702
1780
  var ChangeOutputCollisionError = class extends Error {
1703
1781
  name = "ChangeOutputCollisionError";
@@ -1760,10 +1838,10 @@ var BaseTransactionRequest = class {
1760
1838
  outputs,
1761
1839
  witnesses
1762
1840
  } = {}) {
1763
- this.gasPrice = (0, import_math6.bn)(gasPrice);
1841
+ this.gasPrice = (0, import_math7.bn)(gasPrice);
1764
1842
  this.maturity = maturity ?? 0;
1765
- this.witnessLimit = witnessLimit ? (0, import_math6.bn)(witnessLimit) : void 0;
1766
- this.maxFee = maxFee ? (0, import_math6.bn)(maxFee) : void 0;
1843
+ this.witnessLimit = witnessLimit ? (0, import_math7.bn)(witnessLimit) : void 0;
1844
+ this.maxFee = maxFee ? (0, import_math7.bn)(maxFee) : void 0;
1767
1845
  this.inputs = inputs ?? [];
1768
1846
  this.outputs = outputs ?? [];
1769
1847
  this.witnesses = witnesses ?? [];
@@ -1772,20 +1850,20 @@ var BaseTransactionRequest = class {
1772
1850
  let policyTypes = 0;
1773
1851
  const policies = [];
1774
1852
  if (req.gasPrice) {
1775
- policyTypes += import_transactions5.PolicyType.GasPrice;
1776
- policies.push({ data: req.gasPrice, type: import_transactions5.PolicyType.GasPrice });
1853
+ policyTypes += import_transactions6.PolicyType.GasPrice;
1854
+ policies.push({ data: req.gasPrice, type: import_transactions6.PolicyType.GasPrice });
1777
1855
  }
1778
1856
  if (req.witnessLimit) {
1779
- policyTypes += import_transactions5.PolicyType.WitnessLimit;
1780
- policies.push({ data: req.witnessLimit, type: import_transactions5.PolicyType.WitnessLimit });
1857
+ policyTypes += import_transactions6.PolicyType.WitnessLimit;
1858
+ policies.push({ data: req.witnessLimit, type: import_transactions6.PolicyType.WitnessLimit });
1781
1859
  }
1782
1860
  if (req.maturity > 0) {
1783
- policyTypes += import_transactions5.PolicyType.Maturity;
1784
- policies.push({ data: req.maturity, type: import_transactions5.PolicyType.Maturity });
1861
+ policyTypes += import_transactions6.PolicyType.Maturity;
1862
+ policies.push({ data: req.maturity, type: import_transactions6.PolicyType.Maturity });
1785
1863
  }
1786
1864
  if (req.maxFee) {
1787
- policyTypes += import_transactions5.PolicyType.MaxFee;
1788
- policies.push({ data: req.maxFee, type: import_transactions5.PolicyType.MaxFee });
1865
+ policyTypes += import_transactions6.PolicyType.MaxFee;
1866
+ policies.push({ data: req.maxFee, type: import_transactions6.PolicyType.MaxFee });
1789
1867
  }
1790
1868
  return {
1791
1869
  policyTypes,
@@ -1819,7 +1897,7 @@ var BaseTransactionRequest = class {
1819
1897
  * @returns The transaction bytes.
1820
1898
  */
1821
1899
  toTransactionBytes() {
1822
- return new import_transactions5.TransactionCoder().encode(this.toTransaction());
1900
+ return new import_transactions6.TransactionCoder().encode(this.toTransaction());
1823
1901
  }
1824
1902
  /**
1825
1903
  * @hidden
@@ -1859,7 +1937,7 @@ var BaseTransactionRequest = class {
1859
1937
  * @returns The index of the created witness.
1860
1938
  */
1861
1939
  addEmptyWitness() {
1862
- this.addWitness((0, import_utils9.concat)([import_configs6.ZeroBytes32, import_configs6.ZeroBytes32]));
1940
+ this.addWitness((0, import_utils9.concat)([import_configs7.ZeroBytes32, import_configs7.ZeroBytes32]));
1863
1941
  return this.witnesses.length - 1;
1864
1942
  }
1865
1943
  /**
@@ -1910,7 +1988,7 @@ var BaseTransactionRequest = class {
1910
1988
  */
1911
1989
  getCoinInputs() {
1912
1990
  return this.inputs.filter(
1913
- (input) => input.type === import_transactions5.InputType.Coin
1991
+ (input) => input.type === import_transactions6.InputType.Coin
1914
1992
  );
1915
1993
  }
1916
1994
  /**
@@ -1920,7 +1998,7 @@ var BaseTransactionRequest = class {
1920
1998
  */
1921
1999
  getCoinOutputs() {
1922
2000
  return this.outputs.filter(
1923
- (output) => output.type === import_transactions5.OutputType.Coin
2001
+ (output) => output.type === import_transactions6.OutputType.Coin
1924
2002
  );
1925
2003
  }
1926
2004
  /**
@@ -1930,7 +2008,7 @@ var BaseTransactionRequest = class {
1930
2008
  */
1931
2009
  getChangeOutputs() {
1932
2010
  return this.outputs.filter(
1933
- (output) => output.type === import_transactions5.OutputType.Change
2011
+ (output) => output.type === import_transactions6.OutputType.Change
1934
2012
  );
1935
2013
  }
1936
2014
  /**
@@ -1942,9 +2020,9 @@ var BaseTransactionRequest = class {
1942
2020
  const ownerAddress = (0, import_address.addressify)(owner);
1943
2021
  const found = this.inputs.find((input) => {
1944
2022
  switch (input.type) {
1945
- case import_transactions5.InputType.Coin:
2023
+ case import_transactions6.InputType.Coin:
1946
2024
  return (0, import_utils9.hexlify)(input.owner) === ownerAddress.toB256();
1947
- case import_transactions5.InputType.Message:
2025
+ case import_transactions6.InputType.Message:
1948
2026
  return (0, import_utils9.hexlify)(input.recipient) === ownerAddress.toB256();
1949
2027
  default:
1950
2028
  return false;
@@ -1973,14 +2051,13 @@ var BaseTransactionRequest = class {
1973
2051
  }
1974
2052
  const input = {
1975
2053
  ...coin,
1976
- type: import_transactions5.InputType.Coin,
2054
+ type: import_transactions6.InputType.Coin,
1977
2055
  owner: owner.toB256(),
1978
2056
  amount,
1979
2057
  assetId,
1980
2058
  txPointer: "0x00000000000000000000000000000000",
1981
2059
  witnessIndex,
1982
- predicate: predicate?.bytes,
1983
- predicateData: predicate?.predicateDataBytes
2060
+ predicate: predicate?.bytes
1984
2061
  };
1985
2062
  this.pushInput(input);
1986
2063
  this.addChangeOutput(owner, assetId);
@@ -1995,7 +2072,7 @@ var BaseTransactionRequest = class {
1995
2072
  */
1996
2073
  addMessageInput(message, predicate) {
1997
2074
  const { recipient, sender, amount } = message;
1998
- const assetId = import_configs6.BaseAssetId;
2075
+ const assetId = import_configs7.BaseAssetId;
1999
2076
  let witnessIndex;
2000
2077
  if (predicate) {
2001
2078
  witnessIndex = 0;
@@ -2007,13 +2084,12 @@ var BaseTransactionRequest = class {
2007
2084
  }
2008
2085
  const input = {
2009
2086
  ...message,
2010
- type: import_transactions5.InputType.Message,
2087
+ type: import_transactions6.InputType.Message,
2011
2088
  sender: sender.toB256(),
2012
2089
  recipient: recipient.toB256(),
2013
2090
  amount,
2014
2091
  witnessIndex,
2015
- predicate: predicate?.bytes,
2016
- predicateData: predicate?.predicateDataBytes
2092
+ predicate: predicate?.bytes
2017
2093
  };
2018
2094
  this.pushInput(input);
2019
2095
  this.addChangeOutput(recipient, assetId);
@@ -2077,9 +2153,9 @@ var BaseTransactionRequest = class {
2077
2153
  * @param amount - Amount of coin.
2078
2154
  * @param assetId - Asset ID of coin.
2079
2155
  */
2080
- addCoinOutput(to, amount, assetId = import_configs6.BaseAssetId) {
2156
+ addCoinOutput(to, amount, assetId = import_configs7.BaseAssetId) {
2081
2157
  this.pushOutput({
2082
- type: import_transactions5.OutputType.Coin,
2158
+ type: import_transactions6.OutputType.Coin,
2083
2159
  to: (0, import_address.addressify)(to).toB256(),
2084
2160
  amount,
2085
2161
  assetId
@@ -2095,7 +2171,7 @@ var BaseTransactionRequest = class {
2095
2171
  addCoinOutputs(to, quantities) {
2096
2172
  quantities.map(coinQuantityfy).forEach((quantity) => {
2097
2173
  this.pushOutput({
2098
- type: import_transactions5.OutputType.Coin,
2174
+ type: import_transactions6.OutputType.Coin,
2099
2175
  to: (0, import_address.addressify)(to).toB256(),
2100
2176
  amount: quantity.amount,
2101
2177
  assetId: quantity.assetId
@@ -2109,13 +2185,13 @@ var BaseTransactionRequest = class {
2109
2185
  * @param to - Address of the owner.
2110
2186
  * @param assetId - Asset ID of coin.
2111
2187
  */
2112
- addChangeOutput(to, assetId = import_configs6.BaseAssetId) {
2188
+ addChangeOutput(to, assetId = import_configs7.BaseAssetId) {
2113
2189
  const changeOutput = this.getChangeOutputs().find(
2114
2190
  (output) => (0, import_utils9.hexlify)(output.assetId) === assetId
2115
2191
  );
2116
2192
  if (!changeOutput) {
2117
2193
  this.pushOutput({
2118
- type: import_transactions5.OutputType.Change,
2194
+ type: import_transactions6.OutputType.Change,
2119
2195
  to: (0, import_address.addressify)(to).toB256(),
2120
2196
  assetId
2121
2197
  });
@@ -2168,12 +2244,6 @@ var BaseTransactionRequest = class {
2168
2244
  * @param quantities - CoinQuantity Array.
2169
2245
  */
2170
2246
  fundWithFakeUtxos(quantities, resourcesOwner) {
2171
- let idCounter = 0;
2172
- const generateId = () => {
2173
- const counterString = String(idCounter++);
2174
- const id = import_configs6.ZeroBytes32.slice(0, -counterString.length).concat(counterString);
2175
- return id;
2176
- };
2177
2247
  const findAssetInput = (assetId) => this.inputs.find((input) => {
2178
2248
  if ("assetId" in input) {
2179
2249
  return input.assetId === assetId;
@@ -2183,23 +2253,23 @@ var BaseTransactionRequest = class {
2183
2253
  const updateAssetInput = (assetId, quantity) => {
2184
2254
  const assetInput = findAssetInput(assetId);
2185
2255
  if (assetInput && "assetId" in assetInput) {
2186
- assetInput.id = generateId();
2256
+ assetInput.id = (0, import_utils9.hexlify)((0, import_crypto.randomBytes)(import_abi_coder2.UTXO_ID_LEN));
2187
2257
  assetInput.amount = quantity;
2188
2258
  } else {
2189
2259
  this.addResources([
2190
2260
  {
2191
- id: generateId(),
2261
+ id: (0, import_utils9.hexlify)((0, import_crypto.randomBytes)(import_abi_coder2.UTXO_ID_LEN)),
2192
2262
  amount: quantity,
2193
2263
  assetId,
2194
2264
  owner: resourcesOwner || import_address.Address.fromRandom(),
2195
2265
  maturity: 0,
2196
- blockCreated: (0, import_math6.bn)(1),
2197
- txCreatedIdx: (0, import_math6.bn)(1)
2266
+ blockCreated: (0, import_math7.bn)(1),
2267
+ txCreatedIdx: (0, import_math7.bn)(1)
2198
2268
  }
2199
2269
  ]);
2200
2270
  }
2201
2271
  };
2202
- updateAssetInput(import_configs6.BaseAssetId, (0, import_math6.bn)(1e11));
2272
+ updateAssetInput(import_configs7.BaseAssetId, (0, import_math7.bn)(1e11));
2203
2273
  quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
2204
2274
  }
2205
2275
  /**
@@ -2210,7 +2280,7 @@ var BaseTransactionRequest = class {
2210
2280
  */
2211
2281
  getCoinOutputsQuantities() {
2212
2282
  const coinsQuantities = this.getCoinOutputs().map(({ amount, assetId }) => ({
2213
- amount: (0, import_math6.bn)(amount),
2283
+ amount: (0, import_math7.bn)(amount),
2214
2284
  assetId: assetId.toString()
2215
2285
  }));
2216
2286
  return coinsQuantities;
@@ -2228,18 +2298,18 @@ var BaseTransactionRequest = class {
2228
2298
  this.inputs.forEach((i) => {
2229
2299
  let correspondingInput;
2230
2300
  switch (i.type) {
2231
- case import_transactions5.InputType.Coin:
2232
- correspondingInput = inputs.find((x) => x.type === import_transactions5.InputType.Coin && x.owner === i.owner);
2301
+ case import_transactions6.InputType.Coin:
2302
+ correspondingInput = inputs.find((x) => x.type === import_transactions6.InputType.Coin && x.owner === i.owner);
2233
2303
  break;
2234
- case import_transactions5.InputType.Message:
2304
+ case import_transactions6.InputType.Message:
2235
2305
  correspondingInput = inputs.find(
2236
- (x) => x.type === import_transactions5.InputType.Message && x.sender === i.sender
2306
+ (x) => x.type === import_transactions6.InputType.Message && x.sender === i.sender
2237
2307
  );
2238
2308
  break;
2239
2309
  default:
2240
2310
  return;
2241
2311
  }
2242
- if (correspondingInput && "predicateGasUsed" in correspondingInput && (0, import_math6.bn)(correspondingInput.predicateGasUsed).gt(0)) {
2312
+ if (correspondingInput && "predicateGasUsed" in correspondingInput && (0, import_math7.bn)(correspondingInput.predicateGasUsed).gt(0)) {
2243
2313
  i.predicate = correspondingInput.predicate;
2244
2314
  i.predicateData = correspondingInput.predicateData;
2245
2315
  i.predicateGasUsed = correspondingInput.predicateGasUsed;
@@ -2249,47 +2319,47 @@ var BaseTransactionRequest = class {
2249
2319
  };
2250
2320
 
2251
2321
  // src/providers/transaction-request/create-transaction-request.ts
2252
- var import_configs8 = require("@fuel-ts/address/configs");
2253
- var import_math8 = require("@fuel-ts/math");
2254
- var import_transactions7 = require("@fuel-ts/transactions");
2322
+ var import_configs9 = require("@fuel-ts/address/configs");
2323
+ var import_math9 = require("@fuel-ts/math");
2324
+ var import_transactions8 = require("@fuel-ts/transactions");
2255
2325
  var import_utils13 = require("@fuel-ts/utils");
2256
2326
 
2257
2327
  // src/providers/transaction-request/hash-transaction.ts
2258
- var import_configs7 = require("@fuel-ts/address/configs");
2328
+ var import_configs8 = require("@fuel-ts/address/configs");
2259
2329
  var import_hasher = require("@fuel-ts/hasher");
2260
- var import_math7 = require("@fuel-ts/math");
2261
- var import_transactions6 = require("@fuel-ts/transactions");
2330
+ var import_math8 = require("@fuel-ts/math");
2331
+ var import_transactions7 = require("@fuel-ts/transactions");
2262
2332
  var import_utils11 = require("@fuel-ts/utils");
2263
2333
  var import_ramda2 = require("ramda");
2264
2334
  function hashTransaction(transactionRequest, chainId) {
2265
2335
  const transaction = transactionRequest.toTransaction();
2266
- if (transaction.type === import_transactions6.TransactionType.Script) {
2267
- transaction.receiptsRoot = import_configs7.ZeroBytes32;
2336
+ if (transaction.type === import_transactions7.TransactionType.Script) {
2337
+ transaction.receiptsRoot = import_configs8.ZeroBytes32;
2268
2338
  }
2269
2339
  transaction.inputs = transaction.inputs.map((input) => {
2270
2340
  const inputClone = (0, import_ramda2.clone)(input);
2271
2341
  switch (inputClone.type) {
2272
- case import_transactions6.InputType.Coin: {
2342
+ case import_transactions7.InputType.Coin: {
2273
2343
  inputClone.txPointer = {
2274
2344
  blockHeight: 0,
2275
2345
  txIndex: 0
2276
2346
  };
2277
- inputClone.predicateGasUsed = (0, import_math7.bn)(0);
2347
+ inputClone.predicateGasUsed = (0, import_math8.bn)(0);
2278
2348
  return inputClone;
2279
2349
  }
2280
- case import_transactions6.InputType.Message: {
2281
- inputClone.predicateGasUsed = (0, import_math7.bn)(0);
2350
+ case import_transactions7.InputType.Message: {
2351
+ inputClone.predicateGasUsed = (0, import_math8.bn)(0);
2282
2352
  return inputClone;
2283
2353
  }
2284
- case import_transactions6.InputType.Contract: {
2354
+ case import_transactions7.InputType.Contract: {
2285
2355
  inputClone.txPointer = {
2286
2356
  blockHeight: 0,
2287
2357
  txIndex: 0
2288
2358
  };
2289
- inputClone.txID = import_configs7.ZeroBytes32;
2359
+ inputClone.txID = import_configs8.ZeroBytes32;
2290
2360
  inputClone.outputIndex = 0;
2291
- inputClone.balanceRoot = import_configs7.ZeroBytes32;
2292
- inputClone.stateRoot = import_configs7.ZeroBytes32;
2361
+ inputClone.balanceRoot = import_configs8.ZeroBytes32;
2362
+ inputClone.stateRoot = import_configs8.ZeroBytes32;
2293
2363
  return inputClone;
2294
2364
  }
2295
2365
  default:
@@ -2299,19 +2369,19 @@ function hashTransaction(transactionRequest, chainId) {
2299
2369
  transaction.outputs = transaction.outputs.map((output) => {
2300
2370
  const outputClone = (0, import_ramda2.clone)(output);
2301
2371
  switch (outputClone.type) {
2302
- case import_transactions6.OutputType.Contract: {
2303
- outputClone.balanceRoot = import_configs7.ZeroBytes32;
2304
- outputClone.stateRoot = import_configs7.ZeroBytes32;
2372
+ case import_transactions7.OutputType.Contract: {
2373
+ outputClone.balanceRoot = import_configs8.ZeroBytes32;
2374
+ outputClone.stateRoot = import_configs8.ZeroBytes32;
2305
2375
  return outputClone;
2306
2376
  }
2307
- case import_transactions6.OutputType.Change: {
2308
- outputClone.amount = (0, import_math7.bn)(0);
2377
+ case import_transactions7.OutputType.Change: {
2378
+ outputClone.amount = (0, import_math8.bn)(0);
2309
2379
  return outputClone;
2310
2380
  }
2311
- case import_transactions6.OutputType.Variable: {
2312
- outputClone.to = import_configs7.ZeroBytes32;
2313
- outputClone.amount = (0, import_math7.bn)(0);
2314
- outputClone.assetId = import_configs7.ZeroBytes32;
2381
+ case import_transactions7.OutputType.Variable: {
2382
+ outputClone.to = import_configs8.ZeroBytes32;
2383
+ outputClone.amount = (0, import_math8.bn)(0);
2384
+ outputClone.assetId = import_configs8.ZeroBytes32;
2315
2385
  return outputClone;
2316
2386
  }
2317
2387
  default:
@@ -2321,7 +2391,7 @@ function hashTransaction(transactionRequest, chainId) {
2321
2391
  transaction.witnessesCount = 0;
2322
2392
  transaction.witnesses = [];
2323
2393
  const chainIdBytes = (0, import_hasher.uint64ToBytesBE)(chainId);
2324
- const concatenatedData = (0, import_utils11.concat)([chainIdBytes, new import_transactions6.TransactionCoder().encode(transaction)]);
2394
+ const concatenatedData = (0, import_utils11.concat)([chainIdBytes, new import_transactions7.TransactionCoder().encode(transaction)]);
2325
2395
  return (0, import_hasher.sha256)(concatenatedData);
2326
2396
  }
2327
2397
 
@@ -2357,7 +2427,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2357
2427
  return new this(obj);
2358
2428
  }
2359
2429
  /** Type of the transaction */
2360
- type = import_transactions7.TransactionType.Create;
2430
+ type = import_transactions8.TransactionType.Create;
2361
2431
  /** Witness index of contract bytecode to create */
2362
2432
  bytecodeWitnessIndex;
2363
2433
  /** Salt */
@@ -2377,7 +2447,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2377
2447
  } = {}) {
2378
2448
  super(rest);
2379
2449
  this.bytecodeWitnessIndex = bytecodeWitnessIndex ?? 0;
2380
- this.salt = (0, import_utils13.hexlify)(salt ?? import_configs8.ZeroBytes32);
2450
+ this.salt = (0, import_utils13.hexlify)(salt ?? import_configs9.ZeroBytes32);
2381
2451
  this.storageSlots = [...storageSlots ?? []];
2382
2452
  }
2383
2453
  /**
@@ -2390,12 +2460,12 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2390
2460
  const bytecodeWitnessIndex = this.bytecodeWitnessIndex;
2391
2461
  const storageSlots = this.storageSlots?.map(storageSlotify) ?? [];
2392
2462
  return {
2393
- type: import_transactions7.TransactionType.Create,
2463
+ type: import_transactions8.TransactionType.Create,
2394
2464
  ...baseTransaction,
2395
2465
  bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
2396
2466
  bytecodeWitnessIndex,
2397
2467
  storageSlotsCount: storageSlots.length,
2398
- salt: this.salt ? (0, import_utils13.hexlify)(this.salt) : import_configs8.ZeroBytes32,
2468
+ salt: this.salt ? (0, import_utils13.hexlify)(this.salt) : import_configs9.ZeroBytes32,
2399
2469
  storageSlots
2400
2470
  };
2401
2471
  }
@@ -2406,7 +2476,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2406
2476
  */
2407
2477
  getContractCreatedOutputs() {
2408
2478
  return this.outputs.filter(
2409
- (output) => output.type === import_transactions7.OutputType.ContractCreated
2479
+ (output) => output.type === import_transactions8.OutputType.ContractCreated
2410
2480
  );
2411
2481
  }
2412
2482
  /**
@@ -2427,14 +2497,14 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2427
2497
  */
2428
2498
  addContractCreatedOutput(contractId, stateRoot) {
2429
2499
  this.pushOutput({
2430
- type: import_transactions7.OutputType.ContractCreated,
2500
+ type: import_transactions8.OutputType.ContractCreated,
2431
2501
  contractId,
2432
2502
  stateRoot
2433
2503
  });
2434
2504
  }
2435
2505
  metadataGas(gasCosts) {
2436
2506
  return calculateMetadataGasForTxCreate({
2437
- contractBytesSize: (0, import_math8.bn)((0, import_utils13.arrayify)(this.witnesses[this.bytecodeWitnessIndex] || "0x").length),
2507
+ contractBytesSize: (0, import_math9.bn)((0, import_utils13.arrayify)(this.witnesses[this.bytecodeWitnessIndex] || "0x").length),
2438
2508
  gasCosts,
2439
2509
  stateRootSize: this.storageSlots.length,
2440
2510
  txBytesSize: this.byteSize()
@@ -2443,11 +2513,11 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2443
2513
  };
2444
2514
 
2445
2515
  // src/providers/transaction-request/script-transaction-request.ts
2446
- var import_abi_coder = require("@fuel-ts/abi-coder");
2516
+ var import_abi_coder3 = require("@fuel-ts/abi-coder");
2447
2517
  var import_address2 = require("@fuel-ts/address");
2448
- var import_configs9 = require("@fuel-ts/address/configs");
2449
- var import_math9 = require("@fuel-ts/math");
2450
- var import_transactions8 = require("@fuel-ts/transactions");
2518
+ var import_configs10 = require("@fuel-ts/address/configs");
2519
+ var import_math10 = require("@fuel-ts/math");
2520
+ var import_transactions9 = require("@fuel-ts/transactions");
2451
2521
  var import_utils15 = require("@fuel-ts/utils");
2452
2522
 
2453
2523
  // src/providers/transaction-request/scripts.ts
@@ -2485,13 +2555,14 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2485
2555
  return new this(obj);
2486
2556
  }
2487
2557
  /** Type of the transaction */
2488
- type = import_transactions8.TransactionType.Script;
2558
+ type = import_transactions9.TransactionType.Script;
2489
2559
  /** Gas limit for transaction */
2490
2560
  gasLimit;
2491
2561
  /** Script to execute */
2492
2562
  script;
2493
2563
  /** Script input data (parameters) */
2494
2564
  scriptData;
2565
+ abis;
2495
2566
  /**
2496
2567
  * Constructor for `ScriptTransactionRequest`.
2497
2568
  *
@@ -2499,9 +2570,10 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2499
2570
  */
2500
2571
  constructor({ script, scriptData, gasLimit, ...rest } = {}) {
2501
2572
  super(rest);
2502
- this.gasLimit = (0, import_math9.bn)(gasLimit);
2573
+ this.gasLimit = (0, import_math10.bn)(gasLimit);
2503
2574
  this.script = (0, import_utils15.arrayify)(script ?? returnZeroScript.bytes);
2504
2575
  this.scriptData = (0, import_utils15.arrayify)(scriptData ?? returnZeroScript.encodeScriptData());
2576
+ this.abis = rest.abis;
2505
2577
  }
2506
2578
  /**
2507
2579
  * Converts the transaction request to a `TransactionScript`.
@@ -2512,12 +2584,12 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2512
2584
  const script = (0, import_utils15.arrayify)(this.script ?? "0x");
2513
2585
  const scriptData = (0, import_utils15.arrayify)(this.scriptData ?? "0x");
2514
2586
  return {
2515
- type: import_transactions8.TransactionType.Script,
2587
+ type: import_transactions9.TransactionType.Script,
2516
2588
  scriptGasLimit: this.gasLimit,
2517
2589
  ...super.getBaseTransaction(),
2518
2590
  scriptLength: script.length,
2519
2591
  scriptDataLength: scriptData.length,
2520
- receiptsRoot: import_configs9.ZeroBytes32,
2592
+ receiptsRoot: import_configs10.ZeroBytes32,
2521
2593
  script: (0, import_utils15.hexlify)(script),
2522
2594
  scriptData: (0, import_utils15.hexlify)(scriptData)
2523
2595
  };
@@ -2529,7 +2601,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2529
2601
  */
2530
2602
  getContractInputs() {
2531
2603
  return this.inputs.filter(
2532
- (input) => input.type === import_transactions8.InputType.Contract
2604
+ (input) => input.type === import_transactions9.InputType.Contract
2533
2605
  );
2534
2606
  }
2535
2607
  /**
@@ -2539,7 +2611,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2539
2611
  */
2540
2612
  getContractOutputs() {
2541
2613
  return this.outputs.filter(
2542
- (output) => output.type === import_transactions8.OutputType.Contract
2614
+ (output) => output.type === import_transactions9.OutputType.Contract
2543
2615
  );
2544
2616
  }
2545
2617
  /**
@@ -2549,7 +2621,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2549
2621
  */
2550
2622
  getVariableOutputs() {
2551
2623
  return this.outputs.filter(
2552
- (output) => output.type === import_transactions8.OutputType.Variable
2624
+ (output) => output.type === import_transactions9.OutputType.Variable
2553
2625
  );
2554
2626
  }
2555
2627
  /**
@@ -2572,7 +2644,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2572
2644
  let outputsNumber = numberOfVariables;
2573
2645
  while (outputsNumber) {
2574
2646
  this.pushOutput({
2575
- type: import_transactions8.OutputType.Variable
2647
+ type: import_transactions9.OutputType.Variable
2576
2648
  });
2577
2649
  outputsNumber -= 1;
2578
2650
  }
@@ -2605,12 +2677,12 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2605
2677
  return this;
2606
2678
  }
2607
2679
  const inputIndex = super.pushInput({
2608
- type: import_transactions8.InputType.Contract,
2680
+ type: import_transactions9.InputType.Contract,
2609
2681
  contractId: contractAddress.toB256(),
2610
2682
  txPointer: "0x00000000000000000000000000000000"
2611
2683
  });
2612
2684
  this.pushOutput({
2613
- type: import_transactions8.OutputType.Contract,
2685
+ type: import_transactions9.OutputType.Contract,
2614
2686
  inputIndex
2615
2687
  });
2616
2688
  return this;
@@ -2633,7 +2705,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2633
2705
  * @returns The current instance of the `ScriptTransactionRequest`.
2634
2706
  */
2635
2707
  setData(abi, args) {
2636
- const abiInterface = new import_abi_coder.Interface(abi);
2708
+ const abiInterface = new import_abi_coder3.Interface(abi);
2637
2709
  this.scriptData = abiInterface.functions.main.encodeArguments(args);
2638
2710
  return this;
2639
2711
  }
@@ -2646,38 +2718,38 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2646
2718
  };
2647
2719
 
2648
2720
  // src/providers/transaction-request/utils.ts
2649
- var import_errors8 = require("@fuel-ts/errors");
2650
- var import_transactions9 = require("@fuel-ts/transactions");
2721
+ var import_errors9 = require("@fuel-ts/errors");
2722
+ var import_transactions10 = require("@fuel-ts/transactions");
2651
2723
  var transactionRequestify = (obj) => {
2652
2724
  if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest) {
2653
2725
  return obj;
2654
2726
  }
2655
2727
  const { type } = obj;
2656
2728
  switch (obj.type) {
2657
- case import_transactions9.TransactionType.Script: {
2729
+ case import_transactions10.TransactionType.Script: {
2658
2730
  return ScriptTransactionRequest.from(obj);
2659
2731
  }
2660
- case import_transactions9.TransactionType.Create: {
2732
+ case import_transactions10.TransactionType.Create: {
2661
2733
  return CreateTransactionRequest.from(obj);
2662
2734
  }
2663
2735
  default: {
2664
- throw new import_errors8.FuelError(import_errors8.ErrorCode.INVALID_TRANSACTION_TYPE, `Invalid transaction type: ${type}.`);
2736
+ throw new import_errors9.FuelError(import_errors9.ErrorCode.INVALID_TRANSACTION_TYPE, `Invalid transaction type: ${type}.`);
2665
2737
  }
2666
2738
  }
2667
2739
  };
2668
2740
 
2669
2741
  // src/providers/transaction-response/transaction-response.ts
2670
- var import_errors12 = require("@fuel-ts/errors");
2671
- var import_math13 = require("@fuel-ts/math");
2672
- var import_transactions15 = require("@fuel-ts/transactions");
2742
+ var import_errors13 = require("@fuel-ts/errors");
2743
+ var import_math14 = require("@fuel-ts/math");
2744
+ var import_transactions17 = require("@fuel-ts/transactions");
2673
2745
  var import_utils21 = require("@fuel-ts/utils");
2674
2746
 
2675
2747
  // src/providers/transaction-summary/assemble-transaction-summary.ts
2676
2748
  var import_utils19 = require("@fuel-ts/utils");
2677
2749
 
2678
2750
  // src/providers/transaction-summary/calculate-transaction-fee.ts
2679
- var import_math10 = require("@fuel-ts/math");
2680
- var import_transactions10 = require("@fuel-ts/transactions");
2751
+ var import_math11 = require("@fuel-ts/math");
2752
+ var import_transactions11 = require("@fuel-ts/transactions");
2681
2753
  var import_utils16 = require("@fuel-ts/utils");
2682
2754
  var calculateTransactionFee = (params) => {
2683
2755
  const {
@@ -2685,24 +2757,24 @@ var calculateTransactionFee = (params) => {
2685
2757
  rawPayload,
2686
2758
  consensusParameters: { gasCosts, feeParams }
2687
2759
  } = params;
2688
- const gasPerByte = (0, import_math10.bn)(feeParams.gasPerByte);
2689
- const gasPriceFactor = (0, import_math10.bn)(feeParams.gasPriceFactor);
2760
+ const gasPerByte = (0, import_math11.bn)(feeParams.gasPerByte);
2761
+ const gasPriceFactor = (0, import_math11.bn)(feeParams.gasPriceFactor);
2690
2762
  const transactionBytes = (0, import_utils16.arrayify)(rawPayload);
2691
- const [transaction] = new import_transactions10.TransactionCoder().decode(transactionBytes, 0);
2692
- if (transaction.type === import_transactions10.TransactionType.Mint) {
2763
+ const [transaction] = new import_transactions11.TransactionCoder().decode(transactionBytes, 0);
2764
+ if (transaction.type === import_transactions11.TransactionType.Mint) {
2693
2765
  return {
2694
- fee: (0, import_math10.bn)(0),
2695
- minFee: (0, import_math10.bn)(0),
2696
- maxFee: (0, import_math10.bn)(0),
2697
- feeFromGasUsed: (0, import_math10.bn)(0)
2766
+ fee: (0, import_math11.bn)(0),
2767
+ minFee: (0, import_math11.bn)(0),
2768
+ maxFee: (0, import_math11.bn)(0),
2769
+ feeFromGasUsed: (0, import_math11.bn)(0)
2698
2770
  };
2699
2771
  }
2700
2772
  const { type, witnesses, inputs, policies } = transaction;
2701
- let metadataGas = (0, import_math10.bn)(0);
2702
- let gasLimit = (0, import_math10.bn)(0);
2703
- if (type === import_transactions10.TransactionType.Create) {
2773
+ let metadataGas = (0, import_math11.bn)(0);
2774
+ let gasLimit = (0, import_math11.bn)(0);
2775
+ if (type === import_transactions11.TransactionType.Create) {
2704
2776
  const { bytecodeWitnessIndex, storageSlots } = transaction;
2705
- const contractBytesSize = (0, import_math10.bn)((0, import_utils16.arrayify)(witnesses[bytecodeWitnessIndex].data).length);
2777
+ const contractBytesSize = (0, import_math11.bn)((0, import_utils16.arrayify)(witnesses[bytecodeWitnessIndex].data).length);
2706
2778
  metadataGas = calculateMetadataGasForTxCreate({
2707
2779
  contractBytesSize,
2708
2780
  gasCosts,
@@ -2721,13 +2793,13 @@ var calculateTransactionFee = (params) => {
2721
2793
  }
2722
2794
  const minGas = getMinGas({
2723
2795
  gasCosts,
2724
- gasPerByte: (0, import_math10.bn)(gasPerByte),
2796
+ gasPerByte: (0, import_math11.bn)(gasPerByte),
2725
2797
  inputs,
2726
2798
  metadataGas,
2727
2799
  txBytesSize: transactionBytes.length
2728
2800
  });
2729
- const gasPrice = (0, import_math10.bn)(policies.find((policy) => policy.type === import_transactions10.PolicyType.GasPrice)?.data);
2730
- const witnessLimit = policies.find((policy) => policy.type === import_transactions10.PolicyType.WitnessLimit)?.data;
2801
+ const gasPrice = (0, import_math11.bn)(policies.find((policy) => policy.type === import_transactions11.PolicyType.GasPrice)?.data);
2802
+ const witnessLimit = policies.find((policy) => policy.type === import_transactions11.PolicyType.WitnessLimit)?.data;
2731
2803
  const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
2732
2804
  const maxGas = getMaxGas({
2733
2805
  gasPerByte,
@@ -2749,23 +2821,23 @@ var calculateTransactionFee = (params) => {
2749
2821
  };
2750
2822
 
2751
2823
  // src/providers/transaction-summary/operations.ts
2752
- var import_configs10 = require("@fuel-ts/address/configs");
2753
- var import_errors10 = require("@fuel-ts/errors");
2754
- var import_math12 = require("@fuel-ts/math");
2755
- var import_transactions13 = require("@fuel-ts/transactions");
2824
+ var import_configs11 = require("@fuel-ts/address/configs");
2825
+ var import_errors11 = require("@fuel-ts/errors");
2826
+ var import_math13 = require("@fuel-ts/math");
2827
+ var import_transactions14 = require("@fuel-ts/transactions");
2756
2828
 
2757
2829
  // src/providers/transaction-summary/call.ts
2758
- var import_abi_coder2 = require("@fuel-ts/abi-coder");
2759
- var import_math11 = require("@fuel-ts/math");
2830
+ var import_abi_coder4 = require("@fuel-ts/abi-coder");
2831
+ var import_math12 = require("@fuel-ts/math");
2760
2832
  var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
2761
- const abiInterface = new import_abi_coder2.Interface(abi);
2833
+ const abiInterface = new import_abi_coder4.Interface(abi);
2762
2834
  const callFunctionSelector = receipt.param1.toHex(8);
2763
2835
  const functionFragment = abiInterface.getFunction(callFunctionSelector);
2764
2836
  const inputs = functionFragment.jsonFn.inputs;
2765
2837
  let encodedArgs;
2766
2838
  if (functionFragment.isInputDataPointer) {
2767
2839
  if (rawPayload) {
2768
- const argsOffset = (0, import_math11.bn)(receipt.param2).sub((0, import_abi_coder2.calculateVmTxMemory)({ maxInputs: maxInputs.toNumber() })).toNumber();
2840
+ const argsOffset = (0, import_math12.bn)(receipt.param2).sub((0, import_abi_coder4.calculateVmTxMemory)({ maxInputs: maxInputs.toNumber() })).toNumber();
2769
2841
  encodedArgs = `0x${rawPayload.slice(2).slice(argsOffset * 2)}`;
2770
2842
  }
2771
2843
  } else {
@@ -2799,8 +2871,8 @@ var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
2799
2871
  };
2800
2872
 
2801
2873
  // src/providers/transaction-summary/input.ts
2802
- var import_errors9 = require("@fuel-ts/errors");
2803
- var import_transactions11 = require("@fuel-ts/transactions");
2874
+ var import_errors10 = require("@fuel-ts/errors");
2875
+ var import_transactions12 = require("@fuel-ts/transactions");
2804
2876
  function getInputsByTypes(inputs, types) {
2805
2877
  return inputs.filter((i) => types.includes(i.type));
2806
2878
  }
@@ -2808,16 +2880,16 @@ function getInputsByType(inputs, type) {
2808
2880
  return inputs.filter((i) => i.type === type);
2809
2881
  }
2810
2882
  function getInputsCoin(inputs) {
2811
- return getInputsByType(inputs, import_transactions11.InputType.Coin);
2883
+ return getInputsByType(inputs, import_transactions12.InputType.Coin);
2812
2884
  }
2813
2885
  function getInputsMessage(inputs) {
2814
- return getInputsByType(inputs, import_transactions11.InputType.Message);
2886
+ return getInputsByType(inputs, import_transactions12.InputType.Message);
2815
2887
  }
2816
2888
  function getInputsCoinAndMessage(inputs) {
2817
- return getInputsByTypes(inputs, [import_transactions11.InputType.Coin, import_transactions11.InputType.Message]);
2889
+ return getInputsByTypes(inputs, [import_transactions12.InputType.Coin, import_transactions12.InputType.Message]);
2818
2890
  }
2819
2891
  function getInputsContract(inputs) {
2820
- return getInputsByType(inputs, import_transactions11.InputType.Contract);
2892
+ return getInputsByType(inputs, import_transactions12.InputType.Contract);
2821
2893
  }
2822
2894
  function getInputFromAssetId(inputs, assetId) {
2823
2895
  const coinInputs = getInputsCoin(inputs);
@@ -2836,43 +2908,43 @@ function getInputContractFromIndex(inputs, inputIndex) {
2836
2908
  if (!contractInput) {
2837
2909
  return void 0;
2838
2910
  }
2839
- if (contractInput.type !== import_transactions11.InputType.Contract) {
2840
- throw new import_errors9.FuelError(
2841
- import_errors9.ErrorCode.INVALID_TRANSACTION_INPUT,
2911
+ if (contractInput.type !== import_transactions12.InputType.Contract) {
2912
+ throw new import_errors10.FuelError(
2913
+ import_errors10.ErrorCode.INVALID_TRANSACTION_INPUT,
2842
2914
  `Contract input should be of type 'contract'.`
2843
2915
  );
2844
2916
  }
2845
2917
  return contractInput;
2846
2918
  }
2847
2919
  function getInputAccountAddress(input) {
2848
- if (input.type === import_transactions11.InputType.Coin) {
2920
+ if (input.type === import_transactions12.InputType.Coin) {
2849
2921
  return input.owner.toString();
2850
2922
  }
2851
- if (input.type === import_transactions11.InputType.Message) {
2923
+ if (input.type === import_transactions12.InputType.Message) {
2852
2924
  return input.recipient.toString();
2853
2925
  }
2854
2926
  return "";
2855
2927
  }
2856
2928
 
2857
2929
  // src/providers/transaction-summary/output.ts
2858
- var import_transactions12 = require("@fuel-ts/transactions");
2930
+ var import_transactions13 = require("@fuel-ts/transactions");
2859
2931
  function getOutputsByType(outputs, type) {
2860
2932
  return outputs.filter((o) => o.type === type);
2861
2933
  }
2862
2934
  function getOutputsContractCreated(outputs) {
2863
- return getOutputsByType(outputs, import_transactions12.OutputType.ContractCreated);
2935
+ return getOutputsByType(outputs, import_transactions13.OutputType.ContractCreated);
2864
2936
  }
2865
2937
  function getOutputsCoin(outputs) {
2866
- return getOutputsByType(outputs, import_transactions12.OutputType.Coin);
2938
+ return getOutputsByType(outputs, import_transactions13.OutputType.Coin);
2867
2939
  }
2868
2940
  function getOutputsChange(outputs) {
2869
- return getOutputsByType(outputs, import_transactions12.OutputType.Change);
2941
+ return getOutputsByType(outputs, import_transactions13.OutputType.Change);
2870
2942
  }
2871
2943
  function getOutputsContract(outputs) {
2872
- return getOutputsByType(outputs, import_transactions12.OutputType.Contract);
2944
+ return getOutputsByType(outputs, import_transactions13.OutputType.Contract);
2873
2945
  }
2874
2946
  function getOutputsVariable(outputs) {
2875
- return getOutputsByType(outputs, import_transactions12.OutputType.Variable);
2947
+ return getOutputsByType(outputs, import_transactions13.OutputType.Variable);
2876
2948
  }
2877
2949
 
2878
2950
  // src/providers/transaction-summary/types.ts
@@ -2919,15 +2991,15 @@ function getReceiptsByType(receipts, type) {
2919
2991
  }
2920
2992
  function getTransactionTypeName(transactionType) {
2921
2993
  switch (transactionType) {
2922
- case import_transactions13.TransactionType.Mint:
2994
+ case import_transactions14.TransactionType.Mint:
2923
2995
  return "Mint" /* Mint */;
2924
- case import_transactions13.TransactionType.Create:
2996
+ case import_transactions14.TransactionType.Create:
2925
2997
  return "Create" /* Create */;
2926
- case import_transactions13.TransactionType.Script:
2998
+ case import_transactions14.TransactionType.Script:
2927
2999
  return "Script" /* Script */;
2928
3000
  default:
2929
- throw new import_errors10.FuelError(
2930
- import_errors10.ErrorCode.INVALID_TRANSACTION_TYPE,
3001
+ throw new import_errors11.FuelError(
3002
+ import_errors11.ErrorCode.INVALID_TRANSACTION_TYPE,
2931
3003
  `Invalid transaction type: ${transactionType}.`
2932
3004
  );
2933
3005
  }
@@ -2949,10 +3021,10 @@ function hasSameAssetId(a) {
2949
3021
  return (b) => a.assetId === b.assetId;
2950
3022
  }
2951
3023
  function getReceiptsCall(receipts) {
2952
- return getReceiptsByType(receipts, import_transactions13.ReceiptType.Call);
3024
+ return getReceiptsByType(receipts, import_transactions14.ReceiptType.Call);
2953
3025
  }
2954
3026
  function getReceiptsMessageOut(receipts) {
2955
- return getReceiptsByType(receipts, import_transactions13.ReceiptType.MessageOut);
3027
+ return getReceiptsByType(receipts, import_transactions14.ReceiptType.MessageOut);
2956
3028
  }
2957
3029
  var mergeAssets = (op1, op2) => {
2958
3030
  const assets1 = op1.assetsSent || [];
@@ -2965,7 +3037,7 @@ var mergeAssets = (op1, op2) => {
2965
3037
  if (!matchingAsset) {
2966
3038
  return asset1;
2967
3039
  }
2968
- const mergedAmount = (0, import_math12.bn)(asset1.amount).add(matchingAsset.amount);
3040
+ const mergedAmount = (0, import_math13.bn)(asset1.amount).add(matchingAsset.amount);
2969
3041
  return { ...asset1, amount: mergedAmount };
2970
3042
  });
2971
3043
  return mergedAssets.concat(filteredAssets);
@@ -2991,7 +3063,7 @@ function addOperation(operations, toAdd) {
2991
3063
  return allOperations;
2992
3064
  }
2993
3065
  function getReceiptsTransferOut(receipts) {
2994
- return getReceiptsByType(receipts, import_transactions13.ReceiptType.TransferOut);
3066
+ return getReceiptsByType(receipts, import_transactions14.ReceiptType.TransferOut);
2995
3067
  }
2996
3068
  function getWithdrawFromFuelOperations({
2997
3069
  inputs,
@@ -3094,7 +3166,7 @@ function extractTransferOperationFromReceipt(receipt, contractInputs, changeOutp
3094
3166
  const { to: toAddress, assetId, amount } = receipt;
3095
3167
  let { from: fromAddress } = receipt;
3096
3168
  const toType = contractInputs.some((input) => input.contractID === toAddress) ? 0 /* contract */ : 1 /* account */;
3097
- if (import_configs10.ZeroBytes32 === fromAddress) {
3169
+ if (import_configs11.ZeroBytes32 === fromAddress) {
3098
3170
  const change = changeOutputs.find((output) => output.assetId === assetId);
3099
3171
  fromAddress = change?.to || fromAddress;
3100
3172
  }
@@ -3151,11 +3223,11 @@ function getTransferOperations({
3151
3223
  });
3152
3224
  const transferReceipts = getReceiptsByType(
3153
3225
  receipts,
3154
- import_transactions13.ReceiptType.Transfer
3226
+ import_transactions14.ReceiptType.Transfer
3155
3227
  );
3156
3228
  const transferOutReceipts = getReceiptsByType(
3157
3229
  receipts,
3158
- import_transactions13.ReceiptType.TransferOut
3230
+ import_transactions14.ReceiptType.TransferOut
3159
3231
  );
3160
3232
  [...transferReceipts, ...transferOutReceipts].forEach((receipt) => {
3161
3233
  const operation = extractTransferOperationFromReceipt(receipt, contractInputs, changeOutputs);
@@ -3240,17 +3312,17 @@ function getOperations({
3240
3312
  }
3241
3313
 
3242
3314
  // src/providers/transaction-summary/receipt.ts
3243
- var import_transactions14 = require("@fuel-ts/transactions");
3315
+ var import_transactions15 = require("@fuel-ts/transactions");
3244
3316
  var processGqlReceipt = (gqlReceipt) => {
3245
3317
  const receipt = assembleReceiptByType(gqlReceipt);
3246
3318
  switch (receipt.type) {
3247
- case import_transactions14.ReceiptType.ReturnData: {
3319
+ case import_transactions15.ReceiptType.ReturnData: {
3248
3320
  return {
3249
3321
  ...receipt,
3250
3322
  data: gqlReceipt.data || "0x"
3251
3323
  };
3252
3324
  }
3253
- case import_transactions14.ReceiptType.LogData: {
3325
+ case import_transactions15.ReceiptType.LogData: {
3254
3326
  return {
3255
3327
  ...receipt,
3256
3328
  data: gqlReceipt.data || "0x"
@@ -3263,7 +3335,7 @@ var processGqlReceipt = (gqlReceipt) => {
3263
3335
  var extractMintedAssetsFromReceipts = (receipts) => {
3264
3336
  const mintedAssets = [];
3265
3337
  receipts.forEach((receipt) => {
3266
- if (receipt.type === import_transactions14.ReceiptType.Mint) {
3338
+ if (receipt.type === import_transactions15.ReceiptType.Mint) {
3267
3339
  mintedAssets.push({
3268
3340
  subId: receipt.subId,
3269
3341
  contractId: receipt.contractId,
@@ -3277,7 +3349,7 @@ var extractMintedAssetsFromReceipts = (receipts) => {
3277
3349
  var extractBurnedAssetsFromReceipts = (receipts) => {
3278
3350
  const burnedAssets = [];
3279
3351
  receipts.forEach((receipt) => {
3280
- if (receipt.type === import_transactions14.ReceiptType.Burn) {
3352
+ if (receipt.type === import_transactions15.ReceiptType.Burn) {
3281
3353
  burnedAssets.push({
3282
3354
  subId: receipt.subId,
3283
3355
  contractId: receipt.contractId,
@@ -3290,7 +3362,7 @@ var extractBurnedAssetsFromReceipts = (receipts) => {
3290
3362
  };
3291
3363
 
3292
3364
  // src/providers/transaction-summary/status.ts
3293
- var import_errors11 = require("@fuel-ts/errors");
3365
+ var import_errors12 = require("@fuel-ts/errors");
3294
3366
  var getTransactionStatusName = (gqlStatus) => {
3295
3367
  switch (gqlStatus) {
3296
3368
  case "FailureStatus":
@@ -3302,8 +3374,8 @@ var getTransactionStatusName = (gqlStatus) => {
3302
3374
  case "SqueezedOutStatus":
3303
3375
  return "squeezedout" /* squeezedout */;
3304
3376
  default:
3305
- throw new import_errors11.FuelError(
3306
- import_errors11.ErrorCode.INVALID_TRANSACTION_STATUS,
3377
+ throw new import_errors12.FuelError(
3378
+ import_errors12.ErrorCode.INVALID_TRANSACTION_STATUS,
3307
3379
  `Invalid transaction status: ${gqlStatus}.`
3308
3380
  );
3309
3381
  }
@@ -3414,6 +3486,21 @@ function assembleTransactionSummary(params) {
3414
3486
  return transactionSummary;
3415
3487
  }
3416
3488
 
3489
+ // src/providers/transaction-response/getDecodedLogs.ts
3490
+ var import_abi_coder5 = require("@fuel-ts/abi-coder");
3491
+ var import_transactions16 = require("@fuel-ts/transactions");
3492
+ function getDecodedLogs(receipts, mainAbi, externalAbis = {}) {
3493
+ return receipts.reduce((logs, receipt) => {
3494
+ if (receipt.type === import_transactions16.ReceiptType.LogData || receipt.type === import_transactions16.ReceiptType.Log) {
3495
+ const interfaceToUse = new import_abi_coder5.Interface(externalAbis[receipt.id] || mainAbi);
3496
+ const data = receipt.type === import_transactions16.ReceiptType.Log ? new import_abi_coder5.BigNumberCoder("u64").encode(receipt.val0) : receipt.data;
3497
+ const [decodedLog] = interfaceToUse.decodeLog(data, receipt.val1.toNumber());
3498
+ logs.push(decodedLog);
3499
+ }
3500
+ return logs;
3501
+ }, []);
3502
+ }
3503
+
3417
3504
  // src/providers/transaction-response/transaction-response.ts
3418
3505
  var TransactionResponse = class {
3419
3506
  /** Transaction ID */
@@ -3421,18 +3508,20 @@ var TransactionResponse = class {
3421
3508
  /** Current provider */
3422
3509
  provider;
3423
3510
  /** Gas used on the transaction */
3424
- gasUsed = (0, import_math13.bn)(0);
3511
+ gasUsed = (0, import_math14.bn)(0);
3425
3512
  /** The graphql Transaction with receipts object. */
3426
3513
  gqlTransaction;
3514
+ abis;
3427
3515
  /**
3428
3516
  * Constructor for `TransactionResponse`.
3429
3517
  *
3430
3518
  * @param id - The transaction ID.
3431
3519
  * @param provider - The provider.
3432
3520
  */
3433
- constructor(id, provider) {
3521
+ constructor(id, provider, abis) {
3434
3522
  this.id = id;
3435
3523
  this.provider = provider;
3524
+ this.abis = abis;
3436
3525
  }
3437
3526
  /**
3438
3527
  * Async constructor for `TransactionResponse`. This method can be used to create
@@ -3442,8 +3531,8 @@ var TransactionResponse = class {
3442
3531
  * @param id - The transaction ID.
3443
3532
  * @param provider - The provider.
3444
3533
  */
3445
- static async create(id, provider) {
3446
- const response = new TransactionResponse(id, provider);
3534
+ static async create(id, provider, abis) {
3535
+ const response = new TransactionResponse(id, provider, abis);
3447
3536
  await response.fetch();
3448
3537
  return response;
3449
3538
  }
@@ -3477,7 +3566,7 @@ var TransactionResponse = class {
3477
3566
  * @returns The decoded transaction.
3478
3567
  */
3479
3568
  decodeTransaction(transactionWithReceipts) {
3480
- return new import_transactions15.TransactionCoder().decode(
3569
+ return new import_transactions17.TransactionCoder().decode(
3481
3570
  (0, import_utils21.arrayify)(transactionWithReceipts.rawPayload),
3482
3571
  0
3483
3572
  )?.[0];
@@ -3524,8 +3613,8 @@ var TransactionResponse = class {
3524
3613
  });
3525
3614
  for await (const { statusChange } of subscription) {
3526
3615
  if (statusChange.type === "SqueezedOutStatus") {
3527
- throw new import_errors12.FuelError(
3528
- import_errors12.ErrorCode.TRANSACTION_SQUEEZED_OUT,
3616
+ throw new import_errors13.FuelError(
3617
+ import_errors13.ErrorCode.TRANSACTION_SQUEEZED_OUT,
3529
3618
  `Transaction Squeezed Out with reason: ${statusChange.reason}`
3530
3619
  );
3531
3620
  }
@@ -3547,6 +3636,26 @@ var TransactionResponse = class {
3547
3636
  gqlTransaction: this.gqlTransaction,
3548
3637
  ...transactionSummary
3549
3638
  };
3639
+ let logs = [];
3640
+ if (this.abis) {
3641
+ logs = getDecodedLogs(
3642
+ transactionSummary.receipts,
3643
+ this.abis.main,
3644
+ this.abis.otherContractsAbis
3645
+ );
3646
+ transactionResult.logs = logs;
3647
+ }
3648
+ if (transactionResult.isStatusFailure) {
3649
+ const {
3650
+ receipts,
3651
+ gqlTransaction: { status }
3652
+ } = transactionResult;
3653
+ throw extractTxError({
3654
+ receipts,
3655
+ status,
3656
+ logs
3657
+ });
3658
+ }
3550
3659
  return transactionResult;
3551
3660
  }
3552
3661
  /**
@@ -3555,34 +3664,10 @@ var TransactionResponse = class {
3555
3664
  * @param contractsAbiMap - The contracts ABI map.
3556
3665
  */
3557
3666
  async wait(contractsAbiMap) {
3558
- const result = await this.waitForResult(contractsAbiMap);
3559
- if (result.isStatusFailure) {
3560
- throw new import_errors12.FuelError(
3561
- import_errors12.ErrorCode.TRANSACTION_FAILED,
3562
- `Transaction failed: ${result.gqlTransaction.status.reason}`
3563
- );
3564
- }
3565
- return result;
3667
+ return this.waitForResult(contractsAbiMap);
3566
3668
  }
3567
3669
  };
3568
3670
 
3569
- // src/providers/transaction-response/getDecodedLogs.ts
3570
- var import_abi_coder3 = require("@fuel-ts/abi-coder");
3571
- var import_transactions16 = require("@fuel-ts/transactions");
3572
- function getDecodedLogs(receipts, abiInterface) {
3573
- return receipts.reduce((logs, r) => {
3574
- if (r.type === import_transactions16.ReceiptType.LogData) {
3575
- logs.push(abiInterface.decodeLog(r.data, r.val1.toNumber(), r.id)[0]);
3576
- }
3577
- if (r.type === import_transactions16.ReceiptType.Log) {
3578
- logs.push(
3579
- abiInterface.decodeLog(new import_abi_coder3.BigNumberCoder("u64").encode(r.val0), r.val1.toNumber(), r.id)[0]
3580
- );
3581
- }
3582
- return logs;
3583
- }, []);
3584
- }
3585
-
3586
3671
  // src/providers/utils/auto-retry-fetch.ts
3587
3672
  function getWaitDelay(options, retryAttemptNum) {
3588
3673
  const duration = options.baseDelay ?? 150;
@@ -3641,29 +3726,29 @@ var processGqlChain = (chain) => {
3641
3726
  const { contractParams, feeParams, predicateParams, scriptParams, txParams, gasCosts } = consensusParameters;
3642
3727
  return {
3643
3728
  name,
3644
- baseChainHeight: (0, import_math14.bn)(daHeight),
3729
+ baseChainHeight: (0, import_math15.bn)(daHeight),
3645
3730
  consensusParameters: {
3646
- contractMaxSize: (0, import_math14.bn)(contractParams.contractMaxSize),
3647
- maxInputs: (0, import_math14.bn)(txParams.maxInputs),
3648
- maxOutputs: (0, import_math14.bn)(txParams.maxOutputs),
3649
- maxWitnesses: (0, import_math14.bn)(txParams.maxWitnesses),
3650
- maxGasPerTx: (0, import_math14.bn)(txParams.maxGasPerTx),
3651
- maxScriptLength: (0, import_math14.bn)(scriptParams.maxScriptLength),
3652
- maxScriptDataLength: (0, import_math14.bn)(scriptParams.maxScriptDataLength),
3653
- maxStorageSlots: (0, import_math14.bn)(contractParams.maxStorageSlots),
3654
- maxPredicateLength: (0, import_math14.bn)(predicateParams.maxPredicateLength),
3655
- maxPredicateDataLength: (0, import_math14.bn)(predicateParams.maxPredicateDataLength),
3656
- maxGasPerPredicate: (0, import_math14.bn)(predicateParams.maxGasPerPredicate),
3657
- gasPriceFactor: (0, import_math14.bn)(feeParams.gasPriceFactor),
3658
- gasPerByte: (0, import_math14.bn)(feeParams.gasPerByte),
3659
- maxMessageDataLength: (0, import_math14.bn)(predicateParams.maxMessageDataLength),
3660
- chainId: (0, import_math14.bn)(consensusParameters.chainId),
3731
+ contractMaxSize: (0, import_math15.bn)(contractParams.contractMaxSize),
3732
+ maxInputs: (0, import_math15.bn)(txParams.maxInputs),
3733
+ maxOutputs: (0, import_math15.bn)(txParams.maxOutputs),
3734
+ maxWitnesses: (0, import_math15.bn)(txParams.maxWitnesses),
3735
+ maxGasPerTx: (0, import_math15.bn)(txParams.maxGasPerTx),
3736
+ maxScriptLength: (0, import_math15.bn)(scriptParams.maxScriptLength),
3737
+ maxScriptDataLength: (0, import_math15.bn)(scriptParams.maxScriptDataLength),
3738
+ maxStorageSlots: (0, import_math15.bn)(contractParams.maxStorageSlots),
3739
+ maxPredicateLength: (0, import_math15.bn)(predicateParams.maxPredicateLength),
3740
+ maxPredicateDataLength: (0, import_math15.bn)(predicateParams.maxPredicateDataLength),
3741
+ maxGasPerPredicate: (0, import_math15.bn)(predicateParams.maxGasPerPredicate),
3742
+ gasPriceFactor: (0, import_math15.bn)(feeParams.gasPriceFactor),
3743
+ gasPerByte: (0, import_math15.bn)(feeParams.gasPerByte),
3744
+ maxMessageDataLength: (0, import_math15.bn)(predicateParams.maxMessageDataLength),
3745
+ chainId: (0, import_math15.bn)(consensusParameters.chainId),
3661
3746
  gasCosts
3662
3747
  },
3663
3748
  gasCosts,
3664
3749
  latestBlock: {
3665
3750
  id: latestBlock.id,
3666
- height: (0, import_math14.bn)(latestBlock.header.height),
3751
+ height: (0, import_math15.bn)(latestBlock.header.height),
3667
3752
  time: latestBlock.header.time,
3668
3753
  transactions: latestBlock.transactions.map((i) => ({
3669
3754
  id: i.id
@@ -3733,8 +3818,8 @@ var _Provider = class {
3733
3818
  getChain() {
3734
3819
  const chain = _Provider.chainInfoCache[this.url];
3735
3820
  if (!chain) {
3736
- throw new import_errors13.FuelError(
3737
- import_errors13.ErrorCode.CHAIN_INFO_CACHE_EMPTY,
3821
+ throw new import_errors14.FuelError(
3822
+ import_errors14.ErrorCode.CHAIN_INFO_CACHE_EMPTY,
3738
3823
  "Chain info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
3739
3824
  );
3740
3825
  }
@@ -3746,8 +3831,8 @@ var _Provider = class {
3746
3831
  getNode() {
3747
3832
  const node = _Provider.nodeInfoCache[this.url];
3748
3833
  if (!node) {
3749
- throw new import_errors13.FuelError(
3750
- import_errors13.ErrorCode.NODE_INFO_CACHE_EMPTY,
3834
+ throw new import_errors14.FuelError(
3835
+ import_errors14.ErrorCode.NODE_INFO_CACHE_EMPTY,
3751
3836
  "Node info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
3752
3837
  );
3753
3838
  }
@@ -3794,8 +3879,8 @@ var _Provider = class {
3794
3879
  static ensureClientVersionIsSupported(nodeInfo) {
3795
3880
  const { isMajorSupported, isMinorSupported, supportedVersion } = (0, import_versions.checkFuelCoreVersionCompatibility)(nodeInfo.nodeVersion);
3796
3881
  if (!isMajorSupported || !isMinorSupported) {
3797
- throw new import_errors13.FuelError(
3798
- import_errors13.FuelError.CODES.UNSUPPORTED_FUEL_CLIENT_VERSION,
3882
+ throw new import_errors14.FuelError(
3883
+ import_errors14.FuelError.CODES.UNSUPPORTED_FUEL_CLIENT_VERSION,
3799
3884
  `Fuel client version: ${nodeInfo.nodeVersion}, Supported version: ${supportedVersion}`
3800
3885
  );
3801
3886
  }
@@ -3858,7 +3943,7 @@ var _Provider = class {
3858
3943
  */
3859
3944
  async getBlockNumber() {
3860
3945
  const { chain } = await this.operations.getChain();
3861
- return (0, import_math14.bn)(chain.latestBlock.header.height, 10);
3946
+ return (0, import_math15.bn)(chain.latestBlock.header.height, 10);
3862
3947
  }
3863
3948
  /**
3864
3949
  * Returns the chain information.
@@ -3868,9 +3953,9 @@ var _Provider = class {
3868
3953
  async fetchNode() {
3869
3954
  const { nodeInfo } = await this.operations.getNodeInfo();
3870
3955
  const processedNodeInfo = {
3871
- maxDepth: (0, import_math14.bn)(nodeInfo.maxDepth),
3872
- maxTx: (0, import_math14.bn)(nodeInfo.maxTx),
3873
- minGasPrice: (0, import_math14.bn)(nodeInfo.minGasPrice),
3956
+ maxDepth: (0, import_math15.bn)(nodeInfo.maxDepth),
3957
+ maxTx: (0, import_math15.bn)(nodeInfo.maxTx),
3958
+ minGasPrice: (0, import_math15.bn)(nodeInfo.minGasPrice),
3874
3959
  nodeVersion: nodeInfo.nodeVersion,
3875
3960
  utxoValidation: nodeInfo.utxoValidation,
3876
3961
  vmBacktrace: nodeInfo.vmBacktrace,
@@ -3916,13 +4001,17 @@ var _Provider = class {
3916
4001
  if (estimateTxDependencies) {
3917
4002
  await this.estimateTxDependencies(transactionRequest);
3918
4003
  }
3919
- const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
4004
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
4005
+ let abis;
4006
+ if (transactionRequest.type === import_transactions18.TransactionType.Script) {
4007
+ abis = transactionRequest.abis;
4008
+ }
3920
4009
  if (awaitExecution) {
3921
4010
  const subscription = this.operations.submitAndAwait({ encodedTransaction });
3922
4011
  for await (const { submitAndAwait } of subscription) {
3923
4012
  if (submitAndAwait.type === "SqueezedOutStatus") {
3924
- throw new import_errors13.FuelError(
3925
- import_errors13.ErrorCode.TRANSACTION_SQUEEZED_OUT,
4013
+ throw new import_errors14.FuelError(
4014
+ import_errors14.ErrorCode.TRANSACTION_SQUEEZED_OUT,
3926
4015
  `Transaction Squeezed Out with reason: ${submitAndAwait.reason}`
3927
4016
  );
3928
4017
  }
@@ -3931,14 +4020,14 @@ var _Provider = class {
3931
4020
  }
3932
4021
  }
3933
4022
  const transactionId2 = transactionRequest.getTransactionId(this.getChainId());
3934
- const response = new TransactionResponse(transactionId2, this);
4023
+ const response = new TransactionResponse(transactionId2, this, abis);
3935
4024
  await response.fetch();
3936
4025
  return response;
3937
4026
  }
3938
4027
  const {
3939
4028
  submit: { id: transactionId }
3940
4029
  } = await this.operations.submit({ encodedTransaction });
3941
- return new TransactionResponse(transactionId, this);
4030
+ return new TransactionResponse(transactionId, this, abis);
3942
4031
  }
3943
4032
  /**
3944
4033
  * Executes a transaction without actually submitting it to the chain.
@@ -3955,7 +4044,7 @@ var _Provider = class {
3955
4044
  if (estimateTxDependencies) {
3956
4045
  return this.estimateTxDependencies(transactionRequest);
3957
4046
  }
3958
- const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
4047
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
3959
4048
  const { dryRun: gqlReceipts } = await this.operations.dryRun({
3960
4049
  encodedTransaction,
3961
4050
  utxoValidation: utxoValidation || false
@@ -3974,13 +4063,13 @@ var _Provider = class {
3974
4063
  async estimatePredicates(transactionRequest) {
3975
4064
  const shouldEstimatePredicates = Boolean(
3976
4065
  transactionRequest.inputs.find(
3977
- (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()
4066
+ (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()
3978
4067
  )
3979
4068
  );
3980
4069
  if (!shouldEstimatePredicates) {
3981
4070
  return transactionRequest;
3982
4071
  }
3983
- const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
4072
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
3984
4073
  const response = await this.operations.estimatePredicates({
3985
4074
  encodedTransaction
3986
4075
  });
@@ -3989,7 +4078,7 @@ var _Provider = class {
3989
4078
  } = response;
3990
4079
  if (inputs) {
3991
4080
  inputs.forEach((input, index) => {
3992
- if ("predicateGasUsed" in input && (0, import_math14.bn)(input.predicateGasUsed).gt(0)) {
4081
+ if ("predicateGasUsed" in input && (0, import_math15.bn)(input.predicateGasUsed).gt(0)) {
3993
4082
  transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
3994
4083
  }
3995
4084
  });
@@ -4010,7 +4099,7 @@ var _Provider = class {
4010
4099
  * @returns A promise.
4011
4100
  */
4012
4101
  async estimateTxDependencies(transactionRequest) {
4013
- if (transactionRequest.type === import_transactions17.TransactionType.Create) {
4102
+ if (transactionRequest.type === import_transactions18.TransactionType.Create) {
4014
4103
  return {
4015
4104
  receipts: [],
4016
4105
  outputVariables: 0,
@@ -4023,7 +4112,7 @@ var _Provider = class {
4023
4112
  let outputVariables = 0;
4024
4113
  for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
4025
4114
  const { dryRun: gqlReceipts } = await this.operations.dryRun({
4026
- encodedTransaction: (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes()),
4115
+ encodedTransaction: (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes()),
4027
4116
  utxoValidation: false
4028
4117
  });
4029
4118
  receipts = gqlReceipts.map(processGqlReceipt);
@@ -4046,6 +4135,36 @@ var _Provider = class {
4046
4135
  missingContractIds
4047
4136
  };
4048
4137
  }
4138
+ /**
4139
+ * Estimates the transaction gas and fee based on the provided transaction request.
4140
+ * @param transactionRequest - The transaction request object.
4141
+ * @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
4142
+ */
4143
+ estimateTxGasAndFee(params) {
4144
+ const { transactionRequest } = params;
4145
+ const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
4146
+ const chainInfo = this.getChain();
4147
+ const gasPrice = transactionRequest.gasPrice.eq(0) ? minGasPrice : transactionRequest.gasPrice;
4148
+ transactionRequest.gasPrice = gasPrice;
4149
+ const minGas = transactionRequest.calculateMinGas(chainInfo);
4150
+ const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4151
+ if (transactionRequest.type === import_transactions18.TransactionType.Script) {
4152
+ if (transactionRequest.gasLimit.eq(0)) {
4153
+ transactionRequest.gasLimit = minGas;
4154
+ transactionRequest.gasLimit = maxGasPerTx.sub(
4155
+ transactionRequest.calculateMaxGas(chainInfo, minGas)
4156
+ );
4157
+ }
4158
+ }
4159
+ const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
4160
+ const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4161
+ return {
4162
+ minGas,
4163
+ minFee,
4164
+ maxGas,
4165
+ maxFee
4166
+ };
4167
+ }
4049
4168
  /**
4050
4169
  * Executes a signed transaction without applying the states changes
4051
4170
  * on the chain.
@@ -4061,7 +4180,7 @@ var _Provider = class {
4061
4180
  if (estimateTxDependencies) {
4062
4181
  return this.estimateTxDependencies(transactionRequest);
4063
4182
  }
4064
- const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
4183
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
4065
4184
  const { dryRun: gqlReceipts } = await this.operations.dryRun({
4066
4185
  encodedTransaction,
4067
4186
  utxoValidation: true
@@ -4093,17 +4212,16 @@ var _Provider = class {
4093
4212
  signatureCallback
4094
4213
  } = {}) {
4095
4214
  const txRequestClone = (0, import_ramda3.clone)(transactionRequestify(transactionRequestLike));
4096
- const chainInfo = this.getChain();
4097
- const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
4098
- const gasPrice = (0, import_math14.max)(txRequestClone.gasPrice, minGasPrice);
4099
- const isScriptTransaction = txRequestClone.type === import_transactions17.TransactionType.Script;
4215
+ const { minGasPrice } = this.getGasConfig();
4216
+ const setGasPrice = (0, import_math15.max)(txRequestClone.gasPrice, minGasPrice);
4217
+ const isScriptTransaction = txRequestClone.type === import_transactions18.TransactionType.Script;
4100
4218
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
4101
4219
  const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
4102
4220
  txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
4221
+ if (isScriptTransaction) {
4222
+ txRequestClone.gasLimit = (0, import_math15.bn)(0);
4223
+ }
4103
4224
  if (estimatePredicates) {
4104
- if (isScriptTransaction) {
4105
- txRequestClone.gasLimit = (0, import_math14.bn)(0);
4106
- }
4107
4225
  if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
4108
4226
  resourcesOwner.populateTransactionPredicateData(txRequestClone);
4109
4227
  }
@@ -4112,36 +4230,34 @@ var _Provider = class {
4112
4230
  if (signatureCallback && isScriptTransaction) {
4113
4231
  await signatureCallback(txRequestClone);
4114
4232
  }
4115
- const minGas = txRequestClone.calculateMinGas(chainInfo);
4116
- const maxGas = txRequestClone.calculateMaxGas(chainInfo, minGas);
4233
+ let { maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
4234
+ transactionRequest: txRequestClone
4235
+ });
4117
4236
  let receipts = [];
4118
4237
  let missingContractIds = [];
4119
4238
  let outputVariables = 0;
4239
+ let gasUsed = (0, import_math15.bn)(0);
4120
4240
  if (isScriptTransaction && estimateTxDependencies) {
4121
- txRequestClone.gasPrice = (0, import_math14.bn)(0);
4122
- txRequestClone.gasLimit = (0, import_math14.bn)(maxGasPerTx.sub(maxGas).toNumber() * 0.9);
4241
+ txRequestClone.gasPrice = (0, import_math15.bn)(0);
4123
4242
  const result = await this.estimateTxDependencies(txRequestClone);
4124
4243
  receipts = result.receipts;
4125
4244
  outputVariables = result.outputVariables;
4126
4245
  missingContractIds = result.missingContractIds;
4246
+ gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
4247
+ txRequestClone.gasLimit = gasUsed;
4248
+ txRequestClone.gasPrice = setGasPrice;
4249
+ ({ maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
4250
+ transactionRequest: txRequestClone
4251
+ }));
4127
4252
  }
4128
- const gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : minGas;
4129
- const usedFee = calculatePriceWithFactor(
4130
- gasUsed,
4131
- gasPrice,
4132
- gasPriceFactor
4133
- ).normalizeZeroToOne();
4134
- const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4135
- const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4136
4253
  return {
4137
4254
  requiredQuantities: allQuantities,
4138
4255
  receipts,
4139
4256
  gasUsed,
4140
4257
  minGasPrice,
4141
- gasPrice,
4258
+ gasPrice: setGasPrice,
4142
4259
  minGas,
4143
4260
  maxGas,
4144
- usedFee,
4145
4261
  minFee,
4146
4262
  maxFee,
4147
4263
  estimatedInputs: txRequestClone.inputs,
@@ -4175,17 +4291,17 @@ var _Provider = class {
4175
4291
  const result = await this.operations.getCoins({
4176
4292
  first: 10,
4177
4293
  ...paginationArgs,
4178
- filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils22.hexlify)(assetId) }
4294
+ filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils23.hexlify)(assetId) }
4179
4295
  });
4180
4296
  const coins = result.coins.edges.map((edge) => edge.node);
4181
4297
  return coins.map((coin) => ({
4182
4298
  id: coin.utxoId,
4183
4299
  assetId: coin.assetId,
4184
- amount: (0, import_math14.bn)(coin.amount),
4300
+ amount: (0, import_math15.bn)(coin.amount),
4185
4301
  owner: import_address3.Address.fromAddressOrString(coin.owner),
4186
- maturity: (0, import_math14.bn)(coin.maturity).toNumber(),
4187
- blockCreated: (0, import_math14.bn)(coin.blockCreated),
4188
- txCreatedIdx: (0, import_math14.bn)(coin.txCreatedIdx)
4302
+ maturity: (0, import_math15.bn)(coin.maturity).toNumber(),
4303
+ blockCreated: (0, import_math15.bn)(coin.blockCreated),
4304
+ txCreatedIdx: (0, import_math15.bn)(coin.txCreatedIdx)
4189
4305
  }));
4190
4306
  }
4191
4307
  /**
@@ -4199,19 +4315,19 @@ var _Provider = class {
4199
4315
  async getResourcesToSpend(owner, quantities, excludedIds) {
4200
4316
  const ownerAddress = import_address3.Address.fromAddressOrString(owner);
4201
4317
  const excludeInput = {
4202
- messages: excludedIds?.messages?.map((nonce) => (0, import_utils22.hexlify)(nonce)) || [],
4203
- utxos: excludedIds?.utxos?.map((id) => (0, import_utils22.hexlify)(id)) || []
4318
+ messages: excludedIds?.messages?.map((nonce) => (0, import_utils23.hexlify)(nonce)) || [],
4319
+ utxos: excludedIds?.utxos?.map((id) => (0, import_utils23.hexlify)(id)) || []
4204
4320
  };
4205
4321
  if (this.cache) {
4206
4322
  const uniqueUtxos = new Set(
4207
- excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0, import_utils22.hexlify)(id)))
4323
+ excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0, import_utils23.hexlify)(id)))
4208
4324
  );
4209
4325
  excludeInput.utxos = Array.from(uniqueUtxos);
4210
4326
  }
4211
4327
  const coinsQuery = {
4212
4328
  owner: ownerAddress.toB256(),
4213
4329
  queryPerAsset: quantities.map(coinQuantityfy).map(({ assetId, amount, max: maxPerAsset }) => ({
4214
- assetId: (0, import_utils22.hexlify)(assetId),
4330
+ assetId: (0, import_utils23.hexlify)(assetId),
4215
4331
  amount: amount.toString(10),
4216
4332
  max: maxPerAsset ? maxPerAsset.toString(10) : void 0
4217
4333
  })),
@@ -4222,9 +4338,9 @@ var _Provider = class {
4222
4338
  switch (coin.__typename) {
4223
4339
  case "MessageCoin":
4224
4340
  return {
4225
- amount: (0, import_math14.bn)(coin.amount),
4341
+ amount: (0, import_math15.bn)(coin.amount),
4226
4342
  assetId: coin.assetId,
4227
- daHeight: (0, import_math14.bn)(coin.daHeight),
4343
+ daHeight: (0, import_math15.bn)(coin.daHeight),
4228
4344
  sender: import_address3.Address.fromAddressOrString(coin.sender),
4229
4345
  recipient: import_address3.Address.fromAddressOrString(coin.recipient),
4230
4346
  nonce: coin.nonce
@@ -4232,12 +4348,12 @@ var _Provider = class {
4232
4348
  case "Coin":
4233
4349
  return {
4234
4350
  id: coin.utxoId,
4235
- amount: (0, import_math14.bn)(coin.amount),
4351
+ amount: (0, import_math15.bn)(coin.amount),
4236
4352
  assetId: coin.assetId,
4237
4353
  owner: import_address3.Address.fromAddressOrString(coin.owner),
4238
- maturity: (0, import_math14.bn)(coin.maturity).toNumber(),
4239
- blockCreated: (0, import_math14.bn)(coin.blockCreated),
4240
- txCreatedIdx: (0, import_math14.bn)(coin.txCreatedIdx)
4354
+ maturity: (0, import_math15.bn)(coin.maturity).toNumber(),
4355
+ blockCreated: (0, import_math15.bn)(coin.blockCreated),
4356
+ txCreatedIdx: (0, import_math15.bn)(coin.txCreatedIdx)
4241
4357
  };
4242
4358
  default:
4243
4359
  return null;
@@ -4254,13 +4370,13 @@ var _Provider = class {
4254
4370
  async getBlock(idOrHeight) {
4255
4371
  let variables;
4256
4372
  if (typeof idOrHeight === "number") {
4257
- variables = { height: (0, import_math14.bn)(idOrHeight).toString(10) };
4373
+ variables = { height: (0, import_math15.bn)(idOrHeight).toString(10) };
4258
4374
  } else if (idOrHeight === "latest") {
4259
4375
  variables = { height: (await this.getBlockNumber()).toString(10) };
4260
4376
  } else if (idOrHeight.length === 66) {
4261
4377
  variables = { blockId: idOrHeight };
4262
4378
  } else {
4263
- variables = { blockId: (0, import_math14.bn)(idOrHeight).toString(10) };
4379
+ variables = { blockId: (0, import_math15.bn)(idOrHeight).toString(10) };
4264
4380
  }
4265
4381
  const { block } = await this.operations.getBlock(variables);
4266
4382
  if (!block) {
@@ -4268,7 +4384,7 @@ var _Provider = class {
4268
4384
  }
4269
4385
  return {
4270
4386
  id: block.id,
4271
- height: (0, import_math14.bn)(block.header.height),
4387
+ height: (0, import_math15.bn)(block.header.height),
4272
4388
  time: block.header.time,
4273
4389
  transactionIds: block.transactions.map((tx) => tx.id)
4274
4390
  };
@@ -4283,7 +4399,7 @@ var _Provider = class {
4283
4399
  const { blocks: fetchedData } = await this.operations.getBlocks(params);
4284
4400
  const blocks = fetchedData.edges.map(({ node: block }) => ({
4285
4401
  id: block.id,
4286
- height: (0, import_math14.bn)(block.header.height),
4402
+ height: (0, import_math15.bn)(block.header.height),
4287
4403
  time: block.header.time,
4288
4404
  transactionIds: block.transactions.map((tx) => tx.id)
4289
4405
  }));
@@ -4298,7 +4414,7 @@ var _Provider = class {
4298
4414
  async getBlockWithTransactions(idOrHeight) {
4299
4415
  let variables;
4300
4416
  if (typeof idOrHeight === "number") {
4301
- variables = { blockHeight: (0, import_math14.bn)(idOrHeight).toString(10) };
4417
+ variables = { blockHeight: (0, import_math15.bn)(idOrHeight).toString(10) };
4302
4418
  } else if (idOrHeight === "latest") {
4303
4419
  variables = { blockHeight: (await this.getBlockNumber()).toString() };
4304
4420
  } else {
@@ -4310,11 +4426,11 @@ var _Provider = class {
4310
4426
  }
4311
4427
  return {
4312
4428
  id: block.id,
4313
- height: (0, import_math14.bn)(block.header.height, 10),
4429
+ height: (0, import_math15.bn)(block.header.height, 10),
4314
4430
  time: block.header.time,
4315
4431
  transactionIds: block.transactions.map((tx) => tx.id),
4316
4432
  transactions: block.transactions.map(
4317
- (tx) => new import_transactions17.TransactionCoder().decode((0, import_utils22.arrayify)(tx.rawPayload), 0)?.[0]
4433
+ (tx) => new import_transactions18.TransactionCoder().decode((0, import_utils23.arrayify)(tx.rawPayload), 0)?.[0]
4318
4434
  )
4319
4435
  };
4320
4436
  }
@@ -4329,8 +4445,8 @@ var _Provider = class {
4329
4445
  if (!transaction) {
4330
4446
  return null;
4331
4447
  }
4332
- return new import_transactions17.TransactionCoder().decode(
4333
- (0, import_utils22.arrayify)(transaction.rawPayload),
4448
+ return new import_transactions18.TransactionCoder().decode(
4449
+ (0, import_utils23.arrayify)(transaction.rawPayload),
4334
4450
  0
4335
4451
  )?.[0];
4336
4452
  }
@@ -4357,9 +4473,9 @@ var _Provider = class {
4357
4473
  async getContractBalance(contractId, assetId) {
4358
4474
  const { contractBalance } = await this.operations.getContractBalance({
4359
4475
  contract: import_address3.Address.fromAddressOrString(contractId).toB256(),
4360
- asset: (0, import_utils22.hexlify)(assetId)
4476
+ asset: (0, import_utils23.hexlify)(assetId)
4361
4477
  });
4362
- return (0, import_math14.bn)(contractBalance.amount, 10);
4478
+ return (0, import_math15.bn)(contractBalance.amount, 10);
4363
4479
  }
4364
4480
  /**
4365
4481
  * Returns the balance for the given owner for the given asset ID.
@@ -4371,9 +4487,9 @@ var _Provider = class {
4371
4487
  async getBalance(owner, assetId) {
4372
4488
  const { balance } = await this.operations.getBalance({
4373
4489
  owner: import_address3.Address.fromAddressOrString(owner).toB256(),
4374
- assetId: (0, import_utils22.hexlify)(assetId)
4490
+ assetId: (0, import_utils23.hexlify)(assetId)
4375
4491
  });
4376
- return (0, import_math14.bn)(balance.amount, 10);
4492
+ return (0, import_math15.bn)(balance.amount, 10);
4377
4493
  }
4378
4494
  /**
4379
4495
  * Returns balances for the given owner.
@@ -4391,7 +4507,7 @@ var _Provider = class {
4391
4507
  const balances = result.balances.edges.map((edge) => edge.node);
4392
4508
  return balances.map((balance) => ({
4393
4509
  assetId: balance.assetId,
4394
- amount: (0, import_math14.bn)(balance.amount)
4510
+ amount: (0, import_math15.bn)(balance.amount)
4395
4511
  }));
4396
4512
  }
4397
4513
  /**
@@ -4409,19 +4525,19 @@ var _Provider = class {
4409
4525
  });
4410
4526
  const messages = result.messages.edges.map((edge) => edge.node);
4411
4527
  return messages.map((message) => ({
4412
- messageId: import_transactions17.InputMessageCoder.getMessageId({
4528
+ messageId: import_transactions18.InputMessageCoder.getMessageId({
4413
4529
  sender: message.sender,
4414
4530
  recipient: message.recipient,
4415
4531
  nonce: message.nonce,
4416
- amount: (0, import_math14.bn)(message.amount),
4532
+ amount: (0, import_math15.bn)(message.amount),
4417
4533
  data: message.data
4418
4534
  }),
4419
4535
  sender: import_address3.Address.fromAddressOrString(message.sender),
4420
4536
  recipient: import_address3.Address.fromAddressOrString(message.recipient),
4421
4537
  nonce: message.nonce,
4422
- amount: (0, import_math14.bn)(message.amount),
4423
- data: import_transactions17.InputMessageCoder.decodeData(message.data),
4424
- daHeight: (0, import_math14.bn)(message.daHeight)
4538
+ amount: (0, import_math15.bn)(message.amount),
4539
+ data: import_transactions18.InputMessageCoder.decodeData(message.data),
4540
+ daHeight: (0, import_math15.bn)(message.daHeight)
4425
4541
  }));
4426
4542
  }
4427
4543
  /**
@@ -4439,8 +4555,8 @@ var _Provider = class {
4439
4555
  nonce
4440
4556
  };
4441
4557
  if (commitBlockId && commitBlockHeight) {
4442
- throw new import_errors13.FuelError(
4443
- import_errors13.ErrorCode.INVALID_INPUT_PARAMETERS,
4558
+ throw new import_errors14.FuelError(
4559
+ import_errors14.ErrorCode.INVALID_INPUT_PARAMETERS,
4444
4560
  "commitBlockId and commitBlockHeight cannot be used together"
4445
4561
  );
4446
4562
  }
@@ -4474,41 +4590,41 @@ var _Provider = class {
4474
4590
  } = result.messageProof;
4475
4591
  return {
4476
4592
  messageProof: {
4477
- proofIndex: (0, import_math14.bn)(messageProof.proofIndex),
4593
+ proofIndex: (0, import_math15.bn)(messageProof.proofIndex),
4478
4594
  proofSet: messageProof.proofSet
4479
4595
  },
4480
4596
  blockProof: {
4481
- proofIndex: (0, import_math14.bn)(blockProof.proofIndex),
4597
+ proofIndex: (0, import_math15.bn)(blockProof.proofIndex),
4482
4598
  proofSet: blockProof.proofSet
4483
4599
  },
4484
4600
  messageBlockHeader: {
4485
4601
  id: messageBlockHeader.id,
4486
- daHeight: (0, import_math14.bn)(messageBlockHeader.daHeight),
4487
- transactionsCount: (0, import_math14.bn)(messageBlockHeader.transactionsCount),
4602
+ daHeight: (0, import_math15.bn)(messageBlockHeader.daHeight),
4603
+ transactionsCount: (0, import_math15.bn)(messageBlockHeader.transactionsCount),
4488
4604
  transactionsRoot: messageBlockHeader.transactionsRoot,
4489
- height: (0, import_math14.bn)(messageBlockHeader.height),
4605
+ height: (0, import_math15.bn)(messageBlockHeader.height),
4490
4606
  prevRoot: messageBlockHeader.prevRoot,
4491
4607
  time: messageBlockHeader.time,
4492
4608
  applicationHash: messageBlockHeader.applicationHash,
4493
4609
  messageReceiptRoot: messageBlockHeader.messageReceiptRoot,
4494
- messageReceiptCount: (0, import_math14.bn)(messageBlockHeader.messageReceiptCount)
4610
+ messageReceiptCount: (0, import_math15.bn)(messageBlockHeader.messageReceiptCount)
4495
4611
  },
4496
4612
  commitBlockHeader: {
4497
4613
  id: commitBlockHeader.id,
4498
- daHeight: (0, import_math14.bn)(commitBlockHeader.daHeight),
4499
- transactionsCount: (0, import_math14.bn)(commitBlockHeader.transactionsCount),
4614
+ daHeight: (0, import_math15.bn)(commitBlockHeader.daHeight),
4615
+ transactionsCount: (0, import_math15.bn)(commitBlockHeader.transactionsCount),
4500
4616
  transactionsRoot: commitBlockHeader.transactionsRoot,
4501
- height: (0, import_math14.bn)(commitBlockHeader.height),
4617
+ height: (0, import_math15.bn)(commitBlockHeader.height),
4502
4618
  prevRoot: commitBlockHeader.prevRoot,
4503
4619
  time: commitBlockHeader.time,
4504
4620
  applicationHash: commitBlockHeader.applicationHash,
4505
4621
  messageReceiptRoot: commitBlockHeader.messageReceiptRoot,
4506
- messageReceiptCount: (0, import_math14.bn)(commitBlockHeader.messageReceiptCount)
4622
+ messageReceiptCount: (0, import_math15.bn)(commitBlockHeader.messageReceiptCount)
4507
4623
  },
4508
4624
  sender: import_address3.Address.fromAddressOrString(sender),
4509
4625
  recipient: import_address3.Address.fromAddressOrString(recipient),
4510
4626
  nonce,
4511
- amount: (0, import_math14.bn)(amount),
4627
+ amount: (0, import_math15.bn)(amount),
4512
4628
  data
4513
4629
  };
4514
4630
  }
@@ -4531,10 +4647,10 @@ var _Provider = class {
4531
4647
  */
4532
4648
  async produceBlocks(amount, startTime) {
4533
4649
  const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
4534
- blocksToProduce: (0, import_math14.bn)(amount).toString(10),
4535
- startTimestamp: startTime ? import_utils22.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
4650
+ blocksToProduce: (0, import_math15.bn)(amount).toString(10),
4651
+ startTimestamp: startTime ? import_utils23.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
4536
4652
  });
4537
- return (0, import_math14.bn)(latestBlockHeight);
4653
+ return (0, import_math15.bn)(latestBlockHeight);
4538
4654
  }
4539
4655
  // eslint-disable-next-line @typescript-eslint/require-await
4540
4656
  async getTransactionResponse(transactionId) {
@@ -4548,7 +4664,7 @@ cacheInputs_fn = function(inputs) {
4548
4664
  return;
4549
4665
  }
4550
4666
  inputs.forEach((input) => {
4551
- if (input.type === import_transactions17.InputType.Coin) {
4667
+ if (input.type === import_transactions18.InputType.Coin) {
4552
4668
  this.cache?.set(input.id);
4553
4669
  }
4554
4670
  });
@@ -4557,23 +4673,23 @@ __publicField(Provider, "chainInfoCache", {});
4557
4673
  __publicField(Provider, "nodeInfoCache", {});
4558
4674
 
4559
4675
  // src/providers/transaction-summary/get-transaction-summary.ts
4560
- var import_errors14 = require("@fuel-ts/errors");
4561
- var import_math15 = require("@fuel-ts/math");
4562
- var import_transactions18 = require("@fuel-ts/transactions");
4563
- var import_utils25 = require("@fuel-ts/utils");
4676
+ var import_errors15 = require("@fuel-ts/errors");
4677
+ var import_math16 = require("@fuel-ts/math");
4678
+ var import_transactions19 = require("@fuel-ts/transactions");
4679
+ var import_utils26 = require("@fuel-ts/utils");
4564
4680
  async function getTransactionSummary(params) {
4565
4681
  const { id, provider, abiMap } = params;
4566
4682
  const { transaction: gqlTransaction } = await provider.operations.getTransactionWithReceipts({
4567
4683
  transactionId: id
4568
4684
  });
4569
4685
  if (!gqlTransaction) {
4570
- throw new import_errors14.FuelError(
4571
- import_errors14.ErrorCode.TRANSACTION_NOT_FOUND,
4686
+ throw new import_errors15.FuelError(
4687
+ import_errors15.ErrorCode.TRANSACTION_NOT_FOUND,
4572
4688
  `Transaction not found for given id: ${id}.`
4573
4689
  );
4574
4690
  }
4575
- const [decodedTransaction] = new import_transactions18.TransactionCoder().decode(
4576
- (0, import_utils25.arrayify)(gqlTransaction.rawPayload),
4691
+ const [decodedTransaction] = new import_transactions19.TransactionCoder().decode(
4692
+ (0, import_utils26.arrayify)(gqlTransaction.rawPayload),
4577
4693
  0
4578
4694
  );
4579
4695
  const receipts = gqlTransaction.receipts?.map(processGqlReceipt) || [];
@@ -4584,10 +4700,10 @@ async function getTransactionSummary(params) {
4584
4700
  id: gqlTransaction.id,
4585
4701
  receipts,
4586
4702
  transaction: decodedTransaction,
4587
- transactionBytes: (0, import_utils25.arrayify)(gqlTransaction.rawPayload),
4703
+ transactionBytes: (0, import_utils26.arrayify)(gqlTransaction.rawPayload),
4588
4704
  gqlTransactionStatus: gqlTransaction.status,
4589
- gasPerByte: (0, import_math15.bn)(gasPerByte),
4590
- gasPriceFactor: (0, import_math15.bn)(gasPriceFactor),
4705
+ gasPerByte: (0, import_math16.bn)(gasPerByte),
4706
+ gasPriceFactor: (0, import_math16.bn)(gasPriceFactor),
4591
4707
  abiMap,
4592
4708
  maxInputs,
4593
4709
  gasCosts
@@ -4626,13 +4742,13 @@ async function getTransactionsSummaries(params) {
4626
4742
  const transactions = edges.map((edge) => {
4627
4743
  const { node: gqlTransaction } = edge;
4628
4744
  const { id, rawPayload, receipts: gqlReceipts, status } = gqlTransaction;
4629
- const [decodedTransaction] = new import_transactions18.TransactionCoder().decode((0, import_utils25.arrayify)(rawPayload), 0);
4745
+ const [decodedTransaction] = new import_transactions19.TransactionCoder().decode((0, import_utils26.arrayify)(rawPayload), 0);
4630
4746
  const receipts = gqlReceipts?.map(processGqlReceipt) || [];
4631
4747
  const transactionSummary = assembleTransactionSummary({
4632
4748
  id,
4633
4749
  receipts,
4634
4750
  transaction: decodedTransaction,
4635
- transactionBytes: (0, import_utils25.arrayify)(rawPayload),
4751
+ transactionBytes: (0, import_utils26.arrayify)(rawPayload),
4636
4752
  gqlTransactionStatus: status,
4637
4753
  abiMap,
4638
4754
  gasPerByte,
@@ -4774,18 +4890,18 @@ var assets = [
4774
4890
  ];
4775
4891
 
4776
4892
  // src/utils/formatTransferToContractScriptData.ts
4777
- var import_abi_coder4 = require("@fuel-ts/abi-coder");
4778
- var import_math16 = require("@fuel-ts/math");
4779
- var import_utils26 = require("@fuel-ts/utils");
4893
+ var import_abi_coder6 = require("@fuel-ts/abi-coder");
4894
+ var import_math17 = require("@fuel-ts/math");
4895
+ var import_utils27 = require("@fuel-ts/utils");
4780
4896
  var asm = __toESM(require("@fuels/vm-asm"));
4781
4897
  var formatTransferToContractScriptData = (params) => {
4782
4898
  const { assetId, amountToTransfer, hexlifiedContractId } = params;
4783
- const numberCoder = new import_abi_coder4.BigNumberCoder("u64");
4784
- const encoded = numberCoder.encode(new import_math16.BN(amountToTransfer).toNumber());
4899
+ const numberCoder = new import_abi_coder6.BigNumberCoder("u64");
4900
+ const encoded = numberCoder.encode(new import_math17.BN(amountToTransfer).toNumber());
4785
4901
  const scriptData = Uint8Array.from([
4786
- ...(0, import_utils26.arrayify)(hexlifiedContractId),
4902
+ ...(0, import_utils27.arrayify)(hexlifiedContractId),
4787
4903
  ...encoded,
4788
- ...(0, import_utils26.arrayify)(assetId)
4904
+ ...(0, import_utils27.arrayify)(assetId)
4789
4905
  ]);
4790
4906
  return scriptData;
4791
4907
  };
@@ -4841,7 +4957,7 @@ var Account = class extends import_interfaces.AbstractAccount {
4841
4957
  */
4842
4958
  get provider() {
4843
4959
  if (!this._provider) {
4844
- throw new import_errors15.FuelError(import_errors15.ErrorCode.MISSING_PROVIDER, "Provider not set");
4960
+ throw new import_errors16.FuelError(import_errors16.ErrorCode.MISSING_PROVIDER, "Provider not set");
4845
4961
  }
4846
4962
  return this._provider;
4847
4963
  }
@@ -4893,8 +5009,8 @@ var Account = class extends import_interfaces.AbstractAccount {
4893
5009
  if (!hasNextPage) {
4894
5010
  break;
4895
5011
  }
4896
- throw new import_errors15.FuelError(
4897
- import_errors15.ErrorCode.NOT_SUPPORTED,
5012
+ throw new import_errors16.FuelError(
5013
+ import_errors16.ErrorCode.NOT_SUPPORTED,
4898
5014
  `Wallets containing more than ${pageSize} coins exceed the current supported limit.`
4899
5015
  );
4900
5016
  }
@@ -4919,8 +5035,8 @@ var Account = class extends import_interfaces.AbstractAccount {
4919
5035
  if (!hasNextPage) {
4920
5036
  break;
4921
5037
  }
4922
- throw new import_errors15.FuelError(
4923
- import_errors15.ErrorCode.NOT_SUPPORTED,
5038
+ throw new import_errors16.FuelError(
5039
+ import_errors16.ErrorCode.NOT_SUPPORTED,
4924
5040
  `Wallets containing more than ${pageSize} messages exceed the current supported limit.`
4925
5041
  );
4926
5042
  }
@@ -4932,7 +5048,7 @@ var Account = class extends import_interfaces.AbstractAccount {
4932
5048
  * @param assetId - The asset ID to check the balance for.
4933
5049
  * @returns A promise that resolves to the balance amount.
4934
5050
  */
4935
- async getBalance(assetId = import_configs11.BaseAssetId) {
5051
+ async getBalance(assetId = import_configs12.BaseAssetId) {
4936
5052
  const amount = await this.provider.getBalance(this.address, assetId);
4937
5053
  return amount;
4938
5054
  }
@@ -4955,8 +5071,8 @@ var Account = class extends import_interfaces.AbstractAccount {
4955
5071
  if (!hasNextPage) {
4956
5072
  break;
4957
5073
  }
4958
- throw new import_errors15.FuelError(
4959
- import_errors15.ErrorCode.NOT_SUPPORTED,
5074
+ throw new import_errors16.FuelError(
5075
+ import_errors16.ErrorCode.NOT_SUPPORTED,
4960
5076
  `Wallets containing more than ${pageSize} balances exceed the current supported limit.`
4961
5077
  );
4962
5078
  }
@@ -4972,15 +5088,15 @@ var Account = class extends import_interfaces.AbstractAccount {
4972
5088
  */
4973
5089
  async fund(request, coinQuantities, fee) {
4974
5090
  const updatedQuantities = addAmountToAsset({
4975
- amount: (0, import_math17.bn)(fee),
4976
- assetId: import_configs11.BaseAssetId,
5091
+ amount: (0, import_math18.bn)(fee),
5092
+ assetId: import_configs12.BaseAssetId,
4977
5093
  coinQuantities
4978
5094
  });
4979
5095
  const quantitiesDict = {};
4980
5096
  updatedQuantities.forEach(({ amount, assetId }) => {
4981
5097
  quantitiesDict[assetId] = {
4982
5098
  required: amount,
4983
- owned: (0, import_math17.bn)(0)
5099
+ owned: (0, import_math18.bn)(0)
4984
5100
  };
4985
5101
  });
4986
5102
  const cachedUtxos = [];
@@ -4993,12 +5109,12 @@ var Account = class extends import_interfaces.AbstractAccount {
4993
5109
  if (isCoin2) {
4994
5110
  const assetId = String(input.assetId);
4995
5111
  if (input.owner === owner && quantitiesDict[assetId]) {
4996
- const amount = (0, import_math17.bn)(input.amount);
5112
+ const amount = (0, import_math18.bn)(input.amount);
4997
5113
  quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
4998
5114
  cachedUtxos.push(input.id);
4999
5115
  }
5000
- } else if (input.recipient === owner && input.amount && quantitiesDict[import_configs11.BaseAssetId]) {
5001
- quantitiesDict[import_configs11.BaseAssetId].owned = quantitiesDict[import_configs11.BaseAssetId].owned.add(input.amount);
5116
+ } else if (input.recipient === owner && input.amount && quantitiesDict[import_configs12.BaseAssetId]) {
5117
+ quantitiesDict[import_configs12.BaseAssetId].owned = quantitiesDict[import_configs12.BaseAssetId].owned.add(input.amount);
5002
5118
  cachedMessages.push(input.nonce);
5003
5119
  }
5004
5120
  }
@@ -5030,7 +5146,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5030
5146
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
5031
5147
  * @returns A promise that resolves to the prepared transaction request.
5032
5148
  */
5033
- async createTransfer(destination, amount, assetId = import_configs11.BaseAssetId, txParams = {}) {
5149
+ async createTransfer(destination, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
5034
5150
  const { minGasPrice } = this.provider.getGasConfig();
5035
5151
  const params = { gasPrice: minGasPrice, ...txParams };
5036
5152
  const request = new ScriptTransactionRequest(params);
@@ -5039,8 +5155,8 @@ var Account = class extends import_interfaces.AbstractAccount {
5039
5155
  estimateTxDependencies: true,
5040
5156
  resourcesOwner: this
5041
5157
  });
5042
- request.gasPrice = (0, import_math17.bn)(txParams.gasPrice ?? minGasPrice);
5043
- request.gasLimit = (0, import_math17.bn)(txParams.gasLimit ?? gasUsed);
5158
+ request.gasPrice = (0, import_math18.bn)(txParams.gasPrice ?? minGasPrice);
5159
+ request.gasLimit = (0, import_math18.bn)(txParams.gasLimit ?? gasUsed);
5044
5160
  this.validateGas({
5045
5161
  gasUsed,
5046
5162
  gasPrice: request.gasPrice,
@@ -5060,10 +5176,10 @@ var Account = class extends import_interfaces.AbstractAccount {
5060
5176
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
5061
5177
  * @returns A promise that resolves to the transaction response.
5062
5178
  */
5063
- async transfer(destination, amount, assetId = import_configs11.BaseAssetId, txParams = {}) {
5064
- if ((0, import_math17.bn)(amount).lte(0)) {
5065
- throw new import_errors15.FuelError(
5066
- import_errors15.ErrorCode.INVALID_TRANSFER_AMOUNT,
5179
+ async transfer(destination, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
5180
+ if ((0, import_math18.bn)(amount).lte(0)) {
5181
+ throw new import_errors16.FuelError(
5182
+ import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
5067
5183
  "Transfer amount must be a positive number."
5068
5184
  );
5069
5185
  }
@@ -5079,10 +5195,10 @@ var Account = class extends import_interfaces.AbstractAccount {
5079
5195
  * @param txParams - The optional transaction parameters.
5080
5196
  * @returns A promise that resolves to the transaction response.
5081
5197
  */
5082
- async transferToContract(contractId, amount, assetId = import_configs11.BaseAssetId, txParams = {}) {
5083
- if ((0, import_math17.bn)(amount).lte(0)) {
5084
- throw new import_errors15.FuelError(
5085
- import_errors15.ErrorCode.INVALID_TRANSFER_AMOUNT,
5198
+ async transferToContract(contractId, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
5199
+ if ((0, import_math18.bn)(amount).lte(0)) {
5200
+ throw new import_errors16.FuelError(
5201
+ import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
5086
5202
  "Transfer amount must be a positive number."
5087
5203
  );
5088
5204
  }
@@ -5091,7 +5207,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5091
5207
  const params = { gasPrice: minGasPrice, ...txParams };
5092
5208
  const { script, scriptData } = await assembleTransferToContractScript({
5093
5209
  hexlifiedContractId: contractAddress.toB256(),
5094
- amountToTransfer: (0, import_math17.bn)(amount),
5210
+ amountToTransfer: (0, import_math18.bn)(amount),
5095
5211
  assetId
5096
5212
  });
5097
5213
  const request = new ScriptTransactionRequest({
@@ -5102,9 +5218,9 @@ var Account = class extends import_interfaces.AbstractAccount {
5102
5218
  request.addContractInputAndOutput(contractAddress);
5103
5219
  const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
5104
5220
  request,
5105
- [{ amount: (0, import_math17.bn)(amount), assetId: String(assetId) }]
5221
+ [{ amount: (0, import_math18.bn)(amount), assetId: String(assetId) }]
5106
5222
  );
5107
- request.gasLimit = (0, import_math17.bn)(params.gasLimit ?? gasUsed);
5223
+ request.gasLimit = (0, import_math18.bn)(params.gasLimit ?? gasUsed);
5108
5224
  this.validateGas({
5109
5225
  gasUsed,
5110
5226
  gasPrice: request.gasPrice,
@@ -5125,25 +5241,25 @@ var Account = class extends import_interfaces.AbstractAccount {
5125
5241
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
5126
5242
  const { minGasPrice } = this.provider.getGasConfig();
5127
5243
  const recipientAddress = import_address4.Address.fromAddressOrString(recipient);
5128
- const recipientDataArray = (0, import_utils27.arrayify)(
5244
+ const recipientDataArray = (0, import_utils28.arrayify)(
5129
5245
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
5130
5246
  );
5131
- const amountDataArray = (0, import_utils27.arrayify)(
5132
- "0x".concat((0, import_math17.bn)(amount).toHex().substring(2).padStart(16, "0"))
5247
+ const amountDataArray = (0, import_utils28.arrayify)(
5248
+ "0x".concat((0, import_math18.bn)(amount).toHex().substring(2).padStart(16, "0"))
5133
5249
  );
5134
5250
  const script = new Uint8Array([
5135
- ...(0, import_utils27.arrayify)(withdrawScript.bytes),
5251
+ ...(0, import_utils28.arrayify)(withdrawScript.bytes),
5136
5252
  ...recipientDataArray,
5137
5253
  ...amountDataArray
5138
5254
  ]);
5139
5255
  const params = { script, gasPrice: minGasPrice, ...txParams };
5140
5256
  const request = new ScriptTransactionRequest(params);
5141
- const forwardingQuantities = [{ amount: (0, import_math17.bn)(amount), assetId: import_configs11.BaseAssetId }];
5257
+ const forwardingQuantities = [{ amount: (0, import_math18.bn)(amount), assetId: import_configs12.BaseAssetId }];
5142
5258
  const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
5143
5259
  request,
5144
5260
  forwardingQuantities
5145
5261
  );
5146
- request.gasLimit = (0, import_math17.bn)(params.gasLimit ?? gasUsed);
5262
+ request.gasLimit = (0, import_math18.bn)(params.gasLimit ?? gasUsed);
5147
5263
  this.validateGas({
5148
5264
  gasUsed,
5149
5265
  gasPrice: request.gasPrice,
@@ -5155,7 +5271,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5155
5271
  }
5156
5272
  async signMessage(message) {
5157
5273
  if (!this._connector) {
5158
- throw new import_errors15.FuelError(import_errors15.ErrorCode.MISSING_CONNECTOR, "A connector is required to sign messages.");
5274
+ throw new import_errors16.FuelError(import_errors16.ErrorCode.MISSING_CONNECTOR, "A connector is required to sign messages.");
5159
5275
  }
5160
5276
  return this._connector.signMessage(this.address.toString(), message);
5161
5277
  }
@@ -5167,8 +5283,8 @@ var Account = class extends import_interfaces.AbstractAccount {
5167
5283
  */
5168
5284
  async signTransaction(transactionRequestLike) {
5169
5285
  if (!this._connector) {
5170
- throw new import_errors15.FuelError(
5171
- import_errors15.ErrorCode.MISSING_CONNECTOR,
5286
+ throw new import_errors16.FuelError(
5287
+ import_errors16.ErrorCode.MISSING_CONNECTOR,
5172
5288
  "A connector is required to sign transactions."
5173
5289
  );
5174
5290
  }
@@ -5215,14 +5331,14 @@ var Account = class extends import_interfaces.AbstractAccount {
5215
5331
  minGasPrice
5216
5332
  }) {
5217
5333
  if (minGasPrice.gt(gasPrice)) {
5218
- throw new import_errors15.FuelError(
5219
- import_errors15.ErrorCode.GAS_PRICE_TOO_LOW,
5334
+ throw new import_errors16.FuelError(
5335
+ import_errors16.ErrorCode.GAS_PRICE_TOO_LOW,
5220
5336
  `Gas price '${gasPrice}' is lower than the required: '${minGasPrice}'.`
5221
5337
  );
5222
5338
  }
5223
5339
  if (gasUsed.gt(gasLimit)) {
5224
- throw new import_errors15.FuelError(
5225
- import_errors15.ErrorCode.GAS_LIMIT_TOO_LOW,
5340
+ throw new import_errors16.FuelError(
5341
+ import_errors16.ErrorCode.GAS_LIMIT_TOO_LOW,
5226
5342
  `Gas limit '${gasLimit}' is lower than the required: '${gasUsed}'.`
5227
5343
  );
5228
5344
  }
@@ -5231,14 +5347,14 @@ var Account = class extends import_interfaces.AbstractAccount {
5231
5347
 
5232
5348
  // src/wallet/base-wallet-unlocked.ts
5233
5349
  var import_hasher3 = require("@fuel-ts/hasher");
5234
- var import_utils30 = require("@fuel-ts/utils");
5350
+ var import_utils31 = require("@fuel-ts/utils");
5235
5351
 
5236
5352
  // src/signer/signer.ts
5237
5353
  var import_address5 = require("@fuel-ts/address");
5238
- var import_crypto = require("@fuel-ts/crypto");
5354
+ var import_crypto2 = require("@fuel-ts/crypto");
5239
5355
  var import_hasher2 = require("@fuel-ts/hasher");
5240
- var import_math18 = require("@fuel-ts/math");
5241
- var import_utils28 = require("@fuel-ts/utils");
5356
+ var import_math19 = require("@fuel-ts/math");
5357
+ var import_utils29 = require("@fuel-ts/utils");
5242
5358
  var import_secp256k1 = require("@noble/curves/secp256k1");
5243
5359
  var Signer = class {
5244
5360
  address;
@@ -5257,10 +5373,10 @@ var Signer = class {
5257
5373
  privateKey = `0x${privateKey}`;
5258
5374
  }
5259
5375
  }
5260
- const privateKeyBytes = (0, import_math18.toBytes)(privateKey, 32);
5261
- this.privateKey = (0, import_utils28.hexlify)(privateKeyBytes);
5262
- this.publicKey = (0, import_utils28.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
5263
- this.compressedPublicKey = (0, import_utils28.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
5376
+ const privateKeyBytes = (0, import_math19.toBytes)(privateKey, 32);
5377
+ this.privateKey = (0, import_utils29.hexlify)(privateKeyBytes);
5378
+ this.publicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
5379
+ this.compressedPublicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
5264
5380
  this.address = import_address5.Address.fromPublicKey(this.publicKey);
5265
5381
  }
5266
5382
  /**
@@ -5274,11 +5390,11 @@ var Signer = class {
5274
5390
  * @returns hashed signature
5275
5391
  */
5276
5392
  sign(data) {
5277
- const signature = import_secp256k1.secp256k1.sign((0, import_utils28.arrayify)(data), (0, import_utils28.arrayify)(this.privateKey));
5278
- const r = (0, import_math18.toBytes)(`0x${signature.r.toString(16)}`, 32);
5279
- const s = (0, import_math18.toBytes)(`0x${signature.s.toString(16)}`, 32);
5393
+ const signature = import_secp256k1.secp256k1.sign((0, import_utils29.arrayify)(data), (0, import_utils29.arrayify)(this.privateKey));
5394
+ const r = (0, import_math19.toBytes)(`0x${signature.r.toString(16)}`, 32);
5395
+ const s = (0, import_math19.toBytes)(`0x${signature.s.toString(16)}`, 32);
5280
5396
  s[0] |= (signature.recovery || 0) << 7;
5281
- return (0, import_utils28.hexlify)((0, import_utils28.concat)([r, s]));
5397
+ return (0, import_utils29.hexlify)((0, import_utils29.concat)([r, s]));
5282
5398
  }
5283
5399
  /**
5284
5400
  * Add point on the current elliptic curve
@@ -5287,8 +5403,8 @@ var Signer = class {
5287
5403
  * @returns compressed point on the curve
5288
5404
  */
5289
5405
  addPoint(point) {
5290
- const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(this.compressedPublicKey));
5291
- const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(point));
5406
+ const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(this.compressedPublicKey));
5407
+ const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(point));
5292
5408
  const result = p0.add(p1);
5293
5409
  return `0x${result.toHex(true)}`;
5294
5410
  }
@@ -5300,16 +5416,16 @@ var Signer = class {
5300
5416
  * @returns public key from signature from the
5301
5417
  */
5302
5418
  static recoverPublicKey(data, signature) {
5303
- const signedMessageBytes = (0, import_utils28.arrayify)(signature);
5419
+ const signedMessageBytes = (0, import_utils29.arrayify)(signature);
5304
5420
  const r = signedMessageBytes.slice(0, 32);
5305
5421
  const s = signedMessageBytes.slice(32, 64);
5306
5422
  const recoveryParam = (s[0] & 128) >> 7;
5307
5423
  s[0] &= 127;
5308
- const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils28.hexlify)(r)), BigInt((0, import_utils28.hexlify)(s))).addRecoveryBit(
5424
+ const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils29.hexlify)(r)), BigInt((0, import_utils29.hexlify)(s))).addRecoveryBit(
5309
5425
  recoveryParam
5310
5426
  );
5311
- const publicKey = sig.recoverPublicKey((0, import_utils28.arrayify)(data)).toRawBytes(false).slice(1);
5312
- return (0, import_utils28.hexlify)(publicKey);
5427
+ const publicKey = sig.recoverPublicKey((0, import_utils29.arrayify)(data)).toRawBytes(false).slice(1);
5428
+ return (0, import_utils29.hexlify)(publicKey);
5313
5429
  }
5314
5430
  /**
5315
5431
  * Recover the address from a signature performed with [`sign`](#sign).
@@ -5328,7 +5444,7 @@ var Signer = class {
5328
5444
  * @returns random 32-byte hashed
5329
5445
  */
5330
5446
  static generatePrivateKey(entropy) {
5331
- 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);
5447
+ 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);
5332
5448
  }
5333
5449
  /**
5334
5450
  * Extended publicKey from a compact publicKey
@@ -5337,16 +5453,16 @@ var Signer = class {
5337
5453
  * @returns extended publicKey
5338
5454
  */
5339
5455
  static extendPublicKey(publicKey) {
5340
- const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(publicKey));
5341
- return (0, import_utils28.hexlify)(point.toRawBytes(false).slice(1));
5456
+ const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(publicKey));
5457
+ return (0, import_utils29.hexlify)(point.toRawBytes(false).slice(1));
5342
5458
  }
5343
5459
  };
5344
5460
 
5345
5461
  // src/wallet/keystore-wallet.ts
5346
5462
  var import_address6 = require("@fuel-ts/address");
5347
- var import_crypto2 = require("@fuel-ts/crypto");
5348
- var import_errors16 = require("@fuel-ts/errors");
5349
- var import_utils29 = require("@fuel-ts/utils");
5463
+ var import_crypto3 = require("@fuel-ts/crypto");
5464
+ var import_errors17 = require("@fuel-ts/errors");
5465
+ var import_utils30 = require("@fuel-ts/utils");
5350
5466
  var import_uuid = require("uuid");
5351
5467
  var DEFAULT_KDF_PARAMS_LOG_N = 13;
5352
5468
  var DEFAULT_KDF_PARAMS_R = 8;
@@ -5360,22 +5476,22 @@ var removeHexPrefix = (hexString) => {
5360
5476
  return hexString;
5361
5477
  };
5362
5478
  async function encryptKeystoreWallet(privateKey, address, password) {
5363
- const privateKeyBuffer = (0, import_crypto2.bufferFromString)(removeHexPrefix(privateKey), "hex");
5479
+ const privateKeyBuffer = (0, import_crypto3.bufferFromString)(removeHexPrefix(privateKey), "hex");
5364
5480
  const ownerAddress = import_address6.Address.fromAddressOrString(address);
5365
- const salt = (0, import_crypto2.randomBytes)(DEFAULT_KEY_SIZE);
5366
- const key = (0, import_crypto2.scrypt)({
5367
- password: (0, import_crypto2.bufferFromString)(password),
5481
+ const salt = (0, import_crypto3.randomBytes)(DEFAULT_KEY_SIZE);
5482
+ const key = (0, import_crypto3.scrypt)({
5483
+ password: (0, import_crypto3.bufferFromString)(password),
5368
5484
  salt,
5369
5485
  dklen: DEFAULT_KEY_SIZE,
5370
5486
  n: 2 ** DEFAULT_KDF_PARAMS_LOG_N,
5371
5487
  r: DEFAULT_KDF_PARAMS_R,
5372
5488
  p: DEFAULT_KDF_PARAMS_P
5373
5489
  });
5374
- const iv = (0, import_crypto2.randomBytes)(DEFAULT_IV_SIZE);
5375
- const ciphertext = await (0, import_crypto2.encryptJsonWalletData)(privateKeyBuffer, key, iv);
5490
+ const iv = (0, import_crypto3.randomBytes)(DEFAULT_IV_SIZE);
5491
+ const ciphertext = await (0, import_crypto3.encryptJsonWalletData)(privateKeyBuffer, key, iv);
5376
5492
  const data = Uint8Array.from([...key.subarray(16, 32), ...ciphertext]);
5377
- const macHashUint8Array = (0, import_crypto2.keccak256)(data);
5378
- const mac = (0, import_crypto2.stringFromBuffer)(macHashUint8Array, "hex");
5493
+ const macHashUint8Array = (0, import_crypto3.keccak256)(data);
5494
+ const mac = (0, import_crypto3.stringFromBuffer)(macHashUint8Array, "hex");
5379
5495
  const keystore = {
5380
5496
  id: (0, import_uuid.v4)(),
5381
5497
  version: 3,
@@ -5383,15 +5499,15 @@ async function encryptKeystoreWallet(privateKey, address, password) {
5383
5499
  crypto: {
5384
5500
  cipher: "aes-128-ctr",
5385
5501
  mac,
5386
- cipherparams: { iv: (0, import_crypto2.stringFromBuffer)(iv, "hex") },
5387
- ciphertext: (0, import_crypto2.stringFromBuffer)(ciphertext, "hex"),
5502
+ cipherparams: { iv: (0, import_crypto3.stringFromBuffer)(iv, "hex") },
5503
+ ciphertext: (0, import_crypto3.stringFromBuffer)(ciphertext, "hex"),
5388
5504
  kdf: "scrypt",
5389
5505
  kdfparams: {
5390
5506
  dklen: DEFAULT_KEY_SIZE,
5391
5507
  n: 2 ** DEFAULT_KDF_PARAMS_LOG_N,
5392
5508
  p: DEFAULT_KDF_PARAMS_P,
5393
5509
  r: DEFAULT_KDF_PARAMS_R,
5394
- salt: (0, import_crypto2.stringFromBuffer)(salt, "hex")
5510
+ salt: (0, import_crypto3.stringFromBuffer)(salt, "hex")
5395
5511
  }
5396
5512
  }
5397
5513
  };
@@ -5407,11 +5523,11 @@ async function decryptKeystoreWallet(jsonWallet, password) {
5407
5523
  kdfparams: { dklen, n, r, p, salt }
5408
5524
  }
5409
5525
  } = keystoreWallet;
5410
- const ciphertextBuffer = (0, import_crypto2.bufferFromString)(ciphertext, "hex");
5411
- const ivBuffer = (0, import_crypto2.bufferFromString)(iv, "hex");
5412
- const saltBuffer = (0, import_crypto2.bufferFromString)(salt, "hex");
5413
- const passwordBuffer = (0, import_crypto2.bufferFromString)(password);
5414
- const key = (0, import_crypto2.scrypt)({
5526
+ const ciphertextBuffer = (0, import_crypto3.bufferFromString)(ciphertext, "hex");
5527
+ const ivBuffer = (0, import_crypto3.bufferFromString)(iv, "hex");
5528
+ const saltBuffer = (0, import_crypto3.bufferFromString)(salt, "hex");
5529
+ const passwordBuffer = (0, import_crypto3.bufferFromString)(password);
5530
+ const key = (0, import_crypto3.scrypt)({
5415
5531
  password: passwordBuffer,
5416
5532
  salt: saltBuffer,
5417
5533
  n,
@@ -5420,16 +5536,16 @@ async function decryptKeystoreWallet(jsonWallet, password) {
5420
5536
  dklen
5421
5537
  });
5422
5538
  const data = Uint8Array.from([...key.subarray(16, 32), ...ciphertextBuffer]);
5423
- const macHashUint8Array = (0, import_crypto2.keccak256)(data);
5424
- const macHash = (0, import_crypto2.stringFromBuffer)(macHashUint8Array, "hex");
5539
+ const macHashUint8Array = (0, import_crypto3.keccak256)(data);
5540
+ const macHash = (0, import_crypto3.stringFromBuffer)(macHashUint8Array, "hex");
5425
5541
  if (mac !== macHash) {
5426
- throw new import_errors16.FuelError(
5427
- import_errors16.ErrorCode.INVALID_PASSWORD,
5542
+ throw new import_errors17.FuelError(
5543
+ import_errors17.ErrorCode.INVALID_PASSWORD,
5428
5544
  "Failed to decrypt the keystore wallet, the provided password is incorrect."
5429
5545
  );
5430
5546
  }
5431
- const buffer = await (0, import_crypto2.decryptJsonWalletData)(ciphertextBuffer, key, ivBuffer);
5432
- const privateKey = (0, import_utils29.hexlify)(buffer);
5547
+ const buffer = await (0, import_crypto3.decryptJsonWalletData)(ciphertextBuffer, key, ivBuffer);
5548
+ const privateKey = (0, import_utils30.hexlify)(buffer);
5433
5549
  return privateKey;
5434
5550
  }
5435
5551
 
@@ -5474,7 +5590,7 @@ var BaseWalletUnlocked = class extends Account {
5474
5590
  */
5475
5591
  async signMessage(message) {
5476
5592
  const signedMessage = await this.signer().sign((0, import_hasher3.hashMessage)(message));
5477
- return (0, import_utils30.hexlify)(signedMessage);
5593
+ return (0, import_utils31.hexlify)(signedMessage);
5478
5594
  }
5479
5595
  /**
5480
5596
  * Signs a transaction with the wallet's private key.
@@ -5487,7 +5603,7 @@ var BaseWalletUnlocked = class extends Account {
5487
5603
  const chainId = this.provider.getChainId();
5488
5604
  const hashedTransaction = transactionRequest.getTransactionId(chainId);
5489
5605
  const signature = await this.signer().sign(hashedTransaction);
5490
- return (0, import_utils30.hexlify)(signature);
5606
+ return (0, import_utils31.hexlify)(signature);
5491
5607
  }
5492
5608
  /**
5493
5609
  * Populates a transaction with the witnesses signature.
@@ -5546,17 +5662,17 @@ var BaseWalletUnlocked = class extends Account {
5546
5662
  __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
5547
5663
 
5548
5664
  // src/hdwallet/hdwallet.ts
5549
- var import_errors19 = require("@fuel-ts/errors");
5665
+ var import_errors20 = require("@fuel-ts/errors");
5550
5666
  var import_hasher6 = require("@fuel-ts/hasher");
5551
- var import_math19 = require("@fuel-ts/math");
5552
- var import_utils34 = require("@fuel-ts/utils");
5667
+ var import_math20 = require("@fuel-ts/math");
5668
+ var import_utils35 = require("@fuel-ts/utils");
5553
5669
  var import_ethers3 = require("ethers");
5554
5670
 
5555
5671
  // src/mnemonic/mnemonic.ts
5556
- var import_crypto3 = require("@fuel-ts/crypto");
5557
- var import_errors18 = require("@fuel-ts/errors");
5672
+ var import_crypto4 = require("@fuel-ts/crypto");
5673
+ var import_errors19 = require("@fuel-ts/errors");
5558
5674
  var import_hasher5 = require("@fuel-ts/hasher");
5559
- var import_utils32 = require("@fuel-ts/utils");
5675
+ var import_utils33 = require("@fuel-ts/utils");
5560
5676
  var import_ethers2 = require("ethers");
5561
5677
 
5562
5678
  // src/wordlists/words/english.ts
@@ -7618,9 +7734,9 @@ var Language = /* @__PURE__ */ ((Language2) => {
7618
7734
  })(Language || {});
7619
7735
 
7620
7736
  // src/mnemonic/utils.ts
7621
- var import_errors17 = require("@fuel-ts/errors");
7737
+ var import_errors18 = require("@fuel-ts/errors");
7622
7738
  var import_hasher4 = require("@fuel-ts/hasher");
7623
- var import_utils31 = require("@fuel-ts/utils");
7739
+ var import_utils32 = require("@fuel-ts/utils");
7624
7740
  function toUtf8Bytes(stri) {
7625
7741
  const str = stri.normalize("NFKD");
7626
7742
  const result = [];
@@ -7635,8 +7751,8 @@ function toUtf8Bytes(stri) {
7635
7751
  i += 1;
7636
7752
  const c2 = str.charCodeAt(i);
7637
7753
  if (i >= str.length || (c2 & 64512) !== 56320) {
7638
- throw new import_errors17.FuelError(
7639
- import_errors17.ErrorCode.INVALID_INPUT_PARAMETERS,
7754
+ throw new import_errors18.FuelError(
7755
+ import_errors18.ErrorCode.INVALID_INPUT_PARAMETERS,
7640
7756
  "Invalid UTF-8 in the input string."
7641
7757
  );
7642
7758
  }
@@ -7687,20 +7803,20 @@ function entropyToMnemonicIndices(entropy) {
7687
7803
  }
7688
7804
  }
7689
7805
  const checksumBits = entropy.length / 4;
7690
- const checksum = (0, import_utils31.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
7806
+ const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
7691
7807
  indices[indices.length - 1] <<= checksumBits;
7692
7808
  indices[indices.length - 1] |= checksum >> 8 - checksumBits;
7693
7809
  return indices;
7694
7810
  }
7695
7811
  function mnemonicWordsToEntropy(words, wordlist) {
7696
7812
  const size = Math.ceil(11 * words.length / 8);
7697
- const entropy = (0, import_utils31.arrayify)(new Uint8Array(size));
7813
+ const entropy = (0, import_utils32.arrayify)(new Uint8Array(size));
7698
7814
  let offset = 0;
7699
7815
  for (let i = 0; i < words.length; i += 1) {
7700
7816
  const index = wordlist.indexOf(words[i].normalize("NFKD"));
7701
7817
  if (index === -1) {
7702
- throw new import_errors17.FuelError(
7703
- import_errors17.ErrorCode.INVALID_MNEMONIC,
7818
+ throw new import_errors18.FuelError(
7819
+ import_errors18.ErrorCode.INVALID_MNEMONIC,
7704
7820
  `Invalid mnemonic: the word '${words[i]}' is not found in the provided wordlist.`
7705
7821
  );
7706
7822
  }
@@ -7714,10 +7830,10 @@ function mnemonicWordsToEntropy(words, wordlist) {
7714
7830
  const entropyBits = 32 * words.length / 3;
7715
7831
  const checksumBits = words.length / 3;
7716
7832
  const checksumMask = getUpperMask(checksumBits);
7717
- const checksum = (0, import_utils31.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
7833
+ const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
7718
7834
  if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
7719
- throw new import_errors17.FuelError(
7720
- import_errors17.ErrorCode.INVALID_CHECKSUM,
7835
+ throw new import_errors18.FuelError(
7836
+ import_errors18.ErrorCode.INVALID_CHECKSUM,
7721
7837
  "Checksum validation failed for the provided mnemonic."
7722
7838
  );
7723
7839
  }
@@ -7731,16 +7847,16 @@ var TestnetPRV = "0x04358394";
7731
7847
  var MNEMONIC_SIZES = [12, 15, 18, 21, 24];
7732
7848
  function assertWordList(wordlist) {
7733
7849
  if (wordlist.length !== 2048) {
7734
- throw new import_errors18.FuelError(
7735
- import_errors18.ErrorCode.INVALID_WORD_LIST,
7850
+ throw new import_errors19.FuelError(
7851
+ import_errors19.ErrorCode.INVALID_WORD_LIST,
7736
7852
  `Expected word list length of 2048, but got ${wordlist.length}.`
7737
7853
  );
7738
7854
  }
7739
7855
  }
7740
7856
  function assertEntropy(entropy) {
7741
7857
  if (entropy.length % 4 !== 0 || entropy.length < 16 || entropy.length > 32) {
7742
- throw new import_errors18.FuelError(
7743
- import_errors18.ErrorCode.INVALID_ENTROPY,
7858
+ throw new import_errors19.FuelError(
7859
+ import_errors19.ErrorCode.INVALID_ENTROPY,
7744
7860
  `Entropy should be between 16 and 32 bytes and a multiple of 4, but got ${entropy.length} bytes.`
7745
7861
  );
7746
7862
  }
@@ -7750,7 +7866,7 @@ function assertMnemonic(words) {
7750
7866
  const errorMsg = `Invalid mnemonic size. Expected one of [${MNEMONIC_SIZES.join(
7751
7867
  ", "
7752
7868
  )}] words, but got ${words.length}.`;
7753
- throw new import_errors18.FuelError(import_errors18.ErrorCode.INVALID_MNEMONIC, errorMsg);
7869
+ throw new import_errors19.FuelError(import_errors19.ErrorCode.INVALID_MNEMONIC, errorMsg);
7754
7870
  }
7755
7871
  }
7756
7872
  var Mnemonic = class {
@@ -7789,7 +7905,7 @@ var Mnemonic = class {
7789
7905
  static mnemonicToEntropy(phrase, wordlist = english) {
7790
7906
  const words = getWords(phrase);
7791
7907
  assertMnemonic(words);
7792
- return (0, import_utils32.hexlify)(mnemonicWordsToEntropy(words, wordlist));
7908
+ return (0, import_utils33.hexlify)(mnemonicWordsToEntropy(words, wordlist));
7793
7909
  }
7794
7910
  /**
7795
7911
  * @param entropy - Entropy source to the mnemonic phrase.
@@ -7797,7 +7913,7 @@ var Mnemonic = class {
7797
7913
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
7798
7914
  */
7799
7915
  static entropyToMnemonic(entropy, wordlist = english) {
7800
- const entropyBytes = (0, import_utils32.arrayify)(entropy);
7916
+ const entropyBytes = (0, import_utils33.arrayify)(entropy);
7801
7917
  assertWordList(wordlist);
7802
7918
  assertEntropy(entropyBytes);
7803
7919
  return entropyToMnemonicIndices(entropyBytes).map((i) => wordlist[i]).join(" ");
@@ -7866,14 +7982,14 @@ var Mnemonic = class {
7866
7982
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
7867
7983
  */
7868
7984
  static masterKeysFromSeed(seed) {
7869
- const seedArray = (0, import_utils32.arrayify)(seed);
7985
+ const seedArray = (0, import_utils33.arrayify)(seed);
7870
7986
  if (seedArray.length < 16 || seedArray.length > 64) {
7871
- throw new import_errors18.FuelError(
7872
- import_errors18.ErrorCode.INVALID_SEED,
7987
+ throw new import_errors19.FuelError(
7988
+ import_errors19.ErrorCode.INVALID_SEED,
7873
7989
  `Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
7874
7990
  );
7875
7991
  }
7876
- return (0, import_utils32.arrayify)((0, import_ethers2.computeHmac)("sha512", MasterSecret, seedArray));
7992
+ return (0, import_utils33.arrayify)((0, import_ethers2.computeHmac)("sha512", MasterSecret, seedArray));
7877
7993
  }
7878
7994
  /**
7879
7995
  * Get the extendKey as defined on BIP-32 from the provided seed
@@ -7884,22 +8000,22 @@ var Mnemonic = class {
7884
8000
  */
7885
8001
  static seedToExtendedKey(seed, testnet = false) {
7886
8002
  const masterKey = Mnemonic.masterKeysFromSeed(seed);
7887
- const prefix = (0, import_utils32.arrayify)(testnet ? TestnetPRV : MainnetPRV);
8003
+ const prefix = (0, import_utils33.arrayify)(testnet ? TestnetPRV : MainnetPRV);
7888
8004
  const depth = "0x00";
7889
8005
  const fingerprint = "0x00000000";
7890
8006
  const index = "0x00000000";
7891
8007
  const chainCode = masterKey.slice(32);
7892
8008
  const privateKey = masterKey.slice(0, 32);
7893
- const extendedKey = (0, import_utils32.concat)([
8009
+ const extendedKey = (0, import_utils33.concat)([
7894
8010
  prefix,
7895
8011
  depth,
7896
8012
  fingerprint,
7897
8013
  index,
7898
8014
  chainCode,
7899
- (0, import_utils32.concat)(["0x00", privateKey])
8015
+ (0, import_utils33.concat)(["0x00", privateKey])
7900
8016
  ]);
7901
8017
  const checksum = (0, import_ethers2.dataSlice)((0, import_hasher5.sha256)((0, import_hasher5.sha256)(extendedKey)), 0, 4);
7902
- return (0, import_ethers2.encodeBase58)((0, import_utils32.concat)([extendedKey, checksum]));
8018
+ return (0, import_ethers2.encodeBase58)((0, import_utils33.concat)([extendedKey, checksum]));
7903
8019
  }
7904
8020
  /**
7905
8021
  * Create a new mnemonic using a randomly generated number as entropy.
@@ -7914,7 +8030,7 @@ var Mnemonic = class {
7914
8030
  * @returns A randomly generated mnemonic
7915
8031
  */
7916
8032
  static generate(size = 32, extraEntropy = "") {
7917
- const entropy = extraEntropy ? (0, import_hasher5.sha256)((0, import_utils32.concat)([(0, import_crypto3.randomBytes)(size), (0, import_utils32.arrayify)(extraEntropy)])) : (0, import_crypto3.randomBytes)(size);
8033
+ 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);
7918
8034
  return Mnemonic.entropyToMnemonic(entropy);
7919
8035
  }
7920
8036
  };
@@ -7922,12 +8038,12 @@ var mnemonic_default = Mnemonic;
7922
8038
 
7923
8039
  // src/hdwallet/hdwallet.ts
7924
8040
  var HARDENED_INDEX = 2147483648;
7925
- var MainnetPRV2 = (0, import_utils34.hexlify)("0x0488ade4");
7926
- var MainnetPUB = (0, import_utils34.hexlify)("0x0488b21e");
7927
- var TestnetPRV2 = (0, import_utils34.hexlify)("0x04358394");
7928
- var TestnetPUB = (0, import_utils34.hexlify)("0x043587cf");
8041
+ var MainnetPRV2 = (0, import_utils35.hexlify)("0x0488ade4");
8042
+ var MainnetPUB = (0, import_utils35.hexlify)("0x0488b21e");
8043
+ var TestnetPRV2 = (0, import_utils35.hexlify)("0x04358394");
8044
+ var TestnetPUB = (0, import_utils35.hexlify)("0x043587cf");
7929
8045
  function base58check(data) {
7930
- return (0, import_ethers3.encodeBase58)((0, import_utils34.concat)([data, (0, import_ethers3.dataSlice)((0, import_hasher6.sha256)((0, import_hasher6.sha256)(data)), 0, 4)]));
8046
+ 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)]));
7931
8047
  }
7932
8048
  function getExtendedKeyPrefix(isPublic = false, testnet = false) {
7933
8049
  if (isPublic) {
@@ -7936,17 +8052,17 @@ function getExtendedKeyPrefix(isPublic = false, testnet = false) {
7936
8052
  return testnet ? TestnetPRV2 : MainnetPRV2;
7937
8053
  }
7938
8054
  function isPublicExtendedKey(extendedKey) {
7939
- return [MainnetPUB, TestnetPUB].includes((0, import_utils34.hexlify)(extendedKey.slice(0, 4)));
8055
+ return [MainnetPUB, TestnetPUB].includes((0, import_utils35.hexlify)(extendedKey.slice(0, 4)));
7940
8056
  }
7941
8057
  function isValidExtendedKey(extendedKey) {
7942
8058
  return [MainnetPRV2, TestnetPRV2, MainnetPUB, TestnetPUB].includes(
7943
- (0, import_utils34.hexlify)(extendedKey.slice(0, 4))
8059
+ (0, import_utils35.hexlify)(extendedKey.slice(0, 4))
7944
8060
  );
7945
8061
  }
7946
8062
  function parsePath(path, depth = 0) {
7947
8063
  const components = path.split("/");
7948
8064
  if (components.length === 0 || components[0] === "m" && depth !== 0) {
7949
- throw new import_errors19.FuelError(import_errors19.ErrorCode.HD_WALLET_ERROR, `invalid path - ${path}`);
8065
+ throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, `invalid path - ${path}`);
7950
8066
  }
7951
8067
  if (components[0] === "m") {
7952
8068
  components.shift();
@@ -7958,8 +8074,8 @@ function parsePath(path, depth = 0) {
7958
8074
  var HDWallet = class {
7959
8075
  depth = 0;
7960
8076
  index = 0;
7961
- fingerprint = (0, import_utils34.hexlify)("0x00000000");
7962
- parentFingerprint = (0, import_utils34.hexlify)("0x00000000");
8077
+ fingerprint = (0, import_utils35.hexlify)("0x00000000");
8078
+ parentFingerprint = (0, import_utils35.hexlify)("0x00000000");
7963
8079
  privateKey;
7964
8080
  publicKey;
7965
8081
  chainCode;
@@ -7971,16 +8087,16 @@ var HDWallet = class {
7971
8087
  constructor(config) {
7972
8088
  if (config.privateKey) {
7973
8089
  const signer = new Signer(config.privateKey);
7974
- this.publicKey = (0, import_utils34.hexlify)(signer.compressedPublicKey);
7975
- this.privateKey = (0, import_utils34.hexlify)(config.privateKey);
8090
+ this.publicKey = (0, import_utils35.hexlify)(signer.compressedPublicKey);
8091
+ this.privateKey = (0, import_utils35.hexlify)(config.privateKey);
7976
8092
  } else {
7977
8093
  if (!config.publicKey) {
7978
- throw new import_errors19.FuelError(
7979
- import_errors19.ErrorCode.HD_WALLET_ERROR,
8094
+ throw new import_errors20.FuelError(
8095
+ import_errors20.ErrorCode.HD_WALLET_ERROR,
7980
8096
  "Both public and private Key cannot be missing. At least one should be provided."
7981
8097
  );
7982
8098
  }
7983
- this.publicKey = (0, import_utils34.hexlify)(config.publicKey);
8099
+ this.publicKey = (0, import_utils35.hexlify)(config.publicKey);
7984
8100
  }
7985
8101
  this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
7986
8102
  this.fingerprint = (0, import_ethers3.dataSlice)((0, import_ethers3.ripemd160)((0, import_hasher6.sha256)(this.publicKey)), 0, 4);
@@ -7999,28 +8115,28 @@ var HDWallet = class {
7999
8115
  * @returns A new instance of HDWallet on the derived index
8000
8116
  */
8001
8117
  deriveIndex(index) {
8002
- const privateKey = this.privateKey && (0, import_utils34.arrayify)(this.privateKey);
8003
- const publicKey = (0, import_utils34.arrayify)(this.publicKey);
8004
- const chainCode = (0, import_utils34.arrayify)(this.chainCode);
8118
+ const privateKey = this.privateKey && (0, import_utils35.arrayify)(this.privateKey);
8119
+ const publicKey = (0, import_utils35.arrayify)(this.publicKey);
8120
+ const chainCode = (0, import_utils35.arrayify)(this.chainCode);
8005
8121
  const data = new Uint8Array(37);
8006
8122
  if (index & HARDENED_INDEX) {
8007
8123
  if (!privateKey) {
8008
- throw new import_errors19.FuelError(
8009
- import_errors19.ErrorCode.HD_WALLET_ERROR,
8124
+ throw new import_errors20.FuelError(
8125
+ import_errors20.ErrorCode.HD_WALLET_ERROR,
8010
8126
  "Cannot derive a hardened index without a private Key."
8011
8127
  );
8012
8128
  }
8013
8129
  data.set(privateKey, 1);
8014
8130
  } else {
8015
- data.set((0, import_utils34.arrayify)(this.publicKey));
8131
+ data.set((0, import_utils35.arrayify)(this.publicKey));
8016
8132
  }
8017
- data.set((0, import_math19.toBytes)(index, 4), 33);
8018
- const bytes = (0, import_utils34.arrayify)((0, import_ethers3.computeHmac)("sha512", chainCode, data));
8133
+ data.set((0, import_math20.toBytes)(index, 4), 33);
8134
+ const bytes = (0, import_utils35.arrayify)((0, import_ethers3.computeHmac)("sha512", chainCode, data));
8019
8135
  const IL = bytes.slice(0, 32);
8020
8136
  const IR = bytes.slice(32);
8021
8137
  if (privateKey) {
8022
8138
  const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
8023
- const ki = (0, import_math19.bn)(IL).add(privateKey).mod(N).toBytes(32);
8139
+ const ki = (0, import_math20.bn)(IL).add(privateKey).mod(N).toBytes(32);
8024
8140
  return new HDWallet({
8025
8141
  privateKey: ki,
8026
8142
  chainCode: IR,
@@ -8029,7 +8145,7 @@ var HDWallet = class {
8029
8145
  parentFingerprint: this.fingerprint
8030
8146
  });
8031
8147
  }
8032
- const signer = new Signer((0, import_utils34.hexlify)(IL));
8148
+ const signer = new Signer((0, import_utils35.hexlify)(IL));
8033
8149
  const Ki = signer.addPoint(publicKey);
8034
8150
  return new HDWallet({
8035
8151
  publicKey: Ki,
@@ -8058,18 +8174,18 @@ var HDWallet = class {
8058
8174
  */
8059
8175
  toExtendedKey(isPublic = false, testnet = false) {
8060
8176
  if (this.depth >= 256) {
8061
- throw new import_errors19.FuelError(
8062
- import_errors19.ErrorCode.HD_WALLET_ERROR,
8177
+ throw new import_errors20.FuelError(
8178
+ import_errors20.ErrorCode.HD_WALLET_ERROR,
8063
8179
  `Exceeded max depth of 255. Current depth: ${this.depth}.`
8064
8180
  );
8065
8181
  }
8066
8182
  const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
8067
- const depth = (0, import_utils34.hexlify)(Uint8Array.from([this.depth]));
8183
+ const depth = (0, import_utils35.hexlify)(Uint8Array.from([this.depth]));
8068
8184
  const parentFingerprint = this.parentFingerprint;
8069
- const index = (0, import_math19.toHex)(this.index, 4);
8185
+ const index = (0, import_math20.toHex)(this.index, 4);
8070
8186
  const chainCode = this.chainCode;
8071
- const key = this.privateKey != null && !isPublic ? (0, import_utils34.concat)(["0x00", this.privateKey]) : this.publicKey;
8072
- const extendedKey = (0, import_utils34.arrayify)((0, import_utils34.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
8187
+ const key = this.privateKey != null && !isPublic ? (0, import_utils35.concat)(["0x00", this.privateKey]) : this.publicKey;
8188
+ const extendedKey = (0, import_utils35.arrayify)((0, import_utils35.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
8073
8189
  return base58check(extendedKey);
8074
8190
  }
8075
8191
  /**
@@ -8081,34 +8197,34 @@ var HDWallet = class {
8081
8197
  static fromSeed(seed) {
8082
8198
  const masterKey = mnemonic_default.masterKeysFromSeed(seed);
8083
8199
  return new HDWallet({
8084
- chainCode: (0, import_utils34.arrayify)(masterKey.slice(32)),
8085
- privateKey: (0, import_utils34.arrayify)(masterKey.slice(0, 32))
8200
+ chainCode: (0, import_utils35.arrayify)(masterKey.slice(32)),
8201
+ privateKey: (0, import_utils35.arrayify)(masterKey.slice(0, 32))
8086
8202
  });
8087
8203
  }
8088
8204
  static fromExtendedKey(extendedKey) {
8089
8205
  const decoded = (0, import_ethers3.toBeHex)((0, import_ethers3.decodeBase58)(extendedKey));
8090
- const bytes = (0, import_utils34.arrayify)(decoded);
8206
+ const bytes = (0, import_utils35.arrayify)(decoded);
8091
8207
  const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
8092
8208
  if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
8093
- throw new import_errors19.FuelError(import_errors19.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
8209
+ throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
8094
8210
  }
8095
8211
  if (!validChecksum) {
8096
- throw new import_errors19.FuelError(import_errors19.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
8212
+ throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
8097
8213
  }
8098
8214
  const depth = bytes[4];
8099
- const parentFingerprint = (0, import_utils34.hexlify)(bytes.slice(5, 9));
8100
- const index = parseInt((0, import_utils34.hexlify)(bytes.slice(9, 13)).substring(2), 16);
8101
- const chainCode = (0, import_utils34.hexlify)(bytes.slice(13, 45));
8215
+ const parentFingerprint = (0, import_utils35.hexlify)(bytes.slice(5, 9));
8216
+ const index = parseInt((0, import_utils35.hexlify)(bytes.slice(9, 13)).substring(2), 16);
8217
+ const chainCode = (0, import_utils35.hexlify)(bytes.slice(13, 45));
8102
8218
  const key = bytes.slice(45, 78);
8103
8219
  if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
8104
- throw new import_errors19.FuelError(
8105
- import_errors19.ErrorCode.HD_WALLET_ERROR,
8220
+ throw new import_errors20.FuelError(
8221
+ import_errors20.ErrorCode.HD_WALLET_ERROR,
8106
8222
  "Inconsistency detected: Depth is zero but fingerprint/index is non-zero."
8107
8223
  );
8108
8224
  }
8109
8225
  if (isPublicExtendedKey(bytes)) {
8110
8226
  if (key[0] !== 3) {
8111
- throw new import_errors19.FuelError(import_errors19.ErrorCode.HD_WALLET_ERROR, "Invalid public extended key.");
8227
+ throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Invalid public extended key.");
8112
8228
  }
8113
8229
  return new HDWallet({
8114
8230
  publicKey: key,
@@ -8119,7 +8235,7 @@ var HDWallet = class {
8119
8235
  });
8120
8236
  }
8121
8237
  if (key[0] !== 0) {
8122
- throw new import_errors19.FuelError(import_errors19.ErrorCode.HD_WALLET_ERROR, "Invalid private extended key.");
8238
+ throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Invalid private extended key.");
8123
8239
  }
8124
8240
  return new HDWallet({
8125
8241
  privateKey: key.slice(1),
@@ -8286,8 +8402,8 @@ __publicField(Wallet, "fromEncryptedJson", WalletUnlocked.fromEncryptedJson);
8286
8402
 
8287
8403
  // src/wallet-manager/wallet-manager.ts
8288
8404
  var import_address9 = require("@fuel-ts/address");
8289
- var import_crypto4 = require("@fuel-ts/crypto");
8290
- var import_errors22 = require("@fuel-ts/errors");
8405
+ var import_crypto5 = require("@fuel-ts/crypto");
8406
+ var import_errors23 = require("@fuel-ts/errors");
8291
8407
  var import_events = require("events");
8292
8408
 
8293
8409
  // src/wallet-manager/storages/memory-storage.ts
@@ -8310,7 +8426,7 @@ var MemoryStorage = class {
8310
8426
 
8311
8427
  // src/wallet-manager/vaults/mnemonic-vault.ts
8312
8428
  var import_address7 = require("@fuel-ts/address");
8313
- var import_errors20 = require("@fuel-ts/errors");
8429
+ var import_errors21 = require("@fuel-ts/errors");
8314
8430
  var _secret;
8315
8431
  var MnemonicVault = class {
8316
8432
  constructor(options) {
@@ -8366,8 +8482,8 @@ var MnemonicVault = class {
8366
8482
  }
8367
8483
  numberOfAccounts += 1;
8368
8484
  } while (numberOfAccounts < this.numberOfAccounts);
8369
- throw new import_errors20.FuelError(
8370
- import_errors20.ErrorCode.WALLET_MANAGER_ERROR,
8485
+ throw new import_errors21.FuelError(
8486
+ import_errors21.ErrorCode.WALLET_MANAGER_ERROR,
8371
8487
  `Account with address '${address}' not found in derived wallets.`
8372
8488
  );
8373
8489
  }
@@ -8381,7 +8497,7 @@ __publicField(MnemonicVault, "type", "mnemonic");
8381
8497
 
8382
8498
  // src/wallet-manager/vaults/privatekey-vault.ts
8383
8499
  var import_address8 = require("@fuel-ts/address");
8384
- var import_errors21 = require("@fuel-ts/errors");
8500
+ var import_errors22 = require("@fuel-ts/errors");
8385
8501
  var _privateKeys;
8386
8502
  var PrivateKeyVault = class {
8387
8503
  /**
@@ -8422,8 +8538,8 @@ var PrivateKeyVault = class {
8422
8538
  (pk) => Wallet.fromPrivateKey(pk).address.equals(ownerAddress)
8423
8539
  );
8424
8540
  if (!privateKey) {
8425
- throw new import_errors21.FuelError(
8426
- import_errors21.ErrorCode.WALLET_MANAGER_ERROR,
8541
+ throw new import_errors22.FuelError(
8542
+ import_errors22.ErrorCode.WALLET_MANAGER_ERROR,
8427
8543
  `No private key found for address '${address}'.`
8428
8544
  );
8429
8545
  }
@@ -8447,7 +8563,7 @@ var ERROR_MESSAGES = {
8447
8563
  };
8448
8564
  function assert(condition, message) {
8449
8565
  if (!condition) {
8450
- throw new import_errors22.FuelError(import_errors22.ErrorCode.WALLET_MANAGER_ERROR, message);
8566
+ throw new import_errors23.FuelError(import_errors23.ErrorCode.WALLET_MANAGER_ERROR, message);
8451
8567
  }
8452
8568
  }
8453
8569
  var _vaults, _passphrase, _isLocked, _serializeVaults, serializeVaults_fn, _deserializeVaults, deserializeVaults_fn;
@@ -8614,7 +8730,7 @@ var _WalletManager = class extends import_events.EventEmitter {
8614
8730
  await assert(!__privateGet(this, _isLocked), ERROR_MESSAGES.wallet_not_unlocked);
8615
8731
  const data = await this.storage.getItem(this.STORAGE_KEY);
8616
8732
  if (data) {
8617
- const state = await (0, import_crypto4.decrypt)(__privateGet(this, _passphrase), JSON.parse(data));
8733
+ const state = await (0, import_crypto5.decrypt)(__privateGet(this, _passphrase), JSON.parse(data));
8618
8734
  __privateSet(this, _vaults, __privateMethod(this, _deserializeVaults, deserializeVaults_fn).call(this, state.vaults));
8619
8735
  }
8620
8736
  }
@@ -8623,7 +8739,7 @@ var _WalletManager = class extends import_events.EventEmitter {
8623
8739
  */
8624
8740
  async saveState() {
8625
8741
  await assert(!__privateGet(this, _isLocked), ERROR_MESSAGES.wallet_not_unlocked);
8626
- const encryptedData = await (0, import_crypto4.encrypt)(__privateGet(this, _passphrase), {
8742
+ const encryptedData = await (0, import_crypto5.encrypt)(__privateGet(this, _passphrase), {
8627
8743
  vaults: __privateMethod(this, _serializeVaults, serializeVaults_fn).call(this, __privateGet(this, _vaults))
8628
8744
  });
8629
8745
  await this.storage.setItem(this.STORAGE_KEY, JSON.stringify(encryptedData));
@@ -8673,25 +8789,25 @@ deserializeVaults_fn = function(vaults) {
8673
8789
  __publicField(WalletManager, "Vaults", [MnemonicVault, PrivateKeyVault]);
8674
8790
 
8675
8791
  // src/wallet-manager/types.ts
8676
- var import_errors23 = require("@fuel-ts/errors");
8792
+ var import_errors24 = require("@fuel-ts/errors");
8677
8793
  var Vault = class {
8678
8794
  constructor(_options) {
8679
- throw new import_errors23.FuelError(import_errors23.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
8795
+ throw new import_errors24.FuelError(import_errors24.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
8680
8796
  }
8681
8797
  serialize() {
8682
- throw new import_errors23.FuelError(import_errors23.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
8798
+ throw new import_errors24.FuelError(import_errors24.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
8683
8799
  }
8684
8800
  getAccounts() {
8685
- throw new import_errors23.FuelError(import_errors23.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
8801
+ throw new import_errors24.FuelError(import_errors24.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
8686
8802
  }
8687
8803
  addAccount() {
8688
- throw new import_errors23.FuelError(import_errors23.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
8804
+ throw new import_errors24.FuelError(import_errors24.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
8689
8805
  }
8690
8806
  exportAccount(_address) {
8691
- throw new import_errors23.FuelError(import_errors23.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
8807
+ throw new import_errors24.FuelError(import_errors24.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
8692
8808
  }
8693
8809
  getWallet(_address) {
8694
- throw new import_errors23.FuelError(import_errors23.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
8810
+ throw new import_errors24.FuelError(import_errors24.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
8695
8811
  }
8696
8812
  };
8697
8813
  __publicField(Vault, "type");
@@ -8699,30 +8815,29 @@ var StorageAbstract = class {
8699
8815
  };
8700
8816
 
8701
8817
  // src/predicate/predicate.ts
8702
- var import_abi_coder5 = require("@fuel-ts/abi-coder");
8818
+ var import_abi_coder7 = require("@fuel-ts/abi-coder");
8703
8819
  var import_address10 = require("@fuel-ts/address");
8704
- var import_configs12 = require("@fuel-ts/address/configs");
8705
- var import_errors24 = require("@fuel-ts/errors");
8706
- var import_transactions19 = require("@fuel-ts/transactions");
8707
- var import_utils36 = require("@fuel-ts/utils");
8820
+ var import_configs13 = require("@fuel-ts/address/configs");
8821
+ var import_errors25 = require("@fuel-ts/errors");
8822
+ var import_transactions20 = require("@fuel-ts/transactions");
8823
+ var import_utils37 = require("@fuel-ts/utils");
8708
8824
 
8709
8825
  // src/predicate/utils/getPredicateRoot.ts
8710
8826
  var import_hasher7 = require("@fuel-ts/hasher");
8711
8827
  var import_merkle = require("@fuel-ts/merkle");
8712
- var import_utils35 = require("@fuel-ts/utils");
8828
+ var import_utils36 = require("@fuel-ts/utils");
8713
8829
  var getPredicateRoot = (bytecode) => {
8714
8830
  const chunkSize = 16 * 1024;
8715
- const bytes = (0, import_utils35.arrayify)(bytecode);
8716
- const chunks = (0, import_utils35.chunkAndPadBytes)(bytes, chunkSize);
8717
- const codeRoot = (0, import_merkle.calcRoot)(chunks.map((c) => (0, import_utils35.hexlify)(c)));
8718
- const predicateRoot = (0, import_hasher7.hash)((0, import_utils35.concat)(["0x4655454C", codeRoot]));
8831
+ const bytes = (0, import_utils36.arrayify)(bytecode);
8832
+ const chunks = (0, import_utils36.chunkAndPadBytes)(bytes, chunkSize);
8833
+ const codeRoot = (0, import_merkle.calcRoot)(chunks.map((c) => (0, import_utils36.hexlify)(c)));
8834
+ const predicateRoot = (0, import_hasher7.hash)((0, import_utils36.concat)(["0x4655454C", codeRoot]));
8719
8835
  return predicateRoot;
8720
8836
  };
8721
8837
 
8722
8838
  // src/predicate/predicate.ts
8723
8839
  var Predicate = class extends Account {
8724
8840
  bytes;
8725
- predicateDataBytes = Uint8Array.from([]);
8726
8841
  predicateData = [];
8727
8842
  interface;
8728
8843
  /**
@@ -8764,7 +8879,7 @@ var Predicate = class extends Account {
8764
8879
  const request = transactionRequestify(transactionRequestLike);
8765
8880
  const { policies } = BaseTransactionRequest.getPolicyMeta(request);
8766
8881
  request.inputs?.forEach((input) => {
8767
- if (input.type === import_transactions19.InputType.Coin && (0, import_utils36.hexlify)(input.owner) === this.address.toB256()) {
8882
+ if (input.type === import_transactions20.InputType.Coin && (0, import_utils37.hexlify)(input.owner) === this.address.toB256()) {
8768
8883
  input.predicate = this.bytes;
8769
8884
  input.predicateData = this.getPredicateData(policies.length);
8770
8885
  }
@@ -8780,7 +8895,7 @@ var Predicate = class extends Account {
8780
8895
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
8781
8896
  * @returns A promise that resolves to the prepared transaction request.
8782
8897
  */
8783
- async createTransfer(destination, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
8898
+ async createTransfer(destination, amount, assetId = import_configs13.BaseAssetId, txParams = {}) {
8784
8899
  const request = await super.createTransfer(destination, amount, assetId, txParams);
8785
8900
  return this.populateTransactionPredicateData(request);
8786
8901
  }
@@ -8809,11 +8924,11 @@ var Predicate = class extends Account {
8809
8924
  return new Uint8Array();
8810
8925
  }
8811
8926
  const mainFn = this.interface?.functions.main;
8812
- const paddedCode = new import_transactions19.ByteArrayCoder(this.bytes.length).encode(this.bytes);
8813
- const VM_TX_MEMORY = (0, import_abi_coder5.calculateVmTxMemory)({
8927
+ const paddedCode = new import_transactions20.ByteArrayCoder(this.bytes.length).encode(this.bytes);
8928
+ const VM_TX_MEMORY = (0, import_abi_coder7.calculateVmTxMemory)({
8814
8929
  maxInputs: this.provider.getChain().consensusParameters.maxInputs.toNumber()
8815
8930
  });
8816
- const OFFSET = VM_TX_MEMORY + import_abi_coder5.SCRIPT_FIXED_SIZE + import_abi_coder5.INPUT_COIN_FIXED_SIZE + import_abi_coder5.WORD_SIZE + paddedCode.byteLength + policiesLength * import_abi_coder5.WORD_SIZE;
8931
+ const OFFSET = VM_TX_MEMORY + import_abi_coder7.SCRIPT_FIXED_SIZE + import_abi_coder7.INPUT_COIN_FIXED_SIZE + import_abi_coder7.WORD_SIZE + paddedCode.byteLength + policiesLength * import_abi_coder7.WORD_SIZE;
8817
8932
  return mainFn?.encodeArguments(this.predicateData, OFFSET) || new Uint8Array();
8818
8933
  }
8819
8934
  /**
@@ -8825,13 +8940,13 @@ var Predicate = class extends Account {
8825
8940
  * @returns An object containing the new predicate bytes and interface.
8826
8941
  */
8827
8942
  static processPredicateData(bytes, jsonAbi, configurableConstants) {
8828
- let predicateBytes = (0, import_utils36.arrayify)(bytes);
8943
+ let predicateBytes = (0, import_utils37.arrayify)(bytes);
8829
8944
  let abiInterface;
8830
8945
  if (jsonAbi) {
8831
- abiInterface = new import_abi_coder5.Interface(jsonAbi);
8946
+ abiInterface = new import_abi_coder7.Interface(jsonAbi);
8832
8947
  if (abiInterface.functions.main === void 0) {
8833
- throw new import_errors24.FuelError(
8834
- import_errors24.ErrorCode.ABI_MAIN_METHOD_MISSING,
8948
+ throw new import_errors25.FuelError(
8949
+ import_errors25.ErrorCode.ABI_MAIN_METHOD_MISSING,
8835
8950
  'Cannot use ABI without "main" function.'
8836
8951
  );
8837
8952
  }
@@ -8876,8 +8991,8 @@ var Predicate = class extends Account {
8876
8991
  mutatedBytes.set(encoded, offset);
8877
8992
  });
8878
8993
  } catch (err) {
8879
- throw new import_errors24.FuelError(
8880
- import_errors24.ErrorCode.INVALID_CONFIGURABLE_CONSTANTS,
8994
+ throw new import_errors25.FuelError(
8995
+ import_errors25.ErrorCode.INVALID_CONFIGURABLE_CONSTANTS,
8881
8996
  `Error setting configurable constants: ${err.message}.`
8882
8997
  );
8883
8998
  }
@@ -8886,7 +9001,7 @@ var Predicate = class extends Account {
8886
9001
  };
8887
9002
 
8888
9003
  // src/connectors/fuel.ts
8889
- var import_errors25 = require("@fuel-ts/errors");
9004
+ var import_errors26 = require("@fuel-ts/errors");
8890
9005
 
8891
9006
  // src/connectors/fuel-connector.ts
8892
9007
  var import_events2 = require("events");
@@ -9519,7 +9634,7 @@ var _Fuel = class extends FuelConnector {
9519
9634
  const currentNetwork = await this.currentNetwork();
9520
9635
  provider = await Provider.create(currentNetwork.url);
9521
9636
  } else {
9522
- throw new import_errors25.FuelError(import_errors25.ErrorCode.INVALID_PROVIDER, "Provider is not valid.");
9637
+ throw new import_errors26.FuelError(import_errors26.ErrorCode.INVALID_PROVIDER, "Provider is not valid.");
9523
9638
  }
9524
9639
  return provider;
9525
9640
  }
@@ -9599,7 +9714,9 @@ __publicField(Fuel, "defaultConfig", {});
9599
9714
  WalletUnlocked,
9600
9715
  addAmountToAsset,
9601
9716
  addOperation,
9717
+ assemblePanicError,
9602
9718
  assembleReceiptByType,
9719
+ assembleRevertError,
9603
9720
  assembleTransactionSummary,
9604
9721
  assets,
9605
9722
  buildBlockExplorerUrl,
@@ -9614,6 +9731,7 @@ __publicField(Fuel, "defaultConfig", {});
9614
9731
  english,
9615
9732
  extractBurnedAssetsFromReceipts,
9616
9733
  extractMintedAssetsFromReceipts,
9734
+ extractTxError,
9617
9735
  gasUsedByInputs,
9618
9736
  getAssetEth,
9619
9737
  getAssetFuel,