@fuel-ts/account 0.78.0 → 0.80.0

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

Potentially problematic release.


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

Files changed (39) hide show
  1. package/dist/configs.d.ts +1 -0
  2. package/dist/configs.d.ts.map +1 -1
  3. package/dist/configs.global.js +1 -0
  4. package/dist/configs.global.js.map +1 -1
  5. package/dist/configs.js +3 -0
  6. package/dist/configs.js.map +1 -1
  7. package/dist/configs.mjs +2 -0
  8. package/dist/configs.mjs.map +1 -1
  9. package/dist/index.global.js +388 -210
  10. package/dist/index.global.js.map +1 -1
  11. package/dist/index.js +668 -550
  12. package/dist/index.js.map +1 -1
  13. package/dist/index.mjs +422 -299
  14. package/dist/index.mjs.map +1 -1
  15. package/dist/predicate/predicate.d.ts +0 -1
  16. package/dist/predicate/predicate.d.ts.map +1 -1
  17. package/dist/providers/provider.d.ts +13 -2
  18. package/dist/providers/provider.d.ts.map +1 -1
  19. package/dist/providers/transaction-request/input.d.ts.map +1 -1
  20. package/dist/providers/transaction-request/script-transaction-request.d.ts +3 -0
  21. package/dist/providers/transaction-request/script-transaction-request.d.ts.map +1 -1
  22. package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
  23. package/dist/providers/transaction-request/types.d.ts +5 -0
  24. package/dist/providers/transaction-request/types.d.ts.map +1 -1
  25. package/dist/providers/transaction-response/getDecodedLogs.d.ts +2 -2
  26. package/dist/providers/transaction-response/getDecodedLogs.d.ts.map +1 -1
  27. package/dist/providers/transaction-response/transaction-response.d.ts +5 -2
  28. package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
  29. package/dist/providers/utils/extract-tx-error.d.ts +36 -0
  30. package/dist/providers/utils/extract-tx-error.d.ts.map +1 -0
  31. package/dist/providers/utils/index.d.ts +1 -0
  32. package/dist/providers/utils/index.d.ts.map +1 -1
  33. package/dist/test-utils.global.js +390 -196
  34. package/dist/test-utils.global.js.map +1 -1
  35. package/dist/test-utils.js +625 -499
  36. package/dist/test-utils.js.map +1 -1
  37. package/dist/test-utils.mjs +392 -258
  38. package/dist/test-utils.mjs.map +1 -1
  39. package/package.json +16 -16
package/dist/index.mjs CHANGED
@@ -30,9 +30,9 @@ var __privateMethod = (obj, member, method) => {
30
30
  // src/account.ts
31
31
  import { Address as Address3 } from "@fuel-ts/address";
32
32
  import { BaseAssetId as BaseAssetId3 } from "@fuel-ts/address/configs";
33
- import { ErrorCode as ErrorCode14, FuelError as FuelError14 } from "@fuel-ts/errors";
33
+ import { ErrorCode as ErrorCode15, FuelError as FuelError15 } from "@fuel-ts/errors";
34
34
  import { AbstractAccount } from "@fuel-ts/interfaces";
35
- import { bn as bn16 } from "@fuel-ts/math";
35
+ import { bn as bn17 } from "@fuel-ts/math";
36
36
  import { arrayify as arrayify14 } from "@fuel-ts/utils";
37
37
 
38
38
  // src/providers/coin-quantity.ts
@@ -73,8 +73,8 @@ var addAmountToAsset = (params) => {
73
73
 
74
74
  // src/providers/provider.ts
75
75
  import { Address as Address2 } from "@fuel-ts/address";
76
- import { ErrorCode as ErrorCode12, FuelError as FuelError12 } from "@fuel-ts/errors";
77
- import { BN, bn as bn14, max } from "@fuel-ts/math";
76
+ import { ErrorCode as ErrorCode13, FuelError as FuelError13 } from "@fuel-ts/errors";
77
+ import { BN, bn as bn15, max } from "@fuel-ts/math";
78
78
  import {
79
79
  InputType as InputType6,
80
80
  TransactionType as TransactionType8,
@@ -1023,6 +1023,7 @@ var MemoryCache = class {
1023
1023
  };
1024
1024
 
1025
1025
  // src/providers/transaction-request/input.ts
1026
+ import { BYTES_32, UTXO_ID_LEN } from "@fuel-ts/abi-coder";
1026
1027
  import { ZeroBytes32 } from "@fuel-ts/address/configs";
1027
1028
  import { ErrorCode as ErrorCode3, FuelError as FuelError3 } from "@fuel-ts/errors";
1028
1029
  import { bn as bn2, toNumber } from "@fuel-ts/math";
@@ -1036,8 +1037,8 @@ var inputify = (value) => {
1036
1037
  const predicateData = arrayify(value.predicateData ?? "0x");
1037
1038
  return {
1038
1039
  type: InputType.Coin,
1039
- txID: hexlify3(arrayify(value.id).slice(0, 32)),
1040
- outputIndex: arrayify(value.id)[32],
1040
+ txID: hexlify3(arrayify(value.id).slice(0, BYTES_32)),
1041
+ outputIndex: toNumber(arrayify(value.id).slice(BYTES_32, UTXO_ID_LEN)),
1041
1042
  owner: hexlify3(value.owner),
1042
1043
  amount: bn2(value.amount),
1043
1044
  assetId: hexlify3(value.assetId),
@@ -1155,9 +1156,11 @@ var outputify = (value) => {
1155
1156
  };
1156
1157
 
1157
1158
  // src/providers/transaction-request/transaction-request.ts
1159
+ import { UTXO_ID_LEN as UTXO_ID_LEN2 } from "@fuel-ts/abi-coder";
1158
1160
  import { Address, addressify } from "@fuel-ts/address";
1159
1161
  import { BaseAssetId as BaseAssetId2, ZeroBytes32 as ZeroBytes324 } from "@fuel-ts/address/configs";
1160
- import { bn as bn6 } from "@fuel-ts/math";
1162
+ import { randomBytes } from "@fuel-ts/crypto";
1163
+ import { bn as bn7 } from "@fuel-ts/math";
1161
1164
  import {
1162
1165
  PolicyType,
1163
1166
  TransactionCoder,
@@ -1562,6 +1565,86 @@ function sleep(time) {
1562
1565
  });
1563
1566
  }
1564
1567
 
1568
+ // src/providers/utils/extract-tx-error.ts
1569
+ import { ErrorCode as ErrorCode7, FuelError as FuelError7 } from "@fuel-ts/errors";
1570
+ import { bn as bn6 } from "@fuel-ts/math";
1571
+ import { ReceiptType as ReceiptType3 } from "@fuel-ts/transactions";
1572
+ import {
1573
+ FAILED_REQUIRE_SIGNAL,
1574
+ FAILED_ASSERT_EQ_SIGNAL,
1575
+ FAILED_ASSERT_NE_SIGNAL,
1576
+ FAILED_ASSERT_SIGNAL,
1577
+ FAILED_TRANSFER_TO_ADDRESS_SIGNAL as FAILED_TRANSFER_TO_ADDRESS_SIGNAL2,
1578
+ PANIC_REASONS,
1579
+ PANIC_DOC_URL
1580
+ } from "@fuel-ts/transactions/configs";
1581
+ var assemblePanicError = (status) => {
1582
+ let errorMessage = `The transaction reverted with reason: "${status.reason}".`;
1583
+ const reason = status.reason;
1584
+ if (PANIC_REASONS.includes(status.reason)) {
1585
+ errorMessage = `${errorMessage}
1586
+
1587
+ You can read more about this error at:
1588
+
1589
+ ${PANIC_DOC_URL}#variant.${status.reason}`;
1590
+ }
1591
+ return { errorMessage, reason };
1592
+ };
1593
+ var stringify = (obj) => JSON.stringify(obj, null, 2);
1594
+ var assembleRevertError = (receipts, logs) => {
1595
+ let errorMessage = "The transaction reverted with an unknown reason.";
1596
+ const revertReceipt = receipts.find(({ type }) => type === ReceiptType3.Revert);
1597
+ let reason = "";
1598
+ if (revertReceipt) {
1599
+ const reasonHex = bn6(revertReceipt.val).toHex();
1600
+ switch (reasonHex) {
1601
+ case FAILED_REQUIRE_SIGNAL: {
1602
+ reason = "require";
1603
+ errorMessage = `The transaction reverted because a "require" statement has thrown ${logs.length ? stringify(logs[0]) : "an error."}.`;
1604
+ break;
1605
+ }
1606
+ case FAILED_ASSERT_EQ_SIGNAL: {
1607
+ const sufix = logs.length >= 2 ? ` comparing ${stringify(logs[1])} and ${stringify(logs[0])}.` : ".";
1608
+ reason = "assert_eq";
1609
+ errorMessage = `The transaction reverted because of an "assert_eq" statement${sufix}`;
1610
+ break;
1611
+ }
1612
+ case FAILED_ASSERT_NE_SIGNAL: {
1613
+ const sufix = logs.length >= 2 ? ` comparing ${stringify(logs[1])} and ${stringify(logs[0])}.` : ".";
1614
+ reason = "assert_ne";
1615
+ errorMessage = `The transaction reverted because of an "assert_ne" statement${sufix}`;
1616
+ break;
1617
+ }
1618
+ case FAILED_ASSERT_SIGNAL:
1619
+ reason = "assert";
1620
+ errorMessage = `The transaction reverted because an "assert" statement failed to evaluate to true.`;
1621
+ break;
1622
+ case FAILED_TRANSFER_TO_ADDRESS_SIGNAL2:
1623
+ reason = "MissingOutputChange";
1624
+ errorMessage = `The transaction reverted because it's missing an "OutputChange".`;
1625
+ break;
1626
+ default:
1627
+ reason = "unknown";
1628
+ errorMessage = `The transaction reverted with an unknown reason: ${revertReceipt.val}`;
1629
+ }
1630
+ }
1631
+ return { errorMessage, reason };
1632
+ };
1633
+ var extractTxError = (params) => {
1634
+ const { receipts, status, logs } = params;
1635
+ const isPanic = receipts.some(({ type }) => type === ReceiptType3.Panic);
1636
+ const isRevert = receipts.some(({ type }) => type === ReceiptType3.Revert);
1637
+ const { errorMessage, reason } = status?.type === "FailureStatus" && isPanic ? assemblePanicError(status) : assembleRevertError(receipts, logs);
1638
+ const metadata = {
1639
+ logs,
1640
+ receipts,
1641
+ panic: isPanic,
1642
+ revert: isRevert,
1643
+ reason
1644
+ };
1645
+ return new FuelError7(ErrorCode7.SCRIPT_REVERTED, errorMessage, metadata);
1646
+ };
1647
+
1565
1648
  // src/providers/transaction-request/errors.ts
1566
1649
  var ChangeOutputCollisionError = class extends Error {
1567
1650
  name = "ChangeOutputCollisionError";
@@ -1624,10 +1707,10 @@ var BaseTransactionRequest = class {
1624
1707
  outputs,
1625
1708
  witnesses
1626
1709
  } = {}) {
1627
- this.gasPrice = bn6(gasPrice);
1710
+ this.gasPrice = bn7(gasPrice);
1628
1711
  this.maturity = maturity ?? 0;
1629
- this.witnessLimit = witnessLimit ? bn6(witnessLimit) : void 0;
1630
- this.maxFee = maxFee ? bn6(maxFee) : void 0;
1712
+ this.witnessLimit = witnessLimit ? bn7(witnessLimit) : void 0;
1713
+ this.maxFee = maxFee ? bn7(maxFee) : void 0;
1631
1714
  this.inputs = inputs ?? [];
1632
1715
  this.outputs = outputs ?? [];
1633
1716
  this.witnesses = witnesses ?? [];
@@ -1843,8 +1926,7 @@ var BaseTransactionRequest = class {
1843
1926
  assetId,
1844
1927
  txPointer: "0x00000000000000000000000000000000",
1845
1928
  witnessIndex,
1846
- predicate: predicate?.bytes,
1847
- predicateData: predicate?.predicateDataBytes
1929
+ predicate: predicate?.bytes
1848
1930
  };
1849
1931
  this.pushInput(input);
1850
1932
  this.addChangeOutput(owner, assetId);
@@ -1876,8 +1958,7 @@ var BaseTransactionRequest = class {
1876
1958
  recipient: recipient.toB256(),
1877
1959
  amount,
1878
1960
  witnessIndex,
1879
- predicate: predicate?.bytes,
1880
- predicateData: predicate?.predicateDataBytes
1961
+ predicate: predicate?.bytes
1881
1962
  };
1882
1963
  this.pushInput(input);
1883
1964
  this.addChangeOutput(recipient, assetId);
@@ -2032,12 +2113,6 @@ var BaseTransactionRequest = class {
2032
2113
  * @param quantities - CoinQuantity Array.
2033
2114
  */
2034
2115
  fundWithFakeUtxos(quantities, resourcesOwner) {
2035
- let idCounter = 0;
2036
- const generateId = () => {
2037
- const counterString = String(idCounter++);
2038
- const id = ZeroBytes324.slice(0, -counterString.length).concat(counterString);
2039
- return id;
2040
- };
2041
2116
  const findAssetInput = (assetId) => this.inputs.find((input) => {
2042
2117
  if ("assetId" in input) {
2043
2118
  return input.assetId === assetId;
@@ -2047,23 +2122,23 @@ var BaseTransactionRequest = class {
2047
2122
  const updateAssetInput = (assetId, quantity) => {
2048
2123
  const assetInput = findAssetInput(assetId);
2049
2124
  if (assetInput && "assetId" in assetInput) {
2050
- assetInput.id = generateId();
2125
+ assetInput.id = hexlify7(randomBytes(UTXO_ID_LEN2));
2051
2126
  assetInput.amount = quantity;
2052
2127
  } else {
2053
2128
  this.addResources([
2054
2129
  {
2055
- id: generateId(),
2130
+ id: hexlify7(randomBytes(UTXO_ID_LEN2)),
2056
2131
  amount: quantity,
2057
2132
  assetId,
2058
2133
  owner: resourcesOwner || Address.fromRandom(),
2059
2134
  maturity: 0,
2060
- blockCreated: bn6(1),
2061
- txCreatedIdx: bn6(1)
2135
+ blockCreated: bn7(1),
2136
+ txCreatedIdx: bn7(1)
2062
2137
  }
2063
2138
  ]);
2064
2139
  }
2065
2140
  };
2066
- updateAssetInput(BaseAssetId2, bn6(1e11));
2141
+ updateAssetInput(BaseAssetId2, bn7(1e11));
2067
2142
  quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
2068
2143
  }
2069
2144
  /**
@@ -2074,7 +2149,7 @@ var BaseTransactionRequest = class {
2074
2149
  */
2075
2150
  getCoinOutputsQuantities() {
2076
2151
  const coinsQuantities = this.getCoinOutputs().map(({ amount, assetId }) => ({
2077
- amount: bn6(amount),
2152
+ amount: bn7(amount),
2078
2153
  assetId: assetId.toString()
2079
2154
  }));
2080
2155
  return coinsQuantities;
@@ -2103,7 +2178,7 @@ var BaseTransactionRequest = class {
2103
2178
  default:
2104
2179
  return;
2105
2180
  }
2106
- if (correspondingInput && "predicateGasUsed" in correspondingInput && bn6(correspondingInput.predicateGasUsed).gt(0)) {
2181
+ if (correspondingInput && "predicateGasUsed" in correspondingInput && bn7(correspondingInput.predicateGasUsed).gt(0)) {
2107
2182
  i.predicate = correspondingInput.predicate;
2108
2183
  i.predicateData = correspondingInput.predicateData;
2109
2184
  i.predicateGasUsed = correspondingInput.predicateGasUsed;
@@ -2114,14 +2189,14 @@ var BaseTransactionRequest = class {
2114
2189
 
2115
2190
  // src/providers/transaction-request/create-transaction-request.ts
2116
2191
  import { ZeroBytes32 as ZeroBytes326 } from "@fuel-ts/address/configs";
2117
- import { bn as bn8 } from "@fuel-ts/math";
2192
+ import { bn as bn9 } from "@fuel-ts/math";
2118
2193
  import { TransactionType as TransactionType3, OutputType as OutputType4 } from "@fuel-ts/transactions";
2119
2194
  import { arrayify as arrayify6, hexlify as hexlify9 } from "@fuel-ts/utils";
2120
2195
 
2121
2196
  // src/providers/transaction-request/hash-transaction.ts
2122
2197
  import { ZeroBytes32 as ZeroBytes325 } from "@fuel-ts/address/configs";
2123
2198
  import { uint64ToBytesBE, sha256 } from "@fuel-ts/hasher";
2124
- import { bn as bn7 } from "@fuel-ts/math";
2199
+ import { bn as bn8 } from "@fuel-ts/math";
2125
2200
  import { TransactionType as TransactionType2, InputType as InputType3, OutputType as OutputType3, TransactionCoder as TransactionCoder2 } from "@fuel-ts/transactions";
2126
2201
  import { concat as concat2 } from "@fuel-ts/utils";
2127
2202
  import { clone as clone2 } from "ramda";
@@ -2138,11 +2213,11 @@ function hashTransaction(transactionRequest, chainId) {
2138
2213
  blockHeight: 0,
2139
2214
  txIndex: 0
2140
2215
  };
2141
- inputClone.predicateGasUsed = bn7(0);
2216
+ inputClone.predicateGasUsed = bn8(0);
2142
2217
  return inputClone;
2143
2218
  }
2144
2219
  case InputType3.Message: {
2145
- inputClone.predicateGasUsed = bn7(0);
2220
+ inputClone.predicateGasUsed = bn8(0);
2146
2221
  return inputClone;
2147
2222
  }
2148
2223
  case InputType3.Contract: {
@@ -2169,12 +2244,12 @@ function hashTransaction(transactionRequest, chainId) {
2169
2244
  return outputClone;
2170
2245
  }
2171
2246
  case OutputType3.Change: {
2172
- outputClone.amount = bn7(0);
2247
+ outputClone.amount = bn8(0);
2173
2248
  return outputClone;
2174
2249
  }
2175
2250
  case OutputType3.Variable: {
2176
2251
  outputClone.to = ZeroBytes325;
2177
- outputClone.amount = bn7(0);
2252
+ outputClone.amount = bn8(0);
2178
2253
  outputClone.assetId = ZeroBytes325;
2179
2254
  return outputClone;
2180
2255
  }
@@ -2298,7 +2373,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2298
2373
  }
2299
2374
  metadataGas(gasCosts) {
2300
2375
  return calculateMetadataGasForTxCreate({
2301
- contractBytesSize: bn8(arrayify6(this.witnesses[this.bytecodeWitnessIndex] || "0x").length),
2376
+ contractBytesSize: bn9(arrayify6(this.witnesses[this.bytecodeWitnessIndex] || "0x").length),
2302
2377
  gasCosts,
2303
2378
  stateRootSize: this.storageSlots.length,
2304
2379
  txBytesSize: this.byteSize()
@@ -2310,7 +2385,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2310
2385
  import { Interface } from "@fuel-ts/abi-coder";
2311
2386
  import { addressify as addressify2 } from "@fuel-ts/address";
2312
2387
  import { ZeroBytes32 as ZeroBytes327 } from "@fuel-ts/address/configs";
2313
- import { bn as bn9 } from "@fuel-ts/math";
2388
+ import { bn as bn10 } from "@fuel-ts/math";
2314
2389
  import { InputType as InputType4, OutputType as OutputType5, TransactionType as TransactionType4 } from "@fuel-ts/transactions";
2315
2390
  import { arrayify as arrayify8, hexlify as hexlify10 } from "@fuel-ts/utils";
2316
2391
 
@@ -2356,6 +2431,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2356
2431
  script;
2357
2432
  /** Script input data (parameters) */
2358
2433
  scriptData;
2434
+ abis;
2359
2435
  /**
2360
2436
  * Constructor for `ScriptTransactionRequest`.
2361
2437
  *
@@ -2363,9 +2439,10 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2363
2439
  */
2364
2440
  constructor({ script, scriptData, gasLimit, ...rest } = {}) {
2365
2441
  super(rest);
2366
- this.gasLimit = bn9(gasLimit);
2442
+ this.gasLimit = bn10(gasLimit);
2367
2443
  this.script = arrayify8(script ?? returnZeroScript.bytes);
2368
2444
  this.scriptData = arrayify8(scriptData ?? returnZeroScript.encodeScriptData());
2445
+ this.abis = rest.abis;
2369
2446
  }
2370
2447
  /**
2371
2448
  * Converts the transaction request to a `TransactionScript`.
@@ -2510,7 +2587,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2510
2587
  };
2511
2588
 
2512
2589
  // src/providers/transaction-request/utils.ts
2513
- import { ErrorCode as ErrorCode7, FuelError as FuelError7 } from "@fuel-ts/errors";
2590
+ import { ErrorCode as ErrorCode8, FuelError as FuelError8 } from "@fuel-ts/errors";
2514
2591
  import { TransactionType as TransactionType5 } from "@fuel-ts/transactions";
2515
2592
  var transactionRequestify = (obj) => {
2516
2593
  if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest) {
@@ -2525,14 +2602,14 @@ var transactionRequestify = (obj) => {
2525
2602
  return CreateTransactionRequest.from(obj);
2526
2603
  }
2527
2604
  default: {
2528
- throw new FuelError7(ErrorCode7.INVALID_TRANSACTION_TYPE, `Invalid transaction type: ${type}.`);
2605
+ throw new FuelError8(ErrorCode8.INVALID_TRANSACTION_TYPE, `Invalid transaction type: ${type}.`);
2529
2606
  }
2530
2607
  }
2531
2608
  };
2532
2609
 
2533
2610
  // src/providers/transaction-response/transaction-response.ts
2534
- import { ErrorCode as ErrorCode11, FuelError as FuelError11 } from "@fuel-ts/errors";
2535
- import { bn as bn13 } from "@fuel-ts/math";
2611
+ import { ErrorCode as ErrorCode12, FuelError as FuelError12 } from "@fuel-ts/errors";
2612
+ import { bn as bn14 } from "@fuel-ts/math";
2536
2613
  import { TransactionCoder as TransactionCoder4 } from "@fuel-ts/transactions";
2537
2614
  import { arrayify as arrayify10 } from "@fuel-ts/utils";
2538
2615
 
@@ -2540,7 +2617,7 @@ import { arrayify as arrayify10 } from "@fuel-ts/utils";
2540
2617
  import { DateTime, hexlify as hexlify11 } from "@fuel-ts/utils";
2541
2618
 
2542
2619
  // src/providers/transaction-summary/calculate-transaction-fee.ts
2543
- import { bn as bn10 } from "@fuel-ts/math";
2620
+ import { bn as bn11 } from "@fuel-ts/math";
2544
2621
  import { PolicyType as PolicyType2, TransactionCoder as TransactionCoder3, TransactionType as TransactionType6 } from "@fuel-ts/transactions";
2545
2622
  import { arrayify as arrayify9 } from "@fuel-ts/utils";
2546
2623
  var calculateTransactionFee = (params) => {
@@ -2549,24 +2626,24 @@ var calculateTransactionFee = (params) => {
2549
2626
  rawPayload,
2550
2627
  consensusParameters: { gasCosts, feeParams }
2551
2628
  } = params;
2552
- const gasPerByte = bn10(feeParams.gasPerByte);
2553
- const gasPriceFactor = bn10(feeParams.gasPriceFactor);
2629
+ const gasPerByte = bn11(feeParams.gasPerByte);
2630
+ const gasPriceFactor = bn11(feeParams.gasPriceFactor);
2554
2631
  const transactionBytes = arrayify9(rawPayload);
2555
2632
  const [transaction] = new TransactionCoder3().decode(transactionBytes, 0);
2556
2633
  if (transaction.type === TransactionType6.Mint) {
2557
2634
  return {
2558
- fee: bn10(0),
2559
- minFee: bn10(0),
2560
- maxFee: bn10(0),
2561
- feeFromGasUsed: bn10(0)
2635
+ fee: bn11(0),
2636
+ minFee: bn11(0),
2637
+ maxFee: bn11(0),
2638
+ feeFromGasUsed: bn11(0)
2562
2639
  };
2563
2640
  }
2564
2641
  const { type, witnesses, inputs, policies } = transaction;
2565
- let metadataGas = bn10(0);
2566
- let gasLimit = bn10(0);
2642
+ let metadataGas = bn11(0);
2643
+ let gasLimit = bn11(0);
2567
2644
  if (type === TransactionType6.Create) {
2568
2645
  const { bytecodeWitnessIndex, storageSlots } = transaction;
2569
- const contractBytesSize = bn10(arrayify9(witnesses[bytecodeWitnessIndex].data).length);
2646
+ const contractBytesSize = bn11(arrayify9(witnesses[bytecodeWitnessIndex].data).length);
2570
2647
  metadataGas = calculateMetadataGasForTxCreate({
2571
2648
  contractBytesSize,
2572
2649
  gasCosts,
@@ -2585,12 +2662,12 @@ var calculateTransactionFee = (params) => {
2585
2662
  }
2586
2663
  const minGas = getMinGas({
2587
2664
  gasCosts,
2588
- gasPerByte: bn10(gasPerByte),
2665
+ gasPerByte: bn11(gasPerByte),
2589
2666
  inputs,
2590
2667
  metadataGas,
2591
2668
  txBytesSize: transactionBytes.length
2592
2669
  });
2593
- const gasPrice = bn10(policies.find((policy) => policy.type === PolicyType2.GasPrice)?.data);
2670
+ const gasPrice = bn11(policies.find((policy) => policy.type === PolicyType2.GasPrice)?.data);
2594
2671
  const witnessLimit = policies.find((policy) => policy.type === PolicyType2.WitnessLimit)?.data;
2595
2672
  const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
2596
2673
  const maxGas = getMaxGas({
@@ -2614,13 +2691,13 @@ var calculateTransactionFee = (params) => {
2614
2691
 
2615
2692
  // src/providers/transaction-summary/operations.ts
2616
2693
  import { ZeroBytes32 as ZeroBytes328 } from "@fuel-ts/address/configs";
2617
- import { ErrorCode as ErrorCode9, FuelError as FuelError9 } from "@fuel-ts/errors";
2618
- import { bn as bn12 } from "@fuel-ts/math";
2619
- import { ReceiptType as ReceiptType3, TransactionType as TransactionType7 } from "@fuel-ts/transactions";
2694
+ import { ErrorCode as ErrorCode10, FuelError as FuelError10 } from "@fuel-ts/errors";
2695
+ import { bn as bn13 } from "@fuel-ts/math";
2696
+ import { ReceiptType as ReceiptType4, TransactionType as TransactionType7 } from "@fuel-ts/transactions";
2620
2697
 
2621
2698
  // src/providers/transaction-summary/call.ts
2622
2699
  import { Interface as Interface2, calculateVmTxMemory } from "@fuel-ts/abi-coder";
2623
- import { bn as bn11 } from "@fuel-ts/math";
2700
+ import { bn as bn12 } from "@fuel-ts/math";
2624
2701
  var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
2625
2702
  const abiInterface = new Interface2(abi);
2626
2703
  const callFunctionSelector = receipt.param1.toHex(8);
@@ -2629,7 +2706,7 @@ var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
2629
2706
  let encodedArgs;
2630
2707
  if (functionFragment.isInputDataPointer) {
2631
2708
  if (rawPayload) {
2632
- const argsOffset = bn11(receipt.param2).sub(calculateVmTxMemory({ maxInputs: maxInputs.toNumber() })).toNumber();
2709
+ const argsOffset = bn12(receipt.param2).sub(calculateVmTxMemory({ maxInputs: maxInputs.toNumber() })).toNumber();
2633
2710
  encodedArgs = `0x${rawPayload.slice(2).slice(argsOffset * 2)}`;
2634
2711
  }
2635
2712
  } else {
@@ -2663,7 +2740,7 @@ var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
2663
2740
  };
2664
2741
 
2665
2742
  // src/providers/transaction-summary/input.ts
2666
- import { ErrorCode as ErrorCode8, FuelError as FuelError8 } from "@fuel-ts/errors";
2743
+ import { ErrorCode as ErrorCode9, FuelError as FuelError9 } from "@fuel-ts/errors";
2667
2744
  import { InputType as InputType5 } from "@fuel-ts/transactions";
2668
2745
  function getInputsByTypes(inputs, types) {
2669
2746
  return inputs.filter((i) => types.includes(i.type));
@@ -2701,8 +2778,8 @@ function getInputContractFromIndex(inputs, inputIndex) {
2701
2778
  return void 0;
2702
2779
  }
2703
2780
  if (contractInput.type !== InputType5.Contract) {
2704
- throw new FuelError8(
2705
- ErrorCode8.INVALID_TRANSACTION_INPUT,
2781
+ throw new FuelError9(
2782
+ ErrorCode9.INVALID_TRANSACTION_INPUT,
2706
2783
  `Contract input should be of type 'contract'.`
2707
2784
  );
2708
2785
  }
@@ -2790,8 +2867,8 @@ function getTransactionTypeName(transactionType) {
2790
2867
  case TransactionType7.Script:
2791
2868
  return "Script" /* Script */;
2792
2869
  default:
2793
- throw new FuelError9(
2794
- ErrorCode9.INVALID_TRANSACTION_TYPE,
2870
+ throw new FuelError10(
2871
+ ErrorCode10.INVALID_TRANSACTION_TYPE,
2795
2872
  `Invalid transaction type: ${transactionType}.`
2796
2873
  );
2797
2874
  }
@@ -2813,10 +2890,10 @@ function hasSameAssetId(a) {
2813
2890
  return (b) => a.assetId === b.assetId;
2814
2891
  }
2815
2892
  function getReceiptsCall(receipts) {
2816
- return getReceiptsByType(receipts, ReceiptType3.Call);
2893
+ return getReceiptsByType(receipts, ReceiptType4.Call);
2817
2894
  }
2818
2895
  function getReceiptsMessageOut(receipts) {
2819
- return getReceiptsByType(receipts, ReceiptType3.MessageOut);
2896
+ return getReceiptsByType(receipts, ReceiptType4.MessageOut);
2820
2897
  }
2821
2898
  var mergeAssets = (op1, op2) => {
2822
2899
  const assets1 = op1.assetsSent || [];
@@ -2829,7 +2906,7 @@ var mergeAssets = (op1, op2) => {
2829
2906
  if (!matchingAsset) {
2830
2907
  return asset1;
2831
2908
  }
2832
- const mergedAmount = bn12(asset1.amount).add(matchingAsset.amount);
2909
+ const mergedAmount = bn13(asset1.amount).add(matchingAsset.amount);
2833
2910
  return { ...asset1, amount: mergedAmount };
2834
2911
  });
2835
2912
  return mergedAssets.concat(filteredAssets);
@@ -2855,7 +2932,7 @@ function addOperation(operations, toAdd) {
2855
2932
  return allOperations;
2856
2933
  }
2857
2934
  function getReceiptsTransferOut(receipts) {
2858
- return getReceiptsByType(receipts, ReceiptType3.TransferOut);
2935
+ return getReceiptsByType(receipts, ReceiptType4.TransferOut);
2859
2936
  }
2860
2937
  function getWithdrawFromFuelOperations({
2861
2938
  inputs,
@@ -3015,11 +3092,11 @@ function getTransferOperations({
3015
3092
  });
3016
3093
  const transferReceipts = getReceiptsByType(
3017
3094
  receipts,
3018
- ReceiptType3.Transfer
3095
+ ReceiptType4.Transfer
3019
3096
  );
3020
3097
  const transferOutReceipts = getReceiptsByType(
3021
3098
  receipts,
3022
- ReceiptType3.TransferOut
3099
+ ReceiptType4.TransferOut
3023
3100
  );
3024
3101
  [...transferReceipts, ...transferOutReceipts].forEach((receipt) => {
3025
3102
  const operation = extractTransferOperationFromReceipt(receipt, contractInputs, changeOutputs);
@@ -3104,17 +3181,17 @@ function getOperations({
3104
3181
  }
3105
3182
 
3106
3183
  // src/providers/transaction-summary/receipt.ts
3107
- import { ReceiptType as ReceiptType4 } from "@fuel-ts/transactions";
3184
+ import { ReceiptType as ReceiptType5 } from "@fuel-ts/transactions";
3108
3185
  var processGqlReceipt = (gqlReceipt) => {
3109
3186
  const receipt = assembleReceiptByType(gqlReceipt);
3110
3187
  switch (receipt.type) {
3111
- case ReceiptType4.ReturnData: {
3188
+ case ReceiptType5.ReturnData: {
3112
3189
  return {
3113
3190
  ...receipt,
3114
3191
  data: gqlReceipt.data || "0x"
3115
3192
  };
3116
3193
  }
3117
- case ReceiptType4.LogData: {
3194
+ case ReceiptType5.LogData: {
3118
3195
  return {
3119
3196
  ...receipt,
3120
3197
  data: gqlReceipt.data || "0x"
@@ -3127,7 +3204,7 @@ var processGqlReceipt = (gqlReceipt) => {
3127
3204
  var extractMintedAssetsFromReceipts = (receipts) => {
3128
3205
  const mintedAssets = [];
3129
3206
  receipts.forEach((receipt) => {
3130
- if (receipt.type === ReceiptType4.Mint) {
3207
+ if (receipt.type === ReceiptType5.Mint) {
3131
3208
  mintedAssets.push({
3132
3209
  subId: receipt.subId,
3133
3210
  contractId: receipt.contractId,
@@ -3141,7 +3218,7 @@ var extractMintedAssetsFromReceipts = (receipts) => {
3141
3218
  var extractBurnedAssetsFromReceipts = (receipts) => {
3142
3219
  const burnedAssets = [];
3143
3220
  receipts.forEach((receipt) => {
3144
- if (receipt.type === ReceiptType4.Burn) {
3221
+ if (receipt.type === ReceiptType5.Burn) {
3145
3222
  burnedAssets.push({
3146
3223
  subId: receipt.subId,
3147
3224
  contractId: receipt.contractId,
@@ -3154,7 +3231,7 @@ var extractBurnedAssetsFromReceipts = (receipts) => {
3154
3231
  };
3155
3232
 
3156
3233
  // src/providers/transaction-summary/status.ts
3157
- import { ErrorCode as ErrorCode10, FuelError as FuelError10 } from "@fuel-ts/errors";
3234
+ import { ErrorCode as ErrorCode11, FuelError as FuelError11 } from "@fuel-ts/errors";
3158
3235
  var getTransactionStatusName = (gqlStatus) => {
3159
3236
  switch (gqlStatus) {
3160
3237
  case "FailureStatus":
@@ -3166,8 +3243,8 @@ var getTransactionStatusName = (gqlStatus) => {
3166
3243
  case "SqueezedOutStatus":
3167
3244
  return "squeezedout" /* squeezedout */;
3168
3245
  default:
3169
- throw new FuelError10(
3170
- ErrorCode10.INVALID_TRANSACTION_STATUS,
3246
+ throw new FuelError11(
3247
+ ErrorCode11.INVALID_TRANSACTION_STATUS,
3171
3248
  `Invalid transaction status: ${gqlStatus}.`
3172
3249
  );
3173
3250
  }
@@ -3278,6 +3355,21 @@ function assembleTransactionSummary(params) {
3278
3355
  return transactionSummary;
3279
3356
  }
3280
3357
 
3358
+ // src/providers/transaction-response/getDecodedLogs.ts
3359
+ import { Interface as Interface3, BigNumberCoder } from "@fuel-ts/abi-coder";
3360
+ import { ReceiptType as ReceiptType6 } from "@fuel-ts/transactions";
3361
+ function getDecodedLogs(receipts, mainAbi, externalAbis = {}) {
3362
+ return receipts.reduce((logs, receipt) => {
3363
+ if (receipt.type === ReceiptType6.LogData || receipt.type === ReceiptType6.Log) {
3364
+ const interfaceToUse = new Interface3(externalAbis[receipt.id] || mainAbi);
3365
+ const data = receipt.type === ReceiptType6.Log ? new BigNumberCoder("u64").encode(receipt.val0) : receipt.data;
3366
+ const [decodedLog] = interfaceToUse.decodeLog(data, receipt.val1.toNumber());
3367
+ logs.push(decodedLog);
3368
+ }
3369
+ return logs;
3370
+ }, []);
3371
+ }
3372
+
3281
3373
  // src/providers/transaction-response/transaction-response.ts
3282
3374
  var TransactionResponse = class {
3283
3375
  /** Transaction ID */
@@ -3285,18 +3377,20 @@ var TransactionResponse = class {
3285
3377
  /** Current provider */
3286
3378
  provider;
3287
3379
  /** Gas used on the transaction */
3288
- gasUsed = bn13(0);
3380
+ gasUsed = bn14(0);
3289
3381
  /** The graphql Transaction with receipts object. */
3290
3382
  gqlTransaction;
3383
+ abis;
3291
3384
  /**
3292
3385
  * Constructor for `TransactionResponse`.
3293
3386
  *
3294
3387
  * @param id - The transaction ID.
3295
3388
  * @param provider - The provider.
3296
3389
  */
3297
- constructor(id, provider) {
3390
+ constructor(id, provider, abis) {
3298
3391
  this.id = id;
3299
3392
  this.provider = provider;
3393
+ this.abis = abis;
3300
3394
  }
3301
3395
  /**
3302
3396
  * Async constructor for `TransactionResponse`. This method can be used to create
@@ -3306,8 +3400,8 @@ var TransactionResponse = class {
3306
3400
  * @param id - The transaction ID.
3307
3401
  * @param provider - The provider.
3308
3402
  */
3309
- static async create(id, provider) {
3310
- const response = new TransactionResponse(id, provider);
3403
+ static async create(id, provider, abis) {
3404
+ const response = new TransactionResponse(id, provider, abis);
3311
3405
  await response.fetch();
3312
3406
  return response;
3313
3407
  }
@@ -3388,8 +3482,8 @@ var TransactionResponse = class {
3388
3482
  });
3389
3483
  for await (const { statusChange } of subscription) {
3390
3484
  if (statusChange.type === "SqueezedOutStatus") {
3391
- throw new FuelError11(
3392
- ErrorCode11.TRANSACTION_SQUEEZED_OUT,
3485
+ throw new FuelError12(
3486
+ ErrorCode12.TRANSACTION_SQUEEZED_OUT,
3393
3487
  `Transaction Squeezed Out with reason: ${statusChange.reason}`
3394
3488
  );
3395
3489
  }
@@ -3411,6 +3505,26 @@ var TransactionResponse = class {
3411
3505
  gqlTransaction: this.gqlTransaction,
3412
3506
  ...transactionSummary
3413
3507
  };
3508
+ let logs = [];
3509
+ if (this.abis) {
3510
+ logs = getDecodedLogs(
3511
+ transactionSummary.receipts,
3512
+ this.abis.main,
3513
+ this.abis.otherContractsAbis
3514
+ );
3515
+ transactionResult.logs = logs;
3516
+ }
3517
+ if (transactionResult.isStatusFailure) {
3518
+ const {
3519
+ receipts,
3520
+ gqlTransaction: { status }
3521
+ } = transactionResult;
3522
+ throw extractTxError({
3523
+ receipts,
3524
+ status,
3525
+ logs
3526
+ });
3527
+ }
3414
3528
  return transactionResult;
3415
3529
  }
3416
3530
  /**
@@ -3419,34 +3533,10 @@ var TransactionResponse = class {
3419
3533
  * @param contractsAbiMap - The contracts ABI map.
3420
3534
  */
3421
3535
  async wait(contractsAbiMap) {
3422
- const result = await this.waitForResult(contractsAbiMap);
3423
- if (result.isStatusFailure) {
3424
- throw new FuelError11(
3425
- ErrorCode11.TRANSACTION_FAILED,
3426
- `Transaction failed: ${result.gqlTransaction.status.reason}`
3427
- );
3428
- }
3429
- return result;
3536
+ return this.waitForResult(contractsAbiMap);
3430
3537
  }
3431
3538
  };
3432
3539
 
3433
- // src/providers/transaction-response/getDecodedLogs.ts
3434
- import { BigNumberCoder } from "@fuel-ts/abi-coder";
3435
- import { ReceiptType as ReceiptType5 } from "@fuel-ts/transactions";
3436
- function getDecodedLogs(receipts, abiInterface) {
3437
- return receipts.reduce((logs, r) => {
3438
- if (r.type === ReceiptType5.LogData) {
3439
- logs.push(abiInterface.decodeLog(r.data, r.val1.toNumber(), r.id)[0]);
3440
- }
3441
- if (r.type === ReceiptType5.Log) {
3442
- logs.push(
3443
- abiInterface.decodeLog(new BigNumberCoder("u64").encode(r.val0), r.val1.toNumber(), r.id)[0]
3444
- );
3445
- }
3446
- return logs;
3447
- }, []);
3448
- }
3449
-
3450
3540
  // src/providers/utils/auto-retry-fetch.ts
3451
3541
  function getWaitDelay(options, retryAttemptNum) {
3452
3542
  const duration = options.baseDelay ?? 150;
@@ -3505,29 +3595,29 @@ var processGqlChain = (chain) => {
3505
3595
  const { contractParams, feeParams, predicateParams, scriptParams, txParams, gasCosts } = consensusParameters;
3506
3596
  return {
3507
3597
  name,
3508
- baseChainHeight: bn14(daHeight),
3598
+ baseChainHeight: bn15(daHeight),
3509
3599
  consensusParameters: {
3510
- contractMaxSize: bn14(contractParams.contractMaxSize),
3511
- maxInputs: bn14(txParams.maxInputs),
3512
- maxOutputs: bn14(txParams.maxOutputs),
3513
- maxWitnesses: bn14(txParams.maxWitnesses),
3514
- maxGasPerTx: bn14(txParams.maxGasPerTx),
3515
- maxScriptLength: bn14(scriptParams.maxScriptLength),
3516
- maxScriptDataLength: bn14(scriptParams.maxScriptDataLength),
3517
- maxStorageSlots: bn14(contractParams.maxStorageSlots),
3518
- maxPredicateLength: bn14(predicateParams.maxPredicateLength),
3519
- maxPredicateDataLength: bn14(predicateParams.maxPredicateDataLength),
3520
- maxGasPerPredicate: bn14(predicateParams.maxGasPerPredicate),
3521
- gasPriceFactor: bn14(feeParams.gasPriceFactor),
3522
- gasPerByte: bn14(feeParams.gasPerByte),
3523
- maxMessageDataLength: bn14(predicateParams.maxMessageDataLength),
3524
- chainId: bn14(consensusParameters.chainId),
3600
+ contractMaxSize: bn15(contractParams.contractMaxSize),
3601
+ maxInputs: bn15(txParams.maxInputs),
3602
+ maxOutputs: bn15(txParams.maxOutputs),
3603
+ maxWitnesses: bn15(txParams.maxWitnesses),
3604
+ maxGasPerTx: bn15(txParams.maxGasPerTx),
3605
+ maxScriptLength: bn15(scriptParams.maxScriptLength),
3606
+ maxScriptDataLength: bn15(scriptParams.maxScriptDataLength),
3607
+ maxStorageSlots: bn15(contractParams.maxStorageSlots),
3608
+ maxPredicateLength: bn15(predicateParams.maxPredicateLength),
3609
+ maxPredicateDataLength: bn15(predicateParams.maxPredicateDataLength),
3610
+ maxGasPerPredicate: bn15(predicateParams.maxGasPerPredicate),
3611
+ gasPriceFactor: bn15(feeParams.gasPriceFactor),
3612
+ gasPerByte: bn15(feeParams.gasPerByte),
3613
+ maxMessageDataLength: bn15(predicateParams.maxMessageDataLength),
3614
+ chainId: bn15(consensusParameters.chainId),
3525
3615
  gasCosts
3526
3616
  },
3527
3617
  gasCosts,
3528
3618
  latestBlock: {
3529
3619
  id: latestBlock.id,
3530
- height: bn14(latestBlock.header.height),
3620
+ height: bn15(latestBlock.header.height),
3531
3621
  time: latestBlock.header.time,
3532
3622
  transactions: latestBlock.transactions.map((i) => ({
3533
3623
  id: i.id
@@ -3597,8 +3687,8 @@ var _Provider = class {
3597
3687
  getChain() {
3598
3688
  const chain = _Provider.chainInfoCache[this.url];
3599
3689
  if (!chain) {
3600
- throw new FuelError12(
3601
- ErrorCode12.CHAIN_INFO_CACHE_EMPTY,
3690
+ throw new FuelError13(
3691
+ ErrorCode13.CHAIN_INFO_CACHE_EMPTY,
3602
3692
  "Chain info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
3603
3693
  );
3604
3694
  }
@@ -3610,8 +3700,8 @@ var _Provider = class {
3610
3700
  getNode() {
3611
3701
  const node = _Provider.nodeInfoCache[this.url];
3612
3702
  if (!node) {
3613
- throw new FuelError12(
3614
- ErrorCode12.NODE_INFO_CACHE_EMPTY,
3703
+ throw new FuelError13(
3704
+ ErrorCode13.NODE_INFO_CACHE_EMPTY,
3615
3705
  "Node info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
3616
3706
  );
3617
3707
  }
@@ -3658,8 +3748,8 @@ var _Provider = class {
3658
3748
  static ensureClientVersionIsSupported(nodeInfo) {
3659
3749
  const { isMajorSupported, isMinorSupported, supportedVersion } = checkFuelCoreVersionCompatibility(nodeInfo.nodeVersion);
3660
3750
  if (!isMajorSupported || !isMinorSupported) {
3661
- throw new FuelError12(
3662
- FuelError12.CODES.UNSUPPORTED_FUEL_CLIENT_VERSION,
3751
+ throw new FuelError13(
3752
+ FuelError13.CODES.UNSUPPORTED_FUEL_CLIENT_VERSION,
3663
3753
  `Fuel client version: ${nodeInfo.nodeVersion}, Supported version: ${supportedVersion}`
3664
3754
  );
3665
3755
  }
@@ -3722,7 +3812,7 @@ var _Provider = class {
3722
3812
  */
3723
3813
  async getBlockNumber() {
3724
3814
  const { chain } = await this.operations.getChain();
3725
- return bn14(chain.latestBlock.header.height, 10);
3815
+ return bn15(chain.latestBlock.header.height, 10);
3726
3816
  }
3727
3817
  /**
3728
3818
  * Returns the chain information.
@@ -3732,9 +3822,9 @@ var _Provider = class {
3732
3822
  async fetchNode() {
3733
3823
  const { nodeInfo } = await this.operations.getNodeInfo();
3734
3824
  const processedNodeInfo = {
3735
- maxDepth: bn14(nodeInfo.maxDepth),
3736
- maxTx: bn14(nodeInfo.maxTx),
3737
- minGasPrice: bn14(nodeInfo.minGasPrice),
3825
+ maxDepth: bn15(nodeInfo.maxDepth),
3826
+ maxTx: bn15(nodeInfo.maxTx),
3827
+ minGasPrice: bn15(nodeInfo.minGasPrice),
3738
3828
  nodeVersion: nodeInfo.nodeVersion,
3739
3829
  utxoValidation: nodeInfo.utxoValidation,
3740
3830
  vmBacktrace: nodeInfo.vmBacktrace,
@@ -3781,12 +3871,16 @@ var _Provider = class {
3781
3871
  await this.estimateTxDependencies(transactionRequest);
3782
3872
  }
3783
3873
  const encodedTransaction = hexlify12(transactionRequest.toTransactionBytes());
3874
+ let abis;
3875
+ if (transactionRequest.type === TransactionType8.Script) {
3876
+ abis = transactionRequest.abis;
3877
+ }
3784
3878
  if (awaitExecution) {
3785
3879
  const subscription = this.operations.submitAndAwait({ encodedTransaction });
3786
3880
  for await (const { submitAndAwait } of subscription) {
3787
3881
  if (submitAndAwait.type === "SqueezedOutStatus") {
3788
- throw new FuelError12(
3789
- ErrorCode12.TRANSACTION_SQUEEZED_OUT,
3882
+ throw new FuelError13(
3883
+ ErrorCode13.TRANSACTION_SQUEEZED_OUT,
3790
3884
  `Transaction Squeezed Out with reason: ${submitAndAwait.reason}`
3791
3885
  );
3792
3886
  }
@@ -3795,14 +3889,14 @@ var _Provider = class {
3795
3889
  }
3796
3890
  }
3797
3891
  const transactionId2 = transactionRequest.getTransactionId(this.getChainId());
3798
- const response = new TransactionResponse(transactionId2, this);
3892
+ const response = new TransactionResponse(transactionId2, this, abis);
3799
3893
  await response.fetch();
3800
3894
  return response;
3801
3895
  }
3802
3896
  const {
3803
3897
  submit: { id: transactionId }
3804
3898
  } = await this.operations.submit({ encodedTransaction });
3805
- return new TransactionResponse(transactionId, this);
3899
+ return new TransactionResponse(transactionId, this, abis);
3806
3900
  }
3807
3901
  /**
3808
3902
  * Executes a transaction without actually submitting it to the chain.
@@ -3853,7 +3947,7 @@ var _Provider = class {
3853
3947
  } = response;
3854
3948
  if (inputs) {
3855
3949
  inputs.forEach((input, index) => {
3856
- if ("predicateGasUsed" in input && bn14(input.predicateGasUsed).gt(0)) {
3950
+ if ("predicateGasUsed" in input && bn15(input.predicateGasUsed).gt(0)) {
3857
3951
  transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
3858
3952
  }
3859
3953
  });
@@ -3910,6 +4004,36 @@ var _Provider = class {
3910
4004
  missingContractIds
3911
4005
  };
3912
4006
  }
4007
+ /**
4008
+ * Estimates the transaction gas and fee based on the provided transaction request.
4009
+ * @param transactionRequest - The transaction request object.
4010
+ * @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
4011
+ */
4012
+ estimateTxGasAndFee(params) {
4013
+ const { transactionRequest } = params;
4014
+ const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
4015
+ const chainInfo = this.getChain();
4016
+ const gasPrice = transactionRequest.gasPrice.eq(0) ? minGasPrice : transactionRequest.gasPrice;
4017
+ transactionRequest.gasPrice = gasPrice;
4018
+ const minGas = transactionRequest.calculateMinGas(chainInfo);
4019
+ const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4020
+ if (transactionRequest.type === TransactionType8.Script) {
4021
+ if (transactionRequest.gasLimit.eq(0)) {
4022
+ transactionRequest.gasLimit = minGas;
4023
+ transactionRequest.gasLimit = maxGasPerTx.sub(
4024
+ transactionRequest.calculateMaxGas(chainInfo, minGas)
4025
+ );
4026
+ }
4027
+ }
4028
+ const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
4029
+ const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4030
+ return {
4031
+ minGas,
4032
+ minFee,
4033
+ maxGas,
4034
+ maxFee
4035
+ };
4036
+ }
3913
4037
  /**
3914
4038
  * Executes a signed transaction without applying the states changes
3915
4039
  * on the chain.
@@ -3957,17 +4081,16 @@ var _Provider = class {
3957
4081
  signatureCallback
3958
4082
  } = {}) {
3959
4083
  const txRequestClone = clone3(transactionRequestify(transactionRequestLike));
3960
- const chainInfo = this.getChain();
3961
- const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
3962
- const gasPrice = max(txRequestClone.gasPrice, minGasPrice);
4084
+ const { minGasPrice } = this.getGasConfig();
4085
+ const setGasPrice = max(txRequestClone.gasPrice, minGasPrice);
3963
4086
  const isScriptTransaction = txRequestClone.type === TransactionType8.Script;
3964
4087
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
3965
4088
  const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
3966
4089
  txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
4090
+ if (isScriptTransaction) {
4091
+ txRequestClone.gasLimit = bn15(0);
4092
+ }
3967
4093
  if (estimatePredicates) {
3968
- if (isScriptTransaction) {
3969
- txRequestClone.gasLimit = bn14(0);
3970
- }
3971
4094
  if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
3972
4095
  resourcesOwner.populateTransactionPredicateData(txRequestClone);
3973
4096
  }
@@ -3976,36 +4099,34 @@ var _Provider = class {
3976
4099
  if (signatureCallback && isScriptTransaction) {
3977
4100
  await signatureCallback(txRequestClone);
3978
4101
  }
3979
- const minGas = txRequestClone.calculateMinGas(chainInfo);
3980
- const maxGas = txRequestClone.calculateMaxGas(chainInfo, minGas);
4102
+ let { maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
4103
+ transactionRequest: txRequestClone
4104
+ });
3981
4105
  let receipts = [];
3982
4106
  let missingContractIds = [];
3983
4107
  let outputVariables = 0;
4108
+ let gasUsed = bn15(0);
3984
4109
  if (isScriptTransaction && estimateTxDependencies) {
3985
- txRequestClone.gasPrice = bn14(0);
3986
- txRequestClone.gasLimit = bn14(maxGasPerTx.sub(maxGas).toNumber() * 0.9);
4110
+ txRequestClone.gasPrice = bn15(0);
3987
4111
  const result = await this.estimateTxDependencies(txRequestClone);
3988
4112
  receipts = result.receipts;
3989
4113
  outputVariables = result.outputVariables;
3990
4114
  missingContractIds = result.missingContractIds;
4115
+ gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
4116
+ txRequestClone.gasLimit = gasUsed;
4117
+ txRequestClone.gasPrice = setGasPrice;
4118
+ ({ maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
4119
+ transactionRequest: txRequestClone
4120
+ }));
3991
4121
  }
3992
- const gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : minGas;
3993
- const usedFee = calculatePriceWithFactor(
3994
- gasUsed,
3995
- gasPrice,
3996
- gasPriceFactor
3997
- ).normalizeZeroToOne();
3998
- const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
3999
- const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4000
4122
  return {
4001
4123
  requiredQuantities: allQuantities,
4002
4124
  receipts,
4003
4125
  gasUsed,
4004
4126
  minGasPrice,
4005
- gasPrice,
4127
+ gasPrice: setGasPrice,
4006
4128
  minGas,
4007
4129
  maxGas,
4008
- usedFee,
4009
4130
  minFee,
4010
4131
  maxFee,
4011
4132
  estimatedInputs: txRequestClone.inputs,
@@ -4045,11 +4166,11 @@ var _Provider = class {
4045
4166
  return coins.map((coin) => ({
4046
4167
  id: coin.utxoId,
4047
4168
  assetId: coin.assetId,
4048
- amount: bn14(coin.amount),
4169
+ amount: bn15(coin.amount),
4049
4170
  owner: Address2.fromAddressOrString(coin.owner),
4050
- maturity: bn14(coin.maturity).toNumber(),
4051
- blockCreated: bn14(coin.blockCreated),
4052
- txCreatedIdx: bn14(coin.txCreatedIdx)
4171
+ maturity: bn15(coin.maturity).toNumber(),
4172
+ blockCreated: bn15(coin.blockCreated),
4173
+ txCreatedIdx: bn15(coin.txCreatedIdx)
4053
4174
  }));
4054
4175
  }
4055
4176
  /**
@@ -4086,9 +4207,9 @@ var _Provider = class {
4086
4207
  switch (coin.__typename) {
4087
4208
  case "MessageCoin":
4088
4209
  return {
4089
- amount: bn14(coin.amount),
4210
+ amount: bn15(coin.amount),
4090
4211
  assetId: coin.assetId,
4091
- daHeight: bn14(coin.daHeight),
4212
+ daHeight: bn15(coin.daHeight),
4092
4213
  sender: Address2.fromAddressOrString(coin.sender),
4093
4214
  recipient: Address2.fromAddressOrString(coin.recipient),
4094
4215
  nonce: coin.nonce
@@ -4096,12 +4217,12 @@ var _Provider = class {
4096
4217
  case "Coin":
4097
4218
  return {
4098
4219
  id: coin.utxoId,
4099
- amount: bn14(coin.amount),
4220
+ amount: bn15(coin.amount),
4100
4221
  assetId: coin.assetId,
4101
4222
  owner: Address2.fromAddressOrString(coin.owner),
4102
- maturity: bn14(coin.maturity).toNumber(),
4103
- blockCreated: bn14(coin.blockCreated),
4104
- txCreatedIdx: bn14(coin.txCreatedIdx)
4223
+ maturity: bn15(coin.maturity).toNumber(),
4224
+ blockCreated: bn15(coin.blockCreated),
4225
+ txCreatedIdx: bn15(coin.txCreatedIdx)
4105
4226
  };
4106
4227
  default:
4107
4228
  return null;
@@ -4118,13 +4239,13 @@ var _Provider = class {
4118
4239
  async getBlock(idOrHeight) {
4119
4240
  let variables;
4120
4241
  if (typeof idOrHeight === "number") {
4121
- variables = { height: bn14(idOrHeight).toString(10) };
4242
+ variables = { height: bn15(idOrHeight).toString(10) };
4122
4243
  } else if (idOrHeight === "latest") {
4123
4244
  variables = { height: (await this.getBlockNumber()).toString(10) };
4124
4245
  } else if (idOrHeight.length === 66) {
4125
4246
  variables = { blockId: idOrHeight };
4126
4247
  } else {
4127
- variables = { blockId: bn14(idOrHeight).toString(10) };
4248
+ variables = { blockId: bn15(idOrHeight).toString(10) };
4128
4249
  }
4129
4250
  const { block } = await this.operations.getBlock(variables);
4130
4251
  if (!block) {
@@ -4132,7 +4253,7 @@ var _Provider = class {
4132
4253
  }
4133
4254
  return {
4134
4255
  id: block.id,
4135
- height: bn14(block.header.height),
4256
+ height: bn15(block.header.height),
4136
4257
  time: block.header.time,
4137
4258
  transactionIds: block.transactions.map((tx) => tx.id)
4138
4259
  };
@@ -4147,7 +4268,7 @@ var _Provider = class {
4147
4268
  const { blocks: fetchedData } = await this.operations.getBlocks(params);
4148
4269
  const blocks = fetchedData.edges.map(({ node: block }) => ({
4149
4270
  id: block.id,
4150
- height: bn14(block.header.height),
4271
+ height: bn15(block.header.height),
4151
4272
  time: block.header.time,
4152
4273
  transactionIds: block.transactions.map((tx) => tx.id)
4153
4274
  }));
@@ -4162,7 +4283,7 @@ var _Provider = class {
4162
4283
  async getBlockWithTransactions(idOrHeight) {
4163
4284
  let variables;
4164
4285
  if (typeof idOrHeight === "number") {
4165
- variables = { blockHeight: bn14(idOrHeight).toString(10) };
4286
+ variables = { blockHeight: bn15(idOrHeight).toString(10) };
4166
4287
  } else if (idOrHeight === "latest") {
4167
4288
  variables = { blockHeight: (await this.getBlockNumber()).toString() };
4168
4289
  } else {
@@ -4174,7 +4295,7 @@ var _Provider = class {
4174
4295
  }
4175
4296
  return {
4176
4297
  id: block.id,
4177
- height: bn14(block.header.height, 10),
4298
+ height: bn15(block.header.height, 10),
4178
4299
  time: block.header.time,
4179
4300
  transactionIds: block.transactions.map((tx) => tx.id),
4180
4301
  transactions: block.transactions.map(
@@ -4223,7 +4344,7 @@ var _Provider = class {
4223
4344
  contract: Address2.fromAddressOrString(contractId).toB256(),
4224
4345
  asset: hexlify12(assetId)
4225
4346
  });
4226
- return bn14(contractBalance.amount, 10);
4347
+ return bn15(contractBalance.amount, 10);
4227
4348
  }
4228
4349
  /**
4229
4350
  * Returns the balance for the given owner for the given asset ID.
@@ -4237,7 +4358,7 @@ var _Provider = class {
4237
4358
  owner: Address2.fromAddressOrString(owner).toB256(),
4238
4359
  assetId: hexlify12(assetId)
4239
4360
  });
4240
- return bn14(balance.amount, 10);
4361
+ return bn15(balance.amount, 10);
4241
4362
  }
4242
4363
  /**
4243
4364
  * Returns balances for the given owner.
@@ -4255,7 +4376,7 @@ var _Provider = class {
4255
4376
  const balances = result.balances.edges.map((edge) => edge.node);
4256
4377
  return balances.map((balance) => ({
4257
4378
  assetId: balance.assetId,
4258
- amount: bn14(balance.amount)
4379
+ amount: bn15(balance.amount)
4259
4380
  }));
4260
4381
  }
4261
4382
  /**
@@ -4277,15 +4398,15 @@ var _Provider = class {
4277
4398
  sender: message.sender,
4278
4399
  recipient: message.recipient,
4279
4400
  nonce: message.nonce,
4280
- amount: bn14(message.amount),
4401
+ amount: bn15(message.amount),
4281
4402
  data: message.data
4282
4403
  }),
4283
4404
  sender: Address2.fromAddressOrString(message.sender),
4284
4405
  recipient: Address2.fromAddressOrString(message.recipient),
4285
4406
  nonce: message.nonce,
4286
- amount: bn14(message.amount),
4407
+ amount: bn15(message.amount),
4287
4408
  data: InputMessageCoder.decodeData(message.data),
4288
- daHeight: bn14(message.daHeight)
4409
+ daHeight: bn15(message.daHeight)
4289
4410
  }));
4290
4411
  }
4291
4412
  /**
@@ -4303,8 +4424,8 @@ var _Provider = class {
4303
4424
  nonce
4304
4425
  };
4305
4426
  if (commitBlockId && commitBlockHeight) {
4306
- throw new FuelError12(
4307
- ErrorCode12.INVALID_INPUT_PARAMETERS,
4427
+ throw new FuelError13(
4428
+ ErrorCode13.INVALID_INPUT_PARAMETERS,
4308
4429
  "commitBlockId and commitBlockHeight cannot be used together"
4309
4430
  );
4310
4431
  }
@@ -4338,41 +4459,41 @@ var _Provider = class {
4338
4459
  } = result.messageProof;
4339
4460
  return {
4340
4461
  messageProof: {
4341
- proofIndex: bn14(messageProof.proofIndex),
4462
+ proofIndex: bn15(messageProof.proofIndex),
4342
4463
  proofSet: messageProof.proofSet
4343
4464
  },
4344
4465
  blockProof: {
4345
- proofIndex: bn14(blockProof.proofIndex),
4466
+ proofIndex: bn15(blockProof.proofIndex),
4346
4467
  proofSet: blockProof.proofSet
4347
4468
  },
4348
4469
  messageBlockHeader: {
4349
4470
  id: messageBlockHeader.id,
4350
- daHeight: bn14(messageBlockHeader.daHeight),
4351
- transactionsCount: bn14(messageBlockHeader.transactionsCount),
4471
+ daHeight: bn15(messageBlockHeader.daHeight),
4472
+ transactionsCount: bn15(messageBlockHeader.transactionsCount),
4352
4473
  transactionsRoot: messageBlockHeader.transactionsRoot,
4353
- height: bn14(messageBlockHeader.height),
4474
+ height: bn15(messageBlockHeader.height),
4354
4475
  prevRoot: messageBlockHeader.prevRoot,
4355
4476
  time: messageBlockHeader.time,
4356
4477
  applicationHash: messageBlockHeader.applicationHash,
4357
4478
  messageReceiptRoot: messageBlockHeader.messageReceiptRoot,
4358
- messageReceiptCount: bn14(messageBlockHeader.messageReceiptCount)
4479
+ messageReceiptCount: bn15(messageBlockHeader.messageReceiptCount)
4359
4480
  },
4360
4481
  commitBlockHeader: {
4361
4482
  id: commitBlockHeader.id,
4362
- daHeight: bn14(commitBlockHeader.daHeight),
4363
- transactionsCount: bn14(commitBlockHeader.transactionsCount),
4483
+ daHeight: bn15(commitBlockHeader.daHeight),
4484
+ transactionsCount: bn15(commitBlockHeader.transactionsCount),
4364
4485
  transactionsRoot: commitBlockHeader.transactionsRoot,
4365
- height: bn14(commitBlockHeader.height),
4486
+ height: bn15(commitBlockHeader.height),
4366
4487
  prevRoot: commitBlockHeader.prevRoot,
4367
4488
  time: commitBlockHeader.time,
4368
4489
  applicationHash: commitBlockHeader.applicationHash,
4369
4490
  messageReceiptRoot: commitBlockHeader.messageReceiptRoot,
4370
- messageReceiptCount: bn14(commitBlockHeader.messageReceiptCount)
4491
+ messageReceiptCount: bn15(commitBlockHeader.messageReceiptCount)
4371
4492
  },
4372
4493
  sender: Address2.fromAddressOrString(sender),
4373
4494
  recipient: Address2.fromAddressOrString(recipient),
4374
4495
  nonce,
4375
- amount: bn14(amount),
4496
+ amount: bn15(amount),
4376
4497
  data
4377
4498
  };
4378
4499
  }
@@ -4395,10 +4516,10 @@ var _Provider = class {
4395
4516
  */
4396
4517
  async produceBlocks(amount, startTime) {
4397
4518
  const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
4398
- blocksToProduce: bn14(amount).toString(10),
4519
+ blocksToProduce: bn15(amount).toString(10),
4399
4520
  startTimestamp: startTime ? DateTime2.fromUnixMilliseconds(startTime).toTai64() : void 0
4400
4521
  });
4401
- return bn14(latestBlockHeight);
4522
+ return bn15(latestBlockHeight);
4402
4523
  }
4403
4524
  // eslint-disable-next-line @typescript-eslint/require-await
4404
4525
  async getTransactionResponse(transactionId) {
@@ -4421,8 +4542,8 @@ __publicField(Provider, "chainInfoCache", {});
4421
4542
  __publicField(Provider, "nodeInfoCache", {});
4422
4543
 
4423
4544
  // src/providers/transaction-summary/get-transaction-summary.ts
4424
- import { ErrorCode as ErrorCode13, FuelError as FuelError13 } from "@fuel-ts/errors";
4425
- import { bn as bn15 } from "@fuel-ts/math";
4545
+ import { ErrorCode as ErrorCode14, FuelError as FuelError14 } from "@fuel-ts/errors";
4546
+ import { bn as bn16 } from "@fuel-ts/math";
4426
4547
  import { TransactionCoder as TransactionCoder6 } from "@fuel-ts/transactions";
4427
4548
  import { arrayify as arrayify12 } from "@fuel-ts/utils";
4428
4549
  async function getTransactionSummary(params) {
@@ -4431,8 +4552,8 @@ async function getTransactionSummary(params) {
4431
4552
  transactionId: id
4432
4553
  });
4433
4554
  if (!gqlTransaction) {
4434
- throw new FuelError13(
4435
- ErrorCode13.TRANSACTION_NOT_FOUND,
4555
+ throw new FuelError14(
4556
+ ErrorCode14.TRANSACTION_NOT_FOUND,
4436
4557
  `Transaction not found for given id: ${id}.`
4437
4558
  );
4438
4559
  }
@@ -4450,8 +4571,8 @@ async function getTransactionSummary(params) {
4450
4571
  transaction: decodedTransaction,
4451
4572
  transactionBytes: arrayify12(gqlTransaction.rawPayload),
4452
4573
  gqlTransactionStatus: gqlTransaction.status,
4453
- gasPerByte: bn15(gasPerByte),
4454
- gasPriceFactor: bn15(gasPriceFactor),
4574
+ gasPerByte: bn16(gasPerByte),
4575
+ gasPriceFactor: bn16(gasPriceFactor),
4455
4576
  abiMap,
4456
4577
  maxInputs,
4457
4578
  gasCosts
@@ -4705,7 +4826,7 @@ var Account = class extends AbstractAccount {
4705
4826
  */
4706
4827
  get provider() {
4707
4828
  if (!this._provider) {
4708
- throw new FuelError14(ErrorCode14.MISSING_PROVIDER, "Provider not set");
4829
+ throw new FuelError15(ErrorCode15.MISSING_PROVIDER, "Provider not set");
4709
4830
  }
4710
4831
  return this._provider;
4711
4832
  }
@@ -4757,8 +4878,8 @@ var Account = class extends AbstractAccount {
4757
4878
  if (!hasNextPage) {
4758
4879
  break;
4759
4880
  }
4760
- throw new FuelError14(
4761
- ErrorCode14.NOT_SUPPORTED,
4881
+ throw new FuelError15(
4882
+ ErrorCode15.NOT_SUPPORTED,
4762
4883
  `Wallets containing more than ${pageSize} coins exceed the current supported limit.`
4763
4884
  );
4764
4885
  }
@@ -4783,8 +4904,8 @@ var Account = class extends AbstractAccount {
4783
4904
  if (!hasNextPage) {
4784
4905
  break;
4785
4906
  }
4786
- throw new FuelError14(
4787
- ErrorCode14.NOT_SUPPORTED,
4907
+ throw new FuelError15(
4908
+ ErrorCode15.NOT_SUPPORTED,
4788
4909
  `Wallets containing more than ${pageSize} messages exceed the current supported limit.`
4789
4910
  );
4790
4911
  }
@@ -4819,8 +4940,8 @@ var Account = class extends AbstractAccount {
4819
4940
  if (!hasNextPage) {
4820
4941
  break;
4821
4942
  }
4822
- throw new FuelError14(
4823
- ErrorCode14.NOT_SUPPORTED,
4943
+ throw new FuelError15(
4944
+ ErrorCode15.NOT_SUPPORTED,
4824
4945
  `Wallets containing more than ${pageSize} balances exceed the current supported limit.`
4825
4946
  );
4826
4947
  }
@@ -4836,7 +4957,7 @@ var Account = class extends AbstractAccount {
4836
4957
  */
4837
4958
  async fund(request, coinQuantities, fee) {
4838
4959
  const updatedQuantities = addAmountToAsset({
4839
- amount: bn16(fee),
4960
+ amount: bn17(fee),
4840
4961
  assetId: BaseAssetId3,
4841
4962
  coinQuantities
4842
4963
  });
@@ -4844,7 +4965,7 @@ var Account = class extends AbstractAccount {
4844
4965
  updatedQuantities.forEach(({ amount, assetId }) => {
4845
4966
  quantitiesDict[assetId] = {
4846
4967
  required: amount,
4847
- owned: bn16(0)
4968
+ owned: bn17(0)
4848
4969
  };
4849
4970
  });
4850
4971
  const cachedUtxos = [];
@@ -4857,7 +4978,7 @@ var Account = class extends AbstractAccount {
4857
4978
  if (isCoin2) {
4858
4979
  const assetId = String(input.assetId);
4859
4980
  if (input.owner === owner && quantitiesDict[assetId]) {
4860
- const amount = bn16(input.amount);
4981
+ const amount = bn17(input.amount);
4861
4982
  quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
4862
4983
  cachedUtxos.push(input.id);
4863
4984
  }
@@ -4903,8 +5024,8 @@ var Account = class extends AbstractAccount {
4903
5024
  estimateTxDependencies: true,
4904
5025
  resourcesOwner: this
4905
5026
  });
4906
- request.gasPrice = bn16(txParams.gasPrice ?? minGasPrice);
4907
- request.gasLimit = bn16(txParams.gasLimit ?? gasUsed);
5027
+ request.gasPrice = bn17(txParams.gasPrice ?? minGasPrice);
5028
+ request.gasLimit = bn17(txParams.gasLimit ?? gasUsed);
4908
5029
  this.validateGas({
4909
5030
  gasUsed,
4910
5031
  gasPrice: request.gasPrice,
@@ -4925,9 +5046,9 @@ var Account = class extends AbstractAccount {
4925
5046
  * @returns A promise that resolves to the transaction response.
4926
5047
  */
4927
5048
  async transfer(destination, amount, assetId = BaseAssetId3, txParams = {}) {
4928
- if (bn16(amount).lte(0)) {
4929
- throw new FuelError14(
4930
- ErrorCode14.INVALID_TRANSFER_AMOUNT,
5049
+ if (bn17(amount).lte(0)) {
5050
+ throw new FuelError15(
5051
+ ErrorCode15.INVALID_TRANSFER_AMOUNT,
4931
5052
  "Transfer amount must be a positive number."
4932
5053
  );
4933
5054
  }
@@ -4944,9 +5065,9 @@ var Account = class extends AbstractAccount {
4944
5065
  * @returns A promise that resolves to the transaction response.
4945
5066
  */
4946
5067
  async transferToContract(contractId, amount, assetId = BaseAssetId3, txParams = {}) {
4947
- if (bn16(amount).lte(0)) {
4948
- throw new FuelError14(
4949
- ErrorCode14.INVALID_TRANSFER_AMOUNT,
5068
+ if (bn17(amount).lte(0)) {
5069
+ throw new FuelError15(
5070
+ ErrorCode15.INVALID_TRANSFER_AMOUNT,
4950
5071
  "Transfer amount must be a positive number."
4951
5072
  );
4952
5073
  }
@@ -4955,7 +5076,7 @@ var Account = class extends AbstractAccount {
4955
5076
  const params = { gasPrice: minGasPrice, ...txParams };
4956
5077
  const { script, scriptData } = await assembleTransferToContractScript({
4957
5078
  hexlifiedContractId: contractAddress.toB256(),
4958
- amountToTransfer: bn16(amount),
5079
+ amountToTransfer: bn17(amount),
4959
5080
  assetId
4960
5081
  });
4961
5082
  const request = new ScriptTransactionRequest({
@@ -4966,9 +5087,9 @@ var Account = class extends AbstractAccount {
4966
5087
  request.addContractInputAndOutput(contractAddress);
4967
5088
  const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
4968
5089
  request,
4969
- [{ amount: bn16(amount), assetId: String(assetId) }]
5090
+ [{ amount: bn17(amount), assetId: String(assetId) }]
4970
5091
  );
4971
- request.gasLimit = bn16(params.gasLimit ?? gasUsed);
5092
+ request.gasLimit = bn17(params.gasLimit ?? gasUsed);
4972
5093
  this.validateGas({
4973
5094
  gasUsed,
4974
5095
  gasPrice: request.gasPrice,
@@ -4993,7 +5114,7 @@ var Account = class extends AbstractAccount {
4993
5114
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
4994
5115
  );
4995
5116
  const amountDataArray = arrayify14(
4996
- "0x".concat(bn16(amount).toHex().substring(2).padStart(16, "0"))
5117
+ "0x".concat(bn17(amount).toHex().substring(2).padStart(16, "0"))
4997
5118
  );
4998
5119
  const script = new Uint8Array([
4999
5120
  ...arrayify14(withdrawScript.bytes),
@@ -5002,12 +5123,12 @@ var Account = class extends AbstractAccount {
5002
5123
  ]);
5003
5124
  const params = { script, gasPrice: minGasPrice, ...txParams };
5004
5125
  const request = new ScriptTransactionRequest(params);
5005
- const forwardingQuantities = [{ amount: bn16(amount), assetId: BaseAssetId3 }];
5126
+ const forwardingQuantities = [{ amount: bn17(amount), assetId: BaseAssetId3 }];
5006
5127
  const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
5007
5128
  request,
5008
5129
  forwardingQuantities
5009
5130
  );
5010
- request.gasLimit = bn16(params.gasLimit ?? gasUsed);
5131
+ request.gasLimit = bn17(params.gasLimit ?? gasUsed);
5011
5132
  this.validateGas({
5012
5133
  gasUsed,
5013
5134
  gasPrice: request.gasPrice,
@@ -5019,7 +5140,7 @@ var Account = class extends AbstractAccount {
5019
5140
  }
5020
5141
  async signMessage(message) {
5021
5142
  if (!this._connector) {
5022
- throw new FuelError14(ErrorCode14.MISSING_CONNECTOR, "A connector is required to sign messages.");
5143
+ throw new FuelError15(ErrorCode15.MISSING_CONNECTOR, "A connector is required to sign messages.");
5023
5144
  }
5024
5145
  return this._connector.signMessage(this.address.toString(), message);
5025
5146
  }
@@ -5031,8 +5152,8 @@ var Account = class extends AbstractAccount {
5031
5152
  */
5032
5153
  async signTransaction(transactionRequestLike) {
5033
5154
  if (!this._connector) {
5034
- throw new FuelError14(
5035
- ErrorCode14.MISSING_CONNECTOR,
5155
+ throw new FuelError15(
5156
+ ErrorCode15.MISSING_CONNECTOR,
5036
5157
  "A connector is required to sign transactions."
5037
5158
  );
5038
5159
  }
@@ -5079,14 +5200,14 @@ var Account = class extends AbstractAccount {
5079
5200
  minGasPrice
5080
5201
  }) {
5081
5202
  if (minGasPrice.gt(gasPrice)) {
5082
- throw new FuelError14(
5083
- ErrorCode14.GAS_PRICE_TOO_LOW,
5203
+ throw new FuelError15(
5204
+ ErrorCode15.GAS_PRICE_TOO_LOW,
5084
5205
  `Gas price '${gasPrice}' is lower than the required: '${minGasPrice}'.`
5085
5206
  );
5086
5207
  }
5087
5208
  if (gasUsed.gt(gasLimit)) {
5088
- throw new FuelError14(
5089
- ErrorCode14.GAS_LIMIT_TOO_LOW,
5209
+ throw new FuelError15(
5210
+ ErrorCode15.GAS_LIMIT_TOO_LOW,
5090
5211
  `Gas limit '${gasLimit}' is lower than the required: '${gasUsed}'.`
5091
5212
  );
5092
5213
  }
@@ -5099,7 +5220,7 @@ import { hexlify as hexlify15 } from "@fuel-ts/utils";
5099
5220
 
5100
5221
  // src/signer/signer.ts
5101
5222
  import { Address as Address4 } from "@fuel-ts/address";
5102
- import { randomBytes } from "@fuel-ts/crypto";
5223
+ import { randomBytes as randomBytes2 } from "@fuel-ts/crypto";
5103
5224
  import { hash } from "@fuel-ts/hasher";
5104
5225
  import { toBytes } from "@fuel-ts/math";
5105
5226
  import { hexlify as hexlify13, concat as concat3, arrayify as arrayify15 } from "@fuel-ts/utils";
@@ -5192,7 +5313,7 @@ var Signer = class {
5192
5313
  * @returns random 32-byte hashed
5193
5314
  */
5194
5315
  static generatePrivateKey(entropy) {
5195
- return entropy ? hash(concat3([randomBytes(32), arrayify15(entropy)])) : randomBytes(32);
5316
+ return entropy ? hash(concat3([randomBytes2(32), arrayify15(entropy)])) : randomBytes2(32);
5196
5317
  }
5197
5318
  /**
5198
5319
  * Extended publicKey from a compact publicKey
@@ -5211,13 +5332,13 @@ import { Address as Address5 } from "@fuel-ts/address";
5211
5332
  import {
5212
5333
  bufferFromString,
5213
5334
  keccak256,
5214
- randomBytes as randomBytes2,
5335
+ randomBytes as randomBytes3,
5215
5336
  scrypt,
5216
5337
  stringFromBuffer,
5217
5338
  decryptJsonWalletData,
5218
5339
  encryptJsonWalletData
5219
5340
  } from "@fuel-ts/crypto";
5220
- import { ErrorCode as ErrorCode15, FuelError as FuelError15 } from "@fuel-ts/errors";
5341
+ import { ErrorCode as ErrorCode16, FuelError as FuelError16 } from "@fuel-ts/errors";
5221
5342
  import { hexlify as hexlify14 } from "@fuel-ts/utils";
5222
5343
  import { v4 as uuidv4 } from "uuid";
5223
5344
  var DEFAULT_KDF_PARAMS_LOG_N = 13;
@@ -5234,7 +5355,7 @@ var removeHexPrefix = (hexString) => {
5234
5355
  async function encryptKeystoreWallet(privateKey, address, password) {
5235
5356
  const privateKeyBuffer = bufferFromString(removeHexPrefix(privateKey), "hex");
5236
5357
  const ownerAddress = Address5.fromAddressOrString(address);
5237
- const salt = randomBytes2(DEFAULT_KEY_SIZE);
5358
+ const salt = randomBytes3(DEFAULT_KEY_SIZE);
5238
5359
  const key = scrypt({
5239
5360
  password: bufferFromString(password),
5240
5361
  salt,
@@ -5243,7 +5364,7 @@ async function encryptKeystoreWallet(privateKey, address, password) {
5243
5364
  r: DEFAULT_KDF_PARAMS_R,
5244
5365
  p: DEFAULT_KDF_PARAMS_P
5245
5366
  });
5246
- const iv = randomBytes2(DEFAULT_IV_SIZE);
5367
+ const iv = randomBytes3(DEFAULT_IV_SIZE);
5247
5368
  const ciphertext = await encryptJsonWalletData(privateKeyBuffer, key, iv);
5248
5369
  const data = Uint8Array.from([...key.subarray(16, 32), ...ciphertext]);
5249
5370
  const macHashUint8Array = keccak256(data);
@@ -5295,8 +5416,8 @@ async function decryptKeystoreWallet(jsonWallet, password) {
5295
5416
  const macHashUint8Array = keccak256(data);
5296
5417
  const macHash = stringFromBuffer(macHashUint8Array, "hex");
5297
5418
  if (mac !== macHash) {
5298
- throw new FuelError15(
5299
- ErrorCode15.INVALID_PASSWORD,
5419
+ throw new FuelError16(
5420
+ ErrorCode16.INVALID_PASSWORD,
5300
5421
  "Failed to decrypt the keystore wallet, the provided password is incorrect."
5301
5422
  );
5302
5423
  }
@@ -5418,15 +5539,15 @@ var BaseWalletUnlocked = class extends Account {
5418
5539
  __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
5419
5540
 
5420
5541
  // src/hdwallet/hdwallet.ts
5421
- import { ErrorCode as ErrorCode18, FuelError as FuelError18 } from "@fuel-ts/errors";
5542
+ import { ErrorCode as ErrorCode19, FuelError as FuelError19 } from "@fuel-ts/errors";
5422
5543
  import { sha256 as sha2564 } from "@fuel-ts/hasher";
5423
- import { bn as bn17, toBytes as toBytes2, toHex } from "@fuel-ts/math";
5544
+ import { bn as bn18, toBytes as toBytes2, toHex } from "@fuel-ts/math";
5424
5545
  import { arrayify as arrayify18, hexlify as hexlify17, concat as concat5 } from "@fuel-ts/utils";
5425
5546
  import { toBeHex, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58, computeHmac as computeHmac2, ripemd160 } from "ethers";
5426
5547
 
5427
5548
  // src/mnemonic/mnemonic.ts
5428
- import { randomBytes as randomBytes3 } from "@fuel-ts/crypto";
5429
- import { ErrorCode as ErrorCode17, FuelError as FuelError17 } from "@fuel-ts/errors";
5549
+ import { randomBytes as randomBytes4 } from "@fuel-ts/crypto";
5550
+ import { ErrorCode as ErrorCode18, FuelError as FuelError18 } from "@fuel-ts/errors";
5430
5551
  import { sha256 as sha2563 } from "@fuel-ts/hasher";
5431
5552
  import { arrayify as arrayify17, hexlify as hexlify16, concat as concat4 } from "@fuel-ts/utils";
5432
5553
  import { dataSlice, pbkdf2, computeHmac, encodeBase58 } from "ethers";
@@ -7490,7 +7611,7 @@ var Language = /* @__PURE__ */ ((Language2) => {
7490
7611
  })(Language || {});
7491
7612
 
7492
7613
  // src/mnemonic/utils.ts
7493
- import { ErrorCode as ErrorCode16, FuelError as FuelError16 } from "@fuel-ts/errors";
7614
+ import { ErrorCode as ErrorCode17, FuelError as FuelError17 } from "@fuel-ts/errors";
7494
7615
  import { sha256 as sha2562 } from "@fuel-ts/hasher";
7495
7616
  import { arrayify as arrayify16 } from "@fuel-ts/utils";
7496
7617
  function toUtf8Bytes(stri) {
@@ -7507,8 +7628,8 @@ function toUtf8Bytes(stri) {
7507
7628
  i += 1;
7508
7629
  const c2 = str.charCodeAt(i);
7509
7630
  if (i >= str.length || (c2 & 64512) !== 56320) {
7510
- throw new FuelError16(
7511
- ErrorCode16.INVALID_INPUT_PARAMETERS,
7631
+ throw new FuelError17(
7632
+ ErrorCode17.INVALID_INPUT_PARAMETERS,
7512
7633
  "Invalid UTF-8 in the input string."
7513
7634
  );
7514
7635
  }
@@ -7571,8 +7692,8 @@ function mnemonicWordsToEntropy(words, wordlist) {
7571
7692
  for (let i = 0; i < words.length; i += 1) {
7572
7693
  const index = wordlist.indexOf(words[i].normalize("NFKD"));
7573
7694
  if (index === -1) {
7574
- throw new FuelError16(
7575
- ErrorCode16.INVALID_MNEMONIC,
7695
+ throw new FuelError17(
7696
+ ErrorCode17.INVALID_MNEMONIC,
7576
7697
  `Invalid mnemonic: the word '${words[i]}' is not found in the provided wordlist.`
7577
7698
  );
7578
7699
  }
@@ -7588,8 +7709,8 @@ function mnemonicWordsToEntropy(words, wordlist) {
7588
7709
  const checksumMask = getUpperMask(checksumBits);
7589
7710
  const checksum = arrayify16(sha2562(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
7590
7711
  if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
7591
- throw new FuelError16(
7592
- ErrorCode16.INVALID_CHECKSUM,
7712
+ throw new FuelError17(
7713
+ ErrorCode17.INVALID_CHECKSUM,
7593
7714
  "Checksum validation failed for the provided mnemonic."
7594
7715
  );
7595
7716
  }
@@ -7603,16 +7724,16 @@ var TestnetPRV = "0x04358394";
7603
7724
  var MNEMONIC_SIZES = [12, 15, 18, 21, 24];
7604
7725
  function assertWordList(wordlist) {
7605
7726
  if (wordlist.length !== 2048) {
7606
- throw new FuelError17(
7607
- ErrorCode17.INVALID_WORD_LIST,
7727
+ throw new FuelError18(
7728
+ ErrorCode18.INVALID_WORD_LIST,
7608
7729
  `Expected word list length of 2048, but got ${wordlist.length}.`
7609
7730
  );
7610
7731
  }
7611
7732
  }
7612
7733
  function assertEntropy(entropy) {
7613
7734
  if (entropy.length % 4 !== 0 || entropy.length < 16 || entropy.length > 32) {
7614
- throw new FuelError17(
7615
- ErrorCode17.INVALID_ENTROPY,
7735
+ throw new FuelError18(
7736
+ ErrorCode18.INVALID_ENTROPY,
7616
7737
  `Entropy should be between 16 and 32 bytes and a multiple of 4, but got ${entropy.length} bytes.`
7617
7738
  );
7618
7739
  }
@@ -7622,7 +7743,7 @@ function assertMnemonic(words) {
7622
7743
  const errorMsg = `Invalid mnemonic size. Expected one of [${MNEMONIC_SIZES.join(
7623
7744
  ", "
7624
7745
  )}] words, but got ${words.length}.`;
7625
- throw new FuelError17(ErrorCode17.INVALID_MNEMONIC, errorMsg);
7746
+ throw new FuelError18(ErrorCode18.INVALID_MNEMONIC, errorMsg);
7626
7747
  }
7627
7748
  }
7628
7749
  var Mnemonic = class {
@@ -7740,8 +7861,8 @@ var Mnemonic = class {
7740
7861
  static masterKeysFromSeed(seed) {
7741
7862
  const seedArray = arrayify17(seed);
7742
7863
  if (seedArray.length < 16 || seedArray.length > 64) {
7743
- throw new FuelError17(
7744
- ErrorCode17.INVALID_SEED,
7864
+ throw new FuelError18(
7865
+ ErrorCode18.INVALID_SEED,
7745
7866
  `Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
7746
7867
  );
7747
7868
  }
@@ -7786,7 +7907,7 @@ var Mnemonic = class {
7786
7907
  * @returns A randomly generated mnemonic
7787
7908
  */
7788
7909
  static generate(size = 32, extraEntropy = "") {
7789
- const entropy = extraEntropy ? sha2563(concat4([randomBytes3(size), arrayify17(extraEntropy)])) : randomBytes3(size);
7910
+ const entropy = extraEntropy ? sha2563(concat4([randomBytes4(size), arrayify17(extraEntropy)])) : randomBytes4(size);
7790
7911
  return Mnemonic.entropyToMnemonic(entropy);
7791
7912
  }
7792
7913
  };
@@ -7818,7 +7939,7 @@ function isValidExtendedKey(extendedKey) {
7818
7939
  function parsePath(path, depth = 0) {
7819
7940
  const components = path.split("/");
7820
7941
  if (components.length === 0 || components[0] === "m" && depth !== 0) {
7821
- throw new FuelError18(ErrorCode18.HD_WALLET_ERROR, `invalid path - ${path}`);
7942
+ throw new FuelError19(ErrorCode19.HD_WALLET_ERROR, `invalid path - ${path}`);
7822
7943
  }
7823
7944
  if (components[0] === "m") {
7824
7945
  components.shift();
@@ -7847,8 +7968,8 @@ var HDWallet = class {
7847
7968
  this.privateKey = hexlify17(config.privateKey);
7848
7969
  } else {
7849
7970
  if (!config.publicKey) {
7850
- throw new FuelError18(
7851
- ErrorCode18.HD_WALLET_ERROR,
7971
+ throw new FuelError19(
7972
+ ErrorCode19.HD_WALLET_ERROR,
7852
7973
  "Both public and private Key cannot be missing. At least one should be provided."
7853
7974
  );
7854
7975
  }
@@ -7877,8 +7998,8 @@ var HDWallet = class {
7877
7998
  const data = new Uint8Array(37);
7878
7999
  if (index & HARDENED_INDEX) {
7879
8000
  if (!privateKey) {
7880
- throw new FuelError18(
7881
- ErrorCode18.HD_WALLET_ERROR,
8001
+ throw new FuelError19(
8002
+ ErrorCode19.HD_WALLET_ERROR,
7882
8003
  "Cannot derive a hardened index without a private Key."
7883
8004
  );
7884
8005
  }
@@ -7892,7 +8013,7 @@ var HDWallet = class {
7892
8013
  const IR = bytes.slice(32);
7893
8014
  if (privateKey) {
7894
8015
  const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
7895
- const ki = bn17(IL).add(privateKey).mod(N).toBytes(32);
8016
+ const ki = bn18(IL).add(privateKey).mod(N).toBytes(32);
7896
8017
  return new HDWallet({
7897
8018
  privateKey: ki,
7898
8019
  chainCode: IR,
@@ -7930,8 +8051,8 @@ var HDWallet = class {
7930
8051
  */
7931
8052
  toExtendedKey(isPublic = false, testnet = false) {
7932
8053
  if (this.depth >= 256) {
7933
- throw new FuelError18(
7934
- ErrorCode18.HD_WALLET_ERROR,
8054
+ throw new FuelError19(
8055
+ ErrorCode19.HD_WALLET_ERROR,
7935
8056
  `Exceeded max depth of 255. Current depth: ${this.depth}.`
7936
8057
  );
7937
8058
  }
@@ -7962,10 +8083,10 @@ var HDWallet = class {
7962
8083
  const bytes = arrayify18(decoded);
7963
8084
  const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
7964
8085
  if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
7965
- throw new FuelError18(ErrorCode18.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
8086
+ throw new FuelError19(ErrorCode19.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
7966
8087
  }
7967
8088
  if (!validChecksum) {
7968
- throw new FuelError18(ErrorCode18.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
8089
+ throw new FuelError19(ErrorCode19.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
7969
8090
  }
7970
8091
  const depth = bytes[4];
7971
8092
  const parentFingerprint = hexlify17(bytes.slice(5, 9));
@@ -7973,14 +8094,14 @@ var HDWallet = class {
7973
8094
  const chainCode = hexlify17(bytes.slice(13, 45));
7974
8095
  const key = bytes.slice(45, 78);
7975
8096
  if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
7976
- throw new FuelError18(
7977
- ErrorCode18.HD_WALLET_ERROR,
8097
+ throw new FuelError19(
8098
+ ErrorCode19.HD_WALLET_ERROR,
7978
8099
  "Inconsistency detected: Depth is zero but fingerprint/index is non-zero."
7979
8100
  );
7980
8101
  }
7981
8102
  if (isPublicExtendedKey(bytes)) {
7982
8103
  if (key[0] !== 3) {
7983
- throw new FuelError18(ErrorCode18.HD_WALLET_ERROR, "Invalid public extended key.");
8104
+ throw new FuelError19(ErrorCode19.HD_WALLET_ERROR, "Invalid public extended key.");
7984
8105
  }
7985
8106
  return new HDWallet({
7986
8107
  publicKey: key,
@@ -7991,7 +8112,7 @@ var HDWallet = class {
7991
8112
  });
7992
8113
  }
7993
8114
  if (key[0] !== 0) {
7994
- throw new FuelError18(ErrorCode18.HD_WALLET_ERROR, "Invalid private extended key.");
8115
+ throw new FuelError19(ErrorCode19.HD_WALLET_ERROR, "Invalid private extended key.");
7995
8116
  }
7996
8117
  return new HDWallet({
7997
8118
  privateKey: key.slice(1),
@@ -8159,7 +8280,7 @@ __publicField(Wallet, "fromEncryptedJson", WalletUnlocked.fromEncryptedJson);
8159
8280
  // src/wallet-manager/wallet-manager.ts
8160
8281
  import { Address as Address8 } from "@fuel-ts/address";
8161
8282
  import { encrypt, decrypt } from "@fuel-ts/crypto";
8162
- import { ErrorCode as ErrorCode21, FuelError as FuelError21 } from "@fuel-ts/errors";
8283
+ import { ErrorCode as ErrorCode22, FuelError as FuelError22 } from "@fuel-ts/errors";
8163
8284
  import { EventEmitter } from "events";
8164
8285
 
8165
8286
  // src/wallet-manager/storages/memory-storage.ts
@@ -8182,7 +8303,7 @@ var MemoryStorage = class {
8182
8303
 
8183
8304
  // src/wallet-manager/vaults/mnemonic-vault.ts
8184
8305
  import { Address as Address6 } from "@fuel-ts/address";
8185
- import { ErrorCode as ErrorCode19, FuelError as FuelError19 } from "@fuel-ts/errors";
8306
+ import { ErrorCode as ErrorCode20, FuelError as FuelError20 } from "@fuel-ts/errors";
8186
8307
  var _secret;
8187
8308
  var MnemonicVault = class {
8188
8309
  constructor(options) {
@@ -8238,8 +8359,8 @@ var MnemonicVault = class {
8238
8359
  }
8239
8360
  numberOfAccounts += 1;
8240
8361
  } while (numberOfAccounts < this.numberOfAccounts);
8241
- throw new FuelError19(
8242
- ErrorCode19.WALLET_MANAGER_ERROR,
8362
+ throw new FuelError20(
8363
+ ErrorCode20.WALLET_MANAGER_ERROR,
8243
8364
  `Account with address '${address}' not found in derived wallets.`
8244
8365
  );
8245
8366
  }
@@ -8253,7 +8374,7 @@ __publicField(MnemonicVault, "type", "mnemonic");
8253
8374
 
8254
8375
  // src/wallet-manager/vaults/privatekey-vault.ts
8255
8376
  import { Address as Address7 } from "@fuel-ts/address";
8256
- import { ErrorCode as ErrorCode20, FuelError as FuelError20 } from "@fuel-ts/errors";
8377
+ import { ErrorCode as ErrorCode21, FuelError as FuelError21 } from "@fuel-ts/errors";
8257
8378
  var _privateKeys;
8258
8379
  var PrivateKeyVault = class {
8259
8380
  /**
@@ -8294,8 +8415,8 @@ var PrivateKeyVault = class {
8294
8415
  (pk) => Wallet.fromPrivateKey(pk).address.equals(ownerAddress)
8295
8416
  );
8296
8417
  if (!privateKey) {
8297
- throw new FuelError20(
8298
- ErrorCode20.WALLET_MANAGER_ERROR,
8418
+ throw new FuelError21(
8419
+ ErrorCode21.WALLET_MANAGER_ERROR,
8299
8420
  `No private key found for address '${address}'.`
8300
8421
  );
8301
8422
  }
@@ -8319,7 +8440,7 @@ var ERROR_MESSAGES = {
8319
8440
  };
8320
8441
  function assert(condition, message) {
8321
8442
  if (!condition) {
8322
- throw new FuelError21(ErrorCode21.WALLET_MANAGER_ERROR, message);
8443
+ throw new FuelError22(ErrorCode22.WALLET_MANAGER_ERROR, message);
8323
8444
  }
8324
8445
  }
8325
8446
  var _vaults, _passphrase, _isLocked, _serializeVaults, serializeVaults_fn, _deserializeVaults, deserializeVaults_fn;
@@ -8545,25 +8666,25 @@ deserializeVaults_fn = function(vaults) {
8545
8666
  __publicField(WalletManager, "Vaults", [MnemonicVault, PrivateKeyVault]);
8546
8667
 
8547
8668
  // src/wallet-manager/types.ts
8548
- import { ErrorCode as ErrorCode22, FuelError as FuelError22 } from "@fuel-ts/errors";
8669
+ import { ErrorCode as ErrorCode23, FuelError as FuelError23 } from "@fuel-ts/errors";
8549
8670
  var Vault = class {
8550
8671
  constructor(_options) {
8551
- throw new FuelError22(ErrorCode22.NOT_IMPLEMENTED, "Not implemented.");
8672
+ throw new FuelError23(ErrorCode23.NOT_IMPLEMENTED, "Not implemented.");
8552
8673
  }
8553
8674
  serialize() {
8554
- throw new FuelError22(ErrorCode22.NOT_IMPLEMENTED, "Not implemented.");
8675
+ throw new FuelError23(ErrorCode23.NOT_IMPLEMENTED, "Not implemented.");
8555
8676
  }
8556
8677
  getAccounts() {
8557
- throw new FuelError22(ErrorCode22.NOT_IMPLEMENTED, "Not implemented.");
8678
+ throw new FuelError23(ErrorCode23.NOT_IMPLEMENTED, "Not implemented.");
8558
8679
  }
8559
8680
  addAccount() {
8560
- throw new FuelError22(ErrorCode22.NOT_IMPLEMENTED, "Not implemented.");
8681
+ throw new FuelError23(ErrorCode23.NOT_IMPLEMENTED, "Not implemented.");
8561
8682
  }
8562
8683
  exportAccount(_address) {
8563
- throw new FuelError22(ErrorCode22.NOT_IMPLEMENTED, "Not implemented.");
8684
+ throw new FuelError23(ErrorCode23.NOT_IMPLEMENTED, "Not implemented.");
8564
8685
  }
8565
8686
  getWallet(_address) {
8566
- throw new FuelError22(ErrorCode22.NOT_IMPLEMENTED, "Not implemented.");
8687
+ throw new FuelError23(ErrorCode23.NOT_IMPLEMENTED, "Not implemented.");
8567
8688
  }
8568
8689
  };
8569
8690
  __publicField(Vault, "type");
@@ -8572,7 +8693,7 @@ var StorageAbstract = class {
8572
8693
 
8573
8694
  // src/predicate/predicate.ts
8574
8695
  import {
8575
- Interface as Interface3,
8696
+ Interface as Interface4,
8576
8697
  INPUT_COIN_FIXED_SIZE,
8577
8698
  WORD_SIZE,
8578
8699
  calculateVmTxMemory as calculateVmTxMemory2,
@@ -8580,7 +8701,7 @@ import {
8580
8701
  } from "@fuel-ts/abi-coder";
8581
8702
  import { Address as Address9 } from "@fuel-ts/address";
8582
8703
  import { BaseAssetId as BaseAssetId4 } from "@fuel-ts/address/configs";
8583
- import { ErrorCode as ErrorCode23, FuelError as FuelError23 } from "@fuel-ts/errors";
8704
+ import { ErrorCode as ErrorCode24, FuelError as FuelError24 } from "@fuel-ts/errors";
8584
8705
  import { ByteArrayCoder, InputType as InputType7 } from "@fuel-ts/transactions";
8585
8706
  import { arrayify as arrayify20, hexlify as hexlify19 } from "@fuel-ts/utils";
8586
8707
 
@@ -8600,7 +8721,6 @@ var getPredicateRoot = (bytecode) => {
8600
8721
  // src/predicate/predicate.ts
8601
8722
  var Predicate = class extends Account {
8602
8723
  bytes;
8603
- predicateDataBytes = Uint8Array.from([]);
8604
8724
  predicateData = [];
8605
8725
  interface;
8606
8726
  /**
@@ -8706,10 +8826,10 @@ var Predicate = class extends Account {
8706
8826
  let predicateBytes = arrayify20(bytes);
8707
8827
  let abiInterface;
8708
8828
  if (jsonAbi) {
8709
- abiInterface = new Interface3(jsonAbi);
8829
+ abiInterface = new Interface4(jsonAbi);
8710
8830
  if (abiInterface.functions.main === void 0) {
8711
- throw new FuelError23(
8712
- ErrorCode23.ABI_MAIN_METHOD_MISSING,
8831
+ throw new FuelError24(
8832
+ ErrorCode24.ABI_MAIN_METHOD_MISSING,
8713
8833
  'Cannot use ABI without "main" function.'
8714
8834
  );
8715
8835
  }
@@ -8754,8 +8874,8 @@ var Predicate = class extends Account {
8754
8874
  mutatedBytes.set(encoded, offset);
8755
8875
  });
8756
8876
  } catch (err) {
8757
- throw new FuelError23(
8758
- ErrorCode23.INVALID_CONFIGURABLE_CONSTANTS,
8877
+ throw new FuelError24(
8878
+ ErrorCode24.INVALID_CONFIGURABLE_CONSTANTS,
8759
8879
  `Error setting configurable constants: ${err.message}.`
8760
8880
  );
8761
8881
  }
@@ -8764,7 +8884,7 @@ var Predicate = class extends Account {
8764
8884
  };
8765
8885
 
8766
8886
  // src/connectors/fuel.ts
8767
- import { ErrorCode as ErrorCode24, FuelError as FuelError24 } from "@fuel-ts/errors";
8887
+ import { ErrorCode as ErrorCode25, FuelError as FuelError25 } from "@fuel-ts/errors";
8768
8888
 
8769
8889
  // src/connectors/fuel-connector.ts
8770
8890
  import { EventEmitter as EventEmitter2 } from "events";
@@ -9397,7 +9517,7 @@ var _Fuel = class extends FuelConnector {
9397
9517
  const currentNetwork = await this.currentNetwork();
9398
9518
  provider = await Provider.create(currentNetwork.url);
9399
9519
  } else {
9400
- throw new FuelError24(ErrorCode24.INVALID_PROVIDER, "Provider is not valid.");
9520
+ throw new FuelError25(ErrorCode25.INVALID_PROVIDER, "Provider is not valid.");
9401
9521
  }
9402
9522
  return provider;
9403
9523
  }
@@ -9476,7 +9596,9 @@ export {
9476
9596
  WalletUnlocked,
9477
9597
  addAmountToAsset,
9478
9598
  addOperation,
9599
+ assemblePanicError,
9479
9600
  assembleReceiptByType,
9601
+ assembleRevertError,
9480
9602
  assembleTransactionSummary,
9481
9603
  assets,
9482
9604
  buildBlockExplorerUrl,
@@ -9491,6 +9613,7 @@ export {
9491
9613
  english,
9492
9614
  extractBurnedAssetsFromReceipts,
9493
9615
  extractMintedAssetsFromReceipts,
9616
+ extractTxError,
9494
9617
  gasUsedByInputs,
9495
9618
  getAssetEth,
9496
9619
  getAssetFuel,