@fuel-ts/account 0.79.0 → 0.81.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 (34) 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 +382 -192
  10. package/dist/index.global.js.map +1 -1
  11. package/dist/index.js +667 -554
  12. package/dist/index.js.map +1 -1
  13. package/dist/index.mjs +416 -298
  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/fuel-graphql-subscriber.d.ts +2 -0
  18. package/dist/providers/fuel-graphql-subscriber.d.ts.map +1 -1
  19. package/dist/providers/provider.d.ts +13 -2
  20. package/dist/providers/provider.d.ts.map +1 -1
  21. package/dist/providers/transaction-request/input.d.ts.map +1 -1
  22. package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
  23. package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
  24. package/dist/providers/utils/extract-tx-error.d.ts +36 -0
  25. package/dist/providers/utils/extract-tx-error.d.ts.map +1 -0
  26. package/dist/providers/utils/index.d.ts +1 -0
  27. package/dist/providers/utils/index.d.ts.map +1 -1
  28. package/dist/test-utils.global.js +384 -193
  29. package/dist/test-utils.global.js.map +1 -1
  30. package/dist/test-utils.js +624 -516
  31. package/dist/test-utils.js.map +1 -1
  32. package/dist/test-utils.mjs +388 -272
  33. package/dist/test-utils.mjs.map +1 -1
  34. package/package.json +21 -26
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,
@@ -916,36 +916,45 @@ var _FuelGraphqlSubscriber = class {
916
916
  });
917
917
  this.stream = response.body.getReader();
918
918
  }
919
+ events = [];
920
+ parsingLeftover = "";
919
921
  async next() {
920
922
  if (!this.stream) {
921
923
  await this.setStream();
922
924
  }
923
925
  while (true) {
926
+ if (this.events.length > 0) {
927
+ const { data, errors } = this.events.shift();
928
+ if (Array.isArray(errors)) {
929
+ throw new FuelError(
930
+ FuelError.CODES.INVALID_REQUEST,
931
+ errors.map((err) => err.message).join("\n\n")
932
+ );
933
+ }
934
+ return { value: data, done: false };
935
+ }
924
936
  const { value, done } = await this.stream.read();
925
937
  if (done) {
926
938
  return { value, done };
927
939
  }
928
- const text = _FuelGraphqlSubscriber.textDecoder.decode(value);
929
- if (!text.startsWith("data:")) {
940
+ const decoded = _FuelGraphqlSubscriber.textDecoder.decode(value).replace(":keep-alive-text\n\n", "");
941
+ if (decoded === "") {
930
942
  continue;
931
943
  }
932
- let data;
933
- let errors;
934
- try {
935
- ({ data, errors } = JSON.parse(text.replace(/^data:/, "")));
936
- } catch (e) {
937
- throw new FuelError(
938
- ErrorCode.STREAM_PARSING_ERROR,
939
- `Error while parsing stream data response: ${text}`
940
- );
941
- }
942
- if (Array.isArray(errors)) {
943
- throw new FuelError(
944
- FuelError.CODES.INVALID_REQUEST,
945
- errors.map((err) => err.message).join("\n\n")
946
- );
947
- }
948
- return { value: data, done: false };
944
+ const text = `${this.parsingLeftover}${decoded}`;
945
+ const regex = /data:.*\n\n/g;
946
+ const matches = [...text.matchAll(regex)].flatMap((match) => match);
947
+ matches.forEach((match) => {
948
+ try {
949
+ this.events.push(JSON.parse(match.replace(/^data:/, "")));
950
+ } catch (e) {
951
+ throw new FuelError(
952
+ ErrorCode.STREAM_PARSING_ERROR,
953
+ `Error while parsing stream data response: ${text}`
954
+ );
955
+ }
956
+ });
957
+ this.parsingLeftover = text.replace(matches.join(), "");
949
958
  }
950
959
  }
951
960
  /**
@@ -1023,6 +1032,7 @@ var MemoryCache = class {
1023
1032
  };
1024
1033
 
1025
1034
  // src/providers/transaction-request/input.ts
1035
+ import { BYTES_32, UTXO_ID_LEN } from "@fuel-ts/abi-coder";
1026
1036
  import { ZeroBytes32 } from "@fuel-ts/address/configs";
1027
1037
  import { ErrorCode as ErrorCode3, FuelError as FuelError3 } from "@fuel-ts/errors";
1028
1038
  import { bn as bn2, toNumber } from "@fuel-ts/math";
@@ -1036,8 +1046,8 @@ var inputify = (value) => {
1036
1046
  const predicateData = arrayify(value.predicateData ?? "0x");
1037
1047
  return {
1038
1048
  type: InputType.Coin,
1039
- txID: hexlify3(arrayify(value.id).slice(0, 32)),
1040
- outputIndex: arrayify(value.id)[32],
1049
+ txID: hexlify3(arrayify(value.id).slice(0, BYTES_32)),
1050
+ outputIndex: toNumber(arrayify(value.id).slice(BYTES_32, UTXO_ID_LEN)),
1041
1051
  owner: hexlify3(value.owner),
1042
1052
  amount: bn2(value.amount),
1043
1053
  assetId: hexlify3(value.assetId),
@@ -1155,9 +1165,11 @@ var outputify = (value) => {
1155
1165
  };
1156
1166
 
1157
1167
  // src/providers/transaction-request/transaction-request.ts
1168
+ import { UTXO_ID_LEN as UTXO_ID_LEN2 } from "@fuel-ts/abi-coder";
1158
1169
  import { Address, addressify } from "@fuel-ts/address";
1159
1170
  import { BaseAssetId as BaseAssetId2, ZeroBytes32 as ZeroBytes324 } from "@fuel-ts/address/configs";
1160
- import { bn as bn6 } from "@fuel-ts/math";
1171
+ import { randomBytes } from "@fuel-ts/crypto";
1172
+ import { bn as bn7 } from "@fuel-ts/math";
1161
1173
  import {
1162
1174
  PolicyType,
1163
1175
  TransactionCoder,
@@ -1562,6 +1574,86 @@ function sleep(time) {
1562
1574
  });
1563
1575
  }
1564
1576
 
1577
+ // src/providers/utils/extract-tx-error.ts
1578
+ import { ErrorCode as ErrorCode7, FuelError as FuelError7 } from "@fuel-ts/errors";
1579
+ import { bn as bn6 } from "@fuel-ts/math";
1580
+ import { ReceiptType as ReceiptType3 } from "@fuel-ts/transactions";
1581
+ import {
1582
+ FAILED_REQUIRE_SIGNAL,
1583
+ FAILED_ASSERT_EQ_SIGNAL,
1584
+ FAILED_ASSERT_NE_SIGNAL,
1585
+ FAILED_ASSERT_SIGNAL,
1586
+ FAILED_TRANSFER_TO_ADDRESS_SIGNAL as FAILED_TRANSFER_TO_ADDRESS_SIGNAL2,
1587
+ PANIC_REASONS,
1588
+ PANIC_DOC_URL
1589
+ } from "@fuel-ts/transactions/configs";
1590
+ var assemblePanicError = (status) => {
1591
+ let errorMessage = `The transaction reverted with reason: "${status.reason}".`;
1592
+ const reason = status.reason;
1593
+ if (PANIC_REASONS.includes(status.reason)) {
1594
+ errorMessage = `${errorMessage}
1595
+
1596
+ You can read more about this error at:
1597
+
1598
+ ${PANIC_DOC_URL}#variant.${status.reason}`;
1599
+ }
1600
+ return { errorMessage, reason };
1601
+ };
1602
+ var stringify = (obj) => JSON.stringify(obj, null, 2);
1603
+ var assembleRevertError = (receipts, logs) => {
1604
+ let errorMessage = "The transaction reverted with an unknown reason.";
1605
+ const revertReceipt = receipts.find(({ type }) => type === ReceiptType3.Revert);
1606
+ let reason = "";
1607
+ if (revertReceipt) {
1608
+ const reasonHex = bn6(revertReceipt.val).toHex();
1609
+ switch (reasonHex) {
1610
+ case FAILED_REQUIRE_SIGNAL: {
1611
+ reason = "require";
1612
+ errorMessage = `The transaction reverted because a "require" statement has thrown ${logs.length ? stringify(logs[0]) : "an error."}.`;
1613
+ break;
1614
+ }
1615
+ case FAILED_ASSERT_EQ_SIGNAL: {
1616
+ const sufix = logs.length >= 2 ? ` comparing ${stringify(logs[1])} and ${stringify(logs[0])}.` : ".";
1617
+ reason = "assert_eq";
1618
+ errorMessage = `The transaction reverted because of an "assert_eq" statement${sufix}`;
1619
+ break;
1620
+ }
1621
+ case FAILED_ASSERT_NE_SIGNAL: {
1622
+ const sufix = logs.length >= 2 ? ` comparing ${stringify(logs[1])} and ${stringify(logs[0])}.` : ".";
1623
+ reason = "assert_ne";
1624
+ errorMessage = `The transaction reverted because of an "assert_ne" statement${sufix}`;
1625
+ break;
1626
+ }
1627
+ case FAILED_ASSERT_SIGNAL:
1628
+ reason = "assert";
1629
+ errorMessage = `The transaction reverted because an "assert" statement failed to evaluate to true.`;
1630
+ break;
1631
+ case FAILED_TRANSFER_TO_ADDRESS_SIGNAL2:
1632
+ reason = "MissingOutputChange";
1633
+ errorMessage = `The transaction reverted because it's missing an "OutputChange".`;
1634
+ break;
1635
+ default:
1636
+ reason = "unknown";
1637
+ errorMessage = `The transaction reverted with an unknown reason: ${revertReceipt.val}`;
1638
+ }
1639
+ }
1640
+ return { errorMessage, reason };
1641
+ };
1642
+ var extractTxError = (params) => {
1643
+ const { receipts, status, logs } = params;
1644
+ const isPanic = receipts.some(({ type }) => type === ReceiptType3.Panic);
1645
+ const isRevert = receipts.some(({ type }) => type === ReceiptType3.Revert);
1646
+ const { errorMessage, reason } = status?.type === "FailureStatus" && isPanic ? assemblePanicError(status) : assembleRevertError(receipts, logs);
1647
+ const metadata = {
1648
+ logs,
1649
+ receipts,
1650
+ panic: isPanic,
1651
+ revert: isRevert,
1652
+ reason
1653
+ };
1654
+ return new FuelError7(ErrorCode7.SCRIPT_REVERTED, errorMessage, metadata);
1655
+ };
1656
+
1565
1657
  // src/providers/transaction-request/errors.ts
1566
1658
  var ChangeOutputCollisionError = class extends Error {
1567
1659
  name = "ChangeOutputCollisionError";
@@ -1624,10 +1716,10 @@ var BaseTransactionRequest = class {
1624
1716
  outputs,
1625
1717
  witnesses
1626
1718
  } = {}) {
1627
- this.gasPrice = bn6(gasPrice);
1719
+ this.gasPrice = bn7(gasPrice);
1628
1720
  this.maturity = maturity ?? 0;
1629
- this.witnessLimit = witnessLimit ? bn6(witnessLimit) : void 0;
1630
- this.maxFee = maxFee ? bn6(maxFee) : void 0;
1721
+ this.witnessLimit = witnessLimit ? bn7(witnessLimit) : void 0;
1722
+ this.maxFee = maxFee ? bn7(maxFee) : void 0;
1631
1723
  this.inputs = inputs ?? [];
1632
1724
  this.outputs = outputs ?? [];
1633
1725
  this.witnesses = witnesses ?? [];
@@ -1843,8 +1935,7 @@ var BaseTransactionRequest = class {
1843
1935
  assetId,
1844
1936
  txPointer: "0x00000000000000000000000000000000",
1845
1937
  witnessIndex,
1846
- predicate: predicate?.bytes,
1847
- predicateData: predicate?.predicateDataBytes
1938
+ predicate: predicate?.bytes
1848
1939
  };
1849
1940
  this.pushInput(input);
1850
1941
  this.addChangeOutput(owner, assetId);
@@ -1876,8 +1967,7 @@ var BaseTransactionRequest = class {
1876
1967
  recipient: recipient.toB256(),
1877
1968
  amount,
1878
1969
  witnessIndex,
1879
- predicate: predicate?.bytes,
1880
- predicateData: predicate?.predicateDataBytes
1970
+ predicate: predicate?.bytes
1881
1971
  };
1882
1972
  this.pushInput(input);
1883
1973
  this.addChangeOutput(recipient, assetId);
@@ -2032,12 +2122,6 @@ var BaseTransactionRequest = class {
2032
2122
  * @param quantities - CoinQuantity Array.
2033
2123
  */
2034
2124
  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
2125
  const findAssetInput = (assetId) => this.inputs.find((input) => {
2042
2126
  if ("assetId" in input) {
2043
2127
  return input.assetId === assetId;
@@ -2047,23 +2131,23 @@ var BaseTransactionRequest = class {
2047
2131
  const updateAssetInput = (assetId, quantity) => {
2048
2132
  const assetInput = findAssetInput(assetId);
2049
2133
  if (assetInput && "assetId" in assetInput) {
2050
- assetInput.id = generateId();
2134
+ assetInput.id = hexlify7(randomBytes(UTXO_ID_LEN2));
2051
2135
  assetInput.amount = quantity;
2052
2136
  } else {
2053
2137
  this.addResources([
2054
2138
  {
2055
- id: generateId(),
2139
+ id: hexlify7(randomBytes(UTXO_ID_LEN2)),
2056
2140
  amount: quantity,
2057
2141
  assetId,
2058
2142
  owner: resourcesOwner || Address.fromRandom(),
2059
2143
  maturity: 0,
2060
- blockCreated: bn6(1),
2061
- txCreatedIdx: bn6(1)
2144
+ blockCreated: bn7(1),
2145
+ txCreatedIdx: bn7(1)
2062
2146
  }
2063
2147
  ]);
2064
2148
  }
2065
2149
  };
2066
- updateAssetInput(BaseAssetId2, bn6(1e11));
2150
+ updateAssetInput(BaseAssetId2, bn7(1e11));
2067
2151
  quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
2068
2152
  }
2069
2153
  /**
@@ -2074,7 +2158,7 @@ var BaseTransactionRequest = class {
2074
2158
  */
2075
2159
  getCoinOutputsQuantities() {
2076
2160
  const coinsQuantities = this.getCoinOutputs().map(({ amount, assetId }) => ({
2077
- amount: bn6(amount),
2161
+ amount: bn7(amount),
2078
2162
  assetId: assetId.toString()
2079
2163
  }));
2080
2164
  return coinsQuantities;
@@ -2103,7 +2187,7 @@ var BaseTransactionRequest = class {
2103
2187
  default:
2104
2188
  return;
2105
2189
  }
2106
- if (correspondingInput && "predicateGasUsed" in correspondingInput && bn6(correspondingInput.predicateGasUsed).gt(0)) {
2190
+ if (correspondingInput && "predicateGasUsed" in correspondingInput && bn7(correspondingInput.predicateGasUsed).gt(0)) {
2107
2191
  i.predicate = correspondingInput.predicate;
2108
2192
  i.predicateData = correspondingInput.predicateData;
2109
2193
  i.predicateGasUsed = correspondingInput.predicateGasUsed;
@@ -2114,14 +2198,14 @@ var BaseTransactionRequest = class {
2114
2198
 
2115
2199
  // src/providers/transaction-request/create-transaction-request.ts
2116
2200
  import { ZeroBytes32 as ZeroBytes326 } from "@fuel-ts/address/configs";
2117
- import { bn as bn8 } from "@fuel-ts/math";
2201
+ import { bn as bn9 } from "@fuel-ts/math";
2118
2202
  import { TransactionType as TransactionType3, OutputType as OutputType4 } from "@fuel-ts/transactions";
2119
2203
  import { arrayify as arrayify6, hexlify as hexlify9 } from "@fuel-ts/utils";
2120
2204
 
2121
2205
  // src/providers/transaction-request/hash-transaction.ts
2122
2206
  import { ZeroBytes32 as ZeroBytes325 } from "@fuel-ts/address/configs";
2123
2207
  import { uint64ToBytesBE, sha256 } from "@fuel-ts/hasher";
2124
- import { bn as bn7 } from "@fuel-ts/math";
2208
+ import { bn as bn8 } from "@fuel-ts/math";
2125
2209
  import { TransactionType as TransactionType2, InputType as InputType3, OutputType as OutputType3, TransactionCoder as TransactionCoder2 } from "@fuel-ts/transactions";
2126
2210
  import { concat as concat2 } from "@fuel-ts/utils";
2127
2211
  import { clone as clone2 } from "ramda";
@@ -2138,11 +2222,11 @@ function hashTransaction(transactionRequest, chainId) {
2138
2222
  blockHeight: 0,
2139
2223
  txIndex: 0
2140
2224
  };
2141
- inputClone.predicateGasUsed = bn7(0);
2225
+ inputClone.predicateGasUsed = bn8(0);
2142
2226
  return inputClone;
2143
2227
  }
2144
2228
  case InputType3.Message: {
2145
- inputClone.predicateGasUsed = bn7(0);
2229
+ inputClone.predicateGasUsed = bn8(0);
2146
2230
  return inputClone;
2147
2231
  }
2148
2232
  case InputType3.Contract: {
@@ -2169,12 +2253,12 @@ function hashTransaction(transactionRequest, chainId) {
2169
2253
  return outputClone;
2170
2254
  }
2171
2255
  case OutputType3.Change: {
2172
- outputClone.amount = bn7(0);
2256
+ outputClone.amount = bn8(0);
2173
2257
  return outputClone;
2174
2258
  }
2175
2259
  case OutputType3.Variable: {
2176
2260
  outputClone.to = ZeroBytes325;
2177
- outputClone.amount = bn7(0);
2261
+ outputClone.amount = bn8(0);
2178
2262
  outputClone.assetId = ZeroBytes325;
2179
2263
  return outputClone;
2180
2264
  }
@@ -2298,7 +2382,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2298
2382
  }
2299
2383
  metadataGas(gasCosts) {
2300
2384
  return calculateMetadataGasForTxCreate({
2301
- contractBytesSize: bn8(arrayify6(this.witnesses[this.bytecodeWitnessIndex] || "0x").length),
2385
+ contractBytesSize: bn9(arrayify6(this.witnesses[this.bytecodeWitnessIndex] || "0x").length),
2302
2386
  gasCosts,
2303
2387
  stateRootSize: this.storageSlots.length,
2304
2388
  txBytesSize: this.byteSize()
@@ -2310,7 +2394,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2310
2394
  import { Interface } from "@fuel-ts/abi-coder";
2311
2395
  import { addressify as addressify2 } from "@fuel-ts/address";
2312
2396
  import { ZeroBytes32 as ZeroBytes327 } from "@fuel-ts/address/configs";
2313
- import { bn as bn9 } from "@fuel-ts/math";
2397
+ import { bn as bn10 } from "@fuel-ts/math";
2314
2398
  import { InputType as InputType4, OutputType as OutputType5, TransactionType as TransactionType4 } from "@fuel-ts/transactions";
2315
2399
  import { arrayify as arrayify8, hexlify as hexlify10 } from "@fuel-ts/utils";
2316
2400
 
@@ -2364,7 +2448,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2364
2448
  */
2365
2449
  constructor({ script, scriptData, gasLimit, ...rest } = {}) {
2366
2450
  super(rest);
2367
- this.gasLimit = bn9(gasLimit);
2451
+ this.gasLimit = bn10(gasLimit);
2368
2452
  this.script = arrayify8(script ?? returnZeroScript.bytes);
2369
2453
  this.scriptData = arrayify8(scriptData ?? returnZeroScript.encodeScriptData());
2370
2454
  this.abis = rest.abis;
@@ -2512,7 +2596,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2512
2596
  };
2513
2597
 
2514
2598
  // src/providers/transaction-request/utils.ts
2515
- import { ErrorCode as ErrorCode7, FuelError as FuelError7 } from "@fuel-ts/errors";
2599
+ import { ErrorCode as ErrorCode8, FuelError as FuelError8 } from "@fuel-ts/errors";
2516
2600
  import { TransactionType as TransactionType5 } from "@fuel-ts/transactions";
2517
2601
  var transactionRequestify = (obj) => {
2518
2602
  if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest) {
@@ -2527,14 +2611,14 @@ var transactionRequestify = (obj) => {
2527
2611
  return CreateTransactionRequest.from(obj);
2528
2612
  }
2529
2613
  default: {
2530
- throw new FuelError7(ErrorCode7.INVALID_TRANSACTION_TYPE, `Invalid transaction type: ${type}.`);
2614
+ throw new FuelError8(ErrorCode8.INVALID_TRANSACTION_TYPE, `Invalid transaction type: ${type}.`);
2531
2615
  }
2532
2616
  }
2533
2617
  };
2534
2618
 
2535
2619
  // src/providers/transaction-response/transaction-response.ts
2536
- import { ErrorCode as ErrorCode11, FuelError as FuelError11 } from "@fuel-ts/errors";
2537
- import { bn as bn13 } from "@fuel-ts/math";
2620
+ import { ErrorCode as ErrorCode12, FuelError as FuelError12 } from "@fuel-ts/errors";
2621
+ import { bn as bn14 } from "@fuel-ts/math";
2538
2622
  import { TransactionCoder as TransactionCoder4 } from "@fuel-ts/transactions";
2539
2623
  import { arrayify as arrayify10 } from "@fuel-ts/utils";
2540
2624
 
@@ -2542,7 +2626,7 @@ import { arrayify as arrayify10 } from "@fuel-ts/utils";
2542
2626
  import { DateTime, hexlify as hexlify11 } from "@fuel-ts/utils";
2543
2627
 
2544
2628
  // src/providers/transaction-summary/calculate-transaction-fee.ts
2545
- import { bn as bn10 } from "@fuel-ts/math";
2629
+ import { bn as bn11 } from "@fuel-ts/math";
2546
2630
  import { PolicyType as PolicyType2, TransactionCoder as TransactionCoder3, TransactionType as TransactionType6 } from "@fuel-ts/transactions";
2547
2631
  import { arrayify as arrayify9 } from "@fuel-ts/utils";
2548
2632
  var calculateTransactionFee = (params) => {
@@ -2551,24 +2635,24 @@ var calculateTransactionFee = (params) => {
2551
2635
  rawPayload,
2552
2636
  consensusParameters: { gasCosts, feeParams }
2553
2637
  } = params;
2554
- const gasPerByte = bn10(feeParams.gasPerByte);
2555
- const gasPriceFactor = bn10(feeParams.gasPriceFactor);
2638
+ const gasPerByte = bn11(feeParams.gasPerByte);
2639
+ const gasPriceFactor = bn11(feeParams.gasPriceFactor);
2556
2640
  const transactionBytes = arrayify9(rawPayload);
2557
2641
  const [transaction] = new TransactionCoder3().decode(transactionBytes, 0);
2558
2642
  if (transaction.type === TransactionType6.Mint) {
2559
2643
  return {
2560
- fee: bn10(0),
2561
- minFee: bn10(0),
2562
- maxFee: bn10(0),
2563
- feeFromGasUsed: bn10(0)
2644
+ fee: bn11(0),
2645
+ minFee: bn11(0),
2646
+ maxFee: bn11(0),
2647
+ feeFromGasUsed: bn11(0)
2564
2648
  };
2565
2649
  }
2566
2650
  const { type, witnesses, inputs, policies } = transaction;
2567
- let metadataGas = bn10(0);
2568
- let gasLimit = bn10(0);
2651
+ let metadataGas = bn11(0);
2652
+ let gasLimit = bn11(0);
2569
2653
  if (type === TransactionType6.Create) {
2570
2654
  const { bytecodeWitnessIndex, storageSlots } = transaction;
2571
- const contractBytesSize = bn10(arrayify9(witnesses[bytecodeWitnessIndex].data).length);
2655
+ const contractBytesSize = bn11(arrayify9(witnesses[bytecodeWitnessIndex].data).length);
2572
2656
  metadataGas = calculateMetadataGasForTxCreate({
2573
2657
  contractBytesSize,
2574
2658
  gasCosts,
@@ -2587,12 +2671,12 @@ var calculateTransactionFee = (params) => {
2587
2671
  }
2588
2672
  const minGas = getMinGas({
2589
2673
  gasCosts,
2590
- gasPerByte: bn10(gasPerByte),
2674
+ gasPerByte: bn11(gasPerByte),
2591
2675
  inputs,
2592
2676
  metadataGas,
2593
2677
  txBytesSize: transactionBytes.length
2594
2678
  });
2595
- const gasPrice = bn10(policies.find((policy) => policy.type === PolicyType2.GasPrice)?.data);
2679
+ const gasPrice = bn11(policies.find((policy) => policy.type === PolicyType2.GasPrice)?.data);
2596
2680
  const witnessLimit = policies.find((policy) => policy.type === PolicyType2.WitnessLimit)?.data;
2597
2681
  const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
2598
2682
  const maxGas = getMaxGas({
@@ -2616,13 +2700,13 @@ var calculateTransactionFee = (params) => {
2616
2700
 
2617
2701
  // src/providers/transaction-summary/operations.ts
2618
2702
  import { ZeroBytes32 as ZeroBytes328 } from "@fuel-ts/address/configs";
2619
- import { ErrorCode as ErrorCode9, FuelError as FuelError9 } from "@fuel-ts/errors";
2620
- import { bn as bn12 } from "@fuel-ts/math";
2621
- import { ReceiptType as ReceiptType3, TransactionType as TransactionType7 } from "@fuel-ts/transactions";
2703
+ import { ErrorCode as ErrorCode10, FuelError as FuelError10 } from "@fuel-ts/errors";
2704
+ import { bn as bn13 } from "@fuel-ts/math";
2705
+ import { ReceiptType as ReceiptType4, TransactionType as TransactionType7 } from "@fuel-ts/transactions";
2622
2706
 
2623
2707
  // src/providers/transaction-summary/call.ts
2624
2708
  import { Interface as Interface2, calculateVmTxMemory } from "@fuel-ts/abi-coder";
2625
- import { bn as bn11 } from "@fuel-ts/math";
2709
+ import { bn as bn12 } from "@fuel-ts/math";
2626
2710
  var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
2627
2711
  const abiInterface = new Interface2(abi);
2628
2712
  const callFunctionSelector = receipt.param1.toHex(8);
@@ -2631,7 +2715,7 @@ var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
2631
2715
  let encodedArgs;
2632
2716
  if (functionFragment.isInputDataPointer) {
2633
2717
  if (rawPayload) {
2634
- const argsOffset = bn11(receipt.param2).sub(calculateVmTxMemory({ maxInputs: maxInputs.toNumber() })).toNumber();
2718
+ const argsOffset = bn12(receipt.param2).sub(calculateVmTxMemory({ maxInputs: maxInputs.toNumber() })).toNumber();
2635
2719
  encodedArgs = `0x${rawPayload.slice(2).slice(argsOffset * 2)}`;
2636
2720
  }
2637
2721
  } else {
@@ -2665,7 +2749,7 @@ var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
2665
2749
  };
2666
2750
 
2667
2751
  // src/providers/transaction-summary/input.ts
2668
- import { ErrorCode as ErrorCode8, FuelError as FuelError8 } from "@fuel-ts/errors";
2752
+ import { ErrorCode as ErrorCode9, FuelError as FuelError9 } from "@fuel-ts/errors";
2669
2753
  import { InputType as InputType5 } from "@fuel-ts/transactions";
2670
2754
  function getInputsByTypes(inputs, types) {
2671
2755
  return inputs.filter((i) => types.includes(i.type));
@@ -2703,8 +2787,8 @@ function getInputContractFromIndex(inputs, inputIndex) {
2703
2787
  return void 0;
2704
2788
  }
2705
2789
  if (contractInput.type !== InputType5.Contract) {
2706
- throw new FuelError8(
2707
- ErrorCode8.INVALID_TRANSACTION_INPUT,
2790
+ throw new FuelError9(
2791
+ ErrorCode9.INVALID_TRANSACTION_INPUT,
2708
2792
  `Contract input should be of type 'contract'.`
2709
2793
  );
2710
2794
  }
@@ -2792,8 +2876,8 @@ function getTransactionTypeName(transactionType) {
2792
2876
  case TransactionType7.Script:
2793
2877
  return "Script" /* Script */;
2794
2878
  default:
2795
- throw new FuelError9(
2796
- ErrorCode9.INVALID_TRANSACTION_TYPE,
2879
+ throw new FuelError10(
2880
+ ErrorCode10.INVALID_TRANSACTION_TYPE,
2797
2881
  `Invalid transaction type: ${transactionType}.`
2798
2882
  );
2799
2883
  }
@@ -2815,10 +2899,10 @@ function hasSameAssetId(a) {
2815
2899
  return (b) => a.assetId === b.assetId;
2816
2900
  }
2817
2901
  function getReceiptsCall(receipts) {
2818
- return getReceiptsByType(receipts, ReceiptType3.Call);
2902
+ return getReceiptsByType(receipts, ReceiptType4.Call);
2819
2903
  }
2820
2904
  function getReceiptsMessageOut(receipts) {
2821
- return getReceiptsByType(receipts, ReceiptType3.MessageOut);
2905
+ return getReceiptsByType(receipts, ReceiptType4.MessageOut);
2822
2906
  }
2823
2907
  var mergeAssets = (op1, op2) => {
2824
2908
  const assets1 = op1.assetsSent || [];
@@ -2831,7 +2915,7 @@ var mergeAssets = (op1, op2) => {
2831
2915
  if (!matchingAsset) {
2832
2916
  return asset1;
2833
2917
  }
2834
- const mergedAmount = bn12(asset1.amount).add(matchingAsset.amount);
2918
+ const mergedAmount = bn13(asset1.amount).add(matchingAsset.amount);
2835
2919
  return { ...asset1, amount: mergedAmount };
2836
2920
  });
2837
2921
  return mergedAssets.concat(filteredAssets);
@@ -2857,7 +2941,7 @@ function addOperation(operations, toAdd) {
2857
2941
  return allOperations;
2858
2942
  }
2859
2943
  function getReceiptsTransferOut(receipts) {
2860
- return getReceiptsByType(receipts, ReceiptType3.TransferOut);
2944
+ return getReceiptsByType(receipts, ReceiptType4.TransferOut);
2861
2945
  }
2862
2946
  function getWithdrawFromFuelOperations({
2863
2947
  inputs,
@@ -3017,11 +3101,11 @@ function getTransferOperations({
3017
3101
  });
3018
3102
  const transferReceipts = getReceiptsByType(
3019
3103
  receipts,
3020
- ReceiptType3.Transfer
3104
+ ReceiptType4.Transfer
3021
3105
  );
3022
3106
  const transferOutReceipts = getReceiptsByType(
3023
3107
  receipts,
3024
- ReceiptType3.TransferOut
3108
+ ReceiptType4.TransferOut
3025
3109
  );
3026
3110
  [...transferReceipts, ...transferOutReceipts].forEach((receipt) => {
3027
3111
  const operation = extractTransferOperationFromReceipt(receipt, contractInputs, changeOutputs);
@@ -3106,17 +3190,17 @@ function getOperations({
3106
3190
  }
3107
3191
 
3108
3192
  // src/providers/transaction-summary/receipt.ts
3109
- import { ReceiptType as ReceiptType4 } from "@fuel-ts/transactions";
3193
+ import { ReceiptType as ReceiptType5 } from "@fuel-ts/transactions";
3110
3194
  var processGqlReceipt = (gqlReceipt) => {
3111
3195
  const receipt = assembleReceiptByType(gqlReceipt);
3112
3196
  switch (receipt.type) {
3113
- case ReceiptType4.ReturnData: {
3197
+ case ReceiptType5.ReturnData: {
3114
3198
  return {
3115
3199
  ...receipt,
3116
3200
  data: gqlReceipt.data || "0x"
3117
3201
  };
3118
3202
  }
3119
- case ReceiptType4.LogData: {
3203
+ case ReceiptType5.LogData: {
3120
3204
  return {
3121
3205
  ...receipt,
3122
3206
  data: gqlReceipt.data || "0x"
@@ -3129,7 +3213,7 @@ var processGqlReceipt = (gqlReceipt) => {
3129
3213
  var extractMintedAssetsFromReceipts = (receipts) => {
3130
3214
  const mintedAssets = [];
3131
3215
  receipts.forEach((receipt) => {
3132
- if (receipt.type === ReceiptType4.Mint) {
3216
+ if (receipt.type === ReceiptType5.Mint) {
3133
3217
  mintedAssets.push({
3134
3218
  subId: receipt.subId,
3135
3219
  contractId: receipt.contractId,
@@ -3143,7 +3227,7 @@ var extractMintedAssetsFromReceipts = (receipts) => {
3143
3227
  var extractBurnedAssetsFromReceipts = (receipts) => {
3144
3228
  const burnedAssets = [];
3145
3229
  receipts.forEach((receipt) => {
3146
- if (receipt.type === ReceiptType4.Burn) {
3230
+ if (receipt.type === ReceiptType5.Burn) {
3147
3231
  burnedAssets.push({
3148
3232
  subId: receipt.subId,
3149
3233
  contractId: receipt.contractId,
@@ -3156,7 +3240,7 @@ var extractBurnedAssetsFromReceipts = (receipts) => {
3156
3240
  };
3157
3241
 
3158
3242
  // src/providers/transaction-summary/status.ts
3159
- import { ErrorCode as ErrorCode10, FuelError as FuelError10 } from "@fuel-ts/errors";
3243
+ import { ErrorCode as ErrorCode11, FuelError as FuelError11 } from "@fuel-ts/errors";
3160
3244
  var getTransactionStatusName = (gqlStatus) => {
3161
3245
  switch (gqlStatus) {
3162
3246
  case "FailureStatus":
@@ -3168,8 +3252,8 @@ var getTransactionStatusName = (gqlStatus) => {
3168
3252
  case "SqueezedOutStatus":
3169
3253
  return "squeezedout" /* squeezedout */;
3170
3254
  default:
3171
- throw new FuelError10(
3172
- ErrorCode10.INVALID_TRANSACTION_STATUS,
3255
+ throw new FuelError11(
3256
+ ErrorCode11.INVALID_TRANSACTION_STATUS,
3173
3257
  `Invalid transaction status: ${gqlStatus}.`
3174
3258
  );
3175
3259
  }
@@ -3282,12 +3366,12 @@ function assembleTransactionSummary(params) {
3282
3366
 
3283
3367
  // src/providers/transaction-response/getDecodedLogs.ts
3284
3368
  import { Interface as Interface3, BigNumberCoder } from "@fuel-ts/abi-coder";
3285
- import { ReceiptType as ReceiptType5 } from "@fuel-ts/transactions";
3369
+ import { ReceiptType as ReceiptType6 } from "@fuel-ts/transactions";
3286
3370
  function getDecodedLogs(receipts, mainAbi, externalAbis = {}) {
3287
3371
  return receipts.reduce((logs, receipt) => {
3288
- if (receipt.type === ReceiptType5.LogData || receipt.type === ReceiptType5.Log) {
3372
+ if (receipt.type === ReceiptType6.LogData || receipt.type === ReceiptType6.Log) {
3289
3373
  const interfaceToUse = new Interface3(externalAbis[receipt.id] || mainAbi);
3290
- const data = receipt.type === ReceiptType5.Log ? new BigNumberCoder("u64").encode(receipt.val0) : receipt.data;
3374
+ const data = receipt.type === ReceiptType6.Log ? new BigNumberCoder("u64").encode(receipt.val0) : receipt.data;
3291
3375
  const [decodedLog] = interfaceToUse.decodeLog(data, receipt.val1.toNumber());
3292
3376
  logs.push(decodedLog);
3293
3377
  }
@@ -3302,7 +3386,7 @@ var TransactionResponse = class {
3302
3386
  /** Current provider */
3303
3387
  provider;
3304
3388
  /** Gas used on the transaction */
3305
- gasUsed = bn13(0);
3389
+ gasUsed = bn14(0);
3306
3390
  /** The graphql Transaction with receipts object. */
3307
3391
  gqlTransaction;
3308
3392
  abis;
@@ -3407,8 +3491,8 @@ var TransactionResponse = class {
3407
3491
  });
3408
3492
  for await (const { statusChange } of subscription) {
3409
3493
  if (statusChange.type === "SqueezedOutStatus") {
3410
- throw new FuelError11(
3411
- ErrorCode11.TRANSACTION_SQUEEZED_OUT,
3494
+ throw new FuelError12(
3495
+ ErrorCode12.TRANSACTION_SQUEEZED_OUT,
3412
3496
  `Transaction Squeezed Out with reason: ${statusChange.reason}`
3413
3497
  );
3414
3498
  }
@@ -3430,14 +3514,26 @@ var TransactionResponse = class {
3430
3514
  gqlTransaction: this.gqlTransaction,
3431
3515
  ...transactionSummary
3432
3516
  };
3517
+ let logs = [];
3433
3518
  if (this.abis) {
3434
- const logs = getDecodedLogs(
3519
+ logs = getDecodedLogs(
3435
3520
  transactionSummary.receipts,
3436
3521
  this.abis.main,
3437
3522
  this.abis.otherContractsAbis
3438
3523
  );
3439
3524
  transactionResult.logs = logs;
3440
3525
  }
3526
+ if (transactionResult.isStatusFailure) {
3527
+ const {
3528
+ receipts,
3529
+ gqlTransaction: { status }
3530
+ } = transactionResult;
3531
+ throw extractTxError({
3532
+ receipts,
3533
+ status,
3534
+ logs
3535
+ });
3536
+ }
3441
3537
  return transactionResult;
3442
3538
  }
3443
3539
  /**
@@ -3446,14 +3542,7 @@ var TransactionResponse = class {
3446
3542
  * @param contractsAbiMap - The contracts ABI map.
3447
3543
  */
3448
3544
  async wait(contractsAbiMap) {
3449
- const result = await this.waitForResult(contractsAbiMap);
3450
- if (result.isStatusFailure) {
3451
- throw new FuelError11(
3452
- ErrorCode11.TRANSACTION_FAILED,
3453
- `Transaction failed: ${result.gqlTransaction.status.reason}`
3454
- );
3455
- }
3456
- return result;
3545
+ return this.waitForResult(contractsAbiMap);
3457
3546
  }
3458
3547
  };
3459
3548
 
@@ -3515,29 +3604,29 @@ var processGqlChain = (chain) => {
3515
3604
  const { contractParams, feeParams, predicateParams, scriptParams, txParams, gasCosts } = consensusParameters;
3516
3605
  return {
3517
3606
  name,
3518
- baseChainHeight: bn14(daHeight),
3607
+ baseChainHeight: bn15(daHeight),
3519
3608
  consensusParameters: {
3520
- contractMaxSize: bn14(contractParams.contractMaxSize),
3521
- maxInputs: bn14(txParams.maxInputs),
3522
- maxOutputs: bn14(txParams.maxOutputs),
3523
- maxWitnesses: bn14(txParams.maxWitnesses),
3524
- maxGasPerTx: bn14(txParams.maxGasPerTx),
3525
- maxScriptLength: bn14(scriptParams.maxScriptLength),
3526
- maxScriptDataLength: bn14(scriptParams.maxScriptDataLength),
3527
- maxStorageSlots: bn14(contractParams.maxStorageSlots),
3528
- maxPredicateLength: bn14(predicateParams.maxPredicateLength),
3529
- maxPredicateDataLength: bn14(predicateParams.maxPredicateDataLength),
3530
- maxGasPerPredicate: bn14(predicateParams.maxGasPerPredicate),
3531
- gasPriceFactor: bn14(feeParams.gasPriceFactor),
3532
- gasPerByte: bn14(feeParams.gasPerByte),
3533
- maxMessageDataLength: bn14(predicateParams.maxMessageDataLength),
3534
- chainId: bn14(consensusParameters.chainId),
3609
+ contractMaxSize: bn15(contractParams.contractMaxSize),
3610
+ maxInputs: bn15(txParams.maxInputs),
3611
+ maxOutputs: bn15(txParams.maxOutputs),
3612
+ maxWitnesses: bn15(txParams.maxWitnesses),
3613
+ maxGasPerTx: bn15(txParams.maxGasPerTx),
3614
+ maxScriptLength: bn15(scriptParams.maxScriptLength),
3615
+ maxScriptDataLength: bn15(scriptParams.maxScriptDataLength),
3616
+ maxStorageSlots: bn15(contractParams.maxStorageSlots),
3617
+ maxPredicateLength: bn15(predicateParams.maxPredicateLength),
3618
+ maxPredicateDataLength: bn15(predicateParams.maxPredicateDataLength),
3619
+ maxGasPerPredicate: bn15(predicateParams.maxGasPerPredicate),
3620
+ gasPriceFactor: bn15(feeParams.gasPriceFactor),
3621
+ gasPerByte: bn15(feeParams.gasPerByte),
3622
+ maxMessageDataLength: bn15(predicateParams.maxMessageDataLength),
3623
+ chainId: bn15(consensusParameters.chainId),
3535
3624
  gasCosts
3536
3625
  },
3537
3626
  gasCosts,
3538
3627
  latestBlock: {
3539
3628
  id: latestBlock.id,
3540
- height: bn14(latestBlock.header.height),
3629
+ height: bn15(latestBlock.header.height),
3541
3630
  time: latestBlock.header.time,
3542
3631
  transactions: latestBlock.transactions.map((i) => ({
3543
3632
  id: i.id
@@ -3607,8 +3696,8 @@ var _Provider = class {
3607
3696
  getChain() {
3608
3697
  const chain = _Provider.chainInfoCache[this.url];
3609
3698
  if (!chain) {
3610
- throw new FuelError12(
3611
- ErrorCode12.CHAIN_INFO_CACHE_EMPTY,
3699
+ throw new FuelError13(
3700
+ ErrorCode13.CHAIN_INFO_CACHE_EMPTY,
3612
3701
  "Chain info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
3613
3702
  );
3614
3703
  }
@@ -3620,8 +3709,8 @@ var _Provider = class {
3620
3709
  getNode() {
3621
3710
  const node = _Provider.nodeInfoCache[this.url];
3622
3711
  if (!node) {
3623
- throw new FuelError12(
3624
- ErrorCode12.NODE_INFO_CACHE_EMPTY,
3712
+ throw new FuelError13(
3713
+ ErrorCode13.NODE_INFO_CACHE_EMPTY,
3625
3714
  "Node info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
3626
3715
  );
3627
3716
  }
@@ -3668,8 +3757,8 @@ var _Provider = class {
3668
3757
  static ensureClientVersionIsSupported(nodeInfo) {
3669
3758
  const { isMajorSupported, isMinorSupported, supportedVersion } = checkFuelCoreVersionCompatibility(nodeInfo.nodeVersion);
3670
3759
  if (!isMajorSupported || !isMinorSupported) {
3671
- throw new FuelError12(
3672
- FuelError12.CODES.UNSUPPORTED_FUEL_CLIENT_VERSION,
3760
+ throw new FuelError13(
3761
+ FuelError13.CODES.UNSUPPORTED_FUEL_CLIENT_VERSION,
3673
3762
  `Fuel client version: ${nodeInfo.nodeVersion}, Supported version: ${supportedVersion}`
3674
3763
  );
3675
3764
  }
@@ -3732,7 +3821,7 @@ var _Provider = class {
3732
3821
  */
3733
3822
  async getBlockNumber() {
3734
3823
  const { chain } = await this.operations.getChain();
3735
- return bn14(chain.latestBlock.header.height, 10);
3824
+ return bn15(chain.latestBlock.header.height, 10);
3736
3825
  }
3737
3826
  /**
3738
3827
  * Returns the chain information.
@@ -3742,9 +3831,9 @@ var _Provider = class {
3742
3831
  async fetchNode() {
3743
3832
  const { nodeInfo } = await this.operations.getNodeInfo();
3744
3833
  const processedNodeInfo = {
3745
- maxDepth: bn14(nodeInfo.maxDepth),
3746
- maxTx: bn14(nodeInfo.maxTx),
3747
- minGasPrice: bn14(nodeInfo.minGasPrice),
3834
+ maxDepth: bn15(nodeInfo.maxDepth),
3835
+ maxTx: bn15(nodeInfo.maxTx),
3836
+ minGasPrice: bn15(nodeInfo.minGasPrice),
3748
3837
  nodeVersion: nodeInfo.nodeVersion,
3749
3838
  utxoValidation: nodeInfo.utxoValidation,
3750
3839
  vmBacktrace: nodeInfo.vmBacktrace,
@@ -3799,8 +3888,8 @@ var _Provider = class {
3799
3888
  const subscription = this.operations.submitAndAwait({ encodedTransaction });
3800
3889
  for await (const { submitAndAwait } of subscription) {
3801
3890
  if (submitAndAwait.type === "SqueezedOutStatus") {
3802
- throw new FuelError12(
3803
- ErrorCode12.TRANSACTION_SQUEEZED_OUT,
3891
+ throw new FuelError13(
3892
+ ErrorCode13.TRANSACTION_SQUEEZED_OUT,
3804
3893
  `Transaction Squeezed Out with reason: ${submitAndAwait.reason}`
3805
3894
  );
3806
3895
  }
@@ -3867,7 +3956,7 @@ var _Provider = class {
3867
3956
  } = response;
3868
3957
  if (inputs) {
3869
3958
  inputs.forEach((input, index) => {
3870
- if ("predicateGasUsed" in input && bn14(input.predicateGasUsed).gt(0)) {
3959
+ if ("predicateGasUsed" in input && bn15(input.predicateGasUsed).gt(0)) {
3871
3960
  transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
3872
3961
  }
3873
3962
  });
@@ -3924,6 +4013,36 @@ var _Provider = class {
3924
4013
  missingContractIds
3925
4014
  };
3926
4015
  }
4016
+ /**
4017
+ * Estimates the transaction gas and fee based on the provided transaction request.
4018
+ * @param transactionRequest - The transaction request object.
4019
+ * @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
4020
+ */
4021
+ estimateTxGasAndFee(params) {
4022
+ const { transactionRequest } = params;
4023
+ const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
4024
+ const chainInfo = this.getChain();
4025
+ const gasPrice = transactionRequest.gasPrice.eq(0) ? minGasPrice : transactionRequest.gasPrice;
4026
+ transactionRequest.gasPrice = gasPrice;
4027
+ const minGas = transactionRequest.calculateMinGas(chainInfo);
4028
+ const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4029
+ if (transactionRequest.type === TransactionType8.Script) {
4030
+ if (transactionRequest.gasLimit.eq(0)) {
4031
+ transactionRequest.gasLimit = minGas;
4032
+ transactionRequest.gasLimit = maxGasPerTx.sub(
4033
+ transactionRequest.calculateMaxGas(chainInfo, minGas)
4034
+ );
4035
+ }
4036
+ }
4037
+ const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
4038
+ const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4039
+ return {
4040
+ minGas,
4041
+ minFee,
4042
+ maxGas,
4043
+ maxFee
4044
+ };
4045
+ }
3927
4046
  /**
3928
4047
  * Executes a signed transaction without applying the states changes
3929
4048
  * on the chain.
@@ -3971,17 +4090,16 @@ var _Provider = class {
3971
4090
  signatureCallback
3972
4091
  } = {}) {
3973
4092
  const txRequestClone = clone3(transactionRequestify(transactionRequestLike));
3974
- const chainInfo = this.getChain();
3975
- const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
3976
- const gasPrice = max(txRequestClone.gasPrice, minGasPrice);
4093
+ const { minGasPrice } = this.getGasConfig();
4094
+ const setGasPrice = max(txRequestClone.gasPrice, minGasPrice);
3977
4095
  const isScriptTransaction = txRequestClone.type === TransactionType8.Script;
3978
4096
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
3979
4097
  const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
3980
4098
  txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
4099
+ if (isScriptTransaction) {
4100
+ txRequestClone.gasLimit = bn15(0);
4101
+ }
3981
4102
  if (estimatePredicates) {
3982
- if (isScriptTransaction) {
3983
- txRequestClone.gasLimit = bn14(0);
3984
- }
3985
4103
  if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
3986
4104
  resourcesOwner.populateTransactionPredicateData(txRequestClone);
3987
4105
  }
@@ -3990,36 +4108,34 @@ var _Provider = class {
3990
4108
  if (signatureCallback && isScriptTransaction) {
3991
4109
  await signatureCallback(txRequestClone);
3992
4110
  }
3993
- const minGas = txRequestClone.calculateMinGas(chainInfo);
3994
- const maxGas = txRequestClone.calculateMaxGas(chainInfo, minGas);
4111
+ let { maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
4112
+ transactionRequest: txRequestClone
4113
+ });
3995
4114
  let receipts = [];
3996
4115
  let missingContractIds = [];
3997
4116
  let outputVariables = 0;
4117
+ let gasUsed = bn15(0);
3998
4118
  if (isScriptTransaction && estimateTxDependencies) {
3999
- txRequestClone.gasPrice = bn14(0);
4000
- txRequestClone.gasLimit = bn14(maxGasPerTx.sub(maxGas).toNumber() * 0.9);
4119
+ txRequestClone.gasPrice = bn15(0);
4001
4120
  const result = await this.estimateTxDependencies(txRequestClone);
4002
4121
  receipts = result.receipts;
4003
4122
  outputVariables = result.outputVariables;
4004
4123
  missingContractIds = result.missingContractIds;
4124
+ gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
4125
+ txRequestClone.gasLimit = gasUsed;
4126
+ txRequestClone.gasPrice = setGasPrice;
4127
+ ({ maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
4128
+ transactionRequest: txRequestClone
4129
+ }));
4005
4130
  }
4006
- const gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : minGas;
4007
- const usedFee = calculatePriceWithFactor(
4008
- gasUsed,
4009
- gasPrice,
4010
- gasPriceFactor
4011
- ).normalizeZeroToOne();
4012
- const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4013
- const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
4014
4131
  return {
4015
4132
  requiredQuantities: allQuantities,
4016
4133
  receipts,
4017
4134
  gasUsed,
4018
4135
  minGasPrice,
4019
- gasPrice,
4136
+ gasPrice: setGasPrice,
4020
4137
  minGas,
4021
4138
  maxGas,
4022
- usedFee,
4023
4139
  minFee,
4024
4140
  maxFee,
4025
4141
  estimatedInputs: txRequestClone.inputs,
@@ -4059,11 +4175,11 @@ var _Provider = class {
4059
4175
  return coins.map((coin) => ({
4060
4176
  id: coin.utxoId,
4061
4177
  assetId: coin.assetId,
4062
- amount: bn14(coin.amount),
4178
+ amount: bn15(coin.amount),
4063
4179
  owner: Address2.fromAddressOrString(coin.owner),
4064
- maturity: bn14(coin.maturity).toNumber(),
4065
- blockCreated: bn14(coin.blockCreated),
4066
- txCreatedIdx: bn14(coin.txCreatedIdx)
4180
+ maturity: bn15(coin.maturity).toNumber(),
4181
+ blockCreated: bn15(coin.blockCreated),
4182
+ txCreatedIdx: bn15(coin.txCreatedIdx)
4067
4183
  }));
4068
4184
  }
4069
4185
  /**
@@ -4100,9 +4216,9 @@ var _Provider = class {
4100
4216
  switch (coin.__typename) {
4101
4217
  case "MessageCoin":
4102
4218
  return {
4103
- amount: bn14(coin.amount),
4219
+ amount: bn15(coin.amount),
4104
4220
  assetId: coin.assetId,
4105
- daHeight: bn14(coin.daHeight),
4221
+ daHeight: bn15(coin.daHeight),
4106
4222
  sender: Address2.fromAddressOrString(coin.sender),
4107
4223
  recipient: Address2.fromAddressOrString(coin.recipient),
4108
4224
  nonce: coin.nonce
@@ -4110,12 +4226,12 @@ var _Provider = class {
4110
4226
  case "Coin":
4111
4227
  return {
4112
4228
  id: coin.utxoId,
4113
- amount: bn14(coin.amount),
4229
+ amount: bn15(coin.amount),
4114
4230
  assetId: coin.assetId,
4115
4231
  owner: Address2.fromAddressOrString(coin.owner),
4116
- maturity: bn14(coin.maturity).toNumber(),
4117
- blockCreated: bn14(coin.blockCreated),
4118
- txCreatedIdx: bn14(coin.txCreatedIdx)
4232
+ maturity: bn15(coin.maturity).toNumber(),
4233
+ blockCreated: bn15(coin.blockCreated),
4234
+ txCreatedIdx: bn15(coin.txCreatedIdx)
4119
4235
  };
4120
4236
  default:
4121
4237
  return null;
@@ -4132,13 +4248,13 @@ var _Provider = class {
4132
4248
  async getBlock(idOrHeight) {
4133
4249
  let variables;
4134
4250
  if (typeof idOrHeight === "number") {
4135
- variables = { height: bn14(idOrHeight).toString(10) };
4251
+ variables = { height: bn15(idOrHeight).toString(10) };
4136
4252
  } else if (idOrHeight === "latest") {
4137
4253
  variables = { height: (await this.getBlockNumber()).toString(10) };
4138
4254
  } else if (idOrHeight.length === 66) {
4139
4255
  variables = { blockId: idOrHeight };
4140
4256
  } else {
4141
- variables = { blockId: bn14(idOrHeight).toString(10) };
4257
+ variables = { blockId: bn15(idOrHeight).toString(10) };
4142
4258
  }
4143
4259
  const { block } = await this.operations.getBlock(variables);
4144
4260
  if (!block) {
@@ -4146,7 +4262,7 @@ var _Provider = class {
4146
4262
  }
4147
4263
  return {
4148
4264
  id: block.id,
4149
- height: bn14(block.header.height),
4265
+ height: bn15(block.header.height),
4150
4266
  time: block.header.time,
4151
4267
  transactionIds: block.transactions.map((tx) => tx.id)
4152
4268
  };
@@ -4161,7 +4277,7 @@ var _Provider = class {
4161
4277
  const { blocks: fetchedData } = await this.operations.getBlocks(params);
4162
4278
  const blocks = fetchedData.edges.map(({ node: block }) => ({
4163
4279
  id: block.id,
4164
- height: bn14(block.header.height),
4280
+ height: bn15(block.header.height),
4165
4281
  time: block.header.time,
4166
4282
  transactionIds: block.transactions.map((tx) => tx.id)
4167
4283
  }));
@@ -4176,7 +4292,7 @@ var _Provider = class {
4176
4292
  async getBlockWithTransactions(idOrHeight) {
4177
4293
  let variables;
4178
4294
  if (typeof idOrHeight === "number") {
4179
- variables = { blockHeight: bn14(idOrHeight).toString(10) };
4295
+ variables = { blockHeight: bn15(idOrHeight).toString(10) };
4180
4296
  } else if (idOrHeight === "latest") {
4181
4297
  variables = { blockHeight: (await this.getBlockNumber()).toString() };
4182
4298
  } else {
@@ -4188,7 +4304,7 @@ var _Provider = class {
4188
4304
  }
4189
4305
  return {
4190
4306
  id: block.id,
4191
- height: bn14(block.header.height, 10),
4307
+ height: bn15(block.header.height, 10),
4192
4308
  time: block.header.time,
4193
4309
  transactionIds: block.transactions.map((tx) => tx.id),
4194
4310
  transactions: block.transactions.map(
@@ -4237,7 +4353,7 @@ var _Provider = class {
4237
4353
  contract: Address2.fromAddressOrString(contractId).toB256(),
4238
4354
  asset: hexlify12(assetId)
4239
4355
  });
4240
- return bn14(contractBalance.amount, 10);
4356
+ return bn15(contractBalance.amount, 10);
4241
4357
  }
4242
4358
  /**
4243
4359
  * Returns the balance for the given owner for the given asset ID.
@@ -4251,7 +4367,7 @@ var _Provider = class {
4251
4367
  owner: Address2.fromAddressOrString(owner).toB256(),
4252
4368
  assetId: hexlify12(assetId)
4253
4369
  });
4254
- return bn14(balance.amount, 10);
4370
+ return bn15(balance.amount, 10);
4255
4371
  }
4256
4372
  /**
4257
4373
  * Returns balances for the given owner.
@@ -4269,7 +4385,7 @@ var _Provider = class {
4269
4385
  const balances = result.balances.edges.map((edge) => edge.node);
4270
4386
  return balances.map((balance) => ({
4271
4387
  assetId: balance.assetId,
4272
- amount: bn14(balance.amount)
4388
+ amount: bn15(balance.amount)
4273
4389
  }));
4274
4390
  }
4275
4391
  /**
@@ -4291,15 +4407,15 @@ var _Provider = class {
4291
4407
  sender: message.sender,
4292
4408
  recipient: message.recipient,
4293
4409
  nonce: message.nonce,
4294
- amount: bn14(message.amount),
4410
+ amount: bn15(message.amount),
4295
4411
  data: message.data
4296
4412
  }),
4297
4413
  sender: Address2.fromAddressOrString(message.sender),
4298
4414
  recipient: Address2.fromAddressOrString(message.recipient),
4299
4415
  nonce: message.nonce,
4300
- amount: bn14(message.amount),
4416
+ amount: bn15(message.amount),
4301
4417
  data: InputMessageCoder.decodeData(message.data),
4302
- daHeight: bn14(message.daHeight)
4418
+ daHeight: bn15(message.daHeight)
4303
4419
  }));
4304
4420
  }
4305
4421
  /**
@@ -4317,8 +4433,8 @@ var _Provider = class {
4317
4433
  nonce
4318
4434
  };
4319
4435
  if (commitBlockId && commitBlockHeight) {
4320
- throw new FuelError12(
4321
- ErrorCode12.INVALID_INPUT_PARAMETERS,
4436
+ throw new FuelError13(
4437
+ ErrorCode13.INVALID_INPUT_PARAMETERS,
4322
4438
  "commitBlockId and commitBlockHeight cannot be used together"
4323
4439
  );
4324
4440
  }
@@ -4352,41 +4468,41 @@ var _Provider = class {
4352
4468
  } = result.messageProof;
4353
4469
  return {
4354
4470
  messageProof: {
4355
- proofIndex: bn14(messageProof.proofIndex),
4471
+ proofIndex: bn15(messageProof.proofIndex),
4356
4472
  proofSet: messageProof.proofSet
4357
4473
  },
4358
4474
  blockProof: {
4359
- proofIndex: bn14(blockProof.proofIndex),
4475
+ proofIndex: bn15(blockProof.proofIndex),
4360
4476
  proofSet: blockProof.proofSet
4361
4477
  },
4362
4478
  messageBlockHeader: {
4363
4479
  id: messageBlockHeader.id,
4364
- daHeight: bn14(messageBlockHeader.daHeight),
4365
- transactionsCount: bn14(messageBlockHeader.transactionsCount),
4480
+ daHeight: bn15(messageBlockHeader.daHeight),
4481
+ transactionsCount: bn15(messageBlockHeader.transactionsCount),
4366
4482
  transactionsRoot: messageBlockHeader.transactionsRoot,
4367
- height: bn14(messageBlockHeader.height),
4483
+ height: bn15(messageBlockHeader.height),
4368
4484
  prevRoot: messageBlockHeader.prevRoot,
4369
4485
  time: messageBlockHeader.time,
4370
4486
  applicationHash: messageBlockHeader.applicationHash,
4371
4487
  messageReceiptRoot: messageBlockHeader.messageReceiptRoot,
4372
- messageReceiptCount: bn14(messageBlockHeader.messageReceiptCount)
4488
+ messageReceiptCount: bn15(messageBlockHeader.messageReceiptCount)
4373
4489
  },
4374
4490
  commitBlockHeader: {
4375
4491
  id: commitBlockHeader.id,
4376
- daHeight: bn14(commitBlockHeader.daHeight),
4377
- transactionsCount: bn14(commitBlockHeader.transactionsCount),
4492
+ daHeight: bn15(commitBlockHeader.daHeight),
4493
+ transactionsCount: bn15(commitBlockHeader.transactionsCount),
4378
4494
  transactionsRoot: commitBlockHeader.transactionsRoot,
4379
- height: bn14(commitBlockHeader.height),
4495
+ height: bn15(commitBlockHeader.height),
4380
4496
  prevRoot: commitBlockHeader.prevRoot,
4381
4497
  time: commitBlockHeader.time,
4382
4498
  applicationHash: commitBlockHeader.applicationHash,
4383
4499
  messageReceiptRoot: commitBlockHeader.messageReceiptRoot,
4384
- messageReceiptCount: bn14(commitBlockHeader.messageReceiptCount)
4500
+ messageReceiptCount: bn15(commitBlockHeader.messageReceiptCount)
4385
4501
  },
4386
4502
  sender: Address2.fromAddressOrString(sender),
4387
4503
  recipient: Address2.fromAddressOrString(recipient),
4388
4504
  nonce,
4389
- amount: bn14(amount),
4505
+ amount: bn15(amount),
4390
4506
  data
4391
4507
  };
4392
4508
  }
@@ -4409,10 +4525,10 @@ var _Provider = class {
4409
4525
  */
4410
4526
  async produceBlocks(amount, startTime) {
4411
4527
  const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
4412
- blocksToProduce: bn14(amount).toString(10),
4528
+ blocksToProduce: bn15(amount).toString(10),
4413
4529
  startTimestamp: startTime ? DateTime2.fromUnixMilliseconds(startTime).toTai64() : void 0
4414
4530
  });
4415
- return bn14(latestBlockHeight);
4531
+ return bn15(latestBlockHeight);
4416
4532
  }
4417
4533
  // eslint-disable-next-line @typescript-eslint/require-await
4418
4534
  async getTransactionResponse(transactionId) {
@@ -4435,8 +4551,8 @@ __publicField(Provider, "chainInfoCache", {});
4435
4551
  __publicField(Provider, "nodeInfoCache", {});
4436
4552
 
4437
4553
  // src/providers/transaction-summary/get-transaction-summary.ts
4438
- import { ErrorCode as ErrorCode13, FuelError as FuelError13 } from "@fuel-ts/errors";
4439
- import { bn as bn15 } from "@fuel-ts/math";
4554
+ import { ErrorCode as ErrorCode14, FuelError as FuelError14 } from "@fuel-ts/errors";
4555
+ import { bn as bn16 } from "@fuel-ts/math";
4440
4556
  import { TransactionCoder as TransactionCoder6 } from "@fuel-ts/transactions";
4441
4557
  import { arrayify as arrayify12 } from "@fuel-ts/utils";
4442
4558
  async function getTransactionSummary(params) {
@@ -4445,8 +4561,8 @@ async function getTransactionSummary(params) {
4445
4561
  transactionId: id
4446
4562
  });
4447
4563
  if (!gqlTransaction) {
4448
- throw new FuelError13(
4449
- ErrorCode13.TRANSACTION_NOT_FOUND,
4564
+ throw new FuelError14(
4565
+ ErrorCode14.TRANSACTION_NOT_FOUND,
4450
4566
  `Transaction not found for given id: ${id}.`
4451
4567
  );
4452
4568
  }
@@ -4464,8 +4580,8 @@ async function getTransactionSummary(params) {
4464
4580
  transaction: decodedTransaction,
4465
4581
  transactionBytes: arrayify12(gqlTransaction.rawPayload),
4466
4582
  gqlTransactionStatus: gqlTransaction.status,
4467
- gasPerByte: bn15(gasPerByte),
4468
- gasPriceFactor: bn15(gasPriceFactor),
4583
+ gasPerByte: bn16(gasPerByte),
4584
+ gasPriceFactor: bn16(gasPriceFactor),
4469
4585
  abiMap,
4470
4586
  maxInputs,
4471
4587
  gasCosts
@@ -4719,7 +4835,7 @@ var Account = class extends AbstractAccount {
4719
4835
  */
4720
4836
  get provider() {
4721
4837
  if (!this._provider) {
4722
- throw new FuelError14(ErrorCode14.MISSING_PROVIDER, "Provider not set");
4838
+ throw new FuelError15(ErrorCode15.MISSING_PROVIDER, "Provider not set");
4723
4839
  }
4724
4840
  return this._provider;
4725
4841
  }
@@ -4771,8 +4887,8 @@ var Account = class extends AbstractAccount {
4771
4887
  if (!hasNextPage) {
4772
4888
  break;
4773
4889
  }
4774
- throw new FuelError14(
4775
- ErrorCode14.NOT_SUPPORTED,
4890
+ throw new FuelError15(
4891
+ ErrorCode15.NOT_SUPPORTED,
4776
4892
  `Wallets containing more than ${pageSize} coins exceed the current supported limit.`
4777
4893
  );
4778
4894
  }
@@ -4797,8 +4913,8 @@ var Account = class extends AbstractAccount {
4797
4913
  if (!hasNextPage) {
4798
4914
  break;
4799
4915
  }
4800
- throw new FuelError14(
4801
- ErrorCode14.NOT_SUPPORTED,
4916
+ throw new FuelError15(
4917
+ ErrorCode15.NOT_SUPPORTED,
4802
4918
  `Wallets containing more than ${pageSize} messages exceed the current supported limit.`
4803
4919
  );
4804
4920
  }
@@ -4833,8 +4949,8 @@ var Account = class extends AbstractAccount {
4833
4949
  if (!hasNextPage) {
4834
4950
  break;
4835
4951
  }
4836
- throw new FuelError14(
4837
- ErrorCode14.NOT_SUPPORTED,
4952
+ throw new FuelError15(
4953
+ ErrorCode15.NOT_SUPPORTED,
4838
4954
  `Wallets containing more than ${pageSize} balances exceed the current supported limit.`
4839
4955
  );
4840
4956
  }
@@ -4850,7 +4966,7 @@ var Account = class extends AbstractAccount {
4850
4966
  */
4851
4967
  async fund(request, coinQuantities, fee) {
4852
4968
  const updatedQuantities = addAmountToAsset({
4853
- amount: bn16(fee),
4969
+ amount: bn17(fee),
4854
4970
  assetId: BaseAssetId3,
4855
4971
  coinQuantities
4856
4972
  });
@@ -4858,7 +4974,7 @@ var Account = class extends AbstractAccount {
4858
4974
  updatedQuantities.forEach(({ amount, assetId }) => {
4859
4975
  quantitiesDict[assetId] = {
4860
4976
  required: amount,
4861
- owned: bn16(0)
4977
+ owned: bn17(0)
4862
4978
  };
4863
4979
  });
4864
4980
  const cachedUtxos = [];
@@ -4871,7 +4987,7 @@ var Account = class extends AbstractAccount {
4871
4987
  if (isCoin2) {
4872
4988
  const assetId = String(input.assetId);
4873
4989
  if (input.owner === owner && quantitiesDict[assetId]) {
4874
- const amount = bn16(input.amount);
4990
+ const amount = bn17(input.amount);
4875
4991
  quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
4876
4992
  cachedUtxos.push(input.id);
4877
4993
  }
@@ -4917,8 +5033,8 @@ var Account = class extends AbstractAccount {
4917
5033
  estimateTxDependencies: true,
4918
5034
  resourcesOwner: this
4919
5035
  });
4920
- request.gasPrice = bn16(txParams.gasPrice ?? minGasPrice);
4921
- request.gasLimit = bn16(txParams.gasLimit ?? gasUsed);
5036
+ request.gasPrice = bn17(txParams.gasPrice ?? minGasPrice);
5037
+ request.gasLimit = bn17(txParams.gasLimit ?? gasUsed);
4922
5038
  this.validateGas({
4923
5039
  gasUsed,
4924
5040
  gasPrice: request.gasPrice,
@@ -4939,9 +5055,9 @@ var Account = class extends AbstractAccount {
4939
5055
  * @returns A promise that resolves to the transaction response.
4940
5056
  */
4941
5057
  async transfer(destination, amount, assetId = BaseAssetId3, txParams = {}) {
4942
- if (bn16(amount).lte(0)) {
4943
- throw new FuelError14(
4944
- ErrorCode14.INVALID_TRANSFER_AMOUNT,
5058
+ if (bn17(amount).lte(0)) {
5059
+ throw new FuelError15(
5060
+ ErrorCode15.INVALID_TRANSFER_AMOUNT,
4945
5061
  "Transfer amount must be a positive number."
4946
5062
  );
4947
5063
  }
@@ -4958,9 +5074,9 @@ var Account = class extends AbstractAccount {
4958
5074
  * @returns A promise that resolves to the transaction response.
4959
5075
  */
4960
5076
  async transferToContract(contractId, amount, assetId = BaseAssetId3, txParams = {}) {
4961
- if (bn16(amount).lte(0)) {
4962
- throw new FuelError14(
4963
- ErrorCode14.INVALID_TRANSFER_AMOUNT,
5077
+ if (bn17(amount).lte(0)) {
5078
+ throw new FuelError15(
5079
+ ErrorCode15.INVALID_TRANSFER_AMOUNT,
4964
5080
  "Transfer amount must be a positive number."
4965
5081
  );
4966
5082
  }
@@ -4969,7 +5085,7 @@ var Account = class extends AbstractAccount {
4969
5085
  const params = { gasPrice: minGasPrice, ...txParams };
4970
5086
  const { script, scriptData } = await assembleTransferToContractScript({
4971
5087
  hexlifiedContractId: contractAddress.toB256(),
4972
- amountToTransfer: bn16(amount),
5088
+ amountToTransfer: bn17(amount),
4973
5089
  assetId
4974
5090
  });
4975
5091
  const request = new ScriptTransactionRequest({
@@ -4980,9 +5096,9 @@ var Account = class extends AbstractAccount {
4980
5096
  request.addContractInputAndOutput(contractAddress);
4981
5097
  const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
4982
5098
  request,
4983
- [{ amount: bn16(amount), assetId: String(assetId) }]
5099
+ [{ amount: bn17(amount), assetId: String(assetId) }]
4984
5100
  );
4985
- request.gasLimit = bn16(params.gasLimit ?? gasUsed);
5101
+ request.gasLimit = bn17(params.gasLimit ?? gasUsed);
4986
5102
  this.validateGas({
4987
5103
  gasUsed,
4988
5104
  gasPrice: request.gasPrice,
@@ -5007,7 +5123,7 @@ var Account = class extends AbstractAccount {
5007
5123
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
5008
5124
  );
5009
5125
  const amountDataArray = arrayify14(
5010
- "0x".concat(bn16(amount).toHex().substring(2).padStart(16, "0"))
5126
+ "0x".concat(bn17(amount).toHex().substring(2).padStart(16, "0"))
5011
5127
  );
5012
5128
  const script = new Uint8Array([
5013
5129
  ...arrayify14(withdrawScript.bytes),
@@ -5016,12 +5132,12 @@ var Account = class extends AbstractAccount {
5016
5132
  ]);
5017
5133
  const params = { script, gasPrice: minGasPrice, ...txParams };
5018
5134
  const request = new ScriptTransactionRequest(params);
5019
- const forwardingQuantities = [{ amount: bn16(amount), assetId: BaseAssetId3 }];
5135
+ const forwardingQuantities = [{ amount: bn17(amount), assetId: BaseAssetId3 }];
5020
5136
  const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
5021
5137
  request,
5022
5138
  forwardingQuantities
5023
5139
  );
5024
- request.gasLimit = bn16(params.gasLimit ?? gasUsed);
5140
+ request.gasLimit = bn17(params.gasLimit ?? gasUsed);
5025
5141
  this.validateGas({
5026
5142
  gasUsed,
5027
5143
  gasPrice: request.gasPrice,
@@ -5033,7 +5149,7 @@ var Account = class extends AbstractAccount {
5033
5149
  }
5034
5150
  async signMessage(message) {
5035
5151
  if (!this._connector) {
5036
- throw new FuelError14(ErrorCode14.MISSING_CONNECTOR, "A connector is required to sign messages.");
5152
+ throw new FuelError15(ErrorCode15.MISSING_CONNECTOR, "A connector is required to sign messages.");
5037
5153
  }
5038
5154
  return this._connector.signMessage(this.address.toString(), message);
5039
5155
  }
@@ -5045,8 +5161,8 @@ var Account = class extends AbstractAccount {
5045
5161
  */
5046
5162
  async signTransaction(transactionRequestLike) {
5047
5163
  if (!this._connector) {
5048
- throw new FuelError14(
5049
- ErrorCode14.MISSING_CONNECTOR,
5164
+ throw new FuelError15(
5165
+ ErrorCode15.MISSING_CONNECTOR,
5050
5166
  "A connector is required to sign transactions."
5051
5167
  );
5052
5168
  }
@@ -5093,14 +5209,14 @@ var Account = class extends AbstractAccount {
5093
5209
  minGasPrice
5094
5210
  }) {
5095
5211
  if (minGasPrice.gt(gasPrice)) {
5096
- throw new FuelError14(
5097
- ErrorCode14.GAS_PRICE_TOO_LOW,
5212
+ throw new FuelError15(
5213
+ ErrorCode15.GAS_PRICE_TOO_LOW,
5098
5214
  `Gas price '${gasPrice}' is lower than the required: '${minGasPrice}'.`
5099
5215
  );
5100
5216
  }
5101
5217
  if (gasUsed.gt(gasLimit)) {
5102
- throw new FuelError14(
5103
- ErrorCode14.GAS_LIMIT_TOO_LOW,
5218
+ throw new FuelError15(
5219
+ ErrorCode15.GAS_LIMIT_TOO_LOW,
5104
5220
  `Gas limit '${gasLimit}' is lower than the required: '${gasUsed}'.`
5105
5221
  );
5106
5222
  }
@@ -5113,7 +5229,7 @@ import { hexlify as hexlify15 } from "@fuel-ts/utils";
5113
5229
 
5114
5230
  // src/signer/signer.ts
5115
5231
  import { Address as Address4 } from "@fuel-ts/address";
5116
- import { randomBytes } from "@fuel-ts/crypto";
5232
+ import { randomBytes as randomBytes2 } from "@fuel-ts/crypto";
5117
5233
  import { hash } from "@fuel-ts/hasher";
5118
5234
  import { toBytes } from "@fuel-ts/math";
5119
5235
  import { hexlify as hexlify13, concat as concat3, arrayify as arrayify15 } from "@fuel-ts/utils";
@@ -5206,7 +5322,7 @@ var Signer = class {
5206
5322
  * @returns random 32-byte hashed
5207
5323
  */
5208
5324
  static generatePrivateKey(entropy) {
5209
- return entropy ? hash(concat3([randomBytes(32), arrayify15(entropy)])) : randomBytes(32);
5325
+ return entropy ? hash(concat3([randomBytes2(32), arrayify15(entropy)])) : randomBytes2(32);
5210
5326
  }
5211
5327
  /**
5212
5328
  * Extended publicKey from a compact publicKey
@@ -5225,13 +5341,13 @@ import { Address as Address5 } from "@fuel-ts/address";
5225
5341
  import {
5226
5342
  bufferFromString,
5227
5343
  keccak256,
5228
- randomBytes as randomBytes2,
5344
+ randomBytes as randomBytes3,
5229
5345
  scrypt,
5230
5346
  stringFromBuffer,
5231
5347
  decryptJsonWalletData,
5232
5348
  encryptJsonWalletData
5233
5349
  } from "@fuel-ts/crypto";
5234
- import { ErrorCode as ErrorCode15, FuelError as FuelError15 } from "@fuel-ts/errors";
5350
+ import { ErrorCode as ErrorCode16, FuelError as FuelError16 } from "@fuel-ts/errors";
5235
5351
  import { hexlify as hexlify14 } from "@fuel-ts/utils";
5236
5352
  import { v4 as uuidv4 } from "uuid";
5237
5353
  var DEFAULT_KDF_PARAMS_LOG_N = 13;
@@ -5248,7 +5364,7 @@ var removeHexPrefix = (hexString) => {
5248
5364
  async function encryptKeystoreWallet(privateKey, address, password) {
5249
5365
  const privateKeyBuffer = bufferFromString(removeHexPrefix(privateKey), "hex");
5250
5366
  const ownerAddress = Address5.fromAddressOrString(address);
5251
- const salt = randomBytes2(DEFAULT_KEY_SIZE);
5367
+ const salt = randomBytes3(DEFAULT_KEY_SIZE);
5252
5368
  const key = scrypt({
5253
5369
  password: bufferFromString(password),
5254
5370
  salt,
@@ -5257,7 +5373,7 @@ async function encryptKeystoreWallet(privateKey, address, password) {
5257
5373
  r: DEFAULT_KDF_PARAMS_R,
5258
5374
  p: DEFAULT_KDF_PARAMS_P
5259
5375
  });
5260
- const iv = randomBytes2(DEFAULT_IV_SIZE);
5376
+ const iv = randomBytes3(DEFAULT_IV_SIZE);
5261
5377
  const ciphertext = await encryptJsonWalletData(privateKeyBuffer, key, iv);
5262
5378
  const data = Uint8Array.from([...key.subarray(16, 32), ...ciphertext]);
5263
5379
  const macHashUint8Array = keccak256(data);
@@ -5309,8 +5425,8 @@ async function decryptKeystoreWallet(jsonWallet, password) {
5309
5425
  const macHashUint8Array = keccak256(data);
5310
5426
  const macHash = stringFromBuffer(macHashUint8Array, "hex");
5311
5427
  if (mac !== macHash) {
5312
- throw new FuelError15(
5313
- ErrorCode15.INVALID_PASSWORD,
5428
+ throw new FuelError16(
5429
+ ErrorCode16.INVALID_PASSWORD,
5314
5430
  "Failed to decrypt the keystore wallet, the provided password is incorrect."
5315
5431
  );
5316
5432
  }
@@ -5432,15 +5548,15 @@ var BaseWalletUnlocked = class extends Account {
5432
5548
  __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
5433
5549
 
5434
5550
  // src/hdwallet/hdwallet.ts
5435
- import { ErrorCode as ErrorCode18, FuelError as FuelError18 } from "@fuel-ts/errors";
5551
+ import { ErrorCode as ErrorCode19, FuelError as FuelError19 } from "@fuel-ts/errors";
5436
5552
  import { sha256 as sha2564 } from "@fuel-ts/hasher";
5437
- import { bn as bn17, toBytes as toBytes2, toHex } from "@fuel-ts/math";
5553
+ import { bn as bn18, toBytes as toBytes2, toHex } from "@fuel-ts/math";
5438
5554
  import { arrayify as arrayify18, hexlify as hexlify17, concat as concat5 } from "@fuel-ts/utils";
5439
5555
  import { toBeHex, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58, computeHmac as computeHmac2, ripemd160 } from "ethers";
5440
5556
 
5441
5557
  // src/mnemonic/mnemonic.ts
5442
- import { randomBytes as randomBytes3 } from "@fuel-ts/crypto";
5443
- import { ErrorCode as ErrorCode17, FuelError as FuelError17 } from "@fuel-ts/errors";
5558
+ import { randomBytes as randomBytes4 } from "@fuel-ts/crypto";
5559
+ import { ErrorCode as ErrorCode18, FuelError as FuelError18 } from "@fuel-ts/errors";
5444
5560
  import { sha256 as sha2563 } from "@fuel-ts/hasher";
5445
5561
  import { arrayify as arrayify17, hexlify as hexlify16, concat as concat4 } from "@fuel-ts/utils";
5446
5562
  import { dataSlice, pbkdf2, computeHmac, encodeBase58 } from "ethers";
@@ -7504,7 +7620,7 @@ var Language = /* @__PURE__ */ ((Language2) => {
7504
7620
  })(Language || {});
7505
7621
 
7506
7622
  // src/mnemonic/utils.ts
7507
- import { ErrorCode as ErrorCode16, FuelError as FuelError16 } from "@fuel-ts/errors";
7623
+ import { ErrorCode as ErrorCode17, FuelError as FuelError17 } from "@fuel-ts/errors";
7508
7624
  import { sha256 as sha2562 } from "@fuel-ts/hasher";
7509
7625
  import { arrayify as arrayify16 } from "@fuel-ts/utils";
7510
7626
  function toUtf8Bytes(stri) {
@@ -7521,8 +7637,8 @@ function toUtf8Bytes(stri) {
7521
7637
  i += 1;
7522
7638
  const c2 = str.charCodeAt(i);
7523
7639
  if (i >= str.length || (c2 & 64512) !== 56320) {
7524
- throw new FuelError16(
7525
- ErrorCode16.INVALID_INPUT_PARAMETERS,
7640
+ throw new FuelError17(
7641
+ ErrorCode17.INVALID_INPUT_PARAMETERS,
7526
7642
  "Invalid UTF-8 in the input string."
7527
7643
  );
7528
7644
  }
@@ -7585,8 +7701,8 @@ function mnemonicWordsToEntropy(words, wordlist) {
7585
7701
  for (let i = 0; i < words.length; i += 1) {
7586
7702
  const index = wordlist.indexOf(words[i].normalize("NFKD"));
7587
7703
  if (index === -1) {
7588
- throw new FuelError16(
7589
- ErrorCode16.INVALID_MNEMONIC,
7704
+ throw new FuelError17(
7705
+ ErrorCode17.INVALID_MNEMONIC,
7590
7706
  `Invalid mnemonic: the word '${words[i]}' is not found in the provided wordlist.`
7591
7707
  );
7592
7708
  }
@@ -7602,8 +7718,8 @@ function mnemonicWordsToEntropy(words, wordlist) {
7602
7718
  const checksumMask = getUpperMask(checksumBits);
7603
7719
  const checksum = arrayify16(sha2562(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
7604
7720
  if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
7605
- throw new FuelError16(
7606
- ErrorCode16.INVALID_CHECKSUM,
7721
+ throw new FuelError17(
7722
+ ErrorCode17.INVALID_CHECKSUM,
7607
7723
  "Checksum validation failed for the provided mnemonic."
7608
7724
  );
7609
7725
  }
@@ -7617,16 +7733,16 @@ var TestnetPRV = "0x04358394";
7617
7733
  var MNEMONIC_SIZES = [12, 15, 18, 21, 24];
7618
7734
  function assertWordList(wordlist) {
7619
7735
  if (wordlist.length !== 2048) {
7620
- throw new FuelError17(
7621
- ErrorCode17.INVALID_WORD_LIST,
7736
+ throw new FuelError18(
7737
+ ErrorCode18.INVALID_WORD_LIST,
7622
7738
  `Expected word list length of 2048, but got ${wordlist.length}.`
7623
7739
  );
7624
7740
  }
7625
7741
  }
7626
7742
  function assertEntropy(entropy) {
7627
7743
  if (entropy.length % 4 !== 0 || entropy.length < 16 || entropy.length > 32) {
7628
- throw new FuelError17(
7629
- ErrorCode17.INVALID_ENTROPY,
7744
+ throw new FuelError18(
7745
+ ErrorCode18.INVALID_ENTROPY,
7630
7746
  `Entropy should be between 16 and 32 bytes and a multiple of 4, but got ${entropy.length} bytes.`
7631
7747
  );
7632
7748
  }
@@ -7636,7 +7752,7 @@ function assertMnemonic(words) {
7636
7752
  const errorMsg = `Invalid mnemonic size. Expected one of [${MNEMONIC_SIZES.join(
7637
7753
  ", "
7638
7754
  )}] words, but got ${words.length}.`;
7639
- throw new FuelError17(ErrorCode17.INVALID_MNEMONIC, errorMsg);
7755
+ throw new FuelError18(ErrorCode18.INVALID_MNEMONIC, errorMsg);
7640
7756
  }
7641
7757
  }
7642
7758
  var Mnemonic = class {
@@ -7754,8 +7870,8 @@ var Mnemonic = class {
7754
7870
  static masterKeysFromSeed(seed) {
7755
7871
  const seedArray = arrayify17(seed);
7756
7872
  if (seedArray.length < 16 || seedArray.length > 64) {
7757
- throw new FuelError17(
7758
- ErrorCode17.INVALID_SEED,
7873
+ throw new FuelError18(
7874
+ ErrorCode18.INVALID_SEED,
7759
7875
  `Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
7760
7876
  );
7761
7877
  }
@@ -7800,7 +7916,7 @@ var Mnemonic = class {
7800
7916
  * @returns A randomly generated mnemonic
7801
7917
  */
7802
7918
  static generate(size = 32, extraEntropy = "") {
7803
- const entropy = extraEntropy ? sha2563(concat4([randomBytes3(size), arrayify17(extraEntropy)])) : randomBytes3(size);
7919
+ const entropy = extraEntropy ? sha2563(concat4([randomBytes4(size), arrayify17(extraEntropy)])) : randomBytes4(size);
7804
7920
  return Mnemonic.entropyToMnemonic(entropy);
7805
7921
  }
7806
7922
  };
@@ -7832,7 +7948,7 @@ function isValidExtendedKey(extendedKey) {
7832
7948
  function parsePath(path, depth = 0) {
7833
7949
  const components = path.split("/");
7834
7950
  if (components.length === 0 || components[0] === "m" && depth !== 0) {
7835
- throw new FuelError18(ErrorCode18.HD_WALLET_ERROR, `invalid path - ${path}`);
7951
+ throw new FuelError19(ErrorCode19.HD_WALLET_ERROR, `invalid path - ${path}`);
7836
7952
  }
7837
7953
  if (components[0] === "m") {
7838
7954
  components.shift();
@@ -7861,8 +7977,8 @@ var HDWallet = class {
7861
7977
  this.privateKey = hexlify17(config.privateKey);
7862
7978
  } else {
7863
7979
  if (!config.publicKey) {
7864
- throw new FuelError18(
7865
- ErrorCode18.HD_WALLET_ERROR,
7980
+ throw new FuelError19(
7981
+ ErrorCode19.HD_WALLET_ERROR,
7866
7982
  "Both public and private Key cannot be missing. At least one should be provided."
7867
7983
  );
7868
7984
  }
@@ -7891,8 +8007,8 @@ var HDWallet = class {
7891
8007
  const data = new Uint8Array(37);
7892
8008
  if (index & HARDENED_INDEX) {
7893
8009
  if (!privateKey) {
7894
- throw new FuelError18(
7895
- ErrorCode18.HD_WALLET_ERROR,
8010
+ throw new FuelError19(
8011
+ ErrorCode19.HD_WALLET_ERROR,
7896
8012
  "Cannot derive a hardened index without a private Key."
7897
8013
  );
7898
8014
  }
@@ -7906,7 +8022,7 @@ var HDWallet = class {
7906
8022
  const IR = bytes.slice(32);
7907
8023
  if (privateKey) {
7908
8024
  const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
7909
- const ki = bn17(IL).add(privateKey).mod(N).toBytes(32);
8025
+ const ki = bn18(IL).add(privateKey).mod(N).toBytes(32);
7910
8026
  return new HDWallet({
7911
8027
  privateKey: ki,
7912
8028
  chainCode: IR,
@@ -7944,8 +8060,8 @@ var HDWallet = class {
7944
8060
  */
7945
8061
  toExtendedKey(isPublic = false, testnet = false) {
7946
8062
  if (this.depth >= 256) {
7947
- throw new FuelError18(
7948
- ErrorCode18.HD_WALLET_ERROR,
8063
+ throw new FuelError19(
8064
+ ErrorCode19.HD_WALLET_ERROR,
7949
8065
  `Exceeded max depth of 255. Current depth: ${this.depth}.`
7950
8066
  );
7951
8067
  }
@@ -7976,10 +8092,10 @@ var HDWallet = class {
7976
8092
  const bytes = arrayify18(decoded);
7977
8093
  const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
7978
8094
  if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
7979
- throw new FuelError18(ErrorCode18.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
8095
+ throw new FuelError19(ErrorCode19.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
7980
8096
  }
7981
8097
  if (!validChecksum) {
7982
- throw new FuelError18(ErrorCode18.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
8098
+ throw new FuelError19(ErrorCode19.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
7983
8099
  }
7984
8100
  const depth = bytes[4];
7985
8101
  const parentFingerprint = hexlify17(bytes.slice(5, 9));
@@ -7987,14 +8103,14 @@ var HDWallet = class {
7987
8103
  const chainCode = hexlify17(bytes.slice(13, 45));
7988
8104
  const key = bytes.slice(45, 78);
7989
8105
  if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
7990
- throw new FuelError18(
7991
- ErrorCode18.HD_WALLET_ERROR,
8106
+ throw new FuelError19(
8107
+ ErrorCode19.HD_WALLET_ERROR,
7992
8108
  "Inconsistency detected: Depth is zero but fingerprint/index is non-zero."
7993
8109
  );
7994
8110
  }
7995
8111
  if (isPublicExtendedKey(bytes)) {
7996
8112
  if (key[0] !== 3) {
7997
- throw new FuelError18(ErrorCode18.HD_WALLET_ERROR, "Invalid public extended key.");
8113
+ throw new FuelError19(ErrorCode19.HD_WALLET_ERROR, "Invalid public extended key.");
7998
8114
  }
7999
8115
  return new HDWallet({
8000
8116
  publicKey: key,
@@ -8005,7 +8121,7 @@ var HDWallet = class {
8005
8121
  });
8006
8122
  }
8007
8123
  if (key[0] !== 0) {
8008
- throw new FuelError18(ErrorCode18.HD_WALLET_ERROR, "Invalid private extended key.");
8124
+ throw new FuelError19(ErrorCode19.HD_WALLET_ERROR, "Invalid private extended key.");
8009
8125
  }
8010
8126
  return new HDWallet({
8011
8127
  privateKey: key.slice(1),
@@ -8173,7 +8289,7 @@ __publicField(Wallet, "fromEncryptedJson", WalletUnlocked.fromEncryptedJson);
8173
8289
  // src/wallet-manager/wallet-manager.ts
8174
8290
  import { Address as Address8 } from "@fuel-ts/address";
8175
8291
  import { encrypt, decrypt } from "@fuel-ts/crypto";
8176
- import { ErrorCode as ErrorCode21, FuelError as FuelError21 } from "@fuel-ts/errors";
8292
+ import { ErrorCode as ErrorCode22, FuelError as FuelError22 } from "@fuel-ts/errors";
8177
8293
  import { EventEmitter } from "events";
8178
8294
 
8179
8295
  // src/wallet-manager/storages/memory-storage.ts
@@ -8196,7 +8312,7 @@ var MemoryStorage = class {
8196
8312
 
8197
8313
  // src/wallet-manager/vaults/mnemonic-vault.ts
8198
8314
  import { Address as Address6 } from "@fuel-ts/address";
8199
- import { ErrorCode as ErrorCode19, FuelError as FuelError19 } from "@fuel-ts/errors";
8315
+ import { ErrorCode as ErrorCode20, FuelError as FuelError20 } from "@fuel-ts/errors";
8200
8316
  var _secret;
8201
8317
  var MnemonicVault = class {
8202
8318
  constructor(options) {
@@ -8252,8 +8368,8 @@ var MnemonicVault = class {
8252
8368
  }
8253
8369
  numberOfAccounts += 1;
8254
8370
  } while (numberOfAccounts < this.numberOfAccounts);
8255
- throw new FuelError19(
8256
- ErrorCode19.WALLET_MANAGER_ERROR,
8371
+ throw new FuelError20(
8372
+ ErrorCode20.WALLET_MANAGER_ERROR,
8257
8373
  `Account with address '${address}' not found in derived wallets.`
8258
8374
  );
8259
8375
  }
@@ -8267,7 +8383,7 @@ __publicField(MnemonicVault, "type", "mnemonic");
8267
8383
 
8268
8384
  // src/wallet-manager/vaults/privatekey-vault.ts
8269
8385
  import { Address as Address7 } from "@fuel-ts/address";
8270
- import { ErrorCode as ErrorCode20, FuelError as FuelError20 } from "@fuel-ts/errors";
8386
+ import { ErrorCode as ErrorCode21, FuelError as FuelError21 } from "@fuel-ts/errors";
8271
8387
  var _privateKeys;
8272
8388
  var PrivateKeyVault = class {
8273
8389
  /**
@@ -8308,8 +8424,8 @@ var PrivateKeyVault = class {
8308
8424
  (pk) => Wallet.fromPrivateKey(pk).address.equals(ownerAddress)
8309
8425
  );
8310
8426
  if (!privateKey) {
8311
- throw new FuelError20(
8312
- ErrorCode20.WALLET_MANAGER_ERROR,
8427
+ throw new FuelError21(
8428
+ ErrorCode21.WALLET_MANAGER_ERROR,
8313
8429
  `No private key found for address '${address}'.`
8314
8430
  );
8315
8431
  }
@@ -8333,7 +8449,7 @@ var ERROR_MESSAGES = {
8333
8449
  };
8334
8450
  function assert(condition, message) {
8335
8451
  if (!condition) {
8336
- throw new FuelError21(ErrorCode21.WALLET_MANAGER_ERROR, message);
8452
+ throw new FuelError22(ErrorCode22.WALLET_MANAGER_ERROR, message);
8337
8453
  }
8338
8454
  }
8339
8455
  var _vaults, _passphrase, _isLocked, _serializeVaults, serializeVaults_fn, _deserializeVaults, deserializeVaults_fn;
@@ -8559,25 +8675,25 @@ deserializeVaults_fn = function(vaults) {
8559
8675
  __publicField(WalletManager, "Vaults", [MnemonicVault, PrivateKeyVault]);
8560
8676
 
8561
8677
  // src/wallet-manager/types.ts
8562
- import { ErrorCode as ErrorCode22, FuelError as FuelError22 } from "@fuel-ts/errors";
8678
+ import { ErrorCode as ErrorCode23, FuelError as FuelError23 } from "@fuel-ts/errors";
8563
8679
  var Vault = class {
8564
8680
  constructor(_options) {
8565
- throw new FuelError22(ErrorCode22.NOT_IMPLEMENTED, "Not implemented.");
8681
+ throw new FuelError23(ErrorCode23.NOT_IMPLEMENTED, "Not implemented.");
8566
8682
  }
8567
8683
  serialize() {
8568
- throw new FuelError22(ErrorCode22.NOT_IMPLEMENTED, "Not implemented.");
8684
+ throw new FuelError23(ErrorCode23.NOT_IMPLEMENTED, "Not implemented.");
8569
8685
  }
8570
8686
  getAccounts() {
8571
- throw new FuelError22(ErrorCode22.NOT_IMPLEMENTED, "Not implemented.");
8687
+ throw new FuelError23(ErrorCode23.NOT_IMPLEMENTED, "Not implemented.");
8572
8688
  }
8573
8689
  addAccount() {
8574
- throw new FuelError22(ErrorCode22.NOT_IMPLEMENTED, "Not implemented.");
8690
+ throw new FuelError23(ErrorCode23.NOT_IMPLEMENTED, "Not implemented.");
8575
8691
  }
8576
8692
  exportAccount(_address) {
8577
- throw new FuelError22(ErrorCode22.NOT_IMPLEMENTED, "Not implemented.");
8693
+ throw new FuelError23(ErrorCode23.NOT_IMPLEMENTED, "Not implemented.");
8578
8694
  }
8579
8695
  getWallet(_address) {
8580
- throw new FuelError22(ErrorCode22.NOT_IMPLEMENTED, "Not implemented.");
8696
+ throw new FuelError23(ErrorCode23.NOT_IMPLEMENTED, "Not implemented.");
8581
8697
  }
8582
8698
  };
8583
8699
  __publicField(Vault, "type");
@@ -8594,7 +8710,7 @@ import {
8594
8710
  } from "@fuel-ts/abi-coder";
8595
8711
  import { Address as Address9 } from "@fuel-ts/address";
8596
8712
  import { BaseAssetId as BaseAssetId4 } from "@fuel-ts/address/configs";
8597
- import { ErrorCode as ErrorCode23, FuelError as FuelError23 } from "@fuel-ts/errors";
8713
+ import { ErrorCode as ErrorCode24, FuelError as FuelError24 } from "@fuel-ts/errors";
8598
8714
  import { ByteArrayCoder, InputType as InputType7 } from "@fuel-ts/transactions";
8599
8715
  import { arrayify as arrayify20, hexlify as hexlify19 } from "@fuel-ts/utils";
8600
8716
 
@@ -8614,7 +8730,6 @@ var getPredicateRoot = (bytecode) => {
8614
8730
  // src/predicate/predicate.ts
8615
8731
  var Predicate = class extends Account {
8616
8732
  bytes;
8617
- predicateDataBytes = Uint8Array.from([]);
8618
8733
  predicateData = [];
8619
8734
  interface;
8620
8735
  /**
@@ -8722,8 +8837,8 @@ var Predicate = class extends Account {
8722
8837
  if (jsonAbi) {
8723
8838
  abiInterface = new Interface4(jsonAbi);
8724
8839
  if (abiInterface.functions.main === void 0) {
8725
- throw new FuelError23(
8726
- ErrorCode23.ABI_MAIN_METHOD_MISSING,
8840
+ throw new FuelError24(
8841
+ ErrorCode24.ABI_MAIN_METHOD_MISSING,
8727
8842
  'Cannot use ABI without "main" function.'
8728
8843
  );
8729
8844
  }
@@ -8768,8 +8883,8 @@ var Predicate = class extends Account {
8768
8883
  mutatedBytes.set(encoded, offset);
8769
8884
  });
8770
8885
  } catch (err) {
8771
- throw new FuelError23(
8772
- ErrorCode23.INVALID_CONFIGURABLE_CONSTANTS,
8886
+ throw new FuelError24(
8887
+ ErrorCode24.INVALID_CONFIGURABLE_CONSTANTS,
8773
8888
  `Error setting configurable constants: ${err.message}.`
8774
8889
  );
8775
8890
  }
@@ -8778,7 +8893,7 @@ var Predicate = class extends Account {
8778
8893
  };
8779
8894
 
8780
8895
  // src/connectors/fuel.ts
8781
- import { ErrorCode as ErrorCode24, FuelError as FuelError24 } from "@fuel-ts/errors";
8896
+ import { ErrorCode as ErrorCode25, FuelError as FuelError25 } from "@fuel-ts/errors";
8782
8897
 
8783
8898
  // src/connectors/fuel-connector.ts
8784
8899
  import { EventEmitter as EventEmitter2 } from "events";
@@ -9411,7 +9526,7 @@ var _Fuel = class extends FuelConnector {
9411
9526
  const currentNetwork = await this.currentNetwork();
9412
9527
  provider = await Provider.create(currentNetwork.url);
9413
9528
  } else {
9414
- throw new FuelError24(ErrorCode24.INVALID_PROVIDER, "Provider is not valid.");
9529
+ throw new FuelError25(ErrorCode25.INVALID_PROVIDER, "Provider is not valid.");
9415
9530
  }
9416
9531
  return provider;
9417
9532
  }
@@ -9490,7 +9605,9 @@ export {
9490
9605
  WalletUnlocked,
9491
9606
  addAmountToAsset,
9492
9607
  addOperation,
9608
+ assemblePanicError,
9493
9609
  assembleReceiptByType,
9610
+ assembleRevertError,
9494
9611
  assembleTransactionSummary,
9495
9612
  assets,
9496
9613
  buildBlockExplorerUrl,
@@ -9505,6 +9622,7 @@ export {
9505
9622
  english,
9506
9623
  extractBurnedAssetsFromReceipts,
9507
9624
  extractMintedAssetsFromReceipts,
9625
+ extractTxError,
9508
9626
  gasUsedByInputs,
9509
9627
  getAssetEth,
9510
9628
  getAssetFuel,