@fuel-ts/account 0.0.0-rc-1936-20240328132546 → 0.0.0-rc-1895-20240328133917

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 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 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 it's missing an "OutputChange".`;
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 isPanic = receipts.some(({ type }) => type === import_transactions5.ReceiptType.Panic);
1756
+ let err = status?.type === "FailureStatus" && isPanic ? 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
  /**
@@ -3555,32 +3659,10 @@ var TransactionResponse = class {
3555
3659
  * @param contractsAbiMap - The contracts ABI map.
3556
3660
  */
3557
3661
  async wait(contractsAbiMap) {
3558
- const result = await this.waitForResult(contractsAbiMap);
3559
- if (result.isStatusFailure) {
3560
- throw new import_errors12.FuelError(
3561
- import_errors12.ErrorCode.TRANSACTION_FAILED,
3562
- `Transaction failed: ${result.gqlTransaction.status.reason}`
3563
- );
3564
- }
3565
- return result;
3662
+ return this.waitForResult(contractsAbiMap);
3566
3663
  }
3567
3664
  };
3568
3665
 
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
3666
  // src/providers/utils/auto-retry-fetch.ts
3585
3667
  function getWaitDelay(options, retryAttemptNum) {
3586
3668
  const duration = options.baseDelay ?? 150;
@@ -3639,29 +3721,29 @@ var processGqlChain = (chain) => {
3639
3721
  const { contractParams, feeParams, predicateParams, scriptParams, txParams, gasCosts } = consensusParameters;
3640
3722
  return {
3641
3723
  name,
3642
- baseChainHeight: (0, import_math14.bn)(daHeight),
3724
+ baseChainHeight: (0, import_math15.bn)(daHeight),
3643
3725
  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),
3726
+ contractMaxSize: (0, import_math15.bn)(contractParams.contractMaxSize),
3727
+ maxInputs: (0, import_math15.bn)(txParams.maxInputs),
3728
+ maxOutputs: (0, import_math15.bn)(txParams.maxOutputs),
3729
+ maxWitnesses: (0, import_math15.bn)(txParams.maxWitnesses),
3730
+ maxGasPerTx: (0, import_math15.bn)(txParams.maxGasPerTx),
3731
+ maxScriptLength: (0, import_math15.bn)(scriptParams.maxScriptLength),
3732
+ maxScriptDataLength: (0, import_math15.bn)(scriptParams.maxScriptDataLength),
3733
+ maxStorageSlots: (0, import_math15.bn)(contractParams.maxStorageSlots),
3734
+ maxPredicateLength: (0, import_math15.bn)(predicateParams.maxPredicateLength),
3735
+ maxPredicateDataLength: (0, import_math15.bn)(predicateParams.maxPredicateDataLength),
3736
+ maxGasPerPredicate: (0, import_math15.bn)(predicateParams.maxGasPerPredicate),
3737
+ gasPriceFactor: (0, import_math15.bn)(feeParams.gasPriceFactor),
3738
+ gasPerByte: (0, import_math15.bn)(feeParams.gasPerByte),
3739
+ maxMessageDataLength: (0, import_math15.bn)(predicateParams.maxMessageDataLength),
3740
+ chainId: (0, import_math15.bn)(consensusParameters.chainId),
3659
3741
  gasCosts
3660
3742
  },
3661
3743
  gasCosts,
3662
3744
  latestBlock: {
3663
3745
  id: latestBlock.id,
3664
- height: (0, import_math14.bn)(latestBlock.header.height),
3746
+ height: (0, import_math15.bn)(latestBlock.header.height),
3665
3747
  time: latestBlock.header.time,
3666
3748
  transactions: latestBlock.transactions.map((i) => ({
3667
3749
  id: i.id
@@ -3731,8 +3813,8 @@ var _Provider = class {
3731
3813
  getChain() {
3732
3814
  const chain = _Provider.chainInfoCache[this.url];
3733
3815
  if (!chain) {
3734
- throw new import_errors13.FuelError(
3735
- import_errors13.ErrorCode.CHAIN_INFO_CACHE_EMPTY,
3816
+ throw new import_errors14.FuelError(
3817
+ import_errors14.ErrorCode.CHAIN_INFO_CACHE_EMPTY,
3736
3818
  "Chain info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
3737
3819
  );
3738
3820
  }
@@ -3744,8 +3826,8 @@ var _Provider = class {
3744
3826
  getNode() {
3745
3827
  const node = _Provider.nodeInfoCache[this.url];
3746
3828
  if (!node) {
3747
- throw new import_errors13.FuelError(
3748
- import_errors13.ErrorCode.NODE_INFO_CACHE_EMPTY,
3829
+ throw new import_errors14.FuelError(
3830
+ import_errors14.ErrorCode.NODE_INFO_CACHE_EMPTY,
3749
3831
  "Node info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
3750
3832
  );
3751
3833
  }
@@ -3792,8 +3874,8 @@ var _Provider = class {
3792
3874
  static ensureClientVersionIsSupported(nodeInfo) {
3793
3875
  const { isMajorSupported, isMinorSupported, supportedVersion } = (0, import_versions.checkFuelCoreVersionCompatibility)(nodeInfo.nodeVersion);
3794
3876
  if (!isMajorSupported || !isMinorSupported) {
3795
- throw new import_errors13.FuelError(
3796
- import_errors13.FuelError.CODES.UNSUPPORTED_FUEL_CLIENT_VERSION,
3877
+ throw new import_errors14.FuelError(
3878
+ import_errors14.FuelError.CODES.UNSUPPORTED_FUEL_CLIENT_VERSION,
3797
3879
  `Fuel client version: ${nodeInfo.nodeVersion}, Supported version: ${supportedVersion}`
3798
3880
  );
3799
3881
  }
@@ -3856,7 +3938,7 @@ var _Provider = class {
3856
3938
  */
3857
3939
  async getBlockNumber() {
3858
3940
  const { chain } = await this.operations.getChain();
3859
- return (0, import_math14.bn)(chain.latestBlock.header.height, 10);
3941
+ return (0, import_math15.bn)(chain.latestBlock.header.height, 10);
3860
3942
  }
3861
3943
  /**
3862
3944
  * Returns the chain information.
@@ -3866,9 +3948,9 @@ var _Provider = class {
3866
3948
  async fetchNode() {
3867
3949
  const { nodeInfo } = await this.operations.getNodeInfo();
3868
3950
  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),
3951
+ maxDepth: (0, import_math15.bn)(nodeInfo.maxDepth),
3952
+ maxTx: (0, import_math15.bn)(nodeInfo.maxTx),
3953
+ minGasPrice: (0, import_math15.bn)(nodeInfo.minGasPrice),
3872
3954
  nodeVersion: nodeInfo.nodeVersion,
3873
3955
  utxoValidation: nodeInfo.utxoValidation,
3874
3956
  vmBacktrace: nodeInfo.vmBacktrace,
@@ -3914,13 +3996,17 @@ var _Provider = class {
3914
3996
  if (estimateTxDependencies) {
3915
3997
  await this.estimateTxDependencies(transactionRequest);
3916
3998
  }
3917
- const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
3999
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
4000
+ let abis;
4001
+ if (transactionRequest.type === import_transactions18.TransactionType.Script) {
4002
+ abis = transactionRequest.abis;
4003
+ }
3918
4004
  if (awaitExecution) {
3919
4005
  const subscription = this.operations.submitAndAwait({ encodedTransaction });
3920
4006
  for await (const { submitAndAwait } of subscription) {
3921
4007
  if (submitAndAwait.type === "SqueezedOutStatus") {
3922
- throw new import_errors13.FuelError(
3923
- import_errors13.ErrorCode.TRANSACTION_SQUEEZED_OUT,
4008
+ throw new import_errors14.FuelError(
4009
+ import_errors14.ErrorCode.TRANSACTION_SQUEEZED_OUT,
3924
4010
  `Transaction Squeezed Out with reason: ${submitAndAwait.reason}`
3925
4011
  );
3926
4012
  }
@@ -3929,14 +4015,14 @@ var _Provider = class {
3929
4015
  }
3930
4016
  }
3931
4017
  const transactionId2 = transactionRequest.getTransactionId(this.getChainId());
3932
- const response = new TransactionResponse(transactionId2, this);
4018
+ const response = new TransactionResponse(transactionId2, this, abis);
3933
4019
  await response.fetch();
3934
4020
  return response;
3935
4021
  }
3936
4022
  const {
3937
4023
  submit: { id: transactionId }
3938
4024
  } = await this.operations.submit({ encodedTransaction });
3939
- return new TransactionResponse(transactionId, this);
4025
+ return new TransactionResponse(transactionId, this, abis);
3940
4026
  }
3941
4027
  /**
3942
4028
  * Executes a transaction without actually submitting it to the chain.
@@ -3953,7 +4039,7 @@ var _Provider = class {
3953
4039
  if (estimateTxDependencies) {
3954
4040
  return this.estimateTxDependencies(transactionRequest);
3955
4041
  }
3956
- const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
4042
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
3957
4043
  const { dryRun: gqlReceipts } = await this.operations.dryRun({
3958
4044
  encodedTransaction,
3959
4045
  utxoValidation: utxoValidation || false
@@ -3972,13 +4058,13 @@ var _Provider = class {
3972
4058
  async estimatePredicates(transactionRequest) {
3973
4059
  const shouldEstimatePredicates = Boolean(
3974
4060
  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()
4061
+ (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
4062
  )
3977
4063
  );
3978
4064
  if (!shouldEstimatePredicates) {
3979
4065
  return transactionRequest;
3980
4066
  }
3981
- const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
4067
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
3982
4068
  const response = await this.operations.estimatePredicates({
3983
4069
  encodedTransaction
3984
4070
  });
@@ -3987,7 +4073,7 @@ var _Provider = class {
3987
4073
  } = response;
3988
4074
  if (inputs) {
3989
4075
  inputs.forEach((input, index) => {
3990
- if ("predicateGasUsed" in input && (0, import_math14.bn)(input.predicateGasUsed).gt(0)) {
4076
+ if ("predicateGasUsed" in input && (0, import_math15.bn)(input.predicateGasUsed).gt(0)) {
3991
4077
  transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
3992
4078
  }
3993
4079
  });
@@ -4008,7 +4094,7 @@ var _Provider = class {
4008
4094
  * @returns A promise.
4009
4095
  */
4010
4096
  async estimateTxDependencies(transactionRequest) {
4011
- if (transactionRequest.type === import_transactions17.TransactionType.Create) {
4097
+ if (transactionRequest.type === import_transactions18.TransactionType.Create) {
4012
4098
  return {
4013
4099
  receipts: [],
4014
4100
  outputVariables: 0,
@@ -4021,7 +4107,7 @@ var _Provider = class {
4021
4107
  let outputVariables = 0;
4022
4108
  for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
4023
4109
  const { dryRun: gqlReceipts } = await this.operations.dryRun({
4024
- encodedTransaction: (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes()),
4110
+ encodedTransaction: (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes()),
4025
4111
  utxoValidation: false
4026
4112
  });
4027
4113
  receipts = gqlReceipts.map(processGqlReceipt);
@@ -4059,7 +4145,7 @@ var _Provider = class {
4059
4145
  if (estimateTxDependencies) {
4060
4146
  return this.estimateTxDependencies(transactionRequest);
4061
4147
  }
4062
- const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
4148
+ const encodedTransaction = (0, import_utils23.hexlify)(transactionRequest.toTransactionBytes());
4063
4149
  const { dryRun: gqlReceipts } = await this.operations.dryRun({
4064
4150
  encodedTransaction,
4065
4151
  utxoValidation: true
@@ -4093,14 +4179,14 @@ var _Provider = class {
4093
4179
  const txRequestClone = (0, import_ramda3.clone)(transactionRequestify(transactionRequestLike));
4094
4180
  const chainInfo = this.getChain();
4095
4181
  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;
4182
+ const gasPrice = (0, import_math15.max)(txRequestClone.gasPrice, minGasPrice);
4183
+ const isScriptTransaction = txRequestClone.type === import_transactions18.TransactionType.Script;
4098
4184
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
4099
4185
  const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
4100
4186
  txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
4101
4187
  if (estimatePredicates) {
4102
4188
  if (isScriptTransaction) {
4103
- txRequestClone.gasLimit = (0, import_math14.bn)(0);
4189
+ txRequestClone.gasLimit = (0, import_math15.bn)(0);
4104
4190
  }
4105
4191
  if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
4106
4192
  resourcesOwner.populateTransactionPredicateData(txRequestClone);
@@ -4116,8 +4202,8 @@ var _Provider = class {
4116
4202
  let missingContractIds = [];
4117
4203
  let outputVariables = 0;
4118
4204
  if (isScriptTransaction && estimateTxDependencies) {
4119
- txRequestClone.gasPrice = (0, import_math14.bn)(0);
4120
- txRequestClone.gasLimit = (0, import_math14.bn)(maxGasPerTx.sub(maxGas).toNumber() * 0.9);
4205
+ txRequestClone.gasPrice = (0, import_math15.bn)(0);
4206
+ txRequestClone.gasLimit = (0, import_math15.bn)(maxGasPerTx.sub(maxGas).toNumber() * 0.9);
4121
4207
  const result = await this.estimateTxDependencies(txRequestClone);
4122
4208
  receipts = result.receipts;
4123
4209
  outputVariables = result.outputVariables;
@@ -4173,17 +4259,17 @@ var _Provider = class {
4173
4259
  const result = await this.operations.getCoins({
4174
4260
  first: 10,
4175
4261
  ...paginationArgs,
4176
- filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils22.hexlify)(assetId) }
4262
+ filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils23.hexlify)(assetId) }
4177
4263
  });
4178
4264
  const coins = result.coins.edges.map((edge) => edge.node);
4179
4265
  return coins.map((coin) => ({
4180
4266
  id: coin.utxoId,
4181
4267
  assetId: coin.assetId,
4182
- amount: (0, import_math14.bn)(coin.amount),
4268
+ amount: (0, import_math15.bn)(coin.amount),
4183
4269
  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)
4270
+ maturity: (0, import_math15.bn)(coin.maturity).toNumber(),
4271
+ blockCreated: (0, import_math15.bn)(coin.blockCreated),
4272
+ txCreatedIdx: (0, import_math15.bn)(coin.txCreatedIdx)
4187
4273
  }));
4188
4274
  }
4189
4275
  /**
@@ -4197,19 +4283,19 @@ var _Provider = class {
4197
4283
  async getResourcesToSpend(owner, quantities, excludedIds) {
4198
4284
  const ownerAddress = import_address3.Address.fromAddressOrString(owner);
4199
4285
  const excludeInput = {
4200
- messages: excludedIds?.messages?.map((nonce) => (0, import_utils22.hexlify)(nonce)) || [],
4201
- utxos: excludedIds?.utxos?.map((id) => (0, import_utils22.hexlify)(id)) || []
4286
+ messages: excludedIds?.messages?.map((nonce) => (0, import_utils23.hexlify)(nonce)) || [],
4287
+ utxos: excludedIds?.utxos?.map((id) => (0, import_utils23.hexlify)(id)) || []
4202
4288
  };
4203
4289
  if (this.cache) {
4204
4290
  const uniqueUtxos = new Set(
4205
- excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0, import_utils22.hexlify)(id)))
4291
+ excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0, import_utils23.hexlify)(id)))
4206
4292
  );
4207
4293
  excludeInput.utxos = Array.from(uniqueUtxos);
4208
4294
  }
4209
4295
  const coinsQuery = {
4210
4296
  owner: ownerAddress.toB256(),
4211
4297
  queryPerAsset: quantities.map(coinQuantityfy).map(({ assetId, amount, max: maxPerAsset }) => ({
4212
- assetId: (0, import_utils22.hexlify)(assetId),
4298
+ assetId: (0, import_utils23.hexlify)(assetId),
4213
4299
  amount: amount.toString(10),
4214
4300
  max: maxPerAsset ? maxPerAsset.toString(10) : void 0
4215
4301
  })),
@@ -4220,9 +4306,9 @@ var _Provider = class {
4220
4306
  switch (coin.__typename) {
4221
4307
  case "MessageCoin":
4222
4308
  return {
4223
- amount: (0, import_math14.bn)(coin.amount),
4309
+ amount: (0, import_math15.bn)(coin.amount),
4224
4310
  assetId: coin.assetId,
4225
- daHeight: (0, import_math14.bn)(coin.daHeight),
4311
+ daHeight: (0, import_math15.bn)(coin.daHeight),
4226
4312
  sender: import_address3.Address.fromAddressOrString(coin.sender),
4227
4313
  recipient: import_address3.Address.fromAddressOrString(coin.recipient),
4228
4314
  nonce: coin.nonce
@@ -4230,12 +4316,12 @@ var _Provider = class {
4230
4316
  case "Coin":
4231
4317
  return {
4232
4318
  id: coin.utxoId,
4233
- amount: (0, import_math14.bn)(coin.amount),
4319
+ amount: (0, import_math15.bn)(coin.amount),
4234
4320
  assetId: coin.assetId,
4235
4321
  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)
4322
+ maturity: (0, import_math15.bn)(coin.maturity).toNumber(),
4323
+ blockCreated: (0, import_math15.bn)(coin.blockCreated),
4324
+ txCreatedIdx: (0, import_math15.bn)(coin.txCreatedIdx)
4239
4325
  };
4240
4326
  default:
4241
4327
  return null;
@@ -4252,13 +4338,13 @@ var _Provider = class {
4252
4338
  async getBlock(idOrHeight) {
4253
4339
  let variables;
4254
4340
  if (typeof idOrHeight === "number") {
4255
- variables = { height: (0, import_math14.bn)(idOrHeight).toString(10) };
4341
+ variables = { height: (0, import_math15.bn)(idOrHeight).toString(10) };
4256
4342
  } else if (idOrHeight === "latest") {
4257
4343
  variables = { height: (await this.getBlockNumber()).toString(10) };
4258
4344
  } else if (idOrHeight.length === 66) {
4259
4345
  variables = { blockId: idOrHeight };
4260
4346
  } else {
4261
- variables = { blockId: (0, import_math14.bn)(idOrHeight).toString(10) };
4347
+ variables = { blockId: (0, import_math15.bn)(idOrHeight).toString(10) };
4262
4348
  }
4263
4349
  const { block } = await this.operations.getBlock(variables);
4264
4350
  if (!block) {
@@ -4266,7 +4352,7 @@ var _Provider = class {
4266
4352
  }
4267
4353
  return {
4268
4354
  id: block.id,
4269
- height: (0, import_math14.bn)(block.header.height),
4355
+ height: (0, import_math15.bn)(block.header.height),
4270
4356
  time: block.header.time,
4271
4357
  transactionIds: block.transactions.map((tx) => tx.id)
4272
4358
  };
@@ -4281,7 +4367,7 @@ var _Provider = class {
4281
4367
  const { blocks: fetchedData } = await this.operations.getBlocks(params);
4282
4368
  const blocks = fetchedData.edges.map(({ node: block }) => ({
4283
4369
  id: block.id,
4284
- height: (0, import_math14.bn)(block.header.height),
4370
+ height: (0, import_math15.bn)(block.header.height),
4285
4371
  time: block.header.time,
4286
4372
  transactionIds: block.transactions.map((tx) => tx.id)
4287
4373
  }));
@@ -4296,7 +4382,7 @@ var _Provider = class {
4296
4382
  async getBlockWithTransactions(idOrHeight) {
4297
4383
  let variables;
4298
4384
  if (typeof idOrHeight === "number") {
4299
- variables = { blockHeight: (0, import_math14.bn)(idOrHeight).toString(10) };
4385
+ variables = { blockHeight: (0, import_math15.bn)(idOrHeight).toString(10) };
4300
4386
  } else if (idOrHeight === "latest") {
4301
4387
  variables = { blockHeight: (await this.getBlockNumber()).toString() };
4302
4388
  } else {
@@ -4308,11 +4394,11 @@ var _Provider = class {
4308
4394
  }
4309
4395
  return {
4310
4396
  id: block.id,
4311
- height: (0, import_math14.bn)(block.header.height, 10),
4397
+ height: (0, import_math15.bn)(block.header.height, 10),
4312
4398
  time: block.header.time,
4313
4399
  transactionIds: block.transactions.map((tx) => tx.id),
4314
4400
  transactions: block.transactions.map(
4315
- (tx) => new import_transactions17.TransactionCoder().decode((0, import_utils22.arrayify)(tx.rawPayload), 0)?.[0]
4401
+ (tx) => new import_transactions18.TransactionCoder().decode((0, import_utils23.arrayify)(tx.rawPayload), 0)?.[0]
4316
4402
  )
4317
4403
  };
4318
4404
  }
@@ -4327,8 +4413,8 @@ var _Provider = class {
4327
4413
  if (!transaction) {
4328
4414
  return null;
4329
4415
  }
4330
- return new import_transactions17.TransactionCoder().decode(
4331
- (0, import_utils22.arrayify)(transaction.rawPayload),
4416
+ return new import_transactions18.TransactionCoder().decode(
4417
+ (0, import_utils23.arrayify)(transaction.rawPayload),
4332
4418
  0
4333
4419
  )?.[0];
4334
4420
  }
@@ -4355,9 +4441,9 @@ var _Provider = class {
4355
4441
  async getContractBalance(contractId, assetId) {
4356
4442
  const { contractBalance } = await this.operations.getContractBalance({
4357
4443
  contract: import_address3.Address.fromAddressOrString(contractId).toB256(),
4358
- asset: (0, import_utils22.hexlify)(assetId)
4444
+ asset: (0, import_utils23.hexlify)(assetId)
4359
4445
  });
4360
- return (0, import_math14.bn)(contractBalance.amount, 10);
4446
+ return (0, import_math15.bn)(contractBalance.amount, 10);
4361
4447
  }
4362
4448
  /**
4363
4449
  * Returns the balance for the given owner for the given asset ID.
@@ -4369,9 +4455,9 @@ var _Provider = class {
4369
4455
  async getBalance(owner, assetId) {
4370
4456
  const { balance } = await this.operations.getBalance({
4371
4457
  owner: import_address3.Address.fromAddressOrString(owner).toB256(),
4372
- assetId: (0, import_utils22.hexlify)(assetId)
4458
+ assetId: (0, import_utils23.hexlify)(assetId)
4373
4459
  });
4374
- return (0, import_math14.bn)(balance.amount, 10);
4460
+ return (0, import_math15.bn)(balance.amount, 10);
4375
4461
  }
4376
4462
  /**
4377
4463
  * Returns balances for the given owner.
@@ -4389,7 +4475,7 @@ var _Provider = class {
4389
4475
  const balances = result.balances.edges.map((edge) => edge.node);
4390
4476
  return balances.map((balance) => ({
4391
4477
  assetId: balance.assetId,
4392
- amount: (0, import_math14.bn)(balance.amount)
4478
+ amount: (0, import_math15.bn)(balance.amount)
4393
4479
  }));
4394
4480
  }
4395
4481
  /**
@@ -4407,19 +4493,19 @@ var _Provider = class {
4407
4493
  });
4408
4494
  const messages = result.messages.edges.map((edge) => edge.node);
4409
4495
  return messages.map((message) => ({
4410
- messageId: import_transactions17.InputMessageCoder.getMessageId({
4496
+ messageId: import_transactions18.InputMessageCoder.getMessageId({
4411
4497
  sender: message.sender,
4412
4498
  recipient: message.recipient,
4413
4499
  nonce: message.nonce,
4414
- amount: (0, import_math14.bn)(message.amount),
4500
+ amount: (0, import_math15.bn)(message.amount),
4415
4501
  data: message.data
4416
4502
  }),
4417
4503
  sender: import_address3.Address.fromAddressOrString(message.sender),
4418
4504
  recipient: import_address3.Address.fromAddressOrString(message.recipient),
4419
4505
  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)
4506
+ amount: (0, import_math15.bn)(message.amount),
4507
+ data: import_transactions18.InputMessageCoder.decodeData(message.data),
4508
+ daHeight: (0, import_math15.bn)(message.daHeight)
4423
4509
  }));
4424
4510
  }
4425
4511
  /**
@@ -4437,8 +4523,8 @@ var _Provider = class {
4437
4523
  nonce
4438
4524
  };
4439
4525
  if (commitBlockId && commitBlockHeight) {
4440
- throw new import_errors13.FuelError(
4441
- import_errors13.ErrorCode.INVALID_INPUT_PARAMETERS,
4526
+ throw new import_errors14.FuelError(
4527
+ import_errors14.ErrorCode.INVALID_INPUT_PARAMETERS,
4442
4528
  "commitBlockId and commitBlockHeight cannot be used together"
4443
4529
  );
4444
4530
  }
@@ -4472,41 +4558,41 @@ var _Provider = class {
4472
4558
  } = result.messageProof;
4473
4559
  return {
4474
4560
  messageProof: {
4475
- proofIndex: (0, import_math14.bn)(messageProof.proofIndex),
4561
+ proofIndex: (0, import_math15.bn)(messageProof.proofIndex),
4476
4562
  proofSet: messageProof.proofSet
4477
4563
  },
4478
4564
  blockProof: {
4479
- proofIndex: (0, import_math14.bn)(blockProof.proofIndex),
4565
+ proofIndex: (0, import_math15.bn)(blockProof.proofIndex),
4480
4566
  proofSet: blockProof.proofSet
4481
4567
  },
4482
4568
  messageBlockHeader: {
4483
4569
  id: messageBlockHeader.id,
4484
- daHeight: (0, import_math14.bn)(messageBlockHeader.daHeight),
4485
- transactionsCount: (0, import_math14.bn)(messageBlockHeader.transactionsCount),
4570
+ daHeight: (0, import_math15.bn)(messageBlockHeader.daHeight),
4571
+ transactionsCount: (0, import_math15.bn)(messageBlockHeader.transactionsCount),
4486
4572
  transactionsRoot: messageBlockHeader.transactionsRoot,
4487
- height: (0, import_math14.bn)(messageBlockHeader.height),
4573
+ height: (0, import_math15.bn)(messageBlockHeader.height),
4488
4574
  prevRoot: messageBlockHeader.prevRoot,
4489
4575
  time: messageBlockHeader.time,
4490
4576
  applicationHash: messageBlockHeader.applicationHash,
4491
4577
  messageReceiptRoot: messageBlockHeader.messageReceiptRoot,
4492
- messageReceiptCount: (0, import_math14.bn)(messageBlockHeader.messageReceiptCount)
4578
+ messageReceiptCount: (0, import_math15.bn)(messageBlockHeader.messageReceiptCount)
4493
4579
  },
4494
4580
  commitBlockHeader: {
4495
4581
  id: commitBlockHeader.id,
4496
- daHeight: (0, import_math14.bn)(commitBlockHeader.daHeight),
4497
- transactionsCount: (0, import_math14.bn)(commitBlockHeader.transactionsCount),
4582
+ daHeight: (0, import_math15.bn)(commitBlockHeader.daHeight),
4583
+ transactionsCount: (0, import_math15.bn)(commitBlockHeader.transactionsCount),
4498
4584
  transactionsRoot: commitBlockHeader.transactionsRoot,
4499
- height: (0, import_math14.bn)(commitBlockHeader.height),
4585
+ height: (0, import_math15.bn)(commitBlockHeader.height),
4500
4586
  prevRoot: commitBlockHeader.prevRoot,
4501
4587
  time: commitBlockHeader.time,
4502
4588
  applicationHash: commitBlockHeader.applicationHash,
4503
4589
  messageReceiptRoot: commitBlockHeader.messageReceiptRoot,
4504
- messageReceiptCount: (0, import_math14.bn)(commitBlockHeader.messageReceiptCount)
4590
+ messageReceiptCount: (0, import_math15.bn)(commitBlockHeader.messageReceiptCount)
4505
4591
  },
4506
4592
  sender: import_address3.Address.fromAddressOrString(sender),
4507
4593
  recipient: import_address3.Address.fromAddressOrString(recipient),
4508
4594
  nonce,
4509
- amount: (0, import_math14.bn)(amount),
4595
+ amount: (0, import_math15.bn)(amount),
4510
4596
  data
4511
4597
  };
4512
4598
  }
@@ -4529,10 +4615,10 @@ var _Provider = class {
4529
4615
  */
4530
4616
  async produceBlocks(amount, startTime) {
4531
4617
  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
4618
+ blocksToProduce: (0, import_math15.bn)(amount).toString(10),
4619
+ startTimestamp: startTime ? import_utils23.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
4534
4620
  });
4535
- return (0, import_math14.bn)(latestBlockHeight);
4621
+ return (0, import_math15.bn)(latestBlockHeight);
4536
4622
  }
4537
4623
  // eslint-disable-next-line @typescript-eslint/require-await
4538
4624
  async getTransactionResponse(transactionId) {
@@ -4546,7 +4632,7 @@ cacheInputs_fn = function(inputs) {
4546
4632
  return;
4547
4633
  }
4548
4634
  inputs.forEach((input) => {
4549
- if (input.type === import_transactions17.InputType.Coin) {
4635
+ if (input.type === import_transactions18.InputType.Coin) {
4550
4636
  this.cache?.set(input.id);
4551
4637
  }
4552
4638
  });
@@ -4555,23 +4641,23 @@ __publicField(Provider, "chainInfoCache", {});
4555
4641
  __publicField(Provider, "nodeInfoCache", {});
4556
4642
 
4557
4643
  // 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");
4644
+ var import_errors15 = require("@fuel-ts/errors");
4645
+ var import_math16 = require("@fuel-ts/math");
4646
+ var import_transactions19 = require("@fuel-ts/transactions");
4647
+ var import_utils26 = require("@fuel-ts/utils");
4562
4648
  async function getTransactionSummary(params) {
4563
4649
  const { id, provider, abiMap } = params;
4564
4650
  const { transaction: gqlTransaction } = await provider.operations.getTransactionWithReceipts({
4565
4651
  transactionId: id
4566
4652
  });
4567
4653
  if (!gqlTransaction) {
4568
- throw new import_errors14.FuelError(
4569
- import_errors14.ErrorCode.TRANSACTION_NOT_FOUND,
4654
+ throw new import_errors15.FuelError(
4655
+ import_errors15.ErrorCode.TRANSACTION_NOT_FOUND,
4570
4656
  `Transaction not found for given id: ${id}.`
4571
4657
  );
4572
4658
  }
4573
- const [decodedTransaction] = new import_transactions18.TransactionCoder().decode(
4574
- (0, import_utils25.arrayify)(gqlTransaction.rawPayload),
4659
+ const [decodedTransaction] = new import_transactions19.TransactionCoder().decode(
4660
+ (0, import_utils26.arrayify)(gqlTransaction.rawPayload),
4575
4661
  0
4576
4662
  );
4577
4663
  const receipts = gqlTransaction.receipts?.map(processGqlReceipt) || [];
@@ -4582,10 +4668,10 @@ async function getTransactionSummary(params) {
4582
4668
  id: gqlTransaction.id,
4583
4669
  receipts,
4584
4670
  transaction: decodedTransaction,
4585
- transactionBytes: (0, import_utils25.arrayify)(gqlTransaction.rawPayload),
4671
+ transactionBytes: (0, import_utils26.arrayify)(gqlTransaction.rawPayload),
4586
4672
  gqlTransactionStatus: gqlTransaction.status,
4587
- gasPerByte: (0, import_math15.bn)(gasPerByte),
4588
- gasPriceFactor: (0, import_math15.bn)(gasPriceFactor),
4673
+ gasPerByte: (0, import_math16.bn)(gasPerByte),
4674
+ gasPriceFactor: (0, import_math16.bn)(gasPriceFactor),
4589
4675
  abiMap,
4590
4676
  maxInputs,
4591
4677
  gasCosts
@@ -4624,13 +4710,13 @@ async function getTransactionsSummaries(params) {
4624
4710
  const transactions = edges.map((edge) => {
4625
4711
  const { node: gqlTransaction } = edge;
4626
4712
  const { id, rawPayload, receipts: gqlReceipts, status } = gqlTransaction;
4627
- const [decodedTransaction] = new import_transactions18.TransactionCoder().decode((0, import_utils25.arrayify)(rawPayload), 0);
4713
+ const [decodedTransaction] = new import_transactions19.TransactionCoder().decode((0, import_utils26.arrayify)(rawPayload), 0);
4628
4714
  const receipts = gqlReceipts?.map(processGqlReceipt) || [];
4629
4715
  const transactionSummary = assembleTransactionSummary({
4630
4716
  id,
4631
4717
  receipts,
4632
4718
  transaction: decodedTransaction,
4633
- transactionBytes: (0, import_utils25.arrayify)(rawPayload),
4719
+ transactionBytes: (0, import_utils26.arrayify)(rawPayload),
4634
4720
  gqlTransactionStatus: status,
4635
4721
  abiMap,
4636
4722
  gasPerByte,
@@ -4773,17 +4859,17 @@ var assets = [
4773
4859
 
4774
4860
  // src/utils/formatTransferToContractScriptData.ts
4775
4861
  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");
4862
+ var import_math17 = require("@fuel-ts/math");
4863
+ var import_utils27 = require("@fuel-ts/utils");
4778
4864
  var asm = __toESM(require("@fuels/vm-asm"));
4779
4865
  var formatTransferToContractScriptData = (params) => {
4780
4866
  const { assetId, amountToTransfer, hexlifiedContractId } = params;
4781
4867
  const numberCoder = new import_abi_coder4.BigNumberCoder("u64");
4782
- const encoded = numberCoder.encode(new import_math16.BN(amountToTransfer).toNumber());
4868
+ const encoded = numberCoder.encode(new import_math17.BN(amountToTransfer).toNumber());
4783
4869
  const scriptData = Uint8Array.from([
4784
- ...(0, import_utils26.arrayify)(hexlifiedContractId),
4870
+ ...(0, import_utils27.arrayify)(hexlifiedContractId),
4785
4871
  ...encoded,
4786
- ...(0, import_utils26.arrayify)(assetId)
4872
+ ...(0, import_utils27.arrayify)(assetId)
4787
4873
  ]);
4788
4874
  return scriptData;
4789
4875
  };
@@ -4839,7 +4925,7 @@ var Account = class extends import_interfaces.AbstractAccount {
4839
4925
  */
4840
4926
  get provider() {
4841
4927
  if (!this._provider) {
4842
- throw new import_errors15.FuelError(import_errors15.ErrorCode.MISSING_PROVIDER, "Provider not set");
4928
+ throw new import_errors16.FuelError(import_errors16.ErrorCode.MISSING_PROVIDER, "Provider not set");
4843
4929
  }
4844
4930
  return this._provider;
4845
4931
  }
@@ -4891,8 +4977,8 @@ var Account = class extends import_interfaces.AbstractAccount {
4891
4977
  if (!hasNextPage) {
4892
4978
  break;
4893
4979
  }
4894
- throw new import_errors15.FuelError(
4895
- import_errors15.ErrorCode.NOT_SUPPORTED,
4980
+ throw new import_errors16.FuelError(
4981
+ import_errors16.ErrorCode.NOT_SUPPORTED,
4896
4982
  `Wallets containing more than ${pageSize} coins exceed the current supported limit.`
4897
4983
  );
4898
4984
  }
@@ -4917,8 +5003,8 @@ var Account = class extends import_interfaces.AbstractAccount {
4917
5003
  if (!hasNextPage) {
4918
5004
  break;
4919
5005
  }
4920
- throw new import_errors15.FuelError(
4921
- import_errors15.ErrorCode.NOT_SUPPORTED,
5006
+ throw new import_errors16.FuelError(
5007
+ import_errors16.ErrorCode.NOT_SUPPORTED,
4922
5008
  `Wallets containing more than ${pageSize} messages exceed the current supported limit.`
4923
5009
  );
4924
5010
  }
@@ -4930,7 +5016,7 @@ var Account = class extends import_interfaces.AbstractAccount {
4930
5016
  * @param assetId - The asset ID to check the balance for.
4931
5017
  * @returns A promise that resolves to the balance amount.
4932
5018
  */
4933
- async getBalance(assetId = import_configs11.BaseAssetId) {
5019
+ async getBalance(assetId = import_configs12.BaseAssetId) {
4934
5020
  const amount = await this.provider.getBalance(this.address, assetId);
4935
5021
  return amount;
4936
5022
  }
@@ -4953,8 +5039,8 @@ var Account = class extends import_interfaces.AbstractAccount {
4953
5039
  if (!hasNextPage) {
4954
5040
  break;
4955
5041
  }
4956
- throw new import_errors15.FuelError(
4957
- import_errors15.ErrorCode.NOT_SUPPORTED,
5042
+ throw new import_errors16.FuelError(
5043
+ import_errors16.ErrorCode.NOT_SUPPORTED,
4958
5044
  `Wallets containing more than ${pageSize} balances exceed the current supported limit.`
4959
5045
  );
4960
5046
  }
@@ -4970,15 +5056,15 @@ var Account = class extends import_interfaces.AbstractAccount {
4970
5056
  */
4971
5057
  async fund(request, coinQuantities, fee) {
4972
5058
  const updatedQuantities = addAmountToAsset({
4973
- amount: (0, import_math17.bn)(fee),
4974
- assetId: import_configs11.BaseAssetId,
5059
+ amount: (0, import_math18.bn)(fee),
5060
+ assetId: import_configs12.BaseAssetId,
4975
5061
  coinQuantities
4976
5062
  });
4977
5063
  const quantitiesDict = {};
4978
5064
  updatedQuantities.forEach(({ amount, assetId }) => {
4979
5065
  quantitiesDict[assetId] = {
4980
5066
  required: amount,
4981
- owned: (0, import_math17.bn)(0)
5067
+ owned: (0, import_math18.bn)(0)
4982
5068
  };
4983
5069
  });
4984
5070
  const cachedUtxos = [];
@@ -4991,12 +5077,12 @@ var Account = class extends import_interfaces.AbstractAccount {
4991
5077
  if (isCoin2) {
4992
5078
  const assetId = String(input.assetId);
4993
5079
  if (input.owner === owner && quantitiesDict[assetId]) {
4994
- const amount = (0, import_math17.bn)(input.amount);
5080
+ const amount = (0, import_math18.bn)(input.amount);
4995
5081
  quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
4996
5082
  cachedUtxos.push(input.id);
4997
5083
  }
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);
5084
+ } else if (input.recipient === owner && input.amount && quantitiesDict[import_configs12.BaseAssetId]) {
5085
+ quantitiesDict[import_configs12.BaseAssetId].owned = quantitiesDict[import_configs12.BaseAssetId].owned.add(input.amount);
5000
5086
  cachedMessages.push(input.nonce);
5001
5087
  }
5002
5088
  }
@@ -5028,7 +5114,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5028
5114
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
5029
5115
  * @returns A promise that resolves to the prepared transaction request.
5030
5116
  */
5031
- async createTransfer(destination, amount, assetId = import_configs11.BaseAssetId, txParams = {}) {
5117
+ async createTransfer(destination, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
5032
5118
  const { minGasPrice } = this.provider.getGasConfig();
5033
5119
  const params = { gasPrice: minGasPrice, ...txParams };
5034
5120
  const request = new ScriptTransactionRequest(params);
@@ -5037,8 +5123,8 @@ var Account = class extends import_interfaces.AbstractAccount {
5037
5123
  estimateTxDependencies: true,
5038
5124
  resourcesOwner: this
5039
5125
  });
5040
- request.gasPrice = (0, import_math17.bn)(txParams.gasPrice ?? minGasPrice);
5041
- request.gasLimit = (0, import_math17.bn)(txParams.gasLimit ?? gasUsed);
5126
+ request.gasPrice = (0, import_math18.bn)(txParams.gasPrice ?? minGasPrice);
5127
+ request.gasLimit = (0, import_math18.bn)(txParams.gasLimit ?? gasUsed);
5042
5128
  this.validateGas({
5043
5129
  gasUsed,
5044
5130
  gasPrice: request.gasPrice,
@@ -5058,10 +5144,10 @@ var Account = class extends import_interfaces.AbstractAccount {
5058
5144
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
5059
5145
  * @returns A promise that resolves to the transaction response.
5060
5146
  */
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,
5147
+ async transfer(destination, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
5148
+ if ((0, import_math18.bn)(amount).lte(0)) {
5149
+ throw new import_errors16.FuelError(
5150
+ import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
5065
5151
  "Transfer amount must be a positive number."
5066
5152
  );
5067
5153
  }
@@ -5077,10 +5163,10 @@ var Account = class extends import_interfaces.AbstractAccount {
5077
5163
  * @param txParams - The optional transaction parameters.
5078
5164
  * @returns A promise that resolves to the transaction response.
5079
5165
  */
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,
5166
+ async transferToContract(contractId, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
5167
+ if ((0, import_math18.bn)(amount).lte(0)) {
5168
+ throw new import_errors16.FuelError(
5169
+ import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
5084
5170
  "Transfer amount must be a positive number."
5085
5171
  );
5086
5172
  }
@@ -5089,7 +5175,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5089
5175
  const params = { gasPrice: minGasPrice, ...txParams };
5090
5176
  const { script, scriptData } = await assembleTransferToContractScript({
5091
5177
  hexlifiedContractId: contractAddress.toB256(),
5092
- amountToTransfer: (0, import_math17.bn)(amount),
5178
+ amountToTransfer: (0, import_math18.bn)(amount),
5093
5179
  assetId
5094
5180
  });
5095
5181
  const request = new ScriptTransactionRequest({
@@ -5100,9 +5186,9 @@ var Account = class extends import_interfaces.AbstractAccount {
5100
5186
  request.addContractInputAndOutput(contractAddress);
5101
5187
  const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
5102
5188
  request,
5103
- [{ amount: (0, import_math17.bn)(amount), assetId: String(assetId) }]
5189
+ [{ amount: (0, import_math18.bn)(amount), assetId: String(assetId) }]
5104
5190
  );
5105
- request.gasLimit = (0, import_math17.bn)(params.gasLimit ?? gasUsed);
5191
+ request.gasLimit = (0, import_math18.bn)(params.gasLimit ?? gasUsed);
5106
5192
  this.validateGas({
5107
5193
  gasUsed,
5108
5194
  gasPrice: request.gasPrice,
@@ -5123,25 +5209,25 @@ var Account = class extends import_interfaces.AbstractAccount {
5123
5209
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
5124
5210
  const { minGasPrice } = this.provider.getGasConfig();
5125
5211
  const recipientAddress = import_address4.Address.fromAddressOrString(recipient);
5126
- const recipientDataArray = (0, import_utils27.arrayify)(
5212
+ const recipientDataArray = (0, import_utils28.arrayify)(
5127
5213
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
5128
5214
  );
5129
- const amountDataArray = (0, import_utils27.arrayify)(
5130
- "0x".concat((0, import_math17.bn)(amount).toHex().substring(2).padStart(16, "0"))
5215
+ const amountDataArray = (0, import_utils28.arrayify)(
5216
+ "0x".concat((0, import_math18.bn)(amount).toHex().substring(2).padStart(16, "0"))
5131
5217
  );
5132
5218
  const script = new Uint8Array([
5133
- ...(0, import_utils27.arrayify)(withdrawScript.bytes),
5219
+ ...(0, import_utils28.arrayify)(withdrawScript.bytes),
5134
5220
  ...recipientDataArray,
5135
5221
  ...amountDataArray
5136
5222
  ]);
5137
5223
  const params = { script, gasPrice: minGasPrice, ...txParams };
5138
5224
  const request = new ScriptTransactionRequest(params);
5139
- const forwardingQuantities = [{ amount: (0, import_math17.bn)(amount), assetId: import_configs11.BaseAssetId }];
5225
+ const forwardingQuantities = [{ amount: (0, import_math18.bn)(amount), assetId: import_configs12.BaseAssetId }];
5140
5226
  const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
5141
5227
  request,
5142
5228
  forwardingQuantities
5143
5229
  );
5144
- request.gasLimit = (0, import_math17.bn)(params.gasLimit ?? gasUsed);
5230
+ request.gasLimit = (0, import_math18.bn)(params.gasLimit ?? gasUsed);
5145
5231
  this.validateGas({
5146
5232
  gasUsed,
5147
5233
  gasPrice: request.gasPrice,
@@ -5153,7 +5239,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5153
5239
  }
5154
5240
  async signMessage(message) {
5155
5241
  if (!this._connector) {
5156
- throw new import_errors15.FuelError(import_errors15.ErrorCode.MISSING_CONNECTOR, "A connector is required to sign messages.");
5242
+ throw new import_errors16.FuelError(import_errors16.ErrorCode.MISSING_CONNECTOR, "A connector is required to sign messages.");
5157
5243
  }
5158
5244
  return this._connector.signMessage(this.address.toString(), message);
5159
5245
  }
@@ -5165,8 +5251,8 @@ var Account = class extends import_interfaces.AbstractAccount {
5165
5251
  */
5166
5252
  async signTransaction(transactionRequestLike) {
5167
5253
  if (!this._connector) {
5168
- throw new import_errors15.FuelError(
5169
- import_errors15.ErrorCode.MISSING_CONNECTOR,
5254
+ throw new import_errors16.FuelError(
5255
+ import_errors16.ErrorCode.MISSING_CONNECTOR,
5170
5256
  "A connector is required to sign transactions."
5171
5257
  );
5172
5258
  }
@@ -5213,14 +5299,14 @@ var Account = class extends import_interfaces.AbstractAccount {
5213
5299
  minGasPrice
5214
5300
  }) {
5215
5301
  if (minGasPrice.gt(gasPrice)) {
5216
- throw new import_errors15.FuelError(
5217
- import_errors15.ErrorCode.GAS_PRICE_TOO_LOW,
5302
+ throw new import_errors16.FuelError(
5303
+ import_errors16.ErrorCode.GAS_PRICE_TOO_LOW,
5218
5304
  `Gas price '${gasPrice}' is lower than the required: '${minGasPrice}'.`
5219
5305
  );
5220
5306
  }
5221
5307
  if (gasUsed.gt(gasLimit)) {
5222
- throw new import_errors15.FuelError(
5223
- import_errors15.ErrorCode.GAS_LIMIT_TOO_LOW,
5308
+ throw new import_errors16.FuelError(
5309
+ import_errors16.ErrorCode.GAS_LIMIT_TOO_LOW,
5224
5310
  `Gas limit '${gasLimit}' is lower than the required: '${gasUsed}'.`
5225
5311
  );
5226
5312
  }
@@ -5229,14 +5315,14 @@ var Account = class extends import_interfaces.AbstractAccount {
5229
5315
 
5230
5316
  // src/wallet/base-wallet-unlocked.ts
5231
5317
  var import_hasher3 = require("@fuel-ts/hasher");
5232
- var import_utils30 = require("@fuel-ts/utils");
5318
+ var import_utils31 = require("@fuel-ts/utils");
5233
5319
 
5234
5320
  // src/signer/signer.ts
5235
5321
  var import_address5 = require("@fuel-ts/address");
5236
5322
  var import_crypto = require("@fuel-ts/crypto");
5237
5323
  var import_hasher2 = require("@fuel-ts/hasher");
5238
- var import_math18 = require("@fuel-ts/math");
5239
- var import_utils28 = require("@fuel-ts/utils");
5324
+ var import_math19 = require("@fuel-ts/math");
5325
+ var import_utils29 = require("@fuel-ts/utils");
5240
5326
  var import_secp256k1 = require("@noble/curves/secp256k1");
5241
5327
  var Signer = class {
5242
5328
  address;
@@ -5255,10 +5341,10 @@ var Signer = class {
5255
5341
  privateKey = `0x${privateKey}`;
5256
5342
  }
5257
5343
  }
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));
5344
+ const privateKeyBytes = (0, import_math19.toBytes)(privateKey, 32);
5345
+ this.privateKey = (0, import_utils29.hexlify)(privateKeyBytes);
5346
+ this.publicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
5347
+ this.compressedPublicKey = (0, import_utils29.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
5262
5348
  this.address = import_address5.Address.fromPublicKey(this.publicKey);
5263
5349
  }
5264
5350
  /**
@@ -5272,11 +5358,11 @@ var Signer = class {
5272
5358
  * @returns hashed signature
5273
5359
  */
5274
5360
  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);
5361
+ const signature = import_secp256k1.secp256k1.sign((0, import_utils29.arrayify)(data), (0, import_utils29.arrayify)(this.privateKey));
5362
+ const r = (0, import_math19.toBytes)(`0x${signature.r.toString(16)}`, 32);
5363
+ const s = (0, import_math19.toBytes)(`0x${signature.s.toString(16)}`, 32);
5278
5364
  s[0] |= (signature.recovery || 0) << 7;
5279
- return (0, import_utils28.hexlify)((0, import_utils28.concat)([r, s]));
5365
+ return (0, import_utils29.hexlify)((0, import_utils29.concat)([r, s]));
5280
5366
  }
5281
5367
  /**
5282
5368
  * Add point on the current elliptic curve
@@ -5285,8 +5371,8 @@ var Signer = class {
5285
5371
  * @returns compressed point on the curve
5286
5372
  */
5287
5373
  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));
5374
+ const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(this.compressedPublicKey));
5375
+ const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(point));
5290
5376
  const result = p0.add(p1);
5291
5377
  return `0x${result.toHex(true)}`;
5292
5378
  }
@@ -5298,16 +5384,16 @@ var Signer = class {
5298
5384
  * @returns public key from signature from the
5299
5385
  */
5300
5386
  static recoverPublicKey(data, signature) {
5301
- const signedMessageBytes = (0, import_utils28.arrayify)(signature);
5387
+ const signedMessageBytes = (0, import_utils29.arrayify)(signature);
5302
5388
  const r = signedMessageBytes.slice(0, 32);
5303
5389
  const s = signedMessageBytes.slice(32, 64);
5304
5390
  const recoveryParam = (s[0] & 128) >> 7;
5305
5391
  s[0] &= 127;
5306
- const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils28.hexlify)(r)), BigInt((0, import_utils28.hexlify)(s))).addRecoveryBit(
5392
+ const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils29.hexlify)(r)), BigInt((0, import_utils29.hexlify)(s))).addRecoveryBit(
5307
5393
  recoveryParam
5308
5394
  );
5309
- const publicKey = sig.recoverPublicKey((0, import_utils28.arrayify)(data)).toRawBytes(false).slice(1);
5310
- return (0, import_utils28.hexlify)(publicKey);
5395
+ const publicKey = sig.recoverPublicKey((0, import_utils29.arrayify)(data)).toRawBytes(false).slice(1);
5396
+ return (0, import_utils29.hexlify)(publicKey);
5311
5397
  }
5312
5398
  /**
5313
5399
  * Recover the address from a signature performed with [`sign`](#sign).
@@ -5326,7 +5412,7 @@ var Signer = class {
5326
5412
  * @returns random 32-byte hashed
5327
5413
  */
5328
5414
  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);
5415
+ 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
5416
  }
5331
5417
  /**
5332
5418
  * Extended publicKey from a compact publicKey
@@ -5335,16 +5421,16 @@ var Signer = class {
5335
5421
  * @returns extended publicKey
5336
5422
  */
5337
5423
  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));
5424
+ const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils29.arrayify)(publicKey));
5425
+ return (0, import_utils29.hexlify)(point.toRawBytes(false).slice(1));
5340
5426
  }
5341
5427
  };
5342
5428
 
5343
5429
  // src/wallet/keystore-wallet.ts
5344
5430
  var import_address6 = require("@fuel-ts/address");
5345
5431
  var import_crypto2 = require("@fuel-ts/crypto");
5346
- var import_errors16 = require("@fuel-ts/errors");
5347
- var import_utils29 = require("@fuel-ts/utils");
5432
+ var import_errors17 = require("@fuel-ts/errors");
5433
+ var import_utils30 = require("@fuel-ts/utils");
5348
5434
  var import_uuid = require("uuid");
5349
5435
  var DEFAULT_KDF_PARAMS_LOG_N = 13;
5350
5436
  var DEFAULT_KDF_PARAMS_R = 8;
@@ -5421,13 +5507,13 @@ async function decryptKeystoreWallet(jsonWallet, password) {
5421
5507
  const macHashUint8Array = (0, import_crypto2.keccak256)(data);
5422
5508
  const macHash = (0, import_crypto2.stringFromBuffer)(macHashUint8Array, "hex");
5423
5509
  if (mac !== macHash) {
5424
- throw new import_errors16.FuelError(
5425
- import_errors16.ErrorCode.INVALID_PASSWORD,
5510
+ throw new import_errors17.FuelError(
5511
+ import_errors17.ErrorCode.INVALID_PASSWORD,
5426
5512
  "Failed to decrypt the keystore wallet, the provided password is incorrect."
5427
5513
  );
5428
5514
  }
5429
5515
  const buffer = await (0, import_crypto2.decryptJsonWalletData)(ciphertextBuffer, key, ivBuffer);
5430
- const privateKey = (0, import_utils29.hexlify)(buffer);
5516
+ const privateKey = (0, import_utils30.hexlify)(buffer);
5431
5517
  return privateKey;
5432
5518
  }
5433
5519
 
@@ -5472,7 +5558,7 @@ var BaseWalletUnlocked = class extends Account {
5472
5558
  */
5473
5559
  async signMessage(message) {
5474
5560
  const signedMessage = await this.signer().sign((0, import_hasher3.hashMessage)(message));
5475
- return (0, import_utils30.hexlify)(signedMessage);
5561
+ return (0, import_utils31.hexlify)(signedMessage);
5476
5562
  }
5477
5563
  /**
5478
5564
  * Signs a transaction with the wallet's private key.
@@ -5485,7 +5571,7 @@ var BaseWalletUnlocked = class extends Account {
5485
5571
  const chainId = this.provider.getChainId();
5486
5572
  const hashedTransaction = transactionRequest.getTransactionId(chainId);
5487
5573
  const signature = await this.signer().sign(hashedTransaction);
5488
- return (0, import_utils30.hexlify)(signature);
5574
+ return (0, import_utils31.hexlify)(signature);
5489
5575
  }
5490
5576
  /**
5491
5577
  * Populates a transaction with the witnesses signature.
@@ -5544,17 +5630,17 @@ var BaseWalletUnlocked = class extends Account {
5544
5630
  __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
5545
5631
 
5546
5632
  // src/hdwallet/hdwallet.ts
5547
- var import_errors19 = require("@fuel-ts/errors");
5633
+ var import_errors20 = require("@fuel-ts/errors");
5548
5634
  var import_hasher6 = require("@fuel-ts/hasher");
5549
- var import_math19 = require("@fuel-ts/math");
5550
- var import_utils34 = require("@fuel-ts/utils");
5635
+ var import_math20 = require("@fuel-ts/math");
5636
+ var import_utils35 = require("@fuel-ts/utils");
5551
5637
  var import_ethers3 = require("ethers");
5552
5638
 
5553
5639
  // src/mnemonic/mnemonic.ts
5554
5640
  var import_crypto3 = require("@fuel-ts/crypto");
5555
- var import_errors18 = require("@fuel-ts/errors");
5641
+ var import_errors19 = require("@fuel-ts/errors");
5556
5642
  var import_hasher5 = require("@fuel-ts/hasher");
5557
- var import_utils32 = require("@fuel-ts/utils");
5643
+ var import_utils33 = require("@fuel-ts/utils");
5558
5644
  var import_ethers2 = require("ethers");
5559
5645
 
5560
5646
  // src/wordlists/words/english.ts
@@ -7616,9 +7702,9 @@ var Language = /* @__PURE__ */ ((Language2) => {
7616
7702
  })(Language || {});
7617
7703
 
7618
7704
  // src/mnemonic/utils.ts
7619
- var import_errors17 = require("@fuel-ts/errors");
7705
+ var import_errors18 = require("@fuel-ts/errors");
7620
7706
  var import_hasher4 = require("@fuel-ts/hasher");
7621
- var import_utils31 = require("@fuel-ts/utils");
7707
+ var import_utils32 = require("@fuel-ts/utils");
7622
7708
  function toUtf8Bytes(stri) {
7623
7709
  const str = stri.normalize("NFKD");
7624
7710
  const result = [];
@@ -7633,8 +7719,8 @@ function toUtf8Bytes(stri) {
7633
7719
  i += 1;
7634
7720
  const c2 = str.charCodeAt(i);
7635
7721
  if (i >= str.length || (c2 & 64512) !== 56320) {
7636
- throw new import_errors17.FuelError(
7637
- import_errors17.ErrorCode.INVALID_INPUT_PARAMETERS,
7722
+ throw new import_errors18.FuelError(
7723
+ import_errors18.ErrorCode.INVALID_INPUT_PARAMETERS,
7638
7724
  "Invalid UTF-8 in the input string."
7639
7725
  );
7640
7726
  }
@@ -7685,20 +7771,20 @@ function entropyToMnemonicIndices(entropy) {
7685
7771
  }
7686
7772
  }
7687
7773
  const checksumBits = entropy.length / 4;
7688
- const checksum = (0, import_utils31.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
7774
+ const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
7689
7775
  indices[indices.length - 1] <<= checksumBits;
7690
7776
  indices[indices.length - 1] |= checksum >> 8 - checksumBits;
7691
7777
  return indices;
7692
7778
  }
7693
7779
  function mnemonicWordsToEntropy(words, wordlist) {
7694
7780
  const size = Math.ceil(11 * words.length / 8);
7695
- const entropy = (0, import_utils31.arrayify)(new Uint8Array(size));
7781
+ const entropy = (0, import_utils32.arrayify)(new Uint8Array(size));
7696
7782
  let offset = 0;
7697
7783
  for (let i = 0; i < words.length; i += 1) {
7698
7784
  const index = wordlist.indexOf(words[i].normalize("NFKD"));
7699
7785
  if (index === -1) {
7700
- throw new import_errors17.FuelError(
7701
- import_errors17.ErrorCode.INVALID_MNEMONIC,
7786
+ throw new import_errors18.FuelError(
7787
+ import_errors18.ErrorCode.INVALID_MNEMONIC,
7702
7788
  `Invalid mnemonic: the word '${words[i]}' is not found in the provided wordlist.`
7703
7789
  );
7704
7790
  }
@@ -7712,10 +7798,10 @@ function mnemonicWordsToEntropy(words, wordlist) {
7712
7798
  const entropyBits = 32 * words.length / 3;
7713
7799
  const checksumBits = words.length / 3;
7714
7800
  const checksumMask = getUpperMask(checksumBits);
7715
- const checksum = (0, import_utils31.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
7801
+ const checksum = (0, import_utils32.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
7716
7802
  if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
7717
- throw new import_errors17.FuelError(
7718
- import_errors17.ErrorCode.INVALID_CHECKSUM,
7803
+ throw new import_errors18.FuelError(
7804
+ import_errors18.ErrorCode.INVALID_CHECKSUM,
7719
7805
  "Checksum validation failed for the provided mnemonic."
7720
7806
  );
7721
7807
  }
@@ -7729,16 +7815,16 @@ var TestnetPRV = "0x04358394";
7729
7815
  var MNEMONIC_SIZES = [12, 15, 18, 21, 24];
7730
7816
  function assertWordList(wordlist) {
7731
7817
  if (wordlist.length !== 2048) {
7732
- throw new import_errors18.FuelError(
7733
- import_errors18.ErrorCode.INVALID_WORD_LIST,
7818
+ throw new import_errors19.FuelError(
7819
+ import_errors19.ErrorCode.INVALID_WORD_LIST,
7734
7820
  `Expected word list length of 2048, but got ${wordlist.length}.`
7735
7821
  );
7736
7822
  }
7737
7823
  }
7738
7824
  function assertEntropy(entropy) {
7739
7825
  if (entropy.length % 4 !== 0 || entropy.length < 16 || entropy.length > 32) {
7740
- throw new import_errors18.FuelError(
7741
- import_errors18.ErrorCode.INVALID_ENTROPY,
7826
+ throw new import_errors19.FuelError(
7827
+ import_errors19.ErrorCode.INVALID_ENTROPY,
7742
7828
  `Entropy should be between 16 and 32 bytes and a multiple of 4, but got ${entropy.length} bytes.`
7743
7829
  );
7744
7830
  }
@@ -7748,7 +7834,7 @@ function assertMnemonic(words) {
7748
7834
  const errorMsg = `Invalid mnemonic size. Expected one of [${MNEMONIC_SIZES.join(
7749
7835
  ", "
7750
7836
  )}] words, but got ${words.length}.`;
7751
- throw new import_errors18.FuelError(import_errors18.ErrorCode.INVALID_MNEMONIC, errorMsg);
7837
+ throw new import_errors19.FuelError(import_errors19.ErrorCode.INVALID_MNEMONIC, errorMsg);
7752
7838
  }
7753
7839
  }
7754
7840
  var Mnemonic = class {
@@ -7787,7 +7873,7 @@ var Mnemonic = class {
7787
7873
  static mnemonicToEntropy(phrase, wordlist = english) {
7788
7874
  const words = getWords(phrase);
7789
7875
  assertMnemonic(words);
7790
- return (0, import_utils32.hexlify)(mnemonicWordsToEntropy(words, wordlist));
7876
+ return (0, import_utils33.hexlify)(mnemonicWordsToEntropy(words, wordlist));
7791
7877
  }
7792
7878
  /**
7793
7879
  * @param entropy - Entropy source to the mnemonic phrase.
@@ -7795,7 +7881,7 @@ var Mnemonic = class {
7795
7881
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
7796
7882
  */
7797
7883
  static entropyToMnemonic(entropy, wordlist = english) {
7798
- const entropyBytes = (0, import_utils32.arrayify)(entropy);
7884
+ const entropyBytes = (0, import_utils33.arrayify)(entropy);
7799
7885
  assertWordList(wordlist);
7800
7886
  assertEntropy(entropyBytes);
7801
7887
  return entropyToMnemonicIndices(entropyBytes).map((i) => wordlist[i]).join(" ");
@@ -7864,14 +7950,14 @@ var Mnemonic = class {
7864
7950
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
7865
7951
  */
7866
7952
  static masterKeysFromSeed(seed) {
7867
- const seedArray = (0, import_utils32.arrayify)(seed);
7953
+ const seedArray = (0, import_utils33.arrayify)(seed);
7868
7954
  if (seedArray.length < 16 || seedArray.length > 64) {
7869
- throw new import_errors18.FuelError(
7870
- import_errors18.ErrorCode.INVALID_SEED,
7955
+ throw new import_errors19.FuelError(
7956
+ import_errors19.ErrorCode.INVALID_SEED,
7871
7957
  `Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
7872
7958
  );
7873
7959
  }
7874
- return (0, import_utils32.arrayify)((0, import_ethers2.computeHmac)("sha512", MasterSecret, seedArray));
7960
+ return (0, import_utils33.arrayify)((0, import_ethers2.computeHmac)("sha512", MasterSecret, seedArray));
7875
7961
  }
7876
7962
  /**
7877
7963
  * Get the extendKey as defined on BIP-32 from the provided seed
@@ -7882,22 +7968,22 @@ var Mnemonic = class {
7882
7968
  */
7883
7969
  static seedToExtendedKey(seed, testnet = false) {
7884
7970
  const masterKey = Mnemonic.masterKeysFromSeed(seed);
7885
- const prefix = (0, import_utils32.arrayify)(testnet ? TestnetPRV : MainnetPRV);
7971
+ const prefix = (0, import_utils33.arrayify)(testnet ? TestnetPRV : MainnetPRV);
7886
7972
  const depth = "0x00";
7887
7973
  const fingerprint = "0x00000000";
7888
7974
  const index = "0x00000000";
7889
7975
  const chainCode = masterKey.slice(32);
7890
7976
  const privateKey = masterKey.slice(0, 32);
7891
- const extendedKey = (0, import_utils32.concat)([
7977
+ const extendedKey = (0, import_utils33.concat)([
7892
7978
  prefix,
7893
7979
  depth,
7894
7980
  fingerprint,
7895
7981
  index,
7896
7982
  chainCode,
7897
- (0, import_utils32.concat)(["0x00", privateKey])
7983
+ (0, import_utils33.concat)(["0x00", privateKey])
7898
7984
  ]);
7899
7985
  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]));
7986
+ return (0, import_ethers2.encodeBase58)((0, import_utils33.concat)([extendedKey, checksum]));
7901
7987
  }
7902
7988
  /**
7903
7989
  * Create a new mnemonic using a randomly generated number as entropy.
@@ -7912,7 +7998,7 @@ var Mnemonic = class {
7912
7998
  * @returns A randomly generated mnemonic
7913
7999
  */
7914
8000
  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);
8001
+ 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
8002
  return Mnemonic.entropyToMnemonic(entropy);
7917
8003
  }
7918
8004
  };
@@ -7920,12 +8006,12 @@ var mnemonic_default = Mnemonic;
7920
8006
 
7921
8007
  // src/hdwallet/hdwallet.ts
7922
8008
  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");
8009
+ var MainnetPRV2 = (0, import_utils35.hexlify)("0x0488ade4");
8010
+ var MainnetPUB = (0, import_utils35.hexlify)("0x0488b21e");
8011
+ var TestnetPRV2 = (0, import_utils35.hexlify)("0x04358394");
8012
+ var TestnetPUB = (0, import_utils35.hexlify)("0x043587cf");
7927
8013
  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)]));
8014
+ 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
8015
  }
7930
8016
  function getExtendedKeyPrefix(isPublic = false, testnet = false) {
7931
8017
  if (isPublic) {
@@ -7934,17 +8020,17 @@ function getExtendedKeyPrefix(isPublic = false, testnet = false) {
7934
8020
  return testnet ? TestnetPRV2 : MainnetPRV2;
7935
8021
  }
7936
8022
  function isPublicExtendedKey(extendedKey) {
7937
- return [MainnetPUB, TestnetPUB].includes((0, import_utils34.hexlify)(extendedKey.slice(0, 4)));
8023
+ return [MainnetPUB, TestnetPUB].includes((0, import_utils35.hexlify)(extendedKey.slice(0, 4)));
7938
8024
  }
7939
8025
  function isValidExtendedKey(extendedKey) {
7940
8026
  return [MainnetPRV2, TestnetPRV2, MainnetPUB, TestnetPUB].includes(
7941
- (0, import_utils34.hexlify)(extendedKey.slice(0, 4))
8027
+ (0, import_utils35.hexlify)(extendedKey.slice(0, 4))
7942
8028
  );
7943
8029
  }
7944
8030
  function parsePath(path, depth = 0) {
7945
8031
  const components = path.split("/");
7946
8032
  if (components.length === 0 || components[0] === "m" && depth !== 0) {
7947
- throw new import_errors19.FuelError(import_errors19.ErrorCode.HD_WALLET_ERROR, `invalid path - ${path}`);
8033
+ throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, `invalid path - ${path}`);
7948
8034
  }
7949
8035
  if (components[0] === "m") {
7950
8036
  components.shift();
@@ -7956,8 +8042,8 @@ function parsePath(path, depth = 0) {
7956
8042
  var HDWallet = class {
7957
8043
  depth = 0;
7958
8044
  index = 0;
7959
- fingerprint = (0, import_utils34.hexlify)("0x00000000");
7960
- parentFingerprint = (0, import_utils34.hexlify)("0x00000000");
8045
+ fingerprint = (0, import_utils35.hexlify)("0x00000000");
8046
+ parentFingerprint = (0, import_utils35.hexlify)("0x00000000");
7961
8047
  privateKey;
7962
8048
  publicKey;
7963
8049
  chainCode;
@@ -7969,16 +8055,16 @@ var HDWallet = class {
7969
8055
  constructor(config) {
7970
8056
  if (config.privateKey) {
7971
8057
  const signer = new Signer(config.privateKey);
7972
- this.publicKey = (0, import_utils34.hexlify)(signer.compressedPublicKey);
7973
- this.privateKey = (0, import_utils34.hexlify)(config.privateKey);
8058
+ this.publicKey = (0, import_utils35.hexlify)(signer.compressedPublicKey);
8059
+ this.privateKey = (0, import_utils35.hexlify)(config.privateKey);
7974
8060
  } else {
7975
8061
  if (!config.publicKey) {
7976
- throw new import_errors19.FuelError(
7977
- import_errors19.ErrorCode.HD_WALLET_ERROR,
8062
+ throw new import_errors20.FuelError(
8063
+ import_errors20.ErrorCode.HD_WALLET_ERROR,
7978
8064
  "Both public and private Key cannot be missing. At least one should be provided."
7979
8065
  );
7980
8066
  }
7981
- this.publicKey = (0, import_utils34.hexlify)(config.publicKey);
8067
+ this.publicKey = (0, import_utils35.hexlify)(config.publicKey);
7982
8068
  }
7983
8069
  this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
7984
8070
  this.fingerprint = (0, import_ethers3.dataSlice)((0, import_ethers3.ripemd160)((0, import_hasher6.sha256)(this.publicKey)), 0, 4);
@@ -7997,28 +8083,28 @@ var HDWallet = class {
7997
8083
  * @returns A new instance of HDWallet on the derived index
7998
8084
  */
7999
8085
  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);
8086
+ const privateKey = this.privateKey && (0, import_utils35.arrayify)(this.privateKey);
8087
+ const publicKey = (0, import_utils35.arrayify)(this.publicKey);
8088
+ const chainCode = (0, import_utils35.arrayify)(this.chainCode);
8003
8089
  const data = new Uint8Array(37);
8004
8090
  if (index & HARDENED_INDEX) {
8005
8091
  if (!privateKey) {
8006
- throw new import_errors19.FuelError(
8007
- import_errors19.ErrorCode.HD_WALLET_ERROR,
8092
+ throw new import_errors20.FuelError(
8093
+ import_errors20.ErrorCode.HD_WALLET_ERROR,
8008
8094
  "Cannot derive a hardened index without a private Key."
8009
8095
  );
8010
8096
  }
8011
8097
  data.set(privateKey, 1);
8012
8098
  } else {
8013
- data.set((0, import_utils34.arrayify)(this.publicKey));
8099
+ data.set((0, import_utils35.arrayify)(this.publicKey));
8014
8100
  }
8015
- data.set((0, import_math19.toBytes)(index, 4), 33);
8016
- const bytes = (0, import_utils34.arrayify)((0, import_ethers3.computeHmac)("sha512", chainCode, data));
8101
+ data.set((0, import_math20.toBytes)(index, 4), 33);
8102
+ const bytes = (0, import_utils35.arrayify)((0, import_ethers3.computeHmac)("sha512", chainCode, data));
8017
8103
  const IL = bytes.slice(0, 32);
8018
8104
  const IR = bytes.slice(32);
8019
8105
  if (privateKey) {
8020
8106
  const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
8021
- const ki = (0, import_math19.bn)(IL).add(privateKey).mod(N).toBytes(32);
8107
+ const ki = (0, import_math20.bn)(IL).add(privateKey).mod(N).toBytes(32);
8022
8108
  return new HDWallet({
8023
8109
  privateKey: ki,
8024
8110
  chainCode: IR,
@@ -8027,7 +8113,7 @@ var HDWallet = class {
8027
8113
  parentFingerprint: this.fingerprint
8028
8114
  });
8029
8115
  }
8030
- const signer = new Signer((0, import_utils34.hexlify)(IL));
8116
+ const signer = new Signer((0, import_utils35.hexlify)(IL));
8031
8117
  const Ki = signer.addPoint(publicKey);
8032
8118
  return new HDWallet({
8033
8119
  publicKey: Ki,
@@ -8056,18 +8142,18 @@ var HDWallet = class {
8056
8142
  */
8057
8143
  toExtendedKey(isPublic = false, testnet = false) {
8058
8144
  if (this.depth >= 256) {
8059
- throw new import_errors19.FuelError(
8060
- import_errors19.ErrorCode.HD_WALLET_ERROR,
8145
+ throw new import_errors20.FuelError(
8146
+ import_errors20.ErrorCode.HD_WALLET_ERROR,
8061
8147
  `Exceeded max depth of 255. Current depth: ${this.depth}.`
8062
8148
  );
8063
8149
  }
8064
8150
  const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
8065
- const depth = (0, import_utils34.hexlify)(Uint8Array.from([this.depth]));
8151
+ const depth = (0, import_utils35.hexlify)(Uint8Array.from([this.depth]));
8066
8152
  const parentFingerprint = this.parentFingerprint;
8067
- const index = (0, import_math19.toHex)(this.index, 4);
8153
+ const index = (0, import_math20.toHex)(this.index, 4);
8068
8154
  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]));
8155
+ const key = this.privateKey != null && !isPublic ? (0, import_utils35.concat)(["0x00", this.privateKey]) : this.publicKey;
8156
+ const extendedKey = (0, import_utils35.arrayify)((0, import_utils35.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
8071
8157
  return base58check(extendedKey);
8072
8158
  }
8073
8159
  /**
@@ -8079,34 +8165,34 @@ var HDWallet = class {
8079
8165
  static fromSeed(seed) {
8080
8166
  const masterKey = mnemonic_default.masterKeysFromSeed(seed);
8081
8167
  return new HDWallet({
8082
- chainCode: (0, import_utils34.arrayify)(masterKey.slice(32)),
8083
- privateKey: (0, import_utils34.arrayify)(masterKey.slice(0, 32))
8168
+ chainCode: (0, import_utils35.arrayify)(masterKey.slice(32)),
8169
+ privateKey: (0, import_utils35.arrayify)(masterKey.slice(0, 32))
8084
8170
  });
8085
8171
  }
8086
8172
  static fromExtendedKey(extendedKey) {
8087
8173
  const decoded = (0, import_ethers3.toBeHex)((0, import_ethers3.decodeBase58)(extendedKey));
8088
- const bytes = (0, import_utils34.arrayify)(decoded);
8174
+ const bytes = (0, import_utils35.arrayify)(decoded);
8089
8175
  const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
8090
8176
  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.");
8177
+ throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
8092
8178
  }
8093
8179
  if (!validChecksum) {
8094
- throw new import_errors19.FuelError(import_errors19.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
8180
+ throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
8095
8181
  }
8096
8182
  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));
8183
+ const parentFingerprint = (0, import_utils35.hexlify)(bytes.slice(5, 9));
8184
+ const index = parseInt((0, import_utils35.hexlify)(bytes.slice(9, 13)).substring(2), 16);
8185
+ const chainCode = (0, import_utils35.hexlify)(bytes.slice(13, 45));
8100
8186
  const key = bytes.slice(45, 78);
8101
8187
  if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
8102
- throw new import_errors19.FuelError(
8103
- import_errors19.ErrorCode.HD_WALLET_ERROR,
8188
+ throw new import_errors20.FuelError(
8189
+ import_errors20.ErrorCode.HD_WALLET_ERROR,
8104
8190
  "Inconsistency detected: Depth is zero but fingerprint/index is non-zero."
8105
8191
  );
8106
8192
  }
8107
8193
  if (isPublicExtendedKey(bytes)) {
8108
8194
  if (key[0] !== 3) {
8109
- throw new import_errors19.FuelError(import_errors19.ErrorCode.HD_WALLET_ERROR, "Invalid public extended key.");
8195
+ throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Invalid public extended key.");
8110
8196
  }
8111
8197
  return new HDWallet({
8112
8198
  publicKey: key,
@@ -8117,7 +8203,7 @@ var HDWallet = class {
8117
8203
  });
8118
8204
  }
8119
8205
  if (key[0] !== 0) {
8120
- throw new import_errors19.FuelError(import_errors19.ErrorCode.HD_WALLET_ERROR, "Invalid private extended key.");
8206
+ throw new import_errors20.FuelError(import_errors20.ErrorCode.HD_WALLET_ERROR, "Invalid private extended key.");
8121
8207
  }
8122
8208
  return new HDWallet({
8123
8209
  privateKey: key.slice(1),
@@ -8285,7 +8371,7 @@ __publicField(Wallet, "fromEncryptedJson", WalletUnlocked.fromEncryptedJson);
8285
8371
  // src/wallet-manager/wallet-manager.ts
8286
8372
  var import_address9 = require("@fuel-ts/address");
8287
8373
  var import_crypto4 = require("@fuel-ts/crypto");
8288
- var import_errors22 = require("@fuel-ts/errors");
8374
+ var import_errors23 = require("@fuel-ts/errors");
8289
8375
  var import_events = require("events");
8290
8376
 
8291
8377
  // src/wallet-manager/storages/memory-storage.ts
@@ -8308,7 +8394,7 @@ var MemoryStorage = class {
8308
8394
 
8309
8395
  // src/wallet-manager/vaults/mnemonic-vault.ts
8310
8396
  var import_address7 = require("@fuel-ts/address");
8311
- var import_errors20 = require("@fuel-ts/errors");
8397
+ var import_errors21 = require("@fuel-ts/errors");
8312
8398
  var _secret;
8313
8399
  var MnemonicVault = class {
8314
8400
  constructor(options) {
@@ -8364,8 +8450,8 @@ var MnemonicVault = class {
8364
8450
  }
8365
8451
  numberOfAccounts += 1;
8366
8452
  } while (numberOfAccounts < this.numberOfAccounts);
8367
- throw new import_errors20.FuelError(
8368
- import_errors20.ErrorCode.WALLET_MANAGER_ERROR,
8453
+ throw new import_errors21.FuelError(
8454
+ import_errors21.ErrorCode.WALLET_MANAGER_ERROR,
8369
8455
  `Account with address '${address}' not found in derived wallets.`
8370
8456
  );
8371
8457
  }
@@ -8379,7 +8465,7 @@ __publicField(MnemonicVault, "type", "mnemonic");
8379
8465
 
8380
8466
  // src/wallet-manager/vaults/privatekey-vault.ts
8381
8467
  var import_address8 = require("@fuel-ts/address");
8382
- var import_errors21 = require("@fuel-ts/errors");
8468
+ var import_errors22 = require("@fuel-ts/errors");
8383
8469
  var _privateKeys;
8384
8470
  var PrivateKeyVault = class {
8385
8471
  /**
@@ -8420,8 +8506,8 @@ var PrivateKeyVault = class {
8420
8506
  (pk) => Wallet.fromPrivateKey(pk).address.equals(ownerAddress)
8421
8507
  );
8422
8508
  if (!privateKey) {
8423
- throw new import_errors21.FuelError(
8424
- import_errors21.ErrorCode.WALLET_MANAGER_ERROR,
8509
+ throw new import_errors22.FuelError(
8510
+ import_errors22.ErrorCode.WALLET_MANAGER_ERROR,
8425
8511
  `No private key found for address '${address}'.`
8426
8512
  );
8427
8513
  }
@@ -8445,7 +8531,7 @@ var ERROR_MESSAGES = {
8445
8531
  };
8446
8532
  function assert(condition, message) {
8447
8533
  if (!condition) {
8448
- throw new import_errors22.FuelError(import_errors22.ErrorCode.WALLET_MANAGER_ERROR, message);
8534
+ throw new import_errors23.FuelError(import_errors23.ErrorCode.WALLET_MANAGER_ERROR, message);
8449
8535
  }
8450
8536
  }
8451
8537
  var _vaults, _passphrase, _isLocked, _serializeVaults, serializeVaults_fn, _deserializeVaults, deserializeVaults_fn;
@@ -8671,25 +8757,25 @@ deserializeVaults_fn = function(vaults) {
8671
8757
  __publicField(WalletManager, "Vaults", [MnemonicVault, PrivateKeyVault]);
8672
8758
 
8673
8759
  // src/wallet-manager/types.ts
8674
- var import_errors23 = require("@fuel-ts/errors");
8760
+ var import_errors24 = require("@fuel-ts/errors");
8675
8761
  var Vault = class {
8676
8762
  constructor(_options) {
8677
- throw new import_errors23.FuelError(import_errors23.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
8763
+ throw new import_errors24.FuelError(import_errors24.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
8678
8764
  }
8679
8765
  serialize() {
8680
- throw new import_errors23.FuelError(import_errors23.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
8766
+ throw new import_errors24.FuelError(import_errors24.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
8681
8767
  }
8682
8768
  getAccounts() {
8683
- throw new import_errors23.FuelError(import_errors23.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
8769
+ throw new import_errors24.FuelError(import_errors24.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
8684
8770
  }
8685
8771
  addAccount() {
8686
- throw new import_errors23.FuelError(import_errors23.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
8772
+ throw new import_errors24.FuelError(import_errors24.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
8687
8773
  }
8688
8774
  exportAccount(_address) {
8689
- throw new import_errors23.FuelError(import_errors23.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
8775
+ throw new import_errors24.FuelError(import_errors24.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
8690
8776
  }
8691
8777
  getWallet(_address) {
8692
- throw new import_errors23.FuelError(import_errors23.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
8778
+ throw new import_errors24.FuelError(import_errors24.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
8693
8779
  }
8694
8780
  };
8695
8781
  __publicField(Vault, "type");
@@ -8699,21 +8785,21 @@ var StorageAbstract = class {
8699
8785
  // src/predicate/predicate.ts
8700
8786
  var import_abi_coder5 = require("@fuel-ts/abi-coder");
8701
8787
  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");
8788
+ var import_configs13 = require("@fuel-ts/address/configs");
8789
+ var import_errors25 = require("@fuel-ts/errors");
8790
+ var import_transactions20 = require("@fuel-ts/transactions");
8791
+ var import_utils37 = require("@fuel-ts/utils");
8706
8792
 
8707
8793
  // src/predicate/utils/getPredicateRoot.ts
8708
8794
  var import_hasher7 = require("@fuel-ts/hasher");
8709
8795
  var import_merkle = require("@fuel-ts/merkle");
8710
- var import_utils35 = require("@fuel-ts/utils");
8796
+ var import_utils36 = require("@fuel-ts/utils");
8711
8797
  var getPredicateRoot = (bytecode) => {
8712
8798
  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]));
8799
+ const bytes = (0, import_utils36.arrayify)(bytecode);
8800
+ const chunks = (0, import_utils36.chunkAndPadBytes)(bytes, chunkSize);
8801
+ const codeRoot = (0, import_merkle.calcRoot)(chunks.map((c) => (0, import_utils36.hexlify)(c)));
8802
+ const predicateRoot = (0, import_hasher7.hash)((0, import_utils36.concat)(["0x4655454C", codeRoot]));
8717
8803
  return predicateRoot;
8718
8804
  };
8719
8805
 
@@ -8762,7 +8848,7 @@ var Predicate = class extends Account {
8762
8848
  const request = transactionRequestify(transactionRequestLike);
8763
8849
  const { policies } = BaseTransactionRequest.getPolicyMeta(request);
8764
8850
  request.inputs?.forEach((input) => {
8765
- if (input.type === import_transactions19.InputType.Coin && (0, import_utils36.hexlify)(input.owner) === this.address.toB256()) {
8851
+ if (input.type === import_transactions20.InputType.Coin && (0, import_utils37.hexlify)(input.owner) === this.address.toB256()) {
8766
8852
  input.predicate = this.bytes;
8767
8853
  input.predicateData = this.getPredicateData(policies.length);
8768
8854
  }
@@ -8778,7 +8864,7 @@ var Predicate = class extends Account {
8778
8864
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
8779
8865
  * @returns A promise that resolves to the prepared transaction request.
8780
8866
  */
8781
- async createTransfer(destination, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
8867
+ async createTransfer(destination, amount, assetId = import_configs13.BaseAssetId, txParams = {}) {
8782
8868
  const request = await super.createTransfer(destination, amount, assetId, txParams);
8783
8869
  return this.populateTransactionPredicateData(request);
8784
8870
  }
@@ -8807,7 +8893,7 @@ var Predicate = class extends Account {
8807
8893
  return new Uint8Array();
8808
8894
  }
8809
8895
  const mainFn = this.interface?.functions.main;
8810
- const paddedCode = new import_transactions19.ByteArrayCoder(this.bytes.length).encode(this.bytes);
8896
+ const paddedCode = new import_transactions20.ByteArrayCoder(this.bytes.length).encode(this.bytes);
8811
8897
  const VM_TX_MEMORY = (0, import_abi_coder5.calculateVmTxMemory)({
8812
8898
  maxInputs: this.provider.getChain().consensusParameters.maxInputs.toNumber()
8813
8899
  });
@@ -8823,13 +8909,13 @@ var Predicate = class extends Account {
8823
8909
  * @returns An object containing the new predicate bytes and interface.
8824
8910
  */
8825
8911
  static processPredicateData(bytes, jsonAbi, configurableConstants) {
8826
- let predicateBytes = (0, import_utils36.arrayify)(bytes);
8912
+ let predicateBytes = (0, import_utils37.arrayify)(bytes);
8827
8913
  let abiInterface;
8828
8914
  if (jsonAbi) {
8829
8915
  abiInterface = new import_abi_coder5.Interface(jsonAbi);
8830
8916
  if (abiInterface.functions.main === void 0) {
8831
- throw new import_errors24.FuelError(
8832
- import_errors24.ErrorCode.ABI_MAIN_METHOD_MISSING,
8917
+ throw new import_errors25.FuelError(
8918
+ import_errors25.ErrorCode.ABI_MAIN_METHOD_MISSING,
8833
8919
  'Cannot use ABI without "main" function.'
8834
8920
  );
8835
8921
  }
@@ -8874,8 +8960,8 @@ var Predicate = class extends Account {
8874
8960
  mutatedBytes.set(encoded, offset);
8875
8961
  });
8876
8962
  } catch (err) {
8877
- throw new import_errors24.FuelError(
8878
- import_errors24.ErrorCode.INVALID_CONFIGURABLE_CONSTANTS,
8963
+ throw new import_errors25.FuelError(
8964
+ import_errors25.ErrorCode.INVALID_CONFIGURABLE_CONSTANTS,
8879
8965
  `Error setting configurable constants: ${err.message}.`
8880
8966
  );
8881
8967
  }
@@ -8884,7 +8970,7 @@ var Predicate = class extends Account {
8884
8970
  };
8885
8971
 
8886
8972
  // src/connectors/fuel.ts
8887
- var import_errors25 = require("@fuel-ts/errors");
8973
+ var import_errors26 = require("@fuel-ts/errors");
8888
8974
 
8889
8975
  // src/connectors/fuel-connector.ts
8890
8976
  var import_events2 = require("events");
@@ -9517,7 +9603,7 @@ var _Fuel = class extends FuelConnector {
9517
9603
  const currentNetwork = await this.currentNetwork();
9518
9604
  provider = await Provider.create(currentNetwork.url);
9519
9605
  } else {
9520
- throw new import_errors25.FuelError(import_errors25.ErrorCode.INVALID_PROVIDER, "Provider is not valid.");
9606
+ throw new import_errors26.FuelError(import_errors26.ErrorCode.INVALID_PROVIDER, "Provider is not valid.");
9521
9607
  }
9522
9608
  return provider;
9523
9609
  }
@@ -9597,7 +9683,9 @@ __publicField(Fuel, "defaultConfig", {});
9597
9683
  WalletUnlocked,
9598
9684
  addAmountToAsset,
9599
9685
  addOperation,
9686
+ assemblePanicError,
9600
9687
  assembleReceiptByType,
9688
+ assembleRevertError,
9601
9689
  assembleTransactionSummary,
9602
9690
  assets,
9603
9691
  buildBlockExplorerUrl,
@@ -9612,6 +9700,7 @@ __publicField(Fuel, "defaultConfig", {});
9612
9700
  english,
9613
9701
  extractBurnedAssetsFromReceipts,
9614
9702
  extractMintedAssetsFromReceipts,
9703
+ extractTxError,
9615
9704
  gasUsedByInputs,
9616
9705
  getAssetEth,
9617
9706
  getAssetFuel,