@fuel-ts/account 0.79.0 → 0.81.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of @fuel-ts/account might be problematic. Click here for more details.

Files changed (34) hide show
  1. package/dist/configs.d.ts +1 -0
  2. package/dist/configs.d.ts.map +1 -1
  3. package/dist/configs.global.js +1 -0
  4. package/dist/configs.global.js.map +1 -1
  5. package/dist/configs.js +3 -0
  6. package/dist/configs.js.map +1 -1
  7. package/dist/configs.mjs +2 -0
  8. package/dist/configs.mjs.map +1 -1
  9. package/dist/index.global.js +382 -192
  10. package/dist/index.global.js.map +1 -1
  11. package/dist/index.js +667 -554
  12. package/dist/index.js.map +1 -1
  13. package/dist/index.mjs +416 -298
  14. package/dist/index.mjs.map +1 -1
  15. package/dist/predicate/predicate.d.ts +0 -1
  16. package/dist/predicate/predicate.d.ts.map +1 -1
  17. package/dist/providers/fuel-graphql-subscriber.d.ts +2 -0
  18. package/dist/providers/fuel-graphql-subscriber.d.ts.map +1 -1
  19. package/dist/providers/provider.d.ts +13 -2
  20. package/dist/providers/provider.d.ts.map +1 -1
  21. package/dist/providers/transaction-request/input.d.ts.map +1 -1
  22. package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
  23. package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
  24. package/dist/providers/utils/extract-tx-error.d.ts +36 -0
  25. package/dist/providers/utils/extract-tx-error.d.ts.map +1 -0
  26. package/dist/providers/utils/index.d.ts +1 -0
  27. package/dist/providers/utils/index.d.ts.map +1 -1
  28. package/dist/test-utils.global.js +384 -193
  29. package/dist/test-utils.global.js.map +1 -1
  30. package/dist/test-utils.js +624 -516
  31. package/dist/test-utils.js.map +1 -1
  32. package/dist/test-utils.mjs +388 -272
  33. package/dist/test-utils.mjs.map +1 -1
  34. package/package.json +21 -26
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");
@@ -1063,36 +1066,45 @@ var _FuelGraphqlSubscriber = class {
1063
1066
  });
1064
1067
  this.stream = response.body.getReader();
1065
1068
  }
1069
+ events = [];
1070
+ parsingLeftover = "";
1066
1071
  async next() {
1067
1072
  if (!this.stream) {
1068
1073
  await this.setStream();
1069
1074
  }
1070
1075
  while (true) {
1076
+ if (this.events.length > 0) {
1077
+ const { data, errors } = this.events.shift();
1078
+ if (Array.isArray(errors)) {
1079
+ throw new import_errors.FuelError(
1080
+ import_errors.FuelError.CODES.INVALID_REQUEST,
1081
+ errors.map((err) => err.message).join("\n\n")
1082
+ );
1083
+ }
1084
+ return { value: data, done: false };
1085
+ }
1071
1086
  const { value, done } = await this.stream.read();
1072
1087
  if (done) {
1073
1088
  return { value, done };
1074
1089
  }
1075
- const text = _FuelGraphqlSubscriber.textDecoder.decode(value);
1076
- if (!text.startsWith("data:")) {
1090
+ const decoded = _FuelGraphqlSubscriber.textDecoder.decode(value).replace(":keep-alive-text\n\n", "");
1091
+ if (decoded === "") {
1077
1092
  continue;
1078
1093
  }
1079
- let data;
1080
- let errors;
1081
- try {
1082
- ({ data, errors } = JSON.parse(text.replace(/^data:/, "")));
1083
- } catch (e) {
1084
- throw new import_errors.FuelError(
1085
- import_errors.ErrorCode.STREAM_PARSING_ERROR,
1086
- `Error while parsing stream data response: ${text}`
1087
- );
1088
- }
1089
- if (Array.isArray(errors)) {
1090
- throw new import_errors.FuelError(
1091
- import_errors.FuelError.CODES.INVALID_REQUEST,
1092
- errors.map((err) => err.message).join("\n\n")
1093
- );
1094
- }
1095
- return { value: data, done: false };
1094
+ const text = `${this.parsingLeftover}${decoded}`;
1095
+ const regex = /data:.*\n\n/g;
1096
+ const matches = [...text.matchAll(regex)].flatMap((match) => match);
1097
+ matches.forEach((match) => {
1098
+ try {
1099
+ this.events.push(JSON.parse(match.replace(/^data:/, "")));
1100
+ } catch (e) {
1101
+ throw new import_errors.FuelError(
1102
+ import_errors.ErrorCode.STREAM_PARSING_ERROR,
1103
+ `Error while parsing stream data response: ${text}`
1104
+ );
1105
+ }
1106
+ });
1107
+ this.parsingLeftover = text.replace(matches.join(), "");
1096
1108
  }
1097
1109
  }
1098
1110
  /**
@@ -1170,6 +1182,7 @@ var MemoryCache = class {
1170
1182
  };
1171
1183
 
1172
1184
  // src/providers/transaction-request/input.ts
1185
+ var import_abi_coder = require("@fuel-ts/abi-coder");
1173
1186
  var import_configs2 = require("@fuel-ts/address/configs");
1174
1187
  var import_errors3 = require("@fuel-ts/errors");
1175
1188
  var import_math2 = require("@fuel-ts/math");
@@ -1183,8 +1196,8 @@ var inputify = (value) => {
1183
1196
  const predicateData = (0, import_utils3.arrayify)(value.predicateData ?? "0x");
1184
1197
  return {
1185
1198
  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],
1199
+ txID: (0, import_utils3.hexlify)((0, import_utils3.arrayify)(value.id).slice(0, import_abi_coder.BYTES_32)),
1200
+ outputIndex: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.id).slice(import_abi_coder.BYTES_32, import_abi_coder.UTXO_ID_LEN)),
1188
1201
  owner: (0, import_utils3.hexlify)(value.owner),
1189
1202
  amount: (0, import_math2.bn)(value.amount),
1190
1203
  assetId: (0, import_utils3.hexlify)(value.assetId),
@@ -1302,10 +1315,12 @@ var outputify = (value) => {
1302
1315
  };
1303
1316
 
1304
1317
  // src/providers/transaction-request/transaction-request.ts
1318
+ var import_abi_coder2 = require("@fuel-ts/abi-coder");
1305
1319
  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");
1320
+ var import_configs7 = require("@fuel-ts/address/configs");
1321
+ var import_crypto = require("@fuel-ts/crypto");
1322
+ var import_math7 = require("@fuel-ts/math");
1323
+ var import_transactions6 = require("@fuel-ts/transactions");
1309
1324
  var import_utils9 = require("@fuel-ts/utils");
1310
1325
 
1311
1326
  // src/providers/resource.ts
@@ -1698,6 +1713,78 @@ function sleep(time) {
1698
1713
  });
1699
1714
  }
1700
1715
 
1716
+ // src/providers/utils/extract-tx-error.ts
1717
+ var import_errors7 = require("@fuel-ts/errors");
1718
+ var import_math6 = require("@fuel-ts/math");
1719
+ var import_transactions5 = require("@fuel-ts/transactions");
1720
+ var import_configs6 = require("@fuel-ts/transactions/configs");
1721
+ var assemblePanicError = (status) => {
1722
+ let errorMessage = `The transaction reverted with reason: "${status.reason}".`;
1723
+ const reason = status.reason;
1724
+ if (import_configs6.PANIC_REASONS.includes(status.reason)) {
1725
+ errorMessage = `${errorMessage}
1726
+
1727
+ You can read more about this error at:
1728
+
1729
+ ${import_configs6.PANIC_DOC_URL}#variant.${status.reason}`;
1730
+ }
1731
+ return { errorMessage, reason };
1732
+ };
1733
+ var stringify = (obj) => JSON.stringify(obj, null, 2);
1734
+ var assembleRevertError = (receipts, logs) => {
1735
+ let errorMessage = "The transaction reverted with an unknown reason.";
1736
+ const revertReceipt = receipts.find(({ type }) => type === import_transactions5.ReceiptType.Revert);
1737
+ let reason = "";
1738
+ if (revertReceipt) {
1739
+ const reasonHex = (0, import_math6.bn)(revertReceipt.val).toHex();
1740
+ switch (reasonHex) {
1741
+ case import_configs6.FAILED_REQUIRE_SIGNAL: {
1742
+ reason = "require";
1743
+ errorMessage = `The transaction reverted because a "require" statement has thrown ${logs.length ? stringify(logs[0]) : "an error."}.`;
1744
+ break;
1745
+ }
1746
+ case import_configs6.FAILED_ASSERT_EQ_SIGNAL: {
1747
+ const sufix = logs.length >= 2 ? ` comparing ${stringify(logs[1])} and ${stringify(logs[0])}.` : ".";
1748
+ reason = "assert_eq";
1749
+ errorMessage = `The transaction reverted because of an "assert_eq" statement${sufix}`;
1750
+ break;
1751
+ }
1752
+ case import_configs6.FAILED_ASSERT_NE_SIGNAL: {
1753
+ const sufix = logs.length >= 2 ? ` comparing ${stringify(logs[1])} and ${stringify(logs[0])}.` : ".";
1754
+ reason = "assert_ne";
1755
+ errorMessage = `The transaction reverted because of an "assert_ne" statement${sufix}`;
1756
+ break;
1757
+ }
1758
+ case import_configs6.FAILED_ASSERT_SIGNAL:
1759
+ reason = "assert";
1760
+ errorMessage = `The transaction reverted because an "assert" statement failed to evaluate to true.`;
1761
+ break;
1762
+ case import_configs6.FAILED_TRANSFER_TO_ADDRESS_SIGNAL:
1763
+ reason = "MissingOutputChange";
1764
+ errorMessage = `The transaction reverted because it's missing an "OutputChange".`;
1765
+ break;
1766
+ default:
1767
+ reason = "unknown";
1768
+ errorMessage = `The transaction reverted with an unknown reason: ${revertReceipt.val}`;
1769
+ }
1770
+ }
1771
+ return { errorMessage, reason };
1772
+ };
1773
+ var extractTxError = (params) => {
1774
+ const { receipts, status, logs } = params;
1775
+ const isPanic = receipts.some(({ type }) => type === import_transactions5.ReceiptType.Panic);
1776
+ const isRevert = receipts.some(({ type }) => type === import_transactions5.ReceiptType.Revert);
1777
+ const { errorMessage, reason } = status?.type === "FailureStatus" && isPanic ? assemblePanicError(status) : assembleRevertError(receipts, logs);
1778
+ const metadata = {
1779
+ logs,
1780
+ receipts,
1781
+ panic: isPanic,
1782
+ revert: isRevert,
1783
+ reason
1784
+ };
1785
+ return new import_errors7.FuelError(import_errors7.ErrorCode.SCRIPT_REVERTED, errorMessage, metadata);
1786
+ };
1787
+
1701
1788
  // src/providers/transaction-request/errors.ts
1702
1789
  var ChangeOutputCollisionError = class extends Error {
1703
1790
  name = "ChangeOutputCollisionError";
@@ -1760,10 +1847,10 @@ var BaseTransactionRequest = class {
1760
1847
  outputs,
1761
1848
  witnesses
1762
1849
  } = {}) {
1763
- this.gasPrice = (0, import_math6.bn)(gasPrice);
1850
+ this.gasPrice = (0, import_math7.bn)(gasPrice);
1764
1851
  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;
1852
+ this.witnessLimit = witnessLimit ? (0, import_math7.bn)(witnessLimit) : void 0;
1853
+ this.maxFee = maxFee ? (0, import_math7.bn)(maxFee) : void 0;
1767
1854
  this.inputs = inputs ?? [];
1768
1855
  this.outputs = outputs ?? [];
1769
1856
  this.witnesses = witnesses ?? [];
@@ -1772,20 +1859,20 @@ var BaseTransactionRequest = class {
1772
1859
  let policyTypes = 0;
1773
1860
  const policies = [];
1774
1861
  if (req.gasPrice) {
1775
- policyTypes += import_transactions5.PolicyType.GasPrice;
1776
- policies.push({ data: req.gasPrice, type: import_transactions5.PolicyType.GasPrice });
1862
+ policyTypes += import_transactions6.PolicyType.GasPrice;
1863
+ policies.push({ data: req.gasPrice, type: import_transactions6.PolicyType.GasPrice });
1777
1864
  }
1778
1865
  if (req.witnessLimit) {
1779
- policyTypes += import_transactions5.PolicyType.WitnessLimit;
1780
- policies.push({ data: req.witnessLimit, type: import_transactions5.PolicyType.WitnessLimit });
1866
+ policyTypes += import_transactions6.PolicyType.WitnessLimit;
1867
+ policies.push({ data: req.witnessLimit, type: import_transactions6.PolicyType.WitnessLimit });
1781
1868
  }
1782
1869
  if (req.maturity > 0) {
1783
- policyTypes += import_transactions5.PolicyType.Maturity;
1784
- policies.push({ data: req.maturity, type: import_transactions5.PolicyType.Maturity });
1870
+ policyTypes += import_transactions6.PolicyType.Maturity;
1871
+ policies.push({ data: req.maturity, type: import_transactions6.PolicyType.Maturity });
1785
1872
  }
1786
1873
  if (req.maxFee) {
1787
- policyTypes += import_transactions5.PolicyType.MaxFee;
1788
- policies.push({ data: req.maxFee, type: import_transactions5.PolicyType.MaxFee });
1874
+ policyTypes += import_transactions6.PolicyType.MaxFee;
1875
+ policies.push({ data: req.maxFee, type: import_transactions6.PolicyType.MaxFee });
1789
1876
  }
1790
1877
  return {
1791
1878
  policyTypes,
@@ -1819,7 +1906,7 @@ var BaseTransactionRequest = class {
1819
1906
  * @returns The transaction bytes.
1820
1907
  */
1821
1908
  toTransactionBytes() {
1822
- return new import_transactions5.TransactionCoder().encode(this.toTransaction());
1909
+ return new import_transactions6.TransactionCoder().encode(this.toTransaction());
1823
1910
  }
1824
1911
  /**
1825
1912
  * @hidden
@@ -1859,7 +1946,7 @@ var BaseTransactionRequest = class {
1859
1946
  * @returns The index of the created witness.
1860
1947
  */
1861
1948
  addEmptyWitness() {
1862
- this.addWitness((0, import_utils9.concat)([import_configs6.ZeroBytes32, import_configs6.ZeroBytes32]));
1949
+ this.addWitness((0, import_utils9.concat)([import_configs7.ZeroBytes32, import_configs7.ZeroBytes32]));
1863
1950
  return this.witnesses.length - 1;
1864
1951
  }
1865
1952
  /**
@@ -1910,7 +1997,7 @@ var BaseTransactionRequest = class {
1910
1997
  */
1911
1998
  getCoinInputs() {
1912
1999
  return this.inputs.filter(
1913
- (input) => input.type === import_transactions5.InputType.Coin
2000
+ (input) => input.type === import_transactions6.InputType.Coin
1914
2001
  );
1915
2002
  }
1916
2003
  /**
@@ -1920,7 +2007,7 @@ var BaseTransactionRequest = class {
1920
2007
  */
1921
2008
  getCoinOutputs() {
1922
2009
  return this.outputs.filter(
1923
- (output) => output.type === import_transactions5.OutputType.Coin
2010
+ (output) => output.type === import_transactions6.OutputType.Coin
1924
2011
  );
1925
2012
  }
1926
2013
  /**
@@ -1930,7 +2017,7 @@ var BaseTransactionRequest = class {
1930
2017
  */
1931
2018
  getChangeOutputs() {
1932
2019
  return this.outputs.filter(
1933
- (output) => output.type === import_transactions5.OutputType.Change
2020
+ (output) => output.type === import_transactions6.OutputType.Change
1934
2021
  );
1935
2022
  }
1936
2023
  /**
@@ -1942,9 +2029,9 @@ var BaseTransactionRequest = class {
1942
2029
  const ownerAddress = (0, import_address.addressify)(owner);
1943
2030
  const found = this.inputs.find((input) => {
1944
2031
  switch (input.type) {
1945
- case import_transactions5.InputType.Coin:
2032
+ case import_transactions6.InputType.Coin:
1946
2033
  return (0, import_utils9.hexlify)(input.owner) === ownerAddress.toB256();
1947
- case import_transactions5.InputType.Message:
2034
+ case import_transactions6.InputType.Message:
1948
2035
  return (0, import_utils9.hexlify)(input.recipient) === ownerAddress.toB256();
1949
2036
  default:
1950
2037
  return false;
@@ -1973,14 +2060,13 @@ var BaseTransactionRequest = class {
1973
2060
  }
1974
2061
  const input = {
1975
2062
  ...coin,
1976
- type: import_transactions5.InputType.Coin,
2063
+ type: import_transactions6.InputType.Coin,
1977
2064
  owner: owner.toB256(),
1978
2065
  amount,
1979
2066
  assetId,
1980
2067
  txPointer: "0x00000000000000000000000000000000",
1981
2068
  witnessIndex,
1982
- predicate: predicate?.bytes,
1983
- predicateData: predicate?.predicateDataBytes
2069
+ predicate: predicate?.bytes
1984
2070
  };
1985
2071
  this.pushInput(input);
1986
2072
  this.addChangeOutput(owner, assetId);
@@ -1995,7 +2081,7 @@ var BaseTransactionRequest = class {
1995
2081
  */
1996
2082
  addMessageInput(message, predicate) {
1997
2083
  const { recipient, sender, amount } = message;
1998
- const assetId = import_configs6.BaseAssetId;
2084
+ const assetId = import_configs7.BaseAssetId;
1999
2085
  let witnessIndex;
2000
2086
  if (predicate) {
2001
2087
  witnessIndex = 0;
@@ -2007,13 +2093,12 @@ var BaseTransactionRequest = class {
2007
2093
  }
2008
2094
  const input = {
2009
2095
  ...message,
2010
- type: import_transactions5.InputType.Message,
2096
+ type: import_transactions6.InputType.Message,
2011
2097
  sender: sender.toB256(),
2012
2098
  recipient: recipient.toB256(),
2013
2099
  amount,
2014
2100
  witnessIndex,
2015
- predicate: predicate?.bytes,
2016
- predicateData: predicate?.predicateDataBytes
2101
+ predicate: predicate?.bytes
2017
2102
  };
2018
2103
  this.pushInput(input);
2019
2104
  this.addChangeOutput(recipient, assetId);
@@ -2077,9 +2162,9 @@ var BaseTransactionRequest = class {
2077
2162
  * @param amount - Amount of coin.
2078
2163
  * @param assetId - Asset ID of coin.
2079
2164
  */
2080
- addCoinOutput(to, amount, assetId = import_configs6.BaseAssetId) {
2165
+ addCoinOutput(to, amount, assetId = import_configs7.BaseAssetId) {
2081
2166
  this.pushOutput({
2082
- type: import_transactions5.OutputType.Coin,
2167
+ type: import_transactions6.OutputType.Coin,
2083
2168
  to: (0, import_address.addressify)(to).toB256(),
2084
2169
  amount,
2085
2170
  assetId
@@ -2095,7 +2180,7 @@ var BaseTransactionRequest = class {
2095
2180
  addCoinOutputs(to, quantities) {
2096
2181
  quantities.map(coinQuantityfy).forEach((quantity) => {
2097
2182
  this.pushOutput({
2098
- type: import_transactions5.OutputType.Coin,
2183
+ type: import_transactions6.OutputType.Coin,
2099
2184
  to: (0, import_address.addressify)(to).toB256(),
2100
2185
  amount: quantity.amount,
2101
2186
  assetId: quantity.assetId
@@ -2109,13 +2194,13 @@ var BaseTransactionRequest = class {
2109
2194
  * @param to - Address of the owner.
2110
2195
  * @param assetId - Asset ID of coin.
2111
2196
  */
2112
- addChangeOutput(to, assetId = import_configs6.BaseAssetId) {
2197
+ addChangeOutput(to, assetId = import_configs7.BaseAssetId) {
2113
2198
  const changeOutput = this.getChangeOutputs().find(
2114
2199
  (output) => (0, import_utils9.hexlify)(output.assetId) === assetId
2115
2200
  );
2116
2201
  if (!changeOutput) {
2117
2202
  this.pushOutput({
2118
- type: import_transactions5.OutputType.Change,
2203
+ type: import_transactions6.OutputType.Change,
2119
2204
  to: (0, import_address.addressify)(to).toB256(),
2120
2205
  assetId
2121
2206
  });
@@ -2168,12 +2253,6 @@ var BaseTransactionRequest = class {
2168
2253
  * @param quantities - CoinQuantity Array.
2169
2254
  */
2170
2255
  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
2256
  const findAssetInput = (assetId) => this.inputs.find((input) => {
2178
2257
  if ("assetId" in input) {
2179
2258
  return input.assetId === assetId;
@@ -2183,23 +2262,23 @@ var BaseTransactionRequest = class {
2183
2262
  const updateAssetInput = (assetId, quantity) => {
2184
2263
  const assetInput = findAssetInput(assetId);
2185
2264
  if (assetInput && "assetId" in assetInput) {
2186
- assetInput.id = generateId();
2265
+ assetInput.id = (0, import_utils9.hexlify)((0, import_crypto.randomBytes)(import_abi_coder2.UTXO_ID_LEN));
2187
2266
  assetInput.amount = quantity;
2188
2267
  } else {
2189
2268
  this.addResources([
2190
2269
  {
2191
- id: generateId(),
2270
+ id: (0, import_utils9.hexlify)((0, import_crypto.randomBytes)(import_abi_coder2.UTXO_ID_LEN)),
2192
2271
  amount: quantity,
2193
2272
  assetId,
2194
2273
  owner: resourcesOwner || import_address.Address.fromRandom(),
2195
2274
  maturity: 0,
2196
- blockCreated: (0, import_math6.bn)(1),
2197
- txCreatedIdx: (0, import_math6.bn)(1)
2275
+ blockCreated: (0, import_math7.bn)(1),
2276
+ txCreatedIdx: (0, import_math7.bn)(1)
2198
2277
  }
2199
2278
  ]);
2200
2279
  }
2201
2280
  };
2202
- updateAssetInput(import_configs6.BaseAssetId, (0, import_math6.bn)(1e11));
2281
+ updateAssetInput(import_configs7.BaseAssetId, (0, import_math7.bn)(1e11));
2203
2282
  quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
2204
2283
  }
2205
2284
  /**
@@ -2210,7 +2289,7 @@ var BaseTransactionRequest = class {
2210
2289
  */
2211
2290
  getCoinOutputsQuantities() {
2212
2291
  const coinsQuantities = this.getCoinOutputs().map(({ amount, assetId }) => ({
2213
- amount: (0, import_math6.bn)(amount),
2292
+ amount: (0, import_math7.bn)(amount),
2214
2293
  assetId: assetId.toString()
2215
2294
  }));
2216
2295
  return coinsQuantities;
@@ -2228,18 +2307,18 @@ var BaseTransactionRequest = class {
2228
2307
  this.inputs.forEach((i) => {
2229
2308
  let correspondingInput;
2230
2309
  switch (i.type) {
2231
- case import_transactions5.InputType.Coin:
2232
- correspondingInput = inputs.find((x) => x.type === import_transactions5.InputType.Coin && x.owner === i.owner);
2310
+ case import_transactions6.InputType.Coin:
2311
+ correspondingInput = inputs.find((x) => x.type === import_transactions6.InputType.Coin && x.owner === i.owner);
2233
2312
  break;
2234
- case import_transactions5.InputType.Message:
2313
+ case import_transactions6.InputType.Message:
2235
2314
  correspondingInput = inputs.find(
2236
- (x) => x.type === import_transactions5.InputType.Message && x.sender === i.sender
2315
+ (x) => x.type === import_transactions6.InputType.Message && x.sender === i.sender
2237
2316
  );
2238
2317
  break;
2239
2318
  default:
2240
2319
  return;
2241
2320
  }
2242
- if (correspondingInput && "predicateGasUsed" in correspondingInput && (0, import_math6.bn)(correspondingInput.predicateGasUsed).gt(0)) {
2321
+ if (correspondingInput && "predicateGasUsed" in correspondingInput && (0, import_math7.bn)(correspondingInput.predicateGasUsed).gt(0)) {
2243
2322
  i.predicate = correspondingInput.predicate;
2244
2323
  i.predicateData = correspondingInput.predicateData;
2245
2324
  i.predicateGasUsed = correspondingInput.predicateGasUsed;
@@ -2249,47 +2328,47 @@ var BaseTransactionRequest = class {
2249
2328
  };
2250
2329
 
2251
2330
  // 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");
2331
+ var import_configs9 = require("@fuel-ts/address/configs");
2332
+ var import_math9 = require("@fuel-ts/math");
2333
+ var import_transactions8 = require("@fuel-ts/transactions");
2255
2334
  var import_utils13 = require("@fuel-ts/utils");
2256
2335
 
2257
2336
  // src/providers/transaction-request/hash-transaction.ts
2258
- var import_configs7 = require("@fuel-ts/address/configs");
2337
+ var import_configs8 = require("@fuel-ts/address/configs");
2259
2338
  var import_hasher = require("@fuel-ts/hasher");
2260
- var import_math7 = require("@fuel-ts/math");
2261
- var import_transactions6 = require("@fuel-ts/transactions");
2339
+ var import_math8 = require("@fuel-ts/math");
2340
+ var import_transactions7 = require("@fuel-ts/transactions");
2262
2341
  var import_utils11 = require("@fuel-ts/utils");
2263
2342
  var import_ramda2 = require("ramda");
2264
2343
  function hashTransaction(transactionRequest, chainId) {
2265
2344
  const transaction = transactionRequest.toTransaction();
2266
- if (transaction.type === import_transactions6.TransactionType.Script) {
2267
- transaction.receiptsRoot = import_configs7.ZeroBytes32;
2345
+ if (transaction.type === import_transactions7.TransactionType.Script) {
2346
+ transaction.receiptsRoot = import_configs8.ZeroBytes32;
2268
2347
  }
2269
2348
  transaction.inputs = transaction.inputs.map((input) => {
2270
2349
  const inputClone = (0, import_ramda2.clone)(input);
2271
2350
  switch (inputClone.type) {
2272
- case import_transactions6.InputType.Coin: {
2351
+ case import_transactions7.InputType.Coin: {
2273
2352
  inputClone.txPointer = {
2274
2353
  blockHeight: 0,
2275
2354
  txIndex: 0
2276
2355
  };
2277
- inputClone.predicateGasUsed = (0, import_math7.bn)(0);
2356
+ inputClone.predicateGasUsed = (0, import_math8.bn)(0);
2278
2357
  return inputClone;
2279
2358
  }
2280
- case import_transactions6.InputType.Message: {
2281
- inputClone.predicateGasUsed = (0, import_math7.bn)(0);
2359
+ case import_transactions7.InputType.Message: {
2360
+ inputClone.predicateGasUsed = (0, import_math8.bn)(0);
2282
2361
  return inputClone;
2283
2362
  }
2284
- case import_transactions6.InputType.Contract: {
2363
+ case import_transactions7.InputType.Contract: {
2285
2364
  inputClone.txPointer = {
2286
2365
  blockHeight: 0,
2287
2366
  txIndex: 0
2288
2367
  };
2289
- inputClone.txID = import_configs7.ZeroBytes32;
2368
+ inputClone.txID = import_configs8.ZeroBytes32;
2290
2369
  inputClone.outputIndex = 0;
2291
- inputClone.balanceRoot = import_configs7.ZeroBytes32;
2292
- inputClone.stateRoot = import_configs7.ZeroBytes32;
2370
+ inputClone.balanceRoot = import_configs8.ZeroBytes32;
2371
+ inputClone.stateRoot = import_configs8.ZeroBytes32;
2293
2372
  return inputClone;
2294
2373
  }
2295
2374
  default:
@@ -2299,19 +2378,19 @@ function hashTransaction(transactionRequest, chainId) {
2299
2378
  transaction.outputs = transaction.outputs.map((output) => {
2300
2379
  const outputClone = (0, import_ramda2.clone)(output);
2301
2380
  switch (outputClone.type) {
2302
- case import_transactions6.OutputType.Contract: {
2303
- outputClone.balanceRoot = import_configs7.ZeroBytes32;
2304
- outputClone.stateRoot = import_configs7.ZeroBytes32;
2381
+ case import_transactions7.OutputType.Contract: {
2382
+ outputClone.balanceRoot = import_configs8.ZeroBytes32;
2383
+ outputClone.stateRoot = import_configs8.ZeroBytes32;
2305
2384
  return outputClone;
2306
2385
  }
2307
- case import_transactions6.OutputType.Change: {
2308
- outputClone.amount = (0, import_math7.bn)(0);
2386
+ case import_transactions7.OutputType.Change: {
2387
+ outputClone.amount = (0, import_math8.bn)(0);
2309
2388
  return outputClone;
2310
2389
  }
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;
2390
+ case import_transactions7.OutputType.Variable: {
2391
+ outputClone.to = import_configs8.ZeroBytes32;
2392
+ outputClone.amount = (0, import_math8.bn)(0);
2393
+ outputClone.assetId = import_configs8.ZeroBytes32;
2315
2394
  return outputClone;
2316
2395
  }
2317
2396
  default:
@@ -2321,7 +2400,7 @@ function hashTransaction(transactionRequest, chainId) {
2321
2400
  transaction.witnessesCount = 0;
2322
2401
  transaction.witnesses = [];
2323
2402
  const chainIdBytes = (0, import_hasher.uint64ToBytesBE)(chainId);
2324
- const concatenatedData = (0, import_utils11.concat)([chainIdBytes, new import_transactions6.TransactionCoder().encode(transaction)]);
2403
+ const concatenatedData = (0, import_utils11.concat)([chainIdBytes, new import_transactions7.TransactionCoder().encode(transaction)]);
2325
2404
  return (0, import_hasher.sha256)(concatenatedData);
2326
2405
  }
2327
2406
 
@@ -2357,7 +2436,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2357
2436
  return new this(obj);
2358
2437
  }
2359
2438
  /** Type of the transaction */
2360
- type = import_transactions7.TransactionType.Create;
2439
+ type = import_transactions8.TransactionType.Create;
2361
2440
  /** Witness index of contract bytecode to create */
2362
2441
  bytecodeWitnessIndex;
2363
2442
  /** Salt */
@@ -2377,7 +2456,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2377
2456
  } = {}) {
2378
2457
  super(rest);
2379
2458
  this.bytecodeWitnessIndex = bytecodeWitnessIndex ?? 0;
2380
- this.salt = (0, import_utils13.hexlify)(salt ?? import_configs8.ZeroBytes32);
2459
+ this.salt = (0, import_utils13.hexlify)(salt ?? import_configs9.ZeroBytes32);
2381
2460
  this.storageSlots = [...storageSlots ?? []];
2382
2461
  }
2383
2462
  /**
@@ -2390,12 +2469,12 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2390
2469
  const bytecodeWitnessIndex = this.bytecodeWitnessIndex;
2391
2470
  const storageSlots = this.storageSlots?.map(storageSlotify) ?? [];
2392
2471
  return {
2393
- type: import_transactions7.TransactionType.Create,
2472
+ type: import_transactions8.TransactionType.Create,
2394
2473
  ...baseTransaction,
2395
2474
  bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
2396
2475
  bytecodeWitnessIndex,
2397
2476
  storageSlotsCount: storageSlots.length,
2398
- salt: this.salt ? (0, import_utils13.hexlify)(this.salt) : import_configs8.ZeroBytes32,
2477
+ salt: this.salt ? (0, import_utils13.hexlify)(this.salt) : import_configs9.ZeroBytes32,
2399
2478
  storageSlots
2400
2479
  };
2401
2480
  }
@@ -2406,7 +2485,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2406
2485
  */
2407
2486
  getContractCreatedOutputs() {
2408
2487
  return this.outputs.filter(
2409
- (output) => output.type === import_transactions7.OutputType.ContractCreated
2488
+ (output) => output.type === import_transactions8.OutputType.ContractCreated
2410
2489
  );
2411
2490
  }
2412
2491
  /**
@@ -2427,14 +2506,14 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2427
2506
  */
2428
2507
  addContractCreatedOutput(contractId, stateRoot) {
2429
2508
  this.pushOutput({
2430
- type: import_transactions7.OutputType.ContractCreated,
2509
+ type: import_transactions8.OutputType.ContractCreated,
2431
2510
  contractId,
2432
2511
  stateRoot
2433
2512
  });
2434
2513
  }
2435
2514
  metadataGas(gasCosts) {
2436
2515
  return calculateMetadataGasForTxCreate({
2437
- contractBytesSize: (0, import_math8.bn)((0, import_utils13.arrayify)(this.witnesses[this.bytecodeWitnessIndex] || "0x").length),
2516
+ contractBytesSize: (0, import_math9.bn)((0, import_utils13.arrayify)(this.witnesses[this.bytecodeWitnessIndex] || "0x").length),
2438
2517
  gasCosts,
2439
2518
  stateRootSize: this.storageSlots.length,
2440
2519
  txBytesSize: this.byteSize()
@@ -2443,11 +2522,11 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2443
2522
  };
2444
2523
 
2445
2524
  // src/providers/transaction-request/script-transaction-request.ts
2446
- var import_abi_coder = require("@fuel-ts/abi-coder");
2525
+ var import_abi_coder3 = require("@fuel-ts/abi-coder");
2447
2526
  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");
2527
+ var import_configs10 = require("@fuel-ts/address/configs");
2528
+ var import_math10 = require("@fuel-ts/math");
2529
+ var import_transactions9 = require("@fuel-ts/transactions");
2451
2530
  var import_utils15 = require("@fuel-ts/utils");
2452
2531
 
2453
2532
  // src/providers/transaction-request/scripts.ts
@@ -2485,7 +2564,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2485
2564
  return new this(obj);
2486
2565
  }
2487
2566
  /** Type of the transaction */
2488
- type = import_transactions8.TransactionType.Script;
2567
+ type = import_transactions9.TransactionType.Script;
2489
2568
  /** Gas limit for transaction */
2490
2569
  gasLimit;
2491
2570
  /** Script to execute */
@@ -2500,7 +2579,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2500
2579
  */
2501
2580
  constructor({ script, scriptData, gasLimit, ...rest } = {}) {
2502
2581
  super(rest);
2503
- this.gasLimit = (0, import_math9.bn)(gasLimit);
2582
+ this.gasLimit = (0, import_math10.bn)(gasLimit);
2504
2583
  this.script = (0, import_utils15.arrayify)(script ?? returnZeroScript.bytes);
2505
2584
  this.scriptData = (0, import_utils15.arrayify)(scriptData ?? returnZeroScript.encodeScriptData());
2506
2585
  this.abis = rest.abis;
@@ -2514,12 +2593,12 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2514
2593
  const script = (0, import_utils15.arrayify)(this.script ?? "0x");
2515
2594
  const scriptData = (0, import_utils15.arrayify)(this.scriptData ?? "0x");
2516
2595
  return {
2517
- type: import_transactions8.TransactionType.Script,
2596
+ type: import_transactions9.TransactionType.Script,
2518
2597
  scriptGasLimit: this.gasLimit,
2519
2598
  ...super.getBaseTransaction(),
2520
2599
  scriptLength: script.length,
2521
2600
  scriptDataLength: scriptData.length,
2522
- receiptsRoot: import_configs9.ZeroBytes32,
2601
+ receiptsRoot: import_configs10.ZeroBytes32,
2523
2602
  script: (0, import_utils15.hexlify)(script),
2524
2603
  scriptData: (0, import_utils15.hexlify)(scriptData)
2525
2604
  };
@@ -2531,7 +2610,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2531
2610
  */
2532
2611
  getContractInputs() {
2533
2612
  return this.inputs.filter(
2534
- (input) => input.type === import_transactions8.InputType.Contract
2613
+ (input) => input.type === import_transactions9.InputType.Contract
2535
2614
  );
2536
2615
  }
2537
2616
  /**
@@ -2541,7 +2620,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2541
2620
  */
2542
2621
  getContractOutputs() {
2543
2622
  return this.outputs.filter(
2544
- (output) => output.type === import_transactions8.OutputType.Contract
2623
+ (output) => output.type === import_transactions9.OutputType.Contract
2545
2624
  );
2546
2625
  }
2547
2626
  /**
@@ -2551,7 +2630,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2551
2630
  */
2552
2631
  getVariableOutputs() {
2553
2632
  return this.outputs.filter(
2554
- (output) => output.type === import_transactions8.OutputType.Variable
2633
+ (output) => output.type === import_transactions9.OutputType.Variable
2555
2634
  );
2556
2635
  }
2557
2636
  /**
@@ -2574,7 +2653,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2574
2653
  let outputsNumber = numberOfVariables;
2575
2654
  while (outputsNumber) {
2576
2655
  this.pushOutput({
2577
- type: import_transactions8.OutputType.Variable
2656
+ type: import_transactions9.OutputType.Variable
2578
2657
  });
2579
2658
  outputsNumber -= 1;
2580
2659
  }
@@ -2607,12 +2686,12 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2607
2686
  return this;
2608
2687
  }
2609
2688
  const inputIndex = super.pushInput({
2610
- type: import_transactions8.InputType.Contract,
2689
+ type: import_transactions9.InputType.Contract,
2611
2690
  contractId: contractAddress.toB256(),
2612
2691
  txPointer: "0x00000000000000000000000000000000"
2613
2692
  });
2614
2693
  this.pushOutput({
2615
- type: import_transactions8.OutputType.Contract,
2694
+ type: import_transactions9.OutputType.Contract,
2616
2695
  inputIndex
2617
2696
  });
2618
2697
  return this;
@@ -2635,7 +2714,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2635
2714
  * @returns The current instance of the `ScriptTransactionRequest`.
2636
2715
  */
2637
2716
  setData(abi, args) {
2638
- const abiInterface = new import_abi_coder.Interface(abi);
2717
+ const abiInterface = new import_abi_coder3.Interface(abi);
2639
2718
  this.scriptData = abiInterface.functions.main.encodeArguments(args);
2640
2719
  return this;
2641
2720
  }
@@ -2648,38 +2727,38 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2648
2727
  };
2649
2728
 
2650
2729
  // src/providers/transaction-request/utils.ts
2651
- var import_errors8 = require("@fuel-ts/errors");
2652
- var import_transactions9 = require("@fuel-ts/transactions");
2730
+ var import_errors9 = require("@fuel-ts/errors");
2731
+ var import_transactions10 = require("@fuel-ts/transactions");
2653
2732
  var transactionRequestify = (obj) => {
2654
2733
  if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest) {
2655
2734
  return obj;
2656
2735
  }
2657
2736
  const { type } = obj;
2658
2737
  switch (obj.type) {
2659
- case import_transactions9.TransactionType.Script: {
2738
+ case import_transactions10.TransactionType.Script: {
2660
2739
  return ScriptTransactionRequest.from(obj);
2661
2740
  }
2662
- case import_transactions9.TransactionType.Create: {
2741
+ case import_transactions10.TransactionType.Create: {
2663
2742
  return CreateTransactionRequest.from(obj);
2664
2743
  }
2665
2744
  default: {
2666
- throw new import_errors8.FuelError(import_errors8.ErrorCode.INVALID_TRANSACTION_TYPE, `Invalid transaction type: ${type}.`);
2745
+ throw new import_errors9.FuelError(import_errors9.ErrorCode.INVALID_TRANSACTION_TYPE, `Invalid transaction type: ${type}.`);
2667
2746
  }
2668
2747
  }
2669
2748
  };
2670
2749
 
2671
2750
  // src/providers/transaction-response/transaction-response.ts
2672
- var import_errors12 = require("@fuel-ts/errors");
2673
- var import_math13 = require("@fuel-ts/math");
2674
- var import_transactions16 = require("@fuel-ts/transactions");
2751
+ var import_errors13 = require("@fuel-ts/errors");
2752
+ var import_math14 = require("@fuel-ts/math");
2753
+ var import_transactions17 = require("@fuel-ts/transactions");
2675
2754
  var import_utils21 = require("@fuel-ts/utils");
2676
2755
 
2677
2756
  // src/providers/transaction-summary/assemble-transaction-summary.ts
2678
2757
  var import_utils19 = require("@fuel-ts/utils");
2679
2758
 
2680
2759
  // src/providers/transaction-summary/calculate-transaction-fee.ts
2681
- var import_math10 = require("@fuel-ts/math");
2682
- var import_transactions10 = require("@fuel-ts/transactions");
2760
+ var import_math11 = require("@fuel-ts/math");
2761
+ var import_transactions11 = require("@fuel-ts/transactions");
2683
2762
  var import_utils16 = require("@fuel-ts/utils");
2684
2763
  var calculateTransactionFee = (params) => {
2685
2764
  const {
@@ -2687,24 +2766,24 @@ var calculateTransactionFee = (params) => {
2687
2766
  rawPayload,
2688
2767
  consensusParameters: { gasCosts, feeParams }
2689
2768
  } = params;
2690
- const gasPerByte = (0, import_math10.bn)(feeParams.gasPerByte);
2691
- const gasPriceFactor = (0, import_math10.bn)(feeParams.gasPriceFactor);
2769
+ const gasPerByte = (0, import_math11.bn)(feeParams.gasPerByte);
2770
+ const gasPriceFactor = (0, import_math11.bn)(feeParams.gasPriceFactor);
2692
2771
  const transactionBytes = (0, import_utils16.arrayify)(rawPayload);
2693
- const [transaction] = new import_transactions10.TransactionCoder().decode(transactionBytes, 0);
2694
- if (transaction.type === import_transactions10.TransactionType.Mint) {
2772
+ const [transaction] = new import_transactions11.TransactionCoder().decode(transactionBytes, 0);
2773
+ if (transaction.type === import_transactions11.TransactionType.Mint) {
2695
2774
  return {
2696
- fee: (0, import_math10.bn)(0),
2697
- minFee: (0, import_math10.bn)(0),
2698
- maxFee: (0, import_math10.bn)(0),
2699
- feeFromGasUsed: (0, import_math10.bn)(0)
2775
+ fee: (0, import_math11.bn)(0),
2776
+ minFee: (0, import_math11.bn)(0),
2777
+ maxFee: (0, import_math11.bn)(0),
2778
+ feeFromGasUsed: (0, import_math11.bn)(0)
2700
2779
  };
2701
2780
  }
2702
2781
  const { type, witnesses, inputs, policies } = transaction;
2703
- let metadataGas = (0, import_math10.bn)(0);
2704
- let gasLimit = (0, import_math10.bn)(0);
2705
- if (type === import_transactions10.TransactionType.Create) {
2782
+ let metadataGas = (0, import_math11.bn)(0);
2783
+ let gasLimit = (0, import_math11.bn)(0);
2784
+ if (type === import_transactions11.TransactionType.Create) {
2706
2785
  const { bytecodeWitnessIndex, storageSlots } = transaction;
2707
- const contractBytesSize = (0, import_math10.bn)((0, import_utils16.arrayify)(witnesses[bytecodeWitnessIndex].data).length);
2786
+ const contractBytesSize = (0, import_math11.bn)((0, import_utils16.arrayify)(witnesses[bytecodeWitnessIndex].data).length);
2708
2787
  metadataGas = calculateMetadataGasForTxCreate({
2709
2788
  contractBytesSize,
2710
2789
  gasCosts,
@@ -2723,13 +2802,13 @@ var calculateTransactionFee = (params) => {
2723
2802
  }
2724
2803
  const minGas = getMinGas({
2725
2804
  gasCosts,
2726
- gasPerByte: (0, import_math10.bn)(gasPerByte),
2805
+ gasPerByte: (0, import_math11.bn)(gasPerByte),
2727
2806
  inputs,
2728
2807
  metadataGas,
2729
2808
  txBytesSize: transactionBytes.length
2730
2809
  });
2731
- const gasPrice = (0, import_math10.bn)(policies.find((policy) => policy.type === import_transactions10.PolicyType.GasPrice)?.data);
2732
- const witnessLimit = policies.find((policy) => policy.type === import_transactions10.PolicyType.WitnessLimit)?.data;
2810
+ const gasPrice = (0, import_math11.bn)(policies.find((policy) => policy.type === import_transactions11.PolicyType.GasPrice)?.data);
2811
+ const witnessLimit = policies.find((policy) => policy.type === import_transactions11.PolicyType.WitnessLimit)?.data;
2733
2812
  const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
2734
2813
  const maxGas = getMaxGas({
2735
2814
  gasPerByte,
@@ -2751,23 +2830,23 @@ var calculateTransactionFee = (params) => {
2751
2830
  };
2752
2831
 
2753
2832
  // src/providers/transaction-summary/operations.ts
2754
- var import_configs10 = require("@fuel-ts/address/configs");
2755
- var import_errors10 = require("@fuel-ts/errors");
2756
- var import_math12 = require("@fuel-ts/math");
2757
- var import_transactions13 = require("@fuel-ts/transactions");
2833
+ var import_configs11 = require("@fuel-ts/address/configs");
2834
+ var import_errors11 = require("@fuel-ts/errors");
2835
+ var import_math13 = require("@fuel-ts/math");
2836
+ var import_transactions14 = require("@fuel-ts/transactions");
2758
2837
 
2759
2838
  // src/providers/transaction-summary/call.ts
2760
- var import_abi_coder2 = require("@fuel-ts/abi-coder");
2761
- var import_math11 = require("@fuel-ts/math");
2839
+ var import_abi_coder4 = require("@fuel-ts/abi-coder");
2840
+ var import_math12 = require("@fuel-ts/math");
2762
2841
  var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
2763
- const abiInterface = new import_abi_coder2.Interface(abi);
2842
+ const abiInterface = new import_abi_coder4.Interface(abi);
2764
2843
  const callFunctionSelector = receipt.param1.toHex(8);
2765
2844
  const functionFragment = abiInterface.getFunction(callFunctionSelector);
2766
2845
  const inputs = functionFragment.jsonFn.inputs;
2767
2846
  let encodedArgs;
2768
2847
  if (functionFragment.isInputDataPointer) {
2769
2848
  if (rawPayload) {
2770
- const argsOffset = (0, import_math11.bn)(receipt.param2).sub((0, import_abi_coder2.calculateVmTxMemory)({ maxInputs: maxInputs.toNumber() })).toNumber();
2849
+ const argsOffset = (0, import_math12.bn)(receipt.param2).sub((0, import_abi_coder4.calculateVmTxMemory)({ maxInputs: maxInputs.toNumber() })).toNumber();
2771
2850
  encodedArgs = `0x${rawPayload.slice(2).slice(argsOffset * 2)}`;
2772
2851
  }
2773
2852
  } else {
@@ -2801,8 +2880,8 @@ var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
2801
2880
  };
2802
2881
 
2803
2882
  // src/providers/transaction-summary/input.ts
2804
- var import_errors9 = require("@fuel-ts/errors");
2805
- var import_transactions11 = require("@fuel-ts/transactions");
2883
+ var import_errors10 = require("@fuel-ts/errors");
2884
+ var import_transactions12 = require("@fuel-ts/transactions");
2806
2885
  function getInputsByTypes(inputs, types) {
2807
2886
  return inputs.filter((i) => types.includes(i.type));
2808
2887
  }
@@ -2810,16 +2889,16 @@ function getInputsByType(inputs, type) {
2810
2889
  return inputs.filter((i) => i.type === type);
2811
2890
  }
2812
2891
  function getInputsCoin(inputs) {
2813
- return getInputsByType(inputs, import_transactions11.InputType.Coin);
2892
+ return getInputsByType(inputs, import_transactions12.InputType.Coin);
2814
2893
  }
2815
2894
  function getInputsMessage(inputs) {
2816
- return getInputsByType(inputs, import_transactions11.InputType.Message);
2895
+ return getInputsByType(inputs, import_transactions12.InputType.Message);
2817
2896
  }
2818
2897
  function getInputsCoinAndMessage(inputs) {
2819
- return getInputsByTypes(inputs, [import_transactions11.InputType.Coin, import_transactions11.InputType.Message]);
2898
+ return getInputsByTypes(inputs, [import_transactions12.InputType.Coin, import_transactions12.InputType.Message]);
2820
2899
  }
2821
2900
  function getInputsContract(inputs) {
2822
- return getInputsByType(inputs, import_transactions11.InputType.Contract);
2901
+ return getInputsByType(inputs, import_transactions12.InputType.Contract);
2823
2902
  }
2824
2903
  function getInputFromAssetId(inputs, assetId) {
2825
2904
  const coinInputs = getInputsCoin(inputs);
@@ -2838,43 +2917,43 @@ function getInputContractFromIndex(inputs, inputIndex) {
2838
2917
  if (!contractInput) {
2839
2918
  return void 0;
2840
2919
  }
2841
- if (contractInput.type !== import_transactions11.InputType.Contract) {
2842
- throw new import_errors9.FuelError(
2843
- import_errors9.ErrorCode.INVALID_TRANSACTION_INPUT,
2920
+ if (contractInput.type !== import_transactions12.InputType.Contract) {
2921
+ throw new import_errors10.FuelError(
2922
+ import_errors10.ErrorCode.INVALID_TRANSACTION_INPUT,
2844
2923
  `Contract input should be of type 'contract'.`
2845
2924
  );
2846
2925
  }
2847
2926
  return contractInput;
2848
2927
  }
2849
2928
  function getInputAccountAddress(input) {
2850
- if (input.type === import_transactions11.InputType.Coin) {
2929
+ if (input.type === import_transactions12.InputType.Coin) {
2851
2930
  return input.owner.toString();
2852
2931
  }
2853
- if (input.type === import_transactions11.InputType.Message) {
2932
+ if (input.type === import_transactions12.InputType.Message) {
2854
2933
  return input.recipient.toString();
2855
2934
  }
2856
2935
  return "";
2857
2936
  }
2858
2937
 
2859
2938
  // src/providers/transaction-summary/output.ts
2860
- var import_transactions12 = require("@fuel-ts/transactions");
2939
+ var import_transactions13 = require("@fuel-ts/transactions");
2861
2940
  function getOutputsByType(outputs, type) {
2862
2941
  return outputs.filter((o) => o.type === type);
2863
2942
  }
2864
2943
  function getOutputsContractCreated(outputs) {
2865
- return getOutputsByType(outputs, import_transactions12.OutputType.ContractCreated);
2944
+ return getOutputsByType(outputs, import_transactions13.OutputType.ContractCreated);
2866
2945
  }
2867
2946
  function getOutputsCoin(outputs) {
2868
- return getOutputsByType(outputs, import_transactions12.OutputType.Coin);
2947
+ return getOutputsByType(outputs, import_transactions13.OutputType.Coin);
2869
2948
  }
2870
2949
  function getOutputsChange(outputs) {
2871
- return getOutputsByType(outputs, import_transactions12.OutputType.Change);
2950
+ return getOutputsByType(outputs, import_transactions13.OutputType.Change);
2872
2951
  }
2873
2952
  function getOutputsContract(outputs) {
2874
- return getOutputsByType(outputs, import_transactions12.OutputType.Contract);
2953
+ return getOutputsByType(outputs, import_transactions13.OutputType.Contract);
2875
2954
  }
2876
2955
  function getOutputsVariable(outputs) {
2877
- return getOutputsByType(outputs, import_transactions12.OutputType.Variable);
2956
+ return getOutputsByType(outputs, import_transactions13.OutputType.Variable);
2878
2957
  }
2879
2958
 
2880
2959
  // src/providers/transaction-summary/types.ts
@@ -2921,15 +3000,15 @@ function getReceiptsByType(receipts, type) {
2921
3000
  }
2922
3001
  function getTransactionTypeName(transactionType) {
2923
3002
  switch (transactionType) {
2924
- case import_transactions13.TransactionType.Mint:
3003
+ case import_transactions14.TransactionType.Mint:
2925
3004
  return "Mint" /* Mint */;
2926
- case import_transactions13.TransactionType.Create:
3005
+ case import_transactions14.TransactionType.Create:
2927
3006
  return "Create" /* Create */;
2928
- case import_transactions13.TransactionType.Script:
3007
+ case import_transactions14.TransactionType.Script:
2929
3008
  return "Script" /* Script */;
2930
3009
  default:
2931
- throw new import_errors10.FuelError(
2932
- import_errors10.ErrorCode.INVALID_TRANSACTION_TYPE,
3010
+ throw new import_errors11.FuelError(
3011
+ import_errors11.ErrorCode.INVALID_TRANSACTION_TYPE,
2933
3012
  `Invalid transaction type: ${transactionType}.`
2934
3013
  );
2935
3014
  }
@@ -2951,10 +3030,10 @@ function hasSameAssetId(a) {
2951
3030
  return (b) => a.assetId === b.assetId;
2952
3031
  }
2953
3032
  function getReceiptsCall(receipts) {
2954
- return getReceiptsByType(receipts, import_transactions13.ReceiptType.Call);
3033
+ return getReceiptsByType(receipts, import_transactions14.ReceiptType.Call);
2955
3034
  }
2956
3035
  function getReceiptsMessageOut(receipts) {
2957
- return getReceiptsByType(receipts, import_transactions13.ReceiptType.MessageOut);
3036
+ return getReceiptsByType(receipts, import_transactions14.ReceiptType.MessageOut);
2958
3037
  }
2959
3038
  var mergeAssets = (op1, op2) => {
2960
3039
  const assets1 = op1.assetsSent || [];
@@ -2967,7 +3046,7 @@ var mergeAssets = (op1, op2) => {
2967
3046
  if (!matchingAsset) {
2968
3047
  return asset1;
2969
3048
  }
2970
- const mergedAmount = (0, import_math12.bn)(asset1.amount).add(matchingAsset.amount);
3049
+ const mergedAmount = (0, import_math13.bn)(asset1.amount).add(matchingAsset.amount);
2971
3050
  return { ...asset1, amount: mergedAmount };
2972
3051
  });
2973
3052
  return mergedAssets.concat(filteredAssets);
@@ -2993,7 +3072,7 @@ function addOperation(operations, toAdd) {
2993
3072
  return allOperations;
2994
3073
  }
2995
3074
  function getReceiptsTransferOut(receipts) {
2996
- return getReceiptsByType(receipts, import_transactions13.ReceiptType.TransferOut);
3075
+ return getReceiptsByType(receipts, import_transactions14.ReceiptType.TransferOut);
2997
3076
  }
2998
3077
  function getWithdrawFromFuelOperations({
2999
3078
  inputs,
@@ -3096,7 +3175,7 @@ function extractTransferOperationFromReceipt(receipt, contractInputs, changeOutp
3096
3175
  const { to: toAddress, assetId, amount } = receipt;
3097
3176
  let { from: fromAddress } = receipt;
3098
3177
  const toType = contractInputs.some((input) => input.contractID === toAddress) ? 0 /* contract */ : 1 /* account */;
3099
- if (import_configs10.ZeroBytes32 === fromAddress) {
3178
+ if (import_configs11.ZeroBytes32 === fromAddress) {
3100
3179
  const change = changeOutputs.find((output) => output.assetId === assetId);
3101
3180
  fromAddress = change?.to || fromAddress;
3102
3181
  }
@@ -3153,11 +3232,11 @@ function getTransferOperations({
3153
3232
  });
3154
3233
  const transferReceipts = getReceiptsByType(
3155
3234
  receipts,
3156
- import_transactions13.ReceiptType.Transfer
3235
+ import_transactions14.ReceiptType.Transfer
3157
3236
  );
3158
3237
  const transferOutReceipts = getReceiptsByType(
3159
3238
  receipts,
3160
- import_transactions13.ReceiptType.TransferOut
3239
+ import_transactions14.ReceiptType.TransferOut
3161
3240
  );
3162
3241
  [...transferReceipts, ...transferOutReceipts].forEach((receipt) => {
3163
3242
  const operation = extractTransferOperationFromReceipt(receipt, contractInputs, changeOutputs);
@@ -3242,17 +3321,17 @@ function getOperations({
3242
3321
  }
3243
3322
 
3244
3323
  // src/providers/transaction-summary/receipt.ts
3245
- var import_transactions14 = require("@fuel-ts/transactions");
3324
+ var import_transactions15 = require("@fuel-ts/transactions");
3246
3325
  var processGqlReceipt = (gqlReceipt) => {
3247
3326
  const receipt = assembleReceiptByType(gqlReceipt);
3248
3327
  switch (receipt.type) {
3249
- case import_transactions14.ReceiptType.ReturnData: {
3328
+ case import_transactions15.ReceiptType.ReturnData: {
3250
3329
  return {
3251
3330
  ...receipt,
3252
3331
  data: gqlReceipt.data || "0x"
3253
3332
  };
3254
3333
  }
3255
- case import_transactions14.ReceiptType.LogData: {
3334
+ case import_transactions15.ReceiptType.LogData: {
3256
3335
  return {
3257
3336
  ...receipt,
3258
3337
  data: gqlReceipt.data || "0x"
@@ -3265,7 +3344,7 @@ var processGqlReceipt = (gqlReceipt) => {
3265
3344
  var extractMintedAssetsFromReceipts = (receipts) => {
3266
3345
  const mintedAssets = [];
3267
3346
  receipts.forEach((receipt) => {
3268
- if (receipt.type === import_transactions14.ReceiptType.Mint) {
3347
+ if (receipt.type === import_transactions15.ReceiptType.Mint) {
3269
3348
  mintedAssets.push({
3270
3349
  subId: receipt.subId,
3271
3350
  contractId: receipt.contractId,
@@ -3279,7 +3358,7 @@ var extractMintedAssetsFromReceipts = (receipts) => {
3279
3358
  var extractBurnedAssetsFromReceipts = (receipts) => {
3280
3359
  const burnedAssets = [];
3281
3360
  receipts.forEach((receipt) => {
3282
- if (receipt.type === import_transactions14.ReceiptType.Burn) {
3361
+ if (receipt.type === import_transactions15.ReceiptType.Burn) {
3283
3362
  burnedAssets.push({
3284
3363
  subId: receipt.subId,
3285
3364
  contractId: receipt.contractId,
@@ -3292,7 +3371,7 @@ var extractBurnedAssetsFromReceipts = (receipts) => {
3292
3371
  };
3293
3372
 
3294
3373
  // src/providers/transaction-summary/status.ts
3295
- var import_errors11 = require("@fuel-ts/errors");
3374
+ var import_errors12 = require("@fuel-ts/errors");
3296
3375
  var getTransactionStatusName = (gqlStatus) => {
3297
3376
  switch (gqlStatus) {
3298
3377
  case "FailureStatus":
@@ -3304,8 +3383,8 @@ var getTransactionStatusName = (gqlStatus) => {
3304
3383
  case "SqueezedOutStatus":
3305
3384
  return "squeezedout" /* squeezedout */;
3306
3385
  default:
3307
- throw new import_errors11.FuelError(
3308
- import_errors11.ErrorCode.INVALID_TRANSACTION_STATUS,
3386
+ throw new import_errors12.FuelError(
3387
+ import_errors12.ErrorCode.INVALID_TRANSACTION_STATUS,
3309
3388
  `Invalid transaction status: ${gqlStatus}.`
3310
3389
  );
3311
3390
  }
@@ -3417,13 +3496,13 @@ function assembleTransactionSummary(params) {
3417
3496
  }
3418
3497
 
3419
3498
  // src/providers/transaction-response/getDecodedLogs.ts
3420
- var import_abi_coder3 = require("@fuel-ts/abi-coder");
3421
- var import_transactions15 = require("@fuel-ts/transactions");
3499
+ var import_abi_coder5 = require("@fuel-ts/abi-coder");
3500
+ var import_transactions16 = require("@fuel-ts/transactions");
3422
3501
  function getDecodedLogs(receipts, mainAbi, externalAbis = {}) {
3423
3502
  return receipts.reduce((logs, receipt) => {
3424
- if (receipt.type === import_transactions15.ReceiptType.LogData || receipt.type === import_transactions15.ReceiptType.Log) {
3425
- const interfaceToUse = new import_abi_coder3.Interface(externalAbis[receipt.id] || mainAbi);
3426
- const data = receipt.type === import_transactions15.ReceiptType.Log ? new import_abi_coder3.BigNumberCoder("u64").encode(receipt.val0) : receipt.data;
3503
+ if (receipt.type === import_transactions16.ReceiptType.LogData || receipt.type === import_transactions16.ReceiptType.Log) {
3504
+ const interfaceToUse = new import_abi_coder5.Interface(externalAbis[receipt.id] || mainAbi);
3505
+ const data = receipt.type === import_transactions16.ReceiptType.Log ? new import_abi_coder5.BigNumberCoder("u64").encode(receipt.val0) : receipt.data;
3427
3506
  const [decodedLog] = interfaceToUse.decodeLog(data, receipt.val1.toNumber());
3428
3507
  logs.push(decodedLog);
3429
3508
  }
@@ -3438,7 +3517,7 @@ var TransactionResponse = class {
3438
3517
  /** Current provider */
3439
3518
  provider;
3440
3519
  /** Gas used on the transaction */
3441
- gasUsed = (0, import_math13.bn)(0);
3520
+ gasUsed = (0, import_math14.bn)(0);
3442
3521
  /** The graphql Transaction with receipts object. */
3443
3522
  gqlTransaction;
3444
3523
  abis;
@@ -3496,7 +3575,7 @@ var TransactionResponse = class {
3496
3575
  * @returns The decoded transaction.
3497
3576
  */
3498
3577
  decodeTransaction(transactionWithReceipts) {
3499
- return new import_transactions16.TransactionCoder().decode(
3578
+ return new import_transactions17.TransactionCoder().decode(
3500
3579
  (0, import_utils21.arrayify)(transactionWithReceipts.rawPayload),
3501
3580
  0
3502
3581
  )?.[0];
@@ -3543,8 +3622,8 @@ var TransactionResponse = class {
3543
3622
  });
3544
3623
  for await (const { statusChange } of subscription) {
3545
3624
  if (statusChange.type === "SqueezedOutStatus") {
3546
- throw new import_errors12.FuelError(
3547
- import_errors12.ErrorCode.TRANSACTION_SQUEEZED_OUT,
3625
+ throw new import_errors13.FuelError(
3626
+ import_errors13.ErrorCode.TRANSACTION_SQUEEZED_OUT,
3548
3627
  `Transaction Squeezed Out with reason: ${statusChange.reason}`
3549
3628
  );
3550
3629
  }
@@ -3566,14 +3645,26 @@ var TransactionResponse = class {
3566
3645
  gqlTransaction: this.gqlTransaction,
3567
3646
  ...transactionSummary
3568
3647
  };
3648
+ let logs = [];
3569
3649
  if (this.abis) {
3570
- const logs = getDecodedLogs(
3650
+ logs = getDecodedLogs(
3571
3651
  transactionSummary.receipts,
3572
3652
  this.abis.main,
3573
3653
  this.abis.otherContractsAbis
3574
3654
  );
3575
3655
  transactionResult.logs = logs;
3576
3656
  }
3657
+ if (transactionResult.isStatusFailure) {
3658
+ const {
3659
+ receipts,
3660
+ gqlTransaction: { status }
3661
+ } = transactionResult;
3662
+ throw extractTxError({
3663
+ receipts,
3664
+ status,
3665
+ logs
3666
+ });
3667
+ }
3577
3668
  return transactionResult;
3578
3669
  }
3579
3670
  /**
@@ -3582,14 +3673,7 @@ var TransactionResponse = class {
3582
3673
  * @param contractsAbiMap - The contracts ABI map.
3583
3674
  */
3584
3675
  async wait(contractsAbiMap) {
3585
- const result = await this.waitForResult(contractsAbiMap);
3586
- if (result.isStatusFailure) {
3587
- throw new import_errors12.FuelError(
3588
- import_errors12.ErrorCode.TRANSACTION_FAILED,
3589
- `Transaction failed: ${result.gqlTransaction.status.reason}`
3590
- );
3591
- }
3592
- return result;
3676
+ return this.waitForResult(contractsAbiMap);
3593
3677
  }
3594
3678
  };
3595
3679
 
@@ -3651,29 +3735,29 @@ var processGqlChain = (chain) => {
3651
3735
  const { contractParams, feeParams, predicateParams, scriptParams, txParams, gasCosts } = consensusParameters;
3652
3736
  return {
3653
3737
  name,
3654
- baseChainHeight: (0, import_math14.bn)(daHeight),
3738
+ baseChainHeight: (0, import_math15.bn)(daHeight),
3655
3739
  consensusParameters: {
3656
- contractMaxSize: (0, import_math14.bn)(contractParams.contractMaxSize),
3657
- maxInputs: (0, import_math14.bn)(txParams.maxInputs),
3658
- maxOutputs: (0, import_math14.bn)(txParams.maxOutputs),
3659
- maxWitnesses: (0, import_math14.bn)(txParams.maxWitnesses),
3660
- maxGasPerTx: (0, import_math14.bn)(txParams.maxGasPerTx),
3661
- maxScriptLength: (0, import_math14.bn)(scriptParams.maxScriptLength),
3662
- maxScriptDataLength: (0, import_math14.bn)(scriptParams.maxScriptDataLength),
3663
- maxStorageSlots: (0, import_math14.bn)(contractParams.maxStorageSlots),
3664
- maxPredicateLength: (0, import_math14.bn)(predicateParams.maxPredicateLength),
3665
- maxPredicateDataLength: (0, import_math14.bn)(predicateParams.maxPredicateDataLength),
3666
- maxGasPerPredicate: (0, import_math14.bn)(predicateParams.maxGasPerPredicate),
3667
- gasPriceFactor: (0, import_math14.bn)(feeParams.gasPriceFactor),
3668
- gasPerByte: (0, import_math14.bn)(feeParams.gasPerByte),
3669
- maxMessageDataLength: (0, import_math14.bn)(predicateParams.maxMessageDataLength),
3670
- chainId: (0, import_math14.bn)(consensusParameters.chainId),
3740
+ contractMaxSize: (0, import_math15.bn)(contractParams.contractMaxSize),
3741
+ maxInputs: (0, import_math15.bn)(txParams.maxInputs),
3742
+ maxOutputs: (0, import_math15.bn)(txParams.maxOutputs),
3743
+ maxWitnesses: (0, import_math15.bn)(txParams.maxWitnesses),
3744
+ maxGasPerTx: (0, import_math15.bn)(txParams.maxGasPerTx),
3745
+ maxScriptLength: (0, import_math15.bn)(scriptParams.maxScriptLength),
3746
+ maxScriptDataLength: (0, import_math15.bn)(scriptParams.maxScriptDataLength),
3747
+ maxStorageSlots: (0, import_math15.bn)(contractParams.maxStorageSlots),
3748
+ maxPredicateLength: (0, import_math15.bn)(predicateParams.maxPredicateLength),
3749
+ maxPredicateDataLength: (0, import_math15.bn)(predicateParams.maxPredicateDataLength),
3750
+ maxGasPerPredicate: (0, import_math15.bn)(predicateParams.maxGasPerPredicate),
3751
+ gasPriceFactor: (0, import_math15.bn)(feeParams.gasPriceFactor),
3752
+ gasPerByte: (0, import_math15.bn)(feeParams.gasPerByte),
3753
+ maxMessageDataLength: (0, import_math15.bn)(predicateParams.maxMessageDataLength),
3754
+ chainId: (0, import_math15.bn)(consensusParameters.chainId),
3671
3755
  gasCosts
3672
3756
  },
3673
3757
  gasCosts,
3674
3758
  latestBlock: {
3675
3759
  id: latestBlock.id,
3676
- height: (0, import_math14.bn)(latestBlock.header.height),
3760
+ height: (0, import_math15.bn)(latestBlock.header.height),
3677
3761
  time: latestBlock.header.time,
3678
3762
  transactions: latestBlock.transactions.map((i) => ({
3679
3763
  id: i.id
@@ -3743,8 +3827,8 @@ var _Provider = class {
3743
3827
  getChain() {
3744
3828
  const chain = _Provider.chainInfoCache[this.url];
3745
3829
  if (!chain) {
3746
- throw new import_errors13.FuelError(
3747
- import_errors13.ErrorCode.CHAIN_INFO_CACHE_EMPTY,
3830
+ throw new import_errors14.FuelError(
3831
+ import_errors14.ErrorCode.CHAIN_INFO_CACHE_EMPTY,
3748
3832
  "Chain info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
3749
3833
  );
3750
3834
  }
@@ -3756,8 +3840,8 @@ var _Provider = class {
3756
3840
  getNode() {
3757
3841
  const node = _Provider.nodeInfoCache[this.url];
3758
3842
  if (!node) {
3759
- throw new import_errors13.FuelError(
3760
- import_errors13.ErrorCode.NODE_INFO_CACHE_EMPTY,
3843
+ throw new import_errors14.FuelError(
3844
+ import_errors14.ErrorCode.NODE_INFO_CACHE_EMPTY,
3761
3845
  "Node info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
3762
3846
  );
3763
3847
  }
@@ -3804,8 +3888,8 @@ var _Provider = class {
3804
3888
  static ensureClientVersionIsSupported(nodeInfo) {
3805
3889
  const { isMajorSupported, isMinorSupported, supportedVersion } = (0, import_versions.checkFuelCoreVersionCompatibility)(nodeInfo.nodeVersion);
3806
3890
  if (!isMajorSupported || !isMinorSupported) {
3807
- throw new import_errors13.FuelError(
3808
- import_errors13.FuelError.CODES.UNSUPPORTED_FUEL_CLIENT_VERSION,
3891
+ throw new import_errors14.FuelError(
3892
+ import_errors14.FuelError.CODES.UNSUPPORTED_FUEL_CLIENT_VERSION,
3809
3893
  `Fuel client version: ${nodeInfo.nodeVersion}, Supported version: ${supportedVersion}`
3810
3894
  );
3811
3895
  }
@@ -3868,7 +3952,7 @@ var _Provider = class {
3868
3952
  */
3869
3953
  async getBlockNumber() {
3870
3954
  const { chain } = await this.operations.getChain();
3871
- return (0, import_math14.bn)(chain.latestBlock.header.height, 10);
3955
+ return (0, import_math15.bn)(chain.latestBlock.header.height, 10);
3872
3956
  }
3873
3957
  /**
3874
3958
  * Returns the chain information.
@@ -3878,9 +3962,9 @@ var _Provider = class {
3878
3962
  async fetchNode() {
3879
3963
  const { nodeInfo } = await this.operations.getNodeInfo();
3880
3964
  const processedNodeInfo = {
3881
- maxDepth: (0, import_math14.bn)(nodeInfo.maxDepth),
3882
- maxTx: (0, import_math14.bn)(nodeInfo.maxTx),
3883
- minGasPrice: (0, import_math14.bn)(nodeInfo.minGasPrice),
3965
+ maxDepth: (0, import_math15.bn)(nodeInfo.maxDepth),
3966
+ maxTx: (0, import_math15.bn)(nodeInfo.maxTx),
3967
+ minGasPrice: (0, import_math15.bn)(nodeInfo.minGasPrice),
3884
3968
  nodeVersion: nodeInfo.nodeVersion,
3885
3969
  utxoValidation: nodeInfo.utxoValidation,
3886
3970
  vmBacktrace: nodeInfo.vmBacktrace,
@@ -3926,17 +4010,17 @@ var _Provider = class {
3926
4010
  if (estimateTxDependencies) {
3927
4011
  await this.estimateTxDependencies(transactionRequest);
3928
4012
  }
3929
- const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
4013
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
3930
4014
  let abis;
3931
- if (transactionRequest.type === import_transactions17.TransactionType.Script) {
4015
+ if (transactionRequest.type === import_transactions18.TransactionType.Script) {
3932
4016
  abis = transactionRequest.abis;
3933
4017
  }
3934
4018
  if (awaitExecution) {
3935
4019
  const subscription = this.operations.submitAndAwait({ encodedTransaction });
3936
4020
  for await (const { submitAndAwait } of subscription) {
3937
4021
  if (submitAndAwait.type === "SqueezedOutStatus") {
3938
- throw new import_errors13.FuelError(
3939
- import_errors13.ErrorCode.TRANSACTION_SQUEEZED_OUT,
4022
+ throw new import_errors14.FuelError(
4023
+ import_errors14.ErrorCode.TRANSACTION_SQUEEZED_OUT,
3940
4024
  `Transaction Squeezed Out with reason: ${submitAndAwait.reason}`
3941
4025
  );
3942
4026
  }
@@ -3969,7 +4053,7 @@ var _Provider = class {
3969
4053
  if (estimateTxDependencies) {
3970
4054
  return this.estimateTxDependencies(transactionRequest);
3971
4055
  }
3972
- const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
4056
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
3973
4057
  const { dryRun: gqlReceipts } = await this.operations.dryRun({
3974
4058
  encodedTransaction,
3975
4059
  utxoValidation: utxoValidation || false
@@ -3988,13 +4072,13 @@ var _Provider = class {
3988
4072
  async estimatePredicates(transactionRequest) {
3989
4073
  const shouldEstimatePredicates = Boolean(
3990
4074
  transactionRequest.inputs.find(
3991
- (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()
4075
+ (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()
3992
4076
  )
3993
4077
  );
3994
4078
  if (!shouldEstimatePredicates) {
3995
4079
  return transactionRequest;
3996
4080
  }
3997
- const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
4081
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
3998
4082
  const response = await this.operations.estimatePredicates({
3999
4083
  encodedTransaction
4000
4084
  });
@@ -4003,7 +4087,7 @@ var _Provider = class {
4003
4087
  } = response;
4004
4088
  if (inputs) {
4005
4089
  inputs.forEach((input, index) => {
4006
- if ("predicateGasUsed" in input && (0, import_math14.bn)(input.predicateGasUsed).gt(0)) {
4090
+ if ("predicateGasUsed" in input && (0, import_math15.bn)(input.predicateGasUsed).gt(0)) {
4007
4091
  transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
4008
4092
  }
4009
4093
  });
@@ -4024,7 +4108,7 @@ var _Provider = class {
4024
4108
  * @returns A promise.
4025
4109
  */
4026
4110
  async estimateTxDependencies(transactionRequest) {
4027
- if (transactionRequest.type === import_transactions17.TransactionType.Create) {
4111
+ if (transactionRequest.type === import_transactions18.TransactionType.Create) {
4028
4112
  return {
4029
4113
  receipts: [],
4030
4114
  outputVariables: 0,
@@ -4037,7 +4121,7 @@ var _Provider = class {
4037
4121
  let outputVariables = 0;
4038
4122
  for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
4039
4123
  const { dryRun: gqlReceipts } = await this.operations.dryRun({
4040
- encodedTransaction: (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes()),
4124
+ encodedTransaction: (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes()),
4041
4125
  utxoValidation: false
4042
4126
  });
4043
4127
  receipts = gqlReceipts.map(processGqlReceipt);
@@ -4060,6 +4144,36 @@ var _Provider = class {
4060
4144
  missingContractIds
4061
4145
  };
4062
4146
  }
4147
+ /**
4148
+ * Estimates the transaction gas and fee based on the provided transaction request.
4149
+ * @param transactionRequest - The transaction request object.
4150
+ * @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
4151
+ */
4152
+ estimateTxGasAndFee(params) {
4153
+ const { transactionRequest } = params;
4154
+ const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
4155
+ const chainInfo = this.getChain();
4156
+ const gasPrice = transactionRequest.gasPrice.eq(0) ? minGasPrice : transactionRequest.gasPrice;
4157
+ transactionRequest.gasPrice = gasPrice;
4158
+ const minGas = transactionRequest.calculateMinGas(chainInfo);
4159
+ const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4160
+ if (transactionRequest.type === import_transactions18.TransactionType.Script) {
4161
+ if (transactionRequest.gasLimit.eq(0)) {
4162
+ transactionRequest.gasLimit = minGas;
4163
+ transactionRequest.gasLimit = maxGasPerTx.sub(
4164
+ transactionRequest.calculateMaxGas(chainInfo, minGas)
4165
+ );
4166
+ }
4167
+ }
4168
+ const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
4169
+ const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4170
+ return {
4171
+ minGas,
4172
+ minFee,
4173
+ maxGas,
4174
+ maxFee
4175
+ };
4176
+ }
4063
4177
  /**
4064
4178
  * Executes a signed transaction without applying the states changes
4065
4179
  * on the chain.
@@ -4075,7 +4189,7 @@ var _Provider = class {
4075
4189
  if (estimateTxDependencies) {
4076
4190
  return this.estimateTxDependencies(transactionRequest);
4077
4191
  }
4078
- const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
4192
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
4079
4193
  const { dryRun: gqlReceipts } = await this.operations.dryRun({
4080
4194
  encodedTransaction,
4081
4195
  utxoValidation: true
@@ -4107,17 +4221,16 @@ var _Provider = class {
4107
4221
  signatureCallback
4108
4222
  } = {}) {
4109
4223
  const txRequestClone = (0, import_ramda3.clone)(transactionRequestify(transactionRequestLike));
4110
- const chainInfo = this.getChain();
4111
- const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
4112
- const gasPrice = (0, import_math14.max)(txRequestClone.gasPrice, minGasPrice);
4113
- const isScriptTransaction = txRequestClone.type === import_transactions17.TransactionType.Script;
4224
+ const { minGasPrice } = this.getGasConfig();
4225
+ const setGasPrice = (0, import_math15.max)(txRequestClone.gasPrice, minGasPrice);
4226
+ const isScriptTransaction = txRequestClone.type === import_transactions18.TransactionType.Script;
4114
4227
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
4115
4228
  const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
4116
4229
  txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
4230
+ if (isScriptTransaction) {
4231
+ txRequestClone.gasLimit = (0, import_math15.bn)(0);
4232
+ }
4117
4233
  if (estimatePredicates) {
4118
- if (isScriptTransaction) {
4119
- txRequestClone.gasLimit = (0, import_math14.bn)(0);
4120
- }
4121
4234
  if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
4122
4235
  resourcesOwner.populateTransactionPredicateData(txRequestClone);
4123
4236
  }
@@ -4126,36 +4239,34 @@ var _Provider = class {
4126
4239
  if (signatureCallback && isScriptTransaction) {
4127
4240
  await signatureCallback(txRequestClone);
4128
4241
  }
4129
- const minGas = txRequestClone.calculateMinGas(chainInfo);
4130
- const maxGas = txRequestClone.calculateMaxGas(chainInfo, minGas);
4242
+ let { maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
4243
+ transactionRequest: txRequestClone
4244
+ });
4131
4245
  let receipts = [];
4132
4246
  let missingContractIds = [];
4133
4247
  let outputVariables = 0;
4248
+ let gasUsed = (0, import_math15.bn)(0);
4134
4249
  if (isScriptTransaction && estimateTxDependencies) {
4135
- txRequestClone.gasPrice = (0, import_math14.bn)(0);
4136
- txRequestClone.gasLimit = (0, import_math14.bn)(maxGasPerTx.sub(maxGas).toNumber() * 0.9);
4250
+ txRequestClone.gasPrice = (0, import_math15.bn)(0);
4137
4251
  const result = await this.estimateTxDependencies(txRequestClone);
4138
4252
  receipts = result.receipts;
4139
4253
  outputVariables = result.outputVariables;
4140
4254
  missingContractIds = result.missingContractIds;
4255
+ gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
4256
+ txRequestClone.gasLimit = gasUsed;
4257
+ txRequestClone.gasPrice = setGasPrice;
4258
+ ({ maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
4259
+ transactionRequest: txRequestClone
4260
+ }));
4141
4261
  }
4142
- const gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : minGas;
4143
- const usedFee = calculatePriceWithFactor(
4144
- gasUsed,
4145
- gasPrice,
4146
- gasPriceFactor
4147
- ).normalizeZeroToOne();
4148
- const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4149
- const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4150
4262
  return {
4151
4263
  requiredQuantities: allQuantities,
4152
4264
  receipts,
4153
4265
  gasUsed,
4154
4266
  minGasPrice,
4155
- gasPrice,
4267
+ gasPrice: setGasPrice,
4156
4268
  minGas,
4157
4269
  maxGas,
4158
- usedFee,
4159
4270
  minFee,
4160
4271
  maxFee,
4161
4272
  estimatedInputs: txRequestClone.inputs,
@@ -4189,17 +4300,17 @@ var _Provider = class {
4189
4300
  const result = await this.operations.getCoins({
4190
4301
  first: 10,
4191
4302
  ...paginationArgs,
4192
- filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils22.hexlify)(assetId) }
4303
+ filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils23.hexlify)(assetId) }
4193
4304
  });
4194
4305
  const coins = result.coins.edges.map((edge) => edge.node);
4195
4306
  return coins.map((coin) => ({
4196
4307
  id: coin.utxoId,
4197
4308
  assetId: coin.assetId,
4198
- amount: (0, import_math14.bn)(coin.amount),
4309
+ amount: (0, import_math15.bn)(coin.amount),
4199
4310
  owner: import_address3.Address.fromAddressOrString(coin.owner),
4200
- maturity: (0, import_math14.bn)(coin.maturity).toNumber(),
4201
- blockCreated: (0, import_math14.bn)(coin.blockCreated),
4202
- txCreatedIdx: (0, import_math14.bn)(coin.txCreatedIdx)
4311
+ maturity: (0, import_math15.bn)(coin.maturity).toNumber(),
4312
+ blockCreated: (0, import_math15.bn)(coin.blockCreated),
4313
+ txCreatedIdx: (0, import_math15.bn)(coin.txCreatedIdx)
4203
4314
  }));
4204
4315
  }
4205
4316
  /**
@@ -4213,19 +4324,19 @@ var _Provider = class {
4213
4324
  async getResourcesToSpend(owner, quantities, excludedIds) {
4214
4325
  const ownerAddress = import_address3.Address.fromAddressOrString(owner);
4215
4326
  const excludeInput = {
4216
- messages: excludedIds?.messages?.map((nonce) => (0, import_utils22.hexlify)(nonce)) || [],
4217
- utxos: excludedIds?.utxos?.map((id) => (0, import_utils22.hexlify)(id)) || []
4327
+ messages: excludedIds?.messages?.map((nonce) => (0, import_utils23.hexlify)(nonce)) || [],
4328
+ utxos: excludedIds?.utxos?.map((id) => (0, import_utils23.hexlify)(id)) || []
4218
4329
  };
4219
4330
  if (this.cache) {
4220
4331
  const uniqueUtxos = new Set(
4221
- excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0, import_utils22.hexlify)(id)))
4332
+ excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0, import_utils23.hexlify)(id)))
4222
4333
  );
4223
4334
  excludeInput.utxos = Array.from(uniqueUtxos);
4224
4335
  }
4225
4336
  const coinsQuery = {
4226
4337
  owner: ownerAddress.toB256(),
4227
4338
  queryPerAsset: quantities.map(coinQuantityfy).map(({ assetId, amount, max: maxPerAsset }) => ({
4228
- assetId: (0, import_utils22.hexlify)(assetId),
4339
+ assetId: (0, import_utils23.hexlify)(assetId),
4229
4340
  amount: amount.toString(10),
4230
4341
  max: maxPerAsset ? maxPerAsset.toString(10) : void 0
4231
4342
  })),
@@ -4236,9 +4347,9 @@ var _Provider = class {
4236
4347
  switch (coin.__typename) {
4237
4348
  case "MessageCoin":
4238
4349
  return {
4239
- amount: (0, import_math14.bn)(coin.amount),
4350
+ amount: (0, import_math15.bn)(coin.amount),
4240
4351
  assetId: coin.assetId,
4241
- daHeight: (0, import_math14.bn)(coin.daHeight),
4352
+ daHeight: (0, import_math15.bn)(coin.daHeight),
4242
4353
  sender: import_address3.Address.fromAddressOrString(coin.sender),
4243
4354
  recipient: import_address3.Address.fromAddressOrString(coin.recipient),
4244
4355
  nonce: coin.nonce
@@ -4246,12 +4357,12 @@ var _Provider = class {
4246
4357
  case "Coin":
4247
4358
  return {
4248
4359
  id: coin.utxoId,
4249
- amount: (0, import_math14.bn)(coin.amount),
4360
+ amount: (0, import_math15.bn)(coin.amount),
4250
4361
  assetId: coin.assetId,
4251
4362
  owner: import_address3.Address.fromAddressOrString(coin.owner),
4252
- maturity: (0, import_math14.bn)(coin.maturity).toNumber(),
4253
- blockCreated: (0, import_math14.bn)(coin.blockCreated),
4254
- txCreatedIdx: (0, import_math14.bn)(coin.txCreatedIdx)
4363
+ maturity: (0, import_math15.bn)(coin.maturity).toNumber(),
4364
+ blockCreated: (0, import_math15.bn)(coin.blockCreated),
4365
+ txCreatedIdx: (0, import_math15.bn)(coin.txCreatedIdx)
4255
4366
  };
4256
4367
  default:
4257
4368
  return null;
@@ -4268,13 +4379,13 @@ var _Provider = class {
4268
4379
  async getBlock(idOrHeight) {
4269
4380
  let variables;
4270
4381
  if (typeof idOrHeight === "number") {
4271
- variables = { height: (0, import_math14.bn)(idOrHeight).toString(10) };
4382
+ variables = { height: (0, import_math15.bn)(idOrHeight).toString(10) };
4272
4383
  } else if (idOrHeight === "latest") {
4273
4384
  variables = { height: (await this.getBlockNumber()).toString(10) };
4274
4385
  } else if (idOrHeight.length === 66) {
4275
4386
  variables = { blockId: idOrHeight };
4276
4387
  } else {
4277
- variables = { blockId: (0, import_math14.bn)(idOrHeight).toString(10) };
4388
+ variables = { blockId: (0, import_math15.bn)(idOrHeight).toString(10) };
4278
4389
  }
4279
4390
  const { block } = await this.operations.getBlock(variables);
4280
4391
  if (!block) {
@@ -4282,7 +4393,7 @@ var _Provider = class {
4282
4393
  }
4283
4394
  return {
4284
4395
  id: block.id,
4285
- height: (0, import_math14.bn)(block.header.height),
4396
+ height: (0, import_math15.bn)(block.header.height),
4286
4397
  time: block.header.time,
4287
4398
  transactionIds: block.transactions.map((tx) => tx.id)
4288
4399
  };
@@ -4297,7 +4408,7 @@ var _Provider = class {
4297
4408
  const { blocks: fetchedData } = await this.operations.getBlocks(params);
4298
4409
  const blocks = fetchedData.edges.map(({ node: block }) => ({
4299
4410
  id: block.id,
4300
- height: (0, import_math14.bn)(block.header.height),
4411
+ height: (0, import_math15.bn)(block.header.height),
4301
4412
  time: block.header.time,
4302
4413
  transactionIds: block.transactions.map((tx) => tx.id)
4303
4414
  }));
@@ -4312,7 +4423,7 @@ var _Provider = class {
4312
4423
  async getBlockWithTransactions(idOrHeight) {
4313
4424
  let variables;
4314
4425
  if (typeof idOrHeight === "number") {
4315
- variables = { blockHeight: (0, import_math14.bn)(idOrHeight).toString(10) };
4426
+ variables = { blockHeight: (0, import_math15.bn)(idOrHeight).toString(10) };
4316
4427
  } else if (idOrHeight === "latest") {
4317
4428
  variables = { blockHeight: (await this.getBlockNumber()).toString() };
4318
4429
  } else {
@@ -4324,11 +4435,11 @@ var _Provider = class {
4324
4435
  }
4325
4436
  return {
4326
4437
  id: block.id,
4327
- height: (0, import_math14.bn)(block.header.height, 10),
4438
+ height: (0, import_math15.bn)(block.header.height, 10),
4328
4439
  time: block.header.time,
4329
4440
  transactionIds: block.transactions.map((tx) => tx.id),
4330
4441
  transactions: block.transactions.map(
4331
- (tx) => new import_transactions17.TransactionCoder().decode((0, import_utils22.arrayify)(tx.rawPayload), 0)?.[0]
4442
+ (tx) => new import_transactions18.TransactionCoder().decode((0, import_utils23.arrayify)(tx.rawPayload), 0)?.[0]
4332
4443
  )
4333
4444
  };
4334
4445
  }
@@ -4343,8 +4454,8 @@ var _Provider = class {
4343
4454
  if (!transaction) {
4344
4455
  return null;
4345
4456
  }
4346
- return new import_transactions17.TransactionCoder().decode(
4347
- (0, import_utils22.arrayify)(transaction.rawPayload),
4457
+ return new import_transactions18.TransactionCoder().decode(
4458
+ (0, import_utils23.arrayify)(transaction.rawPayload),
4348
4459
  0
4349
4460
  )?.[0];
4350
4461
  }
@@ -4371,9 +4482,9 @@ var _Provider = class {
4371
4482
  async getContractBalance(contractId, assetId) {
4372
4483
  const { contractBalance } = await this.operations.getContractBalance({
4373
4484
  contract: import_address3.Address.fromAddressOrString(contractId).toB256(),
4374
- asset: (0, import_utils22.hexlify)(assetId)
4485
+ asset: (0, import_utils23.hexlify)(assetId)
4375
4486
  });
4376
- return (0, import_math14.bn)(contractBalance.amount, 10);
4487
+ return (0, import_math15.bn)(contractBalance.amount, 10);
4377
4488
  }
4378
4489
  /**
4379
4490
  * Returns the balance for the given owner for the given asset ID.
@@ -4385,9 +4496,9 @@ var _Provider = class {
4385
4496
  async getBalance(owner, assetId) {
4386
4497
  const { balance } = await this.operations.getBalance({
4387
4498
  owner: import_address3.Address.fromAddressOrString(owner).toB256(),
4388
- assetId: (0, import_utils22.hexlify)(assetId)
4499
+ assetId: (0, import_utils23.hexlify)(assetId)
4389
4500
  });
4390
- return (0, import_math14.bn)(balance.amount, 10);
4501
+ return (0, import_math15.bn)(balance.amount, 10);
4391
4502
  }
4392
4503
  /**
4393
4504
  * Returns balances for the given owner.
@@ -4405,7 +4516,7 @@ var _Provider = class {
4405
4516
  const balances = result.balances.edges.map((edge) => edge.node);
4406
4517
  return balances.map((balance) => ({
4407
4518
  assetId: balance.assetId,
4408
- amount: (0, import_math14.bn)(balance.amount)
4519
+ amount: (0, import_math15.bn)(balance.amount)
4409
4520
  }));
4410
4521
  }
4411
4522
  /**
@@ -4423,19 +4534,19 @@ var _Provider = class {
4423
4534
  });
4424
4535
  const messages = result.messages.edges.map((edge) => edge.node);
4425
4536
  return messages.map((message) => ({
4426
- messageId: import_transactions17.InputMessageCoder.getMessageId({
4537
+ messageId: import_transactions18.InputMessageCoder.getMessageId({
4427
4538
  sender: message.sender,
4428
4539
  recipient: message.recipient,
4429
4540
  nonce: message.nonce,
4430
- amount: (0, import_math14.bn)(message.amount),
4541
+ amount: (0, import_math15.bn)(message.amount),
4431
4542
  data: message.data
4432
4543
  }),
4433
4544
  sender: import_address3.Address.fromAddressOrString(message.sender),
4434
4545
  recipient: import_address3.Address.fromAddressOrString(message.recipient),
4435
4546
  nonce: message.nonce,
4436
- amount: (0, import_math14.bn)(message.amount),
4437
- data: import_transactions17.InputMessageCoder.decodeData(message.data),
4438
- daHeight: (0, import_math14.bn)(message.daHeight)
4547
+ amount: (0, import_math15.bn)(message.amount),
4548
+ data: import_transactions18.InputMessageCoder.decodeData(message.data),
4549
+ daHeight: (0, import_math15.bn)(message.daHeight)
4439
4550
  }));
4440
4551
  }
4441
4552
  /**
@@ -4453,8 +4564,8 @@ var _Provider = class {
4453
4564
  nonce
4454
4565
  };
4455
4566
  if (commitBlockId && commitBlockHeight) {
4456
- throw new import_errors13.FuelError(
4457
- import_errors13.ErrorCode.INVALID_INPUT_PARAMETERS,
4567
+ throw new import_errors14.FuelError(
4568
+ import_errors14.ErrorCode.INVALID_INPUT_PARAMETERS,
4458
4569
  "commitBlockId and commitBlockHeight cannot be used together"
4459
4570
  );
4460
4571
  }
@@ -4488,41 +4599,41 @@ var _Provider = class {
4488
4599
  } = result.messageProof;
4489
4600
  return {
4490
4601
  messageProof: {
4491
- proofIndex: (0, import_math14.bn)(messageProof.proofIndex),
4602
+ proofIndex: (0, import_math15.bn)(messageProof.proofIndex),
4492
4603
  proofSet: messageProof.proofSet
4493
4604
  },
4494
4605
  blockProof: {
4495
- proofIndex: (0, import_math14.bn)(blockProof.proofIndex),
4606
+ proofIndex: (0, import_math15.bn)(blockProof.proofIndex),
4496
4607
  proofSet: blockProof.proofSet
4497
4608
  },
4498
4609
  messageBlockHeader: {
4499
4610
  id: messageBlockHeader.id,
4500
- daHeight: (0, import_math14.bn)(messageBlockHeader.daHeight),
4501
- transactionsCount: (0, import_math14.bn)(messageBlockHeader.transactionsCount),
4611
+ daHeight: (0, import_math15.bn)(messageBlockHeader.daHeight),
4612
+ transactionsCount: (0, import_math15.bn)(messageBlockHeader.transactionsCount),
4502
4613
  transactionsRoot: messageBlockHeader.transactionsRoot,
4503
- height: (0, import_math14.bn)(messageBlockHeader.height),
4614
+ height: (0, import_math15.bn)(messageBlockHeader.height),
4504
4615
  prevRoot: messageBlockHeader.prevRoot,
4505
4616
  time: messageBlockHeader.time,
4506
4617
  applicationHash: messageBlockHeader.applicationHash,
4507
4618
  messageReceiptRoot: messageBlockHeader.messageReceiptRoot,
4508
- messageReceiptCount: (0, import_math14.bn)(messageBlockHeader.messageReceiptCount)
4619
+ messageReceiptCount: (0, import_math15.bn)(messageBlockHeader.messageReceiptCount)
4509
4620
  },
4510
4621
  commitBlockHeader: {
4511
4622
  id: commitBlockHeader.id,
4512
- daHeight: (0, import_math14.bn)(commitBlockHeader.daHeight),
4513
- transactionsCount: (0, import_math14.bn)(commitBlockHeader.transactionsCount),
4623
+ daHeight: (0, import_math15.bn)(commitBlockHeader.daHeight),
4624
+ transactionsCount: (0, import_math15.bn)(commitBlockHeader.transactionsCount),
4514
4625
  transactionsRoot: commitBlockHeader.transactionsRoot,
4515
- height: (0, import_math14.bn)(commitBlockHeader.height),
4626
+ height: (0, import_math15.bn)(commitBlockHeader.height),
4516
4627
  prevRoot: commitBlockHeader.prevRoot,
4517
4628
  time: commitBlockHeader.time,
4518
4629
  applicationHash: commitBlockHeader.applicationHash,
4519
4630
  messageReceiptRoot: commitBlockHeader.messageReceiptRoot,
4520
- messageReceiptCount: (0, import_math14.bn)(commitBlockHeader.messageReceiptCount)
4631
+ messageReceiptCount: (0, import_math15.bn)(commitBlockHeader.messageReceiptCount)
4521
4632
  },
4522
4633
  sender: import_address3.Address.fromAddressOrString(sender),
4523
4634
  recipient: import_address3.Address.fromAddressOrString(recipient),
4524
4635
  nonce,
4525
- amount: (0, import_math14.bn)(amount),
4636
+ amount: (0, import_math15.bn)(amount),
4526
4637
  data
4527
4638
  };
4528
4639
  }
@@ -4545,10 +4656,10 @@ var _Provider = class {
4545
4656
  */
4546
4657
  async produceBlocks(amount, startTime) {
4547
4658
  const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
4548
- blocksToProduce: (0, import_math14.bn)(amount).toString(10),
4549
- startTimestamp: startTime ? import_utils22.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
4659
+ blocksToProduce: (0, import_math15.bn)(amount).toString(10),
4660
+ startTimestamp: startTime ? import_utils23.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
4550
4661
  });
4551
- return (0, import_math14.bn)(latestBlockHeight);
4662
+ return (0, import_math15.bn)(latestBlockHeight);
4552
4663
  }
4553
4664
  // eslint-disable-next-line @typescript-eslint/require-await
4554
4665
  async getTransactionResponse(transactionId) {
@@ -4562,7 +4673,7 @@ cacheInputs_fn = function(inputs) {
4562
4673
  return;
4563
4674
  }
4564
4675
  inputs.forEach((input) => {
4565
- if (input.type === import_transactions17.InputType.Coin) {
4676
+ if (input.type === import_transactions18.InputType.Coin) {
4566
4677
  this.cache?.set(input.id);
4567
4678
  }
4568
4679
  });
@@ -4571,23 +4682,23 @@ __publicField(Provider, "chainInfoCache", {});
4571
4682
  __publicField(Provider, "nodeInfoCache", {});
4572
4683
 
4573
4684
  // src/providers/transaction-summary/get-transaction-summary.ts
4574
- var import_errors14 = require("@fuel-ts/errors");
4575
- var import_math15 = require("@fuel-ts/math");
4576
- var import_transactions18 = require("@fuel-ts/transactions");
4577
- var import_utils25 = require("@fuel-ts/utils");
4685
+ var import_errors15 = require("@fuel-ts/errors");
4686
+ var import_math16 = require("@fuel-ts/math");
4687
+ var import_transactions19 = require("@fuel-ts/transactions");
4688
+ var import_utils26 = require("@fuel-ts/utils");
4578
4689
  async function getTransactionSummary(params) {
4579
4690
  const { id, provider, abiMap } = params;
4580
4691
  const { transaction: gqlTransaction } = await provider.operations.getTransactionWithReceipts({
4581
4692
  transactionId: id
4582
4693
  });
4583
4694
  if (!gqlTransaction) {
4584
- throw new import_errors14.FuelError(
4585
- import_errors14.ErrorCode.TRANSACTION_NOT_FOUND,
4695
+ throw new import_errors15.FuelError(
4696
+ import_errors15.ErrorCode.TRANSACTION_NOT_FOUND,
4586
4697
  `Transaction not found for given id: ${id}.`
4587
4698
  );
4588
4699
  }
4589
- const [decodedTransaction] = new import_transactions18.TransactionCoder().decode(
4590
- (0, import_utils25.arrayify)(gqlTransaction.rawPayload),
4700
+ const [decodedTransaction] = new import_transactions19.TransactionCoder().decode(
4701
+ (0, import_utils26.arrayify)(gqlTransaction.rawPayload),
4591
4702
  0
4592
4703
  );
4593
4704
  const receipts = gqlTransaction.receipts?.map(processGqlReceipt) || [];
@@ -4598,10 +4709,10 @@ async function getTransactionSummary(params) {
4598
4709
  id: gqlTransaction.id,
4599
4710
  receipts,
4600
4711
  transaction: decodedTransaction,
4601
- transactionBytes: (0, import_utils25.arrayify)(gqlTransaction.rawPayload),
4712
+ transactionBytes: (0, import_utils26.arrayify)(gqlTransaction.rawPayload),
4602
4713
  gqlTransactionStatus: gqlTransaction.status,
4603
- gasPerByte: (0, import_math15.bn)(gasPerByte),
4604
- gasPriceFactor: (0, import_math15.bn)(gasPriceFactor),
4714
+ gasPerByte: (0, import_math16.bn)(gasPerByte),
4715
+ gasPriceFactor: (0, import_math16.bn)(gasPriceFactor),
4605
4716
  abiMap,
4606
4717
  maxInputs,
4607
4718
  gasCosts
@@ -4640,13 +4751,13 @@ async function getTransactionsSummaries(params) {
4640
4751
  const transactions = edges.map((edge) => {
4641
4752
  const { node: gqlTransaction } = edge;
4642
4753
  const { id, rawPayload, receipts: gqlReceipts, status } = gqlTransaction;
4643
- const [decodedTransaction] = new import_transactions18.TransactionCoder().decode((0, import_utils25.arrayify)(rawPayload), 0);
4754
+ const [decodedTransaction] = new import_transactions19.TransactionCoder().decode((0, import_utils26.arrayify)(rawPayload), 0);
4644
4755
  const receipts = gqlReceipts?.map(processGqlReceipt) || [];
4645
4756
  const transactionSummary = assembleTransactionSummary({
4646
4757
  id,
4647
4758
  receipts,
4648
4759
  transaction: decodedTransaction,
4649
- transactionBytes: (0, import_utils25.arrayify)(rawPayload),
4760
+ transactionBytes: (0, import_utils26.arrayify)(rawPayload),
4650
4761
  gqlTransactionStatus: status,
4651
4762
  abiMap,
4652
4763
  gasPerByte,
@@ -4788,18 +4899,18 @@ var assets = [
4788
4899
  ];
4789
4900
 
4790
4901
  // src/utils/formatTransferToContractScriptData.ts
4791
- var import_abi_coder4 = require("@fuel-ts/abi-coder");
4792
- var import_math16 = require("@fuel-ts/math");
4793
- var import_utils26 = require("@fuel-ts/utils");
4902
+ var import_abi_coder6 = require("@fuel-ts/abi-coder");
4903
+ var import_math17 = require("@fuel-ts/math");
4904
+ var import_utils27 = require("@fuel-ts/utils");
4794
4905
  var asm = __toESM(require("@fuels/vm-asm"));
4795
4906
  var formatTransferToContractScriptData = (params) => {
4796
4907
  const { assetId, amountToTransfer, hexlifiedContractId } = params;
4797
- const numberCoder = new import_abi_coder4.BigNumberCoder("u64");
4798
- const encoded = numberCoder.encode(new import_math16.BN(amountToTransfer).toNumber());
4908
+ const numberCoder = new import_abi_coder6.BigNumberCoder("u64");
4909
+ const encoded = numberCoder.encode(new import_math17.BN(amountToTransfer).toNumber());
4799
4910
  const scriptData = Uint8Array.from([
4800
- ...(0, import_utils26.arrayify)(hexlifiedContractId),
4911
+ ...(0, import_utils27.arrayify)(hexlifiedContractId),
4801
4912
  ...encoded,
4802
- ...(0, import_utils26.arrayify)(assetId)
4913
+ ...(0, import_utils27.arrayify)(assetId)
4803
4914
  ]);
4804
4915
  return scriptData;
4805
4916
  };
@@ -4855,7 +4966,7 @@ var Account = class extends import_interfaces.AbstractAccount {
4855
4966
  */
4856
4967
  get provider() {
4857
4968
  if (!this._provider) {
4858
- throw new import_errors15.FuelError(import_errors15.ErrorCode.MISSING_PROVIDER, "Provider not set");
4969
+ throw new import_errors16.FuelError(import_errors16.ErrorCode.MISSING_PROVIDER, "Provider not set");
4859
4970
  }
4860
4971
  return this._provider;
4861
4972
  }
@@ -4907,8 +5018,8 @@ var Account = class extends import_interfaces.AbstractAccount {
4907
5018
  if (!hasNextPage) {
4908
5019
  break;
4909
5020
  }
4910
- throw new import_errors15.FuelError(
4911
- import_errors15.ErrorCode.NOT_SUPPORTED,
5021
+ throw new import_errors16.FuelError(
5022
+ import_errors16.ErrorCode.NOT_SUPPORTED,
4912
5023
  `Wallets containing more than ${pageSize} coins exceed the current supported limit.`
4913
5024
  );
4914
5025
  }
@@ -4933,8 +5044,8 @@ var Account = class extends import_interfaces.AbstractAccount {
4933
5044
  if (!hasNextPage) {
4934
5045
  break;
4935
5046
  }
4936
- throw new import_errors15.FuelError(
4937
- import_errors15.ErrorCode.NOT_SUPPORTED,
5047
+ throw new import_errors16.FuelError(
5048
+ import_errors16.ErrorCode.NOT_SUPPORTED,
4938
5049
  `Wallets containing more than ${pageSize} messages exceed the current supported limit.`
4939
5050
  );
4940
5051
  }
@@ -4946,7 +5057,7 @@ var Account = class extends import_interfaces.AbstractAccount {
4946
5057
  * @param assetId - The asset ID to check the balance for.
4947
5058
  * @returns A promise that resolves to the balance amount.
4948
5059
  */
4949
- async getBalance(assetId = import_configs11.BaseAssetId) {
5060
+ async getBalance(assetId = import_configs12.BaseAssetId) {
4950
5061
  const amount = await this.provider.getBalance(this.address, assetId);
4951
5062
  return amount;
4952
5063
  }
@@ -4969,8 +5080,8 @@ var Account = class extends import_interfaces.AbstractAccount {
4969
5080
  if (!hasNextPage) {
4970
5081
  break;
4971
5082
  }
4972
- throw new import_errors15.FuelError(
4973
- import_errors15.ErrorCode.NOT_SUPPORTED,
5083
+ throw new import_errors16.FuelError(
5084
+ import_errors16.ErrorCode.NOT_SUPPORTED,
4974
5085
  `Wallets containing more than ${pageSize} balances exceed the current supported limit.`
4975
5086
  );
4976
5087
  }
@@ -4986,15 +5097,15 @@ var Account = class extends import_interfaces.AbstractAccount {
4986
5097
  */
4987
5098
  async fund(request, coinQuantities, fee) {
4988
5099
  const updatedQuantities = addAmountToAsset({
4989
- amount: (0, import_math17.bn)(fee),
4990
- assetId: import_configs11.BaseAssetId,
5100
+ amount: (0, import_math18.bn)(fee),
5101
+ assetId: import_configs12.BaseAssetId,
4991
5102
  coinQuantities
4992
5103
  });
4993
5104
  const quantitiesDict = {};
4994
5105
  updatedQuantities.forEach(({ amount, assetId }) => {
4995
5106
  quantitiesDict[assetId] = {
4996
5107
  required: amount,
4997
- owned: (0, import_math17.bn)(0)
5108
+ owned: (0, import_math18.bn)(0)
4998
5109
  };
4999
5110
  });
5000
5111
  const cachedUtxos = [];
@@ -5007,12 +5118,12 @@ var Account = class extends import_interfaces.AbstractAccount {
5007
5118
  if (isCoin2) {
5008
5119
  const assetId = String(input.assetId);
5009
5120
  if (input.owner === owner && quantitiesDict[assetId]) {
5010
- const amount = (0, import_math17.bn)(input.amount);
5121
+ const amount = (0, import_math18.bn)(input.amount);
5011
5122
  quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
5012
5123
  cachedUtxos.push(input.id);
5013
5124
  }
5014
- } else if (input.recipient === owner && input.amount && quantitiesDict[import_configs11.BaseAssetId]) {
5015
- quantitiesDict[import_configs11.BaseAssetId].owned = quantitiesDict[import_configs11.BaseAssetId].owned.add(input.amount);
5125
+ } else if (input.recipient === owner && input.amount && quantitiesDict[import_configs12.BaseAssetId]) {
5126
+ quantitiesDict[import_configs12.BaseAssetId].owned = quantitiesDict[import_configs12.BaseAssetId].owned.add(input.amount);
5016
5127
  cachedMessages.push(input.nonce);
5017
5128
  }
5018
5129
  }
@@ -5044,7 +5155,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5044
5155
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
5045
5156
  * @returns A promise that resolves to the prepared transaction request.
5046
5157
  */
5047
- async createTransfer(destination, amount, assetId = import_configs11.BaseAssetId, txParams = {}) {
5158
+ async createTransfer(destination, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
5048
5159
  const { minGasPrice } = this.provider.getGasConfig();
5049
5160
  const params = { gasPrice: minGasPrice, ...txParams };
5050
5161
  const request = new ScriptTransactionRequest(params);
@@ -5053,8 +5164,8 @@ var Account = class extends import_interfaces.AbstractAccount {
5053
5164
  estimateTxDependencies: true,
5054
5165
  resourcesOwner: this
5055
5166
  });
5056
- request.gasPrice = (0, import_math17.bn)(txParams.gasPrice ?? minGasPrice);
5057
- request.gasLimit = (0, import_math17.bn)(txParams.gasLimit ?? gasUsed);
5167
+ request.gasPrice = (0, import_math18.bn)(txParams.gasPrice ?? minGasPrice);
5168
+ request.gasLimit = (0, import_math18.bn)(txParams.gasLimit ?? gasUsed);
5058
5169
  this.validateGas({
5059
5170
  gasUsed,
5060
5171
  gasPrice: request.gasPrice,
@@ -5074,10 +5185,10 @@ var Account = class extends import_interfaces.AbstractAccount {
5074
5185
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
5075
5186
  * @returns A promise that resolves to the transaction response.
5076
5187
  */
5077
- async transfer(destination, amount, assetId = import_configs11.BaseAssetId, txParams = {}) {
5078
- if ((0, import_math17.bn)(amount).lte(0)) {
5079
- throw new import_errors15.FuelError(
5080
- import_errors15.ErrorCode.INVALID_TRANSFER_AMOUNT,
5188
+ async transfer(destination, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
5189
+ if ((0, import_math18.bn)(amount).lte(0)) {
5190
+ throw new import_errors16.FuelError(
5191
+ import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
5081
5192
  "Transfer amount must be a positive number."
5082
5193
  );
5083
5194
  }
@@ -5093,10 +5204,10 @@ var Account = class extends import_interfaces.AbstractAccount {
5093
5204
  * @param txParams - The optional transaction parameters.
5094
5205
  * @returns A promise that resolves to the transaction response.
5095
5206
  */
5096
- async transferToContract(contractId, amount, assetId = import_configs11.BaseAssetId, txParams = {}) {
5097
- if ((0, import_math17.bn)(amount).lte(0)) {
5098
- throw new import_errors15.FuelError(
5099
- import_errors15.ErrorCode.INVALID_TRANSFER_AMOUNT,
5207
+ async transferToContract(contractId, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
5208
+ if ((0, import_math18.bn)(amount).lte(0)) {
5209
+ throw new import_errors16.FuelError(
5210
+ import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
5100
5211
  "Transfer amount must be a positive number."
5101
5212
  );
5102
5213
  }
@@ -5105,7 +5216,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5105
5216
  const params = { gasPrice: minGasPrice, ...txParams };
5106
5217
  const { script, scriptData } = await assembleTransferToContractScript({
5107
5218
  hexlifiedContractId: contractAddress.toB256(),
5108
- amountToTransfer: (0, import_math17.bn)(amount),
5219
+ amountToTransfer: (0, import_math18.bn)(amount),
5109
5220
  assetId
5110
5221
  });
5111
5222
  const request = new ScriptTransactionRequest({
@@ -5116,9 +5227,9 @@ var Account = class extends import_interfaces.AbstractAccount {
5116
5227
  request.addContractInputAndOutput(contractAddress);
5117
5228
  const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
5118
5229
  request,
5119
- [{ amount: (0, import_math17.bn)(amount), assetId: String(assetId) }]
5230
+ [{ amount: (0, import_math18.bn)(amount), assetId: String(assetId) }]
5120
5231
  );
5121
- request.gasLimit = (0, import_math17.bn)(params.gasLimit ?? gasUsed);
5232
+ request.gasLimit = (0, import_math18.bn)(params.gasLimit ?? gasUsed);
5122
5233
  this.validateGas({
5123
5234
  gasUsed,
5124
5235
  gasPrice: request.gasPrice,
@@ -5139,25 +5250,25 @@ var Account = class extends import_interfaces.AbstractAccount {
5139
5250
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
5140
5251
  const { minGasPrice } = this.provider.getGasConfig();
5141
5252
  const recipientAddress = import_address4.Address.fromAddressOrString(recipient);
5142
- const recipientDataArray = (0, import_utils27.arrayify)(
5253
+ const recipientDataArray = (0, import_utils28.arrayify)(
5143
5254
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
5144
5255
  );
5145
- const amountDataArray = (0, import_utils27.arrayify)(
5146
- "0x".concat((0, import_math17.bn)(amount).toHex().substring(2).padStart(16, "0"))
5256
+ const amountDataArray = (0, import_utils28.arrayify)(
5257
+ "0x".concat((0, import_math18.bn)(amount).toHex().substring(2).padStart(16, "0"))
5147
5258
  );
5148
5259
  const script = new Uint8Array([
5149
- ...(0, import_utils27.arrayify)(withdrawScript.bytes),
5260
+ ...(0, import_utils28.arrayify)(withdrawScript.bytes),
5150
5261
  ...recipientDataArray,
5151
5262
  ...amountDataArray
5152
5263
  ]);
5153
5264
  const params = { script, gasPrice: minGasPrice, ...txParams };
5154
5265
  const request = new ScriptTransactionRequest(params);
5155
- const forwardingQuantities = [{ amount: (0, import_math17.bn)(amount), assetId: import_configs11.BaseAssetId }];
5266
+ const forwardingQuantities = [{ amount: (0, import_math18.bn)(amount), assetId: import_configs12.BaseAssetId }];
5156
5267
  const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
5157
5268
  request,
5158
5269
  forwardingQuantities
5159
5270
  );
5160
- request.gasLimit = (0, import_math17.bn)(params.gasLimit ?? gasUsed);
5271
+ request.gasLimit = (0, import_math18.bn)(params.gasLimit ?? gasUsed);
5161
5272
  this.validateGas({
5162
5273
  gasUsed,
5163
5274
  gasPrice: request.gasPrice,
@@ -5169,7 +5280,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5169
5280
  }
5170
5281
  async signMessage(message) {
5171
5282
  if (!this._connector) {
5172
- throw new import_errors15.FuelError(import_errors15.ErrorCode.MISSING_CONNECTOR, "A connector is required to sign messages.");
5283
+ throw new import_errors16.FuelError(import_errors16.ErrorCode.MISSING_CONNECTOR, "A connector is required to sign messages.");
5173
5284
  }
5174
5285
  return this._connector.signMessage(this.address.toString(), message);
5175
5286
  }
@@ -5181,8 +5292,8 @@ var Account = class extends import_interfaces.AbstractAccount {
5181
5292
  */
5182
5293
  async signTransaction(transactionRequestLike) {
5183
5294
  if (!this._connector) {
5184
- throw new import_errors15.FuelError(
5185
- import_errors15.ErrorCode.MISSING_CONNECTOR,
5295
+ throw new import_errors16.FuelError(
5296
+ import_errors16.ErrorCode.MISSING_CONNECTOR,
5186
5297
  "A connector is required to sign transactions."
5187
5298
  );
5188
5299
  }
@@ -5229,14 +5340,14 @@ var Account = class extends import_interfaces.AbstractAccount {
5229
5340
  minGasPrice
5230
5341
  }) {
5231
5342
  if (minGasPrice.gt(gasPrice)) {
5232
- throw new import_errors15.FuelError(
5233
- import_errors15.ErrorCode.GAS_PRICE_TOO_LOW,
5343
+ throw new import_errors16.FuelError(
5344
+ import_errors16.ErrorCode.GAS_PRICE_TOO_LOW,
5234
5345
  `Gas price '${gasPrice}' is lower than the required: '${minGasPrice}'.`
5235
5346
  );
5236
5347
  }
5237
5348
  if (gasUsed.gt(gasLimit)) {
5238
- throw new import_errors15.FuelError(
5239
- import_errors15.ErrorCode.GAS_LIMIT_TOO_LOW,
5349
+ throw new import_errors16.FuelError(
5350
+ import_errors16.ErrorCode.GAS_LIMIT_TOO_LOW,
5240
5351
  `Gas limit '${gasLimit}' is lower than the required: '${gasUsed}'.`
5241
5352
  );
5242
5353
  }
@@ -5245,14 +5356,14 @@ var Account = class extends import_interfaces.AbstractAccount {
5245
5356
 
5246
5357
  // src/wallet/base-wallet-unlocked.ts
5247
5358
  var import_hasher3 = require("@fuel-ts/hasher");
5248
- var import_utils30 = require("@fuel-ts/utils");
5359
+ var import_utils31 = require("@fuel-ts/utils");
5249
5360
 
5250
5361
  // src/signer/signer.ts
5251
5362
  var import_address5 = require("@fuel-ts/address");
5252
- var import_crypto = require("@fuel-ts/crypto");
5363
+ var import_crypto2 = require("@fuel-ts/crypto");
5253
5364
  var import_hasher2 = require("@fuel-ts/hasher");
5254
- var import_math18 = require("@fuel-ts/math");
5255
- var import_utils28 = require("@fuel-ts/utils");
5365
+ var import_math19 = require("@fuel-ts/math");
5366
+ var import_utils29 = require("@fuel-ts/utils");
5256
5367
  var import_secp256k1 = require("@noble/curves/secp256k1");
5257
5368
  var Signer = class {
5258
5369
  address;
@@ -5271,10 +5382,10 @@ var Signer = class {
5271
5382
  privateKey = `0x${privateKey}`;
5272
5383
  }
5273
5384
  }
5274
- const privateKeyBytes = (0, import_math18.toBytes)(privateKey, 32);
5275
- this.privateKey = (0, import_utils28.hexlify)(privateKeyBytes);
5276
- this.publicKey = (0, import_utils28.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
5277
- this.compressedPublicKey = (0, import_utils28.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
5385
+ const privateKeyBytes = (0, import_math19.toBytes)(privateKey, 32);
5386
+ this.privateKey = (0, import_utils29.hexlify)(privateKeyBytes);
5387
+ this.publicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
5388
+ this.compressedPublicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
5278
5389
  this.address = import_address5.Address.fromPublicKey(this.publicKey);
5279
5390
  }
5280
5391
  /**
@@ -5288,11 +5399,11 @@ var Signer = class {
5288
5399
  * @returns hashed signature
5289
5400
  */
5290
5401
  sign(data) {
5291
- const signature = import_secp256k1.secp256k1.sign((0, import_utils28.arrayify)(data), (0, import_utils28.arrayify)(this.privateKey));
5292
- const r = (0, import_math18.toBytes)(`0x${signature.r.toString(16)}`, 32);
5293
- const s = (0, import_math18.toBytes)(`0x${signature.s.toString(16)}`, 32);
5402
+ const signature = import_secp256k1.secp256k1.sign((0, import_utils29.arrayify)(data), (0, import_utils29.arrayify)(this.privateKey));
5403
+ const r = (0, import_math19.toBytes)(`0x${signature.r.toString(16)}`, 32);
5404
+ const s = (0, import_math19.toBytes)(`0x${signature.s.toString(16)}`, 32);
5294
5405
  s[0] |= (signature.recovery || 0) << 7;
5295
- return (0, import_utils28.hexlify)((0, import_utils28.concat)([r, s]));
5406
+ return (0, import_utils29.hexlify)((0, import_utils29.concat)([r, s]));
5296
5407
  }
5297
5408
  /**
5298
5409
  * Add point on the current elliptic curve
@@ -5301,8 +5412,8 @@ var Signer = class {
5301
5412
  * @returns compressed point on the curve
5302
5413
  */
5303
5414
  addPoint(point) {
5304
- const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(this.compressedPublicKey));
5305
- const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(point));
5415
+ const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(this.compressedPublicKey));
5416
+ const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(point));
5306
5417
  const result = p0.add(p1);
5307
5418
  return `0x${result.toHex(true)}`;
5308
5419
  }
@@ -5314,16 +5425,16 @@ var Signer = class {
5314
5425
  * @returns public key from signature from the
5315
5426
  */
5316
5427
  static recoverPublicKey(data, signature) {
5317
- const signedMessageBytes = (0, import_utils28.arrayify)(signature);
5428
+ const signedMessageBytes = (0, import_utils29.arrayify)(signature);
5318
5429
  const r = signedMessageBytes.slice(0, 32);
5319
5430
  const s = signedMessageBytes.slice(32, 64);
5320
5431
  const recoveryParam = (s[0] & 128) >> 7;
5321
5432
  s[0] &= 127;
5322
- const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils28.hexlify)(r)), BigInt((0, import_utils28.hexlify)(s))).addRecoveryBit(
5433
+ const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils29.hexlify)(r)), BigInt((0, import_utils29.hexlify)(s))).addRecoveryBit(
5323
5434
  recoveryParam
5324
5435
  );
5325
- const publicKey = sig.recoverPublicKey((0, import_utils28.arrayify)(data)).toRawBytes(false).slice(1);
5326
- return (0, import_utils28.hexlify)(publicKey);
5436
+ const publicKey = sig.recoverPublicKey((0, import_utils29.arrayify)(data)).toRawBytes(false).slice(1);
5437
+ return (0, import_utils29.hexlify)(publicKey);
5327
5438
  }
5328
5439
  /**
5329
5440
  * Recover the address from a signature performed with [`sign`](#sign).
@@ -5342,7 +5453,7 @@ var Signer = class {
5342
5453
  * @returns random 32-byte hashed
5343
5454
  */
5344
5455
  static generatePrivateKey(entropy) {
5345
- 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);
5456
+ 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);
5346
5457
  }
5347
5458
  /**
5348
5459
  * Extended publicKey from a compact publicKey
@@ -5351,16 +5462,16 @@ var Signer = class {
5351
5462
  * @returns extended publicKey
5352
5463
  */
5353
5464
  static extendPublicKey(publicKey) {
5354
- const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(publicKey));
5355
- return (0, import_utils28.hexlify)(point.toRawBytes(false).slice(1));
5465
+ const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(publicKey));
5466
+ return (0, import_utils29.hexlify)(point.toRawBytes(false).slice(1));
5356
5467
  }
5357
5468
  };
5358
5469
 
5359
5470
  // src/wallet/keystore-wallet.ts
5360
5471
  var import_address6 = require("@fuel-ts/address");
5361
- var import_crypto2 = require("@fuel-ts/crypto");
5362
- var import_errors16 = require("@fuel-ts/errors");
5363
- var import_utils29 = require("@fuel-ts/utils");
5472
+ var import_crypto3 = require("@fuel-ts/crypto");
5473
+ var import_errors17 = require("@fuel-ts/errors");
5474
+ var import_utils30 = require("@fuel-ts/utils");
5364
5475
  var import_uuid = require("uuid");
5365
5476
  var DEFAULT_KDF_PARAMS_LOG_N = 13;
5366
5477
  var DEFAULT_KDF_PARAMS_R = 8;
@@ -5374,22 +5485,22 @@ var removeHexPrefix = (hexString) => {
5374
5485
  return hexString;
5375
5486
  };
5376
5487
  async function encryptKeystoreWallet(privateKey, address, password) {
5377
- const privateKeyBuffer = (0, import_crypto2.bufferFromString)(removeHexPrefix(privateKey), "hex");
5488
+ const privateKeyBuffer = (0, import_crypto3.bufferFromString)(removeHexPrefix(privateKey), "hex");
5378
5489
  const ownerAddress = import_address6.Address.fromAddressOrString(address);
5379
- const salt = (0, import_crypto2.randomBytes)(DEFAULT_KEY_SIZE);
5380
- const key = (0, import_crypto2.scrypt)({
5381
- password: (0, import_crypto2.bufferFromString)(password),
5490
+ const salt = (0, import_crypto3.randomBytes)(DEFAULT_KEY_SIZE);
5491
+ const key = (0, import_crypto3.scrypt)({
5492
+ password: (0, import_crypto3.bufferFromString)(password),
5382
5493
  salt,
5383
5494
  dklen: DEFAULT_KEY_SIZE,
5384
5495
  n: 2 ** DEFAULT_KDF_PARAMS_LOG_N,
5385
5496
  r: DEFAULT_KDF_PARAMS_R,
5386
5497
  p: DEFAULT_KDF_PARAMS_P
5387
5498
  });
5388
- const iv = (0, import_crypto2.randomBytes)(DEFAULT_IV_SIZE);
5389
- const ciphertext = await (0, import_crypto2.encryptJsonWalletData)(privateKeyBuffer, key, iv);
5499
+ const iv = (0, import_crypto3.randomBytes)(DEFAULT_IV_SIZE);
5500
+ const ciphertext = await (0, import_crypto3.encryptJsonWalletData)(privateKeyBuffer, key, iv);
5390
5501
  const data = Uint8Array.from([...key.subarray(16, 32), ...ciphertext]);
5391
- const macHashUint8Array = (0, import_crypto2.keccak256)(data);
5392
- const mac = (0, import_crypto2.stringFromBuffer)(macHashUint8Array, "hex");
5502
+ const macHashUint8Array = (0, import_crypto3.keccak256)(data);
5503
+ const mac = (0, import_crypto3.stringFromBuffer)(macHashUint8Array, "hex");
5393
5504
  const keystore = {
5394
5505
  id: (0, import_uuid.v4)(),
5395
5506
  version: 3,
@@ -5397,15 +5508,15 @@ async function encryptKeystoreWallet(privateKey, address, password) {
5397
5508
  crypto: {
5398
5509
  cipher: "aes-128-ctr",
5399
5510
  mac,
5400
- cipherparams: { iv: (0, import_crypto2.stringFromBuffer)(iv, "hex") },
5401
- ciphertext: (0, import_crypto2.stringFromBuffer)(ciphertext, "hex"),
5511
+ cipherparams: { iv: (0, import_crypto3.stringFromBuffer)(iv, "hex") },
5512
+ ciphertext: (0, import_crypto3.stringFromBuffer)(ciphertext, "hex"),
5402
5513
  kdf: "scrypt",
5403
5514
  kdfparams: {
5404
5515
  dklen: DEFAULT_KEY_SIZE,
5405
5516
  n: 2 ** DEFAULT_KDF_PARAMS_LOG_N,
5406
5517
  p: DEFAULT_KDF_PARAMS_P,
5407
5518
  r: DEFAULT_KDF_PARAMS_R,
5408
- salt: (0, import_crypto2.stringFromBuffer)(salt, "hex")
5519
+ salt: (0, import_crypto3.stringFromBuffer)(salt, "hex")
5409
5520
  }
5410
5521
  }
5411
5522
  };
@@ -5421,11 +5532,11 @@ async function decryptKeystoreWallet(jsonWallet, password) {
5421
5532
  kdfparams: { dklen, n, r, p, salt }
5422
5533
  }
5423
5534
  } = keystoreWallet;
5424
- const ciphertextBuffer = (0, import_crypto2.bufferFromString)(ciphertext, "hex");
5425
- const ivBuffer = (0, import_crypto2.bufferFromString)(iv, "hex");
5426
- const saltBuffer = (0, import_crypto2.bufferFromString)(salt, "hex");
5427
- const passwordBuffer = (0, import_crypto2.bufferFromString)(password);
5428
- const key = (0, import_crypto2.scrypt)({
5535
+ const ciphertextBuffer = (0, import_crypto3.bufferFromString)(ciphertext, "hex");
5536
+ const ivBuffer = (0, import_crypto3.bufferFromString)(iv, "hex");
5537
+ const saltBuffer = (0, import_crypto3.bufferFromString)(salt, "hex");
5538
+ const passwordBuffer = (0, import_crypto3.bufferFromString)(password);
5539
+ const key = (0, import_crypto3.scrypt)({
5429
5540
  password: passwordBuffer,
5430
5541
  salt: saltBuffer,
5431
5542
  n,
@@ -5434,16 +5545,16 @@ async function decryptKeystoreWallet(jsonWallet, password) {
5434
5545
  dklen
5435
5546
  });
5436
5547
  const data = Uint8Array.from([...key.subarray(16, 32), ...ciphertextBuffer]);
5437
- const macHashUint8Array = (0, import_crypto2.keccak256)(data);
5438
- const macHash = (0, import_crypto2.stringFromBuffer)(macHashUint8Array, "hex");
5548
+ const macHashUint8Array = (0, import_crypto3.keccak256)(data);
5549
+ const macHash = (0, import_crypto3.stringFromBuffer)(macHashUint8Array, "hex");
5439
5550
  if (mac !== macHash) {
5440
- throw new import_errors16.FuelError(
5441
- import_errors16.ErrorCode.INVALID_PASSWORD,
5551
+ throw new import_errors17.FuelError(
5552
+ import_errors17.ErrorCode.INVALID_PASSWORD,
5442
5553
  "Failed to decrypt the keystore wallet, the provided password is incorrect."
5443
5554
  );
5444
5555
  }
5445
- const buffer = await (0, import_crypto2.decryptJsonWalletData)(ciphertextBuffer, key, ivBuffer);
5446
- const privateKey = (0, import_utils29.hexlify)(buffer);
5556
+ const buffer = await (0, import_crypto3.decryptJsonWalletData)(ciphertextBuffer, key, ivBuffer);
5557
+ const privateKey = (0, import_utils30.hexlify)(buffer);
5447
5558
  return privateKey;
5448
5559
  }
5449
5560
 
@@ -5488,7 +5599,7 @@ var BaseWalletUnlocked = class extends Account {
5488
5599
  */
5489
5600
  async signMessage(message) {
5490
5601
  const signedMessage = await this.signer().sign((0, import_hasher3.hashMessage)(message));
5491
- return (0, import_utils30.hexlify)(signedMessage);
5602
+ return (0, import_utils31.hexlify)(signedMessage);
5492
5603
  }
5493
5604
  /**
5494
5605
  * Signs a transaction with the wallet's private key.
@@ -5501,7 +5612,7 @@ var BaseWalletUnlocked = class extends Account {
5501
5612
  const chainId = this.provider.getChainId();
5502
5613
  const hashedTransaction = transactionRequest.getTransactionId(chainId);
5503
5614
  const signature = await this.signer().sign(hashedTransaction);
5504
- return (0, import_utils30.hexlify)(signature);
5615
+ return (0, import_utils31.hexlify)(signature);
5505
5616
  }
5506
5617
  /**
5507
5618
  * Populates a transaction with the witnesses signature.
@@ -5560,17 +5671,17 @@ var BaseWalletUnlocked = class extends Account {
5560
5671
  __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
5561
5672
 
5562
5673
  // src/hdwallet/hdwallet.ts
5563
- var import_errors19 = require("@fuel-ts/errors");
5674
+ var import_errors20 = require("@fuel-ts/errors");
5564
5675
  var import_hasher6 = require("@fuel-ts/hasher");
5565
- var import_math19 = require("@fuel-ts/math");
5566
- var import_utils34 = require("@fuel-ts/utils");
5676
+ var import_math20 = require("@fuel-ts/math");
5677
+ var import_utils35 = require("@fuel-ts/utils");
5567
5678
  var import_ethers3 = require("ethers");
5568
5679
 
5569
5680
  // src/mnemonic/mnemonic.ts
5570
- var import_crypto3 = require("@fuel-ts/crypto");
5571
- var import_errors18 = require("@fuel-ts/errors");
5681
+ var import_crypto4 = require("@fuel-ts/crypto");
5682
+ var import_errors19 = require("@fuel-ts/errors");
5572
5683
  var import_hasher5 = require("@fuel-ts/hasher");
5573
- var import_utils32 = require("@fuel-ts/utils");
5684
+ var import_utils33 = require("@fuel-ts/utils");
5574
5685
  var import_ethers2 = require("ethers");
5575
5686
 
5576
5687
  // src/wordlists/words/english.ts
@@ -7632,9 +7743,9 @@ var Language = /* @__PURE__ */ ((Language2) => {
7632
7743
  })(Language || {});
7633
7744
 
7634
7745
  // src/mnemonic/utils.ts
7635
- var import_errors17 = require("@fuel-ts/errors");
7746
+ var import_errors18 = require("@fuel-ts/errors");
7636
7747
  var import_hasher4 = require("@fuel-ts/hasher");
7637
- var import_utils31 = require("@fuel-ts/utils");
7748
+ var import_utils32 = require("@fuel-ts/utils");
7638
7749
  function toUtf8Bytes(stri) {
7639
7750
  const str = stri.normalize("NFKD");
7640
7751
  const result = [];
@@ -7649,8 +7760,8 @@ function toUtf8Bytes(stri) {
7649
7760
  i += 1;
7650
7761
  const c2 = str.charCodeAt(i);
7651
7762
  if (i >= str.length || (c2 & 64512) !== 56320) {
7652
- throw new import_errors17.FuelError(
7653
- import_errors17.ErrorCode.INVALID_INPUT_PARAMETERS,
7763
+ throw new import_errors18.FuelError(
7764
+ import_errors18.ErrorCode.INVALID_INPUT_PARAMETERS,
7654
7765
  "Invalid UTF-8 in the input string."
7655
7766
  );
7656
7767
  }
@@ -7701,20 +7812,20 @@ function entropyToMnemonicIndices(entropy) {
7701
7812
  }
7702
7813
  }
7703
7814
  const checksumBits = entropy.length / 4;
7704
- const checksum = (0, import_utils31.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
7815
+ const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
7705
7816
  indices[indices.length - 1] <<= checksumBits;
7706
7817
  indices[indices.length - 1] |= checksum >> 8 - checksumBits;
7707
7818
  return indices;
7708
7819
  }
7709
7820
  function mnemonicWordsToEntropy(words, wordlist) {
7710
7821
  const size = Math.ceil(11 * words.length / 8);
7711
- const entropy = (0, import_utils31.arrayify)(new Uint8Array(size));
7822
+ const entropy = (0, import_utils32.arrayify)(new Uint8Array(size));
7712
7823
  let offset = 0;
7713
7824
  for (let i = 0; i < words.length; i += 1) {
7714
7825
  const index = wordlist.indexOf(words[i].normalize("NFKD"));
7715
7826
  if (index === -1) {
7716
- throw new import_errors17.FuelError(
7717
- import_errors17.ErrorCode.INVALID_MNEMONIC,
7827
+ throw new import_errors18.FuelError(
7828
+ import_errors18.ErrorCode.INVALID_MNEMONIC,
7718
7829
  `Invalid mnemonic: the word '${words[i]}' is not found in the provided wordlist.`
7719
7830
  );
7720
7831
  }
@@ -7728,10 +7839,10 @@ function mnemonicWordsToEntropy(words, wordlist) {
7728
7839
  const entropyBits = 32 * words.length / 3;
7729
7840
  const checksumBits = words.length / 3;
7730
7841
  const checksumMask = getUpperMask(checksumBits);
7731
- const checksum = (0, import_utils31.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
7842
+ const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
7732
7843
  if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
7733
- throw new import_errors17.FuelError(
7734
- import_errors17.ErrorCode.INVALID_CHECKSUM,
7844
+ throw new import_errors18.FuelError(
7845
+ import_errors18.ErrorCode.INVALID_CHECKSUM,
7735
7846
  "Checksum validation failed for the provided mnemonic."
7736
7847
  );
7737
7848
  }
@@ -7745,16 +7856,16 @@ var TestnetPRV = "0x04358394";
7745
7856
  var MNEMONIC_SIZES = [12, 15, 18, 21, 24];
7746
7857
  function assertWordList(wordlist) {
7747
7858
  if (wordlist.length !== 2048) {
7748
- throw new import_errors18.FuelError(
7749
- import_errors18.ErrorCode.INVALID_WORD_LIST,
7859
+ throw new import_errors19.FuelError(
7860
+ import_errors19.ErrorCode.INVALID_WORD_LIST,
7750
7861
  `Expected word list length of 2048, but got ${wordlist.length}.`
7751
7862
  );
7752
7863
  }
7753
7864
  }
7754
7865
  function assertEntropy(entropy) {
7755
7866
  if (entropy.length % 4 !== 0 || entropy.length < 16 || entropy.length > 32) {
7756
- throw new import_errors18.FuelError(
7757
- import_errors18.ErrorCode.INVALID_ENTROPY,
7867
+ throw new import_errors19.FuelError(
7868
+ import_errors19.ErrorCode.INVALID_ENTROPY,
7758
7869
  `Entropy should be between 16 and 32 bytes and a multiple of 4, but got ${entropy.length} bytes.`
7759
7870
  );
7760
7871
  }
@@ -7764,7 +7875,7 @@ function assertMnemonic(words) {
7764
7875
  const errorMsg = `Invalid mnemonic size. Expected one of [${MNEMONIC_SIZES.join(
7765
7876
  ", "
7766
7877
  )}] words, but got ${words.length}.`;
7767
- throw new import_errors18.FuelError(import_errors18.ErrorCode.INVALID_MNEMONIC, errorMsg);
7878
+ throw new import_errors19.FuelError(import_errors19.ErrorCode.INVALID_MNEMONIC, errorMsg);
7768
7879
  }
7769
7880
  }
7770
7881
  var Mnemonic = class {
@@ -7803,7 +7914,7 @@ var Mnemonic = class {
7803
7914
  static mnemonicToEntropy(phrase, wordlist = english) {
7804
7915
  const words = getWords(phrase);
7805
7916
  assertMnemonic(words);
7806
- return (0, import_utils32.hexlify)(mnemonicWordsToEntropy(words, wordlist));
7917
+ return (0, import_utils33.hexlify)(mnemonicWordsToEntropy(words, wordlist));
7807
7918
  }
7808
7919
  /**
7809
7920
  * @param entropy - Entropy source to the mnemonic phrase.
@@ -7811,7 +7922,7 @@ var Mnemonic = class {
7811
7922
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
7812
7923
  */
7813
7924
  static entropyToMnemonic(entropy, wordlist = english) {
7814
- const entropyBytes = (0, import_utils32.arrayify)(entropy);
7925
+ const entropyBytes = (0, import_utils33.arrayify)(entropy);
7815
7926
  assertWordList(wordlist);
7816
7927
  assertEntropy(entropyBytes);
7817
7928
  return entropyToMnemonicIndices(entropyBytes).map((i) => wordlist[i]).join(" ");
@@ -7880,14 +7991,14 @@ var Mnemonic = class {
7880
7991
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
7881
7992
  */
7882
7993
  static masterKeysFromSeed(seed) {
7883
- const seedArray = (0, import_utils32.arrayify)(seed);
7994
+ const seedArray = (0, import_utils33.arrayify)(seed);
7884
7995
  if (seedArray.length < 16 || seedArray.length > 64) {
7885
- throw new import_errors18.FuelError(
7886
- import_errors18.ErrorCode.INVALID_SEED,
7996
+ throw new import_errors19.FuelError(
7997
+ import_errors19.ErrorCode.INVALID_SEED,
7887
7998
  `Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
7888
7999
  );
7889
8000
  }
7890
- return (0, import_utils32.arrayify)((0, import_ethers2.computeHmac)("sha512", MasterSecret, seedArray));
8001
+ return (0, import_utils33.arrayify)((0, import_ethers2.computeHmac)("sha512", MasterSecret, seedArray));
7891
8002
  }
7892
8003
  /**
7893
8004
  * Get the extendKey as defined on BIP-32 from the provided seed
@@ -7898,22 +8009,22 @@ var Mnemonic = class {
7898
8009
  */
7899
8010
  static seedToExtendedKey(seed, testnet = false) {
7900
8011
  const masterKey = Mnemonic.masterKeysFromSeed(seed);
7901
- const prefix = (0, import_utils32.arrayify)(testnet ? TestnetPRV : MainnetPRV);
8012
+ const prefix = (0, import_utils33.arrayify)(testnet ? TestnetPRV : MainnetPRV);
7902
8013
  const depth = "0x00";
7903
8014
  const fingerprint = "0x00000000";
7904
8015
  const index = "0x00000000";
7905
8016
  const chainCode = masterKey.slice(32);
7906
8017
  const privateKey = masterKey.slice(0, 32);
7907
- const extendedKey = (0, import_utils32.concat)([
8018
+ const extendedKey = (0, import_utils33.concat)([
7908
8019
  prefix,
7909
8020
  depth,
7910
8021
  fingerprint,
7911
8022
  index,
7912
8023
  chainCode,
7913
- (0, import_utils32.concat)(["0x00", privateKey])
8024
+ (0, import_utils33.concat)(["0x00", privateKey])
7914
8025
  ]);
7915
8026
  const checksum = (0, import_ethers2.dataSlice)((0, import_hasher5.sha256)((0, import_hasher5.sha256)(extendedKey)), 0, 4);
7916
- return (0, import_ethers2.encodeBase58)((0, import_utils32.concat)([extendedKey, checksum]));
8027
+ return (0, import_ethers2.encodeBase58)((0, import_utils33.concat)([extendedKey, checksum]));
7917
8028
  }
7918
8029
  /**
7919
8030
  * Create a new mnemonic using a randomly generated number as entropy.
@@ -7928,7 +8039,7 @@ var Mnemonic = class {
7928
8039
  * @returns A randomly generated mnemonic
7929
8040
  */
7930
8041
  static generate(size = 32, extraEntropy = "") {
7931
- 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);
8042
+ 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);
7932
8043
  return Mnemonic.entropyToMnemonic(entropy);
7933
8044
  }
7934
8045
  };
@@ -7936,12 +8047,12 @@ var mnemonic_default = Mnemonic;
7936
8047
 
7937
8048
  // src/hdwallet/hdwallet.ts
7938
8049
  var HARDENED_INDEX = 2147483648;
7939
- var MainnetPRV2 = (0, import_utils34.hexlify)("0x0488ade4");
7940
- var MainnetPUB = (0, import_utils34.hexlify)("0x0488b21e");
7941
- var TestnetPRV2 = (0, import_utils34.hexlify)("0x04358394");
7942
- var TestnetPUB = (0, import_utils34.hexlify)("0x043587cf");
8050
+ var MainnetPRV2 = (0, import_utils35.hexlify)("0x0488ade4");
8051
+ var MainnetPUB = (0, import_utils35.hexlify)("0x0488b21e");
8052
+ var TestnetPRV2 = (0, import_utils35.hexlify)("0x04358394");
8053
+ var TestnetPUB = (0, import_utils35.hexlify)("0x043587cf");
7943
8054
  function base58check(data) {
7944
- 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)]));
8055
+ 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)]));
7945
8056
  }
7946
8057
  function getExtendedKeyPrefix(isPublic = false, testnet = false) {
7947
8058
  if (isPublic) {
@@ -7950,17 +8061,17 @@ function getExtendedKeyPrefix(isPublic = false, testnet = false) {
7950
8061
  return testnet ? TestnetPRV2 : MainnetPRV2;
7951
8062
  }
7952
8063
  function isPublicExtendedKey(extendedKey) {
7953
- return [MainnetPUB, TestnetPUB].includes((0, import_utils34.hexlify)(extendedKey.slice(0, 4)));
8064
+ return [MainnetPUB, TestnetPUB].includes((0, import_utils35.hexlify)(extendedKey.slice(0, 4)));
7954
8065
  }
7955
8066
  function isValidExtendedKey(extendedKey) {
7956
8067
  return [MainnetPRV2, TestnetPRV2, MainnetPUB, TestnetPUB].includes(
7957
- (0, import_utils34.hexlify)(extendedKey.slice(0, 4))
8068
+ (0, import_utils35.hexlify)(extendedKey.slice(0, 4))
7958
8069
  );
7959
8070
  }
7960
8071
  function parsePath(path, depth = 0) {
7961
8072
  const components = path.split("/");
7962
8073
  if (components.length === 0 || components[0] === "m" && depth !== 0) {
7963
- throw new import_errors19.FuelError(import_errors19.ErrorCode.HD_WALLET_ERROR, `invalid path - ${path}`);
8074
+ throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, `invalid path - ${path}`);
7964
8075
  }
7965
8076
  if (components[0] === "m") {
7966
8077
  components.shift();
@@ -7972,8 +8083,8 @@ function parsePath(path, depth = 0) {
7972
8083
  var HDWallet = class {
7973
8084
  depth = 0;
7974
8085
  index = 0;
7975
- fingerprint = (0, import_utils34.hexlify)("0x00000000");
7976
- parentFingerprint = (0, import_utils34.hexlify)("0x00000000");
8086
+ fingerprint = (0, import_utils35.hexlify)("0x00000000");
8087
+ parentFingerprint = (0, import_utils35.hexlify)("0x00000000");
7977
8088
  privateKey;
7978
8089
  publicKey;
7979
8090
  chainCode;
@@ -7985,16 +8096,16 @@ var HDWallet = class {
7985
8096
  constructor(config) {
7986
8097
  if (config.privateKey) {
7987
8098
  const signer = new Signer(config.privateKey);
7988
- this.publicKey = (0, import_utils34.hexlify)(signer.compressedPublicKey);
7989
- this.privateKey = (0, import_utils34.hexlify)(config.privateKey);
8099
+ this.publicKey = (0, import_utils35.hexlify)(signer.compressedPublicKey);
8100
+ this.privateKey = (0, import_utils35.hexlify)(config.privateKey);
7990
8101
  } else {
7991
8102
  if (!config.publicKey) {
7992
- throw new import_errors19.FuelError(
7993
- import_errors19.ErrorCode.HD_WALLET_ERROR,
8103
+ throw new import_errors20.FuelError(
8104
+ import_errors20.ErrorCode.HD_WALLET_ERROR,
7994
8105
  "Both public and private Key cannot be missing. At least one should be provided."
7995
8106
  );
7996
8107
  }
7997
- this.publicKey = (0, import_utils34.hexlify)(config.publicKey);
8108
+ this.publicKey = (0, import_utils35.hexlify)(config.publicKey);
7998
8109
  }
7999
8110
  this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
8000
8111
  this.fingerprint = (0, import_ethers3.dataSlice)((0, import_ethers3.ripemd160)((0, import_hasher6.sha256)(this.publicKey)), 0, 4);
@@ -8013,28 +8124,28 @@ var HDWallet = class {
8013
8124
  * @returns A new instance of HDWallet on the derived index
8014
8125
  */
8015
8126
  deriveIndex(index) {
8016
- const privateKey = this.privateKey && (0, import_utils34.arrayify)(this.privateKey);
8017
- const publicKey = (0, import_utils34.arrayify)(this.publicKey);
8018
- const chainCode = (0, import_utils34.arrayify)(this.chainCode);
8127
+ const privateKey = this.privateKey && (0, import_utils35.arrayify)(this.privateKey);
8128
+ const publicKey = (0, import_utils35.arrayify)(this.publicKey);
8129
+ const chainCode = (0, import_utils35.arrayify)(this.chainCode);
8019
8130
  const data = new Uint8Array(37);
8020
8131
  if (index & HARDENED_INDEX) {
8021
8132
  if (!privateKey) {
8022
- throw new import_errors19.FuelError(
8023
- import_errors19.ErrorCode.HD_WALLET_ERROR,
8133
+ throw new import_errors20.FuelError(
8134
+ import_errors20.ErrorCode.HD_WALLET_ERROR,
8024
8135
  "Cannot derive a hardened index without a private Key."
8025
8136
  );
8026
8137
  }
8027
8138
  data.set(privateKey, 1);
8028
8139
  } else {
8029
- data.set((0, import_utils34.arrayify)(this.publicKey));
8140
+ data.set((0, import_utils35.arrayify)(this.publicKey));
8030
8141
  }
8031
- data.set((0, import_math19.toBytes)(index, 4), 33);
8032
- const bytes = (0, import_utils34.arrayify)((0, import_ethers3.computeHmac)("sha512", chainCode, data));
8142
+ data.set((0, import_math20.toBytes)(index, 4), 33);
8143
+ const bytes = (0, import_utils35.arrayify)((0, import_ethers3.computeHmac)("sha512", chainCode, data));
8033
8144
  const IL = bytes.slice(0, 32);
8034
8145
  const IR = bytes.slice(32);
8035
8146
  if (privateKey) {
8036
8147
  const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
8037
- const ki = (0, import_math19.bn)(IL).add(privateKey).mod(N).toBytes(32);
8148
+ const ki = (0, import_math20.bn)(IL).add(privateKey).mod(N).toBytes(32);
8038
8149
  return new HDWallet({
8039
8150
  privateKey: ki,
8040
8151
  chainCode: IR,
@@ -8043,7 +8154,7 @@ var HDWallet = class {
8043
8154
  parentFingerprint: this.fingerprint
8044
8155
  });
8045
8156
  }
8046
- const signer = new Signer((0, import_utils34.hexlify)(IL));
8157
+ const signer = new Signer((0, import_utils35.hexlify)(IL));
8047
8158
  const Ki = signer.addPoint(publicKey);
8048
8159
  return new HDWallet({
8049
8160
  publicKey: Ki,
@@ -8072,18 +8183,18 @@ var HDWallet = class {
8072
8183
  */
8073
8184
  toExtendedKey(isPublic = false, testnet = false) {
8074
8185
  if (this.depth >= 256) {
8075
- throw new import_errors19.FuelError(
8076
- import_errors19.ErrorCode.HD_WALLET_ERROR,
8186
+ throw new import_errors20.FuelError(
8187
+ import_errors20.ErrorCode.HD_WALLET_ERROR,
8077
8188
  `Exceeded max depth of 255. Current depth: ${this.depth}.`
8078
8189
  );
8079
8190
  }
8080
8191
  const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
8081
- const depth = (0, import_utils34.hexlify)(Uint8Array.from([this.depth]));
8192
+ const depth = (0, import_utils35.hexlify)(Uint8Array.from([this.depth]));
8082
8193
  const parentFingerprint = this.parentFingerprint;
8083
- const index = (0, import_math19.toHex)(this.index, 4);
8194
+ const index = (0, import_math20.toHex)(this.index, 4);
8084
8195
  const chainCode = this.chainCode;
8085
- const key = this.privateKey != null && !isPublic ? (0, import_utils34.concat)(["0x00", this.privateKey]) : this.publicKey;
8086
- const extendedKey = (0, import_utils34.arrayify)((0, import_utils34.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
8196
+ const key = this.privateKey != null && !isPublic ? (0, import_utils35.concat)(["0x00", this.privateKey]) : this.publicKey;
8197
+ const extendedKey = (0, import_utils35.arrayify)((0, import_utils35.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
8087
8198
  return base58check(extendedKey);
8088
8199
  }
8089
8200
  /**
@@ -8095,34 +8206,34 @@ var HDWallet = class {
8095
8206
  static fromSeed(seed) {
8096
8207
  const masterKey = mnemonic_default.masterKeysFromSeed(seed);
8097
8208
  return new HDWallet({
8098
- chainCode: (0, import_utils34.arrayify)(masterKey.slice(32)),
8099
- privateKey: (0, import_utils34.arrayify)(masterKey.slice(0, 32))
8209
+ chainCode: (0, import_utils35.arrayify)(masterKey.slice(32)),
8210
+ privateKey: (0, import_utils35.arrayify)(masterKey.slice(0, 32))
8100
8211
  });
8101
8212
  }
8102
8213
  static fromExtendedKey(extendedKey) {
8103
8214
  const decoded = (0, import_ethers3.toBeHex)((0, import_ethers3.decodeBase58)(extendedKey));
8104
- const bytes = (0, import_utils34.arrayify)(decoded);
8215
+ const bytes = (0, import_utils35.arrayify)(decoded);
8105
8216
  const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
8106
8217
  if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
8107
- throw new import_errors19.FuelError(import_errors19.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
8218
+ throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
8108
8219
  }
8109
8220
  if (!validChecksum) {
8110
- throw new import_errors19.FuelError(import_errors19.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
8221
+ throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
8111
8222
  }
8112
8223
  const depth = bytes[4];
8113
- const parentFingerprint = (0, import_utils34.hexlify)(bytes.slice(5, 9));
8114
- const index = parseInt((0, import_utils34.hexlify)(bytes.slice(9, 13)).substring(2), 16);
8115
- const chainCode = (0, import_utils34.hexlify)(bytes.slice(13, 45));
8224
+ const parentFingerprint = (0, import_utils35.hexlify)(bytes.slice(5, 9));
8225
+ const index = parseInt((0, import_utils35.hexlify)(bytes.slice(9, 13)).substring(2), 16);
8226
+ const chainCode = (0, import_utils35.hexlify)(bytes.slice(13, 45));
8116
8227
  const key = bytes.slice(45, 78);
8117
8228
  if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
8118
- throw new import_errors19.FuelError(
8119
- import_errors19.ErrorCode.HD_WALLET_ERROR,
8229
+ throw new import_errors20.FuelError(
8230
+ import_errors20.ErrorCode.HD_WALLET_ERROR,
8120
8231
  "Inconsistency detected: Depth is zero but fingerprint/index is non-zero."
8121
8232
  );
8122
8233
  }
8123
8234
  if (isPublicExtendedKey(bytes)) {
8124
8235
  if (key[0] !== 3) {
8125
- throw new import_errors19.FuelError(import_errors19.ErrorCode.HD_WALLET_ERROR, "Invalid public extended key.");
8236
+ throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Invalid public extended key.");
8126
8237
  }
8127
8238
  return new HDWallet({
8128
8239
  publicKey: key,
@@ -8133,7 +8244,7 @@ var HDWallet = class {
8133
8244
  });
8134
8245
  }
8135
8246
  if (key[0] !== 0) {
8136
- throw new import_errors19.FuelError(import_errors19.ErrorCode.HD_WALLET_ERROR, "Invalid private extended key.");
8247
+ throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Invalid private extended key.");
8137
8248
  }
8138
8249
  return new HDWallet({
8139
8250
  privateKey: key.slice(1),
@@ -8300,8 +8411,8 @@ __publicField(Wallet, "fromEncryptedJson", WalletUnlocked.fromEncryptedJson);
8300
8411
 
8301
8412
  // src/wallet-manager/wallet-manager.ts
8302
8413
  var import_address9 = require("@fuel-ts/address");
8303
- var import_crypto4 = require("@fuel-ts/crypto");
8304
- var import_errors22 = require("@fuel-ts/errors");
8414
+ var import_crypto5 = require("@fuel-ts/crypto");
8415
+ var import_errors23 = require("@fuel-ts/errors");
8305
8416
  var import_events = require("events");
8306
8417
 
8307
8418
  // src/wallet-manager/storages/memory-storage.ts
@@ -8324,7 +8435,7 @@ var MemoryStorage = class {
8324
8435
 
8325
8436
  // src/wallet-manager/vaults/mnemonic-vault.ts
8326
8437
  var import_address7 = require("@fuel-ts/address");
8327
- var import_errors20 = require("@fuel-ts/errors");
8438
+ var import_errors21 = require("@fuel-ts/errors");
8328
8439
  var _secret;
8329
8440
  var MnemonicVault = class {
8330
8441
  constructor(options) {
@@ -8380,8 +8491,8 @@ var MnemonicVault = class {
8380
8491
  }
8381
8492
  numberOfAccounts += 1;
8382
8493
  } while (numberOfAccounts < this.numberOfAccounts);
8383
- throw new import_errors20.FuelError(
8384
- import_errors20.ErrorCode.WALLET_MANAGER_ERROR,
8494
+ throw new import_errors21.FuelError(
8495
+ import_errors21.ErrorCode.WALLET_MANAGER_ERROR,
8385
8496
  `Account with address '${address}' not found in derived wallets.`
8386
8497
  );
8387
8498
  }
@@ -8395,7 +8506,7 @@ __publicField(MnemonicVault, "type", "mnemonic");
8395
8506
 
8396
8507
  // src/wallet-manager/vaults/privatekey-vault.ts
8397
8508
  var import_address8 = require("@fuel-ts/address");
8398
- var import_errors21 = require("@fuel-ts/errors");
8509
+ var import_errors22 = require("@fuel-ts/errors");
8399
8510
  var _privateKeys;
8400
8511
  var PrivateKeyVault = class {
8401
8512
  /**
@@ -8436,8 +8547,8 @@ var PrivateKeyVault = class {
8436
8547
  (pk) => Wallet.fromPrivateKey(pk).address.equals(ownerAddress)
8437
8548
  );
8438
8549
  if (!privateKey) {
8439
- throw new import_errors21.FuelError(
8440
- import_errors21.ErrorCode.WALLET_MANAGER_ERROR,
8550
+ throw new import_errors22.FuelError(
8551
+ import_errors22.ErrorCode.WALLET_MANAGER_ERROR,
8441
8552
  `No private key found for address '${address}'.`
8442
8553
  );
8443
8554
  }
@@ -8461,7 +8572,7 @@ var ERROR_MESSAGES = {
8461
8572
  };
8462
8573
  function assert(condition, message) {
8463
8574
  if (!condition) {
8464
- throw new import_errors22.FuelError(import_errors22.ErrorCode.WALLET_MANAGER_ERROR, message);
8575
+ throw new import_errors23.FuelError(import_errors23.ErrorCode.WALLET_MANAGER_ERROR, message);
8465
8576
  }
8466
8577
  }
8467
8578
  var _vaults, _passphrase, _isLocked, _serializeVaults, serializeVaults_fn, _deserializeVaults, deserializeVaults_fn;
@@ -8628,7 +8739,7 @@ var _WalletManager = class extends import_events.EventEmitter {
8628
8739
  await assert(!__privateGet(this, _isLocked), ERROR_MESSAGES.wallet_not_unlocked);
8629
8740
  const data = await this.storage.getItem(this.STORAGE_KEY);
8630
8741
  if (data) {
8631
- const state = await (0, import_crypto4.decrypt)(__privateGet(this, _passphrase), JSON.parse(data));
8742
+ const state = await (0, import_crypto5.decrypt)(__privateGet(this, _passphrase), JSON.parse(data));
8632
8743
  __privateSet(this, _vaults, __privateMethod(this, _deserializeVaults, deserializeVaults_fn).call(this, state.vaults));
8633
8744
  }
8634
8745
  }
@@ -8637,7 +8748,7 @@ var _WalletManager = class extends import_events.EventEmitter {
8637
8748
  */
8638
8749
  async saveState() {
8639
8750
  await assert(!__privateGet(this, _isLocked), ERROR_MESSAGES.wallet_not_unlocked);
8640
- const encryptedData = await (0, import_crypto4.encrypt)(__privateGet(this, _passphrase), {
8751
+ const encryptedData = await (0, import_crypto5.encrypt)(__privateGet(this, _passphrase), {
8641
8752
  vaults: __privateMethod(this, _serializeVaults, serializeVaults_fn).call(this, __privateGet(this, _vaults))
8642
8753
  });
8643
8754
  await this.storage.setItem(this.STORAGE_KEY, JSON.stringify(encryptedData));
@@ -8687,25 +8798,25 @@ deserializeVaults_fn = function(vaults) {
8687
8798
  __publicField(WalletManager, "Vaults", [MnemonicVault, PrivateKeyVault]);
8688
8799
 
8689
8800
  // src/wallet-manager/types.ts
8690
- var import_errors23 = require("@fuel-ts/errors");
8801
+ var import_errors24 = require("@fuel-ts/errors");
8691
8802
  var Vault = class {
8692
8803
  constructor(_options) {
8693
- 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.");
8694
8805
  }
8695
8806
  serialize() {
8696
- 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.");
8697
8808
  }
8698
8809
  getAccounts() {
8699
- 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.");
8700
8811
  }
8701
8812
  addAccount() {
8702
- throw new import_errors23.FuelError(import_errors23.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
8813
+ throw new import_errors24.FuelError(import_errors24.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
8703
8814
  }
8704
8815
  exportAccount(_address) {
8705
- throw new import_errors23.FuelError(import_errors23.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
8816
+ throw new import_errors24.FuelError(import_errors24.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
8706
8817
  }
8707
8818
  getWallet(_address) {
8708
- throw new import_errors23.FuelError(import_errors23.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
8819
+ throw new import_errors24.FuelError(import_errors24.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
8709
8820
  }
8710
8821
  };
8711
8822
  __publicField(Vault, "type");
@@ -8713,30 +8824,29 @@ var StorageAbstract = class {
8713
8824
  };
8714
8825
 
8715
8826
  // src/predicate/predicate.ts
8716
- var import_abi_coder5 = require("@fuel-ts/abi-coder");
8827
+ var import_abi_coder7 = require("@fuel-ts/abi-coder");
8717
8828
  var import_address10 = require("@fuel-ts/address");
8718
- var import_configs12 = require("@fuel-ts/address/configs");
8719
- var import_errors24 = require("@fuel-ts/errors");
8720
- var import_transactions19 = require("@fuel-ts/transactions");
8721
- var import_utils36 = require("@fuel-ts/utils");
8829
+ var import_configs13 = require("@fuel-ts/address/configs");
8830
+ var import_errors25 = require("@fuel-ts/errors");
8831
+ var import_transactions20 = require("@fuel-ts/transactions");
8832
+ var import_utils37 = require("@fuel-ts/utils");
8722
8833
 
8723
8834
  // src/predicate/utils/getPredicateRoot.ts
8724
8835
  var import_hasher7 = require("@fuel-ts/hasher");
8725
8836
  var import_merkle = require("@fuel-ts/merkle");
8726
- var import_utils35 = require("@fuel-ts/utils");
8837
+ var import_utils36 = require("@fuel-ts/utils");
8727
8838
  var getPredicateRoot = (bytecode) => {
8728
8839
  const chunkSize = 16 * 1024;
8729
- const bytes = (0, import_utils35.arrayify)(bytecode);
8730
- const chunks = (0, import_utils35.chunkAndPadBytes)(bytes, chunkSize);
8731
- const codeRoot = (0, import_merkle.calcRoot)(chunks.map((c) => (0, import_utils35.hexlify)(c)));
8732
- const predicateRoot = (0, import_hasher7.hash)((0, import_utils35.concat)(["0x4655454C", codeRoot]));
8840
+ const bytes = (0, import_utils36.arrayify)(bytecode);
8841
+ const chunks = (0, import_utils36.chunkAndPadBytes)(bytes, chunkSize);
8842
+ const codeRoot = (0, import_merkle.calcRoot)(chunks.map((c) => (0, import_utils36.hexlify)(c)));
8843
+ const predicateRoot = (0, import_hasher7.hash)((0, import_utils36.concat)(["0x4655454C", codeRoot]));
8733
8844
  return predicateRoot;
8734
8845
  };
8735
8846
 
8736
8847
  // src/predicate/predicate.ts
8737
8848
  var Predicate = class extends Account {
8738
8849
  bytes;
8739
- predicateDataBytes = Uint8Array.from([]);
8740
8850
  predicateData = [];
8741
8851
  interface;
8742
8852
  /**
@@ -8778,7 +8888,7 @@ var Predicate = class extends Account {
8778
8888
  const request = transactionRequestify(transactionRequestLike);
8779
8889
  const { policies } = BaseTransactionRequest.getPolicyMeta(request);
8780
8890
  request.inputs?.forEach((input) => {
8781
- if (input.type === import_transactions19.InputType.Coin && (0, import_utils36.hexlify)(input.owner) === this.address.toB256()) {
8891
+ if (input.type === import_transactions20.InputType.Coin && (0, import_utils37.hexlify)(input.owner) === this.address.toB256()) {
8782
8892
  input.predicate = this.bytes;
8783
8893
  input.predicateData = this.getPredicateData(policies.length);
8784
8894
  }
@@ -8794,7 +8904,7 @@ var Predicate = class extends Account {
8794
8904
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
8795
8905
  * @returns A promise that resolves to the prepared transaction request.
8796
8906
  */
8797
- async createTransfer(destination, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
8907
+ async createTransfer(destination, amount, assetId = import_configs13.BaseAssetId, txParams = {}) {
8798
8908
  const request = await super.createTransfer(destination, amount, assetId, txParams);
8799
8909
  return this.populateTransactionPredicateData(request);
8800
8910
  }
@@ -8823,11 +8933,11 @@ var Predicate = class extends Account {
8823
8933
  return new Uint8Array();
8824
8934
  }
8825
8935
  const mainFn = this.interface?.functions.main;
8826
- const paddedCode = new import_transactions19.ByteArrayCoder(this.bytes.length).encode(this.bytes);
8827
- const VM_TX_MEMORY = (0, import_abi_coder5.calculateVmTxMemory)({
8936
+ const paddedCode = new import_transactions20.ByteArrayCoder(this.bytes.length).encode(this.bytes);
8937
+ const VM_TX_MEMORY = (0, import_abi_coder7.calculateVmTxMemory)({
8828
8938
  maxInputs: this.provider.getChain().consensusParameters.maxInputs.toNumber()
8829
8939
  });
8830
- 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;
8940
+ 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;
8831
8941
  return mainFn?.encodeArguments(this.predicateData, OFFSET) || new Uint8Array();
8832
8942
  }
8833
8943
  /**
@@ -8839,13 +8949,13 @@ var Predicate = class extends Account {
8839
8949
  * @returns An object containing the new predicate bytes and interface.
8840
8950
  */
8841
8951
  static processPredicateData(bytes, jsonAbi, configurableConstants) {
8842
- let predicateBytes = (0, import_utils36.arrayify)(bytes);
8952
+ let predicateBytes = (0, import_utils37.arrayify)(bytes);
8843
8953
  let abiInterface;
8844
8954
  if (jsonAbi) {
8845
- abiInterface = new import_abi_coder5.Interface(jsonAbi);
8955
+ abiInterface = new import_abi_coder7.Interface(jsonAbi);
8846
8956
  if (abiInterface.functions.main === void 0) {
8847
- throw new import_errors24.FuelError(
8848
- import_errors24.ErrorCode.ABI_MAIN_METHOD_MISSING,
8957
+ throw new import_errors25.FuelError(
8958
+ import_errors25.ErrorCode.ABI_MAIN_METHOD_MISSING,
8849
8959
  'Cannot use ABI without "main" function.'
8850
8960
  );
8851
8961
  }
@@ -8890,8 +9000,8 @@ var Predicate = class extends Account {
8890
9000
  mutatedBytes.set(encoded, offset);
8891
9001
  });
8892
9002
  } catch (err) {
8893
- throw new import_errors24.FuelError(
8894
- import_errors24.ErrorCode.INVALID_CONFIGURABLE_CONSTANTS,
9003
+ throw new import_errors25.FuelError(
9004
+ import_errors25.ErrorCode.INVALID_CONFIGURABLE_CONSTANTS,
8895
9005
  `Error setting configurable constants: ${err.message}.`
8896
9006
  );
8897
9007
  }
@@ -8900,7 +9010,7 @@ var Predicate = class extends Account {
8900
9010
  };
8901
9011
 
8902
9012
  // src/connectors/fuel.ts
8903
- var import_errors25 = require("@fuel-ts/errors");
9013
+ var import_errors26 = require("@fuel-ts/errors");
8904
9014
 
8905
9015
  // src/connectors/fuel-connector.ts
8906
9016
  var import_events2 = require("events");
@@ -9533,7 +9643,7 @@ var _Fuel = class extends FuelConnector {
9533
9643
  const currentNetwork = await this.currentNetwork();
9534
9644
  provider = await Provider.create(currentNetwork.url);
9535
9645
  } else {
9536
- throw new import_errors25.FuelError(import_errors25.ErrorCode.INVALID_PROVIDER, "Provider is not valid.");
9646
+ throw new import_errors26.FuelError(import_errors26.ErrorCode.INVALID_PROVIDER, "Provider is not valid.");
9537
9647
  }
9538
9648
  return provider;
9539
9649
  }
@@ -9613,7 +9723,9 @@ __publicField(Fuel, "defaultConfig", {});
9613
9723
  WalletUnlocked,
9614
9724
  addAmountToAsset,
9615
9725
  addOperation,
9726
+ assemblePanicError,
9616
9727
  assembleReceiptByType,
9728
+ assembleRevertError,
9617
9729
  assembleTransactionSummary,
9618
9730
  assets,
9619
9731
  buildBlockExplorerUrl,
@@ -9628,6 +9740,7 @@ __publicField(Fuel, "defaultConfig", {});
9628
9740
  english,
9629
9741
  extractBurnedAssetsFromReceipts,
9630
9742
  extractMintedAssetsFromReceipts,
9743
+ extractTxError,
9631
9744
  gasUsedByInputs,
9632
9745
  getAssetEth,
9633
9746
  getAssetFuel,