@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
@@ -26,8 +26,8 @@ import { hexlify as hexlify15 } from "@fuel-ts/utils";
26
26
  import { Address as Address3 } from "@fuel-ts/address";
27
27
  import { ErrorCode as ErrorCode15, FuelError as FuelError15 } from "@fuel-ts/errors";
28
28
  import { AbstractAccount } from "@fuel-ts/interfaces";
29
- import { bn as bn18 } from "@fuel-ts/math";
30
- import { arrayify as arrayify14, isDefined } from "@fuel-ts/utils";
29
+ import { bn as bn20 } from "@fuel-ts/math";
30
+ import { arrayify as arrayify14, isDefined as isDefined2 } from "@fuel-ts/utils";
31
31
  import { clone as clone4 } from "ramda";
32
32
 
33
33
  // src/providers/coin-quantity.ts
@@ -68,7 +68,7 @@ var addAmountToCoinQuantities = (params) => {
68
68
  // src/providers/provider.ts
69
69
  import { Address as Address2 } from "@fuel-ts/address";
70
70
  import { ErrorCode as ErrorCode13, FuelError as FuelError13 } from "@fuel-ts/errors";
71
- import { BN, bn as bn16 } from "@fuel-ts/math";
71
+ import { BN, bn as bn17 } from "@fuel-ts/math";
72
72
  import {
73
73
  InputType as InputType7,
74
74
  TransactionType as TransactionType8,
@@ -78,7 +78,6 @@ import {
78
78
  import { arrayify as arrayify11, hexlify as hexlify12, DateTime as DateTime2 } from "@fuel-ts/utils";
79
79
  import { checkFuelCoreVersionCompatibility } from "@fuel-ts/versions";
80
80
  import { equalBytes } from "@noble/curves/abstract/utils";
81
- import { Network } from "ethers";
82
81
  import { GraphQLClient } from "graphql-request";
83
82
  import { clone as clone3 } from "ramda";
84
83
 
@@ -135,9 +134,6 @@ var TransactionStatusFragmentFragmentDoc = gql`
135
134
  id
136
135
  }
137
136
  time
138
- receipts {
139
- ...receiptFragment
140
- }
141
137
  programState {
142
138
  returnType
143
139
  data
@@ -145,11 +141,15 @@ var TransactionStatusFragmentFragmentDoc = gql`
145
141
  receipts {
146
142
  ...receiptFragment
147
143
  }
144
+ totalGas
145
+ totalFee
148
146
  }
149
147
  ... on FailureStatus {
150
148
  block {
151
149
  id
152
150
  }
151
+ totalGas
152
+ totalFee
153
153
  time
154
154
  reason
155
155
  receipts {
@@ -189,6 +189,8 @@ var TransactionEstimatePredicatesFragmentFragmentDoc = gql`
189
189
  ${InputEstimatePredicatesFragmentFragmentDoc}`;
190
190
  var DryRunFailureStatusFragmentFragmentDoc = gql`
191
191
  fragment dryRunFailureStatusFragment on DryRunFailureStatus {
192
+ totalGas
193
+ totalFee
192
194
  reason
193
195
  programState {
194
196
  returnType
@@ -198,6 +200,8 @@ var DryRunFailureStatusFragmentFragmentDoc = gql`
198
200
  `;
199
201
  var DryRunSuccessStatusFragmentFragmentDoc = gql`
200
202
  fragment dryRunSuccessStatusFragment on DryRunSuccessStatus {
203
+ totalGas
204
+ totalFee
201
205
  programState {
202
206
  returnType
203
207
  data
@@ -333,6 +337,7 @@ var TxParametersFragmentFragmentDoc = gql`
333
337
  maxWitnesses
334
338
  maxGasPerTx
335
339
  maxSize
340
+ maxBytecodeSubsections
336
341
  }
337
342
  `;
338
343
  var PredicateParametersFragmentFragmentDoc = gql`
@@ -602,6 +607,14 @@ var NodeInfoFragmentFragmentDoc = gql`
602
607
  nodeVersion
603
608
  }
604
609
  `;
610
+ var RelayedTransactionStatusFragmentFragmentDoc = gql`
611
+ fragment relayedTransactionStatusFragment on RelayedTransactionStatus {
612
+ ... on RelayedTransactionFailed {
613
+ blockHeight
614
+ failure
615
+ }
616
+ }
617
+ `;
605
618
  var GetVersionDocument = gql`
606
619
  query getVersion {
607
620
  nodeInfo {
@@ -831,6 +844,13 @@ var GetMessageStatusDocument = gql`
831
844
  }
832
845
  }
833
846
  `;
847
+ var GetRelayedTransactionStatusDocument = gql`
848
+ query getRelayedTransactionStatus($relayedTransactionId: RelayedTransactionId!) {
849
+ relayedTransactionStatus(id: $relayedTransactionId) {
850
+ ...relayedTransactionStatusFragment
851
+ }
852
+ }
853
+ ${RelayedTransactionStatusFragmentFragmentDoc}`;
834
854
  var DryRunDocument = gql`
835
855
  mutation dryRun($encodedTransactions: [HexString!]!, $utxoValidation: Boolean) {
836
856
  dryRun(txs: $encodedTransactions, utxoValidation: $utxoValidation) {
@@ -853,6 +873,13 @@ var ProduceBlocksDocument = gql`
853
873
  )
854
874
  }
855
875
  `;
876
+ var GetMessageByNonceDocument = gql`
877
+ query getMessageByNonce($nonce: Nonce!) {
878
+ message(nonce: $nonce) {
879
+ ...messageFragment
880
+ }
881
+ }
882
+ ${MessageFragmentFragmentDoc}`;
856
883
  var SubmitAndAwaitDocument = gql`
857
884
  subscription submitAndAwait($encodedTransaction: HexString!) {
858
885
  submitAndAwait(tx: $encodedTransaction) {
@@ -938,6 +965,9 @@ function getSdk(requester) {
938
965
  getMessageStatus(variables, options) {
939
966
  return requester(GetMessageStatusDocument, variables, options);
940
967
  },
968
+ getRelayedTransactionStatus(variables, options) {
969
+ return requester(GetRelayedTransactionStatusDocument, variables, options);
970
+ },
941
971
  dryRun(variables, options) {
942
972
  return requester(DryRunDocument, variables, options);
943
973
  },
@@ -947,6 +977,9 @@ function getSdk(requester) {
947
977
  produceBlocks(variables, options) {
948
978
  return requester(ProduceBlocksDocument, variables, options);
949
979
  },
980
+ getMessageByNonce(variables, options) {
981
+ return requester(GetMessageByNonceDocument, variables, options);
982
+ },
950
983
  submitAndAwait(variables, options) {
951
984
  return requester(SubmitAndAwaitDocument, variables, options);
952
985
  },
@@ -1239,7 +1272,7 @@ import {
1239
1272
  OutputType as OutputType2,
1240
1273
  TransactionType
1241
1274
  } from "@fuel-ts/transactions";
1242
- import { concat, hexlify as hexlify7 } from "@fuel-ts/utils";
1275
+ import { concat, hexlify as hexlify7, isDefined } from "@fuel-ts/utils";
1243
1276
 
1244
1277
  // src/providers/resource.ts
1245
1278
  var isCoin = (resource) => "id" in resource;
@@ -1552,7 +1585,7 @@ function calculateMetadataGasForTxScript({
1552
1585
  }
1553
1586
  var calculateGasFee = (params) => {
1554
1587
  const { gas, gasPrice, priceFactor, tip } = params;
1555
- return gas.mul(gasPrice).div(priceFactor).add(tip);
1588
+ return gas.mul(gasPrice).div(priceFactor).add(bn5(tip));
1556
1589
  };
1557
1590
 
1558
1591
  // src/providers/utils/json.ts
@@ -1725,10 +1758,10 @@ var BaseTransactionRequest = class {
1725
1758
  outputs,
1726
1759
  witnesses
1727
1760
  } = {}) {
1728
- this.tip = bn7(tip);
1729
- this.maturity = maturity ?? 0;
1730
- this.witnessLimit = witnessLimit ? bn7(witnessLimit) : void 0;
1731
- this.maxFee = maxFee ? bn7(maxFee) : void 0;
1761
+ this.tip = tip ? bn7(tip) : void 0;
1762
+ this.maturity = maturity && maturity > 0 ? maturity : void 0;
1763
+ this.witnessLimit = isDefined(witnessLimit) ? bn7(witnessLimit) : void 0;
1764
+ this.maxFee = bn7(maxFee);
1732
1765
  this.inputs = inputs ?? [];
1733
1766
  this.outputs = outputs ?? [];
1734
1767
  this.witnesses = witnesses ?? [];
@@ -1736,22 +1769,21 @@ var BaseTransactionRequest = class {
1736
1769
  static getPolicyMeta(req) {
1737
1770
  let policyTypes = 0;
1738
1771
  const policies = [];
1739
- if (req.tip) {
1772
+ const { tip, witnessLimit, maturity } = req;
1773
+ if (bn7(tip).gt(0)) {
1740
1774
  policyTypes += PolicyType.Tip;
1741
- policies.push({ data: req.tip, type: PolicyType.Tip });
1775
+ policies.push({ data: bn7(tip), type: PolicyType.Tip });
1742
1776
  }
1743
- if (req.witnessLimit) {
1777
+ if (isDefined(witnessLimit) && bn7(witnessLimit).gte(0)) {
1744
1778
  policyTypes += PolicyType.WitnessLimit;
1745
- policies.push({ data: req.witnessLimit, type: PolicyType.WitnessLimit });
1779
+ policies.push({ data: bn7(witnessLimit), type: PolicyType.WitnessLimit });
1746
1780
  }
1747
- if (req.maturity > 0) {
1781
+ if (maturity && maturity > 0) {
1748
1782
  policyTypes += PolicyType.Maturity;
1749
- policies.push({ data: req.maturity, type: PolicyType.Maturity });
1750
- }
1751
- if (req.maxFee) {
1752
- policyTypes += PolicyType.MaxFee;
1753
- policies.push({ data: req.maxFee, type: PolicyType.MaxFee });
1783
+ policies.push({ data: maturity, type: PolicyType.Maturity });
1754
1784
  }
1785
+ policyTypes += PolicyType.MaxFee;
1786
+ policies.push({ data: req.maxFee, type: PolicyType.MaxFee });
1755
1787
  return {
1756
1788
  policyTypes,
1757
1789
  policies
@@ -2067,8 +2099,11 @@ var BaseTransactionRequest = class {
2067
2099
  * @hidden
2068
2100
  */
2069
2101
  calculateMinGas(chainInfo) {
2070
- const { gasCosts, consensusParameters } = chainInfo;
2071
- const { gasPerByte } = consensusParameters;
2102
+ const { consensusParameters } = chainInfo;
2103
+ const {
2104
+ gasCosts,
2105
+ feeParameters: { gasPerByte }
2106
+ } = consensusParameters;
2072
2107
  return getMinGas({
2073
2108
  gasPerByte,
2074
2109
  gasCosts,
@@ -2079,7 +2114,10 @@ var BaseTransactionRequest = class {
2079
2114
  }
2080
2115
  calculateMaxGas(chainInfo, minGas) {
2081
2116
  const { consensusParameters } = chainInfo;
2082
- const { gasPerByte, maxGasPerTx } = consensusParameters;
2117
+ const {
2118
+ feeParameters: { gasPerByte },
2119
+ txParameters: { maxGasPerTx }
2120
+ } = consensusParameters;
2083
2121
  const witnessesLength = this.toTransaction().witnesses.reduce(
2084
2122
  (acc, wit) => acc + wit.dataLength,
2085
2123
  0
@@ -2514,7 +2552,10 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2514
2552
  }
2515
2553
  calculateMaxGas(chainInfo, minGas) {
2516
2554
  const { consensusParameters } = chainInfo;
2517
- const { gasPerByte, maxGasPerTx } = consensusParameters;
2555
+ const {
2556
+ feeParameters: { gasPerByte },
2557
+ txParameters: { maxGasPerTx }
2558
+ } = consensusParameters;
2518
2559
  const witnessesLength = this.toTransaction().witnesses.reduce(
2519
2560
  (acc, wit) => acc + wit.dataLength,
2520
2561
  0
@@ -2602,10 +2643,10 @@ var transactionRequestify = (obj) => {
2602
2643
  };
2603
2644
  var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
2604
2645
  (acc, input) => {
2605
- if (input.type === InputType5.Coin && input.owner === owner) {
2646
+ if (input.type === InputType5.Coin && input.owner === owner.toB256()) {
2606
2647
  acc.utxos.push(input.id);
2607
2648
  }
2608
- if (input.type === InputType5.Message && input.recipient === owner) {
2649
+ if (input.type === InputType5.Message && input.recipient === owner.toB256()) {
2609
2650
  acc.messages.push(input.nonce);
2610
2651
  }
2611
2652
  return acc;
@@ -2618,40 +2659,40 @@ var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
2618
2659
 
2619
2660
  // src/providers/transaction-response/transaction-response.ts
2620
2661
  import { ErrorCode as ErrorCode12, FuelError as FuelError12 } from "@fuel-ts/errors";
2621
- import { bn as bn15 } from "@fuel-ts/math";
2662
+ import { bn as bn16 } from "@fuel-ts/math";
2622
2663
  import { TransactionCoder as TransactionCoder4 } from "@fuel-ts/transactions";
2623
2664
  import { arrayify as arrayify10 } from "@fuel-ts/utils";
2624
2665
 
2625
2666
  // src/providers/transaction-summary/assemble-transaction-summary.ts
2626
- import { bn as bn14 } from "@fuel-ts/math";
2667
+ import { bn as bn15 } from "@fuel-ts/math";
2627
2668
  import { PolicyType as PolicyType3 } from "@fuel-ts/transactions";
2628
2669
  import { DateTime, hexlify as hexlify11 } from "@fuel-ts/utils";
2629
2670
 
2630
- // src/providers/transaction-summary/calculate-transaction-fee.ts
2671
+ // src/providers/transaction-summary/calculate-tx-fee-for-summary.ts
2631
2672
  import { bn as bn11 } from "@fuel-ts/math";
2632
2673
  import { PolicyType as PolicyType2, TransactionCoder as TransactionCoder3, TransactionType as TransactionType6 } from "@fuel-ts/transactions";
2633
2674
  import { arrayify as arrayify9 } from "@fuel-ts/utils";
2634
- var calculateTransactionFee = (params) => {
2675
+ var calculateTXFeeForSummary = (params) => {
2635
2676
  const {
2636
2677
  gasPrice,
2637
2678
  rawPayload,
2638
2679
  tip,
2680
+ totalFee,
2639
2681
  consensusParameters: { gasCosts, feeParams, maxGasPerTx }
2640
2682
  } = params;
2683
+ if (totalFee) {
2684
+ return totalFee;
2685
+ }
2641
2686
  const gasPerByte = bn11(feeParams.gasPerByte);
2642
2687
  const gasPriceFactor = bn11(feeParams.gasPriceFactor);
2643
2688
  const transactionBytes = arrayify9(rawPayload);
2644
2689
  const [transaction] = new TransactionCoder3().decode(transactionBytes, 0);
2645
- if (transaction.type === TransactionType6.Mint) {
2646
- return {
2647
- fee: bn11(0),
2648
- minFee: bn11(0),
2649
- maxFee: bn11(0)
2650
- };
2651
- }
2652
2690
  const { type, witnesses, inputs, policies } = transaction;
2653
2691
  let metadataGas = bn11(0);
2654
2692
  let gasLimit = bn11(0);
2693
+ if (type !== TransactionType6.Create && type !== TransactionType6.Script) {
2694
+ return bn11(0);
2695
+ }
2655
2696
  if (type === TransactionType6.Create) {
2656
2697
  const { bytecodeWitnessIndex, storageSlots } = transaction;
2657
2698
  const contractBytesSize = bn11(arrayify9(witnesses[bytecodeWitnessIndex].data).length);
@@ -2688,23 +2729,13 @@ var calculateTransactionFee = (params) => {
2688
2729
  witnessLimit,
2689
2730
  maxGasPerTx
2690
2731
  });
2691
- const minFee = calculateGasFee({
2692
- gasPrice,
2693
- gas: minGas,
2694
- priceFactor: gasPriceFactor,
2695
- tip
2696
- });
2697
2732
  const maxFee = calculateGasFee({
2698
2733
  gasPrice,
2699
2734
  gas: maxGas,
2700
2735
  priceFactor: gasPriceFactor,
2701
2736
  tip
2702
2737
  });
2703
- return {
2704
- minFee,
2705
- maxFee,
2706
- fee: maxFee
2707
- };
2738
+ return maxFee;
2708
2739
  };
2709
2740
 
2710
2741
  // src/providers/transaction-summary/operations.ts
@@ -2863,6 +2894,12 @@ function isTypeCreate(transactionType) {
2863
2894
  function isTypeScript(transactionType) {
2864
2895
  return isType(transactionType, "Script" /* Script */);
2865
2896
  }
2897
+ function isTypeUpgrade(transactionType) {
2898
+ return isType(transactionType, "Upgrade" /* Upgrade */);
2899
+ }
2900
+ function isTypeUpload(transactionType) {
2901
+ return isType(transactionType, "Upload" /* Upload */);
2902
+ }
2866
2903
  function getReceiptsCall(receipts) {
2867
2904
  return getReceiptsByType(receipts, ReceiptType4.Call);
2868
2905
  }
@@ -3203,6 +3240,7 @@ var extractBurnedAssetsFromReceipts = (receipts) => {
3203
3240
 
3204
3241
  // src/providers/transaction-summary/status.ts
3205
3242
  import { ErrorCode as ErrorCode11, FuelError as FuelError11 } from "@fuel-ts/errors";
3243
+ import { bn as bn14 } from "@fuel-ts/math";
3206
3244
  var getTransactionStatusName = (gqlStatus) => {
3207
3245
  switch (gqlStatus) {
3208
3246
  case "FailureStatus":
@@ -3224,6 +3262,8 @@ var processGraphqlStatus = (gqlTransactionStatus) => {
3224
3262
  let time;
3225
3263
  let blockId;
3226
3264
  let status;
3265
+ let totalFee;
3266
+ let totalGas;
3227
3267
  let isStatusFailure = false;
3228
3268
  let isStatusSuccess = false;
3229
3269
  let isStatusPending = false;
@@ -3234,11 +3274,15 @@ var processGraphqlStatus = (gqlTransactionStatus) => {
3234
3274
  time = gqlTransactionStatus.time;
3235
3275
  blockId = gqlTransactionStatus.block.id;
3236
3276
  isStatusSuccess = true;
3277
+ totalFee = bn14(gqlTransactionStatus.totalFee);
3278
+ totalGas = bn14(gqlTransactionStatus.totalGas);
3237
3279
  break;
3238
3280
  case "FailureStatus":
3239
3281
  time = gqlTransactionStatus.time;
3240
3282
  blockId = gqlTransactionStatus.block.id;
3241
3283
  isStatusFailure = true;
3284
+ totalFee = bn14(gqlTransactionStatus.totalFee);
3285
+ totalGas = bn14(gqlTransactionStatus.totalGas);
3242
3286
  break;
3243
3287
  case "SubmittedStatus":
3244
3288
  time = gqlTransactionStatus.time;
@@ -3251,6 +3295,8 @@ var processGraphqlStatus = (gqlTransactionStatus) => {
3251
3295
  time,
3252
3296
  blockId,
3253
3297
  status,
3298
+ totalFee,
3299
+ totalGas,
3254
3300
  isStatusFailure,
3255
3301
  isStatusSuccess,
3256
3302
  isStatusPending
@@ -3286,8 +3332,10 @@ function assembleTransactionSummary(params) {
3286
3332
  maxInputs
3287
3333
  });
3288
3334
  const typeName = getTransactionTypeName(transaction.type);
3289
- const tip = bn14(transaction.policies?.find((policy) => policy.type === PolicyType3.Tip)?.data);
3290
- const { fee } = calculateTransactionFee({
3335
+ const tip = bn15(transaction.policies?.find((policy) => policy.type === PolicyType3.Tip)?.data);
3336
+ const { isStatusFailure, isStatusPending, isStatusSuccess, blockId, status, time, totalFee } = processGraphqlStatus(gqlTransactionStatus);
3337
+ const fee = calculateTXFeeForSummary({
3338
+ totalFee,
3291
3339
  gasPrice,
3292
3340
  rawPayload,
3293
3341
  tip,
@@ -3300,7 +3348,6 @@ function assembleTransactionSummary(params) {
3300
3348
  }
3301
3349
  }
3302
3350
  });
3303
- const { isStatusFailure, isStatusPending, isStatusSuccess, blockId, status, time } = processGraphqlStatus(gqlTransactionStatus);
3304
3351
  const mintedAssets = extractMintedAssetsFromReceipts(receipts);
3305
3352
  const burnedAssets = extractBurnedAssetsFromReceipts(receipts);
3306
3353
  let date;
@@ -3309,6 +3356,7 @@ function assembleTransactionSummary(params) {
3309
3356
  }
3310
3357
  const transactionSummary = {
3311
3358
  id,
3359
+ tip,
3312
3360
  fee,
3313
3361
  gasUsed,
3314
3362
  operations,
@@ -3322,6 +3370,8 @@ function assembleTransactionSummary(params) {
3322
3370
  isTypeMint: isTypeMint(transaction.type),
3323
3371
  isTypeCreate: isTypeCreate(transaction.type),
3324
3372
  isTypeScript: isTypeScript(transaction.type),
3373
+ isTypeUpgrade: isTypeUpgrade(transaction.type),
3374
+ isTypeUpload: isTypeUpload(transaction.type),
3325
3375
  isStatusFailure,
3326
3376
  isStatusSuccess,
3327
3377
  isStatusPending,
@@ -3353,7 +3403,7 @@ var TransactionResponse = class {
3353
3403
  /** Current provider */
3354
3404
  provider;
3355
3405
  /** Gas used on the transaction */
3356
- gasUsed = bn15(0);
3406
+ gasUsed = bn16(0);
3357
3407
  /** The graphql Transaction with receipts object. */
3358
3408
  gqlTransaction;
3359
3409
  abis;
@@ -3438,7 +3488,7 @@ var TransactionResponse = class {
3438
3488
  const receipts = txReceipts.map(processGqlReceipt) || [];
3439
3489
  const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
3440
3490
  const gasPrice = await this.provider.getLatestGasPrice();
3441
- const maxInputs = this.provider.getChain().consensusParameters.maxInputs;
3491
+ const maxInputs = this.provider.getChain().consensusParameters.txParameters.maxInputs;
3442
3492
  const transactionSummary = assembleTransactionSummary({
3443
3493
  id: this.id,
3444
3494
  receipts,
@@ -3574,33 +3624,60 @@ var mergeQuantities = (...coinQuantities) => {
3574
3624
  var MAX_RETRIES = 10;
3575
3625
  var processGqlChain = (chain) => {
3576
3626
  const { name, daHeight, consensusParameters, latestBlock } = chain;
3577
- const { contractParams, feeParams, predicateParams, scriptParams, txParams, gasCosts } = consensusParameters;
3627
+ const {
3628
+ contractParams,
3629
+ feeParams,
3630
+ predicateParams,
3631
+ scriptParams,
3632
+ txParams,
3633
+ gasCosts,
3634
+ baseAssetId,
3635
+ chainId,
3636
+ version
3637
+ } = consensusParameters;
3578
3638
  return {
3579
3639
  name,
3580
- baseChainHeight: bn16(daHeight),
3640
+ baseChainHeight: bn17(daHeight),
3581
3641
  consensusParameters: {
3582
- contractMaxSize: bn16(contractParams.contractMaxSize),
3583
- maxInputs: bn16(txParams.maxInputs),
3584
- maxOutputs: bn16(txParams.maxOutputs),
3585
- maxWitnesses: bn16(txParams.maxWitnesses),
3586
- maxGasPerTx: bn16(txParams.maxGasPerTx),
3587
- maxScriptLength: bn16(scriptParams.maxScriptLength),
3588
- maxScriptDataLength: bn16(scriptParams.maxScriptDataLength),
3589
- maxStorageSlots: bn16(contractParams.maxStorageSlots),
3590
- maxPredicateLength: bn16(predicateParams.maxPredicateLength),
3591
- maxPredicateDataLength: bn16(predicateParams.maxPredicateDataLength),
3592
- maxGasPerPredicate: bn16(predicateParams.maxGasPerPredicate),
3593
- gasPriceFactor: bn16(feeParams.gasPriceFactor),
3594
- gasPerByte: bn16(feeParams.gasPerByte),
3595
- maxMessageDataLength: bn16(predicateParams.maxMessageDataLength),
3596
- chainId: bn16(consensusParameters.chainId),
3597
- baseAssetId: consensusParameters.baseAssetId,
3642
+ version,
3643
+ chainId: bn17(chainId),
3644
+ baseAssetId,
3645
+ feeParameters: {
3646
+ version: feeParams.version,
3647
+ gasPerByte: bn17(feeParams.gasPerByte),
3648
+ gasPriceFactor: bn17(feeParams.gasPriceFactor)
3649
+ },
3650
+ contractParameters: {
3651
+ version: contractParams.version,
3652
+ contractMaxSize: bn17(contractParams.contractMaxSize),
3653
+ maxStorageSlots: bn17(contractParams.maxStorageSlots)
3654
+ },
3655
+ txParameters: {
3656
+ version: txParams.version,
3657
+ maxInputs: bn17(txParams.maxInputs),
3658
+ maxOutputs: bn17(txParams.maxOutputs),
3659
+ maxWitnesses: bn17(txParams.maxWitnesses),
3660
+ maxGasPerTx: bn17(txParams.maxGasPerTx),
3661
+ maxSize: bn17(txParams.maxSize),
3662
+ maxBytecodeSubsections: bn17(txParams.maxBytecodeSubsections)
3663
+ },
3664
+ predicateParameters: {
3665
+ version: predicateParams.version,
3666
+ maxPredicateLength: bn17(predicateParams.maxPredicateLength),
3667
+ maxPredicateDataLength: bn17(predicateParams.maxPredicateDataLength),
3668
+ maxGasPerPredicate: bn17(predicateParams.maxGasPerPredicate),
3669
+ maxMessageDataLength: bn17(predicateParams.maxMessageDataLength)
3670
+ },
3671
+ scriptParameters: {
3672
+ version: scriptParams.version,
3673
+ maxScriptLength: bn17(scriptParams.maxScriptLength),
3674
+ maxScriptDataLength: bn17(scriptParams.maxScriptDataLength)
3675
+ },
3598
3676
  gasCosts
3599
3677
  },
3600
- gasCosts,
3601
3678
  latestBlock: {
3602
3679
  id: latestBlock.id,
3603
- height: bn16(latestBlock.height),
3680
+ height: bn17(latestBlock.height),
3604
3681
  time: latestBlock.header.time,
3605
3682
  transactions: latestBlock.transactions.map((i) => ({
3606
3683
  id: i.id
@@ -3694,7 +3771,12 @@ var _Provider = class {
3694
3771
  * Returns some helpful parameters related to gas fees.
3695
3772
  */
3696
3773
  getGasConfig() {
3697
- const { maxGasPerTx, maxGasPerPredicate, gasPriceFactor, gasPerByte, gasCosts } = this.getChain().consensusParameters;
3774
+ const {
3775
+ txParameters: { maxGasPerTx },
3776
+ predicateParameters: { maxGasPerPredicate },
3777
+ feeParameters: { gasPriceFactor, gasPerByte },
3778
+ gasCosts
3779
+ } = this.getChain().consensusParameters;
3698
3780
  return {
3699
3781
  maxGasPerTx,
3700
3782
  maxGasPerPredicate,
@@ -3743,7 +3825,18 @@ var _Provider = class {
3743
3825
  createOperations() {
3744
3826
  const fetchFn = _Provider.getFetchFn(this.options);
3745
3827
  const gqlClient = new GraphQLClient(this.url, {
3746
- fetch: (url, requestInit) => fetchFn(url, requestInit, this.options)
3828
+ fetch: (url, requestInit) => fetchFn(url, requestInit, this.options),
3829
+ responseMiddleware: (response) => {
3830
+ if ("response" in response) {
3831
+ const graphQlResponse = response.response;
3832
+ if (Array.isArray(graphQlResponse?.errors)) {
3833
+ throw new FuelError13(
3834
+ FuelError13.CODES.INVALID_REQUEST,
3835
+ graphQlResponse.errors.map((err) => err.message).join("\n\n")
3836
+ );
3837
+ }
3838
+ }
3839
+ }
3747
3840
  });
3748
3841
  const executeQuery = (query, vars) => {
3749
3842
  const opDefinition = query.definitions.find((x) => x.kind === "OperationDefinition");
@@ -3771,21 +3864,6 @@ var _Provider = class {
3771
3864
  } = await this.operations.getVersion();
3772
3865
  return nodeVersion;
3773
3866
  }
3774
- /**
3775
- * @hidden
3776
- *
3777
- * Returns the network configuration of the connected Fuel node.
3778
- *
3779
- * @returns A promise that resolves to the network configuration object
3780
- */
3781
- async getNetwork() {
3782
- const {
3783
- name,
3784
- consensusParameters: { chainId }
3785
- } = await this.getChain();
3786
- const network = new Network(name, chainId.toNumber());
3787
- return Promise.resolve(network);
3788
- }
3789
3867
  /**
3790
3868
  * Returns the block number.
3791
3869
  *
@@ -3793,7 +3871,7 @@ var _Provider = class {
3793
3871
  */
3794
3872
  async getBlockNumber() {
3795
3873
  const { chain } = await this.operations.getChain();
3796
- return bn16(chain.latestBlock.height, 10);
3874
+ return bn17(chain.latestBlock.height, 10);
3797
3875
  }
3798
3876
  /**
3799
3877
  * Returns the chain information.
@@ -3803,8 +3881,8 @@ var _Provider = class {
3803
3881
  async fetchNode() {
3804
3882
  const { nodeInfo } = await this.operations.getNodeInfo();
3805
3883
  const processedNodeInfo = {
3806
- maxDepth: bn16(nodeInfo.maxDepth),
3807
- maxTx: bn16(nodeInfo.maxTx),
3884
+ maxDepth: bn17(nodeInfo.maxDepth),
3885
+ maxTx: bn17(nodeInfo.maxTx),
3808
3886
  nodeVersion: nodeInfo.nodeVersion,
3809
3887
  utxoValidation: nodeInfo.utxoValidation,
3810
3888
  vmBacktrace: nodeInfo.vmBacktrace
@@ -3908,9 +3986,9 @@ var _Provider = class {
3908
3986
  encodedTransactions: encodedTransaction,
3909
3987
  utxoValidation: utxoValidation || false
3910
3988
  });
3911
- const [{ receipts: rawReceipts, status }] = dryRunStatuses;
3989
+ const [{ receipts: rawReceipts, status: dryRunStatus }] = dryRunStatuses;
3912
3990
  const receipts = rawReceipts.map(processGqlReceipt);
3913
- return { receipts, dryrunStatus: status };
3991
+ return { receipts, dryRunStatus };
3914
3992
  }
3915
3993
  /**
3916
3994
  * Verifies whether enough gas is available to complete transaction.
@@ -3936,7 +4014,7 @@ var _Provider = class {
3936
4014
  } = response;
3937
4015
  if (inputs) {
3938
4016
  inputs.forEach((input, index) => {
3939
- if ("predicateGasUsed" in input && bn16(input.predicateGasUsed).gt(0)) {
4017
+ if ("predicateGasUsed" in input && bn17(input.predicateGasUsed).gt(0)) {
3940
4018
  transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
3941
4019
  }
3942
4020
  });
@@ -3964,7 +4042,7 @@ var _Provider = class {
3964
4042
  let receipts = [];
3965
4043
  const missingContractIds = [];
3966
4044
  let outputVariables = 0;
3967
- let dryrunStatus;
4045
+ let dryRunStatus;
3968
4046
  for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
3969
4047
  const {
3970
4048
  dryRun: [{ receipts: rawReceipts, status }]
@@ -3973,7 +4051,7 @@ var _Provider = class {
3973
4051
  utxoValidation: false
3974
4052
  });
3975
4053
  receipts = rawReceipts.map(processGqlReceipt);
3976
- dryrunStatus = status;
4054
+ dryRunStatus = status;
3977
4055
  const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
3978
4056
  const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
3979
4057
  if (hasMissingOutputs) {
@@ -3995,7 +4073,7 @@ var _Provider = class {
3995
4073
  receipts,
3996
4074
  outputVariables,
3997
4075
  missingContractIds,
3998
- dryrunStatus
4076
+ dryRunStatus
3999
4077
  };
4000
4078
  }
4001
4079
  /**
@@ -4013,7 +4091,7 @@ var _Provider = class {
4013
4091
  receipts: [],
4014
4092
  outputVariables: 0,
4015
4093
  missingContractIds: [],
4016
- dryrunStatus: void 0
4094
+ dryRunStatus: void 0
4017
4095
  }));
4018
4096
  const allRequests = clone3(transactionRequests);
4019
4097
  const serializedTransactionsMap = /* @__PURE__ */ new Map();
@@ -4038,7 +4116,7 @@ var _Provider = class {
4038
4116
  const { receipts: rawReceipts, status } = dryRunResults.dryRun[i];
4039
4117
  const result = results[requestIdx];
4040
4118
  result.receipts = rawReceipts.map(processGqlReceipt);
4041
- result.dryrunStatus = status;
4119
+ result.dryRunStatus = status;
4042
4120
  const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(
4043
4121
  result.receipts
4044
4122
  );
@@ -4075,7 +4153,7 @@ var _Provider = class {
4075
4153
  });
4076
4154
  const results = dryRunStatuses.map(({ receipts: rawReceipts, status }) => {
4077
4155
  const receipts = rawReceipts.map(processGqlReceipt);
4078
- return { receipts, dryrunStatus: status };
4156
+ return { receipts, dryRunStatus: status };
4079
4157
  });
4080
4158
  return results;
4081
4159
  }
@@ -4094,12 +4172,12 @@ var _Provider = class {
4094
4172
  gasPrice = await this.estimateGasPrice(10);
4095
4173
  }
4096
4174
  const minFee = calculateGasFee({
4097
- gasPrice: bn16(gasPrice),
4175
+ gasPrice: bn17(gasPrice),
4098
4176
  gas: minGas,
4099
4177
  priceFactor: gasPriceFactor,
4100
4178
  tip: transactionRequest.tip
4101
4179
  }).add(1);
4102
- let gasLimit = bn16(0);
4180
+ let gasLimit = bn17(0);
4103
4181
  if (transactionRequest.type === TransactionType8.Script) {
4104
4182
  gasLimit = transactionRequest.gasLimit;
4105
4183
  if (transactionRequest.gasLimit.eq(0)) {
@@ -4112,7 +4190,7 @@ var _Provider = class {
4112
4190
  }
4113
4191
  const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
4114
4192
  const maxFee = calculateGasFee({
4115
- gasPrice: bn16(gasPrice),
4193
+ gasPrice: bn17(gasPrice),
4116
4194
  gas: maxGas,
4117
4195
  priceFactor: gasPriceFactor,
4118
4196
  tip: transactionRequest.tip
@@ -4175,9 +4253,9 @@ var _Provider = class {
4175
4253
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
4176
4254
  const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
4177
4255
  txRequestClone.fundWithFakeUtxos(allQuantities, baseAssetId, resourcesOwner?.address);
4178
- txRequestClone.maxFee = bn16(0);
4256
+ txRequestClone.maxFee = bn17(0);
4179
4257
  if (isScriptTransaction) {
4180
- txRequestClone.gasLimit = bn16(0);
4258
+ txRequestClone.gasLimit = bn17(0);
4181
4259
  }
4182
4260
  if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
4183
4261
  resourcesOwner.populateTransactionPredicateData(txRequestClone);
@@ -4194,9 +4272,10 @@ var _Provider = class {
4194
4272
  transactionRequest: signedRequest
4195
4273
  });
4196
4274
  let receipts = [];
4275
+ let dryRunStatus;
4197
4276
  let missingContractIds = [];
4198
4277
  let outputVariables = 0;
4199
- let gasUsed = bn16(0);
4278
+ let gasUsed = bn17(0);
4200
4279
  txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
4201
4280
  txRequestClone.maxFee = maxFee;
4202
4281
  if (isScriptTransaction) {
@@ -4204,10 +4283,7 @@ var _Provider = class {
4204
4283
  if (signatureCallback) {
4205
4284
  await signatureCallback(txRequestClone);
4206
4285
  }
4207
- const result = await this.estimateTxDependencies(txRequestClone);
4208
- receipts = result.receipts;
4209
- outputVariables = result.outputVariables;
4210
- missingContractIds = result.missingContractIds;
4286
+ ({ receipts, missingContractIds, outputVariables, dryRunStatus } = await this.estimateTxDependencies(txRequestClone));
4211
4287
  gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
4212
4288
  txRequestClone.gasLimit = gasUsed;
4213
4289
  ({ maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
@@ -4227,7 +4303,8 @@ var _Provider = class {
4227
4303
  outputVariables,
4228
4304
  missingContractIds,
4229
4305
  addedSignatures,
4230
- estimatedPredicates: txRequestClone.inputs
4306
+ estimatedPredicates: txRequestClone.inputs,
4307
+ dryRunStatus
4231
4308
  };
4232
4309
  }
4233
4310
  async getResourcesForTransaction(owner, transactionRequestLike, quantitiesToContract = []) {
@@ -4263,10 +4340,10 @@ var _Provider = class {
4263
4340
  return coins.map((coin) => ({
4264
4341
  id: coin.utxoId,
4265
4342
  assetId: coin.assetId,
4266
- amount: bn16(coin.amount),
4343
+ amount: bn17(coin.amount),
4267
4344
  owner: Address2.fromAddressOrString(coin.owner),
4268
- blockCreated: bn16(coin.blockCreated),
4269
- txCreatedIdx: bn16(coin.txCreatedIdx)
4345
+ blockCreated: bn17(coin.blockCreated),
4346
+ txCreatedIdx: bn17(coin.txCreatedIdx)
4270
4347
  }));
4271
4348
  }
4272
4349
  /**
@@ -4303,9 +4380,9 @@ var _Provider = class {
4303
4380
  switch (coin.__typename) {
4304
4381
  case "MessageCoin":
4305
4382
  return {
4306
- amount: bn16(coin.amount),
4383
+ amount: bn17(coin.amount),
4307
4384
  assetId: coin.assetId,
4308
- daHeight: bn16(coin.daHeight),
4385
+ daHeight: bn17(coin.daHeight),
4309
4386
  sender: Address2.fromAddressOrString(coin.sender),
4310
4387
  recipient: Address2.fromAddressOrString(coin.recipient),
4311
4388
  nonce: coin.nonce
@@ -4313,11 +4390,11 @@ var _Provider = class {
4313
4390
  case "Coin":
4314
4391
  return {
4315
4392
  id: coin.utxoId,
4316
- amount: bn16(coin.amount),
4393
+ amount: bn17(coin.amount),
4317
4394
  assetId: coin.assetId,
4318
4395
  owner: Address2.fromAddressOrString(coin.owner),
4319
- blockCreated: bn16(coin.blockCreated),
4320
- txCreatedIdx: bn16(coin.txCreatedIdx)
4396
+ blockCreated: bn17(coin.blockCreated),
4397
+ txCreatedIdx: bn17(coin.txCreatedIdx)
4321
4398
  };
4322
4399
  default:
4323
4400
  return null;
@@ -4334,13 +4411,13 @@ var _Provider = class {
4334
4411
  async getBlock(idOrHeight) {
4335
4412
  let variables;
4336
4413
  if (typeof idOrHeight === "number") {
4337
- variables = { height: bn16(idOrHeight).toString(10) };
4414
+ variables = { height: bn17(idOrHeight).toString(10) };
4338
4415
  } else if (idOrHeight === "latest") {
4339
4416
  variables = { height: (await this.getBlockNumber()).toString(10) };
4340
4417
  } else if (idOrHeight.length === 66) {
4341
4418
  variables = { blockId: idOrHeight };
4342
4419
  } else {
4343
- variables = { blockId: bn16(idOrHeight).toString(10) };
4420
+ variables = { blockId: bn17(idOrHeight).toString(10) };
4344
4421
  }
4345
4422
  const { block } = await this.operations.getBlock(variables);
4346
4423
  if (!block) {
@@ -4348,7 +4425,7 @@ var _Provider = class {
4348
4425
  }
4349
4426
  return {
4350
4427
  id: block.id,
4351
- height: bn16(block.height),
4428
+ height: bn17(block.height),
4352
4429
  time: block.header.time,
4353
4430
  transactionIds: block.transactions.map((tx) => tx.id)
4354
4431
  };
@@ -4363,7 +4440,7 @@ var _Provider = class {
4363
4440
  const { blocks: fetchedData } = await this.operations.getBlocks(params);
4364
4441
  const blocks = fetchedData.edges.map(({ node: block }) => ({
4365
4442
  id: block.id,
4366
- height: bn16(block.height),
4443
+ height: bn17(block.height),
4367
4444
  time: block.header.time,
4368
4445
  transactionIds: block.transactions.map((tx) => tx.id)
4369
4446
  }));
@@ -4378,7 +4455,7 @@ var _Provider = class {
4378
4455
  async getBlockWithTransactions(idOrHeight) {
4379
4456
  let variables;
4380
4457
  if (typeof idOrHeight === "number") {
4381
- variables = { blockHeight: bn16(idOrHeight).toString(10) };
4458
+ variables = { blockHeight: bn17(idOrHeight).toString(10) };
4382
4459
  } else if (idOrHeight === "latest") {
4383
4460
  variables = { blockHeight: (await this.getBlockNumber()).toString() };
4384
4461
  } else {
@@ -4390,7 +4467,7 @@ var _Provider = class {
4390
4467
  }
4391
4468
  return {
4392
4469
  id: block.id,
4393
- height: bn16(block.height, 10),
4470
+ height: bn17(block.height, 10),
4394
4471
  time: block.header.time,
4395
4472
  transactionIds: block.transactions.map((tx) => tx.id),
4396
4473
  transactions: block.transactions.map(
@@ -4439,7 +4516,7 @@ var _Provider = class {
4439
4516
  contract: Address2.fromAddressOrString(contractId).toB256(),
4440
4517
  asset: hexlify12(assetId)
4441
4518
  });
4442
- return bn16(contractBalance.amount, 10);
4519
+ return bn17(contractBalance.amount, 10);
4443
4520
  }
4444
4521
  /**
4445
4522
  * Returns the balance for the given owner for the given asset ID.
@@ -4453,7 +4530,7 @@ var _Provider = class {
4453
4530
  owner: Address2.fromAddressOrString(owner).toB256(),
4454
4531
  assetId: hexlify12(assetId)
4455
4532
  });
4456
- return bn16(balance.amount, 10);
4533
+ return bn17(balance.amount, 10);
4457
4534
  }
4458
4535
  /**
4459
4536
  * Returns balances for the given owner.
@@ -4471,7 +4548,7 @@ var _Provider = class {
4471
4548
  const balances = result.balances.edges.map((edge) => edge.node);
4472
4549
  return balances.map((balance) => ({
4473
4550
  assetId: balance.assetId,
4474
- amount: bn16(balance.amount)
4551
+ amount: bn17(balance.amount)
4475
4552
  }));
4476
4553
  }
4477
4554
  /**
@@ -4493,15 +4570,15 @@ var _Provider = class {
4493
4570
  sender: message.sender,
4494
4571
  recipient: message.recipient,
4495
4572
  nonce: message.nonce,
4496
- amount: bn16(message.amount),
4573
+ amount: bn17(message.amount),
4497
4574
  data: message.data
4498
4575
  }),
4499
4576
  sender: Address2.fromAddressOrString(message.sender),
4500
4577
  recipient: Address2.fromAddressOrString(message.recipient),
4501
4578
  nonce: message.nonce,
4502
- amount: bn16(message.amount),
4579
+ amount: bn17(message.amount),
4503
4580
  data: InputMessageCoder.decodeData(message.data),
4504
- daHeight: bn16(message.daHeight)
4581
+ daHeight: bn17(message.daHeight)
4505
4582
  }));
4506
4583
  }
4507
4584
  /**
@@ -4554,59 +4631,59 @@ var _Provider = class {
4554
4631
  } = result.messageProof;
4555
4632
  return {
4556
4633
  messageProof: {
4557
- proofIndex: bn16(messageProof.proofIndex),
4634
+ proofIndex: bn17(messageProof.proofIndex),
4558
4635
  proofSet: messageProof.proofSet
4559
4636
  },
4560
4637
  blockProof: {
4561
- proofIndex: bn16(blockProof.proofIndex),
4638
+ proofIndex: bn17(blockProof.proofIndex),
4562
4639
  proofSet: blockProof.proofSet
4563
4640
  },
4564
4641
  messageBlockHeader: {
4565
4642
  id: messageBlockHeader.id,
4566
- daHeight: bn16(messageBlockHeader.daHeight),
4567
- transactionsCount: bn16(messageBlockHeader.transactionsCount),
4643
+ daHeight: bn17(messageBlockHeader.daHeight),
4644
+ transactionsCount: Number(messageBlockHeader.transactionsCount),
4568
4645
  transactionsRoot: messageBlockHeader.transactionsRoot,
4569
- height: bn16(messageBlockHeader.height),
4646
+ height: bn17(messageBlockHeader.height),
4570
4647
  prevRoot: messageBlockHeader.prevRoot,
4571
4648
  time: messageBlockHeader.time,
4572
4649
  applicationHash: messageBlockHeader.applicationHash,
4573
- messageReceiptCount: bn16(messageBlockHeader.messageReceiptCount),
4650
+ messageReceiptCount: Number(messageBlockHeader.messageReceiptCount),
4574
4651
  messageOutboxRoot: messageBlockHeader.messageOutboxRoot,
4575
- consensusParametersVersion: messageBlockHeader.consensusParametersVersion,
4652
+ consensusParametersVersion: Number(messageBlockHeader.consensusParametersVersion),
4576
4653
  eventInboxRoot: messageBlockHeader.eventInboxRoot,
4577
- stateTransitionBytecodeVersion: messageBlockHeader.stateTransitionBytecodeVersion
4654
+ stateTransitionBytecodeVersion: Number(messageBlockHeader.stateTransitionBytecodeVersion)
4578
4655
  },
4579
4656
  commitBlockHeader: {
4580
4657
  id: commitBlockHeader.id,
4581
- daHeight: bn16(commitBlockHeader.daHeight),
4582
- transactionsCount: bn16(commitBlockHeader.transactionsCount),
4658
+ daHeight: bn17(commitBlockHeader.daHeight),
4659
+ transactionsCount: Number(commitBlockHeader.transactionsCount),
4583
4660
  transactionsRoot: commitBlockHeader.transactionsRoot,
4584
- height: bn16(commitBlockHeader.height),
4661
+ height: bn17(commitBlockHeader.height),
4585
4662
  prevRoot: commitBlockHeader.prevRoot,
4586
4663
  time: commitBlockHeader.time,
4587
4664
  applicationHash: commitBlockHeader.applicationHash,
4588
- messageReceiptCount: bn16(commitBlockHeader.messageReceiptCount),
4665
+ messageReceiptCount: Number(commitBlockHeader.messageReceiptCount),
4589
4666
  messageOutboxRoot: commitBlockHeader.messageOutboxRoot,
4590
- consensusParametersVersion: commitBlockHeader.consensusParametersVersion,
4667
+ consensusParametersVersion: Number(commitBlockHeader.consensusParametersVersion),
4591
4668
  eventInboxRoot: commitBlockHeader.eventInboxRoot,
4592
- stateTransitionBytecodeVersion: commitBlockHeader.stateTransitionBytecodeVersion
4669
+ stateTransitionBytecodeVersion: Number(commitBlockHeader.stateTransitionBytecodeVersion)
4593
4670
  },
4594
4671
  sender: Address2.fromAddressOrString(sender),
4595
4672
  recipient: Address2.fromAddressOrString(recipient),
4596
4673
  nonce,
4597
- amount: bn16(amount),
4674
+ amount: bn17(amount),
4598
4675
  data
4599
4676
  };
4600
4677
  }
4601
4678
  async getLatestGasPrice() {
4602
4679
  const { latestGasPrice } = await this.operations.getLatestGasPrice();
4603
- return bn16(latestGasPrice.gasPrice);
4680
+ return bn17(latestGasPrice.gasPrice);
4604
4681
  }
4605
4682
  async estimateGasPrice(blockHorizon) {
4606
4683
  const { estimateGasPrice } = await this.operations.estimateGasPrice({
4607
4684
  blockHorizon: String(blockHorizon)
4608
4685
  });
4609
- return bn16(estimateGasPrice.gasPrice);
4686
+ return bn17(estimateGasPrice.gasPrice);
4610
4687
  }
4611
4688
  /**
4612
4689
  * Returns Message Proof for given transaction id and the message id from MessageOut receipt.
@@ -4627,15 +4704,37 @@ var _Provider = class {
4627
4704
  */
4628
4705
  async produceBlocks(amount, startTime) {
4629
4706
  const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
4630
- blocksToProduce: bn16(amount).toString(10),
4707
+ blocksToProduce: bn17(amount).toString(10),
4631
4708
  startTimestamp: startTime ? DateTime2.fromUnixMilliseconds(startTime).toTai64() : void 0
4632
4709
  });
4633
- return bn16(latestBlockHeight);
4710
+ return bn17(latestBlockHeight);
4634
4711
  }
4635
4712
  // eslint-disable-next-line @typescript-eslint/require-await
4636
4713
  async getTransactionResponse(transactionId) {
4637
4714
  return new TransactionResponse(transactionId, this);
4638
4715
  }
4716
+ /**
4717
+ * Returns Message for given nonce.
4718
+ *
4719
+ * @param nonce - The nonce of the message to retrieve.
4720
+ * @returns A promise that resolves to the Message object.
4721
+ */
4722
+ async getMessageByNonce(nonce) {
4723
+ const { message } = await this.operations.getMessageByNonce({ nonce });
4724
+ if (!message) {
4725
+ return null;
4726
+ }
4727
+ return message;
4728
+ }
4729
+ async getRelayedTransactionStatus(relayedTransactionId) {
4730
+ const { relayedTransactionStatus } = await this.operations.getRelayedTransactionStatus({
4731
+ relayedTransactionId
4732
+ });
4733
+ if (!relayedTransactionStatus) {
4734
+ return null;
4735
+ }
4736
+ return relayedTransactionStatus;
4737
+ }
4639
4738
  };
4640
4739
  var Provider = _Provider;
4641
4740
  _cacheInputs = new WeakSet();
@@ -4654,7 +4753,7 @@ __publicField(Provider, "nodeInfoCache", {});
4654
4753
 
4655
4754
  // src/providers/transaction-summary/get-transaction-summary.ts
4656
4755
  import { ErrorCode as ErrorCode14, FuelError as FuelError14 } from "@fuel-ts/errors";
4657
- import { bn as bn17 } from "@fuel-ts/math";
4756
+ import { bn as bn18 } from "@fuel-ts/math";
4658
4757
  import { TransactionCoder as TransactionCoder6 } from "@fuel-ts/transactions";
4659
4758
  import { arrayify as arrayify12 } from "@fuel-ts/utils";
4660
4759
 
@@ -4703,6 +4802,22 @@ var assets = [
4703
4802
  }
4704
4803
  ];
4705
4804
 
4805
+ // src/providers/transaction-request/helpers.ts
4806
+ import { bn as bn19 } from "@fuel-ts/math";
4807
+ import { InputType as InputType8 } from "@fuel-ts/transactions";
4808
+ var isRequestInputCoin = (input) => input.type === InputType8.Coin;
4809
+ var isRequestInputMessage = (input) => input.type === InputType8.Message;
4810
+ var isRequestInputResource = (input) => isRequestInputCoin(input) || isRequestInputMessage(input);
4811
+ var getAssetAmountInRequestInputs = (inputs, assetId, baseAsset) => inputs.filter(isRequestInputResource).reduce((acc, input) => {
4812
+ if (isRequestInputCoin(input) && input.assetId === assetId) {
4813
+ return acc.add(input.amount);
4814
+ }
4815
+ if (isRequestInputMessage(input) && assetId === baseAsset) {
4816
+ return acc.add(input.amount);
4817
+ }
4818
+ return acc;
4819
+ }, bn19(0));
4820
+
4706
4821
  // src/utils/formatTransferToContractScriptData.ts
4707
4822
  import { BigNumberCoder as BigNumberCoder2 } from "@fuel-ts/abi-coder";
4708
4823
  import { BN as BN2 } from "@fuel-ts/math";
@@ -4740,6 +4855,7 @@ var assembleTransferToContractScript = async (params) => {
4740
4855
  };
4741
4856
 
4742
4857
  // src/account.ts
4858
+ var MAX_FUNDING_ATTEMPTS = 2;
4743
4859
  var Account = class extends AbstractAccount {
4744
4860
  /**
4745
4861
  * The address associated with the account.
@@ -4897,16 +5013,17 @@ var Account = class extends AbstractAccount {
4897
5013
  * Adds resources to the transaction enough to fund it.
4898
5014
  *
4899
5015
  * @param request - The transaction request.
4900
- * @param coinQuantities - The coin quantities required to execute the transaction.
5016
+ * @param requiredQuantities - The coin quantities required to execute the transaction.
4901
5017
  * @param fee - The estimated transaction fee.
4902
5018
  * @returns A promise that resolves when the resources are added to the transaction.
4903
5019
  */
4904
5020
  async fund(request, params) {
4905
5021
  const { addedSignatures, estimatedPredicates, maxFee: fee, requiredQuantities } = params;
4906
5022
  const baseAssetId = this.provider.getBaseAssetId();
5023
+ const requiredInBaseAsset = requiredQuantities.find((quantity) => quantity.assetId === baseAssetId)?.amount || bn20(0);
4907
5024
  const txRequest = request;
4908
5025
  const requiredQuantitiesWithFee = addAmountToCoinQuantities({
4909
- amount: bn18(fee),
5026
+ amount: bn20(fee),
4910
5027
  assetId: baseAssetId,
4911
5028
  coinQuantities: requiredQuantities
4912
5029
  });
@@ -4914,21 +5031,17 @@ var Account = class extends AbstractAccount {
4914
5031
  requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
4915
5032
  quantitiesDict[assetId] = {
4916
5033
  required: amount,
4917
- owned: bn18(0)
5034
+ owned: bn20(0)
4918
5035
  };
4919
5036
  });
4920
- txRequest.inputs.forEach((input) => {
4921
- const isResource = "amount" in input;
4922
- if (!isResource) {
4923
- return;
4924
- }
4925
- const isCoin2 = "owner" in input;
5037
+ request.inputs.filter(isRequestInputResource).forEach((input) => {
5038
+ const isCoin2 = isRequestInputCoin(input);
4926
5039
  const assetId = isCoin2 ? String(input.assetId) : baseAssetId;
4927
5040
  if (quantitiesDict[assetId]) {
4928
5041
  quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(input.amount);
4929
5042
  }
4930
5043
  });
4931
- const missingQuantities = [];
5044
+ let missingQuantities = [];
4932
5045
  Object.entries(quantitiesDict).forEach(([assetId, { owned, required }]) => {
4933
5046
  if (owned.lt(required)) {
4934
5047
  missingQuantities.push({
@@ -4937,11 +5050,42 @@ var Account = class extends AbstractAccount {
4937
5050
  });
4938
5051
  }
4939
5052
  });
4940
- const needsToBeFunded = missingQuantities.length;
4941
- if (needsToBeFunded) {
4942
- const excludedIds = cacheTxInputsFromOwner(txRequest.inputs, this.address.toB256());
4943
- const resources = await this.getResourcesToSpend(missingQuantities, excludedIds);
4944
- txRequest.addResources(resources);
5053
+ let needsToBeFunded = missingQuantities.length > 0;
5054
+ let fundingAttempts = 0;
5055
+ while (needsToBeFunded && fundingAttempts < MAX_FUNDING_ATTEMPTS) {
5056
+ const resources = await this.getResourcesToSpend(
5057
+ missingQuantities,
5058
+ cacheTxInputsFromOwner(request.inputs, this.address)
5059
+ );
5060
+ request.addResources(resources);
5061
+ txRequest.shiftPredicateData();
5062
+ txRequest.updatePredicateGasUsed(estimatedPredicates);
5063
+ const requestToReestimate2 = clone4(txRequest);
5064
+ if (addedSignatures) {
5065
+ Array.from({ length: addedSignatures }).forEach(
5066
+ () => requestToReestimate2.addEmptyWitness()
5067
+ );
5068
+ }
5069
+ const { maxFee: newFee } = await this.provider.estimateTxGasAndFee({
5070
+ transactionRequest: requestToReestimate2
5071
+ });
5072
+ const totalBaseAssetOnInputs = getAssetAmountInRequestInputs(
5073
+ request.inputs,
5074
+ baseAssetId,
5075
+ baseAssetId
5076
+ );
5077
+ const totalBaseAssetRequiredWithFee = requiredInBaseAsset.add(newFee);
5078
+ if (totalBaseAssetOnInputs.gt(totalBaseAssetRequiredWithFee)) {
5079
+ needsToBeFunded = false;
5080
+ } else {
5081
+ missingQuantities = [
5082
+ {
5083
+ amount: totalBaseAssetRequiredWithFee.sub(totalBaseAssetOnInputs),
5084
+ assetId: baseAssetId
5085
+ }
5086
+ ];
5087
+ }
5088
+ fundingAttempts += 1;
4945
5089
  }
4946
5090
  txRequest.shiftPredicateData();
4947
5091
  txRequest.updatePredicateGasUsed(estimatedPredicates);
@@ -4992,7 +5136,7 @@ var Account = class extends AbstractAccount {
4992
5136
  * @returns A promise that resolves to the transaction response.
4993
5137
  */
4994
5138
  async transfer(destination, amount, assetId, txParams = {}) {
4995
- if (bn18(amount).lte(0)) {
5139
+ if (bn20(amount).lte(0)) {
4996
5140
  throw new FuelError15(
4997
5141
  ErrorCode15.INVALID_TRANSFER_AMOUNT,
4998
5142
  "Transfer amount must be a positive number."
@@ -5012,7 +5156,7 @@ var Account = class extends AbstractAccount {
5012
5156
  * @returns A promise that resolves to the transaction response.
5013
5157
  */
5014
5158
  async transferToContract(contractId, amount, assetId, txParams = {}) {
5015
- if (bn18(amount).lte(0)) {
5159
+ if (bn20(amount).lte(0)) {
5016
5160
  throw new FuelError15(
5017
5161
  ErrorCode15.INVALID_TRANSFER_AMOUNT,
5018
5162
  "Transfer amount must be a positive number."
@@ -5022,7 +5166,7 @@ var Account = class extends AbstractAccount {
5022
5166
  const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
5023
5167
  const { script, scriptData } = await assembleTransferToContractScript({
5024
5168
  hexlifiedContractId: contractAddress.toB256(),
5025
- amountToTransfer: bn18(amount),
5169
+ amountToTransfer: bn20(amount),
5026
5170
  assetId: assetIdToTransfer
5027
5171
  });
5028
5172
  const request = new ScriptTransactionRequest({
@@ -5033,7 +5177,7 @@ var Account = class extends AbstractAccount {
5033
5177
  request.addContractInputAndOutput(contractAddress);
5034
5178
  const txCost = await this.provider.getTransactionCost(request, {
5035
5179
  resourcesOwner: this,
5036
- quantitiesToContract: [{ amount: bn18(amount), assetId: String(assetIdToTransfer) }]
5180
+ quantitiesToContract: [{ amount: bn20(amount), assetId: String(assetIdToTransfer) }]
5037
5181
  });
5038
5182
  this.validateGasLimitAndMaxFee({
5039
5183
  gasUsed: txCost.gasUsed,
@@ -5059,7 +5203,7 @@ var Account = class extends AbstractAccount {
5059
5203
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
5060
5204
  );
5061
5205
  const amountDataArray = arrayify14(
5062
- "0x".concat(bn18(amount).toHex().substring(2).padStart(16, "0"))
5206
+ "0x".concat(bn20(amount).toHex().substring(2).padStart(16, "0"))
5063
5207
  );
5064
5208
  const script = new Uint8Array([
5065
5209
  ...arrayify14(withdrawScript.bytes),
@@ -5069,7 +5213,7 @@ var Account = class extends AbstractAccount {
5069
5213
  const params = { script, ...txParams };
5070
5214
  const baseAssetId = this.provider.getBaseAssetId();
5071
5215
  const request = new ScriptTransactionRequest(params);
5072
- const quantitiesToContract = [{ amount: bn18(amount), assetId: baseAssetId }];
5216
+ const quantitiesToContract = [{ amount: bn20(amount), assetId: baseAssetId }];
5073
5217
  const txCost = await this.provider.getTransactionCost(request, { quantitiesToContract });
5074
5218
  this.validateGasLimitAndMaxFee({
5075
5219
  gasUsed: txCost.gasUsed,
@@ -5141,13 +5285,13 @@ var Account = class extends AbstractAccount {
5141
5285
  gasUsed,
5142
5286
  maxFee
5143
5287
  }) {
5144
- if (isDefined(setGasLimit) && gasUsed.gt(setGasLimit)) {
5288
+ if (isDefined2(setGasLimit) && gasUsed.gt(setGasLimit)) {
5145
5289
  throw new FuelError15(
5146
5290
  ErrorCode15.GAS_LIMIT_TOO_LOW,
5147
5291
  `Gas limit '${setGasLimit}' is lower than the required: '${gasUsed}'.`
5148
5292
  );
5149
5293
  }
5150
- if (isDefined(setMaxFee) && maxFee.gt(setMaxFee)) {
5294
+ if (isDefined2(setMaxFee) && maxFee.gt(setMaxFee)) {
5151
5295
  throw new FuelError15(
5152
5296
  ErrorCode15.MAX_FEE_TOO_LOW,
5153
5297
  `Max fee '${setMaxFee}' is lower than the required: '${maxFee}'.`
@@ -5479,7 +5623,7 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
5479
5623
  // src/hdwallet/hdwallet.ts
5480
5624
  import { ErrorCode as ErrorCode19, FuelError as FuelError19 } from "@fuel-ts/errors";
5481
5625
  import { sha256 as sha2564 } from "@fuel-ts/hasher";
5482
- import { bn as bn19, toBytes as toBytes2, toHex } from "@fuel-ts/math";
5626
+ import { bn as bn21, toBytes as toBytes2, toHex } from "@fuel-ts/math";
5483
5627
  import { arrayify as arrayify18, hexlify as hexlify17, concat as concat5 } from "@fuel-ts/utils";
5484
5628
  import { toBeHex, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58, computeHmac as computeHmac2, ripemd160 } from "ethers";
5485
5629
 
@@ -7945,7 +8089,7 @@ var HDWallet = class {
7945
8089
  const IR = bytes.slice(32);
7946
8090
  if (privateKey) {
7947
8091
  const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
7948
- const ki = bn19(IL).add(privateKey).mod(N).toBytes(32);
8092
+ const ki = bn21(IL).add(privateKey).mod(N).toBytes(32);
7949
8093
  return new HDWallet({
7950
8094
  privateKey: ki,
7951
8095
  chainCode: IR,
@@ -8360,9 +8504,11 @@ var launchNode = async ({
8360
8504
  const chainConfigWritePath = path.join(tempDirPath, "chainConfig.json");
8361
8505
  const stateConfigWritePath = path.join(tempDirPath, "stateConfig.json");
8362
8506
  const metadataWritePath = path.join(tempDirPath, "metadata.json");
8507
+ const stateTransitionWritePath = path.join(tempDirPath, "state_transition_bytecode.wasm");
8363
8508
  writeFileSync(chainConfigWritePath, JSON.stringify(chainConfigJson), "utf8");
8364
8509
  writeFileSync(stateConfigWritePath, fixedStateConfigJSON, "utf8");
8365
8510
  writeFileSync(metadataWritePath, JSON.stringify(metadataJson), "utf8");
8511
+ writeFileSync(stateTransitionWritePath, JSON.stringify(""));
8366
8512
  snapshotDirToUse = tempDirPath;
8367
8513
  }
8368
8514
  const child = spawn(