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

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

Potentially problematic release.


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

@@ -25,9 +25,9 @@ import { hexlify as hexlify15 } from "@fuel-ts/utils";
25
25
  // src/account.ts
26
26
  import { Address as Address3 } from "@fuel-ts/address";
27
27
  import { BaseAssetId as BaseAssetId3 } from "@fuel-ts/address/configs";
28
- import { ErrorCode as ErrorCode14, FuelError as FuelError14 } from "@fuel-ts/errors";
28
+ import { ErrorCode as ErrorCode15, FuelError as FuelError15 } from "@fuel-ts/errors";
29
29
  import { AbstractAccount } from "@fuel-ts/interfaces";
30
- import { bn as bn16 } from "@fuel-ts/math";
30
+ import { bn as bn17 } from "@fuel-ts/math";
31
31
  import { arrayify as arrayify14 } from "@fuel-ts/utils";
32
32
 
33
33
  // src/providers/coin-quantity.ts
@@ -68,8 +68,8 @@ var addAmountToAsset = (params) => {
68
68
 
69
69
  // src/providers/provider.ts
70
70
  import { Address as Address2 } from "@fuel-ts/address";
71
- import { ErrorCode as ErrorCode12, FuelError as FuelError12 } from "@fuel-ts/errors";
72
- import { BN, bn as bn14, max } from "@fuel-ts/math";
71
+ import { ErrorCode as ErrorCode13, FuelError as FuelError13 } from "@fuel-ts/errors";
72
+ import { BN, bn as bn15, max } from "@fuel-ts/math";
73
73
  import {
74
74
  InputType as InputType6,
75
75
  TransactionType as TransactionType8,
@@ -1152,7 +1152,7 @@ var outputify = (value) => {
1152
1152
  // src/providers/transaction-request/transaction-request.ts
1153
1153
  import { Address, addressify } from "@fuel-ts/address";
1154
1154
  import { BaseAssetId as BaseAssetId2, ZeroBytes32 as ZeroBytes324 } from "@fuel-ts/address/configs";
1155
- import { bn as bn6 } from "@fuel-ts/math";
1155
+ import { bn as bn7 } from "@fuel-ts/math";
1156
1156
  import {
1157
1157
  PolicyType,
1158
1158
  TransactionCoder,
@@ -1495,6 +1495,76 @@ function sleep(time) {
1495
1495
  });
1496
1496
  }
1497
1497
 
1498
+ // src/providers/utils/extract-tx-error.ts
1499
+ import { ErrorCode as ErrorCode7, FuelError as FuelError7 } from "@fuel-ts/errors";
1500
+ import { bn as bn6 } from "@fuel-ts/math";
1501
+ import { ReceiptType as ReceiptType3 } from "@fuel-ts/transactions";
1502
+ import {
1503
+ FAILED_REQUIRE_SIGNAL,
1504
+ FAILED_ASSERT_EQ_SIGNAL,
1505
+ FAILED_ASSERT_NE_SIGNAL,
1506
+ FAILED_ASSERT_SIGNAL,
1507
+ FAILED_TRANSFER_TO_ADDRESS_SIGNAL as FAILED_TRANSFER_TO_ADDRESS_SIGNAL2,
1508
+ PANIC_REASONS,
1509
+ PANIC_DOC_URL
1510
+ } from "@fuel-ts/transactions/configs";
1511
+ var assemblePanicError = (status) => {
1512
+ let errorMessage = `The transaction reverted with reason: "${status.reason}".`;
1513
+ if (PANIC_REASONS.includes(status.reason)) {
1514
+ errorMessage = `${errorMessage}
1515
+
1516
+ You can read more about this error at:
1517
+
1518
+ ${PANIC_DOC_URL}#variant.${status.reason}`;
1519
+ }
1520
+ return errorMessage;
1521
+ };
1522
+ var stringify = (obj) => JSON.stringify(obj, null, 2);
1523
+ var assembleRevertError = (receipts, logs) => {
1524
+ let errorMessage = "The transaction reverted with an unknown reason.";
1525
+ const revertReceipt = receipts.find(({ type }) => type === ReceiptType3.Revert);
1526
+ if (revertReceipt) {
1527
+ const reasonHex = bn6(revertReceipt.val).toHex();
1528
+ switch (reasonHex) {
1529
+ case FAILED_REQUIRE_SIGNAL: {
1530
+ errorMessage = `The transaction reverted because of a "require" statement has thrown ${logs.length ? stringify(logs[0]) : "an error."}.`;
1531
+ break;
1532
+ }
1533
+ case FAILED_ASSERT_EQ_SIGNAL: {
1534
+ const sufix = logs.length >= 2 ? ` comparing ${stringify(logs[1])} and ${stringify(logs[0])}.` : ".";
1535
+ errorMessage = `The transaction reverted because of an "assert_eq" statement${sufix}`;
1536
+ break;
1537
+ }
1538
+ case FAILED_ASSERT_NE_SIGNAL: {
1539
+ const sufix = logs.length >= 2 ? ` comparing ${stringify(logs[1])} and ${stringify(logs[0])}.` : ".";
1540
+ errorMessage = `The transaction reverted because of an "assert_ne" statement${sufix}`;
1541
+ break;
1542
+ }
1543
+ case FAILED_ASSERT_SIGNAL:
1544
+ errorMessage = `The transaction reverted because of an "assert" statement failed to evaluate to true.`;
1545
+ break;
1546
+ case FAILED_TRANSFER_TO_ADDRESS_SIGNAL2:
1547
+ errorMessage = `The transaction reverted because missing "OutputChange"(s).`;
1548
+ break;
1549
+ default:
1550
+ errorMessage = `The transaction reverted with an unknown reason: ${revertReceipt.val}`;
1551
+ }
1552
+ }
1553
+ return errorMessage;
1554
+ };
1555
+ var extractTxError = (params) => {
1556
+ const { receipts, status, logs } = params;
1557
+ const wasPanic = receipts.some(({ type }) => type === ReceiptType3.Panic);
1558
+ let err = status?.type === "FailureStatus" && wasPanic ? assemblePanicError(status) : assembleRevertError(receipts, logs);
1559
+ err += `
1560
+
1561
+ logs: ${JSON.stringify(logs, null, 2)}`;
1562
+ err += `
1563
+
1564
+ receipts: ${JSON.stringify(receipts, null, 2)}`;
1565
+ return new FuelError7(ErrorCode7.SCRIPT_REVERTED, err);
1566
+ };
1567
+
1498
1568
  // src/providers/transaction-request/errors.ts
1499
1569
  var NoWitnessAtIndexError = class extends Error {
1500
1570
  constructor(index) {
@@ -1545,10 +1615,10 @@ var BaseTransactionRequest = class {
1545
1615
  outputs,
1546
1616
  witnesses
1547
1617
  } = {}) {
1548
- this.gasPrice = bn6(gasPrice);
1618
+ this.gasPrice = bn7(gasPrice);
1549
1619
  this.maturity = maturity ?? 0;
1550
- this.witnessLimit = witnessLimit ? bn6(witnessLimit) : void 0;
1551
- this.maxFee = maxFee ? bn6(maxFee) : void 0;
1620
+ this.witnessLimit = witnessLimit ? bn7(witnessLimit) : void 0;
1621
+ this.maxFee = maxFee ? bn7(maxFee) : void 0;
1552
1622
  this.inputs = inputs ?? [];
1553
1623
  this.outputs = outputs ?? [];
1554
1624
  this.witnesses = witnesses ?? [];
@@ -1978,13 +2048,13 @@ var BaseTransactionRequest = class {
1978
2048
  assetId,
1979
2049
  owner: resourcesOwner || Address.fromRandom(),
1980
2050
  maturity: 0,
1981
- blockCreated: bn6(1),
1982
- txCreatedIdx: bn6(1)
2051
+ blockCreated: bn7(1),
2052
+ txCreatedIdx: bn7(1)
1983
2053
  }
1984
2054
  ]);
1985
2055
  }
1986
2056
  };
1987
- updateAssetInput(BaseAssetId2, bn6(1e11));
2057
+ updateAssetInput(BaseAssetId2, bn7(1e11));
1988
2058
  quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
1989
2059
  }
1990
2060
  /**
@@ -1995,7 +2065,7 @@ var BaseTransactionRequest = class {
1995
2065
  */
1996
2066
  getCoinOutputsQuantities() {
1997
2067
  const coinsQuantities = this.getCoinOutputs().map(({ amount, assetId }) => ({
1998
- amount: bn6(amount),
2068
+ amount: bn7(amount),
1999
2069
  assetId: assetId.toString()
2000
2070
  }));
2001
2071
  return coinsQuantities;
@@ -2024,7 +2094,7 @@ var BaseTransactionRequest = class {
2024
2094
  default:
2025
2095
  return;
2026
2096
  }
2027
- if (correspondingInput && "predicateGasUsed" in correspondingInput && bn6(correspondingInput.predicateGasUsed).gt(0)) {
2097
+ if (correspondingInput && "predicateGasUsed" in correspondingInput && bn7(correspondingInput.predicateGasUsed).gt(0)) {
2028
2098
  i.predicate = correspondingInput.predicate;
2029
2099
  i.predicateData = correspondingInput.predicateData;
2030
2100
  i.predicateGasUsed = correspondingInput.predicateGasUsed;
@@ -2035,14 +2105,14 @@ var BaseTransactionRequest = class {
2035
2105
 
2036
2106
  // src/providers/transaction-request/create-transaction-request.ts
2037
2107
  import { ZeroBytes32 as ZeroBytes326 } from "@fuel-ts/address/configs";
2038
- import { bn as bn8 } from "@fuel-ts/math";
2108
+ import { bn as bn9 } from "@fuel-ts/math";
2039
2109
  import { TransactionType as TransactionType3, OutputType as OutputType4 } from "@fuel-ts/transactions";
2040
2110
  import { arrayify as arrayify6, hexlify as hexlify9 } from "@fuel-ts/utils";
2041
2111
 
2042
2112
  // src/providers/transaction-request/hash-transaction.ts
2043
2113
  import { ZeroBytes32 as ZeroBytes325 } from "@fuel-ts/address/configs";
2044
2114
  import { uint64ToBytesBE, sha256 } from "@fuel-ts/hasher";
2045
- import { bn as bn7 } from "@fuel-ts/math";
2115
+ import { bn as bn8 } from "@fuel-ts/math";
2046
2116
  import { TransactionType as TransactionType2, InputType as InputType3, OutputType as OutputType3, TransactionCoder as TransactionCoder2 } from "@fuel-ts/transactions";
2047
2117
  import { concat as concat2 } from "@fuel-ts/utils";
2048
2118
  import { clone as clone2 } from "ramda";
@@ -2059,11 +2129,11 @@ function hashTransaction(transactionRequest, chainId) {
2059
2129
  blockHeight: 0,
2060
2130
  txIndex: 0
2061
2131
  };
2062
- inputClone.predicateGasUsed = bn7(0);
2132
+ inputClone.predicateGasUsed = bn8(0);
2063
2133
  return inputClone;
2064
2134
  }
2065
2135
  case InputType3.Message: {
2066
- inputClone.predicateGasUsed = bn7(0);
2136
+ inputClone.predicateGasUsed = bn8(0);
2067
2137
  return inputClone;
2068
2138
  }
2069
2139
  case InputType3.Contract: {
@@ -2090,12 +2160,12 @@ function hashTransaction(transactionRequest, chainId) {
2090
2160
  return outputClone;
2091
2161
  }
2092
2162
  case OutputType3.Change: {
2093
- outputClone.amount = bn7(0);
2163
+ outputClone.amount = bn8(0);
2094
2164
  return outputClone;
2095
2165
  }
2096
2166
  case OutputType3.Variable: {
2097
2167
  outputClone.to = ZeroBytes325;
2098
- outputClone.amount = bn7(0);
2168
+ outputClone.amount = bn8(0);
2099
2169
  outputClone.assetId = ZeroBytes325;
2100
2170
  return outputClone;
2101
2171
  }
@@ -2219,7 +2289,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2219
2289
  }
2220
2290
  metadataGas(gasCosts) {
2221
2291
  return calculateMetadataGasForTxCreate({
2222
- contractBytesSize: bn8(arrayify6(this.witnesses[this.bytecodeWitnessIndex] || "0x").length),
2292
+ contractBytesSize: bn9(arrayify6(this.witnesses[this.bytecodeWitnessIndex] || "0x").length),
2223
2293
  gasCosts,
2224
2294
  stateRootSize: this.storageSlots.length,
2225
2295
  txBytesSize: this.byteSize()
@@ -2231,7 +2301,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2231
2301
  import { Interface } from "@fuel-ts/abi-coder";
2232
2302
  import { addressify as addressify2 } from "@fuel-ts/address";
2233
2303
  import { ZeroBytes32 as ZeroBytes327 } from "@fuel-ts/address/configs";
2234
- import { bn as bn9 } from "@fuel-ts/math";
2304
+ import { bn as bn10 } from "@fuel-ts/math";
2235
2305
  import { InputType as InputType4, OutputType as OutputType5, TransactionType as TransactionType4 } from "@fuel-ts/transactions";
2236
2306
  import { arrayify as arrayify8, hexlify as hexlify10 } from "@fuel-ts/utils";
2237
2307
 
@@ -2277,6 +2347,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2277
2347
  script;
2278
2348
  /** Script input data (parameters) */
2279
2349
  scriptData;
2350
+ abis;
2280
2351
  /**
2281
2352
  * Constructor for `ScriptTransactionRequest`.
2282
2353
  *
@@ -2284,9 +2355,10 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2284
2355
  */
2285
2356
  constructor({ script, scriptData, gasLimit, ...rest } = {}) {
2286
2357
  super(rest);
2287
- this.gasLimit = bn9(gasLimit);
2358
+ this.gasLimit = bn10(gasLimit);
2288
2359
  this.script = arrayify8(script ?? returnZeroScript.bytes);
2289
2360
  this.scriptData = arrayify8(scriptData ?? returnZeroScript.encodeScriptData());
2361
+ this.abis = rest.abis;
2290
2362
  }
2291
2363
  /**
2292
2364
  * Converts the transaction request to a `TransactionScript`.
@@ -2431,7 +2503,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2431
2503
  };
2432
2504
 
2433
2505
  // src/providers/transaction-request/utils.ts
2434
- import { ErrorCode as ErrorCode7, FuelError as FuelError7 } from "@fuel-ts/errors";
2506
+ import { ErrorCode as ErrorCode8, FuelError as FuelError8 } from "@fuel-ts/errors";
2435
2507
  import { TransactionType as TransactionType5 } from "@fuel-ts/transactions";
2436
2508
  var transactionRequestify = (obj) => {
2437
2509
  if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest) {
@@ -2446,14 +2518,14 @@ var transactionRequestify = (obj) => {
2446
2518
  return CreateTransactionRequest.from(obj);
2447
2519
  }
2448
2520
  default: {
2449
- throw new FuelError7(ErrorCode7.INVALID_TRANSACTION_TYPE, `Invalid transaction type: ${type}.`);
2521
+ throw new FuelError8(ErrorCode8.INVALID_TRANSACTION_TYPE, `Invalid transaction type: ${type}.`);
2450
2522
  }
2451
2523
  }
2452
2524
  };
2453
2525
 
2454
2526
  // src/providers/transaction-response/transaction-response.ts
2455
- import { ErrorCode as ErrorCode11, FuelError as FuelError11 } from "@fuel-ts/errors";
2456
- import { bn as bn13 } from "@fuel-ts/math";
2527
+ import { ErrorCode as ErrorCode12, FuelError as FuelError12 } from "@fuel-ts/errors";
2528
+ import { bn as bn14 } from "@fuel-ts/math";
2457
2529
  import { TransactionCoder as TransactionCoder4 } from "@fuel-ts/transactions";
2458
2530
  import { arrayify as arrayify10 } from "@fuel-ts/utils";
2459
2531
 
@@ -2461,7 +2533,7 @@ import { arrayify as arrayify10 } from "@fuel-ts/utils";
2461
2533
  import { DateTime, hexlify as hexlify11 } from "@fuel-ts/utils";
2462
2534
 
2463
2535
  // src/providers/transaction-summary/calculate-transaction-fee.ts
2464
- import { bn as bn10 } from "@fuel-ts/math";
2536
+ import { bn as bn11 } from "@fuel-ts/math";
2465
2537
  import { PolicyType as PolicyType2, TransactionCoder as TransactionCoder3, TransactionType as TransactionType6 } from "@fuel-ts/transactions";
2466
2538
  import { arrayify as arrayify9 } from "@fuel-ts/utils";
2467
2539
  var calculateTransactionFee = (params) => {
@@ -2470,24 +2542,24 @@ var calculateTransactionFee = (params) => {
2470
2542
  rawPayload,
2471
2543
  consensusParameters: { gasCosts, feeParams }
2472
2544
  } = params;
2473
- const gasPerByte = bn10(feeParams.gasPerByte);
2474
- const gasPriceFactor = bn10(feeParams.gasPriceFactor);
2545
+ const gasPerByte = bn11(feeParams.gasPerByte);
2546
+ const gasPriceFactor = bn11(feeParams.gasPriceFactor);
2475
2547
  const transactionBytes = arrayify9(rawPayload);
2476
2548
  const [transaction] = new TransactionCoder3().decode(transactionBytes, 0);
2477
2549
  if (transaction.type === TransactionType6.Mint) {
2478
2550
  return {
2479
- fee: bn10(0),
2480
- minFee: bn10(0),
2481
- maxFee: bn10(0),
2482
- feeFromGasUsed: bn10(0)
2551
+ fee: bn11(0),
2552
+ minFee: bn11(0),
2553
+ maxFee: bn11(0),
2554
+ feeFromGasUsed: bn11(0)
2483
2555
  };
2484
2556
  }
2485
2557
  const { type, witnesses, inputs, policies } = transaction;
2486
- let metadataGas = bn10(0);
2487
- let gasLimit = bn10(0);
2558
+ let metadataGas = bn11(0);
2559
+ let gasLimit = bn11(0);
2488
2560
  if (type === TransactionType6.Create) {
2489
2561
  const { bytecodeWitnessIndex, storageSlots } = transaction;
2490
- const contractBytesSize = bn10(arrayify9(witnesses[bytecodeWitnessIndex].data).length);
2562
+ const contractBytesSize = bn11(arrayify9(witnesses[bytecodeWitnessIndex].data).length);
2491
2563
  metadataGas = calculateMetadataGasForTxCreate({
2492
2564
  contractBytesSize,
2493
2565
  gasCosts,
@@ -2506,12 +2578,12 @@ var calculateTransactionFee = (params) => {
2506
2578
  }
2507
2579
  const minGas = getMinGas({
2508
2580
  gasCosts,
2509
- gasPerByte: bn10(gasPerByte),
2581
+ gasPerByte: bn11(gasPerByte),
2510
2582
  inputs,
2511
2583
  metadataGas,
2512
2584
  txBytesSize: transactionBytes.length
2513
2585
  });
2514
- const gasPrice = bn10(policies.find((policy) => policy.type === PolicyType2.GasPrice)?.data);
2586
+ const gasPrice = bn11(policies.find((policy) => policy.type === PolicyType2.GasPrice)?.data);
2515
2587
  const witnessLimit = policies.find((policy) => policy.type === PolicyType2.WitnessLimit)?.data;
2516
2588
  const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
2517
2589
  const maxGas = getMaxGas({
@@ -2535,13 +2607,13 @@ var calculateTransactionFee = (params) => {
2535
2607
 
2536
2608
  // src/providers/transaction-summary/operations.ts
2537
2609
  import { ZeroBytes32 as ZeroBytes328 } from "@fuel-ts/address/configs";
2538
- import { ErrorCode as ErrorCode9, FuelError as FuelError9 } from "@fuel-ts/errors";
2539
- import { bn as bn12 } from "@fuel-ts/math";
2540
- import { ReceiptType as ReceiptType3, TransactionType as TransactionType7 } from "@fuel-ts/transactions";
2610
+ import { ErrorCode as ErrorCode10, FuelError as FuelError10 } from "@fuel-ts/errors";
2611
+ import { bn as bn13 } from "@fuel-ts/math";
2612
+ import { ReceiptType as ReceiptType4, TransactionType as TransactionType7 } from "@fuel-ts/transactions";
2541
2613
 
2542
2614
  // src/providers/transaction-summary/call.ts
2543
2615
  import { Interface as Interface2, calculateVmTxMemory } from "@fuel-ts/abi-coder";
2544
- import { bn as bn11 } from "@fuel-ts/math";
2616
+ import { bn as bn12 } from "@fuel-ts/math";
2545
2617
  var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
2546
2618
  const abiInterface = new Interface2(abi);
2547
2619
  const callFunctionSelector = receipt.param1.toHex(8);
@@ -2550,7 +2622,7 @@ var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
2550
2622
  let encodedArgs;
2551
2623
  if (functionFragment.isInputDataPointer) {
2552
2624
  if (rawPayload) {
2553
- const argsOffset = bn11(receipt.param2).sub(calculateVmTxMemory({ maxInputs: maxInputs.toNumber() })).toNumber();
2625
+ const argsOffset = bn12(receipt.param2).sub(calculateVmTxMemory({ maxInputs: maxInputs.toNumber() })).toNumber();
2554
2626
  encodedArgs = `0x${rawPayload.slice(2).slice(argsOffset * 2)}`;
2555
2627
  }
2556
2628
  } else {
@@ -2584,7 +2656,7 @@ var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
2584
2656
  };
2585
2657
 
2586
2658
  // src/providers/transaction-summary/input.ts
2587
- import { ErrorCode as ErrorCode8, FuelError as FuelError8 } from "@fuel-ts/errors";
2659
+ import { ErrorCode as ErrorCode9, FuelError as FuelError9 } from "@fuel-ts/errors";
2588
2660
  import { InputType as InputType5 } from "@fuel-ts/transactions";
2589
2661
  function getInputsByTypes(inputs, types) {
2590
2662
  return inputs.filter((i) => types.includes(i.type));
@@ -2622,8 +2694,8 @@ function getInputContractFromIndex(inputs, inputIndex) {
2622
2694
  return void 0;
2623
2695
  }
2624
2696
  if (contractInput.type !== InputType5.Contract) {
2625
- throw new FuelError8(
2626
- ErrorCode8.INVALID_TRANSACTION_INPUT,
2697
+ throw new FuelError9(
2698
+ ErrorCode9.INVALID_TRANSACTION_INPUT,
2627
2699
  `Contract input should be of type 'contract'.`
2628
2700
  );
2629
2701
  }
@@ -2670,8 +2742,8 @@ function getTransactionTypeName(transactionType) {
2670
2742
  case TransactionType7.Script:
2671
2743
  return "Script" /* Script */;
2672
2744
  default:
2673
- throw new FuelError9(
2674
- ErrorCode9.INVALID_TRANSACTION_TYPE,
2745
+ throw new FuelError10(
2746
+ ErrorCode10.INVALID_TRANSACTION_TYPE,
2675
2747
  `Invalid transaction type: ${transactionType}.`
2676
2748
  );
2677
2749
  }
@@ -2690,10 +2762,10 @@ function isTypeScript(transactionType) {
2690
2762
  return isType(transactionType, "Script" /* Script */);
2691
2763
  }
2692
2764
  function getReceiptsCall(receipts) {
2693
- return getReceiptsByType(receipts, ReceiptType3.Call);
2765
+ return getReceiptsByType(receipts, ReceiptType4.Call);
2694
2766
  }
2695
2767
  function getReceiptsMessageOut(receipts) {
2696
- return getReceiptsByType(receipts, ReceiptType3.MessageOut);
2768
+ return getReceiptsByType(receipts, ReceiptType4.MessageOut);
2697
2769
  }
2698
2770
  var mergeAssets = (op1, op2) => {
2699
2771
  const assets1 = op1.assetsSent || [];
@@ -2706,7 +2778,7 @@ var mergeAssets = (op1, op2) => {
2706
2778
  if (!matchingAsset) {
2707
2779
  return asset1;
2708
2780
  }
2709
- const mergedAmount = bn12(asset1.amount).add(matchingAsset.amount);
2781
+ const mergedAmount = bn13(asset1.amount).add(matchingAsset.amount);
2710
2782
  return { ...asset1, amount: mergedAmount };
2711
2783
  });
2712
2784
  return mergedAssets.concat(filteredAssets);
@@ -2889,11 +2961,11 @@ function getTransferOperations({
2889
2961
  });
2890
2962
  const transferReceipts = getReceiptsByType(
2891
2963
  receipts,
2892
- ReceiptType3.Transfer
2964
+ ReceiptType4.Transfer
2893
2965
  );
2894
2966
  const transferOutReceipts = getReceiptsByType(
2895
2967
  receipts,
2896
- ReceiptType3.TransferOut
2968
+ ReceiptType4.TransferOut
2897
2969
  );
2898
2970
  [...transferReceipts, ...transferOutReceipts].forEach((receipt) => {
2899
2971
  const operation = extractTransferOperationFromReceipt(receipt, contractInputs, changeOutputs);
@@ -2978,17 +3050,17 @@ function getOperations({
2978
3050
  }
2979
3051
 
2980
3052
  // src/providers/transaction-summary/receipt.ts
2981
- import { ReceiptType as ReceiptType4 } from "@fuel-ts/transactions";
3053
+ import { ReceiptType as ReceiptType5 } from "@fuel-ts/transactions";
2982
3054
  var processGqlReceipt = (gqlReceipt) => {
2983
3055
  const receipt = assembleReceiptByType(gqlReceipt);
2984
3056
  switch (receipt.type) {
2985
- case ReceiptType4.ReturnData: {
3057
+ case ReceiptType5.ReturnData: {
2986
3058
  return {
2987
3059
  ...receipt,
2988
3060
  data: gqlReceipt.data || "0x"
2989
3061
  };
2990
3062
  }
2991
- case ReceiptType4.LogData: {
3063
+ case ReceiptType5.LogData: {
2992
3064
  return {
2993
3065
  ...receipt,
2994
3066
  data: gqlReceipt.data || "0x"
@@ -3001,7 +3073,7 @@ var processGqlReceipt = (gqlReceipt) => {
3001
3073
  var extractMintedAssetsFromReceipts = (receipts) => {
3002
3074
  const mintedAssets = [];
3003
3075
  receipts.forEach((receipt) => {
3004
- if (receipt.type === ReceiptType4.Mint) {
3076
+ if (receipt.type === ReceiptType5.Mint) {
3005
3077
  mintedAssets.push({
3006
3078
  subId: receipt.subId,
3007
3079
  contractId: receipt.contractId,
@@ -3015,7 +3087,7 @@ var extractMintedAssetsFromReceipts = (receipts) => {
3015
3087
  var extractBurnedAssetsFromReceipts = (receipts) => {
3016
3088
  const burnedAssets = [];
3017
3089
  receipts.forEach((receipt) => {
3018
- if (receipt.type === ReceiptType4.Burn) {
3090
+ if (receipt.type === ReceiptType5.Burn) {
3019
3091
  burnedAssets.push({
3020
3092
  subId: receipt.subId,
3021
3093
  contractId: receipt.contractId,
@@ -3028,7 +3100,7 @@ var extractBurnedAssetsFromReceipts = (receipts) => {
3028
3100
  };
3029
3101
 
3030
3102
  // src/providers/transaction-summary/status.ts
3031
- import { ErrorCode as ErrorCode10, FuelError as FuelError10 } from "@fuel-ts/errors";
3103
+ import { ErrorCode as ErrorCode11, FuelError as FuelError11 } from "@fuel-ts/errors";
3032
3104
  var getTransactionStatusName = (gqlStatus) => {
3033
3105
  switch (gqlStatus) {
3034
3106
  case "FailureStatus":
@@ -3040,8 +3112,8 @@ var getTransactionStatusName = (gqlStatus) => {
3040
3112
  case "SqueezedOutStatus":
3041
3113
  return "squeezedout" /* squeezedout */;
3042
3114
  default:
3043
- throw new FuelError10(
3044
- ErrorCode10.INVALID_TRANSACTION_STATUS,
3115
+ throw new FuelError11(
3116
+ ErrorCode11.INVALID_TRANSACTION_STATUS,
3045
3117
  `Invalid transaction status: ${gqlStatus}.`
3046
3118
  );
3047
3119
  }
@@ -3152,6 +3224,21 @@ function assembleTransactionSummary(params) {
3152
3224
  return transactionSummary;
3153
3225
  }
3154
3226
 
3227
+ // src/providers/transaction-response/getDecodedLogs.ts
3228
+ import { Interface as Interface3, BigNumberCoder } from "@fuel-ts/abi-coder";
3229
+ import { ReceiptType as ReceiptType6 } from "@fuel-ts/transactions";
3230
+ function getDecodedLogs(receipts, mainAbi, externalAbis = {}) {
3231
+ return receipts.reduce((logs, receipt) => {
3232
+ if (receipt.type === ReceiptType6.LogData || receipt.type === ReceiptType6.Log) {
3233
+ const interfaceToUse = new Interface3(externalAbis[receipt.id] || mainAbi);
3234
+ const data = receipt.type === ReceiptType6.Log ? new BigNumberCoder("u64").encode(receipt.val0) : receipt.data;
3235
+ const [decodedLog] = interfaceToUse.decodeLog(data, receipt.val1.toNumber());
3236
+ logs.push(decodedLog);
3237
+ }
3238
+ return logs;
3239
+ }, []);
3240
+ }
3241
+
3155
3242
  // src/providers/transaction-response/transaction-response.ts
3156
3243
  var TransactionResponse = class {
3157
3244
  /** Transaction ID */
@@ -3159,18 +3246,20 @@ var TransactionResponse = class {
3159
3246
  /** Current provider */
3160
3247
  provider;
3161
3248
  /** Gas used on the transaction */
3162
- gasUsed = bn13(0);
3249
+ gasUsed = bn14(0);
3163
3250
  /** The graphql Transaction with receipts object. */
3164
3251
  gqlTransaction;
3252
+ abis;
3165
3253
  /**
3166
3254
  * Constructor for `TransactionResponse`.
3167
3255
  *
3168
3256
  * @param id - The transaction ID.
3169
3257
  * @param provider - The provider.
3170
3258
  */
3171
- constructor(id, provider) {
3259
+ constructor(id, provider, abis) {
3172
3260
  this.id = id;
3173
3261
  this.provider = provider;
3262
+ this.abis = abis;
3174
3263
  }
3175
3264
  /**
3176
3265
  * Async constructor for `TransactionResponse`. This method can be used to create
@@ -3180,8 +3269,8 @@ var TransactionResponse = class {
3180
3269
  * @param id - The transaction ID.
3181
3270
  * @param provider - The provider.
3182
3271
  */
3183
- static async create(id, provider) {
3184
- const response = new TransactionResponse(id, provider);
3272
+ static async create(id, provider, abis) {
3273
+ const response = new TransactionResponse(id, provider, abis);
3185
3274
  await response.fetch();
3186
3275
  return response;
3187
3276
  }
@@ -3262,8 +3351,8 @@ var TransactionResponse = class {
3262
3351
  });
3263
3352
  for await (const { statusChange } of subscription) {
3264
3353
  if (statusChange.type === "SqueezedOutStatus") {
3265
- throw new FuelError11(
3266
- ErrorCode11.TRANSACTION_SQUEEZED_OUT,
3354
+ throw new FuelError12(
3355
+ ErrorCode12.TRANSACTION_SQUEEZED_OUT,
3267
3356
  `Transaction Squeezed Out with reason: ${statusChange.reason}`
3268
3357
  );
3269
3358
  }
@@ -3285,6 +3374,26 @@ var TransactionResponse = class {
3285
3374
  gqlTransaction: this.gqlTransaction,
3286
3375
  ...transactionSummary
3287
3376
  };
3377
+ let logs = [];
3378
+ if (this.abis) {
3379
+ logs = getDecodedLogs(
3380
+ transactionSummary.receipts,
3381
+ this.abis.main,
3382
+ this.abis.otherContractsAbis
3383
+ );
3384
+ transactionResult.logs = logs;
3385
+ }
3386
+ if (transactionResult.isStatusFailure) {
3387
+ const {
3388
+ receipts,
3389
+ gqlTransaction: { status }
3390
+ } = transactionResult;
3391
+ throw extractTxError({
3392
+ receipts,
3393
+ status,
3394
+ logs
3395
+ });
3396
+ }
3288
3397
  return transactionResult;
3289
3398
  }
3290
3399
  /**
@@ -3295,19 +3404,21 @@ var TransactionResponse = class {
3295
3404
  async wait(contractsAbiMap) {
3296
3405
  const result = await this.waitForResult(contractsAbiMap);
3297
3406
  if (result.isStatusFailure) {
3298
- throw new FuelError11(
3299
- ErrorCode11.TRANSACTION_FAILED,
3300
- `Transaction failed: ${result.gqlTransaction.status.reason}`
3301
- );
3407
+ const {
3408
+ receipts,
3409
+ logs = [],
3410
+ gqlTransaction: { status }
3411
+ } = result;
3412
+ throw extractTxError({
3413
+ receipts,
3414
+ logs,
3415
+ status
3416
+ });
3302
3417
  }
3303
3418
  return result;
3304
3419
  }
3305
3420
  };
3306
3421
 
3307
- // src/providers/transaction-response/getDecodedLogs.ts
3308
- import { Interface as Interface3, BigNumberCoder } from "@fuel-ts/abi-coder";
3309
- import { ReceiptType as ReceiptType5 } from "@fuel-ts/transactions";
3310
-
3311
3422
  // src/providers/utils/auto-retry-fetch.ts
3312
3423
  function getWaitDelay(options, retryAttemptNum) {
3313
3424
  const duration = options.baseDelay ?? 150;
@@ -3366,29 +3477,29 @@ var processGqlChain = (chain) => {
3366
3477
  const { contractParams, feeParams, predicateParams, scriptParams, txParams, gasCosts } = consensusParameters;
3367
3478
  return {
3368
3479
  name,
3369
- baseChainHeight: bn14(daHeight),
3480
+ baseChainHeight: bn15(daHeight),
3370
3481
  consensusParameters: {
3371
- contractMaxSize: bn14(contractParams.contractMaxSize),
3372
- maxInputs: bn14(txParams.maxInputs),
3373
- maxOutputs: bn14(txParams.maxOutputs),
3374
- maxWitnesses: bn14(txParams.maxWitnesses),
3375
- maxGasPerTx: bn14(txParams.maxGasPerTx),
3376
- maxScriptLength: bn14(scriptParams.maxScriptLength),
3377
- maxScriptDataLength: bn14(scriptParams.maxScriptDataLength),
3378
- maxStorageSlots: bn14(contractParams.maxStorageSlots),
3379
- maxPredicateLength: bn14(predicateParams.maxPredicateLength),
3380
- maxPredicateDataLength: bn14(predicateParams.maxPredicateDataLength),
3381
- maxGasPerPredicate: bn14(predicateParams.maxGasPerPredicate),
3382
- gasPriceFactor: bn14(feeParams.gasPriceFactor),
3383
- gasPerByte: bn14(feeParams.gasPerByte),
3384
- maxMessageDataLength: bn14(predicateParams.maxMessageDataLength),
3385
- chainId: bn14(consensusParameters.chainId),
3482
+ contractMaxSize: bn15(contractParams.contractMaxSize),
3483
+ maxInputs: bn15(txParams.maxInputs),
3484
+ maxOutputs: bn15(txParams.maxOutputs),
3485
+ maxWitnesses: bn15(txParams.maxWitnesses),
3486
+ maxGasPerTx: bn15(txParams.maxGasPerTx),
3487
+ maxScriptLength: bn15(scriptParams.maxScriptLength),
3488
+ maxScriptDataLength: bn15(scriptParams.maxScriptDataLength),
3489
+ maxStorageSlots: bn15(contractParams.maxStorageSlots),
3490
+ maxPredicateLength: bn15(predicateParams.maxPredicateLength),
3491
+ maxPredicateDataLength: bn15(predicateParams.maxPredicateDataLength),
3492
+ maxGasPerPredicate: bn15(predicateParams.maxGasPerPredicate),
3493
+ gasPriceFactor: bn15(feeParams.gasPriceFactor),
3494
+ gasPerByte: bn15(feeParams.gasPerByte),
3495
+ maxMessageDataLength: bn15(predicateParams.maxMessageDataLength),
3496
+ chainId: bn15(consensusParameters.chainId),
3386
3497
  gasCosts
3387
3498
  },
3388
3499
  gasCosts,
3389
3500
  latestBlock: {
3390
3501
  id: latestBlock.id,
3391
- height: bn14(latestBlock.header.height),
3502
+ height: bn15(latestBlock.header.height),
3392
3503
  time: latestBlock.header.time,
3393
3504
  transactions: latestBlock.transactions.map((i) => ({
3394
3505
  id: i.id
@@ -3458,8 +3569,8 @@ var _Provider = class {
3458
3569
  getChain() {
3459
3570
  const chain = _Provider.chainInfoCache[this.url];
3460
3571
  if (!chain) {
3461
- throw new FuelError12(
3462
- ErrorCode12.CHAIN_INFO_CACHE_EMPTY,
3572
+ throw new FuelError13(
3573
+ ErrorCode13.CHAIN_INFO_CACHE_EMPTY,
3463
3574
  "Chain info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
3464
3575
  );
3465
3576
  }
@@ -3471,8 +3582,8 @@ var _Provider = class {
3471
3582
  getNode() {
3472
3583
  const node = _Provider.nodeInfoCache[this.url];
3473
3584
  if (!node) {
3474
- throw new FuelError12(
3475
- ErrorCode12.NODE_INFO_CACHE_EMPTY,
3585
+ throw new FuelError13(
3586
+ ErrorCode13.NODE_INFO_CACHE_EMPTY,
3476
3587
  "Node info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
3477
3588
  );
3478
3589
  }
@@ -3519,8 +3630,8 @@ var _Provider = class {
3519
3630
  static ensureClientVersionIsSupported(nodeInfo) {
3520
3631
  const { isMajorSupported, isMinorSupported, supportedVersion } = checkFuelCoreVersionCompatibility(nodeInfo.nodeVersion);
3521
3632
  if (!isMajorSupported || !isMinorSupported) {
3522
- throw new FuelError12(
3523
- FuelError12.CODES.UNSUPPORTED_FUEL_CLIENT_VERSION,
3633
+ throw new FuelError13(
3634
+ FuelError13.CODES.UNSUPPORTED_FUEL_CLIENT_VERSION,
3524
3635
  `Fuel client version: ${nodeInfo.nodeVersion}, Supported version: ${supportedVersion}`
3525
3636
  );
3526
3637
  }
@@ -3583,7 +3694,7 @@ var _Provider = class {
3583
3694
  */
3584
3695
  async getBlockNumber() {
3585
3696
  const { chain } = await this.operations.getChain();
3586
- return bn14(chain.latestBlock.header.height, 10);
3697
+ return bn15(chain.latestBlock.header.height, 10);
3587
3698
  }
3588
3699
  /**
3589
3700
  * Returns the chain information.
@@ -3593,9 +3704,9 @@ var _Provider = class {
3593
3704
  async fetchNode() {
3594
3705
  const { nodeInfo } = await this.operations.getNodeInfo();
3595
3706
  const processedNodeInfo = {
3596
- maxDepth: bn14(nodeInfo.maxDepth),
3597
- maxTx: bn14(nodeInfo.maxTx),
3598
- minGasPrice: bn14(nodeInfo.minGasPrice),
3707
+ maxDepth: bn15(nodeInfo.maxDepth),
3708
+ maxTx: bn15(nodeInfo.maxTx),
3709
+ minGasPrice: bn15(nodeInfo.minGasPrice),
3599
3710
  nodeVersion: nodeInfo.nodeVersion,
3600
3711
  utxoValidation: nodeInfo.utxoValidation,
3601
3712
  vmBacktrace: nodeInfo.vmBacktrace,
@@ -3642,12 +3753,16 @@ var _Provider = class {
3642
3753
  await this.estimateTxDependencies(transactionRequest);
3643
3754
  }
3644
3755
  const encodedTransaction = hexlify12(transactionRequest.toTransactionBytes());
3756
+ let abis;
3757
+ if (transactionRequest.type === TransactionType8.Script) {
3758
+ abis = transactionRequest.abis;
3759
+ }
3645
3760
  if (awaitExecution) {
3646
3761
  const subscription = this.operations.submitAndAwait({ encodedTransaction });
3647
3762
  for await (const { submitAndAwait } of subscription) {
3648
3763
  if (submitAndAwait.type === "SqueezedOutStatus") {
3649
- throw new FuelError12(
3650
- ErrorCode12.TRANSACTION_SQUEEZED_OUT,
3764
+ throw new FuelError13(
3765
+ ErrorCode13.TRANSACTION_SQUEEZED_OUT,
3651
3766
  `Transaction Squeezed Out with reason: ${submitAndAwait.reason}`
3652
3767
  );
3653
3768
  }
@@ -3656,14 +3771,14 @@ var _Provider = class {
3656
3771
  }
3657
3772
  }
3658
3773
  const transactionId2 = transactionRequest.getTransactionId(this.getChainId());
3659
- const response = new TransactionResponse(transactionId2, this);
3774
+ const response = new TransactionResponse(transactionId2, this, abis);
3660
3775
  await response.fetch();
3661
3776
  return response;
3662
3777
  }
3663
3778
  const {
3664
3779
  submit: { id: transactionId }
3665
3780
  } = await this.operations.submit({ encodedTransaction });
3666
- return new TransactionResponse(transactionId, this);
3781
+ return new TransactionResponse(transactionId, this, abis);
3667
3782
  }
3668
3783
  /**
3669
3784
  * Executes a transaction without actually submitting it to the chain.
@@ -3714,7 +3829,7 @@ var _Provider = class {
3714
3829
  } = response;
3715
3830
  if (inputs) {
3716
3831
  inputs.forEach((input, index) => {
3717
- if ("predicateGasUsed" in input && bn14(input.predicateGasUsed).gt(0)) {
3832
+ if ("predicateGasUsed" in input && bn15(input.predicateGasUsed).gt(0)) {
3718
3833
  transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
3719
3834
  }
3720
3835
  });
@@ -3827,7 +3942,7 @@ var _Provider = class {
3827
3942
  txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
3828
3943
  if (estimatePredicates) {
3829
3944
  if (isScriptTransaction) {
3830
- txRequestClone.gasLimit = bn14(0);
3945
+ txRequestClone.gasLimit = bn15(0);
3831
3946
  }
3832
3947
  if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
3833
3948
  resourcesOwner.populateTransactionPredicateData(txRequestClone);
@@ -3843,8 +3958,8 @@ var _Provider = class {
3843
3958
  let missingContractIds = [];
3844
3959
  let outputVariables = 0;
3845
3960
  if (isScriptTransaction && estimateTxDependencies) {
3846
- txRequestClone.gasPrice = bn14(0);
3847
- txRequestClone.gasLimit = bn14(maxGasPerTx.sub(maxGas).toNumber() * 0.9);
3961
+ txRequestClone.gasPrice = bn15(0);
3962
+ txRequestClone.gasLimit = bn15(maxGasPerTx.sub(maxGas).toNumber() * 0.9);
3848
3963
  const result = await this.estimateTxDependencies(txRequestClone);
3849
3964
  receipts = result.receipts;
3850
3965
  outputVariables = result.outputVariables;
@@ -3906,11 +4021,11 @@ var _Provider = class {
3906
4021
  return coins.map((coin) => ({
3907
4022
  id: coin.utxoId,
3908
4023
  assetId: coin.assetId,
3909
- amount: bn14(coin.amount),
4024
+ amount: bn15(coin.amount),
3910
4025
  owner: Address2.fromAddressOrString(coin.owner),
3911
- maturity: bn14(coin.maturity).toNumber(),
3912
- blockCreated: bn14(coin.blockCreated),
3913
- txCreatedIdx: bn14(coin.txCreatedIdx)
4026
+ maturity: bn15(coin.maturity).toNumber(),
4027
+ blockCreated: bn15(coin.blockCreated),
4028
+ txCreatedIdx: bn15(coin.txCreatedIdx)
3914
4029
  }));
3915
4030
  }
3916
4031
  /**
@@ -3947,9 +4062,9 @@ var _Provider = class {
3947
4062
  switch (coin.__typename) {
3948
4063
  case "MessageCoin":
3949
4064
  return {
3950
- amount: bn14(coin.amount),
4065
+ amount: bn15(coin.amount),
3951
4066
  assetId: coin.assetId,
3952
- daHeight: bn14(coin.daHeight),
4067
+ daHeight: bn15(coin.daHeight),
3953
4068
  sender: Address2.fromAddressOrString(coin.sender),
3954
4069
  recipient: Address2.fromAddressOrString(coin.recipient),
3955
4070
  nonce: coin.nonce
@@ -3957,12 +4072,12 @@ var _Provider = class {
3957
4072
  case "Coin":
3958
4073
  return {
3959
4074
  id: coin.utxoId,
3960
- amount: bn14(coin.amount),
4075
+ amount: bn15(coin.amount),
3961
4076
  assetId: coin.assetId,
3962
4077
  owner: Address2.fromAddressOrString(coin.owner),
3963
- maturity: bn14(coin.maturity).toNumber(),
3964
- blockCreated: bn14(coin.blockCreated),
3965
- txCreatedIdx: bn14(coin.txCreatedIdx)
4078
+ maturity: bn15(coin.maturity).toNumber(),
4079
+ blockCreated: bn15(coin.blockCreated),
4080
+ txCreatedIdx: bn15(coin.txCreatedIdx)
3966
4081
  };
3967
4082
  default:
3968
4083
  return null;
@@ -3979,13 +4094,13 @@ var _Provider = class {
3979
4094
  async getBlock(idOrHeight) {
3980
4095
  let variables;
3981
4096
  if (typeof idOrHeight === "number") {
3982
- variables = { height: bn14(idOrHeight).toString(10) };
4097
+ variables = { height: bn15(idOrHeight).toString(10) };
3983
4098
  } else if (idOrHeight === "latest") {
3984
4099
  variables = { height: (await this.getBlockNumber()).toString(10) };
3985
4100
  } else if (idOrHeight.length === 66) {
3986
4101
  variables = { blockId: idOrHeight };
3987
4102
  } else {
3988
- variables = { blockId: bn14(idOrHeight).toString(10) };
4103
+ variables = { blockId: bn15(idOrHeight).toString(10) };
3989
4104
  }
3990
4105
  const { block } = await this.operations.getBlock(variables);
3991
4106
  if (!block) {
@@ -3993,7 +4108,7 @@ var _Provider = class {
3993
4108
  }
3994
4109
  return {
3995
4110
  id: block.id,
3996
- height: bn14(block.header.height),
4111
+ height: bn15(block.header.height),
3997
4112
  time: block.header.time,
3998
4113
  transactionIds: block.transactions.map((tx) => tx.id)
3999
4114
  };
@@ -4008,7 +4123,7 @@ var _Provider = class {
4008
4123
  const { blocks: fetchedData } = await this.operations.getBlocks(params);
4009
4124
  const blocks = fetchedData.edges.map(({ node: block }) => ({
4010
4125
  id: block.id,
4011
- height: bn14(block.header.height),
4126
+ height: bn15(block.header.height),
4012
4127
  time: block.header.time,
4013
4128
  transactionIds: block.transactions.map((tx) => tx.id)
4014
4129
  }));
@@ -4023,7 +4138,7 @@ var _Provider = class {
4023
4138
  async getBlockWithTransactions(idOrHeight) {
4024
4139
  let variables;
4025
4140
  if (typeof idOrHeight === "number") {
4026
- variables = { blockHeight: bn14(idOrHeight).toString(10) };
4141
+ variables = { blockHeight: bn15(idOrHeight).toString(10) };
4027
4142
  } else if (idOrHeight === "latest") {
4028
4143
  variables = { blockHeight: (await this.getBlockNumber()).toString() };
4029
4144
  } else {
@@ -4035,7 +4150,7 @@ var _Provider = class {
4035
4150
  }
4036
4151
  return {
4037
4152
  id: block.id,
4038
- height: bn14(block.header.height, 10),
4153
+ height: bn15(block.header.height, 10),
4039
4154
  time: block.header.time,
4040
4155
  transactionIds: block.transactions.map((tx) => tx.id),
4041
4156
  transactions: block.transactions.map(
@@ -4084,7 +4199,7 @@ var _Provider = class {
4084
4199
  contract: Address2.fromAddressOrString(contractId).toB256(),
4085
4200
  asset: hexlify12(assetId)
4086
4201
  });
4087
- return bn14(contractBalance.amount, 10);
4202
+ return bn15(contractBalance.amount, 10);
4088
4203
  }
4089
4204
  /**
4090
4205
  * Returns the balance for the given owner for the given asset ID.
@@ -4098,7 +4213,7 @@ var _Provider = class {
4098
4213
  owner: Address2.fromAddressOrString(owner).toB256(),
4099
4214
  assetId: hexlify12(assetId)
4100
4215
  });
4101
- return bn14(balance.amount, 10);
4216
+ return bn15(balance.amount, 10);
4102
4217
  }
4103
4218
  /**
4104
4219
  * Returns balances for the given owner.
@@ -4116,7 +4231,7 @@ var _Provider = class {
4116
4231
  const balances = result.balances.edges.map((edge) => edge.node);
4117
4232
  return balances.map((balance) => ({
4118
4233
  assetId: balance.assetId,
4119
- amount: bn14(balance.amount)
4234
+ amount: bn15(balance.amount)
4120
4235
  }));
4121
4236
  }
4122
4237
  /**
@@ -4138,15 +4253,15 @@ var _Provider = class {
4138
4253
  sender: message.sender,
4139
4254
  recipient: message.recipient,
4140
4255
  nonce: message.nonce,
4141
- amount: bn14(message.amount),
4256
+ amount: bn15(message.amount),
4142
4257
  data: message.data
4143
4258
  }),
4144
4259
  sender: Address2.fromAddressOrString(message.sender),
4145
4260
  recipient: Address2.fromAddressOrString(message.recipient),
4146
4261
  nonce: message.nonce,
4147
- amount: bn14(message.amount),
4262
+ amount: bn15(message.amount),
4148
4263
  data: InputMessageCoder.decodeData(message.data),
4149
- daHeight: bn14(message.daHeight)
4264
+ daHeight: bn15(message.daHeight)
4150
4265
  }));
4151
4266
  }
4152
4267
  /**
@@ -4164,8 +4279,8 @@ var _Provider = class {
4164
4279
  nonce
4165
4280
  };
4166
4281
  if (commitBlockId && commitBlockHeight) {
4167
- throw new FuelError12(
4168
- ErrorCode12.INVALID_INPUT_PARAMETERS,
4282
+ throw new FuelError13(
4283
+ ErrorCode13.INVALID_INPUT_PARAMETERS,
4169
4284
  "commitBlockId and commitBlockHeight cannot be used together"
4170
4285
  );
4171
4286
  }
@@ -4199,41 +4314,41 @@ var _Provider = class {
4199
4314
  } = result.messageProof;
4200
4315
  return {
4201
4316
  messageProof: {
4202
- proofIndex: bn14(messageProof.proofIndex),
4317
+ proofIndex: bn15(messageProof.proofIndex),
4203
4318
  proofSet: messageProof.proofSet
4204
4319
  },
4205
4320
  blockProof: {
4206
- proofIndex: bn14(blockProof.proofIndex),
4321
+ proofIndex: bn15(blockProof.proofIndex),
4207
4322
  proofSet: blockProof.proofSet
4208
4323
  },
4209
4324
  messageBlockHeader: {
4210
4325
  id: messageBlockHeader.id,
4211
- daHeight: bn14(messageBlockHeader.daHeight),
4212
- transactionsCount: bn14(messageBlockHeader.transactionsCount),
4326
+ daHeight: bn15(messageBlockHeader.daHeight),
4327
+ transactionsCount: bn15(messageBlockHeader.transactionsCount),
4213
4328
  transactionsRoot: messageBlockHeader.transactionsRoot,
4214
- height: bn14(messageBlockHeader.height),
4329
+ height: bn15(messageBlockHeader.height),
4215
4330
  prevRoot: messageBlockHeader.prevRoot,
4216
4331
  time: messageBlockHeader.time,
4217
4332
  applicationHash: messageBlockHeader.applicationHash,
4218
4333
  messageReceiptRoot: messageBlockHeader.messageReceiptRoot,
4219
- messageReceiptCount: bn14(messageBlockHeader.messageReceiptCount)
4334
+ messageReceiptCount: bn15(messageBlockHeader.messageReceiptCount)
4220
4335
  },
4221
4336
  commitBlockHeader: {
4222
4337
  id: commitBlockHeader.id,
4223
- daHeight: bn14(commitBlockHeader.daHeight),
4224
- transactionsCount: bn14(commitBlockHeader.transactionsCount),
4338
+ daHeight: bn15(commitBlockHeader.daHeight),
4339
+ transactionsCount: bn15(commitBlockHeader.transactionsCount),
4225
4340
  transactionsRoot: commitBlockHeader.transactionsRoot,
4226
- height: bn14(commitBlockHeader.height),
4341
+ height: bn15(commitBlockHeader.height),
4227
4342
  prevRoot: commitBlockHeader.prevRoot,
4228
4343
  time: commitBlockHeader.time,
4229
4344
  applicationHash: commitBlockHeader.applicationHash,
4230
4345
  messageReceiptRoot: commitBlockHeader.messageReceiptRoot,
4231
- messageReceiptCount: bn14(commitBlockHeader.messageReceiptCount)
4346
+ messageReceiptCount: bn15(commitBlockHeader.messageReceiptCount)
4232
4347
  },
4233
4348
  sender: Address2.fromAddressOrString(sender),
4234
4349
  recipient: Address2.fromAddressOrString(recipient),
4235
4350
  nonce,
4236
- amount: bn14(amount),
4351
+ amount: bn15(amount),
4237
4352
  data
4238
4353
  };
4239
4354
  }
@@ -4256,10 +4371,10 @@ var _Provider = class {
4256
4371
  */
4257
4372
  async produceBlocks(amount, startTime) {
4258
4373
  const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
4259
- blocksToProduce: bn14(amount).toString(10),
4374
+ blocksToProduce: bn15(amount).toString(10),
4260
4375
  startTimestamp: startTime ? DateTime2.fromUnixMilliseconds(startTime).toTai64() : void 0
4261
4376
  });
4262
- return bn14(latestBlockHeight);
4377
+ return bn15(latestBlockHeight);
4263
4378
  }
4264
4379
  // eslint-disable-next-line @typescript-eslint/require-await
4265
4380
  async getTransactionResponse(transactionId) {
@@ -4282,8 +4397,8 @@ __publicField(Provider, "chainInfoCache", {});
4282
4397
  __publicField(Provider, "nodeInfoCache", {});
4283
4398
 
4284
4399
  // src/providers/transaction-summary/get-transaction-summary.ts
4285
- import { ErrorCode as ErrorCode13, FuelError as FuelError13 } from "@fuel-ts/errors";
4286
- import { bn as bn15 } from "@fuel-ts/math";
4400
+ import { ErrorCode as ErrorCode14, FuelError as FuelError14 } from "@fuel-ts/errors";
4401
+ import { bn as bn16 } from "@fuel-ts/math";
4287
4402
  import { TransactionCoder as TransactionCoder6 } from "@fuel-ts/transactions";
4288
4403
  import { arrayify as arrayify12 } from "@fuel-ts/utils";
4289
4404
 
@@ -4400,7 +4515,7 @@ var Account = class extends AbstractAccount {
4400
4515
  */
4401
4516
  get provider() {
4402
4517
  if (!this._provider) {
4403
- throw new FuelError14(ErrorCode14.MISSING_PROVIDER, "Provider not set");
4518
+ throw new FuelError15(ErrorCode15.MISSING_PROVIDER, "Provider not set");
4404
4519
  }
4405
4520
  return this._provider;
4406
4521
  }
@@ -4452,8 +4567,8 @@ var Account = class extends AbstractAccount {
4452
4567
  if (!hasNextPage) {
4453
4568
  break;
4454
4569
  }
4455
- throw new FuelError14(
4456
- ErrorCode14.NOT_SUPPORTED,
4570
+ throw new FuelError15(
4571
+ ErrorCode15.NOT_SUPPORTED,
4457
4572
  `Wallets containing more than ${pageSize} coins exceed the current supported limit.`
4458
4573
  );
4459
4574
  }
@@ -4478,8 +4593,8 @@ var Account = class extends AbstractAccount {
4478
4593
  if (!hasNextPage) {
4479
4594
  break;
4480
4595
  }
4481
- throw new FuelError14(
4482
- ErrorCode14.NOT_SUPPORTED,
4596
+ throw new FuelError15(
4597
+ ErrorCode15.NOT_SUPPORTED,
4483
4598
  `Wallets containing more than ${pageSize} messages exceed the current supported limit.`
4484
4599
  );
4485
4600
  }
@@ -4514,8 +4629,8 @@ var Account = class extends AbstractAccount {
4514
4629
  if (!hasNextPage) {
4515
4630
  break;
4516
4631
  }
4517
- throw new FuelError14(
4518
- ErrorCode14.NOT_SUPPORTED,
4632
+ throw new FuelError15(
4633
+ ErrorCode15.NOT_SUPPORTED,
4519
4634
  `Wallets containing more than ${pageSize} balances exceed the current supported limit.`
4520
4635
  );
4521
4636
  }
@@ -4531,7 +4646,7 @@ var Account = class extends AbstractAccount {
4531
4646
  */
4532
4647
  async fund(request, coinQuantities, fee) {
4533
4648
  const updatedQuantities = addAmountToAsset({
4534
- amount: bn16(fee),
4649
+ amount: bn17(fee),
4535
4650
  assetId: BaseAssetId3,
4536
4651
  coinQuantities
4537
4652
  });
@@ -4539,7 +4654,7 @@ var Account = class extends AbstractAccount {
4539
4654
  updatedQuantities.forEach(({ amount, assetId }) => {
4540
4655
  quantitiesDict[assetId] = {
4541
4656
  required: amount,
4542
- owned: bn16(0)
4657
+ owned: bn17(0)
4543
4658
  };
4544
4659
  });
4545
4660
  const cachedUtxos = [];
@@ -4552,7 +4667,7 @@ var Account = class extends AbstractAccount {
4552
4667
  if (isCoin2) {
4553
4668
  const assetId = String(input.assetId);
4554
4669
  if (input.owner === owner && quantitiesDict[assetId]) {
4555
- const amount = bn16(input.amount);
4670
+ const amount = bn17(input.amount);
4556
4671
  quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
4557
4672
  cachedUtxos.push(input.id);
4558
4673
  }
@@ -4598,8 +4713,8 @@ var Account = class extends AbstractAccount {
4598
4713
  estimateTxDependencies: true,
4599
4714
  resourcesOwner: this
4600
4715
  });
4601
- request.gasPrice = bn16(txParams.gasPrice ?? minGasPrice);
4602
- request.gasLimit = bn16(txParams.gasLimit ?? gasUsed);
4716
+ request.gasPrice = bn17(txParams.gasPrice ?? minGasPrice);
4717
+ request.gasLimit = bn17(txParams.gasLimit ?? gasUsed);
4603
4718
  this.validateGas({
4604
4719
  gasUsed,
4605
4720
  gasPrice: request.gasPrice,
@@ -4620,9 +4735,9 @@ var Account = class extends AbstractAccount {
4620
4735
  * @returns A promise that resolves to the transaction response.
4621
4736
  */
4622
4737
  async transfer(destination, amount, assetId = BaseAssetId3, txParams = {}) {
4623
- if (bn16(amount).lte(0)) {
4624
- throw new FuelError14(
4625
- ErrorCode14.INVALID_TRANSFER_AMOUNT,
4738
+ if (bn17(amount).lte(0)) {
4739
+ throw new FuelError15(
4740
+ ErrorCode15.INVALID_TRANSFER_AMOUNT,
4626
4741
  "Transfer amount must be a positive number."
4627
4742
  );
4628
4743
  }
@@ -4639,9 +4754,9 @@ var Account = class extends AbstractAccount {
4639
4754
  * @returns A promise that resolves to the transaction response.
4640
4755
  */
4641
4756
  async transferToContract(contractId, amount, assetId = BaseAssetId3, txParams = {}) {
4642
- if (bn16(amount).lte(0)) {
4643
- throw new FuelError14(
4644
- ErrorCode14.INVALID_TRANSFER_AMOUNT,
4757
+ if (bn17(amount).lte(0)) {
4758
+ throw new FuelError15(
4759
+ ErrorCode15.INVALID_TRANSFER_AMOUNT,
4645
4760
  "Transfer amount must be a positive number."
4646
4761
  );
4647
4762
  }
@@ -4650,7 +4765,7 @@ var Account = class extends AbstractAccount {
4650
4765
  const params = { gasPrice: minGasPrice, ...txParams };
4651
4766
  const { script, scriptData } = await assembleTransferToContractScript({
4652
4767
  hexlifiedContractId: contractAddress.toB256(),
4653
- amountToTransfer: bn16(amount),
4768
+ amountToTransfer: bn17(amount),
4654
4769
  assetId
4655
4770
  });
4656
4771
  const request = new ScriptTransactionRequest({
@@ -4661,9 +4776,9 @@ var Account = class extends AbstractAccount {
4661
4776
  request.addContractInputAndOutput(contractAddress);
4662
4777
  const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
4663
4778
  request,
4664
- [{ amount: bn16(amount), assetId: String(assetId) }]
4779
+ [{ amount: bn17(amount), assetId: String(assetId) }]
4665
4780
  );
4666
- request.gasLimit = bn16(params.gasLimit ?? gasUsed);
4781
+ request.gasLimit = bn17(params.gasLimit ?? gasUsed);
4667
4782
  this.validateGas({
4668
4783
  gasUsed,
4669
4784
  gasPrice: request.gasPrice,
@@ -4688,7 +4803,7 @@ var Account = class extends AbstractAccount {
4688
4803
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
4689
4804
  );
4690
4805
  const amountDataArray = arrayify14(
4691
- "0x".concat(bn16(amount).toHex().substring(2).padStart(16, "0"))
4806
+ "0x".concat(bn17(amount).toHex().substring(2).padStart(16, "0"))
4692
4807
  );
4693
4808
  const script = new Uint8Array([
4694
4809
  ...arrayify14(withdrawScript.bytes),
@@ -4697,12 +4812,12 @@ var Account = class extends AbstractAccount {
4697
4812
  ]);
4698
4813
  const params = { script, gasPrice: minGasPrice, ...txParams };
4699
4814
  const request = new ScriptTransactionRequest(params);
4700
- const forwardingQuantities = [{ amount: bn16(amount), assetId: BaseAssetId3 }];
4815
+ const forwardingQuantities = [{ amount: bn17(amount), assetId: BaseAssetId3 }];
4701
4816
  const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
4702
4817
  request,
4703
4818
  forwardingQuantities
4704
4819
  );
4705
- request.gasLimit = bn16(params.gasLimit ?? gasUsed);
4820
+ request.gasLimit = bn17(params.gasLimit ?? gasUsed);
4706
4821
  this.validateGas({
4707
4822
  gasUsed,
4708
4823
  gasPrice: request.gasPrice,
@@ -4714,7 +4829,7 @@ var Account = class extends AbstractAccount {
4714
4829
  }
4715
4830
  async signMessage(message) {
4716
4831
  if (!this._connector) {
4717
- throw new FuelError14(ErrorCode14.MISSING_CONNECTOR, "A connector is required to sign messages.");
4832
+ throw new FuelError15(ErrorCode15.MISSING_CONNECTOR, "A connector is required to sign messages.");
4718
4833
  }
4719
4834
  return this._connector.signMessage(this.address.toString(), message);
4720
4835
  }
@@ -4726,8 +4841,8 @@ var Account = class extends AbstractAccount {
4726
4841
  */
4727
4842
  async signTransaction(transactionRequestLike) {
4728
4843
  if (!this._connector) {
4729
- throw new FuelError14(
4730
- ErrorCode14.MISSING_CONNECTOR,
4844
+ throw new FuelError15(
4845
+ ErrorCode15.MISSING_CONNECTOR,
4731
4846
  "A connector is required to sign transactions."
4732
4847
  );
4733
4848
  }
@@ -4774,14 +4889,14 @@ var Account = class extends AbstractAccount {
4774
4889
  minGasPrice
4775
4890
  }) {
4776
4891
  if (minGasPrice.gt(gasPrice)) {
4777
- throw new FuelError14(
4778
- ErrorCode14.GAS_PRICE_TOO_LOW,
4892
+ throw new FuelError15(
4893
+ ErrorCode15.GAS_PRICE_TOO_LOW,
4779
4894
  `Gas price '${gasPrice}' is lower than the required: '${minGasPrice}'.`
4780
4895
  );
4781
4896
  }
4782
4897
  if (gasUsed.gt(gasLimit)) {
4783
- throw new FuelError14(
4784
- ErrorCode14.GAS_LIMIT_TOO_LOW,
4898
+ throw new FuelError15(
4899
+ ErrorCode15.GAS_LIMIT_TOO_LOW,
4785
4900
  `Gas limit '${gasLimit}' is lower than the required: '${gasUsed}'.`
4786
4901
  );
4787
4902
  }
@@ -4908,7 +5023,7 @@ import {
4908
5023
  decryptJsonWalletData,
4909
5024
  encryptJsonWalletData
4910
5025
  } from "@fuel-ts/crypto";
4911
- import { ErrorCode as ErrorCode15, FuelError as FuelError15 } from "@fuel-ts/errors";
5026
+ import { ErrorCode as ErrorCode16, FuelError as FuelError16 } from "@fuel-ts/errors";
4912
5027
  import { hexlify as hexlify14 } from "@fuel-ts/utils";
4913
5028
  import { v4 as uuidv4 } from "uuid";
4914
5029
  var DEFAULT_KDF_PARAMS_LOG_N = 13;
@@ -4986,8 +5101,8 @@ async function decryptKeystoreWallet(jsonWallet, password) {
4986
5101
  const macHashUint8Array = keccak256(data);
4987
5102
  const macHash = stringFromBuffer(macHashUint8Array, "hex");
4988
5103
  if (mac !== macHash) {
4989
- throw new FuelError15(
4990
- ErrorCode15.INVALID_PASSWORD,
5104
+ throw new FuelError16(
5105
+ ErrorCode16.INVALID_PASSWORD,
4991
5106
  "Failed to decrypt the keystore wallet, the provided password is incorrect."
4992
5107
  );
4993
5108
  }
@@ -5109,15 +5224,15 @@ var BaseWalletUnlocked = class extends Account {
5109
5224
  __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
5110
5225
 
5111
5226
  // src/hdwallet/hdwallet.ts
5112
- import { ErrorCode as ErrorCode18, FuelError as FuelError18 } from "@fuel-ts/errors";
5227
+ import { ErrorCode as ErrorCode19, FuelError as FuelError19 } from "@fuel-ts/errors";
5113
5228
  import { sha256 as sha2564 } from "@fuel-ts/hasher";
5114
- import { bn as bn17, toBytes as toBytes2, toHex } from "@fuel-ts/math";
5229
+ import { bn as bn18, toBytes as toBytes2, toHex } from "@fuel-ts/math";
5115
5230
  import { arrayify as arrayify18, hexlify as hexlify17, concat as concat5 } from "@fuel-ts/utils";
5116
5231
  import { toBeHex, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58, computeHmac as computeHmac2, ripemd160 } from "ethers";
5117
5232
 
5118
5233
  // src/mnemonic/mnemonic.ts
5119
5234
  import { randomBytes as randomBytes3 } from "@fuel-ts/crypto";
5120
- import { ErrorCode as ErrorCode17, FuelError as FuelError17 } from "@fuel-ts/errors";
5235
+ import { ErrorCode as ErrorCode18, FuelError as FuelError18 } from "@fuel-ts/errors";
5121
5236
  import { sha256 as sha2563 } from "@fuel-ts/hasher";
5122
5237
  import { arrayify as arrayify17, hexlify as hexlify16, concat as concat4 } from "@fuel-ts/utils";
5123
5238
  import { dataSlice, pbkdf2, computeHmac, encodeBase58 } from "ethers";
@@ -7175,7 +7290,7 @@ var english = [
7175
7290
  ];
7176
7291
 
7177
7292
  // src/mnemonic/utils.ts
7178
- import { ErrorCode as ErrorCode16, FuelError as FuelError16 } from "@fuel-ts/errors";
7293
+ import { ErrorCode as ErrorCode17, FuelError as FuelError17 } from "@fuel-ts/errors";
7179
7294
  import { sha256 as sha2562 } from "@fuel-ts/hasher";
7180
7295
  import { arrayify as arrayify16 } from "@fuel-ts/utils";
7181
7296
  function toUtf8Bytes(stri) {
@@ -7192,8 +7307,8 @@ function toUtf8Bytes(stri) {
7192
7307
  i += 1;
7193
7308
  const c2 = str.charCodeAt(i);
7194
7309
  if (i >= str.length || (c2 & 64512) !== 56320) {
7195
- throw new FuelError16(
7196
- ErrorCode16.INVALID_INPUT_PARAMETERS,
7310
+ throw new FuelError17(
7311
+ ErrorCode17.INVALID_INPUT_PARAMETERS,
7197
7312
  "Invalid UTF-8 in the input string."
7198
7313
  );
7199
7314
  }
@@ -7256,8 +7371,8 @@ function mnemonicWordsToEntropy(words, wordlist) {
7256
7371
  for (let i = 0; i < words.length; i += 1) {
7257
7372
  const index = wordlist.indexOf(words[i].normalize("NFKD"));
7258
7373
  if (index === -1) {
7259
- throw new FuelError16(
7260
- ErrorCode16.INVALID_MNEMONIC,
7374
+ throw new FuelError17(
7375
+ ErrorCode17.INVALID_MNEMONIC,
7261
7376
  `Invalid mnemonic: the word '${words[i]}' is not found in the provided wordlist.`
7262
7377
  );
7263
7378
  }
@@ -7273,8 +7388,8 @@ function mnemonicWordsToEntropy(words, wordlist) {
7273
7388
  const checksumMask = getUpperMask(checksumBits);
7274
7389
  const checksum = arrayify16(sha2562(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
7275
7390
  if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
7276
- throw new FuelError16(
7277
- ErrorCode16.INVALID_CHECKSUM,
7391
+ throw new FuelError17(
7392
+ ErrorCode17.INVALID_CHECKSUM,
7278
7393
  "Checksum validation failed for the provided mnemonic."
7279
7394
  );
7280
7395
  }
@@ -7288,16 +7403,16 @@ var TestnetPRV = "0x04358394";
7288
7403
  var MNEMONIC_SIZES = [12, 15, 18, 21, 24];
7289
7404
  function assertWordList(wordlist) {
7290
7405
  if (wordlist.length !== 2048) {
7291
- throw new FuelError17(
7292
- ErrorCode17.INVALID_WORD_LIST,
7406
+ throw new FuelError18(
7407
+ ErrorCode18.INVALID_WORD_LIST,
7293
7408
  `Expected word list length of 2048, but got ${wordlist.length}.`
7294
7409
  );
7295
7410
  }
7296
7411
  }
7297
7412
  function assertEntropy(entropy) {
7298
7413
  if (entropy.length % 4 !== 0 || entropy.length < 16 || entropy.length > 32) {
7299
- throw new FuelError17(
7300
- ErrorCode17.INVALID_ENTROPY,
7414
+ throw new FuelError18(
7415
+ ErrorCode18.INVALID_ENTROPY,
7301
7416
  `Entropy should be between 16 and 32 bytes and a multiple of 4, but got ${entropy.length} bytes.`
7302
7417
  );
7303
7418
  }
@@ -7307,7 +7422,7 @@ function assertMnemonic(words) {
7307
7422
  const errorMsg = `Invalid mnemonic size. Expected one of [${MNEMONIC_SIZES.join(
7308
7423
  ", "
7309
7424
  )}] words, but got ${words.length}.`;
7310
- throw new FuelError17(ErrorCode17.INVALID_MNEMONIC, errorMsg);
7425
+ throw new FuelError18(ErrorCode18.INVALID_MNEMONIC, errorMsg);
7311
7426
  }
7312
7427
  }
7313
7428
  var Mnemonic = class {
@@ -7425,8 +7540,8 @@ var Mnemonic = class {
7425
7540
  static masterKeysFromSeed(seed) {
7426
7541
  const seedArray = arrayify17(seed);
7427
7542
  if (seedArray.length < 16 || seedArray.length > 64) {
7428
- throw new FuelError17(
7429
- ErrorCode17.INVALID_SEED,
7543
+ throw new FuelError18(
7544
+ ErrorCode18.INVALID_SEED,
7430
7545
  `Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
7431
7546
  );
7432
7547
  }
@@ -7503,7 +7618,7 @@ function isValidExtendedKey(extendedKey) {
7503
7618
  function parsePath(path2, depth = 0) {
7504
7619
  const components = path2.split("/");
7505
7620
  if (components.length === 0 || components[0] === "m" && depth !== 0) {
7506
- throw new FuelError18(ErrorCode18.HD_WALLET_ERROR, `invalid path - ${path2}`);
7621
+ throw new FuelError19(ErrorCode19.HD_WALLET_ERROR, `invalid path - ${path2}`);
7507
7622
  }
7508
7623
  if (components[0] === "m") {
7509
7624
  components.shift();
@@ -7532,8 +7647,8 @@ var HDWallet = class {
7532
7647
  this.privateKey = hexlify17(config.privateKey);
7533
7648
  } else {
7534
7649
  if (!config.publicKey) {
7535
- throw new FuelError18(
7536
- ErrorCode18.HD_WALLET_ERROR,
7650
+ throw new FuelError19(
7651
+ ErrorCode19.HD_WALLET_ERROR,
7537
7652
  "Both public and private Key cannot be missing. At least one should be provided."
7538
7653
  );
7539
7654
  }
@@ -7562,8 +7677,8 @@ var HDWallet = class {
7562
7677
  const data = new Uint8Array(37);
7563
7678
  if (index & HARDENED_INDEX) {
7564
7679
  if (!privateKey) {
7565
- throw new FuelError18(
7566
- ErrorCode18.HD_WALLET_ERROR,
7680
+ throw new FuelError19(
7681
+ ErrorCode19.HD_WALLET_ERROR,
7567
7682
  "Cannot derive a hardened index without a private Key."
7568
7683
  );
7569
7684
  }
@@ -7577,7 +7692,7 @@ var HDWallet = class {
7577
7692
  const IR = bytes.slice(32);
7578
7693
  if (privateKey) {
7579
7694
  const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
7580
- const ki = bn17(IL).add(privateKey).mod(N).toBytes(32);
7695
+ const ki = bn18(IL).add(privateKey).mod(N).toBytes(32);
7581
7696
  return new HDWallet({
7582
7697
  privateKey: ki,
7583
7698
  chainCode: IR,
@@ -7615,8 +7730,8 @@ var HDWallet = class {
7615
7730
  */
7616
7731
  toExtendedKey(isPublic = false, testnet = false) {
7617
7732
  if (this.depth >= 256) {
7618
- throw new FuelError18(
7619
- ErrorCode18.HD_WALLET_ERROR,
7733
+ throw new FuelError19(
7734
+ ErrorCode19.HD_WALLET_ERROR,
7620
7735
  `Exceeded max depth of 255. Current depth: ${this.depth}.`
7621
7736
  );
7622
7737
  }
@@ -7647,10 +7762,10 @@ var HDWallet = class {
7647
7762
  const bytes = arrayify18(decoded);
7648
7763
  const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
7649
7764
  if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
7650
- throw new FuelError18(ErrorCode18.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
7765
+ throw new FuelError19(ErrorCode19.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
7651
7766
  }
7652
7767
  if (!validChecksum) {
7653
- throw new FuelError18(ErrorCode18.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
7768
+ throw new FuelError19(ErrorCode19.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
7654
7769
  }
7655
7770
  const depth = bytes[4];
7656
7771
  const parentFingerprint = hexlify17(bytes.slice(5, 9));
@@ -7658,14 +7773,14 @@ var HDWallet = class {
7658
7773
  const chainCode = hexlify17(bytes.slice(13, 45));
7659
7774
  const key = bytes.slice(45, 78);
7660
7775
  if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
7661
- throw new FuelError18(
7662
- ErrorCode18.HD_WALLET_ERROR,
7776
+ throw new FuelError19(
7777
+ ErrorCode19.HD_WALLET_ERROR,
7663
7778
  "Inconsistency detected: Depth is zero but fingerprint/index is non-zero."
7664
7779
  );
7665
7780
  }
7666
7781
  if (isPublicExtendedKey(bytes)) {
7667
7782
  if (key[0] !== 3) {
7668
- throw new FuelError18(ErrorCode18.HD_WALLET_ERROR, "Invalid public extended key.");
7783
+ throw new FuelError19(ErrorCode19.HD_WALLET_ERROR, "Invalid public extended key.");
7669
7784
  }
7670
7785
  return new HDWallet({
7671
7786
  publicKey: key,
@@ -7676,7 +7791,7 @@ var HDWallet = class {
7676
7791
  });
7677
7792
  }
7678
7793
  if (key[0] !== 0) {
7679
- throw new FuelError18(ErrorCode18.HD_WALLET_ERROR, "Invalid private extended key.");
7794
+ throw new FuelError19(ErrorCode19.HD_WALLET_ERROR, "Invalid private extended key.");
7680
7795
  }
7681
7796
  return new HDWallet({
7682
7797
  privateKey: key.slice(1),