@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
package/dist/index.js CHANGED
@@ -125,6 +125,7 @@ __export(src_exports, {
125
125
  calculateTXFeeForSummary: () => calculateTXFeeForSummary,
126
126
  coinQuantityfy: () => coinQuantityfy,
127
127
  deferPromise: () => deferPromise,
128
+ deployScriptOrPredicate: () => deployScriptOrPredicate,
128
129
  dispatchFuelConnectorEvent: () => dispatchFuelConnectorEvent,
129
130
  english: () => english,
130
131
  extractBurnedAssetsFromReceipts: () => extractBurnedAssetsFromReceipts,
@@ -218,11 +219,11 @@ module.exports = __toCommonJS(src_exports);
218
219
 
219
220
  // src/account.ts
220
221
  var import_abi_coder7 = require("@fuel-ts/abi-coder");
221
- var import_address4 = require("@fuel-ts/address");
222
+ var import_address5 = require("@fuel-ts/address");
222
223
  var import_crypto2 = require("@fuel-ts/crypto");
223
- var import_errors19 = require("@fuel-ts/errors");
224
+ var import_errors20 = require("@fuel-ts/errors");
224
225
  var import_interfaces = require("@fuel-ts/interfaces");
225
- var import_math21 = require("@fuel-ts/math");
226
+ var import_math20 = require("@fuel-ts/math");
226
227
  var import_transactions24 = require("@fuel-ts/transactions");
227
228
  var import_utils34 = require("@fuel-ts/utils");
228
229
  var import_ramda9 = require("ramda");
@@ -264,7 +265,7 @@ var addAmountToCoinQuantities = (params) => {
264
265
 
265
266
  // src/providers/provider.ts
266
267
  var import_address3 = require("@fuel-ts/address");
267
- var import_errors17 = require("@fuel-ts/errors");
268
+ var import_errors18 = require("@fuel-ts/errors");
268
269
  var import_math18 = require("@fuel-ts/math");
269
270
  var import_transactions22 = require("@fuel-ts/transactions");
270
271
  var import_utils28 = require("@fuel-ts/utils");
@@ -317,9 +318,6 @@ var ReceiptFragmentDoc = import_graphql_tag.default`
317
318
  var SuccessStatusFragmentDoc = import_graphql_tag.default`
318
319
  fragment SuccessStatusFragment on SuccessStatus {
319
320
  type: __typename
320
- block {
321
- id
322
- }
323
321
  time
324
322
  programState {
325
323
  returnType
@@ -332,6 +330,14 @@ var SuccessStatusFragmentDoc = import_graphql_tag.default`
332
330
  totalFee
333
331
  }
334
332
  ${ReceiptFragmentDoc}`;
333
+ var SuccessStatusWithBlockIdFragmentDoc = import_graphql_tag.default`
334
+ fragment SuccessStatusWithBlockIdFragment on SuccessStatus {
335
+ ...SuccessStatusFragment
336
+ block {
337
+ id
338
+ }
339
+ }
340
+ ${SuccessStatusFragmentDoc}`;
335
341
  var MalleableTransactionFieldsFragmentDoc = import_graphql_tag.default`
336
342
  fragment malleableTransactionFieldsFragment on Transaction {
337
343
  receiptsRoot
@@ -376,9 +382,6 @@ var MalleableTransactionFieldsFragmentDoc = import_graphql_tag.default`
376
382
  var FailureStatusFragmentDoc = import_graphql_tag.default`
377
383
  fragment FailureStatusFragment on FailureStatus {
378
384
  type: __typename
379
- block {
380
- id
381
- }
382
385
  totalGas
383
386
  totalFee
384
387
  time
@@ -388,6 +391,14 @@ var FailureStatusFragmentDoc = import_graphql_tag.default`
388
391
  }
389
392
  }
390
393
  ${ReceiptFragmentDoc}`;
394
+ var FailureStatusWithBlockIdFragmentDoc = import_graphql_tag.default`
395
+ fragment FailureStatusWithBlockIdFragment on FailureStatus {
396
+ ...FailureStatusFragment
397
+ block {
398
+ id
399
+ }
400
+ }
401
+ ${FailureStatusFragmentDoc}`;
391
402
  var SqueezedOutStatusFragmentDoc = import_graphql_tag.default`
392
403
  fragment SqueezedOutStatusFragment on SqueezedOutStatus {
393
404
  type: __typename
@@ -400,13 +411,13 @@ var TransactionStatusSubscriptionFragmentDoc = import_graphql_tag.default`
400
411
  ...SubmittedStatusFragment
401
412
  }
402
413
  ... on SuccessStatus {
403
- ...SuccessStatusFragment
414
+ ...SuccessStatusWithBlockIdFragment
404
415
  transaction {
405
416
  ...malleableTransactionFieldsFragment
406
417
  }
407
418
  }
408
419
  ... on FailureStatus {
409
- ...FailureStatusFragment
420
+ ...FailureStatusWithBlockIdFragment
410
421
  transaction {
411
422
  ...malleableTransactionFieldsFragment
412
423
  }
@@ -416,9 +427,9 @@ var TransactionStatusSubscriptionFragmentDoc = import_graphql_tag.default`
416
427
  }
417
428
  }
418
429
  ${SubmittedStatusFragmentDoc}
419
- ${SuccessStatusFragmentDoc}
430
+ ${SuccessStatusWithBlockIdFragmentDoc}
420
431
  ${MalleableTransactionFieldsFragmentDoc}
421
- ${FailureStatusFragmentDoc}
432
+ ${FailureStatusWithBlockIdFragmentDoc}
422
433
  ${SqueezedOutStatusFragmentDoc}`;
423
434
  var TransactionStatusFragmentDoc = import_graphql_tag.default`
424
435
  fragment transactionStatusFragment on TransactionStatus {
@@ -448,6 +459,12 @@ var TransactionFragmentDoc = import_graphql_tag.default`
448
459
  }
449
460
  }
450
461
  ${TransactionStatusFragmentDoc}`;
462
+ var TransactionRawPayloadFragmentDoc = import_graphql_tag.default`
463
+ fragment transactionRawPayloadFragment on Transaction {
464
+ id
465
+ rawPayload
466
+ }
467
+ `;
451
468
  var InputEstimatePredicatesFragmentDoc = import_graphql_tag.default`
452
469
  fragment inputEstimatePredicatesFragment on Input {
453
470
  ... on InputCoin {
@@ -535,7 +552,6 @@ var CoinFragmentDoc = import_graphql_tag.default`
535
552
  fragment coinFragment on Coin {
536
553
  type: __typename
537
554
  utxoId
538
- owner
539
555
  amount
540
556
  assetId
541
557
  blockCreated
@@ -559,10 +575,15 @@ var MessageFragmentDoc = import_graphql_tag.default`
559
575
  sender
560
576
  recipient
561
577
  data
562
- nonce
563
578
  daHeight
564
579
  }
565
580
  `;
581
+ var GetMessageFragmentDoc = import_graphql_tag.default`
582
+ fragment getMessageFragment on Message {
583
+ ...messageFragment
584
+ nonce
585
+ }
586
+ ${MessageFragmentDoc}`;
566
587
  var MessageProofFragmentDoc = import_graphql_tag.default`
567
588
  fragment messageProofFragment on MessageProof {
568
589
  messageProof {
@@ -607,7 +628,6 @@ var MessageProofFragmentDoc = import_graphql_tag.default`
607
628
  }
608
629
  sender
609
630
  recipient
610
- nonce
611
631
  amount
612
632
  data
613
633
  }
@@ -756,12 +776,6 @@ var RelayedTransactionStatusFragmentDoc = import_graphql_tag.default`
756
776
  }
757
777
  }
758
778
  `;
759
- var TransactionRawPayloadFragmentDoc = import_graphql_tag.default`
760
- fragment transactionRawPayload on Transaction {
761
- id
762
- rawPayload
763
- }
764
- `;
765
779
  var GetVersionDocument = import_graphql_tag.default`
766
780
  query getVersion {
767
781
  nodeInfo {
@@ -804,16 +818,34 @@ var GetTransactionDocument = import_graphql_tag.default`
804
818
  var GetTransactionWithReceiptsDocument = import_graphql_tag.default`
805
819
  query getTransactionWithReceipts($transactionId: TransactionId!) {
806
820
  transaction(id: $transactionId) {
807
- ...transactionFragment
821
+ id
822
+ rawPayload
823
+ status {
824
+ ... on SubmittedStatus {
825
+ ...SubmittedStatusFragment
826
+ }
827
+ ... on SuccessStatus {
828
+ ...SuccessStatusWithBlockIdFragment
829
+ }
830
+ ... on FailureStatus {
831
+ ...FailureStatusWithBlockIdFragment
832
+ }
833
+ ... on SqueezedOutStatus {
834
+ ...SqueezedOutStatusFragment
835
+ }
836
+ }
808
837
  }
809
838
  }
810
- ${TransactionFragmentDoc}`;
839
+ ${SubmittedStatusFragmentDoc}
840
+ ${SuccessStatusWithBlockIdFragmentDoc}
841
+ ${FailureStatusWithBlockIdFragmentDoc}
842
+ ${SqueezedOutStatusFragmentDoc}`;
811
843
  var GetTransactionsDocument = import_graphql_tag.default`
812
844
  query getTransactions($after: String, $before: String, $first: Int, $last: Int) {
813
845
  transactions(after: $after, before: $before, first: $first, last: $last) {
814
846
  edges {
815
847
  node {
816
- ...transactionFragment
848
+ rawPayload
817
849
  }
818
850
  }
819
851
  pageInfo {
@@ -821,8 +853,7 @@ var GetTransactionsDocument = import_graphql_tag.default`
821
853
  }
822
854
  }
823
855
  }
824
- ${TransactionFragmentDoc}
825
- ${PageInfoFragmentDoc}`;
856
+ ${PageInfoFragmentDoc}`;
826
857
  var GetTransactionsByOwnerDocument = import_graphql_tag.default`
827
858
  query getTransactionsByOwner($owner: Address!, $after: String, $before: String, $first: Int, $last: Int) {
828
859
  transactionsByOwner(
@@ -881,7 +912,7 @@ var GetBlockWithTransactionsDocument = import_graphql_tag.default`
881
912
  block(id: $blockId, height: $blockHeight) {
882
913
  ...blockFragment
883
914
  transactions {
884
- ...transactionRawPayload
915
+ ...transactionRawPayloadFragment
885
916
  }
886
917
  }
887
918
  }
@@ -906,6 +937,7 @@ var GetCoinDocument = import_graphql_tag.default`
906
937
  query getCoin($coinId: UtxoId!) {
907
938
  coin(utxoId: $coinId) {
908
939
  ...coinFragment
940
+ owner
909
941
  }
910
942
  }
911
943
  ${CoinFragmentDoc}`;
@@ -1014,13 +1046,13 @@ var GetMessagesDocument = import_graphql_tag.default`
1014
1046
  }
1015
1047
  edges {
1016
1048
  node {
1017
- ...messageFragment
1049
+ ...getMessageFragment
1018
1050
  }
1019
1051
  }
1020
1052
  }
1021
1053
  }
1022
1054
  ${PageInfoFragmentDoc}
1023
- ${MessageFragmentDoc}`;
1055
+ ${GetMessageFragmentDoc}`;
1024
1056
  var GetMessageProofDocument = import_graphql_tag.default`
1025
1057
  query getMessageProof($transactionId: TransactionId!, $nonce: Nonce!, $commitBlockId: BlockId, $commitBlockHeight: U32) {
1026
1058
  messageProof(
@@ -1555,9 +1587,11 @@ function assembleReceiptByType(receipt) {
1555
1587
  const { receiptType } = receipt;
1556
1588
  switch (receiptType) {
1557
1589
  case "CALL" /* Call */: {
1590
+ const id = hexOrZero(receipt.id || receipt.contractId);
1558
1591
  const callReceipt = {
1559
1592
  type: import_transactions3.ReceiptType.Call,
1560
- from: hexOrZero(receipt.id || receipt.contractId),
1593
+ id,
1594
+ from: id,
1561
1595
  to: hexOrZero(receipt?.to),
1562
1596
  amount: (0, import_math4.bn)(receipt.amount),
1563
1597
  assetId: hexOrZero(receipt.assetId),
@@ -1614,24 +1648,36 @@ function assembleReceiptByType(receipt) {
1614
1648
  return revertReceipt;
1615
1649
  }
1616
1650
  case "LOG" /* Log */: {
1651
+ const ra = (0, import_math4.bn)(receipt.ra);
1652
+ const rb = (0, import_math4.bn)(receipt.rb);
1653
+ const rc = (0, import_math4.bn)(receipt.rc);
1654
+ const rd = (0, import_math4.bn)(receipt.rd);
1617
1655
  const logReceipt = {
1618
1656
  type: import_transactions3.ReceiptType.Log,
1619
1657
  id: hexOrZero(receipt.id || receipt.contractId),
1620
- val0: (0, import_math4.bn)(receipt.ra),
1621
- val1: (0, import_math4.bn)(receipt.rb),
1622
- val2: (0, import_math4.bn)(receipt.rc),
1623
- val3: (0, import_math4.bn)(receipt.rd),
1658
+ ra,
1659
+ rb,
1660
+ rc,
1661
+ rd,
1662
+ val0: ra,
1663
+ val1: rb,
1664
+ val2: rc,
1665
+ val3: rd,
1624
1666
  pc: (0, import_math4.bn)(receipt.pc),
1625
1667
  is: (0, import_math4.bn)(receipt.is)
1626
1668
  };
1627
1669
  return logReceipt;
1628
1670
  }
1629
1671
  case "LOG_DATA" /* LogData */: {
1672
+ const ra = (0, import_math4.bn)(receipt.ra);
1673
+ const rb = (0, import_math4.bn)(receipt.rb);
1630
1674
  const logDataReceipt = {
1631
1675
  type: import_transactions3.ReceiptType.LogData,
1632
1676
  id: hexOrZero(receipt.id || receipt.contractId),
1633
- val0: (0, import_math4.bn)(receipt.ra),
1634
- val1: (0, import_math4.bn)(receipt.rb),
1677
+ ra,
1678
+ rb,
1679
+ val0: ra,
1680
+ val1: rb,
1635
1681
  ptr: (0, import_math4.bn)(receipt.ptr),
1636
1682
  len: (0, import_math4.bn)(receipt.len),
1637
1683
  digest: hexOrZero(receipt.digest),
@@ -1642,9 +1688,11 @@ function assembleReceiptByType(receipt) {
1642
1688
  return logDataReceipt;
1643
1689
  }
1644
1690
  case "TRANSFER" /* Transfer */: {
1691
+ const id = hexOrZero(receipt.id || receipt.contractId);
1645
1692
  const transferReceipt = {
1646
1693
  type: import_transactions3.ReceiptType.Transfer,
1647
- from: hexOrZero(receipt.id || receipt.contractId),
1694
+ id,
1695
+ from: id,
1648
1696
  to: hexOrZero(receipt.toAddress || receipt?.to),
1649
1697
  amount: (0, import_math4.bn)(receipt.amount),
1650
1698
  assetId: hexOrZero(receipt.assetId),
@@ -1654,9 +1702,11 @@ function assembleReceiptByType(receipt) {
1654
1702
  return transferReceipt;
1655
1703
  }
1656
1704
  case "TRANSFER_OUT" /* TransferOut */: {
1705
+ const id = hexOrZero(receipt.id || receipt.contractId);
1657
1706
  const transferOutReceipt = {
1658
1707
  type: import_transactions3.ReceiptType.TransferOut,
1659
- from: hexOrZero(receipt.id || receipt.contractId),
1708
+ id,
1709
+ from: id,
1660
1710
  to: hexOrZero(receipt.toAddress || receipt.to),
1661
1711
  amount: (0, import_math4.bn)(receipt.amount),
1662
1712
  assetId: hexOrZero(receipt.assetId),
@@ -2718,7 +2768,7 @@ var BlobTransactionRequest = class extends BaseTransactionRequest {
2718
2768
  type = import_transactions7.TransactionType.Blob;
2719
2769
  /** Blob ID */
2720
2770
  blobId;
2721
- /** Witness index of contract bytecode to create */
2771
+ /** Witness index of the bytecode to create */
2722
2772
  witnessIndex;
2723
2773
  /**
2724
2774
  * Creates an instance `BlobTransactionRequest`.
@@ -4102,14 +4152,14 @@ var processGraphqlStatus = (gqlTransactionStatus) => {
4102
4152
  switch (gqlTransactionStatus.type) {
4103
4153
  case "SuccessStatus":
4104
4154
  time = gqlTransactionStatus.time;
4105
- blockId = gqlTransactionStatus.block.id;
4155
+ blockId = gqlTransactionStatus.block?.id;
4106
4156
  isStatusSuccess = true;
4107
4157
  totalFee = (0, import_math15.bn)(gqlTransactionStatus.totalFee);
4108
4158
  totalGas = (0, import_math15.bn)(gqlTransactionStatus.totalGas);
4109
4159
  break;
4110
4160
  case "FailureStatus":
4111
4161
  time = gqlTransactionStatus.time;
4112
- blockId = gqlTransactionStatus.block.id;
4162
+ blockId = gqlTransactionStatus.block?.id;
4113
4163
  isStatusFailure = true;
4114
4164
  totalFee = (0, import_math15.bn)(gqlTransactionStatus.totalFee);
4115
4165
  totalGas = (0, import_math15.bn)(gqlTransactionStatus.totalGas);
@@ -4420,8 +4470,8 @@ var TransactionResponse = class {
4420
4470
  const subscription = this.submitTxSubscription ?? await this.provider.operations.statusChange({
4421
4471
  transactionId: this.id
4422
4472
  });
4423
- for await (const sub of subscription) {
4424
- const statusChange = "statusChange" in sub ? sub.statusChange : sub.submitAndAwaitStatus;
4473
+ for await (const sub2 of subscription) {
4474
+ const statusChange = "statusChange" in sub2 ? sub2.statusChange : sub2.submitAndAwaitStatus;
4425
4475
  this.status = statusChange;
4426
4476
  if (statusChange.type === "SqueezedOutStatus") {
4427
4477
  this.unsetResourceCache();
@@ -4544,11 +4594,53 @@ var handleGqlErrorMessage = (errorMessage, rawError) => {
4544
4594
  {},
4545
4595
  rawError
4546
4596
  );
4597
+ case "max number of coins is reached while trying to fit the target" /* MAX_COINS_REACHED */:
4598
+ throw new import_errors16.FuelError(
4599
+ import_errors16.ErrorCode.MAX_COINS_REACHED,
4600
+ "The account retrieving coins has exceeded the maximum number of coins per asset. Please consider combining your coins into a single UTXO.",
4601
+ {},
4602
+ rawError
4603
+ );
4547
4604
  default:
4548
4605
  throw new import_errors16.FuelError(import_errors16.ErrorCode.INVALID_REQUEST, errorMessage);
4549
4606
  }
4550
4607
  };
4551
4608
 
4609
+ // src/providers/utils/validate-pagination-args.ts
4610
+ var import_errors17 = require("@fuel-ts/errors");
4611
+ var validatePaginationArgs = (params) => {
4612
+ const { paginationLimit, inputArgs = {} } = params;
4613
+ const { first, last, after, before } = inputArgs;
4614
+ if (after && before) {
4615
+ throw new import_errors17.FuelError(
4616
+ import_errors17.ErrorCode.INVALID_INPUT_PARAMETERS,
4617
+ 'Pagination arguments "after" and "before" cannot be used together'
4618
+ );
4619
+ }
4620
+ if ((first || 0) > paginationLimit || (last || 0) > paginationLimit) {
4621
+ throw new import_errors17.FuelError(
4622
+ import_errors17.ErrorCode.INVALID_INPUT_PARAMETERS,
4623
+ `Pagination limit for this query cannot exceed ${paginationLimit} items`
4624
+ );
4625
+ }
4626
+ if (first && before) {
4627
+ throw new import_errors17.FuelError(
4628
+ import_errors17.ErrorCode.INVALID_INPUT_PARAMETERS,
4629
+ 'The use of pagination argument "first" with "before" is not supported'
4630
+ );
4631
+ }
4632
+ if (last && after) {
4633
+ throw new import_errors17.FuelError(
4634
+ import_errors17.ErrorCode.INVALID_INPUT_PARAMETERS,
4635
+ 'The use of pagination argument "last" with "after" is not supported'
4636
+ );
4637
+ }
4638
+ if (!first && !last) {
4639
+ inputArgs.first = paginationLimit;
4640
+ }
4641
+ return inputArgs;
4642
+ };
4643
+
4552
4644
  // src/providers/provider.ts
4553
4645
  var MAX_RETRIES = 10;
4554
4646
  var RESOURCES_PAGE_SIZE_LIMIT = 512;
@@ -4693,7 +4785,7 @@ var _Provider = class {
4693
4785
  try {
4694
4786
  parsedUrl = new URL(url);
4695
4787
  } catch (error) {
4696
- throw new import_errors17.FuelError(import_errors17.FuelError.CODES.INVALID_URL, "Invalid URL provided.", { url }, error);
4788
+ throw new import_errors18.FuelError(import_errors18.FuelError.CODES.INVALID_URL, "Invalid URL provided.", { url }, error);
4697
4789
  }
4698
4790
  const username = parsedUrl.username;
4699
4791
  const password = parsedUrl.password;
@@ -4728,8 +4820,8 @@ var _Provider = class {
4728
4820
  getChain() {
4729
4821
  const chain = _Provider.chainInfoCache[this.urlWithoutAuth];
4730
4822
  if (!chain) {
4731
- throw new import_errors17.FuelError(
4732
- import_errors17.ErrorCode.CHAIN_INFO_CACHE_EMPTY,
4823
+ throw new import_errors18.FuelError(
4824
+ import_errors18.ErrorCode.CHAIN_INFO_CACHE_EMPTY,
4733
4825
  "Chain info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
4734
4826
  );
4735
4827
  }
@@ -4743,8 +4835,8 @@ var _Provider = class {
4743
4835
  getNode() {
4744
4836
  const node = _Provider.nodeInfoCache[this.urlWithoutAuth];
4745
4837
  if (!node) {
4746
- throw new import_errors17.FuelError(
4747
- import_errors17.ErrorCode.NODE_INFO_CACHE_EMPTY,
4838
+ throw new import_errors18.FuelError(
4839
+ import_errors18.ErrorCode.NODE_INFO_CACHE_EMPTY,
4748
4840
  "Node info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
4749
4841
  );
4750
4842
  }
@@ -4840,7 +4932,7 @@ Supported fuel-core version: ${supportedVersion}.`
4840
4932
  createOperations() {
4841
4933
  const fetchFn = _Provider.getFetchFn(this.options);
4842
4934
  const gqlClient = new import_graphql_request.GraphQLClient(this.urlWithoutAuth, {
4843
- fetch: (url, requestInit) => fetchFn(url, requestInit, this.options),
4935
+ fetch: (input, requestInit) => fetchFn(input.toString(), requestInit || {}, this.options),
4844
4936
  responseMiddleware: (response) => {
4845
4937
  if ("response" in response) {
4846
4938
  const graphQlResponse = response.response;
@@ -4970,14 +5062,14 @@ Supported fuel-core version: ${supportedVersion}.`
4970
5062
  }
4971
5063
  } = this.getChain();
4972
5064
  if ((0, import_math18.bn)(tx.inputs.length).gt(maxInputs)) {
4973
- throw new import_errors17.FuelError(
4974
- import_errors17.ErrorCode.MAX_INPUTS_EXCEEDED,
5065
+ throw new import_errors18.FuelError(
5066
+ import_errors18.ErrorCode.MAX_INPUTS_EXCEEDED,
4975
5067
  `The transaction exceeds the maximum allowed number of inputs. Tx inputs: ${tx.inputs.length}, max inputs: ${maxInputs}`
4976
5068
  );
4977
5069
  }
4978
5070
  if ((0, import_math18.bn)(tx.outputs.length).gt(maxOutputs)) {
4979
- throw new import_errors17.FuelError(
4980
- import_errors17.ErrorCode.MAX_OUTPUTS_EXCEEDED,
5071
+ throw new import_errors18.FuelError(
5072
+ import_errors18.ErrorCode.MAX_OUTPUTS_EXCEEDED,
4981
5073
  `The transaction exceeds the maximum allowed number of outputs. Tx outputs: ${tx.outputs.length}, max outputs: ${maxOutputs}`
4982
5074
  );
4983
5075
  }
@@ -5091,7 +5183,8 @@ Supported fuel-core version: ${supportedVersion}.`
5091
5183
  dryRun: [{ receipts: rawReceipts, status }]
5092
5184
  } = await this.operations.dryRun({
5093
5185
  encodedTransactions: [(0, import_utils28.hexlify)(transactionRequest.toTransactionBytes())],
5094
- utxoValidation: false
5186
+ utxoValidation: false,
5187
+ gasPrice: "0"
5095
5188
  });
5096
5189
  receipts = rawReceipts.map(processGqlReceipt);
5097
5190
  dryRunStatus = status;
@@ -5105,7 +5198,8 @@ Supported fuel-core version: ${supportedVersion}.`
5105
5198
  missingContractIds.push(contractId);
5106
5199
  });
5107
5200
  const { maxFee } = await this.estimateTxGasAndFee({
5108
- transactionRequest
5201
+ transactionRequest,
5202
+ gasPrice: (0, import_math18.bn)(0)
5109
5203
  });
5110
5204
  transactionRequest.maxFee = maxFee;
5111
5205
  } else {
@@ -5241,7 +5335,7 @@ Supported fuel-core version: ${supportedVersion}.`
5241
5335
  const chainInfo = this.getChain();
5242
5336
  const { gasPriceFactor, maxGasPerTx } = this.getGasConfig();
5243
5337
  const minGas = transactionRequest.calculateMinGas(chainInfo);
5244
- if (!gasPrice) {
5338
+ if (!(0, import_utils28.isDefined)(gasPrice)) {
5245
5339
  gasPrice = await this.estimateGasPrice(10);
5246
5340
  }
5247
5341
  const minFee = calculateGasFee({
@@ -5390,7 +5484,7 @@ Supported fuel-core version: ${supportedVersion}.`
5390
5484
  const {
5391
5485
  coins: { edges, pageInfo }
5392
5486
  } = await this.operations.getCoins({
5393
- ...this.validatePaginationArgs({
5487
+ ...validatePaginationArgs({
5394
5488
  paginationLimit: RESOURCES_PAGE_SIZE_LIMIT,
5395
5489
  inputArgs: paginationArgs
5396
5490
  }),
@@ -5400,7 +5494,7 @@ Supported fuel-core version: ${supportedVersion}.`
5400
5494
  id: node.utxoId,
5401
5495
  assetId: node.assetId,
5402
5496
  amount: (0, import_math18.bn)(node.amount),
5403
- owner: import_address3.Address.fromAddressOrString(node.owner),
5497
+ owner: ownerAddress,
5404
5498
  blockCreated: (0, import_math18.bn)(node.blockCreated),
5405
5499
  txCreatedIdx: (0, import_math18.bn)(node.txCreatedIdx)
5406
5500
  }));
@@ -5454,7 +5548,7 @@ Supported fuel-core version: ${supportedVersion}.`
5454
5548
  id: coin.utxoId,
5455
5549
  amount: (0, import_math18.bn)(coin.amount),
5456
5550
  assetId: coin.assetId,
5457
- owner: import_address3.Address.fromAddressOrString(coin.owner),
5551
+ owner: ownerAddress,
5458
5552
  blockCreated: (0, import_math18.bn)(coin.blockCreated),
5459
5553
  txCreatedIdx: (0, import_math18.bn)(coin.txCreatedIdx)
5460
5554
  };
@@ -5529,7 +5623,7 @@ Supported fuel-core version: ${supportedVersion}.`
5529
5623
  const {
5530
5624
  blocks: { edges, pageInfo }
5531
5625
  } = await this.operations.getBlocks({
5532
- ...this.validatePaginationArgs({
5626
+ ...validatePaginationArgs({
5533
5627
  paginationLimit: BLOCKS_PAGE_SIZE_LIMIT,
5534
5628
  inputArgs: params
5535
5629
  })
@@ -5608,7 +5702,7 @@ Supported fuel-core version: ${supportedVersion}.`
5608
5702
  0
5609
5703
  )?.[0];
5610
5704
  } catch (error) {
5611
- if (error instanceof import_errors17.FuelError && error.code === import_errors17.ErrorCode.UNSUPPORTED_TRANSACTION_TYPE) {
5705
+ if (error instanceof import_errors18.FuelError && error.code === import_errors18.ErrorCode.UNSUPPORTED_TRANSACTION_TYPE) {
5612
5706
  console.warn("Unsupported transaction type encountered");
5613
5707
  return null;
5614
5708
  }
@@ -5624,7 +5718,7 @@ Supported fuel-core version: ${supportedVersion}.`
5624
5718
  const {
5625
5719
  transactions: { edges, pageInfo }
5626
5720
  } = await this.operations.getTransactions({
5627
- ...this.validatePaginationArgs({
5721
+ ...validatePaginationArgs({
5628
5722
  inputArgs: paginationArgs,
5629
5723
  paginationLimit: TRANSACTIONS_PAGE_SIZE_LIMIT
5630
5724
  })
@@ -5634,7 +5728,7 @@ Supported fuel-core version: ${supportedVersion}.`
5634
5728
  try {
5635
5729
  return coder.decode((0, import_utils28.arrayify)(rawPayload), 0)[0];
5636
5730
  } catch (error) {
5637
- if (error instanceof import_errors17.FuelError && error.code === import_errors17.ErrorCode.UNSUPPORTED_TRANSACTION_TYPE) {
5731
+ if (error instanceof import_errors18.FuelError && error.code === import_errors18.ErrorCode.UNSUPPORTED_TRANSACTION_TYPE) {
5638
5732
  console.warn("Unsupported transaction type encountered");
5639
5733
  return null;
5640
5734
  }
@@ -5719,7 +5813,7 @@ Supported fuel-core version: ${supportedVersion}.`
5719
5813
  const {
5720
5814
  messages: { edges, pageInfo }
5721
5815
  } = await this.operations.getMessages({
5722
- ...this.validatePaginationArgs({
5816
+ ...validatePaginationArgs({
5723
5817
  inputArgs: paginationArgs,
5724
5818
  paginationLimit: RESOURCES_PAGE_SIZE_LIMIT
5725
5819
  }),
@@ -5760,8 +5854,8 @@ Supported fuel-core version: ${supportedVersion}.`
5760
5854
  nonce
5761
5855
  };
5762
5856
  if (commitBlockId && commitBlockHeight) {
5763
- throw new import_errors17.FuelError(
5764
- import_errors17.ErrorCode.INVALID_INPUT_PARAMETERS,
5857
+ throw new import_errors18.FuelError(
5858
+ import_errors18.ErrorCode.INVALID_INPUT_PARAMETERS,
5765
5859
  "commitBlockId and commitBlockHeight cannot be used together"
5766
5860
  );
5767
5861
  }
@@ -5943,13 +6037,13 @@ Supported fuel-core version: ${supportedVersion}.`
5943
6037
  messageId: import_transactions22.InputMessageCoder.getMessageId({
5944
6038
  sender: rawMessage.sender,
5945
6039
  recipient: rawMessage.recipient,
5946
- nonce: rawMessage.nonce,
6040
+ nonce,
5947
6041
  amount: (0, import_math18.bn)(rawMessage.amount),
5948
6042
  data: rawMessage.data
5949
6043
  }),
5950
6044
  sender: import_address3.Address.fromAddressOrString(rawMessage.sender),
5951
6045
  recipient: import_address3.Address.fromAddressOrString(rawMessage.recipient),
5952
- nonce: rawMessage.nonce,
6046
+ nonce,
5953
6047
  amount: (0, import_math18.bn)(rawMessage.amount),
5954
6048
  data: import_transactions22.InputMessageCoder.decodeData(rawMessage.data),
5955
6049
  daHeight: (0, import_math18.bn)(rawMessage.daHeight)
@@ -5971,41 +6065,6 @@ Supported fuel-core version: ${supportedVersion}.`
5971
6065
  }
5972
6066
  return relayedTransactionStatus;
5973
6067
  }
5974
- /**
5975
- * @hidden
5976
- */
5977
- validatePaginationArgs(params) {
5978
- const { paginationLimit, inputArgs = {} } = params;
5979
- const { first, last, after, before } = inputArgs;
5980
- if (after && before) {
5981
- throw new import_errors17.FuelError(
5982
- import_errors17.ErrorCode.INVALID_INPUT_PARAMETERS,
5983
- 'Pagination arguments "after" and "before" cannot be used together'
5984
- );
5985
- }
5986
- if ((first || 0) > paginationLimit || (last || 0) > paginationLimit) {
5987
- throw new import_errors17.FuelError(
5988
- import_errors17.ErrorCode.INVALID_INPUT_PARAMETERS,
5989
- `Pagination limit for this query cannot exceed ${paginationLimit} items`
5990
- );
5991
- }
5992
- if (first && before) {
5993
- throw new import_errors17.FuelError(
5994
- import_errors17.ErrorCode.INVALID_INPUT_PARAMETERS,
5995
- 'The use of pagination argument "first" with "before" is not supported'
5996
- );
5997
- }
5998
- if (last && after) {
5999
- throw new import_errors17.FuelError(
6000
- import_errors17.ErrorCode.INVALID_INPUT_PARAMETERS,
6001
- 'The use of pagination argument "last" with "after" is not supported'
6002
- );
6003
- }
6004
- if (!first && !last) {
6005
- inputArgs.first = paginationLimit;
6006
- }
6007
- return inputArgs;
6008
- }
6009
6068
  /**
6010
6069
  * @hidden
6011
6070
  */
@@ -6051,7 +6110,7 @@ __publicField(Provider, "chainInfoCache", {});
6051
6110
  __publicField(Provider, "nodeInfoCache", {});
6052
6111
 
6053
6112
  // src/providers/transaction-summary/get-transaction-summary.ts
6054
- var import_errors18 = require("@fuel-ts/errors");
6113
+ var import_errors19 = require("@fuel-ts/errors");
6055
6114
  var import_math19 = require("@fuel-ts/math");
6056
6115
  var import_transactions23 = require("@fuel-ts/transactions");
6057
6116
  var import_utils31 = require("@fuel-ts/utils");
@@ -6061,8 +6120,8 @@ async function getTransactionSummary(params) {
6061
6120
  transactionId: id
6062
6121
  });
6063
6122
  if (!gqlTransaction) {
6064
- throw new import_errors18.FuelError(
6065
- import_errors18.ErrorCode.TRANSACTION_NOT_FOUND,
6123
+ throw new import_errors19.FuelError(
6124
+ import_errors19.ErrorCode.TRANSACTION_NOT_FOUND,
6066
6125
  `Transaction not found for given id: ${id}.`
6067
6126
  );
6068
6127
  }
@@ -6130,7 +6189,15 @@ async function getTransactionSummaryFromRequest(params) {
6130
6189
  }
6131
6190
  async function getTransactionsSummaries(params) {
6132
6191
  const { filters, provider, abiMap } = params;
6133
- const { transactionsByOwner } = await provider.operations.getTransactionsByOwner(filters);
6192
+ const { owner, ...inputArgs } = filters;
6193
+ const validPaginationParams = validatePaginationArgs({
6194
+ inputArgs,
6195
+ paginationLimit: TRANSACTIONS_PAGE_SIZE_LIMIT
6196
+ });
6197
+ const { transactionsByOwner } = await provider.operations.getTransactionsByOwner({
6198
+ ...validPaginationParams,
6199
+ owner
6200
+ });
6134
6201
  const { edges, pageInfo } = transactionsByOwner;
6135
6202
  const {
6136
6203
  consensusParameters: {
@@ -6850,37 +6917,45 @@ var mergeQuantities = (...coinQuantities) => {
6850
6917
 
6851
6918
  // src/utils/formatTransferToContractScriptData.ts
6852
6919
  var import_abi_coder6 = require("@fuel-ts/abi-coder");
6853
- var import_math20 = require("@fuel-ts/math");
6920
+ var import_address4 = require("@fuel-ts/address");
6854
6921
  var import_utils33 = require("@fuel-ts/utils");
6855
6922
  var asm = __toESM(require("@fuels/vm-asm"));
6856
- var formatTransferToContractScriptData = (params) => {
6857
- const { assetId, amountToTransfer, hexlifiedContractId } = params;
6923
+ var formatTransferToContractScriptData = (transferParams) => {
6858
6924
  const numberCoder = new import_abi_coder6.BigNumberCoder("u64");
6859
- const encoded = numberCoder.encode(new import_math20.BN(amountToTransfer).toNumber());
6860
- const scriptData = Uint8Array.from([
6861
- ...(0, import_utils33.arrayify)(hexlifiedContractId),
6862
- ...encoded,
6863
- ...(0, import_utils33.arrayify)(assetId)
6864
- ]);
6865
- return scriptData;
6925
+ return transferParams.reduce((acc, transferParam) => {
6926
+ const { assetId, amount, contractId } = transferParam;
6927
+ const encoded = numberCoder.encode(amount);
6928
+ const scriptData = (0, import_utils33.concat)([
6929
+ import_address4.Address.fromAddressOrString(contractId).toBytes(),
6930
+ encoded,
6931
+ (0, import_utils33.arrayify)(assetId)
6932
+ ]);
6933
+ return (0, import_utils33.concat)([acc, scriptData]);
6934
+ }, new Uint8Array());
6866
6935
  };
6867
- var assembleTransferToContractScript = async (params) => {
6868
- const scriptData = formatTransferToContractScriptData(params);
6936
+ var assembleTransferToContractScript = async (transferParams) => {
6937
+ const scriptData = formatTransferToContractScriptData(transferParams);
6869
6938
  await asm.initWasm();
6870
- const gtf2 = asm.gtf(16, 0, asm.GTFArgs.ScriptData);
6871
- const addi2 = asm.addi(17, 16, 32);
6872
- const lw2 = asm.lw(18, 17, 0);
6873
- const addi22 = asm.addi(19, 17, 8);
6874
- const tr2 = asm.tr(16, 18, 19);
6875
- const ret2 = asm.ret(1);
6876
- const script = Uint8Array.from([
6877
- ...gtf2.to_bytes(),
6878
- ...addi2.to_bytes(),
6879
- ...lw2.to_bytes(),
6880
- ...addi22.to_bytes(),
6881
- ...tr2.to_bytes(),
6882
- ...ret2.to_bytes()
6883
- ]);
6939
+ let script = new Uint8Array();
6940
+ transferParams.forEach((_, i) => {
6941
+ const offset = (import_abi_coder6.CONTRACT_ID_LEN + import_abi_coder6.WORD_SIZE + import_abi_coder6.ASSET_ID_LEN) * i;
6942
+ script = (0, import_utils33.concat)([
6943
+ script,
6944
+ // Load ScriptData into register 0x10.
6945
+ asm.gtf(16, 0, asm.GTFArgs.ScriptData).to_bytes(),
6946
+ // Add the offset to 0x10 so it will point to the current contract ID, store in 0x11.
6947
+ asm.addi(17, 16, offset).to_bytes(),
6948
+ // Add CONTRACT_ID_LEN to 0x11 to point to the amount in the ScriptData, store in 0x12.
6949
+ asm.addi(18, 17, import_abi_coder6.CONTRACT_ID_LEN).to_bytes(),
6950
+ // Load word to the amount at 0x12 into register 0x13.
6951
+ asm.lw(19, 18, 0).to_bytes(),
6952
+ // Add WORD_SIZE to 0x12 to point to the asset ID in the ScriptData, store in 0x14.
6953
+ asm.addi(20, 18, import_abi_coder6.WORD_SIZE).to_bytes(),
6954
+ // Perform the transfer using contract ID in 0x11, amount in 0x13, and asset ID in 0x14.
6955
+ asm.tr(17, 19, 20).to_bytes()
6956
+ ]);
6957
+ });
6958
+ script = (0, import_utils33.concat)([script, asm.ret(1).to_bytes()]);
6884
6959
  return { script, scriptData };
6885
6960
  };
6886
6961
 
@@ -6910,7 +6985,7 @@ var Account = class extends import_interfaces.AbstractAccount {
6910
6985
  super();
6911
6986
  this._provider = provider;
6912
6987
  this._connector = connector;
6913
- this.address = import_address4.Address.fromDynamicInput(address);
6988
+ this.address = import_address5.Address.fromDynamicInput(address);
6914
6989
  }
6915
6990
  /**
6916
6991
  * The provider used to interact with the network.
@@ -6921,7 +6996,7 @@ var Account = class extends import_interfaces.AbstractAccount {
6921
6996
  */
6922
6997
  get provider() {
6923
6998
  if (!this._provider) {
6924
- throw new import_errors19.FuelError(import_errors19.ErrorCode.MISSING_PROVIDER, "Provider not set");
6999
+ throw new import_errors20.FuelError(import_errors20.ErrorCode.MISSING_PROVIDER, "Provider not set");
6925
7000
  }
6926
7001
  return this._provider;
6927
7002
  }
@@ -7001,9 +7076,9 @@ var Account = class extends import_interfaces.AbstractAccount {
7001
7076
  const { addedSignatures, estimatedPredicates, requiredQuantities, updateMaxFee, gasPrice } = params;
7002
7077
  const fee = request.maxFee;
7003
7078
  const baseAssetId = this.provider.getBaseAssetId();
7004
- const requiredInBaseAsset = requiredQuantities.find((quantity) => quantity.assetId === baseAssetId)?.amount || (0, import_math21.bn)(0);
7079
+ const requiredInBaseAsset = requiredQuantities.find((quantity) => quantity.assetId === baseAssetId)?.amount || (0, import_math20.bn)(0);
7005
7080
  const requiredQuantitiesWithFee = addAmountToCoinQuantities({
7006
- amount: (0, import_math21.bn)(fee),
7081
+ amount: (0, import_math20.bn)(fee),
7007
7082
  assetId: baseAssetId,
7008
7083
  coinQuantities: requiredQuantities
7009
7084
  });
@@ -7011,7 +7086,7 @@ var Account = class extends import_interfaces.AbstractAccount {
7011
7086
  requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
7012
7087
  quantitiesDict[assetId] = {
7013
7088
  required: amount,
7014
- owned: (0, import_math21.bn)(0)
7089
+ owned: (0, import_math20.bn)(0)
7015
7090
  };
7016
7091
  });
7017
7092
  request.inputs.filter(isRequestInputResource).forEach((input) => {
@@ -7072,8 +7147,8 @@ var Account = class extends import_interfaces.AbstractAccount {
7072
7147
  fundingAttempts += 1;
7073
7148
  }
7074
7149
  if (needsToBeFunded) {
7075
- throw new import_errors19.FuelError(
7076
- import_errors19.ErrorCode.NOT_ENOUGH_FUNDS,
7150
+ throw new import_errors20.FuelError(
7151
+ import_errors20.ErrorCode.NOT_ENOUGH_FUNDS,
7077
7152
  `The account ${this.address} does not have enough base asset funds to cover the transaction execution.`
7078
7153
  );
7079
7154
  }
@@ -7087,7 +7162,8 @@ var Account = class extends import_interfaces.AbstractAccount {
7087
7162
  return request;
7088
7163
  }
7089
7164
  const { maxFee } = await this.provider.estimateTxGasAndFee({
7090
- transactionRequest: requestToReestimate
7165
+ transactionRequest: requestToReestimate,
7166
+ gasPrice
7091
7167
  });
7092
7168
  request.maxFee = maxFee;
7093
7169
  return request;
@@ -7144,7 +7220,7 @@ var Account = class extends import_interfaces.AbstractAccount {
7144
7220
  const { destination, amount, assetId } = transferParams;
7145
7221
  this.validateTransferAmount(amount);
7146
7222
  request.addCoinOutput(
7147
- import_address4.Address.fromAddressOrString(destination),
7223
+ import_address5.Address.fromAddressOrString(destination),
7148
7224
  amount,
7149
7225
  assetId ?? this.provider.getBaseAssetId()
7150
7226
  );
@@ -7178,35 +7254,35 @@ var Account = class extends import_interfaces.AbstractAccount {
7178
7254
  * @returns A promise that resolves to the transaction response.
7179
7255
  */
7180
7256
  async transferToContract(contractId, amount, assetId, txParams = {}) {
7181
- if ((0, import_math21.bn)(amount).lte(0)) {
7182
- throw new import_errors19.FuelError(
7183
- import_errors19.ErrorCode.INVALID_TRANSFER_AMOUNT,
7184
- "Transfer amount must be a positive number."
7185
- );
7186
- }
7187
- const contractAddress = import_address4.Address.fromAddressOrString(contractId);
7188
- const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
7189
- const { script, scriptData } = await assembleTransferToContractScript({
7190
- hexlifiedContractId: contractAddress.toB256(),
7191
- amountToTransfer: (0, import_math21.bn)(amount),
7192
- assetId: assetIdToTransfer
7193
- });
7257
+ return this.batchTransferToContracts([{ amount, assetId, contractId }], txParams);
7258
+ }
7259
+ async batchTransferToContracts(contractTransferParams, txParams = {}) {
7194
7260
  let request = new ScriptTransactionRequest({
7195
- ...txParams,
7196
- script,
7197
- scriptData
7198
- });
7199
- request.addContractInputAndOutput(contractAddress);
7200
- const txCost = await this.getTransactionCost(request, {
7201
- quantities: [{ amount: (0, import_math21.bn)(amount), assetId: String(assetIdToTransfer) }]
7261
+ ...txParams
7202
7262
  });
7203
- request = this.validateGasLimitAndMaxFee({
7204
- transactionRequest: request,
7205
- gasUsed: txCost.gasUsed,
7206
- maxFee: txCost.maxFee,
7207
- txParams
7263
+ const quantities = [];
7264
+ const transferParams = contractTransferParams.map((transferParam) => {
7265
+ const amount = (0, import_math20.bn)(transferParam.amount);
7266
+ const contractAddress = import_address5.Address.fromAddressOrString(transferParam.contractId);
7267
+ const assetId = transferParam.assetId ? (0, import_utils34.hexlify)(transferParam.assetId) : this.provider.getBaseAssetId();
7268
+ if (amount.lte(0)) {
7269
+ throw new import_errors20.FuelError(
7270
+ import_errors20.ErrorCode.INVALID_TRANSFER_AMOUNT,
7271
+ "Transfer amount must be a positive number."
7272
+ );
7273
+ }
7274
+ request.addContractInputAndOutput(contractAddress);
7275
+ quantities.push({ amount, assetId });
7276
+ return {
7277
+ amount,
7278
+ contractId: contractAddress.toB256(),
7279
+ assetId
7280
+ };
7208
7281
  });
7209
- await this.fund(request, txCost);
7282
+ const { script, scriptData } = await assembleTransferToContractScript(transferParams);
7283
+ request.script = script;
7284
+ request.scriptData = scriptData;
7285
+ request = await this.estimateAndFundTransaction(request, txParams, { quantities });
7210
7286
  return this.sendTransaction(request);
7211
7287
  }
7212
7288
  /**
@@ -7218,12 +7294,12 @@ var Account = class extends import_interfaces.AbstractAccount {
7218
7294
  * @returns A promise that resolves to the transaction response.
7219
7295
  */
7220
7296
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
7221
- const recipientAddress = import_address4.Address.fromAddressOrString(recipient);
7297
+ const recipientAddress = import_address5.Address.fromAddressOrString(recipient);
7222
7298
  const recipientDataArray = (0, import_utils34.arrayify)(
7223
7299
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
7224
7300
  );
7225
7301
  const amountDataArray = (0, import_utils34.arrayify)(
7226
- "0x".concat((0, import_math21.bn)(amount).toHex().substring(2).padStart(16, "0"))
7302
+ "0x".concat((0, import_math20.bn)(amount).toHex().substring(2).padStart(16, "0"))
7227
7303
  );
7228
7304
  const script = new Uint8Array([
7229
7305
  ...(0, import_utils34.arrayify)(withdrawScript.bytes),
@@ -7233,7 +7309,7 @@ var Account = class extends import_interfaces.AbstractAccount {
7233
7309
  const params = { script, ...txParams };
7234
7310
  const baseAssetId = this.provider.getBaseAssetId();
7235
7311
  let request = new ScriptTransactionRequest(params);
7236
- const quantities = [{ amount: (0, import_math21.bn)(amount), assetId: baseAssetId }];
7312
+ const quantities = [{ amount: (0, import_math20.bn)(amount), assetId: baseAssetId }];
7237
7313
  const txCost = await this.getTransactionCost(request, { quantities });
7238
7314
  request = this.validateGasLimitAndMaxFee({
7239
7315
  transactionRequest: request,
@@ -7259,7 +7335,7 @@ var Account = class extends import_interfaces.AbstractAccount {
7259
7335
  const baseAssetId = this.provider.getBaseAssetId();
7260
7336
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
7261
7337
  const requiredQuantities = mergeQuantities(coinOutputsQuantities, quantities);
7262
- const transactionFeeForDryRun = [{ assetId: baseAssetId, amount: (0, import_math21.bn)("100000000000000000") }];
7338
+ const transactionFeeForDryRun = [{ assetId: baseAssetId, amount: (0, import_math20.bn)("100000000000000000") }];
7263
7339
  const findAssetInput = (assetId) => txRequestClone.inputs.find((input) => {
7264
7340
  if (input.type === import_transactions24.InputType.Coin) {
7265
7341
  return input.assetId === assetId;
@@ -7306,7 +7382,7 @@ var Account = class extends import_interfaces.AbstractAccount {
7306
7382
  */
7307
7383
  async signMessage(message) {
7308
7384
  if (!this._connector) {
7309
- throw new import_errors19.FuelError(import_errors19.ErrorCode.MISSING_CONNECTOR, "A connector is required to sign messages.");
7385
+ throw new import_errors20.FuelError(import_errors20.ErrorCode.MISSING_CONNECTOR, "A connector is required to sign messages.");
7310
7386
  }
7311
7387
  return this._connector.signMessage(this.address.toString(), message);
7312
7388
  }
@@ -7318,8 +7394,8 @@ var Account = class extends import_interfaces.AbstractAccount {
7318
7394
  */
7319
7395
  async signTransaction(transactionRequestLike) {
7320
7396
  if (!this._connector) {
7321
- throw new import_errors19.FuelError(
7322
- import_errors19.ErrorCode.MISSING_CONNECTOR,
7397
+ throw new import_errors20.FuelError(
7398
+ import_errors20.ErrorCode.MISSING_CONNECTOR,
7323
7399
  "A connector is required to sign transactions."
7324
7400
  );
7325
7401
  }
@@ -7370,24 +7446,24 @@ var Account = class extends import_interfaces.AbstractAccount {
7370
7446
  return coins.map((coin) => ({
7371
7447
  id: (0, import_utils34.hexlify)((0, import_crypto2.randomBytes)(import_abi_coder7.UTXO_ID_LEN)),
7372
7448
  owner: this.address,
7373
- blockCreated: (0, import_math21.bn)(1),
7374
- txCreatedIdx: (0, import_math21.bn)(1),
7449
+ blockCreated: (0, import_math20.bn)(1),
7450
+ txCreatedIdx: (0, import_math20.bn)(1),
7375
7451
  ...coin
7376
7452
  }));
7377
7453
  }
7378
7454
  /** @hidden * */
7379
7455
  validateTransferAmount(amount) {
7380
- if ((0, import_math21.bn)(amount).lte(0)) {
7381
- throw new import_errors19.FuelError(
7382
- import_errors19.ErrorCode.INVALID_TRANSFER_AMOUNT,
7456
+ if ((0, import_math20.bn)(amount).lte(0)) {
7457
+ throw new import_errors20.FuelError(
7458
+ import_errors20.ErrorCode.INVALID_TRANSFER_AMOUNT,
7383
7459
  "Transfer amount must be a positive number."
7384
7460
  );
7385
7461
  }
7386
7462
  }
7387
7463
  /** @hidden * */
7388
- async estimateAndFundTransaction(transactionRequest, txParams) {
7464
+ async estimateAndFundTransaction(transactionRequest, txParams, costParams) {
7389
7465
  let request = transactionRequest;
7390
- const txCost = await this.getTransactionCost(request);
7466
+ const txCost = await this.getTransactionCost(request, costParams);
7391
7467
  request = this.validateGasLimitAndMaxFee({
7392
7468
  transactionRequest: request,
7393
7469
  gasUsed: txCost.gasUsed,
@@ -7408,16 +7484,16 @@ var Account = class extends import_interfaces.AbstractAccount {
7408
7484
  if (!(0, import_utils34.isDefined)(setGasLimit)) {
7409
7485
  request.gasLimit = gasUsed;
7410
7486
  } else if (gasUsed.gt(setGasLimit)) {
7411
- throw new import_errors19.FuelError(
7412
- import_errors19.ErrorCode.GAS_LIMIT_TOO_LOW,
7487
+ throw new import_errors20.FuelError(
7488
+ import_errors20.ErrorCode.GAS_LIMIT_TOO_LOW,
7413
7489
  `Gas limit '${setGasLimit}' is lower than the required: '${gasUsed}'.`
7414
7490
  );
7415
7491
  }
7416
7492
  if (!(0, import_utils34.isDefined)(setMaxFee)) {
7417
7493
  request.maxFee = maxFee;
7418
7494
  } else if (maxFee.gt(setMaxFee)) {
7419
- throw new import_errors19.FuelError(
7420
- import_errors19.ErrorCode.MAX_FEE_TOO_LOW,
7495
+ throw new import_errors20.FuelError(
7496
+ import_errors20.ErrorCode.MAX_FEE_TOO_LOW,
7421
7497
  `Max fee '${setMaxFee}' is lower than the required: '${maxFee}'.`
7422
7498
  );
7423
7499
  }
@@ -7430,10 +7506,10 @@ var import_hasher4 = require("@fuel-ts/hasher");
7430
7506
  var import_utils37 = require("@fuel-ts/utils");
7431
7507
 
7432
7508
  // src/signer/signer.ts
7433
- var import_address5 = require("@fuel-ts/address");
7509
+ var import_address6 = require("@fuel-ts/address");
7434
7510
  var import_crypto3 = require("@fuel-ts/crypto");
7435
7511
  var import_hasher3 = require("@fuel-ts/hasher");
7436
- var import_math22 = require("@fuel-ts/math");
7512
+ var import_math21 = require("@fuel-ts/math");
7437
7513
  var import_utils35 = require("@fuel-ts/utils");
7438
7514
  var import_secp256k1 = require("@noble/curves/secp256k1");
7439
7515
  var Signer = class {
@@ -7453,11 +7529,11 @@ var Signer = class {
7453
7529
  privateKey = `0x${privateKey}`;
7454
7530
  }
7455
7531
  }
7456
- const privateKeyBytes = (0, import_math22.toBytes)(privateKey, 32);
7532
+ const privateKeyBytes = (0, import_math21.toBytes)(privateKey, 32);
7457
7533
  this.privateKey = (0, import_utils35.hexlify)(privateKeyBytes);
7458
7534
  this.publicKey = (0, import_utils35.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
7459
7535
  this.compressedPublicKey = (0, import_utils35.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
7460
- this.address = import_address5.Address.fromPublicKey(this.publicKey);
7536
+ this.address = import_address6.Address.fromPublicKey(this.publicKey);
7461
7537
  }
7462
7538
  /**
7463
7539
  * Sign data using the Signer instance
@@ -7471,8 +7547,8 @@ var Signer = class {
7471
7547
  */
7472
7548
  sign(data) {
7473
7549
  const signature = import_secp256k1.secp256k1.sign((0, import_utils35.arrayify)(data), (0, import_utils35.arrayify)(this.privateKey));
7474
- const r = (0, import_math22.toBytes)(`0x${signature.r.toString(16)}`, 32);
7475
- const s = (0, import_math22.toBytes)(`0x${signature.s.toString(16)}`, 32);
7550
+ const r = (0, import_math21.toBytes)(`0x${signature.r.toString(16)}`, 32);
7551
+ const s = (0, import_math21.toBytes)(`0x${signature.s.toString(16)}`, 32);
7476
7552
  s[0] |= (signature.recovery || 0) << 7;
7477
7553
  return (0, import_utils35.hexlify)((0, import_utils35.concat)([r, s]));
7478
7554
  }
@@ -7515,7 +7591,7 @@ var Signer = class {
7515
7591
  * @returns Address from signature
7516
7592
  */
7517
7593
  static recoverAddress(data, signature) {
7518
- return import_address5.Address.fromPublicKey(Signer.recoverPublicKey(data, signature));
7594
+ return import_address6.Address.fromPublicKey(Signer.recoverPublicKey(data, signature));
7519
7595
  }
7520
7596
  /**
7521
7597
  * Generate a random privateKey
@@ -7539,9 +7615,9 @@ var Signer = class {
7539
7615
  };
7540
7616
 
7541
7617
  // src/wallet/keystore-wallet.ts
7542
- var import_address6 = require("@fuel-ts/address");
7618
+ var import_address7 = require("@fuel-ts/address");
7543
7619
  var import_crypto4 = require("@fuel-ts/crypto");
7544
- var import_errors20 = require("@fuel-ts/errors");
7620
+ var import_errors21 = require("@fuel-ts/errors");
7545
7621
  var import_utils36 = require("@fuel-ts/utils");
7546
7622
  var DEFAULT_KDF_PARAMS_LOG_N = 13;
7547
7623
  var DEFAULT_KDF_PARAMS_R = 8;
@@ -7556,7 +7632,7 @@ var removeHexPrefix = (hexString) => {
7556
7632
  };
7557
7633
  async function encryptKeystoreWallet(privateKey, address, password) {
7558
7634
  const privateKeyBuffer = (0, import_crypto4.bufferFromString)(removeHexPrefix(privateKey), "hex");
7559
- const ownerAddress = import_address6.Address.fromAddressOrString(address);
7635
+ const ownerAddress = import_address7.Address.fromAddressOrString(address);
7560
7636
  const salt = (0, import_crypto4.randomBytes)(DEFAULT_KEY_SIZE);
7561
7637
  const key = (0, import_crypto4.scrypt)({
7562
7638
  password: (0, import_crypto4.bufferFromString)(password),
@@ -7618,8 +7694,8 @@ async function decryptKeystoreWallet(jsonWallet, password) {
7618
7694
  const macHashUint8Array = (0, import_crypto4.keccak256)(data);
7619
7695
  const macHash = (0, import_crypto4.stringFromBuffer)(macHashUint8Array, "hex");
7620
7696
  if (mac !== macHash) {
7621
- throw new import_errors20.FuelError(
7622
- import_errors20.ErrorCode.INVALID_PASSWORD,
7697
+ throw new import_errors21.FuelError(
7698
+ import_errors21.ErrorCode.INVALID_PASSWORD,
7623
7699
  "Failed to decrypt the keystore wallet, the provided password is incorrect."
7624
7700
  );
7625
7701
  }
@@ -7749,14 +7825,14 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
7749
7825
 
7750
7826
  // src/hdwallet/hdwallet.ts
7751
7827
  var import_crypto6 = require("@fuel-ts/crypto");
7752
- var import_errors23 = require("@fuel-ts/errors");
7828
+ var import_errors24 = require("@fuel-ts/errors");
7753
7829
  var import_hasher7 = require("@fuel-ts/hasher");
7754
- var import_math23 = require("@fuel-ts/math");
7830
+ var import_math22 = require("@fuel-ts/math");
7755
7831
  var import_utils41 = require("@fuel-ts/utils");
7756
7832
 
7757
7833
  // src/mnemonic/mnemonic.ts
7758
7834
  var import_crypto5 = require("@fuel-ts/crypto");
7759
- var import_errors22 = require("@fuel-ts/errors");
7835
+ var import_errors23 = require("@fuel-ts/errors");
7760
7836
  var import_hasher6 = require("@fuel-ts/hasher");
7761
7837
  var import_utils39 = require("@fuel-ts/utils");
7762
7838
 
@@ -9819,7 +9895,7 @@ var Language = /* @__PURE__ */ ((Language2) => {
9819
9895
  })(Language || {});
9820
9896
 
9821
9897
  // src/mnemonic/utils.ts
9822
- var import_errors21 = require("@fuel-ts/errors");
9898
+ var import_errors22 = require("@fuel-ts/errors");
9823
9899
  var import_hasher5 = require("@fuel-ts/hasher");
9824
9900
  var import_utils38 = require("@fuel-ts/utils");
9825
9901
  function getLowerMask(bits) {
@@ -9868,8 +9944,8 @@ function mnemonicWordsToEntropy(words, wordlist) {
9868
9944
  for (let i = 0; i < words.length; i += 1) {
9869
9945
  const index = wordlist.indexOf(words[i].normalize("NFKD"));
9870
9946
  if (index === -1) {
9871
- throw new import_errors21.FuelError(
9872
- import_errors21.ErrorCode.INVALID_MNEMONIC,
9947
+ throw new import_errors22.FuelError(
9948
+ import_errors22.ErrorCode.INVALID_MNEMONIC,
9873
9949
  `Invalid mnemonic: the word '${words[i]}' is not found in the provided wordlist.`
9874
9950
  );
9875
9951
  }
@@ -9885,8 +9961,8 @@ function mnemonicWordsToEntropy(words, wordlist) {
9885
9961
  const checksumMask = getUpperMask(checksumBits);
9886
9962
  const checksum = (0, import_utils38.arrayify)((0, import_hasher5.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
9887
9963
  if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
9888
- throw new import_errors21.FuelError(
9889
- import_errors21.ErrorCode.INVALID_CHECKSUM,
9964
+ throw new import_errors22.FuelError(
9965
+ import_errors22.ErrorCode.INVALID_CHECKSUM,
9890
9966
  "Checksum validation failed for the provided mnemonic."
9891
9967
  );
9892
9968
  }
@@ -9900,16 +9976,16 @@ var TestnetPRV = "0x04358394";
9900
9976
  var MNEMONIC_SIZES = [12, 15, 18, 21, 24];
9901
9977
  function assertWordList(wordlist) {
9902
9978
  if (wordlist.length !== 2048) {
9903
- throw new import_errors22.FuelError(
9904
- import_errors22.ErrorCode.INVALID_WORD_LIST,
9979
+ throw new import_errors23.FuelError(
9980
+ import_errors23.ErrorCode.INVALID_WORD_LIST,
9905
9981
  `Expected word list length of 2048, but got ${wordlist.length}.`
9906
9982
  );
9907
9983
  }
9908
9984
  }
9909
9985
  function assertEntropy(entropy) {
9910
9986
  if (entropy.length % 4 !== 0 || entropy.length < 16 || entropy.length > 32) {
9911
- throw new import_errors22.FuelError(
9912
- import_errors22.ErrorCode.INVALID_ENTROPY,
9987
+ throw new import_errors23.FuelError(
9988
+ import_errors23.ErrorCode.INVALID_ENTROPY,
9913
9989
  `Entropy should be between 16 and 32 bytes and a multiple of 4, but got ${entropy.length} bytes.`
9914
9990
  );
9915
9991
  }
@@ -9919,7 +9995,7 @@ function assertMnemonic(words) {
9919
9995
  const errorMsg = `Invalid mnemonic size. Expected one of [${MNEMONIC_SIZES.join(
9920
9996
  ", "
9921
9997
  )}] words, but got ${words.length}.`;
9922
- throw new import_errors22.FuelError(import_errors22.ErrorCode.INVALID_MNEMONIC, errorMsg);
9998
+ throw new import_errors23.FuelError(import_errors23.ErrorCode.INVALID_MNEMONIC, errorMsg);
9923
9999
  }
9924
10000
  }
9925
10001
  var Mnemonic = class {
@@ -10037,8 +10113,8 @@ var Mnemonic = class {
10037
10113
  static masterKeysFromSeed(seed) {
10038
10114
  const seedArray = (0, import_utils39.arrayify)(seed);
10039
10115
  if (seedArray.length < 16 || seedArray.length > 64) {
10040
- throw new import_errors22.FuelError(
10041
- import_errors22.ErrorCode.INVALID_SEED,
10116
+ throw new import_errors23.FuelError(
10117
+ import_errors23.ErrorCode.INVALID_SEED,
10042
10118
  `Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
10043
10119
  );
10044
10120
  }
@@ -10115,7 +10191,7 @@ function isValidExtendedKey(extendedKey) {
10115
10191
  function parsePath(path, depth = 0) {
10116
10192
  const components = path.split("/");
10117
10193
  if (components.length === 0 || components[0] === "m" && depth !== 0) {
10118
- throw new import_errors23.FuelError(import_errors23.ErrorCode.HD_WALLET_ERROR, `invalid path - ${path}`);
10194
+ throw new import_errors24.FuelError(import_errors24.ErrorCode.HD_WALLET_ERROR, `invalid path - ${path}`);
10119
10195
  }
10120
10196
  if (components[0] === "m") {
10121
10197
  components.shift();
@@ -10144,8 +10220,8 @@ var HDWallet = class {
10144
10220
  this.privateKey = (0, import_utils41.hexlify)(config.privateKey);
10145
10221
  } else {
10146
10222
  if (!config.publicKey) {
10147
- throw new import_errors23.FuelError(
10148
- import_errors23.ErrorCode.HD_WALLET_ERROR,
10223
+ throw new import_errors24.FuelError(
10224
+ import_errors24.ErrorCode.HD_WALLET_ERROR,
10149
10225
  "Both public and private Key cannot be missing. At least one should be provided."
10150
10226
  );
10151
10227
  }
@@ -10174,8 +10250,8 @@ var HDWallet = class {
10174
10250
  const data = new Uint8Array(37);
10175
10251
  if (index & HARDENED_INDEX) {
10176
10252
  if (!privateKey) {
10177
- throw new import_errors23.FuelError(
10178
- import_errors23.ErrorCode.HD_WALLET_ERROR,
10253
+ throw new import_errors24.FuelError(
10254
+ import_errors24.ErrorCode.HD_WALLET_ERROR,
10179
10255
  "Cannot derive a hardened index without a private Key."
10180
10256
  );
10181
10257
  }
@@ -10183,13 +10259,13 @@ var HDWallet = class {
10183
10259
  } else {
10184
10260
  data.set((0, import_utils41.arrayify)(this.publicKey));
10185
10261
  }
10186
- data.set((0, import_math23.toBytes)(index, 4), 33);
10262
+ data.set((0, import_math22.toBytes)(index, 4), 33);
10187
10263
  const bytes = (0, import_utils41.arrayify)((0, import_crypto6.computeHmac)("sha512", chainCode, data));
10188
10264
  const IL = bytes.slice(0, 32);
10189
10265
  const IR = bytes.slice(32);
10190
10266
  if (privateKey) {
10191
10267
  const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
10192
- const ki = (0, import_math23.bn)(IL).add(privateKey).mod(N).toBytes(32);
10268
+ const ki = (0, import_math22.bn)(IL).add(privateKey).mod(N).toBytes(32);
10193
10269
  return new HDWallet({
10194
10270
  privateKey: ki,
10195
10271
  chainCode: IR,
@@ -10227,15 +10303,15 @@ var HDWallet = class {
10227
10303
  */
10228
10304
  toExtendedKey(isPublic = false, testnet = false) {
10229
10305
  if (this.depth >= 256) {
10230
- throw new import_errors23.FuelError(
10231
- import_errors23.ErrorCode.HD_WALLET_ERROR,
10306
+ throw new import_errors24.FuelError(
10307
+ import_errors24.ErrorCode.HD_WALLET_ERROR,
10232
10308
  `Exceeded max depth of 255. Current depth: ${this.depth}.`
10233
10309
  );
10234
10310
  }
10235
10311
  const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
10236
10312
  const depth = (0, import_utils41.hexlify)(Uint8Array.from([this.depth]));
10237
10313
  const parentFingerprint = this.parentFingerprint;
10238
- const index = (0, import_math23.toHex)(this.index, 4);
10314
+ const index = (0, import_math22.toHex)(this.index, 4);
10239
10315
  const chainCode = this.chainCode;
10240
10316
  const key = this.privateKey != null && !isPublic ? (0, import_utils41.concat)(["0x00", this.privateKey]) : this.publicKey;
10241
10317
  const extendedKey = (0, import_utils41.arrayify)((0, import_utils41.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
@@ -10255,14 +10331,14 @@ var HDWallet = class {
10255
10331
  });
10256
10332
  }
10257
10333
  static fromExtendedKey(extendedKey) {
10258
- const decoded = (0, import_utils41.hexlify)((0, import_math23.toBytes)((0, import_utils41.decodeBase58)(extendedKey)));
10334
+ const decoded = (0, import_utils41.hexlify)((0, import_math22.toBytes)((0, import_utils41.decodeBase58)(extendedKey)));
10259
10335
  const bytes = (0, import_utils41.arrayify)(decoded);
10260
10336
  const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
10261
10337
  if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
10262
- throw new import_errors23.FuelError(import_errors23.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
10338
+ throw new import_errors24.FuelError(import_errors24.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
10263
10339
  }
10264
10340
  if (!validChecksum) {
10265
- throw new import_errors23.FuelError(import_errors23.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
10341
+ throw new import_errors24.FuelError(import_errors24.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
10266
10342
  }
10267
10343
  const depth = bytes[4];
10268
10344
  const parentFingerprint = (0, import_utils41.hexlify)(bytes.slice(5, 9));
@@ -10270,14 +10346,14 @@ var HDWallet = class {
10270
10346
  const chainCode = (0, import_utils41.hexlify)(bytes.slice(13, 45));
10271
10347
  const key = bytes.slice(45, 78);
10272
10348
  if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
10273
- throw new import_errors23.FuelError(
10274
- import_errors23.ErrorCode.HD_WALLET_ERROR,
10349
+ throw new import_errors24.FuelError(
10350
+ import_errors24.ErrorCode.HD_WALLET_ERROR,
10275
10351
  "Inconsistency detected: Depth is zero but fingerprint/index is non-zero."
10276
10352
  );
10277
10353
  }
10278
10354
  if (isPublicExtendedKey(bytes)) {
10279
10355
  if (key[0] !== 3) {
10280
- throw new import_errors23.FuelError(import_errors23.ErrorCode.HD_WALLET_ERROR, "Invalid public extended key.");
10356
+ throw new import_errors24.FuelError(import_errors24.ErrorCode.HD_WALLET_ERROR, "Invalid public extended key.");
10281
10357
  }
10282
10358
  return new HDWallet({
10283
10359
  publicKey: key,
@@ -10288,7 +10364,7 @@ var HDWallet = class {
10288
10364
  });
10289
10365
  }
10290
10366
  if (key[0] !== 0) {
10291
- throw new import_errors23.FuelError(import_errors23.ErrorCode.HD_WALLET_ERROR, "Invalid private extended key.");
10367
+ throw new import_errors24.FuelError(import_errors24.ErrorCode.HD_WALLET_ERROR, "Invalid private extended key.");
10292
10368
  }
10293
10369
  return new HDWallet({
10294
10370
  privateKey: key.slice(1),
@@ -10454,9 +10530,9 @@ __publicField(Wallet, "fromExtendedKey", WalletUnlocked.fromExtendedKey);
10454
10530
  __publicField(Wallet, "fromEncryptedJson", WalletUnlocked.fromEncryptedJson);
10455
10531
 
10456
10532
  // src/wallet-manager/wallet-manager.ts
10457
- var import_address9 = require("@fuel-ts/address");
10533
+ var import_address10 = require("@fuel-ts/address");
10458
10534
  var import_crypto7 = require("@fuel-ts/crypto");
10459
- var import_errors26 = require("@fuel-ts/errors");
10535
+ var import_errors27 = require("@fuel-ts/errors");
10460
10536
  var import_events = require("events");
10461
10537
 
10462
10538
  // src/wallet-manager/storages/memory-storage.ts
@@ -10478,8 +10554,8 @@ var MemoryStorage = class {
10478
10554
  };
10479
10555
 
10480
10556
  // src/wallet-manager/vaults/mnemonic-vault.ts
10481
- var import_address7 = require("@fuel-ts/address");
10482
- var import_errors24 = require("@fuel-ts/errors");
10557
+ var import_address8 = require("@fuel-ts/address");
10558
+ var import_errors25 = require("@fuel-ts/errors");
10483
10559
  var _secret;
10484
10560
  var MnemonicVault = class {
10485
10561
  constructor(options) {
@@ -10527,7 +10603,7 @@ var MnemonicVault = class {
10527
10603
  }
10528
10604
  exportAccount(address) {
10529
10605
  let numberOfAccounts = 0;
10530
- const ownerAddress = import_address7.Address.fromAddressOrString(address);
10606
+ const ownerAddress = import_address8.Address.fromAddressOrString(address);
10531
10607
  do {
10532
10608
  const wallet = Wallet.fromMnemonic(__privateGet(this, _secret), this.getDerivePath(numberOfAccounts));
10533
10609
  if (wallet.address.equals(ownerAddress)) {
@@ -10535,8 +10611,8 @@ var MnemonicVault = class {
10535
10611
  }
10536
10612
  numberOfAccounts += 1;
10537
10613
  } while (numberOfAccounts < this.numberOfAccounts);
10538
- throw new import_errors24.FuelError(
10539
- import_errors24.ErrorCode.WALLET_MANAGER_ERROR,
10614
+ throw new import_errors25.FuelError(
10615
+ import_errors25.ErrorCode.WALLET_MANAGER_ERROR,
10540
10616
  `Account with address '${address}' not found in derived wallets.`
10541
10617
  );
10542
10618
  }
@@ -10549,8 +10625,8 @@ _secret = new WeakMap();
10549
10625
  __publicField(MnemonicVault, "type", "mnemonic");
10550
10626
 
10551
10627
  // src/wallet-manager/vaults/privatekey-vault.ts
10552
- var import_address8 = require("@fuel-ts/address");
10553
- var import_errors25 = require("@fuel-ts/errors");
10628
+ var import_address9 = require("@fuel-ts/address");
10629
+ var import_errors26 = require("@fuel-ts/errors");
10554
10630
  var _privateKeys;
10555
10631
  var PrivateKeyVault = class {
10556
10632
  /**
@@ -10586,13 +10662,13 @@ var PrivateKeyVault = class {
10586
10662
  return this.getPublicAccount(wallet.privateKey);
10587
10663
  }
10588
10664
  exportAccount(address) {
10589
- const ownerAddress = import_address8.Address.fromAddressOrString(address);
10665
+ const ownerAddress = import_address9.Address.fromAddressOrString(address);
10590
10666
  const privateKey = __privateGet(this, _privateKeys).find(
10591
10667
  (pk) => Wallet.fromPrivateKey(pk).address.equals(ownerAddress)
10592
10668
  );
10593
10669
  if (!privateKey) {
10594
- throw new import_errors25.FuelError(
10595
- import_errors25.ErrorCode.WALLET_MANAGER_ERROR,
10670
+ throw new import_errors26.FuelError(
10671
+ import_errors26.ErrorCode.WALLET_MANAGER_ERROR,
10596
10672
  `No private key found for address '${address}'.`
10597
10673
  );
10598
10674
  }
@@ -10616,7 +10692,7 @@ var ERROR_MESSAGES = {
10616
10692
  };
10617
10693
  function assert(condition, message) {
10618
10694
  if (!condition) {
10619
- throw new import_errors26.FuelError(import_errors26.ErrorCode.WALLET_MANAGER_ERROR, message);
10695
+ throw new import_errors27.FuelError(import_errors27.ErrorCode.WALLET_MANAGER_ERROR, message);
10620
10696
  }
10621
10697
  }
10622
10698
  var _vaults, _passphrase, _isLocked, _serializeVaults, serializeVaults_fn, _deserializeVaults, deserializeVaults_fn;
@@ -10684,7 +10760,7 @@ var _WalletManager = class extends import_events.EventEmitter {
10684
10760
  * Create a Wallet instance for the specific account
10685
10761
  */
10686
10762
  getWallet(address) {
10687
- const ownerAddress = import_address9.Address.fromAddressOrString(address);
10763
+ const ownerAddress = import_address10.Address.fromAddressOrString(address);
10688
10764
  const vaultState = __privateGet(this, _vaults).find(
10689
10765
  (vs) => vs.vault.getAccounts().find((a) => a.address.equals(ownerAddress))
10690
10766
  );
@@ -10695,7 +10771,7 @@ var _WalletManager = class extends import_events.EventEmitter {
10695
10771
  * Export specific account privateKey
10696
10772
  */
10697
10773
  exportPrivateKey(address) {
10698
- const ownerAddress = import_address9.Address.fromAddressOrString(address);
10774
+ const ownerAddress = import_address10.Address.fromAddressOrString(address);
10699
10775
  assert(!__privateGet(this, _isLocked), ERROR_MESSAGES.wallet_not_unlocked);
10700
10776
  const vaultState = __privateGet(this, _vaults).find(
10701
10777
  (vs) => vs.vault.getAccounts().find((a) => a.address.equals(ownerAddress))
@@ -10842,25 +10918,25 @@ deserializeVaults_fn = function(vaults) {
10842
10918
  __publicField(WalletManager, "Vaults", [MnemonicVault, PrivateKeyVault]);
10843
10919
 
10844
10920
  // src/wallet-manager/types.ts
10845
- var import_errors27 = require("@fuel-ts/errors");
10921
+ var import_errors28 = require("@fuel-ts/errors");
10846
10922
  var Vault = class {
10847
10923
  constructor(_options) {
10848
- throw new import_errors27.FuelError(import_errors27.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
10924
+ throw new import_errors28.FuelError(import_errors28.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
10849
10925
  }
10850
10926
  serialize() {
10851
- throw new import_errors27.FuelError(import_errors27.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
10927
+ throw new import_errors28.FuelError(import_errors28.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
10852
10928
  }
10853
10929
  getAccounts() {
10854
- throw new import_errors27.FuelError(import_errors27.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
10930
+ throw new import_errors28.FuelError(import_errors28.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
10855
10931
  }
10856
10932
  addAccount() {
10857
- throw new import_errors27.FuelError(import_errors27.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
10933
+ throw new import_errors28.FuelError(import_errors28.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
10858
10934
  }
10859
10935
  exportAccount(_address) {
10860
- throw new import_errors27.FuelError(import_errors27.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
10936
+ throw new import_errors28.FuelError(import_errors28.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
10861
10937
  }
10862
10938
  getWallet(_address) {
10863
- throw new import_errors27.FuelError(import_errors27.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
10939
+ throw new import_errors28.FuelError(import_errors28.ErrorCode.NOT_IMPLEMENTED, "Not implemented.");
10864
10940
  }
10865
10941
  };
10866
10942
  __publicField(Vault, "type");
@@ -10869,35 +10945,237 @@ var StorageAbstract = class {
10869
10945
 
10870
10946
  // src/predicate/predicate.ts
10871
10947
  var import_abi_coder8 = require("@fuel-ts/abi-coder");
10872
- var import_address10 = require("@fuel-ts/address");
10873
- var import_errors28 = require("@fuel-ts/errors");
10948
+ var import_address11 = require("@fuel-ts/address");
10949
+ var import_errors30 = require("@fuel-ts/errors");
10950
+ var import_utils45 = require("@fuel-ts/utils");
10951
+
10952
+ // src/utils/deployScriptOrPredicate.ts
10953
+ var import_errors29 = require("@fuel-ts/errors");
10954
+ var import_hasher8 = require("@fuel-ts/hasher");
10955
+ var import_math23 = require("@fuel-ts/math");
10874
10956
  var import_utils43 = require("@fuel-ts/utils");
10875
10957
 
10958
+ // src/utils/predicate-script-loader-instructions.ts
10959
+ var import_utils42 = require("@fuel-ts/utils");
10960
+ var asm2 = __toESM(require("@fuels/vm-asm"));
10961
+ var BLOB_ID_SIZE = 32;
10962
+ var REG_ADDRESS_OF_DATA_AFTER_CODE = 16;
10963
+ var REG_START_OF_LOADED_CODE = 17;
10964
+ var REG_GENERAL_USE = 18;
10965
+ var WORD_SIZE2 = 8;
10966
+ function getDataOffset(binary) {
10967
+ const OFFSET_INDEX = 8;
10968
+ const dataView = new DataView(binary.buffer, OFFSET_INDEX, 8);
10969
+ const dataOffset = dataView.getBigUint64(0, false);
10970
+ return Number(dataOffset);
10971
+ }
10972
+ function getPredicateScriptLoaderInstructions(originalBinary, blobId) {
10973
+ const { RegId, Instruction } = asm2;
10974
+ const REG_PC = RegId.pc().to_u8();
10975
+ const REG_SP = RegId.sp().to_u8();
10976
+ const REG_IS = RegId.is().to_u8();
10977
+ const getInstructions = (numOfInstructions2) => [
10978
+ // 1. Load the blob content into memory
10979
+ // Find the start of the hardcoded blob ID, which is located after the loader code ends.
10980
+ asm2.move_(REG_ADDRESS_OF_DATA_AFTER_CODE, REG_PC),
10981
+ // hold the address of the blob ID.
10982
+ asm2.addi(
10983
+ REG_ADDRESS_OF_DATA_AFTER_CODE,
10984
+ REG_ADDRESS_OF_DATA_AFTER_CODE,
10985
+ numOfInstructions2 * Instruction.size()
10986
+ ),
10987
+ // The code is going to be loaded from the current value of SP onwards, save
10988
+ // the location into REG_START_OF_LOADED_CODE so we can jump into it at the end.
10989
+ asm2.move_(REG_START_OF_LOADED_CODE, REG_SP),
10990
+ // REG_GENERAL_USE to hold the size of the blob.
10991
+ asm2.bsiz(REG_GENERAL_USE, REG_ADDRESS_OF_DATA_AFTER_CODE),
10992
+ // Push the blob contents onto the stack.
10993
+ asm2.ldc(REG_ADDRESS_OF_DATA_AFTER_CODE, 0, REG_GENERAL_USE, 1),
10994
+ // Move on to the data section length
10995
+ asm2.addi(REG_ADDRESS_OF_DATA_AFTER_CODE, REG_ADDRESS_OF_DATA_AFTER_CODE, BLOB_ID_SIZE),
10996
+ // load the size of the data section into REG_GENERAL_USE
10997
+ asm2.lw(REG_GENERAL_USE, REG_ADDRESS_OF_DATA_AFTER_CODE, 0),
10998
+ // after we have read the length of the data section, we move the pointer to the actual
10999
+ // data by skipping WORD_SIZE bytes.
11000
+ asm2.addi(REG_ADDRESS_OF_DATA_AFTER_CODE, REG_ADDRESS_OF_DATA_AFTER_CODE, WORD_SIZE2),
11001
+ // load the data section of the executable
11002
+ asm2.ldc(REG_ADDRESS_OF_DATA_AFTER_CODE, 0, REG_GENERAL_USE, 2),
11003
+ // Jump into the memory where the contract is loaded.
11004
+ // What follows is called _jmp_mem by the sway compiler.
11005
+ // Subtract the address contained in IS because jmp will add it back.
11006
+ asm2.sub(REG_START_OF_LOADED_CODE, REG_START_OF_LOADED_CODE, REG_IS),
11007
+ // jmp will multiply by 4, so we need to divide to cancel that out.
11008
+ asm2.divi(REG_START_OF_LOADED_CODE, REG_START_OF_LOADED_CODE, 4),
11009
+ // Jump to the start of the contract we loaded.
11010
+ asm2.jmp(REG_START_OF_LOADED_CODE)
11011
+ ];
11012
+ const getInstructionsNoDataSection = (numOfInstructions2) => [
11013
+ // 1. Load the blob content into memory
11014
+ // Find the start of the hardcoded blob ID, which is located after the loader code ends.
11015
+ // 1. Load the blob content into memory
11016
+ // Find the start of the hardcoded blob ID, which is located after the loader code ends.
11017
+ asm2.move_(REG_ADDRESS_OF_DATA_AFTER_CODE, REG_PC),
11018
+ // hold the address of the blob ID.
11019
+ asm2.addi(
11020
+ REG_ADDRESS_OF_DATA_AFTER_CODE,
11021
+ REG_ADDRESS_OF_DATA_AFTER_CODE,
11022
+ numOfInstructions2 * Instruction.size()
11023
+ ),
11024
+ // The code is going to be loaded from the current value of SP onwards, save
11025
+ // the location into REG_START_OF_LOADED_CODE so we can jump into it at the end.
11026
+ asm2.move_(REG_START_OF_LOADED_CODE, REG_SP),
11027
+ // REG_GENERAL_USE to hold the size of the blob.
11028
+ asm2.bsiz(REG_GENERAL_USE, REG_ADDRESS_OF_DATA_AFTER_CODE),
11029
+ // Push the blob contents onto the stack.
11030
+ asm2.ldc(REG_ADDRESS_OF_DATA_AFTER_CODE, 0, REG_GENERAL_USE, 1),
11031
+ // Jump into the memory where the contract is loaded.
11032
+ // What follows is called _jmp_mem by the sway compiler.
11033
+ // Subtract the address contained in IS because jmp will add it back.
11034
+ asm2.sub(REG_START_OF_LOADED_CODE, REG_START_OF_LOADED_CODE, REG_IS),
11035
+ // jmp will multiply by 4, so we need to divide to cancel that out.
11036
+ asm2.divi(REG_START_OF_LOADED_CODE, REG_START_OF_LOADED_CODE, 4),
11037
+ // Jump to the start of the contract we loaded.
11038
+ asm2.jmp(REG_START_OF_LOADED_CODE)
11039
+ ];
11040
+ const offset = getDataOffset(originalBinary);
11041
+ if (originalBinary.length < offset) {
11042
+ throw new Error(
11043
+ `Data section offset is out of bounds, offset: ${offset}, binary length: ${originalBinary.length}`
11044
+ );
11045
+ }
11046
+ const dataSection = originalBinary.slice(offset);
11047
+ if (dataSection.length > 0) {
11048
+ const numOfInstructions2 = getInstructions(0).length;
11049
+ if (numOfInstructions2 > 65535) {
11050
+ throw new Error("Too many instructions, exceeding u16::MAX.");
11051
+ }
11052
+ const instructionBytes2 = new Uint8Array(
11053
+ getInstructions(numOfInstructions2).flatMap(
11054
+ (instruction) => Array.from(instruction.to_bytes())
11055
+ )
11056
+ );
11057
+ const blobBytes2 = new Uint8Array(blobId);
11058
+ const dataSectionLenBytes = new Uint8Array(8);
11059
+ const dataView = new DataView(dataSectionLenBytes.buffer);
11060
+ dataView.setBigUint64(0, BigInt(dataSection.length), false);
11061
+ const loaderBytecode2 = new Uint8Array([
11062
+ ...instructionBytes2,
11063
+ ...blobBytes2,
11064
+ ...dataSectionLenBytes
11065
+ ]);
11066
+ return {
11067
+ loaderBytecode: (0, import_utils42.concat)([loaderBytecode2, dataSection]),
11068
+ blobOffset: loaderBytecode2.length
11069
+ };
11070
+ }
11071
+ const numOfInstructions = getInstructionsNoDataSection(0).length;
11072
+ if (numOfInstructions > 65535) {
11073
+ throw new Error("Too many instructions, exceeding u16::MAX.");
11074
+ }
11075
+ const instructionBytes = new Uint8Array(
11076
+ getInstructionsNoDataSection(numOfInstructions).flatMap(
11077
+ (instruction) => Array.from(instruction.to_bytes())
11078
+ )
11079
+ );
11080
+ const blobBytes = new Uint8Array(blobId);
11081
+ const loaderBytecode = new Uint8Array([...instructionBytes, ...blobBytes]);
11082
+ return { loaderBytecode };
11083
+ }
11084
+
11085
+ // src/utils/deployScriptOrPredicate.ts
11086
+ async function fundBlobTx(deployer, blobTxRequest) {
11087
+ let totalCost = (0, import_math23.bn)(0);
11088
+ const chainInfo = deployer.provider.getChain();
11089
+ const gasPrice = await deployer.provider.estimateGasPrice(10);
11090
+ const priceFactor = chainInfo.consensusParameters.feeParameters.gasPriceFactor;
11091
+ const minGas = blobTxRequest.calculateMinGas(chainInfo);
11092
+ const minFee = calculateGasFee({
11093
+ gasPrice,
11094
+ gas: minGas,
11095
+ priceFactor,
11096
+ tip: blobTxRequest.tip
11097
+ }).add(1);
11098
+ totalCost = totalCost.add(minFee);
11099
+ if (totalCost.gt(await deployer.getBalance())) {
11100
+ throw new import_errors29.FuelError(import_errors29.ErrorCode.FUNDS_TOO_LOW, "Insufficient balance to deploy predicate.");
11101
+ }
11102
+ const txCost = await deployer.getTransactionCost(blobTxRequest);
11103
+ blobTxRequest.maxFee = txCost.maxFee;
11104
+ return deployer.fund(blobTxRequest, txCost);
11105
+ }
11106
+ function adjustConfigurableOffsets(jsonAbi, configurableOffsetDiff) {
11107
+ const { configurables: readOnlyConfigurables } = jsonAbi;
11108
+ const configurables = [];
11109
+ readOnlyConfigurables.forEach((config) => {
11110
+ configurables.push({ ...config, offset: config.offset - configurableOffsetDiff });
11111
+ });
11112
+ return { ...jsonAbi, configurables };
11113
+ }
11114
+ async function deployScriptOrPredicate({
11115
+ deployer,
11116
+ bytecode,
11117
+ abi,
11118
+ loaderInstanceCallback
11119
+ }) {
11120
+ const dataSectionOffset = getDataOffset((0, import_utils43.arrayify)(bytecode));
11121
+ const byteCodeWithoutDataSection = bytecode.slice(0, dataSectionOffset);
11122
+ const blobId = (0, import_hasher8.hash)(byteCodeWithoutDataSection);
11123
+ const blobTxRequest = new BlobTransactionRequest({
11124
+ blobId,
11125
+ witnessIndex: 0,
11126
+ witnesses: [byteCodeWithoutDataSection]
11127
+ });
11128
+ const { loaderBytecode, blobOffset } = getPredicateScriptLoaderInstructions(
11129
+ (0, import_utils43.arrayify)(bytecode),
11130
+ (0, import_utils43.arrayify)(blobId)
11131
+ );
11132
+ const configurableOffsetDiff = byteCodeWithoutDataSection.length - (blobOffset || 0);
11133
+ const newAbi = adjustConfigurableOffsets(abi, configurableOffsetDiff);
11134
+ const blobExists = (await deployer.provider.getBlobs([blobId])).length > 0;
11135
+ const loaderInstance = loaderInstanceCallback(loaderBytecode, newAbi);
11136
+ if (blobExists) {
11137
+ return {
11138
+ waitForResult: () => Promise.resolve(loaderInstance),
11139
+ blobId
11140
+ };
11141
+ }
11142
+ const fundedBlobRequest = await fundBlobTx(deployer, blobTxRequest);
11143
+ const waitForResult = async () => {
11144
+ try {
11145
+ const blobTx = await deployer.sendTransaction(fundedBlobRequest);
11146
+ const result = await blobTx.waitForResult();
11147
+ if (result.status !== "success" /* success */) {
11148
+ throw new Error();
11149
+ }
11150
+ } catch (err) {
11151
+ throw new import_errors29.FuelError(import_errors29.ErrorCode.TRANSACTION_FAILED, "Failed to deploy predicate chunk");
11152
+ }
11153
+ return loaderInstance;
11154
+ };
11155
+ return {
11156
+ waitForResult,
11157
+ blobId
11158
+ };
11159
+ }
11160
+
10876
11161
  // src/predicate/utils/getPredicateRoot.ts
10877
- var import_hasher8 = require("@fuel-ts/hasher");
11162
+ var import_hasher9 = require("@fuel-ts/hasher");
10878
11163
  var import_merkle = require("@fuel-ts/merkle");
10879
- var import_utils42 = require("@fuel-ts/utils");
11164
+ var import_utils44 = require("@fuel-ts/utils");
10880
11165
  var getPredicateRoot = (bytecode) => {
10881
11166
  const chunkSize = 16 * 1024;
10882
- const bytes = (0, import_utils42.arrayify)(bytecode);
10883
- const chunks = (0, import_utils42.chunkAndPadBytes)(bytes, chunkSize);
10884
- const codeRoot = (0, import_merkle.calcRoot)(chunks.map((c) => (0, import_utils42.hexlify)(c)));
10885
- const predicateRoot = (0, import_hasher8.hash)((0, import_utils42.concat)(["0x4655454C", codeRoot]));
11167
+ const bytes = (0, import_utils44.arrayify)(bytecode);
11168
+ const chunks = (0, import_utils44.chunkAndPadBytes)(bytes, chunkSize);
11169
+ const codeRoot = (0, import_merkle.calcRoot)(chunks.map((c) => (0, import_utils44.hexlify)(c)));
11170
+ const predicateRoot = (0, import_hasher9.hash)((0, import_utils44.concat)(["0x4655454C", codeRoot]));
10886
11171
  return predicateRoot;
10887
11172
  };
10888
11173
 
10889
11174
  // src/predicate/predicate.ts
10890
- function getDataOffset(binary) {
10891
- const buffer = binary.buffer.slice(binary.byteOffset + 8, binary.byteOffset + 16);
10892
- const dataView = new DataView(buffer);
10893
- const dataOffset = dataView.getBigUint64(0, false);
10894
- return Number(dataOffset);
10895
- }
10896
11175
  var Predicate = class extends Account {
10897
11176
  bytes;
10898
11177
  predicateData = [];
10899
11178
  interface;
10900
- loaderBytecode = "";
10901
11179
  /**
10902
11180
  * Creates an instance of the Predicate class.
10903
11181
  *
@@ -10912,24 +11190,17 @@ var Predicate = class extends Account {
10912
11190
  abi,
10913
11191
  provider,
10914
11192
  data,
10915
- configurableConstants,
10916
- /**
10917
- * TODO: Implement a getBytes method within the Predicate class. This method should return the loaderBytecode if it is set.
10918
- * The getBytes method should be used in all places where we use this.bytes.
10919
- * Note: Do not set loaderBytecode to a default string here; it should remain undefined when not provided.
10920
- */
10921
- loaderBytecode = ""
11193
+ configurableConstants
10922
11194
  }) {
10923
11195
  const { predicateBytes, predicateInterface } = Predicate.processPredicateData(
10924
11196
  bytecode,
10925
11197
  abi,
10926
11198
  configurableConstants
10927
11199
  );
10928
- const address = import_address10.Address.fromB256(getPredicateRoot(predicateBytes));
11200
+ const address = import_address11.Address.fromB256(getPredicateRoot(predicateBytes));
10929
11201
  super(address, provider);
10930
11202
  this.bytes = predicateBytes;
10931
11203
  this.interface = predicateInterface;
10932
- this.loaderBytecode = loaderBytecode;
10933
11204
  if (data !== void 0 && data.length > 0) {
10934
11205
  this.predicateData = data;
10935
11206
  }
@@ -10948,8 +11219,8 @@ var Predicate = class extends Account {
10948
11219
  }
10949
11220
  request.inputs.filter(isRequestInputCoinOrMessage).forEach((input) => {
10950
11221
  if (isRequestInputResourceFromOwner(input, this.address)) {
10951
- input.predicate = (0, import_utils43.hexlify)(this.bytes);
10952
- input.predicateData = (0, import_utils43.hexlify)(this.getPredicateData());
11222
+ input.predicate = (0, import_utils45.hexlify)(this.bytes);
11223
+ input.predicateData = (0, import_utils45.hexlify)(this.getPredicateData());
10953
11224
  input.witnessIndex = 0;
10954
11225
  }
10955
11226
  });
@@ -10991,16 +11262,13 @@ var Predicate = class extends Account {
10991
11262
  * @returns An object containing the new predicate bytes and interface.
10992
11263
  */
10993
11264
  static processPredicateData(bytes, jsonAbi, configurableConstants) {
10994
- let predicateBytes = (0, import_utils43.arrayify)(bytes);
10995
- let abiInterface;
10996
- if (jsonAbi) {
10997
- abiInterface = new import_abi_coder8.Interface(jsonAbi);
10998
- if (abiInterface.functions.main === void 0) {
10999
- throw new import_errors28.FuelError(
11000
- import_errors28.ErrorCode.ABI_MAIN_METHOD_MISSING,
11001
- 'Cannot use ABI without "main" function.'
11002
- );
11003
- }
11265
+ let predicateBytes = (0, import_utils45.arrayify)(bytes);
11266
+ const abiInterface = new import_abi_coder8.Interface(jsonAbi);
11267
+ if (abiInterface.functions.main === void 0) {
11268
+ throw new import_errors30.FuelError(
11269
+ import_errors30.ErrorCode.ABI_MAIN_METHOD_MISSING,
11270
+ 'Cannot use ABI without "main" function.'
11271
+ );
11004
11272
  }
11005
11273
  if (configurableConstants && Object.keys(configurableConstants).length) {
11006
11274
  predicateBytes = Predicate.setConfigurableConstants(
@@ -11029,8 +11297,8 @@ var Predicate = class extends Account {
11029
11297
  );
11030
11298
  return resources.map((resource) => ({
11031
11299
  ...resource,
11032
- predicate: (0, import_utils43.hexlify)(this.bytes),
11033
- predicateData: (0, import_utils43.hexlify)(this.getPredicateData())
11300
+ predicate: (0, import_utils45.hexlify)(this.bytes),
11301
+ predicateData: (0, import_utils45.hexlify)(this.getPredicateData())
11034
11302
  }));
11035
11303
  }
11036
11304
  /**
@@ -11042,8 +11310,8 @@ var Predicate = class extends Account {
11042
11310
  generateFakeResources(coins) {
11043
11311
  return super.generateFakeResources(coins).map((coin) => ({
11044
11312
  ...coin,
11045
- predicate: (0, import_utils43.hexlify)(this.bytes),
11046
- predicateData: (0, import_utils43.hexlify)(this.getPredicateData())
11313
+ predicate: (0, import_utils45.hexlify)(this.bytes),
11314
+ predicateData: (0, import_utils45.hexlify)(this.getPredicateData())
11047
11315
  }));
11048
11316
  }
11049
11317
  /**
@@ -11054,25 +11322,19 @@ var Predicate = class extends Account {
11054
11322
  * @param abiInterface - The ABI interface of the predicate.
11055
11323
  * @returns The mutated bytes with the configurable constants set.
11056
11324
  */
11057
- static setConfigurableConstants(bytes, configurableConstants, abiInterface, loaderBytecode) {
11325
+ static setConfigurableConstants(bytes, configurableConstants, abiInterface) {
11058
11326
  const mutatedBytes = bytes;
11059
11327
  try {
11060
- if (!abiInterface) {
11061
- throw new import_errors28.FuelError(
11062
- import_errors28.ErrorCode.INVALID_CONFIGURABLE_CONSTANTS,
11063
- "Cannot validate configurable constants because the Predicate was instantiated without a JSON ABI"
11064
- );
11065
- }
11066
11328
  if (Object.keys(abiInterface.configurables).length === 0) {
11067
- throw new import_errors28.FuelError(
11068
- import_errors28.ErrorCode.INVALID_CONFIGURABLE_CONSTANTS,
11329
+ throw new import_errors30.FuelError(
11330
+ import_errors30.ErrorCode.INVALID_CONFIGURABLE_CONSTANTS,
11069
11331
  "Predicate has no configurable constants to be set"
11070
11332
  );
11071
11333
  }
11072
11334
  Object.entries(configurableConstants).forEach(([key, value]) => {
11073
11335
  if (!abiInterface?.configurables[key]) {
11074
- throw new import_errors28.FuelError(
11075
- import_errors28.ErrorCode.CONFIGURABLE_NOT_FOUND,
11336
+ throw new import_errors30.FuelError(
11337
+ import_errors30.ErrorCode.CONFIGURABLE_NOT_FOUND,
11076
11338
  `No configurable constant named '${key}' found in the Predicate`
11077
11339
  );
11078
11340
  }
@@ -11080,18 +11342,9 @@ var Predicate = class extends Account {
11080
11342
  const encoded = abiInterface.encodeConfigurable(key, value);
11081
11343
  mutatedBytes.set(encoded, offset);
11082
11344
  });
11083
- if (loaderBytecode) {
11084
- const offset = getDataOffset(bytes);
11085
- const dataSection = mutatedBytes.slice(offset);
11086
- const dataSectionLen = dataSection.length;
11087
- const dataSectionLenBytes = new Uint8Array(8);
11088
- const dataSectionLenDataView = new DataView(dataSectionLenBytes.buffer);
11089
- dataSectionLenDataView.setBigUint64(0, BigInt(dataSectionLen), false);
11090
- mutatedBytes.set((0, import_utils43.concat)([loaderBytecode, dataSectionLenBytes, dataSection]));
11091
- }
11092
11345
  } catch (err) {
11093
- throw new import_errors28.FuelError(
11094
- import_errors28.ErrorCode.INVALID_CONFIGURABLE_CONSTANTS,
11346
+ throw new import_errors30.FuelError(
11347
+ import_errors30.ErrorCode.INVALID_CONFIGURABLE_CONSTANTS,
11095
11348
  `Error setting configurable constants: ${err.message}.`
11096
11349
  );
11097
11350
  }
@@ -11119,13 +11372,35 @@ var Predicate = class extends Account {
11119
11372
  }
11120
11373
  return index;
11121
11374
  }
11375
+ /**
11376
+ *
11377
+ * @param account - The account used to pay the deployment costs.
11378
+ * @returns The _blobId_ and a _waitForResult_ callback that returns the deployed predicate
11379
+ * once the blob deployment transaction finishes.
11380
+ *
11381
+ * The returned loader predicate will have the same configurable constants
11382
+ * as the original predicate which was used to generate the loader predicate.
11383
+ */
11384
+ async deploy(account) {
11385
+ return deployScriptOrPredicate({
11386
+ deployer: account,
11387
+ abi: this.interface.jsonAbi,
11388
+ bytecode: this.bytes,
11389
+ loaderInstanceCallback: (loaderBytecode, newAbi) => new Predicate({
11390
+ bytecode: loaderBytecode,
11391
+ abi: newAbi,
11392
+ provider: this.provider,
11393
+ data: this.predicateData
11394
+ })
11395
+ });
11396
+ }
11122
11397
  };
11123
11398
 
11124
11399
  // src/connectors/fuel.ts
11125
- var import_errors31 = require("@fuel-ts/errors");
11400
+ var import_errors33 = require("@fuel-ts/errors");
11126
11401
 
11127
11402
  // src/connectors/fuel-connector.ts
11128
- var import_errors29 = require("@fuel-ts/errors");
11403
+ var import_errors31 = require("@fuel-ts/errors");
11129
11404
  var import_events2 = require("events");
11130
11405
 
11131
11406
  // src/connectors/types/connector-types.ts
@@ -11200,7 +11475,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
11200
11475
  * @returns Always true.
11201
11476
  */
11202
11477
  async ping() {
11203
- throw new import_errors29.FuelError(import_errors29.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11478
+ throw new import_errors31.FuelError(import_errors31.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11204
11479
  }
11205
11480
  /**
11206
11481
  * Should return the current version of the connector
@@ -11209,7 +11484,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
11209
11484
  * @returns boolean - connection status.
11210
11485
  */
11211
11486
  async version() {
11212
- throw new import_errors29.FuelError(import_errors29.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11487
+ throw new import_errors31.FuelError(import_errors31.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11213
11488
  }
11214
11489
  /**
11215
11490
  * Should return true if the connector is connected
@@ -11218,7 +11493,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
11218
11493
  * @returns The connection status.
11219
11494
  */
11220
11495
  async isConnected() {
11221
- throw new import_errors29.FuelError(import_errors29.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11496
+ throw new import_errors31.FuelError(import_errors31.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11222
11497
  }
11223
11498
  /**
11224
11499
  * Should return all the accounts authorized for the
@@ -11227,7 +11502,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
11227
11502
  * @returns The accounts addresses strings
11228
11503
  */
11229
11504
  async accounts() {
11230
- throw new import_errors29.FuelError(import_errors29.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11505
+ throw new import_errors31.FuelError(import_errors31.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11231
11506
  }
11232
11507
  /**
11233
11508
  * Should start the connection process and return
@@ -11239,7 +11514,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
11239
11514
  * @returns boolean - connection status.
11240
11515
  */
11241
11516
  async connect() {
11242
- throw new import_errors29.FuelError(import_errors29.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11517
+ throw new import_errors31.FuelError(import_errors31.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11243
11518
  }
11244
11519
  /**
11245
11520
  * Should disconnect the current connection and
@@ -11249,7 +11524,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
11249
11524
  * @returns The connection status.
11250
11525
  */
11251
11526
  async disconnect() {
11252
- throw new import_errors29.FuelError(import_errors29.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11527
+ throw new import_errors31.FuelError(import_errors31.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11253
11528
  }
11254
11529
  /**
11255
11530
  * Should start the sign message process and return
@@ -11261,7 +11536,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
11261
11536
  * @returns Message signature
11262
11537
  */
11263
11538
  async signMessage(_address, _message) {
11264
- throw new import_errors29.FuelError(import_errors29.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11539
+ throw new import_errors31.FuelError(import_errors31.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11265
11540
  }
11266
11541
  /**
11267
11542
  * Should start the sign transaction process and return
@@ -11273,7 +11548,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
11273
11548
  * @returns Transaction signature
11274
11549
  */
11275
11550
  async signTransaction(_address, _transaction) {
11276
- throw new import_errors29.FuelError(import_errors29.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11551
+ throw new import_errors31.FuelError(import_errors31.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11277
11552
  }
11278
11553
  /**
11279
11554
  * Should start the send transaction process and return
@@ -11289,7 +11564,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
11289
11564
  * @returns The transaction id
11290
11565
  */
11291
11566
  async sendTransaction(_address, _transaction) {
11292
- throw new import_errors29.FuelError(import_errors29.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11567
+ throw new import_errors31.FuelError(import_errors31.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11293
11568
  }
11294
11569
  /**
11295
11570
  * Should return the current account selected inside the connector, if the account
@@ -11300,7 +11575,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
11300
11575
  * @returns The current account selected otherwise null.
11301
11576
  */
11302
11577
  async currentAccount() {
11303
- throw new import_errors29.FuelError(import_errors29.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11578
+ throw new import_errors31.FuelError(import_errors31.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11304
11579
  }
11305
11580
  /**
11306
11581
  * Should add the assets metadata to the connector and return true if the asset
@@ -11314,7 +11589,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
11314
11589
  * @returns True if the asset was added successfully
11315
11590
  */
11316
11591
  async addAssets(_assets) {
11317
- throw new import_errors29.FuelError(import_errors29.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11592
+ throw new import_errors31.FuelError(import_errors31.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11318
11593
  }
11319
11594
  /**
11320
11595
  * Should add the asset metadata to the connector and return true if the asset
@@ -11328,7 +11603,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
11328
11603
  * @returns True if the asset was added successfully
11329
11604
  */
11330
11605
  async addAsset(_asset) {
11331
- throw new import_errors29.FuelError(import_errors29.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11606
+ throw new import_errors31.FuelError(import_errors31.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11332
11607
  }
11333
11608
  /**
11334
11609
  * Should return all the assets added to the connector. If a connection is already established.
@@ -11336,7 +11611,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
11336
11611
  * @returns Array of assets metadata from the connector vinculated to the all accounts from a specific Wallet.
11337
11612
  */
11338
11613
  async assets() {
11339
- throw new import_errors29.FuelError(import_errors29.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11614
+ throw new import_errors31.FuelError(import_errors31.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11340
11615
  }
11341
11616
  /**
11342
11617
  * Should start the add network process and return true if the network was added successfully.
@@ -11347,7 +11622,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
11347
11622
  * @returns Return true if the network was added successfully
11348
11623
  */
11349
11624
  async addNetwork(_networkUrl) {
11350
- throw new import_errors29.FuelError(import_errors29.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11625
+ throw new import_errors31.FuelError(import_errors31.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11351
11626
  }
11352
11627
  /**
11353
11628
  * Should start the select network process and return true if the network has change successfully.
@@ -11358,7 +11633,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
11358
11633
  * @returns Return true if the network was added successfully
11359
11634
  */
11360
11635
  async selectNetwork(_network) {
11361
- throw new import_errors29.FuelError(import_errors29.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11636
+ throw new import_errors31.FuelError(import_errors31.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11362
11637
  }
11363
11638
  /**
11364
11639
  * Should return all the networks available from the connector. If the connection is already established.
@@ -11366,7 +11641,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
11366
11641
  * @returns Return all the networks added to the connector.
11367
11642
  */
11368
11643
  async networks() {
11369
- throw new import_errors29.FuelError(import_errors29.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11644
+ throw new import_errors31.FuelError(import_errors31.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11370
11645
  }
11371
11646
  /**
11372
11647
  * Should return the current network selected inside the connector. Even if the connection is not established.
@@ -11374,7 +11649,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
11374
11649
  * @returns Return the current network selected inside the connector.
11375
11650
  */
11376
11651
  async currentNetwork() {
11377
- throw new import_errors29.FuelError(import_errors29.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11652
+ throw new import_errors31.FuelError(import_errors31.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11378
11653
  }
11379
11654
  /**
11380
11655
  * Should add the ABI to the connector and return true if the ABI was added successfully.
@@ -11384,7 +11659,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
11384
11659
  * @returns Return true if the ABI was added successfully.
11385
11660
  */
11386
11661
  async addABI(_contractId, _abi) {
11387
- throw new import_errors29.FuelError(import_errors29.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11662
+ throw new import_errors31.FuelError(import_errors31.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11388
11663
  }
11389
11664
  /**
11390
11665
  * Should return the ABI from the connector vinculated to the all accounts from a specific Wallet.
@@ -11393,7 +11668,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
11393
11668
  * @returns The ABI if it exists, otherwise return null.
11394
11669
  */
11395
11670
  async getABI(_id) {
11396
- throw new import_errors29.FuelError(import_errors29.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11671
+ throw new import_errors31.FuelError(import_errors31.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11397
11672
  }
11398
11673
  /**
11399
11674
  * Should return true if the abi exists in the connector vinculated to the all accounts from a specific Wallet.
@@ -11402,7 +11677,7 @@ var FuelConnector = class extends import_events2.EventEmitter {
11402
11677
  * @returns Returns true if the abi exists or false if not.
11403
11678
  */
11404
11679
  async hasABI(_id) {
11405
- throw new import_errors29.FuelError(import_errors29.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11680
+ throw new import_errors31.FuelError(import_errors31.FuelError.CODES.NOT_IMPLEMENTED, "Method not implemented.");
11406
11681
  }
11407
11682
  /**
11408
11683
  * Event listener for the connector.
@@ -11446,7 +11721,7 @@ function dispatchFuelConnectorEvent(connector) {
11446
11721
  }
11447
11722
 
11448
11723
  // src/connectors/utils/promises.ts
11449
- var import_errors30 = require("@fuel-ts/errors");
11724
+ var import_errors32 = require("@fuel-ts/errors");
11450
11725
  function deferPromise() {
11451
11726
  const defer = {};
11452
11727
  defer.promise = new Promise((resolve, reject) => {
@@ -11458,7 +11733,7 @@ function deferPromise() {
11458
11733
  async function withTimeout(promise, timeout = 1050) {
11459
11734
  const timeoutPromise = new Promise((resolve, reject) => {
11460
11735
  setTimeout(() => {
11461
- reject(new import_errors30.FuelError(import_errors30.FuelError.CODES.TIMEOUT_EXCEEDED, "Promise timed out"));
11736
+ reject(new import_errors32.FuelError(import_errors32.FuelError.CODES.TIMEOUT_EXCEEDED, "Promise timed out"));
11462
11737
  }, timeout);
11463
11738
  });
11464
11739
  return Promise.race([timeoutPromise, promise]);
@@ -11493,7 +11768,7 @@ var _Fuel = class extends FuelConnector {
11493
11768
  this._targetUnsubscribe = this.setupConnectorListener();
11494
11769
  await connectResponse;
11495
11770
  } catch (error) {
11496
- throw new import_errors31.FuelError(import_errors31.ErrorCode.INVALID_PROVIDER, "Error initializing Fuel Connector");
11771
+ throw new import_errors33.FuelError(import_errors33.ErrorCode.INVALID_PROVIDER, "Error initializing Fuel Connector");
11497
11772
  }
11498
11773
  }
11499
11774
  async init() {
@@ -11559,8 +11834,8 @@ var _Fuel = class extends FuelConnector {
11559
11834
  const hasConnector = await this.hasConnector();
11560
11835
  await this.pingConnector();
11561
11836
  if (!this._currentConnector || !hasConnector) {
11562
- throw new import_errors31.FuelError(
11563
- import_errors31.ErrorCode.MISSING_CONNECTOR,
11837
+ throw new import_errors33.FuelError(
11838
+ import_errors33.ErrorCode.MISSING_CONNECTOR,
11564
11839
  `No connector selected for calling ${method}. Use hasConnector before executing other methods.`
11565
11840
  );
11566
11841
  }
@@ -11624,7 +11899,7 @@ var _Fuel = class extends FuelConnector {
11624
11899
  cacheTime: PING_CACHE_TIME
11625
11900
  })();
11626
11901
  } catch {
11627
- throw new import_errors31.FuelError(import_errors31.ErrorCode.INVALID_PROVIDER, "Current connector is not available.");
11902
+ throw new import_errors33.FuelError(import_errors33.ErrorCode.INVALID_PROVIDER, "Current connector is not available.");
11628
11903
  }
11629
11904
  }
11630
11905
  /**
@@ -11773,7 +12048,7 @@ var _Fuel = class extends FuelConnector {
11773
12048
  const currentNetwork = await this.currentNetwork();
11774
12049
  provider = await Provider.create(currentNetwork.url);
11775
12050
  } else {
11776
- throw new import_errors31.FuelError(import_errors31.ErrorCode.INVALID_PROVIDER, "Provider is not valid.");
12051
+ throw new import_errors33.FuelError(import_errors33.ErrorCode.INVALID_PROVIDER, "Provider is not valid.");
11777
12052
  }
11778
12053
  return provider;
11779
12054
  }
@@ -11881,6 +12156,7 @@ __publicField(Fuel, "defaultConfig", {});
11881
12156
  calculateTXFeeForSummary,
11882
12157
  coinQuantityfy,
11883
12158
  deferPromise,
12159
+ deployScriptOrPredicate,
11884
12160
  dispatchFuelConnectorEvent,
11885
12161
  english,
11886
12162
  extractBurnedAssetsFromReceipts,