@fuel-ts/account 0.96.1 → 0.97.0

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 (40) hide show
  1. package/dist/account.d.ts +6 -0
  2. package/dist/account.d.ts.map +1 -1
  3. package/dist/index.d.ts +1 -0
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.global.js +563 -298
  6. package/dist/index.global.js.map +1 -1
  7. package/dist/index.js +594 -320
  8. package/dist/index.js.map +1 -1
  9. package/dist/index.mjs +600 -327
  10. package/dist/index.mjs.map +1 -1
  11. package/dist/predicate/predicate.d.ts +16 -11
  12. package/dist/predicate/predicate.d.ts.map +1 -1
  13. package/dist/providers/__generated__/operations.d.ts +94 -126
  14. package/dist/providers/__generated__/operations.d.ts.map +1 -1
  15. package/dist/providers/provider.d.ts +5 -8
  16. package/dist/providers/provider.d.ts.map +1 -1
  17. package/dist/providers/transaction-request/blob-transaction-request.d.ts +2 -2
  18. package/dist/providers/transaction-request/blob-transaction-request.d.ts.map +1 -1
  19. package/dist/providers/transaction-summary/get-transaction-summary.d.ts +3 -2
  20. package/dist/providers/transaction-summary/get-transaction-summary.d.ts.map +1 -1
  21. package/dist/providers/transaction-summary/types.d.ts +38 -8
  22. package/dist/providers/transaction-summary/types.d.ts.map +1 -1
  23. package/dist/providers/utils/handle-gql-error-message.d.ts +2 -1
  24. package/dist/providers/utils/handle-gql-error-message.d.ts.map +1 -1
  25. package/dist/providers/utils/receipts.d.ts.map +1 -1
  26. package/dist/providers/utils/validate-pagination-args.d.ts +9 -0
  27. package/dist/providers/utils/validate-pagination-args.d.ts.map +1 -0
  28. package/dist/test-utils.global.js +302 -237
  29. package/dist/test-utils.global.js.map +1 -1
  30. package/dist/test-utils.js +276 -211
  31. package/dist/test-utils.js.map +1 -1
  32. package/dist/test-utils.mjs +287 -222
  33. package/dist/test-utils.mjs.map +1 -1
  34. package/dist/utils/deployScriptOrPredicate.d.ts +14 -0
  35. package/dist/utils/deployScriptOrPredicate.d.ts.map +1 -0
  36. package/dist/utils/formatTransferToContractScriptData.d.ts +7 -7
  37. package/dist/utils/formatTransferToContractScriptData.d.ts.map +1 -1
  38. package/dist/utils/predicate-script-loader-instructions.d.ts +9 -0
  39. package/dist/utils/predicate-script-loader-instructions.d.ts.map +1 -0
  40. package/package.json +17 -17
@@ -370,7 +370,7 @@ var addAmountToCoinQuantities = (params) => {
370
370
 
371
371
  // src/providers/provider.ts
372
372
  import { Address as Address3 } from "@fuel-ts/address";
373
- import { ErrorCode as ErrorCode14, FuelError as FuelError17 } from "@fuel-ts/errors";
373
+ import { ErrorCode as ErrorCode15, FuelError as FuelError18 } from "@fuel-ts/errors";
374
374
  import { BN as BN2, bn as bn17 } from "@fuel-ts/math";
375
375
  import { InputType as InputType7, InputMessageCoder as InputMessageCoder2, TransactionCoder as TransactionCoder5 } from "@fuel-ts/transactions";
376
376
  import { arrayify as arrayify13, hexlify as hexlify17, DateTime as DateTime2, isDefined as isDefined2 } from "@fuel-ts/utils";
@@ -423,9 +423,6 @@ var ReceiptFragmentDoc = gql`
423
423
  var SuccessStatusFragmentDoc = gql`
424
424
  fragment SuccessStatusFragment on SuccessStatus {
425
425
  type: __typename
426
- block {
427
- id
428
- }
429
426
  time
430
427
  programState {
431
428
  returnType
@@ -438,6 +435,14 @@ var SuccessStatusFragmentDoc = gql`
438
435
  totalFee
439
436
  }
440
437
  ${ReceiptFragmentDoc}`;
438
+ var SuccessStatusWithBlockIdFragmentDoc = gql`
439
+ fragment SuccessStatusWithBlockIdFragment on SuccessStatus {
440
+ ...SuccessStatusFragment
441
+ block {
442
+ id
443
+ }
444
+ }
445
+ ${SuccessStatusFragmentDoc}`;
441
446
  var MalleableTransactionFieldsFragmentDoc = gql`
442
447
  fragment malleableTransactionFieldsFragment on Transaction {
443
448
  receiptsRoot
@@ -482,9 +487,6 @@ var MalleableTransactionFieldsFragmentDoc = gql`
482
487
  var FailureStatusFragmentDoc = gql`
483
488
  fragment FailureStatusFragment on FailureStatus {
484
489
  type: __typename
485
- block {
486
- id
487
- }
488
490
  totalGas
489
491
  totalFee
490
492
  time
@@ -494,6 +496,14 @@ var FailureStatusFragmentDoc = gql`
494
496
  }
495
497
  }
496
498
  ${ReceiptFragmentDoc}`;
499
+ var FailureStatusWithBlockIdFragmentDoc = gql`
500
+ fragment FailureStatusWithBlockIdFragment on FailureStatus {
501
+ ...FailureStatusFragment
502
+ block {
503
+ id
504
+ }
505
+ }
506
+ ${FailureStatusFragmentDoc}`;
497
507
  var SqueezedOutStatusFragmentDoc = gql`
498
508
  fragment SqueezedOutStatusFragment on SqueezedOutStatus {
499
509
  type: __typename
@@ -506,13 +516,13 @@ var TransactionStatusSubscriptionFragmentDoc = gql`
506
516
  ...SubmittedStatusFragment
507
517
  }
508
518
  ... on SuccessStatus {
509
- ...SuccessStatusFragment
519
+ ...SuccessStatusWithBlockIdFragment
510
520
  transaction {
511
521
  ...malleableTransactionFieldsFragment
512
522
  }
513
523
  }
514
524
  ... on FailureStatus {
515
- ...FailureStatusFragment
525
+ ...FailureStatusWithBlockIdFragment
516
526
  transaction {
517
527
  ...malleableTransactionFieldsFragment
518
528
  }
@@ -522,9 +532,9 @@ var TransactionStatusSubscriptionFragmentDoc = gql`
522
532
  }
523
533
  }
524
534
  ${SubmittedStatusFragmentDoc}
525
- ${SuccessStatusFragmentDoc}
535
+ ${SuccessStatusWithBlockIdFragmentDoc}
526
536
  ${MalleableTransactionFieldsFragmentDoc}
527
- ${FailureStatusFragmentDoc}
537
+ ${FailureStatusWithBlockIdFragmentDoc}
528
538
  ${SqueezedOutStatusFragmentDoc}`;
529
539
  var TransactionStatusFragmentDoc = gql`
530
540
  fragment transactionStatusFragment on TransactionStatus {
@@ -554,6 +564,12 @@ var TransactionFragmentDoc = gql`
554
564
  }
555
565
  }
556
566
  ${TransactionStatusFragmentDoc}`;
567
+ var TransactionRawPayloadFragmentDoc = gql`
568
+ fragment transactionRawPayloadFragment on Transaction {
569
+ id
570
+ rawPayload
571
+ }
572
+ `;
557
573
  var InputEstimatePredicatesFragmentDoc = gql`
558
574
  fragment inputEstimatePredicatesFragment on Input {
559
575
  ... on InputCoin {
@@ -641,7 +657,6 @@ var CoinFragmentDoc = gql`
641
657
  fragment coinFragment on Coin {
642
658
  type: __typename
643
659
  utxoId
644
- owner
645
660
  amount
646
661
  assetId
647
662
  blockCreated
@@ -665,10 +680,15 @@ var MessageFragmentDoc = gql`
665
680
  sender
666
681
  recipient
667
682
  data
668
- nonce
669
683
  daHeight
670
684
  }
671
685
  `;
686
+ var GetMessageFragmentDoc = gql`
687
+ fragment getMessageFragment on Message {
688
+ ...messageFragment
689
+ nonce
690
+ }
691
+ ${MessageFragmentDoc}`;
672
692
  var MessageProofFragmentDoc = gql`
673
693
  fragment messageProofFragment on MessageProof {
674
694
  messageProof {
@@ -713,7 +733,6 @@ var MessageProofFragmentDoc = gql`
713
733
  }
714
734
  sender
715
735
  recipient
716
- nonce
717
736
  amount
718
737
  data
719
738
  }
@@ -862,12 +881,6 @@ var RelayedTransactionStatusFragmentDoc = gql`
862
881
  }
863
882
  }
864
883
  `;
865
- var TransactionRawPayloadFragmentDoc = gql`
866
- fragment transactionRawPayload on Transaction {
867
- id
868
- rawPayload
869
- }
870
- `;
871
884
  var GetVersionDocument = gql`
872
885
  query getVersion {
873
886
  nodeInfo {
@@ -910,16 +923,34 @@ var GetTransactionDocument = gql`
910
923
  var GetTransactionWithReceiptsDocument = gql`
911
924
  query getTransactionWithReceipts($transactionId: TransactionId!) {
912
925
  transaction(id: $transactionId) {
913
- ...transactionFragment
926
+ id
927
+ rawPayload
928
+ status {
929
+ ... on SubmittedStatus {
930
+ ...SubmittedStatusFragment
931
+ }
932
+ ... on SuccessStatus {
933
+ ...SuccessStatusWithBlockIdFragment
934
+ }
935
+ ... on FailureStatus {
936
+ ...FailureStatusWithBlockIdFragment
937
+ }
938
+ ... on SqueezedOutStatus {
939
+ ...SqueezedOutStatusFragment
940
+ }
941
+ }
914
942
  }
915
943
  }
916
- ${TransactionFragmentDoc}`;
944
+ ${SubmittedStatusFragmentDoc}
945
+ ${SuccessStatusWithBlockIdFragmentDoc}
946
+ ${FailureStatusWithBlockIdFragmentDoc}
947
+ ${SqueezedOutStatusFragmentDoc}`;
917
948
  var GetTransactionsDocument = gql`
918
949
  query getTransactions($after: String, $before: String, $first: Int, $last: Int) {
919
950
  transactions(after: $after, before: $before, first: $first, last: $last) {
920
951
  edges {
921
952
  node {
922
- ...transactionFragment
953
+ rawPayload
923
954
  }
924
955
  }
925
956
  pageInfo {
@@ -927,8 +958,7 @@ var GetTransactionsDocument = gql`
927
958
  }
928
959
  }
929
960
  }
930
- ${TransactionFragmentDoc}
931
- ${PageInfoFragmentDoc}`;
961
+ ${PageInfoFragmentDoc}`;
932
962
  var GetTransactionsByOwnerDocument = gql`
933
963
  query getTransactionsByOwner($owner: Address!, $after: String, $before: String, $first: Int, $last: Int) {
934
964
  transactionsByOwner(
@@ -987,7 +1017,7 @@ var GetBlockWithTransactionsDocument = gql`
987
1017
  block(id: $blockId, height: $blockHeight) {
988
1018
  ...blockFragment
989
1019
  transactions {
990
- ...transactionRawPayload
1020
+ ...transactionRawPayloadFragment
991
1021
  }
992
1022
  }
993
1023
  }
@@ -1012,6 +1042,7 @@ var GetCoinDocument = gql`
1012
1042
  query getCoin($coinId: UtxoId!) {
1013
1043
  coin(utxoId: $coinId) {
1014
1044
  ...coinFragment
1045
+ owner
1015
1046
  }
1016
1047
  }
1017
1048
  ${CoinFragmentDoc}`;
@@ -1120,13 +1151,13 @@ var GetMessagesDocument = gql`
1120
1151
  }
1121
1152
  edges {
1122
1153
  node {
1123
- ...messageFragment
1154
+ ...getMessageFragment
1124
1155
  }
1125
1156
  }
1126
1157
  }
1127
1158
  }
1128
1159
  ${PageInfoFragmentDoc}
1129
- ${MessageFragmentDoc}`;
1160
+ ${GetMessageFragmentDoc}`;
1130
1161
  var GetMessageProofDocument = gql`
1131
1162
  query getMessageProof($transactionId: TransactionId!, $nonce: Nonce!, $commitBlockId: BlockId, $commitBlockHeight: U32) {
1132
1163
  messageProof(
@@ -1664,9 +1695,11 @@ function assembleReceiptByType(receipt) {
1664
1695
  const { receiptType } = receipt;
1665
1696
  switch (receiptType) {
1666
1697
  case "CALL" /* Call */: {
1698
+ const id = hexOrZero(receipt.id || receipt.contractId);
1667
1699
  const callReceipt = {
1668
1700
  type: ReceiptType.Call,
1669
- from: hexOrZero(receipt.id || receipt.contractId),
1701
+ id,
1702
+ from: id,
1670
1703
  to: hexOrZero(receipt?.to),
1671
1704
  amount: bn4(receipt.amount),
1672
1705
  assetId: hexOrZero(receipt.assetId),
@@ -1723,24 +1756,36 @@ function assembleReceiptByType(receipt) {
1723
1756
  return revertReceipt;
1724
1757
  }
1725
1758
  case "LOG" /* Log */: {
1759
+ const ra = bn4(receipt.ra);
1760
+ const rb = bn4(receipt.rb);
1761
+ const rc = bn4(receipt.rc);
1762
+ const rd = bn4(receipt.rd);
1726
1763
  const logReceipt = {
1727
1764
  type: ReceiptType.Log,
1728
1765
  id: hexOrZero(receipt.id || receipt.contractId),
1729
- val0: bn4(receipt.ra),
1730
- val1: bn4(receipt.rb),
1731
- val2: bn4(receipt.rc),
1732
- val3: bn4(receipt.rd),
1766
+ ra,
1767
+ rb,
1768
+ rc,
1769
+ rd,
1770
+ val0: ra,
1771
+ val1: rb,
1772
+ val2: rc,
1773
+ val3: rd,
1733
1774
  pc: bn4(receipt.pc),
1734
1775
  is: bn4(receipt.is)
1735
1776
  };
1736
1777
  return logReceipt;
1737
1778
  }
1738
1779
  case "LOG_DATA" /* LogData */: {
1780
+ const ra = bn4(receipt.ra);
1781
+ const rb = bn4(receipt.rb);
1739
1782
  const logDataReceipt = {
1740
1783
  type: ReceiptType.LogData,
1741
1784
  id: hexOrZero(receipt.id || receipt.contractId),
1742
- val0: bn4(receipt.ra),
1743
- val1: bn4(receipt.rb),
1785
+ ra,
1786
+ rb,
1787
+ val0: ra,
1788
+ val1: rb,
1744
1789
  ptr: bn4(receipt.ptr),
1745
1790
  len: bn4(receipt.len),
1746
1791
  digest: hexOrZero(receipt.digest),
@@ -1751,9 +1796,11 @@ function assembleReceiptByType(receipt) {
1751
1796
  return logDataReceipt;
1752
1797
  }
1753
1798
  case "TRANSFER" /* Transfer */: {
1799
+ const id = hexOrZero(receipt.id || receipt.contractId);
1754
1800
  const transferReceipt = {
1755
1801
  type: ReceiptType.Transfer,
1756
- from: hexOrZero(receipt.id || receipt.contractId),
1802
+ id,
1803
+ from: id,
1757
1804
  to: hexOrZero(receipt.toAddress || receipt?.to),
1758
1805
  amount: bn4(receipt.amount),
1759
1806
  assetId: hexOrZero(receipt.assetId),
@@ -1763,9 +1810,11 @@ function assembleReceiptByType(receipt) {
1763
1810
  return transferReceipt;
1764
1811
  }
1765
1812
  case "TRANSFER_OUT" /* TransferOut */: {
1813
+ const id = hexOrZero(receipt.id || receipt.contractId);
1766
1814
  const transferOutReceipt = {
1767
1815
  type: ReceiptType.TransferOut,
1768
- from: hexOrZero(receipt.id || receipt.contractId),
1816
+ id,
1817
+ from: id,
1769
1818
  to: hexOrZero(receipt.toAddress || receipt.to),
1770
1819
  amount: bn4(receipt.amount),
1771
1820
  assetId: hexOrZero(receipt.assetId),
@@ -2750,7 +2799,7 @@ var BlobTransactionRequest = class extends BaseTransactionRequest {
2750
2799
  type = TransactionType.Blob;
2751
2800
  /** Blob ID */
2752
2801
  blobId;
2753
- /** Witness index of contract bytecode to create */
2802
+ /** Witness index of the bytecode to create */
2754
2803
  witnessIndex;
2755
2804
  /**
2756
2805
  * Creates an instance `BlobTransactionRequest`.
@@ -4084,14 +4133,14 @@ var processGraphqlStatus = (gqlTransactionStatus) => {
4084
4133
  switch (gqlTransactionStatus.type) {
4085
4134
  case "SuccessStatus":
4086
4135
  time = gqlTransactionStatus.time;
4087
- blockId = gqlTransactionStatus.block.id;
4136
+ blockId = gqlTransactionStatus.block?.id;
4088
4137
  isStatusSuccess = true;
4089
4138
  totalFee = bn14(gqlTransactionStatus.totalFee);
4090
4139
  totalGas = bn14(gqlTransactionStatus.totalGas);
4091
4140
  break;
4092
4141
  case "FailureStatus":
4093
4142
  time = gqlTransactionStatus.time;
4094
- blockId = gqlTransactionStatus.block.id;
4143
+ blockId = gqlTransactionStatus.block?.id;
4095
4144
  isStatusFailure = true;
4096
4145
  totalFee = bn14(gqlTransactionStatus.totalFee);
4097
4146
  totalGas = bn14(gqlTransactionStatus.totalGas);
@@ -4526,11 +4575,53 @@ var handleGqlErrorMessage = (errorMessage, rawError) => {
4526
4575
  {},
4527
4576
  rawError
4528
4577
  );
4578
+ case "max number of coins is reached while trying to fit the target" /* MAX_COINS_REACHED */:
4579
+ throw new FuelError16(
4580
+ ErrorCode13.MAX_COINS_REACHED,
4581
+ "The account retrieving coins has exceeded the maximum number of coins per asset. Please consider combining your coins into a single UTXO.",
4582
+ {},
4583
+ rawError
4584
+ );
4529
4585
  default:
4530
4586
  throw new FuelError16(ErrorCode13.INVALID_REQUEST, errorMessage);
4531
4587
  }
4532
4588
  };
4533
4589
 
4590
+ // src/providers/utils/validate-pagination-args.ts
4591
+ import { FuelError as FuelError17, ErrorCode as ErrorCode14 } from "@fuel-ts/errors";
4592
+ var validatePaginationArgs = (params) => {
4593
+ const { paginationLimit, inputArgs = {} } = params;
4594
+ const { first, last, after, before } = inputArgs;
4595
+ if (after && before) {
4596
+ throw new FuelError17(
4597
+ ErrorCode14.INVALID_INPUT_PARAMETERS,
4598
+ 'Pagination arguments "after" and "before" cannot be used together'
4599
+ );
4600
+ }
4601
+ if ((first || 0) > paginationLimit || (last || 0) > paginationLimit) {
4602
+ throw new FuelError17(
4603
+ ErrorCode14.INVALID_INPUT_PARAMETERS,
4604
+ `Pagination limit for this query cannot exceed ${paginationLimit} items`
4605
+ );
4606
+ }
4607
+ if (first && before) {
4608
+ throw new FuelError17(
4609
+ ErrorCode14.INVALID_INPUT_PARAMETERS,
4610
+ 'The use of pagination argument "first" with "before" is not supported'
4611
+ );
4612
+ }
4613
+ if (last && after) {
4614
+ throw new FuelError17(
4615
+ ErrorCode14.INVALID_INPUT_PARAMETERS,
4616
+ 'The use of pagination argument "last" with "after" is not supported'
4617
+ );
4618
+ }
4619
+ if (!first && !last) {
4620
+ inputArgs.first = paginationLimit;
4621
+ }
4622
+ return inputArgs;
4623
+ };
4624
+
4534
4625
  // src/providers/provider.ts
4535
4626
  var MAX_RETRIES = 10;
4536
4627
  var RESOURCES_PAGE_SIZE_LIMIT = 512;
@@ -4675,7 +4766,7 @@ var _Provider = class {
4675
4766
  try {
4676
4767
  parsedUrl = new URL(url);
4677
4768
  } catch (error) {
4678
- throw new FuelError17(FuelError17.CODES.INVALID_URL, "Invalid URL provided.", { url }, error);
4769
+ throw new FuelError18(FuelError18.CODES.INVALID_URL, "Invalid URL provided.", { url }, error);
4679
4770
  }
4680
4771
  const username = parsedUrl.username;
4681
4772
  const password = parsedUrl.password;
@@ -4710,8 +4801,8 @@ var _Provider = class {
4710
4801
  getChain() {
4711
4802
  const chain = _Provider.chainInfoCache[this.urlWithoutAuth];
4712
4803
  if (!chain) {
4713
- throw new FuelError17(
4714
- ErrorCode14.CHAIN_INFO_CACHE_EMPTY,
4804
+ throw new FuelError18(
4805
+ ErrorCode15.CHAIN_INFO_CACHE_EMPTY,
4715
4806
  "Chain info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
4716
4807
  );
4717
4808
  }
@@ -4725,8 +4816,8 @@ var _Provider = class {
4725
4816
  getNode() {
4726
4817
  const node = _Provider.nodeInfoCache[this.urlWithoutAuth];
4727
4818
  if (!node) {
4728
- throw new FuelError17(
4729
- ErrorCode14.NODE_INFO_CACHE_EMPTY,
4819
+ throw new FuelError18(
4820
+ ErrorCode15.NODE_INFO_CACHE_EMPTY,
4730
4821
  "Node info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
4731
4822
  );
4732
4823
  }
@@ -4952,14 +5043,14 @@ Supported fuel-core version: ${supportedVersion}.`
4952
5043
  }
4953
5044
  } = this.getChain();
4954
5045
  if (bn17(tx.inputs.length).gt(maxInputs)) {
4955
- throw new FuelError17(
4956
- ErrorCode14.MAX_INPUTS_EXCEEDED,
5046
+ throw new FuelError18(
5047
+ ErrorCode15.MAX_INPUTS_EXCEEDED,
4957
5048
  `The transaction exceeds the maximum allowed number of inputs. Tx inputs: ${tx.inputs.length}, max inputs: ${maxInputs}`
4958
5049
  );
4959
5050
  }
4960
5051
  if (bn17(tx.outputs.length).gt(maxOutputs)) {
4961
- throw new FuelError17(
4962
- ErrorCode14.MAX_OUTPUTS_EXCEEDED,
5052
+ throw new FuelError18(
5053
+ ErrorCode15.MAX_OUTPUTS_EXCEEDED,
4963
5054
  `The transaction exceeds the maximum allowed number of outputs. Tx outputs: ${tx.outputs.length}, max outputs: ${maxOutputs}`
4964
5055
  );
4965
5056
  }
@@ -5372,7 +5463,7 @@ Supported fuel-core version: ${supportedVersion}.`
5372
5463
  const {
5373
5464
  coins: { edges, pageInfo }
5374
5465
  } = await this.operations.getCoins({
5375
- ...this.validatePaginationArgs({
5466
+ ...validatePaginationArgs({
5376
5467
  paginationLimit: RESOURCES_PAGE_SIZE_LIMIT,
5377
5468
  inputArgs: paginationArgs
5378
5469
  }),
@@ -5382,7 +5473,7 @@ Supported fuel-core version: ${supportedVersion}.`
5382
5473
  id: node.utxoId,
5383
5474
  assetId: node.assetId,
5384
5475
  amount: bn17(node.amount),
5385
- owner: Address3.fromAddressOrString(node.owner),
5476
+ owner: ownerAddress,
5386
5477
  blockCreated: bn17(node.blockCreated),
5387
5478
  txCreatedIdx: bn17(node.txCreatedIdx)
5388
5479
  }));
@@ -5436,7 +5527,7 @@ Supported fuel-core version: ${supportedVersion}.`
5436
5527
  id: coin.utxoId,
5437
5528
  amount: bn17(coin.amount),
5438
5529
  assetId: coin.assetId,
5439
- owner: Address3.fromAddressOrString(coin.owner),
5530
+ owner: ownerAddress,
5440
5531
  blockCreated: bn17(coin.blockCreated),
5441
5532
  txCreatedIdx: bn17(coin.txCreatedIdx)
5442
5533
  };
@@ -5511,7 +5602,7 @@ Supported fuel-core version: ${supportedVersion}.`
5511
5602
  const {
5512
5603
  blocks: { edges, pageInfo }
5513
5604
  } = await this.operations.getBlocks({
5514
- ...this.validatePaginationArgs({
5605
+ ...validatePaginationArgs({
5515
5606
  paginationLimit: BLOCKS_PAGE_SIZE_LIMIT,
5516
5607
  inputArgs: params
5517
5608
  })
@@ -5590,7 +5681,7 @@ Supported fuel-core version: ${supportedVersion}.`
5590
5681
  0
5591
5682
  )?.[0];
5592
5683
  } catch (error) {
5593
- if (error instanceof FuelError17 && error.code === ErrorCode14.UNSUPPORTED_TRANSACTION_TYPE) {
5684
+ if (error instanceof FuelError18 && error.code === ErrorCode15.UNSUPPORTED_TRANSACTION_TYPE) {
5594
5685
  console.warn("Unsupported transaction type encountered");
5595
5686
  return null;
5596
5687
  }
@@ -5606,7 +5697,7 @@ Supported fuel-core version: ${supportedVersion}.`
5606
5697
  const {
5607
5698
  transactions: { edges, pageInfo }
5608
5699
  } = await this.operations.getTransactions({
5609
- ...this.validatePaginationArgs({
5700
+ ...validatePaginationArgs({
5610
5701
  inputArgs: paginationArgs,
5611
5702
  paginationLimit: TRANSACTIONS_PAGE_SIZE_LIMIT
5612
5703
  })
@@ -5616,7 +5707,7 @@ Supported fuel-core version: ${supportedVersion}.`
5616
5707
  try {
5617
5708
  return coder.decode(arrayify13(rawPayload), 0)[0];
5618
5709
  } catch (error) {
5619
- if (error instanceof FuelError17 && error.code === ErrorCode14.UNSUPPORTED_TRANSACTION_TYPE) {
5710
+ if (error instanceof FuelError18 && error.code === ErrorCode15.UNSUPPORTED_TRANSACTION_TYPE) {
5620
5711
  console.warn("Unsupported transaction type encountered");
5621
5712
  return null;
5622
5713
  }
@@ -5701,7 +5792,7 @@ Supported fuel-core version: ${supportedVersion}.`
5701
5792
  const {
5702
5793
  messages: { edges, pageInfo }
5703
5794
  } = await this.operations.getMessages({
5704
- ...this.validatePaginationArgs({
5795
+ ...validatePaginationArgs({
5705
5796
  inputArgs: paginationArgs,
5706
5797
  paginationLimit: RESOURCES_PAGE_SIZE_LIMIT
5707
5798
  }),
@@ -5742,8 +5833,8 @@ Supported fuel-core version: ${supportedVersion}.`
5742
5833
  nonce
5743
5834
  };
5744
5835
  if (commitBlockId && commitBlockHeight) {
5745
- throw new FuelError17(
5746
- ErrorCode14.INVALID_INPUT_PARAMETERS,
5836
+ throw new FuelError18(
5837
+ ErrorCode15.INVALID_INPUT_PARAMETERS,
5747
5838
  "commitBlockId and commitBlockHeight cannot be used together"
5748
5839
  );
5749
5840
  }
@@ -5925,13 +6016,13 @@ Supported fuel-core version: ${supportedVersion}.`
5925
6016
  messageId: InputMessageCoder2.getMessageId({
5926
6017
  sender: rawMessage.sender,
5927
6018
  recipient: rawMessage.recipient,
5928
- nonce: rawMessage.nonce,
6019
+ nonce,
5929
6020
  amount: bn17(rawMessage.amount),
5930
6021
  data: rawMessage.data
5931
6022
  }),
5932
6023
  sender: Address3.fromAddressOrString(rawMessage.sender),
5933
6024
  recipient: Address3.fromAddressOrString(rawMessage.recipient),
5934
- nonce: rawMessage.nonce,
6025
+ nonce,
5935
6026
  amount: bn17(rawMessage.amount),
5936
6027
  data: InputMessageCoder2.decodeData(rawMessage.data),
5937
6028
  daHeight: bn17(rawMessage.daHeight)
@@ -5953,41 +6044,6 @@ Supported fuel-core version: ${supportedVersion}.`
5953
6044
  }
5954
6045
  return relayedTransactionStatus;
5955
6046
  }
5956
- /**
5957
- * @hidden
5958
- */
5959
- validatePaginationArgs(params) {
5960
- const { paginationLimit, inputArgs = {} } = params;
5961
- const { first, last, after, before } = inputArgs;
5962
- if (after && before) {
5963
- throw new FuelError17(
5964
- ErrorCode14.INVALID_INPUT_PARAMETERS,
5965
- 'Pagination arguments "after" and "before" cannot be used together'
5966
- );
5967
- }
5968
- if ((first || 0) > paginationLimit || (last || 0) > paginationLimit) {
5969
- throw new FuelError17(
5970
- ErrorCode14.INVALID_INPUT_PARAMETERS,
5971
- `Pagination limit for this query cannot exceed ${paginationLimit} items`
5972
- );
5973
- }
5974
- if (first && before) {
5975
- throw new FuelError17(
5976
- ErrorCode14.INVALID_INPUT_PARAMETERS,
5977
- 'The use of pagination argument "first" with "before" is not supported'
5978
- );
5979
- }
5980
- if (last && after) {
5981
- throw new FuelError17(
5982
- ErrorCode14.INVALID_INPUT_PARAMETERS,
5983
- 'The use of pagination argument "last" with "after" is not supported'
5984
- );
5985
- }
5986
- if (!first && !last) {
5987
- inputArgs.first = paginationLimit;
5988
- }
5989
- return inputArgs;
5990
- }
5991
6047
  /**
5992
6048
  * @hidden
5993
6049
  */
@@ -6033,7 +6089,7 @@ __publicField(Provider, "chainInfoCache", {});
6033
6089
  __publicField(Provider, "nodeInfoCache", {});
6034
6090
 
6035
6091
  // src/providers/transaction-summary/get-transaction-summary.ts
6036
- import { ErrorCode as ErrorCode15, FuelError as FuelError18 } from "@fuel-ts/errors";
6092
+ import { ErrorCode as ErrorCode16, FuelError as FuelError19 } from "@fuel-ts/errors";
6037
6093
  import { bn as bn18 } from "@fuel-ts/math";
6038
6094
  import { TransactionCoder as TransactionCoder6 } from "@fuel-ts/transactions";
6039
6095
  import { arrayify as arrayify14 } from "@fuel-ts/utils";
@@ -6667,7 +6723,7 @@ __publicField(TestAssetId, "B", new _TestAssetId(
6667
6723
 
6668
6724
  // src/test-utils/wallet-config.ts
6669
6725
  import { randomBytes as randomBytes8 } from "@fuel-ts/crypto";
6670
- import { FuelError as FuelError24 } from "@fuel-ts/errors";
6726
+ import { FuelError as FuelError25 } from "@fuel-ts/errors";
6671
6727
  import { defaultSnapshotConfigs as defaultSnapshotConfigs2, hexlify as hexlify24 } from "@fuel-ts/utils";
6672
6728
 
6673
6729
  // src/wallet/base-wallet-unlocked.ts
@@ -6676,9 +6732,9 @@ import { hexlify as hexlify21 } from "@fuel-ts/utils";
6676
6732
 
6677
6733
  // src/account.ts
6678
6734
  import { UTXO_ID_LEN as UTXO_ID_LEN3 } from "@fuel-ts/abi-coder";
6679
- import { Address as Address4 } from "@fuel-ts/address";
6735
+ import { Address as Address5 } from "@fuel-ts/address";
6680
6736
  import { randomBytes as randomBytes5 } from "@fuel-ts/crypto";
6681
- import { ErrorCode as ErrorCode16, FuelError as FuelError19 } from "@fuel-ts/errors";
6737
+ import { ErrorCode as ErrorCode17, FuelError as FuelError20 } from "@fuel-ts/errors";
6682
6738
  import { AbstractAccount } from "@fuel-ts/interfaces";
6683
6739
  import { bn as bn19 } from "@fuel-ts/math";
6684
6740
  import { InputType as InputType8 } from "@fuel-ts/transactions";
@@ -6700,38 +6756,47 @@ var mergeQuantities = (...coinQuantities) => {
6700
6756
  };
6701
6757
 
6702
6758
  // src/utils/formatTransferToContractScriptData.ts
6703
- import { BigNumberCoder as BigNumberCoder2 } from "@fuel-ts/abi-coder";
6759
+ import { ASSET_ID_LEN, BigNumberCoder as BigNumberCoder2, CONTRACT_ID_LEN, WORD_SIZE } from "@fuel-ts/abi-coder";
6760
+ import { Address as Address4 } from "@fuel-ts/address";
6704
6761
  import { BN as BN3 } from "@fuel-ts/math";
6705
- import { arrayify as arrayify15 } from "@fuel-ts/utils";
6762
+ import { arrayify as arrayify15, concat as concat4 } from "@fuel-ts/utils";
6706
6763
  import * as asm from "@fuels/vm-asm";
6707
- var formatTransferToContractScriptData = (params) => {
6708
- const { assetId, amountToTransfer, hexlifiedContractId } = params;
6764
+ var formatTransferToContractScriptData = (transferParams) => {
6709
6765
  const numberCoder = new BigNumberCoder2("u64");
6710
- const encoded = numberCoder.encode(new BN3(amountToTransfer).toNumber());
6711
- const scriptData = Uint8Array.from([
6712
- ...arrayify15(hexlifiedContractId),
6713
- ...encoded,
6714
- ...arrayify15(assetId)
6715
- ]);
6716
- return scriptData;
6766
+ return transferParams.reduce((acc, transferParam) => {
6767
+ const { assetId, amount, contractId } = transferParam;
6768
+ const encoded = numberCoder.encode(new BN3(amount).toNumber());
6769
+ const scriptData = concat4([
6770
+ Address4.fromAddressOrString(contractId).toBytes(),
6771
+ encoded,
6772
+ arrayify15(assetId)
6773
+ ]);
6774
+ return concat4([acc, scriptData]);
6775
+ }, new Uint8Array());
6717
6776
  };
6718
- var assembleTransferToContractScript = async (params) => {
6719
- const scriptData = formatTransferToContractScriptData(params);
6777
+ var assembleTransferToContractScript = async (transferParams) => {
6778
+ const scriptData = formatTransferToContractScriptData(transferParams);
6720
6779
  await asm.initWasm();
6721
- const gtf2 = asm.gtf(16, 0, asm.GTFArgs.ScriptData);
6722
- const addi2 = asm.addi(17, 16, 32);
6723
- const lw2 = asm.lw(18, 17, 0);
6724
- const addi22 = asm.addi(19, 17, 8);
6725
- const tr2 = asm.tr(16, 18, 19);
6726
- const ret2 = asm.ret(1);
6727
- const script = Uint8Array.from([
6728
- ...gtf2.to_bytes(),
6729
- ...addi2.to_bytes(),
6730
- ...lw2.to_bytes(),
6731
- ...addi22.to_bytes(),
6732
- ...tr2.to_bytes(),
6733
- ...ret2.to_bytes()
6734
- ]);
6780
+ let script = new Uint8Array();
6781
+ transferParams.forEach((_, i) => {
6782
+ const offset = (CONTRACT_ID_LEN + WORD_SIZE + ASSET_ID_LEN) * i;
6783
+ script = concat4([
6784
+ script,
6785
+ // Load ScriptData into register 0x10.
6786
+ asm.gtf(16, 0, asm.GTFArgs.ScriptData).to_bytes(),
6787
+ // Add the offset to 0x10 so it will point to the current contract ID, store in 0x11.
6788
+ asm.addi(17, 16, offset).to_bytes(),
6789
+ // Add CONTRACT_ID_LEN to 0x11 to point to the amount in the ScriptData, store in 0x12.
6790
+ asm.addi(18, 17, CONTRACT_ID_LEN).to_bytes(),
6791
+ // Load word to the amount at 0x12 into register 0x13.
6792
+ asm.lw(19, 18, 0).to_bytes(),
6793
+ // Add WORD_SIZE to 0x12 to point to the asset ID in the ScriptData, store in 0x14.
6794
+ asm.addi(20, 18, WORD_SIZE).to_bytes(),
6795
+ // Perform the transfer using contract ID in 0x11, amount in 0x13, and asset ID in 0x14.
6796
+ asm.tr(17, 19, 20).to_bytes()
6797
+ ]);
6798
+ });
6799
+ script = concat4([script, asm.ret(1).to_bytes()]);
6735
6800
  return { script, scriptData };
6736
6801
  };
6737
6802
 
@@ -6761,7 +6826,7 @@ var Account = class extends AbstractAccount {
6761
6826
  super();
6762
6827
  this._provider = provider;
6763
6828
  this._connector = connector;
6764
- this.address = Address4.fromDynamicInput(address);
6829
+ this.address = Address5.fromDynamicInput(address);
6765
6830
  }
6766
6831
  /**
6767
6832
  * The provider used to interact with the network.
@@ -6772,7 +6837,7 @@ var Account = class extends AbstractAccount {
6772
6837
  */
6773
6838
  get provider() {
6774
6839
  if (!this._provider) {
6775
- throw new FuelError19(ErrorCode16.MISSING_PROVIDER, "Provider not set");
6840
+ throw new FuelError20(ErrorCode17.MISSING_PROVIDER, "Provider not set");
6776
6841
  }
6777
6842
  return this._provider;
6778
6843
  }
@@ -6923,8 +6988,8 @@ var Account = class extends AbstractAccount {
6923
6988
  fundingAttempts += 1;
6924
6989
  }
6925
6990
  if (needsToBeFunded) {
6926
- throw new FuelError19(
6927
- ErrorCode16.NOT_ENOUGH_FUNDS,
6991
+ throw new FuelError20(
6992
+ ErrorCode17.NOT_ENOUGH_FUNDS,
6928
6993
  `The account ${this.address} does not have enough base asset funds to cover the transaction execution.`
6929
6994
  );
6930
6995
  }
@@ -6995,7 +7060,7 @@ var Account = class extends AbstractAccount {
6995
7060
  const { destination, amount, assetId } = transferParams;
6996
7061
  this.validateTransferAmount(amount);
6997
7062
  request.addCoinOutput(
6998
- Address4.fromAddressOrString(destination),
7063
+ Address5.fromAddressOrString(destination),
6999
7064
  amount,
7000
7065
  assetId ?? this.provider.getBaseAssetId()
7001
7066
  );
@@ -7029,35 +7094,35 @@ var Account = class extends AbstractAccount {
7029
7094
  * @returns A promise that resolves to the transaction response.
7030
7095
  */
7031
7096
  async transferToContract(contractId, amount, assetId, txParams = {}) {
7032
- if (bn19(amount).lte(0)) {
7033
- throw new FuelError19(
7034
- ErrorCode16.INVALID_TRANSFER_AMOUNT,
7035
- "Transfer amount must be a positive number."
7036
- );
7037
- }
7038
- const contractAddress = Address4.fromAddressOrString(contractId);
7039
- const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
7040
- const { script, scriptData } = await assembleTransferToContractScript({
7041
- hexlifiedContractId: contractAddress.toB256(),
7042
- amountToTransfer: bn19(amount),
7043
- assetId: assetIdToTransfer
7044
- });
7097
+ return this.batchTransferToContracts([{ amount, assetId, contractId }], txParams);
7098
+ }
7099
+ async batchTransferToContracts(contractTransferParams, txParams = {}) {
7045
7100
  let request = new ScriptTransactionRequest({
7046
- ...txParams,
7047
- script,
7048
- scriptData
7101
+ ...txParams
7049
7102
  });
7050
- request.addContractInputAndOutput(contractAddress);
7051
- const txCost = await this.getTransactionCost(request, {
7052
- quantities: [{ amount: bn19(amount), assetId: String(assetIdToTransfer) }]
7053
- });
7054
- request = this.validateGasLimitAndMaxFee({
7055
- transactionRequest: request,
7056
- gasUsed: txCost.gasUsed,
7057
- maxFee: txCost.maxFee,
7058
- txParams
7103
+ const quantities = [];
7104
+ const transferParams = contractTransferParams.map((transferParam) => {
7105
+ const amount = bn19(transferParam.amount);
7106
+ const contractAddress = Address5.fromAddressOrString(transferParam.contractId);
7107
+ const assetId = transferParam.assetId ? hexlify19(transferParam.assetId) : this.provider.getBaseAssetId();
7108
+ if (amount.lte(0)) {
7109
+ throw new FuelError20(
7110
+ ErrorCode17.INVALID_TRANSFER_AMOUNT,
7111
+ "Transfer amount must be a positive number."
7112
+ );
7113
+ }
7114
+ request.addContractInputAndOutput(contractAddress);
7115
+ quantities.push({ amount, assetId });
7116
+ return {
7117
+ amount,
7118
+ contractId: contractAddress.toB256(),
7119
+ assetId
7120
+ };
7059
7121
  });
7060
- await this.fund(request, txCost);
7122
+ const { script, scriptData } = await assembleTransferToContractScript(transferParams);
7123
+ request.script = script;
7124
+ request.scriptData = scriptData;
7125
+ request = await this.estimateAndFundTransaction(request, txParams, { quantities });
7061
7126
  return this.sendTransaction(request);
7062
7127
  }
7063
7128
  /**
@@ -7069,7 +7134,7 @@ var Account = class extends AbstractAccount {
7069
7134
  * @returns A promise that resolves to the transaction response.
7070
7135
  */
7071
7136
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
7072
- const recipientAddress = Address4.fromAddressOrString(recipient);
7137
+ const recipientAddress = Address5.fromAddressOrString(recipient);
7073
7138
  const recipientDataArray = arrayify16(
7074
7139
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
7075
7140
  );
@@ -7157,7 +7222,7 @@ var Account = class extends AbstractAccount {
7157
7222
  */
7158
7223
  async signMessage(message) {
7159
7224
  if (!this._connector) {
7160
- throw new FuelError19(ErrorCode16.MISSING_CONNECTOR, "A connector is required to sign messages.");
7225
+ throw new FuelError20(ErrorCode17.MISSING_CONNECTOR, "A connector is required to sign messages.");
7161
7226
  }
7162
7227
  return this._connector.signMessage(this.address.toString(), message);
7163
7228
  }
@@ -7169,8 +7234,8 @@ var Account = class extends AbstractAccount {
7169
7234
  */
7170
7235
  async signTransaction(transactionRequestLike) {
7171
7236
  if (!this._connector) {
7172
- throw new FuelError19(
7173
- ErrorCode16.MISSING_CONNECTOR,
7237
+ throw new FuelError20(
7238
+ ErrorCode17.MISSING_CONNECTOR,
7174
7239
  "A connector is required to sign transactions."
7175
7240
  );
7176
7241
  }
@@ -7229,16 +7294,16 @@ var Account = class extends AbstractAccount {
7229
7294
  /** @hidden * */
7230
7295
  validateTransferAmount(amount) {
7231
7296
  if (bn19(amount).lte(0)) {
7232
- throw new FuelError19(
7233
- ErrorCode16.INVALID_TRANSFER_AMOUNT,
7297
+ throw new FuelError20(
7298
+ ErrorCode17.INVALID_TRANSFER_AMOUNT,
7234
7299
  "Transfer amount must be a positive number."
7235
7300
  );
7236
7301
  }
7237
7302
  }
7238
7303
  /** @hidden * */
7239
- async estimateAndFundTransaction(transactionRequest, txParams) {
7304
+ async estimateAndFundTransaction(transactionRequest, txParams, costParams) {
7240
7305
  let request = transactionRequest;
7241
- const txCost = await this.getTransactionCost(request);
7306
+ const txCost = await this.getTransactionCost(request, costParams);
7242
7307
  request = this.validateGasLimitAndMaxFee({
7243
7308
  transactionRequest: request,
7244
7309
  gasUsed: txCost.gasUsed,
@@ -7259,16 +7324,16 @@ var Account = class extends AbstractAccount {
7259
7324
  if (!isDefined3(setGasLimit)) {
7260
7325
  request.gasLimit = gasUsed;
7261
7326
  } else if (gasUsed.gt(setGasLimit)) {
7262
- throw new FuelError19(
7263
- ErrorCode16.GAS_LIMIT_TOO_LOW,
7327
+ throw new FuelError20(
7328
+ ErrorCode17.GAS_LIMIT_TOO_LOW,
7264
7329
  `Gas limit '${setGasLimit}' is lower than the required: '${gasUsed}'.`
7265
7330
  );
7266
7331
  }
7267
7332
  if (!isDefined3(setMaxFee)) {
7268
7333
  request.maxFee = maxFee;
7269
7334
  } else if (maxFee.gt(setMaxFee)) {
7270
- throw new FuelError19(
7271
- ErrorCode16.MAX_FEE_TOO_LOW,
7335
+ throw new FuelError20(
7336
+ ErrorCode17.MAX_FEE_TOO_LOW,
7272
7337
  `Max fee '${setMaxFee}' is lower than the required: '${maxFee}'.`
7273
7338
  );
7274
7339
  }
@@ -7277,7 +7342,7 @@ var Account = class extends AbstractAccount {
7277
7342
  };
7278
7343
 
7279
7344
  // src/wallet/keystore-wallet.ts
7280
- import { Address as Address5 } from "@fuel-ts/address";
7345
+ import { Address as Address6 } from "@fuel-ts/address";
7281
7346
  import {
7282
7347
  bufferFromString,
7283
7348
  keccak256,
@@ -7288,7 +7353,7 @@ import {
7288
7353
  encryptJsonWalletData,
7289
7354
  randomUUID as randomUUID2
7290
7355
  } from "@fuel-ts/crypto";
7291
- import { ErrorCode as ErrorCode17, FuelError as FuelError20 } from "@fuel-ts/errors";
7356
+ import { ErrorCode as ErrorCode18, FuelError as FuelError21 } from "@fuel-ts/errors";
7292
7357
  import { hexlify as hexlify20 } from "@fuel-ts/utils";
7293
7358
  var DEFAULT_KDF_PARAMS_LOG_N = 13;
7294
7359
  var DEFAULT_KDF_PARAMS_R = 8;
@@ -7303,7 +7368,7 @@ var removeHexPrefix = (hexString) => {
7303
7368
  };
7304
7369
  async function encryptKeystoreWallet(privateKey, address, password) {
7305
7370
  const privateKeyBuffer = bufferFromString(removeHexPrefix(privateKey), "hex");
7306
- const ownerAddress = Address5.fromAddressOrString(address);
7371
+ const ownerAddress = Address6.fromAddressOrString(address);
7307
7372
  const salt = randomBytes6(DEFAULT_KEY_SIZE);
7308
7373
  const key = scrypt({
7309
7374
  password: bufferFromString(password),
@@ -7365,8 +7430,8 @@ async function decryptKeystoreWallet(jsonWallet, password) {
7365
7430
  const macHashUint8Array = keccak256(data);
7366
7431
  const macHash = stringFromBuffer(macHashUint8Array, "hex");
7367
7432
  if (mac !== macHash) {
7368
- throw new FuelError20(
7369
- ErrorCode17.INVALID_PASSWORD,
7433
+ throw new FuelError21(
7434
+ ErrorCode18.INVALID_PASSWORD,
7370
7435
  "Failed to decrypt the keystore wallet, the provided password is incorrect."
7371
7436
  );
7372
7437
  }
@@ -7496,16 +7561,16 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
7496
7561
 
7497
7562
  // src/hdwallet/hdwallet.ts
7498
7563
  import { computeHmac as computeHmac2, ripemd160 } from "@fuel-ts/crypto";
7499
- import { ErrorCode as ErrorCode20, FuelError as FuelError23 } from "@fuel-ts/errors";
7564
+ import { ErrorCode as ErrorCode21, FuelError as FuelError24 } from "@fuel-ts/errors";
7500
7565
  import { sha256 as sha2564 } from "@fuel-ts/hasher";
7501
7566
  import { bn as bn20, toBytes as toBytes2, toHex } from "@fuel-ts/math";
7502
- import { arrayify as arrayify19, hexlify as hexlify23, concat as concat5, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58 } from "@fuel-ts/utils";
7567
+ import { arrayify as arrayify19, hexlify as hexlify23, concat as concat6, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58 } from "@fuel-ts/utils";
7503
7568
 
7504
7569
  // src/mnemonic/mnemonic.ts
7505
7570
  import { randomBytes as randomBytes7, pbkdf2, computeHmac } from "@fuel-ts/crypto";
7506
- import { ErrorCode as ErrorCode19, FuelError as FuelError22 } from "@fuel-ts/errors";
7571
+ import { ErrorCode as ErrorCode20, FuelError as FuelError23 } from "@fuel-ts/errors";
7507
7572
  import { sha256 as sha2563 } from "@fuel-ts/hasher";
7508
- import { arrayify as arrayify18, hexlify as hexlify22, concat as concat4, dataSlice, encodeBase58, toUtf8Bytes } from "@fuel-ts/utils";
7573
+ import { arrayify as arrayify18, hexlify as hexlify22, concat as concat5, dataSlice, encodeBase58, toUtf8Bytes } from "@fuel-ts/utils";
7509
7574
 
7510
7575
  // src/wordlists/words/english.ts
7511
7576
  var english = [
@@ -9560,7 +9625,7 @@ var english = [
9560
9625
  ];
9561
9626
 
9562
9627
  // src/mnemonic/utils.ts
9563
- import { ErrorCode as ErrorCode18, FuelError as FuelError21 } from "@fuel-ts/errors";
9628
+ import { ErrorCode as ErrorCode19, FuelError as FuelError22 } from "@fuel-ts/errors";
9564
9629
  import { sha256 as sha2562 } from "@fuel-ts/hasher";
9565
9630
  import { arrayify as arrayify17 } from "@fuel-ts/utils";
9566
9631
  function getLowerMask(bits) {
@@ -9609,8 +9674,8 @@ function mnemonicWordsToEntropy(words, wordlist) {
9609
9674
  for (let i = 0; i < words.length; i += 1) {
9610
9675
  const index = wordlist.indexOf(words[i].normalize("NFKD"));
9611
9676
  if (index === -1) {
9612
- throw new FuelError21(
9613
- ErrorCode18.INVALID_MNEMONIC,
9677
+ throw new FuelError22(
9678
+ ErrorCode19.INVALID_MNEMONIC,
9614
9679
  `Invalid mnemonic: the word '${words[i]}' is not found in the provided wordlist.`
9615
9680
  );
9616
9681
  }
@@ -9626,8 +9691,8 @@ function mnemonicWordsToEntropy(words, wordlist) {
9626
9691
  const checksumMask = getUpperMask(checksumBits);
9627
9692
  const checksum = arrayify17(sha2562(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
9628
9693
  if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
9629
- throw new FuelError21(
9630
- ErrorCode18.INVALID_CHECKSUM,
9694
+ throw new FuelError22(
9695
+ ErrorCode19.INVALID_CHECKSUM,
9631
9696
  "Checksum validation failed for the provided mnemonic."
9632
9697
  );
9633
9698
  }
@@ -9641,16 +9706,16 @@ var TestnetPRV = "0x04358394";
9641
9706
  var MNEMONIC_SIZES = [12, 15, 18, 21, 24];
9642
9707
  function assertWordList(wordlist) {
9643
9708
  if (wordlist.length !== 2048) {
9644
- throw new FuelError22(
9645
- ErrorCode19.INVALID_WORD_LIST,
9709
+ throw new FuelError23(
9710
+ ErrorCode20.INVALID_WORD_LIST,
9646
9711
  `Expected word list length of 2048, but got ${wordlist.length}.`
9647
9712
  );
9648
9713
  }
9649
9714
  }
9650
9715
  function assertEntropy(entropy) {
9651
9716
  if (entropy.length % 4 !== 0 || entropy.length < 16 || entropy.length > 32) {
9652
- throw new FuelError22(
9653
- ErrorCode19.INVALID_ENTROPY,
9717
+ throw new FuelError23(
9718
+ ErrorCode20.INVALID_ENTROPY,
9654
9719
  `Entropy should be between 16 and 32 bytes and a multiple of 4, but got ${entropy.length} bytes.`
9655
9720
  );
9656
9721
  }
@@ -9660,7 +9725,7 @@ function assertMnemonic(words) {
9660
9725
  const errorMsg = `Invalid mnemonic size. Expected one of [${MNEMONIC_SIZES.join(
9661
9726
  ", "
9662
9727
  )}] words, but got ${words.length}.`;
9663
- throw new FuelError22(ErrorCode19.INVALID_MNEMONIC, errorMsg);
9728
+ throw new FuelError23(ErrorCode20.INVALID_MNEMONIC, errorMsg);
9664
9729
  }
9665
9730
  }
9666
9731
  var Mnemonic = class {
@@ -9778,8 +9843,8 @@ var Mnemonic = class {
9778
9843
  static masterKeysFromSeed(seed) {
9779
9844
  const seedArray = arrayify18(seed);
9780
9845
  if (seedArray.length < 16 || seedArray.length > 64) {
9781
- throw new FuelError22(
9782
- ErrorCode19.INVALID_SEED,
9846
+ throw new FuelError23(
9847
+ ErrorCode20.INVALID_SEED,
9783
9848
  `Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
9784
9849
  );
9785
9850
  }
@@ -9800,16 +9865,16 @@ var Mnemonic = class {
9800
9865
  const index = "0x00000000";
9801
9866
  const chainCode = masterKey.slice(32);
9802
9867
  const privateKey = masterKey.slice(0, 32);
9803
- const extendedKey = concat4([
9868
+ const extendedKey = concat5([
9804
9869
  prefix,
9805
9870
  depth,
9806
9871
  fingerprint,
9807
9872
  index,
9808
9873
  chainCode,
9809
- concat4(["0x00", privateKey])
9874
+ concat5(["0x00", privateKey])
9810
9875
  ]);
9811
9876
  const checksum = dataSlice(sha2563(sha2563(extendedKey)), 0, 4);
9812
- return encodeBase58(concat4([extendedKey, checksum]));
9877
+ return encodeBase58(concat5([extendedKey, checksum]));
9813
9878
  }
9814
9879
  /**
9815
9880
  * Create a new mnemonic using a randomly generated number as entropy.
@@ -9824,7 +9889,7 @@ var Mnemonic = class {
9824
9889
  * @returns A randomly generated mnemonic
9825
9890
  */
9826
9891
  static generate(size = 32, extraEntropy = "") {
9827
- const entropy = extraEntropy ? sha2563(concat4([randomBytes7(size), arrayify18(extraEntropy)])) : randomBytes7(size);
9892
+ const entropy = extraEntropy ? sha2563(concat5([randomBytes7(size), arrayify18(extraEntropy)])) : randomBytes7(size);
9828
9893
  return Mnemonic.entropyToMnemonic(entropy);
9829
9894
  }
9830
9895
  };
@@ -9837,7 +9902,7 @@ var MainnetPUB = hexlify23("0x0488b21e");
9837
9902
  var TestnetPRV2 = hexlify23("0x04358394");
9838
9903
  var TestnetPUB = hexlify23("0x043587cf");
9839
9904
  function base58check(data) {
9840
- return encodeBase582(concat5([data, dataSlice2(sha2564(sha2564(data)), 0, 4)]));
9905
+ return encodeBase582(concat6([data, dataSlice2(sha2564(sha2564(data)), 0, 4)]));
9841
9906
  }
9842
9907
  function getExtendedKeyPrefix(isPublic = false, testnet = false) {
9843
9908
  if (isPublic) {
@@ -9856,7 +9921,7 @@ function isValidExtendedKey(extendedKey) {
9856
9921
  function parsePath(path2, depth = 0) {
9857
9922
  const components = path2.split("/");
9858
9923
  if (components.length === 0 || components[0] === "m" && depth !== 0) {
9859
- throw new FuelError23(ErrorCode20.HD_WALLET_ERROR, `invalid path - ${path2}`);
9924
+ throw new FuelError24(ErrorCode21.HD_WALLET_ERROR, `invalid path - ${path2}`);
9860
9925
  }
9861
9926
  if (components[0] === "m") {
9862
9927
  components.shift();
@@ -9885,8 +9950,8 @@ var HDWallet = class {
9885
9950
  this.privateKey = hexlify23(config.privateKey);
9886
9951
  } else {
9887
9952
  if (!config.publicKey) {
9888
- throw new FuelError23(
9889
- ErrorCode20.HD_WALLET_ERROR,
9953
+ throw new FuelError24(
9954
+ ErrorCode21.HD_WALLET_ERROR,
9890
9955
  "Both public and private Key cannot be missing. At least one should be provided."
9891
9956
  );
9892
9957
  }
@@ -9915,8 +9980,8 @@ var HDWallet = class {
9915
9980
  const data = new Uint8Array(37);
9916
9981
  if (index & HARDENED_INDEX) {
9917
9982
  if (!privateKey) {
9918
- throw new FuelError23(
9919
- ErrorCode20.HD_WALLET_ERROR,
9983
+ throw new FuelError24(
9984
+ ErrorCode21.HD_WALLET_ERROR,
9920
9985
  "Cannot derive a hardened index without a private Key."
9921
9986
  );
9922
9987
  }
@@ -9968,8 +10033,8 @@ var HDWallet = class {
9968
10033
  */
9969
10034
  toExtendedKey(isPublic = false, testnet = false) {
9970
10035
  if (this.depth >= 256) {
9971
- throw new FuelError23(
9972
- ErrorCode20.HD_WALLET_ERROR,
10036
+ throw new FuelError24(
10037
+ ErrorCode21.HD_WALLET_ERROR,
9973
10038
  `Exceeded max depth of 255. Current depth: ${this.depth}.`
9974
10039
  );
9975
10040
  }
@@ -9978,8 +10043,8 @@ var HDWallet = class {
9978
10043
  const parentFingerprint = this.parentFingerprint;
9979
10044
  const index = toHex(this.index, 4);
9980
10045
  const chainCode = this.chainCode;
9981
- const key = this.privateKey != null && !isPublic ? concat5(["0x00", this.privateKey]) : this.publicKey;
9982
- const extendedKey = arrayify19(concat5([prefix, depth, parentFingerprint, index, chainCode, key]));
10046
+ const key = this.privateKey != null && !isPublic ? concat6(["0x00", this.privateKey]) : this.publicKey;
10047
+ const extendedKey = arrayify19(concat6([prefix, depth, parentFingerprint, index, chainCode, key]));
9983
10048
  return base58check(extendedKey);
9984
10049
  }
9985
10050
  /**
@@ -10000,10 +10065,10 @@ var HDWallet = class {
10000
10065
  const bytes = arrayify19(decoded);
10001
10066
  const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
10002
10067
  if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
10003
- throw new FuelError23(ErrorCode20.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
10068
+ throw new FuelError24(ErrorCode21.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
10004
10069
  }
10005
10070
  if (!validChecksum) {
10006
- throw new FuelError23(ErrorCode20.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
10071
+ throw new FuelError24(ErrorCode21.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
10007
10072
  }
10008
10073
  const depth = bytes[4];
10009
10074
  const parentFingerprint = hexlify23(bytes.slice(5, 9));
@@ -10011,14 +10076,14 @@ var HDWallet = class {
10011
10076
  const chainCode = hexlify23(bytes.slice(13, 45));
10012
10077
  const key = bytes.slice(45, 78);
10013
10078
  if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
10014
- throw new FuelError23(
10015
- ErrorCode20.HD_WALLET_ERROR,
10079
+ throw new FuelError24(
10080
+ ErrorCode21.HD_WALLET_ERROR,
10016
10081
  "Inconsistency detected: Depth is zero but fingerprint/index is non-zero."
10017
10082
  );
10018
10083
  }
10019
10084
  if (isPublicExtendedKey(bytes)) {
10020
10085
  if (key[0] !== 3) {
10021
- throw new FuelError23(ErrorCode20.HD_WALLET_ERROR, "Invalid public extended key.");
10086
+ throw new FuelError24(ErrorCode21.HD_WALLET_ERROR, "Invalid public extended key.");
10022
10087
  }
10023
10088
  return new HDWallet({
10024
10089
  publicKey: key,
@@ -10029,7 +10094,7 @@ var HDWallet = class {
10029
10094
  });
10030
10095
  }
10031
10096
  if (key[0] !== 0) {
10032
- throw new FuelError23(ErrorCode20.HD_WALLET_ERROR, "Invalid private extended key.");
10097
+ throw new FuelError24(ErrorCode21.HD_WALLET_ERROR, "Invalid private extended key.");
10033
10098
  }
10034
10099
  return new HDWallet({
10035
10100
  privateKey: key.slice(1),
@@ -10273,26 +10338,26 @@ var WalletsConfig = class {
10273
10338
  amountPerCoin
10274
10339
  }) {
10275
10340
  if (Array.isArray(wallets) && wallets.length === 0 || typeof wallets === "number" && wallets <= 0) {
10276
- throw new FuelError24(
10277
- FuelError24.CODES.INVALID_INPUT_PARAMETERS,
10341
+ throw new FuelError25(
10342
+ FuelError25.CODES.INVALID_INPUT_PARAMETERS,
10278
10343
  "Number of wallets must be greater than zero."
10279
10344
  );
10280
10345
  }
10281
10346
  if (Array.isArray(assets2) && assets2.length === 0 || typeof assets2 === "number" && assets2 <= 0) {
10282
- throw new FuelError24(
10283
- FuelError24.CODES.INVALID_INPUT_PARAMETERS,
10347
+ throw new FuelError25(
10348
+ FuelError25.CODES.INVALID_INPUT_PARAMETERS,
10284
10349
  "Number of assets per wallet must be greater than zero."
10285
10350
  );
10286
10351
  }
10287
10352
  if (coinsPerAsset <= 0) {
10288
- throw new FuelError24(
10289
- FuelError24.CODES.INVALID_INPUT_PARAMETERS,
10353
+ throw new FuelError25(
10354
+ FuelError25.CODES.INVALID_INPUT_PARAMETERS,
10290
10355
  "Number of coins per asset must be greater than zero."
10291
10356
  );
10292
10357
  }
10293
10358
  if (amountPerCoin < 0) {
10294
- throw new FuelError24(
10295
- FuelError24.CODES.INVALID_INPUT_PARAMETERS,
10359
+ throw new FuelError25(
10360
+ FuelError25.CODES.INVALID_INPUT_PARAMETERS,
10296
10361
  "Amount per coin must be greater than or equal to zero."
10297
10362
  );
10298
10363
  }
@@ -10363,7 +10428,7 @@ async function setupTestProviderAndWallets({
10363
10428
  }
10364
10429
 
10365
10430
  // src/test-utils/test-message.ts
10366
- import { Address as Address6 } from "@fuel-ts/address";
10431
+ import { Address as Address7 } from "@fuel-ts/address";
10367
10432
  import { randomBytes as randomBytes9 } from "@fuel-ts/crypto";
10368
10433
  import { bn as bn21 } from "@fuel-ts/math";
10369
10434
  import { hexlify as hexlify25 } from "@fuel-ts/utils";
@@ -10381,8 +10446,8 @@ var TestMessage = class {
10381
10446
  * It can also be used standalone and passed into the initial state of a chain via the `.toChainMessage` method.
10382
10447
  */
10383
10448
  constructor({
10384
- sender = Address6.fromRandom(),
10385
- recipient = Address6.fromRandom(),
10449
+ sender = Address7.fromRandom(),
10450
+ recipient = Address7.fromRandom(),
10386
10451
  nonce = hexlify25(randomBytes9(32)),
10387
10452
  amount = 1e6,
10388
10453
  data = "",