@fuel-ts/account 0.0.0-rc-1936-20240326112905 → 0.0.0-rc-1895-20240327220629

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,68 @@ 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
+ if (import_configs6.PANIC_REASONS.includes(status.reason)) {
1712
+ errorMessage = `${errorMessage}
1713
+
1714
+ You can read more about this error at:
1715
+
1716
+ ${import_configs6.PANIC_DOC_URL}#variant.${status.reason}`;
1717
+ }
1718
+ return errorMessage;
1719
+ };
1720
+ var stringify = (obj) => JSON.stringify(obj, null, 2);
1721
+ var assembleRevertError = (receipts, logs) => {
1722
+ let errorMessage = "The transaction reverted with an unknown reason.";
1723
+ const revertReceipt = receipts.find(({ type }) => type === import_transactions5.ReceiptType.Revert);
1724
+ if (revertReceipt) {
1725
+ const reasonHex = (0, import_math6.bn)(revertReceipt.val).toHex();
1726
+ switch (reasonHex) {
1727
+ case import_configs6.FAILED_REQUIRE_SIGNAL: {
1728
+ errorMessage = `The transaction reverted because of a "require" statement has thrown ${logs.length ? stringify(logs[0]) : "an error."}.`;
1729
+ break;
1730
+ }
1731
+ case import_configs6.FAILED_ASSERT_EQ_SIGNAL: {
1732
+ const sufix = logs.length >= 2 ? ` comparing ${stringify(logs[1])} and ${stringify(logs[0])}.` : ".";
1733
+ errorMessage = `The transaction reverted because of an "assert_eq" statement${sufix}`;
1734
+ break;
1735
+ }
1736
+ case import_configs6.FAILED_ASSERT_NE_SIGNAL: {
1737
+ const sufix = logs.length >= 2 ? ` comparing ${stringify(logs[1])} and ${stringify(logs[0])}.` : ".";
1738
+ errorMessage = `The transaction reverted because of an "assert_ne" statement${sufix}`;
1739
+ break;
1740
+ }
1741
+ case import_configs6.FAILED_ASSERT_SIGNAL:
1742
+ errorMessage = `The transaction reverted because of an "assert" statement failed to evaluate to true.`;
1743
+ break;
1744
+ case import_configs6.FAILED_TRANSFER_TO_ADDRESS_SIGNAL:
1745
+ errorMessage = `The transaction reverted because missing "OutputChange"(s).`;
1746
+ break;
1747
+ default:
1748
+ errorMessage = `The transaction reverted with an unknown reason: ${revertReceipt.val}`;
1749
+ }
1750
+ }
1751
+ return errorMessage;
1752
+ };
1753
+ var extractTxError = (params) => {
1754
+ const { receipts, status, logs } = params;
1755
+ const wasPanic = receipts.some(({ type }) => type === import_transactions5.ReceiptType.Panic);
1756
+ let err = status?.type === "FailureStatus" && wasPanic ? assemblePanicError(status) : assembleRevertError(receipts, logs);
1757
+ err += `
1758
+
1759
+ logs: ${JSON.stringify(logs, null, 2)}`;
1760
+ err += `
1761
+
1762
+ receipts: ${JSON.stringify(receipts, null, 2)}`;
1763
+ return new import_errors7.FuelError(import_errors7.ErrorCode.SCRIPT_REVERTED, err);
1764
+ };
1765
+
1701
1766
  // src/providers/transaction-request/errors.ts
1702
1767
  var ChangeOutputCollisionError = class extends Error {
1703
1768
  name = "ChangeOutputCollisionError";
@@ -1760,10 +1825,10 @@ var BaseTransactionRequest = class {
1760
1825
  outputs,
1761
1826
  witnesses
1762
1827
  } = {}) {
1763
- this.gasPrice = (0, import_math6.bn)(gasPrice);
1828
+ this.gasPrice = (0, import_math7.bn)(gasPrice);
1764
1829
  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;
1830
+ this.witnessLimit = witnessLimit ? (0, import_math7.bn)(witnessLimit) : void 0;
1831
+ this.maxFee = maxFee ? (0, import_math7.bn)(maxFee) : void 0;
1767
1832
  this.inputs = inputs ?? [];
1768
1833
  this.outputs = outputs ?? [];
1769
1834
  this.witnesses = witnesses ?? [];
@@ -1772,20 +1837,20 @@ var BaseTransactionRequest = class {
1772
1837
  let policyTypes = 0;
1773
1838
  const policies = [];
1774
1839
  if (req.gasPrice) {
1775
- policyTypes += import_transactions5.PolicyType.GasPrice;
1776
- policies.push({ data: req.gasPrice, type: import_transactions5.PolicyType.GasPrice });
1840
+ policyTypes += import_transactions6.PolicyType.GasPrice;
1841
+ policies.push({ data: req.gasPrice, type: import_transactions6.PolicyType.GasPrice });
1777
1842
  }
1778
1843
  if (req.witnessLimit) {
1779
- policyTypes += import_transactions5.PolicyType.WitnessLimit;
1780
- policies.push({ data: req.witnessLimit, type: import_transactions5.PolicyType.WitnessLimit });
1844
+ policyTypes += import_transactions6.PolicyType.WitnessLimit;
1845
+ policies.push({ data: req.witnessLimit, type: import_transactions6.PolicyType.WitnessLimit });
1781
1846
  }
1782
1847
  if (req.maturity > 0) {
1783
- policyTypes += import_transactions5.PolicyType.Maturity;
1784
- policies.push({ data: req.maturity, type: import_transactions5.PolicyType.Maturity });
1848
+ policyTypes += import_transactions6.PolicyType.Maturity;
1849
+ policies.push({ data: req.maturity, type: import_transactions6.PolicyType.Maturity });
1785
1850
  }
1786
1851
  if (req.maxFee) {
1787
- policyTypes += import_transactions5.PolicyType.MaxFee;
1788
- policies.push({ data: req.maxFee, type: import_transactions5.PolicyType.MaxFee });
1852
+ policyTypes += import_transactions6.PolicyType.MaxFee;
1853
+ policies.push({ data: req.maxFee, type: import_transactions6.PolicyType.MaxFee });
1789
1854
  }
1790
1855
  return {
1791
1856
  policyTypes,
@@ -1819,7 +1884,7 @@ var BaseTransactionRequest = class {
1819
1884
  * @returns The transaction bytes.
1820
1885
  */
1821
1886
  toTransactionBytes() {
1822
- return new import_transactions5.TransactionCoder().encode(this.toTransaction());
1887
+ return new import_transactions6.TransactionCoder().encode(this.toTransaction());
1823
1888
  }
1824
1889
  /**
1825
1890
  * @hidden
@@ -1859,7 +1924,7 @@ var BaseTransactionRequest = class {
1859
1924
  * @returns The index of the created witness.
1860
1925
  */
1861
1926
  addEmptyWitness() {
1862
- this.addWitness((0, import_utils9.concat)([import_configs6.ZeroBytes32, import_configs6.ZeroBytes32]));
1927
+ this.addWitness((0, import_utils9.concat)([import_configs7.ZeroBytes32, import_configs7.ZeroBytes32]));
1863
1928
  return this.witnesses.length - 1;
1864
1929
  }
1865
1930
  /**
@@ -1910,7 +1975,7 @@ var BaseTransactionRequest = class {
1910
1975
  */
1911
1976
  getCoinInputs() {
1912
1977
  return this.inputs.filter(
1913
- (input) => input.type === import_transactions5.InputType.Coin
1978
+ (input) => input.type === import_transactions6.InputType.Coin
1914
1979
  );
1915
1980
  }
1916
1981
  /**
@@ -1920,7 +1985,7 @@ var BaseTransactionRequest = class {
1920
1985
  */
1921
1986
  getCoinOutputs() {
1922
1987
  return this.outputs.filter(
1923
- (output) => output.type === import_transactions5.OutputType.Coin
1988
+ (output) => output.type === import_transactions6.OutputType.Coin
1924
1989
  );
1925
1990
  }
1926
1991
  /**
@@ -1930,7 +1995,7 @@ var BaseTransactionRequest = class {
1930
1995
  */
1931
1996
  getChangeOutputs() {
1932
1997
  return this.outputs.filter(
1933
- (output) => output.type === import_transactions5.OutputType.Change
1998
+ (output) => output.type === import_transactions6.OutputType.Change
1934
1999
  );
1935
2000
  }
1936
2001
  /**
@@ -1942,9 +2007,9 @@ var BaseTransactionRequest = class {
1942
2007
  const ownerAddress = (0, import_address.addressify)(owner);
1943
2008
  const found = this.inputs.find((input) => {
1944
2009
  switch (input.type) {
1945
- case import_transactions5.InputType.Coin:
2010
+ case import_transactions6.InputType.Coin:
1946
2011
  return (0, import_utils9.hexlify)(input.owner) === ownerAddress.toB256();
1947
- case import_transactions5.InputType.Message:
2012
+ case import_transactions6.InputType.Message:
1948
2013
  return (0, import_utils9.hexlify)(input.recipient) === ownerAddress.toB256();
1949
2014
  default:
1950
2015
  return false;
@@ -1973,7 +2038,7 @@ var BaseTransactionRequest = class {
1973
2038
  }
1974
2039
  const input = {
1975
2040
  ...coin,
1976
- type: import_transactions5.InputType.Coin,
2041
+ type: import_transactions6.InputType.Coin,
1977
2042
  owner: owner.toB256(),
1978
2043
  amount,
1979
2044
  assetId,
@@ -1995,7 +2060,7 @@ var BaseTransactionRequest = class {
1995
2060
  */
1996
2061
  addMessageInput(message, predicate) {
1997
2062
  const { recipient, sender, amount } = message;
1998
- const assetId = import_configs6.BaseAssetId;
2063
+ const assetId = import_configs7.BaseAssetId;
1999
2064
  let witnessIndex;
2000
2065
  if (predicate) {
2001
2066
  witnessIndex = 0;
@@ -2007,7 +2072,7 @@ var BaseTransactionRequest = class {
2007
2072
  }
2008
2073
  const input = {
2009
2074
  ...message,
2010
- type: import_transactions5.InputType.Message,
2075
+ type: import_transactions6.InputType.Message,
2011
2076
  sender: sender.toB256(),
2012
2077
  recipient: recipient.toB256(),
2013
2078
  amount,
@@ -2077,9 +2142,9 @@ var BaseTransactionRequest = class {
2077
2142
  * @param amount - Amount of coin.
2078
2143
  * @param assetId - Asset ID of coin.
2079
2144
  */
2080
- addCoinOutput(to, amount, assetId = import_configs6.BaseAssetId) {
2145
+ addCoinOutput(to, amount, assetId = import_configs7.BaseAssetId) {
2081
2146
  this.pushOutput({
2082
- type: import_transactions5.OutputType.Coin,
2147
+ type: import_transactions6.OutputType.Coin,
2083
2148
  to: (0, import_address.addressify)(to).toB256(),
2084
2149
  amount,
2085
2150
  assetId
@@ -2095,7 +2160,7 @@ var BaseTransactionRequest = class {
2095
2160
  addCoinOutputs(to, quantities) {
2096
2161
  quantities.map(coinQuantityfy).forEach((quantity) => {
2097
2162
  this.pushOutput({
2098
- type: import_transactions5.OutputType.Coin,
2163
+ type: import_transactions6.OutputType.Coin,
2099
2164
  to: (0, import_address.addressify)(to).toB256(),
2100
2165
  amount: quantity.amount,
2101
2166
  assetId: quantity.assetId
@@ -2109,13 +2174,13 @@ var BaseTransactionRequest = class {
2109
2174
  * @param to - Address of the owner.
2110
2175
  * @param assetId - Asset ID of coin.
2111
2176
  */
2112
- addChangeOutput(to, assetId = import_configs6.BaseAssetId) {
2177
+ addChangeOutput(to, assetId = import_configs7.BaseAssetId) {
2113
2178
  const changeOutput = this.getChangeOutputs().find(
2114
2179
  (output) => (0, import_utils9.hexlify)(output.assetId) === assetId
2115
2180
  );
2116
2181
  if (!changeOutput) {
2117
2182
  this.pushOutput({
2118
- type: import_transactions5.OutputType.Change,
2183
+ type: import_transactions6.OutputType.Change,
2119
2184
  to: (0, import_address.addressify)(to).toB256(),
2120
2185
  assetId
2121
2186
  });
@@ -2171,7 +2236,7 @@ var BaseTransactionRequest = class {
2171
2236
  let idCounter = 0;
2172
2237
  const generateId = () => {
2173
2238
  const counterString = String(idCounter++);
2174
- const id = import_configs6.ZeroBytes32.slice(0, -counterString.length).concat(counterString);
2239
+ const id = import_configs7.ZeroBytes32.slice(0, -counterString.length).concat(counterString);
2175
2240
  return id;
2176
2241
  };
2177
2242
  const findAssetInput = (assetId) => this.inputs.find((input) => {
@@ -2193,13 +2258,13 @@ var BaseTransactionRequest = class {
2193
2258
  assetId,
2194
2259
  owner: resourcesOwner || import_address.Address.fromRandom(),
2195
2260
  maturity: 0,
2196
- blockCreated: (0, import_math6.bn)(1),
2197
- txCreatedIdx: (0, import_math6.bn)(1)
2261
+ blockCreated: (0, import_math7.bn)(1),
2262
+ txCreatedIdx: (0, import_math7.bn)(1)
2198
2263
  }
2199
2264
  ]);
2200
2265
  }
2201
2266
  };
2202
- updateAssetInput(import_configs6.BaseAssetId, (0, import_math6.bn)(1e11));
2267
+ updateAssetInput(import_configs7.BaseAssetId, (0, import_math7.bn)(1e11));
2203
2268
  quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
2204
2269
  }
2205
2270
  /**
@@ -2210,7 +2275,7 @@ var BaseTransactionRequest = class {
2210
2275
  */
2211
2276
  getCoinOutputsQuantities() {
2212
2277
  const coinsQuantities = this.getCoinOutputs().map(({ amount, assetId }) => ({
2213
- amount: (0, import_math6.bn)(amount),
2278
+ amount: (0, import_math7.bn)(amount),
2214
2279
  assetId: assetId.toString()
2215
2280
  }));
2216
2281
  return coinsQuantities;
@@ -2228,18 +2293,18 @@ var BaseTransactionRequest = class {
2228
2293
  this.inputs.forEach((i) => {
2229
2294
  let correspondingInput;
2230
2295
  switch (i.type) {
2231
- case import_transactions5.InputType.Coin:
2232
- correspondingInput = inputs.find((x) => x.type === import_transactions5.InputType.Coin && x.owner === i.owner);
2296
+ case import_transactions6.InputType.Coin:
2297
+ correspondingInput = inputs.find((x) => x.type === import_transactions6.InputType.Coin && x.owner === i.owner);
2233
2298
  break;
2234
- case import_transactions5.InputType.Message:
2299
+ case import_transactions6.InputType.Message:
2235
2300
  correspondingInput = inputs.find(
2236
- (x) => x.type === import_transactions5.InputType.Message && x.sender === i.sender
2301
+ (x) => x.type === import_transactions6.InputType.Message && x.sender === i.sender
2237
2302
  );
2238
2303
  break;
2239
2304
  default:
2240
2305
  return;
2241
2306
  }
2242
- if (correspondingInput && "predicateGasUsed" in correspondingInput && (0, import_math6.bn)(correspondingInput.predicateGasUsed).gt(0)) {
2307
+ if (correspondingInput && "predicateGasUsed" in correspondingInput && (0, import_math7.bn)(correspondingInput.predicateGasUsed).gt(0)) {
2243
2308
  i.predicate = correspondingInput.predicate;
2244
2309
  i.predicateData = correspondingInput.predicateData;
2245
2310
  i.predicateGasUsed = correspondingInput.predicateGasUsed;
@@ -2249,47 +2314,47 @@ var BaseTransactionRequest = class {
2249
2314
  };
2250
2315
 
2251
2316
  // 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");
2317
+ var import_configs9 = require("@fuel-ts/address/configs");
2318
+ var import_math9 = require("@fuel-ts/math");
2319
+ var import_transactions8 = require("@fuel-ts/transactions");
2255
2320
  var import_utils13 = require("@fuel-ts/utils");
2256
2321
 
2257
2322
  // src/providers/transaction-request/hash-transaction.ts
2258
- var import_configs7 = require("@fuel-ts/address/configs");
2323
+ var import_configs8 = require("@fuel-ts/address/configs");
2259
2324
  var import_hasher = require("@fuel-ts/hasher");
2260
- var import_math7 = require("@fuel-ts/math");
2261
- var import_transactions6 = require("@fuel-ts/transactions");
2325
+ var import_math8 = require("@fuel-ts/math");
2326
+ var import_transactions7 = require("@fuel-ts/transactions");
2262
2327
  var import_utils11 = require("@fuel-ts/utils");
2263
2328
  var import_ramda2 = require("ramda");
2264
2329
  function hashTransaction(transactionRequest, chainId) {
2265
2330
  const transaction = transactionRequest.toTransaction();
2266
- if (transaction.type === import_transactions6.TransactionType.Script) {
2267
- transaction.receiptsRoot = import_configs7.ZeroBytes32;
2331
+ if (transaction.type === import_transactions7.TransactionType.Script) {
2332
+ transaction.receiptsRoot = import_configs8.ZeroBytes32;
2268
2333
  }
2269
2334
  transaction.inputs = transaction.inputs.map((input) => {
2270
2335
  const inputClone = (0, import_ramda2.clone)(input);
2271
2336
  switch (inputClone.type) {
2272
- case import_transactions6.InputType.Coin: {
2337
+ case import_transactions7.InputType.Coin: {
2273
2338
  inputClone.txPointer = {
2274
2339
  blockHeight: 0,
2275
2340
  txIndex: 0
2276
2341
  };
2277
- inputClone.predicateGasUsed = (0, import_math7.bn)(0);
2342
+ inputClone.predicateGasUsed = (0, import_math8.bn)(0);
2278
2343
  return inputClone;
2279
2344
  }
2280
- case import_transactions6.InputType.Message: {
2281
- inputClone.predicateGasUsed = (0, import_math7.bn)(0);
2345
+ case import_transactions7.InputType.Message: {
2346
+ inputClone.predicateGasUsed = (0, import_math8.bn)(0);
2282
2347
  return inputClone;
2283
2348
  }
2284
- case import_transactions6.InputType.Contract: {
2349
+ case import_transactions7.InputType.Contract: {
2285
2350
  inputClone.txPointer = {
2286
2351
  blockHeight: 0,
2287
2352
  txIndex: 0
2288
2353
  };
2289
- inputClone.txID = import_configs7.ZeroBytes32;
2354
+ inputClone.txID = import_configs8.ZeroBytes32;
2290
2355
  inputClone.outputIndex = 0;
2291
- inputClone.balanceRoot = import_configs7.ZeroBytes32;
2292
- inputClone.stateRoot = import_configs7.ZeroBytes32;
2356
+ inputClone.balanceRoot = import_configs8.ZeroBytes32;
2357
+ inputClone.stateRoot = import_configs8.ZeroBytes32;
2293
2358
  return inputClone;
2294
2359
  }
2295
2360
  default:
@@ -2299,19 +2364,19 @@ function hashTransaction(transactionRequest, chainId) {
2299
2364
  transaction.outputs = transaction.outputs.map((output) => {
2300
2365
  const outputClone = (0, import_ramda2.clone)(output);
2301
2366
  switch (outputClone.type) {
2302
- case import_transactions6.OutputType.Contract: {
2303
- outputClone.balanceRoot = import_configs7.ZeroBytes32;
2304
- outputClone.stateRoot = import_configs7.ZeroBytes32;
2367
+ case import_transactions7.OutputType.Contract: {
2368
+ outputClone.balanceRoot = import_configs8.ZeroBytes32;
2369
+ outputClone.stateRoot = import_configs8.ZeroBytes32;
2305
2370
  return outputClone;
2306
2371
  }
2307
- case import_transactions6.OutputType.Change: {
2308
- outputClone.amount = (0, import_math7.bn)(0);
2372
+ case import_transactions7.OutputType.Change: {
2373
+ outputClone.amount = (0, import_math8.bn)(0);
2309
2374
  return outputClone;
2310
2375
  }
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;
2376
+ case import_transactions7.OutputType.Variable: {
2377
+ outputClone.to = import_configs8.ZeroBytes32;
2378
+ outputClone.amount = (0, import_math8.bn)(0);
2379
+ outputClone.assetId = import_configs8.ZeroBytes32;
2315
2380
  return outputClone;
2316
2381
  }
2317
2382
  default:
@@ -2321,7 +2386,7 @@ function hashTransaction(transactionRequest, chainId) {
2321
2386
  transaction.witnessesCount = 0;
2322
2387
  transaction.witnesses = [];
2323
2388
  const chainIdBytes = (0, import_hasher.uint64ToBytesBE)(chainId);
2324
- const concatenatedData = (0, import_utils11.concat)([chainIdBytes, new import_transactions6.TransactionCoder().encode(transaction)]);
2389
+ const concatenatedData = (0, import_utils11.concat)([chainIdBytes, new import_transactions7.TransactionCoder().encode(transaction)]);
2325
2390
  return (0, import_hasher.sha256)(concatenatedData);
2326
2391
  }
2327
2392
 
@@ -2357,7 +2422,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2357
2422
  return new this(obj);
2358
2423
  }
2359
2424
  /** Type of the transaction */
2360
- type = import_transactions7.TransactionType.Create;
2425
+ type = import_transactions8.TransactionType.Create;
2361
2426
  /** Witness index of contract bytecode to create */
2362
2427
  bytecodeWitnessIndex;
2363
2428
  /** Salt */
@@ -2377,7 +2442,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2377
2442
  } = {}) {
2378
2443
  super(rest);
2379
2444
  this.bytecodeWitnessIndex = bytecodeWitnessIndex ?? 0;
2380
- this.salt = (0, import_utils13.hexlify)(salt ?? import_configs8.ZeroBytes32);
2445
+ this.salt = (0, import_utils13.hexlify)(salt ?? import_configs9.ZeroBytes32);
2381
2446
  this.storageSlots = [...storageSlots ?? []];
2382
2447
  }
2383
2448
  /**
@@ -2390,12 +2455,12 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2390
2455
  const bytecodeWitnessIndex = this.bytecodeWitnessIndex;
2391
2456
  const storageSlots = this.storageSlots?.map(storageSlotify) ?? [];
2392
2457
  return {
2393
- type: import_transactions7.TransactionType.Create,
2458
+ type: import_transactions8.TransactionType.Create,
2394
2459
  ...baseTransaction,
2395
2460
  bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
2396
2461
  bytecodeWitnessIndex,
2397
2462
  storageSlotsCount: storageSlots.length,
2398
- salt: this.salt ? (0, import_utils13.hexlify)(this.salt) : import_configs8.ZeroBytes32,
2463
+ salt: this.salt ? (0, import_utils13.hexlify)(this.salt) : import_configs9.ZeroBytes32,
2399
2464
  storageSlots
2400
2465
  };
2401
2466
  }
@@ -2406,7 +2471,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2406
2471
  */
2407
2472
  getContractCreatedOutputs() {
2408
2473
  return this.outputs.filter(
2409
- (output) => output.type === import_transactions7.OutputType.ContractCreated
2474
+ (output) => output.type === import_transactions8.OutputType.ContractCreated
2410
2475
  );
2411
2476
  }
2412
2477
  /**
@@ -2427,14 +2492,14 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2427
2492
  */
2428
2493
  addContractCreatedOutput(contractId, stateRoot) {
2429
2494
  this.pushOutput({
2430
- type: import_transactions7.OutputType.ContractCreated,
2495
+ type: import_transactions8.OutputType.ContractCreated,
2431
2496
  contractId,
2432
2497
  stateRoot
2433
2498
  });
2434
2499
  }
2435
2500
  metadataGas(gasCosts) {
2436
2501
  return calculateMetadataGasForTxCreate({
2437
- contractBytesSize: (0, import_math8.bn)((0, import_utils13.arrayify)(this.witnesses[this.bytecodeWitnessIndex] || "0x").length),
2502
+ contractBytesSize: (0, import_math9.bn)((0, import_utils13.arrayify)(this.witnesses[this.bytecodeWitnessIndex] || "0x").length),
2438
2503
  gasCosts,
2439
2504
  stateRootSize: this.storageSlots.length,
2440
2505
  txBytesSize: this.byteSize()
@@ -2445,9 +2510,9 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2445
2510
  // src/providers/transaction-request/script-transaction-request.ts
2446
2511
  var import_abi_coder = require("@fuel-ts/abi-coder");
2447
2512
  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");
2513
+ var import_configs10 = require("@fuel-ts/address/configs");
2514
+ var import_math10 = require("@fuel-ts/math");
2515
+ var import_transactions9 = require("@fuel-ts/transactions");
2451
2516
  var import_utils15 = require("@fuel-ts/utils");
2452
2517
 
2453
2518
  // src/providers/transaction-request/scripts.ts
@@ -2485,13 +2550,14 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2485
2550
  return new this(obj);
2486
2551
  }
2487
2552
  /** Type of the transaction */
2488
- type = import_transactions8.TransactionType.Script;
2553
+ type = import_transactions9.TransactionType.Script;
2489
2554
  /** Gas limit for transaction */
2490
2555
  gasLimit;
2491
2556
  /** Script to execute */
2492
2557
  script;
2493
2558
  /** Script input data (parameters) */
2494
2559
  scriptData;
2560
+ abis;
2495
2561
  /**
2496
2562
  * Constructor for `ScriptTransactionRequest`.
2497
2563
  *
@@ -2499,9 +2565,10 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2499
2565
  */
2500
2566
  constructor({ script, scriptData, gasLimit, ...rest } = {}) {
2501
2567
  super(rest);
2502
- this.gasLimit = (0, import_math9.bn)(gasLimit);
2568
+ this.gasLimit = (0, import_math10.bn)(gasLimit);
2503
2569
  this.script = (0, import_utils15.arrayify)(script ?? returnZeroScript.bytes);
2504
2570
  this.scriptData = (0, import_utils15.arrayify)(scriptData ?? returnZeroScript.encodeScriptData());
2571
+ this.abis = rest.abis;
2505
2572
  }
2506
2573
  /**
2507
2574
  * Converts the transaction request to a `TransactionScript`.
@@ -2512,12 +2579,12 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2512
2579
  const script = (0, import_utils15.arrayify)(this.script ?? "0x");
2513
2580
  const scriptData = (0, import_utils15.arrayify)(this.scriptData ?? "0x");
2514
2581
  return {
2515
- type: import_transactions8.TransactionType.Script,
2582
+ type: import_transactions9.TransactionType.Script,
2516
2583
  scriptGasLimit: this.gasLimit,
2517
2584
  ...super.getBaseTransaction(),
2518
2585
  scriptLength: script.length,
2519
2586
  scriptDataLength: scriptData.length,
2520
- receiptsRoot: import_configs9.ZeroBytes32,
2587
+ receiptsRoot: import_configs10.ZeroBytes32,
2521
2588
  script: (0, import_utils15.hexlify)(script),
2522
2589
  scriptData: (0, import_utils15.hexlify)(scriptData)
2523
2590
  };
@@ -2529,7 +2596,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2529
2596
  */
2530
2597
  getContractInputs() {
2531
2598
  return this.inputs.filter(
2532
- (input) => input.type === import_transactions8.InputType.Contract
2599
+ (input) => input.type === import_transactions9.InputType.Contract
2533
2600
  );
2534
2601
  }
2535
2602
  /**
@@ -2539,7 +2606,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2539
2606
  */
2540
2607
  getContractOutputs() {
2541
2608
  return this.outputs.filter(
2542
- (output) => output.type === import_transactions8.OutputType.Contract
2609
+ (output) => output.type === import_transactions9.OutputType.Contract
2543
2610
  );
2544
2611
  }
2545
2612
  /**
@@ -2549,7 +2616,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2549
2616
  */
2550
2617
  getVariableOutputs() {
2551
2618
  return this.outputs.filter(
2552
- (output) => output.type === import_transactions8.OutputType.Variable
2619
+ (output) => output.type === import_transactions9.OutputType.Variable
2553
2620
  );
2554
2621
  }
2555
2622
  /**
@@ -2572,7 +2639,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2572
2639
  let outputsNumber = numberOfVariables;
2573
2640
  while (outputsNumber) {
2574
2641
  this.pushOutput({
2575
- type: import_transactions8.OutputType.Variable
2642
+ type: import_transactions9.OutputType.Variable
2576
2643
  });
2577
2644
  outputsNumber -= 1;
2578
2645
  }
@@ -2605,12 +2672,12 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2605
2672
  return this;
2606
2673
  }
2607
2674
  const inputIndex = super.pushInput({
2608
- type: import_transactions8.InputType.Contract,
2675
+ type: import_transactions9.InputType.Contract,
2609
2676
  contractId: contractAddress.toB256(),
2610
2677
  txPointer: "0x00000000000000000000000000000000"
2611
2678
  });
2612
2679
  this.pushOutput({
2613
- type: import_transactions8.OutputType.Contract,
2680
+ type: import_transactions9.OutputType.Contract,
2614
2681
  inputIndex
2615
2682
  });
2616
2683
  return this;
@@ -2646,38 +2713,38 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2646
2713
  };
2647
2714
 
2648
2715
  // src/providers/transaction-request/utils.ts
2649
- var import_errors8 = require("@fuel-ts/errors");
2650
- var import_transactions9 = require("@fuel-ts/transactions");
2716
+ var import_errors9 = require("@fuel-ts/errors");
2717
+ var import_transactions10 = require("@fuel-ts/transactions");
2651
2718
  var transactionRequestify = (obj) => {
2652
2719
  if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest) {
2653
2720
  return obj;
2654
2721
  }
2655
2722
  const { type } = obj;
2656
2723
  switch (obj.type) {
2657
- case import_transactions9.TransactionType.Script: {
2724
+ case import_transactions10.TransactionType.Script: {
2658
2725
  return ScriptTransactionRequest.from(obj);
2659
2726
  }
2660
- case import_transactions9.TransactionType.Create: {
2727
+ case import_transactions10.TransactionType.Create: {
2661
2728
  return CreateTransactionRequest.from(obj);
2662
2729
  }
2663
2730
  default: {
2664
- throw new import_errors8.FuelError(import_errors8.ErrorCode.INVALID_TRANSACTION_TYPE, `Invalid transaction type: ${type}.`);
2731
+ throw new import_errors9.FuelError(import_errors9.ErrorCode.INVALID_TRANSACTION_TYPE, `Invalid transaction type: ${type}.`);
2665
2732
  }
2666
2733
  }
2667
2734
  };
2668
2735
 
2669
2736
  // src/providers/transaction-response/transaction-response.ts
2670
- var import_errors12 = require("@fuel-ts/errors");
2671
- var import_math13 = require("@fuel-ts/math");
2672
- var import_transactions15 = require("@fuel-ts/transactions");
2737
+ var import_errors13 = require("@fuel-ts/errors");
2738
+ var import_math14 = require("@fuel-ts/math");
2739
+ var import_transactions17 = require("@fuel-ts/transactions");
2673
2740
  var import_utils21 = require("@fuel-ts/utils");
2674
2741
 
2675
2742
  // src/providers/transaction-summary/assemble-transaction-summary.ts
2676
2743
  var import_utils19 = require("@fuel-ts/utils");
2677
2744
 
2678
2745
  // src/providers/transaction-summary/calculate-transaction-fee.ts
2679
- var import_math10 = require("@fuel-ts/math");
2680
- var import_transactions10 = require("@fuel-ts/transactions");
2746
+ var import_math11 = require("@fuel-ts/math");
2747
+ var import_transactions11 = require("@fuel-ts/transactions");
2681
2748
  var import_utils16 = require("@fuel-ts/utils");
2682
2749
  var calculateTransactionFee = (params) => {
2683
2750
  const {
@@ -2685,24 +2752,24 @@ var calculateTransactionFee = (params) => {
2685
2752
  rawPayload,
2686
2753
  consensusParameters: { gasCosts, feeParams }
2687
2754
  } = params;
2688
- const gasPerByte = (0, import_math10.bn)(feeParams.gasPerByte);
2689
- const gasPriceFactor = (0, import_math10.bn)(feeParams.gasPriceFactor);
2755
+ const gasPerByte = (0, import_math11.bn)(feeParams.gasPerByte);
2756
+ const gasPriceFactor = (0, import_math11.bn)(feeParams.gasPriceFactor);
2690
2757
  const transactionBytes = (0, import_utils16.arrayify)(rawPayload);
2691
- const [transaction] = new import_transactions10.TransactionCoder().decode(transactionBytes, 0);
2692
- if (transaction.type === import_transactions10.TransactionType.Mint) {
2758
+ const [transaction] = new import_transactions11.TransactionCoder().decode(transactionBytes, 0);
2759
+ if (transaction.type === import_transactions11.TransactionType.Mint) {
2693
2760
  return {
2694
- fee: (0, import_math10.bn)(0),
2695
- minFee: (0, import_math10.bn)(0),
2696
- maxFee: (0, import_math10.bn)(0),
2697
- feeFromGasUsed: (0, import_math10.bn)(0)
2761
+ fee: (0, import_math11.bn)(0),
2762
+ minFee: (0, import_math11.bn)(0),
2763
+ maxFee: (0, import_math11.bn)(0),
2764
+ feeFromGasUsed: (0, import_math11.bn)(0)
2698
2765
  };
2699
2766
  }
2700
2767
  const { type, witnesses, inputs, policies } = transaction;
2701
- let metadataGas = (0, import_math10.bn)(0);
2702
- let gasLimit = (0, import_math10.bn)(0);
2703
- if (type === import_transactions10.TransactionType.Create) {
2768
+ let metadataGas = (0, import_math11.bn)(0);
2769
+ let gasLimit = (0, import_math11.bn)(0);
2770
+ if (type === import_transactions11.TransactionType.Create) {
2704
2771
  const { bytecodeWitnessIndex, storageSlots } = transaction;
2705
- const contractBytesSize = (0, import_math10.bn)((0, import_utils16.arrayify)(witnesses[bytecodeWitnessIndex].data).length);
2772
+ const contractBytesSize = (0, import_math11.bn)((0, import_utils16.arrayify)(witnesses[bytecodeWitnessIndex].data).length);
2706
2773
  metadataGas = calculateMetadataGasForTxCreate({
2707
2774
  contractBytesSize,
2708
2775
  gasCosts,
@@ -2721,13 +2788,13 @@ var calculateTransactionFee = (params) => {
2721
2788
  }
2722
2789
  const minGas = getMinGas({
2723
2790
  gasCosts,
2724
- gasPerByte: (0, import_math10.bn)(gasPerByte),
2791
+ gasPerByte: (0, import_math11.bn)(gasPerByte),
2725
2792
  inputs,
2726
2793
  metadataGas,
2727
2794
  txBytesSize: transactionBytes.length
2728
2795
  });
2729
- const gasPrice = (0, import_math10.bn)(policies.find((policy) => policy.type === import_transactions10.PolicyType.GasPrice)?.data);
2730
- const witnessLimit = policies.find((policy) => policy.type === import_transactions10.PolicyType.WitnessLimit)?.data;
2796
+ const gasPrice = (0, import_math11.bn)(policies.find((policy) => policy.type === import_transactions11.PolicyType.GasPrice)?.data);
2797
+ const witnessLimit = policies.find((policy) => policy.type === import_transactions11.PolicyType.WitnessLimit)?.data;
2731
2798
  const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
2732
2799
  const maxGas = getMaxGas({
2733
2800
  gasPerByte,
@@ -2749,14 +2816,14 @@ var calculateTransactionFee = (params) => {
2749
2816
  };
2750
2817
 
2751
2818
  // src/providers/transaction-summary/operations.ts
2752
- var import_configs10 = require("@fuel-ts/address/configs");
2753
- var import_errors10 = require("@fuel-ts/errors");
2754
- var import_math12 = require("@fuel-ts/math");
2755
- var import_transactions13 = require("@fuel-ts/transactions");
2819
+ var import_configs11 = require("@fuel-ts/address/configs");
2820
+ var import_errors11 = require("@fuel-ts/errors");
2821
+ var import_math13 = require("@fuel-ts/math");
2822
+ var import_transactions14 = require("@fuel-ts/transactions");
2756
2823
 
2757
2824
  // src/providers/transaction-summary/call.ts
2758
2825
  var import_abi_coder2 = require("@fuel-ts/abi-coder");
2759
- var import_math11 = require("@fuel-ts/math");
2826
+ var import_math12 = require("@fuel-ts/math");
2760
2827
  var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
2761
2828
  const abiInterface = new import_abi_coder2.Interface(abi);
2762
2829
  const callFunctionSelector = receipt.param1.toHex(8);
@@ -2765,7 +2832,7 @@ var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
2765
2832
  let encodedArgs;
2766
2833
  if (functionFragment.isInputDataPointer) {
2767
2834
  if (rawPayload) {
2768
- const argsOffset = (0, import_math11.bn)(receipt.param2).sub((0, import_abi_coder2.calculateVmTxMemory)({ maxInputs: maxInputs.toNumber() })).toNumber();
2835
+ const argsOffset = (0, import_math12.bn)(receipt.param2).sub((0, import_abi_coder2.calculateVmTxMemory)({ maxInputs: maxInputs.toNumber() })).toNumber();
2769
2836
  encodedArgs = `0x${rawPayload.slice(2).slice(argsOffset * 2)}`;
2770
2837
  }
2771
2838
  } else {
@@ -2799,8 +2866,8 @@ var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
2799
2866
  };
2800
2867
 
2801
2868
  // src/providers/transaction-summary/input.ts
2802
- var import_errors9 = require("@fuel-ts/errors");
2803
- var import_transactions11 = require("@fuel-ts/transactions");
2869
+ var import_errors10 = require("@fuel-ts/errors");
2870
+ var import_transactions12 = require("@fuel-ts/transactions");
2804
2871
  function getInputsByTypes(inputs, types) {
2805
2872
  return inputs.filter((i) => types.includes(i.type));
2806
2873
  }
@@ -2808,16 +2875,16 @@ function getInputsByType(inputs, type) {
2808
2875
  return inputs.filter((i) => i.type === type);
2809
2876
  }
2810
2877
  function getInputsCoin(inputs) {
2811
- return getInputsByType(inputs, import_transactions11.InputType.Coin);
2878
+ return getInputsByType(inputs, import_transactions12.InputType.Coin);
2812
2879
  }
2813
2880
  function getInputsMessage(inputs) {
2814
- return getInputsByType(inputs, import_transactions11.InputType.Message);
2881
+ return getInputsByType(inputs, import_transactions12.InputType.Message);
2815
2882
  }
2816
2883
  function getInputsCoinAndMessage(inputs) {
2817
- return getInputsByTypes(inputs, [import_transactions11.InputType.Coin, import_transactions11.InputType.Message]);
2884
+ return getInputsByTypes(inputs, [import_transactions12.InputType.Coin, import_transactions12.InputType.Message]);
2818
2885
  }
2819
2886
  function getInputsContract(inputs) {
2820
- return getInputsByType(inputs, import_transactions11.InputType.Contract);
2887
+ return getInputsByType(inputs, import_transactions12.InputType.Contract);
2821
2888
  }
2822
2889
  function getInputFromAssetId(inputs, assetId) {
2823
2890
  const coinInputs = getInputsCoin(inputs);
@@ -2836,43 +2903,43 @@ function getInputContractFromIndex(inputs, inputIndex) {
2836
2903
  if (!contractInput) {
2837
2904
  return void 0;
2838
2905
  }
2839
- if (contractInput.type !== import_transactions11.InputType.Contract) {
2840
- throw new import_errors9.FuelError(
2841
- import_errors9.ErrorCode.INVALID_TRANSACTION_INPUT,
2906
+ if (contractInput.type !== import_transactions12.InputType.Contract) {
2907
+ throw new import_errors10.FuelError(
2908
+ import_errors10.ErrorCode.INVALID_TRANSACTION_INPUT,
2842
2909
  `Contract input should be of type 'contract'.`
2843
2910
  );
2844
2911
  }
2845
2912
  return contractInput;
2846
2913
  }
2847
2914
  function getInputAccountAddress(input) {
2848
- if (input.type === import_transactions11.InputType.Coin) {
2915
+ if (input.type === import_transactions12.InputType.Coin) {
2849
2916
  return input.owner.toString();
2850
2917
  }
2851
- if (input.type === import_transactions11.InputType.Message) {
2918
+ if (input.type === import_transactions12.InputType.Message) {
2852
2919
  return input.recipient.toString();
2853
2920
  }
2854
2921
  return "";
2855
2922
  }
2856
2923
 
2857
2924
  // src/providers/transaction-summary/output.ts
2858
- var import_transactions12 = require("@fuel-ts/transactions");
2925
+ var import_transactions13 = require("@fuel-ts/transactions");
2859
2926
  function getOutputsByType(outputs, type) {
2860
2927
  return outputs.filter((o) => o.type === type);
2861
2928
  }
2862
2929
  function getOutputsContractCreated(outputs) {
2863
- return getOutputsByType(outputs, import_transactions12.OutputType.ContractCreated);
2930
+ return getOutputsByType(outputs, import_transactions13.OutputType.ContractCreated);
2864
2931
  }
2865
2932
  function getOutputsCoin(outputs) {
2866
- return getOutputsByType(outputs, import_transactions12.OutputType.Coin);
2933
+ return getOutputsByType(outputs, import_transactions13.OutputType.Coin);
2867
2934
  }
2868
2935
  function getOutputsChange(outputs) {
2869
- return getOutputsByType(outputs, import_transactions12.OutputType.Change);
2936
+ return getOutputsByType(outputs, import_transactions13.OutputType.Change);
2870
2937
  }
2871
2938
  function getOutputsContract(outputs) {
2872
- return getOutputsByType(outputs, import_transactions12.OutputType.Contract);
2939
+ return getOutputsByType(outputs, import_transactions13.OutputType.Contract);
2873
2940
  }
2874
2941
  function getOutputsVariable(outputs) {
2875
- return getOutputsByType(outputs, import_transactions12.OutputType.Variable);
2942
+ return getOutputsByType(outputs, import_transactions13.OutputType.Variable);
2876
2943
  }
2877
2944
 
2878
2945
  // src/providers/transaction-summary/types.ts
@@ -2919,15 +2986,15 @@ function getReceiptsByType(receipts, type) {
2919
2986
  }
2920
2987
  function getTransactionTypeName(transactionType) {
2921
2988
  switch (transactionType) {
2922
- case import_transactions13.TransactionType.Mint:
2989
+ case import_transactions14.TransactionType.Mint:
2923
2990
  return "Mint" /* Mint */;
2924
- case import_transactions13.TransactionType.Create:
2991
+ case import_transactions14.TransactionType.Create:
2925
2992
  return "Create" /* Create */;
2926
- case import_transactions13.TransactionType.Script:
2993
+ case import_transactions14.TransactionType.Script:
2927
2994
  return "Script" /* Script */;
2928
2995
  default:
2929
- throw new import_errors10.FuelError(
2930
- import_errors10.ErrorCode.INVALID_TRANSACTION_TYPE,
2996
+ throw new import_errors11.FuelError(
2997
+ import_errors11.ErrorCode.INVALID_TRANSACTION_TYPE,
2931
2998
  `Invalid transaction type: ${transactionType}.`
2932
2999
  );
2933
3000
  }
@@ -2949,10 +3016,10 @@ function hasSameAssetId(a) {
2949
3016
  return (b) => a.assetId === b.assetId;
2950
3017
  }
2951
3018
  function getReceiptsCall(receipts) {
2952
- return getReceiptsByType(receipts, import_transactions13.ReceiptType.Call);
3019
+ return getReceiptsByType(receipts, import_transactions14.ReceiptType.Call);
2953
3020
  }
2954
3021
  function getReceiptsMessageOut(receipts) {
2955
- return getReceiptsByType(receipts, import_transactions13.ReceiptType.MessageOut);
3022
+ return getReceiptsByType(receipts, import_transactions14.ReceiptType.MessageOut);
2956
3023
  }
2957
3024
  var mergeAssets = (op1, op2) => {
2958
3025
  const assets1 = op1.assetsSent || [];
@@ -2965,7 +3032,7 @@ var mergeAssets = (op1, op2) => {
2965
3032
  if (!matchingAsset) {
2966
3033
  return asset1;
2967
3034
  }
2968
- const mergedAmount = (0, import_math12.bn)(asset1.amount).add(matchingAsset.amount);
3035
+ const mergedAmount = (0, import_math13.bn)(asset1.amount).add(matchingAsset.amount);
2969
3036
  return { ...asset1, amount: mergedAmount };
2970
3037
  });
2971
3038
  return mergedAssets.concat(filteredAssets);
@@ -2991,7 +3058,7 @@ function addOperation(operations, toAdd) {
2991
3058
  return allOperations;
2992
3059
  }
2993
3060
  function getReceiptsTransferOut(receipts) {
2994
- return getReceiptsByType(receipts, import_transactions13.ReceiptType.TransferOut);
3061
+ return getReceiptsByType(receipts, import_transactions14.ReceiptType.TransferOut);
2995
3062
  }
2996
3063
  function getWithdrawFromFuelOperations({
2997
3064
  inputs,
@@ -3094,7 +3161,7 @@ function extractTransferOperationFromReceipt(receipt, contractInputs, changeOutp
3094
3161
  const { to: toAddress, assetId, amount } = receipt;
3095
3162
  let { from: fromAddress } = receipt;
3096
3163
  const toType = contractInputs.some((input) => input.contractID === toAddress) ? 0 /* contract */ : 1 /* account */;
3097
- if (import_configs10.ZeroBytes32 === fromAddress) {
3164
+ if (import_configs11.ZeroBytes32 === fromAddress) {
3098
3165
  const change = changeOutputs.find((output) => output.assetId === assetId);
3099
3166
  fromAddress = change?.to || fromAddress;
3100
3167
  }
@@ -3151,11 +3218,11 @@ function getTransferOperations({
3151
3218
  });
3152
3219
  const transferReceipts = getReceiptsByType(
3153
3220
  receipts,
3154
- import_transactions13.ReceiptType.Transfer
3221
+ import_transactions14.ReceiptType.Transfer
3155
3222
  );
3156
3223
  const transferOutReceipts = getReceiptsByType(
3157
3224
  receipts,
3158
- import_transactions13.ReceiptType.TransferOut
3225
+ import_transactions14.ReceiptType.TransferOut
3159
3226
  );
3160
3227
  [...transferReceipts, ...transferOutReceipts].forEach((receipt) => {
3161
3228
  const operation = extractTransferOperationFromReceipt(receipt, contractInputs, changeOutputs);
@@ -3240,17 +3307,17 @@ function getOperations({
3240
3307
  }
3241
3308
 
3242
3309
  // src/providers/transaction-summary/receipt.ts
3243
- var import_transactions14 = require("@fuel-ts/transactions");
3310
+ var import_transactions15 = require("@fuel-ts/transactions");
3244
3311
  var processGqlReceipt = (gqlReceipt) => {
3245
3312
  const receipt = assembleReceiptByType(gqlReceipt);
3246
3313
  switch (receipt.type) {
3247
- case import_transactions14.ReceiptType.ReturnData: {
3314
+ case import_transactions15.ReceiptType.ReturnData: {
3248
3315
  return {
3249
3316
  ...receipt,
3250
3317
  data: gqlReceipt.data || "0x"
3251
3318
  };
3252
3319
  }
3253
- case import_transactions14.ReceiptType.LogData: {
3320
+ case import_transactions15.ReceiptType.LogData: {
3254
3321
  return {
3255
3322
  ...receipt,
3256
3323
  data: gqlReceipt.data || "0x"
@@ -3263,7 +3330,7 @@ var processGqlReceipt = (gqlReceipt) => {
3263
3330
  var extractMintedAssetsFromReceipts = (receipts) => {
3264
3331
  const mintedAssets = [];
3265
3332
  receipts.forEach((receipt) => {
3266
- if (receipt.type === import_transactions14.ReceiptType.Mint) {
3333
+ if (receipt.type === import_transactions15.ReceiptType.Mint) {
3267
3334
  mintedAssets.push({
3268
3335
  subId: receipt.subId,
3269
3336
  contractId: receipt.contractId,
@@ -3277,7 +3344,7 @@ var extractMintedAssetsFromReceipts = (receipts) => {
3277
3344
  var extractBurnedAssetsFromReceipts = (receipts) => {
3278
3345
  const burnedAssets = [];
3279
3346
  receipts.forEach((receipt) => {
3280
- if (receipt.type === import_transactions14.ReceiptType.Burn) {
3347
+ if (receipt.type === import_transactions15.ReceiptType.Burn) {
3281
3348
  burnedAssets.push({
3282
3349
  subId: receipt.subId,
3283
3350
  contractId: receipt.contractId,
@@ -3290,7 +3357,7 @@ var extractBurnedAssetsFromReceipts = (receipts) => {
3290
3357
  };
3291
3358
 
3292
3359
  // src/providers/transaction-summary/status.ts
3293
- var import_errors11 = require("@fuel-ts/errors");
3360
+ var import_errors12 = require("@fuel-ts/errors");
3294
3361
  var getTransactionStatusName = (gqlStatus) => {
3295
3362
  switch (gqlStatus) {
3296
3363
  case "FailureStatus":
@@ -3302,8 +3369,8 @@ var getTransactionStatusName = (gqlStatus) => {
3302
3369
  case "SqueezedOutStatus":
3303
3370
  return "squeezedout" /* squeezedout */;
3304
3371
  default:
3305
- throw new import_errors11.FuelError(
3306
- import_errors11.ErrorCode.INVALID_TRANSACTION_STATUS,
3372
+ throw new import_errors12.FuelError(
3373
+ import_errors12.ErrorCode.INVALID_TRANSACTION_STATUS,
3307
3374
  `Invalid transaction status: ${gqlStatus}.`
3308
3375
  );
3309
3376
  }
@@ -3414,6 +3481,21 @@ function assembleTransactionSummary(params) {
3414
3481
  return transactionSummary;
3415
3482
  }
3416
3483
 
3484
+ // src/providers/transaction-response/getDecodedLogs.ts
3485
+ var import_abi_coder3 = require("@fuel-ts/abi-coder");
3486
+ var import_transactions16 = require("@fuel-ts/transactions");
3487
+ function getDecodedLogs(receipts, mainAbi, externalAbis = {}) {
3488
+ return receipts.reduce((logs, receipt) => {
3489
+ if (receipt.type === import_transactions16.ReceiptType.LogData || receipt.type === import_transactions16.ReceiptType.Log) {
3490
+ const interfaceToUse = new import_abi_coder3.Interface(externalAbis[receipt.id] || mainAbi);
3491
+ const data = receipt.type === import_transactions16.ReceiptType.Log ? new import_abi_coder3.BigNumberCoder("u64").encode(receipt.val0) : receipt.data;
3492
+ const [decodedLog] = interfaceToUse.decodeLog(data, receipt.val1.toNumber());
3493
+ logs.push(decodedLog);
3494
+ }
3495
+ return logs;
3496
+ }, []);
3497
+ }
3498
+
3417
3499
  // src/providers/transaction-response/transaction-response.ts
3418
3500
  var TransactionResponse = class {
3419
3501
  /** Transaction ID */
@@ -3421,18 +3503,20 @@ var TransactionResponse = class {
3421
3503
  /** Current provider */
3422
3504
  provider;
3423
3505
  /** Gas used on the transaction */
3424
- gasUsed = (0, import_math13.bn)(0);
3506
+ gasUsed = (0, import_math14.bn)(0);
3425
3507
  /** The graphql Transaction with receipts object. */
3426
3508
  gqlTransaction;
3509
+ abis;
3427
3510
  /**
3428
3511
  * Constructor for `TransactionResponse`.
3429
3512
  *
3430
3513
  * @param id - The transaction ID.
3431
3514
  * @param provider - The provider.
3432
3515
  */
3433
- constructor(id, provider) {
3516
+ constructor(id, provider, abis) {
3434
3517
  this.id = id;
3435
3518
  this.provider = provider;
3519
+ this.abis = abis;
3436
3520
  }
3437
3521
  /**
3438
3522
  * Async constructor for `TransactionResponse`. This method can be used to create
@@ -3442,8 +3526,8 @@ var TransactionResponse = class {
3442
3526
  * @param id - The transaction ID.
3443
3527
  * @param provider - The provider.
3444
3528
  */
3445
- static async create(id, provider) {
3446
- const response = new TransactionResponse(id, provider);
3529
+ static async create(id, provider, abis) {
3530
+ const response = new TransactionResponse(id, provider, abis);
3447
3531
  await response.fetch();
3448
3532
  return response;
3449
3533
  }
@@ -3477,7 +3561,7 @@ var TransactionResponse = class {
3477
3561
  * @returns The decoded transaction.
3478
3562
  */
3479
3563
  decodeTransaction(transactionWithReceipts) {
3480
- return new import_transactions15.TransactionCoder().decode(
3564
+ return new import_transactions17.TransactionCoder().decode(
3481
3565
  (0, import_utils21.arrayify)(transactionWithReceipts.rawPayload),
3482
3566
  0
3483
3567
  )?.[0];
@@ -3524,8 +3608,8 @@ var TransactionResponse = class {
3524
3608
  });
3525
3609
  for await (const { statusChange } of subscription) {
3526
3610
  if (statusChange.type === "SqueezedOutStatus") {
3527
- throw new import_errors12.FuelError(
3528
- import_errors12.ErrorCode.TRANSACTION_SQUEEZED_OUT,
3611
+ throw new import_errors13.FuelError(
3612
+ import_errors13.ErrorCode.TRANSACTION_SQUEEZED_OUT,
3529
3613
  `Transaction Squeezed Out with reason: ${statusChange.reason}`
3530
3614
  );
3531
3615
  }
@@ -3547,6 +3631,26 @@ var TransactionResponse = class {
3547
3631
  gqlTransaction: this.gqlTransaction,
3548
3632
  ...transactionSummary
3549
3633
  };
3634
+ let logs = [];
3635
+ if (this.abis) {
3636
+ logs = getDecodedLogs(
3637
+ transactionSummary.receipts,
3638
+ this.abis.main,
3639
+ this.abis.otherContractsAbis
3640
+ );
3641
+ transactionResult.logs = logs;
3642
+ }
3643
+ if (transactionResult.isStatusFailure) {
3644
+ const {
3645
+ receipts,
3646
+ gqlTransaction: { status }
3647
+ } = transactionResult;
3648
+ throw extractTxError({
3649
+ receipts,
3650
+ status,
3651
+ logs
3652
+ });
3653
+ }
3550
3654
  return transactionResult;
3551
3655
  }
3552
3656
  /**
@@ -3557,30 +3661,21 @@ var TransactionResponse = class {
3557
3661
  async wait(contractsAbiMap) {
3558
3662
  const result = await this.waitForResult(contractsAbiMap);
3559
3663
  if (result.isStatusFailure) {
3560
- throw new import_errors12.FuelError(
3561
- import_errors12.ErrorCode.TRANSACTION_FAILED,
3562
- `Transaction failed: ${result.gqlTransaction.status.reason}`
3563
- );
3664
+ const {
3665
+ receipts,
3666
+ logs = [],
3667
+ gqlTransaction: { status }
3668
+ } = result;
3669
+ throw extractTxError({
3670
+ receipts,
3671
+ logs,
3672
+ status
3673
+ });
3564
3674
  }
3565
3675
  return result;
3566
3676
  }
3567
3677
  };
3568
3678
 
3569
- // src/providers/transaction-response/getDecodedLogs.ts
3570
- var import_abi_coder3 = require("@fuel-ts/abi-coder");
3571
- var import_transactions16 = require("@fuel-ts/transactions");
3572
- function getDecodedLogs(receipts, mainAbi, externalAbis = {}) {
3573
- return receipts.reduce((logs, receipt) => {
3574
- if (receipt.type === import_transactions16.ReceiptType.LogData || receipt.type === import_transactions16.ReceiptType.Log) {
3575
- const interfaceToUse = externalAbis[receipt.id] ? new import_abi_coder3.Interface(externalAbis[receipt.id]) : new import_abi_coder3.Interface(mainAbi);
3576
- const data = receipt.type === import_transactions16.ReceiptType.Log ? new import_abi_coder3.BigNumberCoder("u64").encode(receipt.val0) : receipt.data;
3577
- const [decodedLog] = interfaceToUse.decodeLog(data, receipt.val1.toNumber());
3578
- logs.push(decodedLog);
3579
- }
3580
- return logs;
3581
- }, []);
3582
- }
3583
-
3584
3679
  // src/providers/utils/auto-retry-fetch.ts
3585
3680
  function getWaitDelay(options, retryAttemptNum) {
3586
3681
  const duration = options.baseDelay ?? 150;
@@ -3639,29 +3734,29 @@ var processGqlChain = (chain) => {
3639
3734
  const { contractParams, feeParams, predicateParams, scriptParams, txParams, gasCosts } = consensusParameters;
3640
3735
  return {
3641
3736
  name,
3642
- baseChainHeight: (0, import_math14.bn)(daHeight),
3737
+ baseChainHeight: (0, import_math15.bn)(daHeight),
3643
3738
  consensusParameters: {
3644
- contractMaxSize: (0, import_math14.bn)(contractParams.contractMaxSize),
3645
- maxInputs: (0, import_math14.bn)(txParams.maxInputs),
3646
- maxOutputs: (0, import_math14.bn)(txParams.maxOutputs),
3647
- maxWitnesses: (0, import_math14.bn)(txParams.maxWitnesses),
3648
- maxGasPerTx: (0, import_math14.bn)(txParams.maxGasPerTx),
3649
- maxScriptLength: (0, import_math14.bn)(scriptParams.maxScriptLength),
3650
- maxScriptDataLength: (0, import_math14.bn)(scriptParams.maxScriptDataLength),
3651
- maxStorageSlots: (0, import_math14.bn)(contractParams.maxStorageSlots),
3652
- maxPredicateLength: (0, import_math14.bn)(predicateParams.maxPredicateLength),
3653
- maxPredicateDataLength: (0, import_math14.bn)(predicateParams.maxPredicateDataLength),
3654
- maxGasPerPredicate: (0, import_math14.bn)(predicateParams.maxGasPerPredicate),
3655
- gasPriceFactor: (0, import_math14.bn)(feeParams.gasPriceFactor),
3656
- gasPerByte: (0, import_math14.bn)(feeParams.gasPerByte),
3657
- maxMessageDataLength: (0, import_math14.bn)(predicateParams.maxMessageDataLength),
3658
- chainId: (0, import_math14.bn)(consensusParameters.chainId),
3739
+ contractMaxSize: (0, import_math15.bn)(contractParams.contractMaxSize),
3740
+ maxInputs: (0, import_math15.bn)(txParams.maxInputs),
3741
+ maxOutputs: (0, import_math15.bn)(txParams.maxOutputs),
3742
+ maxWitnesses: (0, import_math15.bn)(txParams.maxWitnesses),
3743
+ maxGasPerTx: (0, import_math15.bn)(txParams.maxGasPerTx),
3744
+ maxScriptLength: (0, import_math15.bn)(scriptParams.maxScriptLength),
3745
+ maxScriptDataLength: (0, import_math15.bn)(scriptParams.maxScriptDataLength),
3746
+ maxStorageSlots: (0, import_math15.bn)(contractParams.maxStorageSlots),
3747
+ maxPredicateLength: (0, import_math15.bn)(predicateParams.maxPredicateLength),
3748
+ maxPredicateDataLength: (0, import_math15.bn)(predicateParams.maxPredicateDataLength),
3749
+ maxGasPerPredicate: (0, import_math15.bn)(predicateParams.maxGasPerPredicate),
3750
+ gasPriceFactor: (0, import_math15.bn)(feeParams.gasPriceFactor),
3751
+ gasPerByte: (0, import_math15.bn)(feeParams.gasPerByte),
3752
+ maxMessageDataLength: (0, import_math15.bn)(predicateParams.maxMessageDataLength),
3753
+ chainId: (0, import_math15.bn)(consensusParameters.chainId),
3659
3754
  gasCosts
3660
3755
  },
3661
3756
  gasCosts,
3662
3757
  latestBlock: {
3663
3758
  id: latestBlock.id,
3664
- height: (0, import_math14.bn)(latestBlock.header.height),
3759
+ height: (0, import_math15.bn)(latestBlock.header.height),
3665
3760
  time: latestBlock.header.time,
3666
3761
  transactions: latestBlock.transactions.map((i) => ({
3667
3762
  id: i.id
@@ -3731,8 +3826,8 @@ var _Provider = class {
3731
3826
  getChain() {
3732
3827
  const chain = _Provider.chainInfoCache[this.url];
3733
3828
  if (!chain) {
3734
- throw new import_errors13.FuelError(
3735
- import_errors13.ErrorCode.CHAIN_INFO_CACHE_EMPTY,
3829
+ throw new import_errors14.FuelError(
3830
+ import_errors14.ErrorCode.CHAIN_INFO_CACHE_EMPTY,
3736
3831
  "Chain info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
3737
3832
  );
3738
3833
  }
@@ -3744,8 +3839,8 @@ var _Provider = class {
3744
3839
  getNode() {
3745
3840
  const node = _Provider.nodeInfoCache[this.url];
3746
3841
  if (!node) {
3747
- throw new import_errors13.FuelError(
3748
- import_errors13.ErrorCode.NODE_INFO_CACHE_EMPTY,
3842
+ throw new import_errors14.FuelError(
3843
+ import_errors14.ErrorCode.NODE_INFO_CACHE_EMPTY,
3749
3844
  "Node info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
3750
3845
  );
3751
3846
  }
@@ -3792,8 +3887,8 @@ var _Provider = class {
3792
3887
  static ensureClientVersionIsSupported(nodeInfo) {
3793
3888
  const { isMajorSupported, isMinorSupported, supportedVersion } = (0, import_versions.checkFuelCoreVersionCompatibility)(nodeInfo.nodeVersion);
3794
3889
  if (!isMajorSupported || !isMinorSupported) {
3795
- throw new import_errors13.FuelError(
3796
- import_errors13.FuelError.CODES.UNSUPPORTED_FUEL_CLIENT_VERSION,
3890
+ throw new import_errors14.FuelError(
3891
+ import_errors14.FuelError.CODES.UNSUPPORTED_FUEL_CLIENT_VERSION,
3797
3892
  `Fuel client version: ${nodeInfo.nodeVersion}, Supported version: ${supportedVersion}`
3798
3893
  );
3799
3894
  }
@@ -3856,7 +3951,7 @@ var _Provider = class {
3856
3951
  */
3857
3952
  async getBlockNumber() {
3858
3953
  const { chain } = await this.operations.getChain();
3859
- return (0, import_math14.bn)(chain.latestBlock.header.height, 10);
3954
+ return (0, import_math15.bn)(chain.latestBlock.header.height, 10);
3860
3955
  }
3861
3956
  /**
3862
3957
  * Returns the chain information.
@@ -3866,9 +3961,9 @@ var _Provider = class {
3866
3961
  async fetchNode() {
3867
3962
  const { nodeInfo } = await this.operations.getNodeInfo();
3868
3963
  const processedNodeInfo = {
3869
- maxDepth: (0, import_math14.bn)(nodeInfo.maxDepth),
3870
- maxTx: (0, import_math14.bn)(nodeInfo.maxTx),
3871
- minGasPrice: (0, import_math14.bn)(nodeInfo.minGasPrice),
3964
+ maxDepth: (0, import_math15.bn)(nodeInfo.maxDepth),
3965
+ maxTx: (0, import_math15.bn)(nodeInfo.maxTx),
3966
+ minGasPrice: (0, import_math15.bn)(nodeInfo.minGasPrice),
3872
3967
  nodeVersion: nodeInfo.nodeVersion,
3873
3968
  utxoValidation: nodeInfo.utxoValidation,
3874
3969
  vmBacktrace: nodeInfo.vmBacktrace,
@@ -3914,13 +4009,17 @@ var _Provider = class {
3914
4009
  if (estimateTxDependencies) {
3915
4010
  await this.estimateTxDependencies(transactionRequest);
3916
4011
  }
3917
- const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
4012
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
4013
+ let abis;
4014
+ if (transactionRequest.type === import_transactions18.TransactionType.Script) {
4015
+ abis = transactionRequest.abis;
4016
+ }
3918
4017
  if (awaitExecution) {
3919
4018
  const subscription = this.operations.submitAndAwait({ encodedTransaction });
3920
4019
  for await (const { submitAndAwait } of subscription) {
3921
4020
  if (submitAndAwait.type === "SqueezedOutStatus") {
3922
- throw new import_errors13.FuelError(
3923
- import_errors13.ErrorCode.TRANSACTION_SQUEEZED_OUT,
4021
+ throw new import_errors14.FuelError(
4022
+ import_errors14.ErrorCode.TRANSACTION_SQUEEZED_OUT,
3924
4023
  `Transaction Squeezed Out with reason: ${submitAndAwait.reason}`
3925
4024
  );
3926
4025
  }
@@ -3929,14 +4028,14 @@ var _Provider = class {
3929
4028
  }
3930
4029
  }
3931
4030
  const transactionId2 = transactionRequest.getTransactionId(this.getChainId());
3932
- const response = new TransactionResponse(transactionId2, this);
4031
+ const response = new TransactionResponse(transactionId2, this, abis);
3933
4032
  await response.fetch();
3934
4033
  return response;
3935
4034
  }
3936
4035
  const {
3937
4036
  submit: { id: transactionId }
3938
4037
  } = await this.operations.submit({ encodedTransaction });
3939
- return new TransactionResponse(transactionId, this);
4038
+ return new TransactionResponse(transactionId, this, abis);
3940
4039
  }
3941
4040
  /**
3942
4041
  * Executes a transaction without actually submitting it to the chain.
@@ -3953,7 +4052,7 @@ var _Provider = class {
3953
4052
  if (estimateTxDependencies) {
3954
4053
  return this.estimateTxDependencies(transactionRequest);
3955
4054
  }
3956
- const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
4055
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
3957
4056
  const { dryRun: gqlReceipts } = await this.operations.dryRun({
3958
4057
  encodedTransaction,
3959
4058
  utxoValidation: utxoValidation || false
@@ -3972,13 +4071,13 @@ var _Provider = class {
3972
4071
  async estimatePredicates(transactionRequest) {
3973
4072
  const shouldEstimatePredicates = Boolean(
3974
4073
  transactionRequest.inputs.find(
3975
- (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()
4074
+ (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()
3976
4075
  )
3977
4076
  );
3978
4077
  if (!shouldEstimatePredicates) {
3979
4078
  return transactionRequest;
3980
4079
  }
3981
- const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
4080
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
3982
4081
  const response = await this.operations.estimatePredicates({
3983
4082
  encodedTransaction
3984
4083
  });
@@ -3987,7 +4086,7 @@ var _Provider = class {
3987
4086
  } = response;
3988
4087
  if (inputs) {
3989
4088
  inputs.forEach((input, index) => {
3990
- if ("predicateGasUsed" in input && (0, import_math14.bn)(input.predicateGasUsed).gt(0)) {
4089
+ if ("predicateGasUsed" in input && (0, import_math15.bn)(input.predicateGasUsed).gt(0)) {
3991
4090
  transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
3992
4091
  }
3993
4092
  });
@@ -4008,7 +4107,7 @@ var _Provider = class {
4008
4107
  * @returns A promise.
4009
4108
  */
4010
4109
  async estimateTxDependencies(transactionRequest) {
4011
- if (transactionRequest.type === import_transactions17.TransactionType.Create) {
4110
+ if (transactionRequest.type === import_transactions18.TransactionType.Create) {
4012
4111
  return {
4013
4112
  receipts: [],
4014
4113
  outputVariables: 0,
@@ -4021,7 +4120,7 @@ var _Provider = class {
4021
4120
  let outputVariables = 0;
4022
4121
  for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
4023
4122
  const { dryRun: gqlReceipts } = await this.operations.dryRun({
4024
- encodedTransaction: (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes()),
4123
+ encodedTransaction: (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes()),
4025
4124
  utxoValidation: false
4026
4125
  });
4027
4126
  receipts = gqlReceipts.map(processGqlReceipt);
@@ -4059,7 +4158,7 @@ var _Provider = class {
4059
4158
  if (estimateTxDependencies) {
4060
4159
  return this.estimateTxDependencies(transactionRequest);
4061
4160
  }
4062
- const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
4161
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
4063
4162
  const { dryRun: gqlReceipts } = await this.operations.dryRun({
4064
4163
  encodedTransaction,
4065
4164
  utxoValidation: true
@@ -4093,14 +4192,14 @@ var _Provider = class {
4093
4192
  const txRequestClone = (0, import_ramda3.clone)(transactionRequestify(transactionRequestLike));
4094
4193
  const chainInfo = this.getChain();
4095
4194
  const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
4096
- const gasPrice = (0, import_math14.max)(txRequestClone.gasPrice, minGasPrice);
4097
- const isScriptTransaction = txRequestClone.type === import_transactions17.TransactionType.Script;
4195
+ const gasPrice = (0, import_math15.max)(txRequestClone.gasPrice, minGasPrice);
4196
+ const isScriptTransaction = txRequestClone.type === import_transactions18.TransactionType.Script;
4098
4197
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
4099
4198
  const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
4100
4199
  txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
4101
4200
  if (estimatePredicates) {
4102
4201
  if (isScriptTransaction) {
4103
- txRequestClone.gasLimit = (0, import_math14.bn)(0);
4202
+ txRequestClone.gasLimit = (0, import_math15.bn)(0);
4104
4203
  }
4105
4204
  if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
4106
4205
  resourcesOwner.populateTransactionPredicateData(txRequestClone);
@@ -4116,8 +4215,8 @@ var _Provider = class {
4116
4215
  let missingContractIds = [];
4117
4216
  let outputVariables = 0;
4118
4217
  if (isScriptTransaction && estimateTxDependencies) {
4119
- txRequestClone.gasPrice = (0, import_math14.bn)(0);
4120
- txRequestClone.gasLimit = (0, import_math14.bn)(maxGasPerTx.sub(maxGas).toNumber() * 0.9);
4218
+ txRequestClone.gasPrice = (0, import_math15.bn)(0);
4219
+ txRequestClone.gasLimit = (0, import_math15.bn)(maxGasPerTx.sub(maxGas).toNumber() * 0.9);
4121
4220
  const result = await this.estimateTxDependencies(txRequestClone);
4122
4221
  receipts = result.receipts;
4123
4222
  outputVariables = result.outputVariables;
@@ -4173,17 +4272,17 @@ var _Provider = class {
4173
4272
  const result = await this.operations.getCoins({
4174
4273
  first: 10,
4175
4274
  ...paginationArgs,
4176
- filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils22.hexlify)(assetId) }
4275
+ filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils23.hexlify)(assetId) }
4177
4276
  });
4178
4277
  const coins = result.coins.edges.map((edge) => edge.node);
4179
4278
  return coins.map((coin) => ({
4180
4279
  id: coin.utxoId,
4181
4280
  assetId: coin.assetId,
4182
- amount: (0, import_math14.bn)(coin.amount),
4281
+ amount: (0, import_math15.bn)(coin.amount),
4183
4282
  owner: import_address3.Address.fromAddressOrString(coin.owner),
4184
- maturity: (0, import_math14.bn)(coin.maturity).toNumber(),
4185
- blockCreated: (0, import_math14.bn)(coin.blockCreated),
4186
- txCreatedIdx: (0, import_math14.bn)(coin.txCreatedIdx)
4283
+ maturity: (0, import_math15.bn)(coin.maturity).toNumber(),
4284
+ blockCreated: (0, import_math15.bn)(coin.blockCreated),
4285
+ txCreatedIdx: (0, import_math15.bn)(coin.txCreatedIdx)
4187
4286
  }));
4188
4287
  }
4189
4288
  /**
@@ -4197,19 +4296,19 @@ var _Provider = class {
4197
4296
  async getResourcesToSpend(owner, quantities, excludedIds) {
4198
4297
  const ownerAddress = import_address3.Address.fromAddressOrString(owner);
4199
4298
  const excludeInput = {
4200
- messages: excludedIds?.messages?.map((nonce) => (0, import_utils22.hexlify)(nonce)) || [],
4201
- utxos: excludedIds?.utxos?.map((id) => (0, import_utils22.hexlify)(id)) || []
4299
+ messages: excludedIds?.messages?.map((nonce) => (0, import_utils23.hexlify)(nonce)) || [],
4300
+ utxos: excludedIds?.utxos?.map((id) => (0, import_utils23.hexlify)(id)) || []
4202
4301
  };
4203
4302
  if (this.cache) {
4204
4303
  const uniqueUtxos = new Set(
4205
- excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0, import_utils22.hexlify)(id)))
4304
+ excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0, import_utils23.hexlify)(id)))
4206
4305
  );
4207
4306
  excludeInput.utxos = Array.from(uniqueUtxos);
4208
4307
  }
4209
4308
  const coinsQuery = {
4210
4309
  owner: ownerAddress.toB256(),
4211
4310
  queryPerAsset: quantities.map(coinQuantityfy).map(({ assetId, amount, max: maxPerAsset }) => ({
4212
- assetId: (0, import_utils22.hexlify)(assetId),
4311
+ assetId: (0, import_utils23.hexlify)(assetId),
4213
4312
  amount: amount.toString(10),
4214
4313
  max: maxPerAsset ? maxPerAsset.toString(10) : void 0
4215
4314
  })),
@@ -4220,9 +4319,9 @@ var _Provider = class {
4220
4319
  switch (coin.__typename) {
4221
4320
  case "MessageCoin":
4222
4321
  return {
4223
- amount: (0, import_math14.bn)(coin.amount),
4322
+ amount: (0, import_math15.bn)(coin.amount),
4224
4323
  assetId: coin.assetId,
4225
- daHeight: (0, import_math14.bn)(coin.daHeight),
4324
+ daHeight: (0, import_math15.bn)(coin.daHeight),
4226
4325
  sender: import_address3.Address.fromAddressOrString(coin.sender),
4227
4326
  recipient: import_address3.Address.fromAddressOrString(coin.recipient),
4228
4327
  nonce: coin.nonce
@@ -4230,12 +4329,12 @@ var _Provider = class {
4230
4329
  case "Coin":
4231
4330
  return {
4232
4331
  id: coin.utxoId,
4233
- amount: (0, import_math14.bn)(coin.amount),
4332
+ amount: (0, import_math15.bn)(coin.amount),
4234
4333
  assetId: coin.assetId,
4235
4334
  owner: import_address3.Address.fromAddressOrString(coin.owner),
4236
- maturity: (0, import_math14.bn)(coin.maturity).toNumber(),
4237
- blockCreated: (0, import_math14.bn)(coin.blockCreated),
4238
- txCreatedIdx: (0, import_math14.bn)(coin.txCreatedIdx)
4335
+ maturity: (0, import_math15.bn)(coin.maturity).toNumber(),
4336
+ blockCreated: (0, import_math15.bn)(coin.blockCreated),
4337
+ txCreatedIdx: (0, import_math15.bn)(coin.txCreatedIdx)
4239
4338
  };
4240
4339
  default:
4241
4340
  return null;
@@ -4252,13 +4351,13 @@ var _Provider = class {
4252
4351
  async getBlock(idOrHeight) {
4253
4352
  let variables;
4254
4353
  if (typeof idOrHeight === "number") {
4255
- variables = { height: (0, import_math14.bn)(idOrHeight).toString(10) };
4354
+ variables = { height: (0, import_math15.bn)(idOrHeight).toString(10) };
4256
4355
  } else if (idOrHeight === "latest") {
4257
4356
  variables = { height: (await this.getBlockNumber()).toString(10) };
4258
4357
  } else if (idOrHeight.length === 66) {
4259
4358
  variables = { blockId: idOrHeight };
4260
4359
  } else {
4261
- variables = { blockId: (0, import_math14.bn)(idOrHeight).toString(10) };
4360
+ variables = { blockId: (0, import_math15.bn)(idOrHeight).toString(10) };
4262
4361
  }
4263
4362
  const { block } = await this.operations.getBlock(variables);
4264
4363
  if (!block) {
@@ -4266,7 +4365,7 @@ var _Provider = class {
4266
4365
  }
4267
4366
  return {
4268
4367
  id: block.id,
4269
- height: (0, import_math14.bn)(block.header.height),
4368
+ height: (0, import_math15.bn)(block.header.height),
4270
4369
  time: block.header.time,
4271
4370
  transactionIds: block.transactions.map((tx) => tx.id)
4272
4371
  };
@@ -4281,7 +4380,7 @@ var _Provider = class {
4281
4380
  const { blocks: fetchedData } = await this.operations.getBlocks(params);
4282
4381
  const blocks = fetchedData.edges.map(({ node: block }) => ({
4283
4382
  id: block.id,
4284
- height: (0, import_math14.bn)(block.header.height),
4383
+ height: (0, import_math15.bn)(block.header.height),
4285
4384
  time: block.header.time,
4286
4385
  transactionIds: block.transactions.map((tx) => tx.id)
4287
4386
  }));
@@ -4296,7 +4395,7 @@ var _Provider = class {
4296
4395
  async getBlockWithTransactions(idOrHeight) {
4297
4396
  let variables;
4298
4397
  if (typeof idOrHeight === "number") {
4299
- variables = { blockHeight: (0, import_math14.bn)(idOrHeight).toString(10) };
4398
+ variables = { blockHeight: (0, import_math15.bn)(idOrHeight).toString(10) };
4300
4399
  } else if (idOrHeight === "latest") {
4301
4400
  variables = { blockHeight: (await this.getBlockNumber()).toString() };
4302
4401
  } else {
@@ -4308,11 +4407,11 @@ var _Provider = class {
4308
4407
  }
4309
4408
  return {
4310
4409
  id: block.id,
4311
- height: (0, import_math14.bn)(block.header.height, 10),
4410
+ height: (0, import_math15.bn)(block.header.height, 10),
4312
4411
  time: block.header.time,
4313
4412
  transactionIds: block.transactions.map((tx) => tx.id),
4314
4413
  transactions: block.transactions.map(
4315
- (tx) => new import_transactions17.TransactionCoder().decode((0, import_utils22.arrayify)(tx.rawPayload), 0)?.[0]
4414
+ (tx) => new import_transactions18.TransactionCoder().decode((0, import_utils23.arrayify)(tx.rawPayload), 0)?.[0]
4316
4415
  )
4317
4416
  };
4318
4417
  }
@@ -4327,8 +4426,8 @@ var _Provider = class {
4327
4426
  if (!transaction) {
4328
4427
  return null;
4329
4428
  }
4330
- return new import_transactions17.TransactionCoder().decode(
4331
- (0, import_utils22.arrayify)(transaction.rawPayload),
4429
+ return new import_transactions18.TransactionCoder().decode(
4430
+ (0, import_utils23.arrayify)(transaction.rawPayload),
4332
4431
  0
4333
4432
  )?.[0];
4334
4433
  }
@@ -4355,9 +4454,9 @@ var _Provider = class {
4355
4454
  async getContractBalance(contractId, assetId) {
4356
4455
  const { contractBalance } = await this.operations.getContractBalance({
4357
4456
  contract: import_address3.Address.fromAddressOrString(contractId).toB256(),
4358
- asset: (0, import_utils22.hexlify)(assetId)
4457
+ asset: (0, import_utils23.hexlify)(assetId)
4359
4458
  });
4360
- return (0, import_math14.bn)(contractBalance.amount, 10);
4459
+ return (0, import_math15.bn)(contractBalance.amount, 10);
4361
4460
  }
4362
4461
  /**
4363
4462
  * Returns the balance for the given owner for the given asset ID.
@@ -4369,9 +4468,9 @@ var _Provider = class {
4369
4468
  async getBalance(owner, assetId) {
4370
4469
  const { balance } = await this.operations.getBalance({
4371
4470
  owner: import_address3.Address.fromAddressOrString(owner).toB256(),
4372
- assetId: (0, import_utils22.hexlify)(assetId)
4471
+ assetId: (0, import_utils23.hexlify)(assetId)
4373
4472
  });
4374
- return (0, import_math14.bn)(balance.amount, 10);
4473
+ return (0, import_math15.bn)(balance.amount, 10);
4375
4474
  }
4376
4475
  /**
4377
4476
  * Returns balances for the given owner.
@@ -4389,7 +4488,7 @@ var _Provider = class {
4389
4488
  const balances = result.balances.edges.map((edge) => edge.node);
4390
4489
  return balances.map((balance) => ({
4391
4490
  assetId: balance.assetId,
4392
- amount: (0, import_math14.bn)(balance.amount)
4491
+ amount: (0, import_math15.bn)(balance.amount)
4393
4492
  }));
4394
4493
  }
4395
4494
  /**
@@ -4407,19 +4506,19 @@ var _Provider = class {
4407
4506
  });
4408
4507
  const messages = result.messages.edges.map((edge) => edge.node);
4409
4508
  return messages.map((message) => ({
4410
- messageId: import_transactions17.InputMessageCoder.getMessageId({
4509
+ messageId: import_transactions18.InputMessageCoder.getMessageId({
4411
4510
  sender: message.sender,
4412
4511
  recipient: message.recipient,
4413
4512
  nonce: message.nonce,
4414
- amount: (0, import_math14.bn)(message.amount),
4513
+ amount: (0, import_math15.bn)(message.amount),
4415
4514
  data: message.data
4416
4515
  }),
4417
4516
  sender: import_address3.Address.fromAddressOrString(message.sender),
4418
4517
  recipient: import_address3.Address.fromAddressOrString(message.recipient),
4419
4518
  nonce: message.nonce,
4420
- amount: (0, import_math14.bn)(message.amount),
4421
- data: import_transactions17.InputMessageCoder.decodeData(message.data),
4422
- daHeight: (0, import_math14.bn)(message.daHeight)
4519
+ amount: (0, import_math15.bn)(message.amount),
4520
+ data: import_transactions18.InputMessageCoder.decodeData(message.data),
4521
+ daHeight: (0, import_math15.bn)(message.daHeight)
4423
4522
  }));
4424
4523
  }
4425
4524
  /**
@@ -4437,8 +4536,8 @@ var _Provider = class {
4437
4536
  nonce
4438
4537
  };
4439
4538
  if (commitBlockId && commitBlockHeight) {
4440
- throw new import_errors13.FuelError(
4441
- import_errors13.ErrorCode.INVALID_INPUT_PARAMETERS,
4539
+ throw new import_errors14.FuelError(
4540
+ import_errors14.ErrorCode.INVALID_INPUT_PARAMETERS,
4442
4541
  "commitBlockId and commitBlockHeight cannot be used together"
4443
4542
  );
4444
4543
  }
@@ -4472,41 +4571,41 @@ var _Provider = class {
4472
4571
  } = result.messageProof;
4473
4572
  return {
4474
4573
  messageProof: {
4475
- proofIndex: (0, import_math14.bn)(messageProof.proofIndex),
4574
+ proofIndex: (0, import_math15.bn)(messageProof.proofIndex),
4476
4575
  proofSet: messageProof.proofSet
4477
4576
  },
4478
4577
  blockProof: {
4479
- proofIndex: (0, import_math14.bn)(blockProof.proofIndex),
4578
+ proofIndex: (0, import_math15.bn)(blockProof.proofIndex),
4480
4579
  proofSet: blockProof.proofSet
4481
4580
  },
4482
4581
  messageBlockHeader: {
4483
4582
  id: messageBlockHeader.id,
4484
- daHeight: (0, import_math14.bn)(messageBlockHeader.daHeight),
4485
- transactionsCount: (0, import_math14.bn)(messageBlockHeader.transactionsCount),
4583
+ daHeight: (0, import_math15.bn)(messageBlockHeader.daHeight),
4584
+ transactionsCount: (0, import_math15.bn)(messageBlockHeader.transactionsCount),
4486
4585
  transactionsRoot: messageBlockHeader.transactionsRoot,
4487
- height: (0, import_math14.bn)(messageBlockHeader.height),
4586
+ height: (0, import_math15.bn)(messageBlockHeader.height),
4488
4587
  prevRoot: messageBlockHeader.prevRoot,
4489
4588
  time: messageBlockHeader.time,
4490
4589
  applicationHash: messageBlockHeader.applicationHash,
4491
4590
  messageReceiptRoot: messageBlockHeader.messageReceiptRoot,
4492
- messageReceiptCount: (0, import_math14.bn)(messageBlockHeader.messageReceiptCount)
4591
+ messageReceiptCount: (0, import_math15.bn)(messageBlockHeader.messageReceiptCount)
4493
4592
  },
4494
4593
  commitBlockHeader: {
4495
4594
  id: commitBlockHeader.id,
4496
- daHeight: (0, import_math14.bn)(commitBlockHeader.daHeight),
4497
- transactionsCount: (0, import_math14.bn)(commitBlockHeader.transactionsCount),
4595
+ daHeight: (0, import_math15.bn)(commitBlockHeader.daHeight),
4596
+ transactionsCount: (0, import_math15.bn)(commitBlockHeader.transactionsCount),
4498
4597
  transactionsRoot: commitBlockHeader.transactionsRoot,
4499
- height: (0, import_math14.bn)(commitBlockHeader.height),
4598
+ height: (0, import_math15.bn)(commitBlockHeader.height),
4500
4599
  prevRoot: commitBlockHeader.prevRoot,
4501
4600
  time: commitBlockHeader.time,
4502
4601
  applicationHash: commitBlockHeader.applicationHash,
4503
4602
  messageReceiptRoot: commitBlockHeader.messageReceiptRoot,
4504
- messageReceiptCount: (0, import_math14.bn)(commitBlockHeader.messageReceiptCount)
4603
+ messageReceiptCount: (0, import_math15.bn)(commitBlockHeader.messageReceiptCount)
4505
4604
  },
4506
4605
  sender: import_address3.Address.fromAddressOrString(sender),
4507
4606
  recipient: import_address3.Address.fromAddressOrString(recipient),
4508
4607
  nonce,
4509
- amount: (0, import_math14.bn)(amount),
4608
+ amount: (0, import_math15.bn)(amount),
4510
4609
  data
4511
4610
  };
4512
4611
  }
@@ -4529,10 +4628,10 @@ var _Provider = class {
4529
4628
  */
4530
4629
  async produceBlocks(amount, startTime) {
4531
4630
  const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
4532
- blocksToProduce: (0, import_math14.bn)(amount).toString(10),
4533
- startTimestamp: startTime ? import_utils22.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
4631
+ blocksToProduce: (0, import_math15.bn)(amount).toString(10),
4632
+ startTimestamp: startTime ? import_utils23.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
4534
4633
  });
4535
- return (0, import_math14.bn)(latestBlockHeight);
4634
+ return (0, import_math15.bn)(latestBlockHeight);
4536
4635
  }
4537
4636
  // eslint-disable-next-line @typescript-eslint/require-await
4538
4637
  async getTransactionResponse(transactionId) {
@@ -4546,7 +4645,7 @@ cacheInputs_fn = function(inputs) {
4546
4645
  return;
4547
4646
  }
4548
4647
  inputs.forEach((input) => {
4549
- if (input.type === import_transactions17.InputType.Coin) {
4648
+ if (input.type === import_transactions18.InputType.Coin) {
4550
4649
  this.cache?.set(input.id);
4551
4650
  }
4552
4651
  });
@@ -4555,23 +4654,23 @@ __publicField(Provider, "chainInfoCache", {});
4555
4654
  __publicField(Provider, "nodeInfoCache", {});
4556
4655
 
4557
4656
  // src/providers/transaction-summary/get-transaction-summary.ts
4558
- var import_errors14 = require("@fuel-ts/errors");
4559
- var import_math15 = require("@fuel-ts/math");
4560
- var import_transactions18 = require("@fuel-ts/transactions");
4561
- var import_utils25 = require("@fuel-ts/utils");
4657
+ var import_errors15 = require("@fuel-ts/errors");
4658
+ var import_math16 = require("@fuel-ts/math");
4659
+ var import_transactions19 = require("@fuel-ts/transactions");
4660
+ var import_utils26 = require("@fuel-ts/utils");
4562
4661
  async function getTransactionSummary(params) {
4563
4662
  const { id, provider, abiMap } = params;
4564
4663
  const { transaction: gqlTransaction } = await provider.operations.getTransactionWithReceipts({
4565
4664
  transactionId: id
4566
4665
  });
4567
4666
  if (!gqlTransaction) {
4568
- throw new import_errors14.FuelError(
4569
- import_errors14.ErrorCode.TRANSACTION_NOT_FOUND,
4667
+ throw new import_errors15.FuelError(
4668
+ import_errors15.ErrorCode.TRANSACTION_NOT_FOUND,
4570
4669
  `Transaction not found for given id: ${id}.`
4571
4670
  );
4572
4671
  }
4573
- const [decodedTransaction] = new import_transactions18.TransactionCoder().decode(
4574
- (0, import_utils25.arrayify)(gqlTransaction.rawPayload),
4672
+ const [decodedTransaction] = new import_transactions19.TransactionCoder().decode(
4673
+ (0, import_utils26.arrayify)(gqlTransaction.rawPayload),
4575
4674
  0
4576
4675
  );
4577
4676
  const receipts = gqlTransaction.receipts?.map(processGqlReceipt) || [];
@@ -4582,10 +4681,10 @@ async function getTransactionSummary(params) {
4582
4681
  id: gqlTransaction.id,
4583
4682
  receipts,
4584
4683
  transaction: decodedTransaction,
4585
- transactionBytes: (0, import_utils25.arrayify)(gqlTransaction.rawPayload),
4684
+ transactionBytes: (0, import_utils26.arrayify)(gqlTransaction.rawPayload),
4586
4685
  gqlTransactionStatus: gqlTransaction.status,
4587
- gasPerByte: (0, import_math15.bn)(gasPerByte),
4588
- gasPriceFactor: (0, import_math15.bn)(gasPriceFactor),
4686
+ gasPerByte: (0, import_math16.bn)(gasPerByte),
4687
+ gasPriceFactor: (0, import_math16.bn)(gasPriceFactor),
4589
4688
  abiMap,
4590
4689
  maxInputs,
4591
4690
  gasCosts
@@ -4624,13 +4723,13 @@ async function getTransactionsSummaries(params) {
4624
4723
  const transactions = edges.map((edge) => {
4625
4724
  const { node: gqlTransaction } = edge;
4626
4725
  const { id, rawPayload, receipts: gqlReceipts, status } = gqlTransaction;
4627
- const [decodedTransaction] = new import_transactions18.TransactionCoder().decode((0, import_utils25.arrayify)(rawPayload), 0);
4726
+ const [decodedTransaction] = new import_transactions19.TransactionCoder().decode((0, import_utils26.arrayify)(rawPayload), 0);
4628
4727
  const receipts = gqlReceipts?.map(processGqlReceipt) || [];
4629
4728
  const transactionSummary = assembleTransactionSummary({
4630
4729
  id,
4631
4730
  receipts,
4632
4731
  transaction: decodedTransaction,
4633
- transactionBytes: (0, import_utils25.arrayify)(rawPayload),
4732
+ transactionBytes: (0, import_utils26.arrayify)(rawPayload),
4634
4733
  gqlTransactionStatus: status,
4635
4734
  abiMap,
4636
4735
  gasPerByte,
@@ -4773,17 +4872,17 @@ var assets = [
4773
4872
 
4774
4873
  // src/utils/formatTransferToContractScriptData.ts
4775
4874
  var import_abi_coder4 = require("@fuel-ts/abi-coder");
4776
- var import_math16 = require("@fuel-ts/math");
4777
- var import_utils26 = require("@fuel-ts/utils");
4875
+ var import_math17 = require("@fuel-ts/math");
4876
+ var import_utils27 = require("@fuel-ts/utils");
4778
4877
  var asm = __toESM(require("@fuels/vm-asm"));
4779
4878
  var formatTransferToContractScriptData = (params) => {
4780
4879
  const { assetId, amountToTransfer, hexlifiedContractId } = params;
4781
4880
  const numberCoder = new import_abi_coder4.BigNumberCoder("u64");
4782
- const encoded = numberCoder.encode(new import_math16.BN(amountToTransfer).toNumber());
4881
+ const encoded = numberCoder.encode(new import_math17.BN(amountToTransfer).toNumber());
4783
4882
  const scriptData = Uint8Array.from([
4784
- ...(0, import_utils26.arrayify)(hexlifiedContractId),
4883
+ ...(0, import_utils27.arrayify)(hexlifiedContractId),
4785
4884
  ...encoded,
4786
- ...(0, import_utils26.arrayify)(assetId)
4885
+ ...(0, import_utils27.arrayify)(assetId)
4787
4886
  ]);
4788
4887
  return scriptData;
4789
4888
  };
@@ -4839,7 +4938,7 @@ var Account = class extends import_interfaces.AbstractAccount {
4839
4938
  */
4840
4939
  get provider() {
4841
4940
  if (!this._provider) {
4842
- throw new import_errors15.FuelError(import_errors15.ErrorCode.MISSING_PROVIDER, "Provider not set");
4941
+ throw new import_errors16.FuelError(import_errors16.ErrorCode.MISSING_PROVIDER, "Provider not set");
4843
4942
  }
4844
4943
  return this._provider;
4845
4944
  }
@@ -4891,8 +4990,8 @@ var Account = class extends import_interfaces.AbstractAccount {
4891
4990
  if (!hasNextPage) {
4892
4991
  break;
4893
4992
  }
4894
- throw new import_errors15.FuelError(
4895
- import_errors15.ErrorCode.NOT_SUPPORTED,
4993
+ throw new import_errors16.FuelError(
4994
+ import_errors16.ErrorCode.NOT_SUPPORTED,
4896
4995
  `Wallets containing more than ${pageSize} coins exceed the current supported limit.`
4897
4996
  );
4898
4997
  }
@@ -4917,8 +5016,8 @@ var Account = class extends import_interfaces.AbstractAccount {
4917
5016
  if (!hasNextPage) {
4918
5017
  break;
4919
5018
  }
4920
- throw new import_errors15.FuelError(
4921
- import_errors15.ErrorCode.NOT_SUPPORTED,
5019
+ throw new import_errors16.FuelError(
5020
+ import_errors16.ErrorCode.NOT_SUPPORTED,
4922
5021
  `Wallets containing more than ${pageSize} messages exceed the current supported limit.`
4923
5022
  );
4924
5023
  }
@@ -4930,7 +5029,7 @@ var Account = class extends import_interfaces.AbstractAccount {
4930
5029
  * @param assetId - The asset ID to check the balance for.
4931
5030
  * @returns A promise that resolves to the balance amount.
4932
5031
  */
4933
- async getBalance(assetId = import_configs11.BaseAssetId) {
5032
+ async getBalance(assetId = import_configs12.BaseAssetId) {
4934
5033
  const amount = await this.provider.getBalance(this.address, assetId);
4935
5034
  return amount;
4936
5035
  }
@@ -4953,8 +5052,8 @@ var Account = class extends import_interfaces.AbstractAccount {
4953
5052
  if (!hasNextPage) {
4954
5053
  break;
4955
5054
  }
4956
- throw new import_errors15.FuelError(
4957
- import_errors15.ErrorCode.NOT_SUPPORTED,
5055
+ throw new import_errors16.FuelError(
5056
+ import_errors16.ErrorCode.NOT_SUPPORTED,
4958
5057
  `Wallets containing more than ${pageSize} balances exceed the current supported limit.`
4959
5058
  );
4960
5059
  }
@@ -4970,15 +5069,15 @@ var Account = class extends import_interfaces.AbstractAccount {
4970
5069
  */
4971
5070
  async fund(request, coinQuantities, fee) {
4972
5071
  const updatedQuantities = addAmountToAsset({
4973
- amount: (0, import_math17.bn)(fee),
4974
- assetId: import_configs11.BaseAssetId,
5072
+ amount: (0, import_math18.bn)(fee),
5073
+ assetId: import_configs12.BaseAssetId,
4975
5074
  coinQuantities
4976
5075
  });
4977
5076
  const quantitiesDict = {};
4978
5077
  updatedQuantities.forEach(({ amount, assetId }) => {
4979
5078
  quantitiesDict[assetId] = {
4980
5079
  required: amount,
4981
- owned: (0, import_math17.bn)(0)
5080
+ owned: (0, import_math18.bn)(0)
4982
5081
  };
4983
5082
  });
4984
5083
  const cachedUtxos = [];
@@ -4991,12 +5090,12 @@ var Account = class extends import_interfaces.AbstractAccount {
4991
5090
  if (isCoin2) {
4992
5091
  const assetId = String(input.assetId);
4993
5092
  if (input.owner === owner && quantitiesDict[assetId]) {
4994
- const amount = (0, import_math17.bn)(input.amount);
5093
+ const amount = (0, import_math18.bn)(input.amount);
4995
5094
  quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
4996
5095
  cachedUtxos.push(input.id);
4997
5096
  }
4998
- } else if (input.recipient === owner && input.amount && quantitiesDict[import_configs11.BaseAssetId]) {
4999
- quantitiesDict[import_configs11.BaseAssetId].owned = quantitiesDict[import_configs11.BaseAssetId].owned.add(input.amount);
5097
+ } else if (input.recipient === owner && input.amount && quantitiesDict[import_configs12.BaseAssetId]) {
5098
+ quantitiesDict[import_configs12.BaseAssetId].owned = quantitiesDict[import_configs12.BaseAssetId].owned.add(input.amount);
5000
5099
  cachedMessages.push(input.nonce);
5001
5100
  }
5002
5101
  }
@@ -5028,7 +5127,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5028
5127
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
5029
5128
  * @returns A promise that resolves to the prepared transaction request.
5030
5129
  */
5031
- async createTransfer(destination, amount, assetId = import_configs11.BaseAssetId, txParams = {}) {
5130
+ async createTransfer(destination, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
5032
5131
  const { minGasPrice } = this.provider.getGasConfig();
5033
5132
  const params = { gasPrice: minGasPrice, ...txParams };
5034
5133
  const request = new ScriptTransactionRequest(params);
@@ -5037,8 +5136,8 @@ var Account = class extends import_interfaces.AbstractAccount {
5037
5136
  estimateTxDependencies: true,
5038
5137
  resourcesOwner: this
5039
5138
  });
5040
- request.gasPrice = (0, import_math17.bn)(txParams.gasPrice ?? minGasPrice);
5041
- request.gasLimit = (0, import_math17.bn)(txParams.gasLimit ?? gasUsed);
5139
+ request.gasPrice = (0, import_math18.bn)(txParams.gasPrice ?? minGasPrice);
5140
+ request.gasLimit = (0, import_math18.bn)(txParams.gasLimit ?? gasUsed);
5042
5141
  this.validateGas({
5043
5142
  gasUsed,
5044
5143
  gasPrice: request.gasPrice,
@@ -5058,10 +5157,10 @@ var Account = class extends import_interfaces.AbstractAccount {
5058
5157
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
5059
5158
  * @returns A promise that resolves to the transaction response.
5060
5159
  */
5061
- async transfer(destination, amount, assetId = import_configs11.BaseAssetId, txParams = {}) {
5062
- if ((0, import_math17.bn)(amount).lte(0)) {
5063
- throw new import_errors15.FuelError(
5064
- import_errors15.ErrorCode.INVALID_TRANSFER_AMOUNT,
5160
+ async transfer(destination, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
5161
+ if ((0, import_math18.bn)(amount).lte(0)) {
5162
+ throw new import_errors16.FuelError(
5163
+ import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
5065
5164
  "Transfer amount must be a positive number."
5066
5165
  );
5067
5166
  }
@@ -5077,10 +5176,10 @@ var Account = class extends import_interfaces.AbstractAccount {
5077
5176
  * @param txParams - The optional transaction parameters.
5078
5177
  * @returns A promise that resolves to the transaction response.
5079
5178
  */
5080
- async transferToContract(contractId, amount, assetId = import_configs11.BaseAssetId, txParams = {}) {
5081
- if ((0, import_math17.bn)(amount).lte(0)) {
5082
- throw new import_errors15.FuelError(
5083
- import_errors15.ErrorCode.INVALID_TRANSFER_AMOUNT,
5179
+ async transferToContract(contractId, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
5180
+ if ((0, import_math18.bn)(amount).lte(0)) {
5181
+ throw new import_errors16.FuelError(
5182
+ import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
5084
5183
  "Transfer amount must be a positive number."
5085
5184
  );
5086
5185
  }
@@ -5089,7 +5188,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5089
5188
  const params = { gasPrice: minGasPrice, ...txParams };
5090
5189
  const { script, scriptData } = await assembleTransferToContractScript({
5091
5190
  hexlifiedContractId: contractAddress.toB256(),
5092
- amountToTransfer: (0, import_math17.bn)(amount),
5191
+ amountToTransfer: (0, import_math18.bn)(amount),
5093
5192
  assetId
5094
5193
  });
5095
5194
  const request = new ScriptTransactionRequest({
@@ -5100,9 +5199,9 @@ var Account = class extends import_interfaces.AbstractAccount {
5100
5199
  request.addContractInputAndOutput(contractAddress);
5101
5200
  const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
5102
5201
  request,
5103
- [{ amount: (0, import_math17.bn)(amount), assetId: String(assetId) }]
5202
+ [{ amount: (0, import_math18.bn)(amount), assetId: String(assetId) }]
5104
5203
  );
5105
- request.gasLimit = (0, import_math17.bn)(params.gasLimit ?? gasUsed);
5204
+ request.gasLimit = (0, import_math18.bn)(params.gasLimit ?? gasUsed);
5106
5205
  this.validateGas({
5107
5206
  gasUsed,
5108
5207
  gasPrice: request.gasPrice,
@@ -5123,25 +5222,25 @@ var Account = class extends import_interfaces.AbstractAccount {
5123
5222
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
5124
5223
  const { minGasPrice } = this.provider.getGasConfig();
5125
5224
  const recipientAddress = import_address4.Address.fromAddressOrString(recipient);
5126
- const recipientDataArray = (0, import_utils27.arrayify)(
5225
+ const recipientDataArray = (0, import_utils28.arrayify)(
5127
5226
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
5128
5227
  );
5129
- const amountDataArray = (0, import_utils27.arrayify)(
5130
- "0x".concat((0, import_math17.bn)(amount).toHex().substring(2).padStart(16, "0"))
5228
+ const amountDataArray = (0, import_utils28.arrayify)(
5229
+ "0x".concat((0, import_math18.bn)(amount).toHex().substring(2).padStart(16, "0"))
5131
5230
  );
5132
5231
  const script = new Uint8Array([
5133
- ...(0, import_utils27.arrayify)(withdrawScript.bytes),
5232
+ ...(0, import_utils28.arrayify)(withdrawScript.bytes),
5134
5233
  ...recipientDataArray,
5135
5234
  ...amountDataArray
5136
5235
  ]);
5137
5236
  const params = { script, gasPrice: minGasPrice, ...txParams };
5138
5237
  const request = new ScriptTransactionRequest(params);
5139
- const forwardingQuantities = [{ amount: (0, import_math17.bn)(amount), assetId: import_configs11.BaseAssetId }];
5238
+ const forwardingQuantities = [{ amount: (0, import_math18.bn)(amount), assetId: import_configs12.BaseAssetId }];
5140
5239
  const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
5141
5240
  request,
5142
5241
  forwardingQuantities
5143
5242
  );
5144
- request.gasLimit = (0, import_math17.bn)(params.gasLimit ?? gasUsed);
5243
+ request.gasLimit = (0, import_math18.bn)(params.gasLimit ?? gasUsed);
5145
5244
  this.validateGas({
5146
5245
  gasUsed,
5147
5246
  gasPrice: request.gasPrice,
@@ -5153,7 +5252,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5153
5252
  }
5154
5253
  async signMessage(message) {
5155
5254
  if (!this._connector) {
5156
- throw new import_errors15.FuelError(import_errors15.ErrorCode.MISSING_CONNECTOR, "A connector is required to sign messages.");
5255
+ throw new import_errors16.FuelError(import_errors16.ErrorCode.MISSING_CONNECTOR, "A connector is required to sign messages.");
5157
5256
  }
5158
5257
  return this._connector.signMessage(this.address.toString(), message);
5159
5258
  }
@@ -5165,8 +5264,8 @@ var Account = class extends import_interfaces.AbstractAccount {
5165
5264
  */
5166
5265
  async signTransaction(transactionRequestLike) {
5167
5266
  if (!this._connector) {
5168
- throw new import_errors15.FuelError(
5169
- import_errors15.ErrorCode.MISSING_CONNECTOR,
5267
+ throw new import_errors16.FuelError(
5268
+ import_errors16.ErrorCode.MISSING_CONNECTOR,
5170
5269
  "A connector is required to sign transactions."
5171
5270
  );
5172
5271
  }
@@ -5213,14 +5312,14 @@ var Account = class extends import_interfaces.AbstractAccount {
5213
5312
  minGasPrice
5214
5313
  }) {
5215
5314
  if (minGasPrice.gt(gasPrice)) {
5216
- throw new import_errors15.FuelError(
5217
- import_errors15.ErrorCode.GAS_PRICE_TOO_LOW,
5315
+ throw new import_errors16.FuelError(
5316
+ import_errors16.ErrorCode.GAS_PRICE_TOO_LOW,
5218
5317
  `Gas price '${gasPrice}' is lower than the required: '${minGasPrice}'.`
5219
5318
  );
5220
5319
  }
5221
5320
  if (gasUsed.gt(gasLimit)) {
5222
- throw new import_errors15.FuelError(
5223
- import_errors15.ErrorCode.GAS_LIMIT_TOO_LOW,
5321
+ throw new import_errors16.FuelError(
5322
+ import_errors16.ErrorCode.GAS_LIMIT_TOO_LOW,
5224
5323
  `Gas limit '${gasLimit}' is lower than the required: '${gasUsed}'.`
5225
5324
  );
5226
5325
  }
@@ -5229,14 +5328,14 @@ var Account = class extends import_interfaces.AbstractAccount {
5229
5328
 
5230
5329
  // src/wallet/base-wallet-unlocked.ts
5231
5330
  var import_hasher3 = require("@fuel-ts/hasher");
5232
- var import_utils30 = require("@fuel-ts/utils");
5331
+ var import_utils31 = require("@fuel-ts/utils");
5233
5332
 
5234
5333
  // src/signer/signer.ts
5235
5334
  var import_address5 = require("@fuel-ts/address");
5236
5335
  var import_crypto = require("@fuel-ts/crypto");
5237
5336
  var import_hasher2 = require("@fuel-ts/hasher");
5238
- var import_math18 = require("@fuel-ts/math");
5239
- var import_utils28 = require("@fuel-ts/utils");
5337
+ var import_math19 = require("@fuel-ts/math");
5338
+ var import_utils29 = require("@fuel-ts/utils");
5240
5339
  var import_secp256k1 = require("@noble/curves/secp256k1");
5241
5340
  var Signer = class {
5242
5341
  address;
@@ -5255,10 +5354,10 @@ var Signer = class {
5255
5354
  privateKey = `0x${privateKey}`;
5256
5355
  }
5257
5356
  }
5258
- const privateKeyBytes = (0, import_math18.toBytes)(privateKey, 32);
5259
- this.privateKey = (0, import_utils28.hexlify)(privateKeyBytes);
5260
- this.publicKey = (0, import_utils28.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
5261
- this.compressedPublicKey = (0, import_utils28.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
5357
+ const privateKeyBytes = (0, import_math19.toBytes)(privateKey, 32);
5358
+ this.privateKey = (0, import_utils29.hexlify)(privateKeyBytes);
5359
+ this.publicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
5360
+ this.compressedPublicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
5262
5361
  this.address = import_address5.Address.fromPublicKey(this.publicKey);
5263
5362
  }
5264
5363
  /**
@@ -5272,11 +5371,11 @@ var Signer = class {
5272
5371
  * @returns hashed signature
5273
5372
  */
5274
5373
  sign(data) {
5275
- const signature = import_secp256k1.secp256k1.sign((0, import_utils28.arrayify)(data), (0, import_utils28.arrayify)(this.privateKey));
5276
- const r = (0, import_math18.toBytes)(`0x${signature.r.toString(16)}`, 32);
5277
- const s = (0, import_math18.toBytes)(`0x${signature.s.toString(16)}`, 32);
5374
+ const signature = import_secp256k1.secp256k1.sign((0, import_utils29.arrayify)(data), (0, import_utils29.arrayify)(this.privateKey));
5375
+ const r = (0, import_math19.toBytes)(`0x${signature.r.toString(16)}`, 32);
5376
+ const s = (0, import_math19.toBytes)(`0x${signature.s.toString(16)}`, 32);
5278
5377
  s[0] |= (signature.recovery || 0) << 7;
5279
- return (0, import_utils28.hexlify)((0, import_utils28.concat)([r, s]));
5378
+ return (0, import_utils29.hexlify)((0, import_utils29.concat)([r, s]));
5280
5379
  }
5281
5380
  /**
5282
5381
  * Add point on the current elliptic curve
@@ -5285,8 +5384,8 @@ var Signer = class {
5285
5384
  * @returns compressed point on the curve
5286
5385
  */
5287
5386
  addPoint(point) {
5288
- const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(this.compressedPublicKey));
5289
- const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(point));
5387
+ const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(this.compressedPublicKey));
5388
+ const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(point));
5290
5389
  const result = p0.add(p1);
5291
5390
  return `0x${result.toHex(true)}`;
5292
5391
  }
@@ -5298,16 +5397,16 @@ var Signer = class {
5298
5397
  * @returns public key from signature from the
5299
5398
  */
5300
5399
  static recoverPublicKey(data, signature) {
5301
- const signedMessageBytes = (0, import_utils28.arrayify)(signature);
5400
+ const signedMessageBytes = (0, import_utils29.arrayify)(signature);
5302
5401
  const r = signedMessageBytes.slice(0, 32);
5303
5402
  const s = signedMessageBytes.slice(32, 64);
5304
5403
  const recoveryParam = (s[0] & 128) >> 7;
5305
5404
  s[0] &= 127;
5306
- const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils28.hexlify)(r)), BigInt((0, import_utils28.hexlify)(s))).addRecoveryBit(
5405
+ const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils29.hexlify)(r)), BigInt((0, import_utils29.hexlify)(s))).addRecoveryBit(
5307
5406
  recoveryParam
5308
5407
  );
5309
- const publicKey = sig.recoverPublicKey((0, import_utils28.arrayify)(data)).toRawBytes(false).slice(1);
5310
- return (0, import_utils28.hexlify)(publicKey);
5408
+ const publicKey = sig.recoverPublicKey((0, import_utils29.arrayify)(data)).toRawBytes(false).slice(1);
5409
+ return (0, import_utils29.hexlify)(publicKey);
5311
5410
  }
5312
5411
  /**
5313
5412
  * Recover the address from a signature performed with [`sign`](#sign).
@@ -5326,7 +5425,7 @@ var Signer = class {
5326
5425
  * @returns random 32-byte hashed
5327
5426
  */
5328
5427
  static generatePrivateKey(entropy) {
5329
- 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);
5428
+ 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);
5330
5429
  }
5331
5430
  /**
5332
5431
  * Extended publicKey from a compact publicKey
@@ -5335,16 +5434,16 @@ var Signer = class {
5335
5434
  * @returns extended publicKey
5336
5435
  */
5337
5436
  static extendPublicKey(publicKey) {
5338
- const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(publicKey));
5339
- return (0, import_utils28.hexlify)(point.toRawBytes(false).slice(1));
5437
+ const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(publicKey));
5438
+ return (0, import_utils29.hexlify)(point.toRawBytes(false).slice(1));
5340
5439
  }
5341
5440
  };
5342
5441
 
5343
5442
  // src/wallet/keystore-wallet.ts
5344
5443
  var import_address6 = require("@fuel-ts/address");
5345
5444
  var import_crypto2 = require("@fuel-ts/crypto");
5346
- var import_errors16 = require("@fuel-ts/errors");
5347
- var import_utils29 = require("@fuel-ts/utils");
5445
+ var import_errors17 = require("@fuel-ts/errors");
5446
+ var import_utils30 = require("@fuel-ts/utils");
5348
5447
  var import_uuid = require("uuid");
5349
5448
  var DEFAULT_KDF_PARAMS_LOG_N = 13;
5350
5449
  var DEFAULT_KDF_PARAMS_R = 8;
@@ -5421,13 +5520,13 @@ async function decryptKeystoreWallet(jsonWallet, password) {
5421
5520
  const macHashUint8Array = (0, import_crypto2.keccak256)(data);
5422
5521
  const macHash = (0, import_crypto2.stringFromBuffer)(macHashUint8Array, "hex");
5423
5522
  if (mac !== macHash) {
5424
- throw new import_errors16.FuelError(
5425
- import_errors16.ErrorCode.INVALID_PASSWORD,
5523
+ throw new import_errors17.FuelError(
5524
+ import_errors17.ErrorCode.INVALID_PASSWORD,
5426
5525
  "Failed to decrypt the keystore wallet, the provided password is incorrect."
5427
5526
  );
5428
5527
  }
5429
5528
  const buffer = await (0, import_crypto2.decryptJsonWalletData)(ciphertextBuffer, key, ivBuffer);
5430
- const privateKey = (0, import_utils29.hexlify)(buffer);
5529
+ const privateKey = (0, import_utils30.hexlify)(buffer);
5431
5530
  return privateKey;
5432
5531
  }
5433
5532
 
@@ -5472,7 +5571,7 @@ var BaseWalletUnlocked = class extends Account {
5472
5571
  */
5473
5572
  async signMessage(message) {
5474
5573
  const signedMessage = await this.signer().sign((0, import_hasher3.hashMessage)(message));
5475
- return (0, import_utils30.hexlify)(signedMessage);
5574
+ return (0, import_utils31.hexlify)(signedMessage);
5476
5575
  }
5477
5576
  /**
5478
5577
  * Signs a transaction with the wallet's private key.
@@ -5485,7 +5584,7 @@ var BaseWalletUnlocked = class extends Account {
5485
5584
  const chainId = this.provider.getChainId();
5486
5585
  const hashedTransaction = transactionRequest.getTransactionId(chainId);
5487
5586
  const signature = await this.signer().sign(hashedTransaction);
5488
- return (0, import_utils30.hexlify)(signature);
5587
+ return (0, import_utils31.hexlify)(signature);
5489
5588
  }
5490
5589
  /**
5491
5590
  * Populates a transaction with the witnesses signature.
@@ -5544,17 +5643,17 @@ var BaseWalletUnlocked = class extends Account {
5544
5643
  __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
5545
5644
 
5546
5645
  // src/hdwallet/hdwallet.ts
5547
- var import_errors19 = require("@fuel-ts/errors");
5646
+ var import_errors20 = require("@fuel-ts/errors");
5548
5647
  var import_hasher6 = require("@fuel-ts/hasher");
5549
- var import_math19 = require("@fuel-ts/math");
5550
- var import_utils34 = require("@fuel-ts/utils");
5648
+ var import_math20 = require("@fuel-ts/math");
5649
+ var import_utils35 = require("@fuel-ts/utils");
5551
5650
  var import_ethers3 = require("ethers");
5552
5651
 
5553
5652
  // src/mnemonic/mnemonic.ts
5554
5653
  var import_crypto3 = require("@fuel-ts/crypto");
5555
- var import_errors18 = require("@fuel-ts/errors");
5654
+ var import_errors19 = require("@fuel-ts/errors");
5556
5655
  var import_hasher5 = require("@fuel-ts/hasher");
5557
- var import_utils32 = require("@fuel-ts/utils");
5656
+ var import_utils33 = require("@fuel-ts/utils");
5558
5657
  var import_ethers2 = require("ethers");
5559
5658
 
5560
5659
  // src/wordlists/words/english.ts
@@ -7616,9 +7715,9 @@ var Language = /* @__PURE__ */ ((Language2) => {
7616
7715
  })(Language || {});
7617
7716
 
7618
7717
  // src/mnemonic/utils.ts
7619
- var import_errors17 = require("@fuel-ts/errors");
7718
+ var import_errors18 = require("@fuel-ts/errors");
7620
7719
  var import_hasher4 = require("@fuel-ts/hasher");
7621
- var import_utils31 = require("@fuel-ts/utils");
7720
+ var import_utils32 = require("@fuel-ts/utils");
7622
7721
  function toUtf8Bytes(stri) {
7623
7722
  const str = stri.normalize("NFKD");
7624
7723
  const result = [];
@@ -7633,8 +7732,8 @@ function toUtf8Bytes(stri) {
7633
7732
  i += 1;
7634
7733
  const c2 = str.charCodeAt(i);
7635
7734
  if (i >= str.length || (c2 & 64512) !== 56320) {
7636
- throw new import_errors17.FuelError(
7637
- import_errors17.ErrorCode.INVALID_INPUT_PARAMETERS,
7735
+ throw new import_errors18.FuelError(
7736
+ import_errors18.ErrorCode.INVALID_INPUT_PARAMETERS,
7638
7737
  "Invalid UTF-8 in the input string."
7639
7738
  );
7640
7739
  }
@@ -7685,20 +7784,20 @@ function entropyToMnemonicIndices(entropy) {
7685
7784
  }
7686
7785
  }
7687
7786
  const checksumBits = entropy.length / 4;
7688
- const checksum = (0, import_utils31.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
7787
+ const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
7689
7788
  indices[indices.length - 1] <<= checksumBits;
7690
7789
  indices[indices.length - 1] |= checksum >> 8 - checksumBits;
7691
7790
  return indices;
7692
7791
  }
7693
7792
  function mnemonicWordsToEntropy(words, wordlist) {
7694
7793
  const size = Math.ceil(11 * words.length / 8);
7695
- const entropy = (0, import_utils31.arrayify)(new Uint8Array(size));
7794
+ const entropy = (0, import_utils32.arrayify)(new Uint8Array(size));
7696
7795
  let offset = 0;
7697
7796
  for (let i = 0; i < words.length; i += 1) {
7698
7797
  const index = wordlist.indexOf(words[i].normalize("NFKD"));
7699
7798
  if (index === -1) {
7700
- throw new import_errors17.FuelError(
7701
- import_errors17.ErrorCode.INVALID_MNEMONIC,
7799
+ throw new import_errors18.FuelError(
7800
+ import_errors18.ErrorCode.INVALID_MNEMONIC,
7702
7801
  `Invalid mnemonic: the word '${words[i]}' is not found in the provided wordlist.`
7703
7802
  );
7704
7803
  }
@@ -7712,10 +7811,10 @@ function mnemonicWordsToEntropy(words, wordlist) {
7712
7811
  const entropyBits = 32 * words.length / 3;
7713
7812
  const checksumBits = words.length / 3;
7714
7813
  const checksumMask = getUpperMask(checksumBits);
7715
- const checksum = (0, import_utils31.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
7814
+ const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
7716
7815
  if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
7717
- throw new import_errors17.FuelError(
7718
- import_errors17.ErrorCode.INVALID_CHECKSUM,
7816
+ throw new import_errors18.FuelError(
7817
+ import_errors18.ErrorCode.INVALID_CHECKSUM,
7719
7818
  "Checksum validation failed for the provided mnemonic."
7720
7819
  );
7721
7820
  }
@@ -7729,16 +7828,16 @@ var TestnetPRV = "0x04358394";
7729
7828
  var MNEMONIC_SIZES = [12, 15, 18, 21, 24];
7730
7829
  function assertWordList(wordlist) {
7731
7830
  if (wordlist.length !== 2048) {
7732
- throw new import_errors18.FuelError(
7733
- import_errors18.ErrorCode.INVALID_WORD_LIST,
7831
+ throw new import_errors19.FuelError(
7832
+ import_errors19.ErrorCode.INVALID_WORD_LIST,
7734
7833
  `Expected word list length of 2048, but got ${wordlist.length}.`
7735
7834
  );
7736
7835
  }
7737
7836
  }
7738
7837
  function assertEntropy(entropy) {
7739
7838
  if (entropy.length % 4 !== 0 || entropy.length < 16 || entropy.length > 32) {
7740
- throw new import_errors18.FuelError(
7741
- import_errors18.ErrorCode.INVALID_ENTROPY,
7839
+ throw new import_errors19.FuelError(
7840
+ import_errors19.ErrorCode.INVALID_ENTROPY,
7742
7841
  `Entropy should be between 16 and 32 bytes and a multiple of 4, but got ${entropy.length} bytes.`
7743
7842
  );
7744
7843
  }
@@ -7748,7 +7847,7 @@ function assertMnemonic(words) {
7748
7847
  const errorMsg = `Invalid mnemonic size. Expected one of [${MNEMONIC_SIZES.join(
7749
7848
  ", "
7750
7849
  )}] words, but got ${words.length}.`;
7751
- throw new import_errors18.FuelError(import_errors18.ErrorCode.INVALID_MNEMONIC, errorMsg);
7850
+ throw new import_errors19.FuelError(import_errors19.ErrorCode.INVALID_MNEMONIC, errorMsg);
7752
7851
  }
7753
7852
  }
7754
7853
  var Mnemonic = class {
@@ -7787,7 +7886,7 @@ var Mnemonic = class {
7787
7886
  static mnemonicToEntropy(phrase, wordlist = english) {
7788
7887
  const words = getWords(phrase);
7789
7888
  assertMnemonic(words);
7790
- return (0, import_utils32.hexlify)(mnemonicWordsToEntropy(words, wordlist));
7889
+ return (0, import_utils33.hexlify)(mnemonicWordsToEntropy(words, wordlist));
7791
7890
  }
7792
7891
  /**
7793
7892
  * @param entropy - Entropy source to the mnemonic phrase.
@@ -7795,7 +7894,7 @@ var Mnemonic = class {
7795
7894
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
7796
7895
  */
7797
7896
  static entropyToMnemonic(entropy, wordlist = english) {
7798
- const entropyBytes = (0, import_utils32.arrayify)(entropy);
7897
+ const entropyBytes = (0, import_utils33.arrayify)(entropy);
7799
7898
  assertWordList(wordlist);
7800
7899
  assertEntropy(entropyBytes);
7801
7900
  return entropyToMnemonicIndices(entropyBytes).map((i) => wordlist[i]).join(" ");
@@ -7864,14 +7963,14 @@ var Mnemonic = class {
7864
7963
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
7865
7964
  */
7866
7965
  static masterKeysFromSeed(seed) {
7867
- const seedArray = (0, import_utils32.arrayify)(seed);
7966
+ const seedArray = (0, import_utils33.arrayify)(seed);
7868
7967
  if (seedArray.length < 16 || seedArray.length > 64) {
7869
- throw new import_errors18.FuelError(
7870
- import_errors18.ErrorCode.INVALID_SEED,
7968
+ throw new import_errors19.FuelError(
7969
+ import_errors19.ErrorCode.INVALID_SEED,
7871
7970
  `Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
7872
7971
  );
7873
7972
  }
7874
- return (0, import_utils32.arrayify)((0, import_ethers2.computeHmac)("sha512", MasterSecret, seedArray));
7973
+ return (0, import_utils33.arrayify)((0, import_ethers2.computeHmac)("sha512", MasterSecret, seedArray));
7875
7974
  }
7876
7975
  /**
7877
7976
  * Get the extendKey as defined on BIP-32 from the provided seed
@@ -7882,22 +7981,22 @@ var Mnemonic = class {
7882
7981
  */
7883
7982
  static seedToExtendedKey(seed, testnet = false) {
7884
7983
  const masterKey = Mnemonic.masterKeysFromSeed(seed);
7885
- const prefix = (0, import_utils32.arrayify)(testnet ? TestnetPRV : MainnetPRV);
7984
+ const prefix = (0, import_utils33.arrayify)(testnet ? TestnetPRV : MainnetPRV);
7886
7985
  const depth = "0x00";
7887
7986
  const fingerprint = "0x00000000";
7888
7987
  const index = "0x00000000";
7889
7988
  const chainCode = masterKey.slice(32);
7890
7989
  const privateKey = masterKey.slice(0, 32);
7891
- const extendedKey = (0, import_utils32.concat)([
7990
+ const extendedKey = (0, import_utils33.concat)([
7892
7991
  prefix,
7893
7992
  depth,
7894
7993
  fingerprint,
7895
7994
  index,
7896
7995
  chainCode,
7897
- (0, import_utils32.concat)(["0x00", privateKey])
7996
+ (0, import_utils33.concat)(["0x00", privateKey])
7898
7997
  ]);
7899
7998
  const checksum = (0, import_ethers2.dataSlice)((0, import_hasher5.sha256)((0, import_hasher5.sha256)(extendedKey)), 0, 4);
7900
- return (0, import_ethers2.encodeBase58)((0, import_utils32.concat)([extendedKey, checksum]));
7999
+ return (0, import_ethers2.encodeBase58)((0, import_utils33.concat)([extendedKey, checksum]));
7901
8000
  }
7902
8001
  /**
7903
8002
  * Create a new mnemonic using a randomly generated number as entropy.
@@ -7912,7 +8011,7 @@ var Mnemonic = class {
7912
8011
  * @returns A randomly generated mnemonic
7913
8012
  */
7914
8013
  static generate(size = 32, extraEntropy = "") {
7915
- 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);
8014
+ 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);
7916
8015
  return Mnemonic.entropyToMnemonic(entropy);
7917
8016
  }
7918
8017
  };
@@ -7920,12 +8019,12 @@ var mnemonic_default = Mnemonic;
7920
8019
 
7921
8020
  // src/hdwallet/hdwallet.ts
7922
8021
  var HARDENED_INDEX = 2147483648;
7923
- var MainnetPRV2 = (0, import_utils34.hexlify)("0x0488ade4");
7924
- var MainnetPUB = (0, import_utils34.hexlify)("0x0488b21e");
7925
- var TestnetPRV2 = (0, import_utils34.hexlify)("0x04358394");
7926
- var TestnetPUB = (0, import_utils34.hexlify)("0x043587cf");
8022
+ var MainnetPRV2 = (0, import_utils35.hexlify)("0x0488ade4");
8023
+ var MainnetPUB = (0, import_utils35.hexlify)("0x0488b21e");
8024
+ var TestnetPRV2 = (0, import_utils35.hexlify)("0x04358394");
8025
+ var TestnetPUB = (0, import_utils35.hexlify)("0x043587cf");
7927
8026
  function base58check(data) {
7928
- 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)]));
8027
+ 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)]));
7929
8028
  }
7930
8029
  function getExtendedKeyPrefix(isPublic = false, testnet = false) {
7931
8030
  if (isPublic) {
@@ -7934,17 +8033,17 @@ function getExtendedKeyPrefix(isPublic = false, testnet = false) {
7934
8033
  return testnet ? TestnetPRV2 : MainnetPRV2;
7935
8034
  }
7936
8035
  function isPublicExtendedKey(extendedKey) {
7937
- return [MainnetPUB, TestnetPUB].includes((0, import_utils34.hexlify)(extendedKey.slice(0, 4)));
8036
+ return [MainnetPUB, TestnetPUB].includes((0, import_utils35.hexlify)(extendedKey.slice(0, 4)));
7938
8037
  }
7939
8038
  function isValidExtendedKey(extendedKey) {
7940
8039
  return [MainnetPRV2, TestnetPRV2, MainnetPUB, TestnetPUB].includes(
7941
- (0, import_utils34.hexlify)(extendedKey.slice(0, 4))
8040
+ (0, import_utils35.hexlify)(extendedKey.slice(0, 4))
7942
8041
  );
7943
8042
  }
7944
8043
  function parsePath(path, depth = 0) {
7945
8044
  const components = path.split("/");
7946
8045
  if (components.length === 0 || components[0] === "m" && depth !== 0) {
7947
- throw new import_errors19.FuelError(import_errors19.ErrorCode.HD_WALLET_ERROR, `invalid path - ${path}`);
8046
+ throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, `invalid path - ${path}`);
7948
8047
  }
7949
8048
  if (components[0] === "m") {
7950
8049
  components.shift();
@@ -7956,8 +8055,8 @@ function parsePath(path, depth = 0) {
7956
8055
  var HDWallet = class {
7957
8056
  depth = 0;
7958
8057
  index = 0;
7959
- fingerprint = (0, import_utils34.hexlify)("0x00000000");
7960
- parentFingerprint = (0, import_utils34.hexlify)("0x00000000");
8058
+ fingerprint = (0, import_utils35.hexlify)("0x00000000");
8059
+ parentFingerprint = (0, import_utils35.hexlify)("0x00000000");
7961
8060
  privateKey;
7962
8061
  publicKey;
7963
8062
  chainCode;
@@ -7969,16 +8068,16 @@ var HDWallet = class {
7969
8068
  constructor(config) {
7970
8069
  if (config.privateKey) {
7971
8070
  const signer = new Signer(config.privateKey);
7972
- this.publicKey = (0, import_utils34.hexlify)(signer.compressedPublicKey);
7973
- this.privateKey = (0, import_utils34.hexlify)(config.privateKey);
8071
+ this.publicKey = (0, import_utils35.hexlify)(signer.compressedPublicKey);
8072
+ this.privateKey = (0, import_utils35.hexlify)(config.privateKey);
7974
8073
  } else {
7975
8074
  if (!config.publicKey) {
7976
- throw new import_errors19.FuelError(
7977
- import_errors19.ErrorCode.HD_WALLET_ERROR,
8075
+ throw new import_errors20.FuelError(
8076
+ import_errors20.ErrorCode.HD_WALLET_ERROR,
7978
8077
  "Both public and private Key cannot be missing. At least one should be provided."
7979
8078
  );
7980
8079
  }
7981
- this.publicKey = (0, import_utils34.hexlify)(config.publicKey);
8080
+ this.publicKey = (0, import_utils35.hexlify)(config.publicKey);
7982
8081
  }
7983
8082
  this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
7984
8083
  this.fingerprint = (0, import_ethers3.dataSlice)((0, import_ethers3.ripemd160)((0, import_hasher6.sha256)(this.publicKey)), 0, 4);
@@ -7997,28 +8096,28 @@ var HDWallet = class {
7997
8096
  * @returns A new instance of HDWallet on the derived index
7998
8097
  */
7999
8098
  deriveIndex(index) {
8000
- const privateKey = this.privateKey && (0, import_utils34.arrayify)(this.privateKey);
8001
- const publicKey = (0, import_utils34.arrayify)(this.publicKey);
8002
- const chainCode = (0, import_utils34.arrayify)(this.chainCode);
8099
+ const privateKey = this.privateKey && (0, import_utils35.arrayify)(this.privateKey);
8100
+ const publicKey = (0, import_utils35.arrayify)(this.publicKey);
8101
+ const chainCode = (0, import_utils35.arrayify)(this.chainCode);
8003
8102
  const data = new Uint8Array(37);
8004
8103
  if (index & HARDENED_INDEX) {
8005
8104
  if (!privateKey) {
8006
- throw new import_errors19.FuelError(
8007
- import_errors19.ErrorCode.HD_WALLET_ERROR,
8105
+ throw new import_errors20.FuelError(
8106
+ import_errors20.ErrorCode.HD_WALLET_ERROR,
8008
8107
  "Cannot derive a hardened index without a private Key."
8009
8108
  );
8010
8109
  }
8011
8110
  data.set(privateKey, 1);
8012
8111
  } else {
8013
- data.set((0, import_utils34.arrayify)(this.publicKey));
8112
+ data.set((0, import_utils35.arrayify)(this.publicKey));
8014
8113
  }
8015
- data.set((0, import_math19.toBytes)(index, 4), 33);
8016
- const bytes = (0, import_utils34.arrayify)((0, import_ethers3.computeHmac)("sha512", chainCode, data));
8114
+ data.set((0, import_math20.toBytes)(index, 4), 33);
8115
+ const bytes = (0, import_utils35.arrayify)((0, import_ethers3.computeHmac)("sha512", chainCode, data));
8017
8116
  const IL = bytes.slice(0, 32);
8018
8117
  const IR = bytes.slice(32);
8019
8118
  if (privateKey) {
8020
8119
  const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
8021
- const ki = (0, import_math19.bn)(IL).add(privateKey).mod(N).toBytes(32);
8120
+ const ki = (0, import_math20.bn)(IL).add(privateKey).mod(N).toBytes(32);
8022
8121
  return new HDWallet({
8023
8122
  privateKey: ki,
8024
8123
  chainCode: IR,
@@ -8027,7 +8126,7 @@ var HDWallet = class {
8027
8126
  parentFingerprint: this.fingerprint
8028
8127
  });
8029
8128
  }
8030
- const signer = new Signer((0, import_utils34.hexlify)(IL));
8129
+ const signer = new Signer((0, import_utils35.hexlify)(IL));
8031
8130
  const Ki = signer.addPoint(publicKey);
8032
8131
  return new HDWallet({
8033
8132
  publicKey: Ki,
@@ -8056,18 +8155,18 @@ var HDWallet = class {
8056
8155
  */
8057
8156
  toExtendedKey(isPublic = false, testnet = false) {
8058
8157
  if (this.depth >= 256) {
8059
- throw new import_errors19.FuelError(
8060
- import_errors19.ErrorCode.HD_WALLET_ERROR,
8158
+ throw new import_errors20.FuelError(
8159
+ import_errors20.ErrorCode.HD_WALLET_ERROR,
8061
8160
  `Exceeded max depth of 255. Current depth: ${this.depth}.`
8062
8161
  );
8063
8162
  }
8064
8163
  const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
8065
- const depth = (0, import_utils34.hexlify)(Uint8Array.from([this.depth]));
8164
+ const depth = (0, import_utils35.hexlify)(Uint8Array.from([this.depth]));
8066
8165
  const parentFingerprint = this.parentFingerprint;
8067
- const index = (0, import_math19.toHex)(this.index, 4);
8166
+ const index = (0, import_math20.toHex)(this.index, 4);
8068
8167
  const chainCode = this.chainCode;
8069
- const key = this.privateKey != null && !isPublic ? (0, import_utils34.concat)(["0x00", this.privateKey]) : this.publicKey;
8070
- const extendedKey = (0, import_utils34.arrayify)((0, import_utils34.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
8168
+ const key = this.privateKey != null && !isPublic ? (0, import_utils35.concat)(["0x00", this.privateKey]) : this.publicKey;
8169
+ const extendedKey = (0, import_utils35.arrayify)((0, import_utils35.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
8071
8170
  return base58check(extendedKey);
8072
8171
  }
8073
8172
  /**
@@ -8079,34 +8178,34 @@ var HDWallet = class {
8079
8178
  static fromSeed(seed) {
8080
8179
  const masterKey = mnemonic_default.masterKeysFromSeed(seed);
8081
8180
  return new HDWallet({
8082
- chainCode: (0, import_utils34.arrayify)(masterKey.slice(32)),
8083
- privateKey: (0, import_utils34.arrayify)(masterKey.slice(0, 32))
8181
+ chainCode: (0, import_utils35.arrayify)(masterKey.slice(32)),
8182
+ privateKey: (0, import_utils35.arrayify)(masterKey.slice(0, 32))
8084
8183
  });
8085
8184
  }
8086
8185
  static fromExtendedKey(extendedKey) {
8087
8186
  const decoded = (0, import_ethers3.toBeHex)((0, import_ethers3.decodeBase58)(extendedKey));
8088
- const bytes = (0, import_utils34.arrayify)(decoded);
8187
+ const bytes = (0, import_utils35.arrayify)(decoded);
8089
8188
  const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
8090
8189
  if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
8091
- throw new import_errors19.FuelError(import_errors19.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
8190
+ throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
8092
8191
  }
8093
8192
  if (!validChecksum) {
8094
- throw new import_errors19.FuelError(import_errors19.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
8193
+ throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
8095
8194
  }
8096
8195
  const depth = bytes[4];
8097
- const parentFingerprint = (0, import_utils34.hexlify)(bytes.slice(5, 9));
8098
- const index = parseInt((0, import_utils34.hexlify)(bytes.slice(9, 13)).substring(2), 16);
8099
- const chainCode = (0, import_utils34.hexlify)(bytes.slice(13, 45));
8196
+ const parentFingerprint = (0, import_utils35.hexlify)(bytes.slice(5, 9));
8197
+ const index = parseInt((0, import_utils35.hexlify)(bytes.slice(9, 13)).substring(2), 16);
8198
+ const chainCode = (0, import_utils35.hexlify)(bytes.slice(13, 45));
8100
8199
  const key = bytes.slice(45, 78);
8101
8200
  if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
8102
- throw new import_errors19.FuelError(
8103
- import_errors19.ErrorCode.HD_WALLET_ERROR,
8201
+ throw new import_errors20.FuelError(
8202
+ import_errors20.ErrorCode.HD_WALLET_ERROR,
8104
8203
  "Inconsistency detected: Depth is zero but fingerprint/index is non-zero."
8105
8204
  );
8106
8205
  }
8107
8206
  if (isPublicExtendedKey(bytes)) {
8108
8207
  if (key[0] !== 3) {
8109
- throw new import_errors19.FuelError(import_errors19.ErrorCode.HD_WALLET_ERROR, "Invalid public extended key.");
8208
+ throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Invalid public extended key.");
8110
8209
  }
8111
8210
  return new HDWallet({
8112
8211
  publicKey: key,
@@ -8117,7 +8216,7 @@ var HDWallet = class {
8117
8216
  });
8118
8217
  }
8119
8218
  if (key[0] !== 0) {
8120
- throw new import_errors19.FuelError(import_errors19.ErrorCode.HD_WALLET_ERROR, "Invalid private extended key.");
8219
+ throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Invalid private extended key.");
8121
8220
  }
8122
8221
  return new HDWallet({
8123
8222
  privateKey: key.slice(1),
@@ -8285,7 +8384,7 @@ __publicField(Wallet, "fromEncryptedJson", WalletUnlocked.fromEncryptedJson);
8285
8384
  // src/wallet-manager/wallet-manager.ts
8286
8385
  var import_address9 = require("@fuel-ts/address");
8287
8386
  var import_crypto4 = require("@fuel-ts/crypto");
8288
- var import_errors22 = require("@fuel-ts/errors");
8387
+ var import_errors23 = require("@fuel-ts/errors");
8289
8388
  var import_events = require("events");
8290
8389
 
8291
8390
  // src/wallet-manager/storages/memory-storage.ts
@@ -8308,7 +8407,7 @@ var MemoryStorage = class {
8308
8407
 
8309
8408
  // src/wallet-manager/vaults/mnemonic-vault.ts
8310
8409
  var import_address7 = require("@fuel-ts/address");
8311
- var import_errors20 = require("@fuel-ts/errors");
8410
+ var import_errors21 = require("@fuel-ts/errors");
8312
8411
  var _secret;
8313
8412
  var MnemonicVault = class {
8314
8413
  constructor(options) {
@@ -8364,8 +8463,8 @@ var MnemonicVault = class {
8364
8463
  }
8365
8464
  numberOfAccounts += 1;
8366
8465
  } while (numberOfAccounts < this.numberOfAccounts);
8367
- throw new import_errors20.FuelError(
8368
- import_errors20.ErrorCode.WALLET_MANAGER_ERROR,
8466
+ throw new import_errors21.FuelError(
8467
+ import_errors21.ErrorCode.WALLET_MANAGER_ERROR,
8369
8468
  `Account with address '${address}' not found in derived wallets.`
8370
8469
  );
8371
8470
  }
@@ -8379,7 +8478,7 @@ __publicField(MnemonicVault, "type", "mnemonic");
8379
8478
 
8380
8479
  // src/wallet-manager/vaults/privatekey-vault.ts
8381
8480
  var import_address8 = require("@fuel-ts/address");
8382
- var import_errors21 = require("@fuel-ts/errors");
8481
+ var import_errors22 = require("@fuel-ts/errors");
8383
8482
  var _privateKeys;
8384
8483
  var PrivateKeyVault = class {
8385
8484
  /**
@@ -8420,8 +8519,8 @@ var PrivateKeyVault = class {
8420
8519
  (pk) => Wallet.fromPrivateKey(pk).address.equals(ownerAddress)
8421
8520
  );
8422
8521
  if (!privateKey) {
8423
- throw new import_errors21.FuelError(
8424
- import_errors21.ErrorCode.WALLET_MANAGER_ERROR,
8522
+ throw new import_errors22.FuelError(
8523
+ import_errors22.ErrorCode.WALLET_MANAGER_ERROR,
8425
8524
  `No private key found for address '${address}'.`
8426
8525
  );
8427
8526
  }
@@ -8445,7 +8544,7 @@ var ERROR_MESSAGES = {
8445
8544
  };
8446
8545
  function assert(condition, message) {
8447
8546
  if (!condition) {
8448
- throw new import_errors22.FuelError(import_errors22.ErrorCode.WALLET_MANAGER_ERROR, message);
8547
+ throw new import_errors23.FuelError(import_errors23.ErrorCode.WALLET_MANAGER_ERROR, message);
8449
8548
  }
8450
8549
  }
8451
8550
  var _vaults, _passphrase, _isLocked, _serializeVaults, serializeVaults_fn, _deserializeVaults, deserializeVaults_fn;
@@ -8671,25 +8770,25 @@ deserializeVaults_fn = function(vaults) {
8671
8770
  __publicField(WalletManager, "Vaults", [MnemonicVault, PrivateKeyVault]);
8672
8771
 
8673
8772
  // src/wallet-manager/types.ts
8674
- var import_errors23 = require("@fuel-ts/errors");
8773
+ var import_errors24 = require("@fuel-ts/errors");
8675
8774
  var Vault = class {
8676
8775
  constructor(_options) {
8677
- 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.");
8678
8777
  }
8679
8778
  serialize() {
8680
- 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.");
8681
8780
  }
8682
8781
  getAccounts() {
8683
- 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.");
8684
8783
  }
8685
8784
  addAccount() {
8686
- 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.");
8687
8786
  }
8688
8787
  exportAccount(_address) {
8689
- 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.");
8690
8789
  }
8691
8790
  getWallet(_address) {
8692
- throw new import_errors23.FuelError(import_errors23.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
8791
+ throw new import_errors24.FuelError(import_errors24.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
8693
8792
  }
8694
8793
  };
8695
8794
  __publicField(Vault, "type");
@@ -8699,21 +8798,21 @@ var StorageAbstract = class {
8699
8798
  // src/predicate/predicate.ts
8700
8799
  var import_abi_coder5 = require("@fuel-ts/abi-coder");
8701
8800
  var import_address10 = require("@fuel-ts/address");
8702
- var import_configs12 = require("@fuel-ts/address/configs");
8703
- var import_errors24 = require("@fuel-ts/errors");
8704
- var import_transactions19 = require("@fuel-ts/transactions");
8705
- var import_utils36 = require("@fuel-ts/utils");
8801
+ var import_configs13 = require("@fuel-ts/address/configs");
8802
+ var import_errors25 = require("@fuel-ts/errors");
8803
+ var import_transactions20 = require("@fuel-ts/transactions");
8804
+ var import_utils37 = require("@fuel-ts/utils");
8706
8805
 
8707
8806
  // src/predicate/utils/getPredicateRoot.ts
8708
8807
  var import_hasher7 = require("@fuel-ts/hasher");
8709
8808
  var import_merkle = require("@fuel-ts/merkle");
8710
- var import_utils35 = require("@fuel-ts/utils");
8809
+ var import_utils36 = require("@fuel-ts/utils");
8711
8810
  var getPredicateRoot = (bytecode) => {
8712
8811
  const chunkSize = 16 * 1024;
8713
- const bytes = (0, import_utils35.arrayify)(bytecode);
8714
- const chunks = (0, import_utils35.chunkAndPadBytes)(bytes, chunkSize);
8715
- const codeRoot = (0, import_merkle.calcRoot)(chunks.map((c) => (0, import_utils35.hexlify)(c)));
8716
- const predicateRoot = (0, import_hasher7.hash)((0, import_utils35.concat)(["0x4655454C", codeRoot]));
8812
+ const bytes = (0, import_utils36.arrayify)(bytecode);
8813
+ const chunks = (0, import_utils36.chunkAndPadBytes)(bytes, chunkSize);
8814
+ const codeRoot = (0, import_merkle.calcRoot)(chunks.map((c) => (0, import_utils36.hexlify)(c)));
8815
+ const predicateRoot = (0, import_hasher7.hash)((0, import_utils36.concat)(["0x4655454C", codeRoot]));
8717
8816
  return predicateRoot;
8718
8817
  };
8719
8818
 
@@ -8762,7 +8861,7 @@ var Predicate = class extends Account {
8762
8861
  const request = transactionRequestify(transactionRequestLike);
8763
8862
  const { policies } = BaseTransactionRequest.getPolicyMeta(request);
8764
8863
  request.inputs?.forEach((input) => {
8765
- if (input.type === import_transactions19.InputType.Coin && (0, import_utils36.hexlify)(input.owner) === this.address.toB256()) {
8864
+ if (input.type === import_transactions20.InputType.Coin && (0, import_utils37.hexlify)(input.owner) === this.address.toB256()) {
8766
8865
  input.predicate = this.bytes;
8767
8866
  input.predicateData = this.getPredicateData(policies.length);
8768
8867
  }
@@ -8778,7 +8877,7 @@ var Predicate = class extends Account {
8778
8877
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
8779
8878
  * @returns A promise that resolves to the prepared transaction request.
8780
8879
  */
8781
- async createTransfer(destination, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
8880
+ async createTransfer(destination, amount, assetId = import_configs13.BaseAssetId, txParams = {}) {
8782
8881
  const request = await super.createTransfer(destination, amount, assetId, txParams);
8783
8882
  return this.populateTransactionPredicateData(request);
8784
8883
  }
@@ -8807,7 +8906,7 @@ var Predicate = class extends Account {
8807
8906
  return new Uint8Array();
8808
8907
  }
8809
8908
  const mainFn = this.interface?.functions.main;
8810
- const paddedCode = new import_transactions19.ByteArrayCoder(this.bytes.length).encode(this.bytes);
8909
+ const paddedCode = new import_transactions20.ByteArrayCoder(this.bytes.length).encode(this.bytes);
8811
8910
  const VM_TX_MEMORY = (0, import_abi_coder5.calculateVmTxMemory)({
8812
8911
  maxInputs: this.provider.getChain().consensusParameters.maxInputs.toNumber()
8813
8912
  });
@@ -8823,13 +8922,13 @@ var Predicate = class extends Account {
8823
8922
  * @returns An object containing the new predicate bytes and interface.
8824
8923
  */
8825
8924
  static processPredicateData(bytes, jsonAbi, configurableConstants) {
8826
- let predicateBytes = (0, import_utils36.arrayify)(bytes);
8925
+ let predicateBytes = (0, import_utils37.arrayify)(bytes);
8827
8926
  let abiInterface;
8828
8927
  if (jsonAbi) {
8829
8928
  abiInterface = new import_abi_coder5.Interface(jsonAbi);
8830
8929
  if (abiInterface.functions.main === void 0) {
8831
- throw new import_errors24.FuelError(
8832
- import_errors24.ErrorCode.ABI_MAIN_METHOD_MISSING,
8930
+ throw new import_errors25.FuelError(
8931
+ import_errors25.ErrorCode.ABI_MAIN_METHOD_MISSING,
8833
8932
  'Cannot use ABI without "main" function.'
8834
8933
  );
8835
8934
  }
@@ -8874,8 +8973,8 @@ var Predicate = class extends Account {
8874
8973
  mutatedBytes.set(encoded, offset);
8875
8974
  });
8876
8975
  } catch (err) {
8877
- throw new import_errors24.FuelError(
8878
- import_errors24.ErrorCode.INVALID_CONFIGURABLE_CONSTANTS,
8976
+ throw new import_errors25.FuelError(
8977
+ import_errors25.ErrorCode.INVALID_CONFIGURABLE_CONSTANTS,
8879
8978
  `Error setting configurable constants: ${err.message}.`
8880
8979
  );
8881
8980
  }
@@ -8884,7 +8983,7 @@ var Predicate = class extends Account {
8884
8983
  };
8885
8984
 
8886
8985
  // src/connectors/fuel.ts
8887
- var import_errors25 = require("@fuel-ts/errors");
8986
+ var import_errors26 = require("@fuel-ts/errors");
8888
8987
 
8889
8988
  // src/connectors/fuel-connector.ts
8890
8989
  var import_events2 = require("events");
@@ -9517,7 +9616,7 @@ var _Fuel = class extends FuelConnector {
9517
9616
  const currentNetwork = await this.currentNetwork();
9518
9617
  provider = await Provider.create(currentNetwork.url);
9519
9618
  } else {
9520
- throw new import_errors25.FuelError(import_errors25.ErrorCode.INVALID_PROVIDER, "Provider is not valid.");
9619
+ throw new import_errors26.FuelError(import_errors26.ErrorCode.INVALID_PROVIDER, "Provider is not valid.");
9521
9620
  }
9522
9621
  return provider;
9523
9622
  }
@@ -9597,7 +9696,9 @@ __publicField(Fuel, "defaultConfig", {});
9597
9696
  WalletUnlocked,
9598
9697
  addAmountToAsset,
9599
9698
  addOperation,
9699
+ assemblePanicError,
9600
9700
  assembleReceiptByType,
9701
+ assembleRevertError,
9601
9702
  assembleTransactionSummary,
9602
9703
  assets,
9603
9704
  buildBlockExplorerUrl,
@@ -9612,6 +9713,7 @@ __publicField(Fuel, "defaultConfig", {});
9612
9713
  english,
9613
9714
  extractBurnedAssetsFromReceipts,
9614
9715
  extractMintedAssetsFromReceipts,
9716
+ extractTxError,
9615
9717
  gasUsedByInputs,
9616
9718
  getAssetEth,
9617
9719
  getAssetFuel,