@fuel-ts/account 0.0.0-rc-1832-20240402201930 → 0.0.0-rc-1895-20240403004459

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,86 @@ 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
+ const reason = status.reason;
1514
+ if (PANIC_REASONS.includes(status.reason)) {
1515
+ errorMessage = `${errorMessage}
1516
+
1517
+ You can read more about this error at:
1518
+
1519
+ ${PANIC_DOC_URL}#variant.${status.reason}`;
1520
+ }
1521
+ return { errorMessage, reason };
1522
+ };
1523
+ var stringify = (obj) => JSON.stringify(obj, null, 2);
1524
+ var assembleRevertError = (receipts, logs) => {
1525
+ let errorMessage = "The transaction reverted with an unknown reason.";
1526
+ const revertReceipt = receipts.find(({ type }) => type === ReceiptType3.Revert);
1527
+ let reason = "";
1528
+ if (revertReceipt) {
1529
+ const reasonHex = bn6(revertReceipt.val).toHex();
1530
+ switch (reasonHex) {
1531
+ case FAILED_REQUIRE_SIGNAL: {
1532
+ reason = "require";
1533
+ errorMessage = `The transaction reverted because a "require" statement has thrown ${logs.length ? stringify(logs[0]) : "an error."}.`;
1534
+ break;
1535
+ }
1536
+ case FAILED_ASSERT_EQ_SIGNAL: {
1537
+ const sufix = logs.length >= 2 ? ` comparing ${stringify(logs[1])} and ${stringify(logs[0])}.` : ".";
1538
+ reason = "assert_eq";
1539
+ errorMessage = `The transaction reverted because of an "assert_eq" statement${sufix}`;
1540
+ break;
1541
+ }
1542
+ case FAILED_ASSERT_NE_SIGNAL: {
1543
+ const sufix = logs.length >= 2 ? ` comparing ${stringify(logs[1])} and ${stringify(logs[0])}.` : ".";
1544
+ reason = "assert_ne";
1545
+ errorMessage = `The transaction reverted because of an "assert_ne" statement${sufix}`;
1546
+ break;
1547
+ }
1548
+ case FAILED_ASSERT_SIGNAL:
1549
+ reason = "assert";
1550
+ errorMessage = `The transaction reverted because an "assert" statement failed to evaluate to true.`;
1551
+ break;
1552
+ case FAILED_TRANSFER_TO_ADDRESS_SIGNAL2:
1553
+ reason = "MissingOutputChange";
1554
+ errorMessage = `The transaction reverted because it's missing an "OutputChange".`;
1555
+ break;
1556
+ default:
1557
+ reason = "unknown";
1558
+ errorMessage = `The transaction reverted with an unknown reason: ${revertReceipt.val}`;
1559
+ }
1560
+ }
1561
+ return { errorMessage, reason };
1562
+ };
1563
+ var extractTxError = (params) => {
1564
+ const { receipts, status, logs } = params;
1565
+ const isPanic = receipts.some(({ type }) => type === ReceiptType3.Panic);
1566
+ const isRevert = receipts.some(({ type }) => type === ReceiptType3.Revert);
1567
+ const { errorMessage, reason } = status?.type === "FailureStatus" && isPanic ? assemblePanicError(status) : assembleRevertError(receipts, logs);
1568
+ const metadata = {
1569
+ logs,
1570
+ receipts,
1571
+ panic: isPanic,
1572
+ revert: isRevert,
1573
+ reason
1574
+ };
1575
+ return new FuelError7(ErrorCode7.SCRIPT_REVERTED, errorMessage, metadata);
1576
+ };
1577
+
1498
1578
  // src/providers/transaction-request/errors.ts
1499
1579
  var NoWitnessAtIndexError = class extends Error {
1500
1580
  constructor(index) {
@@ -1545,10 +1625,10 @@ var BaseTransactionRequest = class {
1545
1625
  outputs,
1546
1626
  witnesses
1547
1627
  } = {}) {
1548
- this.gasPrice = bn6(gasPrice);
1628
+ this.gasPrice = bn7(gasPrice);
1549
1629
  this.maturity = maturity ?? 0;
1550
- this.witnessLimit = witnessLimit ? bn6(witnessLimit) : void 0;
1551
- this.maxFee = maxFee ? bn6(maxFee) : void 0;
1630
+ this.witnessLimit = witnessLimit ? bn7(witnessLimit) : void 0;
1631
+ this.maxFee = maxFee ? bn7(maxFee) : void 0;
1552
1632
  this.inputs = inputs ?? [];
1553
1633
  this.outputs = outputs ?? [];
1554
1634
  this.witnesses = witnesses ?? [];
@@ -1978,13 +2058,13 @@ var BaseTransactionRequest = class {
1978
2058
  assetId,
1979
2059
  owner: resourcesOwner || Address.fromRandom(),
1980
2060
  maturity: 0,
1981
- blockCreated: bn6(1),
1982
- txCreatedIdx: bn6(1)
2061
+ blockCreated: bn7(1),
2062
+ txCreatedIdx: bn7(1)
1983
2063
  }
1984
2064
  ]);
1985
2065
  }
1986
2066
  };
1987
- updateAssetInput(BaseAssetId2, bn6(1e11));
2067
+ updateAssetInput(BaseAssetId2, bn7(1e11));
1988
2068
  quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
1989
2069
  }
1990
2070
  /**
@@ -1995,7 +2075,7 @@ var BaseTransactionRequest = class {
1995
2075
  */
1996
2076
  getCoinOutputsQuantities() {
1997
2077
  const coinsQuantities = this.getCoinOutputs().map(({ amount, assetId }) => ({
1998
- amount: bn6(amount),
2078
+ amount: bn7(amount),
1999
2079
  assetId: assetId.toString()
2000
2080
  }));
2001
2081
  return coinsQuantities;
@@ -2024,7 +2104,7 @@ var BaseTransactionRequest = class {
2024
2104
  default:
2025
2105
  return;
2026
2106
  }
2027
- if (correspondingInput && "predicateGasUsed" in correspondingInput && bn6(correspondingInput.predicateGasUsed).gt(0)) {
2107
+ if (correspondingInput && "predicateGasUsed" in correspondingInput && bn7(correspondingInput.predicateGasUsed).gt(0)) {
2028
2108
  i.predicate = correspondingInput.predicate;
2029
2109
  i.predicateData = correspondingInput.predicateData;
2030
2110
  i.predicateGasUsed = correspondingInput.predicateGasUsed;
@@ -2035,14 +2115,14 @@ var BaseTransactionRequest = class {
2035
2115
 
2036
2116
  // src/providers/transaction-request/create-transaction-request.ts
2037
2117
  import { ZeroBytes32 as ZeroBytes326 } from "@fuel-ts/address/configs";
2038
- import { bn as bn8 } from "@fuel-ts/math";
2118
+ import { bn as bn9 } from "@fuel-ts/math";
2039
2119
  import { TransactionType as TransactionType3, OutputType as OutputType4 } from "@fuel-ts/transactions";
2040
2120
  import { arrayify as arrayify6, hexlify as hexlify9 } from "@fuel-ts/utils";
2041
2121
 
2042
2122
  // src/providers/transaction-request/hash-transaction.ts
2043
2123
  import { ZeroBytes32 as ZeroBytes325 } from "@fuel-ts/address/configs";
2044
2124
  import { uint64ToBytesBE, sha256 } from "@fuel-ts/hasher";
2045
- import { bn as bn7 } from "@fuel-ts/math";
2125
+ import { bn as bn8 } from "@fuel-ts/math";
2046
2126
  import { TransactionType as TransactionType2, InputType as InputType3, OutputType as OutputType3, TransactionCoder as TransactionCoder2 } from "@fuel-ts/transactions";
2047
2127
  import { concat as concat2 } from "@fuel-ts/utils";
2048
2128
  import { clone as clone2 } from "ramda";
@@ -2059,11 +2139,11 @@ function hashTransaction(transactionRequest, chainId) {
2059
2139
  blockHeight: 0,
2060
2140
  txIndex: 0
2061
2141
  };
2062
- inputClone.predicateGasUsed = bn7(0);
2142
+ inputClone.predicateGasUsed = bn8(0);
2063
2143
  return inputClone;
2064
2144
  }
2065
2145
  case InputType3.Message: {
2066
- inputClone.predicateGasUsed = bn7(0);
2146
+ inputClone.predicateGasUsed = bn8(0);
2067
2147
  return inputClone;
2068
2148
  }
2069
2149
  case InputType3.Contract: {
@@ -2090,12 +2170,12 @@ function hashTransaction(transactionRequest, chainId) {
2090
2170
  return outputClone;
2091
2171
  }
2092
2172
  case OutputType3.Change: {
2093
- outputClone.amount = bn7(0);
2173
+ outputClone.amount = bn8(0);
2094
2174
  return outputClone;
2095
2175
  }
2096
2176
  case OutputType3.Variable: {
2097
2177
  outputClone.to = ZeroBytes325;
2098
- outputClone.amount = bn7(0);
2178
+ outputClone.amount = bn8(0);
2099
2179
  outputClone.assetId = ZeroBytes325;
2100
2180
  return outputClone;
2101
2181
  }
@@ -2219,7 +2299,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2219
2299
  }
2220
2300
  metadataGas(gasCosts) {
2221
2301
  return calculateMetadataGasForTxCreate({
2222
- contractBytesSize: bn8(arrayify6(this.witnesses[this.bytecodeWitnessIndex] || "0x").length),
2302
+ contractBytesSize: bn9(arrayify6(this.witnesses[this.bytecodeWitnessIndex] || "0x").length),
2223
2303
  gasCosts,
2224
2304
  stateRootSize: this.storageSlots.length,
2225
2305
  txBytesSize: this.byteSize()
@@ -2231,7 +2311,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2231
2311
  import { Interface } from "@fuel-ts/abi-coder";
2232
2312
  import { addressify as addressify2 } from "@fuel-ts/address";
2233
2313
  import { ZeroBytes32 as ZeroBytes327 } from "@fuel-ts/address/configs";
2234
- import { bn as bn9 } from "@fuel-ts/math";
2314
+ import { bn as bn10 } from "@fuel-ts/math";
2235
2315
  import { InputType as InputType4, OutputType as OutputType5, TransactionType as TransactionType4 } from "@fuel-ts/transactions";
2236
2316
  import { arrayify as arrayify8, hexlify as hexlify10 } from "@fuel-ts/utils";
2237
2317
 
@@ -2285,7 +2365,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2285
2365
  */
2286
2366
  constructor({ script, scriptData, gasLimit, ...rest } = {}) {
2287
2367
  super(rest);
2288
- this.gasLimit = bn9(gasLimit);
2368
+ this.gasLimit = bn10(gasLimit);
2289
2369
  this.script = arrayify8(script ?? returnZeroScript.bytes);
2290
2370
  this.scriptData = arrayify8(scriptData ?? returnZeroScript.encodeScriptData());
2291
2371
  this.abis = rest.abis;
@@ -2433,7 +2513,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2433
2513
  };
2434
2514
 
2435
2515
  // src/providers/transaction-request/utils.ts
2436
- import { ErrorCode as ErrorCode7, FuelError as FuelError7 } from "@fuel-ts/errors";
2516
+ import { ErrorCode as ErrorCode8, FuelError as FuelError8 } from "@fuel-ts/errors";
2437
2517
  import { TransactionType as TransactionType5 } from "@fuel-ts/transactions";
2438
2518
  var transactionRequestify = (obj) => {
2439
2519
  if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest) {
@@ -2448,14 +2528,14 @@ var transactionRequestify = (obj) => {
2448
2528
  return CreateTransactionRequest.from(obj);
2449
2529
  }
2450
2530
  default: {
2451
- throw new FuelError7(ErrorCode7.INVALID_TRANSACTION_TYPE, `Invalid transaction type: ${type}.`);
2531
+ throw new FuelError8(ErrorCode8.INVALID_TRANSACTION_TYPE, `Invalid transaction type: ${type}.`);
2452
2532
  }
2453
2533
  }
2454
2534
  };
2455
2535
 
2456
2536
  // src/providers/transaction-response/transaction-response.ts
2457
- import { ErrorCode as ErrorCode11, FuelError as FuelError11 } from "@fuel-ts/errors";
2458
- import { bn as bn13 } from "@fuel-ts/math";
2537
+ import { ErrorCode as ErrorCode12, FuelError as FuelError12 } from "@fuel-ts/errors";
2538
+ import { bn as bn14 } from "@fuel-ts/math";
2459
2539
  import { TransactionCoder as TransactionCoder4 } from "@fuel-ts/transactions";
2460
2540
  import { arrayify as arrayify10 } from "@fuel-ts/utils";
2461
2541
 
@@ -2463,7 +2543,7 @@ import { arrayify as arrayify10 } from "@fuel-ts/utils";
2463
2543
  import { DateTime, hexlify as hexlify11 } from "@fuel-ts/utils";
2464
2544
 
2465
2545
  // src/providers/transaction-summary/calculate-transaction-fee.ts
2466
- import { bn as bn10 } from "@fuel-ts/math";
2546
+ import { bn as bn11 } from "@fuel-ts/math";
2467
2547
  import { PolicyType as PolicyType2, TransactionCoder as TransactionCoder3, TransactionType as TransactionType6 } from "@fuel-ts/transactions";
2468
2548
  import { arrayify as arrayify9 } from "@fuel-ts/utils";
2469
2549
  var calculateTransactionFee = (params) => {
@@ -2472,24 +2552,24 @@ var calculateTransactionFee = (params) => {
2472
2552
  rawPayload,
2473
2553
  consensusParameters: { gasCosts, feeParams }
2474
2554
  } = params;
2475
- const gasPerByte = bn10(feeParams.gasPerByte);
2476
- const gasPriceFactor = bn10(feeParams.gasPriceFactor);
2555
+ const gasPerByte = bn11(feeParams.gasPerByte);
2556
+ const gasPriceFactor = bn11(feeParams.gasPriceFactor);
2477
2557
  const transactionBytes = arrayify9(rawPayload);
2478
2558
  const [transaction] = new TransactionCoder3().decode(transactionBytes, 0);
2479
2559
  if (transaction.type === TransactionType6.Mint) {
2480
2560
  return {
2481
- fee: bn10(0),
2482
- minFee: bn10(0),
2483
- maxFee: bn10(0),
2484
- feeFromGasUsed: bn10(0)
2561
+ fee: bn11(0),
2562
+ minFee: bn11(0),
2563
+ maxFee: bn11(0),
2564
+ feeFromGasUsed: bn11(0)
2485
2565
  };
2486
2566
  }
2487
2567
  const { type, witnesses, inputs, policies } = transaction;
2488
- let metadataGas = bn10(0);
2489
- let gasLimit = bn10(0);
2568
+ let metadataGas = bn11(0);
2569
+ let gasLimit = bn11(0);
2490
2570
  if (type === TransactionType6.Create) {
2491
2571
  const { bytecodeWitnessIndex, storageSlots } = transaction;
2492
- const contractBytesSize = bn10(arrayify9(witnesses[bytecodeWitnessIndex].data).length);
2572
+ const contractBytesSize = bn11(arrayify9(witnesses[bytecodeWitnessIndex].data).length);
2493
2573
  metadataGas = calculateMetadataGasForTxCreate({
2494
2574
  contractBytesSize,
2495
2575
  gasCosts,
@@ -2508,12 +2588,12 @@ var calculateTransactionFee = (params) => {
2508
2588
  }
2509
2589
  const minGas = getMinGas({
2510
2590
  gasCosts,
2511
- gasPerByte: bn10(gasPerByte),
2591
+ gasPerByte: bn11(gasPerByte),
2512
2592
  inputs,
2513
2593
  metadataGas,
2514
2594
  txBytesSize: transactionBytes.length
2515
2595
  });
2516
- const gasPrice = bn10(policies.find((policy) => policy.type === PolicyType2.GasPrice)?.data);
2596
+ const gasPrice = bn11(policies.find((policy) => policy.type === PolicyType2.GasPrice)?.data);
2517
2597
  const witnessLimit = policies.find((policy) => policy.type === PolicyType2.WitnessLimit)?.data;
2518
2598
  const witnessesLength = witnesses.reduce((acc, wit) => acc + wit.dataLength, 0);
2519
2599
  const maxGas = getMaxGas({
@@ -2537,13 +2617,13 @@ var calculateTransactionFee = (params) => {
2537
2617
 
2538
2618
  // src/providers/transaction-summary/operations.ts
2539
2619
  import { ZeroBytes32 as ZeroBytes328 } from "@fuel-ts/address/configs";
2540
- import { ErrorCode as ErrorCode9, FuelError as FuelError9 } from "@fuel-ts/errors";
2541
- import { bn as bn12 } from "@fuel-ts/math";
2542
- import { ReceiptType as ReceiptType3, TransactionType as TransactionType7 } from "@fuel-ts/transactions";
2620
+ import { ErrorCode as ErrorCode10, FuelError as FuelError10 } from "@fuel-ts/errors";
2621
+ import { bn as bn13 } from "@fuel-ts/math";
2622
+ import { ReceiptType as ReceiptType4, TransactionType as TransactionType7 } from "@fuel-ts/transactions";
2543
2623
 
2544
2624
  // src/providers/transaction-summary/call.ts
2545
2625
  import { Interface as Interface2, calculateVmTxMemory } from "@fuel-ts/abi-coder";
2546
- import { bn as bn11 } from "@fuel-ts/math";
2626
+ import { bn as bn12 } from "@fuel-ts/math";
2547
2627
  var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
2548
2628
  const abiInterface = new Interface2(abi);
2549
2629
  const callFunctionSelector = receipt.param1.toHex(8);
@@ -2552,7 +2632,7 @@ var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
2552
2632
  let encodedArgs;
2553
2633
  if (functionFragment.isInputDataPointer) {
2554
2634
  if (rawPayload) {
2555
- const argsOffset = bn11(receipt.param2).sub(calculateVmTxMemory({ maxInputs: maxInputs.toNumber() })).toNumber();
2635
+ const argsOffset = bn12(receipt.param2).sub(calculateVmTxMemory({ maxInputs: maxInputs.toNumber() })).toNumber();
2556
2636
  encodedArgs = `0x${rawPayload.slice(2).slice(argsOffset * 2)}`;
2557
2637
  }
2558
2638
  } else {
@@ -2586,7 +2666,7 @@ var getFunctionCall = ({ abi, receipt, rawPayload, maxInputs }) => {
2586
2666
  };
2587
2667
 
2588
2668
  // src/providers/transaction-summary/input.ts
2589
- import { ErrorCode as ErrorCode8, FuelError as FuelError8 } from "@fuel-ts/errors";
2669
+ import { ErrorCode as ErrorCode9, FuelError as FuelError9 } from "@fuel-ts/errors";
2590
2670
  import { InputType as InputType5 } from "@fuel-ts/transactions";
2591
2671
  function getInputsByTypes(inputs, types) {
2592
2672
  return inputs.filter((i) => types.includes(i.type));
@@ -2624,8 +2704,8 @@ function getInputContractFromIndex(inputs, inputIndex) {
2624
2704
  return void 0;
2625
2705
  }
2626
2706
  if (contractInput.type !== InputType5.Contract) {
2627
- throw new FuelError8(
2628
- ErrorCode8.INVALID_TRANSACTION_INPUT,
2707
+ throw new FuelError9(
2708
+ ErrorCode9.INVALID_TRANSACTION_INPUT,
2629
2709
  `Contract input should be of type 'contract'.`
2630
2710
  );
2631
2711
  }
@@ -2672,8 +2752,8 @@ function getTransactionTypeName(transactionType) {
2672
2752
  case TransactionType7.Script:
2673
2753
  return "Script" /* Script */;
2674
2754
  default:
2675
- throw new FuelError9(
2676
- ErrorCode9.INVALID_TRANSACTION_TYPE,
2755
+ throw new FuelError10(
2756
+ ErrorCode10.INVALID_TRANSACTION_TYPE,
2677
2757
  `Invalid transaction type: ${transactionType}.`
2678
2758
  );
2679
2759
  }
@@ -2692,10 +2772,10 @@ function isTypeScript(transactionType) {
2692
2772
  return isType(transactionType, "Script" /* Script */);
2693
2773
  }
2694
2774
  function getReceiptsCall(receipts) {
2695
- return getReceiptsByType(receipts, ReceiptType3.Call);
2775
+ return getReceiptsByType(receipts, ReceiptType4.Call);
2696
2776
  }
2697
2777
  function getReceiptsMessageOut(receipts) {
2698
- return getReceiptsByType(receipts, ReceiptType3.MessageOut);
2778
+ return getReceiptsByType(receipts, ReceiptType4.MessageOut);
2699
2779
  }
2700
2780
  var mergeAssets = (op1, op2) => {
2701
2781
  const assets1 = op1.assetsSent || [];
@@ -2708,7 +2788,7 @@ var mergeAssets = (op1, op2) => {
2708
2788
  if (!matchingAsset) {
2709
2789
  return asset1;
2710
2790
  }
2711
- const mergedAmount = bn12(asset1.amount).add(matchingAsset.amount);
2791
+ const mergedAmount = bn13(asset1.amount).add(matchingAsset.amount);
2712
2792
  return { ...asset1, amount: mergedAmount };
2713
2793
  });
2714
2794
  return mergedAssets.concat(filteredAssets);
@@ -2891,11 +2971,11 @@ function getTransferOperations({
2891
2971
  });
2892
2972
  const transferReceipts = getReceiptsByType(
2893
2973
  receipts,
2894
- ReceiptType3.Transfer
2974
+ ReceiptType4.Transfer
2895
2975
  );
2896
2976
  const transferOutReceipts = getReceiptsByType(
2897
2977
  receipts,
2898
- ReceiptType3.TransferOut
2978
+ ReceiptType4.TransferOut
2899
2979
  );
2900
2980
  [...transferReceipts, ...transferOutReceipts].forEach((receipt) => {
2901
2981
  const operation = extractTransferOperationFromReceipt(receipt, contractInputs, changeOutputs);
@@ -2980,17 +3060,17 @@ function getOperations({
2980
3060
  }
2981
3061
 
2982
3062
  // src/providers/transaction-summary/receipt.ts
2983
- import { ReceiptType as ReceiptType4 } from "@fuel-ts/transactions";
3063
+ import { ReceiptType as ReceiptType5 } from "@fuel-ts/transactions";
2984
3064
  var processGqlReceipt = (gqlReceipt) => {
2985
3065
  const receipt = assembleReceiptByType(gqlReceipt);
2986
3066
  switch (receipt.type) {
2987
- case ReceiptType4.ReturnData: {
3067
+ case ReceiptType5.ReturnData: {
2988
3068
  return {
2989
3069
  ...receipt,
2990
3070
  data: gqlReceipt.data || "0x"
2991
3071
  };
2992
3072
  }
2993
- case ReceiptType4.LogData: {
3073
+ case ReceiptType5.LogData: {
2994
3074
  return {
2995
3075
  ...receipt,
2996
3076
  data: gqlReceipt.data || "0x"
@@ -3003,7 +3083,7 @@ var processGqlReceipt = (gqlReceipt) => {
3003
3083
  var extractMintedAssetsFromReceipts = (receipts) => {
3004
3084
  const mintedAssets = [];
3005
3085
  receipts.forEach((receipt) => {
3006
- if (receipt.type === ReceiptType4.Mint) {
3086
+ if (receipt.type === ReceiptType5.Mint) {
3007
3087
  mintedAssets.push({
3008
3088
  subId: receipt.subId,
3009
3089
  contractId: receipt.contractId,
@@ -3017,7 +3097,7 @@ var extractMintedAssetsFromReceipts = (receipts) => {
3017
3097
  var extractBurnedAssetsFromReceipts = (receipts) => {
3018
3098
  const burnedAssets = [];
3019
3099
  receipts.forEach((receipt) => {
3020
- if (receipt.type === ReceiptType4.Burn) {
3100
+ if (receipt.type === ReceiptType5.Burn) {
3021
3101
  burnedAssets.push({
3022
3102
  subId: receipt.subId,
3023
3103
  contractId: receipt.contractId,
@@ -3030,7 +3110,7 @@ var extractBurnedAssetsFromReceipts = (receipts) => {
3030
3110
  };
3031
3111
 
3032
3112
  // src/providers/transaction-summary/status.ts
3033
- import { ErrorCode as ErrorCode10, FuelError as FuelError10 } from "@fuel-ts/errors";
3113
+ import { ErrorCode as ErrorCode11, FuelError as FuelError11 } from "@fuel-ts/errors";
3034
3114
  var getTransactionStatusName = (gqlStatus) => {
3035
3115
  switch (gqlStatus) {
3036
3116
  case "FailureStatus":
@@ -3042,8 +3122,8 @@ var getTransactionStatusName = (gqlStatus) => {
3042
3122
  case "SqueezedOutStatus":
3043
3123
  return "squeezedout" /* squeezedout */;
3044
3124
  default:
3045
- throw new FuelError10(
3046
- ErrorCode10.INVALID_TRANSACTION_STATUS,
3125
+ throw new FuelError11(
3126
+ ErrorCode11.INVALID_TRANSACTION_STATUS,
3047
3127
  `Invalid transaction status: ${gqlStatus}.`
3048
3128
  );
3049
3129
  }
@@ -3156,12 +3236,12 @@ function assembleTransactionSummary(params) {
3156
3236
 
3157
3237
  // src/providers/transaction-response/getDecodedLogs.ts
3158
3238
  import { Interface as Interface3, BigNumberCoder } from "@fuel-ts/abi-coder";
3159
- import { ReceiptType as ReceiptType5 } from "@fuel-ts/transactions";
3239
+ import { ReceiptType as ReceiptType6 } from "@fuel-ts/transactions";
3160
3240
  function getDecodedLogs(receipts, mainAbi, externalAbis = {}) {
3161
3241
  return receipts.reduce((logs, receipt) => {
3162
- if (receipt.type === ReceiptType5.LogData || receipt.type === ReceiptType5.Log) {
3242
+ if (receipt.type === ReceiptType6.LogData || receipt.type === ReceiptType6.Log) {
3163
3243
  const interfaceToUse = new Interface3(externalAbis[receipt.id] || mainAbi);
3164
- const data = receipt.type === ReceiptType5.Log ? new BigNumberCoder("u64").encode(receipt.val0) : receipt.data;
3244
+ const data = receipt.type === ReceiptType6.Log ? new BigNumberCoder("u64").encode(receipt.val0) : receipt.data;
3165
3245
  const [decodedLog] = interfaceToUse.decodeLog(data, receipt.val1.toNumber());
3166
3246
  logs.push(decodedLog);
3167
3247
  }
@@ -3176,7 +3256,7 @@ var TransactionResponse = class {
3176
3256
  /** Current provider */
3177
3257
  provider;
3178
3258
  /** Gas used on the transaction */
3179
- gasUsed = bn13(0);
3259
+ gasUsed = bn14(0);
3180
3260
  /** The graphql Transaction with receipts object. */
3181
3261
  gqlTransaction;
3182
3262
  abis;
@@ -3281,8 +3361,8 @@ var TransactionResponse = class {
3281
3361
  });
3282
3362
  for await (const { statusChange } of subscription) {
3283
3363
  if (statusChange.type === "SqueezedOutStatus") {
3284
- throw new FuelError11(
3285
- ErrorCode11.TRANSACTION_SQUEEZED_OUT,
3364
+ throw new FuelError12(
3365
+ ErrorCode12.TRANSACTION_SQUEEZED_OUT,
3286
3366
  `Transaction Squeezed Out with reason: ${statusChange.reason}`
3287
3367
  );
3288
3368
  }
@@ -3304,14 +3384,26 @@ var TransactionResponse = class {
3304
3384
  gqlTransaction: this.gqlTransaction,
3305
3385
  ...transactionSummary
3306
3386
  };
3387
+ let logs = [];
3307
3388
  if (this.abis) {
3308
- const logs = getDecodedLogs(
3389
+ logs = getDecodedLogs(
3309
3390
  transactionSummary.receipts,
3310
3391
  this.abis.main,
3311
3392
  this.abis.otherContractsAbis
3312
3393
  );
3313
3394
  transactionResult.logs = logs;
3314
3395
  }
3396
+ if (transactionResult.isStatusFailure) {
3397
+ const {
3398
+ receipts,
3399
+ gqlTransaction: { status }
3400
+ } = transactionResult;
3401
+ throw extractTxError({
3402
+ receipts,
3403
+ status,
3404
+ logs
3405
+ });
3406
+ }
3315
3407
  return transactionResult;
3316
3408
  }
3317
3409
  /**
@@ -3320,14 +3412,7 @@ var TransactionResponse = class {
3320
3412
  * @param contractsAbiMap - The contracts ABI map.
3321
3413
  */
3322
3414
  async wait(contractsAbiMap) {
3323
- const result = await this.waitForResult(contractsAbiMap);
3324
- if (result.isStatusFailure) {
3325
- throw new FuelError11(
3326
- ErrorCode11.TRANSACTION_FAILED,
3327
- `Transaction failed: ${result.gqlTransaction.status.reason}`
3328
- );
3329
- }
3330
- return result;
3415
+ return this.waitForResult(contractsAbiMap);
3331
3416
  }
3332
3417
  };
3333
3418
 
@@ -3389,29 +3474,29 @@ var processGqlChain = (chain) => {
3389
3474
  const { contractParams, feeParams, predicateParams, scriptParams, txParams, gasCosts } = consensusParameters;
3390
3475
  return {
3391
3476
  name,
3392
- baseChainHeight: bn14(daHeight),
3477
+ baseChainHeight: bn15(daHeight),
3393
3478
  consensusParameters: {
3394
- contractMaxSize: bn14(contractParams.contractMaxSize),
3395
- maxInputs: bn14(txParams.maxInputs),
3396
- maxOutputs: bn14(txParams.maxOutputs),
3397
- maxWitnesses: bn14(txParams.maxWitnesses),
3398
- maxGasPerTx: bn14(txParams.maxGasPerTx),
3399
- maxScriptLength: bn14(scriptParams.maxScriptLength),
3400
- maxScriptDataLength: bn14(scriptParams.maxScriptDataLength),
3401
- maxStorageSlots: bn14(contractParams.maxStorageSlots),
3402
- maxPredicateLength: bn14(predicateParams.maxPredicateLength),
3403
- maxPredicateDataLength: bn14(predicateParams.maxPredicateDataLength),
3404
- maxGasPerPredicate: bn14(predicateParams.maxGasPerPredicate),
3405
- gasPriceFactor: bn14(feeParams.gasPriceFactor),
3406
- gasPerByte: bn14(feeParams.gasPerByte),
3407
- maxMessageDataLength: bn14(predicateParams.maxMessageDataLength),
3408
- chainId: bn14(consensusParameters.chainId),
3479
+ contractMaxSize: bn15(contractParams.contractMaxSize),
3480
+ maxInputs: bn15(txParams.maxInputs),
3481
+ maxOutputs: bn15(txParams.maxOutputs),
3482
+ maxWitnesses: bn15(txParams.maxWitnesses),
3483
+ maxGasPerTx: bn15(txParams.maxGasPerTx),
3484
+ maxScriptLength: bn15(scriptParams.maxScriptLength),
3485
+ maxScriptDataLength: bn15(scriptParams.maxScriptDataLength),
3486
+ maxStorageSlots: bn15(contractParams.maxStorageSlots),
3487
+ maxPredicateLength: bn15(predicateParams.maxPredicateLength),
3488
+ maxPredicateDataLength: bn15(predicateParams.maxPredicateDataLength),
3489
+ maxGasPerPredicate: bn15(predicateParams.maxGasPerPredicate),
3490
+ gasPriceFactor: bn15(feeParams.gasPriceFactor),
3491
+ gasPerByte: bn15(feeParams.gasPerByte),
3492
+ maxMessageDataLength: bn15(predicateParams.maxMessageDataLength),
3493
+ chainId: bn15(consensusParameters.chainId),
3409
3494
  gasCosts
3410
3495
  },
3411
3496
  gasCosts,
3412
3497
  latestBlock: {
3413
3498
  id: latestBlock.id,
3414
- height: bn14(latestBlock.header.height),
3499
+ height: bn15(latestBlock.header.height),
3415
3500
  time: latestBlock.header.time,
3416
3501
  transactions: latestBlock.transactions.map((i) => ({
3417
3502
  id: i.id
@@ -3481,8 +3566,8 @@ var _Provider = class {
3481
3566
  getChain() {
3482
3567
  const chain = _Provider.chainInfoCache[this.url];
3483
3568
  if (!chain) {
3484
- throw new FuelError12(
3485
- ErrorCode12.CHAIN_INFO_CACHE_EMPTY,
3569
+ throw new FuelError13(
3570
+ ErrorCode13.CHAIN_INFO_CACHE_EMPTY,
3486
3571
  "Chain info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
3487
3572
  );
3488
3573
  }
@@ -3494,8 +3579,8 @@ var _Provider = class {
3494
3579
  getNode() {
3495
3580
  const node = _Provider.nodeInfoCache[this.url];
3496
3581
  if (!node) {
3497
- throw new FuelError12(
3498
- ErrorCode12.NODE_INFO_CACHE_EMPTY,
3582
+ throw new FuelError13(
3583
+ ErrorCode13.NODE_INFO_CACHE_EMPTY,
3499
3584
  "Node info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
3500
3585
  );
3501
3586
  }
@@ -3542,8 +3627,8 @@ var _Provider = class {
3542
3627
  static ensureClientVersionIsSupported(nodeInfo) {
3543
3628
  const { isMajorSupported, isMinorSupported, supportedVersion } = checkFuelCoreVersionCompatibility(nodeInfo.nodeVersion);
3544
3629
  if (!isMajorSupported || !isMinorSupported) {
3545
- throw new FuelError12(
3546
- FuelError12.CODES.UNSUPPORTED_FUEL_CLIENT_VERSION,
3630
+ throw new FuelError13(
3631
+ FuelError13.CODES.UNSUPPORTED_FUEL_CLIENT_VERSION,
3547
3632
  `Fuel client version: ${nodeInfo.nodeVersion}, Supported version: ${supportedVersion}`
3548
3633
  );
3549
3634
  }
@@ -3606,7 +3691,7 @@ var _Provider = class {
3606
3691
  */
3607
3692
  async getBlockNumber() {
3608
3693
  const { chain } = await this.operations.getChain();
3609
- return bn14(chain.latestBlock.header.height, 10);
3694
+ return bn15(chain.latestBlock.header.height, 10);
3610
3695
  }
3611
3696
  /**
3612
3697
  * Returns the chain information.
@@ -3616,9 +3701,9 @@ var _Provider = class {
3616
3701
  async fetchNode() {
3617
3702
  const { nodeInfo } = await this.operations.getNodeInfo();
3618
3703
  const processedNodeInfo = {
3619
- maxDepth: bn14(nodeInfo.maxDepth),
3620
- maxTx: bn14(nodeInfo.maxTx),
3621
- minGasPrice: bn14(nodeInfo.minGasPrice),
3704
+ maxDepth: bn15(nodeInfo.maxDepth),
3705
+ maxTx: bn15(nodeInfo.maxTx),
3706
+ minGasPrice: bn15(nodeInfo.minGasPrice),
3622
3707
  nodeVersion: nodeInfo.nodeVersion,
3623
3708
  utxoValidation: nodeInfo.utxoValidation,
3624
3709
  vmBacktrace: nodeInfo.vmBacktrace,
@@ -3673,8 +3758,8 @@ var _Provider = class {
3673
3758
  const subscription = this.operations.submitAndAwait({ encodedTransaction });
3674
3759
  for await (const { submitAndAwait } of subscription) {
3675
3760
  if (submitAndAwait.type === "SqueezedOutStatus") {
3676
- throw new FuelError12(
3677
- ErrorCode12.TRANSACTION_SQUEEZED_OUT,
3761
+ throw new FuelError13(
3762
+ ErrorCode13.TRANSACTION_SQUEEZED_OUT,
3678
3763
  `Transaction Squeezed Out with reason: ${submitAndAwait.reason}`
3679
3764
  );
3680
3765
  }
@@ -3741,7 +3826,7 @@ var _Provider = class {
3741
3826
  } = response;
3742
3827
  if (inputs) {
3743
3828
  inputs.forEach((input, index) => {
3744
- if ("predicateGasUsed" in input && bn14(input.predicateGasUsed).gt(0)) {
3829
+ if ("predicateGasUsed" in input && bn15(input.predicateGasUsed).gt(0)) {
3745
3830
  transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
3746
3831
  }
3747
3832
  });
@@ -3854,7 +3939,7 @@ var _Provider = class {
3854
3939
  txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
3855
3940
  if (estimatePredicates) {
3856
3941
  if (isScriptTransaction) {
3857
- txRequestClone.gasLimit = bn14(0);
3942
+ txRequestClone.gasLimit = bn15(0);
3858
3943
  }
3859
3944
  if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
3860
3945
  resourcesOwner.populateTransactionPredicateData(txRequestClone);
@@ -3870,8 +3955,8 @@ var _Provider = class {
3870
3955
  let missingContractIds = [];
3871
3956
  let outputVariables = 0;
3872
3957
  if (isScriptTransaction && estimateTxDependencies) {
3873
- txRequestClone.gasPrice = bn14(0);
3874
- txRequestClone.gasLimit = bn14(maxGasPerTx.sub(maxGas).toNumber() * 0.9);
3958
+ txRequestClone.gasPrice = bn15(0);
3959
+ txRequestClone.gasLimit = bn15(maxGasPerTx.sub(maxGas).toNumber() * 0.9);
3875
3960
  const result = await this.estimateTxDependencies(txRequestClone);
3876
3961
  receipts = result.receipts;
3877
3962
  outputVariables = result.outputVariables;
@@ -3933,11 +4018,11 @@ var _Provider = class {
3933
4018
  return coins.map((coin) => ({
3934
4019
  id: coin.utxoId,
3935
4020
  assetId: coin.assetId,
3936
- amount: bn14(coin.amount),
4021
+ amount: bn15(coin.amount),
3937
4022
  owner: Address2.fromAddressOrString(coin.owner),
3938
- maturity: bn14(coin.maturity).toNumber(),
3939
- blockCreated: bn14(coin.blockCreated),
3940
- txCreatedIdx: bn14(coin.txCreatedIdx)
4023
+ maturity: bn15(coin.maturity).toNumber(),
4024
+ blockCreated: bn15(coin.blockCreated),
4025
+ txCreatedIdx: bn15(coin.txCreatedIdx)
3941
4026
  }));
3942
4027
  }
3943
4028
  /**
@@ -3974,9 +4059,9 @@ var _Provider = class {
3974
4059
  switch (coin.__typename) {
3975
4060
  case "MessageCoin":
3976
4061
  return {
3977
- amount: bn14(coin.amount),
4062
+ amount: bn15(coin.amount),
3978
4063
  assetId: coin.assetId,
3979
- daHeight: bn14(coin.daHeight),
4064
+ daHeight: bn15(coin.daHeight),
3980
4065
  sender: Address2.fromAddressOrString(coin.sender),
3981
4066
  recipient: Address2.fromAddressOrString(coin.recipient),
3982
4067
  nonce: coin.nonce
@@ -3984,12 +4069,12 @@ var _Provider = class {
3984
4069
  case "Coin":
3985
4070
  return {
3986
4071
  id: coin.utxoId,
3987
- amount: bn14(coin.amount),
4072
+ amount: bn15(coin.amount),
3988
4073
  assetId: coin.assetId,
3989
4074
  owner: Address2.fromAddressOrString(coin.owner),
3990
- maturity: bn14(coin.maturity).toNumber(),
3991
- blockCreated: bn14(coin.blockCreated),
3992
- txCreatedIdx: bn14(coin.txCreatedIdx)
4075
+ maturity: bn15(coin.maturity).toNumber(),
4076
+ blockCreated: bn15(coin.blockCreated),
4077
+ txCreatedIdx: bn15(coin.txCreatedIdx)
3993
4078
  };
3994
4079
  default:
3995
4080
  return null;
@@ -4006,13 +4091,13 @@ var _Provider = class {
4006
4091
  async getBlock(idOrHeight) {
4007
4092
  let variables;
4008
4093
  if (typeof idOrHeight === "number") {
4009
- variables = { height: bn14(idOrHeight).toString(10) };
4094
+ variables = { height: bn15(idOrHeight).toString(10) };
4010
4095
  } else if (idOrHeight === "latest") {
4011
4096
  variables = { height: (await this.getBlockNumber()).toString(10) };
4012
4097
  } else if (idOrHeight.length === 66) {
4013
4098
  variables = { blockId: idOrHeight };
4014
4099
  } else {
4015
- variables = { blockId: bn14(idOrHeight).toString(10) };
4100
+ variables = { blockId: bn15(idOrHeight).toString(10) };
4016
4101
  }
4017
4102
  const { block } = await this.operations.getBlock(variables);
4018
4103
  if (!block) {
@@ -4020,7 +4105,7 @@ var _Provider = class {
4020
4105
  }
4021
4106
  return {
4022
4107
  id: block.id,
4023
- height: bn14(block.header.height),
4108
+ height: bn15(block.header.height),
4024
4109
  time: block.header.time,
4025
4110
  transactionIds: block.transactions.map((tx) => tx.id)
4026
4111
  };
@@ -4035,7 +4120,7 @@ var _Provider = class {
4035
4120
  const { blocks: fetchedData } = await this.operations.getBlocks(params);
4036
4121
  const blocks = fetchedData.edges.map(({ node: block }) => ({
4037
4122
  id: block.id,
4038
- height: bn14(block.header.height),
4123
+ height: bn15(block.header.height),
4039
4124
  time: block.header.time,
4040
4125
  transactionIds: block.transactions.map((tx) => tx.id)
4041
4126
  }));
@@ -4050,7 +4135,7 @@ var _Provider = class {
4050
4135
  async getBlockWithTransactions(idOrHeight) {
4051
4136
  let variables;
4052
4137
  if (typeof idOrHeight === "number") {
4053
- variables = { blockHeight: bn14(idOrHeight).toString(10) };
4138
+ variables = { blockHeight: bn15(idOrHeight).toString(10) };
4054
4139
  } else if (idOrHeight === "latest") {
4055
4140
  variables = { blockHeight: (await this.getBlockNumber()).toString() };
4056
4141
  } else {
@@ -4062,7 +4147,7 @@ var _Provider = class {
4062
4147
  }
4063
4148
  return {
4064
4149
  id: block.id,
4065
- height: bn14(block.header.height, 10),
4150
+ height: bn15(block.header.height, 10),
4066
4151
  time: block.header.time,
4067
4152
  transactionIds: block.transactions.map((tx) => tx.id),
4068
4153
  transactions: block.transactions.map(
@@ -4111,7 +4196,7 @@ var _Provider = class {
4111
4196
  contract: Address2.fromAddressOrString(contractId).toB256(),
4112
4197
  asset: hexlify12(assetId)
4113
4198
  });
4114
- return bn14(contractBalance.amount, 10);
4199
+ return bn15(contractBalance.amount, 10);
4115
4200
  }
4116
4201
  /**
4117
4202
  * Returns the balance for the given owner for the given asset ID.
@@ -4125,7 +4210,7 @@ var _Provider = class {
4125
4210
  owner: Address2.fromAddressOrString(owner).toB256(),
4126
4211
  assetId: hexlify12(assetId)
4127
4212
  });
4128
- return bn14(balance.amount, 10);
4213
+ return bn15(balance.amount, 10);
4129
4214
  }
4130
4215
  /**
4131
4216
  * Returns balances for the given owner.
@@ -4143,7 +4228,7 @@ var _Provider = class {
4143
4228
  const balances = result.balances.edges.map((edge) => edge.node);
4144
4229
  return balances.map((balance) => ({
4145
4230
  assetId: balance.assetId,
4146
- amount: bn14(balance.amount)
4231
+ amount: bn15(balance.amount)
4147
4232
  }));
4148
4233
  }
4149
4234
  /**
@@ -4165,15 +4250,15 @@ var _Provider = class {
4165
4250
  sender: message.sender,
4166
4251
  recipient: message.recipient,
4167
4252
  nonce: message.nonce,
4168
- amount: bn14(message.amount),
4253
+ amount: bn15(message.amount),
4169
4254
  data: message.data
4170
4255
  }),
4171
4256
  sender: Address2.fromAddressOrString(message.sender),
4172
4257
  recipient: Address2.fromAddressOrString(message.recipient),
4173
4258
  nonce: message.nonce,
4174
- amount: bn14(message.amount),
4259
+ amount: bn15(message.amount),
4175
4260
  data: InputMessageCoder.decodeData(message.data),
4176
- daHeight: bn14(message.daHeight)
4261
+ daHeight: bn15(message.daHeight)
4177
4262
  }));
4178
4263
  }
4179
4264
  /**
@@ -4191,8 +4276,8 @@ var _Provider = class {
4191
4276
  nonce
4192
4277
  };
4193
4278
  if (commitBlockId && commitBlockHeight) {
4194
- throw new FuelError12(
4195
- ErrorCode12.INVALID_INPUT_PARAMETERS,
4279
+ throw new FuelError13(
4280
+ ErrorCode13.INVALID_INPUT_PARAMETERS,
4196
4281
  "commitBlockId and commitBlockHeight cannot be used together"
4197
4282
  );
4198
4283
  }
@@ -4226,41 +4311,41 @@ var _Provider = class {
4226
4311
  } = result.messageProof;
4227
4312
  return {
4228
4313
  messageProof: {
4229
- proofIndex: bn14(messageProof.proofIndex),
4314
+ proofIndex: bn15(messageProof.proofIndex),
4230
4315
  proofSet: messageProof.proofSet
4231
4316
  },
4232
4317
  blockProof: {
4233
- proofIndex: bn14(blockProof.proofIndex),
4318
+ proofIndex: bn15(blockProof.proofIndex),
4234
4319
  proofSet: blockProof.proofSet
4235
4320
  },
4236
4321
  messageBlockHeader: {
4237
4322
  id: messageBlockHeader.id,
4238
- daHeight: bn14(messageBlockHeader.daHeight),
4239
- transactionsCount: bn14(messageBlockHeader.transactionsCount),
4323
+ daHeight: bn15(messageBlockHeader.daHeight),
4324
+ transactionsCount: bn15(messageBlockHeader.transactionsCount),
4240
4325
  transactionsRoot: messageBlockHeader.transactionsRoot,
4241
- height: bn14(messageBlockHeader.height),
4326
+ height: bn15(messageBlockHeader.height),
4242
4327
  prevRoot: messageBlockHeader.prevRoot,
4243
4328
  time: messageBlockHeader.time,
4244
4329
  applicationHash: messageBlockHeader.applicationHash,
4245
4330
  messageReceiptRoot: messageBlockHeader.messageReceiptRoot,
4246
- messageReceiptCount: bn14(messageBlockHeader.messageReceiptCount)
4331
+ messageReceiptCount: bn15(messageBlockHeader.messageReceiptCount)
4247
4332
  },
4248
4333
  commitBlockHeader: {
4249
4334
  id: commitBlockHeader.id,
4250
- daHeight: bn14(commitBlockHeader.daHeight),
4251
- transactionsCount: bn14(commitBlockHeader.transactionsCount),
4335
+ daHeight: bn15(commitBlockHeader.daHeight),
4336
+ transactionsCount: bn15(commitBlockHeader.transactionsCount),
4252
4337
  transactionsRoot: commitBlockHeader.transactionsRoot,
4253
- height: bn14(commitBlockHeader.height),
4338
+ height: bn15(commitBlockHeader.height),
4254
4339
  prevRoot: commitBlockHeader.prevRoot,
4255
4340
  time: commitBlockHeader.time,
4256
4341
  applicationHash: commitBlockHeader.applicationHash,
4257
4342
  messageReceiptRoot: commitBlockHeader.messageReceiptRoot,
4258
- messageReceiptCount: bn14(commitBlockHeader.messageReceiptCount)
4343
+ messageReceiptCount: bn15(commitBlockHeader.messageReceiptCount)
4259
4344
  },
4260
4345
  sender: Address2.fromAddressOrString(sender),
4261
4346
  recipient: Address2.fromAddressOrString(recipient),
4262
4347
  nonce,
4263
- amount: bn14(amount),
4348
+ amount: bn15(amount),
4264
4349
  data
4265
4350
  };
4266
4351
  }
@@ -4283,10 +4368,10 @@ var _Provider = class {
4283
4368
  */
4284
4369
  async produceBlocks(amount, startTime) {
4285
4370
  const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
4286
- blocksToProduce: bn14(amount).toString(10),
4371
+ blocksToProduce: bn15(amount).toString(10),
4287
4372
  startTimestamp: startTime ? DateTime2.fromUnixMilliseconds(startTime).toTai64() : void 0
4288
4373
  });
4289
- return bn14(latestBlockHeight);
4374
+ return bn15(latestBlockHeight);
4290
4375
  }
4291
4376
  // eslint-disable-next-line @typescript-eslint/require-await
4292
4377
  async getTransactionResponse(transactionId) {
@@ -4309,8 +4394,8 @@ __publicField(Provider, "chainInfoCache", {});
4309
4394
  __publicField(Provider, "nodeInfoCache", {});
4310
4395
 
4311
4396
  // src/providers/transaction-summary/get-transaction-summary.ts
4312
- import { ErrorCode as ErrorCode13, FuelError as FuelError13 } from "@fuel-ts/errors";
4313
- import { bn as bn15 } from "@fuel-ts/math";
4397
+ import { ErrorCode as ErrorCode14, FuelError as FuelError14 } from "@fuel-ts/errors";
4398
+ import { bn as bn16 } from "@fuel-ts/math";
4314
4399
  import { TransactionCoder as TransactionCoder6 } from "@fuel-ts/transactions";
4315
4400
  import { arrayify as arrayify12 } from "@fuel-ts/utils";
4316
4401
 
@@ -4427,7 +4512,7 @@ var Account = class extends AbstractAccount {
4427
4512
  */
4428
4513
  get provider() {
4429
4514
  if (!this._provider) {
4430
- throw new FuelError14(ErrorCode14.MISSING_PROVIDER, "Provider not set");
4515
+ throw new FuelError15(ErrorCode15.MISSING_PROVIDER, "Provider not set");
4431
4516
  }
4432
4517
  return this._provider;
4433
4518
  }
@@ -4479,8 +4564,8 @@ var Account = class extends AbstractAccount {
4479
4564
  if (!hasNextPage) {
4480
4565
  break;
4481
4566
  }
4482
- throw new FuelError14(
4483
- ErrorCode14.NOT_SUPPORTED,
4567
+ throw new FuelError15(
4568
+ ErrorCode15.NOT_SUPPORTED,
4484
4569
  `Wallets containing more than ${pageSize} coins exceed the current supported limit.`
4485
4570
  );
4486
4571
  }
@@ -4505,8 +4590,8 @@ var Account = class extends AbstractAccount {
4505
4590
  if (!hasNextPage) {
4506
4591
  break;
4507
4592
  }
4508
- throw new FuelError14(
4509
- ErrorCode14.NOT_SUPPORTED,
4593
+ throw new FuelError15(
4594
+ ErrorCode15.NOT_SUPPORTED,
4510
4595
  `Wallets containing more than ${pageSize} messages exceed the current supported limit.`
4511
4596
  );
4512
4597
  }
@@ -4541,8 +4626,8 @@ var Account = class extends AbstractAccount {
4541
4626
  if (!hasNextPage) {
4542
4627
  break;
4543
4628
  }
4544
- throw new FuelError14(
4545
- ErrorCode14.NOT_SUPPORTED,
4629
+ throw new FuelError15(
4630
+ ErrorCode15.NOT_SUPPORTED,
4546
4631
  `Wallets containing more than ${pageSize} balances exceed the current supported limit.`
4547
4632
  );
4548
4633
  }
@@ -4558,7 +4643,7 @@ var Account = class extends AbstractAccount {
4558
4643
  */
4559
4644
  async fund(request, coinQuantities, fee) {
4560
4645
  const updatedQuantities = addAmountToAsset({
4561
- amount: bn16(fee),
4646
+ amount: bn17(fee),
4562
4647
  assetId: BaseAssetId3,
4563
4648
  coinQuantities
4564
4649
  });
@@ -4566,7 +4651,7 @@ var Account = class extends AbstractAccount {
4566
4651
  updatedQuantities.forEach(({ amount, assetId }) => {
4567
4652
  quantitiesDict[assetId] = {
4568
4653
  required: amount,
4569
- owned: bn16(0)
4654
+ owned: bn17(0)
4570
4655
  };
4571
4656
  });
4572
4657
  const cachedUtxos = [];
@@ -4579,7 +4664,7 @@ var Account = class extends AbstractAccount {
4579
4664
  if (isCoin2) {
4580
4665
  const assetId = String(input.assetId);
4581
4666
  if (input.owner === owner && quantitiesDict[assetId]) {
4582
- const amount = bn16(input.amount);
4667
+ const amount = bn17(input.amount);
4583
4668
  quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
4584
4669
  cachedUtxos.push(input.id);
4585
4670
  }
@@ -4625,8 +4710,8 @@ var Account = class extends AbstractAccount {
4625
4710
  estimateTxDependencies: true,
4626
4711
  resourcesOwner: this
4627
4712
  });
4628
- request.gasPrice = bn16(txParams.gasPrice ?? minGasPrice);
4629
- request.gasLimit = bn16(txParams.gasLimit ?? gasUsed);
4713
+ request.gasPrice = bn17(txParams.gasPrice ?? minGasPrice);
4714
+ request.gasLimit = bn17(txParams.gasLimit ?? gasUsed);
4630
4715
  this.validateGas({
4631
4716
  gasUsed,
4632
4717
  gasPrice: request.gasPrice,
@@ -4647,9 +4732,9 @@ var Account = class extends AbstractAccount {
4647
4732
  * @returns A promise that resolves to the transaction response.
4648
4733
  */
4649
4734
  async transfer(destination, amount, assetId = BaseAssetId3, txParams = {}) {
4650
- if (bn16(amount).lte(0)) {
4651
- throw new FuelError14(
4652
- ErrorCode14.INVALID_TRANSFER_AMOUNT,
4735
+ if (bn17(amount).lte(0)) {
4736
+ throw new FuelError15(
4737
+ ErrorCode15.INVALID_TRANSFER_AMOUNT,
4653
4738
  "Transfer amount must be a positive number."
4654
4739
  );
4655
4740
  }
@@ -4666,9 +4751,9 @@ var Account = class extends AbstractAccount {
4666
4751
  * @returns A promise that resolves to the transaction response.
4667
4752
  */
4668
4753
  async transferToContract(contractId, amount, assetId = BaseAssetId3, txParams = {}) {
4669
- if (bn16(amount).lte(0)) {
4670
- throw new FuelError14(
4671
- ErrorCode14.INVALID_TRANSFER_AMOUNT,
4754
+ if (bn17(amount).lte(0)) {
4755
+ throw new FuelError15(
4756
+ ErrorCode15.INVALID_TRANSFER_AMOUNT,
4672
4757
  "Transfer amount must be a positive number."
4673
4758
  );
4674
4759
  }
@@ -4677,7 +4762,7 @@ var Account = class extends AbstractAccount {
4677
4762
  const params = { gasPrice: minGasPrice, ...txParams };
4678
4763
  const { script, scriptData } = await assembleTransferToContractScript({
4679
4764
  hexlifiedContractId: contractAddress.toB256(),
4680
- amountToTransfer: bn16(amount),
4765
+ amountToTransfer: bn17(amount),
4681
4766
  assetId
4682
4767
  });
4683
4768
  const request = new ScriptTransactionRequest({
@@ -4688,9 +4773,9 @@ var Account = class extends AbstractAccount {
4688
4773
  request.addContractInputAndOutput(contractAddress);
4689
4774
  const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(
4690
4775
  request,
4691
- [{ amount: bn16(amount), assetId: String(assetId) }]
4776
+ [{ amount: bn17(amount), assetId: String(assetId) }]
4692
4777
  );
4693
- request.gasLimit = bn16(params.gasLimit ?? gasUsed);
4778
+ request.gasLimit = bn17(params.gasLimit ?? gasUsed);
4694
4779
  this.validateGas({
4695
4780
  gasUsed,
4696
4781
  gasPrice: request.gasPrice,
@@ -4715,7 +4800,7 @@ var Account = class extends AbstractAccount {
4715
4800
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
4716
4801
  );
4717
4802
  const amountDataArray = arrayify14(
4718
- "0x".concat(bn16(amount).toHex().substring(2).padStart(16, "0"))
4803
+ "0x".concat(bn17(amount).toHex().substring(2).padStart(16, "0"))
4719
4804
  );
4720
4805
  const script = new Uint8Array([
4721
4806
  ...arrayify14(withdrawScript.bytes),
@@ -4724,12 +4809,12 @@ var Account = class extends AbstractAccount {
4724
4809
  ]);
4725
4810
  const params = { script, gasPrice: minGasPrice, ...txParams };
4726
4811
  const request = new ScriptTransactionRequest(params);
4727
- const forwardingQuantities = [{ amount: bn16(amount), assetId: BaseAssetId3 }];
4812
+ const forwardingQuantities = [{ amount: bn17(amount), assetId: BaseAssetId3 }];
4728
4813
  const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
4729
4814
  request,
4730
4815
  forwardingQuantities
4731
4816
  );
4732
- request.gasLimit = bn16(params.gasLimit ?? gasUsed);
4817
+ request.gasLimit = bn17(params.gasLimit ?? gasUsed);
4733
4818
  this.validateGas({
4734
4819
  gasUsed,
4735
4820
  gasPrice: request.gasPrice,
@@ -4741,7 +4826,7 @@ var Account = class extends AbstractAccount {
4741
4826
  }
4742
4827
  async signMessage(message) {
4743
4828
  if (!this._connector) {
4744
- throw new FuelError14(ErrorCode14.MISSING_CONNECTOR, "A connector is required to sign messages.");
4829
+ throw new FuelError15(ErrorCode15.MISSING_CONNECTOR, "A connector is required to sign messages.");
4745
4830
  }
4746
4831
  return this._connector.signMessage(this.address.toString(), message);
4747
4832
  }
@@ -4753,8 +4838,8 @@ var Account = class extends AbstractAccount {
4753
4838
  */
4754
4839
  async signTransaction(transactionRequestLike) {
4755
4840
  if (!this._connector) {
4756
- throw new FuelError14(
4757
- ErrorCode14.MISSING_CONNECTOR,
4841
+ throw new FuelError15(
4842
+ ErrorCode15.MISSING_CONNECTOR,
4758
4843
  "A connector is required to sign transactions."
4759
4844
  );
4760
4845
  }
@@ -4801,14 +4886,14 @@ var Account = class extends AbstractAccount {
4801
4886
  minGasPrice
4802
4887
  }) {
4803
4888
  if (minGasPrice.gt(gasPrice)) {
4804
- throw new FuelError14(
4805
- ErrorCode14.GAS_PRICE_TOO_LOW,
4889
+ throw new FuelError15(
4890
+ ErrorCode15.GAS_PRICE_TOO_LOW,
4806
4891
  `Gas price '${gasPrice}' is lower than the required: '${minGasPrice}'.`
4807
4892
  );
4808
4893
  }
4809
4894
  if (gasUsed.gt(gasLimit)) {
4810
- throw new FuelError14(
4811
- ErrorCode14.GAS_LIMIT_TOO_LOW,
4895
+ throw new FuelError15(
4896
+ ErrorCode15.GAS_LIMIT_TOO_LOW,
4812
4897
  `Gas limit '${gasLimit}' is lower than the required: '${gasUsed}'.`
4813
4898
  );
4814
4899
  }
@@ -4935,7 +5020,7 @@ import {
4935
5020
  decryptJsonWalletData,
4936
5021
  encryptJsonWalletData
4937
5022
  } from "@fuel-ts/crypto";
4938
- import { ErrorCode as ErrorCode15, FuelError as FuelError15 } from "@fuel-ts/errors";
5023
+ import { ErrorCode as ErrorCode16, FuelError as FuelError16 } from "@fuel-ts/errors";
4939
5024
  import { hexlify as hexlify14 } from "@fuel-ts/utils";
4940
5025
  import { v4 as uuidv4 } from "uuid";
4941
5026
  var DEFAULT_KDF_PARAMS_LOG_N = 13;
@@ -5013,8 +5098,8 @@ async function decryptKeystoreWallet(jsonWallet, password) {
5013
5098
  const macHashUint8Array = keccak256(data);
5014
5099
  const macHash = stringFromBuffer(macHashUint8Array, "hex");
5015
5100
  if (mac !== macHash) {
5016
- throw new FuelError15(
5017
- ErrorCode15.INVALID_PASSWORD,
5101
+ throw new FuelError16(
5102
+ ErrorCode16.INVALID_PASSWORD,
5018
5103
  "Failed to decrypt the keystore wallet, the provided password is incorrect."
5019
5104
  );
5020
5105
  }
@@ -5136,15 +5221,15 @@ var BaseWalletUnlocked = class extends Account {
5136
5221
  __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
5137
5222
 
5138
5223
  // src/hdwallet/hdwallet.ts
5139
- import { ErrorCode as ErrorCode18, FuelError as FuelError18 } from "@fuel-ts/errors";
5224
+ import { ErrorCode as ErrorCode19, FuelError as FuelError19 } from "@fuel-ts/errors";
5140
5225
  import { sha256 as sha2564 } from "@fuel-ts/hasher";
5141
- import { bn as bn17, toBytes as toBytes2, toHex } from "@fuel-ts/math";
5226
+ import { bn as bn18, toBytes as toBytes2, toHex } from "@fuel-ts/math";
5142
5227
  import { arrayify as arrayify18, hexlify as hexlify17, concat as concat5 } from "@fuel-ts/utils";
5143
5228
  import { toBeHex, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58, computeHmac as computeHmac2, ripemd160 } from "ethers";
5144
5229
 
5145
5230
  // src/mnemonic/mnemonic.ts
5146
5231
  import { randomBytes as randomBytes3 } from "@fuel-ts/crypto";
5147
- import { ErrorCode as ErrorCode17, FuelError as FuelError17 } from "@fuel-ts/errors";
5232
+ import { ErrorCode as ErrorCode18, FuelError as FuelError18 } from "@fuel-ts/errors";
5148
5233
  import { sha256 as sha2563 } from "@fuel-ts/hasher";
5149
5234
  import { arrayify as arrayify17, hexlify as hexlify16, concat as concat4 } from "@fuel-ts/utils";
5150
5235
  import { dataSlice, pbkdf2, computeHmac, encodeBase58 } from "ethers";
@@ -7202,7 +7287,7 @@ var english = [
7202
7287
  ];
7203
7288
 
7204
7289
  // src/mnemonic/utils.ts
7205
- import { ErrorCode as ErrorCode16, FuelError as FuelError16 } from "@fuel-ts/errors";
7290
+ import { ErrorCode as ErrorCode17, FuelError as FuelError17 } from "@fuel-ts/errors";
7206
7291
  import { sha256 as sha2562 } from "@fuel-ts/hasher";
7207
7292
  import { arrayify as arrayify16 } from "@fuel-ts/utils";
7208
7293
  function toUtf8Bytes(stri) {
@@ -7219,8 +7304,8 @@ function toUtf8Bytes(stri) {
7219
7304
  i += 1;
7220
7305
  const c2 = str.charCodeAt(i);
7221
7306
  if (i >= str.length || (c2 & 64512) !== 56320) {
7222
- throw new FuelError16(
7223
- ErrorCode16.INVALID_INPUT_PARAMETERS,
7307
+ throw new FuelError17(
7308
+ ErrorCode17.INVALID_INPUT_PARAMETERS,
7224
7309
  "Invalid UTF-8 in the input string."
7225
7310
  );
7226
7311
  }
@@ -7283,8 +7368,8 @@ function mnemonicWordsToEntropy(words, wordlist) {
7283
7368
  for (let i = 0; i < words.length; i += 1) {
7284
7369
  const index = wordlist.indexOf(words[i].normalize("NFKD"));
7285
7370
  if (index === -1) {
7286
- throw new FuelError16(
7287
- ErrorCode16.INVALID_MNEMONIC,
7371
+ throw new FuelError17(
7372
+ ErrorCode17.INVALID_MNEMONIC,
7288
7373
  `Invalid mnemonic: the word '${words[i]}' is not found in the provided wordlist.`
7289
7374
  );
7290
7375
  }
@@ -7300,8 +7385,8 @@ function mnemonicWordsToEntropy(words, wordlist) {
7300
7385
  const checksumMask = getUpperMask(checksumBits);
7301
7386
  const checksum = arrayify16(sha2562(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
7302
7387
  if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
7303
- throw new FuelError16(
7304
- ErrorCode16.INVALID_CHECKSUM,
7388
+ throw new FuelError17(
7389
+ ErrorCode17.INVALID_CHECKSUM,
7305
7390
  "Checksum validation failed for the provided mnemonic."
7306
7391
  );
7307
7392
  }
@@ -7315,16 +7400,16 @@ var TestnetPRV = "0x04358394";
7315
7400
  var MNEMONIC_SIZES = [12, 15, 18, 21, 24];
7316
7401
  function assertWordList(wordlist) {
7317
7402
  if (wordlist.length !== 2048) {
7318
- throw new FuelError17(
7319
- ErrorCode17.INVALID_WORD_LIST,
7403
+ throw new FuelError18(
7404
+ ErrorCode18.INVALID_WORD_LIST,
7320
7405
  `Expected word list length of 2048, but got ${wordlist.length}.`
7321
7406
  );
7322
7407
  }
7323
7408
  }
7324
7409
  function assertEntropy(entropy) {
7325
7410
  if (entropy.length % 4 !== 0 || entropy.length < 16 || entropy.length > 32) {
7326
- throw new FuelError17(
7327
- ErrorCode17.INVALID_ENTROPY,
7411
+ throw new FuelError18(
7412
+ ErrorCode18.INVALID_ENTROPY,
7328
7413
  `Entropy should be between 16 and 32 bytes and a multiple of 4, but got ${entropy.length} bytes.`
7329
7414
  );
7330
7415
  }
@@ -7334,7 +7419,7 @@ function assertMnemonic(words) {
7334
7419
  const errorMsg = `Invalid mnemonic size. Expected one of [${MNEMONIC_SIZES.join(
7335
7420
  ", "
7336
7421
  )}] words, but got ${words.length}.`;
7337
- throw new FuelError17(ErrorCode17.INVALID_MNEMONIC, errorMsg);
7422
+ throw new FuelError18(ErrorCode18.INVALID_MNEMONIC, errorMsg);
7338
7423
  }
7339
7424
  }
7340
7425
  var Mnemonic = class {
@@ -7452,8 +7537,8 @@ var Mnemonic = class {
7452
7537
  static masterKeysFromSeed(seed) {
7453
7538
  const seedArray = arrayify17(seed);
7454
7539
  if (seedArray.length < 16 || seedArray.length > 64) {
7455
- throw new FuelError17(
7456
- ErrorCode17.INVALID_SEED,
7540
+ throw new FuelError18(
7541
+ ErrorCode18.INVALID_SEED,
7457
7542
  `Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
7458
7543
  );
7459
7544
  }
@@ -7530,7 +7615,7 @@ function isValidExtendedKey(extendedKey) {
7530
7615
  function parsePath(path2, depth = 0) {
7531
7616
  const components = path2.split("/");
7532
7617
  if (components.length === 0 || components[0] === "m" && depth !== 0) {
7533
- throw new FuelError18(ErrorCode18.HD_WALLET_ERROR, `invalid path - ${path2}`);
7618
+ throw new FuelError19(ErrorCode19.HD_WALLET_ERROR, `invalid path - ${path2}`);
7534
7619
  }
7535
7620
  if (components[0] === "m") {
7536
7621
  components.shift();
@@ -7559,8 +7644,8 @@ var HDWallet = class {
7559
7644
  this.privateKey = hexlify17(config.privateKey);
7560
7645
  } else {
7561
7646
  if (!config.publicKey) {
7562
- throw new FuelError18(
7563
- ErrorCode18.HD_WALLET_ERROR,
7647
+ throw new FuelError19(
7648
+ ErrorCode19.HD_WALLET_ERROR,
7564
7649
  "Both public and private Key cannot be missing. At least one should be provided."
7565
7650
  );
7566
7651
  }
@@ -7589,8 +7674,8 @@ var HDWallet = class {
7589
7674
  const data = new Uint8Array(37);
7590
7675
  if (index & HARDENED_INDEX) {
7591
7676
  if (!privateKey) {
7592
- throw new FuelError18(
7593
- ErrorCode18.HD_WALLET_ERROR,
7677
+ throw new FuelError19(
7678
+ ErrorCode19.HD_WALLET_ERROR,
7594
7679
  "Cannot derive a hardened index without a private Key."
7595
7680
  );
7596
7681
  }
@@ -7604,7 +7689,7 @@ var HDWallet = class {
7604
7689
  const IR = bytes.slice(32);
7605
7690
  if (privateKey) {
7606
7691
  const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
7607
- const ki = bn17(IL).add(privateKey).mod(N).toBytes(32);
7692
+ const ki = bn18(IL).add(privateKey).mod(N).toBytes(32);
7608
7693
  return new HDWallet({
7609
7694
  privateKey: ki,
7610
7695
  chainCode: IR,
@@ -7642,8 +7727,8 @@ var HDWallet = class {
7642
7727
  */
7643
7728
  toExtendedKey(isPublic = false, testnet = false) {
7644
7729
  if (this.depth >= 256) {
7645
- throw new FuelError18(
7646
- ErrorCode18.HD_WALLET_ERROR,
7730
+ throw new FuelError19(
7731
+ ErrorCode19.HD_WALLET_ERROR,
7647
7732
  `Exceeded max depth of 255. Current depth: ${this.depth}.`
7648
7733
  );
7649
7734
  }
@@ -7674,10 +7759,10 @@ var HDWallet = class {
7674
7759
  const bytes = arrayify18(decoded);
7675
7760
  const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
7676
7761
  if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
7677
- throw new FuelError18(ErrorCode18.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
7762
+ throw new FuelError19(ErrorCode19.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
7678
7763
  }
7679
7764
  if (!validChecksum) {
7680
- throw new FuelError18(ErrorCode18.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
7765
+ throw new FuelError19(ErrorCode19.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
7681
7766
  }
7682
7767
  const depth = bytes[4];
7683
7768
  const parentFingerprint = hexlify17(bytes.slice(5, 9));
@@ -7685,14 +7770,14 @@ var HDWallet = class {
7685
7770
  const chainCode = hexlify17(bytes.slice(13, 45));
7686
7771
  const key = bytes.slice(45, 78);
7687
7772
  if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
7688
- throw new FuelError18(
7689
- ErrorCode18.HD_WALLET_ERROR,
7773
+ throw new FuelError19(
7774
+ ErrorCode19.HD_WALLET_ERROR,
7690
7775
  "Inconsistency detected: Depth is zero but fingerprint/index is non-zero."
7691
7776
  );
7692
7777
  }
7693
7778
  if (isPublicExtendedKey(bytes)) {
7694
7779
  if (key[0] !== 3) {
7695
- throw new FuelError18(ErrorCode18.HD_WALLET_ERROR, "Invalid public extended key.");
7780
+ throw new FuelError19(ErrorCode19.HD_WALLET_ERROR, "Invalid public extended key.");
7696
7781
  }
7697
7782
  return new HDWallet({
7698
7783
  publicKey: key,
@@ -7703,7 +7788,7 @@ var HDWallet = class {
7703
7788
  });
7704
7789
  }
7705
7790
  if (key[0] !== 0) {
7706
- throw new FuelError18(ErrorCode18.HD_WALLET_ERROR, "Invalid private extended key.");
7791
+ throw new FuelError19(ErrorCode19.HD_WALLET_ERROR, "Invalid private extended key.");
7707
7792
  }
7708
7793
  return new HDWallet({
7709
7794
  privateKey: key.slice(1),