@fuel-ts/account 0.94.2 → 0.94.4

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.
Files changed (35) hide show
  1. package/dist/account.d.ts +1 -1
  2. package/dist/account.d.ts.map +1 -1
  3. package/dist/index.global.js +376 -277
  4. package/dist/index.global.js.map +1 -1
  5. package/dist/index.js +328 -173
  6. package/dist/index.js.map +1 -1
  7. package/dist/index.mjs +325 -173
  8. package/dist/index.mjs.map +1 -1
  9. package/dist/predicate/predicate.d.ts.map +1 -1
  10. package/dist/providers/__generated__/operations.d.ts +81 -0
  11. package/dist/providers/__generated__/operations.d.ts.map +1 -1
  12. package/dist/providers/message.d.ts +3 -0
  13. package/dist/providers/message.d.ts.map +1 -1
  14. package/dist/providers/provider.d.ts +27 -2
  15. package/dist/providers/provider.d.ts.map +1 -1
  16. package/dist/providers/transaction-request/blob-transaction-request.d.ts.map +1 -1
  17. package/dist/providers/transaction-request/create-transaction-request.d.ts.map +1 -1
  18. package/dist/providers/transaction-request/helpers.d.ts +2 -0
  19. package/dist/providers/transaction-request/helpers.d.ts.map +1 -1
  20. package/dist/providers/transaction-request/script-transaction-request.d.ts.map +1 -1
  21. package/dist/providers/transaction-request/transaction-request.d.ts +4 -2
  22. package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
  23. package/dist/providers/utils/extract-tx-error.d.ts.map +1 -1
  24. package/dist/providers/utils/handle-gql-error-message.d.ts +6 -0
  25. package/dist/providers/utils/handle-gql-error-message.d.ts.map +1 -0
  26. package/dist/test-utils/launchNode.d.ts.map +1 -1
  27. package/dist/test-utils.global.js +220 -127
  28. package/dist/test-utils.global.js.map +1 -1
  29. package/dist/test-utils.js +283 -140
  30. package/dist/test-utils.js.map +1 -1
  31. package/dist/test-utils.mjs +281 -138
  32. package/dist/test-utils.mjs.map +1 -1
  33. package/dist/wallet/base-wallet-unlocked.d.ts +1 -1
  34. package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
  35. package/package.json +16 -16
@@ -311,20 +311,14 @@ var launchNode = async ({
311
311
  const rows = text.split("\n");
312
312
  const rowWithUrl = rows.find((row) => row.indexOf(graphQLStartSubstring) !== -1);
313
313
  const [realIp, realPort] = rowWithUrl.split(" ").at(-1).trim().split(":");
314
- setTimeout(
315
- () => (
316
- // Resolve with the cleanup method.
317
- resolve({
318
- cleanup,
319
- ip: realIp,
320
- port: realPort,
321
- url: `http://${realIp}:${realPort}/v1/graphql`,
322
- snapshotDir: snapshotDirToUse,
323
- pid: child.pid
324
- })
325
- ),
326
- 500
327
- );
314
+ resolve({
315
+ cleanup,
316
+ ip: realIp,
317
+ port: realPort,
318
+ url: `http://${realIp}:${realPort}/v1/graphql`,
319
+ snapshotDir: snapshotDirToUse,
320
+ pid: child.pid
321
+ });
328
322
  }
329
323
  if (/error/i.test(text)) {
330
324
  console.log(text);
@@ -382,14 +376,15 @@ var addAmountToCoinQuantities = (params) => {
382
376
 
383
377
  // src/providers/provider.ts
384
378
  import { Address as Address3 } from "@fuel-ts/address";
385
- import { ErrorCode as ErrorCode13, FuelError as FuelError15 } from "@fuel-ts/errors";
379
+ import { ErrorCode as ErrorCode14, FuelError as FuelError16 } from "@fuel-ts/errors";
386
380
  import { BN as BN2, bn as bn17 } from "@fuel-ts/math";
387
381
  import { InputType as InputType7, InputMessageCoder, TransactionCoder as TransactionCoder5 } from "@fuel-ts/transactions";
388
382
  import { arrayify as arrayify12, hexlify as hexlify14, DateTime as DateTime2, isDefined as isDefined2 } from "@fuel-ts/utils";
389
383
  import { checkFuelCoreVersionCompatibility } from "@fuel-ts/versions";
390
384
  import { equalBytes } from "@noble/curves/abstract/utils";
391
385
  import { GraphQLClient } from "graphql-request";
392
- import { clone as clone3 } from "ramda";
386
+ import gql2 from "graphql-tag";
387
+ import { clone as clone6 } from "ramda";
393
388
 
394
389
  // src/providers/__generated__/operations.ts
395
390
  import gql from "graphql-tag";
@@ -722,6 +717,14 @@ var BlockFragmentDoc = gql`
722
717
  height
723
718
  header {
724
719
  time
720
+ daHeight
721
+ stateTransitionBytecodeVersion
722
+ transactionsCount
723
+ transactionsRoot
724
+ messageOutboxRoot
725
+ eventInboxRoot
726
+ prevRoot
727
+ applicationHash
725
728
  }
726
729
  transactions {
727
730
  id
@@ -1716,6 +1719,9 @@ import {
1716
1719
  } from "@fuel-ts/transactions";
1717
1720
  import { concat as concat2, hexlify as hexlify9, isDefined } from "@fuel-ts/utils";
1718
1721
 
1722
+ // src/providers/message.ts
1723
+ var isMessageCoin = (message) => !("data" in message);
1724
+
1719
1725
  // src/providers/resource.ts
1720
1726
  var isCoin = (resource) => "id" in resource;
1721
1727
 
@@ -2103,20 +2109,22 @@ var assembleRevertError = (receipts, logs, metadata) => {
2103
2109
  let reason = "";
2104
2110
  if (revertReceipt) {
2105
2111
  const reasonHex = bn6(revertReceipt.val).toHex();
2112
+ const lastLog = logs[logs.length - 1];
2113
+ const lastButOneLog = logs[logs.length - 2];
2106
2114
  switch (reasonHex) {
2107
2115
  case FAILED_REQUIRE_SIGNAL: {
2108
2116
  reason = "require";
2109
- errorMessage = `The transaction reverted because a "require" statement has thrown ${logs.length ? stringify(logs[0]) : "an error."}.`;
2117
+ errorMessage = `The transaction reverted because a "require" statement has thrown ${logs.length ? stringify(lastLog) : "an error."}.`;
2110
2118
  break;
2111
2119
  }
2112
2120
  case FAILED_ASSERT_EQ_SIGNAL: {
2113
- const sufix = logs.length >= 2 ? ` comparing ${stringify(logs[1])} and ${stringify(logs[0])}.` : ".";
2121
+ const sufix = logs.length >= 2 ? ` comparing ${stringify(lastLog)} and ${stringify(lastButOneLog)}.` : ".";
2114
2122
  reason = "assert_eq";
2115
2123
  errorMessage = `The transaction reverted because of an "assert_eq" statement${sufix}`;
2116
2124
  break;
2117
2125
  }
2118
2126
  case FAILED_ASSERT_NE_SIGNAL: {
2119
- const sufix = logs.length >= 2 ? ` comparing ${stringify(logs[1])} and ${stringify(logs[0])}.` : ".";
2127
+ const sufix = logs.length >= 2 ? ` comparing ${stringify(lastButOneLog)} and ${stringify(lastLog)}.` : ".";
2120
2128
  reason = "assert_ne";
2121
2129
  errorMessage = `The transaction reverted because of an "assert_ne" statement${sufix}`;
2122
2130
  break;
@@ -2177,7 +2185,9 @@ import { bn as bn7 } from "@fuel-ts/math";
2177
2185
  import { InputType as InputType2 } from "@fuel-ts/transactions";
2178
2186
  var isRequestInputCoin = (input) => input.type === InputType2.Coin;
2179
2187
  var isRequestInputMessage = (input) => input.type === InputType2.Message;
2180
- var isRequestInputResource = (input) => isRequestInputCoin(input) || isRequestInputMessage(input);
2188
+ var isRequestInputMessageWithoutData = (input) => input.type === InputType2.Message && bn7(input.data).isZero();
2189
+ var isRequestInputCoinOrMessage = (input) => isRequestInputCoin(input) || isRequestInputMessage(input);
2190
+ var isRequestInputResource = (input) => isRequestInputCoin(input) || isRequestInputMessageWithoutData(input);
2181
2191
  var getRequestInputResourceOwner = (input) => isRequestInputCoin(input) ? input.owner : input.recipient;
2182
2192
  var isRequestInputResourceFromOwner = (input, owner) => getRequestInputResourceOwner(input) === owner.toB256();
2183
2193
  var getAssetAmountInRequestInputs = (inputs, assetId, baseAsset) => inputs.filter(isRequestInputResource).reduce((acc, input) => {
@@ -2473,7 +2483,7 @@ var BaseTransactionRequest = class {
2473
2483
  * @param message - Message resource.
2474
2484
  */
2475
2485
  addMessageInput(message) {
2476
- const { recipient, sender, amount, predicate, nonce, assetId, predicateData } = message;
2486
+ const { recipient, sender, amount, predicate, nonce, predicateData } = message;
2477
2487
  let witnessIndex;
2478
2488
  if (message.predicate) {
2479
2489
  witnessIndex = 0;
@@ -2488,13 +2498,16 @@ var BaseTransactionRequest = class {
2488
2498
  type: InputType3.Message,
2489
2499
  sender: sender.toB256(),
2490
2500
  recipient: recipient.toB256(),
2501
+ data: isMessageCoin(message) ? "0x" : message.data,
2491
2502
  amount,
2492
2503
  witnessIndex,
2493
2504
  predicate,
2494
2505
  predicateData
2495
2506
  };
2496
2507
  this.pushInput(input);
2497
- this.addChangeOutput(recipient, assetId);
2508
+ if (isMessageCoin(message)) {
2509
+ this.addChangeOutput(recipient, message.assetId);
2510
+ }
2498
2511
  }
2499
2512
  /**
2500
2513
  * Adds a single resource to the transaction by adding a coin/message input and a
@@ -2626,6 +2639,8 @@ var BaseTransactionRequest = class {
2626
2639
  *
2627
2640
  * @param quantities - CoinQuantity Array.
2628
2641
  * @param baseAssetId - The base asset to fund the transaction.
2642
+ * @deprecated - This method is deprecated and will be removed in future versions.
2643
+ * Please use `Account.generateFakeResources` along with `this.addResources` instead.
2629
2644
  */
2630
2645
  fundWithFakeUtxos(quantities, baseAssetId, resourcesOwner) {
2631
2646
  const findAssetInput = (assetId) => this.inputs.find((input) => {
@@ -2694,7 +2709,7 @@ var BaseTransactionRequest = class {
2694
2709
  });
2695
2710
  }
2696
2711
  updatePredicateGasUsed(inputs) {
2697
- const inputsToExtractGasUsed = inputs.filter(isRequestInputResource);
2712
+ const inputsToExtractGasUsed = inputs.filter(isRequestInputCoinOrMessage);
2698
2713
  this.inputs.filter(isRequestInputResource).forEach((i) => {
2699
2714
  const owner = getRequestInputResourceOwner(i);
2700
2715
  const correspondingInput = inputsToExtractGasUsed.find(
@@ -2710,6 +2725,9 @@ var BaseTransactionRequest = class {
2710
2725
  }
2711
2726
  };
2712
2727
 
2728
+ // src/providers/transaction-request/blob-transaction-request.ts
2729
+ import { clone as clone3 } from "ramda";
2730
+
2713
2731
  // src/providers/transaction-request/hash-transaction.ts
2714
2732
  import { ZeroBytes32 as ZeroBytes325 } from "@fuel-ts/address/configs";
2715
2733
  import { uint64ToBytesBE, sha256 } from "@fuel-ts/hasher";
@@ -2784,10 +2802,7 @@ function hashTransaction(transactionRequest, chainId) {
2784
2802
  // src/providers/transaction-request/blob-transaction-request.ts
2785
2803
  var BlobTransactionRequest = class extends BaseTransactionRequest {
2786
2804
  static from(obj) {
2787
- if (obj instanceof this) {
2788
- return obj;
2789
- }
2790
- return new this(obj);
2805
+ return new this(clone3(obj));
2791
2806
  }
2792
2807
  /** Type of the transaction */
2793
2808
  type = TransactionType.Blob;
@@ -2850,6 +2865,7 @@ import { ZeroBytes32 as ZeroBytes326 } from "@fuel-ts/address/configs";
2850
2865
  import { bn as bn10 } from "@fuel-ts/math";
2851
2866
  import { TransactionType as TransactionType3, OutputType as OutputType4 } from "@fuel-ts/transactions";
2852
2867
  import { arrayify as arrayify7, hexlify as hexlify11 } from "@fuel-ts/utils";
2868
+ import { clone as clone4 } from "ramda";
2853
2869
 
2854
2870
  // src/providers/transaction-request/storage-slot.ts
2855
2871
  import { arrayify as arrayify6, hexlify as hexlify10 } from "@fuel-ts/utils";
@@ -2877,10 +2893,7 @@ var storageSlotify = (storageSlot) => {
2877
2893
  // src/providers/transaction-request/create-transaction-request.ts
2878
2894
  var CreateTransactionRequest = class extends BaseTransactionRequest {
2879
2895
  static from(obj) {
2880
- if (obj instanceof this) {
2881
- return obj;
2882
- }
2883
- return new this(obj);
2896
+ return new this(clone4(obj));
2884
2897
  }
2885
2898
  /** Type of the transaction */
2886
2899
  type = TransactionType3.Create;
@@ -2969,6 +2982,7 @@ import { ZeroBytes32 as ZeroBytes327 } from "@fuel-ts/address/configs";
2969
2982
  import { bn as bn11 } from "@fuel-ts/math";
2970
2983
  import { InputType as InputType5, OutputType as OutputType5, TransactionType as TransactionType4 } from "@fuel-ts/transactions";
2971
2984
  import { arrayify as arrayify9, hexlify as hexlify12 } from "@fuel-ts/utils";
2985
+ import { clone as clone5 } from "ramda";
2972
2986
 
2973
2987
  // src/providers/transaction-request/scripts.ts
2974
2988
  import { arrayify as arrayify8 } from "@fuel-ts/utils";
@@ -2999,10 +3013,7 @@ var withdrawScript = {
2999
3013
  // src/providers/transaction-request/script-transaction-request.ts
3000
3014
  var ScriptTransactionRequest = class extends BaseTransactionRequest {
3001
3015
  static from(obj) {
3002
- if (obj instanceof this) {
3003
- return obj;
3004
- }
3005
- return new this(obj);
3016
+ return new this(clone5(obj));
3006
3017
  }
3007
3018
  /** Type of the transaction */
3008
3019
  type = TransactionType4.Script;
@@ -4308,6 +4319,22 @@ function autoRetryFetch(fetchFn, options, retryAttemptNum = 0) {
4308
4319
  };
4309
4320
  }
4310
4321
 
4322
+ // src/providers/utils/handle-gql-error-message.ts
4323
+ import { ErrorCode as ErrorCode13, FuelError as FuelError15 } from "@fuel-ts/errors";
4324
+ var handleGqlErrorMessage = (errorMessage, rawError) => {
4325
+ switch (errorMessage) {
4326
+ case "not enough coins to fit the target" /* NOT_ENOUGH_COINS */:
4327
+ throw new FuelError15(
4328
+ ErrorCode13.NOT_ENOUGH_FUNDS,
4329
+ `The account(s) sending the transaction don't have enough funds to cover the transaction.`,
4330
+ {},
4331
+ rawError
4332
+ );
4333
+ default:
4334
+ throw new FuelError15(ErrorCode13.INVALID_REQUEST, errorMessage);
4335
+ }
4336
+ };
4337
+
4311
4338
  // src/providers/provider.ts
4312
4339
  var MAX_RETRIES = 10;
4313
4340
  var RESOURCES_PAGE_SIZE_LIMIT = 512;
@@ -4434,6 +4461,17 @@ var _Provider = class {
4434
4461
  return options.fetch ? options.fetch(url, fullRequest, options) : fetch(url, fullRequest);
4435
4462
  }, retryOptions);
4436
4463
  }
4464
+ static extractBasicAuth(url) {
4465
+ const parsedUrl = new URL(url);
4466
+ const username = parsedUrl.username;
4467
+ const password = parsedUrl.password;
4468
+ const urlNoBasicAuth = `${parsedUrl.origin}${parsedUrl.pathname}`;
4469
+ if (!(username && password)) {
4470
+ return { url, auth: void 0 };
4471
+ }
4472
+ const auth = `Basic ${btoa(`${username}:${password}`)}`;
4473
+ return { url: urlNoBasicAuth, auth };
4474
+ }
4437
4475
  /**
4438
4476
  * Creates a new instance of the Provider class. This is the recommended way to initialize a Provider.
4439
4477
  *
@@ -4443,7 +4481,17 @@ var _Provider = class {
4443
4481
  * @returns A promise that resolves to a Provider instance.
4444
4482
  */
4445
4483
  static async create(url, options = {}) {
4446
- const provider = new _Provider(url, options);
4484
+ const { url: urlToUse, auth } = this.extractBasicAuth(url);
4485
+ const provider = new _Provider(urlToUse, {
4486
+ ...options,
4487
+ requestMiddleware: async (request) => {
4488
+ if (auth) {
4489
+ request.headers ??= {};
4490
+ request.headers.Authorization = auth;
4491
+ }
4492
+ return options.requestMiddleware?.(request) ?? request;
4493
+ }
4494
+ });
4447
4495
  await provider.fetchChainAndNodeInfo();
4448
4496
  return provider;
4449
4497
  }
@@ -4455,8 +4503,8 @@ var _Provider = class {
4455
4503
  getChain() {
4456
4504
  const chain = _Provider.chainInfoCache[this.url];
4457
4505
  if (!chain) {
4458
- throw new FuelError15(
4459
- ErrorCode13.CHAIN_INFO_CACHE_EMPTY,
4506
+ throw new FuelError16(
4507
+ ErrorCode14.CHAIN_INFO_CACHE_EMPTY,
4460
4508
  "Chain info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
4461
4509
  );
4462
4510
  }
@@ -4470,8 +4518,8 @@ var _Provider = class {
4470
4518
  getNode() {
4471
4519
  const node = _Provider.nodeInfoCache[this.url];
4472
4520
  if (!node) {
4473
- throw new FuelError15(
4474
- ErrorCode13.NODE_INFO_CACHE_EMPTY,
4521
+ throw new FuelError16(
4522
+ ErrorCode14.NODE_INFO_CACHE_EMPTY,
4475
4523
  "Node info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
4476
4524
  );
4477
4525
  }
@@ -4549,10 +4597,9 @@ Supported fuel-core version: ${supportedVersion}.`
4549
4597
  if ("response" in response) {
4550
4598
  const graphQlResponse = response.response;
4551
4599
  if (Array.isArray(graphQlResponse?.errors)) {
4552
- throw new FuelError15(
4553
- FuelError15.CODES.INVALID_REQUEST,
4554
- graphQlResponse.errors.map((err) => err.message).join("\n\n")
4555
- );
4600
+ for (const error of graphQlResponse.errors) {
4601
+ handleGqlErrorMessage(error.message, error);
4602
+ }
4556
4603
  }
4557
4604
  }
4558
4605
  }
@@ -4570,7 +4617,26 @@ Supported fuel-core version: ${supportedVersion}.`
4570
4617
  }
4571
4618
  return gqlClient.request(query, vars);
4572
4619
  };
4573
- return getSdk(executeQuery);
4620
+ const customOperations = (requester) => ({
4621
+ getBlobs(variables) {
4622
+ const queryParams = variables.blobIds.map((_, i) => `$blobId${i}: BlobId!`).join(", ");
4623
+ const blobParams = variables.blobIds.map((_, i) => `blob${i}: blob(id: $blobId${i}) { id }`).join("\n");
4624
+ const updatedVariables = variables.blobIds.reduce(
4625
+ (acc, blobId, i) => {
4626
+ acc[`blobId${i}`] = blobId;
4627
+ return acc;
4628
+ },
4629
+ {}
4630
+ );
4631
+ const document = gql2`
4632
+ query getBlobs(${queryParams}) {
4633
+ ${blobParams}
4634
+ }
4635
+ `;
4636
+ return requester(document, updatedVariables);
4637
+ }
4638
+ });
4639
+ return { ...getSdk(executeQuery), ...customOperations(executeQuery) };
4574
4640
  }
4575
4641
  /**
4576
4642
  * Returns the version of the connected node.
@@ -4645,14 +4711,14 @@ Supported fuel-core version: ${supportedVersion}.`
4645
4711
  validateTransaction(tx, consensusParameters) {
4646
4712
  const { maxOutputs, maxInputs } = consensusParameters.txParameters;
4647
4713
  if (bn17(tx.inputs.length).gt(maxInputs)) {
4648
- throw new FuelError15(
4649
- ErrorCode13.MAX_INPUTS_EXCEEDED,
4714
+ throw new FuelError16(
4715
+ ErrorCode14.MAX_INPUTS_EXCEEDED,
4650
4716
  "The transaction exceeds the maximum allowed number of inputs."
4651
4717
  );
4652
4718
  }
4653
4719
  if (bn17(tx.outputs.length).gt(maxOutputs)) {
4654
- throw new FuelError15(
4655
- ErrorCode13.MAX_OUTPUTS_EXCEEDED,
4720
+ throw new FuelError16(
4721
+ ErrorCode14.MAX_OUTPUTS_EXCEEDED,
4656
4722
  "The transaction exceeds the maximum allowed number of outputs."
4657
4723
  );
4658
4724
  }
@@ -4667,7 +4733,6 @@ Supported fuel-core version: ${supportedVersion}.`
4667
4733
  * @param sendTransactionParams - The provider send transaction parameters (optional).
4668
4734
  * @returns A promise that resolves to the transaction response object.
4669
4735
  */
4670
- // #region Provider-sendTransaction
4671
4736
  async sendTransaction(transactionRequestLike, { estimateTxDependencies = true } = {}) {
4672
4737
  const transactionRequest = transactionRequestify(transactionRequestLike);
4673
4738
  if (estimateTxDependencies) {
@@ -4814,7 +4879,7 @@ Supported fuel-core version: ${supportedVersion}.`
4814
4879
  missingContractIds: [],
4815
4880
  dryRunStatus: void 0
4816
4881
  }));
4817
- const allRequests = clone3(transactionRequests);
4882
+ const allRequests = clone6(transactionRequests);
4818
4883
  const serializedTransactionsMap = /* @__PURE__ */ new Map();
4819
4884
  allRequests.forEach((req, index) => {
4820
4885
  if (isTransactionTypeScript(req)) {
@@ -4974,13 +5039,13 @@ Supported fuel-core version: ${supportedVersion}.`
4974
5039
  * @returns A promise that resolves to the transaction cost object.
4975
5040
  */
4976
5041
  async getTransactionCost(transactionRequestLike, { signatureCallback } = {}) {
4977
- const txRequestClone = clone3(transactionRequestify(transactionRequestLike));
5042
+ const txRequestClone = clone6(transactionRequestify(transactionRequestLike));
4978
5043
  const updateMaxFee = txRequestClone.maxFee.eq(0);
4979
5044
  const isScriptTransaction = isTransactionTypeScript(txRequestClone);
4980
5045
  if (isScriptTransaction) {
4981
5046
  txRequestClone.gasLimit = bn17(0);
4982
5047
  }
4983
- const signedRequest = clone3(txRequestClone);
5048
+ const signedRequest = clone6(txRequestClone);
4984
5049
  let addedSignatures = 0;
4985
5050
  if (signatureCallback && isTransactionTypeScript(signedRequest)) {
4986
5051
  const lengthBefore = signedRequest.witnesses.length;
@@ -5118,6 +5183,21 @@ Supported fuel-core version: ${supportedVersion}.`
5118
5183
  }).filter((v) => !!v);
5119
5184
  return coins;
5120
5185
  }
5186
+ /**
5187
+ * Returns an array of blobIds that exist on chain, for a given array of blobIds.
5188
+ *
5189
+ * @param blobIds - blobIds to check.
5190
+ * @returns - A promise that resolves to an array of blobIds that exist on chain.
5191
+ */
5192
+ async getBlobs(blobIds) {
5193
+ const res = await this.operations.getBlobs({ blobIds });
5194
+ const blobs = [];
5195
+ Object.keys(res).forEach((key) => {
5196
+ const val = res[key];
5197
+ blobs.push(val?.id ?? null);
5198
+ });
5199
+ return blobs.filter((v) => v);
5200
+ }
5121
5201
  /**
5122
5202
  * Returns block matching the given ID or height.
5123
5203
  *
@@ -5139,11 +5219,22 @@ Supported fuel-core version: ${supportedVersion}.`
5139
5219
  if (!block) {
5140
5220
  return null;
5141
5221
  }
5222
+ const { header, height, id, transactions } = block;
5142
5223
  return {
5143
- id: block.id,
5144
- height: bn17(block.height),
5145
- time: block.header.time,
5146
- transactionIds: block.transactions.map((tx) => tx.id)
5224
+ id,
5225
+ height: bn17(height),
5226
+ time: header.time,
5227
+ header: {
5228
+ applicationHash: header.applicationHash,
5229
+ daHeight: bn17(header.daHeight),
5230
+ eventInboxRoot: header.eventInboxRoot,
5231
+ messageOutboxRoot: header.messageOutboxRoot,
5232
+ prevRoot: header.prevRoot,
5233
+ stateTransitionBytecodeVersion: header.stateTransitionBytecodeVersion,
5234
+ transactionsCount: header.transactionsCount,
5235
+ transactionsRoot: header.transactionsRoot
5236
+ },
5237
+ transactionIds: transactions.map((tx) => tx.id)
5147
5238
  };
5148
5239
  }
5149
5240
  /**
@@ -5165,6 +5256,16 @@ Supported fuel-core version: ${supportedVersion}.`
5165
5256
  id: block.id,
5166
5257
  height: bn17(block.height),
5167
5258
  time: block.header.time,
5259
+ header: {
5260
+ applicationHash: block.header.applicationHash,
5261
+ daHeight: bn17(block.header.daHeight),
5262
+ eventInboxRoot: block.header.eventInboxRoot,
5263
+ messageOutboxRoot: block.header.messageOutboxRoot,
5264
+ prevRoot: block.header.prevRoot,
5265
+ stateTransitionBytecodeVersion: block.header.stateTransitionBytecodeVersion,
5266
+ transactionsCount: block.header.transactionsCount,
5267
+ transactionsRoot: block.header.transactionsRoot
5268
+ },
5168
5269
  transactionIds: block.transactions.map((tx) => tx.id)
5169
5270
  }));
5170
5271
  return { blocks, pageInfo };
@@ -5192,6 +5293,16 @@ Supported fuel-core version: ${supportedVersion}.`
5192
5293
  id: block.id,
5193
5294
  height: bn17(block.height, 10),
5194
5295
  time: block.header.time,
5296
+ header: {
5297
+ applicationHash: block.header.applicationHash,
5298
+ daHeight: bn17(block.header.daHeight),
5299
+ eventInboxRoot: block.header.eventInboxRoot,
5300
+ messageOutboxRoot: block.header.messageOutboxRoot,
5301
+ prevRoot: block.header.prevRoot,
5302
+ stateTransitionBytecodeVersion: block.header.stateTransitionBytecodeVersion,
5303
+ transactionsCount: block.header.transactionsCount,
5304
+ transactionsRoot: block.header.transactionsRoot
5305
+ },
5195
5306
  transactionIds: block.transactions.map((tx) => tx.id),
5196
5307
  transactions: block.transactions.map(
5197
5308
  (tx) => new TransactionCoder5().decode(arrayify12(tx.rawPayload), 0)?.[0]
@@ -5209,10 +5320,18 @@ Supported fuel-core version: ${supportedVersion}.`
5209
5320
  if (!transaction) {
5210
5321
  return null;
5211
5322
  }
5212
- return new TransactionCoder5().decode(
5213
- arrayify12(transaction.rawPayload),
5214
- 0
5215
- )?.[0];
5323
+ try {
5324
+ return new TransactionCoder5().decode(
5325
+ arrayify12(transaction.rawPayload),
5326
+ 0
5327
+ )?.[0];
5328
+ } catch (error) {
5329
+ if (error instanceof FuelError16 && error.code === ErrorCode14.UNSUPPORTED_TRANSACTION_TYPE) {
5330
+ console.warn("Unsupported transaction type encountered");
5331
+ return null;
5332
+ }
5333
+ throw error;
5334
+ }
5216
5335
  }
5217
5336
  /**
5218
5337
  * Retrieves transactions based on the provided pagination arguments.
@@ -5224,9 +5343,17 @@ Supported fuel-core version: ${supportedVersion}.`
5224
5343
  transactions: { edges, pageInfo }
5225
5344
  } = await this.operations.getTransactions(paginationArgs);
5226
5345
  const coder = new TransactionCoder5();
5227
- const transactions = edges.map(
5228
- ({ node: { rawPayload } }) => coder.decode(arrayify12(rawPayload), 0)[0]
5229
- );
5346
+ const transactions = edges.map(({ node: { rawPayload } }) => {
5347
+ try {
5348
+ return coder.decode(arrayify12(rawPayload), 0)[0];
5349
+ } catch (error) {
5350
+ if (error instanceof FuelError16 && error.code === ErrorCode14.UNSUPPORTED_TRANSACTION_TYPE) {
5351
+ console.warn("Unsupported transaction type encountered");
5352
+ return null;
5353
+ }
5354
+ throw error;
5355
+ }
5356
+ }).filter((tx) => tx !== null);
5230
5357
  return { transactions, pageInfo };
5231
5358
  }
5232
5359
  /**
@@ -5346,8 +5473,8 @@ Supported fuel-core version: ${supportedVersion}.`
5346
5473
  nonce
5347
5474
  };
5348
5475
  if (commitBlockId && commitBlockHeight) {
5349
- throw new FuelError15(
5350
- ErrorCode13.INVALID_INPUT_PARAMETERS,
5476
+ throw new FuelError16(
5477
+ ErrorCode14.INVALID_INPUT_PARAMETERS,
5351
5478
  "commitBlockId and commitBlockHeight cannot be used together"
5352
5479
  );
5353
5480
  }
@@ -5487,10 +5614,25 @@ Supported fuel-core version: ${supportedVersion}.`
5487
5614
  * @returns A promise that resolves to the Message object or null.
5488
5615
  */
5489
5616
  async getMessageByNonce(nonce) {
5490
- const { message } = await this.operations.getMessageByNonce({ nonce });
5491
- if (!message) {
5617
+ const { message: rawMessage } = await this.operations.getMessageByNonce({ nonce });
5618
+ if (!rawMessage) {
5492
5619
  return null;
5493
5620
  }
5621
+ const message = {
5622
+ messageId: InputMessageCoder.getMessageId({
5623
+ sender: rawMessage.sender,
5624
+ recipient: rawMessage.recipient,
5625
+ nonce: rawMessage.nonce,
5626
+ amount: bn17(rawMessage.amount),
5627
+ data: rawMessage.data
5628
+ }),
5629
+ sender: Address3.fromAddressOrString(rawMessage.sender),
5630
+ recipient: Address3.fromAddressOrString(rawMessage.recipient),
5631
+ nonce: rawMessage.nonce,
5632
+ amount: bn17(rawMessage.amount),
5633
+ data: InputMessageCoder.decodeData(rawMessage.data),
5634
+ daHeight: bn17(rawMessage.daHeight)
5635
+ };
5494
5636
  return message;
5495
5637
  }
5496
5638
  /**
@@ -5515,26 +5657,26 @@ Supported fuel-core version: ${supportedVersion}.`
5515
5657
  const { paginationLimit, inputArgs = {} } = params;
5516
5658
  const { first, last, after, before } = inputArgs;
5517
5659
  if (after && before) {
5518
- throw new FuelError15(
5519
- ErrorCode13.INVALID_INPUT_PARAMETERS,
5660
+ throw new FuelError16(
5661
+ ErrorCode14.INVALID_INPUT_PARAMETERS,
5520
5662
  'Pagination arguments "after" and "before" cannot be used together'
5521
5663
  );
5522
5664
  }
5523
5665
  if ((first || 0) > paginationLimit || (last || 0) > paginationLimit) {
5524
- throw new FuelError15(
5525
- ErrorCode13.INVALID_INPUT_PARAMETERS,
5666
+ throw new FuelError16(
5667
+ ErrorCode14.INVALID_INPUT_PARAMETERS,
5526
5668
  `Pagination limit for this query cannot exceed ${paginationLimit} items`
5527
5669
  );
5528
5670
  }
5529
5671
  if (first && before) {
5530
- throw new FuelError15(
5531
- ErrorCode13.INVALID_INPUT_PARAMETERS,
5672
+ throw new FuelError16(
5673
+ ErrorCode14.INVALID_INPUT_PARAMETERS,
5532
5674
  'The use of pagination argument "first" with "before" is not supported'
5533
5675
  );
5534
5676
  }
5535
5677
  if (last && after) {
5536
- throw new FuelError15(
5537
- ErrorCode13.INVALID_INPUT_PARAMETERS,
5678
+ throw new FuelError16(
5679
+ ErrorCode14.INVALID_INPUT_PARAMETERS,
5538
5680
  'The use of pagination argument "last" with "after" is not supported'
5539
5681
  );
5540
5682
  }
@@ -5588,7 +5730,7 @@ __publicField(Provider, "chainInfoCache", {});
5588
5730
  __publicField(Provider, "nodeInfoCache", {});
5589
5731
 
5590
5732
  // src/providers/transaction-summary/get-transaction-summary.ts
5591
- import { ErrorCode as ErrorCode14, FuelError as FuelError16 } from "@fuel-ts/errors";
5733
+ import { ErrorCode as ErrorCode15, FuelError as FuelError17 } from "@fuel-ts/errors";
5592
5734
  import { bn as bn18 } from "@fuel-ts/math";
5593
5735
  import { TransactionCoder as TransactionCoder6 } from "@fuel-ts/transactions";
5594
5736
  import { arrayify as arrayify13 } from "@fuel-ts/utils";
@@ -5689,7 +5831,7 @@ __publicField(TestAssetId, "B", new _TestAssetId(
5689
5831
 
5690
5832
  // src/test-utils/wallet-config.ts
5691
5833
  import { randomBytes as randomBytes8 } from "@fuel-ts/crypto";
5692
- import { FuelError as FuelError22 } from "@fuel-ts/errors";
5834
+ import { FuelError as FuelError23 } from "@fuel-ts/errors";
5693
5835
  import { defaultSnapshotConfigs as defaultSnapshotConfigs2, hexlify as hexlify21 } from "@fuel-ts/utils";
5694
5836
 
5695
5837
  // src/wallet/base-wallet-unlocked.ts
@@ -5700,11 +5842,12 @@ import { hexlify as hexlify18 } from "@fuel-ts/utils";
5700
5842
  import { UTXO_ID_LEN as UTXO_ID_LEN3 } from "@fuel-ts/abi-coder";
5701
5843
  import { Address as Address4 } from "@fuel-ts/address";
5702
5844
  import { randomBytes as randomBytes5 } from "@fuel-ts/crypto";
5703
- import { ErrorCode as ErrorCode15, FuelError as FuelError17 } from "@fuel-ts/errors";
5845
+ import { ErrorCode as ErrorCode16, FuelError as FuelError18 } from "@fuel-ts/errors";
5704
5846
  import { AbstractAccount } from "@fuel-ts/interfaces";
5705
5847
  import { bn as bn19 } from "@fuel-ts/math";
5848
+ import { InputType as InputType8 } from "@fuel-ts/transactions";
5706
5849
  import { arrayify as arrayify15, hexlify as hexlify16, isDefined as isDefined3 } from "@fuel-ts/utils";
5707
- import { clone as clone4 } from "ramda";
5850
+ import { clone as clone7 } from "ramda";
5708
5851
 
5709
5852
  // src/providers/utils/merge-quantities.ts
5710
5853
  var mergeQuantities = (...coinQuantities) => {
@@ -5793,7 +5936,7 @@ var Account = class extends AbstractAccount {
5793
5936
  */
5794
5937
  get provider() {
5795
5938
  if (!this._provider) {
5796
- throw new FuelError17(ErrorCode15.MISSING_PROVIDER, "Provider not set");
5939
+ throw new FuelError18(ErrorCode16.MISSING_PROVIDER, "Provider not set");
5797
5940
  }
5798
5941
  return this._provider;
5799
5942
  }
@@ -5911,7 +6054,7 @@ var Account = class extends AbstractAccount {
5911
6054
  );
5912
6055
  request.addResources(resources);
5913
6056
  request.updatePredicateGasUsed(estimatedPredicates);
5914
- const requestToReestimate2 = clone4(request);
6057
+ const requestToReestimate2 = clone7(request);
5915
6058
  if (addedSignatures) {
5916
6059
  Array.from({ length: addedSignatures }).forEach(
5917
6060
  () => requestToReestimate2.addEmptyWitness()
@@ -5926,7 +6069,7 @@ var Account = class extends AbstractAccount {
5926
6069
  gasPrice
5927
6070
  });
5928
6071
  const totalBaseAssetOnInputs = getAssetAmountInRequestInputs(
5929
- request.inputs,
6072
+ request.inputs.filter(isRequestInputResource),
5930
6073
  baseAssetId,
5931
6074
  baseAssetId
5932
6075
  );
@@ -5944,13 +6087,13 @@ var Account = class extends AbstractAccount {
5944
6087
  fundingAttempts += 1;
5945
6088
  }
5946
6089
  if (needsToBeFunded) {
5947
- throw new FuelError17(
5948
- ErrorCode15.NOT_ENOUGH_FUNDS,
6090
+ throw new FuelError18(
6091
+ ErrorCode16.NOT_ENOUGH_FUNDS,
5949
6092
  `The account ${this.address} does not have enough base asset funds to cover the transaction execution.`
5950
6093
  );
5951
6094
  }
5952
6095
  request.updatePredicateGasUsed(estimatedPredicates);
5953
- const requestToReestimate = clone4(request);
6096
+ const requestToReestimate = clone7(request);
5954
6097
  if (addedSignatures) {
5955
6098
  Array.from({ length: addedSignatures }).forEach(() => requestToReestimate.addEmptyWitness());
5956
6099
  }
@@ -6050,8 +6193,8 @@ var Account = class extends AbstractAccount {
6050
6193
  */
6051
6194
  async transferToContract(contractId, amount, assetId, txParams = {}) {
6052
6195
  if (bn19(amount).lte(0)) {
6053
- throw new FuelError17(
6054
- ErrorCode15.INVALID_TRANSFER_AMOUNT,
6196
+ throw new FuelError18(
6197
+ ErrorCode16.INVALID_TRANSFER_AMOUNT,
6055
6198
  "Transfer amount must be a positive number."
6056
6199
  );
6057
6200
  }
@@ -6126,16 +6269,16 @@ var Account = class extends AbstractAccount {
6126
6269
  * @returns A promise that resolves to the transaction cost object.
6127
6270
  */
6128
6271
  async getTransactionCost(transactionRequestLike, { signatureCallback, quantities = [] } = {}) {
6129
- const txRequestClone = clone4(transactionRequestify(transactionRequestLike));
6272
+ const txRequestClone = clone7(transactionRequestify(transactionRequestLike));
6130
6273
  const baseAssetId = this.provider.getBaseAssetId();
6131
6274
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
6132
6275
  const requiredQuantities = mergeQuantities(coinOutputsQuantities, quantities);
6133
6276
  const transactionFeeForDryRun = [{ assetId: baseAssetId, amount: bn19("100000000000000000") }];
6134
6277
  const findAssetInput = (assetId) => txRequestClone.inputs.find((input) => {
6135
- if ("assetId" in input) {
6278
+ if (input.type === InputType8.Coin) {
6136
6279
  return input.assetId === assetId;
6137
6280
  }
6138
- if ("recipient" in input) {
6281
+ if (isRequestInputMessageWithoutData(input)) {
6139
6282
  return baseAssetId === assetId;
6140
6283
  }
6141
6284
  return false;
@@ -6177,7 +6320,7 @@ var Account = class extends AbstractAccount {
6177
6320
  */
6178
6321
  async signMessage(message) {
6179
6322
  if (!this._connector) {
6180
- throw new FuelError17(ErrorCode15.MISSING_CONNECTOR, "A connector is required to sign messages.");
6323
+ throw new FuelError18(ErrorCode16.MISSING_CONNECTOR, "A connector is required to sign messages.");
6181
6324
  }
6182
6325
  return this._connector.signMessage(this.address.toString(), message);
6183
6326
  }
@@ -6189,8 +6332,8 @@ var Account = class extends AbstractAccount {
6189
6332
  */
6190
6333
  async signTransaction(transactionRequestLike) {
6191
6334
  if (!this._connector) {
6192
- throw new FuelError17(
6193
- ErrorCode15.MISSING_CONNECTOR,
6335
+ throw new FuelError18(
6336
+ ErrorCode16.MISSING_CONNECTOR,
6194
6337
  "A connector is required to sign transactions."
6195
6338
  );
6196
6339
  }
@@ -6249,8 +6392,8 @@ var Account = class extends AbstractAccount {
6249
6392
  /** @hidden * */
6250
6393
  validateTransferAmount(amount) {
6251
6394
  if (bn19(amount).lte(0)) {
6252
- throw new FuelError17(
6253
- ErrorCode15.INVALID_TRANSFER_AMOUNT,
6395
+ throw new FuelError18(
6396
+ ErrorCode16.INVALID_TRANSFER_AMOUNT,
6254
6397
  "Transfer amount must be a positive number."
6255
6398
  );
6256
6399
  }
@@ -6279,16 +6422,16 @@ var Account = class extends AbstractAccount {
6279
6422
  if (!isDefined3(setGasLimit)) {
6280
6423
  request.gasLimit = gasUsed;
6281
6424
  } else if (gasUsed.gt(setGasLimit)) {
6282
- throw new FuelError17(
6283
- ErrorCode15.GAS_LIMIT_TOO_LOW,
6425
+ throw new FuelError18(
6426
+ ErrorCode16.GAS_LIMIT_TOO_LOW,
6284
6427
  `Gas limit '${setGasLimit}' is lower than the required: '${gasUsed}'.`
6285
6428
  );
6286
6429
  }
6287
6430
  if (!isDefined3(setMaxFee)) {
6288
6431
  request.maxFee = maxFee;
6289
6432
  } else if (maxFee.gt(setMaxFee)) {
6290
- throw new FuelError17(
6291
- ErrorCode15.MAX_FEE_TOO_LOW,
6433
+ throw new FuelError18(
6434
+ ErrorCode16.MAX_FEE_TOO_LOW,
6292
6435
  `Max fee '${setMaxFee}' is lower than the required: '${maxFee}'.`
6293
6436
  );
6294
6437
  }
@@ -6308,7 +6451,7 @@ import {
6308
6451
  encryptJsonWalletData,
6309
6452
  randomUUID as randomUUID2
6310
6453
  } from "@fuel-ts/crypto";
6311
- import { ErrorCode as ErrorCode16, FuelError as FuelError18 } from "@fuel-ts/errors";
6454
+ import { ErrorCode as ErrorCode17, FuelError as FuelError19 } from "@fuel-ts/errors";
6312
6455
  import { hexlify as hexlify17 } from "@fuel-ts/utils";
6313
6456
  var DEFAULT_KDF_PARAMS_LOG_N = 13;
6314
6457
  var DEFAULT_KDF_PARAMS_R = 8;
@@ -6385,8 +6528,8 @@ async function decryptKeystoreWallet(jsonWallet, password) {
6385
6528
  const macHashUint8Array = keccak256(data);
6386
6529
  const macHash = stringFromBuffer(macHashUint8Array, "hex");
6387
6530
  if (mac !== macHash) {
6388
- throw new FuelError18(
6389
- ErrorCode16.INVALID_PASSWORD,
6531
+ throw new FuelError19(
6532
+ ErrorCode17.INVALID_PASSWORD,
6390
6533
  "Failed to decrypt the keystore wallet, the provided password is incorrect."
6391
6534
  );
6392
6535
  }
@@ -6516,14 +6659,14 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
6516
6659
 
6517
6660
  // src/hdwallet/hdwallet.ts
6518
6661
  import { computeHmac as computeHmac2, ripemd160 } from "@fuel-ts/crypto";
6519
- import { ErrorCode as ErrorCode19, FuelError as FuelError21 } from "@fuel-ts/errors";
6662
+ import { ErrorCode as ErrorCode20, FuelError as FuelError22 } from "@fuel-ts/errors";
6520
6663
  import { sha256 as sha2564 } from "@fuel-ts/hasher";
6521
6664
  import { bn as bn20, toBytes as toBytes2, toHex } from "@fuel-ts/math";
6522
6665
  import { arrayify as arrayify18, hexlify as hexlify20, concat as concat5, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58 } from "@fuel-ts/utils";
6523
6666
 
6524
6667
  // src/mnemonic/mnemonic.ts
6525
6668
  import { randomBytes as randomBytes7, pbkdf2, computeHmac } from "@fuel-ts/crypto";
6526
- import { ErrorCode as ErrorCode18, FuelError as FuelError20 } from "@fuel-ts/errors";
6669
+ import { ErrorCode as ErrorCode19, FuelError as FuelError21 } from "@fuel-ts/errors";
6527
6670
  import { sha256 as sha2563 } from "@fuel-ts/hasher";
6528
6671
  import { arrayify as arrayify17, hexlify as hexlify19, concat as concat4, dataSlice, encodeBase58, toUtf8Bytes } from "@fuel-ts/utils";
6529
6672
 
@@ -8580,7 +8723,7 @@ var english = [
8580
8723
  ];
8581
8724
 
8582
8725
  // src/mnemonic/utils.ts
8583
- import { ErrorCode as ErrorCode17, FuelError as FuelError19 } from "@fuel-ts/errors";
8726
+ import { ErrorCode as ErrorCode18, FuelError as FuelError20 } from "@fuel-ts/errors";
8584
8727
  import { sha256 as sha2562 } from "@fuel-ts/hasher";
8585
8728
  import { arrayify as arrayify16 } from "@fuel-ts/utils";
8586
8729
  function getLowerMask(bits) {
@@ -8629,8 +8772,8 @@ function mnemonicWordsToEntropy(words, wordlist) {
8629
8772
  for (let i = 0; i < words.length; i += 1) {
8630
8773
  const index = wordlist.indexOf(words[i].normalize("NFKD"));
8631
8774
  if (index === -1) {
8632
- throw new FuelError19(
8633
- ErrorCode17.INVALID_MNEMONIC,
8775
+ throw new FuelError20(
8776
+ ErrorCode18.INVALID_MNEMONIC,
8634
8777
  `Invalid mnemonic: the word '${words[i]}' is not found in the provided wordlist.`
8635
8778
  );
8636
8779
  }
@@ -8646,8 +8789,8 @@ function mnemonicWordsToEntropy(words, wordlist) {
8646
8789
  const checksumMask = getUpperMask(checksumBits);
8647
8790
  const checksum = arrayify16(sha2562(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
8648
8791
  if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
8649
- throw new FuelError19(
8650
- ErrorCode17.INVALID_CHECKSUM,
8792
+ throw new FuelError20(
8793
+ ErrorCode18.INVALID_CHECKSUM,
8651
8794
  "Checksum validation failed for the provided mnemonic."
8652
8795
  );
8653
8796
  }
@@ -8661,16 +8804,16 @@ var TestnetPRV = "0x04358394";
8661
8804
  var MNEMONIC_SIZES = [12, 15, 18, 21, 24];
8662
8805
  function assertWordList(wordlist) {
8663
8806
  if (wordlist.length !== 2048) {
8664
- throw new FuelError20(
8665
- ErrorCode18.INVALID_WORD_LIST,
8807
+ throw new FuelError21(
8808
+ ErrorCode19.INVALID_WORD_LIST,
8666
8809
  `Expected word list length of 2048, but got ${wordlist.length}.`
8667
8810
  );
8668
8811
  }
8669
8812
  }
8670
8813
  function assertEntropy(entropy) {
8671
8814
  if (entropy.length % 4 !== 0 || entropy.length < 16 || entropy.length > 32) {
8672
- throw new FuelError20(
8673
- ErrorCode18.INVALID_ENTROPY,
8815
+ throw new FuelError21(
8816
+ ErrorCode19.INVALID_ENTROPY,
8674
8817
  `Entropy should be between 16 and 32 bytes and a multiple of 4, but got ${entropy.length} bytes.`
8675
8818
  );
8676
8819
  }
@@ -8680,7 +8823,7 @@ function assertMnemonic(words) {
8680
8823
  const errorMsg = `Invalid mnemonic size. Expected one of [${MNEMONIC_SIZES.join(
8681
8824
  ", "
8682
8825
  )}] words, but got ${words.length}.`;
8683
- throw new FuelError20(ErrorCode18.INVALID_MNEMONIC, errorMsg);
8826
+ throw new FuelError21(ErrorCode19.INVALID_MNEMONIC, errorMsg);
8684
8827
  }
8685
8828
  }
8686
8829
  var Mnemonic = class {
@@ -8798,8 +8941,8 @@ var Mnemonic = class {
8798
8941
  static masterKeysFromSeed(seed) {
8799
8942
  const seedArray = arrayify17(seed);
8800
8943
  if (seedArray.length < 16 || seedArray.length > 64) {
8801
- throw new FuelError20(
8802
- ErrorCode18.INVALID_SEED,
8944
+ throw new FuelError21(
8945
+ ErrorCode19.INVALID_SEED,
8803
8946
  `Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
8804
8947
  );
8805
8948
  }
@@ -8876,7 +9019,7 @@ function isValidExtendedKey(extendedKey) {
8876
9019
  function parsePath(path2, depth = 0) {
8877
9020
  const components = path2.split("/");
8878
9021
  if (components.length === 0 || components[0] === "m" && depth !== 0) {
8879
- throw new FuelError21(ErrorCode19.HD_WALLET_ERROR, `invalid path - ${path2}`);
9022
+ throw new FuelError22(ErrorCode20.HD_WALLET_ERROR, `invalid path - ${path2}`);
8880
9023
  }
8881
9024
  if (components[0] === "m") {
8882
9025
  components.shift();
@@ -8905,8 +9048,8 @@ var HDWallet = class {
8905
9048
  this.privateKey = hexlify20(config.privateKey);
8906
9049
  } else {
8907
9050
  if (!config.publicKey) {
8908
- throw new FuelError21(
8909
- ErrorCode19.HD_WALLET_ERROR,
9051
+ throw new FuelError22(
9052
+ ErrorCode20.HD_WALLET_ERROR,
8910
9053
  "Both public and private Key cannot be missing. At least one should be provided."
8911
9054
  );
8912
9055
  }
@@ -8935,8 +9078,8 @@ var HDWallet = class {
8935
9078
  const data = new Uint8Array(37);
8936
9079
  if (index & HARDENED_INDEX) {
8937
9080
  if (!privateKey) {
8938
- throw new FuelError21(
8939
- ErrorCode19.HD_WALLET_ERROR,
9081
+ throw new FuelError22(
9082
+ ErrorCode20.HD_WALLET_ERROR,
8940
9083
  "Cannot derive a hardened index without a private Key."
8941
9084
  );
8942
9085
  }
@@ -8988,8 +9131,8 @@ var HDWallet = class {
8988
9131
  */
8989
9132
  toExtendedKey(isPublic = false, testnet = false) {
8990
9133
  if (this.depth >= 256) {
8991
- throw new FuelError21(
8992
- ErrorCode19.HD_WALLET_ERROR,
9134
+ throw new FuelError22(
9135
+ ErrorCode20.HD_WALLET_ERROR,
8993
9136
  `Exceeded max depth of 255. Current depth: ${this.depth}.`
8994
9137
  );
8995
9138
  }
@@ -9020,10 +9163,10 @@ var HDWallet = class {
9020
9163
  const bytes = arrayify18(decoded);
9021
9164
  const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
9022
9165
  if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
9023
- throw new FuelError21(ErrorCode19.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
9166
+ throw new FuelError22(ErrorCode20.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
9024
9167
  }
9025
9168
  if (!validChecksum) {
9026
- throw new FuelError21(ErrorCode19.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
9169
+ throw new FuelError22(ErrorCode20.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
9027
9170
  }
9028
9171
  const depth = bytes[4];
9029
9172
  const parentFingerprint = hexlify20(bytes.slice(5, 9));
@@ -9031,14 +9174,14 @@ var HDWallet = class {
9031
9174
  const chainCode = hexlify20(bytes.slice(13, 45));
9032
9175
  const key = bytes.slice(45, 78);
9033
9176
  if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
9034
- throw new FuelError21(
9035
- ErrorCode19.HD_WALLET_ERROR,
9177
+ throw new FuelError22(
9178
+ ErrorCode20.HD_WALLET_ERROR,
9036
9179
  "Inconsistency detected: Depth is zero but fingerprint/index is non-zero."
9037
9180
  );
9038
9181
  }
9039
9182
  if (isPublicExtendedKey(bytes)) {
9040
9183
  if (key[0] !== 3) {
9041
- throw new FuelError21(ErrorCode19.HD_WALLET_ERROR, "Invalid public extended key.");
9184
+ throw new FuelError22(ErrorCode20.HD_WALLET_ERROR, "Invalid public extended key.");
9042
9185
  }
9043
9186
  return new HDWallet({
9044
9187
  publicKey: key,
@@ -9049,7 +9192,7 @@ var HDWallet = class {
9049
9192
  });
9050
9193
  }
9051
9194
  if (key[0] !== 0) {
9052
- throw new FuelError21(ErrorCode19.HD_WALLET_ERROR, "Invalid private extended key.");
9195
+ throw new FuelError22(ErrorCode20.HD_WALLET_ERROR, "Invalid private extended key.");
9053
9196
  }
9054
9197
  return new HDWallet({
9055
9198
  privateKey: key.slice(1),
@@ -9293,26 +9436,26 @@ var WalletsConfig = class {
9293
9436
  amountPerCoin
9294
9437
  }) {
9295
9438
  if (Array.isArray(wallets) && wallets.length === 0 || typeof wallets === "number" && wallets <= 0) {
9296
- throw new FuelError22(
9297
- FuelError22.CODES.INVALID_INPUT_PARAMETERS,
9439
+ throw new FuelError23(
9440
+ FuelError23.CODES.INVALID_INPUT_PARAMETERS,
9298
9441
  "Number of wallets must be greater than zero."
9299
9442
  );
9300
9443
  }
9301
9444
  if (Array.isArray(assets2) && assets2.length === 0 || typeof assets2 === "number" && assets2 <= 0) {
9302
- throw new FuelError22(
9303
- FuelError22.CODES.INVALID_INPUT_PARAMETERS,
9445
+ throw new FuelError23(
9446
+ FuelError23.CODES.INVALID_INPUT_PARAMETERS,
9304
9447
  "Number of assets per wallet must be greater than zero."
9305
9448
  );
9306
9449
  }
9307
9450
  if (coinsPerAsset <= 0) {
9308
- throw new FuelError22(
9309
- FuelError22.CODES.INVALID_INPUT_PARAMETERS,
9451
+ throw new FuelError23(
9452
+ FuelError23.CODES.INVALID_INPUT_PARAMETERS,
9310
9453
  "Number of coins per asset must be greater than zero."
9311
9454
  );
9312
9455
  }
9313
9456
  if (amountPerCoin < 0) {
9314
- throw new FuelError22(
9315
- FuelError22.CODES.INVALID_INPUT_PARAMETERS,
9457
+ throw new FuelError23(
9458
+ FuelError23.CODES.INVALID_INPUT_PARAMETERS,
9316
9459
  "Amount per coin must be greater than or equal to zero."
9317
9460
  );
9318
9461
  }