@fuel-ts/account 0.96.1 → 0.97.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/dist/account.d.ts +6 -0
  2. package/dist/account.d.ts.map +1 -1
  3. package/dist/connectors/fuel-connector.d.ts.map +1 -1
  4. package/dist/index.d.ts +1 -0
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.global.js +1401 -14796
  7. package/dist/index.global.js.map +1 -1
  8. package/dist/index.js +621 -345
  9. package/dist/index.js.map +1 -1
  10. package/dist/index.mjs +608 -333
  11. package/dist/index.mjs.map +1 -1
  12. package/dist/predicate/predicate.d.ts +16 -11
  13. package/dist/predicate/predicate.d.ts.map +1 -1
  14. package/dist/providers/__generated__/operations.d.ts +94 -126
  15. package/dist/providers/__generated__/operations.d.ts.map +1 -1
  16. package/dist/providers/provider.d.ts +5 -8
  17. package/dist/providers/provider.d.ts.map +1 -1
  18. package/dist/providers/transaction-request/blob-transaction-request.d.ts +2 -2
  19. package/dist/providers/transaction-request/blob-transaction-request.d.ts.map +1 -1
  20. package/dist/providers/transaction-request/create-transaction-request.d.ts.map +1 -1
  21. package/dist/providers/transaction-request/errors.d.ts.map +1 -1
  22. package/dist/providers/transaction-request/script-transaction-request.d.ts.map +1 -1
  23. package/dist/providers/transaction-request/upgrade-transaction-request.d.ts.map +1 -1
  24. package/dist/providers/transaction-request/upload-transaction-request.d.ts.map +1 -1
  25. package/dist/providers/transaction-summary/get-transaction-summary.d.ts +9 -3
  26. package/dist/providers/transaction-summary/get-transaction-summary.d.ts.map +1 -1
  27. package/dist/providers/transaction-summary/operations.d.ts +21 -3
  28. package/dist/providers/transaction-summary/operations.d.ts.map +1 -1
  29. package/dist/providers/transaction-summary/types.d.ts +38 -8
  30. package/dist/providers/transaction-summary/types.d.ts.map +1 -1
  31. package/dist/providers/utils/handle-gql-error-message.d.ts +2 -1
  32. package/dist/providers/utils/handle-gql-error-message.d.ts.map +1 -1
  33. package/dist/providers/utils/receipts.d.ts.map +1 -1
  34. package/dist/providers/utils/validate-pagination-args.d.ts +9 -0
  35. package/dist/providers/utils/validate-pagination-args.d.ts.map +1 -0
  36. package/dist/test-utils/launchNode.d.ts.map +1 -1
  37. package/dist/test-utils.global.js +963 -14555
  38. package/dist/test-utils.global.js.map +1 -1
  39. package/dist/test-utils.js +304 -234
  40. package/dist/test-utils.js.map +1 -1
  41. package/dist/test-utils.mjs +298 -228
  42. package/dist/test-utils.mjs.map +1 -1
  43. package/dist/utils/deployScriptOrPredicate.d.ts +14 -0
  44. package/dist/utils/deployScriptOrPredicate.d.ts.map +1 -0
  45. package/dist/utils/formatTransferToContractScriptData.d.ts +7 -7
  46. package/dist/utils/formatTransferToContractScriptData.d.ts.map +1 -1
  47. package/dist/utils/predicate-script-loader-instructions.d.ts +9 -0
  48. package/dist/utils/predicate-script-loader-instructions.d.ts.map +1 -0
  49. package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
  50. package/package.json +19 -19
@@ -291,6 +291,8 @@ var launchNode = async ({
291
291
  console.log(
292
292
  `fuel-core node under pid ${child.pid} does not exist. The node might have been killed before cleanup was called. Exiting cleanly.`
293
293
  );
294
+ } else if (error.message.includes("pid must be a positive integer")) {
295
+ process.kill(+child.pid);
294
296
  } else {
295
297
  throw e;
296
298
  }
@@ -319,6 +321,7 @@ var launchNode = async ({
319
321
  reject(new FuelError(FuelError.CODES.NODE_LAUNCH_FAILED, text));
320
322
  }
321
323
  });
324
+ process.setMaxListeners(100);
322
325
  process.on("exit", cleanup);
323
326
  process.on("SIGINT", cleanup);
324
327
  process.on("SIGUSR1", cleanup);
@@ -370,7 +373,7 @@ var addAmountToCoinQuantities = (params) => {
370
373
 
371
374
  // src/providers/provider.ts
372
375
  import { Address as Address3 } from "@fuel-ts/address";
373
- import { ErrorCode as ErrorCode14, FuelError as FuelError17 } from "@fuel-ts/errors";
376
+ import { ErrorCode as ErrorCode15, FuelError as FuelError18 } from "@fuel-ts/errors";
374
377
  import { BN as BN2, bn as bn17 } from "@fuel-ts/math";
375
378
  import { InputType as InputType7, InputMessageCoder as InputMessageCoder2, TransactionCoder as TransactionCoder5 } from "@fuel-ts/transactions";
376
379
  import { arrayify as arrayify13, hexlify as hexlify17, DateTime as DateTime2, isDefined as isDefined2 } from "@fuel-ts/utils";
@@ -423,9 +426,6 @@ var ReceiptFragmentDoc = gql`
423
426
  var SuccessStatusFragmentDoc = gql`
424
427
  fragment SuccessStatusFragment on SuccessStatus {
425
428
  type: __typename
426
- block {
427
- id
428
- }
429
429
  time
430
430
  programState {
431
431
  returnType
@@ -438,6 +438,14 @@ var SuccessStatusFragmentDoc = gql`
438
438
  totalFee
439
439
  }
440
440
  ${ReceiptFragmentDoc}`;
441
+ var SuccessStatusWithBlockIdFragmentDoc = gql`
442
+ fragment SuccessStatusWithBlockIdFragment on SuccessStatus {
443
+ ...SuccessStatusFragment
444
+ block {
445
+ id
446
+ }
447
+ }
448
+ ${SuccessStatusFragmentDoc}`;
441
449
  var MalleableTransactionFieldsFragmentDoc = gql`
442
450
  fragment malleableTransactionFieldsFragment on Transaction {
443
451
  receiptsRoot
@@ -482,9 +490,6 @@ var MalleableTransactionFieldsFragmentDoc = gql`
482
490
  var FailureStatusFragmentDoc = gql`
483
491
  fragment FailureStatusFragment on FailureStatus {
484
492
  type: __typename
485
- block {
486
- id
487
- }
488
493
  totalGas
489
494
  totalFee
490
495
  time
@@ -494,6 +499,14 @@ var FailureStatusFragmentDoc = gql`
494
499
  }
495
500
  }
496
501
  ${ReceiptFragmentDoc}`;
502
+ var FailureStatusWithBlockIdFragmentDoc = gql`
503
+ fragment FailureStatusWithBlockIdFragment on FailureStatus {
504
+ ...FailureStatusFragment
505
+ block {
506
+ id
507
+ }
508
+ }
509
+ ${FailureStatusFragmentDoc}`;
497
510
  var SqueezedOutStatusFragmentDoc = gql`
498
511
  fragment SqueezedOutStatusFragment on SqueezedOutStatus {
499
512
  type: __typename
@@ -506,13 +519,13 @@ var TransactionStatusSubscriptionFragmentDoc = gql`
506
519
  ...SubmittedStatusFragment
507
520
  }
508
521
  ... on SuccessStatus {
509
- ...SuccessStatusFragment
522
+ ...SuccessStatusWithBlockIdFragment
510
523
  transaction {
511
524
  ...malleableTransactionFieldsFragment
512
525
  }
513
526
  }
514
527
  ... on FailureStatus {
515
- ...FailureStatusFragment
528
+ ...FailureStatusWithBlockIdFragment
516
529
  transaction {
517
530
  ...malleableTransactionFieldsFragment
518
531
  }
@@ -522,9 +535,9 @@ var TransactionStatusSubscriptionFragmentDoc = gql`
522
535
  }
523
536
  }
524
537
  ${SubmittedStatusFragmentDoc}
525
- ${SuccessStatusFragmentDoc}
538
+ ${SuccessStatusWithBlockIdFragmentDoc}
526
539
  ${MalleableTransactionFieldsFragmentDoc}
527
- ${FailureStatusFragmentDoc}
540
+ ${FailureStatusWithBlockIdFragmentDoc}
528
541
  ${SqueezedOutStatusFragmentDoc}`;
529
542
  var TransactionStatusFragmentDoc = gql`
530
543
  fragment transactionStatusFragment on TransactionStatus {
@@ -554,6 +567,12 @@ var TransactionFragmentDoc = gql`
554
567
  }
555
568
  }
556
569
  ${TransactionStatusFragmentDoc}`;
570
+ var TransactionRawPayloadFragmentDoc = gql`
571
+ fragment transactionRawPayloadFragment on Transaction {
572
+ id
573
+ rawPayload
574
+ }
575
+ `;
557
576
  var InputEstimatePredicatesFragmentDoc = gql`
558
577
  fragment inputEstimatePredicatesFragment on Input {
559
578
  ... on InputCoin {
@@ -641,7 +660,6 @@ var CoinFragmentDoc = gql`
641
660
  fragment coinFragment on Coin {
642
661
  type: __typename
643
662
  utxoId
644
- owner
645
663
  amount
646
664
  assetId
647
665
  blockCreated
@@ -665,10 +683,15 @@ var MessageFragmentDoc = gql`
665
683
  sender
666
684
  recipient
667
685
  data
668
- nonce
669
686
  daHeight
670
687
  }
671
688
  `;
689
+ var GetMessageFragmentDoc = gql`
690
+ fragment getMessageFragment on Message {
691
+ ...messageFragment
692
+ nonce
693
+ }
694
+ ${MessageFragmentDoc}`;
672
695
  var MessageProofFragmentDoc = gql`
673
696
  fragment messageProofFragment on MessageProof {
674
697
  messageProof {
@@ -713,7 +736,6 @@ var MessageProofFragmentDoc = gql`
713
736
  }
714
737
  sender
715
738
  recipient
716
- nonce
717
739
  amount
718
740
  data
719
741
  }
@@ -862,12 +884,6 @@ var RelayedTransactionStatusFragmentDoc = gql`
862
884
  }
863
885
  }
864
886
  `;
865
- var TransactionRawPayloadFragmentDoc = gql`
866
- fragment transactionRawPayload on Transaction {
867
- id
868
- rawPayload
869
- }
870
- `;
871
887
  var GetVersionDocument = gql`
872
888
  query getVersion {
873
889
  nodeInfo {
@@ -910,16 +926,34 @@ var GetTransactionDocument = gql`
910
926
  var GetTransactionWithReceiptsDocument = gql`
911
927
  query getTransactionWithReceipts($transactionId: TransactionId!) {
912
928
  transaction(id: $transactionId) {
913
- ...transactionFragment
929
+ id
930
+ rawPayload
931
+ status {
932
+ ... on SubmittedStatus {
933
+ ...SubmittedStatusFragment
934
+ }
935
+ ... on SuccessStatus {
936
+ ...SuccessStatusWithBlockIdFragment
937
+ }
938
+ ... on FailureStatus {
939
+ ...FailureStatusWithBlockIdFragment
940
+ }
941
+ ... on SqueezedOutStatus {
942
+ ...SqueezedOutStatusFragment
943
+ }
944
+ }
914
945
  }
915
946
  }
916
- ${TransactionFragmentDoc}`;
947
+ ${SubmittedStatusFragmentDoc}
948
+ ${SuccessStatusWithBlockIdFragmentDoc}
949
+ ${FailureStatusWithBlockIdFragmentDoc}
950
+ ${SqueezedOutStatusFragmentDoc}`;
917
951
  var GetTransactionsDocument = gql`
918
952
  query getTransactions($after: String, $before: String, $first: Int, $last: Int) {
919
953
  transactions(after: $after, before: $before, first: $first, last: $last) {
920
954
  edges {
921
955
  node {
922
- ...transactionFragment
956
+ rawPayload
923
957
  }
924
958
  }
925
959
  pageInfo {
@@ -927,8 +961,7 @@ var GetTransactionsDocument = gql`
927
961
  }
928
962
  }
929
963
  }
930
- ${TransactionFragmentDoc}
931
- ${PageInfoFragmentDoc}`;
964
+ ${PageInfoFragmentDoc}`;
932
965
  var GetTransactionsByOwnerDocument = gql`
933
966
  query getTransactionsByOwner($owner: Address!, $after: String, $before: String, $first: Int, $last: Int) {
934
967
  transactionsByOwner(
@@ -987,7 +1020,7 @@ var GetBlockWithTransactionsDocument = gql`
987
1020
  block(id: $blockId, height: $blockHeight) {
988
1021
  ...blockFragment
989
1022
  transactions {
990
- ...transactionRawPayload
1023
+ ...transactionRawPayloadFragment
991
1024
  }
992
1025
  }
993
1026
  }
@@ -1012,6 +1045,7 @@ var GetCoinDocument = gql`
1012
1045
  query getCoin($coinId: UtxoId!) {
1013
1046
  coin(utxoId: $coinId) {
1014
1047
  ...coinFragment
1048
+ owner
1015
1049
  }
1016
1050
  }
1017
1051
  ${CoinFragmentDoc}`;
@@ -1120,13 +1154,13 @@ var GetMessagesDocument = gql`
1120
1154
  }
1121
1155
  edges {
1122
1156
  node {
1123
- ...messageFragment
1157
+ ...getMessageFragment
1124
1158
  }
1125
1159
  }
1126
1160
  }
1127
1161
  }
1128
1162
  ${PageInfoFragmentDoc}
1129
- ${MessageFragmentDoc}`;
1163
+ ${GetMessageFragmentDoc}`;
1130
1164
  var GetMessageProofDocument = gql`
1131
1165
  query getMessageProof($transactionId: TransactionId!, $nonce: Nonce!, $commitBlockId: BlockId, $commitBlockHeight: U32) {
1132
1166
  messageProof(
@@ -1664,9 +1698,11 @@ function assembleReceiptByType(receipt) {
1664
1698
  const { receiptType } = receipt;
1665
1699
  switch (receiptType) {
1666
1700
  case "CALL" /* Call */: {
1701
+ const id = hexOrZero(receipt.id || receipt.contractId);
1667
1702
  const callReceipt = {
1668
1703
  type: ReceiptType.Call,
1669
- from: hexOrZero(receipt.id || receipt.contractId),
1704
+ id,
1705
+ from: id,
1670
1706
  to: hexOrZero(receipt?.to),
1671
1707
  amount: bn4(receipt.amount),
1672
1708
  assetId: hexOrZero(receipt.assetId),
@@ -1723,24 +1759,36 @@ function assembleReceiptByType(receipt) {
1723
1759
  return revertReceipt;
1724
1760
  }
1725
1761
  case "LOG" /* Log */: {
1762
+ const ra = bn4(receipt.ra);
1763
+ const rb = bn4(receipt.rb);
1764
+ const rc = bn4(receipt.rc);
1765
+ const rd = bn4(receipt.rd);
1726
1766
  const logReceipt = {
1727
1767
  type: ReceiptType.Log,
1728
1768
  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),
1769
+ ra,
1770
+ rb,
1771
+ rc,
1772
+ rd,
1773
+ val0: ra,
1774
+ val1: rb,
1775
+ val2: rc,
1776
+ val3: rd,
1733
1777
  pc: bn4(receipt.pc),
1734
1778
  is: bn4(receipt.is)
1735
1779
  };
1736
1780
  return logReceipt;
1737
1781
  }
1738
1782
  case "LOG_DATA" /* LogData */: {
1783
+ const ra = bn4(receipt.ra);
1784
+ const rb = bn4(receipt.rb);
1739
1785
  const logDataReceipt = {
1740
1786
  type: ReceiptType.LogData,
1741
1787
  id: hexOrZero(receipt.id || receipt.contractId),
1742
- val0: bn4(receipt.ra),
1743
- val1: bn4(receipt.rb),
1788
+ ra,
1789
+ rb,
1790
+ val0: ra,
1791
+ val1: rb,
1744
1792
  ptr: bn4(receipt.ptr),
1745
1793
  len: bn4(receipt.len),
1746
1794
  digest: hexOrZero(receipt.digest),
@@ -1751,9 +1799,11 @@ function assembleReceiptByType(receipt) {
1751
1799
  return logDataReceipt;
1752
1800
  }
1753
1801
  case "TRANSFER" /* Transfer */: {
1802
+ const id = hexOrZero(receipt.id || receipt.contractId);
1754
1803
  const transferReceipt = {
1755
1804
  type: ReceiptType.Transfer,
1756
- from: hexOrZero(receipt.id || receipt.contractId),
1805
+ id,
1806
+ from: id,
1757
1807
  to: hexOrZero(receipt.toAddress || receipt?.to),
1758
1808
  amount: bn4(receipt.amount),
1759
1809
  assetId: hexOrZero(receipt.assetId),
@@ -1763,9 +1813,11 @@ function assembleReceiptByType(receipt) {
1763
1813
  return transferReceipt;
1764
1814
  }
1765
1815
  case "TRANSFER_OUT" /* TransferOut */: {
1816
+ const id = hexOrZero(receipt.id || receipt.contractId);
1766
1817
  const transferOutReceipt = {
1767
1818
  type: ReceiptType.TransferOut,
1768
- from: hexOrZero(receipt.id || receipt.contractId),
1819
+ id,
1820
+ from: id,
1769
1821
  to: hexOrZero(receipt.toAddress || receipt.to),
1770
1822
  amount: bn4(receipt.amount),
1771
1823
  assetId: hexOrZero(receipt.assetId),
@@ -2750,7 +2802,7 @@ var BlobTransactionRequest = class extends BaseTransactionRequest {
2750
2802
  type = TransactionType.Blob;
2751
2803
  /** Blob ID */
2752
2804
  blobId;
2753
- /** Witness index of contract bytecode to create */
2805
+ /** Witness index of the bytecode to create */
2754
2806
  witnessIndex;
2755
2807
  /**
2756
2808
  * Creates an instance `BlobTransactionRequest`.
@@ -4084,14 +4136,14 @@ var processGraphqlStatus = (gqlTransactionStatus) => {
4084
4136
  switch (gqlTransactionStatus.type) {
4085
4137
  case "SuccessStatus":
4086
4138
  time = gqlTransactionStatus.time;
4087
- blockId = gqlTransactionStatus.block.id;
4139
+ blockId = gqlTransactionStatus.block?.id;
4088
4140
  isStatusSuccess = true;
4089
4141
  totalFee = bn14(gqlTransactionStatus.totalFee);
4090
4142
  totalGas = bn14(gqlTransactionStatus.totalGas);
4091
4143
  break;
4092
4144
  case "FailureStatus":
4093
4145
  time = gqlTransactionStatus.time;
4094
- blockId = gqlTransactionStatus.block.id;
4146
+ blockId = gqlTransactionStatus.block?.id;
4095
4147
  isStatusFailure = true;
4096
4148
  totalFee = bn14(gqlTransactionStatus.totalFee);
4097
4149
  totalGas = bn14(gqlTransactionStatus.totalGas);
@@ -4526,11 +4578,53 @@ var handleGqlErrorMessage = (errorMessage, rawError) => {
4526
4578
  {},
4527
4579
  rawError
4528
4580
  );
4581
+ case "max number of coins is reached while trying to fit the target" /* MAX_COINS_REACHED */:
4582
+ throw new FuelError16(
4583
+ ErrorCode13.MAX_COINS_REACHED,
4584
+ "The account retrieving coins has exceeded the maximum number of coins per asset. Please consider combining your coins into a single UTXO.",
4585
+ {},
4586
+ rawError
4587
+ );
4529
4588
  default:
4530
4589
  throw new FuelError16(ErrorCode13.INVALID_REQUEST, errorMessage);
4531
4590
  }
4532
4591
  };
4533
4592
 
4593
+ // src/providers/utils/validate-pagination-args.ts
4594
+ import { FuelError as FuelError17, ErrorCode as ErrorCode14 } from "@fuel-ts/errors";
4595
+ var validatePaginationArgs = (params) => {
4596
+ const { paginationLimit, inputArgs = {} } = params;
4597
+ const { first, last, after, before } = inputArgs;
4598
+ if (after && before) {
4599
+ throw new FuelError17(
4600
+ ErrorCode14.INVALID_INPUT_PARAMETERS,
4601
+ 'Pagination arguments "after" and "before" cannot be used together'
4602
+ );
4603
+ }
4604
+ if ((first || 0) > paginationLimit || (last || 0) > paginationLimit) {
4605
+ throw new FuelError17(
4606
+ ErrorCode14.INVALID_INPUT_PARAMETERS,
4607
+ `Pagination limit for this query cannot exceed ${paginationLimit} items`
4608
+ );
4609
+ }
4610
+ if (first && before) {
4611
+ throw new FuelError17(
4612
+ ErrorCode14.INVALID_INPUT_PARAMETERS,
4613
+ 'The use of pagination argument "first" with "before" is not supported'
4614
+ );
4615
+ }
4616
+ if (last && after) {
4617
+ throw new FuelError17(
4618
+ ErrorCode14.INVALID_INPUT_PARAMETERS,
4619
+ 'The use of pagination argument "last" with "after" is not supported'
4620
+ );
4621
+ }
4622
+ if (!first && !last) {
4623
+ inputArgs.first = paginationLimit;
4624
+ }
4625
+ return inputArgs;
4626
+ };
4627
+
4534
4628
  // src/providers/provider.ts
4535
4629
  var MAX_RETRIES = 10;
4536
4630
  var RESOURCES_PAGE_SIZE_LIMIT = 512;
@@ -4675,7 +4769,7 @@ var _Provider = class {
4675
4769
  try {
4676
4770
  parsedUrl = new URL(url);
4677
4771
  } catch (error) {
4678
- throw new FuelError17(FuelError17.CODES.INVALID_URL, "Invalid URL provided.", { url }, error);
4772
+ throw new FuelError18(FuelError18.CODES.INVALID_URL, "Invalid URL provided.", { url }, error);
4679
4773
  }
4680
4774
  const username = parsedUrl.username;
4681
4775
  const password = parsedUrl.password;
@@ -4710,8 +4804,8 @@ var _Provider = class {
4710
4804
  getChain() {
4711
4805
  const chain = _Provider.chainInfoCache[this.urlWithoutAuth];
4712
4806
  if (!chain) {
4713
- throw new FuelError17(
4714
- ErrorCode14.CHAIN_INFO_CACHE_EMPTY,
4807
+ throw new FuelError18(
4808
+ ErrorCode15.CHAIN_INFO_CACHE_EMPTY,
4715
4809
  "Chain info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
4716
4810
  );
4717
4811
  }
@@ -4725,8 +4819,8 @@ var _Provider = class {
4725
4819
  getNode() {
4726
4820
  const node = _Provider.nodeInfoCache[this.urlWithoutAuth];
4727
4821
  if (!node) {
4728
- throw new FuelError17(
4729
- ErrorCode14.NODE_INFO_CACHE_EMPTY,
4822
+ throw new FuelError18(
4823
+ ErrorCode15.NODE_INFO_CACHE_EMPTY,
4730
4824
  "Node info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
4731
4825
  );
4732
4826
  }
@@ -4822,7 +4916,7 @@ Supported fuel-core version: ${supportedVersion}.`
4822
4916
  createOperations() {
4823
4917
  const fetchFn = _Provider.getFetchFn(this.options);
4824
4918
  const gqlClient = new GraphQLClient(this.urlWithoutAuth, {
4825
- fetch: (url, requestInit) => fetchFn(url, requestInit, this.options),
4919
+ fetch: (input, requestInit) => fetchFn(input.toString(), requestInit || {}, this.options),
4826
4920
  responseMiddleware: (response) => {
4827
4921
  if ("response" in response) {
4828
4922
  const graphQlResponse = response.response;
@@ -4952,14 +5046,14 @@ Supported fuel-core version: ${supportedVersion}.`
4952
5046
  }
4953
5047
  } = this.getChain();
4954
5048
  if (bn17(tx.inputs.length).gt(maxInputs)) {
4955
- throw new FuelError17(
4956
- ErrorCode14.MAX_INPUTS_EXCEEDED,
5049
+ throw new FuelError18(
5050
+ ErrorCode15.MAX_INPUTS_EXCEEDED,
4957
5051
  `The transaction exceeds the maximum allowed number of inputs. Tx inputs: ${tx.inputs.length}, max inputs: ${maxInputs}`
4958
5052
  );
4959
5053
  }
4960
5054
  if (bn17(tx.outputs.length).gt(maxOutputs)) {
4961
- throw new FuelError17(
4962
- ErrorCode14.MAX_OUTPUTS_EXCEEDED,
5055
+ throw new FuelError18(
5056
+ ErrorCode15.MAX_OUTPUTS_EXCEEDED,
4963
5057
  `The transaction exceeds the maximum allowed number of outputs. Tx outputs: ${tx.outputs.length}, max outputs: ${maxOutputs}`
4964
5058
  );
4965
5059
  }
@@ -5073,7 +5167,8 @@ Supported fuel-core version: ${supportedVersion}.`
5073
5167
  dryRun: [{ receipts: rawReceipts, status }]
5074
5168
  } = await this.operations.dryRun({
5075
5169
  encodedTransactions: [hexlify17(transactionRequest.toTransactionBytes())],
5076
- utxoValidation: false
5170
+ utxoValidation: false,
5171
+ gasPrice: "0"
5077
5172
  });
5078
5173
  receipts = rawReceipts.map(processGqlReceipt);
5079
5174
  dryRunStatus = status;
@@ -5087,7 +5182,8 @@ Supported fuel-core version: ${supportedVersion}.`
5087
5182
  missingContractIds.push(contractId);
5088
5183
  });
5089
5184
  const { maxFee } = await this.estimateTxGasAndFee({
5090
- transactionRequest
5185
+ transactionRequest,
5186
+ gasPrice: bn17(0)
5091
5187
  });
5092
5188
  transactionRequest.maxFee = maxFee;
5093
5189
  } else {
@@ -5223,7 +5319,7 @@ Supported fuel-core version: ${supportedVersion}.`
5223
5319
  const chainInfo = this.getChain();
5224
5320
  const { gasPriceFactor, maxGasPerTx } = this.getGasConfig();
5225
5321
  const minGas = transactionRequest.calculateMinGas(chainInfo);
5226
- if (!gasPrice) {
5322
+ if (!isDefined2(gasPrice)) {
5227
5323
  gasPrice = await this.estimateGasPrice(10);
5228
5324
  }
5229
5325
  const minFee = calculateGasFee({
@@ -5372,7 +5468,7 @@ Supported fuel-core version: ${supportedVersion}.`
5372
5468
  const {
5373
5469
  coins: { edges, pageInfo }
5374
5470
  } = await this.operations.getCoins({
5375
- ...this.validatePaginationArgs({
5471
+ ...validatePaginationArgs({
5376
5472
  paginationLimit: RESOURCES_PAGE_SIZE_LIMIT,
5377
5473
  inputArgs: paginationArgs
5378
5474
  }),
@@ -5382,7 +5478,7 @@ Supported fuel-core version: ${supportedVersion}.`
5382
5478
  id: node.utxoId,
5383
5479
  assetId: node.assetId,
5384
5480
  amount: bn17(node.amount),
5385
- owner: Address3.fromAddressOrString(node.owner),
5481
+ owner: ownerAddress,
5386
5482
  blockCreated: bn17(node.blockCreated),
5387
5483
  txCreatedIdx: bn17(node.txCreatedIdx)
5388
5484
  }));
@@ -5436,7 +5532,7 @@ Supported fuel-core version: ${supportedVersion}.`
5436
5532
  id: coin.utxoId,
5437
5533
  amount: bn17(coin.amount),
5438
5534
  assetId: coin.assetId,
5439
- owner: Address3.fromAddressOrString(coin.owner),
5535
+ owner: ownerAddress,
5440
5536
  blockCreated: bn17(coin.blockCreated),
5441
5537
  txCreatedIdx: bn17(coin.txCreatedIdx)
5442
5538
  };
@@ -5511,7 +5607,7 @@ Supported fuel-core version: ${supportedVersion}.`
5511
5607
  const {
5512
5608
  blocks: { edges, pageInfo }
5513
5609
  } = await this.operations.getBlocks({
5514
- ...this.validatePaginationArgs({
5610
+ ...validatePaginationArgs({
5515
5611
  paginationLimit: BLOCKS_PAGE_SIZE_LIMIT,
5516
5612
  inputArgs: params
5517
5613
  })
@@ -5590,7 +5686,7 @@ Supported fuel-core version: ${supportedVersion}.`
5590
5686
  0
5591
5687
  )?.[0];
5592
5688
  } catch (error) {
5593
- if (error instanceof FuelError17 && error.code === ErrorCode14.UNSUPPORTED_TRANSACTION_TYPE) {
5689
+ if (error instanceof FuelError18 && error.code === ErrorCode15.UNSUPPORTED_TRANSACTION_TYPE) {
5594
5690
  console.warn("Unsupported transaction type encountered");
5595
5691
  return null;
5596
5692
  }
@@ -5606,7 +5702,7 @@ Supported fuel-core version: ${supportedVersion}.`
5606
5702
  const {
5607
5703
  transactions: { edges, pageInfo }
5608
5704
  } = await this.operations.getTransactions({
5609
- ...this.validatePaginationArgs({
5705
+ ...validatePaginationArgs({
5610
5706
  inputArgs: paginationArgs,
5611
5707
  paginationLimit: TRANSACTIONS_PAGE_SIZE_LIMIT
5612
5708
  })
@@ -5616,7 +5712,7 @@ Supported fuel-core version: ${supportedVersion}.`
5616
5712
  try {
5617
5713
  return coder.decode(arrayify13(rawPayload), 0)[0];
5618
5714
  } catch (error) {
5619
- if (error instanceof FuelError17 && error.code === ErrorCode14.UNSUPPORTED_TRANSACTION_TYPE) {
5715
+ if (error instanceof FuelError18 && error.code === ErrorCode15.UNSUPPORTED_TRANSACTION_TYPE) {
5620
5716
  console.warn("Unsupported transaction type encountered");
5621
5717
  return null;
5622
5718
  }
@@ -5701,7 +5797,7 @@ Supported fuel-core version: ${supportedVersion}.`
5701
5797
  const {
5702
5798
  messages: { edges, pageInfo }
5703
5799
  } = await this.operations.getMessages({
5704
- ...this.validatePaginationArgs({
5800
+ ...validatePaginationArgs({
5705
5801
  inputArgs: paginationArgs,
5706
5802
  paginationLimit: RESOURCES_PAGE_SIZE_LIMIT
5707
5803
  }),
@@ -5742,8 +5838,8 @@ Supported fuel-core version: ${supportedVersion}.`
5742
5838
  nonce
5743
5839
  };
5744
5840
  if (commitBlockId && commitBlockHeight) {
5745
- throw new FuelError17(
5746
- ErrorCode14.INVALID_INPUT_PARAMETERS,
5841
+ throw new FuelError18(
5842
+ ErrorCode15.INVALID_INPUT_PARAMETERS,
5747
5843
  "commitBlockId and commitBlockHeight cannot be used together"
5748
5844
  );
5749
5845
  }
@@ -5925,13 +6021,13 @@ Supported fuel-core version: ${supportedVersion}.`
5925
6021
  messageId: InputMessageCoder2.getMessageId({
5926
6022
  sender: rawMessage.sender,
5927
6023
  recipient: rawMessage.recipient,
5928
- nonce: rawMessage.nonce,
6024
+ nonce,
5929
6025
  amount: bn17(rawMessage.amount),
5930
6026
  data: rawMessage.data
5931
6027
  }),
5932
6028
  sender: Address3.fromAddressOrString(rawMessage.sender),
5933
6029
  recipient: Address3.fromAddressOrString(rawMessage.recipient),
5934
- nonce: rawMessage.nonce,
6030
+ nonce,
5935
6031
  amount: bn17(rawMessage.amount),
5936
6032
  data: InputMessageCoder2.decodeData(rawMessage.data),
5937
6033
  daHeight: bn17(rawMessage.daHeight)
@@ -5953,41 +6049,6 @@ Supported fuel-core version: ${supportedVersion}.`
5953
6049
  }
5954
6050
  return relayedTransactionStatus;
5955
6051
  }
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
6052
  /**
5992
6053
  * @hidden
5993
6054
  */
@@ -6033,7 +6094,7 @@ __publicField(Provider, "chainInfoCache", {});
6033
6094
  __publicField(Provider, "nodeInfoCache", {});
6034
6095
 
6035
6096
  // src/providers/transaction-summary/get-transaction-summary.ts
6036
- import { ErrorCode as ErrorCode15, FuelError as FuelError18 } from "@fuel-ts/errors";
6097
+ import { ErrorCode as ErrorCode16, FuelError as FuelError19 } from "@fuel-ts/errors";
6037
6098
  import { bn as bn18 } from "@fuel-ts/math";
6038
6099
  import { TransactionCoder as TransactionCoder6 } from "@fuel-ts/transactions";
6039
6100
  import { arrayify as arrayify14 } from "@fuel-ts/utils";
@@ -6667,7 +6728,7 @@ __publicField(TestAssetId, "B", new _TestAssetId(
6667
6728
 
6668
6729
  // src/test-utils/wallet-config.ts
6669
6730
  import { randomBytes as randomBytes8 } from "@fuel-ts/crypto";
6670
- import { FuelError as FuelError24 } from "@fuel-ts/errors";
6731
+ import { FuelError as FuelError25 } from "@fuel-ts/errors";
6671
6732
  import { defaultSnapshotConfigs as defaultSnapshotConfigs2, hexlify as hexlify24 } from "@fuel-ts/utils";
6672
6733
 
6673
6734
  // src/wallet/base-wallet-unlocked.ts
@@ -6676,9 +6737,9 @@ import { hexlify as hexlify21 } from "@fuel-ts/utils";
6676
6737
 
6677
6738
  // src/account.ts
6678
6739
  import { UTXO_ID_LEN as UTXO_ID_LEN3 } from "@fuel-ts/abi-coder";
6679
- import { Address as Address4 } from "@fuel-ts/address";
6740
+ import { Address as Address5 } from "@fuel-ts/address";
6680
6741
  import { randomBytes as randomBytes5 } from "@fuel-ts/crypto";
6681
- import { ErrorCode as ErrorCode16, FuelError as FuelError19 } from "@fuel-ts/errors";
6742
+ import { ErrorCode as ErrorCode17, FuelError as FuelError20 } from "@fuel-ts/errors";
6682
6743
  import { AbstractAccount } from "@fuel-ts/interfaces";
6683
6744
  import { bn as bn19 } from "@fuel-ts/math";
6684
6745
  import { InputType as InputType8 } from "@fuel-ts/transactions";
@@ -6700,38 +6761,46 @@ var mergeQuantities = (...coinQuantities) => {
6700
6761
  };
6701
6762
 
6702
6763
  // src/utils/formatTransferToContractScriptData.ts
6703
- import { BigNumberCoder as BigNumberCoder2 } from "@fuel-ts/abi-coder";
6704
- import { BN as BN3 } from "@fuel-ts/math";
6705
- import { arrayify as arrayify15 } from "@fuel-ts/utils";
6764
+ import { ASSET_ID_LEN, BigNumberCoder as BigNumberCoder2, CONTRACT_ID_LEN, WORD_SIZE } from "@fuel-ts/abi-coder";
6765
+ import { Address as Address4 } from "@fuel-ts/address";
6766
+ import { arrayify as arrayify15, concat as concat4 } from "@fuel-ts/utils";
6706
6767
  import * as asm from "@fuels/vm-asm";
6707
- var formatTransferToContractScriptData = (params) => {
6708
- const { assetId, amountToTransfer, hexlifiedContractId } = params;
6768
+ var formatTransferToContractScriptData = (transferParams) => {
6709
6769
  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;
6770
+ return transferParams.reduce((acc, transferParam) => {
6771
+ const { assetId, amount, contractId } = transferParam;
6772
+ const encoded = numberCoder.encode(amount);
6773
+ const scriptData = concat4([
6774
+ Address4.fromAddressOrString(contractId).toBytes(),
6775
+ encoded,
6776
+ arrayify15(assetId)
6777
+ ]);
6778
+ return concat4([acc, scriptData]);
6779
+ }, new Uint8Array());
6717
6780
  };
6718
- var assembleTransferToContractScript = async (params) => {
6719
- const scriptData = formatTransferToContractScriptData(params);
6781
+ var assembleTransferToContractScript = async (transferParams) => {
6782
+ const scriptData = formatTransferToContractScriptData(transferParams);
6720
6783
  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
- ]);
6784
+ let script = new Uint8Array();
6785
+ transferParams.forEach((_, i) => {
6786
+ const offset = (CONTRACT_ID_LEN + WORD_SIZE + ASSET_ID_LEN) * i;
6787
+ script = concat4([
6788
+ script,
6789
+ // Load ScriptData into register 0x10.
6790
+ asm.gtf(16, 0, asm.GTFArgs.ScriptData).to_bytes(),
6791
+ // Add the offset to 0x10 so it will point to the current contract ID, store in 0x11.
6792
+ asm.addi(17, 16, offset).to_bytes(),
6793
+ // Add CONTRACT_ID_LEN to 0x11 to point to the amount in the ScriptData, store in 0x12.
6794
+ asm.addi(18, 17, CONTRACT_ID_LEN).to_bytes(),
6795
+ // Load word to the amount at 0x12 into register 0x13.
6796
+ asm.lw(19, 18, 0).to_bytes(),
6797
+ // Add WORD_SIZE to 0x12 to point to the asset ID in the ScriptData, store in 0x14.
6798
+ asm.addi(20, 18, WORD_SIZE).to_bytes(),
6799
+ // Perform the transfer using contract ID in 0x11, amount in 0x13, and asset ID in 0x14.
6800
+ asm.tr(17, 19, 20).to_bytes()
6801
+ ]);
6802
+ });
6803
+ script = concat4([script, asm.ret(1).to_bytes()]);
6735
6804
  return { script, scriptData };
6736
6805
  };
6737
6806
 
@@ -6761,7 +6830,7 @@ var Account = class extends AbstractAccount {
6761
6830
  super();
6762
6831
  this._provider = provider;
6763
6832
  this._connector = connector;
6764
- this.address = Address4.fromDynamicInput(address);
6833
+ this.address = Address5.fromDynamicInput(address);
6765
6834
  }
6766
6835
  /**
6767
6836
  * The provider used to interact with the network.
@@ -6772,7 +6841,7 @@ var Account = class extends AbstractAccount {
6772
6841
  */
6773
6842
  get provider() {
6774
6843
  if (!this._provider) {
6775
- throw new FuelError19(ErrorCode16.MISSING_PROVIDER, "Provider not set");
6844
+ throw new FuelError20(ErrorCode17.MISSING_PROVIDER, "Provider not set");
6776
6845
  }
6777
6846
  return this._provider;
6778
6847
  }
@@ -6923,8 +6992,8 @@ var Account = class extends AbstractAccount {
6923
6992
  fundingAttempts += 1;
6924
6993
  }
6925
6994
  if (needsToBeFunded) {
6926
- throw new FuelError19(
6927
- ErrorCode16.NOT_ENOUGH_FUNDS,
6995
+ throw new FuelError20(
6996
+ ErrorCode17.NOT_ENOUGH_FUNDS,
6928
6997
  `The account ${this.address} does not have enough base asset funds to cover the transaction execution.`
6929
6998
  );
6930
6999
  }
@@ -6938,7 +7007,8 @@ var Account = class extends AbstractAccount {
6938
7007
  return request;
6939
7008
  }
6940
7009
  const { maxFee } = await this.provider.estimateTxGasAndFee({
6941
- transactionRequest: requestToReestimate
7010
+ transactionRequest: requestToReestimate,
7011
+ gasPrice
6942
7012
  });
6943
7013
  request.maxFee = maxFee;
6944
7014
  return request;
@@ -6995,7 +7065,7 @@ var Account = class extends AbstractAccount {
6995
7065
  const { destination, amount, assetId } = transferParams;
6996
7066
  this.validateTransferAmount(amount);
6997
7067
  request.addCoinOutput(
6998
- Address4.fromAddressOrString(destination),
7068
+ Address5.fromAddressOrString(destination),
6999
7069
  amount,
7000
7070
  assetId ?? this.provider.getBaseAssetId()
7001
7071
  );
@@ -7029,35 +7099,35 @@ var Account = class extends AbstractAccount {
7029
7099
  * @returns A promise that resolves to the transaction response.
7030
7100
  */
7031
7101
  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
- });
7102
+ return this.batchTransferToContracts([{ amount, assetId, contractId }], txParams);
7103
+ }
7104
+ async batchTransferToContracts(contractTransferParams, txParams = {}) {
7045
7105
  let request = new ScriptTransactionRequest({
7046
- ...txParams,
7047
- script,
7048
- scriptData
7106
+ ...txParams
7049
7107
  });
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
7108
+ const quantities = [];
7109
+ const transferParams = contractTransferParams.map((transferParam) => {
7110
+ const amount = bn19(transferParam.amount);
7111
+ const contractAddress = Address5.fromAddressOrString(transferParam.contractId);
7112
+ const assetId = transferParam.assetId ? hexlify19(transferParam.assetId) : this.provider.getBaseAssetId();
7113
+ if (amount.lte(0)) {
7114
+ throw new FuelError20(
7115
+ ErrorCode17.INVALID_TRANSFER_AMOUNT,
7116
+ "Transfer amount must be a positive number."
7117
+ );
7118
+ }
7119
+ request.addContractInputAndOutput(contractAddress);
7120
+ quantities.push({ amount, assetId });
7121
+ return {
7122
+ amount,
7123
+ contractId: contractAddress.toB256(),
7124
+ assetId
7125
+ };
7059
7126
  });
7060
- await this.fund(request, txCost);
7127
+ const { script, scriptData } = await assembleTransferToContractScript(transferParams);
7128
+ request.script = script;
7129
+ request.scriptData = scriptData;
7130
+ request = await this.estimateAndFundTransaction(request, txParams, { quantities });
7061
7131
  return this.sendTransaction(request);
7062
7132
  }
7063
7133
  /**
@@ -7069,7 +7139,7 @@ var Account = class extends AbstractAccount {
7069
7139
  * @returns A promise that resolves to the transaction response.
7070
7140
  */
7071
7141
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
7072
- const recipientAddress = Address4.fromAddressOrString(recipient);
7142
+ const recipientAddress = Address5.fromAddressOrString(recipient);
7073
7143
  const recipientDataArray = arrayify16(
7074
7144
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
7075
7145
  );
@@ -7157,7 +7227,7 @@ var Account = class extends AbstractAccount {
7157
7227
  */
7158
7228
  async signMessage(message) {
7159
7229
  if (!this._connector) {
7160
- throw new FuelError19(ErrorCode16.MISSING_CONNECTOR, "A connector is required to sign messages.");
7230
+ throw new FuelError20(ErrorCode17.MISSING_CONNECTOR, "A connector is required to sign messages.");
7161
7231
  }
7162
7232
  return this._connector.signMessage(this.address.toString(), message);
7163
7233
  }
@@ -7169,8 +7239,8 @@ var Account = class extends AbstractAccount {
7169
7239
  */
7170
7240
  async signTransaction(transactionRequestLike) {
7171
7241
  if (!this._connector) {
7172
- throw new FuelError19(
7173
- ErrorCode16.MISSING_CONNECTOR,
7242
+ throw new FuelError20(
7243
+ ErrorCode17.MISSING_CONNECTOR,
7174
7244
  "A connector is required to sign transactions."
7175
7245
  );
7176
7246
  }
@@ -7229,16 +7299,16 @@ var Account = class extends AbstractAccount {
7229
7299
  /** @hidden * */
7230
7300
  validateTransferAmount(amount) {
7231
7301
  if (bn19(amount).lte(0)) {
7232
- throw new FuelError19(
7233
- ErrorCode16.INVALID_TRANSFER_AMOUNT,
7302
+ throw new FuelError20(
7303
+ ErrorCode17.INVALID_TRANSFER_AMOUNT,
7234
7304
  "Transfer amount must be a positive number."
7235
7305
  );
7236
7306
  }
7237
7307
  }
7238
7308
  /** @hidden * */
7239
- async estimateAndFundTransaction(transactionRequest, txParams) {
7309
+ async estimateAndFundTransaction(transactionRequest, txParams, costParams) {
7240
7310
  let request = transactionRequest;
7241
- const txCost = await this.getTransactionCost(request);
7311
+ const txCost = await this.getTransactionCost(request, costParams);
7242
7312
  request = this.validateGasLimitAndMaxFee({
7243
7313
  transactionRequest: request,
7244
7314
  gasUsed: txCost.gasUsed,
@@ -7259,16 +7329,16 @@ var Account = class extends AbstractAccount {
7259
7329
  if (!isDefined3(setGasLimit)) {
7260
7330
  request.gasLimit = gasUsed;
7261
7331
  } else if (gasUsed.gt(setGasLimit)) {
7262
- throw new FuelError19(
7263
- ErrorCode16.GAS_LIMIT_TOO_LOW,
7332
+ throw new FuelError20(
7333
+ ErrorCode17.GAS_LIMIT_TOO_LOW,
7264
7334
  `Gas limit '${setGasLimit}' is lower than the required: '${gasUsed}'.`
7265
7335
  );
7266
7336
  }
7267
7337
  if (!isDefined3(setMaxFee)) {
7268
7338
  request.maxFee = maxFee;
7269
7339
  } else if (maxFee.gt(setMaxFee)) {
7270
- throw new FuelError19(
7271
- ErrorCode16.MAX_FEE_TOO_LOW,
7340
+ throw new FuelError20(
7341
+ ErrorCode17.MAX_FEE_TOO_LOW,
7272
7342
  `Max fee '${setMaxFee}' is lower than the required: '${maxFee}'.`
7273
7343
  );
7274
7344
  }
@@ -7277,7 +7347,7 @@ var Account = class extends AbstractAccount {
7277
7347
  };
7278
7348
 
7279
7349
  // src/wallet/keystore-wallet.ts
7280
- import { Address as Address5 } from "@fuel-ts/address";
7350
+ import { Address as Address6 } from "@fuel-ts/address";
7281
7351
  import {
7282
7352
  bufferFromString,
7283
7353
  keccak256,
@@ -7288,7 +7358,7 @@ import {
7288
7358
  encryptJsonWalletData,
7289
7359
  randomUUID as randomUUID2
7290
7360
  } from "@fuel-ts/crypto";
7291
- import { ErrorCode as ErrorCode17, FuelError as FuelError20 } from "@fuel-ts/errors";
7361
+ import { ErrorCode as ErrorCode18, FuelError as FuelError21 } from "@fuel-ts/errors";
7292
7362
  import { hexlify as hexlify20 } from "@fuel-ts/utils";
7293
7363
  var DEFAULT_KDF_PARAMS_LOG_N = 13;
7294
7364
  var DEFAULT_KDF_PARAMS_R = 8;
@@ -7303,7 +7373,7 @@ var removeHexPrefix = (hexString) => {
7303
7373
  };
7304
7374
  async function encryptKeystoreWallet(privateKey, address, password) {
7305
7375
  const privateKeyBuffer = bufferFromString(removeHexPrefix(privateKey), "hex");
7306
- const ownerAddress = Address5.fromAddressOrString(address);
7376
+ const ownerAddress = Address6.fromAddressOrString(address);
7307
7377
  const salt = randomBytes6(DEFAULT_KEY_SIZE);
7308
7378
  const key = scrypt({
7309
7379
  password: bufferFromString(password),
@@ -7365,8 +7435,8 @@ async function decryptKeystoreWallet(jsonWallet, password) {
7365
7435
  const macHashUint8Array = keccak256(data);
7366
7436
  const macHash = stringFromBuffer(macHashUint8Array, "hex");
7367
7437
  if (mac !== macHash) {
7368
- throw new FuelError20(
7369
- ErrorCode17.INVALID_PASSWORD,
7438
+ throw new FuelError21(
7439
+ ErrorCode18.INVALID_PASSWORD,
7370
7440
  "Failed to decrypt the keystore wallet, the provided password is incorrect."
7371
7441
  );
7372
7442
  }
@@ -7496,16 +7566,16 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
7496
7566
 
7497
7567
  // src/hdwallet/hdwallet.ts
7498
7568
  import { computeHmac as computeHmac2, ripemd160 } from "@fuel-ts/crypto";
7499
- import { ErrorCode as ErrorCode20, FuelError as FuelError23 } from "@fuel-ts/errors";
7569
+ import { ErrorCode as ErrorCode21, FuelError as FuelError24 } from "@fuel-ts/errors";
7500
7570
  import { sha256 as sha2564 } from "@fuel-ts/hasher";
7501
7571
  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";
7572
+ import { arrayify as arrayify19, hexlify as hexlify23, concat as concat6, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58 } from "@fuel-ts/utils";
7503
7573
 
7504
7574
  // src/mnemonic/mnemonic.ts
7505
7575
  import { randomBytes as randomBytes7, pbkdf2, computeHmac } from "@fuel-ts/crypto";
7506
- import { ErrorCode as ErrorCode19, FuelError as FuelError22 } from "@fuel-ts/errors";
7576
+ import { ErrorCode as ErrorCode20, FuelError as FuelError23 } from "@fuel-ts/errors";
7507
7577
  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";
7578
+ import { arrayify as arrayify18, hexlify as hexlify22, concat as concat5, dataSlice, encodeBase58, toUtf8Bytes } from "@fuel-ts/utils";
7509
7579
 
7510
7580
  // src/wordlists/words/english.ts
7511
7581
  var english = [
@@ -9560,7 +9630,7 @@ var english = [
9560
9630
  ];
9561
9631
 
9562
9632
  // src/mnemonic/utils.ts
9563
- import { ErrorCode as ErrorCode18, FuelError as FuelError21 } from "@fuel-ts/errors";
9633
+ import { ErrorCode as ErrorCode19, FuelError as FuelError22 } from "@fuel-ts/errors";
9564
9634
  import { sha256 as sha2562 } from "@fuel-ts/hasher";
9565
9635
  import { arrayify as arrayify17 } from "@fuel-ts/utils";
9566
9636
  function getLowerMask(bits) {
@@ -9609,8 +9679,8 @@ function mnemonicWordsToEntropy(words, wordlist) {
9609
9679
  for (let i = 0; i < words.length; i += 1) {
9610
9680
  const index = wordlist.indexOf(words[i].normalize("NFKD"));
9611
9681
  if (index === -1) {
9612
- throw new FuelError21(
9613
- ErrorCode18.INVALID_MNEMONIC,
9682
+ throw new FuelError22(
9683
+ ErrorCode19.INVALID_MNEMONIC,
9614
9684
  `Invalid mnemonic: the word '${words[i]}' is not found in the provided wordlist.`
9615
9685
  );
9616
9686
  }
@@ -9626,8 +9696,8 @@ function mnemonicWordsToEntropy(words, wordlist) {
9626
9696
  const checksumMask = getUpperMask(checksumBits);
9627
9697
  const checksum = arrayify17(sha2562(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
9628
9698
  if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
9629
- throw new FuelError21(
9630
- ErrorCode18.INVALID_CHECKSUM,
9699
+ throw new FuelError22(
9700
+ ErrorCode19.INVALID_CHECKSUM,
9631
9701
  "Checksum validation failed for the provided mnemonic."
9632
9702
  );
9633
9703
  }
@@ -9641,16 +9711,16 @@ var TestnetPRV = "0x04358394";
9641
9711
  var MNEMONIC_SIZES = [12, 15, 18, 21, 24];
9642
9712
  function assertWordList(wordlist) {
9643
9713
  if (wordlist.length !== 2048) {
9644
- throw new FuelError22(
9645
- ErrorCode19.INVALID_WORD_LIST,
9714
+ throw new FuelError23(
9715
+ ErrorCode20.INVALID_WORD_LIST,
9646
9716
  `Expected word list length of 2048, but got ${wordlist.length}.`
9647
9717
  );
9648
9718
  }
9649
9719
  }
9650
9720
  function assertEntropy(entropy) {
9651
9721
  if (entropy.length % 4 !== 0 || entropy.length < 16 || entropy.length > 32) {
9652
- throw new FuelError22(
9653
- ErrorCode19.INVALID_ENTROPY,
9722
+ throw new FuelError23(
9723
+ ErrorCode20.INVALID_ENTROPY,
9654
9724
  `Entropy should be between 16 and 32 bytes and a multiple of 4, but got ${entropy.length} bytes.`
9655
9725
  );
9656
9726
  }
@@ -9660,7 +9730,7 @@ function assertMnemonic(words) {
9660
9730
  const errorMsg = `Invalid mnemonic size. Expected one of [${MNEMONIC_SIZES.join(
9661
9731
  ", "
9662
9732
  )}] words, but got ${words.length}.`;
9663
- throw new FuelError22(ErrorCode19.INVALID_MNEMONIC, errorMsg);
9733
+ throw new FuelError23(ErrorCode20.INVALID_MNEMONIC, errorMsg);
9664
9734
  }
9665
9735
  }
9666
9736
  var Mnemonic = class {
@@ -9778,8 +9848,8 @@ var Mnemonic = class {
9778
9848
  static masterKeysFromSeed(seed) {
9779
9849
  const seedArray = arrayify18(seed);
9780
9850
  if (seedArray.length < 16 || seedArray.length > 64) {
9781
- throw new FuelError22(
9782
- ErrorCode19.INVALID_SEED,
9851
+ throw new FuelError23(
9852
+ ErrorCode20.INVALID_SEED,
9783
9853
  `Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
9784
9854
  );
9785
9855
  }
@@ -9800,16 +9870,16 @@ var Mnemonic = class {
9800
9870
  const index = "0x00000000";
9801
9871
  const chainCode = masterKey.slice(32);
9802
9872
  const privateKey = masterKey.slice(0, 32);
9803
- const extendedKey = concat4([
9873
+ const extendedKey = concat5([
9804
9874
  prefix,
9805
9875
  depth,
9806
9876
  fingerprint,
9807
9877
  index,
9808
9878
  chainCode,
9809
- concat4(["0x00", privateKey])
9879
+ concat5(["0x00", privateKey])
9810
9880
  ]);
9811
9881
  const checksum = dataSlice(sha2563(sha2563(extendedKey)), 0, 4);
9812
- return encodeBase58(concat4([extendedKey, checksum]));
9882
+ return encodeBase58(concat5([extendedKey, checksum]));
9813
9883
  }
9814
9884
  /**
9815
9885
  * Create a new mnemonic using a randomly generated number as entropy.
@@ -9824,7 +9894,7 @@ var Mnemonic = class {
9824
9894
  * @returns A randomly generated mnemonic
9825
9895
  */
9826
9896
  static generate(size = 32, extraEntropy = "") {
9827
- const entropy = extraEntropy ? sha2563(concat4([randomBytes7(size), arrayify18(extraEntropy)])) : randomBytes7(size);
9897
+ const entropy = extraEntropy ? sha2563(concat5([randomBytes7(size), arrayify18(extraEntropy)])) : randomBytes7(size);
9828
9898
  return Mnemonic.entropyToMnemonic(entropy);
9829
9899
  }
9830
9900
  };
@@ -9837,7 +9907,7 @@ var MainnetPUB = hexlify23("0x0488b21e");
9837
9907
  var TestnetPRV2 = hexlify23("0x04358394");
9838
9908
  var TestnetPUB = hexlify23("0x043587cf");
9839
9909
  function base58check(data) {
9840
- return encodeBase582(concat5([data, dataSlice2(sha2564(sha2564(data)), 0, 4)]));
9910
+ return encodeBase582(concat6([data, dataSlice2(sha2564(sha2564(data)), 0, 4)]));
9841
9911
  }
9842
9912
  function getExtendedKeyPrefix(isPublic = false, testnet = false) {
9843
9913
  if (isPublic) {
@@ -9856,7 +9926,7 @@ function isValidExtendedKey(extendedKey) {
9856
9926
  function parsePath(path2, depth = 0) {
9857
9927
  const components = path2.split("/");
9858
9928
  if (components.length === 0 || components[0] === "m" && depth !== 0) {
9859
- throw new FuelError23(ErrorCode20.HD_WALLET_ERROR, `invalid path - ${path2}`);
9929
+ throw new FuelError24(ErrorCode21.HD_WALLET_ERROR, `invalid path - ${path2}`);
9860
9930
  }
9861
9931
  if (components[0] === "m") {
9862
9932
  components.shift();
@@ -9885,8 +9955,8 @@ var HDWallet = class {
9885
9955
  this.privateKey = hexlify23(config.privateKey);
9886
9956
  } else {
9887
9957
  if (!config.publicKey) {
9888
- throw new FuelError23(
9889
- ErrorCode20.HD_WALLET_ERROR,
9958
+ throw new FuelError24(
9959
+ ErrorCode21.HD_WALLET_ERROR,
9890
9960
  "Both public and private Key cannot be missing. At least one should be provided."
9891
9961
  );
9892
9962
  }
@@ -9915,8 +9985,8 @@ var HDWallet = class {
9915
9985
  const data = new Uint8Array(37);
9916
9986
  if (index & HARDENED_INDEX) {
9917
9987
  if (!privateKey) {
9918
- throw new FuelError23(
9919
- ErrorCode20.HD_WALLET_ERROR,
9988
+ throw new FuelError24(
9989
+ ErrorCode21.HD_WALLET_ERROR,
9920
9990
  "Cannot derive a hardened index without a private Key."
9921
9991
  );
9922
9992
  }
@@ -9968,8 +10038,8 @@ var HDWallet = class {
9968
10038
  */
9969
10039
  toExtendedKey(isPublic = false, testnet = false) {
9970
10040
  if (this.depth >= 256) {
9971
- throw new FuelError23(
9972
- ErrorCode20.HD_WALLET_ERROR,
10041
+ throw new FuelError24(
10042
+ ErrorCode21.HD_WALLET_ERROR,
9973
10043
  `Exceeded max depth of 255. Current depth: ${this.depth}.`
9974
10044
  );
9975
10045
  }
@@ -9978,8 +10048,8 @@ var HDWallet = class {
9978
10048
  const parentFingerprint = this.parentFingerprint;
9979
10049
  const index = toHex(this.index, 4);
9980
10050
  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]));
10051
+ const key = this.privateKey != null && !isPublic ? concat6(["0x00", this.privateKey]) : this.publicKey;
10052
+ const extendedKey = arrayify19(concat6([prefix, depth, parentFingerprint, index, chainCode, key]));
9983
10053
  return base58check(extendedKey);
9984
10054
  }
9985
10055
  /**
@@ -10000,10 +10070,10 @@ var HDWallet = class {
10000
10070
  const bytes = arrayify19(decoded);
10001
10071
  const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
10002
10072
  if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
10003
- throw new FuelError23(ErrorCode20.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
10073
+ throw new FuelError24(ErrorCode21.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
10004
10074
  }
10005
10075
  if (!validChecksum) {
10006
- throw new FuelError23(ErrorCode20.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
10076
+ throw new FuelError24(ErrorCode21.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
10007
10077
  }
10008
10078
  const depth = bytes[4];
10009
10079
  const parentFingerprint = hexlify23(bytes.slice(5, 9));
@@ -10011,14 +10081,14 @@ var HDWallet = class {
10011
10081
  const chainCode = hexlify23(bytes.slice(13, 45));
10012
10082
  const key = bytes.slice(45, 78);
10013
10083
  if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
10014
- throw new FuelError23(
10015
- ErrorCode20.HD_WALLET_ERROR,
10084
+ throw new FuelError24(
10085
+ ErrorCode21.HD_WALLET_ERROR,
10016
10086
  "Inconsistency detected: Depth is zero but fingerprint/index is non-zero."
10017
10087
  );
10018
10088
  }
10019
10089
  if (isPublicExtendedKey(bytes)) {
10020
10090
  if (key[0] !== 3) {
10021
- throw new FuelError23(ErrorCode20.HD_WALLET_ERROR, "Invalid public extended key.");
10091
+ throw new FuelError24(ErrorCode21.HD_WALLET_ERROR, "Invalid public extended key.");
10022
10092
  }
10023
10093
  return new HDWallet({
10024
10094
  publicKey: key,
@@ -10029,7 +10099,7 @@ var HDWallet = class {
10029
10099
  });
10030
10100
  }
10031
10101
  if (key[0] !== 0) {
10032
- throw new FuelError23(ErrorCode20.HD_WALLET_ERROR, "Invalid private extended key.");
10102
+ throw new FuelError24(ErrorCode21.HD_WALLET_ERROR, "Invalid private extended key.");
10033
10103
  }
10034
10104
  return new HDWallet({
10035
10105
  privateKey: key.slice(1),
@@ -10273,26 +10343,26 @@ var WalletsConfig = class {
10273
10343
  amountPerCoin
10274
10344
  }) {
10275
10345
  if (Array.isArray(wallets) && wallets.length === 0 || typeof wallets === "number" && wallets <= 0) {
10276
- throw new FuelError24(
10277
- FuelError24.CODES.INVALID_INPUT_PARAMETERS,
10346
+ throw new FuelError25(
10347
+ FuelError25.CODES.INVALID_INPUT_PARAMETERS,
10278
10348
  "Number of wallets must be greater than zero."
10279
10349
  );
10280
10350
  }
10281
10351
  if (Array.isArray(assets2) && assets2.length === 0 || typeof assets2 === "number" && assets2 <= 0) {
10282
- throw new FuelError24(
10283
- FuelError24.CODES.INVALID_INPUT_PARAMETERS,
10352
+ throw new FuelError25(
10353
+ FuelError25.CODES.INVALID_INPUT_PARAMETERS,
10284
10354
  "Number of assets per wallet must be greater than zero."
10285
10355
  );
10286
10356
  }
10287
10357
  if (coinsPerAsset <= 0) {
10288
- throw new FuelError24(
10289
- FuelError24.CODES.INVALID_INPUT_PARAMETERS,
10358
+ throw new FuelError25(
10359
+ FuelError25.CODES.INVALID_INPUT_PARAMETERS,
10290
10360
  "Number of coins per asset must be greater than zero."
10291
10361
  );
10292
10362
  }
10293
10363
  if (amountPerCoin < 0) {
10294
- throw new FuelError24(
10295
- FuelError24.CODES.INVALID_INPUT_PARAMETERS,
10364
+ throw new FuelError25(
10365
+ FuelError25.CODES.INVALID_INPUT_PARAMETERS,
10296
10366
  "Amount per coin must be greater than or equal to zero."
10297
10367
  );
10298
10368
  }
@@ -10363,7 +10433,7 @@ async function setupTestProviderAndWallets({
10363
10433
  }
10364
10434
 
10365
10435
  // src/test-utils/test-message.ts
10366
- import { Address as Address6 } from "@fuel-ts/address";
10436
+ import { Address as Address7 } from "@fuel-ts/address";
10367
10437
  import { randomBytes as randomBytes9 } from "@fuel-ts/crypto";
10368
10438
  import { bn as bn21 } from "@fuel-ts/math";
10369
10439
  import { hexlify as hexlify25 } from "@fuel-ts/utils";
@@ -10381,8 +10451,8 @@ var TestMessage = class {
10381
10451
  * It can also be used standalone and passed into the initial state of a chain via the `.toChainMessage` method.
10382
10452
  */
10383
10453
  constructor({
10384
- sender = Address6.fromRandom(),
10385
- recipient = Address6.fromRandom(),
10454
+ sender = Address7.fromRandom(),
10455
+ recipient = Address7.fromRandom(),
10386
10456
  nonce = hexlify25(randomBytes9(32)),
10387
10457
  amount = 1e6,
10388
10458
  data = "",