@fuel-ts/account 0.0.0-rc-1832-20240402201930 → 0.0.0-rc-1895-20240403004459

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");
@@ -1303,9 +1306,9 @@ var outputify = (value) => {
1303
1306
 
1304
1307
  // src/providers/transaction-request/transaction-request.ts
1305
1308
  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");
1309
+ var import_configs7 = require("@fuel-ts/address/configs");
1310
+ var import_math7 = require("@fuel-ts/math");
1311
+ var import_transactions6 = require("@fuel-ts/transactions");
1309
1312
  var import_utils9 = require("@fuel-ts/utils");
1310
1313
 
1311
1314
  // src/providers/resource.ts
@@ -1698,6 +1701,78 @@ function sleep(time) {
1698
1701
  });
1699
1702
  }
1700
1703
 
1704
+ // src/providers/utils/extract-tx-error.ts
1705
+ var import_errors7 = require("@fuel-ts/errors");
1706
+ var import_math6 = require("@fuel-ts/math");
1707
+ var import_transactions5 = require("@fuel-ts/transactions");
1708
+ var import_configs6 = require("@fuel-ts/transactions/configs");
1709
+ var assemblePanicError = (status) => {
1710
+ let errorMessage = `The transaction reverted with reason: "${status.reason}".`;
1711
+ const reason = status.reason;
1712
+ if (import_configs6.PANIC_REASONS.includes(status.reason)) {
1713
+ errorMessage = `${errorMessage}
1714
+
1715
+ You can read more about this error at:
1716
+
1717
+ ${import_configs6.PANIC_DOC_URL}#variant.${status.reason}`;
1718
+ }
1719
+ return { errorMessage, reason };
1720
+ };
1721
+ var stringify = (obj) => JSON.stringify(obj, null, 2);
1722
+ var assembleRevertError = (receipts, logs) => {
1723
+ let errorMessage = "The transaction reverted with an unknown reason.";
1724
+ const revertReceipt = receipts.find(({ type }) => type === import_transactions5.ReceiptType.Revert);
1725
+ let reason = "";
1726
+ if (revertReceipt) {
1727
+ const reasonHex = (0, import_math6.bn)(revertReceipt.val).toHex();
1728
+ switch (reasonHex) {
1729
+ case import_configs6.FAILED_REQUIRE_SIGNAL: {
1730
+ reason = "require";
1731
+ errorMessage = `The transaction reverted because a "require" statement has thrown ${logs.length ? stringify(logs[0]) : "an error."}.`;
1732
+ break;
1733
+ }
1734
+ case import_configs6.FAILED_ASSERT_EQ_SIGNAL: {
1735
+ const sufix = logs.length >= 2 ? ` comparing ${stringify(logs[1])} and ${stringify(logs[0])}.` : ".";
1736
+ reason = "assert_eq";
1737
+ errorMessage = `The transaction reverted because of an "assert_eq" statement${sufix}`;
1738
+ break;
1739
+ }
1740
+ case import_configs6.FAILED_ASSERT_NE_SIGNAL: {
1741
+ const sufix = logs.length >= 2 ? ` comparing ${stringify(logs[1])} and ${stringify(logs[0])}.` : ".";
1742
+ reason = "assert_ne";
1743
+ errorMessage = `The transaction reverted because of an "assert_ne" statement${sufix}`;
1744
+ break;
1745
+ }
1746
+ case import_configs6.FAILED_ASSERT_SIGNAL:
1747
+ reason = "assert";
1748
+ errorMessage = `The transaction reverted because an "assert" statement failed to evaluate to true.`;
1749
+ break;
1750
+ case import_configs6.FAILED_TRANSFER_TO_ADDRESS_SIGNAL:
1751
+ reason = "MissingOutputChange";
1752
+ errorMessage = `The transaction reverted because it's missing an "OutputChange".`;
1753
+ break;
1754
+ default:
1755
+ reason = "unknown";
1756
+ errorMessage = `The transaction reverted with an unknown reason: ${revertReceipt.val}`;
1757
+ }
1758
+ }
1759
+ return { errorMessage, reason };
1760
+ };
1761
+ var extractTxError = (params) => {
1762
+ const { receipts, status, logs } = params;
1763
+ const isPanic = receipts.some(({ type }) => type === import_transactions5.ReceiptType.Panic);
1764
+ const isRevert = receipts.some(({ type }) => type === import_transactions5.ReceiptType.Revert);
1765
+ const { errorMessage, reason } = status?.type === "FailureStatus" && isPanic ? assemblePanicError(status) : assembleRevertError(receipts, logs);
1766
+ const metadata = {
1767
+ logs,
1768
+ receipts,
1769
+ panic: isPanic,
1770
+ revert: isRevert,
1771
+ reason
1772
+ };
1773
+ return new import_errors7.FuelError(import_errors7.ErrorCode.SCRIPT_REVERTED, errorMessage, metadata);
1774
+ };
1775
+
1701
1776
  // src/providers/transaction-request/errors.ts
1702
1777
  var ChangeOutputCollisionError = class extends Error {
1703
1778
  name = "ChangeOutputCollisionError";
@@ -1760,10 +1835,10 @@ var BaseTransactionRequest = class {
1760
1835
  outputs,
1761
1836
  witnesses
1762
1837
  } = {}) {
1763
- this.gasPrice = (0, import_math6.bn)(gasPrice);
1838
+ this.gasPrice = (0, import_math7.bn)(gasPrice);
1764
1839
  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;
1840
+ this.witnessLimit = witnessLimit ? (0, import_math7.bn)(witnessLimit) : void 0;
1841
+ this.maxFee = maxFee ? (0, import_math7.bn)(maxFee) : void 0;
1767
1842
  this.inputs = inputs ?? [];
1768
1843
  this.outputs = outputs ?? [];
1769
1844
  this.witnesses = witnesses ?? [];
@@ -1772,20 +1847,20 @@ var BaseTransactionRequest = class {
1772
1847
  let policyTypes = 0;
1773
1848
  const policies = [];
1774
1849
  if (req.gasPrice) {
1775
- policyTypes += import_transactions5.PolicyType.GasPrice;
1776
- policies.push({ data: req.gasPrice, type: import_transactions5.PolicyType.GasPrice });
1850
+ policyTypes += import_transactions6.PolicyType.GasPrice;
1851
+ policies.push({ data: req.gasPrice, type: import_transactions6.PolicyType.GasPrice });
1777
1852
  }
1778
1853
  if (req.witnessLimit) {
1779
- policyTypes += import_transactions5.PolicyType.WitnessLimit;
1780
- policies.push({ data: req.witnessLimit, type: import_transactions5.PolicyType.WitnessLimit });
1854
+ policyTypes += import_transactions6.PolicyType.WitnessLimit;
1855
+ policies.push({ data: req.witnessLimit, type: import_transactions6.PolicyType.WitnessLimit });
1781
1856
  }
1782
1857
  if (req.maturity > 0) {
1783
- policyTypes += import_transactions5.PolicyType.Maturity;
1784
- policies.push({ data: req.maturity, type: import_transactions5.PolicyType.Maturity });
1858
+ policyTypes += import_transactions6.PolicyType.Maturity;
1859
+ policies.push({ data: req.maturity, type: import_transactions6.PolicyType.Maturity });
1785
1860
  }
1786
1861
  if (req.maxFee) {
1787
- policyTypes += import_transactions5.PolicyType.MaxFee;
1788
- policies.push({ data: req.maxFee, type: import_transactions5.PolicyType.MaxFee });
1862
+ policyTypes += import_transactions6.PolicyType.MaxFee;
1863
+ policies.push({ data: req.maxFee, type: import_transactions6.PolicyType.MaxFee });
1789
1864
  }
1790
1865
  return {
1791
1866
  policyTypes,
@@ -1819,7 +1894,7 @@ var BaseTransactionRequest = class {
1819
1894
  * @returns The transaction bytes.
1820
1895
  */
1821
1896
  toTransactionBytes() {
1822
- return new import_transactions5.TransactionCoder().encode(this.toTransaction());
1897
+ return new import_transactions6.TransactionCoder().encode(this.toTransaction());
1823
1898
  }
1824
1899
  /**
1825
1900
  * @hidden
@@ -1859,7 +1934,7 @@ var BaseTransactionRequest = class {
1859
1934
  * @returns The index of the created witness.
1860
1935
  */
1861
1936
  addEmptyWitness() {
1862
- this.addWitness((0, import_utils9.concat)([import_configs6.ZeroBytes32, import_configs6.ZeroBytes32]));
1937
+ this.addWitness((0, import_utils9.concat)([import_configs7.ZeroBytes32, import_configs7.ZeroBytes32]));
1863
1938
  return this.witnesses.length - 1;
1864
1939
  }
1865
1940
  /**
@@ -1910,7 +1985,7 @@ var BaseTransactionRequest = class {
1910
1985
  */
1911
1986
  getCoinInputs() {
1912
1987
  return this.inputs.filter(
1913
- (input) => input.type === import_transactions5.InputType.Coin
1988
+ (input) => input.type === import_transactions6.InputType.Coin
1914
1989
  );
1915
1990
  }
1916
1991
  /**
@@ -1920,7 +1995,7 @@ var BaseTransactionRequest = class {
1920
1995
  */
1921
1996
  getCoinOutputs() {
1922
1997
  return this.outputs.filter(
1923
- (output) => output.type === import_transactions5.OutputType.Coin
1998
+ (output) => output.type === import_transactions6.OutputType.Coin
1924
1999
  );
1925
2000
  }
1926
2001
  /**
@@ -1930,7 +2005,7 @@ var BaseTransactionRequest = class {
1930
2005
  */
1931
2006
  getChangeOutputs() {
1932
2007
  return this.outputs.filter(
1933
- (output) => output.type === import_transactions5.OutputType.Change
2008
+ (output) => output.type === import_transactions6.OutputType.Change
1934
2009
  );
1935
2010
  }
1936
2011
  /**
@@ -1942,9 +2017,9 @@ var BaseTransactionRequest = class {
1942
2017
  const ownerAddress = (0, import_address.addressify)(owner);
1943
2018
  const found = this.inputs.find((input) => {
1944
2019
  switch (input.type) {
1945
- case import_transactions5.InputType.Coin:
2020
+ case import_transactions6.InputType.Coin:
1946
2021
  return (0, import_utils9.hexlify)(input.owner) === ownerAddress.toB256();
1947
- case import_transactions5.InputType.Message:
2022
+ case import_transactions6.InputType.Message:
1948
2023
  return (0, import_utils9.hexlify)(input.recipient) === ownerAddress.toB256();
1949
2024
  default:
1950
2025
  return false;
@@ -1973,7 +2048,7 @@ var BaseTransactionRequest = class {
1973
2048
  }
1974
2049
  const input = {
1975
2050
  ...coin,
1976
- type: import_transactions5.InputType.Coin,
2051
+ type: import_transactions6.InputType.Coin,
1977
2052
  owner: owner.toB256(),
1978
2053
  amount,
1979
2054
  assetId,
@@ -1995,7 +2070,7 @@ var BaseTransactionRequest = class {
1995
2070
  */
1996
2071
  addMessageInput(message, predicate) {
1997
2072
  const { recipient, sender, amount } = message;
1998
- const assetId = import_configs6.BaseAssetId;
2073
+ const assetId = import_configs7.BaseAssetId;
1999
2074
  let witnessIndex;
2000
2075
  if (predicate) {
2001
2076
  witnessIndex = 0;
@@ -2007,7 +2082,7 @@ var BaseTransactionRequest = class {
2007
2082
  }
2008
2083
  const input = {
2009
2084
  ...message,
2010
- type: import_transactions5.InputType.Message,
2085
+ type: import_transactions6.InputType.Message,
2011
2086
  sender: sender.toB256(),
2012
2087
  recipient: recipient.toB256(),
2013
2088
  amount,
@@ -2077,9 +2152,9 @@ var BaseTransactionRequest = class {
2077
2152
  * @param amount - Amount of coin.
2078
2153
  * @param assetId - Asset ID of coin.
2079
2154
  */
2080
- addCoinOutput(to, amount, assetId = import_configs6.BaseAssetId) {
2155
+ addCoinOutput(to, amount, assetId = import_configs7.BaseAssetId) {
2081
2156
  this.pushOutput({
2082
- type: import_transactions5.OutputType.Coin,
2157
+ type: import_transactions6.OutputType.Coin,
2083
2158
  to: (0, import_address.addressify)(to).toB256(),
2084
2159
  amount,
2085
2160
  assetId
@@ -2095,7 +2170,7 @@ var BaseTransactionRequest = class {
2095
2170
  addCoinOutputs(to, quantities) {
2096
2171
  quantities.map(coinQuantityfy).forEach((quantity) => {
2097
2172
  this.pushOutput({
2098
- type: import_transactions5.OutputType.Coin,
2173
+ type: import_transactions6.OutputType.Coin,
2099
2174
  to: (0, import_address.addressify)(to).toB256(),
2100
2175
  amount: quantity.amount,
2101
2176
  assetId: quantity.assetId
@@ -2109,13 +2184,13 @@ var BaseTransactionRequest = class {
2109
2184
  * @param to - Address of the owner.
2110
2185
  * @param assetId - Asset ID of coin.
2111
2186
  */
2112
- addChangeOutput(to, assetId = import_configs6.BaseAssetId) {
2187
+ addChangeOutput(to, assetId = import_configs7.BaseAssetId) {
2113
2188
  const changeOutput = this.getChangeOutputs().find(
2114
2189
  (output) => (0, import_utils9.hexlify)(output.assetId) === assetId
2115
2190
  );
2116
2191
  if (!changeOutput) {
2117
2192
  this.pushOutput({
2118
- type: import_transactions5.OutputType.Change,
2193
+ type: import_transactions6.OutputType.Change,
2119
2194
  to: (0, import_address.addressify)(to).toB256(),
2120
2195
  assetId
2121
2196
  });
@@ -2171,7 +2246,7 @@ var BaseTransactionRequest = class {
2171
2246
  let idCounter = 0;
2172
2247
  const generateId = () => {
2173
2248
  const counterString = String(idCounter++);
2174
- const id = import_configs6.ZeroBytes32.slice(0, -counterString.length).concat(counterString);
2249
+ const id = import_configs7.ZeroBytes32.slice(0, -counterString.length).concat(counterString);
2175
2250
  return id;
2176
2251
  };
2177
2252
  const findAssetInput = (assetId) => this.inputs.find((input) => {
@@ -2193,13 +2268,13 @@ var BaseTransactionRequest = class {
2193
2268
  assetId,
2194
2269
  owner: resourcesOwner || import_address.Address.fromRandom(),
2195
2270
  maturity: 0,
2196
- blockCreated: (0, import_math6.bn)(1),
2197
- txCreatedIdx: (0, import_math6.bn)(1)
2271
+ blockCreated: (0, import_math7.bn)(1),
2272
+ txCreatedIdx: (0, import_math7.bn)(1)
2198
2273
  }
2199
2274
  ]);
2200
2275
  }
2201
2276
  };
2202
- updateAssetInput(import_configs6.BaseAssetId, (0, import_math6.bn)(1e11));
2277
+ updateAssetInput(import_configs7.BaseAssetId, (0, import_math7.bn)(1e11));
2203
2278
  quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
2204
2279
  }
2205
2280
  /**
@@ -2210,7 +2285,7 @@ var BaseTransactionRequest = class {
2210
2285
  */
2211
2286
  getCoinOutputsQuantities() {
2212
2287
  const coinsQuantities = this.getCoinOutputs().map(({ amount, assetId }) => ({
2213
- amount: (0, import_math6.bn)(amount),
2288
+ amount: (0, import_math7.bn)(amount),
2214
2289
  assetId: assetId.toString()
2215
2290
  }));
2216
2291
  return coinsQuantities;
@@ -2228,18 +2303,18 @@ var BaseTransactionRequest = class {
2228
2303
  this.inputs.forEach((i) => {
2229
2304
  let correspondingInput;
2230
2305
  switch (i.type) {
2231
- case import_transactions5.InputType.Coin:
2232
- correspondingInput = inputs.find((x) => x.type === import_transactions5.InputType.Coin && x.owner === i.owner);
2306
+ case import_transactions6.InputType.Coin:
2307
+ correspondingInput = inputs.find((x) => x.type === import_transactions6.InputType.Coin && x.owner === i.owner);
2233
2308
  break;
2234
- case import_transactions5.InputType.Message:
2309
+ case import_transactions6.InputType.Message:
2235
2310
  correspondingInput = inputs.find(
2236
- (x) => x.type === import_transactions5.InputType.Message && x.sender === i.sender
2311
+ (x) => x.type === import_transactions6.InputType.Message && x.sender === i.sender
2237
2312
  );
2238
2313
  break;
2239
2314
  default:
2240
2315
  return;
2241
2316
  }
2242
- if (correspondingInput && "predicateGasUsed" in correspondingInput && (0, import_math6.bn)(correspondingInput.predicateGasUsed).gt(0)) {
2317
+ if (correspondingInput && "predicateGasUsed" in correspondingInput && (0, import_math7.bn)(correspondingInput.predicateGasUsed).gt(0)) {
2243
2318
  i.predicate = correspondingInput.predicate;
2244
2319
  i.predicateData = correspondingInput.predicateData;
2245
2320
  i.predicateGasUsed = correspondingInput.predicateGasUsed;
@@ -2249,47 +2324,47 @@ var BaseTransactionRequest = class {
2249
2324
  };
2250
2325
 
2251
2326
  // 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");
2327
+ var import_configs9 = require("@fuel-ts/address/configs");
2328
+ var import_math9 = require("@fuel-ts/math");
2329
+ var import_transactions8 = require("@fuel-ts/transactions");
2255
2330
  var import_utils13 = require("@fuel-ts/utils");
2256
2331
 
2257
2332
  // src/providers/transaction-request/hash-transaction.ts
2258
- var import_configs7 = require("@fuel-ts/address/configs");
2333
+ var import_configs8 = require("@fuel-ts/address/configs");
2259
2334
  var import_hasher = require("@fuel-ts/hasher");
2260
- var import_math7 = require("@fuel-ts/math");
2261
- var import_transactions6 = require("@fuel-ts/transactions");
2335
+ var import_math8 = require("@fuel-ts/math");
2336
+ var import_transactions7 = require("@fuel-ts/transactions");
2262
2337
  var import_utils11 = require("@fuel-ts/utils");
2263
2338
  var import_ramda2 = require("ramda");
2264
2339
  function hashTransaction(transactionRequest, chainId) {
2265
2340
  const transaction = transactionRequest.toTransaction();
2266
- if (transaction.type === import_transactions6.TransactionType.Script) {
2267
- transaction.receiptsRoot = import_configs7.ZeroBytes32;
2341
+ if (transaction.type === import_transactions7.TransactionType.Script) {
2342
+ transaction.receiptsRoot = import_configs8.ZeroBytes32;
2268
2343
  }
2269
2344
  transaction.inputs = transaction.inputs.map((input) => {
2270
2345
  const inputClone = (0, import_ramda2.clone)(input);
2271
2346
  switch (inputClone.type) {
2272
- case import_transactions6.InputType.Coin: {
2347
+ case import_transactions7.InputType.Coin: {
2273
2348
  inputClone.txPointer = {
2274
2349
  blockHeight: 0,
2275
2350
  txIndex: 0
2276
2351
  };
2277
- inputClone.predicateGasUsed = (0, import_math7.bn)(0);
2352
+ inputClone.predicateGasUsed = (0, import_math8.bn)(0);
2278
2353
  return inputClone;
2279
2354
  }
2280
- case import_transactions6.InputType.Message: {
2281
- inputClone.predicateGasUsed = (0, import_math7.bn)(0);
2355
+ case import_transactions7.InputType.Message: {
2356
+ inputClone.predicateGasUsed = (0, import_math8.bn)(0);
2282
2357
  return inputClone;
2283
2358
  }
2284
- case import_transactions6.InputType.Contract: {
2359
+ case import_transactions7.InputType.Contract: {
2285
2360
  inputClone.txPointer = {
2286
2361
  blockHeight: 0,
2287
2362
  txIndex: 0
2288
2363
  };
2289
- inputClone.txID = import_configs7.ZeroBytes32;
2364
+ inputClone.txID = import_configs8.ZeroBytes32;
2290
2365
  inputClone.outputIndex = 0;
2291
- inputClone.balanceRoot = import_configs7.ZeroBytes32;
2292
- inputClone.stateRoot = import_configs7.ZeroBytes32;
2366
+ inputClone.balanceRoot = import_configs8.ZeroBytes32;
2367
+ inputClone.stateRoot = import_configs8.ZeroBytes32;
2293
2368
  return inputClone;
2294
2369
  }
2295
2370
  default:
@@ -2299,19 +2374,19 @@ function hashTransaction(transactionRequest, chainId) {
2299
2374
  transaction.outputs = transaction.outputs.map((output) => {
2300
2375
  const outputClone = (0, import_ramda2.clone)(output);
2301
2376
  switch (outputClone.type) {
2302
- case import_transactions6.OutputType.Contract: {
2303
- outputClone.balanceRoot = import_configs7.ZeroBytes32;
2304
- outputClone.stateRoot = import_configs7.ZeroBytes32;
2377
+ case import_transactions7.OutputType.Contract: {
2378
+ outputClone.balanceRoot = import_configs8.ZeroBytes32;
2379
+ outputClone.stateRoot = import_configs8.ZeroBytes32;
2305
2380
  return outputClone;
2306
2381
  }
2307
- case import_transactions6.OutputType.Change: {
2308
- outputClone.amount = (0, import_math7.bn)(0);
2382
+ case import_transactions7.OutputType.Change: {
2383
+ outputClone.amount = (0, import_math8.bn)(0);
2309
2384
  return outputClone;
2310
2385
  }
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;
2386
+ case import_transactions7.OutputType.Variable: {
2387
+ outputClone.to = import_configs8.ZeroBytes32;
2388
+ outputClone.amount = (0, import_math8.bn)(0);
2389
+ outputClone.assetId = import_configs8.ZeroBytes32;
2315
2390
  return outputClone;
2316
2391
  }
2317
2392
  default:
@@ -2321,7 +2396,7 @@ function hashTransaction(transactionRequest, chainId) {
2321
2396
  transaction.witnessesCount = 0;
2322
2397
  transaction.witnesses = [];
2323
2398
  const chainIdBytes = (0, import_hasher.uint64ToBytesBE)(chainId);
2324
- const concatenatedData = (0, import_utils11.concat)([chainIdBytes, new import_transactions6.TransactionCoder().encode(transaction)]);
2399
+ const concatenatedData = (0, import_utils11.concat)([chainIdBytes, new import_transactions7.TransactionCoder().encode(transaction)]);
2325
2400
  return (0, import_hasher.sha256)(concatenatedData);
2326
2401
  }
2327
2402
 
@@ -2357,7 +2432,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2357
2432
  return new this(obj);
2358
2433
  }
2359
2434
  /** Type of the transaction */
2360
- type = import_transactions7.TransactionType.Create;
2435
+ type = import_transactions8.TransactionType.Create;
2361
2436
  /** Witness index of contract bytecode to create */
2362
2437
  bytecodeWitnessIndex;
2363
2438
  /** Salt */
@@ -2377,7 +2452,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2377
2452
  } = {}) {
2378
2453
  super(rest);
2379
2454
  this.bytecodeWitnessIndex = bytecodeWitnessIndex ?? 0;
2380
- this.salt = (0, import_utils13.hexlify)(salt ?? import_configs8.ZeroBytes32);
2455
+ this.salt = (0, import_utils13.hexlify)(salt ?? import_configs9.ZeroBytes32);
2381
2456
  this.storageSlots = [...storageSlots ?? []];
2382
2457
  }
2383
2458
  /**
@@ -2390,12 +2465,12 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2390
2465
  const bytecodeWitnessIndex = this.bytecodeWitnessIndex;
2391
2466
  const storageSlots = this.storageSlots?.map(storageSlotify) ?? [];
2392
2467
  return {
2393
- type: import_transactions7.TransactionType.Create,
2468
+ type: import_transactions8.TransactionType.Create,
2394
2469
  ...baseTransaction,
2395
2470
  bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
2396
2471
  bytecodeWitnessIndex,
2397
2472
  storageSlotsCount: storageSlots.length,
2398
- salt: this.salt ? (0, import_utils13.hexlify)(this.salt) : import_configs8.ZeroBytes32,
2473
+ salt: this.salt ? (0, import_utils13.hexlify)(this.salt) : import_configs9.ZeroBytes32,
2399
2474
  storageSlots
2400
2475
  };
2401
2476
  }
@@ -2406,7 +2481,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2406
2481
  */
2407
2482
  getContractCreatedOutputs() {
2408
2483
  return this.outputs.filter(
2409
- (output) => output.type === import_transactions7.OutputType.ContractCreated
2484
+ (output) => output.type === import_transactions8.OutputType.ContractCreated
2410
2485
  );
2411
2486
  }
2412
2487
  /**
@@ -2427,14 +2502,14 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2427
2502
  */
2428
2503
  addContractCreatedOutput(contractId, stateRoot) {
2429
2504
  this.pushOutput({
2430
- type: import_transactions7.OutputType.ContractCreated,
2505
+ type: import_transactions8.OutputType.ContractCreated,
2431
2506
  contractId,
2432
2507
  stateRoot
2433
2508
  });
2434
2509
  }
2435
2510
  metadataGas(gasCosts) {
2436
2511
  return calculateMetadataGasForTxCreate({
2437
- contractBytesSize: (0, import_math8.bn)((0, import_utils13.arrayify)(this.witnesses[this.bytecodeWitnessIndex] || "0x").length),
2512
+ contractBytesSize: (0, import_math9.bn)((0, import_utils13.arrayify)(this.witnesses[this.bytecodeWitnessIndex] || "0x").length),
2438
2513
  gasCosts,
2439
2514
  stateRootSize: this.storageSlots.length,
2440
2515
  txBytesSize: this.byteSize()
@@ -2445,9 +2520,9 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2445
2520
  // src/providers/transaction-request/script-transaction-request.ts
2446
2521
  var import_abi_coder = require("@fuel-ts/abi-coder");
2447
2522
  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");
2523
+ var import_configs10 = require("@fuel-ts/address/configs");
2524
+ var import_math10 = require("@fuel-ts/math");
2525
+ var import_transactions9 = require("@fuel-ts/transactions");
2451
2526
  var import_utils15 = require("@fuel-ts/utils");
2452
2527
 
2453
2528
  // src/providers/transaction-request/scripts.ts
@@ -2485,7 +2560,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2485
2560
  return new this(obj);
2486
2561
  }
2487
2562
  /** Type of the transaction */
2488
- type = import_transactions8.TransactionType.Script;
2563
+ type = import_transactions9.TransactionType.Script;
2489
2564
  /** Gas limit for transaction */
2490
2565
  gasLimit;
2491
2566
  /** Script to execute */
@@ -2500,7 +2575,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2500
2575
  */
2501
2576
  constructor({ script, scriptData, gasLimit, ...rest } = {}) {
2502
2577
  super(rest);
2503
- this.gasLimit = (0, import_math9.bn)(gasLimit);
2578
+ this.gasLimit = (0, import_math10.bn)(gasLimit);
2504
2579
  this.script = (0, import_utils15.arrayify)(script ?? returnZeroScript.bytes);
2505
2580
  this.scriptData = (0, import_utils15.arrayify)(scriptData ?? returnZeroScript.encodeScriptData());
2506
2581
  this.abis = rest.abis;
@@ -2514,12 +2589,12 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2514
2589
  const script = (0, import_utils15.arrayify)(this.script ?? "0x");
2515
2590
  const scriptData = (0, import_utils15.arrayify)(this.scriptData ?? "0x");
2516
2591
  return {
2517
- type: import_transactions8.TransactionType.Script,
2592
+ type: import_transactions9.TransactionType.Script,
2518
2593
  scriptGasLimit: this.gasLimit,
2519
2594
  ...super.getBaseTransaction(),
2520
2595
  scriptLength: script.length,
2521
2596
  scriptDataLength: scriptData.length,
2522
- receiptsRoot: import_configs9.ZeroBytes32,
2597
+ receiptsRoot: import_configs10.ZeroBytes32,
2523
2598
  script: (0, import_utils15.hexlify)(script),
2524
2599
  scriptData: (0, import_utils15.hexlify)(scriptData)
2525
2600
  };
@@ -2531,7 +2606,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2531
2606
  */
2532
2607
  getContractInputs() {
2533
2608
  return this.inputs.filter(
2534
- (input) => input.type === import_transactions8.InputType.Contract
2609
+ (input) => input.type === import_transactions9.InputType.Contract
2535
2610
  );
2536
2611
  }
2537
2612
  /**
@@ -2541,7 +2616,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2541
2616
  */
2542
2617
  getContractOutputs() {
2543
2618
  return this.outputs.filter(
2544
- (output) => output.type === import_transactions8.OutputType.Contract
2619
+ (output) => output.type === import_transactions9.OutputType.Contract
2545
2620
  );
2546
2621
  }
2547
2622
  /**
@@ -2551,7 +2626,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2551
2626
  */
2552
2627
  getVariableOutputs() {
2553
2628
  return this.outputs.filter(
2554
- (output) => output.type === import_transactions8.OutputType.Variable
2629
+ (output) => output.type === import_transactions9.OutputType.Variable
2555
2630
  );
2556
2631
  }
2557
2632
  /**
@@ -2574,7 +2649,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2574
2649
  let outputsNumber = numberOfVariables;
2575
2650
  while (outputsNumber) {
2576
2651
  this.pushOutput({
2577
- type: import_transactions8.OutputType.Variable
2652
+ type: import_transactions9.OutputType.Variable
2578
2653
  });
2579
2654
  outputsNumber -= 1;
2580
2655
  }
@@ -2607,12 +2682,12 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2607
2682
  return this;
2608
2683
  }
2609
2684
  const inputIndex = super.pushInput({
2610
- type: import_transactions8.InputType.Contract,
2685
+ type: import_transactions9.InputType.Contract,
2611
2686
  contractId: contractAddress.toB256(),
2612
2687
  txPointer: "0x00000000000000000000000000000000"
2613
2688
  });
2614
2689
  this.pushOutput({
2615
- type: import_transactions8.OutputType.Contract,
2690
+ type: import_transactions9.OutputType.Contract,
2616
2691
  inputIndex
2617
2692
  });
2618
2693
  return this;
@@ -2648,38 +2723,38 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2648
2723
  };
2649
2724
 
2650
2725
  // src/providers/transaction-request/utils.ts
2651
- var import_errors8 = require("@fuel-ts/errors");
2652
- var import_transactions9 = require("@fuel-ts/transactions");
2726
+ var import_errors9 = require("@fuel-ts/errors");
2727
+ var import_transactions10 = require("@fuel-ts/transactions");
2653
2728
  var transactionRequestify = (obj) => {
2654
2729
  if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest) {
2655
2730
  return obj;
2656
2731
  }
2657
2732
  const { type } = obj;
2658
2733
  switch (obj.type) {
2659
- case import_transactions9.TransactionType.Script: {
2734
+ case import_transactions10.TransactionType.Script: {
2660
2735
  return ScriptTransactionRequest.from(obj);
2661
2736
  }
2662
- case import_transactions9.TransactionType.Create: {
2737
+ case import_transactions10.TransactionType.Create: {
2663
2738
  return CreateTransactionRequest.from(obj);
2664
2739
  }
2665
2740
  default: {
2666
- throw new import_errors8.FuelError(import_errors8.ErrorCode.INVALID_TRANSACTION_TYPE, `Invalid transaction type: ${type}.`);
2741
+ throw new import_errors9.FuelError(import_errors9.ErrorCode.INVALID_TRANSACTION_TYPE, `Invalid transaction type: ${type}.`);
2667
2742
  }
2668
2743
  }
2669
2744
  };
2670
2745
 
2671
2746
  // 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");
2747
+ var import_errors13 = require("@fuel-ts/errors");
2748
+ var import_math14 = require("@fuel-ts/math");
2749
+ var import_transactions17 = require("@fuel-ts/transactions");
2675
2750
  var import_utils21 = require("@fuel-ts/utils");
2676
2751
 
2677
2752
  // src/providers/transaction-summary/assemble-transaction-summary.ts
2678
2753
  var import_utils19 = require("@fuel-ts/utils");
2679
2754
 
2680
2755
  // src/providers/transaction-summary/calculate-transaction-fee.ts
2681
- var import_math10 = require("@fuel-ts/math");
2682
- var import_transactions10 = require("@fuel-ts/transactions");
2756
+ var import_math11 = require("@fuel-ts/math");
2757
+ var import_transactions11 = require("@fuel-ts/transactions");
2683
2758
  var import_utils16 = require("@fuel-ts/utils");
2684
2759
  var calculateTransactionFee = (params) => {
2685
2760
  const {
@@ -2687,24 +2762,24 @@ var calculateTransactionFee = (params) => {
2687
2762
  rawPayload,
2688
2763
  consensusParameters: { gasCosts, feeParams }
2689
2764
  } = params;
2690
- const gasPerByte = (0, import_math10.bn)(feeParams.gasPerByte);
2691
- const gasPriceFactor = (0, import_math10.bn)(feeParams.gasPriceFactor);
2765
+ const gasPerByte = (0, import_math11.bn)(feeParams.gasPerByte);
2766
+ const gasPriceFactor = (0, import_math11.bn)(feeParams.gasPriceFactor);
2692
2767
  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) {
2768
+ const [transaction] = new import_transactions11.TransactionCoder().decode(transactionBytes, 0);
2769
+ if (transaction.type === import_transactions11.TransactionType.Mint) {
2695
2770
  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)
2771
+ fee: (0, import_math11.bn)(0),
2772
+ minFee: (0, import_math11.bn)(0),
2773
+ maxFee: (0, import_math11.bn)(0),
2774
+ feeFromGasUsed: (0, import_math11.bn)(0)
2700
2775
  };
2701
2776
  }
2702
2777
  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) {
2778
+ let metadataGas = (0, import_math11.bn)(0);
2779
+ let gasLimit = (0, import_math11.bn)(0);
2780
+ if (type === import_transactions11.TransactionType.Create) {
2706
2781
  const { bytecodeWitnessIndex, storageSlots } = transaction;
2707
- const contractBytesSize = (0, import_math10.bn)((0, import_utils16.arrayify)(witnesses[bytecodeWitnessIndex].data).length);
2782
+ const contractBytesSize = (0, import_math11.bn)((0, import_utils16.arrayify)(witnesses[bytecodeWitnessIndex].data).length);
2708
2783
  metadataGas = calculateMetadataGasForTxCreate({
2709
2784
  contractBytesSize,
2710
2785
  gasCosts,
@@ -2723,13 +2798,13 @@ var calculateTransactionFee = (params) => {
2723
2798
  }
2724
2799
  const minGas = getMinGas({
2725
2800
  gasCosts,
2726
- gasPerByte: (0, import_math10.bn)(gasPerByte),
2801
+ gasPerByte: (0, import_math11.bn)(gasPerByte),
2727
2802
  inputs,
2728
2803
  metadataGas,
2729
2804
  txBytesSize: transactionBytes.length
2730
2805
  });
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;
2806
+ const gasPrice = (0, import_math11.bn)(policies.find((policy) => policy.type === import_transactions11.PolicyType.GasPrice)?.data);
2807
+ const witnessLimit = policies.find((policy) => policy.type === import_transactions11.PolicyType.WitnessLimit)?.data;
2733
2808
  const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
2734
2809
  const maxGas = getMaxGas({
2735
2810
  gasPerByte,
@@ -2751,14 +2826,14 @@ var calculateTransactionFee = (params) => {
2751
2826
  };
2752
2827
 
2753
2828
  // 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");
2829
+ var import_configs11 = require("@fuel-ts/address/configs");
2830
+ var import_errors11 = require("@fuel-ts/errors");
2831
+ var import_math13 = require("@fuel-ts/math");
2832
+ var import_transactions14 = require("@fuel-ts/transactions");
2758
2833
 
2759
2834
  // src/providers/transaction-summary/call.ts
2760
2835
  var import_abi_coder2 = require("@fuel-ts/abi-coder");
2761
- var import_math11 = require("@fuel-ts/math");
2836
+ var import_math12 = require("@fuel-ts/math");
2762
2837
  var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
2763
2838
  const abiInterface = new import_abi_coder2.Interface(abi);
2764
2839
  const callFunctionSelector = receipt.param1.toHex(8);
@@ -2767,7 +2842,7 @@ var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
2767
2842
  let encodedArgs;
2768
2843
  if (functionFragment.isInputDataPointer) {
2769
2844
  if (rawPayload) {
2770
- const argsOffset = (0, import_math11.bn)(receipt.param2).sub((0, import_abi_coder2.calculateVmTxMemory)({ maxInputs: maxInputs.toNumber() })).toNumber();
2845
+ const argsOffset = (0, import_math12.bn)(receipt.param2).sub((0, import_abi_coder2.calculateVmTxMemory)({ maxInputs: maxInputs.toNumber() })).toNumber();
2771
2846
  encodedArgs = `0x${rawPayload.slice(2).slice(argsOffset * 2)}`;
2772
2847
  }
2773
2848
  } else {
@@ -2801,8 +2876,8 @@ var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
2801
2876
  };
2802
2877
 
2803
2878
  // src/providers/transaction-summary/input.ts
2804
- var import_errors9 = require("@fuel-ts/errors");
2805
- var import_transactions11 = require("@fuel-ts/transactions");
2879
+ var import_errors10 = require("@fuel-ts/errors");
2880
+ var import_transactions12 = require("@fuel-ts/transactions");
2806
2881
  function getInputsByTypes(inputs, types) {
2807
2882
  return inputs.filter((i) => types.includes(i.type));
2808
2883
  }
@@ -2810,16 +2885,16 @@ function getInputsByType(inputs, type) {
2810
2885
  return inputs.filter((i) => i.type === type);
2811
2886
  }
2812
2887
  function getInputsCoin(inputs) {
2813
- return getInputsByType(inputs, import_transactions11.InputType.Coin);
2888
+ return getInputsByType(inputs, import_transactions12.InputType.Coin);
2814
2889
  }
2815
2890
  function getInputsMessage(inputs) {
2816
- return getInputsByType(inputs, import_transactions11.InputType.Message);
2891
+ return getInputsByType(inputs, import_transactions12.InputType.Message);
2817
2892
  }
2818
2893
  function getInputsCoinAndMessage(inputs) {
2819
- return getInputsByTypes(inputs, [import_transactions11.InputType.Coin, import_transactions11.InputType.Message]);
2894
+ return getInputsByTypes(inputs, [import_transactions12.InputType.Coin, import_transactions12.InputType.Message]);
2820
2895
  }
2821
2896
  function getInputsContract(inputs) {
2822
- return getInputsByType(inputs, import_transactions11.InputType.Contract);
2897
+ return getInputsByType(inputs, import_transactions12.InputType.Contract);
2823
2898
  }
2824
2899
  function getInputFromAssetId(inputs, assetId) {
2825
2900
  const coinInputs = getInputsCoin(inputs);
@@ -2838,43 +2913,43 @@ function getInputContractFromIndex(inputs, inputIndex) {
2838
2913
  if (!contractInput) {
2839
2914
  return void 0;
2840
2915
  }
2841
- if (contractInput.type !== import_transactions11.InputType.Contract) {
2842
- throw new import_errors9.FuelError(
2843
- import_errors9.ErrorCode.INVALID_TRANSACTION_INPUT,
2916
+ if (contractInput.type !== import_transactions12.InputType.Contract) {
2917
+ throw new import_errors10.FuelError(
2918
+ import_errors10.ErrorCode.INVALID_TRANSACTION_INPUT,
2844
2919
  `Contract input should be of type 'contract'.`
2845
2920
  );
2846
2921
  }
2847
2922
  return contractInput;
2848
2923
  }
2849
2924
  function getInputAccountAddress(input) {
2850
- if (input.type === import_transactions11.InputType.Coin) {
2925
+ if (input.type === import_transactions12.InputType.Coin) {
2851
2926
  return input.owner.toString();
2852
2927
  }
2853
- if (input.type === import_transactions11.InputType.Message) {
2928
+ if (input.type === import_transactions12.InputType.Message) {
2854
2929
  return input.recipient.toString();
2855
2930
  }
2856
2931
  return "";
2857
2932
  }
2858
2933
 
2859
2934
  // src/providers/transaction-summary/output.ts
2860
- var import_transactions12 = require("@fuel-ts/transactions");
2935
+ var import_transactions13 = require("@fuel-ts/transactions");
2861
2936
  function getOutputsByType(outputs, type) {
2862
2937
  return outputs.filter((o) => o.type === type);
2863
2938
  }
2864
2939
  function getOutputsContractCreated(outputs) {
2865
- return getOutputsByType(outputs, import_transactions12.OutputType.ContractCreated);
2940
+ return getOutputsByType(outputs, import_transactions13.OutputType.ContractCreated);
2866
2941
  }
2867
2942
  function getOutputsCoin(outputs) {
2868
- return getOutputsByType(outputs, import_transactions12.OutputType.Coin);
2943
+ return getOutputsByType(outputs, import_transactions13.OutputType.Coin);
2869
2944
  }
2870
2945
  function getOutputsChange(outputs) {
2871
- return getOutputsByType(outputs, import_transactions12.OutputType.Change);
2946
+ return getOutputsByType(outputs, import_transactions13.OutputType.Change);
2872
2947
  }
2873
2948
  function getOutputsContract(outputs) {
2874
- return getOutputsByType(outputs, import_transactions12.OutputType.Contract);
2949
+ return getOutputsByType(outputs, import_transactions13.OutputType.Contract);
2875
2950
  }
2876
2951
  function getOutputsVariable(outputs) {
2877
- return getOutputsByType(outputs, import_transactions12.OutputType.Variable);
2952
+ return getOutputsByType(outputs, import_transactions13.OutputType.Variable);
2878
2953
  }
2879
2954
 
2880
2955
  // src/providers/transaction-summary/types.ts
@@ -2921,15 +2996,15 @@ function getReceiptsByType(receipts, type) {
2921
2996
  }
2922
2997
  function getTransactionTypeName(transactionType) {
2923
2998
  switch (transactionType) {
2924
- case import_transactions13.TransactionType.Mint:
2999
+ case import_transactions14.TransactionType.Mint:
2925
3000
  return "Mint" /* Mint */;
2926
- case import_transactions13.TransactionType.Create:
3001
+ case import_transactions14.TransactionType.Create:
2927
3002
  return "Create" /* Create */;
2928
- case import_transactions13.TransactionType.Script:
3003
+ case import_transactions14.TransactionType.Script:
2929
3004
  return "Script" /* Script */;
2930
3005
  default:
2931
- throw new import_errors10.FuelError(
2932
- import_errors10.ErrorCode.INVALID_TRANSACTION_TYPE,
3006
+ throw new import_errors11.FuelError(
3007
+ import_errors11.ErrorCode.INVALID_TRANSACTION_TYPE,
2933
3008
  `Invalid transaction type: ${transactionType}.`
2934
3009
  );
2935
3010
  }
@@ -2951,10 +3026,10 @@ function hasSameAssetId(a) {
2951
3026
  return (b) => a.assetId === b.assetId;
2952
3027
  }
2953
3028
  function getReceiptsCall(receipts) {
2954
- return getReceiptsByType(receipts, import_transactions13.ReceiptType.Call);
3029
+ return getReceiptsByType(receipts, import_transactions14.ReceiptType.Call);
2955
3030
  }
2956
3031
  function getReceiptsMessageOut(receipts) {
2957
- return getReceiptsByType(receipts, import_transactions13.ReceiptType.MessageOut);
3032
+ return getReceiptsByType(receipts, import_transactions14.ReceiptType.MessageOut);
2958
3033
  }
2959
3034
  var mergeAssets = (op1, op2) => {
2960
3035
  const assets1 = op1.assetsSent || [];
@@ -2967,7 +3042,7 @@ var mergeAssets = (op1, op2) => {
2967
3042
  if (!matchingAsset) {
2968
3043
  return asset1;
2969
3044
  }
2970
- const mergedAmount = (0, import_math12.bn)(asset1.amount).add(matchingAsset.amount);
3045
+ const mergedAmount = (0, import_math13.bn)(asset1.amount).add(matchingAsset.amount);
2971
3046
  return { ...asset1, amount: mergedAmount };
2972
3047
  });
2973
3048
  return mergedAssets.concat(filteredAssets);
@@ -2993,7 +3068,7 @@ function addOperation(operations, toAdd) {
2993
3068
  return allOperations;
2994
3069
  }
2995
3070
  function getReceiptsTransferOut(receipts) {
2996
- return getReceiptsByType(receipts, import_transactions13.ReceiptType.TransferOut);
3071
+ return getReceiptsByType(receipts, import_transactions14.ReceiptType.TransferOut);
2997
3072
  }
2998
3073
  function getWithdrawFromFuelOperations({
2999
3074
  inputs,
@@ -3096,7 +3171,7 @@ function extractTransferOperationFromReceipt(receipt, contractInputs, changeOutp
3096
3171
  const { to: toAddress, assetId, amount } = receipt;
3097
3172
  let { from: fromAddress } = receipt;
3098
3173
  const toType = contractInputs.some((input) => input.contractID === toAddress) ? 0 /* contract */ : 1 /* account */;
3099
- if (import_configs10.ZeroBytes32 === fromAddress) {
3174
+ if (import_configs11.ZeroBytes32 === fromAddress) {
3100
3175
  const change = changeOutputs.find((output) => output.assetId === assetId);
3101
3176
  fromAddress = change?.to || fromAddress;
3102
3177
  }
@@ -3153,11 +3228,11 @@ function getTransferOperations({
3153
3228
  });
3154
3229
  const transferReceipts = getReceiptsByType(
3155
3230
  receipts,
3156
- import_transactions13.ReceiptType.Transfer
3231
+ import_transactions14.ReceiptType.Transfer
3157
3232
  );
3158
3233
  const transferOutReceipts = getReceiptsByType(
3159
3234
  receipts,
3160
- import_transactions13.ReceiptType.TransferOut
3235
+ import_transactions14.ReceiptType.TransferOut
3161
3236
  );
3162
3237
  [...transferReceipts, ...transferOutReceipts].forEach((receipt) => {
3163
3238
  const operation = extractTransferOperationFromReceipt(receipt, contractInputs, changeOutputs);
@@ -3242,17 +3317,17 @@ function getOperations({
3242
3317
  }
3243
3318
 
3244
3319
  // src/providers/transaction-summary/receipt.ts
3245
- var import_transactions14 = require("@fuel-ts/transactions");
3320
+ var import_transactions15 = require("@fuel-ts/transactions");
3246
3321
  var processGqlReceipt = (gqlReceipt) => {
3247
3322
  const receipt = assembleReceiptByType(gqlReceipt);
3248
3323
  switch (receipt.type) {
3249
- case import_transactions14.ReceiptType.ReturnData: {
3324
+ case import_transactions15.ReceiptType.ReturnData: {
3250
3325
  return {
3251
3326
  ...receipt,
3252
3327
  data: gqlReceipt.data || "0x"
3253
3328
  };
3254
3329
  }
3255
- case import_transactions14.ReceiptType.LogData: {
3330
+ case import_transactions15.ReceiptType.LogData: {
3256
3331
  return {
3257
3332
  ...receipt,
3258
3333
  data: gqlReceipt.data || "0x"
@@ -3265,7 +3340,7 @@ var processGqlReceipt = (gqlReceipt) => {
3265
3340
  var extractMintedAssetsFromReceipts = (receipts) => {
3266
3341
  const mintedAssets = [];
3267
3342
  receipts.forEach((receipt) => {
3268
- if (receipt.type === import_transactions14.ReceiptType.Mint) {
3343
+ if (receipt.type === import_transactions15.ReceiptType.Mint) {
3269
3344
  mintedAssets.push({
3270
3345
  subId: receipt.subId,
3271
3346
  contractId: receipt.contractId,
@@ -3279,7 +3354,7 @@ var extractMintedAssetsFromReceipts = (receipts) => {
3279
3354
  var extractBurnedAssetsFromReceipts = (receipts) => {
3280
3355
  const burnedAssets = [];
3281
3356
  receipts.forEach((receipt) => {
3282
- if (receipt.type === import_transactions14.ReceiptType.Burn) {
3357
+ if (receipt.type === import_transactions15.ReceiptType.Burn) {
3283
3358
  burnedAssets.push({
3284
3359
  subId: receipt.subId,
3285
3360
  contractId: receipt.contractId,
@@ -3292,7 +3367,7 @@ var extractBurnedAssetsFromReceipts = (receipts) => {
3292
3367
  };
3293
3368
 
3294
3369
  // src/providers/transaction-summary/status.ts
3295
- var import_errors11 = require("@fuel-ts/errors");
3370
+ var import_errors12 = require("@fuel-ts/errors");
3296
3371
  var getTransactionStatusName = (gqlStatus) => {
3297
3372
  switch (gqlStatus) {
3298
3373
  case "FailureStatus":
@@ -3304,8 +3379,8 @@ var getTransactionStatusName = (gqlStatus) => {
3304
3379
  case "SqueezedOutStatus":
3305
3380
  return "squeezedout" /* squeezedout */;
3306
3381
  default:
3307
- throw new import_errors11.FuelError(
3308
- import_errors11.ErrorCode.INVALID_TRANSACTION_STATUS,
3382
+ throw new import_errors12.FuelError(
3383
+ import_errors12.ErrorCode.INVALID_TRANSACTION_STATUS,
3309
3384
  `Invalid transaction status: ${gqlStatus}.`
3310
3385
  );
3311
3386
  }
@@ -3418,12 +3493,12 @@ function assembleTransactionSummary(params) {
3418
3493
 
3419
3494
  // src/providers/transaction-response/getDecodedLogs.ts
3420
3495
  var import_abi_coder3 = require("@fuel-ts/abi-coder");
3421
- var import_transactions15 = require("@fuel-ts/transactions");
3496
+ var import_transactions16 = require("@fuel-ts/transactions");
3422
3497
  function getDecodedLogs(receipts, mainAbi, externalAbis = {}) {
3423
3498
  return receipts.reduce((logs, receipt) => {
3424
- if (receipt.type === import_transactions15.ReceiptType.LogData || receipt.type === import_transactions15.ReceiptType.Log) {
3499
+ if (receipt.type === import_transactions16.ReceiptType.LogData || receipt.type === import_transactions16.ReceiptType.Log) {
3425
3500
  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;
3501
+ const data = receipt.type === import_transactions16.ReceiptType.Log ? new import_abi_coder3.BigNumberCoder("u64").encode(receipt.val0) : receipt.data;
3427
3502
  const [decodedLog] = interfaceToUse.decodeLog(data, receipt.val1.toNumber());
3428
3503
  logs.push(decodedLog);
3429
3504
  }
@@ -3438,7 +3513,7 @@ var TransactionResponse = class {
3438
3513
  /** Current provider */
3439
3514
  provider;
3440
3515
  /** Gas used on the transaction */
3441
- gasUsed = (0, import_math13.bn)(0);
3516
+ gasUsed = (0, import_math14.bn)(0);
3442
3517
  /** The graphql Transaction with receipts object. */
3443
3518
  gqlTransaction;
3444
3519
  abis;
@@ -3496,7 +3571,7 @@ var TransactionResponse = class {
3496
3571
  * @returns The decoded transaction.
3497
3572
  */
3498
3573
  decodeTransaction(transactionWithReceipts) {
3499
- return new import_transactions16.TransactionCoder().decode(
3574
+ return new import_transactions17.TransactionCoder().decode(
3500
3575
  (0, import_utils21.arrayify)(transactionWithReceipts.rawPayload),
3501
3576
  0
3502
3577
  )?.[0];
@@ -3543,8 +3618,8 @@ var TransactionResponse = class {
3543
3618
  });
3544
3619
  for await (const { statusChange } of subscription) {
3545
3620
  if (statusChange.type === "SqueezedOutStatus") {
3546
- throw new import_errors12.FuelError(
3547
- import_errors12.ErrorCode.TRANSACTION_SQUEEZED_OUT,
3621
+ throw new import_errors13.FuelError(
3622
+ import_errors13.ErrorCode.TRANSACTION_SQUEEZED_OUT,
3548
3623
  `Transaction Squeezed Out with reason: ${statusChange.reason}`
3549
3624
  );
3550
3625
  }
@@ -3566,14 +3641,26 @@ var TransactionResponse = class {
3566
3641
  gqlTransaction: this.gqlTransaction,
3567
3642
  ...transactionSummary
3568
3643
  };
3644
+ let logs = [];
3569
3645
  if (this.abis) {
3570
- const logs = getDecodedLogs(
3646
+ logs = getDecodedLogs(
3571
3647
  transactionSummary.receipts,
3572
3648
  this.abis.main,
3573
3649
  this.abis.otherContractsAbis
3574
3650
  );
3575
3651
  transactionResult.logs = logs;
3576
3652
  }
3653
+ if (transactionResult.isStatusFailure) {
3654
+ const {
3655
+ receipts,
3656
+ gqlTransaction: { status }
3657
+ } = transactionResult;
3658
+ throw extractTxError({
3659
+ receipts,
3660
+ status,
3661
+ logs
3662
+ });
3663
+ }
3577
3664
  return transactionResult;
3578
3665
  }
3579
3666
  /**
@@ -3582,14 +3669,7 @@ var TransactionResponse = class {
3582
3669
  * @param contractsAbiMap - The contracts ABI map.
3583
3670
  */
3584
3671
  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;
3672
+ return this.waitForResult(contractsAbiMap);
3593
3673
  }
3594
3674
  };
3595
3675
 
@@ -3651,29 +3731,29 @@ var processGqlChain = (chain) => {
3651
3731
  const { contractParams, feeParams, predicateParams, scriptParams, txParams, gasCosts } = consensusParameters;
3652
3732
  return {
3653
3733
  name,
3654
- baseChainHeight: (0, import_math14.bn)(daHeight),
3734
+ baseChainHeight: (0, import_math15.bn)(daHeight),
3655
3735
  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),
3736
+ contractMaxSize: (0, import_math15.bn)(contractParams.contractMaxSize),
3737
+ maxInputs: (0, import_math15.bn)(txParams.maxInputs),
3738
+ maxOutputs: (0, import_math15.bn)(txParams.maxOutputs),
3739
+ maxWitnesses: (0, import_math15.bn)(txParams.maxWitnesses),
3740
+ maxGasPerTx: (0, import_math15.bn)(txParams.maxGasPerTx),
3741
+ maxScriptLength: (0, import_math15.bn)(scriptParams.maxScriptLength),
3742
+ maxScriptDataLength: (0, import_math15.bn)(scriptParams.maxScriptDataLength),
3743
+ maxStorageSlots: (0, import_math15.bn)(contractParams.maxStorageSlots),
3744
+ maxPredicateLength: (0, import_math15.bn)(predicateParams.maxPredicateLength),
3745
+ maxPredicateDataLength: (0, import_math15.bn)(predicateParams.maxPredicateDataLength),
3746
+ maxGasPerPredicate: (0, import_math15.bn)(predicateParams.maxGasPerPredicate),
3747
+ gasPriceFactor: (0, import_math15.bn)(feeParams.gasPriceFactor),
3748
+ gasPerByte: (0, import_math15.bn)(feeParams.gasPerByte),
3749
+ maxMessageDataLength: (0, import_math15.bn)(predicateParams.maxMessageDataLength),
3750
+ chainId: (0, import_math15.bn)(consensusParameters.chainId),
3671
3751
  gasCosts
3672
3752
  },
3673
3753
  gasCosts,
3674
3754
  latestBlock: {
3675
3755
  id: latestBlock.id,
3676
- height: (0, import_math14.bn)(latestBlock.header.height),
3756
+ height: (0, import_math15.bn)(latestBlock.header.height),
3677
3757
  time: latestBlock.header.time,
3678
3758
  transactions: latestBlock.transactions.map((i) => ({
3679
3759
  id: i.id
@@ -3743,8 +3823,8 @@ var _Provider = class {
3743
3823
  getChain() {
3744
3824
  const chain = _Provider.chainInfoCache[this.url];
3745
3825
  if (!chain) {
3746
- throw new import_errors13.FuelError(
3747
- import_errors13.ErrorCode.CHAIN_INFO_CACHE_EMPTY,
3826
+ throw new import_errors14.FuelError(
3827
+ import_errors14.ErrorCode.CHAIN_INFO_CACHE_EMPTY,
3748
3828
  "Chain info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
3749
3829
  );
3750
3830
  }
@@ -3756,8 +3836,8 @@ var _Provider = class {
3756
3836
  getNode() {
3757
3837
  const node = _Provider.nodeInfoCache[this.url];
3758
3838
  if (!node) {
3759
- throw new import_errors13.FuelError(
3760
- import_errors13.ErrorCode.NODE_INFO_CACHE_EMPTY,
3839
+ throw new import_errors14.FuelError(
3840
+ import_errors14.ErrorCode.NODE_INFO_CACHE_EMPTY,
3761
3841
  "Node info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
3762
3842
  );
3763
3843
  }
@@ -3804,8 +3884,8 @@ var _Provider = class {
3804
3884
  static ensureClientVersionIsSupported(nodeInfo) {
3805
3885
  const { isMajorSupported, isMinorSupported, supportedVersion } = (0, import_versions.checkFuelCoreVersionCompatibility)(nodeInfo.nodeVersion);
3806
3886
  if (!isMajorSupported || !isMinorSupported) {
3807
- throw new import_errors13.FuelError(
3808
- import_errors13.FuelError.CODES.UNSUPPORTED_FUEL_CLIENT_VERSION,
3887
+ throw new import_errors14.FuelError(
3888
+ import_errors14.FuelError.CODES.UNSUPPORTED_FUEL_CLIENT_VERSION,
3809
3889
  `Fuel client version: ${nodeInfo.nodeVersion}, Supported version: ${supportedVersion}`
3810
3890
  );
3811
3891
  }
@@ -3868,7 +3948,7 @@ var _Provider = class {
3868
3948
  */
3869
3949
  async getBlockNumber() {
3870
3950
  const { chain } = await this.operations.getChain();
3871
- return (0, import_math14.bn)(chain.latestBlock.header.height, 10);
3951
+ return (0, import_math15.bn)(chain.latestBlock.header.height, 10);
3872
3952
  }
3873
3953
  /**
3874
3954
  * Returns the chain information.
@@ -3878,9 +3958,9 @@ var _Provider = class {
3878
3958
  async fetchNode() {
3879
3959
  const { nodeInfo } = await this.operations.getNodeInfo();
3880
3960
  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),
3961
+ maxDepth: (0, import_math15.bn)(nodeInfo.maxDepth),
3962
+ maxTx: (0, import_math15.bn)(nodeInfo.maxTx),
3963
+ minGasPrice: (0, import_math15.bn)(nodeInfo.minGasPrice),
3884
3964
  nodeVersion: nodeInfo.nodeVersion,
3885
3965
  utxoValidation: nodeInfo.utxoValidation,
3886
3966
  vmBacktrace: nodeInfo.vmBacktrace,
@@ -3926,17 +4006,17 @@ var _Provider = class {
3926
4006
  if (estimateTxDependencies) {
3927
4007
  await this.estimateTxDependencies(transactionRequest);
3928
4008
  }
3929
- const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
4009
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
3930
4010
  let abis;
3931
- if (transactionRequest.type === import_transactions17.TransactionType.Script) {
4011
+ if (transactionRequest.type === import_transactions18.TransactionType.Script) {
3932
4012
  abis = transactionRequest.abis;
3933
4013
  }
3934
4014
  if (awaitExecution) {
3935
4015
  const subscription = this.operations.submitAndAwait({ encodedTransaction });
3936
4016
  for await (const { submitAndAwait } of subscription) {
3937
4017
  if (submitAndAwait.type === "SqueezedOutStatus") {
3938
- throw new import_errors13.FuelError(
3939
- import_errors13.ErrorCode.TRANSACTION_SQUEEZED_OUT,
4018
+ throw new import_errors14.FuelError(
4019
+ import_errors14.ErrorCode.TRANSACTION_SQUEEZED_OUT,
3940
4020
  `Transaction Squeezed Out with reason: ${submitAndAwait.reason}`
3941
4021
  );
3942
4022
  }
@@ -3969,7 +4049,7 @@ var _Provider = class {
3969
4049
  if (estimateTxDependencies) {
3970
4050
  return this.estimateTxDependencies(transactionRequest);
3971
4051
  }
3972
- const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
4052
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
3973
4053
  const { dryRun: gqlReceipts } = await this.operations.dryRun({
3974
4054
  encodedTransaction,
3975
4055
  utxoValidation: utxoValidation || false
@@ -3988,13 +4068,13 @@ var _Provider = class {
3988
4068
  async estimatePredicates(transactionRequest) {
3989
4069
  const shouldEstimatePredicates = Boolean(
3990
4070
  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()
4071
+ (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
4072
  )
3993
4073
  );
3994
4074
  if (!shouldEstimatePredicates) {
3995
4075
  return transactionRequest;
3996
4076
  }
3997
- const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
4077
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
3998
4078
  const response = await this.operations.estimatePredicates({
3999
4079
  encodedTransaction
4000
4080
  });
@@ -4003,7 +4083,7 @@ var _Provider = class {
4003
4083
  } = response;
4004
4084
  if (inputs) {
4005
4085
  inputs.forEach((input, index) => {
4006
- if ("predicateGasUsed" in input && (0, import_math14.bn)(input.predicateGasUsed).gt(0)) {
4086
+ if ("predicateGasUsed" in input && (0, import_math15.bn)(input.predicateGasUsed).gt(0)) {
4007
4087
  transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
4008
4088
  }
4009
4089
  });
@@ -4024,7 +4104,7 @@ var _Provider = class {
4024
4104
  * @returns A promise.
4025
4105
  */
4026
4106
  async estimateTxDependencies(transactionRequest) {
4027
- if (transactionRequest.type === import_transactions17.TransactionType.Create) {
4107
+ if (transactionRequest.type === import_transactions18.TransactionType.Create) {
4028
4108
  return {
4029
4109
  receipts: [],
4030
4110
  outputVariables: 0,
@@ -4037,7 +4117,7 @@ var _Provider = class {
4037
4117
  let outputVariables = 0;
4038
4118
  for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
4039
4119
  const { dryRun: gqlReceipts } = await this.operations.dryRun({
4040
- encodedTransaction: (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes()),
4120
+ encodedTransaction: (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes()),
4041
4121
  utxoValidation: false
4042
4122
  });
4043
4123
  receipts = gqlReceipts.map(processGqlReceipt);
@@ -4075,7 +4155,7 @@ var _Provider = class {
4075
4155
  if (estimateTxDependencies) {
4076
4156
  return this.estimateTxDependencies(transactionRequest);
4077
4157
  }
4078
- const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
4158
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
4079
4159
  const { dryRun: gqlReceipts } = await this.operations.dryRun({
4080
4160
  encodedTransaction,
4081
4161
  utxoValidation: true
@@ -4109,14 +4189,14 @@ var _Provider = class {
4109
4189
  const txRequestClone = (0, import_ramda3.clone)(transactionRequestify(transactionRequestLike));
4110
4190
  const chainInfo = this.getChain();
4111
4191
  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;
4192
+ const gasPrice = (0, import_math15.max)(txRequestClone.gasPrice, minGasPrice);
4193
+ const isScriptTransaction = txRequestClone.type === import_transactions18.TransactionType.Script;
4114
4194
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
4115
4195
  const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
4116
4196
  txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
4117
4197
  if (estimatePredicates) {
4118
4198
  if (isScriptTransaction) {
4119
- txRequestClone.gasLimit = (0, import_math14.bn)(0);
4199
+ txRequestClone.gasLimit = (0, import_math15.bn)(0);
4120
4200
  }
4121
4201
  if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
4122
4202
  resourcesOwner.populateTransactionPredicateData(txRequestClone);
@@ -4132,8 +4212,8 @@ var _Provider = class {
4132
4212
  let missingContractIds = [];
4133
4213
  let outputVariables = 0;
4134
4214
  if (isScriptTransaction && estimateTxDependencies) {
4135
- txRequestClone.gasPrice = (0, import_math14.bn)(0);
4136
- txRequestClone.gasLimit = (0, import_math14.bn)(maxGasPerTx.sub(maxGas).toNumber() * 0.9);
4215
+ txRequestClone.gasPrice = (0, import_math15.bn)(0);
4216
+ txRequestClone.gasLimit = (0, import_math15.bn)(maxGasPerTx.sub(maxGas).toNumber() * 0.9);
4137
4217
  const result = await this.estimateTxDependencies(txRequestClone);
4138
4218
  receipts = result.receipts;
4139
4219
  outputVariables = result.outputVariables;
@@ -4189,17 +4269,17 @@ var _Provider = class {
4189
4269
  const result = await this.operations.getCoins({
4190
4270
  first: 10,
4191
4271
  ...paginationArgs,
4192
- filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils22.hexlify)(assetId) }
4272
+ filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils23.hexlify)(assetId) }
4193
4273
  });
4194
4274
  const coins = result.coins.edges.map((edge) => edge.node);
4195
4275
  return coins.map((coin) => ({
4196
4276
  id: coin.utxoId,
4197
4277
  assetId: coin.assetId,
4198
- amount: (0, import_math14.bn)(coin.amount),
4278
+ amount: (0, import_math15.bn)(coin.amount),
4199
4279
  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)
4280
+ maturity: (0, import_math15.bn)(coin.maturity).toNumber(),
4281
+ blockCreated: (0, import_math15.bn)(coin.blockCreated),
4282
+ txCreatedIdx: (0, import_math15.bn)(coin.txCreatedIdx)
4203
4283
  }));
4204
4284
  }
4205
4285
  /**
@@ -4213,19 +4293,19 @@ var _Provider = class {
4213
4293
  async getResourcesToSpend(owner, quantities, excludedIds) {
4214
4294
  const ownerAddress = import_address3.Address.fromAddressOrString(owner);
4215
4295
  const excludeInput = {
4216
- messages: excludedIds?.messages?.map((nonce) => (0, import_utils22.hexlify)(nonce)) || [],
4217
- utxos: excludedIds?.utxos?.map((id) => (0, import_utils22.hexlify)(id)) || []
4296
+ messages: excludedIds?.messages?.map((nonce) => (0, import_utils23.hexlify)(nonce)) || [],
4297
+ utxos: excludedIds?.utxos?.map((id) => (0, import_utils23.hexlify)(id)) || []
4218
4298
  };
4219
4299
  if (this.cache) {
4220
4300
  const uniqueUtxos = new Set(
4221
- excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0, import_utils22.hexlify)(id)))
4301
+ excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0, import_utils23.hexlify)(id)))
4222
4302
  );
4223
4303
  excludeInput.utxos = Array.from(uniqueUtxos);
4224
4304
  }
4225
4305
  const coinsQuery = {
4226
4306
  owner: ownerAddress.toB256(),
4227
4307
  queryPerAsset: quantities.map(coinQuantityfy).map(({ assetId, amount, max: maxPerAsset }) => ({
4228
- assetId: (0, import_utils22.hexlify)(assetId),
4308
+ assetId: (0, import_utils23.hexlify)(assetId),
4229
4309
  amount: amount.toString(10),
4230
4310
  max: maxPerAsset ? maxPerAsset.toString(10) : void 0
4231
4311
  })),
@@ -4236,9 +4316,9 @@ var _Provider = class {
4236
4316
  switch (coin.__typename) {
4237
4317
  case "MessageCoin":
4238
4318
  return {
4239
- amount: (0, import_math14.bn)(coin.amount),
4319
+ amount: (0, import_math15.bn)(coin.amount),
4240
4320
  assetId: coin.assetId,
4241
- daHeight: (0, import_math14.bn)(coin.daHeight),
4321
+ daHeight: (0, import_math15.bn)(coin.daHeight),
4242
4322
  sender: import_address3.Address.fromAddressOrString(coin.sender),
4243
4323
  recipient: import_address3.Address.fromAddressOrString(coin.recipient),
4244
4324
  nonce: coin.nonce
@@ -4246,12 +4326,12 @@ var _Provider = class {
4246
4326
  case "Coin":
4247
4327
  return {
4248
4328
  id: coin.utxoId,
4249
- amount: (0, import_math14.bn)(coin.amount),
4329
+ amount: (0, import_math15.bn)(coin.amount),
4250
4330
  assetId: coin.assetId,
4251
4331
  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)
4332
+ maturity: (0, import_math15.bn)(coin.maturity).toNumber(),
4333
+ blockCreated: (0, import_math15.bn)(coin.blockCreated),
4334
+ txCreatedIdx: (0, import_math15.bn)(coin.txCreatedIdx)
4255
4335
  };
4256
4336
  default:
4257
4337
  return null;
@@ -4268,13 +4348,13 @@ var _Provider = class {
4268
4348
  async getBlock(idOrHeight) {
4269
4349
  let variables;
4270
4350
  if (typeof idOrHeight === "number") {
4271
- variables = { height: (0, import_math14.bn)(idOrHeight).toString(10) };
4351
+ variables = { height: (0, import_math15.bn)(idOrHeight).toString(10) };
4272
4352
  } else if (idOrHeight === "latest") {
4273
4353
  variables = { height: (await this.getBlockNumber()).toString(10) };
4274
4354
  } else if (idOrHeight.length === 66) {
4275
4355
  variables = { blockId: idOrHeight };
4276
4356
  } else {
4277
- variables = { blockId: (0, import_math14.bn)(idOrHeight).toString(10) };
4357
+ variables = { blockId: (0, import_math15.bn)(idOrHeight).toString(10) };
4278
4358
  }
4279
4359
  const { block } = await this.operations.getBlock(variables);
4280
4360
  if (!block) {
@@ -4282,7 +4362,7 @@ var _Provider = class {
4282
4362
  }
4283
4363
  return {
4284
4364
  id: block.id,
4285
- height: (0, import_math14.bn)(block.header.height),
4365
+ height: (0, import_math15.bn)(block.header.height),
4286
4366
  time: block.header.time,
4287
4367
  transactionIds: block.transactions.map((tx) => tx.id)
4288
4368
  };
@@ -4297,7 +4377,7 @@ var _Provider = class {
4297
4377
  const { blocks: fetchedData } = await this.operations.getBlocks(params);
4298
4378
  const blocks = fetchedData.edges.map(({ node: block }) => ({
4299
4379
  id: block.id,
4300
- height: (0, import_math14.bn)(block.header.height),
4380
+ height: (0, import_math15.bn)(block.header.height),
4301
4381
  time: block.header.time,
4302
4382
  transactionIds: block.transactions.map((tx) => tx.id)
4303
4383
  }));
@@ -4312,7 +4392,7 @@ var _Provider = class {
4312
4392
  async getBlockWithTransactions(idOrHeight) {
4313
4393
  let variables;
4314
4394
  if (typeof idOrHeight === "number") {
4315
- variables = { blockHeight: (0, import_math14.bn)(idOrHeight).toString(10) };
4395
+ variables = { blockHeight: (0, import_math15.bn)(idOrHeight).toString(10) };
4316
4396
  } else if (idOrHeight === "latest") {
4317
4397
  variables = { blockHeight: (await this.getBlockNumber()).toString() };
4318
4398
  } else {
@@ -4324,11 +4404,11 @@ var _Provider = class {
4324
4404
  }
4325
4405
  return {
4326
4406
  id: block.id,
4327
- height: (0, import_math14.bn)(block.header.height, 10),
4407
+ height: (0, import_math15.bn)(block.header.height, 10),
4328
4408
  time: block.header.time,
4329
4409
  transactionIds: block.transactions.map((tx) => tx.id),
4330
4410
  transactions: block.transactions.map(
4331
- (tx) => new import_transactions17.TransactionCoder().decode((0, import_utils22.arrayify)(tx.rawPayload), 0)?.[0]
4411
+ (tx) => new import_transactions18.TransactionCoder().decode((0, import_utils23.arrayify)(tx.rawPayload), 0)?.[0]
4332
4412
  )
4333
4413
  };
4334
4414
  }
@@ -4343,8 +4423,8 @@ var _Provider = class {
4343
4423
  if (!transaction) {
4344
4424
  return null;
4345
4425
  }
4346
- return new import_transactions17.TransactionCoder().decode(
4347
- (0, import_utils22.arrayify)(transaction.rawPayload),
4426
+ return new import_transactions18.TransactionCoder().decode(
4427
+ (0, import_utils23.arrayify)(transaction.rawPayload),
4348
4428
  0
4349
4429
  )?.[0];
4350
4430
  }
@@ -4371,9 +4451,9 @@ var _Provider = class {
4371
4451
  async getContractBalance(contractId, assetId) {
4372
4452
  const { contractBalance } = await this.operations.getContractBalance({
4373
4453
  contract: import_address3.Address.fromAddressOrString(contractId).toB256(),
4374
- asset: (0, import_utils22.hexlify)(assetId)
4454
+ asset: (0, import_utils23.hexlify)(assetId)
4375
4455
  });
4376
- return (0, import_math14.bn)(contractBalance.amount, 10);
4456
+ return (0, import_math15.bn)(contractBalance.amount, 10);
4377
4457
  }
4378
4458
  /**
4379
4459
  * Returns the balance for the given owner for the given asset ID.
@@ -4385,9 +4465,9 @@ var _Provider = class {
4385
4465
  async getBalance(owner, assetId) {
4386
4466
  const { balance } = await this.operations.getBalance({
4387
4467
  owner: import_address3.Address.fromAddressOrString(owner).toB256(),
4388
- assetId: (0, import_utils22.hexlify)(assetId)
4468
+ assetId: (0, import_utils23.hexlify)(assetId)
4389
4469
  });
4390
- return (0, import_math14.bn)(balance.amount, 10);
4470
+ return (0, import_math15.bn)(balance.amount, 10);
4391
4471
  }
4392
4472
  /**
4393
4473
  * Returns balances for the given owner.
@@ -4405,7 +4485,7 @@ var _Provider = class {
4405
4485
  const balances = result.balances.edges.map((edge) => edge.node);
4406
4486
  return balances.map((balance) => ({
4407
4487
  assetId: balance.assetId,
4408
- amount: (0, import_math14.bn)(balance.amount)
4488
+ amount: (0, import_math15.bn)(balance.amount)
4409
4489
  }));
4410
4490
  }
4411
4491
  /**
@@ -4423,19 +4503,19 @@ var _Provider = class {
4423
4503
  });
4424
4504
  const messages = result.messages.edges.map((edge) => edge.node);
4425
4505
  return messages.map((message) => ({
4426
- messageId: import_transactions17.InputMessageCoder.getMessageId({
4506
+ messageId: import_transactions18.InputMessageCoder.getMessageId({
4427
4507
  sender: message.sender,
4428
4508
  recipient: message.recipient,
4429
4509
  nonce: message.nonce,
4430
- amount: (0, import_math14.bn)(message.amount),
4510
+ amount: (0, import_math15.bn)(message.amount),
4431
4511
  data: message.data
4432
4512
  }),
4433
4513
  sender: import_address3.Address.fromAddressOrString(message.sender),
4434
4514
  recipient: import_address3.Address.fromAddressOrString(message.recipient),
4435
4515
  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)
4516
+ amount: (0, import_math15.bn)(message.amount),
4517
+ data: import_transactions18.InputMessageCoder.decodeData(message.data),
4518
+ daHeight: (0, import_math15.bn)(message.daHeight)
4439
4519
  }));
4440
4520
  }
4441
4521
  /**
@@ -4453,8 +4533,8 @@ var _Provider = class {
4453
4533
  nonce
4454
4534
  };
4455
4535
  if (commitBlockId && commitBlockHeight) {
4456
- throw new import_errors13.FuelError(
4457
- import_errors13.ErrorCode.INVALID_INPUT_PARAMETERS,
4536
+ throw new import_errors14.FuelError(
4537
+ import_errors14.ErrorCode.INVALID_INPUT_PARAMETERS,
4458
4538
  "commitBlockId and commitBlockHeight cannot be used together"
4459
4539
  );
4460
4540
  }
@@ -4488,41 +4568,41 @@ var _Provider = class {
4488
4568
  } = result.messageProof;
4489
4569
  return {
4490
4570
  messageProof: {
4491
- proofIndex: (0, import_math14.bn)(messageProof.proofIndex),
4571
+ proofIndex: (0, import_math15.bn)(messageProof.proofIndex),
4492
4572
  proofSet: messageProof.proofSet
4493
4573
  },
4494
4574
  blockProof: {
4495
- proofIndex: (0, import_math14.bn)(blockProof.proofIndex),
4575
+ proofIndex: (0, import_math15.bn)(blockProof.proofIndex),
4496
4576
  proofSet: blockProof.proofSet
4497
4577
  },
4498
4578
  messageBlockHeader: {
4499
4579
  id: messageBlockHeader.id,
4500
- daHeight: (0, import_math14.bn)(messageBlockHeader.daHeight),
4501
- transactionsCount: (0, import_math14.bn)(messageBlockHeader.transactionsCount),
4580
+ daHeight: (0, import_math15.bn)(messageBlockHeader.daHeight),
4581
+ transactionsCount: (0, import_math15.bn)(messageBlockHeader.transactionsCount),
4502
4582
  transactionsRoot: messageBlockHeader.transactionsRoot,
4503
- height: (0, import_math14.bn)(messageBlockHeader.height),
4583
+ height: (0, import_math15.bn)(messageBlockHeader.height),
4504
4584
  prevRoot: messageBlockHeader.prevRoot,
4505
4585
  time: messageBlockHeader.time,
4506
4586
  applicationHash: messageBlockHeader.applicationHash,
4507
4587
  messageReceiptRoot: messageBlockHeader.messageReceiptRoot,
4508
- messageReceiptCount: (0, import_math14.bn)(messageBlockHeader.messageReceiptCount)
4588
+ messageReceiptCount: (0, import_math15.bn)(messageBlockHeader.messageReceiptCount)
4509
4589
  },
4510
4590
  commitBlockHeader: {
4511
4591
  id: commitBlockHeader.id,
4512
- daHeight: (0, import_math14.bn)(commitBlockHeader.daHeight),
4513
- transactionsCount: (0, import_math14.bn)(commitBlockHeader.transactionsCount),
4592
+ daHeight: (0, import_math15.bn)(commitBlockHeader.daHeight),
4593
+ transactionsCount: (0, import_math15.bn)(commitBlockHeader.transactionsCount),
4514
4594
  transactionsRoot: commitBlockHeader.transactionsRoot,
4515
- height: (0, import_math14.bn)(commitBlockHeader.height),
4595
+ height: (0, import_math15.bn)(commitBlockHeader.height),
4516
4596
  prevRoot: commitBlockHeader.prevRoot,
4517
4597
  time: commitBlockHeader.time,
4518
4598
  applicationHash: commitBlockHeader.applicationHash,
4519
4599
  messageReceiptRoot: commitBlockHeader.messageReceiptRoot,
4520
- messageReceiptCount: (0, import_math14.bn)(commitBlockHeader.messageReceiptCount)
4600
+ messageReceiptCount: (0, import_math15.bn)(commitBlockHeader.messageReceiptCount)
4521
4601
  },
4522
4602
  sender: import_address3.Address.fromAddressOrString(sender),
4523
4603
  recipient: import_address3.Address.fromAddressOrString(recipient),
4524
4604
  nonce,
4525
- amount: (0, import_math14.bn)(amount),
4605
+ amount: (0, import_math15.bn)(amount),
4526
4606
  data
4527
4607
  };
4528
4608
  }
@@ -4545,10 +4625,10 @@ var _Provider = class {
4545
4625
  */
4546
4626
  async produceBlocks(amount, startTime) {
4547
4627
  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
4628
+ blocksToProduce: (0, import_math15.bn)(amount).toString(10),
4629
+ startTimestamp: startTime ? import_utils23.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
4550
4630
  });
4551
- return (0, import_math14.bn)(latestBlockHeight);
4631
+ return (0, import_math15.bn)(latestBlockHeight);
4552
4632
  }
4553
4633
  // eslint-disable-next-line @typescript-eslint/require-await
4554
4634
  async getTransactionResponse(transactionId) {
@@ -4562,7 +4642,7 @@ cacheInputs_fn = function(inputs) {
4562
4642
  return;
4563
4643
  }
4564
4644
  inputs.forEach((input) => {
4565
- if (input.type === import_transactions17.InputType.Coin) {
4645
+ if (input.type === import_transactions18.InputType.Coin) {
4566
4646
  this.cache?.set(input.id);
4567
4647
  }
4568
4648
  });
@@ -4571,23 +4651,23 @@ __publicField(Provider, "chainInfoCache", {});
4571
4651
  __publicField(Provider, "nodeInfoCache", {});
4572
4652
 
4573
4653
  // 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");
4654
+ var import_errors15 = require("@fuel-ts/errors");
4655
+ var import_math16 = require("@fuel-ts/math");
4656
+ var import_transactions19 = require("@fuel-ts/transactions");
4657
+ var import_utils26 = require("@fuel-ts/utils");
4578
4658
  async function getTransactionSummary(params) {
4579
4659
  const { id, provider, abiMap } = params;
4580
4660
  const { transaction: gqlTransaction } = await provider.operations.getTransactionWithReceipts({
4581
4661
  transactionId: id
4582
4662
  });
4583
4663
  if (!gqlTransaction) {
4584
- throw new import_errors14.FuelError(
4585
- import_errors14.ErrorCode.TRANSACTION_NOT_FOUND,
4664
+ throw new import_errors15.FuelError(
4665
+ import_errors15.ErrorCode.TRANSACTION_NOT_FOUND,
4586
4666
  `Transaction not found for given id: ${id}.`
4587
4667
  );
4588
4668
  }
4589
- const [decodedTransaction] = new import_transactions18.TransactionCoder().decode(
4590
- (0, import_utils25.arrayify)(gqlTransaction.rawPayload),
4669
+ const [decodedTransaction] = new import_transactions19.TransactionCoder().decode(
4670
+ (0, import_utils26.arrayify)(gqlTransaction.rawPayload),
4591
4671
  0
4592
4672
  );
4593
4673
  const receipts = gqlTransaction.receipts?.map(processGqlReceipt) || [];
@@ -4598,10 +4678,10 @@ async function getTransactionSummary(params) {
4598
4678
  id: gqlTransaction.id,
4599
4679
  receipts,
4600
4680
  transaction: decodedTransaction,
4601
- transactionBytes: (0, import_utils25.arrayify)(gqlTransaction.rawPayload),
4681
+ transactionBytes: (0, import_utils26.arrayify)(gqlTransaction.rawPayload),
4602
4682
  gqlTransactionStatus: gqlTransaction.status,
4603
- gasPerByte: (0, import_math15.bn)(gasPerByte),
4604
- gasPriceFactor: (0, import_math15.bn)(gasPriceFactor),
4683
+ gasPerByte: (0, import_math16.bn)(gasPerByte),
4684
+ gasPriceFactor: (0, import_math16.bn)(gasPriceFactor),
4605
4685
  abiMap,
4606
4686
  maxInputs,
4607
4687
  gasCosts
@@ -4640,13 +4720,13 @@ async function getTransactionsSummaries(params) {
4640
4720
  const transactions = edges.map((edge) => {
4641
4721
  const { node: gqlTransaction } = edge;
4642
4722
  const { id, rawPayload, receipts: gqlReceipts, status } = gqlTransaction;
4643
- const [decodedTransaction] = new import_transactions18.TransactionCoder().decode((0, import_utils25.arrayify)(rawPayload), 0);
4723
+ const [decodedTransaction] = new import_transactions19.TransactionCoder().decode((0, import_utils26.arrayify)(rawPayload), 0);
4644
4724
  const receipts = gqlReceipts?.map(processGqlReceipt) || [];
4645
4725
  const transactionSummary = assembleTransactionSummary({
4646
4726
  id,
4647
4727
  receipts,
4648
4728
  transaction: decodedTransaction,
4649
- transactionBytes: (0, import_utils25.arrayify)(rawPayload),
4729
+ transactionBytes: (0, import_utils26.arrayify)(rawPayload),
4650
4730
  gqlTransactionStatus: status,
4651
4731
  abiMap,
4652
4732
  gasPerByte,
@@ -4789,17 +4869,17 @@ var assets = [
4789
4869
 
4790
4870
  // src/utils/formatTransferToContractScriptData.ts
4791
4871
  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");
4872
+ var import_math17 = require("@fuel-ts/math");
4873
+ var import_utils27 = require("@fuel-ts/utils");
4794
4874
  var asm = __toESM(require("@fuels/vm-asm"));
4795
4875
  var formatTransferToContractScriptData = (params) => {
4796
4876
  const { assetId, amountToTransfer, hexlifiedContractId } = params;
4797
4877
  const numberCoder = new import_abi_coder4.BigNumberCoder("u64");
4798
- const encoded = numberCoder.encode(new import_math16.BN(amountToTransfer).toNumber());
4878
+ const encoded = numberCoder.encode(new import_math17.BN(amountToTransfer).toNumber());
4799
4879
  const scriptData = Uint8Array.from([
4800
- ...(0, import_utils26.arrayify)(hexlifiedContractId),
4880
+ ...(0, import_utils27.arrayify)(hexlifiedContractId),
4801
4881
  ...encoded,
4802
- ...(0, import_utils26.arrayify)(assetId)
4882
+ ...(0, import_utils27.arrayify)(assetId)
4803
4883
  ]);
4804
4884
  return scriptData;
4805
4885
  };
@@ -4855,7 +4935,7 @@ var Account = class extends import_interfaces.AbstractAccount {
4855
4935
  */
4856
4936
  get provider() {
4857
4937
  if (!this._provider) {
4858
- throw new import_errors15.FuelError(import_errors15.ErrorCode.MISSING_PROVIDER, "Provider not set");
4938
+ throw new import_errors16.FuelError(import_errors16.ErrorCode.MISSING_PROVIDER, "Provider not set");
4859
4939
  }
4860
4940
  return this._provider;
4861
4941
  }
@@ -4907,8 +4987,8 @@ var Account = class extends import_interfaces.AbstractAccount {
4907
4987
  if (!hasNextPage) {
4908
4988
  break;
4909
4989
  }
4910
- throw new import_errors15.FuelError(
4911
- import_errors15.ErrorCode.NOT_SUPPORTED,
4990
+ throw new import_errors16.FuelError(
4991
+ import_errors16.ErrorCode.NOT_SUPPORTED,
4912
4992
  `Wallets containing more than ${pageSize} coins exceed the current supported limit.`
4913
4993
  );
4914
4994
  }
@@ -4933,8 +5013,8 @@ var Account = class extends import_interfaces.AbstractAccount {
4933
5013
  if (!hasNextPage) {
4934
5014
  break;
4935
5015
  }
4936
- throw new import_errors15.FuelError(
4937
- import_errors15.ErrorCode.NOT_SUPPORTED,
5016
+ throw new import_errors16.FuelError(
5017
+ import_errors16.ErrorCode.NOT_SUPPORTED,
4938
5018
  `Wallets containing more than ${pageSize} messages exceed the current supported limit.`
4939
5019
  );
4940
5020
  }
@@ -4946,7 +5026,7 @@ var Account = class extends import_interfaces.AbstractAccount {
4946
5026
  * @param assetId - The asset ID to check the balance for.
4947
5027
  * @returns A promise that resolves to the balance amount.
4948
5028
  */
4949
- async getBalance(assetId = import_configs11.BaseAssetId) {
5029
+ async getBalance(assetId = import_configs12.BaseAssetId) {
4950
5030
  const amount = await this.provider.getBalance(this.address, assetId);
4951
5031
  return amount;
4952
5032
  }
@@ -4969,8 +5049,8 @@ var Account = class extends import_interfaces.AbstractAccount {
4969
5049
  if (!hasNextPage) {
4970
5050
  break;
4971
5051
  }
4972
- throw new import_errors15.FuelError(
4973
- import_errors15.ErrorCode.NOT_SUPPORTED,
5052
+ throw new import_errors16.FuelError(
5053
+ import_errors16.ErrorCode.NOT_SUPPORTED,
4974
5054
  `Wallets containing more than ${pageSize} balances exceed the current supported limit.`
4975
5055
  );
4976
5056
  }
@@ -4986,15 +5066,15 @@ var Account = class extends import_interfaces.AbstractAccount {
4986
5066
  */
4987
5067
  async fund(request, coinQuantities, fee) {
4988
5068
  const updatedQuantities = addAmountToAsset({
4989
- amount: (0, import_math17.bn)(fee),
4990
- assetId: import_configs11.BaseAssetId,
5069
+ amount: (0, import_math18.bn)(fee),
5070
+ assetId: import_configs12.BaseAssetId,
4991
5071
  coinQuantities
4992
5072
  });
4993
5073
  const quantitiesDict = {};
4994
5074
  updatedQuantities.forEach(({ amount, assetId }) => {
4995
5075
  quantitiesDict[assetId] = {
4996
5076
  required: amount,
4997
- owned: (0, import_math17.bn)(0)
5077
+ owned: (0, import_math18.bn)(0)
4998
5078
  };
4999
5079
  });
5000
5080
  const cachedUtxos = [];
@@ -5007,12 +5087,12 @@ var Account = class extends import_interfaces.AbstractAccount {
5007
5087
  if (isCoin2) {
5008
5088
  const assetId = String(input.assetId);
5009
5089
  if (input.owner === owner && quantitiesDict[assetId]) {
5010
- const amount = (0, import_math17.bn)(input.amount);
5090
+ const amount = (0, import_math18.bn)(input.amount);
5011
5091
  quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
5012
5092
  cachedUtxos.push(input.id);
5013
5093
  }
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);
5094
+ } else if (input.recipient === owner && input.amount && quantitiesDict[import_configs12.BaseAssetId]) {
5095
+ quantitiesDict[import_configs12.BaseAssetId].owned = quantitiesDict[import_configs12.BaseAssetId].owned.add(input.amount);
5016
5096
  cachedMessages.push(input.nonce);
5017
5097
  }
5018
5098
  }
@@ -5044,7 +5124,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5044
5124
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
5045
5125
  * @returns A promise that resolves to the prepared transaction request.
5046
5126
  */
5047
- async createTransfer(destination, amount, assetId = import_configs11.BaseAssetId, txParams = {}) {
5127
+ async createTransfer(destination, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
5048
5128
  const { minGasPrice } = this.provider.getGasConfig();
5049
5129
  const params = { gasPrice: minGasPrice, ...txParams };
5050
5130
  const request = new ScriptTransactionRequest(params);
@@ -5053,8 +5133,8 @@ var Account = class extends import_interfaces.AbstractAccount {
5053
5133
  estimateTxDependencies: true,
5054
5134
  resourcesOwner: this
5055
5135
  });
5056
- request.gasPrice = (0, import_math17.bn)(txParams.gasPrice ?? minGasPrice);
5057
- request.gasLimit = (0, import_math17.bn)(txParams.gasLimit ?? gasUsed);
5136
+ request.gasPrice = (0, import_math18.bn)(txParams.gasPrice ?? minGasPrice);
5137
+ request.gasLimit = (0, import_math18.bn)(txParams.gasLimit ?? gasUsed);
5058
5138
  this.validateGas({
5059
5139
  gasUsed,
5060
5140
  gasPrice: request.gasPrice,
@@ -5074,10 +5154,10 @@ var Account = class extends import_interfaces.AbstractAccount {
5074
5154
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
5075
5155
  * @returns A promise that resolves to the transaction response.
5076
5156
  */
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,
5157
+ async transfer(destination, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
5158
+ if ((0, import_math18.bn)(amount).lte(0)) {
5159
+ throw new import_errors16.FuelError(
5160
+ import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
5081
5161
  "Transfer amount must be a positive number."
5082
5162
  );
5083
5163
  }
@@ -5093,10 +5173,10 @@ var Account = class extends import_interfaces.AbstractAccount {
5093
5173
  * @param txParams - The optional transaction parameters.
5094
5174
  * @returns A promise that resolves to the transaction response.
5095
5175
  */
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,
5176
+ async transferToContract(contractId, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
5177
+ if ((0, import_math18.bn)(amount).lte(0)) {
5178
+ throw new import_errors16.FuelError(
5179
+ import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
5100
5180
  "Transfer amount must be a positive number."
5101
5181
  );
5102
5182
  }
@@ -5105,7 +5185,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5105
5185
  const params = { gasPrice: minGasPrice, ...txParams };
5106
5186
  const { script, scriptData } = await assembleTransferToContractScript({
5107
5187
  hexlifiedContractId: contractAddress.toB256(),
5108
- amountToTransfer: (0, import_math17.bn)(amount),
5188
+ amountToTransfer: (0, import_math18.bn)(amount),
5109
5189
  assetId
5110
5190
  });
5111
5191
  const request = new ScriptTransactionRequest({
@@ -5116,9 +5196,9 @@ var Account = class extends import_interfaces.AbstractAccount {
5116
5196
  request.addContractInputAndOutput(contractAddress);
5117
5197
  const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
5118
5198
  request,
5119
- [{ amount: (0, import_math17.bn)(amount), assetId: String(assetId) }]
5199
+ [{ amount: (0, import_math18.bn)(amount), assetId: String(assetId) }]
5120
5200
  );
5121
- request.gasLimit = (0, import_math17.bn)(params.gasLimit ?? gasUsed);
5201
+ request.gasLimit = (0, import_math18.bn)(params.gasLimit ?? gasUsed);
5122
5202
  this.validateGas({
5123
5203
  gasUsed,
5124
5204
  gasPrice: request.gasPrice,
@@ -5139,25 +5219,25 @@ var Account = class extends import_interfaces.AbstractAccount {
5139
5219
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
5140
5220
  const { minGasPrice } = this.provider.getGasConfig();
5141
5221
  const recipientAddress = import_address4.Address.fromAddressOrString(recipient);
5142
- const recipientDataArray = (0, import_utils27.arrayify)(
5222
+ const recipientDataArray = (0, import_utils28.arrayify)(
5143
5223
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
5144
5224
  );
5145
- const amountDataArray = (0, import_utils27.arrayify)(
5146
- "0x".concat((0, import_math17.bn)(amount).toHex().substring(2).padStart(16, "0"))
5225
+ const amountDataArray = (0, import_utils28.arrayify)(
5226
+ "0x".concat((0, import_math18.bn)(amount).toHex().substring(2).padStart(16, "0"))
5147
5227
  );
5148
5228
  const script = new Uint8Array([
5149
- ...(0, import_utils27.arrayify)(withdrawScript.bytes),
5229
+ ...(0, import_utils28.arrayify)(withdrawScript.bytes),
5150
5230
  ...recipientDataArray,
5151
5231
  ...amountDataArray
5152
5232
  ]);
5153
5233
  const params = { script, gasPrice: minGasPrice, ...txParams };
5154
5234
  const request = new ScriptTransactionRequest(params);
5155
- const forwardingQuantities = [{ amount: (0, import_math17.bn)(amount), assetId: import_configs11.BaseAssetId }];
5235
+ const forwardingQuantities = [{ amount: (0, import_math18.bn)(amount), assetId: import_configs12.BaseAssetId }];
5156
5236
  const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
5157
5237
  request,
5158
5238
  forwardingQuantities
5159
5239
  );
5160
- request.gasLimit = (0, import_math17.bn)(params.gasLimit ?? gasUsed);
5240
+ request.gasLimit = (0, import_math18.bn)(params.gasLimit ?? gasUsed);
5161
5241
  this.validateGas({
5162
5242
  gasUsed,
5163
5243
  gasPrice: request.gasPrice,
@@ -5169,7 +5249,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5169
5249
  }
5170
5250
  async signMessage(message) {
5171
5251
  if (!this._connector) {
5172
- throw new import_errors15.FuelError(import_errors15.ErrorCode.MISSING_CONNECTOR, "A connector is required to sign messages.");
5252
+ throw new import_errors16.FuelError(import_errors16.ErrorCode.MISSING_CONNECTOR, "A connector is required to sign messages.");
5173
5253
  }
5174
5254
  return this._connector.signMessage(this.address.toString(), message);
5175
5255
  }
@@ -5181,8 +5261,8 @@ var Account = class extends import_interfaces.AbstractAccount {
5181
5261
  */
5182
5262
  async signTransaction(transactionRequestLike) {
5183
5263
  if (!this._connector) {
5184
- throw new import_errors15.FuelError(
5185
- import_errors15.ErrorCode.MISSING_CONNECTOR,
5264
+ throw new import_errors16.FuelError(
5265
+ import_errors16.ErrorCode.MISSING_CONNECTOR,
5186
5266
  "A connector is required to sign transactions."
5187
5267
  );
5188
5268
  }
@@ -5229,14 +5309,14 @@ var Account = class extends import_interfaces.AbstractAccount {
5229
5309
  minGasPrice
5230
5310
  }) {
5231
5311
  if (minGasPrice.gt(gasPrice)) {
5232
- throw new import_errors15.FuelError(
5233
- import_errors15.ErrorCode.GAS_PRICE_TOO_LOW,
5312
+ throw new import_errors16.FuelError(
5313
+ import_errors16.ErrorCode.GAS_PRICE_TOO_LOW,
5234
5314
  `Gas price '${gasPrice}' is lower than the required: '${minGasPrice}'.`
5235
5315
  );
5236
5316
  }
5237
5317
  if (gasUsed.gt(gasLimit)) {
5238
- throw new import_errors15.FuelError(
5239
- import_errors15.ErrorCode.GAS_LIMIT_TOO_LOW,
5318
+ throw new import_errors16.FuelError(
5319
+ import_errors16.ErrorCode.GAS_LIMIT_TOO_LOW,
5240
5320
  `Gas limit '${gasLimit}' is lower than the required: '${gasUsed}'.`
5241
5321
  );
5242
5322
  }
@@ -5245,14 +5325,14 @@ var Account = class extends import_interfaces.AbstractAccount {
5245
5325
 
5246
5326
  // src/wallet/base-wallet-unlocked.ts
5247
5327
  var import_hasher3 = require("@fuel-ts/hasher");
5248
- var import_utils30 = require("@fuel-ts/utils");
5328
+ var import_utils31 = require("@fuel-ts/utils");
5249
5329
 
5250
5330
  // src/signer/signer.ts
5251
5331
  var import_address5 = require("@fuel-ts/address");
5252
5332
  var import_crypto = require("@fuel-ts/crypto");
5253
5333
  var import_hasher2 = require("@fuel-ts/hasher");
5254
- var import_math18 = require("@fuel-ts/math");
5255
- var import_utils28 = require("@fuel-ts/utils");
5334
+ var import_math19 = require("@fuel-ts/math");
5335
+ var import_utils29 = require("@fuel-ts/utils");
5256
5336
  var import_secp256k1 = require("@noble/curves/secp256k1");
5257
5337
  var Signer = class {
5258
5338
  address;
@@ -5271,10 +5351,10 @@ var Signer = class {
5271
5351
  privateKey = `0x${privateKey}`;
5272
5352
  }
5273
5353
  }
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));
5354
+ const privateKeyBytes = (0, import_math19.toBytes)(privateKey, 32);
5355
+ this.privateKey = (0, import_utils29.hexlify)(privateKeyBytes);
5356
+ this.publicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
5357
+ this.compressedPublicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
5278
5358
  this.address = import_address5.Address.fromPublicKey(this.publicKey);
5279
5359
  }
5280
5360
  /**
@@ -5288,11 +5368,11 @@ var Signer = class {
5288
5368
  * @returns hashed signature
5289
5369
  */
5290
5370
  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);
5371
+ const signature = import_secp256k1.secp256k1.sign((0, import_utils29.arrayify)(data), (0, import_utils29.arrayify)(this.privateKey));
5372
+ const r = (0, import_math19.toBytes)(`0x${signature.r.toString(16)}`, 32);
5373
+ const s = (0, import_math19.toBytes)(`0x${signature.s.toString(16)}`, 32);
5294
5374
  s[0] |= (signature.recovery || 0) << 7;
5295
- return (0, import_utils28.hexlify)((0, import_utils28.concat)([r, s]));
5375
+ return (0, import_utils29.hexlify)((0, import_utils29.concat)([r, s]));
5296
5376
  }
5297
5377
  /**
5298
5378
  * Add point on the current elliptic curve
@@ -5301,8 +5381,8 @@ var Signer = class {
5301
5381
  * @returns compressed point on the curve
5302
5382
  */
5303
5383
  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));
5384
+ const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(this.compressedPublicKey));
5385
+ const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(point));
5306
5386
  const result = p0.add(p1);
5307
5387
  return `0x${result.toHex(true)}`;
5308
5388
  }
@@ -5314,16 +5394,16 @@ var Signer = class {
5314
5394
  * @returns public key from signature from the
5315
5395
  */
5316
5396
  static recoverPublicKey(data, signature) {
5317
- const signedMessageBytes = (0, import_utils28.arrayify)(signature);
5397
+ const signedMessageBytes = (0, import_utils29.arrayify)(signature);
5318
5398
  const r = signedMessageBytes.slice(0, 32);
5319
5399
  const s = signedMessageBytes.slice(32, 64);
5320
5400
  const recoveryParam = (s[0] & 128) >> 7;
5321
5401
  s[0] &= 127;
5322
- const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils28.hexlify)(r)), BigInt((0, import_utils28.hexlify)(s))).addRecoveryBit(
5402
+ const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils29.hexlify)(r)), BigInt((0, import_utils29.hexlify)(s))).addRecoveryBit(
5323
5403
  recoveryParam
5324
5404
  );
5325
- const publicKey = sig.recoverPublicKey((0, import_utils28.arrayify)(data)).toRawBytes(false).slice(1);
5326
- return (0, import_utils28.hexlify)(publicKey);
5405
+ const publicKey = sig.recoverPublicKey((0, import_utils29.arrayify)(data)).toRawBytes(false).slice(1);
5406
+ return (0, import_utils29.hexlify)(publicKey);
5327
5407
  }
5328
5408
  /**
5329
5409
  * Recover the address from a signature performed with [`sign`](#sign).
@@ -5342,7 +5422,7 @@ var Signer = class {
5342
5422
  * @returns random 32-byte hashed
5343
5423
  */
5344
5424
  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);
5425
+ return entropy ? (0, import_hasher2.hash)((0, import_utils29.concat)([(0, import_crypto.randomBytes)(32), (0, import_utils29.arrayify)(entropy)])) : (0, import_crypto.randomBytes)(32);
5346
5426
  }
5347
5427
  /**
5348
5428
  * Extended publicKey from a compact publicKey
@@ -5351,16 +5431,16 @@ var Signer = class {
5351
5431
  * @returns extended publicKey
5352
5432
  */
5353
5433
  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));
5434
+ const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(publicKey));
5435
+ return (0, import_utils29.hexlify)(point.toRawBytes(false).slice(1));
5356
5436
  }
5357
5437
  };
5358
5438
 
5359
5439
  // src/wallet/keystore-wallet.ts
5360
5440
  var import_address6 = require("@fuel-ts/address");
5361
5441
  var import_crypto2 = require("@fuel-ts/crypto");
5362
- var import_errors16 = require("@fuel-ts/errors");
5363
- var import_utils29 = require("@fuel-ts/utils");
5442
+ var import_errors17 = require("@fuel-ts/errors");
5443
+ var import_utils30 = require("@fuel-ts/utils");
5364
5444
  var import_uuid = require("uuid");
5365
5445
  var DEFAULT_KDF_PARAMS_LOG_N = 13;
5366
5446
  var DEFAULT_KDF_PARAMS_R = 8;
@@ -5437,13 +5517,13 @@ async function decryptKeystoreWallet(jsonWallet, password) {
5437
5517
  const macHashUint8Array = (0, import_crypto2.keccak256)(data);
5438
5518
  const macHash = (0, import_crypto2.stringFromBuffer)(macHashUint8Array, "hex");
5439
5519
  if (mac !== macHash) {
5440
- throw new import_errors16.FuelError(
5441
- import_errors16.ErrorCode.INVALID_PASSWORD,
5520
+ throw new import_errors17.FuelError(
5521
+ import_errors17.ErrorCode.INVALID_PASSWORD,
5442
5522
  "Failed to decrypt the keystore wallet, the provided password is incorrect."
5443
5523
  );
5444
5524
  }
5445
5525
  const buffer = await (0, import_crypto2.decryptJsonWalletData)(ciphertextBuffer, key, ivBuffer);
5446
- const privateKey = (0, import_utils29.hexlify)(buffer);
5526
+ const privateKey = (0, import_utils30.hexlify)(buffer);
5447
5527
  return privateKey;
5448
5528
  }
5449
5529
 
@@ -5488,7 +5568,7 @@ var BaseWalletUnlocked = class extends Account {
5488
5568
  */
5489
5569
  async signMessage(message) {
5490
5570
  const signedMessage = await this.signer().sign((0, import_hasher3.hashMessage)(message));
5491
- return (0, import_utils30.hexlify)(signedMessage);
5571
+ return (0, import_utils31.hexlify)(signedMessage);
5492
5572
  }
5493
5573
  /**
5494
5574
  * Signs a transaction with the wallet's private key.
@@ -5501,7 +5581,7 @@ var BaseWalletUnlocked = class extends Account {
5501
5581
  const chainId = this.provider.getChainId();
5502
5582
  const hashedTransaction = transactionRequest.getTransactionId(chainId);
5503
5583
  const signature = await this.signer().sign(hashedTransaction);
5504
- return (0, import_utils30.hexlify)(signature);
5584
+ return (0, import_utils31.hexlify)(signature);
5505
5585
  }
5506
5586
  /**
5507
5587
  * Populates a transaction with the witnesses signature.
@@ -5560,17 +5640,17 @@ var BaseWalletUnlocked = class extends Account {
5560
5640
  __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
5561
5641
 
5562
5642
  // src/hdwallet/hdwallet.ts
5563
- var import_errors19 = require("@fuel-ts/errors");
5643
+ var import_errors20 = require("@fuel-ts/errors");
5564
5644
  var import_hasher6 = require("@fuel-ts/hasher");
5565
- var import_math19 = require("@fuel-ts/math");
5566
- var import_utils34 = require("@fuel-ts/utils");
5645
+ var import_math20 = require("@fuel-ts/math");
5646
+ var import_utils35 = require("@fuel-ts/utils");
5567
5647
  var import_ethers3 = require("ethers");
5568
5648
 
5569
5649
  // src/mnemonic/mnemonic.ts
5570
5650
  var import_crypto3 = require("@fuel-ts/crypto");
5571
- var import_errors18 = require("@fuel-ts/errors");
5651
+ var import_errors19 = require("@fuel-ts/errors");
5572
5652
  var import_hasher5 = require("@fuel-ts/hasher");
5573
- var import_utils32 = require("@fuel-ts/utils");
5653
+ var import_utils33 = require("@fuel-ts/utils");
5574
5654
  var import_ethers2 = require("ethers");
5575
5655
 
5576
5656
  // src/wordlists/words/english.ts
@@ -7632,9 +7712,9 @@ var Language = /* @__PURE__ */ ((Language2) => {
7632
7712
  })(Language || {});
7633
7713
 
7634
7714
  // src/mnemonic/utils.ts
7635
- var import_errors17 = require("@fuel-ts/errors");
7715
+ var import_errors18 = require("@fuel-ts/errors");
7636
7716
  var import_hasher4 = require("@fuel-ts/hasher");
7637
- var import_utils31 = require("@fuel-ts/utils");
7717
+ var import_utils32 = require("@fuel-ts/utils");
7638
7718
  function toUtf8Bytes(stri) {
7639
7719
  const str = stri.normalize("NFKD");
7640
7720
  const result = [];
@@ -7649,8 +7729,8 @@ function toUtf8Bytes(stri) {
7649
7729
  i += 1;
7650
7730
  const c2 = str.charCodeAt(i);
7651
7731
  if (i >= str.length || (c2 & 64512) !== 56320) {
7652
- throw new import_errors17.FuelError(
7653
- import_errors17.ErrorCode.INVALID_INPUT_PARAMETERS,
7732
+ throw new import_errors18.FuelError(
7733
+ import_errors18.ErrorCode.INVALID_INPUT_PARAMETERS,
7654
7734
  "Invalid UTF-8 in the input string."
7655
7735
  );
7656
7736
  }
@@ -7701,20 +7781,20 @@ function entropyToMnemonicIndices(entropy) {
7701
7781
  }
7702
7782
  }
7703
7783
  const checksumBits = entropy.length / 4;
7704
- const checksum = (0, import_utils31.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
7784
+ const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
7705
7785
  indices[indices.length - 1] <<= checksumBits;
7706
7786
  indices[indices.length - 1] |= checksum >> 8 - checksumBits;
7707
7787
  return indices;
7708
7788
  }
7709
7789
  function mnemonicWordsToEntropy(words, wordlist) {
7710
7790
  const size = Math.ceil(11 * words.length / 8);
7711
- const entropy = (0, import_utils31.arrayify)(new Uint8Array(size));
7791
+ const entropy = (0, import_utils32.arrayify)(new Uint8Array(size));
7712
7792
  let offset = 0;
7713
7793
  for (let i = 0; i < words.length; i += 1) {
7714
7794
  const index = wordlist.indexOf(words[i].normalize("NFKD"));
7715
7795
  if (index === -1) {
7716
- throw new import_errors17.FuelError(
7717
- import_errors17.ErrorCode.INVALID_MNEMONIC,
7796
+ throw new import_errors18.FuelError(
7797
+ import_errors18.ErrorCode.INVALID_MNEMONIC,
7718
7798
  `Invalid mnemonic: the word '${words[i]}' is not found in the provided wordlist.`
7719
7799
  );
7720
7800
  }
@@ -7728,10 +7808,10 @@ function mnemonicWordsToEntropy(words, wordlist) {
7728
7808
  const entropyBits = 32 * words.length / 3;
7729
7809
  const checksumBits = words.length / 3;
7730
7810
  const checksumMask = getUpperMask(checksumBits);
7731
- const checksum = (0, import_utils31.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
7811
+ const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
7732
7812
  if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
7733
- throw new import_errors17.FuelError(
7734
- import_errors17.ErrorCode.INVALID_CHECKSUM,
7813
+ throw new import_errors18.FuelError(
7814
+ import_errors18.ErrorCode.INVALID_CHECKSUM,
7735
7815
  "Checksum validation failed for the provided mnemonic."
7736
7816
  );
7737
7817
  }
@@ -7745,16 +7825,16 @@ var TestnetPRV = "0x04358394";
7745
7825
  var MNEMONIC_SIZES = [12, 15, 18, 21, 24];
7746
7826
  function assertWordList(wordlist) {
7747
7827
  if (wordlist.length !== 2048) {
7748
- throw new import_errors18.FuelError(
7749
- import_errors18.ErrorCode.INVALID_WORD_LIST,
7828
+ throw new import_errors19.FuelError(
7829
+ import_errors19.ErrorCode.INVALID_WORD_LIST,
7750
7830
  `Expected word list length of 2048, but got ${wordlist.length}.`
7751
7831
  );
7752
7832
  }
7753
7833
  }
7754
7834
  function assertEntropy(entropy) {
7755
7835
  if (entropy.length % 4 !== 0 || entropy.length < 16 || entropy.length > 32) {
7756
- throw new import_errors18.FuelError(
7757
- import_errors18.ErrorCode.INVALID_ENTROPY,
7836
+ throw new import_errors19.FuelError(
7837
+ import_errors19.ErrorCode.INVALID_ENTROPY,
7758
7838
  `Entropy should be between 16 and 32 bytes and a multiple of 4, but got ${entropy.length} bytes.`
7759
7839
  );
7760
7840
  }
@@ -7764,7 +7844,7 @@ function assertMnemonic(words) {
7764
7844
  const errorMsg = `Invalid mnemonic size. Expected one of [${MNEMONIC_SIZES.join(
7765
7845
  ", "
7766
7846
  )}] words, but got ${words.length}.`;
7767
- throw new import_errors18.FuelError(import_errors18.ErrorCode.INVALID_MNEMONIC, errorMsg);
7847
+ throw new import_errors19.FuelError(import_errors19.ErrorCode.INVALID_MNEMONIC, errorMsg);
7768
7848
  }
7769
7849
  }
7770
7850
  var Mnemonic = class {
@@ -7803,7 +7883,7 @@ var Mnemonic = class {
7803
7883
  static mnemonicToEntropy(phrase, wordlist = english) {
7804
7884
  const words = getWords(phrase);
7805
7885
  assertMnemonic(words);
7806
- return (0, import_utils32.hexlify)(mnemonicWordsToEntropy(words, wordlist));
7886
+ return (0, import_utils33.hexlify)(mnemonicWordsToEntropy(words, wordlist));
7807
7887
  }
7808
7888
  /**
7809
7889
  * @param entropy - Entropy source to the mnemonic phrase.
@@ -7811,7 +7891,7 @@ var Mnemonic = class {
7811
7891
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
7812
7892
  */
7813
7893
  static entropyToMnemonic(entropy, wordlist = english) {
7814
- const entropyBytes = (0, import_utils32.arrayify)(entropy);
7894
+ const entropyBytes = (0, import_utils33.arrayify)(entropy);
7815
7895
  assertWordList(wordlist);
7816
7896
  assertEntropy(entropyBytes);
7817
7897
  return entropyToMnemonicIndices(entropyBytes).map((i) => wordlist[i]).join(" ");
@@ -7880,14 +7960,14 @@ var Mnemonic = class {
7880
7960
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
7881
7961
  */
7882
7962
  static masterKeysFromSeed(seed) {
7883
- const seedArray = (0, import_utils32.arrayify)(seed);
7963
+ const seedArray = (0, import_utils33.arrayify)(seed);
7884
7964
  if (seedArray.length < 16 || seedArray.length > 64) {
7885
- throw new import_errors18.FuelError(
7886
- import_errors18.ErrorCode.INVALID_SEED,
7965
+ throw new import_errors19.FuelError(
7966
+ import_errors19.ErrorCode.INVALID_SEED,
7887
7967
  `Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
7888
7968
  );
7889
7969
  }
7890
- return (0, import_utils32.arrayify)((0, import_ethers2.computeHmac)("sha512", MasterSecret, seedArray));
7970
+ return (0, import_utils33.arrayify)((0, import_ethers2.computeHmac)("sha512", MasterSecret, seedArray));
7891
7971
  }
7892
7972
  /**
7893
7973
  * Get the extendKey as defined on BIP-32 from the provided seed
@@ -7898,22 +7978,22 @@ var Mnemonic = class {
7898
7978
  */
7899
7979
  static seedToExtendedKey(seed, testnet = false) {
7900
7980
  const masterKey = Mnemonic.masterKeysFromSeed(seed);
7901
- const prefix = (0, import_utils32.arrayify)(testnet ? TestnetPRV : MainnetPRV);
7981
+ const prefix = (0, import_utils33.arrayify)(testnet ? TestnetPRV : MainnetPRV);
7902
7982
  const depth = "0x00";
7903
7983
  const fingerprint = "0x00000000";
7904
7984
  const index = "0x00000000";
7905
7985
  const chainCode = masterKey.slice(32);
7906
7986
  const privateKey = masterKey.slice(0, 32);
7907
- const extendedKey = (0, import_utils32.concat)([
7987
+ const extendedKey = (0, import_utils33.concat)([
7908
7988
  prefix,
7909
7989
  depth,
7910
7990
  fingerprint,
7911
7991
  index,
7912
7992
  chainCode,
7913
- (0, import_utils32.concat)(["0x00", privateKey])
7993
+ (0, import_utils33.concat)(["0x00", privateKey])
7914
7994
  ]);
7915
7995
  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]));
7996
+ return (0, import_ethers2.encodeBase58)((0, import_utils33.concat)([extendedKey, checksum]));
7917
7997
  }
7918
7998
  /**
7919
7999
  * Create a new mnemonic using a randomly generated number as entropy.
@@ -7928,7 +8008,7 @@ var Mnemonic = class {
7928
8008
  * @returns A randomly generated mnemonic
7929
8009
  */
7930
8010
  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);
8011
+ const entropy = extraEntropy ? (0, import_hasher5.sha256)((0, import_utils33.concat)([(0, import_crypto3.randomBytes)(size), (0, import_utils33.arrayify)(extraEntropy)])) : (0, import_crypto3.randomBytes)(size);
7932
8012
  return Mnemonic.entropyToMnemonic(entropy);
7933
8013
  }
7934
8014
  };
@@ -7936,12 +8016,12 @@ var mnemonic_default = Mnemonic;
7936
8016
 
7937
8017
  // src/hdwallet/hdwallet.ts
7938
8018
  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");
8019
+ var MainnetPRV2 = (0, import_utils35.hexlify)("0x0488ade4");
8020
+ var MainnetPUB = (0, import_utils35.hexlify)("0x0488b21e");
8021
+ var TestnetPRV2 = (0, import_utils35.hexlify)("0x04358394");
8022
+ var TestnetPUB = (0, import_utils35.hexlify)("0x043587cf");
7943
8023
  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)]));
8024
+ 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
8025
  }
7946
8026
  function getExtendedKeyPrefix(isPublic = false, testnet = false) {
7947
8027
  if (isPublic) {
@@ -7950,17 +8030,17 @@ function getExtendedKeyPrefix(isPublic = false, testnet = false) {
7950
8030
  return testnet ? TestnetPRV2 : MainnetPRV2;
7951
8031
  }
7952
8032
  function isPublicExtendedKey(extendedKey) {
7953
- return [MainnetPUB, TestnetPUB].includes((0, import_utils34.hexlify)(extendedKey.slice(0, 4)));
8033
+ return [MainnetPUB, TestnetPUB].includes((0, import_utils35.hexlify)(extendedKey.slice(0, 4)));
7954
8034
  }
7955
8035
  function isValidExtendedKey(extendedKey) {
7956
8036
  return [MainnetPRV2, TestnetPRV2, MainnetPUB, TestnetPUB].includes(
7957
- (0, import_utils34.hexlify)(extendedKey.slice(0, 4))
8037
+ (0, import_utils35.hexlify)(extendedKey.slice(0, 4))
7958
8038
  );
7959
8039
  }
7960
8040
  function parsePath(path, depth = 0) {
7961
8041
  const components = path.split("/");
7962
8042
  if (components.length === 0 || components[0] === "m" && depth !== 0) {
7963
- throw new import_errors19.FuelError(import_errors19.ErrorCode.HD_WALLET_ERROR, `invalid path - ${path}`);
8043
+ throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, `invalid path - ${path}`);
7964
8044
  }
7965
8045
  if (components[0] === "m") {
7966
8046
  components.shift();
@@ -7972,8 +8052,8 @@ function parsePath(path, depth = 0) {
7972
8052
  var HDWallet = class {
7973
8053
  depth = 0;
7974
8054
  index = 0;
7975
- fingerprint = (0, import_utils34.hexlify)("0x00000000");
7976
- parentFingerprint = (0, import_utils34.hexlify)("0x00000000");
8055
+ fingerprint = (0, import_utils35.hexlify)("0x00000000");
8056
+ parentFingerprint = (0, import_utils35.hexlify)("0x00000000");
7977
8057
  privateKey;
7978
8058
  publicKey;
7979
8059
  chainCode;
@@ -7985,16 +8065,16 @@ var HDWallet = class {
7985
8065
  constructor(config) {
7986
8066
  if (config.privateKey) {
7987
8067
  const signer = new Signer(config.privateKey);
7988
- this.publicKey = (0, import_utils34.hexlify)(signer.compressedPublicKey);
7989
- this.privateKey = (0, import_utils34.hexlify)(config.privateKey);
8068
+ this.publicKey = (0, import_utils35.hexlify)(signer.compressedPublicKey);
8069
+ this.privateKey = (0, import_utils35.hexlify)(config.privateKey);
7990
8070
  } else {
7991
8071
  if (!config.publicKey) {
7992
- throw new import_errors19.FuelError(
7993
- import_errors19.ErrorCode.HD_WALLET_ERROR,
8072
+ throw new import_errors20.FuelError(
8073
+ import_errors20.ErrorCode.HD_WALLET_ERROR,
7994
8074
  "Both public and private Key cannot be missing. At least one should be provided."
7995
8075
  );
7996
8076
  }
7997
- this.publicKey = (0, import_utils34.hexlify)(config.publicKey);
8077
+ this.publicKey = (0, import_utils35.hexlify)(config.publicKey);
7998
8078
  }
7999
8079
  this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
8000
8080
  this.fingerprint = (0, import_ethers3.dataSlice)((0, import_ethers3.ripemd160)((0, import_hasher6.sha256)(this.publicKey)), 0, 4);
@@ -8013,28 +8093,28 @@ var HDWallet = class {
8013
8093
  * @returns A new instance of HDWallet on the derived index
8014
8094
  */
8015
8095
  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);
8096
+ const privateKey = this.privateKey && (0, import_utils35.arrayify)(this.privateKey);
8097
+ const publicKey = (0, import_utils35.arrayify)(this.publicKey);
8098
+ const chainCode = (0, import_utils35.arrayify)(this.chainCode);
8019
8099
  const data = new Uint8Array(37);
8020
8100
  if (index & HARDENED_INDEX) {
8021
8101
  if (!privateKey) {
8022
- throw new import_errors19.FuelError(
8023
- import_errors19.ErrorCode.HD_WALLET_ERROR,
8102
+ throw new import_errors20.FuelError(
8103
+ import_errors20.ErrorCode.HD_WALLET_ERROR,
8024
8104
  "Cannot derive a hardened index without a private Key."
8025
8105
  );
8026
8106
  }
8027
8107
  data.set(privateKey, 1);
8028
8108
  } else {
8029
- data.set((0, import_utils34.arrayify)(this.publicKey));
8109
+ data.set((0, import_utils35.arrayify)(this.publicKey));
8030
8110
  }
8031
- data.set((0, import_math19.toBytes)(index, 4), 33);
8032
- const bytes = (0, import_utils34.arrayify)((0, import_ethers3.computeHmac)("sha512", chainCode, data));
8111
+ data.set((0, import_math20.toBytes)(index, 4), 33);
8112
+ const bytes = (0, import_utils35.arrayify)((0, import_ethers3.computeHmac)("sha512", chainCode, data));
8033
8113
  const IL = bytes.slice(0, 32);
8034
8114
  const IR = bytes.slice(32);
8035
8115
  if (privateKey) {
8036
8116
  const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
8037
- const ki = (0, import_math19.bn)(IL).add(privateKey).mod(N).toBytes(32);
8117
+ const ki = (0, import_math20.bn)(IL).add(privateKey).mod(N).toBytes(32);
8038
8118
  return new HDWallet({
8039
8119
  privateKey: ki,
8040
8120
  chainCode: IR,
@@ -8043,7 +8123,7 @@ var HDWallet = class {
8043
8123
  parentFingerprint: this.fingerprint
8044
8124
  });
8045
8125
  }
8046
- const signer = new Signer((0, import_utils34.hexlify)(IL));
8126
+ const signer = new Signer((0, import_utils35.hexlify)(IL));
8047
8127
  const Ki = signer.addPoint(publicKey);
8048
8128
  return new HDWallet({
8049
8129
  publicKey: Ki,
@@ -8072,18 +8152,18 @@ var HDWallet = class {
8072
8152
  */
8073
8153
  toExtendedKey(isPublic = false, testnet = false) {
8074
8154
  if (this.depth >= 256) {
8075
- throw new import_errors19.FuelError(
8076
- import_errors19.ErrorCode.HD_WALLET_ERROR,
8155
+ throw new import_errors20.FuelError(
8156
+ import_errors20.ErrorCode.HD_WALLET_ERROR,
8077
8157
  `Exceeded max depth of 255. Current depth: ${this.depth}.`
8078
8158
  );
8079
8159
  }
8080
8160
  const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
8081
- const depth = (0, import_utils34.hexlify)(Uint8Array.from([this.depth]));
8161
+ const depth = (0, import_utils35.hexlify)(Uint8Array.from([this.depth]));
8082
8162
  const parentFingerprint = this.parentFingerprint;
8083
- const index = (0, import_math19.toHex)(this.index, 4);
8163
+ const index = (0, import_math20.toHex)(this.index, 4);
8084
8164
  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]));
8165
+ const key = this.privateKey != null && !isPublic ? (0, import_utils35.concat)(["0x00", this.privateKey]) : this.publicKey;
8166
+ const extendedKey = (0, import_utils35.arrayify)((0, import_utils35.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
8087
8167
  return base58check(extendedKey);
8088
8168
  }
8089
8169
  /**
@@ -8095,34 +8175,34 @@ var HDWallet = class {
8095
8175
  static fromSeed(seed) {
8096
8176
  const masterKey = mnemonic_default.masterKeysFromSeed(seed);
8097
8177
  return new HDWallet({
8098
- chainCode: (0, import_utils34.arrayify)(masterKey.slice(32)),
8099
- privateKey: (0, import_utils34.arrayify)(masterKey.slice(0, 32))
8178
+ chainCode: (0, import_utils35.arrayify)(masterKey.slice(32)),
8179
+ privateKey: (0, import_utils35.arrayify)(masterKey.slice(0, 32))
8100
8180
  });
8101
8181
  }
8102
8182
  static fromExtendedKey(extendedKey) {
8103
8183
  const decoded = (0, import_ethers3.toBeHex)((0, import_ethers3.decodeBase58)(extendedKey));
8104
- const bytes = (0, import_utils34.arrayify)(decoded);
8184
+ const bytes = (0, import_utils35.arrayify)(decoded);
8105
8185
  const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
8106
8186
  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.");
8187
+ throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
8108
8188
  }
8109
8189
  if (!validChecksum) {
8110
- throw new import_errors19.FuelError(import_errors19.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
8190
+ throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
8111
8191
  }
8112
8192
  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));
8193
+ const parentFingerprint = (0, import_utils35.hexlify)(bytes.slice(5, 9));
8194
+ const index = parseInt((0, import_utils35.hexlify)(bytes.slice(9, 13)).substring(2), 16);
8195
+ const chainCode = (0, import_utils35.hexlify)(bytes.slice(13, 45));
8116
8196
  const key = bytes.slice(45, 78);
8117
8197
  if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
8118
- throw new import_errors19.FuelError(
8119
- import_errors19.ErrorCode.HD_WALLET_ERROR,
8198
+ throw new import_errors20.FuelError(
8199
+ import_errors20.ErrorCode.HD_WALLET_ERROR,
8120
8200
  "Inconsistency detected: Depth is zero but fingerprint/index is non-zero."
8121
8201
  );
8122
8202
  }
8123
8203
  if (isPublicExtendedKey(bytes)) {
8124
8204
  if (key[0] !== 3) {
8125
- throw new import_errors19.FuelError(import_errors19.ErrorCode.HD_WALLET_ERROR, "Invalid public extended key.");
8205
+ throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Invalid public extended key.");
8126
8206
  }
8127
8207
  return new HDWallet({
8128
8208
  publicKey: key,
@@ -8133,7 +8213,7 @@ var HDWallet = class {
8133
8213
  });
8134
8214
  }
8135
8215
  if (key[0] !== 0) {
8136
- throw new import_errors19.FuelError(import_errors19.ErrorCode.HD_WALLET_ERROR, "Invalid private extended key.");
8216
+ throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Invalid private extended key.");
8137
8217
  }
8138
8218
  return new HDWallet({
8139
8219
  privateKey: key.slice(1),
@@ -8301,7 +8381,7 @@ __publicField(Wallet, "fromEncryptedJson", WalletUnlocked.fromEncryptedJson);
8301
8381
  // src/wallet-manager/wallet-manager.ts
8302
8382
  var import_address9 = require("@fuel-ts/address");
8303
8383
  var import_crypto4 = require("@fuel-ts/crypto");
8304
- var import_errors22 = require("@fuel-ts/errors");
8384
+ var import_errors23 = require("@fuel-ts/errors");
8305
8385
  var import_events = require("events");
8306
8386
 
8307
8387
  // src/wallet-manager/storages/memory-storage.ts
@@ -8324,7 +8404,7 @@ var MemoryStorage = class {
8324
8404
 
8325
8405
  // src/wallet-manager/vaults/mnemonic-vault.ts
8326
8406
  var import_address7 = require("@fuel-ts/address");
8327
- var import_errors20 = require("@fuel-ts/errors");
8407
+ var import_errors21 = require("@fuel-ts/errors");
8328
8408
  var _secret;
8329
8409
  var MnemonicVault = class {
8330
8410
  constructor(options) {
@@ -8380,8 +8460,8 @@ var MnemonicVault = class {
8380
8460
  }
8381
8461
  numberOfAccounts += 1;
8382
8462
  } while (numberOfAccounts < this.numberOfAccounts);
8383
- throw new import_errors20.FuelError(
8384
- import_errors20.ErrorCode.WALLET_MANAGER_ERROR,
8463
+ throw new import_errors21.FuelError(
8464
+ import_errors21.ErrorCode.WALLET_MANAGER_ERROR,
8385
8465
  `Account with address '${address}' not found in derived wallets.`
8386
8466
  );
8387
8467
  }
@@ -8395,7 +8475,7 @@ __publicField(MnemonicVault, "type", "mnemonic");
8395
8475
 
8396
8476
  // src/wallet-manager/vaults/privatekey-vault.ts
8397
8477
  var import_address8 = require("@fuel-ts/address");
8398
- var import_errors21 = require("@fuel-ts/errors");
8478
+ var import_errors22 = require("@fuel-ts/errors");
8399
8479
  var _privateKeys;
8400
8480
  var PrivateKeyVault = class {
8401
8481
  /**
@@ -8436,8 +8516,8 @@ var PrivateKeyVault = class {
8436
8516
  (pk) => Wallet.fromPrivateKey(pk).address.equals(ownerAddress)
8437
8517
  );
8438
8518
  if (!privateKey) {
8439
- throw new import_errors21.FuelError(
8440
- import_errors21.ErrorCode.WALLET_MANAGER_ERROR,
8519
+ throw new import_errors22.FuelError(
8520
+ import_errors22.ErrorCode.WALLET_MANAGER_ERROR,
8441
8521
  `No private key found for address '${address}'.`
8442
8522
  );
8443
8523
  }
@@ -8461,7 +8541,7 @@ var ERROR_MESSAGES = {
8461
8541
  };
8462
8542
  function assert(condition, message) {
8463
8543
  if (!condition) {
8464
- throw new import_errors22.FuelError(import_errors22.ErrorCode.WALLET_MANAGER_ERROR, message);
8544
+ throw new import_errors23.FuelError(import_errors23.ErrorCode.WALLET_MANAGER_ERROR, message);
8465
8545
  }
8466
8546
  }
8467
8547
  var _vaults, _passphrase, _isLocked, _serializeVaults, serializeVaults_fn, _deserializeVaults, deserializeVaults_fn;
@@ -8687,25 +8767,25 @@ deserializeVaults_fn = function(vaults) {
8687
8767
  __publicField(WalletManager, "Vaults", [MnemonicVault, PrivateKeyVault]);
8688
8768
 
8689
8769
  // src/wallet-manager/types.ts
8690
- var import_errors23 = require("@fuel-ts/errors");
8770
+ var import_errors24 = require("@fuel-ts/errors");
8691
8771
  var Vault = class {
8692
8772
  constructor(_options) {
8693
- throw new import_errors23.FuelError(import_errors23.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
8773
+ throw new import_errors24.FuelError(import_errors24.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
8694
8774
  }
8695
8775
  serialize() {
8696
- throw new import_errors23.FuelError(import_errors23.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
8776
+ throw new import_errors24.FuelError(import_errors24.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
8697
8777
  }
8698
8778
  getAccounts() {
8699
- throw new import_errors23.FuelError(import_errors23.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
8779
+ throw new import_errors24.FuelError(import_errors24.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
8700
8780
  }
8701
8781
  addAccount() {
8702
- throw new import_errors23.FuelError(import_errors23.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
8782
+ throw new import_errors24.FuelError(import_errors24.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
8703
8783
  }
8704
8784
  exportAccount(_address) {
8705
- throw new import_errors23.FuelError(import_errors23.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
8785
+ throw new import_errors24.FuelError(import_errors24.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
8706
8786
  }
8707
8787
  getWallet(_address) {
8708
- throw new import_errors23.FuelError(import_errors23.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
8788
+ throw new import_errors24.FuelError(import_errors24.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
8709
8789
  }
8710
8790
  };
8711
8791
  __publicField(Vault, "type");
@@ -8715,21 +8795,21 @@ var StorageAbstract = class {
8715
8795
  // src/predicate/predicate.ts
8716
8796
  var import_abi_coder5 = require("@fuel-ts/abi-coder");
8717
8797
  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");
8798
+ var import_configs13 = require("@fuel-ts/address/configs");
8799
+ var import_errors25 = require("@fuel-ts/errors");
8800
+ var import_transactions20 = require("@fuel-ts/transactions");
8801
+ var import_utils37 = require("@fuel-ts/utils");
8722
8802
 
8723
8803
  // src/predicate/utils/getPredicateRoot.ts
8724
8804
  var import_hasher7 = require("@fuel-ts/hasher");
8725
8805
  var import_merkle = require("@fuel-ts/merkle");
8726
- var import_utils35 = require("@fuel-ts/utils");
8806
+ var import_utils36 = require("@fuel-ts/utils");
8727
8807
  var getPredicateRoot = (bytecode) => {
8728
8808
  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]));
8809
+ const bytes = (0, import_utils36.arrayify)(bytecode);
8810
+ const chunks = (0, import_utils36.chunkAndPadBytes)(bytes, chunkSize);
8811
+ const codeRoot = (0, import_merkle.calcRoot)(chunks.map((c) => (0, import_utils36.hexlify)(c)));
8812
+ const predicateRoot = (0, import_hasher7.hash)((0, import_utils36.concat)(["0x4655454C", codeRoot]));
8733
8813
  return predicateRoot;
8734
8814
  };
8735
8815
 
@@ -8778,7 +8858,7 @@ var Predicate = class extends Account {
8778
8858
  const request = transactionRequestify(transactionRequestLike);
8779
8859
  const { policies } = BaseTransactionRequest.getPolicyMeta(request);
8780
8860
  request.inputs?.forEach((input) => {
8781
- if (input.type === import_transactions19.InputType.Coin && (0, import_utils36.hexlify)(input.owner) === this.address.toB256()) {
8861
+ if (input.type === import_transactions20.InputType.Coin && (0, import_utils37.hexlify)(input.owner) === this.address.toB256()) {
8782
8862
  input.predicate = this.bytes;
8783
8863
  input.predicateData = this.getPredicateData(policies.length);
8784
8864
  }
@@ -8794,7 +8874,7 @@ var Predicate = class extends Account {
8794
8874
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
8795
8875
  * @returns A promise that resolves to the prepared transaction request.
8796
8876
  */
8797
- async createTransfer(destination, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
8877
+ async createTransfer(destination, amount, assetId = import_configs13.BaseAssetId, txParams = {}) {
8798
8878
  const request = await super.createTransfer(destination, amount, assetId, txParams);
8799
8879
  return this.populateTransactionPredicateData(request);
8800
8880
  }
@@ -8823,7 +8903,7 @@ var Predicate = class extends Account {
8823
8903
  return new Uint8Array();
8824
8904
  }
8825
8905
  const mainFn = this.interface?.functions.main;
8826
- const paddedCode = new import_transactions19.ByteArrayCoder(this.bytes.length).encode(this.bytes);
8906
+ const paddedCode = new import_transactions20.ByteArrayCoder(this.bytes.length).encode(this.bytes);
8827
8907
  const VM_TX_MEMORY = (0, import_abi_coder5.calculateVmTxMemory)({
8828
8908
  maxInputs: this.provider.getChain().consensusParameters.maxInputs.toNumber()
8829
8909
  });
@@ -8839,13 +8919,13 @@ var Predicate = class extends Account {
8839
8919
  * @returns An object containing the new predicate bytes and interface.
8840
8920
  */
8841
8921
  static processPredicateData(bytes, jsonAbi, configurableConstants) {
8842
- let predicateBytes = (0, import_utils36.arrayify)(bytes);
8922
+ let predicateBytes = (0, import_utils37.arrayify)(bytes);
8843
8923
  let abiInterface;
8844
8924
  if (jsonAbi) {
8845
8925
  abiInterface = new import_abi_coder5.Interface(jsonAbi);
8846
8926
  if (abiInterface.functions.main === void 0) {
8847
- throw new import_errors24.FuelError(
8848
- import_errors24.ErrorCode.ABI_MAIN_METHOD_MISSING,
8927
+ throw new import_errors25.FuelError(
8928
+ import_errors25.ErrorCode.ABI_MAIN_METHOD_MISSING,
8849
8929
  'Cannot use ABI without "main" function.'
8850
8930
  );
8851
8931
  }
@@ -8890,8 +8970,8 @@ var Predicate = class extends Account {
8890
8970
  mutatedBytes.set(encoded, offset);
8891
8971
  });
8892
8972
  } catch (err) {
8893
- throw new import_errors24.FuelError(
8894
- import_errors24.ErrorCode.INVALID_CONFIGURABLE_CONSTANTS,
8973
+ throw new import_errors25.FuelError(
8974
+ import_errors25.ErrorCode.INVALID_CONFIGURABLE_CONSTANTS,
8895
8975
  `Error setting configurable constants: ${err.message}.`
8896
8976
  );
8897
8977
  }
@@ -8900,7 +8980,7 @@ var Predicate = class extends Account {
8900
8980
  };
8901
8981
 
8902
8982
  // src/connectors/fuel.ts
8903
- var import_errors25 = require("@fuel-ts/errors");
8983
+ var import_errors26 = require("@fuel-ts/errors");
8904
8984
 
8905
8985
  // src/connectors/fuel-connector.ts
8906
8986
  var import_events2 = require("events");
@@ -9533,7 +9613,7 @@ var _Fuel = class extends FuelConnector {
9533
9613
  const currentNetwork = await this.currentNetwork();
9534
9614
  provider = await Provider.create(currentNetwork.url);
9535
9615
  } else {
9536
- throw new import_errors25.FuelError(import_errors25.ErrorCode.INVALID_PROVIDER, "Provider is not valid.");
9616
+ throw new import_errors26.FuelError(import_errors26.ErrorCode.INVALID_PROVIDER, "Provider is not valid.");
9537
9617
  }
9538
9618
  return provider;
9539
9619
  }
@@ -9613,7 +9693,9 @@ __publicField(Fuel, "defaultConfig", {});
9613
9693
  WalletUnlocked,
9614
9694
  addAmountToAsset,
9615
9695
  addOperation,
9696
+ assemblePanicError,
9616
9697
  assembleReceiptByType,
9698
+ assembleRevertError,
9617
9699
  assembleTransactionSummary,
9618
9700
  assets,
9619
9701
  buildBlockExplorerUrl,
@@ -9628,6 +9710,7 @@ __publicField(Fuel, "defaultConfig", {});
9628
9710
  english,
9629
9711
  extractBurnedAssetsFromReceipts,
9630
9712
  extractMintedAssetsFromReceipts,
9713
+ extractTxError,
9631
9714
  gasUsedByInputs,
9632
9715
  getAssetEth,
9633
9716
  getAssetFuel,