@fuel-ts/account 0.83.0 → 0.84.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

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 -1619
  5. package/dist/index.global.js.map +1 -1
  6. package/dist/index.js +365 -207
  7. package/dist/index.js.map +1 -1
  8. package/dist/index.mjs +346 -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 -1622
  47. package/dist/test-utils.global.js.map +1 -1
  48. package/dist/test-utils.js +342 -196
  49. package/dist/test-utils.js.map +1 -1
  50. package/dist/test-utils.mjs +327 -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,10 @@ 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
+ feeParameters: { gasPerByte },
2571
+ txParameters: { maxGasPerTx }
2572
+ } = consensusParameters;
2532
2573
  const witnessesLength = this.toTransaction().witnesses.reduce(
2533
2574
  (acc, wit) => acc + wit.dataLength,
2534
2575
  0
@@ -2616,10 +2657,10 @@ var transactionRequestify = (obj) => {
2616
2657
  };
2617
2658
  var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
2618
2659
  (acc, input) => {
2619
- if (input.type === import_transactions10.InputType.Coin && input.owner === owner) {
2660
+ if (input.type === import_transactions10.InputType.Coin && input.owner === owner.toB256()) {
2620
2661
  acc.utxos.push(input.id);
2621
2662
  }
2622
- if (input.type === import_transactions10.InputType.Message && input.recipient === owner) {
2663
+ if (input.type === import_transactions10.InputType.Message && input.recipient === owner.toB256()) {
2623
2664
  acc.messages.push(input.nonce);
2624
2665
  }
2625
2666
  return acc;
@@ -2632,40 +2673,40 @@ var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
2632
2673
 
2633
2674
  // src/providers/transaction-response/transaction-response.ts
2634
2675
  var import_errors13 = require("@fuel-ts/errors");
2635
- var import_math15 = require("@fuel-ts/math");
2676
+ var import_math16 = require("@fuel-ts/math");
2636
2677
  var import_transactions18 = require("@fuel-ts/transactions");
2637
2678
  var import_utils20 = require("@fuel-ts/utils");
2638
2679
 
2639
2680
  // src/providers/transaction-summary/assemble-transaction-summary.ts
2640
- var import_math14 = require("@fuel-ts/math");
2681
+ var import_math15 = require("@fuel-ts/math");
2641
2682
  var import_transactions16 = require("@fuel-ts/transactions");
2642
2683
  var import_utils18 = require("@fuel-ts/utils");
2643
2684
 
2644
- // src/providers/transaction-summary/calculate-transaction-fee.ts
2685
+ // src/providers/transaction-summary/calculate-tx-fee-for-summary.ts
2645
2686
  var import_math11 = require("@fuel-ts/math");
2646
2687
  var import_transactions11 = require("@fuel-ts/transactions");
2647
2688
  var import_utils16 = require("@fuel-ts/utils");
2648
- var calculateTransactionFee = (params) => {
2689
+ var calculateTXFeeForSummary = (params) => {
2649
2690
  const {
2650
2691
  gasPrice,
2651
2692
  rawPayload,
2652
2693
  tip,
2694
+ totalFee,
2653
2695
  consensusParameters: { gasCosts, feeParams, maxGasPerTx }
2654
2696
  } = params;
2697
+ if (totalFee) {
2698
+ return totalFee;
2699
+ }
2655
2700
  const gasPerByte = (0, import_math11.bn)(feeParams.gasPerByte);
2656
2701
  const gasPriceFactor = (0, import_math11.bn)(feeParams.gasPriceFactor);
2657
2702
  const transactionBytes = (0, import_utils16.arrayify)(rawPayload);
2658
2703
  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
2704
  const { type, witnesses, inputs, policies } = transaction;
2667
2705
  let metadataGas = (0, import_math11.bn)(0);
2668
2706
  let gasLimit = (0, import_math11.bn)(0);
2707
+ if (type !== import_transactions11.TransactionType.Create && type !== import_transactions11.TransactionType.Script) {
2708
+ return (0, import_math11.bn)(0);
2709
+ }
2669
2710
  if (type === import_transactions11.TransactionType.Create) {
2670
2711
  const { bytecodeWitnessIndex, storageSlots } = transaction;
2671
2712
  const contractBytesSize = (0, import_math11.bn)((0, import_utils16.arrayify)(witnesses[bytecodeWitnessIndex].data).length);
@@ -2702,23 +2743,13 @@ var calculateTransactionFee = (params) => {
2702
2743
  witnessLimit,
2703
2744
  maxGasPerTx
2704
2745
  });
2705
- const minFee = calculateGasFee({
2706
- gasPrice,
2707
- gas: minGas,
2708
- priceFactor: gasPriceFactor,
2709
- tip
2710
- });
2711
2746
  const maxFee = calculateGasFee({
2712
2747
  gasPrice,
2713
2748
  gas: maxGas,
2714
2749
  priceFactor: gasPriceFactor,
2715
2750
  tip
2716
2751
  });
2717
- return {
2718
- minFee,
2719
- maxFee,
2720
- fee: maxFee
2721
- };
2752
+ return maxFee;
2722
2753
  };
2723
2754
 
2724
2755
  // src/providers/transaction-summary/operations.ts
@@ -2877,6 +2908,12 @@ function isTypeCreate(transactionType) {
2877
2908
  function isTypeScript(transactionType) {
2878
2909
  return isType(transactionType, "Script" /* Script */);
2879
2910
  }
2911
+ function isTypeUpgrade(transactionType) {
2912
+ return isType(transactionType, "Upgrade" /* Upgrade */);
2913
+ }
2914
+ function isTypeUpload(transactionType) {
2915
+ return isType(transactionType, "Upload" /* Upload */);
2916
+ }
2880
2917
  function getReceiptsCall(receipts) {
2881
2918
  return getReceiptsByType(receipts, import_transactions14.ReceiptType.Call);
2882
2919
  }
@@ -3217,6 +3254,7 @@ var extractBurnedAssetsFromReceipts = (receipts) => {
3217
3254
 
3218
3255
  // src/providers/transaction-summary/status.ts
3219
3256
  var import_errors12 = require("@fuel-ts/errors");
3257
+ var import_math14 = require("@fuel-ts/math");
3220
3258
  var getTransactionStatusName = (gqlStatus) => {
3221
3259
  switch (gqlStatus) {
3222
3260
  case "FailureStatus":
@@ -3238,6 +3276,8 @@ var processGraphqlStatus = (gqlTransactionStatus) => {
3238
3276
  let time;
3239
3277
  let blockId;
3240
3278
  let status;
3279
+ let totalFee;
3280
+ let totalGas;
3241
3281
  let isStatusFailure = false;
3242
3282
  let isStatusSuccess = false;
3243
3283
  let isStatusPending = false;
@@ -3248,11 +3288,15 @@ var processGraphqlStatus = (gqlTransactionStatus) => {
3248
3288
  time = gqlTransactionStatus.time;
3249
3289
  blockId = gqlTransactionStatus.block.id;
3250
3290
  isStatusSuccess = true;
3291
+ totalFee = (0, import_math14.bn)(gqlTransactionStatus.totalFee);
3292
+ totalGas = (0, import_math14.bn)(gqlTransactionStatus.totalGas);
3251
3293
  break;
3252
3294
  case "FailureStatus":
3253
3295
  time = gqlTransactionStatus.time;
3254
3296
  blockId = gqlTransactionStatus.block.id;
3255
3297
  isStatusFailure = true;
3298
+ totalFee = (0, import_math14.bn)(gqlTransactionStatus.totalFee);
3299
+ totalGas = (0, import_math14.bn)(gqlTransactionStatus.totalGas);
3256
3300
  break;
3257
3301
  case "SubmittedStatus":
3258
3302
  time = gqlTransactionStatus.time;
@@ -3265,6 +3309,8 @@ var processGraphqlStatus = (gqlTransactionStatus) => {
3265
3309
  time,
3266
3310
  blockId,
3267
3311
  status,
3312
+ totalFee,
3313
+ totalGas,
3268
3314
  isStatusFailure,
3269
3315
  isStatusSuccess,
3270
3316
  isStatusPending
@@ -3300,8 +3346,10 @@ function assembleTransactionSummary(params) {
3300
3346
  maxInputs
3301
3347
  });
3302
3348
  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({
3349
+ const tip = (0, import_math15.bn)(transaction.policies?.find((policy) => policy.type === import_transactions16.PolicyType.Tip)?.data);
3350
+ const { isStatusFailure, isStatusPending, isStatusSuccess, blockId, status, time, totalFee } = processGraphqlStatus(gqlTransactionStatus);
3351
+ const fee = calculateTXFeeForSummary({
3352
+ totalFee,
3305
3353
  gasPrice,
3306
3354
  rawPayload,
3307
3355
  tip,
@@ -3314,7 +3362,6 @@ function assembleTransactionSummary(params) {
3314
3362
  }
3315
3363
  }
3316
3364
  });
3317
- const { isStatusFailure, isStatusPending, isStatusSuccess, blockId, status, time } = processGraphqlStatus(gqlTransactionStatus);
3318
3365
  const mintedAssets = extractMintedAssetsFromReceipts(receipts);
3319
3366
  const burnedAssets = extractBurnedAssetsFromReceipts(receipts);
3320
3367
  let date;
@@ -3323,6 +3370,7 @@ function assembleTransactionSummary(params) {
3323
3370
  }
3324
3371
  const transactionSummary = {
3325
3372
  id,
3373
+ tip,
3326
3374
  fee,
3327
3375
  gasUsed,
3328
3376
  operations,
@@ -3336,6 +3384,8 @@ function assembleTransactionSummary(params) {
3336
3384
  isTypeMint: isTypeMint(transaction.type),
3337
3385
  isTypeCreate: isTypeCreate(transaction.type),
3338
3386
  isTypeScript: isTypeScript(transaction.type),
3387
+ isTypeUpgrade: isTypeUpgrade(transaction.type),
3388
+ isTypeUpload: isTypeUpload(transaction.type),
3339
3389
  isStatusFailure,
3340
3390
  isStatusSuccess,
3341
3391
  isStatusPending,
@@ -3367,7 +3417,7 @@ var TransactionResponse = class {
3367
3417
  /** Current provider */
3368
3418
  provider;
3369
3419
  /** Gas used on the transaction */
3370
- gasUsed = (0, import_math15.bn)(0);
3420
+ gasUsed = (0, import_math16.bn)(0);
3371
3421
  /** The graphql Transaction with receipts object. */
3372
3422
  gqlTransaction;
3373
3423
  abis;
@@ -3452,7 +3502,7 @@ var TransactionResponse = class {
3452
3502
  const receipts = txReceipts.map(processGqlReceipt) || [];
3453
3503
  const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
3454
3504
  const gasPrice = await this.provider.getLatestGasPrice();
3455
- const maxInputs = this.provider.getChain().consensusParameters.maxInputs;
3505
+ const maxInputs = this.provider.getChain().consensusParameters.txParameters.maxInputs;
3456
3506
  const transactionSummary = assembleTransactionSummary({
3457
3507
  id: this.id,
3458
3508
  receipts,
@@ -3588,33 +3638,60 @@ var mergeQuantities = (...coinQuantities) => {
3588
3638
  var MAX_RETRIES = 10;
3589
3639
  var processGqlChain = (chain) => {
3590
3640
  const { name, daHeight, consensusParameters, latestBlock } = chain;
3591
- const { contractParams, feeParams, predicateParams, scriptParams, txParams, gasCosts } = consensusParameters;
3641
+ const {
3642
+ contractParams,
3643
+ feeParams,
3644
+ predicateParams,
3645
+ scriptParams,
3646
+ txParams,
3647
+ gasCosts,
3648
+ baseAssetId,
3649
+ chainId,
3650
+ version
3651
+ } = consensusParameters;
3592
3652
  return {
3593
3653
  name,
3594
- baseChainHeight: (0, import_math16.bn)(daHeight),
3654
+ baseChainHeight: (0, import_math17.bn)(daHeight),
3595
3655
  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,
3656
+ version,
3657
+ chainId: (0, import_math17.bn)(chainId),
3658
+ baseAssetId,
3659
+ feeParameters: {
3660
+ version: feeParams.version,
3661
+ gasPerByte: (0, import_math17.bn)(feeParams.gasPerByte),
3662
+ gasPriceFactor: (0, import_math17.bn)(feeParams.gasPriceFactor)
3663
+ },
3664
+ contractParameters: {
3665
+ version: contractParams.version,
3666
+ contractMaxSize: (0, import_math17.bn)(contractParams.contractMaxSize),
3667
+ maxStorageSlots: (0, import_math17.bn)(contractParams.maxStorageSlots)
3668
+ },
3669
+ txParameters: {
3670
+ version: txParams.version,
3671
+ maxInputs: (0, import_math17.bn)(txParams.maxInputs),
3672
+ maxOutputs: (0, import_math17.bn)(txParams.maxOutputs),
3673
+ maxWitnesses: (0, import_math17.bn)(txParams.maxWitnesses),
3674
+ maxGasPerTx: (0, import_math17.bn)(txParams.maxGasPerTx),
3675
+ maxSize: (0, import_math17.bn)(txParams.maxSize),
3676
+ maxBytecodeSubsections: (0, import_math17.bn)(txParams.maxBytecodeSubsections)
3677
+ },
3678
+ predicateParameters: {
3679
+ version: predicateParams.version,
3680
+ maxPredicateLength: (0, import_math17.bn)(predicateParams.maxPredicateLength),
3681
+ maxPredicateDataLength: (0, import_math17.bn)(predicateParams.maxPredicateDataLength),
3682
+ maxGasPerPredicate: (0, import_math17.bn)(predicateParams.maxGasPerPredicate),
3683
+ maxMessageDataLength: (0, import_math17.bn)(predicateParams.maxMessageDataLength)
3684
+ },
3685
+ scriptParameters: {
3686
+ version: scriptParams.version,
3687
+ maxScriptLength: (0, import_math17.bn)(scriptParams.maxScriptLength),
3688
+ maxScriptDataLength: (0, import_math17.bn)(scriptParams.maxScriptDataLength)
3689
+ },
3612
3690
  gasCosts
3613
3691
  },
3614
- gasCosts,
3615
3692
  latestBlock: {
3616
3693
  id: latestBlock.id,
3617
- height: (0, import_math16.bn)(latestBlock.height),
3694
+ height: (0, import_math17.bn)(latestBlock.height),
3618
3695
  time: latestBlock.header.time,
3619
3696
  transactions: latestBlock.transactions.map((i) => ({
3620
3697
  id: i.id
@@ -3708,7 +3785,12 @@ var _Provider = class {
3708
3785
  * Returns some helpful parameters related to gas fees.
3709
3786
  */
3710
3787
  getGasConfig() {
3711
- const { maxGasPerTx, maxGasPerPredicate, gasPriceFactor, gasPerByte, gasCosts } = this.getChain().consensusParameters;
3788
+ const {
3789
+ txParameters: { maxGasPerTx },
3790
+ predicateParameters: { maxGasPerPredicate },
3791
+ feeParameters: { gasPriceFactor, gasPerByte },
3792
+ gasCosts
3793
+ } = this.getChain().consensusParameters;
3712
3794
  return {
3713
3795
  maxGasPerTx,
3714
3796
  maxGasPerPredicate,
@@ -3757,7 +3839,18 @@ var _Provider = class {
3757
3839
  createOperations() {
3758
3840
  const fetchFn = _Provider.getFetchFn(this.options);
3759
3841
  const gqlClient = new import_graphql_request.GraphQLClient(this.url, {
3760
- fetch: (url, requestInit) => fetchFn(url, requestInit, this.options)
3842
+ fetch: (url, requestInit) => fetchFn(url, requestInit, this.options),
3843
+ responseMiddleware: (response) => {
3844
+ if ("response" in response) {
3845
+ const graphQlResponse = response.response;
3846
+ if (Array.isArray(graphQlResponse?.errors)) {
3847
+ throw new import_errors14.FuelError(
3848
+ import_errors14.FuelError.CODES.INVALID_REQUEST,
3849
+ graphQlResponse.errors.map((err) => err.message).join("\n\n")
3850
+ );
3851
+ }
3852
+ }
3853
+ }
3761
3854
  });
3762
3855
  const executeQuery = (query, vars) => {
3763
3856
  const opDefinition = query.definitions.find((x) => x.kind === "OperationDefinition");
@@ -3785,21 +3878,6 @@ var _Provider = class {
3785
3878
  } = await this.operations.getVersion();
3786
3879
  return nodeVersion;
3787
3880
  }
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
3881
  /**
3804
3882
  * Returns the block number.
3805
3883
  *
@@ -3807,7 +3885,7 @@ var _Provider = class {
3807
3885
  */
3808
3886
  async getBlockNumber() {
3809
3887
  const { chain } = await this.operations.getChain();
3810
- return (0, import_math16.bn)(chain.latestBlock.height, 10);
3888
+ return (0, import_math17.bn)(chain.latestBlock.height, 10);
3811
3889
  }
3812
3890
  /**
3813
3891
  * Returns the chain information.
@@ -3817,8 +3895,8 @@ var _Provider = class {
3817
3895
  async fetchNode() {
3818
3896
  const { nodeInfo } = await this.operations.getNodeInfo();
3819
3897
  const processedNodeInfo = {
3820
- maxDepth: (0, import_math16.bn)(nodeInfo.maxDepth),
3821
- maxTx: (0, import_math16.bn)(nodeInfo.maxTx),
3898
+ maxDepth: (0, import_math17.bn)(nodeInfo.maxDepth),
3899
+ maxTx: (0, import_math17.bn)(nodeInfo.maxTx),
3822
3900
  nodeVersion: nodeInfo.nodeVersion,
3823
3901
  utxoValidation: nodeInfo.utxoValidation,
3824
3902
  vmBacktrace: nodeInfo.vmBacktrace
@@ -3922,9 +4000,9 @@ var _Provider = class {
3922
4000
  encodedTransactions: encodedTransaction,
3923
4001
  utxoValidation: utxoValidation || false
3924
4002
  });
3925
- const [{ receipts: rawReceipts, status }] = dryRunStatuses;
4003
+ const [{ receipts: rawReceipts, status: dryRunStatus }] = dryRunStatuses;
3926
4004
  const receipts = rawReceipts.map(processGqlReceipt);
3927
- return { receipts, dryrunStatus: status };
4005
+ return { receipts, dryRunStatus };
3928
4006
  }
3929
4007
  /**
3930
4008
  * Verifies whether enough gas is available to complete transaction.
@@ -3935,7 +4013,7 @@ var _Provider = class {
3935
4013
  async estimatePredicates(transactionRequest) {
3936
4014
  const shouldEstimatePredicates = Boolean(
3937
4015
  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()
4016
+ (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
4017
  )
3940
4018
  );
3941
4019
  if (!shouldEstimatePredicates) {
@@ -3950,7 +4028,7 @@ var _Provider = class {
3950
4028
  } = response;
3951
4029
  if (inputs) {
3952
4030
  inputs.forEach((input, index) => {
3953
- if ("predicateGasUsed" in input && (0, import_math16.bn)(input.predicateGasUsed).gt(0)) {
4031
+ if ("predicateGasUsed" in input && (0, import_math17.bn)(input.predicateGasUsed).gt(0)) {
3954
4032
  transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
3955
4033
  }
3956
4034
  });
@@ -3978,7 +4056,7 @@ var _Provider = class {
3978
4056
  let receipts = [];
3979
4057
  const missingContractIds = [];
3980
4058
  let outputVariables = 0;
3981
- let dryrunStatus;
4059
+ let dryRunStatus;
3982
4060
  for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
3983
4061
  const {
3984
4062
  dryRun: [{ receipts: rawReceipts, status }]
@@ -3987,7 +4065,7 @@ var _Provider = class {
3987
4065
  utxoValidation: false
3988
4066
  });
3989
4067
  receipts = rawReceipts.map(processGqlReceipt);
3990
- dryrunStatus = status;
4068
+ dryRunStatus = status;
3991
4069
  const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
3992
4070
  const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
3993
4071
  if (hasMissingOutputs) {
@@ -4009,7 +4087,7 @@ var _Provider = class {
4009
4087
  receipts,
4010
4088
  outputVariables,
4011
4089
  missingContractIds,
4012
- dryrunStatus
4090
+ dryRunStatus
4013
4091
  };
4014
4092
  }
4015
4093
  /**
@@ -4027,7 +4105,7 @@ var _Provider = class {
4027
4105
  receipts: [],
4028
4106
  outputVariables: 0,
4029
4107
  missingContractIds: [],
4030
- dryrunStatus: void 0
4108
+ dryRunStatus: void 0
4031
4109
  }));
4032
4110
  const allRequests = (0, import_ramda3.clone)(transactionRequests);
4033
4111
  const serializedTransactionsMap = /* @__PURE__ */ new Map();
@@ -4052,7 +4130,7 @@ var _Provider = class {
4052
4130
  const { receipts: rawReceipts, status } = dryRunResults.dryRun[i];
4053
4131
  const result = results[requestIdx];
4054
4132
  result.receipts = rawReceipts.map(processGqlReceipt);
4055
- result.dryrunStatus = status;
4133
+ result.dryRunStatus = status;
4056
4134
  const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(
4057
4135
  result.receipts
4058
4136
  );
@@ -4089,7 +4167,7 @@ var _Provider = class {
4089
4167
  });
4090
4168
  const results = dryRunStatuses.map(({ receipts: rawReceipts, status }) => {
4091
4169
  const receipts = rawReceipts.map(processGqlReceipt);
4092
- return { receipts, dryrunStatus: status };
4170
+ return { receipts, dryRunStatus: status };
4093
4171
  });
4094
4172
  return results;
4095
4173
  }
@@ -4108,12 +4186,12 @@ var _Provider = class {
4108
4186
  gasPrice = await this.estimateGasPrice(10);
4109
4187
  }
4110
4188
  const minFee = calculateGasFee({
4111
- gasPrice: (0, import_math16.bn)(gasPrice),
4189
+ gasPrice: (0, import_math17.bn)(gasPrice),
4112
4190
  gas: minGas,
4113
4191
  priceFactor: gasPriceFactor,
4114
4192
  tip: transactionRequest.tip
4115
4193
  }).add(1);
4116
- let gasLimit = (0, import_math16.bn)(0);
4194
+ let gasLimit = (0, import_math17.bn)(0);
4117
4195
  if (transactionRequest.type === import_transactions19.TransactionType.Script) {
4118
4196
  gasLimit = transactionRequest.gasLimit;
4119
4197
  if (transactionRequest.gasLimit.eq(0)) {
@@ -4126,7 +4204,7 @@ var _Provider = class {
4126
4204
  }
4127
4205
  const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
4128
4206
  const maxFee = calculateGasFee({
4129
- gasPrice: (0, import_math16.bn)(gasPrice),
4207
+ gasPrice: (0, import_math17.bn)(gasPrice),
4130
4208
  gas: maxGas,
4131
4209
  priceFactor: gasPriceFactor,
4132
4210
  tip: transactionRequest.tip
@@ -4189,9 +4267,9 @@ var _Provider = class {
4189
4267
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
4190
4268
  const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
4191
4269
  txRequestClone.fundWithFakeUtxos(allQuantities, baseAssetId, resourcesOwner?.address);
4192
- txRequestClone.maxFee = (0, import_math16.bn)(0);
4270
+ txRequestClone.maxFee = (0, import_math17.bn)(0);
4193
4271
  if (isScriptTransaction) {
4194
- txRequestClone.gasLimit = (0, import_math16.bn)(0);
4272
+ txRequestClone.gasLimit = (0, import_math17.bn)(0);
4195
4273
  }
4196
4274
  if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
4197
4275
  resourcesOwner.populateTransactionPredicateData(txRequestClone);
@@ -4208,9 +4286,10 @@ var _Provider = class {
4208
4286
  transactionRequest: signedRequest
4209
4287
  });
4210
4288
  let receipts = [];
4289
+ let dryRunStatus;
4211
4290
  let missingContractIds = [];
4212
4291
  let outputVariables = 0;
4213
- let gasUsed = (0, import_math16.bn)(0);
4292
+ let gasUsed = (0, import_math17.bn)(0);
4214
4293
  txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
4215
4294
  txRequestClone.maxFee = maxFee;
4216
4295
  if (isScriptTransaction) {
@@ -4218,10 +4297,7 @@ var _Provider = class {
4218
4297
  if (signatureCallback) {
4219
4298
  await signatureCallback(txRequestClone);
4220
4299
  }
4221
- const result = await this.estimateTxDependencies(txRequestClone);
4222
- receipts = result.receipts;
4223
- outputVariables = result.outputVariables;
4224
- missingContractIds = result.missingContractIds;
4300
+ ({ receipts, missingContractIds, outputVariables, dryRunStatus } = await this.estimateTxDependencies(txRequestClone));
4225
4301
  gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
4226
4302
  txRequestClone.gasLimit = gasUsed;
4227
4303
  ({ maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
@@ -4241,7 +4317,8 @@ var _Provider = class {
4241
4317
  outputVariables,
4242
4318
  missingContractIds,
4243
4319
  addedSignatures,
4244
- estimatedPredicates: txRequestClone.inputs
4320
+ estimatedPredicates: txRequestClone.inputs,
4321
+ dryRunStatus
4245
4322
  };
4246
4323
  }
4247
4324
  async getResourcesForTransaction(owner, transactionRequestLike, quantitiesToContract = []) {
@@ -4277,10 +4354,10 @@ var _Provider = class {
4277
4354
  return coins.map((coin) => ({
4278
4355
  id: coin.utxoId,
4279
4356
  assetId: coin.assetId,
4280
- amount: (0, import_math16.bn)(coin.amount),
4357
+ amount: (0, import_math17.bn)(coin.amount),
4281
4358
  owner: import_address3.Address.fromAddressOrString(coin.owner),
4282
- blockCreated: (0, import_math16.bn)(coin.blockCreated),
4283
- txCreatedIdx: (0, import_math16.bn)(coin.txCreatedIdx)
4359
+ blockCreated: (0, import_math17.bn)(coin.blockCreated),
4360
+ txCreatedIdx: (0, import_math17.bn)(coin.txCreatedIdx)
4284
4361
  }));
4285
4362
  }
4286
4363
  /**
@@ -4317,9 +4394,9 @@ var _Provider = class {
4317
4394
  switch (coin.__typename) {
4318
4395
  case "MessageCoin":
4319
4396
  return {
4320
- amount: (0, import_math16.bn)(coin.amount),
4397
+ amount: (0, import_math17.bn)(coin.amount),
4321
4398
  assetId: coin.assetId,
4322
- daHeight: (0, import_math16.bn)(coin.daHeight),
4399
+ daHeight: (0, import_math17.bn)(coin.daHeight),
4323
4400
  sender: import_address3.Address.fromAddressOrString(coin.sender),
4324
4401
  recipient: import_address3.Address.fromAddressOrString(coin.recipient),
4325
4402
  nonce: coin.nonce
@@ -4327,11 +4404,11 @@ var _Provider = class {
4327
4404
  case "Coin":
4328
4405
  return {
4329
4406
  id: coin.utxoId,
4330
- amount: (0, import_math16.bn)(coin.amount),
4407
+ amount: (0, import_math17.bn)(coin.amount),
4331
4408
  assetId: coin.assetId,
4332
4409
  owner: import_address3.Address.fromAddressOrString(coin.owner),
4333
- blockCreated: (0, import_math16.bn)(coin.blockCreated),
4334
- txCreatedIdx: (0, import_math16.bn)(coin.txCreatedIdx)
4410
+ blockCreated: (0, import_math17.bn)(coin.blockCreated),
4411
+ txCreatedIdx: (0, import_math17.bn)(coin.txCreatedIdx)
4335
4412
  };
4336
4413
  default:
4337
4414
  return null;
@@ -4348,13 +4425,13 @@ var _Provider = class {
4348
4425
  async getBlock(idOrHeight) {
4349
4426
  let variables;
4350
4427
  if (typeof idOrHeight === "number") {
4351
- variables = { height: (0, import_math16.bn)(idOrHeight).toString(10) };
4428
+ variables = { height: (0, import_math17.bn)(idOrHeight).toString(10) };
4352
4429
  } else if (idOrHeight === "latest") {
4353
4430
  variables = { height: (await this.getBlockNumber()).toString(10) };
4354
4431
  } else if (idOrHeight.length === 66) {
4355
4432
  variables = { blockId: idOrHeight };
4356
4433
  } else {
4357
- variables = { blockId: (0, import_math16.bn)(idOrHeight).toString(10) };
4434
+ variables = { blockId: (0, import_math17.bn)(idOrHeight).toString(10) };
4358
4435
  }
4359
4436
  const { block } = await this.operations.getBlock(variables);
4360
4437
  if (!block) {
@@ -4362,7 +4439,7 @@ var _Provider = class {
4362
4439
  }
4363
4440
  return {
4364
4441
  id: block.id,
4365
- height: (0, import_math16.bn)(block.height),
4442
+ height: (0, import_math17.bn)(block.height),
4366
4443
  time: block.header.time,
4367
4444
  transactionIds: block.transactions.map((tx) => tx.id)
4368
4445
  };
@@ -4377,7 +4454,7 @@ var _Provider = class {
4377
4454
  const { blocks: fetchedData } = await this.operations.getBlocks(params);
4378
4455
  const blocks = fetchedData.edges.map(({ node: block }) => ({
4379
4456
  id: block.id,
4380
- height: (0, import_math16.bn)(block.height),
4457
+ height: (0, import_math17.bn)(block.height),
4381
4458
  time: block.header.time,
4382
4459
  transactionIds: block.transactions.map((tx) => tx.id)
4383
4460
  }));
@@ -4392,7 +4469,7 @@ var _Provider = class {
4392
4469
  async getBlockWithTransactions(idOrHeight) {
4393
4470
  let variables;
4394
4471
  if (typeof idOrHeight === "number") {
4395
- variables = { blockHeight: (0, import_math16.bn)(idOrHeight).toString(10) };
4472
+ variables = { blockHeight: (0, import_math17.bn)(idOrHeight).toString(10) };
4396
4473
  } else if (idOrHeight === "latest") {
4397
4474
  variables = { blockHeight: (await this.getBlockNumber()).toString() };
4398
4475
  } else {
@@ -4404,7 +4481,7 @@ var _Provider = class {
4404
4481
  }
4405
4482
  return {
4406
4483
  id: block.id,
4407
- height: (0, import_math16.bn)(block.height, 10),
4484
+ height: (0, import_math17.bn)(block.height, 10),
4408
4485
  time: block.header.time,
4409
4486
  transactionIds: block.transactions.map((tx) => tx.id),
4410
4487
  transactions: block.transactions.map(
@@ -4453,7 +4530,7 @@ var _Provider = class {
4453
4530
  contract: import_address3.Address.fromAddressOrString(contractId).toB256(),
4454
4531
  asset: (0, import_utils22.hexlify)(assetId)
4455
4532
  });
4456
- return (0, import_math16.bn)(contractBalance.amount, 10);
4533
+ return (0, import_math17.bn)(contractBalance.amount, 10);
4457
4534
  }
4458
4535
  /**
4459
4536
  * Returns the balance for the given owner for the given asset ID.
@@ -4467,7 +4544,7 @@ var _Provider = class {
4467
4544
  owner: import_address3.Address.fromAddressOrString(owner).toB256(),
4468
4545
  assetId: (0, import_utils22.hexlify)(assetId)
4469
4546
  });
4470
- return (0, import_math16.bn)(balance.amount, 10);
4547
+ return (0, import_math17.bn)(balance.amount, 10);
4471
4548
  }
4472
4549
  /**
4473
4550
  * Returns balances for the given owner.
@@ -4485,7 +4562,7 @@ var _Provider = class {
4485
4562
  const balances = result.balances.edges.map((edge) => edge.node);
4486
4563
  return balances.map((balance) => ({
4487
4564
  assetId: balance.assetId,
4488
- amount: (0, import_math16.bn)(balance.amount)
4565
+ amount: (0, import_math17.bn)(balance.amount)
4489
4566
  }));
4490
4567
  }
4491
4568
  /**
@@ -4507,15 +4584,15 @@ var _Provider = class {
4507
4584
  sender: message.sender,
4508
4585
  recipient: message.recipient,
4509
4586
  nonce: message.nonce,
4510
- amount: (0, import_math16.bn)(message.amount),
4587
+ amount: (0, import_math17.bn)(message.amount),
4511
4588
  data: message.data
4512
4589
  }),
4513
4590
  sender: import_address3.Address.fromAddressOrString(message.sender),
4514
4591
  recipient: import_address3.Address.fromAddressOrString(message.recipient),
4515
4592
  nonce: message.nonce,
4516
- amount: (0, import_math16.bn)(message.amount),
4593
+ amount: (0, import_math17.bn)(message.amount),
4517
4594
  data: import_transactions19.InputMessageCoder.decodeData(message.data),
4518
- daHeight: (0, import_math16.bn)(message.daHeight)
4595
+ daHeight: (0, import_math17.bn)(message.daHeight)
4519
4596
  }));
4520
4597
  }
4521
4598
  /**
@@ -4568,59 +4645,59 @@ var _Provider = class {
4568
4645
  } = result.messageProof;
4569
4646
  return {
4570
4647
  messageProof: {
4571
- proofIndex: (0, import_math16.bn)(messageProof.proofIndex),
4648
+ proofIndex: (0, import_math17.bn)(messageProof.proofIndex),
4572
4649
  proofSet: messageProof.proofSet
4573
4650
  },
4574
4651
  blockProof: {
4575
- proofIndex: (0, import_math16.bn)(blockProof.proofIndex),
4652
+ proofIndex: (0, import_math17.bn)(blockProof.proofIndex),
4576
4653
  proofSet: blockProof.proofSet
4577
4654
  },
4578
4655
  messageBlockHeader: {
4579
4656
  id: messageBlockHeader.id,
4580
- daHeight: (0, import_math16.bn)(messageBlockHeader.daHeight),
4581
- transactionsCount: (0, import_math16.bn)(messageBlockHeader.transactionsCount),
4657
+ daHeight: (0, import_math17.bn)(messageBlockHeader.daHeight),
4658
+ transactionsCount: Number(messageBlockHeader.transactionsCount),
4582
4659
  transactionsRoot: messageBlockHeader.transactionsRoot,
4583
- height: (0, import_math16.bn)(messageBlockHeader.height),
4660
+ height: (0, import_math17.bn)(messageBlockHeader.height),
4584
4661
  prevRoot: messageBlockHeader.prevRoot,
4585
4662
  time: messageBlockHeader.time,
4586
4663
  applicationHash: messageBlockHeader.applicationHash,
4587
- messageReceiptCount: (0, import_math16.bn)(messageBlockHeader.messageReceiptCount),
4664
+ messageReceiptCount: Number(messageBlockHeader.messageReceiptCount),
4588
4665
  messageOutboxRoot: messageBlockHeader.messageOutboxRoot,
4589
- consensusParametersVersion: messageBlockHeader.consensusParametersVersion,
4666
+ consensusParametersVersion: Number(messageBlockHeader.consensusParametersVersion),
4590
4667
  eventInboxRoot: messageBlockHeader.eventInboxRoot,
4591
- stateTransitionBytecodeVersion: messageBlockHeader.stateTransitionBytecodeVersion
4668
+ stateTransitionBytecodeVersion: Number(messageBlockHeader.stateTransitionBytecodeVersion)
4592
4669
  },
4593
4670
  commitBlockHeader: {
4594
4671
  id: commitBlockHeader.id,
4595
- daHeight: (0, import_math16.bn)(commitBlockHeader.daHeight),
4596
- transactionsCount: (0, import_math16.bn)(commitBlockHeader.transactionsCount),
4672
+ daHeight: (0, import_math17.bn)(commitBlockHeader.daHeight),
4673
+ transactionsCount: Number(commitBlockHeader.transactionsCount),
4597
4674
  transactionsRoot: commitBlockHeader.transactionsRoot,
4598
- height: (0, import_math16.bn)(commitBlockHeader.height),
4675
+ height: (0, import_math17.bn)(commitBlockHeader.height),
4599
4676
  prevRoot: commitBlockHeader.prevRoot,
4600
4677
  time: commitBlockHeader.time,
4601
4678
  applicationHash: commitBlockHeader.applicationHash,
4602
- messageReceiptCount: (0, import_math16.bn)(commitBlockHeader.messageReceiptCount),
4679
+ messageReceiptCount: Number(commitBlockHeader.messageReceiptCount),
4603
4680
  messageOutboxRoot: commitBlockHeader.messageOutboxRoot,
4604
- consensusParametersVersion: commitBlockHeader.consensusParametersVersion,
4681
+ consensusParametersVersion: Number(commitBlockHeader.consensusParametersVersion),
4605
4682
  eventInboxRoot: commitBlockHeader.eventInboxRoot,
4606
- stateTransitionBytecodeVersion: commitBlockHeader.stateTransitionBytecodeVersion
4683
+ stateTransitionBytecodeVersion: Number(commitBlockHeader.stateTransitionBytecodeVersion)
4607
4684
  },
4608
4685
  sender: import_address3.Address.fromAddressOrString(sender),
4609
4686
  recipient: import_address3.Address.fromAddressOrString(recipient),
4610
4687
  nonce,
4611
- amount: (0, import_math16.bn)(amount),
4688
+ amount: (0, import_math17.bn)(amount),
4612
4689
  data
4613
4690
  };
4614
4691
  }
4615
4692
  async getLatestGasPrice() {
4616
4693
  const { latestGasPrice } = await this.operations.getLatestGasPrice();
4617
- return (0, import_math16.bn)(latestGasPrice.gasPrice);
4694
+ return (0, import_math17.bn)(latestGasPrice.gasPrice);
4618
4695
  }
4619
4696
  async estimateGasPrice(blockHorizon) {
4620
4697
  const { estimateGasPrice } = await this.operations.estimateGasPrice({
4621
4698
  blockHorizon: String(blockHorizon)
4622
4699
  });
4623
- return (0, import_math16.bn)(estimateGasPrice.gasPrice);
4700
+ return (0, import_math17.bn)(estimateGasPrice.gasPrice);
4624
4701
  }
4625
4702
  /**
4626
4703
  * Returns Message Proof for given transaction id and the message id from MessageOut receipt.
@@ -4641,15 +4718,37 @@ var _Provider = class {
4641
4718
  */
4642
4719
  async produceBlocks(amount, startTime) {
4643
4720
  const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
4644
- blocksToProduce: (0, import_math16.bn)(amount).toString(10),
4721
+ blocksToProduce: (0, import_math17.bn)(amount).toString(10),
4645
4722
  startTimestamp: startTime ? import_utils22.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
4646
4723
  });
4647
- return (0, import_math16.bn)(latestBlockHeight);
4724
+ return (0, import_math17.bn)(latestBlockHeight);
4648
4725
  }
4649
4726
  // eslint-disable-next-line @typescript-eslint/require-await
4650
4727
  async getTransactionResponse(transactionId) {
4651
4728
  return new TransactionResponse(transactionId, this);
4652
4729
  }
4730
+ /**
4731
+ * Returns Message for given nonce.
4732
+ *
4733
+ * @param nonce - The nonce of the message to retrieve.
4734
+ * @returns A promise that resolves to the Message object.
4735
+ */
4736
+ async getMessageByNonce(nonce) {
4737
+ const { message } = await this.operations.getMessageByNonce({ nonce });
4738
+ if (!message) {
4739
+ return null;
4740
+ }
4741
+ return message;
4742
+ }
4743
+ async getRelayedTransactionStatus(relayedTransactionId) {
4744
+ const { relayedTransactionStatus } = await this.operations.getRelayedTransactionStatus({
4745
+ relayedTransactionId
4746
+ });
4747
+ if (!relayedTransactionStatus) {
4748
+ return null;
4749
+ }
4750
+ return relayedTransactionStatus;
4751
+ }
4653
4752
  };
4654
4753
  var Provider = _Provider;
4655
4754
  _cacheInputs = new WeakSet();
@@ -4668,7 +4767,7 @@ __publicField(Provider, "nodeInfoCache", {});
4668
4767
 
4669
4768
  // src/providers/transaction-summary/get-transaction-summary.ts
4670
4769
  var import_errors15 = require("@fuel-ts/errors");
4671
- var import_math17 = require("@fuel-ts/math");
4770
+ var import_math18 = require("@fuel-ts/math");
4672
4771
  var import_transactions20 = require("@fuel-ts/transactions");
4673
4772
  var import_utils25 = require("@fuel-ts/utils");
4674
4773
 
@@ -4717,15 +4816,31 @@ var assets = [
4717
4816
  }
4718
4817
  ];
4719
4818
 
4819
+ // src/providers/transaction-request/helpers.ts
4820
+ var import_math19 = require("@fuel-ts/math");
4821
+ var import_transactions21 = require("@fuel-ts/transactions");
4822
+ var isRequestInputCoin = (input) => input.type === import_transactions21.InputType.Coin;
4823
+ var isRequestInputMessage = (input) => input.type === import_transactions21.InputType.Message;
4824
+ var isRequestInputResource = (input) => isRequestInputCoin(input) || isRequestInputMessage(input);
4825
+ var getAssetAmountInRequestInputs = (inputs, assetId, baseAsset) => inputs.filter(isRequestInputResource).reduce((acc, input) => {
4826
+ if (isRequestInputCoin(input) && input.assetId === assetId) {
4827
+ return acc.add(input.amount);
4828
+ }
4829
+ if (isRequestInputMessage(input) && assetId === baseAsset) {
4830
+ return acc.add(input.amount);
4831
+ }
4832
+ return acc;
4833
+ }, (0, import_math19.bn)(0));
4834
+
4720
4835
  // src/utils/formatTransferToContractScriptData.ts
4721
4836
  var import_abi_coder6 = require("@fuel-ts/abi-coder");
4722
- var import_math18 = require("@fuel-ts/math");
4837
+ var import_math20 = require("@fuel-ts/math");
4723
4838
  var import_utils26 = require("@fuel-ts/utils");
4724
4839
  var asm = __toESM(require("@fuels/vm-asm"));
4725
4840
  var formatTransferToContractScriptData = (params) => {
4726
4841
  const { assetId, amountToTransfer, hexlifiedContractId } = params;
4727
4842
  const numberCoder = new import_abi_coder6.BigNumberCoder("u64");
4728
- const encoded = numberCoder.encode(new import_math18.BN(amountToTransfer).toNumber());
4843
+ const encoded = numberCoder.encode(new import_math20.BN(amountToTransfer).toNumber());
4729
4844
  const scriptData = Uint8Array.from([
4730
4845
  ...(0, import_utils26.arrayify)(hexlifiedContractId),
4731
4846
  ...encoded,
@@ -4754,6 +4869,7 @@ var assembleTransferToContractScript = async (params) => {
4754
4869
  };
4755
4870
 
4756
4871
  // src/account.ts
4872
+ var MAX_FUNDING_ATTEMPTS = 2;
4757
4873
  var Account = class extends import_interfaces.AbstractAccount {
4758
4874
  /**
4759
4875
  * The address associated with the account.
@@ -4911,16 +5027,17 @@ var Account = class extends import_interfaces.AbstractAccount {
4911
5027
  * Adds resources to the transaction enough to fund it.
4912
5028
  *
4913
5029
  * @param request - The transaction request.
4914
- * @param coinQuantities - The coin quantities required to execute the transaction.
5030
+ * @param requiredQuantities - The coin quantities required to execute the transaction.
4915
5031
  * @param fee - The estimated transaction fee.
4916
5032
  * @returns A promise that resolves when the resources are added to the transaction.
4917
5033
  */
4918
5034
  async fund(request, params) {
4919
5035
  const { addedSignatures, estimatedPredicates, maxFee: fee, requiredQuantities } = params;
4920
5036
  const baseAssetId = this.provider.getBaseAssetId();
5037
+ const requiredInBaseAsset = requiredQuantities.find((quantity) => quantity.assetId === baseAssetId)?.amount || (0, import_math21.bn)(0);
4921
5038
  const txRequest = request;
4922
5039
  const requiredQuantitiesWithFee = addAmountToCoinQuantities({
4923
- amount: (0, import_math19.bn)(fee),
5040
+ amount: (0, import_math21.bn)(fee),
4924
5041
  assetId: baseAssetId,
4925
5042
  coinQuantities: requiredQuantities
4926
5043
  });
@@ -4928,21 +5045,17 @@ var Account = class extends import_interfaces.AbstractAccount {
4928
5045
  requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
4929
5046
  quantitiesDict[assetId] = {
4930
5047
  required: amount,
4931
- owned: (0, import_math19.bn)(0)
5048
+ owned: (0, import_math21.bn)(0)
4932
5049
  };
4933
5050
  });
4934
- txRequest.inputs.forEach((input) => {
4935
- const isResource = "amount" in input;
4936
- if (!isResource) {
4937
- return;
4938
- }
4939
- const isCoin2 = "owner" in input;
5051
+ request.inputs.filter(isRequestInputResource).forEach((input) => {
5052
+ const isCoin2 = isRequestInputCoin(input);
4940
5053
  const assetId = isCoin2 ? String(input.assetId) : baseAssetId;
4941
5054
  if (quantitiesDict[assetId]) {
4942
5055
  quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(input.amount);
4943
5056
  }
4944
5057
  });
4945
- const missingQuantities = [];
5058
+ let missingQuantities = [];
4946
5059
  Object.entries(quantitiesDict).forEach(([assetId, { owned, required }]) => {
4947
5060
  if (owned.lt(required)) {
4948
5061
  missingQuantities.push({
@@ -4951,11 +5064,42 @@ var Account = class extends import_interfaces.AbstractAccount {
4951
5064
  });
4952
5065
  }
4953
5066
  });
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);
5067
+ let needsToBeFunded = missingQuantities.length > 0;
5068
+ let fundingAttempts = 0;
5069
+ while (needsToBeFunded && fundingAttempts < MAX_FUNDING_ATTEMPTS) {
5070
+ const resources = await this.getResourcesToSpend(
5071
+ missingQuantities,
5072
+ cacheTxInputsFromOwner(request.inputs, this.address)
5073
+ );
5074
+ request.addResources(resources);
5075
+ txRequest.shiftPredicateData();
5076
+ txRequest.updatePredicateGasUsed(estimatedPredicates);
5077
+ const requestToReestimate2 = (0, import_ramda4.clone)(txRequest);
5078
+ if (addedSignatures) {
5079
+ Array.from({ length: addedSignatures }).forEach(
5080
+ () => requestToReestimate2.addEmptyWitness()
5081
+ );
5082
+ }
5083
+ const { maxFee: newFee } = await this.provider.estimateTxGasAndFee({
5084
+ transactionRequest: requestToReestimate2
5085
+ });
5086
+ const totalBaseAssetOnInputs = getAssetAmountInRequestInputs(
5087
+ request.inputs,
5088
+ baseAssetId,
5089
+ baseAssetId
5090
+ );
5091
+ const totalBaseAssetRequiredWithFee = requiredInBaseAsset.add(newFee);
5092
+ if (totalBaseAssetOnInputs.gt(totalBaseAssetRequiredWithFee)) {
5093
+ needsToBeFunded = false;
5094
+ } else {
5095
+ missingQuantities = [
5096
+ {
5097
+ amount: totalBaseAssetRequiredWithFee.sub(totalBaseAssetOnInputs),
5098
+ assetId: baseAssetId
5099
+ }
5100
+ ];
5101
+ }
5102
+ fundingAttempts += 1;
4959
5103
  }
4960
5104
  txRequest.shiftPredicateData();
4961
5105
  txRequest.updatePredicateGasUsed(estimatedPredicates);
@@ -5006,7 +5150,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5006
5150
  * @returns A promise that resolves to the transaction response.
5007
5151
  */
5008
5152
  async transfer(destination, amount, assetId, txParams = {}) {
5009
- if ((0, import_math19.bn)(amount).lte(0)) {
5153
+ if ((0, import_math21.bn)(amount).lte(0)) {
5010
5154
  throw new import_errors16.FuelError(
5011
5155
  import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
5012
5156
  "Transfer amount must be a positive number."
@@ -5026,7 +5170,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5026
5170
  * @returns A promise that resolves to the transaction response.
5027
5171
  */
5028
5172
  async transferToContract(contractId, amount, assetId, txParams = {}) {
5029
- if ((0, import_math19.bn)(amount).lte(0)) {
5173
+ if ((0, import_math21.bn)(amount).lte(0)) {
5030
5174
  throw new import_errors16.FuelError(
5031
5175
  import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
5032
5176
  "Transfer amount must be a positive number."
@@ -5036,7 +5180,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5036
5180
  const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
5037
5181
  const { script, scriptData } = await assembleTransferToContractScript({
5038
5182
  hexlifiedContractId: contractAddress.toB256(),
5039
- amountToTransfer: (0, import_math19.bn)(amount),
5183
+ amountToTransfer: (0, import_math21.bn)(amount),
5040
5184
  assetId: assetIdToTransfer
5041
5185
  });
5042
5186
  const request = new ScriptTransactionRequest({
@@ -5047,7 +5191,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5047
5191
  request.addContractInputAndOutput(contractAddress);
5048
5192
  const txCost = await this.provider.getTransactionCost(request, {
5049
5193
  resourcesOwner: this,
5050
- quantitiesToContract: [{ amount: (0, import_math19.bn)(amount), assetId: String(assetIdToTransfer) }]
5194
+ quantitiesToContract: [{ amount: (0, import_math21.bn)(amount), assetId: String(assetIdToTransfer) }]
5051
5195
  });
5052
5196
  this.validateGasLimitAndMaxFee({
5053
5197
  gasUsed: txCost.gasUsed,
@@ -5073,7 +5217,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5073
5217
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
5074
5218
  );
5075
5219
  const amountDataArray = (0, import_utils27.arrayify)(
5076
- "0x".concat((0, import_math19.bn)(amount).toHex().substring(2).padStart(16, "0"))
5220
+ "0x".concat((0, import_math21.bn)(amount).toHex().substring(2).padStart(16, "0"))
5077
5221
  );
5078
5222
  const script = new Uint8Array([
5079
5223
  ...(0, import_utils27.arrayify)(withdrawScript.bytes),
@@ -5083,7 +5227,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5083
5227
  const params = { script, ...txParams };
5084
5228
  const baseAssetId = this.provider.getBaseAssetId();
5085
5229
  const request = new ScriptTransactionRequest(params);
5086
- const quantitiesToContract = [{ amount: (0, import_math19.bn)(amount), assetId: baseAssetId }];
5230
+ const quantitiesToContract = [{ amount: (0, import_math21.bn)(amount), assetId: baseAssetId }];
5087
5231
  const txCost = await this.provider.getTransactionCost(request, { quantitiesToContract });
5088
5232
  this.validateGasLimitAndMaxFee({
5089
5233
  gasUsed: txCost.gasUsed,
@@ -5174,7 +5318,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5174
5318
  var import_address5 = require("@fuel-ts/address");
5175
5319
  var import_crypto2 = require("@fuel-ts/crypto");
5176
5320
  var import_hasher2 = require("@fuel-ts/hasher");
5177
- var import_math20 = require("@fuel-ts/math");
5321
+ var import_math22 = require("@fuel-ts/math");
5178
5322
  var import_utils28 = require("@fuel-ts/utils");
5179
5323
  var import_secp256k1 = require("@noble/curves/secp256k1");
5180
5324
  var Signer = class {
@@ -5194,7 +5338,7 @@ var Signer = class {
5194
5338
  privateKey = `0x${privateKey}`;
5195
5339
  }
5196
5340
  }
5197
- const privateKeyBytes = (0, import_math20.toBytes)(privateKey, 32);
5341
+ const privateKeyBytes = (0, import_math22.toBytes)(privateKey, 32);
5198
5342
  this.privateKey = (0, import_utils28.hexlify)(privateKeyBytes);
5199
5343
  this.publicKey = (0, import_utils28.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
5200
5344
  this.compressedPublicKey = (0, import_utils28.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
@@ -5212,8 +5356,8 @@ var Signer = class {
5212
5356
  */
5213
5357
  sign(data) {
5214
5358
  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);
5359
+ const r = (0, import_math22.toBytes)(`0x${signature.r.toString(16)}`, 32);
5360
+ const s = (0, import_math22.toBytes)(`0x${signature.s.toString(16)}`, 32);
5217
5361
  s[0] |= (signature.recovery || 0) << 7;
5218
5362
  return (0, import_utils28.hexlify)((0, import_utils28.concat)([r, s]));
5219
5363
  }
@@ -5485,16 +5629,16 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
5485
5629
  // src/hdwallet/hdwallet.ts
5486
5630
  var import_errors20 = require("@fuel-ts/errors");
5487
5631
  var import_hasher6 = require("@fuel-ts/hasher");
5488
- var import_math21 = require("@fuel-ts/math");
5632
+ var import_math23 = require("@fuel-ts/math");
5489
5633
  var import_utils34 = require("@fuel-ts/utils");
5490
- var import_ethers3 = require("ethers");
5634
+ var import_ethers2 = require("ethers");
5491
5635
 
5492
5636
  // src/mnemonic/mnemonic.ts
5493
5637
  var import_crypto4 = require("@fuel-ts/crypto");
5494
5638
  var import_errors19 = require("@fuel-ts/errors");
5495
5639
  var import_hasher5 = require("@fuel-ts/hasher");
5496
5640
  var import_utils32 = require("@fuel-ts/utils");
5497
- var import_ethers2 = require("ethers");
5641
+ var import_ethers = require("ethers");
5498
5642
 
5499
5643
  // src/wordlists/words/english.ts
5500
5644
  var english = [
@@ -7742,7 +7886,7 @@ var Mnemonic = class {
7742
7886
  assertMnemonic(getWords(phrase));
7743
7887
  const phraseBytes = toUtf8Bytes(getPhrase(phrase));
7744
7888
  const salt = toUtf8Bytes(`mnemonic${passphrase}`);
7745
- return (0, import_ethers2.pbkdf2)(phraseBytes, salt, 2048, 64, "sha512");
7889
+ return (0, import_ethers.pbkdf2)(phraseBytes, salt, 2048, 64, "sha512");
7746
7890
  }
7747
7891
  /**
7748
7892
  * @param phrase - Mnemonic phrase composed by words from the provided wordlist
@@ -7804,7 +7948,7 @@ var Mnemonic = class {
7804
7948
  `Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
7805
7949
  );
7806
7950
  }
7807
- return (0, import_utils32.arrayify)((0, import_ethers2.computeHmac)("sha512", MasterSecret, seedArray));
7951
+ return (0, import_utils32.arrayify)((0, import_ethers.computeHmac)("sha512", MasterSecret, seedArray));
7808
7952
  }
7809
7953
  /**
7810
7954
  * Get the extendKey as defined on BIP-32 from the provided seed
@@ -7829,8 +7973,8 @@ var Mnemonic = class {
7829
7973
  chainCode,
7830
7974
  (0, import_utils32.concat)(["0x00", privateKey])
7831
7975
  ]);
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]));
7976
+ const checksum = (0, import_ethers.dataSlice)((0, import_hasher5.sha256)((0, import_hasher5.sha256)(extendedKey)), 0, 4);
7977
+ return (0, import_ethers.encodeBase58)((0, import_utils32.concat)([extendedKey, checksum]));
7834
7978
  }
7835
7979
  /**
7836
7980
  * Create a new mnemonic using a randomly generated number as entropy.
@@ -7858,7 +8002,7 @@ var MainnetPUB = (0, import_utils34.hexlify)("0x0488b21e");
7858
8002
  var TestnetPRV2 = (0, import_utils34.hexlify)("0x04358394");
7859
8003
  var TestnetPUB = (0, import_utils34.hexlify)("0x043587cf");
7860
8004
  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)]));
8005
+ 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
8006
  }
7863
8007
  function getExtendedKeyPrefix(isPublic = false, testnet = false) {
7864
8008
  if (isPublic) {
@@ -7914,7 +8058,7 @@ var HDWallet = class {
7914
8058
  this.publicKey = (0, import_utils34.hexlify)(config.publicKey);
7915
8059
  }
7916
8060
  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);
8061
+ this.fingerprint = (0, import_ethers2.dataSlice)((0, import_ethers2.ripemd160)((0, import_hasher6.sha256)(this.publicKey)), 0, 4);
7918
8062
  this.depth = config.depth || this.depth;
7919
8063
  this.index = config.index || this.index;
7920
8064
  this.chainCode = config.chainCode;
@@ -7945,13 +8089,13 @@ var HDWallet = class {
7945
8089
  } else {
7946
8090
  data.set((0, import_utils34.arrayify)(this.publicKey));
7947
8091
  }
7948
- data.set((0, import_math21.toBytes)(index, 4), 33);
7949
- const bytes = (0, import_utils34.arrayify)((0, import_ethers3.computeHmac)("sha512", chainCode, data));
8092
+ data.set((0, import_math23.toBytes)(index, 4), 33);
8093
+ const bytes = (0, import_utils34.arrayify)((0, import_ethers2.computeHmac)("sha512", chainCode, data));
7950
8094
  const IL = bytes.slice(0, 32);
7951
8095
  const IR = bytes.slice(32);
7952
8096
  if (privateKey) {
7953
8097
  const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
7954
- const ki = (0, import_math21.bn)(IL).add(privateKey).mod(N).toBytes(32);
8098
+ const ki = (0, import_math23.bn)(IL).add(privateKey).mod(N).toBytes(32);
7955
8099
  return new HDWallet({
7956
8100
  privateKey: ki,
7957
8101
  chainCode: IR,
@@ -7997,7 +8141,7 @@ var HDWallet = class {
7997
8141
  const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
7998
8142
  const depth = (0, import_utils34.hexlify)(Uint8Array.from([this.depth]));
7999
8143
  const parentFingerprint = this.parentFingerprint;
8000
- const index = (0, import_math21.toHex)(this.index, 4);
8144
+ const index = (0, import_math23.toHex)(this.index, 4);
8001
8145
  const chainCode = this.chainCode;
8002
8146
  const key = this.privateKey != null && !isPublic ? (0, import_utils34.concat)(["0x00", this.privateKey]) : this.publicKey;
8003
8147
  const extendedKey = (0, import_utils34.arrayify)((0, import_utils34.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
@@ -8017,7 +8161,7 @@ var HDWallet = class {
8017
8161
  });
8018
8162
  }
8019
8163
  static fromExtendedKey(extendedKey) {
8020
- const decoded = (0, import_ethers3.toBeHex)((0, import_ethers3.decodeBase58)(extendedKey));
8164
+ const decoded = (0, import_ethers2.toBeHex)((0, import_ethers2.decodeBase58)(extendedKey));
8021
8165
  const bytes = (0, import_utils34.arrayify)(decoded);
8022
8166
  const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
8023
8167
  if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
@@ -8366,9 +8510,11 @@ var launchNode = async ({
8366
8510
  const chainConfigWritePath = import_path.default.join(tempDirPath, "chainConfig.json");
8367
8511
  const stateConfigWritePath = import_path.default.join(tempDirPath, "stateConfig.json");
8368
8512
  const metadataWritePath = import_path.default.join(tempDirPath, "metadata.json");
8513
+ const stateTransitionWritePath = import_path.default.join(tempDirPath, "state_transition_bytecode.wasm");
8369
8514
  (0, import_fs.writeFileSync)(chainConfigWritePath, JSON.stringify(chainConfigJson), "utf8");
8370
8515
  (0, import_fs.writeFileSync)(stateConfigWritePath, fixedStateConfigJSON, "utf8");
8371
8516
  (0, import_fs.writeFileSync)(metadataWritePath, JSON.stringify(metadataJson), "utf8");
8517
+ (0, import_fs.writeFileSync)(stateTransitionWritePath, JSON.stringify(""));
8372
8518
  snapshotDirToUse = tempDirPath;
8373
8519
  }
8374
8520
  const child = (0, import_child_process.spawn)(