@fuel-ts/account 0.79.0 → 0.80.0

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

Potentially problematic release.


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

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