@fuel-ts/account 0.94.3 → 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 (32) hide show
  1. package/dist/account.d.ts.map +1 -1
  2. package/dist/index.global.js +352 -268
  3. package/dist/index.global.js.map +1 -1
  4. package/dist/index.js +307 -167
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.mjs +304 -167
  7. package/dist/index.mjs.map +1 -1
  8. package/dist/predicate/predicate.d.ts.map +1 -1
  9. package/dist/providers/__generated__/operations.d.ts +81 -0
  10. package/dist/providers/__generated__/operations.d.ts.map +1 -1
  11. package/dist/providers/message.d.ts +3 -0
  12. package/dist/providers/message.d.ts.map +1 -1
  13. package/dist/providers/provider.d.ts +27 -2
  14. package/dist/providers/provider.d.ts.map +1 -1
  15. package/dist/providers/transaction-request/blob-transaction-request.d.ts.map +1 -1
  16. package/dist/providers/transaction-request/create-transaction-request.d.ts.map +1 -1
  17. package/dist/providers/transaction-request/helpers.d.ts +2 -0
  18. package/dist/providers/transaction-request/helpers.d.ts.map +1 -1
  19. package/dist/providers/transaction-request/script-transaction-request.d.ts.map +1 -1
  20. package/dist/providers/transaction-request/transaction-request.d.ts +4 -2
  21. package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
  22. package/dist/providers/utils/extract-tx-error.d.ts.map +1 -1
  23. package/dist/providers/utils/handle-gql-error-message.d.ts +6 -0
  24. package/dist/providers/utils/handle-gql-error-message.d.ts.map +1 -0
  25. package/dist/test-utils/launchNode.d.ts.map +1 -1
  26. package/dist/test-utils.global.js +196 -118
  27. package/dist/test-utils.global.js.map +1 -1
  28. package/dist/test-utils.js +262 -134
  29. package/dist/test-utils.js.map +1 -1
  30. package/dist/test-utils.mjs +260 -132
  31. package/dist/test-utils.mjs.map +1 -1
  32. package/package.json +16 -16
@@ -349,20 +349,14 @@ var launchNode = async ({
349
349
  const rows = text.split("\n");
350
350
  const rowWithUrl = rows.find((row) => row.indexOf(graphQLStartSubstring) !== -1);
351
351
  const [realIp, realPort] = rowWithUrl.split(" ").at(-1).trim().split(":");
352
- setTimeout(
353
- () => (
354
- // Resolve with the cleanup method.
355
- resolve({
356
- cleanup,
357
- ip: realIp,
358
- port: realPort,
359
- url: `http://${realIp}:${realPort}/v1/graphql`,
360
- snapshotDir: snapshotDirToUse,
361
- pid: child.pid
362
- })
363
- ),
364
- 500
365
- );
352
+ resolve({
353
+ cleanup,
354
+ ip: realIp,
355
+ port: realPort,
356
+ url: `http://${realIp}:${realPort}/v1/graphql`,
357
+ snapshotDir: snapshotDirToUse,
358
+ pid: child.pid
359
+ });
366
360
  }
367
361
  if (/error/i.test(text)) {
368
362
  console.log(text);
@@ -381,7 +375,7 @@ var launchNode = async ({
381
375
 
382
376
  // src/test-utils/setup-test-provider-and-wallets.ts
383
377
  var import_utils41 = require("@fuel-ts/utils");
384
- var import_ramda5 = require("ramda");
378
+ var import_ramda8 = require("ramda");
385
379
 
386
380
  // src/providers/coin-quantity.ts
387
381
  var import_math2 = require("@fuel-ts/math");
@@ -420,14 +414,15 @@ var addAmountToCoinQuantities = (params) => {
420
414
 
421
415
  // src/providers/provider.ts
422
416
  var import_address4 = require("@fuel-ts/address");
423
- var import_errors16 = require("@fuel-ts/errors");
417
+ var import_errors17 = require("@fuel-ts/errors");
424
418
  var import_math19 = require("@fuel-ts/math");
425
419
  var import_transactions20 = require("@fuel-ts/transactions");
426
420
  var import_utils26 = require("@fuel-ts/utils");
427
421
  var import_versions = require("@fuel-ts/versions");
428
422
  var import_utils27 = require("@noble/curves/abstract/utils");
429
423
  var import_graphql_request = require("graphql-request");
430
- var import_ramda3 = require("ramda");
424
+ var import_graphql_tag2 = __toESM(require("graphql-tag"));
425
+ var import_ramda6 = require("ramda");
431
426
 
432
427
  // src/providers/__generated__/operations.ts
433
428
  var import_graphql_tag = __toESM(require("graphql-tag"));
@@ -760,6 +755,14 @@ var BlockFragmentDoc = import_graphql_tag.default`
760
755
  height
761
756
  header {
762
757
  time
758
+ daHeight
759
+ stateTransitionBytecodeVersion
760
+ transactionsCount
761
+ transactionsRoot
762
+ messageOutboxRoot
763
+ eventInboxRoot
764
+ prevRoot
765
+ applicationHash
763
766
  }
764
767
  transactions {
765
768
  id
@@ -1748,6 +1751,9 @@ var import_math9 = require("@fuel-ts/math");
1748
1751
  var import_transactions7 = require("@fuel-ts/transactions");
1749
1752
  var import_utils11 = require("@fuel-ts/utils");
1750
1753
 
1754
+ // src/providers/message.ts
1755
+ var isMessageCoin = (message) => !("data" in message);
1756
+
1751
1757
  // src/providers/resource.ts
1752
1758
  var isCoin = (resource) => "id" in resource;
1753
1759
 
@@ -2122,20 +2128,22 @@ var assembleRevertError = (receipts, logs, metadata) => {
2122
2128
  let reason = "";
2123
2129
  if (revertReceipt) {
2124
2130
  const reasonHex = (0, import_math7.bn)(revertReceipt.val).toHex();
2131
+ const lastLog = logs[logs.length - 1];
2132
+ const lastButOneLog = logs[logs.length - 2];
2125
2133
  switch (reasonHex) {
2126
2134
  case import_configs5.FAILED_REQUIRE_SIGNAL: {
2127
2135
  reason = "require";
2128
- errorMessage = `The transaction reverted because a "require" statement has thrown ${logs.length ? stringify(logs[0]) : "an error."}.`;
2136
+ errorMessage = `The transaction reverted because a "require" statement has thrown ${logs.length ? stringify(lastLog) : "an error."}.`;
2129
2137
  break;
2130
2138
  }
2131
2139
  case import_configs5.FAILED_ASSERT_EQ_SIGNAL: {
2132
- const sufix = logs.length >= 2 ? ` comparing ${stringify(logs[1])} and ${stringify(logs[0])}.` : ".";
2140
+ const sufix = logs.length >= 2 ? ` comparing ${stringify(lastLog)} and ${stringify(lastButOneLog)}.` : ".";
2133
2141
  reason = "assert_eq";
2134
2142
  errorMessage = `The transaction reverted because of an "assert_eq" statement${sufix}`;
2135
2143
  break;
2136
2144
  }
2137
2145
  case import_configs5.FAILED_ASSERT_NE_SIGNAL: {
2138
- const sufix = logs.length >= 2 ? ` comparing ${stringify(logs[1])} and ${stringify(logs[0])}.` : ".";
2146
+ const sufix = logs.length >= 2 ? ` comparing ${stringify(lastButOneLog)} and ${stringify(lastLog)}.` : ".";
2139
2147
  reason = "assert_ne";
2140
2148
  errorMessage = `The transaction reverted because of an "assert_ne" statement${sufix}`;
2141
2149
  break;
@@ -2196,7 +2204,9 @@ var import_math8 = require("@fuel-ts/math");
2196
2204
  var import_transactions6 = require("@fuel-ts/transactions");
2197
2205
  var isRequestInputCoin = (input) => input.type === import_transactions6.InputType.Coin;
2198
2206
  var isRequestInputMessage = (input) => input.type === import_transactions6.InputType.Message;
2199
- var isRequestInputResource = (input) => isRequestInputCoin(input) || isRequestInputMessage(input);
2207
+ var isRequestInputMessageWithoutData = (input) => input.type === import_transactions6.InputType.Message && (0, import_math8.bn)(input.data).isZero();
2208
+ var isRequestInputCoinOrMessage = (input) => isRequestInputCoin(input) || isRequestInputMessage(input);
2209
+ var isRequestInputResource = (input) => isRequestInputCoin(input) || isRequestInputMessageWithoutData(input);
2200
2210
  var getRequestInputResourceOwner = (input) => isRequestInputCoin(input) ? input.owner : input.recipient;
2201
2211
  var isRequestInputResourceFromOwner = (input, owner) => getRequestInputResourceOwner(input) === owner.toB256();
2202
2212
  var getAssetAmountInRequestInputs = (inputs, assetId, baseAsset) => inputs.filter(isRequestInputResource).reduce((acc, input) => {
@@ -2492,7 +2502,7 @@ var BaseTransactionRequest = class {
2492
2502
  * @param message - Message resource.
2493
2503
  */
2494
2504
  addMessageInput(message) {
2495
- const { recipient, sender, amount, predicate, nonce, assetId, predicateData } = message;
2505
+ const { recipient, sender, amount, predicate, nonce, predicateData } = message;
2496
2506
  let witnessIndex;
2497
2507
  if (message.predicate) {
2498
2508
  witnessIndex = 0;
@@ -2507,13 +2517,16 @@ var BaseTransactionRequest = class {
2507
2517
  type: import_transactions7.InputType.Message,
2508
2518
  sender: sender.toB256(),
2509
2519
  recipient: recipient.toB256(),
2520
+ data: isMessageCoin(message) ? "0x" : message.data,
2510
2521
  amount,
2511
2522
  witnessIndex,
2512
2523
  predicate,
2513
2524
  predicateData
2514
2525
  };
2515
2526
  this.pushInput(input);
2516
- this.addChangeOutput(recipient, assetId);
2527
+ if (isMessageCoin(message)) {
2528
+ this.addChangeOutput(recipient, message.assetId);
2529
+ }
2517
2530
  }
2518
2531
  /**
2519
2532
  * Adds a single resource to the transaction by adding a coin/message input and a
@@ -2645,6 +2658,8 @@ var BaseTransactionRequest = class {
2645
2658
  *
2646
2659
  * @param quantities - CoinQuantity Array.
2647
2660
  * @param baseAssetId - The base asset to fund the transaction.
2661
+ * @deprecated - This method is deprecated and will be removed in future versions.
2662
+ * Please use `Account.generateFakeResources` along with `this.addResources` instead.
2648
2663
  */
2649
2664
  fundWithFakeUtxos(quantities, baseAssetId, resourcesOwner) {
2650
2665
  const findAssetInput = (assetId) => this.inputs.find((input) => {
@@ -2713,7 +2728,7 @@ var BaseTransactionRequest = class {
2713
2728
  });
2714
2729
  }
2715
2730
  updatePredicateGasUsed(inputs) {
2716
- const inputsToExtractGasUsed = inputs.filter(isRequestInputResource);
2731
+ const inputsToExtractGasUsed = inputs.filter(isRequestInputCoinOrMessage);
2717
2732
  this.inputs.filter(isRequestInputResource).forEach((i) => {
2718
2733
  const owner = getRequestInputResourceOwner(i);
2719
2734
  const correspondingInput = inputsToExtractGasUsed.find(
@@ -2729,6 +2744,9 @@ var BaseTransactionRequest = class {
2729
2744
  }
2730
2745
  };
2731
2746
 
2747
+ // src/providers/transaction-request/blob-transaction-request.ts
2748
+ var import_ramda3 = require("ramda");
2749
+
2732
2750
  // src/providers/transaction-request/hash-transaction.ts
2733
2751
  var import_configs7 = require("@fuel-ts/address/configs");
2734
2752
  var import_hasher2 = require("@fuel-ts/hasher");
@@ -2803,10 +2821,7 @@ function hashTransaction(transactionRequest, chainId) {
2803
2821
  // src/providers/transaction-request/blob-transaction-request.ts
2804
2822
  var BlobTransactionRequest = class extends BaseTransactionRequest {
2805
2823
  static from(obj) {
2806
- if (obj instanceof this) {
2807
- return obj;
2808
- }
2809
- return new this(obj);
2824
+ return new this((0, import_ramda3.clone)(obj));
2810
2825
  }
2811
2826
  /** Type of the transaction */
2812
2827
  type = import_transactions7.TransactionType.Blob;
@@ -2869,6 +2884,7 @@ var import_configs8 = require("@fuel-ts/address/configs");
2869
2884
  var import_math11 = require("@fuel-ts/math");
2870
2885
  var import_transactions9 = require("@fuel-ts/transactions");
2871
2886
  var import_utils16 = require("@fuel-ts/utils");
2887
+ var import_ramda4 = require("ramda");
2872
2888
 
2873
2889
  // src/providers/transaction-request/storage-slot.ts
2874
2890
  var import_utils15 = require("@fuel-ts/utils");
@@ -2896,10 +2912,7 @@ var storageSlotify = (storageSlot) => {
2896
2912
  // src/providers/transaction-request/create-transaction-request.ts
2897
2913
  var CreateTransactionRequest = class extends BaseTransactionRequest {
2898
2914
  static from(obj) {
2899
- if (obj instanceof this) {
2900
- return obj;
2901
- }
2902
- return new this(obj);
2915
+ return new this((0, import_ramda4.clone)(obj));
2903
2916
  }
2904
2917
  /** Type of the transaction */
2905
2918
  type = import_transactions9.TransactionType.Create;
@@ -2988,6 +3001,7 @@ var import_configs9 = require("@fuel-ts/address/configs");
2988
3001
  var import_math12 = require("@fuel-ts/math");
2989
3002
  var import_transactions10 = require("@fuel-ts/transactions");
2990
3003
  var import_utils18 = require("@fuel-ts/utils");
3004
+ var import_ramda5 = require("ramda");
2991
3005
 
2992
3006
  // src/providers/transaction-request/scripts.ts
2993
3007
  var import_utils17 = require("@fuel-ts/utils");
@@ -3018,10 +3032,7 @@ var withdrawScript = {
3018
3032
  // src/providers/transaction-request/script-transaction-request.ts
3019
3033
  var ScriptTransactionRequest = class extends BaseTransactionRequest {
3020
3034
  static from(obj) {
3021
- if (obj instanceof this) {
3022
- return obj;
3023
- }
3024
- return new this(obj);
3035
+ return new this((0, import_ramda5.clone)(obj));
3025
3036
  }
3026
3037
  /** Type of the transaction */
3027
3038
  type = import_transactions10.TransactionType.Script;
@@ -4327,6 +4338,22 @@ function autoRetryFetch(fetchFn, options, retryAttemptNum = 0) {
4327
4338
  };
4328
4339
  }
4329
4340
 
4341
+ // src/providers/utils/handle-gql-error-message.ts
4342
+ var import_errors16 = require("@fuel-ts/errors");
4343
+ var handleGqlErrorMessage = (errorMessage, rawError) => {
4344
+ switch (errorMessage) {
4345
+ case "not enough coins to fit the target" /* NOT_ENOUGH_COINS */:
4346
+ throw new import_errors16.FuelError(
4347
+ import_errors16.ErrorCode.NOT_ENOUGH_FUNDS,
4348
+ `The account(s) sending the transaction don't have enough funds to cover the transaction.`,
4349
+ {},
4350
+ rawError
4351
+ );
4352
+ default:
4353
+ throw new import_errors16.FuelError(import_errors16.ErrorCode.INVALID_REQUEST, errorMessage);
4354
+ }
4355
+ };
4356
+
4330
4357
  // src/providers/provider.ts
4331
4358
  var MAX_RETRIES = 10;
4332
4359
  var RESOURCES_PAGE_SIZE_LIMIT = 512;
@@ -4453,6 +4480,17 @@ var _Provider = class {
4453
4480
  return options.fetch ? options.fetch(url, fullRequest, options) : fetch(url, fullRequest);
4454
4481
  }, retryOptions);
4455
4482
  }
4483
+ static extractBasicAuth(url) {
4484
+ const parsedUrl = new URL(url);
4485
+ const username = parsedUrl.username;
4486
+ const password = parsedUrl.password;
4487
+ const urlNoBasicAuth = `${parsedUrl.origin}${parsedUrl.pathname}`;
4488
+ if (!(username && password)) {
4489
+ return { url, auth: void 0 };
4490
+ }
4491
+ const auth = `Basic ${btoa(`${username}:${password}`)}`;
4492
+ return { url: urlNoBasicAuth, auth };
4493
+ }
4456
4494
  /**
4457
4495
  * Creates a new instance of the Provider class. This is the recommended way to initialize a Provider.
4458
4496
  *
@@ -4462,7 +4500,17 @@ var _Provider = class {
4462
4500
  * @returns A promise that resolves to a Provider instance.
4463
4501
  */
4464
4502
  static async create(url, options = {}) {
4465
- const provider = new _Provider(url, options);
4503
+ const { url: urlToUse, auth } = this.extractBasicAuth(url);
4504
+ const provider = new _Provider(urlToUse, {
4505
+ ...options,
4506
+ requestMiddleware: async (request) => {
4507
+ if (auth) {
4508
+ request.headers ??= {};
4509
+ request.headers.Authorization = auth;
4510
+ }
4511
+ return options.requestMiddleware?.(request) ?? request;
4512
+ }
4513
+ });
4466
4514
  await provider.fetchChainAndNodeInfo();
4467
4515
  return provider;
4468
4516
  }
@@ -4474,8 +4522,8 @@ var _Provider = class {
4474
4522
  getChain() {
4475
4523
  const chain = _Provider.chainInfoCache[this.url];
4476
4524
  if (!chain) {
4477
- throw new import_errors16.FuelError(
4478
- import_errors16.ErrorCode.CHAIN_INFO_CACHE_EMPTY,
4525
+ throw new import_errors17.FuelError(
4526
+ import_errors17.ErrorCode.CHAIN_INFO_CACHE_EMPTY,
4479
4527
  "Chain info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
4480
4528
  );
4481
4529
  }
@@ -4489,8 +4537,8 @@ var _Provider = class {
4489
4537
  getNode() {
4490
4538
  const node = _Provider.nodeInfoCache[this.url];
4491
4539
  if (!node) {
4492
- throw new import_errors16.FuelError(
4493
- import_errors16.ErrorCode.NODE_INFO_CACHE_EMPTY,
4540
+ throw new import_errors17.FuelError(
4541
+ import_errors17.ErrorCode.NODE_INFO_CACHE_EMPTY,
4494
4542
  "Node info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
4495
4543
  );
4496
4544
  }
@@ -4568,10 +4616,9 @@ Supported fuel-core version: ${supportedVersion}.`
4568
4616
  if ("response" in response) {
4569
4617
  const graphQlResponse = response.response;
4570
4618
  if (Array.isArray(graphQlResponse?.errors)) {
4571
- throw new import_errors16.FuelError(
4572
- import_errors16.FuelError.CODES.INVALID_REQUEST,
4573
- graphQlResponse.errors.map((err) => err.message).join("\n\n")
4574
- );
4619
+ for (const error of graphQlResponse.errors) {
4620
+ handleGqlErrorMessage(error.message, error);
4621
+ }
4575
4622
  }
4576
4623
  }
4577
4624
  }
@@ -4589,7 +4636,26 @@ Supported fuel-core version: ${supportedVersion}.`
4589
4636
  }
4590
4637
  return gqlClient.request(query, vars);
4591
4638
  };
4592
- return getSdk(executeQuery);
4639
+ const customOperations = (requester) => ({
4640
+ getBlobs(variables) {
4641
+ const queryParams = variables.blobIds.map((_, i) => `$blobId${i}: BlobId!`).join(", ");
4642
+ const blobParams = variables.blobIds.map((_, i) => `blob${i}: blob(id: $blobId${i}) { id }`).join("\n");
4643
+ const updatedVariables = variables.blobIds.reduce(
4644
+ (acc, blobId, i) => {
4645
+ acc[`blobId${i}`] = blobId;
4646
+ return acc;
4647
+ },
4648
+ {}
4649
+ );
4650
+ const document = import_graphql_tag2.default`
4651
+ query getBlobs(${queryParams}) {
4652
+ ${blobParams}
4653
+ }
4654
+ `;
4655
+ return requester(document, updatedVariables);
4656
+ }
4657
+ });
4658
+ return { ...getSdk(executeQuery), ...customOperations(executeQuery) };
4593
4659
  }
4594
4660
  /**
4595
4661
  * Returns the version of the connected node.
@@ -4664,14 +4730,14 @@ Supported fuel-core version: ${supportedVersion}.`
4664
4730
  validateTransaction(tx, consensusParameters) {
4665
4731
  const { maxOutputs, maxInputs } = consensusParameters.txParameters;
4666
4732
  if ((0, import_math19.bn)(tx.inputs.length).gt(maxInputs)) {
4667
- throw new import_errors16.FuelError(
4668
- import_errors16.ErrorCode.MAX_INPUTS_EXCEEDED,
4733
+ throw new import_errors17.FuelError(
4734
+ import_errors17.ErrorCode.MAX_INPUTS_EXCEEDED,
4669
4735
  "The transaction exceeds the maximum allowed number of inputs."
4670
4736
  );
4671
4737
  }
4672
4738
  if ((0, import_math19.bn)(tx.outputs.length).gt(maxOutputs)) {
4673
- throw new import_errors16.FuelError(
4674
- import_errors16.ErrorCode.MAX_OUTPUTS_EXCEEDED,
4739
+ throw new import_errors17.FuelError(
4740
+ import_errors17.ErrorCode.MAX_OUTPUTS_EXCEEDED,
4675
4741
  "The transaction exceeds the maximum allowed number of outputs."
4676
4742
  );
4677
4743
  }
@@ -4832,7 +4898,7 @@ Supported fuel-core version: ${supportedVersion}.`
4832
4898
  missingContractIds: [],
4833
4899
  dryRunStatus: void 0
4834
4900
  }));
4835
- const allRequests = (0, import_ramda3.clone)(transactionRequests);
4901
+ const allRequests = (0, import_ramda6.clone)(transactionRequests);
4836
4902
  const serializedTransactionsMap = /* @__PURE__ */ new Map();
4837
4903
  allRequests.forEach((req, index) => {
4838
4904
  if (isTransactionTypeScript(req)) {
@@ -4992,13 +5058,13 @@ Supported fuel-core version: ${supportedVersion}.`
4992
5058
  * @returns A promise that resolves to the transaction cost object.
4993
5059
  */
4994
5060
  async getTransactionCost(transactionRequestLike, { signatureCallback } = {}) {
4995
- const txRequestClone = (0, import_ramda3.clone)(transactionRequestify(transactionRequestLike));
5061
+ const txRequestClone = (0, import_ramda6.clone)(transactionRequestify(transactionRequestLike));
4996
5062
  const updateMaxFee = txRequestClone.maxFee.eq(0);
4997
5063
  const isScriptTransaction = isTransactionTypeScript(txRequestClone);
4998
5064
  if (isScriptTransaction) {
4999
5065
  txRequestClone.gasLimit = (0, import_math19.bn)(0);
5000
5066
  }
5001
- const signedRequest = (0, import_ramda3.clone)(txRequestClone);
5067
+ const signedRequest = (0, import_ramda6.clone)(txRequestClone);
5002
5068
  let addedSignatures = 0;
5003
5069
  if (signatureCallback && isTransactionTypeScript(signedRequest)) {
5004
5070
  const lengthBefore = signedRequest.witnesses.length;
@@ -5136,6 +5202,21 @@ Supported fuel-core version: ${supportedVersion}.`
5136
5202
  }).filter((v) => !!v);
5137
5203
  return coins;
5138
5204
  }
5205
+ /**
5206
+ * Returns an array of blobIds that exist on chain, for a given array of blobIds.
5207
+ *
5208
+ * @param blobIds - blobIds to check.
5209
+ * @returns - A promise that resolves to an array of blobIds that exist on chain.
5210
+ */
5211
+ async getBlobs(blobIds) {
5212
+ const res = await this.operations.getBlobs({ blobIds });
5213
+ const blobs = [];
5214
+ Object.keys(res).forEach((key) => {
5215
+ const val = res[key];
5216
+ blobs.push(val?.id ?? null);
5217
+ });
5218
+ return blobs.filter((v) => v);
5219
+ }
5139
5220
  /**
5140
5221
  * Returns block matching the given ID or height.
5141
5222
  *
@@ -5157,11 +5238,22 @@ Supported fuel-core version: ${supportedVersion}.`
5157
5238
  if (!block) {
5158
5239
  return null;
5159
5240
  }
5241
+ const { header, height, id, transactions } = block;
5160
5242
  return {
5161
- id: block.id,
5162
- height: (0, import_math19.bn)(block.height),
5163
- time: block.header.time,
5164
- transactionIds: block.transactions.map((tx) => tx.id)
5243
+ id,
5244
+ height: (0, import_math19.bn)(height),
5245
+ time: header.time,
5246
+ header: {
5247
+ applicationHash: header.applicationHash,
5248
+ daHeight: (0, import_math19.bn)(header.daHeight),
5249
+ eventInboxRoot: header.eventInboxRoot,
5250
+ messageOutboxRoot: header.messageOutboxRoot,
5251
+ prevRoot: header.prevRoot,
5252
+ stateTransitionBytecodeVersion: header.stateTransitionBytecodeVersion,
5253
+ transactionsCount: header.transactionsCount,
5254
+ transactionsRoot: header.transactionsRoot
5255
+ },
5256
+ transactionIds: transactions.map((tx) => tx.id)
5165
5257
  };
5166
5258
  }
5167
5259
  /**
@@ -5183,6 +5275,16 @@ Supported fuel-core version: ${supportedVersion}.`
5183
5275
  id: block.id,
5184
5276
  height: (0, import_math19.bn)(block.height),
5185
5277
  time: block.header.time,
5278
+ header: {
5279
+ applicationHash: block.header.applicationHash,
5280
+ daHeight: (0, import_math19.bn)(block.header.daHeight),
5281
+ eventInboxRoot: block.header.eventInboxRoot,
5282
+ messageOutboxRoot: block.header.messageOutboxRoot,
5283
+ prevRoot: block.header.prevRoot,
5284
+ stateTransitionBytecodeVersion: block.header.stateTransitionBytecodeVersion,
5285
+ transactionsCount: block.header.transactionsCount,
5286
+ transactionsRoot: block.header.transactionsRoot
5287
+ },
5186
5288
  transactionIds: block.transactions.map((tx) => tx.id)
5187
5289
  }));
5188
5290
  return { blocks, pageInfo };
@@ -5210,6 +5312,16 @@ Supported fuel-core version: ${supportedVersion}.`
5210
5312
  id: block.id,
5211
5313
  height: (0, import_math19.bn)(block.height, 10),
5212
5314
  time: block.header.time,
5315
+ header: {
5316
+ applicationHash: block.header.applicationHash,
5317
+ daHeight: (0, import_math19.bn)(block.header.daHeight),
5318
+ eventInboxRoot: block.header.eventInboxRoot,
5319
+ messageOutboxRoot: block.header.messageOutboxRoot,
5320
+ prevRoot: block.header.prevRoot,
5321
+ stateTransitionBytecodeVersion: block.header.stateTransitionBytecodeVersion,
5322
+ transactionsCount: block.header.transactionsCount,
5323
+ transactionsRoot: block.header.transactionsRoot
5324
+ },
5213
5325
  transactionIds: block.transactions.map((tx) => tx.id),
5214
5326
  transactions: block.transactions.map(
5215
5327
  (tx) => new import_transactions20.TransactionCoder().decode((0, import_utils26.arrayify)(tx.rawPayload), 0)?.[0]
@@ -5233,7 +5345,7 @@ Supported fuel-core version: ${supportedVersion}.`
5233
5345
  0
5234
5346
  )?.[0];
5235
5347
  } catch (error) {
5236
- if (error instanceof import_errors16.FuelError && error.code === import_errors16.ErrorCode.UNSUPPORTED_TRANSACTION_TYPE) {
5348
+ if (error instanceof import_errors17.FuelError && error.code === import_errors17.ErrorCode.UNSUPPORTED_TRANSACTION_TYPE) {
5237
5349
  console.warn("Unsupported transaction type encountered");
5238
5350
  return null;
5239
5351
  }
@@ -5254,7 +5366,7 @@ Supported fuel-core version: ${supportedVersion}.`
5254
5366
  try {
5255
5367
  return coder.decode((0, import_utils26.arrayify)(rawPayload), 0)[0];
5256
5368
  } catch (error) {
5257
- if (error instanceof import_errors16.FuelError && error.code === import_errors16.ErrorCode.UNSUPPORTED_TRANSACTION_TYPE) {
5369
+ if (error instanceof import_errors17.FuelError && error.code === import_errors17.ErrorCode.UNSUPPORTED_TRANSACTION_TYPE) {
5258
5370
  console.warn("Unsupported transaction type encountered");
5259
5371
  return null;
5260
5372
  }
@@ -5380,8 +5492,8 @@ Supported fuel-core version: ${supportedVersion}.`
5380
5492
  nonce
5381
5493
  };
5382
5494
  if (commitBlockId && commitBlockHeight) {
5383
- throw new import_errors16.FuelError(
5384
- import_errors16.ErrorCode.INVALID_INPUT_PARAMETERS,
5495
+ throw new import_errors17.FuelError(
5496
+ import_errors17.ErrorCode.INVALID_INPUT_PARAMETERS,
5385
5497
  "commitBlockId and commitBlockHeight cannot be used together"
5386
5498
  );
5387
5499
  }
@@ -5521,10 +5633,25 @@ Supported fuel-core version: ${supportedVersion}.`
5521
5633
  * @returns A promise that resolves to the Message object or null.
5522
5634
  */
5523
5635
  async getMessageByNonce(nonce) {
5524
- const { message } = await this.operations.getMessageByNonce({ nonce });
5525
- if (!message) {
5636
+ const { message: rawMessage } = await this.operations.getMessageByNonce({ nonce });
5637
+ if (!rawMessage) {
5526
5638
  return null;
5527
5639
  }
5640
+ const message = {
5641
+ messageId: import_transactions20.InputMessageCoder.getMessageId({
5642
+ sender: rawMessage.sender,
5643
+ recipient: rawMessage.recipient,
5644
+ nonce: rawMessage.nonce,
5645
+ amount: (0, import_math19.bn)(rawMessage.amount),
5646
+ data: rawMessage.data
5647
+ }),
5648
+ sender: import_address4.Address.fromAddressOrString(rawMessage.sender),
5649
+ recipient: import_address4.Address.fromAddressOrString(rawMessage.recipient),
5650
+ nonce: rawMessage.nonce,
5651
+ amount: (0, import_math19.bn)(rawMessage.amount),
5652
+ data: import_transactions20.InputMessageCoder.decodeData(rawMessage.data),
5653
+ daHeight: (0, import_math19.bn)(rawMessage.daHeight)
5654
+ };
5528
5655
  return message;
5529
5656
  }
5530
5657
  /**
@@ -5549,26 +5676,26 @@ Supported fuel-core version: ${supportedVersion}.`
5549
5676
  const { paginationLimit, inputArgs = {} } = params;
5550
5677
  const { first, last, after, before } = inputArgs;
5551
5678
  if (after && before) {
5552
- throw new import_errors16.FuelError(
5553
- import_errors16.ErrorCode.INVALID_INPUT_PARAMETERS,
5679
+ throw new import_errors17.FuelError(
5680
+ import_errors17.ErrorCode.INVALID_INPUT_PARAMETERS,
5554
5681
  'Pagination arguments "after" and "before" cannot be used together'
5555
5682
  );
5556
5683
  }
5557
5684
  if ((first || 0) > paginationLimit || (last || 0) > paginationLimit) {
5558
- throw new import_errors16.FuelError(
5559
- import_errors16.ErrorCode.INVALID_INPUT_PARAMETERS,
5685
+ throw new import_errors17.FuelError(
5686
+ import_errors17.ErrorCode.INVALID_INPUT_PARAMETERS,
5560
5687
  `Pagination limit for this query cannot exceed ${paginationLimit} items`
5561
5688
  );
5562
5689
  }
5563
5690
  if (first && before) {
5564
- throw new import_errors16.FuelError(
5565
- import_errors16.ErrorCode.INVALID_INPUT_PARAMETERS,
5691
+ throw new import_errors17.FuelError(
5692
+ import_errors17.ErrorCode.INVALID_INPUT_PARAMETERS,
5566
5693
  'The use of pagination argument "first" with "before" is not supported'
5567
5694
  );
5568
5695
  }
5569
5696
  if (last && after) {
5570
- throw new import_errors16.FuelError(
5571
- import_errors16.ErrorCode.INVALID_INPUT_PARAMETERS,
5697
+ throw new import_errors17.FuelError(
5698
+ import_errors17.ErrorCode.INVALID_INPUT_PARAMETERS,
5572
5699
  'The use of pagination argument "last" with "after" is not supported'
5573
5700
  );
5574
5701
  }
@@ -5622,7 +5749,7 @@ __publicField(Provider, "chainInfoCache", {});
5622
5749
  __publicField(Provider, "nodeInfoCache", {});
5623
5750
 
5624
5751
  // src/providers/transaction-summary/get-transaction-summary.ts
5625
- var import_errors17 = require("@fuel-ts/errors");
5752
+ var import_errors18 = require("@fuel-ts/errors");
5626
5753
  var import_math20 = require("@fuel-ts/math");
5627
5754
  var import_transactions21 = require("@fuel-ts/transactions");
5628
5755
  var import_utils29 = require("@fuel-ts/utils");
@@ -5723,7 +5850,7 @@ __publicField(TestAssetId, "B", new _TestAssetId(
5723
5850
 
5724
5851
  // src/test-utils/wallet-config.ts
5725
5852
  var import_crypto9 = require("@fuel-ts/crypto");
5726
- var import_errors23 = require("@fuel-ts/errors");
5853
+ var import_errors24 = require("@fuel-ts/errors");
5727
5854
  var import_utils40 = require("@fuel-ts/utils");
5728
5855
 
5729
5856
  // src/wallet/base-wallet-unlocked.ts
@@ -5734,11 +5861,12 @@ var import_utils35 = require("@fuel-ts/utils");
5734
5861
  var import_abi_coder8 = require("@fuel-ts/abi-coder");
5735
5862
  var import_address5 = require("@fuel-ts/address");
5736
5863
  var import_crypto5 = require("@fuel-ts/crypto");
5737
- var import_errors18 = require("@fuel-ts/errors");
5864
+ var import_errors19 = require("@fuel-ts/errors");
5738
5865
  var import_interfaces = require("@fuel-ts/interfaces");
5739
5866
  var import_math22 = require("@fuel-ts/math");
5867
+ var import_transactions22 = require("@fuel-ts/transactions");
5740
5868
  var import_utils33 = require("@fuel-ts/utils");
5741
- var import_ramda4 = require("ramda");
5869
+ var import_ramda7 = require("ramda");
5742
5870
 
5743
5871
  // src/providers/utils/merge-quantities.ts
5744
5872
  var mergeQuantities = (...coinQuantities) => {
@@ -5827,7 +5955,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5827
5955
  */
5828
5956
  get provider() {
5829
5957
  if (!this._provider) {
5830
- throw new import_errors18.FuelError(import_errors18.ErrorCode.MISSING_PROVIDER, "Provider not set");
5958
+ throw new import_errors19.FuelError(import_errors19.ErrorCode.MISSING_PROVIDER, "Provider not set");
5831
5959
  }
5832
5960
  return this._provider;
5833
5961
  }
@@ -5945,7 +6073,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5945
6073
  );
5946
6074
  request.addResources(resources);
5947
6075
  request.updatePredicateGasUsed(estimatedPredicates);
5948
- const requestToReestimate2 = (0, import_ramda4.clone)(request);
6076
+ const requestToReestimate2 = (0, import_ramda7.clone)(request);
5949
6077
  if (addedSignatures) {
5950
6078
  Array.from({ length: addedSignatures }).forEach(
5951
6079
  () => requestToReestimate2.addEmptyWitness()
@@ -5960,7 +6088,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5960
6088
  gasPrice
5961
6089
  });
5962
6090
  const totalBaseAssetOnInputs = getAssetAmountInRequestInputs(
5963
- request.inputs,
6091
+ request.inputs.filter(isRequestInputResource),
5964
6092
  baseAssetId,
5965
6093
  baseAssetId
5966
6094
  );
@@ -5978,13 +6106,13 @@ var Account = class extends import_interfaces.AbstractAccount {
5978
6106
  fundingAttempts += 1;
5979
6107
  }
5980
6108
  if (needsToBeFunded) {
5981
- throw new import_errors18.FuelError(
5982
- import_errors18.ErrorCode.NOT_ENOUGH_FUNDS,
6109
+ throw new import_errors19.FuelError(
6110
+ import_errors19.ErrorCode.NOT_ENOUGH_FUNDS,
5983
6111
  `The account ${this.address} does not have enough base asset funds to cover the transaction execution.`
5984
6112
  );
5985
6113
  }
5986
6114
  request.updatePredicateGasUsed(estimatedPredicates);
5987
- const requestToReestimate = (0, import_ramda4.clone)(request);
6115
+ const requestToReestimate = (0, import_ramda7.clone)(request);
5988
6116
  if (addedSignatures) {
5989
6117
  Array.from({ length: addedSignatures }).forEach(() => requestToReestimate.addEmptyWitness());
5990
6118
  }
@@ -6084,8 +6212,8 @@ var Account = class extends import_interfaces.AbstractAccount {
6084
6212
  */
6085
6213
  async transferToContract(contractId, amount, assetId, txParams = {}) {
6086
6214
  if ((0, import_math22.bn)(amount).lte(0)) {
6087
- throw new import_errors18.FuelError(
6088
- import_errors18.ErrorCode.INVALID_TRANSFER_AMOUNT,
6215
+ throw new import_errors19.FuelError(
6216
+ import_errors19.ErrorCode.INVALID_TRANSFER_AMOUNT,
6089
6217
  "Transfer amount must be a positive number."
6090
6218
  );
6091
6219
  }
@@ -6160,16 +6288,16 @@ var Account = class extends import_interfaces.AbstractAccount {
6160
6288
  * @returns A promise that resolves to the transaction cost object.
6161
6289
  */
6162
6290
  async getTransactionCost(transactionRequestLike, { signatureCallback, quantities = [] } = {}) {
6163
- const txRequestClone = (0, import_ramda4.clone)(transactionRequestify(transactionRequestLike));
6291
+ const txRequestClone = (0, import_ramda7.clone)(transactionRequestify(transactionRequestLike));
6164
6292
  const baseAssetId = this.provider.getBaseAssetId();
6165
6293
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
6166
6294
  const requiredQuantities = mergeQuantities(coinOutputsQuantities, quantities);
6167
6295
  const transactionFeeForDryRun = [{ assetId: baseAssetId, amount: (0, import_math22.bn)("100000000000000000") }];
6168
6296
  const findAssetInput = (assetId) => txRequestClone.inputs.find((input) => {
6169
- if ("assetId" in input) {
6297
+ if (input.type === import_transactions22.InputType.Coin) {
6170
6298
  return input.assetId === assetId;
6171
6299
  }
6172
- if ("recipient" in input) {
6300
+ if (isRequestInputMessageWithoutData(input)) {
6173
6301
  return baseAssetId === assetId;
6174
6302
  }
6175
6303
  return false;
@@ -6211,7 +6339,7 @@ var Account = class extends import_interfaces.AbstractAccount {
6211
6339
  */
6212
6340
  async signMessage(message) {
6213
6341
  if (!this._connector) {
6214
- throw new import_errors18.FuelError(import_errors18.ErrorCode.MISSING_CONNECTOR, "A connector is required to sign messages.");
6342
+ throw new import_errors19.FuelError(import_errors19.ErrorCode.MISSING_CONNECTOR, "A connector is required to sign messages.");
6215
6343
  }
6216
6344
  return this._connector.signMessage(this.address.toString(), message);
6217
6345
  }
@@ -6223,8 +6351,8 @@ var Account = class extends import_interfaces.AbstractAccount {
6223
6351
  */
6224
6352
  async signTransaction(transactionRequestLike) {
6225
6353
  if (!this._connector) {
6226
- throw new import_errors18.FuelError(
6227
- import_errors18.ErrorCode.MISSING_CONNECTOR,
6354
+ throw new import_errors19.FuelError(
6355
+ import_errors19.ErrorCode.MISSING_CONNECTOR,
6228
6356
  "A connector is required to sign transactions."
6229
6357
  );
6230
6358
  }
@@ -6283,8 +6411,8 @@ var Account = class extends import_interfaces.AbstractAccount {
6283
6411
  /** @hidden * */
6284
6412
  validateTransferAmount(amount) {
6285
6413
  if ((0, import_math22.bn)(amount).lte(0)) {
6286
- throw new import_errors18.FuelError(
6287
- import_errors18.ErrorCode.INVALID_TRANSFER_AMOUNT,
6414
+ throw new import_errors19.FuelError(
6415
+ import_errors19.ErrorCode.INVALID_TRANSFER_AMOUNT,
6288
6416
  "Transfer amount must be a positive number."
6289
6417
  );
6290
6418
  }
@@ -6313,16 +6441,16 @@ var Account = class extends import_interfaces.AbstractAccount {
6313
6441
  if (!(0, import_utils33.isDefined)(setGasLimit)) {
6314
6442
  request.gasLimit = gasUsed;
6315
6443
  } else if (gasUsed.gt(setGasLimit)) {
6316
- throw new import_errors18.FuelError(
6317
- import_errors18.ErrorCode.GAS_LIMIT_TOO_LOW,
6444
+ throw new import_errors19.FuelError(
6445
+ import_errors19.ErrorCode.GAS_LIMIT_TOO_LOW,
6318
6446
  `Gas limit '${setGasLimit}' is lower than the required: '${gasUsed}'.`
6319
6447
  );
6320
6448
  }
6321
6449
  if (!(0, import_utils33.isDefined)(setMaxFee)) {
6322
6450
  request.maxFee = maxFee;
6323
6451
  } else if (maxFee.gt(setMaxFee)) {
6324
- throw new import_errors18.FuelError(
6325
- import_errors18.ErrorCode.MAX_FEE_TOO_LOW,
6452
+ throw new import_errors19.FuelError(
6453
+ import_errors19.ErrorCode.MAX_FEE_TOO_LOW,
6326
6454
  `Max fee '${setMaxFee}' is lower than the required: '${maxFee}'.`
6327
6455
  );
6328
6456
  }
@@ -6333,7 +6461,7 @@ var Account = class extends import_interfaces.AbstractAccount {
6333
6461
  // src/wallet/keystore-wallet.ts
6334
6462
  var import_address6 = require("@fuel-ts/address");
6335
6463
  var import_crypto6 = require("@fuel-ts/crypto");
6336
- var import_errors19 = require("@fuel-ts/errors");
6464
+ var import_errors20 = require("@fuel-ts/errors");
6337
6465
  var import_utils34 = require("@fuel-ts/utils");
6338
6466
  var DEFAULT_KDF_PARAMS_LOG_N = 13;
6339
6467
  var DEFAULT_KDF_PARAMS_R = 8;
@@ -6410,8 +6538,8 @@ async function decryptKeystoreWallet(jsonWallet, password) {
6410
6538
  const macHashUint8Array = (0, import_crypto6.keccak256)(data);
6411
6539
  const macHash = (0, import_crypto6.stringFromBuffer)(macHashUint8Array, "hex");
6412
6540
  if (mac !== macHash) {
6413
- throw new import_errors19.FuelError(
6414
- import_errors19.ErrorCode.INVALID_PASSWORD,
6541
+ throw new import_errors20.FuelError(
6542
+ import_errors20.ErrorCode.INVALID_PASSWORD,
6415
6543
  "Failed to decrypt the keystore wallet, the provided password is incorrect."
6416
6544
  );
6417
6545
  }
@@ -6541,14 +6669,14 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
6541
6669
 
6542
6670
  // src/hdwallet/hdwallet.ts
6543
6671
  var import_crypto8 = require("@fuel-ts/crypto");
6544
- var import_errors22 = require("@fuel-ts/errors");
6672
+ var import_errors23 = require("@fuel-ts/errors");
6545
6673
  var import_hasher6 = require("@fuel-ts/hasher");
6546
6674
  var import_math23 = require("@fuel-ts/math");
6547
6675
  var import_utils39 = require("@fuel-ts/utils");
6548
6676
 
6549
6677
  // src/mnemonic/mnemonic.ts
6550
6678
  var import_crypto7 = require("@fuel-ts/crypto");
6551
- var import_errors21 = require("@fuel-ts/errors");
6679
+ var import_errors22 = require("@fuel-ts/errors");
6552
6680
  var import_hasher5 = require("@fuel-ts/hasher");
6553
6681
  var import_utils37 = require("@fuel-ts/utils");
6554
6682
 
@@ -8605,7 +8733,7 @@ var english = [
8605
8733
  ];
8606
8734
 
8607
8735
  // src/mnemonic/utils.ts
8608
- var import_errors20 = require("@fuel-ts/errors");
8736
+ var import_errors21 = require("@fuel-ts/errors");
8609
8737
  var import_hasher4 = require("@fuel-ts/hasher");
8610
8738
  var import_utils36 = require("@fuel-ts/utils");
8611
8739
  function getLowerMask(bits) {
@@ -8654,8 +8782,8 @@ function mnemonicWordsToEntropy(words, wordlist) {
8654
8782
  for (let i = 0; i < words.length; i += 1) {
8655
8783
  const index = wordlist.indexOf(words[i].normalize("NFKD"));
8656
8784
  if (index === -1) {
8657
- throw new import_errors20.FuelError(
8658
- import_errors20.ErrorCode.INVALID_MNEMONIC,
8785
+ throw new import_errors21.FuelError(
8786
+ import_errors21.ErrorCode.INVALID_MNEMONIC,
8659
8787
  `Invalid mnemonic: the word '${words[i]}' is not found in the provided wordlist.`
8660
8788
  );
8661
8789
  }
@@ -8671,8 +8799,8 @@ function mnemonicWordsToEntropy(words, wordlist) {
8671
8799
  const checksumMask = getUpperMask(checksumBits);
8672
8800
  const checksum = (0, import_utils36.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
8673
8801
  if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
8674
- throw new import_errors20.FuelError(
8675
- import_errors20.ErrorCode.INVALID_CHECKSUM,
8802
+ throw new import_errors21.FuelError(
8803
+ import_errors21.ErrorCode.INVALID_CHECKSUM,
8676
8804
  "Checksum validation failed for the provided mnemonic."
8677
8805
  );
8678
8806
  }
@@ -8686,16 +8814,16 @@ var TestnetPRV = "0x04358394";
8686
8814
  var MNEMONIC_SIZES = [12, 15, 18, 21, 24];
8687
8815
  function assertWordList(wordlist) {
8688
8816
  if (wordlist.length !== 2048) {
8689
- throw new import_errors21.FuelError(
8690
- import_errors21.ErrorCode.INVALID_WORD_LIST,
8817
+ throw new import_errors22.FuelError(
8818
+ import_errors22.ErrorCode.INVALID_WORD_LIST,
8691
8819
  `Expected word list length of 2048, but got ${wordlist.length}.`
8692
8820
  );
8693
8821
  }
8694
8822
  }
8695
8823
  function assertEntropy(entropy) {
8696
8824
  if (entropy.length % 4 !== 0 || entropy.length < 16 || entropy.length > 32) {
8697
- throw new import_errors21.FuelError(
8698
- import_errors21.ErrorCode.INVALID_ENTROPY,
8825
+ throw new import_errors22.FuelError(
8826
+ import_errors22.ErrorCode.INVALID_ENTROPY,
8699
8827
  `Entropy should be between 16 and 32 bytes and a multiple of 4, but got ${entropy.length} bytes.`
8700
8828
  );
8701
8829
  }
@@ -8705,7 +8833,7 @@ function assertMnemonic(words) {
8705
8833
  const errorMsg = `Invalid mnemonic size. Expected one of [${MNEMONIC_SIZES.join(
8706
8834
  ", "
8707
8835
  )}] words, but got ${words.length}.`;
8708
- throw new import_errors21.FuelError(import_errors21.ErrorCode.INVALID_MNEMONIC, errorMsg);
8836
+ throw new import_errors22.FuelError(import_errors22.ErrorCode.INVALID_MNEMONIC, errorMsg);
8709
8837
  }
8710
8838
  }
8711
8839
  var Mnemonic = class {
@@ -8823,8 +8951,8 @@ var Mnemonic = class {
8823
8951
  static masterKeysFromSeed(seed) {
8824
8952
  const seedArray = (0, import_utils37.arrayify)(seed);
8825
8953
  if (seedArray.length < 16 || seedArray.length > 64) {
8826
- throw new import_errors21.FuelError(
8827
- import_errors21.ErrorCode.INVALID_SEED,
8954
+ throw new import_errors22.FuelError(
8955
+ import_errors22.ErrorCode.INVALID_SEED,
8828
8956
  `Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
8829
8957
  );
8830
8958
  }
@@ -8901,7 +9029,7 @@ function isValidExtendedKey(extendedKey) {
8901
9029
  function parsePath(path2, depth = 0) {
8902
9030
  const components = path2.split("/");
8903
9031
  if (components.length === 0 || components[0] === "m" && depth !== 0) {
8904
- throw new import_errors22.FuelError(import_errors22.ErrorCode.HD_WALLET_ERROR, `invalid path - ${path2}`);
9032
+ throw new import_errors23.FuelError(import_errors23.ErrorCode.HD_WALLET_ERROR, `invalid path - ${path2}`);
8905
9033
  }
8906
9034
  if (components[0] === "m") {
8907
9035
  components.shift();
@@ -8930,8 +9058,8 @@ var HDWallet = class {
8930
9058
  this.privateKey = (0, import_utils39.hexlify)(config.privateKey);
8931
9059
  } else {
8932
9060
  if (!config.publicKey) {
8933
- throw new import_errors22.FuelError(
8934
- import_errors22.ErrorCode.HD_WALLET_ERROR,
9061
+ throw new import_errors23.FuelError(
9062
+ import_errors23.ErrorCode.HD_WALLET_ERROR,
8935
9063
  "Both public and private Key cannot be missing. At least one should be provided."
8936
9064
  );
8937
9065
  }
@@ -8960,8 +9088,8 @@ var HDWallet = class {
8960
9088
  const data = new Uint8Array(37);
8961
9089
  if (index & HARDENED_INDEX) {
8962
9090
  if (!privateKey) {
8963
- throw new import_errors22.FuelError(
8964
- import_errors22.ErrorCode.HD_WALLET_ERROR,
9091
+ throw new import_errors23.FuelError(
9092
+ import_errors23.ErrorCode.HD_WALLET_ERROR,
8965
9093
  "Cannot derive a hardened index without a private Key."
8966
9094
  );
8967
9095
  }
@@ -9013,8 +9141,8 @@ var HDWallet = class {
9013
9141
  */
9014
9142
  toExtendedKey(isPublic = false, testnet = false) {
9015
9143
  if (this.depth >= 256) {
9016
- throw new import_errors22.FuelError(
9017
- import_errors22.ErrorCode.HD_WALLET_ERROR,
9144
+ throw new import_errors23.FuelError(
9145
+ import_errors23.ErrorCode.HD_WALLET_ERROR,
9018
9146
  `Exceeded max depth of 255. Current depth: ${this.depth}.`
9019
9147
  );
9020
9148
  }
@@ -9045,10 +9173,10 @@ var HDWallet = class {
9045
9173
  const bytes = (0, import_utils39.arrayify)(decoded);
9046
9174
  const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
9047
9175
  if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
9048
- throw new import_errors22.FuelError(import_errors22.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
9176
+ throw new import_errors23.FuelError(import_errors23.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
9049
9177
  }
9050
9178
  if (!validChecksum) {
9051
- throw new import_errors22.FuelError(import_errors22.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
9179
+ throw new import_errors23.FuelError(import_errors23.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
9052
9180
  }
9053
9181
  const depth = bytes[4];
9054
9182
  const parentFingerprint = (0, import_utils39.hexlify)(bytes.slice(5, 9));
@@ -9056,14 +9184,14 @@ var HDWallet = class {
9056
9184
  const chainCode = (0, import_utils39.hexlify)(bytes.slice(13, 45));
9057
9185
  const key = bytes.slice(45, 78);
9058
9186
  if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
9059
- throw new import_errors22.FuelError(
9060
- import_errors22.ErrorCode.HD_WALLET_ERROR,
9187
+ throw new import_errors23.FuelError(
9188
+ import_errors23.ErrorCode.HD_WALLET_ERROR,
9061
9189
  "Inconsistency detected: Depth is zero but fingerprint/index is non-zero."
9062
9190
  );
9063
9191
  }
9064
9192
  if (isPublicExtendedKey(bytes)) {
9065
9193
  if (key[0] !== 3) {
9066
- throw new import_errors22.FuelError(import_errors22.ErrorCode.HD_WALLET_ERROR, "Invalid public extended key.");
9194
+ throw new import_errors23.FuelError(import_errors23.ErrorCode.HD_WALLET_ERROR, "Invalid public extended key.");
9067
9195
  }
9068
9196
  return new HDWallet({
9069
9197
  publicKey: key,
@@ -9074,7 +9202,7 @@ var HDWallet = class {
9074
9202
  });
9075
9203
  }
9076
9204
  if (key[0] !== 0) {
9077
- throw new import_errors22.FuelError(import_errors22.ErrorCode.HD_WALLET_ERROR, "Invalid private extended key.");
9205
+ throw new import_errors23.FuelError(import_errors23.ErrorCode.HD_WALLET_ERROR, "Invalid private extended key.");
9078
9206
  }
9079
9207
  return new HDWallet({
9080
9208
  privateKey: key.slice(1),
@@ -9318,26 +9446,26 @@ var WalletsConfig = class {
9318
9446
  amountPerCoin
9319
9447
  }) {
9320
9448
  if (Array.isArray(wallets) && wallets.length === 0 || typeof wallets === "number" && wallets <= 0) {
9321
- throw new import_errors23.FuelError(
9322
- import_errors23.FuelError.CODES.INVALID_INPUT_PARAMETERS,
9449
+ throw new import_errors24.FuelError(
9450
+ import_errors24.FuelError.CODES.INVALID_INPUT_PARAMETERS,
9323
9451
  "Number of wallets must be greater than zero."
9324
9452
  );
9325
9453
  }
9326
9454
  if (Array.isArray(assets2) && assets2.length === 0 || typeof assets2 === "number" && assets2 <= 0) {
9327
- throw new import_errors23.FuelError(
9328
- import_errors23.FuelError.CODES.INVALID_INPUT_PARAMETERS,
9455
+ throw new import_errors24.FuelError(
9456
+ import_errors24.FuelError.CODES.INVALID_INPUT_PARAMETERS,
9329
9457
  "Number of assets per wallet must be greater than zero."
9330
9458
  );
9331
9459
  }
9332
9460
  if (coinsPerAsset <= 0) {
9333
- throw new import_errors23.FuelError(
9334
- import_errors23.FuelError.CODES.INVALID_INPUT_PARAMETERS,
9461
+ throw new import_errors24.FuelError(
9462
+ import_errors24.FuelError.CODES.INVALID_INPUT_PARAMETERS,
9335
9463
  "Number of coins per asset must be greater than zero."
9336
9464
  );
9337
9465
  }
9338
9466
  if (amountPerCoin < 0) {
9339
- throw new import_errors23.FuelError(
9340
- import_errors23.FuelError.CODES.INVALID_INPUT_PARAMETERS,
9467
+ throw new import_errors24.FuelError(
9468
+ import_errors24.FuelError.CODES.INVALID_INPUT_PARAMETERS,
9341
9469
  "Amount per coin must be greater than or equal to zero."
9342
9470
  );
9343
9471
  }
@@ -9369,7 +9497,7 @@ async function setupTestProviderAndWallets({
9369
9497
  const launchNodeOptions = {
9370
9498
  loggingEnabled: false,
9371
9499
  ...nodeOptions,
9372
- snapshotConfig: (0, import_ramda5.mergeDeepRight)(
9500
+ snapshotConfig: (0, import_ramda8.mergeDeepRight)(
9373
9501
  import_utils41.defaultSnapshotConfigs,
9374
9502
  walletsConfig.apply(nodeOptions?.snapshotConfig)
9375
9503
  ),