@fuel-ts/account 0.100.0 → 0.100.1

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.
@@ -455,7 +455,7 @@ var addAmountToCoinQuantities = (params) => {
455
455
 
456
456
  // src/providers/provider.ts
457
457
  var import_address4 = require("@fuel-ts/address");
458
- var import_errors20 = require("@fuel-ts/errors");
458
+ var import_errors21 = require("@fuel-ts/errors");
459
459
  var import_math19 = require("@fuel-ts/math");
460
460
  var import_transactions23 = require("@fuel-ts/transactions");
461
461
  var import_utils30 = require("@fuel-ts/utils");
@@ -464,6 +464,17 @@ var import_graphql_request = require("graphql-request");
464
464
  var import_graphql_tag2 = __toESM(require("graphql-tag"));
465
465
  var import_ramda8 = require("ramda");
466
466
 
467
+ // src/connectors/utils/promises.ts
468
+ var import_errors2 = require("@fuel-ts/errors");
469
+ function deferPromise() {
470
+ const defer = {};
471
+ defer.promise = new Promise((resolve, reject) => {
472
+ defer.reject = reject;
473
+ defer.resolve = resolve;
474
+ });
475
+ return defer;
476
+ }
477
+
467
478
  // src/providers/__generated__/operations.ts
468
479
  var import_graphql_tag = __toESM(require("graphql-tag"));
469
480
  var SubmittedStatusFragmentDoc = import_graphql_tag.default`
@@ -1516,35 +1527,35 @@ function getSdk(requester) {
1516
1527
  }
1517
1528
 
1518
1529
  // src/providers/fuel-graphql-subscriber.ts
1519
- var import_errors3 = require("@fuel-ts/errors");
1530
+ var import_errors4 = require("@fuel-ts/errors");
1520
1531
  var import_graphql = require("graphql");
1521
1532
 
1522
1533
  // src/providers/utils/handle-gql-error-message.ts
1523
- var import_errors2 = require("@fuel-ts/errors");
1534
+ var import_errors3 = require("@fuel-ts/errors");
1524
1535
  var mapGqlErrorMessage = (error) => {
1525
1536
  if (new RegExp("the target cannot be met due to no coins available or exceeding the \\d+ coin limit." /* NOT_ENOUGH_COINS_MAX_COINS */).test(error.message)) {
1526
- return new import_errors2.FuelError(
1527
- import_errors2.ErrorCode.INSUFFICIENT_FUNDS_OR_MAX_COINS,
1537
+ return new import_errors3.FuelError(
1538
+ import_errors3.ErrorCode.INSUFFICIENT_FUNDS_OR_MAX_COINS,
1528
1539
  `Insufficient funds or too many small value coins. Consider combining UTXOs.`,
1529
1540
  {},
1530
1541
  error
1531
1542
  );
1532
1543
  }
1533
1544
  if (new RegExp("resource was not found in table" /* ASSET_NOT_FOUND */).test(error.message)) {
1534
- return new import_errors2.FuelError(
1535
- import_errors2.ErrorCode.ASSET_NOT_FOUND,
1545
+ return new import_errors3.FuelError(
1546
+ import_errors3.ErrorCode.ASSET_NOT_FOUND,
1536
1547
  `Asset not found for given asset id.`,
1537
1548
  {},
1538
1549
  error
1539
1550
  );
1540
1551
  }
1541
- return new import_errors2.FuelError(import_errors2.ErrorCode.INVALID_REQUEST, error.message, {}, error);
1552
+ return new import_errors3.FuelError(import_errors3.ErrorCode.INVALID_REQUEST, error.message, {}, error);
1542
1553
  };
1543
1554
  var mapGqlErrorWithIncompatibleNodeVersion = (error, incompatibleNodeVersionMessage) => {
1544
1555
  if (!incompatibleNodeVersionMessage) {
1545
1556
  return error;
1546
1557
  }
1547
- return new import_errors2.FuelError(
1558
+ return new import_errors3.FuelError(
1548
1559
  error.code,
1549
1560
  `${error.message}
1550
1561
 
@@ -1563,7 +1574,7 @@ var assertGqlResponseHasNoErrors = (errors, incompatibleNodeVersionMessage = fal
1563
1574
  }
1564
1575
  const errorMessage = mappedErrors.map((err) => err.message).join("\n");
1565
1576
  throw mapGqlErrorWithIncompatibleNodeVersion(
1566
- new import_errors2.FuelError(import_errors2.ErrorCode.INVALID_REQUEST, errorMessage, {}, mappedErrors),
1577
+ new import_errors3.FuelError(import_errors3.ErrorCode.INVALID_REQUEST, errorMessage, {}, mappedErrors),
1567
1578
  incompatibleNodeVersionMessage
1568
1579
  );
1569
1580
  };
@@ -1614,8 +1625,8 @@ var _FuelGraphqlSubscriber = class {
1614
1625
  try {
1615
1626
  this.events.push(JSON.parse(match.replace(/^data:/, "")));
1616
1627
  } catch (e) {
1617
- throw new import_errors3.FuelError(
1618
- import_errors3.ErrorCode.STREAM_PARSING_ERROR,
1628
+ throw new import_errors4.FuelError(
1629
+ import_errors4.ErrorCode.STREAM_PARSING_ERROR,
1619
1630
  `Error while parsing stream data response: ${text}`
1620
1631
  );
1621
1632
  }
@@ -1638,13 +1649,13 @@ __publicField(FuelGraphqlSubscriber, "incompatibleNodeVersionMessage", false);
1638
1649
  __publicField(FuelGraphqlSubscriber, "textDecoder", new TextDecoder());
1639
1650
 
1640
1651
  // src/providers/resource-cache.ts
1641
- var import_errors14 = require("@fuel-ts/errors");
1652
+ var import_errors15 = require("@fuel-ts/errors");
1642
1653
  var import_utils23 = require("@fuel-ts/utils");
1643
1654
 
1644
1655
  // src/providers/transaction-request/input.ts
1645
1656
  var import_abi_coder2 = require("@fuel-ts/abi-coder");
1646
1657
  var import_configs = require("@fuel-ts/address/configs");
1647
- var import_errors4 = require("@fuel-ts/errors");
1658
+ var import_errors5 = require("@fuel-ts/errors");
1648
1659
  var import_math3 = require("@fuel-ts/math");
1649
1660
  var import_transactions = require("@fuel-ts/transactions");
1650
1661
  var import_utils4 = require("@fuel-ts/utils");
@@ -1708,8 +1719,8 @@ var inputify = (value) => {
1708
1719
  };
1709
1720
  }
1710
1721
  default: {
1711
- throw new import_errors4.FuelError(
1712
- import_errors4.ErrorCode.INVALID_TRANSACTION_INPUT,
1722
+ throw new import_errors5.FuelError(
1723
+ import_errors5.ErrorCode.INVALID_TRANSACTION_INPUT,
1713
1724
  `Invalid transaction input type: ${type}.`
1714
1725
  );
1715
1726
  }
@@ -1718,7 +1729,7 @@ var inputify = (value) => {
1718
1729
 
1719
1730
  // src/providers/transaction-request/output.ts
1720
1731
  var import_configs2 = require("@fuel-ts/address/configs");
1721
- var import_errors5 = require("@fuel-ts/errors");
1732
+ var import_errors6 = require("@fuel-ts/errors");
1722
1733
  var import_math4 = require("@fuel-ts/math");
1723
1734
  var import_transactions2 = require("@fuel-ts/transactions");
1724
1735
  var import_utils5 = require("@fuel-ts/utils");
@@ -1765,8 +1776,8 @@ var outputify = (value) => {
1765
1776
  };
1766
1777
  }
1767
1778
  default: {
1768
- throw new import_errors5.FuelError(
1769
- import_errors5.ErrorCode.INVALID_TRANSACTION_INPUT,
1779
+ throw new import_errors6.FuelError(
1780
+ import_errors6.ErrorCode.INVALID_TRANSACTION_INPUT,
1770
1781
  `Invalid transaction output type: ${type}.`
1771
1782
  );
1772
1783
  }
@@ -1778,7 +1789,7 @@ var import_abi_coder3 = require("@fuel-ts/abi-coder");
1778
1789
  var import_address2 = require("@fuel-ts/address");
1779
1790
  var import_configs6 = require("@fuel-ts/address/configs");
1780
1791
  var import_crypto3 = require("@fuel-ts/crypto");
1781
- var import_errors10 = require("@fuel-ts/errors");
1792
+ var import_errors11 = require("@fuel-ts/errors");
1782
1793
  var import_math9 = require("@fuel-ts/math");
1783
1794
  var import_transactions8 = require("@fuel-ts/transactions");
1784
1795
  var import_utils11 = require("@fuel-ts/utils");
@@ -1795,7 +1806,7 @@ var import_configs4 = require("@fuel-ts/transactions/configs");
1795
1806
 
1796
1807
  // src/providers/utils/serialization.ts
1797
1808
  var import_configs3 = require("@fuel-ts/address/configs");
1798
- var import_errors6 = require("@fuel-ts/errors");
1809
+ var import_errors7 = require("@fuel-ts/errors");
1799
1810
  var import_math5 = require("@fuel-ts/math");
1800
1811
  var import_transactions3 = require("@fuel-ts/transactions");
1801
1812
  var import_utils6 = require("@fuel-ts/utils");
@@ -2130,7 +2141,7 @@ var deserializeReceipt = (receipt) => {
2130
2141
  return burnReceipt;
2131
2142
  }
2132
2143
  default:
2133
- throw new import_errors6.FuelError(import_errors6.ErrorCode.INVALID_RECEIPT_TYPE, `Invalid receipt type: ${receiptType}.`);
2144
+ throw new import_errors7.FuelError(import_errors7.ErrorCode.INVALID_RECEIPT_TYPE, `Invalid receipt type: ${receiptType}.`);
2134
2145
  }
2135
2146
  };
2136
2147
 
@@ -2154,7 +2165,7 @@ var getReceiptsWithMissingData = (receipts) => receipts.reduce(
2154
2165
  );
2155
2166
 
2156
2167
  // src/providers/utils/block-explorer.ts
2157
- var import_errors7 = require("@fuel-ts/errors");
2168
+ var import_errors8 = require("@fuel-ts/errors");
2158
2169
 
2159
2170
  // src/providers/utils/gas.ts
2160
2171
  var import_math6 = require("@fuel-ts/math");
@@ -2326,7 +2337,7 @@ function normalizeJSON(root) {
2326
2337
  }
2327
2338
 
2328
2339
  // src/providers/utils/extract-tx-error.ts
2329
- var import_errors8 = require("@fuel-ts/errors");
2340
+ var import_errors9 = require("@fuel-ts/errors");
2330
2341
  var import_math7 = require("@fuel-ts/math");
2331
2342
  var import_transactions6 = require("@fuel-ts/transactions");
2332
2343
  var import_configs5 = require("@fuel-ts/transactions/configs");
@@ -2339,7 +2350,7 @@ You can read more about this error at:
2339
2350
 
2340
2351
  ${import_configs5.PANIC_DOC_URL}#variant.${statusReason}`;
2341
2352
  }
2342
- return new import_errors8.FuelError(import_errors8.ErrorCode.SCRIPT_REVERTED, errorMessage, {
2353
+ return new import_errors9.FuelError(import_errors9.ErrorCode.SCRIPT_REVERTED, errorMessage, {
2343
2354
  ...metadata,
2344
2355
  reason: statusReason
2345
2356
  });
@@ -2380,8 +2391,8 @@ var assembleRevertError = (receipts, logs, metadata) => {
2380
2391
  errorMessage = `The transaction reverted because it's missing an "OutputVariable".`;
2381
2392
  break;
2382
2393
  default:
2383
- throw new import_errors8.FuelError(
2384
- import_errors8.ErrorCode.UNKNOWN,
2394
+ throw new import_errors9.FuelError(
2395
+ import_errors9.ErrorCode.UNKNOWN,
2385
2396
  `The transaction reverted with an unknown reason: ${revertReceipt.val}`,
2386
2397
  {
2387
2398
  ...metadata,
@@ -2390,7 +2401,7 @@ var assembleRevertError = (receipts, logs, metadata) => {
2390
2401
  );
2391
2402
  }
2392
2403
  }
2393
- return new import_errors8.FuelError(import_errors8.ErrorCode.SCRIPT_REVERTED, errorMessage, {
2404
+ return new import_errors9.FuelError(import_errors9.ErrorCode.SCRIPT_REVERTED, errorMessage, {
2394
2405
  ...metadata,
2395
2406
  reason
2396
2407
  });
@@ -2423,7 +2434,7 @@ var NoWitnessAtIndexError = class extends Error {
2423
2434
  };
2424
2435
 
2425
2436
  // src/providers/transaction-request/helpers.ts
2426
- var import_errors9 = require("@fuel-ts/errors");
2437
+ var import_errors10 = require("@fuel-ts/errors");
2427
2438
  var import_math8 = require("@fuel-ts/math");
2428
2439
  var import_transactions7 = require("@fuel-ts/transactions");
2429
2440
  var import_utils9 = require("@fuel-ts/utils");
@@ -2482,7 +2493,7 @@ var validateTransactionForAssetBurn = (baseAssetId, transactionRequest, enableAs
2482
2493
  "Add the relevant change outputs to the transaction to avoid burning assets.",
2483
2494
  "Or enable asset burn, upon sending the transaction."
2484
2495
  ].join("\n");
2485
- throw new import_errors9.FuelError(import_errors9.ErrorCode.ASSET_BURN_DETECTED, message);
2496
+ throw new import_errors10.FuelError(import_errors10.ErrorCode.ASSET_BURN_DETECTED, message);
2486
2497
  };
2487
2498
 
2488
2499
  // src/providers/transaction-request/witness.ts
@@ -2880,7 +2891,7 @@ var BaseTransactionRequest = class {
2880
2891
  * @hidden
2881
2892
  */
2882
2893
  metadataGas(_gasCosts) {
2883
- throw new import_errors10.FuelError(import_errors10.FuelError.CODES.NOT_IMPLEMENTED, "Not implemented");
2894
+ throw new import_errors11.FuelError(import_errors11.FuelError.CODES.NOT_IMPLEMENTED, "Not implemented");
2884
2895
  }
2885
2896
  /**
2886
2897
  * @hidden
@@ -3503,7 +3514,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
3503
3514
  };
3504
3515
 
3505
3516
  // src/providers/transaction-request/upgrade-transaction-request.ts
3506
- var import_errors12 = require("@fuel-ts/errors");
3517
+ var import_errors13 = require("@fuel-ts/errors");
3507
3518
  var import_hasher3 = require("@fuel-ts/hasher");
3508
3519
  var import_transactions12 = require("@fuel-ts/transactions");
3509
3520
  var import_utils19 = require("@fuel-ts/utils");
@@ -3607,7 +3618,7 @@ var UpgradeTransactionRequest = class extends BaseTransactionRequest {
3607
3618
  }
3608
3619
  };
3609
3620
  } else {
3610
- throw new import_errors12.FuelError(import_errors12.FuelError.CODES.NOT_IMPLEMENTED, "Invalid upgrade purpose");
3621
+ throw new import_errors13.FuelError(import_errors13.FuelError.CODES.NOT_IMPLEMENTED, "Invalid upgrade purpose");
3611
3622
  }
3612
3623
  return {
3613
3624
  type: import_transactions12.TransactionType.Upgrade,
@@ -3649,7 +3660,7 @@ var UpgradeTransactionRequest = class extends BaseTransactionRequest {
3649
3660
  txBytesSize
3650
3661
  });
3651
3662
  }
3652
- throw new import_errors12.FuelError(import_errors12.FuelError.CODES.NOT_IMPLEMENTED, "Invalid upgrade purpose");
3663
+ throw new import_errors13.FuelError(import_errors13.FuelError.CODES.NOT_IMPLEMENTED, "Invalid upgrade purpose");
3653
3664
  }
3654
3665
  };
3655
3666
 
@@ -3760,7 +3771,7 @@ var UploadTransactionRequest = class extends BaseTransactionRequest {
3760
3771
  };
3761
3772
 
3762
3773
  // src/providers/transaction-request/utils.ts
3763
- var import_errors13 = require("@fuel-ts/errors");
3774
+ var import_errors14 = require("@fuel-ts/errors");
3764
3775
  var import_transactions14 = require("@fuel-ts/transactions");
3765
3776
  var transactionRequestify = (obj) => {
3766
3777
  if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest || obj instanceof BlobTransactionRequest || obj instanceof UpgradeTransactionRequest || obj instanceof UploadTransactionRequest) {
@@ -3784,8 +3795,8 @@ var transactionRequestify = (obj) => {
3784
3795
  return UploadTransactionRequest.from(obj);
3785
3796
  }
3786
3797
  default: {
3787
- throw new import_errors13.FuelError(
3788
- import_errors13.ErrorCode.UNSUPPORTED_TRANSACTION_TYPE,
3798
+ throw new import_errors14.FuelError(
3799
+ import_errors14.ErrorCode.UNSUPPORTED_TRANSACTION_TYPE,
3789
3800
  `Unsupported transaction type: ${type}.`
3790
3801
  );
3791
3802
  }
@@ -3801,8 +3812,8 @@ var ResourceCache = class {
3801
3812
  constructor(ttl) {
3802
3813
  this.ttl = ttl;
3803
3814
  if (typeof ttl !== "number" || this.ttl <= 0) {
3804
- throw new import_errors14.FuelError(
3805
- import_errors14.ErrorCode.INVALID_TTL,
3815
+ throw new import_errors15.FuelError(
3816
+ import_errors15.ErrorCode.INVALID_TTL,
3806
3817
  `Invalid TTL: ${this.ttl}. Use a value greater than zero.`
3807
3818
  );
3808
3819
  }
@@ -3886,7 +3897,7 @@ var ResourceCache = class {
3886
3897
  };
3887
3898
 
3888
3899
  // src/providers/transaction-response/transaction-response.ts
3889
- var import_errors18 = require("@fuel-ts/errors");
3900
+ var import_errors19 = require("@fuel-ts/errors");
3890
3901
  var import_math18 = require("@fuel-ts/math");
3891
3902
  var import_transactions22 = require("@fuel-ts/transactions");
3892
3903
  var import_utils27 = require("@fuel-ts/utils");
@@ -3964,12 +3975,12 @@ var calculateTXFeeForSummary = (params) => {
3964
3975
 
3965
3976
  // src/providers/transaction-summary/operations.ts
3966
3977
  var import_configs11 = require("@fuel-ts/address/configs");
3967
- var import_errors16 = require("@fuel-ts/errors");
3978
+ var import_errors17 = require("@fuel-ts/errors");
3968
3979
  var import_math15 = require("@fuel-ts/math");
3969
3980
  var import_transactions18 = require("@fuel-ts/transactions");
3970
3981
 
3971
3982
  // src/providers/transaction-summary/input.ts
3972
- var import_errors15 = require("@fuel-ts/errors");
3983
+ var import_errors16 = require("@fuel-ts/errors");
3973
3984
  var import_math14 = require("@fuel-ts/math");
3974
3985
  var import_transactions16 = require("@fuel-ts/transactions");
3975
3986
  function getInputsByTypes(inputs, types) {
@@ -4038,8 +4049,8 @@ function getInputContractFromIndex(inputs, inputIndex) {
4038
4049
  return void 0;
4039
4050
  }
4040
4051
  if (contractInput.type !== import_transactions16.InputType.Contract) {
4041
- throw new import_errors15.FuelError(
4042
- import_errors15.ErrorCode.INVALID_TRANSACTION_INPUT,
4052
+ throw new import_errors16.FuelError(
4053
+ import_errors16.ErrorCode.INVALID_TRANSACTION_INPUT,
4043
4054
  `Contract input should be of type 'contract'.`
4044
4055
  );
4045
4056
  }
@@ -4092,8 +4103,8 @@ function getTransactionTypeName(transactionType) {
4092
4103
  case import_transactions18.TransactionType.Upload:
4093
4104
  return "Upload" /* Upload */;
4094
4105
  default:
4095
- throw new import_errors16.FuelError(
4096
- import_errors16.ErrorCode.UNSUPPORTED_TRANSACTION_TYPE,
4106
+ throw new import_errors17.FuelError(
4107
+ import_errors17.ErrorCode.UNSUPPORTED_TRANSACTION_TYPE,
4097
4108
  `Unsupported transaction type: ${transactionType}.`
4098
4109
  );
4099
4110
  }
@@ -4472,7 +4483,7 @@ var extractBurnedAssetsFromReceipts = (receipts) => {
4472
4483
  };
4473
4484
 
4474
4485
  // src/providers/transaction-summary/status.ts
4475
- var import_errors17 = require("@fuel-ts/errors");
4486
+ var import_errors18 = require("@fuel-ts/errors");
4476
4487
  var import_math16 = require("@fuel-ts/math");
4477
4488
  var getTransactionStatusName = (gqlStatus) => {
4478
4489
  switch (gqlStatus) {
@@ -4485,8 +4496,8 @@ var getTransactionStatusName = (gqlStatus) => {
4485
4496
  case "SqueezedOutStatus":
4486
4497
  return "squeezedout" /* squeezedout */;
4487
4498
  default:
4488
- throw new import_errors17.FuelError(
4489
- import_errors17.ErrorCode.INVALID_TRANSACTION_STATUS,
4499
+ throw new import_errors18.FuelError(
4500
+ import_errors18.ErrorCode.INVALID_TRANSACTION_STATUS,
4490
4501
  `Invalid transaction status: ${gqlStatus}.`
4491
4502
  );
4492
4503
  }
@@ -4619,14 +4630,26 @@ function assembleTransactionSummary(params) {
4619
4630
 
4620
4631
  // src/providers/transaction-response/getDecodedLogs.ts
4621
4632
  var import_abi_coder5 = require("@fuel-ts/abi-coder");
4633
+ var import_configs12 = require("@fuel-ts/address/configs");
4622
4634
  var import_transactions21 = require("@fuel-ts/transactions");
4623
4635
  function getDecodedLogs(receipts, mainAbi, externalAbis = {}) {
4636
+ let mainContract = "";
4637
+ if (mainAbi.programType === "contract") {
4638
+ const firstCallReceipt = receipts.find(
4639
+ (r) => r.type === import_transactions21.ReceiptType.Call && r.id === import_configs12.ZeroBytes32
4640
+ );
4641
+ mainContract = firstCallReceipt.to;
4642
+ }
4624
4643
  return receipts.reduce((logs, receipt) => {
4625
4644
  if (receipt.type === import_transactions21.ReceiptType.LogData || receipt.type === import_transactions21.ReceiptType.Log) {
4626
- const interfaceToUse = new import_abi_coder5.Interface(externalAbis[receipt.id] || mainAbi);
4627
- const data = receipt.type === import_transactions21.ReceiptType.Log ? new import_abi_coder5.BigNumberCoder("u64").encode(receipt.ra) : receipt.data;
4628
- const [decodedLog] = interfaceToUse.decodeLog(data, receipt.rb.toString());
4629
- logs.push(decodedLog);
4645
+ const isLogFromMainAbi = receipt.id === import_configs12.ZeroBytes32 || mainContract === receipt.id;
4646
+ const isDecodable = isLogFromMainAbi || externalAbis[receipt.id];
4647
+ if (isDecodable) {
4648
+ const interfaceToUse = isLogFromMainAbi ? new import_abi_coder5.Interface(mainAbi) : new import_abi_coder5.Interface(externalAbis[receipt.id]);
4649
+ const data = receipt.type === import_transactions21.ReceiptType.Log ? new import_abi_coder5.BigNumberCoder("u64").encode(receipt.ra) : receipt.data;
4650
+ const [decodedLog] = interfaceToUse.decodeLog(data, receipt.rb.toString());
4651
+ logs.push(decodedLog);
4652
+ }
4630
4653
  }
4631
4654
  return logs;
4632
4655
  }, []);
@@ -4831,8 +4854,8 @@ var TransactionResponse = class {
4831
4854
  this.status = statusChange;
4832
4855
  if (statusChange.type === "SqueezedOutStatus") {
4833
4856
  this.unsetResourceCache();
4834
- throw new import_errors18.FuelError(
4835
- import_errors18.ErrorCode.TRANSACTION_SQUEEZED_OUT,
4857
+ throw new import_errors19.FuelError(
4858
+ import_errors19.ErrorCode.TRANSACTION_SQUEEZED_OUT,
4836
4859
  `Transaction Squeezed Out with reason: ${statusChange.reason}`
4837
4860
  );
4838
4861
  }
@@ -4956,31 +4979,31 @@ var adjustResourcesToExclude = (params) => {
4956
4979
  };
4957
4980
 
4958
4981
  // src/providers/utils/validate-pagination-args.ts
4959
- var import_errors19 = require("@fuel-ts/errors");
4982
+ var import_errors20 = require("@fuel-ts/errors");
4960
4983
  var validatePaginationArgs = (params) => {
4961
4984
  const { paginationLimit, inputArgs = {} } = params;
4962
4985
  const { first, last, after, before } = inputArgs;
4963
4986
  if (after && before) {
4964
- throw new import_errors19.FuelError(
4965
- import_errors19.ErrorCode.INVALID_INPUT_PARAMETERS,
4987
+ throw new import_errors20.FuelError(
4988
+ import_errors20.ErrorCode.INVALID_INPUT_PARAMETERS,
4966
4989
  'Pagination arguments "after" and "before" cannot be used together'
4967
4990
  );
4968
4991
  }
4969
4992
  if ((first || 0) > paginationLimit || (last || 0) > paginationLimit) {
4970
- throw new import_errors19.FuelError(
4971
- import_errors19.ErrorCode.INVALID_INPUT_PARAMETERS,
4993
+ throw new import_errors20.FuelError(
4994
+ import_errors20.ErrorCode.INVALID_INPUT_PARAMETERS,
4972
4995
  `Pagination limit for this query cannot exceed ${paginationLimit} items`
4973
4996
  );
4974
4997
  }
4975
4998
  if (first && before) {
4976
- throw new import_errors19.FuelError(
4977
- import_errors19.ErrorCode.INVALID_INPUT_PARAMETERS,
4999
+ throw new import_errors20.FuelError(
5000
+ import_errors20.ErrorCode.INVALID_INPUT_PARAMETERS,
4978
5001
  'The use of pagination argument "first" with "before" is not supported'
4979
5002
  );
4980
5003
  }
4981
5004
  if (last && after) {
4982
- throw new import_errors19.FuelError(
4983
- import_errors19.ErrorCode.INVALID_INPUT_PARAMETERS,
5005
+ throw new import_errors20.FuelError(
5006
+ import_errors20.ErrorCode.INVALID_INPUT_PARAMETERS,
4984
5007
  'The use of pagination argument "last" with "after" is not supported'
4985
5008
  );
4986
5009
  }
@@ -5064,6 +5087,7 @@ var _Provider = class {
5064
5087
  }
5065
5088
  /** @hidden */
5066
5089
  static clearChainAndNodeCaches() {
5090
+ _Provider.inflightFetchChainAndNodeInfoRequests = {};
5067
5091
  _Provider.nodeInfoCache = {};
5068
5092
  _Provider.chainInfoCache = {};
5069
5093
  }
@@ -5092,7 +5116,7 @@ var _Provider = class {
5092
5116
  try {
5093
5117
  parsedUrl = new URL(url);
5094
5118
  } catch (error) {
5095
- throw new import_errors20.FuelError(import_errors20.FuelError.CODES.INVALID_URL, "Invalid URL provided.", { url }, error);
5119
+ throw new import_errors21.FuelError(import_errors21.FuelError.CODES.INVALID_URL, "Invalid URL provided.", { url }, error);
5096
5120
  }
5097
5121
  const username = parsedUrl.username;
5098
5122
  const password = parsedUrl.password;
@@ -5181,13 +5205,24 @@ var _Provider = class {
5181
5205
  throw new Error(`Jumps to the catch block and re-fetch`);
5182
5206
  }
5183
5207
  } catch (_err) {
5208
+ const inflightRequest = _Provider.inflightFetchChainAndNodeInfoRequests[this.urlWithoutAuth];
5209
+ if (inflightRequest) {
5210
+ const now2 = await inflightRequest;
5211
+ this.consensusParametersTimestamp = now2;
5212
+ return this.fetchChainAndNodeInfo();
5213
+ }
5214
+ const { promise, resolve } = deferPromise();
5215
+ _Provider.inflightFetchChainAndNodeInfoRequests[this.urlWithoutAuth] = promise;
5184
5216
  const data = await this.operations.getChainAndNodeInfo();
5185
5217
  nodeInfo = deserializeNodeInfo(data.nodeInfo);
5186
- _Provider.setIncompatibleNodeVersionMessage(nodeInfo);
5187
5218
  chain = deserializeChain(data.chain);
5219
+ _Provider.setIncompatibleNodeVersionMessage(nodeInfo);
5188
5220
  _Provider.chainInfoCache[this.urlWithoutAuth] = chain;
5189
5221
  _Provider.nodeInfoCache[this.urlWithoutAuth] = nodeInfo;
5190
- this.consensusParametersTimestamp = Date.now();
5222
+ const now = Date.now();
5223
+ this.consensusParametersTimestamp = now;
5224
+ resolve(now);
5225
+ delete _Provider.inflightFetchChainAndNodeInfoRequests[this.urlWithoutAuth];
5191
5226
  }
5192
5227
  return {
5193
5228
  chain,
@@ -5365,14 +5400,14 @@ var _Provider = class {
5365
5400
  }
5366
5401
  } = await this.getChain();
5367
5402
  if ((0, import_math19.bn)(tx.inputs.length).gt(maxInputs)) {
5368
- throw new import_errors20.FuelError(
5369
- import_errors20.ErrorCode.MAX_INPUTS_EXCEEDED,
5403
+ throw new import_errors21.FuelError(
5404
+ import_errors21.ErrorCode.MAX_INPUTS_EXCEEDED,
5370
5405
  `The transaction exceeds the maximum allowed number of inputs. Tx inputs: ${tx.inputs.length}, max inputs: ${maxInputs}`
5371
5406
  );
5372
5407
  }
5373
5408
  if ((0, import_math19.bn)(tx.outputs.length).gt(maxOutputs)) {
5374
- throw new import_errors20.FuelError(
5375
- import_errors20.ErrorCode.MAX_OUTPUTS_EXCEEDED,
5409
+ throw new import_errors21.FuelError(
5410
+ import_errors21.ErrorCode.MAX_OUTPUTS_EXCEEDED,
5376
5411
  `The transaction exceeds the maximum allowed number of outputs. Tx outputs: ${tx.outputs.length}, max outputs: ${maxOutputs}`
5377
5412
  );
5378
5413
  }
@@ -6071,7 +6106,7 @@ var _Provider = class {
6071
6106
  0
6072
6107
  )?.[0];
6073
6108
  } catch (error) {
6074
- if (error instanceof import_errors20.FuelError && error.code === import_errors20.ErrorCode.UNSUPPORTED_TRANSACTION_TYPE) {
6109
+ if (error instanceof import_errors21.FuelError && error.code === import_errors21.ErrorCode.UNSUPPORTED_TRANSACTION_TYPE) {
6075
6110
  console.warn("Unsupported transaction type encountered");
6076
6111
  return null;
6077
6112
  }
@@ -6097,7 +6132,7 @@ var _Provider = class {
6097
6132
  try {
6098
6133
  return coder.decode((0, import_utils30.arrayify)(rawPayload), 0)[0];
6099
6134
  } catch (error) {
6100
- if (error instanceof import_errors20.FuelError && error.code === import_errors20.ErrorCode.UNSUPPORTED_TRANSACTION_TYPE) {
6135
+ if (error instanceof import_errors21.FuelError && error.code === import_errors21.ErrorCode.UNSUPPORTED_TRANSACTION_TYPE) {
6101
6136
  console.warn("Unsupported transaction type encountered");
6102
6137
  return null;
6103
6138
  }
@@ -6275,8 +6310,8 @@ var _Provider = class {
6275
6310
  nonce
6276
6311
  };
6277
6312
  if (commitBlockId && commitBlockHeight) {
6278
- throw new import_errors20.FuelError(
6279
- import_errors20.ErrorCode.INVALID_INPUT_PARAMETERS,
6313
+ throw new import_errors21.FuelError(
6314
+ import_errors21.ErrorCode.INVALID_INPUT_PARAMETERS,
6280
6315
  "commitBlockId and commitBlockHeight cannot be used together"
6281
6316
  );
6282
6317
  }
@@ -6531,6 +6566,8 @@ cacheInputs_fn = function(inputs, transactionId) {
6531
6566
  this.cache.set(transactionId, inputs);
6532
6567
  };
6533
6568
  /** @hidden */
6569
+ __publicField(Provider, "inflightFetchChainAndNodeInfoRequests", {});
6570
+ /** @hidden */
6534
6571
  __publicField(Provider, "chainInfoCache", {});
6535
6572
  /** @hidden */
6536
6573
  __publicField(Provider, "nodeInfoCache", {});
@@ -6538,7 +6575,7 @@ __publicField(Provider, "nodeInfoCache", {});
6538
6575
  __publicField(Provider, "incompatibleNodeVersionMessage", "");
6539
6576
 
6540
6577
  // src/providers/transaction-summary/get-transaction-summary.ts
6541
- var import_errors21 = require("@fuel-ts/errors");
6578
+ var import_errors22 = require("@fuel-ts/errors");
6542
6579
  var import_math20 = require("@fuel-ts/math");
6543
6580
  var import_transactions24 = require("@fuel-ts/transactions");
6544
6581
  var import_utils32 = require("@fuel-ts/utils");
@@ -6573,7 +6610,7 @@ __publicField(TestAssetId, "B", new _TestAssetId(
6573
6610
 
6574
6611
  // src/test-utils/wallet-config.ts
6575
6612
  var import_crypto9 = require("@fuel-ts/crypto");
6576
- var import_errors27 = require("@fuel-ts/errors");
6613
+ var import_errors28 = require("@fuel-ts/errors");
6577
6614
  var import_math24 = require("@fuel-ts/math");
6578
6615
  var import_utils43 = require("@fuel-ts/utils");
6579
6616
 
@@ -6585,7 +6622,7 @@ var import_utils38 = require("@fuel-ts/utils");
6585
6622
  var import_abi_coder7 = require("@fuel-ts/abi-coder");
6586
6623
  var import_address6 = require("@fuel-ts/address");
6587
6624
  var import_crypto5 = require("@fuel-ts/crypto");
6588
- var import_errors22 = require("@fuel-ts/errors");
6625
+ var import_errors23 = require("@fuel-ts/errors");
6589
6626
  var import_math22 = require("@fuel-ts/math");
6590
6627
  var import_transactions26 = require("@fuel-ts/transactions");
6591
6628
  var import_utils36 = require("@fuel-ts/utils");
@@ -6686,7 +6723,7 @@ var Account = class extends AbstractAccount {
6686
6723
  */
6687
6724
  get provider() {
6688
6725
  if (!this._provider) {
6689
- throw new import_errors22.FuelError(import_errors22.ErrorCode.MISSING_PROVIDER, "Provider not set");
6726
+ throw new import_errors23.FuelError(import_errors23.ErrorCode.MISSING_PROVIDER, "Provider not set");
6690
6727
  }
6691
6728
  return this._provider;
6692
6729
  }
@@ -6845,8 +6882,8 @@ var Account = class extends AbstractAccount {
6845
6882
  fundingAttempts += 1;
6846
6883
  }
6847
6884
  if (needsToBeFunded) {
6848
- throw new import_errors22.FuelError(
6849
- import_errors22.ErrorCode.INSUFFICIENT_FUNDS_OR_MAX_COINS,
6885
+ throw new import_errors23.FuelError(
6886
+ import_errors23.ErrorCode.INSUFFICIENT_FUNDS_OR_MAX_COINS,
6850
6887
  `The account ${this.address} does not have enough base asset funds to cover the transaction execution.`
6851
6888
  );
6852
6889
  }
@@ -6965,8 +7002,8 @@ var Account = class extends AbstractAccount {
6965
7002
  const contractAddress = new import_address6.Address(transferParam.contractId);
6966
7003
  const assetId = transferParam.assetId ? (0, import_utils36.hexlify)(transferParam.assetId) : defaultAssetId;
6967
7004
  if (amount.lte(0)) {
6968
- throw new import_errors22.FuelError(
6969
- import_errors22.ErrorCode.INVALID_TRANSFER_AMOUNT,
7005
+ throw new import_errors23.FuelError(
7006
+ import_errors23.ErrorCode.INVALID_TRANSFER_AMOUNT,
6970
7007
  "Transfer amount must be a positive number."
6971
7008
  );
6972
7009
  }
@@ -7082,7 +7119,7 @@ var Account = class extends AbstractAccount {
7082
7119
  */
7083
7120
  async signMessage(message) {
7084
7121
  if (!this._connector) {
7085
- throw new import_errors22.FuelError(import_errors22.ErrorCode.MISSING_CONNECTOR, "A connector is required to sign messages.");
7122
+ throw new import_errors23.FuelError(import_errors23.ErrorCode.MISSING_CONNECTOR, "A connector is required to sign messages.");
7086
7123
  }
7087
7124
  return this._connector.signMessage(this.address.toString(), message);
7088
7125
  }
@@ -7094,8 +7131,8 @@ var Account = class extends AbstractAccount {
7094
7131
  */
7095
7132
  async signTransaction(transactionRequestLike) {
7096
7133
  if (!this._connector) {
7097
- throw new import_errors22.FuelError(
7098
- import_errors22.ErrorCode.MISSING_CONNECTOR,
7134
+ throw new import_errors23.FuelError(
7135
+ import_errors23.ErrorCode.MISSING_CONNECTOR,
7099
7136
  "A connector is required to sign transactions."
7100
7137
  );
7101
7138
  }
@@ -7191,8 +7228,8 @@ var Account = class extends AbstractAccount {
7191
7228
  /** @hidden * */
7192
7229
  validateTransferAmount(amount) {
7193
7230
  if ((0, import_math22.bn)(amount).lte(0)) {
7194
- throw new import_errors22.FuelError(
7195
- import_errors22.ErrorCode.INVALID_TRANSFER_AMOUNT,
7231
+ throw new import_errors23.FuelError(
7232
+ import_errors23.ErrorCode.INVALID_TRANSFER_AMOUNT,
7196
7233
  "Transfer amount must be a positive number."
7197
7234
  );
7198
7235
  }
@@ -7221,16 +7258,16 @@ var Account = class extends AbstractAccount {
7221
7258
  if (!(0, import_utils36.isDefined)(setGasLimit)) {
7222
7259
  request.gasLimit = gasUsed;
7223
7260
  } else if (gasUsed.gt(setGasLimit)) {
7224
- throw new import_errors22.FuelError(
7225
- import_errors22.ErrorCode.GAS_LIMIT_TOO_LOW,
7261
+ throw new import_errors23.FuelError(
7262
+ import_errors23.ErrorCode.GAS_LIMIT_TOO_LOW,
7226
7263
  `Gas limit '${setGasLimit}' is lower than the required: '${gasUsed}'.`
7227
7264
  );
7228
7265
  }
7229
7266
  if (!(0, import_utils36.isDefined)(setMaxFee)) {
7230
7267
  request.maxFee = maxFee;
7231
7268
  } else if (maxFee.gt(setMaxFee)) {
7232
- throw new import_errors22.FuelError(
7233
- import_errors22.ErrorCode.MAX_FEE_TOO_LOW,
7269
+ throw new import_errors23.FuelError(
7270
+ import_errors23.ErrorCode.MAX_FEE_TOO_LOW,
7234
7271
  `Max fee '${setMaxFee}' is lower than the required: '${maxFee}'.`
7235
7272
  );
7236
7273
  }
@@ -7241,7 +7278,7 @@ var Account = class extends AbstractAccount {
7241
7278
  // src/wallet/keystore-wallet.ts
7242
7279
  var import_address7 = require("@fuel-ts/address");
7243
7280
  var import_crypto6 = require("@fuel-ts/crypto");
7244
- var import_errors23 = require("@fuel-ts/errors");
7281
+ var import_errors24 = require("@fuel-ts/errors");
7245
7282
  var import_utils37 = require("@fuel-ts/utils");
7246
7283
  var DEFAULT_KDF_PARAMS_LOG_N = 13;
7247
7284
  var DEFAULT_KDF_PARAMS_R = 8;
@@ -7318,8 +7355,8 @@ async function decryptKeystoreWallet(jsonWallet, password) {
7318
7355
  const macHashUint8Array = (0, import_crypto6.keccak256)(data);
7319
7356
  const macHash = (0, import_crypto6.stringFromBuffer)(macHashUint8Array, "hex");
7320
7357
  if (mac !== macHash) {
7321
- throw new import_errors23.FuelError(
7322
- import_errors23.ErrorCode.INVALID_PASSWORD,
7358
+ throw new import_errors24.FuelError(
7359
+ import_errors24.ErrorCode.INVALID_PASSWORD,
7323
7360
  "Failed to decrypt the keystore wallet, the provided password is incorrect."
7324
7361
  );
7325
7362
  }
@@ -7454,14 +7491,14 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
7454
7491
 
7455
7492
  // src/hdwallet/hdwallet.ts
7456
7493
  var import_crypto8 = require("@fuel-ts/crypto");
7457
- var import_errors26 = require("@fuel-ts/errors");
7494
+ var import_errors27 = require("@fuel-ts/errors");
7458
7495
  var import_hasher7 = require("@fuel-ts/hasher");
7459
7496
  var import_math23 = require("@fuel-ts/math");
7460
7497
  var import_utils42 = require("@fuel-ts/utils");
7461
7498
 
7462
7499
  // src/mnemonic/mnemonic.ts
7463
7500
  var import_crypto7 = require("@fuel-ts/crypto");
7464
- var import_errors25 = require("@fuel-ts/errors");
7501
+ var import_errors26 = require("@fuel-ts/errors");
7465
7502
  var import_hasher6 = require("@fuel-ts/hasher");
7466
7503
  var import_utils40 = require("@fuel-ts/utils");
7467
7504
 
@@ -9518,7 +9555,7 @@ var english = [
9518
9555
  ];
9519
9556
 
9520
9557
  // src/mnemonic/utils.ts
9521
- var import_errors24 = require("@fuel-ts/errors");
9558
+ var import_errors25 = require("@fuel-ts/errors");
9522
9559
  var import_hasher5 = require("@fuel-ts/hasher");
9523
9560
  var import_utils39 = require("@fuel-ts/utils");
9524
9561
  function getLowerMask(bits) {
@@ -9567,8 +9604,8 @@ function mnemonicWordsToEntropy(words, wordlist) {
9567
9604
  for (let i = 0; i < words.length; i += 1) {
9568
9605
  const index = wordlist.indexOf(words[i].normalize("NFKD"));
9569
9606
  if (index === -1) {
9570
- throw new import_errors24.FuelError(
9571
- import_errors24.ErrorCode.INVALID_MNEMONIC,
9607
+ throw new import_errors25.FuelError(
9608
+ import_errors25.ErrorCode.INVALID_MNEMONIC,
9572
9609
  `Invalid mnemonic: the word '${words[i]}' is not found in the provided wordlist.`
9573
9610
  );
9574
9611
  }
@@ -9584,8 +9621,8 @@ function mnemonicWordsToEntropy(words, wordlist) {
9584
9621
  const checksumMask = getUpperMask(checksumBits);
9585
9622
  const checksum = (0, import_utils39.arrayify)((0, import_hasher5.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
9586
9623
  if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
9587
- throw new import_errors24.FuelError(
9588
- import_errors24.ErrorCode.INVALID_CHECKSUM,
9624
+ throw new import_errors25.FuelError(
9625
+ import_errors25.ErrorCode.INVALID_CHECKSUM,
9589
9626
  "Checksum validation failed for the provided mnemonic."
9590
9627
  );
9591
9628
  }
@@ -9599,16 +9636,16 @@ var TestnetPRV = "0x04358394";
9599
9636
  var MNEMONIC_SIZES = [12, 15, 18, 21, 24];
9600
9637
  function assertWordList(wordlist) {
9601
9638
  if (wordlist.length !== 2048) {
9602
- throw new import_errors25.FuelError(
9603
- import_errors25.ErrorCode.INVALID_WORD_LIST,
9639
+ throw new import_errors26.FuelError(
9640
+ import_errors26.ErrorCode.INVALID_WORD_LIST,
9604
9641
  `Expected word list length of 2048, but got ${wordlist.length}.`
9605
9642
  );
9606
9643
  }
9607
9644
  }
9608
9645
  function assertEntropy(entropy) {
9609
9646
  if (entropy.length % 4 !== 0 || entropy.length < 16 || entropy.length > 32) {
9610
- throw new import_errors25.FuelError(
9611
- import_errors25.ErrorCode.INVALID_ENTROPY,
9647
+ throw new import_errors26.FuelError(
9648
+ import_errors26.ErrorCode.INVALID_ENTROPY,
9612
9649
  `Entropy should be between 16 and 32 bytes and a multiple of 4, but got ${entropy.length} bytes.`
9613
9650
  );
9614
9651
  }
@@ -9618,7 +9655,7 @@ function assertMnemonic(words) {
9618
9655
  const errorMsg = `Invalid mnemonic size. Expected one of [${MNEMONIC_SIZES.join(
9619
9656
  ", "
9620
9657
  )}] words, but got ${words.length}.`;
9621
- throw new import_errors25.FuelError(import_errors25.ErrorCode.INVALID_MNEMONIC, errorMsg);
9658
+ throw new import_errors26.FuelError(import_errors26.ErrorCode.INVALID_MNEMONIC, errorMsg);
9622
9659
  }
9623
9660
  }
9624
9661
  var Mnemonic = class {
@@ -9736,8 +9773,8 @@ var Mnemonic = class {
9736
9773
  static masterKeysFromSeed(seed) {
9737
9774
  const seedArray = (0, import_utils40.arrayify)(seed);
9738
9775
  if (seedArray.length < 16 || seedArray.length > 64) {
9739
- throw new import_errors25.FuelError(
9740
- import_errors25.ErrorCode.INVALID_SEED,
9776
+ throw new import_errors26.FuelError(
9777
+ import_errors26.ErrorCode.INVALID_SEED,
9741
9778
  `Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
9742
9779
  );
9743
9780
  }
@@ -9814,7 +9851,7 @@ function isValidExtendedKey(extendedKey) {
9814
9851
  function parsePath(path2, depth = 0) {
9815
9852
  const components = path2.split("/");
9816
9853
  if (components.length === 0 || components[0] === "m" && depth !== 0) {
9817
- throw new import_errors26.FuelError(import_errors26.ErrorCode.HD_WALLET_ERROR, `invalid path - ${path2}`);
9854
+ throw new import_errors27.FuelError(import_errors27.ErrorCode.HD_WALLET_ERROR, `invalid path - ${path2}`);
9818
9855
  }
9819
9856
  if (components[0] === "m") {
9820
9857
  components.shift();
@@ -9843,8 +9880,8 @@ var HDWallet = class {
9843
9880
  this.privateKey = (0, import_utils42.hexlify)(config.privateKey);
9844
9881
  } else {
9845
9882
  if (!config.publicKey) {
9846
- throw new import_errors26.FuelError(
9847
- import_errors26.ErrorCode.HD_WALLET_ERROR,
9883
+ throw new import_errors27.FuelError(
9884
+ import_errors27.ErrorCode.HD_WALLET_ERROR,
9848
9885
  "Both public and private Key cannot be missing. At least one should be provided."
9849
9886
  );
9850
9887
  }
@@ -9873,8 +9910,8 @@ var HDWallet = class {
9873
9910
  const data = new Uint8Array(37);
9874
9911
  if (index & HARDENED_INDEX) {
9875
9912
  if (!privateKey) {
9876
- throw new import_errors26.FuelError(
9877
- import_errors26.ErrorCode.HD_WALLET_ERROR,
9913
+ throw new import_errors27.FuelError(
9914
+ import_errors27.ErrorCode.HD_WALLET_ERROR,
9878
9915
  "Cannot derive a hardened index without a private Key."
9879
9916
  );
9880
9917
  }
@@ -9926,8 +9963,8 @@ var HDWallet = class {
9926
9963
  */
9927
9964
  toExtendedKey(isPublic = false, testnet = false) {
9928
9965
  if (this.depth >= 256) {
9929
- throw new import_errors26.FuelError(
9930
- import_errors26.ErrorCode.HD_WALLET_ERROR,
9966
+ throw new import_errors27.FuelError(
9967
+ import_errors27.ErrorCode.HD_WALLET_ERROR,
9931
9968
  `Exceeded max depth of 255. Current depth: ${this.depth}.`
9932
9969
  );
9933
9970
  }
@@ -9958,10 +9995,10 @@ var HDWallet = class {
9958
9995
  const bytes = (0, import_utils42.arrayify)(decoded);
9959
9996
  const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
9960
9997
  if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
9961
- throw new import_errors26.FuelError(import_errors26.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
9998
+ throw new import_errors27.FuelError(import_errors27.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
9962
9999
  }
9963
10000
  if (!validChecksum) {
9964
- throw new import_errors26.FuelError(import_errors26.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
10001
+ throw new import_errors27.FuelError(import_errors27.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
9965
10002
  }
9966
10003
  const depth = bytes[4];
9967
10004
  const parentFingerprint = (0, import_utils42.hexlify)(bytes.slice(5, 9));
@@ -9969,14 +10006,14 @@ var HDWallet = class {
9969
10006
  const chainCode = (0, import_utils42.hexlify)(bytes.slice(13, 45));
9970
10007
  const key = bytes.slice(45, 78);
9971
10008
  if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
9972
- throw new import_errors26.FuelError(
9973
- import_errors26.ErrorCode.HD_WALLET_ERROR,
10009
+ throw new import_errors27.FuelError(
10010
+ import_errors27.ErrorCode.HD_WALLET_ERROR,
9974
10011
  "Inconsistency detected: Depth is zero but fingerprint/index is non-zero."
9975
10012
  );
9976
10013
  }
9977
10014
  if (isPublicExtendedKey(bytes)) {
9978
10015
  if (key[0] !== 3) {
9979
- throw new import_errors26.FuelError(import_errors26.ErrorCode.HD_WALLET_ERROR, "Invalid public extended key.");
10016
+ throw new import_errors27.FuelError(import_errors27.ErrorCode.HD_WALLET_ERROR, "Invalid public extended key.");
9980
10017
  }
9981
10018
  return new HDWallet({
9982
10019
  publicKey: key,
@@ -9987,7 +10024,7 @@ var HDWallet = class {
9987
10024
  });
9988
10025
  }
9989
10026
  if (key[0] !== 0) {
9990
- throw new import_errors26.FuelError(import_errors26.ErrorCode.HD_WALLET_ERROR, "Invalid private extended key.");
10027
+ throw new import_errors27.FuelError(import_errors27.ErrorCode.HD_WALLET_ERROR, "Invalid private extended key.");
9991
10028
  }
9992
10029
  return new HDWallet({
9993
10030
  privateKey: key.slice(1),
@@ -10231,26 +10268,26 @@ var WalletsConfig = class {
10231
10268
  amountPerCoin
10232
10269
  }) {
10233
10270
  if (Array.isArray(wallets) && wallets.length === 0 || typeof wallets === "number" && wallets <= 0) {
10234
- throw new import_errors27.FuelError(
10235
- import_errors27.FuelError.CODES.INVALID_INPUT_PARAMETERS,
10271
+ throw new import_errors28.FuelError(
10272
+ import_errors28.FuelError.CODES.INVALID_INPUT_PARAMETERS,
10236
10273
  "Number of wallets must be greater than zero."
10237
10274
  );
10238
10275
  }
10239
10276
  if (Array.isArray(assets) && assets.length === 0 || typeof assets === "number" && assets <= 0) {
10240
- throw new import_errors27.FuelError(
10241
- import_errors27.FuelError.CODES.INVALID_INPUT_PARAMETERS,
10277
+ throw new import_errors28.FuelError(
10278
+ import_errors28.FuelError.CODES.INVALID_INPUT_PARAMETERS,
10242
10279
  "Number of assets per wallet must be greater than zero."
10243
10280
  );
10244
10281
  }
10245
10282
  if (coinsPerAsset <= 0) {
10246
- throw new import_errors27.FuelError(
10247
- import_errors27.FuelError.CODES.INVALID_INPUT_PARAMETERS,
10283
+ throw new import_errors28.FuelError(
10284
+ import_errors28.FuelError.CODES.INVALID_INPUT_PARAMETERS,
10248
10285
  "Number of coins per asset must be greater than zero."
10249
10286
  );
10250
10287
  }
10251
10288
  if ((0, import_math24.bn)(amountPerCoin).lt(0)) {
10252
- throw new import_errors27.FuelError(
10253
- import_errors27.FuelError.CODES.INVALID_INPUT_PARAMETERS,
10289
+ throw new import_errors28.FuelError(
10290
+ import_errors28.FuelError.CODES.INVALID_INPUT_PARAMETERS,
10254
10291
  "Amount per coin must be greater than or equal to zero."
10255
10292
  );
10256
10293
  }