@fuel-ts/account 0.0.0-pr-2149-20240427110619 → 0.0.0-pr-2217-20240503100416

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.

Potentially problematic release.


This version of @fuel-ts/account might be problematic. Click here for more details.

Files changed (54) hide show
  1. package/README.md +15 -12
  2. package/dist/account.d.ts +1 -1
  3. package/dist/account.d.ts.map +1 -1
  4. package/dist/index.global.js +1624 -1618
  5. package/dist/index.global.js.map +1 -1
  6. package/dist/index.js +366 -207
  7. package/dist/index.js.map +1 -1
  8. package/dist/index.mjs +347 -190
  9. package/dist/index.mjs.map +1 -1
  10. package/dist/providers/__generated__/operations.d.ts +203 -80
  11. package/dist/providers/__generated__/operations.d.ts.map +1 -1
  12. package/dist/providers/message.d.ts +2 -2
  13. package/dist/providers/message.d.ts.map +1 -1
  14. package/dist/providers/provider.d.ts +30 -29
  15. package/dist/providers/provider.d.ts.map +1 -1
  16. package/dist/providers/resource.d.ts +0 -1
  17. package/dist/providers/resource.d.ts.map +1 -1
  18. package/dist/providers/transaction-request/helpers.d.ts +8 -0
  19. package/dist/providers/transaction-request/helpers.d.ts.map +1 -0
  20. package/dist/providers/transaction-request/script-transaction-request.d.ts +2 -3
  21. package/dist/providers/transaction-request/script-transaction-request.d.ts.map +1 -1
  22. package/dist/providers/transaction-request/transaction-request.d.ts +5 -6
  23. package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
  24. package/dist/providers/transaction-request/utils.d.ts +2 -1
  25. package/dist/providers/transaction-request/utils.d.ts.map +1 -1
  26. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts +2 -2
  27. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts.map +1 -1
  28. package/dist/providers/transaction-summary/calculate-tx-fee-for-summary.d.ts +20 -0
  29. package/dist/providers/transaction-summary/calculate-tx-fee-for-summary.d.ts.map +1 -0
  30. package/dist/providers/transaction-summary/get-transaction-summary.d.ts.map +1 -1
  31. package/dist/providers/transaction-summary/index.d.ts +1 -1
  32. package/dist/providers/transaction-summary/index.d.ts.map +1 -1
  33. package/dist/providers/transaction-summary/operations.d.ts +4 -0
  34. package/dist/providers/transaction-summary/operations.d.ts.map +1 -1
  35. package/dist/providers/transaction-summary/status.d.ts +5 -1
  36. package/dist/providers/transaction-summary/status.d.ts.map +1 -1
  37. package/dist/providers/transaction-summary/types.d.ts +6 -1
  38. package/dist/providers/transaction-summary/types.d.ts.map +1 -1
  39. package/dist/providers/utils/gas.d.ts +7 -6
  40. package/dist/providers/utils/gas.d.ts.map +1 -1
  41. package/dist/test-utils/launchNode.d.ts.map +1 -1
  42. package/dist/test-utils/resources.d.ts +4 -0
  43. package/dist/test-utils/resources.d.ts.map +1 -0
  44. package/dist/test-utils/transactionRequest.d.ts +5 -0
  45. package/dist/test-utils/transactionRequest.d.ts.map +1 -0
  46. package/dist/test-utils.global.js +1628 -1621
  47. package/dist/test-utils.global.js.map +1 -1
  48. package/dist/test-utils.js +343 -196
  49. package/dist/test-utils.js.map +1 -1
  50. package/dist/test-utils.mjs +328 -181
  51. package/dist/test-utils.mjs.map +1 -1
  52. package/package.json +17 -17
  53. package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts +0 -22
  54. package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts.map +0 -1
@@ -64,7 +64,7 @@ var import_utils30 = require("@fuel-ts/utils");
64
64
  var import_address4 = require("@fuel-ts/address");
65
65
  var import_errors16 = require("@fuel-ts/errors");
66
66
  var import_interfaces = require("@fuel-ts/interfaces");
67
- var import_math19 = require("@fuel-ts/math");
67
+ var import_math21 = require("@fuel-ts/math");
68
68
  var import_utils27 = require("@fuel-ts/utils");
69
69
  var import_ramda4 = require("ramda");
70
70
 
@@ -106,12 +106,11 @@ var addAmountToCoinQuantities = (params) => {
106
106
  // src/providers/provider.ts
107
107
  var import_address3 = require("@fuel-ts/address");
108
108
  var import_errors14 = require("@fuel-ts/errors");
109
- var import_math16 = require("@fuel-ts/math");
109
+ var import_math17 = require("@fuel-ts/math");
110
110
  var import_transactions19 = require("@fuel-ts/transactions");
111
111
  var import_utils22 = require("@fuel-ts/utils");
112
112
  var import_versions = require("@fuel-ts/versions");
113
113
  var import_utils23 = require("@noble/curves/abstract/utils");
114
- var import_ethers = require("ethers");
115
114
  var import_graphql_request = require("graphql-request");
116
115
  var import_ramda3 = require("ramda");
117
116
 
@@ -168,9 +167,6 @@ var TransactionStatusFragmentFragmentDoc = import_graphql_tag.default`
168
167
  id
169
168
  }
170
169
  time
171
- receipts {
172
- ...receiptFragment
173
- }
174
170
  programState {
175
171
  returnType
176
172
  data
@@ -178,11 +174,15 @@ var TransactionStatusFragmentFragmentDoc = import_graphql_tag.default`
178
174
  receipts {
179
175
  ...receiptFragment
180
176
  }
177
+ totalGas
178
+ totalFee
181
179
  }
182
180
  ... on FailureStatus {
183
181
  block {
184
182
  id
185
183
  }
184
+ totalGas
185
+ totalFee
186
186
  time
187
187
  reason
188
188
  receipts {
@@ -222,6 +222,8 @@ var TransactionEstimatePredicatesFragmentFragmentDoc = import_graphql_tag.defaul
222
222
  ${InputEstimatePredicatesFragmentFragmentDoc}`;
223
223
  var DryRunFailureStatusFragmentFragmentDoc = import_graphql_tag.default`
224
224
  fragment dryRunFailureStatusFragment on DryRunFailureStatus {
225
+ totalGas
226
+ totalFee
225
227
  reason
226
228
  programState {
227
229
  returnType
@@ -231,6 +233,8 @@ var DryRunFailureStatusFragmentFragmentDoc = import_graphql_tag.default`
231
233
  `;
232
234
  var DryRunSuccessStatusFragmentFragmentDoc = import_graphql_tag.default`
233
235
  fragment dryRunSuccessStatusFragment on DryRunSuccessStatus {
236
+ totalGas
237
+ totalFee
234
238
  programState {
235
239
  returnType
236
240
  data
@@ -366,6 +370,7 @@ var TxParametersFragmentFragmentDoc = import_graphql_tag.default`
366
370
  maxWitnesses
367
371
  maxGasPerTx
368
372
  maxSize
373
+ maxBytecodeSubsections
369
374
  }
370
375
  `;
371
376
  var PredicateParametersFragmentFragmentDoc = import_graphql_tag.default`
@@ -635,6 +640,14 @@ var NodeInfoFragmentFragmentDoc = import_graphql_tag.default`
635
640
  nodeVersion
636
641
  }
637
642
  `;
643
+ var RelayedTransactionStatusFragmentFragmentDoc = import_graphql_tag.default`
644
+ fragment relayedTransactionStatusFragment on RelayedTransactionStatus {
645
+ ... on RelayedTransactionFailed {
646
+ blockHeight
647
+ failure
648
+ }
649
+ }
650
+ `;
638
651
  var GetVersionDocument = import_graphql_tag.default`
639
652
  query getVersion {
640
653
  nodeInfo {
@@ -864,6 +877,13 @@ var GetMessageStatusDocument = import_graphql_tag.default`
864
877
  }
865
878
  }
866
879
  `;
880
+ var GetRelayedTransactionStatusDocument = import_graphql_tag.default`
881
+ query getRelayedTransactionStatus($relayedTransactionId: RelayedTransactionId!) {
882
+ relayedTransactionStatus(id: $relayedTransactionId) {
883
+ ...relayedTransactionStatusFragment
884
+ }
885
+ }
886
+ ${RelayedTransactionStatusFragmentFragmentDoc}`;
867
887
  var DryRunDocument = import_graphql_tag.default`
868
888
  mutation dryRun($encodedTransactions: [HexString!]!, $utxoValidation: Boolean) {
869
889
  dryRun(txs: $encodedTransactions, utxoValidation: $utxoValidation) {
@@ -886,6 +906,13 @@ var ProduceBlocksDocument = import_graphql_tag.default`
886
906
  )
887
907
  }
888
908
  `;
909
+ var GetMessageByNonceDocument = import_graphql_tag.default`
910
+ query getMessageByNonce($nonce: Nonce!) {
911
+ message(nonce: $nonce) {
912
+ ...messageFragment
913
+ }
914
+ }
915
+ ${MessageFragmentFragmentDoc}`;
889
916
  var SubmitAndAwaitDocument = import_graphql_tag.default`
890
917
  subscription submitAndAwait($encodedTransaction: HexString!) {
891
918
  submitAndAwait(tx: $encodedTransaction) {
@@ -971,6 +998,9 @@ function getSdk(requester) {
971
998
  getMessageStatus(variables, options) {
972
999
  return requester(GetMessageStatusDocument, variables, options);
973
1000
  },
1001
+ getRelayedTransactionStatus(variables, options) {
1002
+ return requester(GetRelayedTransactionStatusDocument, variables, options);
1003
+ },
974
1004
  dryRun(variables, options) {
975
1005
  return requester(DryRunDocument, variables, options);
976
1006
  },
@@ -980,6 +1010,9 @@ function getSdk(requester) {
980
1010
  produceBlocks(variables, options) {
981
1011
  return requester(ProduceBlocksDocument, variables, options);
982
1012
  },
1013
+ getMessageByNonce(variables, options) {
1014
+ return requester(GetMessageByNonceDocument, variables, options);
1015
+ },
983
1016
  submitAndAwait(variables, options) {
984
1017
  return requester(SubmitAndAwaitDocument, variables, options);
985
1018
  },
@@ -1574,7 +1607,7 @@ function calculateMetadataGasForTxScript({
1574
1607
  }
1575
1608
  var calculateGasFee = (params) => {
1576
1609
  const { gas, gasPrice, priceFactor, tip } = params;
1577
- return gas.mul(gasPrice).div(priceFactor).add(tip);
1610
+ return gas.mul(gasPrice).div(priceFactor).add((0, import_math5.bn)(tip));
1578
1611
  };
1579
1612
 
1580
1613
  // src/providers/utils/json.ts
@@ -1739,10 +1772,10 @@ var BaseTransactionRequest = class {
1739
1772
  outputs,
1740
1773
  witnesses
1741
1774
  } = {}) {
1742
- this.tip = (0, import_math7.bn)(tip);
1743
- this.maturity = maturity ?? 0;
1744
- this.witnessLimit = witnessLimit ? (0, import_math7.bn)(witnessLimit) : void 0;
1745
- this.maxFee = maxFee ? (0, import_math7.bn)(maxFee) : void 0;
1775
+ this.tip = tip ? (0, import_math7.bn)(tip) : void 0;
1776
+ this.maturity = maturity && maturity > 0 ? maturity : void 0;
1777
+ this.witnessLimit = (0, import_utils9.isDefined)(witnessLimit) ? (0, import_math7.bn)(witnessLimit) : void 0;
1778
+ this.maxFee = (0, import_math7.bn)(maxFee);
1746
1779
  this.inputs = inputs ?? [];
1747
1780
  this.outputs = outputs ?? [];
1748
1781
  this.witnesses = witnesses ?? [];
@@ -1750,22 +1783,21 @@ var BaseTransactionRequest = class {
1750
1783
  static getPolicyMeta(req) {
1751
1784
  let policyTypes = 0;
1752
1785
  const policies = [];
1753
- if (req.tip) {
1786
+ const { tip, witnessLimit, maturity } = req;
1787
+ if ((0, import_math7.bn)(tip).gt(0)) {
1754
1788
  policyTypes += import_transactions6.PolicyType.Tip;
1755
- policies.push({ data: req.tip, type: import_transactions6.PolicyType.Tip });
1789
+ policies.push({ data: (0, import_math7.bn)(tip), type: import_transactions6.PolicyType.Tip });
1756
1790
  }
1757
- if (req.witnessLimit) {
1791
+ if ((0, import_utils9.isDefined)(witnessLimit) && (0, import_math7.bn)(witnessLimit).gte(0)) {
1758
1792
  policyTypes += import_transactions6.PolicyType.WitnessLimit;
1759
- policies.push({ data: req.witnessLimit, type: import_transactions6.PolicyType.WitnessLimit });
1793
+ policies.push({ data: (0, import_math7.bn)(witnessLimit), type: import_transactions6.PolicyType.WitnessLimit });
1760
1794
  }
1761
- if (req.maturity > 0) {
1795
+ if (maturity && maturity > 0) {
1762
1796
  policyTypes += import_transactions6.PolicyType.Maturity;
1763
- policies.push({ data: req.maturity, type: import_transactions6.PolicyType.Maturity });
1764
- }
1765
- if (req.maxFee) {
1766
- policyTypes += import_transactions6.PolicyType.MaxFee;
1767
- policies.push({ data: req.maxFee, type: import_transactions6.PolicyType.MaxFee });
1797
+ policies.push({ data: maturity, type: import_transactions6.PolicyType.Maturity });
1768
1798
  }
1799
+ policyTypes += import_transactions6.PolicyType.MaxFee;
1800
+ policies.push({ data: req.maxFee, type: import_transactions6.PolicyType.MaxFee });
1769
1801
  return {
1770
1802
  policyTypes,
1771
1803
  policies
@@ -2081,8 +2113,11 @@ var BaseTransactionRequest = class {
2081
2113
  * @hidden
2082
2114
  */
2083
2115
  calculateMinGas(chainInfo) {
2084
- const { gasCosts, consensusParameters } = chainInfo;
2085
- const { gasPerByte } = consensusParameters;
2116
+ const { consensusParameters } = chainInfo;
2117
+ const {
2118
+ gasCosts,
2119
+ feeParameters: { gasPerByte }
2120
+ } = consensusParameters;
2086
2121
  return getMinGas({
2087
2122
  gasPerByte,
2088
2123
  gasCosts,
@@ -2093,7 +2128,10 @@ var BaseTransactionRequest = class {
2093
2128
  }
2094
2129
  calculateMaxGas(chainInfo, minGas) {
2095
2130
  const { consensusParameters } = chainInfo;
2096
- const { gasPerByte, maxGasPerTx } = consensusParameters;
2131
+ const {
2132
+ feeParameters: { gasPerByte },
2133
+ txParameters: { maxGasPerTx }
2134
+ } = consensusParameters;
2097
2135
  const witnessesLength = this.toTransaction().witnesses.reduce(
2098
2136
  (acc, wit) => acc + wit.dataLength,
2099
2137
  0
@@ -2528,7 +2566,11 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2528
2566
  }
2529
2567
  calculateMaxGas(chainInfo, minGas) {
2530
2568
  const { consensusParameters } = chainInfo;
2531
- const { gasPerByte, maxGasPerTx } = consensusParameters;
2569
+ const {
2570
+ // TODO: Validade if it will be simpler to pass only required props
2571
+ feeParameters: { gasPerByte },
2572
+ txParameters: { maxGasPerTx }
2573
+ } = consensusParameters;
2532
2574
  const witnessesLength = this.toTransaction().witnesses.reduce(
2533
2575
  (acc, wit) => acc + wit.dataLength,
2534
2576
  0
@@ -2616,10 +2658,10 @@ var transactionRequestify = (obj) => {
2616
2658
  };
2617
2659
  var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
2618
2660
  (acc, input) => {
2619
- if (input.type === import_transactions10.InputType.Coin && input.owner === owner) {
2661
+ if (input.type === import_transactions10.InputType.Coin && input.owner === owner.toB256()) {
2620
2662
  acc.utxos.push(input.id);
2621
2663
  }
2622
- if (input.type === import_transactions10.InputType.Message && input.recipient === owner) {
2664
+ if (input.type === import_transactions10.InputType.Message && input.recipient === owner.toB256()) {
2623
2665
  acc.messages.push(input.nonce);
2624
2666
  }
2625
2667
  return acc;
@@ -2632,40 +2674,40 @@ var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
2632
2674
 
2633
2675
  // src/providers/transaction-response/transaction-response.ts
2634
2676
  var import_errors13 = require("@fuel-ts/errors");
2635
- var import_math15 = require("@fuel-ts/math");
2677
+ var import_math16 = require("@fuel-ts/math");
2636
2678
  var import_transactions18 = require("@fuel-ts/transactions");
2637
2679
  var import_utils20 = require("@fuel-ts/utils");
2638
2680
 
2639
2681
  // src/providers/transaction-summary/assemble-transaction-summary.ts
2640
- var import_math14 = require("@fuel-ts/math");
2682
+ var import_math15 = require("@fuel-ts/math");
2641
2683
  var import_transactions16 = require("@fuel-ts/transactions");
2642
2684
  var import_utils18 = require("@fuel-ts/utils");
2643
2685
 
2644
- // src/providers/transaction-summary/calculate-transaction-fee.ts
2686
+ // src/providers/transaction-summary/calculate-tx-fee-for-summary.ts
2645
2687
  var import_math11 = require("@fuel-ts/math");
2646
2688
  var import_transactions11 = require("@fuel-ts/transactions");
2647
2689
  var import_utils16 = require("@fuel-ts/utils");
2648
- var calculateTransactionFee = (params) => {
2690
+ var calculateTXFeeForSummary = (params) => {
2649
2691
  const {
2650
2692
  gasPrice,
2651
2693
  rawPayload,
2652
2694
  tip,
2695
+ totalFee,
2653
2696
  consensusParameters: { gasCosts, feeParams, maxGasPerTx }
2654
2697
  } = params;
2698
+ if (totalFee) {
2699
+ return totalFee;
2700
+ }
2655
2701
  const gasPerByte = (0, import_math11.bn)(feeParams.gasPerByte);
2656
2702
  const gasPriceFactor = (0, import_math11.bn)(feeParams.gasPriceFactor);
2657
2703
  const transactionBytes = (0, import_utils16.arrayify)(rawPayload);
2658
2704
  const [transaction] = new import_transactions11.TransactionCoder().decode(transactionBytes, 0);
2659
- if (transaction.type === import_transactions11.TransactionType.Mint) {
2660
- return {
2661
- fee: (0, import_math11.bn)(0),
2662
- minFee: (0, import_math11.bn)(0),
2663
- maxFee: (0, import_math11.bn)(0)
2664
- };
2665
- }
2666
2705
  const { type, witnesses, inputs, policies } = transaction;
2667
2706
  let metadataGas = (0, import_math11.bn)(0);
2668
2707
  let gasLimit = (0, import_math11.bn)(0);
2708
+ if (type !== import_transactions11.TransactionType.Create && type !== import_transactions11.TransactionType.Script) {
2709
+ return (0, import_math11.bn)(0);
2710
+ }
2669
2711
  if (type === import_transactions11.TransactionType.Create) {
2670
2712
  const { bytecodeWitnessIndex, storageSlots } = transaction;
2671
2713
  const contractBytesSize = (0, import_math11.bn)((0, import_utils16.arrayify)(witnesses[bytecodeWitnessIndex].data).length);
@@ -2702,23 +2744,13 @@ var calculateTransactionFee = (params) => {
2702
2744
  witnessLimit,
2703
2745
  maxGasPerTx
2704
2746
  });
2705
- const minFee = calculateGasFee({
2706
- gasPrice,
2707
- gas: minGas,
2708
- priceFactor: gasPriceFactor,
2709
- tip
2710
- });
2711
2747
  const maxFee = calculateGasFee({
2712
2748
  gasPrice,
2713
2749
  gas: maxGas,
2714
2750
  priceFactor: gasPriceFactor,
2715
2751
  tip
2716
2752
  });
2717
- return {
2718
- minFee,
2719
- maxFee,
2720
- fee: maxFee
2721
- };
2753
+ return maxFee;
2722
2754
  };
2723
2755
 
2724
2756
  // src/providers/transaction-summary/operations.ts
@@ -2877,6 +2909,12 @@ function isTypeCreate(transactionType) {
2877
2909
  function isTypeScript(transactionType) {
2878
2910
  return isType(transactionType, "Script" /* Script */);
2879
2911
  }
2912
+ function isTypeUpgrade(transactionType) {
2913
+ return isType(transactionType, "Upgrade" /* Upgrade */);
2914
+ }
2915
+ function isTypeUpload(transactionType) {
2916
+ return isType(transactionType, "Upload" /* Upload */);
2917
+ }
2880
2918
  function getReceiptsCall(receipts) {
2881
2919
  return getReceiptsByType(receipts, import_transactions14.ReceiptType.Call);
2882
2920
  }
@@ -3217,6 +3255,7 @@ var extractBurnedAssetsFromReceipts = (receipts) => {
3217
3255
 
3218
3256
  // src/providers/transaction-summary/status.ts
3219
3257
  var import_errors12 = require("@fuel-ts/errors");
3258
+ var import_math14 = require("@fuel-ts/math");
3220
3259
  var getTransactionStatusName = (gqlStatus) => {
3221
3260
  switch (gqlStatus) {
3222
3261
  case "FailureStatus":
@@ -3238,6 +3277,8 @@ var processGraphqlStatus = (gqlTransactionStatus) => {
3238
3277
  let time;
3239
3278
  let blockId;
3240
3279
  let status;
3280
+ let totalFee;
3281
+ let totalGas;
3241
3282
  let isStatusFailure = false;
3242
3283
  let isStatusSuccess = false;
3243
3284
  let isStatusPending = false;
@@ -3248,11 +3289,15 @@ var processGraphqlStatus = (gqlTransactionStatus) => {
3248
3289
  time = gqlTransactionStatus.time;
3249
3290
  blockId = gqlTransactionStatus.block.id;
3250
3291
  isStatusSuccess = true;
3292
+ totalFee = (0, import_math14.bn)(gqlTransactionStatus.totalFee);
3293
+ totalGas = (0, import_math14.bn)(gqlTransactionStatus.totalGas);
3251
3294
  break;
3252
3295
  case "FailureStatus":
3253
3296
  time = gqlTransactionStatus.time;
3254
3297
  blockId = gqlTransactionStatus.block.id;
3255
3298
  isStatusFailure = true;
3299
+ totalFee = (0, import_math14.bn)(gqlTransactionStatus.totalFee);
3300
+ totalGas = (0, import_math14.bn)(gqlTransactionStatus.totalGas);
3256
3301
  break;
3257
3302
  case "SubmittedStatus":
3258
3303
  time = gqlTransactionStatus.time;
@@ -3265,6 +3310,8 @@ var processGraphqlStatus = (gqlTransactionStatus) => {
3265
3310
  time,
3266
3311
  blockId,
3267
3312
  status,
3313
+ totalFee,
3314
+ totalGas,
3268
3315
  isStatusFailure,
3269
3316
  isStatusSuccess,
3270
3317
  isStatusPending
@@ -3300,8 +3347,10 @@ function assembleTransactionSummary(params) {
3300
3347
  maxInputs
3301
3348
  });
3302
3349
  const typeName = getTransactionTypeName(transaction.type);
3303
- const tip = (0, import_math14.bn)(transaction.policies?.find((policy) => policy.type === import_transactions16.PolicyType.Tip)?.data);
3304
- const { fee } = calculateTransactionFee({
3350
+ const tip = (0, import_math15.bn)(transaction.policies?.find((policy) => policy.type === import_transactions16.PolicyType.Tip)?.data);
3351
+ const { isStatusFailure, isStatusPending, isStatusSuccess, blockId, status, time, totalFee } = processGraphqlStatus(gqlTransactionStatus);
3352
+ const fee = calculateTXFeeForSummary({
3353
+ totalFee,
3305
3354
  gasPrice,
3306
3355
  rawPayload,
3307
3356
  tip,
@@ -3314,7 +3363,6 @@ function assembleTransactionSummary(params) {
3314
3363
  }
3315
3364
  }
3316
3365
  });
3317
- const { isStatusFailure, isStatusPending, isStatusSuccess, blockId, status, time } = processGraphqlStatus(gqlTransactionStatus);
3318
3366
  const mintedAssets = extractMintedAssetsFromReceipts(receipts);
3319
3367
  const burnedAssets = extractBurnedAssetsFromReceipts(receipts);
3320
3368
  let date;
@@ -3323,6 +3371,7 @@ function assembleTransactionSummary(params) {
3323
3371
  }
3324
3372
  const transactionSummary = {
3325
3373
  id,
3374
+ tip,
3326
3375
  fee,
3327
3376
  gasUsed,
3328
3377
  operations,
@@ -3336,6 +3385,8 @@ function assembleTransactionSummary(params) {
3336
3385
  isTypeMint: isTypeMint(transaction.type),
3337
3386
  isTypeCreate: isTypeCreate(transaction.type),
3338
3387
  isTypeScript: isTypeScript(transaction.type),
3388
+ isTypeUpgrade: isTypeUpgrade(transaction.type),
3389
+ isTypeUpload: isTypeUpload(transaction.type),
3339
3390
  isStatusFailure,
3340
3391
  isStatusSuccess,
3341
3392
  isStatusPending,
@@ -3367,7 +3418,7 @@ var TransactionResponse = class {
3367
3418
  /** Current provider */
3368
3419
  provider;
3369
3420
  /** Gas used on the transaction */
3370
- gasUsed = (0, import_math15.bn)(0);
3421
+ gasUsed = (0, import_math16.bn)(0);
3371
3422
  /** The graphql Transaction with receipts object. */
3372
3423
  gqlTransaction;
3373
3424
  abis;
@@ -3452,7 +3503,7 @@ var TransactionResponse = class {
3452
3503
  const receipts = txReceipts.map(processGqlReceipt) || [];
3453
3504
  const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
3454
3505
  const gasPrice = await this.provider.getLatestGasPrice();
3455
- const maxInputs = this.provider.getChain().consensusParameters.maxInputs;
3506
+ const maxInputs = this.provider.getChain().consensusParameters.txParameters.maxInputs;
3456
3507
  const transactionSummary = assembleTransactionSummary({
3457
3508
  id: this.id,
3458
3509
  receipts,
@@ -3588,33 +3639,60 @@ var mergeQuantities = (...coinQuantities) => {
3588
3639
  var MAX_RETRIES = 10;
3589
3640
  var processGqlChain = (chain) => {
3590
3641
  const { name, daHeight, consensusParameters, latestBlock } = chain;
3591
- const { contractParams, feeParams, predicateParams, scriptParams, txParams, gasCosts } = consensusParameters;
3642
+ const {
3643
+ contractParams,
3644
+ feeParams,
3645
+ predicateParams,
3646
+ scriptParams,
3647
+ txParams,
3648
+ gasCosts,
3649
+ baseAssetId,
3650
+ chainId,
3651
+ version
3652
+ } = consensusParameters;
3592
3653
  return {
3593
3654
  name,
3594
- baseChainHeight: (0, import_math16.bn)(daHeight),
3655
+ baseChainHeight: (0, import_math17.bn)(daHeight),
3595
3656
  consensusParameters: {
3596
- contractMaxSize: (0, import_math16.bn)(contractParams.contractMaxSize),
3597
- maxInputs: (0, import_math16.bn)(txParams.maxInputs),
3598
- maxOutputs: (0, import_math16.bn)(txParams.maxOutputs),
3599
- maxWitnesses: (0, import_math16.bn)(txParams.maxWitnesses),
3600
- maxGasPerTx: (0, import_math16.bn)(txParams.maxGasPerTx),
3601
- maxScriptLength: (0, import_math16.bn)(scriptParams.maxScriptLength),
3602
- maxScriptDataLength: (0, import_math16.bn)(scriptParams.maxScriptDataLength),
3603
- maxStorageSlots: (0, import_math16.bn)(contractParams.maxStorageSlots),
3604
- maxPredicateLength: (0, import_math16.bn)(predicateParams.maxPredicateLength),
3605
- maxPredicateDataLength: (0, import_math16.bn)(predicateParams.maxPredicateDataLength),
3606
- maxGasPerPredicate: (0, import_math16.bn)(predicateParams.maxGasPerPredicate),
3607
- gasPriceFactor: (0, import_math16.bn)(feeParams.gasPriceFactor),
3608
- gasPerByte: (0, import_math16.bn)(feeParams.gasPerByte),
3609
- maxMessageDataLength: (0, import_math16.bn)(predicateParams.maxMessageDataLength),
3610
- chainId: (0, import_math16.bn)(consensusParameters.chainId),
3611
- baseAssetId: consensusParameters.baseAssetId,
3657
+ version,
3658
+ chainId: (0, import_math17.bn)(chainId),
3659
+ baseAssetId,
3660
+ feeParameters: {
3661
+ version: feeParams.version,
3662
+ gasPerByte: (0, import_math17.bn)(feeParams.gasPerByte),
3663
+ gasPriceFactor: (0, import_math17.bn)(feeParams.gasPriceFactor)
3664
+ },
3665
+ contractParameters: {
3666
+ version: contractParams.version,
3667
+ contractMaxSize: (0, import_math17.bn)(contractParams.contractMaxSize),
3668
+ maxStorageSlots: (0, import_math17.bn)(contractParams.maxStorageSlots)
3669
+ },
3670
+ txParameters: {
3671
+ version: txParams.version,
3672
+ maxInputs: (0, import_math17.bn)(txParams.maxInputs),
3673
+ maxOutputs: (0, import_math17.bn)(txParams.maxOutputs),
3674
+ maxWitnesses: (0, import_math17.bn)(txParams.maxWitnesses),
3675
+ maxGasPerTx: (0, import_math17.bn)(txParams.maxGasPerTx),
3676
+ maxSize: (0, import_math17.bn)(txParams.maxSize),
3677
+ maxBytecodeSubsections: (0, import_math17.bn)(txParams.maxBytecodeSubsections)
3678
+ },
3679
+ predicateParameters: {
3680
+ version: predicateParams.version,
3681
+ maxPredicateLength: (0, import_math17.bn)(predicateParams.maxPredicateLength),
3682
+ maxPredicateDataLength: (0, import_math17.bn)(predicateParams.maxPredicateDataLength),
3683
+ maxGasPerPredicate: (0, import_math17.bn)(predicateParams.maxGasPerPredicate),
3684
+ maxMessageDataLength: (0, import_math17.bn)(predicateParams.maxMessageDataLength)
3685
+ },
3686
+ scriptParameters: {
3687
+ version: scriptParams.version,
3688
+ maxScriptLength: (0, import_math17.bn)(scriptParams.maxScriptLength),
3689
+ maxScriptDataLength: (0, import_math17.bn)(scriptParams.maxScriptDataLength)
3690
+ },
3612
3691
  gasCosts
3613
3692
  },
3614
- gasCosts,
3615
3693
  latestBlock: {
3616
3694
  id: latestBlock.id,
3617
- height: (0, import_math16.bn)(latestBlock.height),
3695
+ height: (0, import_math17.bn)(latestBlock.height),
3618
3696
  time: latestBlock.header.time,
3619
3697
  transactions: latestBlock.transactions.map((i) => ({
3620
3698
  id: i.id
@@ -3708,7 +3786,12 @@ var _Provider = class {
3708
3786
  * Returns some helpful parameters related to gas fees.
3709
3787
  */
3710
3788
  getGasConfig() {
3711
- const { maxGasPerTx, maxGasPerPredicate, gasPriceFactor, gasPerByte, gasCosts } = this.getChain().consensusParameters;
3789
+ const {
3790
+ txParameters: { maxGasPerTx },
3791
+ predicateParameters: { maxGasPerPredicate },
3792
+ feeParameters: { gasPriceFactor, gasPerByte },
3793
+ gasCosts
3794
+ } = this.getChain().consensusParameters;
3712
3795
  return {
3713
3796
  maxGasPerTx,
3714
3797
  maxGasPerPredicate,
@@ -3757,7 +3840,18 @@ var _Provider = class {
3757
3840
  createOperations() {
3758
3841
  const fetchFn = _Provider.getFetchFn(this.options);
3759
3842
  const gqlClient = new import_graphql_request.GraphQLClient(this.url, {
3760
- fetch: (url, requestInit) => fetchFn(url, requestInit, this.options)
3843
+ fetch: (url, requestInit) => fetchFn(url, requestInit, this.options),
3844
+ responseMiddleware: (response) => {
3845
+ if ("response" in response) {
3846
+ const graphQlResponse = response.response;
3847
+ if (Array.isArray(graphQlResponse?.errors)) {
3848
+ throw new import_errors14.FuelError(
3849
+ import_errors14.FuelError.CODES.INVALID_REQUEST,
3850
+ graphQlResponse.errors.map((err) => err.message).join("\n\n")
3851
+ );
3852
+ }
3853
+ }
3854
+ }
3761
3855
  });
3762
3856
  const executeQuery = (query, vars) => {
3763
3857
  const opDefinition = query.definitions.find((x) => x.kind === "OperationDefinition");
@@ -3785,21 +3879,6 @@ var _Provider = class {
3785
3879
  } = await this.operations.getVersion();
3786
3880
  return nodeVersion;
3787
3881
  }
3788
- /**
3789
- * @hidden
3790
- *
3791
- * Returns the network configuration of the connected Fuel node.
3792
- *
3793
- * @returns A promise that resolves to the network configuration object
3794
- */
3795
- async getNetwork() {
3796
- const {
3797
- name,
3798
- consensusParameters: { chainId }
3799
- } = await this.getChain();
3800
- const network = new import_ethers.Network(name, chainId.toNumber());
3801
- return Promise.resolve(network);
3802
- }
3803
3882
  /**
3804
3883
  * Returns the block number.
3805
3884
  *
@@ -3807,7 +3886,7 @@ var _Provider = class {
3807
3886
  */
3808
3887
  async getBlockNumber() {
3809
3888
  const { chain } = await this.operations.getChain();
3810
- return (0, import_math16.bn)(chain.latestBlock.height, 10);
3889
+ return (0, import_math17.bn)(chain.latestBlock.height, 10);
3811
3890
  }
3812
3891
  /**
3813
3892
  * Returns the chain information.
@@ -3817,8 +3896,8 @@ var _Provider = class {
3817
3896
  async fetchNode() {
3818
3897
  const { nodeInfo } = await this.operations.getNodeInfo();
3819
3898
  const processedNodeInfo = {
3820
- maxDepth: (0, import_math16.bn)(nodeInfo.maxDepth),
3821
- maxTx: (0, import_math16.bn)(nodeInfo.maxTx),
3899
+ maxDepth: (0, import_math17.bn)(nodeInfo.maxDepth),
3900
+ maxTx: (0, import_math17.bn)(nodeInfo.maxTx),
3822
3901
  nodeVersion: nodeInfo.nodeVersion,
3823
3902
  utxoValidation: nodeInfo.utxoValidation,
3824
3903
  vmBacktrace: nodeInfo.vmBacktrace
@@ -3922,9 +4001,9 @@ var _Provider = class {
3922
4001
  encodedTransactions: encodedTransaction,
3923
4002
  utxoValidation: utxoValidation || false
3924
4003
  });
3925
- const [{ receipts: rawReceipts, status }] = dryRunStatuses;
4004
+ const [{ receipts: rawReceipts, status: dryRunStatus }] = dryRunStatuses;
3926
4005
  const receipts = rawReceipts.map(processGqlReceipt);
3927
- return { receipts, dryrunStatus: status };
4006
+ return { receipts, dryRunStatus };
3928
4007
  }
3929
4008
  /**
3930
4009
  * Verifies whether enough gas is available to complete transaction.
@@ -3935,7 +4014,7 @@ var _Provider = class {
3935
4014
  async estimatePredicates(transactionRequest) {
3936
4015
  const shouldEstimatePredicates = Boolean(
3937
4016
  transactionRequest.inputs.find(
3938
- (input) => "predicate" in input && input.predicate && !(0, import_utils23.equalBytes)((0, import_utils22.arrayify)(input.predicate), (0, import_utils22.arrayify)("0x")) && new import_math16.BN(input.predicateGasUsed).isZero()
4017
+ (input) => "predicate" in input && input.predicate && !(0, import_utils23.equalBytes)((0, import_utils22.arrayify)(input.predicate), (0, import_utils22.arrayify)("0x")) && new import_math17.BN(input.predicateGasUsed).isZero()
3939
4018
  )
3940
4019
  );
3941
4020
  if (!shouldEstimatePredicates) {
@@ -3950,7 +4029,7 @@ var _Provider = class {
3950
4029
  } = response;
3951
4030
  if (inputs) {
3952
4031
  inputs.forEach((input, index) => {
3953
- if ("predicateGasUsed" in input && (0, import_math16.bn)(input.predicateGasUsed).gt(0)) {
4032
+ if ("predicateGasUsed" in input && (0, import_math17.bn)(input.predicateGasUsed).gt(0)) {
3954
4033
  transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
3955
4034
  }
3956
4035
  });
@@ -3978,7 +4057,7 @@ var _Provider = class {
3978
4057
  let receipts = [];
3979
4058
  const missingContractIds = [];
3980
4059
  let outputVariables = 0;
3981
- let dryrunStatus;
4060
+ let dryRunStatus;
3982
4061
  for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
3983
4062
  const {
3984
4063
  dryRun: [{ receipts: rawReceipts, status }]
@@ -3987,7 +4066,7 @@ var _Provider = class {
3987
4066
  utxoValidation: false
3988
4067
  });
3989
4068
  receipts = rawReceipts.map(processGqlReceipt);
3990
- dryrunStatus = status;
4069
+ dryRunStatus = status;
3991
4070
  const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
3992
4071
  const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
3993
4072
  if (hasMissingOutputs) {
@@ -4009,7 +4088,7 @@ var _Provider = class {
4009
4088
  receipts,
4010
4089
  outputVariables,
4011
4090
  missingContractIds,
4012
- dryrunStatus
4091
+ dryRunStatus
4013
4092
  };
4014
4093
  }
4015
4094
  /**
@@ -4027,7 +4106,7 @@ var _Provider = class {
4027
4106
  receipts: [],
4028
4107
  outputVariables: 0,
4029
4108
  missingContractIds: [],
4030
- dryrunStatus: void 0
4109
+ dryRunStatus: void 0
4031
4110
  }));
4032
4111
  const allRequests = (0, import_ramda3.clone)(transactionRequests);
4033
4112
  const serializedTransactionsMap = /* @__PURE__ */ new Map();
@@ -4052,7 +4131,7 @@ var _Provider = class {
4052
4131
  const { receipts: rawReceipts, status } = dryRunResults.dryRun[i];
4053
4132
  const result = results[requestIdx];
4054
4133
  result.receipts = rawReceipts.map(processGqlReceipt);
4055
- result.dryrunStatus = status;
4134
+ result.dryRunStatus = status;
4056
4135
  const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(
4057
4136
  result.receipts
4058
4137
  );
@@ -4089,7 +4168,7 @@ var _Provider = class {
4089
4168
  });
4090
4169
  const results = dryRunStatuses.map(({ receipts: rawReceipts, status }) => {
4091
4170
  const receipts = rawReceipts.map(processGqlReceipt);
4092
- return { receipts, dryrunStatus: status };
4171
+ return { receipts, dryRunStatus: status };
4093
4172
  });
4094
4173
  return results;
4095
4174
  }
@@ -4108,12 +4187,12 @@ var _Provider = class {
4108
4187
  gasPrice = await this.estimateGasPrice(10);
4109
4188
  }
4110
4189
  const minFee = calculateGasFee({
4111
- gasPrice: (0, import_math16.bn)(gasPrice),
4190
+ gasPrice: (0, import_math17.bn)(gasPrice),
4112
4191
  gas: minGas,
4113
4192
  priceFactor: gasPriceFactor,
4114
4193
  tip: transactionRequest.tip
4115
4194
  }).add(1);
4116
- let gasLimit = (0, import_math16.bn)(0);
4195
+ let gasLimit = (0, import_math17.bn)(0);
4117
4196
  if (transactionRequest.type === import_transactions19.TransactionType.Script) {
4118
4197
  gasLimit = transactionRequest.gasLimit;
4119
4198
  if (transactionRequest.gasLimit.eq(0)) {
@@ -4126,7 +4205,7 @@ var _Provider = class {
4126
4205
  }
4127
4206
  const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
4128
4207
  const maxFee = calculateGasFee({
4129
- gasPrice: (0, import_math16.bn)(gasPrice),
4208
+ gasPrice: (0, import_math17.bn)(gasPrice),
4130
4209
  gas: maxGas,
4131
4210
  priceFactor: gasPriceFactor,
4132
4211
  tip: transactionRequest.tip
@@ -4189,9 +4268,9 @@ var _Provider = class {
4189
4268
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
4190
4269
  const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
4191
4270
  txRequestClone.fundWithFakeUtxos(allQuantities, baseAssetId, resourcesOwner?.address);
4192
- txRequestClone.maxFee = (0, import_math16.bn)(0);
4271
+ txRequestClone.maxFee = (0, import_math17.bn)(0);
4193
4272
  if (isScriptTransaction) {
4194
- txRequestClone.gasLimit = (0, import_math16.bn)(0);
4273
+ txRequestClone.gasLimit = (0, import_math17.bn)(0);
4195
4274
  }
4196
4275
  if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
4197
4276
  resourcesOwner.populateTransactionPredicateData(txRequestClone);
@@ -4208,9 +4287,10 @@ var _Provider = class {
4208
4287
  transactionRequest: signedRequest
4209
4288
  });
4210
4289
  let receipts = [];
4290
+ let dryRunStatus;
4211
4291
  let missingContractIds = [];
4212
4292
  let outputVariables = 0;
4213
- let gasUsed = (0, import_math16.bn)(0);
4293
+ let gasUsed = (0, import_math17.bn)(0);
4214
4294
  txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
4215
4295
  txRequestClone.maxFee = maxFee;
4216
4296
  if (isScriptTransaction) {
@@ -4218,10 +4298,7 @@ var _Provider = class {
4218
4298
  if (signatureCallback) {
4219
4299
  await signatureCallback(txRequestClone);
4220
4300
  }
4221
- const result = await this.estimateTxDependencies(txRequestClone);
4222
- receipts = result.receipts;
4223
- outputVariables = result.outputVariables;
4224
- missingContractIds = result.missingContractIds;
4301
+ ({ receipts, missingContractIds, outputVariables, dryRunStatus } = await this.estimateTxDependencies(txRequestClone));
4225
4302
  gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
4226
4303
  txRequestClone.gasLimit = gasUsed;
4227
4304
  ({ maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
@@ -4241,7 +4318,8 @@ var _Provider = class {
4241
4318
  outputVariables,
4242
4319
  missingContractIds,
4243
4320
  addedSignatures,
4244
- estimatedPredicates: txRequestClone.inputs
4321
+ estimatedPredicates: txRequestClone.inputs,
4322
+ dryRunStatus
4245
4323
  };
4246
4324
  }
4247
4325
  async getResourcesForTransaction(owner, transactionRequestLike, quantitiesToContract = []) {
@@ -4277,10 +4355,10 @@ var _Provider = class {
4277
4355
  return coins.map((coin) => ({
4278
4356
  id: coin.utxoId,
4279
4357
  assetId: coin.assetId,
4280
- amount: (0, import_math16.bn)(coin.amount),
4358
+ amount: (0, import_math17.bn)(coin.amount),
4281
4359
  owner: import_address3.Address.fromAddressOrString(coin.owner),
4282
- blockCreated: (0, import_math16.bn)(coin.blockCreated),
4283
- txCreatedIdx: (0, import_math16.bn)(coin.txCreatedIdx)
4360
+ blockCreated: (0, import_math17.bn)(coin.blockCreated),
4361
+ txCreatedIdx: (0, import_math17.bn)(coin.txCreatedIdx)
4284
4362
  }));
4285
4363
  }
4286
4364
  /**
@@ -4317,9 +4395,9 @@ var _Provider = class {
4317
4395
  switch (coin.__typename) {
4318
4396
  case "MessageCoin":
4319
4397
  return {
4320
- amount: (0, import_math16.bn)(coin.amount),
4398
+ amount: (0, import_math17.bn)(coin.amount),
4321
4399
  assetId: coin.assetId,
4322
- daHeight: (0, import_math16.bn)(coin.daHeight),
4400
+ daHeight: (0, import_math17.bn)(coin.daHeight),
4323
4401
  sender: import_address3.Address.fromAddressOrString(coin.sender),
4324
4402
  recipient: import_address3.Address.fromAddressOrString(coin.recipient),
4325
4403
  nonce: coin.nonce
@@ -4327,11 +4405,11 @@ var _Provider = class {
4327
4405
  case "Coin":
4328
4406
  return {
4329
4407
  id: coin.utxoId,
4330
- amount: (0, import_math16.bn)(coin.amount),
4408
+ amount: (0, import_math17.bn)(coin.amount),
4331
4409
  assetId: coin.assetId,
4332
4410
  owner: import_address3.Address.fromAddressOrString(coin.owner),
4333
- blockCreated: (0, import_math16.bn)(coin.blockCreated),
4334
- txCreatedIdx: (0, import_math16.bn)(coin.txCreatedIdx)
4411
+ blockCreated: (0, import_math17.bn)(coin.blockCreated),
4412
+ txCreatedIdx: (0, import_math17.bn)(coin.txCreatedIdx)
4335
4413
  };
4336
4414
  default:
4337
4415
  return null;
@@ -4348,13 +4426,13 @@ var _Provider = class {
4348
4426
  async getBlock(idOrHeight) {
4349
4427
  let variables;
4350
4428
  if (typeof idOrHeight === "number") {
4351
- variables = { height: (0, import_math16.bn)(idOrHeight).toString(10) };
4429
+ variables = { height: (0, import_math17.bn)(idOrHeight).toString(10) };
4352
4430
  } else if (idOrHeight === "latest") {
4353
4431
  variables = { height: (await this.getBlockNumber()).toString(10) };
4354
4432
  } else if (idOrHeight.length === 66) {
4355
4433
  variables = { blockId: idOrHeight };
4356
4434
  } else {
4357
- variables = { blockId: (0, import_math16.bn)(idOrHeight).toString(10) };
4435
+ variables = { blockId: (0, import_math17.bn)(idOrHeight).toString(10) };
4358
4436
  }
4359
4437
  const { block } = await this.operations.getBlock(variables);
4360
4438
  if (!block) {
@@ -4362,7 +4440,7 @@ var _Provider = class {
4362
4440
  }
4363
4441
  return {
4364
4442
  id: block.id,
4365
- height: (0, import_math16.bn)(block.height),
4443
+ height: (0, import_math17.bn)(block.height),
4366
4444
  time: block.header.time,
4367
4445
  transactionIds: block.transactions.map((tx) => tx.id)
4368
4446
  };
@@ -4377,7 +4455,7 @@ var _Provider = class {
4377
4455
  const { blocks: fetchedData } = await this.operations.getBlocks(params);
4378
4456
  const blocks = fetchedData.edges.map(({ node: block }) => ({
4379
4457
  id: block.id,
4380
- height: (0, import_math16.bn)(block.height),
4458
+ height: (0, import_math17.bn)(block.height),
4381
4459
  time: block.header.time,
4382
4460
  transactionIds: block.transactions.map((tx) => tx.id)
4383
4461
  }));
@@ -4392,7 +4470,7 @@ var _Provider = class {
4392
4470
  async getBlockWithTransactions(idOrHeight) {
4393
4471
  let variables;
4394
4472
  if (typeof idOrHeight === "number") {
4395
- variables = { blockHeight: (0, import_math16.bn)(idOrHeight).toString(10) };
4473
+ variables = { blockHeight: (0, import_math17.bn)(idOrHeight).toString(10) };
4396
4474
  } else if (idOrHeight === "latest") {
4397
4475
  variables = { blockHeight: (await this.getBlockNumber()).toString() };
4398
4476
  } else {
@@ -4404,7 +4482,7 @@ var _Provider = class {
4404
4482
  }
4405
4483
  return {
4406
4484
  id: block.id,
4407
- height: (0, import_math16.bn)(block.height, 10),
4485
+ height: (0, import_math17.bn)(block.height, 10),
4408
4486
  time: block.header.time,
4409
4487
  transactionIds: block.transactions.map((tx) => tx.id),
4410
4488
  transactions: block.transactions.map(
@@ -4453,7 +4531,7 @@ var _Provider = class {
4453
4531
  contract: import_address3.Address.fromAddressOrString(contractId).toB256(),
4454
4532
  asset: (0, import_utils22.hexlify)(assetId)
4455
4533
  });
4456
- return (0, import_math16.bn)(contractBalance.amount, 10);
4534
+ return (0, import_math17.bn)(contractBalance.amount, 10);
4457
4535
  }
4458
4536
  /**
4459
4537
  * Returns the balance for the given owner for the given asset ID.
@@ -4467,7 +4545,7 @@ var _Provider = class {
4467
4545
  owner: import_address3.Address.fromAddressOrString(owner).toB256(),
4468
4546
  assetId: (0, import_utils22.hexlify)(assetId)
4469
4547
  });
4470
- return (0, import_math16.bn)(balance.amount, 10);
4548
+ return (0, import_math17.bn)(balance.amount, 10);
4471
4549
  }
4472
4550
  /**
4473
4551
  * Returns balances for the given owner.
@@ -4485,7 +4563,7 @@ var _Provider = class {
4485
4563
  const balances = result.balances.edges.map((edge) => edge.node);
4486
4564
  return balances.map((balance) => ({
4487
4565
  assetId: balance.assetId,
4488
- amount: (0, import_math16.bn)(balance.amount)
4566
+ amount: (0, import_math17.bn)(balance.amount)
4489
4567
  }));
4490
4568
  }
4491
4569
  /**
@@ -4507,15 +4585,15 @@ var _Provider = class {
4507
4585
  sender: message.sender,
4508
4586
  recipient: message.recipient,
4509
4587
  nonce: message.nonce,
4510
- amount: (0, import_math16.bn)(message.amount),
4588
+ amount: (0, import_math17.bn)(message.amount),
4511
4589
  data: message.data
4512
4590
  }),
4513
4591
  sender: import_address3.Address.fromAddressOrString(message.sender),
4514
4592
  recipient: import_address3.Address.fromAddressOrString(message.recipient),
4515
4593
  nonce: message.nonce,
4516
- amount: (0, import_math16.bn)(message.amount),
4594
+ amount: (0, import_math17.bn)(message.amount),
4517
4595
  data: import_transactions19.InputMessageCoder.decodeData(message.data),
4518
- daHeight: (0, import_math16.bn)(message.daHeight)
4596
+ daHeight: (0, import_math17.bn)(message.daHeight)
4519
4597
  }));
4520
4598
  }
4521
4599
  /**
@@ -4568,59 +4646,59 @@ var _Provider = class {
4568
4646
  } = result.messageProof;
4569
4647
  return {
4570
4648
  messageProof: {
4571
- proofIndex: (0, import_math16.bn)(messageProof.proofIndex),
4649
+ proofIndex: (0, import_math17.bn)(messageProof.proofIndex),
4572
4650
  proofSet: messageProof.proofSet
4573
4651
  },
4574
4652
  blockProof: {
4575
- proofIndex: (0, import_math16.bn)(blockProof.proofIndex),
4653
+ proofIndex: (0, import_math17.bn)(blockProof.proofIndex),
4576
4654
  proofSet: blockProof.proofSet
4577
4655
  },
4578
4656
  messageBlockHeader: {
4579
4657
  id: messageBlockHeader.id,
4580
- daHeight: (0, import_math16.bn)(messageBlockHeader.daHeight),
4581
- transactionsCount: (0, import_math16.bn)(messageBlockHeader.transactionsCount),
4658
+ daHeight: (0, import_math17.bn)(messageBlockHeader.daHeight),
4659
+ transactionsCount: Number(messageBlockHeader.transactionsCount),
4582
4660
  transactionsRoot: messageBlockHeader.transactionsRoot,
4583
- height: (0, import_math16.bn)(messageBlockHeader.height),
4661
+ height: (0, import_math17.bn)(messageBlockHeader.height),
4584
4662
  prevRoot: messageBlockHeader.prevRoot,
4585
4663
  time: messageBlockHeader.time,
4586
4664
  applicationHash: messageBlockHeader.applicationHash,
4587
- messageReceiptCount: (0, import_math16.bn)(messageBlockHeader.messageReceiptCount),
4665
+ messageReceiptCount: Number(messageBlockHeader.messageReceiptCount),
4588
4666
  messageOutboxRoot: messageBlockHeader.messageOutboxRoot,
4589
- consensusParametersVersion: messageBlockHeader.consensusParametersVersion,
4667
+ consensusParametersVersion: Number(messageBlockHeader.consensusParametersVersion),
4590
4668
  eventInboxRoot: messageBlockHeader.eventInboxRoot,
4591
- stateTransitionBytecodeVersion: messageBlockHeader.stateTransitionBytecodeVersion
4669
+ stateTransitionBytecodeVersion: Number(messageBlockHeader.stateTransitionBytecodeVersion)
4592
4670
  },
4593
4671
  commitBlockHeader: {
4594
4672
  id: commitBlockHeader.id,
4595
- daHeight: (0, import_math16.bn)(commitBlockHeader.daHeight),
4596
- transactionsCount: (0, import_math16.bn)(commitBlockHeader.transactionsCount),
4673
+ daHeight: (0, import_math17.bn)(commitBlockHeader.daHeight),
4674
+ transactionsCount: Number(commitBlockHeader.transactionsCount),
4597
4675
  transactionsRoot: commitBlockHeader.transactionsRoot,
4598
- height: (0, import_math16.bn)(commitBlockHeader.height),
4676
+ height: (0, import_math17.bn)(commitBlockHeader.height),
4599
4677
  prevRoot: commitBlockHeader.prevRoot,
4600
4678
  time: commitBlockHeader.time,
4601
4679
  applicationHash: commitBlockHeader.applicationHash,
4602
- messageReceiptCount: (0, import_math16.bn)(commitBlockHeader.messageReceiptCount),
4680
+ messageReceiptCount: Number(commitBlockHeader.messageReceiptCount),
4603
4681
  messageOutboxRoot: commitBlockHeader.messageOutboxRoot,
4604
- consensusParametersVersion: commitBlockHeader.consensusParametersVersion,
4682
+ consensusParametersVersion: Number(commitBlockHeader.consensusParametersVersion),
4605
4683
  eventInboxRoot: commitBlockHeader.eventInboxRoot,
4606
- stateTransitionBytecodeVersion: commitBlockHeader.stateTransitionBytecodeVersion
4684
+ stateTransitionBytecodeVersion: Number(commitBlockHeader.stateTransitionBytecodeVersion)
4607
4685
  },
4608
4686
  sender: import_address3.Address.fromAddressOrString(sender),
4609
4687
  recipient: import_address3.Address.fromAddressOrString(recipient),
4610
4688
  nonce,
4611
- amount: (0, import_math16.bn)(amount),
4689
+ amount: (0, import_math17.bn)(amount),
4612
4690
  data
4613
4691
  };
4614
4692
  }
4615
4693
  async getLatestGasPrice() {
4616
4694
  const { latestGasPrice } = await this.operations.getLatestGasPrice();
4617
- return (0, import_math16.bn)(latestGasPrice.gasPrice);
4695
+ return (0, import_math17.bn)(latestGasPrice.gasPrice);
4618
4696
  }
4619
4697
  async estimateGasPrice(blockHorizon) {
4620
4698
  const { estimateGasPrice } = await this.operations.estimateGasPrice({
4621
4699
  blockHorizon: String(blockHorizon)
4622
4700
  });
4623
- return (0, import_math16.bn)(estimateGasPrice.gasPrice);
4701
+ return (0, import_math17.bn)(estimateGasPrice.gasPrice);
4624
4702
  }
4625
4703
  /**
4626
4704
  * Returns Message Proof for given transaction id and the message id from MessageOut receipt.
@@ -4641,15 +4719,37 @@ var _Provider = class {
4641
4719
  */
4642
4720
  async produceBlocks(amount, startTime) {
4643
4721
  const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
4644
- blocksToProduce: (0, import_math16.bn)(amount).toString(10),
4722
+ blocksToProduce: (0, import_math17.bn)(amount).toString(10),
4645
4723
  startTimestamp: startTime ? import_utils22.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
4646
4724
  });
4647
- return (0, import_math16.bn)(latestBlockHeight);
4725
+ return (0, import_math17.bn)(latestBlockHeight);
4648
4726
  }
4649
4727
  // eslint-disable-next-line @typescript-eslint/require-await
4650
4728
  async getTransactionResponse(transactionId) {
4651
4729
  return new TransactionResponse(transactionId, this);
4652
4730
  }
4731
+ /**
4732
+ * Returns Message for given nonce.
4733
+ *
4734
+ * @param nonce - The nonce of the message to retrieve.
4735
+ * @returns A promise that resolves to the Message object.
4736
+ */
4737
+ async getMessageByNonce(nonce) {
4738
+ const { message } = await this.operations.getMessageByNonce({ nonce });
4739
+ if (!message) {
4740
+ return null;
4741
+ }
4742
+ return message;
4743
+ }
4744
+ async getRelayedTransactionStatus(relayedTransactionId) {
4745
+ const { relayedTransactionStatus } = await this.operations.getRelayedTransactionStatus({
4746
+ relayedTransactionId
4747
+ });
4748
+ if (!relayedTransactionStatus) {
4749
+ return null;
4750
+ }
4751
+ return relayedTransactionStatus;
4752
+ }
4653
4753
  };
4654
4754
  var Provider = _Provider;
4655
4755
  _cacheInputs = new WeakSet();
@@ -4668,7 +4768,7 @@ __publicField(Provider, "nodeInfoCache", {});
4668
4768
 
4669
4769
  // src/providers/transaction-summary/get-transaction-summary.ts
4670
4770
  var import_errors15 = require("@fuel-ts/errors");
4671
- var import_math17 = require("@fuel-ts/math");
4771
+ var import_math18 = require("@fuel-ts/math");
4672
4772
  var import_transactions20 = require("@fuel-ts/transactions");
4673
4773
  var import_utils25 = require("@fuel-ts/utils");
4674
4774
 
@@ -4717,15 +4817,31 @@ var assets = [
4717
4817
  }
4718
4818
  ];
4719
4819
 
4820
+ // src/providers/transaction-request/helpers.ts
4821
+ var import_math19 = require("@fuel-ts/math");
4822
+ var import_transactions21 = require("@fuel-ts/transactions");
4823
+ var isRequestInputCoin = (input) => input.type === import_transactions21.InputType.Coin;
4824
+ var isRequestInputMessage = (input) => input.type === import_transactions21.InputType.Message;
4825
+ var isRequestInputResource = (input) => isRequestInputCoin(input) || isRequestInputMessage(input);
4826
+ var getAssetAmountInRequestInputs = (inputs, assetId, baseAsset) => inputs.filter(isRequestInputResource).reduce((acc, input) => {
4827
+ if (isRequestInputCoin(input) && input.assetId === assetId) {
4828
+ return acc.add(input.amount);
4829
+ }
4830
+ if (isRequestInputMessage(input) && assetId === baseAsset) {
4831
+ return acc.add(input.amount);
4832
+ }
4833
+ return acc;
4834
+ }, (0, import_math19.bn)(0));
4835
+
4720
4836
  // src/utils/formatTransferToContractScriptData.ts
4721
4837
  var import_abi_coder6 = require("@fuel-ts/abi-coder");
4722
- var import_math18 = require("@fuel-ts/math");
4838
+ var import_math20 = require("@fuel-ts/math");
4723
4839
  var import_utils26 = require("@fuel-ts/utils");
4724
4840
  var asm = __toESM(require("@fuels/vm-asm"));
4725
4841
  var formatTransferToContractScriptData = (params) => {
4726
4842
  const { assetId, amountToTransfer, hexlifiedContractId } = params;
4727
4843
  const numberCoder = new import_abi_coder6.BigNumberCoder("u64");
4728
- const encoded = numberCoder.encode(new import_math18.BN(amountToTransfer).toNumber());
4844
+ const encoded = numberCoder.encode(new import_math20.BN(amountToTransfer).toNumber());
4729
4845
  const scriptData = Uint8Array.from([
4730
4846
  ...(0, import_utils26.arrayify)(hexlifiedContractId),
4731
4847
  ...encoded,
@@ -4754,6 +4870,7 @@ var assembleTransferToContractScript = async (params) => {
4754
4870
  };
4755
4871
 
4756
4872
  // src/account.ts
4873
+ var MAX_FUNDING_ATTEMPTS = 2;
4757
4874
  var Account = class extends import_interfaces.AbstractAccount {
4758
4875
  /**
4759
4876
  * The address associated with the account.
@@ -4911,16 +5028,17 @@ var Account = class extends import_interfaces.AbstractAccount {
4911
5028
  * Adds resources to the transaction enough to fund it.
4912
5029
  *
4913
5030
  * @param request - The transaction request.
4914
- * @param coinQuantities - The coin quantities required to execute the transaction.
5031
+ * @param requiredQuantities - The coin quantities required to execute the transaction.
4915
5032
  * @param fee - The estimated transaction fee.
4916
5033
  * @returns A promise that resolves when the resources are added to the transaction.
4917
5034
  */
4918
5035
  async fund(request, params) {
4919
5036
  const { addedSignatures, estimatedPredicates, maxFee: fee, requiredQuantities } = params;
4920
5037
  const baseAssetId = this.provider.getBaseAssetId();
5038
+ const requiredInBaseAsset = requiredQuantities.find((quantity) => quantity.assetId === baseAssetId)?.amount || (0, import_math21.bn)(0);
4921
5039
  const txRequest = request;
4922
5040
  const requiredQuantitiesWithFee = addAmountToCoinQuantities({
4923
- amount: (0, import_math19.bn)(fee),
5041
+ amount: (0, import_math21.bn)(fee),
4924
5042
  assetId: baseAssetId,
4925
5043
  coinQuantities: requiredQuantities
4926
5044
  });
@@ -4928,21 +5046,17 @@ var Account = class extends import_interfaces.AbstractAccount {
4928
5046
  requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
4929
5047
  quantitiesDict[assetId] = {
4930
5048
  required: amount,
4931
- owned: (0, import_math19.bn)(0)
5049
+ owned: (0, import_math21.bn)(0)
4932
5050
  };
4933
5051
  });
4934
- txRequest.inputs.forEach((input) => {
4935
- const isResource = "amount" in input;
4936
- if (!isResource) {
4937
- return;
4938
- }
4939
- const isCoin2 = "owner" in input;
5052
+ request.inputs.filter(isRequestInputResource).forEach((input) => {
5053
+ const isCoin2 = isRequestInputCoin(input);
4940
5054
  const assetId = isCoin2 ? String(input.assetId) : baseAssetId;
4941
5055
  if (quantitiesDict[assetId]) {
4942
5056
  quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(input.amount);
4943
5057
  }
4944
5058
  });
4945
- const missingQuantities = [];
5059
+ let missingQuantities = [];
4946
5060
  Object.entries(quantitiesDict).forEach(([assetId, { owned, required }]) => {
4947
5061
  if (owned.lt(required)) {
4948
5062
  missingQuantities.push({
@@ -4951,11 +5065,42 @@ var Account = class extends import_interfaces.AbstractAccount {
4951
5065
  });
4952
5066
  }
4953
5067
  });
4954
- const needsToBeFunded = missingQuantities.length;
4955
- if (needsToBeFunded) {
4956
- const excludedIds = cacheTxInputsFromOwner(txRequest.inputs, this.address.toB256());
4957
- const resources = await this.getResourcesToSpend(missingQuantities, excludedIds);
4958
- txRequest.addResources(resources);
5068
+ let needsToBeFunded = missingQuantities.length > 0;
5069
+ let fundingAttempts = 0;
5070
+ while (needsToBeFunded && fundingAttempts < MAX_FUNDING_ATTEMPTS) {
5071
+ const resources = await this.getResourcesToSpend(
5072
+ missingQuantities,
5073
+ cacheTxInputsFromOwner(request.inputs, this.address)
5074
+ );
5075
+ request.addResources(resources);
5076
+ txRequest.shiftPredicateData();
5077
+ txRequest.updatePredicateGasUsed(estimatedPredicates);
5078
+ const requestToReestimate2 = (0, import_ramda4.clone)(txRequest);
5079
+ if (addedSignatures) {
5080
+ Array.from({ length: addedSignatures }).forEach(
5081
+ () => requestToReestimate2.addEmptyWitness()
5082
+ );
5083
+ }
5084
+ const { maxFee: newFee } = await this.provider.estimateTxGasAndFee({
5085
+ transactionRequest: requestToReestimate2
5086
+ });
5087
+ const totalBaseAssetOnInputs = getAssetAmountInRequestInputs(
5088
+ request.inputs,
5089
+ baseAssetId,
5090
+ baseAssetId
5091
+ );
5092
+ const totalBaseAssetRequiredWithFee = requiredInBaseAsset.add(newFee);
5093
+ if (totalBaseAssetOnInputs.gt(totalBaseAssetRequiredWithFee)) {
5094
+ needsToBeFunded = false;
5095
+ } else {
5096
+ missingQuantities = [
5097
+ {
5098
+ amount: totalBaseAssetRequiredWithFee.sub(totalBaseAssetOnInputs),
5099
+ assetId: baseAssetId
5100
+ }
5101
+ ];
5102
+ }
5103
+ fundingAttempts += 1;
4959
5104
  }
4960
5105
  txRequest.shiftPredicateData();
4961
5106
  txRequest.updatePredicateGasUsed(estimatedPredicates);
@@ -5006,7 +5151,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5006
5151
  * @returns A promise that resolves to the transaction response.
5007
5152
  */
5008
5153
  async transfer(destination, amount, assetId, txParams = {}) {
5009
- if ((0, import_math19.bn)(amount).lte(0)) {
5154
+ if ((0, import_math21.bn)(amount).lte(0)) {
5010
5155
  throw new import_errors16.FuelError(
5011
5156
  import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
5012
5157
  "Transfer amount must be a positive number."
@@ -5026,7 +5171,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5026
5171
  * @returns A promise that resolves to the transaction response.
5027
5172
  */
5028
5173
  async transferToContract(contractId, amount, assetId, txParams = {}) {
5029
- if ((0, import_math19.bn)(amount).lte(0)) {
5174
+ if ((0, import_math21.bn)(amount).lte(0)) {
5030
5175
  throw new import_errors16.FuelError(
5031
5176
  import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
5032
5177
  "Transfer amount must be a positive number."
@@ -5036,7 +5181,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5036
5181
  const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
5037
5182
  const { script, scriptData } = await assembleTransferToContractScript({
5038
5183
  hexlifiedContractId: contractAddress.toB256(),
5039
- amountToTransfer: (0, import_math19.bn)(amount),
5184
+ amountToTransfer: (0, import_math21.bn)(amount),
5040
5185
  assetId: assetIdToTransfer
5041
5186
  });
5042
5187
  const request = new ScriptTransactionRequest({
@@ -5047,7 +5192,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5047
5192
  request.addContractInputAndOutput(contractAddress);
5048
5193
  const txCost = await this.provider.getTransactionCost(request, {
5049
5194
  resourcesOwner: this,
5050
- quantitiesToContract: [{ amount: (0, import_math19.bn)(amount), assetId: String(assetIdToTransfer) }]
5195
+ quantitiesToContract: [{ amount: (0, import_math21.bn)(amount), assetId: String(assetIdToTransfer) }]
5051
5196
  });
5052
5197
  this.validateGasLimitAndMaxFee({
5053
5198
  gasUsed: txCost.gasUsed,
@@ -5073,7 +5218,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5073
5218
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
5074
5219
  );
5075
5220
  const amountDataArray = (0, import_utils27.arrayify)(
5076
- "0x".concat((0, import_math19.bn)(amount).toHex().substring(2).padStart(16, "0"))
5221
+ "0x".concat((0, import_math21.bn)(amount).toHex().substring(2).padStart(16, "0"))
5077
5222
  );
5078
5223
  const script = new Uint8Array([
5079
5224
  ...(0, import_utils27.arrayify)(withdrawScript.bytes),
@@ -5083,7 +5228,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5083
5228
  const params = { script, ...txParams };
5084
5229
  const baseAssetId = this.provider.getBaseAssetId();
5085
5230
  const request = new ScriptTransactionRequest(params);
5086
- const quantitiesToContract = [{ amount: (0, import_math19.bn)(amount), assetId: baseAssetId }];
5231
+ const quantitiesToContract = [{ amount: (0, import_math21.bn)(amount), assetId: baseAssetId }];
5087
5232
  const txCost = await this.provider.getTransactionCost(request, { quantitiesToContract });
5088
5233
  this.validateGasLimitAndMaxFee({
5089
5234
  gasUsed: txCost.gasUsed,
@@ -5174,7 +5319,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5174
5319
  var import_address5 = require("@fuel-ts/address");
5175
5320
  var import_crypto2 = require("@fuel-ts/crypto");
5176
5321
  var import_hasher2 = require("@fuel-ts/hasher");
5177
- var import_math20 = require("@fuel-ts/math");
5322
+ var import_math22 = require("@fuel-ts/math");
5178
5323
  var import_utils28 = require("@fuel-ts/utils");
5179
5324
  var import_secp256k1 = require("@noble/curves/secp256k1");
5180
5325
  var Signer = class {
@@ -5194,7 +5339,7 @@ var Signer = class {
5194
5339
  privateKey = `0x${privateKey}`;
5195
5340
  }
5196
5341
  }
5197
- const privateKeyBytes = (0, import_math20.toBytes)(privateKey, 32);
5342
+ const privateKeyBytes = (0, import_math22.toBytes)(privateKey, 32);
5198
5343
  this.privateKey = (0, import_utils28.hexlify)(privateKeyBytes);
5199
5344
  this.publicKey = (0, import_utils28.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
5200
5345
  this.compressedPublicKey = (0, import_utils28.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
@@ -5212,8 +5357,8 @@ var Signer = class {
5212
5357
  */
5213
5358
  sign(data) {
5214
5359
  const signature = import_secp256k1.secp256k1.sign((0, import_utils28.arrayify)(data), (0, import_utils28.arrayify)(this.privateKey));
5215
- const r = (0, import_math20.toBytes)(`0x${signature.r.toString(16)}`, 32);
5216
- const s = (0, import_math20.toBytes)(`0x${signature.s.toString(16)}`, 32);
5360
+ const r = (0, import_math22.toBytes)(`0x${signature.r.toString(16)}`, 32);
5361
+ const s = (0, import_math22.toBytes)(`0x${signature.s.toString(16)}`, 32);
5217
5362
  s[0] |= (signature.recovery || 0) << 7;
5218
5363
  return (0, import_utils28.hexlify)((0, import_utils28.concat)([r, s]));
5219
5364
  }
@@ -5485,16 +5630,16 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
5485
5630
  // src/hdwallet/hdwallet.ts
5486
5631
  var import_errors20 = require("@fuel-ts/errors");
5487
5632
  var import_hasher6 = require("@fuel-ts/hasher");
5488
- var import_math21 = require("@fuel-ts/math");
5633
+ var import_math23 = require("@fuel-ts/math");
5489
5634
  var import_utils34 = require("@fuel-ts/utils");
5490
- var import_ethers3 = require("ethers");
5635
+ var import_ethers2 = require("ethers");
5491
5636
 
5492
5637
  // src/mnemonic/mnemonic.ts
5493
5638
  var import_crypto4 = require("@fuel-ts/crypto");
5494
5639
  var import_errors19 = require("@fuel-ts/errors");
5495
5640
  var import_hasher5 = require("@fuel-ts/hasher");
5496
5641
  var import_utils32 = require("@fuel-ts/utils");
5497
- var import_ethers2 = require("ethers");
5642
+ var import_ethers = require("ethers");
5498
5643
 
5499
5644
  // src/wordlists/words/english.ts
5500
5645
  var english = [
@@ -7742,7 +7887,7 @@ var Mnemonic = class {
7742
7887
  assertMnemonic(getWords(phrase));
7743
7888
  const phraseBytes = toUtf8Bytes(getPhrase(phrase));
7744
7889
  const salt = toUtf8Bytes(`mnemonic${passphrase}`);
7745
- return (0, import_ethers2.pbkdf2)(phraseBytes, salt, 2048, 64, "sha512");
7890
+ return (0, import_ethers.pbkdf2)(phraseBytes, salt, 2048, 64, "sha512");
7746
7891
  }
7747
7892
  /**
7748
7893
  * @param phrase - Mnemonic phrase composed by words from the provided wordlist
@@ -7804,7 +7949,7 @@ var Mnemonic = class {
7804
7949
  `Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
7805
7950
  );
7806
7951
  }
7807
- return (0, import_utils32.arrayify)((0, import_ethers2.computeHmac)("sha512", MasterSecret, seedArray));
7952
+ return (0, import_utils32.arrayify)((0, import_ethers.computeHmac)("sha512", MasterSecret, seedArray));
7808
7953
  }
7809
7954
  /**
7810
7955
  * Get the extendKey as defined on BIP-32 from the provided seed
@@ -7829,8 +7974,8 @@ var Mnemonic = class {
7829
7974
  chainCode,
7830
7975
  (0, import_utils32.concat)(["0x00", privateKey])
7831
7976
  ]);
7832
- const checksum = (0, import_ethers2.dataSlice)((0, import_hasher5.sha256)((0, import_hasher5.sha256)(extendedKey)), 0, 4);
7833
- return (0, import_ethers2.encodeBase58)((0, import_utils32.concat)([extendedKey, checksum]));
7977
+ const checksum = (0, import_ethers.dataSlice)((0, import_hasher5.sha256)((0, import_hasher5.sha256)(extendedKey)), 0, 4);
7978
+ return (0, import_ethers.encodeBase58)((0, import_utils32.concat)([extendedKey, checksum]));
7834
7979
  }
7835
7980
  /**
7836
7981
  * Create a new mnemonic using a randomly generated number as entropy.
@@ -7858,7 +8003,7 @@ var MainnetPUB = (0, import_utils34.hexlify)("0x0488b21e");
7858
8003
  var TestnetPRV2 = (0, import_utils34.hexlify)("0x04358394");
7859
8004
  var TestnetPUB = (0, import_utils34.hexlify)("0x043587cf");
7860
8005
  function base58check(data) {
7861
- return (0, import_ethers3.encodeBase58)((0, import_utils34.concat)([data, (0, import_ethers3.dataSlice)((0, import_hasher6.sha256)((0, import_hasher6.sha256)(data)), 0, 4)]));
8006
+ return (0, import_ethers2.encodeBase58)((0, import_utils34.concat)([data, (0, import_ethers2.dataSlice)((0, import_hasher6.sha256)((0, import_hasher6.sha256)(data)), 0, 4)]));
7862
8007
  }
7863
8008
  function getExtendedKeyPrefix(isPublic = false, testnet = false) {
7864
8009
  if (isPublic) {
@@ -7914,7 +8059,7 @@ var HDWallet = class {
7914
8059
  this.publicKey = (0, import_utils34.hexlify)(config.publicKey);
7915
8060
  }
7916
8061
  this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
7917
- this.fingerprint = (0, import_ethers3.dataSlice)((0, import_ethers3.ripemd160)((0, import_hasher6.sha256)(this.publicKey)), 0, 4);
8062
+ this.fingerprint = (0, import_ethers2.dataSlice)((0, import_ethers2.ripemd160)((0, import_hasher6.sha256)(this.publicKey)), 0, 4);
7918
8063
  this.depth = config.depth || this.depth;
7919
8064
  this.index = config.index || this.index;
7920
8065
  this.chainCode = config.chainCode;
@@ -7945,13 +8090,13 @@ var HDWallet = class {
7945
8090
  } else {
7946
8091
  data.set((0, import_utils34.arrayify)(this.publicKey));
7947
8092
  }
7948
- data.set((0, import_math21.toBytes)(index, 4), 33);
7949
- const bytes = (0, import_utils34.arrayify)((0, import_ethers3.computeHmac)("sha512", chainCode, data));
8093
+ data.set((0, import_math23.toBytes)(index, 4), 33);
8094
+ const bytes = (0, import_utils34.arrayify)((0, import_ethers2.computeHmac)("sha512", chainCode, data));
7950
8095
  const IL = bytes.slice(0, 32);
7951
8096
  const IR = bytes.slice(32);
7952
8097
  if (privateKey) {
7953
8098
  const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
7954
- const ki = (0, import_math21.bn)(IL).add(privateKey).mod(N).toBytes(32);
8099
+ const ki = (0, import_math23.bn)(IL).add(privateKey).mod(N).toBytes(32);
7955
8100
  return new HDWallet({
7956
8101
  privateKey: ki,
7957
8102
  chainCode: IR,
@@ -7997,7 +8142,7 @@ var HDWallet = class {
7997
8142
  const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
7998
8143
  const depth = (0, import_utils34.hexlify)(Uint8Array.from([this.depth]));
7999
8144
  const parentFingerprint = this.parentFingerprint;
8000
- const index = (0, import_math21.toHex)(this.index, 4);
8145
+ const index = (0, import_math23.toHex)(this.index, 4);
8001
8146
  const chainCode = this.chainCode;
8002
8147
  const key = this.privateKey != null && !isPublic ? (0, import_utils34.concat)(["0x00", this.privateKey]) : this.publicKey;
8003
8148
  const extendedKey = (0, import_utils34.arrayify)((0, import_utils34.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
@@ -8017,7 +8162,7 @@ var HDWallet = class {
8017
8162
  });
8018
8163
  }
8019
8164
  static fromExtendedKey(extendedKey) {
8020
- const decoded = (0, import_ethers3.toBeHex)((0, import_ethers3.decodeBase58)(extendedKey));
8165
+ const decoded = (0, import_ethers2.toBeHex)((0, import_ethers2.decodeBase58)(extendedKey));
8021
8166
  const bytes = (0, import_utils34.arrayify)(decoded);
8022
8167
  const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
8023
8168
  if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
@@ -8366,9 +8511,11 @@ var launchNode = async ({
8366
8511
  const chainConfigWritePath = import_path.default.join(tempDirPath, "chainConfig.json");
8367
8512
  const stateConfigWritePath = import_path.default.join(tempDirPath, "stateConfig.json");
8368
8513
  const metadataWritePath = import_path.default.join(tempDirPath, "metadata.json");
8514
+ const stateTransitionWritePath = import_path.default.join(tempDirPath, "state_transition_bytecode.wasm");
8369
8515
  (0, import_fs.writeFileSync)(chainConfigWritePath, JSON.stringify(chainConfigJson), "utf8");
8370
8516
  (0, import_fs.writeFileSync)(stateConfigWritePath, fixedStateConfigJSON, "utf8");
8371
8517
  (0, import_fs.writeFileSync)(metadataWritePath, JSON.stringify(metadataJson), "utf8");
8518
+ (0, import_fs.writeFileSync)(stateTransitionWritePath, JSON.stringify(""));
8372
8519
  snapshotDirToUse = tempDirPath;
8373
8520
  }
8374
8521
  const child = (0, import_child_process.spawn)(