@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
package/dist/index.js CHANGED
@@ -108,7 +108,7 @@ __export(src_exports, {
108
108
  calculateGasFee: () => calculateGasFee,
109
109
  calculateMetadataGasForTxCreate: () => calculateMetadataGasForTxCreate,
110
110
  calculateMetadataGasForTxScript: () => calculateMetadataGasForTxScript,
111
- calculateTransactionFee: () => calculateTransactionFee,
111
+ calculateTXFeeForSummary: () => calculateTXFeeForSummary,
112
112
  coinQuantityfy: () => coinQuantityfy,
113
113
  deferPromise: () => deferPromise,
114
114
  dispatchFuelConnectorEvent: () => dispatchFuelConnectorEvent,
@@ -168,6 +168,8 @@ __export(src_exports, {
168
168
  isTypeCreate: () => isTypeCreate,
169
169
  isTypeMint: () => isTypeMint,
170
170
  isTypeScript: () => isTypeScript,
171
+ isTypeUpgrade: () => isTypeUpgrade,
172
+ isTypeUpload: () => isTypeUpload,
171
173
  normalizeJSON: () => normalizeJSON,
172
174
  outputify: () => outputify,
173
175
  processGqlReceipt: () => processGqlReceipt,
@@ -187,7 +189,7 @@ module.exports = __toCommonJS(src_exports);
187
189
  var import_address4 = require("@fuel-ts/address");
188
190
  var import_errors16 = require("@fuel-ts/errors");
189
191
  var import_interfaces = require("@fuel-ts/interfaces");
190
- var import_math19 = require("@fuel-ts/math");
192
+ var import_math21 = require("@fuel-ts/math");
191
193
  var import_utils27 = require("@fuel-ts/utils");
192
194
  var import_ramda4 = require("ramda");
193
195
 
@@ -229,12 +231,11 @@ var addAmountToCoinQuantities = (params) => {
229
231
  // src/providers/provider.ts
230
232
  var import_address3 = require("@fuel-ts/address");
231
233
  var import_errors14 = require("@fuel-ts/errors");
232
- var import_math16 = require("@fuel-ts/math");
234
+ var import_math17 = require("@fuel-ts/math");
233
235
  var import_transactions19 = require("@fuel-ts/transactions");
234
236
  var import_utils22 = require("@fuel-ts/utils");
235
237
  var import_versions = require("@fuel-ts/versions");
236
238
  var import_utils23 = require("@noble/curves/abstract/utils");
237
- var import_ethers = require("ethers");
238
239
  var import_graphql_request = require("graphql-request");
239
240
  var import_ramda3 = require("ramda");
240
241
 
@@ -291,9 +292,6 @@ var TransactionStatusFragmentFragmentDoc = import_graphql_tag.default`
291
292
  id
292
293
  }
293
294
  time
294
- receipts {
295
- ...receiptFragment
296
- }
297
295
  programState {
298
296
  returnType
299
297
  data
@@ -301,11 +299,15 @@ var TransactionStatusFragmentFragmentDoc = import_graphql_tag.default`
301
299
  receipts {
302
300
  ...receiptFragment
303
301
  }
302
+ totalGas
303
+ totalFee
304
304
  }
305
305
  ... on FailureStatus {
306
306
  block {
307
307
  id
308
308
  }
309
+ totalGas
310
+ totalFee
309
311
  time
310
312
  reason
311
313
  receipts {
@@ -345,6 +347,8 @@ var TransactionEstimatePredicatesFragmentFragmentDoc = import_graphql_tag.defaul
345
347
  ${InputEstimatePredicatesFragmentFragmentDoc}`;
346
348
  var DryRunFailureStatusFragmentFragmentDoc = import_graphql_tag.default`
347
349
  fragment dryRunFailureStatusFragment on DryRunFailureStatus {
350
+ totalGas
351
+ totalFee
348
352
  reason
349
353
  programState {
350
354
  returnType
@@ -354,6 +358,8 @@ var DryRunFailureStatusFragmentFragmentDoc = import_graphql_tag.default`
354
358
  `;
355
359
  var DryRunSuccessStatusFragmentFragmentDoc = import_graphql_tag.default`
356
360
  fragment dryRunSuccessStatusFragment on DryRunSuccessStatus {
361
+ totalGas
362
+ totalFee
357
363
  programState {
358
364
  returnType
359
365
  data
@@ -489,6 +495,7 @@ var TxParametersFragmentFragmentDoc = import_graphql_tag.default`
489
495
  maxWitnesses
490
496
  maxGasPerTx
491
497
  maxSize
498
+ maxBytecodeSubsections
492
499
  }
493
500
  `;
494
501
  var PredicateParametersFragmentFragmentDoc = import_graphql_tag.default`
@@ -758,6 +765,14 @@ var NodeInfoFragmentFragmentDoc = import_graphql_tag.default`
758
765
  nodeVersion
759
766
  }
760
767
  `;
768
+ var RelayedTransactionStatusFragmentFragmentDoc = import_graphql_tag.default`
769
+ fragment relayedTransactionStatusFragment on RelayedTransactionStatus {
770
+ ... on RelayedTransactionFailed {
771
+ blockHeight
772
+ failure
773
+ }
774
+ }
775
+ `;
761
776
  var GetVersionDocument = import_graphql_tag.default`
762
777
  query getVersion {
763
778
  nodeInfo {
@@ -987,6 +1002,13 @@ var GetMessageStatusDocument = import_graphql_tag.default`
987
1002
  }
988
1003
  }
989
1004
  `;
1005
+ var GetRelayedTransactionStatusDocument = import_graphql_tag.default`
1006
+ query getRelayedTransactionStatus($relayedTransactionId: RelayedTransactionId!) {
1007
+ relayedTransactionStatus(id: $relayedTransactionId) {
1008
+ ...relayedTransactionStatusFragment
1009
+ }
1010
+ }
1011
+ ${RelayedTransactionStatusFragmentFragmentDoc}`;
990
1012
  var DryRunDocument = import_graphql_tag.default`
991
1013
  mutation dryRun($encodedTransactions: [HexString!]!, $utxoValidation: Boolean) {
992
1014
  dryRun(txs: $encodedTransactions, utxoValidation: $utxoValidation) {
@@ -1009,6 +1031,13 @@ var ProduceBlocksDocument = import_graphql_tag.default`
1009
1031
  )
1010
1032
  }
1011
1033
  `;
1034
+ var GetMessageByNonceDocument = import_graphql_tag.default`
1035
+ query getMessageByNonce($nonce: Nonce!) {
1036
+ message(nonce: $nonce) {
1037
+ ...messageFragment
1038
+ }
1039
+ }
1040
+ ${MessageFragmentFragmentDoc}`;
1012
1041
  var SubmitAndAwaitDocument = import_graphql_tag.default`
1013
1042
  subscription submitAndAwait($encodedTransaction: HexString!) {
1014
1043
  submitAndAwait(tx: $encodedTransaction) {
@@ -1094,6 +1123,9 @@ function getSdk(requester) {
1094
1123
  getMessageStatus(variables, options) {
1095
1124
  return requester(GetMessageStatusDocument, variables, options);
1096
1125
  },
1126
+ getRelayedTransactionStatus(variables, options) {
1127
+ return requester(GetRelayedTransactionStatusDocument, variables, options);
1128
+ },
1097
1129
  dryRun(variables, options) {
1098
1130
  return requester(DryRunDocument, variables, options);
1099
1131
  },
@@ -1103,6 +1135,9 @@ function getSdk(requester) {
1103
1135
  produceBlocks(variables, options) {
1104
1136
  return requester(ProduceBlocksDocument, variables, options);
1105
1137
  },
1138
+ getMessageByNonce(variables, options) {
1139
+ return requester(GetMessageByNonceDocument, variables, options);
1140
+ },
1106
1141
  submitAndAwait(variables, options) {
1107
1142
  return requester(SubmitAndAwaitDocument, variables, options);
1108
1143
  },
@@ -1759,7 +1794,7 @@ function calculateMetadataGasForTxScript({
1759
1794
  }
1760
1795
  var calculateGasFee = (params) => {
1761
1796
  const { gas, gasPrice, priceFactor, tip } = params;
1762
- return gas.mul(gasPrice).div(priceFactor).add(tip);
1797
+ return gas.mul(gasPrice).div(priceFactor).add((0, import_math5.bn)(tip));
1763
1798
  };
1764
1799
 
1765
1800
  // src/providers/utils/json.ts
@@ -1936,10 +1971,10 @@ var BaseTransactionRequest = class {
1936
1971
  outputs,
1937
1972
  witnesses
1938
1973
  } = {}) {
1939
- this.tip = (0, import_math7.bn)(tip);
1940
- this.maturity = maturity ?? 0;
1941
- this.witnessLimit = witnessLimit ? (0, import_math7.bn)(witnessLimit) : void 0;
1942
- this.maxFee = maxFee ? (0, import_math7.bn)(maxFee) : void 0;
1974
+ this.tip = tip ? (0, import_math7.bn)(tip) : void 0;
1975
+ this.maturity = maturity && maturity > 0 ? maturity : void 0;
1976
+ this.witnessLimit = (0, import_utils9.isDefined)(witnessLimit) ? (0, import_math7.bn)(witnessLimit) : void 0;
1977
+ this.maxFee = (0, import_math7.bn)(maxFee);
1943
1978
  this.inputs = inputs ?? [];
1944
1979
  this.outputs = outputs ?? [];
1945
1980
  this.witnesses = witnesses ?? [];
@@ -1947,22 +1982,21 @@ var BaseTransactionRequest = class {
1947
1982
  static getPolicyMeta(req) {
1948
1983
  let policyTypes = 0;
1949
1984
  const policies = [];
1950
- if (req.tip) {
1985
+ const { tip, witnessLimit, maturity } = req;
1986
+ if ((0, import_math7.bn)(tip).gt(0)) {
1951
1987
  policyTypes += import_transactions6.PolicyType.Tip;
1952
- policies.push({ data: req.tip, type: import_transactions6.PolicyType.Tip });
1988
+ policies.push({ data: (0, import_math7.bn)(tip), type: import_transactions6.PolicyType.Tip });
1953
1989
  }
1954
- if (req.witnessLimit) {
1990
+ if ((0, import_utils9.isDefined)(witnessLimit) && (0, import_math7.bn)(witnessLimit).gte(0)) {
1955
1991
  policyTypes += import_transactions6.PolicyType.WitnessLimit;
1956
- policies.push({ data: req.witnessLimit, type: import_transactions6.PolicyType.WitnessLimit });
1992
+ policies.push({ data: (0, import_math7.bn)(witnessLimit), type: import_transactions6.PolicyType.WitnessLimit });
1957
1993
  }
1958
- if (req.maturity > 0) {
1994
+ if (maturity && maturity > 0) {
1959
1995
  policyTypes += import_transactions6.PolicyType.Maturity;
1960
- policies.push({ data: req.maturity, type: import_transactions6.PolicyType.Maturity });
1961
- }
1962
- if (req.maxFee) {
1963
- policyTypes += import_transactions6.PolicyType.MaxFee;
1964
- policies.push({ data: req.maxFee, type: import_transactions6.PolicyType.MaxFee });
1996
+ policies.push({ data: maturity, type: import_transactions6.PolicyType.Maturity });
1965
1997
  }
1998
+ policyTypes += import_transactions6.PolicyType.MaxFee;
1999
+ policies.push({ data: req.maxFee, type: import_transactions6.PolicyType.MaxFee });
1966
2000
  return {
1967
2001
  policyTypes,
1968
2002
  policies
@@ -2278,8 +2312,11 @@ var BaseTransactionRequest = class {
2278
2312
  * @hidden
2279
2313
  */
2280
2314
  calculateMinGas(chainInfo) {
2281
- const { gasCosts, consensusParameters } = chainInfo;
2282
- const { gasPerByte } = consensusParameters;
2315
+ const { consensusParameters } = chainInfo;
2316
+ const {
2317
+ gasCosts,
2318
+ feeParameters: { gasPerByte }
2319
+ } = consensusParameters;
2283
2320
  return getMinGas({
2284
2321
  gasPerByte,
2285
2322
  gasCosts,
@@ -2290,7 +2327,10 @@ var BaseTransactionRequest = class {
2290
2327
  }
2291
2328
  calculateMaxGas(chainInfo, minGas) {
2292
2329
  const { consensusParameters } = chainInfo;
2293
- const { gasPerByte, maxGasPerTx } = consensusParameters;
2330
+ const {
2331
+ feeParameters: { gasPerByte },
2332
+ txParameters: { maxGasPerTx }
2333
+ } = consensusParameters;
2294
2334
  const witnessesLength = this.toTransaction().witnesses.reduce(
2295
2335
  (acc, wit) => acc + wit.dataLength,
2296
2336
  0
@@ -2725,7 +2765,10 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2725
2765
  }
2726
2766
  calculateMaxGas(chainInfo, minGas) {
2727
2767
  const { consensusParameters } = chainInfo;
2728
- const { gasPerByte, maxGasPerTx } = consensusParameters;
2768
+ const {
2769
+ feeParameters: { gasPerByte },
2770
+ txParameters: { maxGasPerTx }
2771
+ } = consensusParameters;
2729
2772
  const witnessesLength = this.toTransaction().witnesses.reduce(
2730
2773
  (acc, wit) => acc + wit.dataLength,
2731
2774
  0
@@ -2813,10 +2856,10 @@ var transactionRequestify = (obj) => {
2813
2856
  };
2814
2857
  var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
2815
2858
  (acc, input) => {
2816
- if (input.type === import_transactions10.InputType.Coin && input.owner === owner) {
2859
+ if (input.type === import_transactions10.InputType.Coin && input.owner === owner.toB256()) {
2817
2860
  acc.utxos.push(input.id);
2818
2861
  }
2819
- if (input.type === import_transactions10.InputType.Message && input.recipient === owner) {
2862
+ if (input.type === import_transactions10.InputType.Message && input.recipient === owner.toB256()) {
2820
2863
  acc.messages.push(input.nonce);
2821
2864
  }
2822
2865
  return acc;
@@ -2829,40 +2872,40 @@ var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
2829
2872
 
2830
2873
  // src/providers/transaction-response/transaction-response.ts
2831
2874
  var import_errors13 = require("@fuel-ts/errors");
2832
- var import_math15 = require("@fuel-ts/math");
2875
+ var import_math16 = require("@fuel-ts/math");
2833
2876
  var import_transactions18 = require("@fuel-ts/transactions");
2834
2877
  var import_utils20 = require("@fuel-ts/utils");
2835
2878
 
2836
2879
  // src/providers/transaction-summary/assemble-transaction-summary.ts
2837
- var import_math14 = require("@fuel-ts/math");
2880
+ var import_math15 = require("@fuel-ts/math");
2838
2881
  var import_transactions16 = require("@fuel-ts/transactions");
2839
2882
  var import_utils18 = require("@fuel-ts/utils");
2840
2883
 
2841
- // src/providers/transaction-summary/calculate-transaction-fee.ts
2884
+ // src/providers/transaction-summary/calculate-tx-fee-for-summary.ts
2842
2885
  var import_math11 = require("@fuel-ts/math");
2843
2886
  var import_transactions11 = require("@fuel-ts/transactions");
2844
2887
  var import_utils16 = require("@fuel-ts/utils");
2845
- var calculateTransactionFee = (params) => {
2888
+ var calculateTXFeeForSummary = (params) => {
2846
2889
  const {
2847
2890
  gasPrice,
2848
2891
  rawPayload,
2849
2892
  tip,
2893
+ totalFee,
2850
2894
  consensusParameters: { gasCosts, feeParams, maxGasPerTx }
2851
2895
  } = params;
2896
+ if (totalFee) {
2897
+ return totalFee;
2898
+ }
2852
2899
  const gasPerByte = (0, import_math11.bn)(feeParams.gasPerByte);
2853
2900
  const gasPriceFactor = (0, import_math11.bn)(feeParams.gasPriceFactor);
2854
2901
  const transactionBytes = (0, import_utils16.arrayify)(rawPayload);
2855
2902
  const [transaction] = new import_transactions11.TransactionCoder().decode(transactionBytes, 0);
2856
- if (transaction.type === import_transactions11.TransactionType.Mint) {
2857
- return {
2858
- fee: (0, import_math11.bn)(0),
2859
- minFee: (0, import_math11.bn)(0),
2860
- maxFee: (0, import_math11.bn)(0)
2861
- };
2862
- }
2863
2903
  const { type, witnesses, inputs, policies } = transaction;
2864
2904
  let metadataGas = (0, import_math11.bn)(0);
2865
2905
  let gasLimit = (0, import_math11.bn)(0);
2906
+ if (type !== import_transactions11.TransactionType.Create && type !== import_transactions11.TransactionType.Script) {
2907
+ return (0, import_math11.bn)(0);
2908
+ }
2866
2909
  if (type === import_transactions11.TransactionType.Create) {
2867
2910
  const { bytecodeWitnessIndex, storageSlots } = transaction;
2868
2911
  const contractBytesSize = (0, import_math11.bn)((0, import_utils16.arrayify)(witnesses[bytecodeWitnessIndex].data).length);
@@ -2899,23 +2942,13 @@ var calculateTransactionFee = (params) => {
2899
2942
  witnessLimit,
2900
2943
  maxGasPerTx
2901
2944
  });
2902
- const minFee = calculateGasFee({
2903
- gasPrice,
2904
- gas: minGas,
2905
- priceFactor: gasPriceFactor,
2906
- tip
2907
- });
2908
2945
  const maxFee = calculateGasFee({
2909
2946
  gasPrice,
2910
2947
  gas: maxGas,
2911
2948
  priceFactor: gasPriceFactor,
2912
2949
  tip
2913
2950
  });
2914
- return {
2915
- minFee,
2916
- maxFee,
2917
- fee: maxFee
2918
- };
2951
+ return maxFee;
2919
2952
  };
2920
2953
 
2921
2954
  // src/providers/transaction-summary/operations.ts
@@ -3050,6 +3083,8 @@ var TransactionTypeName = /* @__PURE__ */ ((TransactionTypeName2) => {
3050
3083
  TransactionTypeName2["Create"] = "Create";
3051
3084
  TransactionTypeName2["Mint"] = "Mint";
3052
3085
  TransactionTypeName2["Script"] = "Script";
3086
+ TransactionTypeName2["Upgrade"] = "Upgrade";
3087
+ TransactionTypeName2["Upload"] = "Upload";
3053
3088
  return TransactionTypeName2;
3054
3089
  })(TransactionTypeName || {});
3055
3090
  var TransactionStatus = /* @__PURE__ */ ((TransactionStatus2) => {
@@ -3115,6 +3150,12 @@ function isTypeCreate(transactionType) {
3115
3150
  function isTypeScript(transactionType) {
3116
3151
  return isType(transactionType, "Script" /* Script */);
3117
3152
  }
3153
+ function isTypeUpgrade(transactionType) {
3154
+ return isType(transactionType, "Upgrade" /* Upgrade */);
3155
+ }
3156
+ function isTypeUpload(transactionType) {
3157
+ return isType(transactionType, "Upload" /* Upload */);
3158
+ }
3118
3159
  function hasSameAssetId(a) {
3119
3160
  return (b) => a.assetId === b.assetId;
3120
3161
  }
@@ -3461,6 +3502,7 @@ var extractBurnedAssetsFromReceipts = (receipts) => {
3461
3502
 
3462
3503
  // src/providers/transaction-summary/status.ts
3463
3504
  var import_errors12 = require("@fuel-ts/errors");
3505
+ var import_math14 = require("@fuel-ts/math");
3464
3506
  var getTransactionStatusName = (gqlStatus) => {
3465
3507
  switch (gqlStatus) {
3466
3508
  case "FailureStatus":
@@ -3482,6 +3524,8 @@ var processGraphqlStatus = (gqlTransactionStatus) => {
3482
3524
  let time;
3483
3525
  let blockId;
3484
3526
  let status;
3527
+ let totalFee;
3528
+ let totalGas;
3485
3529
  let isStatusFailure = false;
3486
3530
  let isStatusSuccess = false;
3487
3531
  let isStatusPending = false;
@@ -3492,11 +3536,15 @@ var processGraphqlStatus = (gqlTransactionStatus) => {
3492
3536
  time = gqlTransactionStatus.time;
3493
3537
  blockId = gqlTransactionStatus.block.id;
3494
3538
  isStatusSuccess = true;
3539
+ totalFee = (0, import_math14.bn)(gqlTransactionStatus.totalFee);
3540
+ totalGas = (0, import_math14.bn)(gqlTransactionStatus.totalGas);
3495
3541
  break;
3496
3542
  case "FailureStatus":
3497
3543
  time = gqlTransactionStatus.time;
3498
3544
  blockId = gqlTransactionStatus.block.id;
3499
3545
  isStatusFailure = true;
3546
+ totalFee = (0, import_math14.bn)(gqlTransactionStatus.totalFee);
3547
+ totalGas = (0, import_math14.bn)(gqlTransactionStatus.totalGas);
3500
3548
  break;
3501
3549
  case "SubmittedStatus":
3502
3550
  time = gqlTransactionStatus.time;
@@ -3509,6 +3557,8 @@ var processGraphqlStatus = (gqlTransactionStatus) => {
3509
3557
  time,
3510
3558
  blockId,
3511
3559
  status,
3560
+ totalFee,
3561
+ totalGas,
3512
3562
  isStatusFailure,
3513
3563
  isStatusSuccess,
3514
3564
  isStatusPending
@@ -3544,8 +3594,10 @@ function assembleTransactionSummary(params) {
3544
3594
  maxInputs
3545
3595
  });
3546
3596
  const typeName = getTransactionTypeName(transaction.type);
3547
- const tip = (0, import_math14.bn)(transaction.policies?.find((policy) => policy.type === import_transactions16.PolicyType.Tip)?.data);
3548
- const { fee } = calculateTransactionFee({
3597
+ const tip = (0, import_math15.bn)(transaction.policies?.find((policy) => policy.type === import_transactions16.PolicyType.Tip)?.data);
3598
+ const { isStatusFailure, isStatusPending, isStatusSuccess, blockId, status, time, totalFee } = processGraphqlStatus(gqlTransactionStatus);
3599
+ const fee = calculateTXFeeForSummary({
3600
+ totalFee,
3549
3601
  gasPrice,
3550
3602
  rawPayload,
3551
3603
  tip,
@@ -3558,7 +3610,6 @@ function assembleTransactionSummary(params) {
3558
3610
  }
3559
3611
  }
3560
3612
  });
3561
- const { isStatusFailure, isStatusPending, isStatusSuccess, blockId, status, time } = processGraphqlStatus(gqlTransactionStatus);
3562
3613
  const mintedAssets = extractMintedAssetsFromReceipts(receipts);
3563
3614
  const burnedAssets = extractBurnedAssetsFromReceipts(receipts);
3564
3615
  let date;
@@ -3567,6 +3618,7 @@ function assembleTransactionSummary(params) {
3567
3618
  }
3568
3619
  const transactionSummary = {
3569
3620
  id,
3621
+ tip,
3570
3622
  fee,
3571
3623
  gasUsed,
3572
3624
  operations,
@@ -3580,6 +3632,8 @@ function assembleTransactionSummary(params) {
3580
3632
  isTypeMint: isTypeMint(transaction.type),
3581
3633
  isTypeCreate: isTypeCreate(transaction.type),
3582
3634
  isTypeScript: isTypeScript(transaction.type),
3635
+ isTypeUpgrade: isTypeUpgrade(transaction.type),
3636
+ isTypeUpload: isTypeUpload(transaction.type),
3583
3637
  isStatusFailure,
3584
3638
  isStatusSuccess,
3585
3639
  isStatusPending,
@@ -3611,7 +3665,7 @@ var TransactionResponse = class {
3611
3665
  /** Current provider */
3612
3666
  provider;
3613
3667
  /** Gas used on the transaction */
3614
- gasUsed = (0, import_math15.bn)(0);
3668
+ gasUsed = (0, import_math16.bn)(0);
3615
3669
  /** The graphql Transaction with receipts object. */
3616
3670
  gqlTransaction;
3617
3671
  abis;
@@ -3696,7 +3750,7 @@ var TransactionResponse = class {
3696
3750
  const receipts = txReceipts.map(processGqlReceipt) || [];
3697
3751
  const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
3698
3752
  const gasPrice = await this.provider.getLatestGasPrice();
3699
- const maxInputs = this.provider.getChain().consensusParameters.maxInputs;
3753
+ const maxInputs = this.provider.getChain().consensusParameters.txParameters.maxInputs;
3700
3754
  const transactionSummary = assembleTransactionSummary({
3701
3755
  id: this.id,
3702
3756
  receipts,
@@ -3832,33 +3886,60 @@ var mergeQuantities = (...coinQuantities) => {
3832
3886
  var MAX_RETRIES = 10;
3833
3887
  var processGqlChain = (chain) => {
3834
3888
  const { name, daHeight, consensusParameters, latestBlock } = chain;
3835
- const { contractParams, feeParams, predicateParams, scriptParams, txParams, gasCosts } = consensusParameters;
3889
+ const {
3890
+ contractParams,
3891
+ feeParams,
3892
+ predicateParams,
3893
+ scriptParams,
3894
+ txParams,
3895
+ gasCosts,
3896
+ baseAssetId,
3897
+ chainId,
3898
+ version
3899
+ } = consensusParameters;
3836
3900
  return {
3837
3901
  name,
3838
- baseChainHeight: (0, import_math16.bn)(daHeight),
3902
+ baseChainHeight: (0, import_math17.bn)(daHeight),
3839
3903
  consensusParameters: {
3840
- contractMaxSize: (0, import_math16.bn)(contractParams.contractMaxSize),
3841
- maxInputs: (0, import_math16.bn)(txParams.maxInputs),
3842
- maxOutputs: (0, import_math16.bn)(txParams.maxOutputs),
3843
- maxWitnesses: (0, import_math16.bn)(txParams.maxWitnesses),
3844
- maxGasPerTx: (0, import_math16.bn)(txParams.maxGasPerTx),
3845
- maxScriptLength: (0, import_math16.bn)(scriptParams.maxScriptLength),
3846
- maxScriptDataLength: (0, import_math16.bn)(scriptParams.maxScriptDataLength),
3847
- maxStorageSlots: (0, import_math16.bn)(contractParams.maxStorageSlots),
3848
- maxPredicateLength: (0, import_math16.bn)(predicateParams.maxPredicateLength),
3849
- maxPredicateDataLength: (0, import_math16.bn)(predicateParams.maxPredicateDataLength),
3850
- maxGasPerPredicate: (0, import_math16.bn)(predicateParams.maxGasPerPredicate),
3851
- gasPriceFactor: (0, import_math16.bn)(feeParams.gasPriceFactor),
3852
- gasPerByte: (0, import_math16.bn)(feeParams.gasPerByte),
3853
- maxMessageDataLength: (0, import_math16.bn)(predicateParams.maxMessageDataLength),
3854
- chainId: (0, import_math16.bn)(consensusParameters.chainId),
3855
- baseAssetId: consensusParameters.baseAssetId,
3904
+ version,
3905
+ chainId: (0, import_math17.bn)(chainId),
3906
+ baseAssetId,
3907
+ feeParameters: {
3908
+ version: feeParams.version,
3909
+ gasPerByte: (0, import_math17.bn)(feeParams.gasPerByte),
3910
+ gasPriceFactor: (0, import_math17.bn)(feeParams.gasPriceFactor)
3911
+ },
3912
+ contractParameters: {
3913
+ version: contractParams.version,
3914
+ contractMaxSize: (0, import_math17.bn)(contractParams.contractMaxSize),
3915
+ maxStorageSlots: (0, import_math17.bn)(contractParams.maxStorageSlots)
3916
+ },
3917
+ txParameters: {
3918
+ version: txParams.version,
3919
+ maxInputs: (0, import_math17.bn)(txParams.maxInputs),
3920
+ maxOutputs: (0, import_math17.bn)(txParams.maxOutputs),
3921
+ maxWitnesses: (0, import_math17.bn)(txParams.maxWitnesses),
3922
+ maxGasPerTx: (0, import_math17.bn)(txParams.maxGasPerTx),
3923
+ maxSize: (0, import_math17.bn)(txParams.maxSize),
3924
+ maxBytecodeSubsections: (0, import_math17.bn)(txParams.maxBytecodeSubsections)
3925
+ },
3926
+ predicateParameters: {
3927
+ version: predicateParams.version,
3928
+ maxPredicateLength: (0, import_math17.bn)(predicateParams.maxPredicateLength),
3929
+ maxPredicateDataLength: (0, import_math17.bn)(predicateParams.maxPredicateDataLength),
3930
+ maxGasPerPredicate: (0, import_math17.bn)(predicateParams.maxGasPerPredicate),
3931
+ maxMessageDataLength: (0, import_math17.bn)(predicateParams.maxMessageDataLength)
3932
+ },
3933
+ scriptParameters: {
3934
+ version: scriptParams.version,
3935
+ maxScriptLength: (0, import_math17.bn)(scriptParams.maxScriptLength),
3936
+ maxScriptDataLength: (0, import_math17.bn)(scriptParams.maxScriptDataLength)
3937
+ },
3856
3938
  gasCosts
3857
3939
  },
3858
- gasCosts,
3859
3940
  latestBlock: {
3860
3941
  id: latestBlock.id,
3861
- height: (0, import_math16.bn)(latestBlock.height),
3942
+ height: (0, import_math17.bn)(latestBlock.height),
3862
3943
  time: latestBlock.header.time,
3863
3944
  transactions: latestBlock.transactions.map((i) => ({
3864
3945
  id: i.id
@@ -3952,7 +4033,12 @@ var _Provider = class {
3952
4033
  * Returns some helpful parameters related to gas fees.
3953
4034
  */
3954
4035
  getGasConfig() {
3955
- const { maxGasPerTx, maxGasPerPredicate, gasPriceFactor, gasPerByte, gasCosts } = this.getChain().consensusParameters;
4036
+ const {
4037
+ txParameters: { maxGasPerTx },
4038
+ predicateParameters: { maxGasPerPredicate },
4039
+ feeParameters: { gasPriceFactor, gasPerByte },
4040
+ gasCosts
4041
+ } = this.getChain().consensusParameters;
3956
4042
  return {
3957
4043
  maxGasPerTx,
3958
4044
  maxGasPerPredicate,
@@ -4001,7 +4087,18 @@ var _Provider = class {
4001
4087
  createOperations() {
4002
4088
  const fetchFn = _Provider.getFetchFn(this.options);
4003
4089
  const gqlClient = new import_graphql_request.GraphQLClient(this.url, {
4004
- fetch: (url, requestInit) => fetchFn(url, requestInit, this.options)
4090
+ fetch: (url, requestInit) => fetchFn(url, requestInit, this.options),
4091
+ responseMiddleware: (response) => {
4092
+ if ("response" in response) {
4093
+ const graphQlResponse = response.response;
4094
+ if (Array.isArray(graphQlResponse?.errors)) {
4095
+ throw new import_errors14.FuelError(
4096
+ import_errors14.FuelError.CODES.INVALID_REQUEST,
4097
+ graphQlResponse.errors.map((err) => err.message).join("\n\n")
4098
+ );
4099
+ }
4100
+ }
4101
+ }
4005
4102
  });
4006
4103
  const executeQuery = (query, vars) => {
4007
4104
  const opDefinition = query.definitions.find((x) => x.kind === "OperationDefinition");
@@ -4029,21 +4126,6 @@ var _Provider = class {
4029
4126
  } = await this.operations.getVersion();
4030
4127
  return nodeVersion;
4031
4128
  }
4032
- /**
4033
- * @hidden
4034
- *
4035
- * Returns the network configuration of the connected Fuel node.
4036
- *
4037
- * @returns A promise that resolves to the network configuration object
4038
- */
4039
- async getNetwork() {
4040
- const {
4041
- name,
4042
- consensusParameters: { chainId }
4043
- } = await this.getChain();
4044
- const network = new import_ethers.Network(name, chainId.toNumber());
4045
- return Promise.resolve(network);
4046
- }
4047
4129
  /**
4048
4130
  * Returns the block number.
4049
4131
  *
@@ -4051,7 +4133,7 @@ var _Provider = class {
4051
4133
  */
4052
4134
  async getBlockNumber() {
4053
4135
  const { chain } = await this.operations.getChain();
4054
- return (0, import_math16.bn)(chain.latestBlock.height, 10);
4136
+ return (0, import_math17.bn)(chain.latestBlock.height, 10);
4055
4137
  }
4056
4138
  /**
4057
4139
  * Returns the chain information.
@@ -4061,8 +4143,8 @@ var _Provider = class {
4061
4143
  async fetchNode() {
4062
4144
  const { nodeInfo } = await this.operations.getNodeInfo();
4063
4145
  const processedNodeInfo = {
4064
- maxDepth: (0, import_math16.bn)(nodeInfo.maxDepth),
4065
- maxTx: (0, import_math16.bn)(nodeInfo.maxTx),
4146
+ maxDepth: (0, import_math17.bn)(nodeInfo.maxDepth),
4147
+ maxTx: (0, import_math17.bn)(nodeInfo.maxTx),
4066
4148
  nodeVersion: nodeInfo.nodeVersion,
4067
4149
  utxoValidation: nodeInfo.utxoValidation,
4068
4150
  vmBacktrace: nodeInfo.vmBacktrace
@@ -4166,9 +4248,9 @@ var _Provider = class {
4166
4248
  encodedTransactions: encodedTransaction,
4167
4249
  utxoValidation: utxoValidation || false
4168
4250
  });
4169
- const [{ receipts: rawReceipts, status }] = dryRunStatuses;
4251
+ const [{ receipts: rawReceipts, status: dryRunStatus }] = dryRunStatuses;
4170
4252
  const receipts = rawReceipts.map(processGqlReceipt);
4171
- return { receipts, dryrunStatus: status };
4253
+ return { receipts, dryRunStatus };
4172
4254
  }
4173
4255
  /**
4174
4256
  * Verifies whether enough gas is available to complete transaction.
@@ -4179,7 +4261,7 @@ var _Provider = class {
4179
4261
  async estimatePredicates(transactionRequest) {
4180
4262
  const shouldEstimatePredicates = Boolean(
4181
4263
  transactionRequest.inputs.find(
4182
- (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()
4264
+ (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()
4183
4265
  )
4184
4266
  );
4185
4267
  if (!shouldEstimatePredicates) {
@@ -4194,7 +4276,7 @@ var _Provider = class {
4194
4276
  } = response;
4195
4277
  if (inputs) {
4196
4278
  inputs.forEach((input, index) => {
4197
- if ("predicateGasUsed" in input && (0, import_math16.bn)(input.predicateGasUsed).gt(0)) {
4279
+ if ("predicateGasUsed" in input && (0, import_math17.bn)(input.predicateGasUsed).gt(0)) {
4198
4280
  transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
4199
4281
  }
4200
4282
  });
@@ -4222,7 +4304,7 @@ var _Provider = class {
4222
4304
  let receipts = [];
4223
4305
  const missingContractIds = [];
4224
4306
  let outputVariables = 0;
4225
- let dryrunStatus;
4307
+ let dryRunStatus;
4226
4308
  for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
4227
4309
  const {
4228
4310
  dryRun: [{ receipts: rawReceipts, status }]
@@ -4231,7 +4313,7 @@ var _Provider = class {
4231
4313
  utxoValidation: false
4232
4314
  });
4233
4315
  receipts = rawReceipts.map(processGqlReceipt);
4234
- dryrunStatus = status;
4316
+ dryRunStatus = status;
4235
4317
  const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
4236
4318
  const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
4237
4319
  if (hasMissingOutputs) {
@@ -4253,7 +4335,7 @@ var _Provider = class {
4253
4335
  receipts,
4254
4336
  outputVariables,
4255
4337
  missingContractIds,
4256
- dryrunStatus
4338
+ dryRunStatus
4257
4339
  };
4258
4340
  }
4259
4341
  /**
@@ -4271,7 +4353,7 @@ var _Provider = class {
4271
4353
  receipts: [],
4272
4354
  outputVariables: 0,
4273
4355
  missingContractIds: [],
4274
- dryrunStatus: void 0
4356
+ dryRunStatus: void 0
4275
4357
  }));
4276
4358
  const allRequests = (0, import_ramda3.clone)(transactionRequests);
4277
4359
  const serializedTransactionsMap = /* @__PURE__ */ new Map();
@@ -4296,7 +4378,7 @@ var _Provider = class {
4296
4378
  const { receipts: rawReceipts, status } = dryRunResults.dryRun[i];
4297
4379
  const result = results[requestIdx];
4298
4380
  result.receipts = rawReceipts.map(processGqlReceipt);
4299
- result.dryrunStatus = status;
4381
+ result.dryRunStatus = status;
4300
4382
  const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(
4301
4383
  result.receipts
4302
4384
  );
@@ -4333,7 +4415,7 @@ var _Provider = class {
4333
4415
  });
4334
4416
  const results = dryRunStatuses.map(({ receipts: rawReceipts, status }) => {
4335
4417
  const receipts = rawReceipts.map(processGqlReceipt);
4336
- return { receipts, dryrunStatus: status };
4418
+ return { receipts, dryRunStatus: status };
4337
4419
  });
4338
4420
  return results;
4339
4421
  }
@@ -4352,12 +4434,12 @@ var _Provider = class {
4352
4434
  gasPrice = await this.estimateGasPrice(10);
4353
4435
  }
4354
4436
  const minFee = calculateGasFee({
4355
- gasPrice: (0, import_math16.bn)(gasPrice),
4437
+ gasPrice: (0, import_math17.bn)(gasPrice),
4356
4438
  gas: minGas,
4357
4439
  priceFactor: gasPriceFactor,
4358
4440
  tip: transactionRequest.tip
4359
4441
  }).add(1);
4360
- let gasLimit = (0, import_math16.bn)(0);
4442
+ let gasLimit = (0, import_math17.bn)(0);
4361
4443
  if (transactionRequest.type === import_transactions19.TransactionType.Script) {
4362
4444
  gasLimit = transactionRequest.gasLimit;
4363
4445
  if (transactionRequest.gasLimit.eq(0)) {
@@ -4370,7 +4452,7 @@ var _Provider = class {
4370
4452
  }
4371
4453
  const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
4372
4454
  const maxFee = calculateGasFee({
4373
- gasPrice: (0, import_math16.bn)(gasPrice),
4455
+ gasPrice: (0, import_math17.bn)(gasPrice),
4374
4456
  gas: maxGas,
4375
4457
  priceFactor: gasPriceFactor,
4376
4458
  tip: transactionRequest.tip
@@ -4433,9 +4515,9 @@ var _Provider = class {
4433
4515
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
4434
4516
  const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
4435
4517
  txRequestClone.fundWithFakeUtxos(allQuantities, baseAssetId, resourcesOwner?.address);
4436
- txRequestClone.maxFee = (0, import_math16.bn)(0);
4518
+ txRequestClone.maxFee = (0, import_math17.bn)(0);
4437
4519
  if (isScriptTransaction) {
4438
- txRequestClone.gasLimit = (0, import_math16.bn)(0);
4520
+ txRequestClone.gasLimit = (0, import_math17.bn)(0);
4439
4521
  }
4440
4522
  if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
4441
4523
  resourcesOwner.populateTransactionPredicateData(txRequestClone);
@@ -4452,9 +4534,10 @@ var _Provider = class {
4452
4534
  transactionRequest: signedRequest
4453
4535
  });
4454
4536
  let receipts = [];
4537
+ let dryRunStatus;
4455
4538
  let missingContractIds = [];
4456
4539
  let outputVariables = 0;
4457
- let gasUsed = (0, import_math16.bn)(0);
4540
+ let gasUsed = (0, import_math17.bn)(0);
4458
4541
  txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
4459
4542
  txRequestClone.maxFee = maxFee;
4460
4543
  if (isScriptTransaction) {
@@ -4462,10 +4545,7 @@ var _Provider = class {
4462
4545
  if (signatureCallback) {
4463
4546
  await signatureCallback(txRequestClone);
4464
4547
  }
4465
- const result = await this.estimateTxDependencies(txRequestClone);
4466
- receipts = result.receipts;
4467
- outputVariables = result.outputVariables;
4468
- missingContractIds = result.missingContractIds;
4548
+ ({ receipts, missingContractIds, outputVariables, dryRunStatus } = await this.estimateTxDependencies(txRequestClone));
4469
4549
  gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
4470
4550
  txRequestClone.gasLimit = gasUsed;
4471
4551
  ({ maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
@@ -4485,7 +4565,8 @@ var _Provider = class {
4485
4565
  outputVariables,
4486
4566
  missingContractIds,
4487
4567
  addedSignatures,
4488
- estimatedPredicates: txRequestClone.inputs
4568
+ estimatedPredicates: txRequestClone.inputs,
4569
+ dryRunStatus
4489
4570
  };
4490
4571
  }
4491
4572
  async getResourcesForTransaction(owner, transactionRequestLike, quantitiesToContract = []) {
@@ -4521,10 +4602,10 @@ var _Provider = class {
4521
4602
  return coins.map((coin) => ({
4522
4603
  id: coin.utxoId,
4523
4604
  assetId: coin.assetId,
4524
- amount: (0, import_math16.bn)(coin.amount),
4605
+ amount: (0, import_math17.bn)(coin.amount),
4525
4606
  owner: import_address3.Address.fromAddressOrString(coin.owner),
4526
- blockCreated: (0, import_math16.bn)(coin.blockCreated),
4527
- txCreatedIdx: (0, import_math16.bn)(coin.txCreatedIdx)
4607
+ blockCreated: (0, import_math17.bn)(coin.blockCreated),
4608
+ txCreatedIdx: (0, import_math17.bn)(coin.txCreatedIdx)
4528
4609
  }));
4529
4610
  }
4530
4611
  /**
@@ -4561,9 +4642,9 @@ var _Provider = class {
4561
4642
  switch (coin.__typename) {
4562
4643
  case "MessageCoin":
4563
4644
  return {
4564
- amount: (0, import_math16.bn)(coin.amount),
4645
+ amount: (0, import_math17.bn)(coin.amount),
4565
4646
  assetId: coin.assetId,
4566
- daHeight: (0, import_math16.bn)(coin.daHeight),
4647
+ daHeight: (0, import_math17.bn)(coin.daHeight),
4567
4648
  sender: import_address3.Address.fromAddressOrString(coin.sender),
4568
4649
  recipient: import_address3.Address.fromAddressOrString(coin.recipient),
4569
4650
  nonce: coin.nonce
@@ -4571,11 +4652,11 @@ var _Provider = class {
4571
4652
  case "Coin":
4572
4653
  return {
4573
4654
  id: coin.utxoId,
4574
- amount: (0, import_math16.bn)(coin.amount),
4655
+ amount: (0, import_math17.bn)(coin.amount),
4575
4656
  assetId: coin.assetId,
4576
4657
  owner: import_address3.Address.fromAddressOrString(coin.owner),
4577
- blockCreated: (0, import_math16.bn)(coin.blockCreated),
4578
- txCreatedIdx: (0, import_math16.bn)(coin.txCreatedIdx)
4658
+ blockCreated: (0, import_math17.bn)(coin.blockCreated),
4659
+ txCreatedIdx: (0, import_math17.bn)(coin.txCreatedIdx)
4579
4660
  };
4580
4661
  default:
4581
4662
  return null;
@@ -4592,13 +4673,13 @@ var _Provider = class {
4592
4673
  async getBlock(idOrHeight) {
4593
4674
  let variables;
4594
4675
  if (typeof idOrHeight === "number") {
4595
- variables = { height: (0, import_math16.bn)(idOrHeight).toString(10) };
4676
+ variables = { height: (0, import_math17.bn)(idOrHeight).toString(10) };
4596
4677
  } else if (idOrHeight === "latest") {
4597
4678
  variables = { height: (await this.getBlockNumber()).toString(10) };
4598
4679
  } else if (idOrHeight.length === 66) {
4599
4680
  variables = { blockId: idOrHeight };
4600
4681
  } else {
4601
- variables = { blockId: (0, import_math16.bn)(idOrHeight).toString(10) };
4682
+ variables = { blockId: (0, import_math17.bn)(idOrHeight).toString(10) };
4602
4683
  }
4603
4684
  const { block } = await this.operations.getBlock(variables);
4604
4685
  if (!block) {
@@ -4606,7 +4687,7 @@ var _Provider = class {
4606
4687
  }
4607
4688
  return {
4608
4689
  id: block.id,
4609
- height: (0, import_math16.bn)(block.height),
4690
+ height: (0, import_math17.bn)(block.height),
4610
4691
  time: block.header.time,
4611
4692
  transactionIds: block.transactions.map((tx) => tx.id)
4612
4693
  };
@@ -4621,7 +4702,7 @@ var _Provider = class {
4621
4702
  const { blocks: fetchedData } = await this.operations.getBlocks(params);
4622
4703
  const blocks = fetchedData.edges.map(({ node: block }) => ({
4623
4704
  id: block.id,
4624
- height: (0, import_math16.bn)(block.height),
4705
+ height: (0, import_math17.bn)(block.height),
4625
4706
  time: block.header.time,
4626
4707
  transactionIds: block.transactions.map((tx) => tx.id)
4627
4708
  }));
@@ -4636,7 +4717,7 @@ var _Provider = class {
4636
4717
  async getBlockWithTransactions(idOrHeight) {
4637
4718
  let variables;
4638
4719
  if (typeof idOrHeight === "number") {
4639
- variables = { blockHeight: (0, import_math16.bn)(idOrHeight).toString(10) };
4720
+ variables = { blockHeight: (0, import_math17.bn)(idOrHeight).toString(10) };
4640
4721
  } else if (idOrHeight === "latest") {
4641
4722
  variables = { blockHeight: (await this.getBlockNumber()).toString() };
4642
4723
  } else {
@@ -4648,7 +4729,7 @@ var _Provider = class {
4648
4729
  }
4649
4730
  return {
4650
4731
  id: block.id,
4651
- height: (0, import_math16.bn)(block.height, 10),
4732
+ height: (0, import_math17.bn)(block.height, 10),
4652
4733
  time: block.header.time,
4653
4734
  transactionIds: block.transactions.map((tx) => tx.id),
4654
4735
  transactions: block.transactions.map(
@@ -4697,7 +4778,7 @@ var _Provider = class {
4697
4778
  contract: import_address3.Address.fromAddressOrString(contractId).toB256(),
4698
4779
  asset: (0, import_utils22.hexlify)(assetId)
4699
4780
  });
4700
- return (0, import_math16.bn)(contractBalance.amount, 10);
4781
+ return (0, import_math17.bn)(contractBalance.amount, 10);
4701
4782
  }
4702
4783
  /**
4703
4784
  * Returns the balance for the given owner for the given asset ID.
@@ -4711,7 +4792,7 @@ var _Provider = class {
4711
4792
  owner: import_address3.Address.fromAddressOrString(owner).toB256(),
4712
4793
  assetId: (0, import_utils22.hexlify)(assetId)
4713
4794
  });
4714
- return (0, import_math16.bn)(balance.amount, 10);
4795
+ return (0, import_math17.bn)(balance.amount, 10);
4715
4796
  }
4716
4797
  /**
4717
4798
  * Returns balances for the given owner.
@@ -4729,7 +4810,7 @@ var _Provider = class {
4729
4810
  const balances = result.balances.edges.map((edge) => edge.node);
4730
4811
  return balances.map((balance) => ({
4731
4812
  assetId: balance.assetId,
4732
- amount: (0, import_math16.bn)(balance.amount)
4813
+ amount: (0, import_math17.bn)(balance.amount)
4733
4814
  }));
4734
4815
  }
4735
4816
  /**
@@ -4751,15 +4832,15 @@ var _Provider = class {
4751
4832
  sender: message.sender,
4752
4833
  recipient: message.recipient,
4753
4834
  nonce: message.nonce,
4754
- amount: (0, import_math16.bn)(message.amount),
4835
+ amount: (0, import_math17.bn)(message.amount),
4755
4836
  data: message.data
4756
4837
  }),
4757
4838
  sender: import_address3.Address.fromAddressOrString(message.sender),
4758
4839
  recipient: import_address3.Address.fromAddressOrString(message.recipient),
4759
4840
  nonce: message.nonce,
4760
- amount: (0, import_math16.bn)(message.amount),
4841
+ amount: (0, import_math17.bn)(message.amount),
4761
4842
  data: import_transactions19.InputMessageCoder.decodeData(message.data),
4762
- daHeight: (0, import_math16.bn)(message.daHeight)
4843
+ daHeight: (0, import_math17.bn)(message.daHeight)
4763
4844
  }));
4764
4845
  }
4765
4846
  /**
@@ -4812,59 +4893,59 @@ var _Provider = class {
4812
4893
  } = result.messageProof;
4813
4894
  return {
4814
4895
  messageProof: {
4815
- proofIndex: (0, import_math16.bn)(messageProof.proofIndex),
4896
+ proofIndex: (0, import_math17.bn)(messageProof.proofIndex),
4816
4897
  proofSet: messageProof.proofSet
4817
4898
  },
4818
4899
  blockProof: {
4819
- proofIndex: (0, import_math16.bn)(blockProof.proofIndex),
4900
+ proofIndex: (0, import_math17.bn)(blockProof.proofIndex),
4820
4901
  proofSet: blockProof.proofSet
4821
4902
  },
4822
4903
  messageBlockHeader: {
4823
4904
  id: messageBlockHeader.id,
4824
- daHeight: (0, import_math16.bn)(messageBlockHeader.daHeight),
4825
- transactionsCount: (0, import_math16.bn)(messageBlockHeader.transactionsCount),
4905
+ daHeight: (0, import_math17.bn)(messageBlockHeader.daHeight),
4906
+ transactionsCount: Number(messageBlockHeader.transactionsCount),
4826
4907
  transactionsRoot: messageBlockHeader.transactionsRoot,
4827
- height: (0, import_math16.bn)(messageBlockHeader.height),
4908
+ height: (0, import_math17.bn)(messageBlockHeader.height),
4828
4909
  prevRoot: messageBlockHeader.prevRoot,
4829
4910
  time: messageBlockHeader.time,
4830
4911
  applicationHash: messageBlockHeader.applicationHash,
4831
- messageReceiptCount: (0, import_math16.bn)(messageBlockHeader.messageReceiptCount),
4912
+ messageReceiptCount: Number(messageBlockHeader.messageReceiptCount),
4832
4913
  messageOutboxRoot: messageBlockHeader.messageOutboxRoot,
4833
- consensusParametersVersion: messageBlockHeader.consensusParametersVersion,
4914
+ consensusParametersVersion: Number(messageBlockHeader.consensusParametersVersion),
4834
4915
  eventInboxRoot: messageBlockHeader.eventInboxRoot,
4835
- stateTransitionBytecodeVersion: messageBlockHeader.stateTransitionBytecodeVersion
4916
+ stateTransitionBytecodeVersion: Number(messageBlockHeader.stateTransitionBytecodeVersion)
4836
4917
  },
4837
4918
  commitBlockHeader: {
4838
4919
  id: commitBlockHeader.id,
4839
- daHeight: (0, import_math16.bn)(commitBlockHeader.daHeight),
4840
- transactionsCount: (0, import_math16.bn)(commitBlockHeader.transactionsCount),
4920
+ daHeight: (0, import_math17.bn)(commitBlockHeader.daHeight),
4921
+ transactionsCount: Number(commitBlockHeader.transactionsCount),
4841
4922
  transactionsRoot: commitBlockHeader.transactionsRoot,
4842
- height: (0, import_math16.bn)(commitBlockHeader.height),
4923
+ height: (0, import_math17.bn)(commitBlockHeader.height),
4843
4924
  prevRoot: commitBlockHeader.prevRoot,
4844
4925
  time: commitBlockHeader.time,
4845
4926
  applicationHash: commitBlockHeader.applicationHash,
4846
- messageReceiptCount: (0, import_math16.bn)(commitBlockHeader.messageReceiptCount),
4927
+ messageReceiptCount: Number(commitBlockHeader.messageReceiptCount),
4847
4928
  messageOutboxRoot: commitBlockHeader.messageOutboxRoot,
4848
- consensusParametersVersion: commitBlockHeader.consensusParametersVersion,
4929
+ consensusParametersVersion: Number(commitBlockHeader.consensusParametersVersion),
4849
4930
  eventInboxRoot: commitBlockHeader.eventInboxRoot,
4850
- stateTransitionBytecodeVersion: commitBlockHeader.stateTransitionBytecodeVersion
4931
+ stateTransitionBytecodeVersion: Number(commitBlockHeader.stateTransitionBytecodeVersion)
4851
4932
  },
4852
4933
  sender: import_address3.Address.fromAddressOrString(sender),
4853
4934
  recipient: import_address3.Address.fromAddressOrString(recipient),
4854
4935
  nonce,
4855
- amount: (0, import_math16.bn)(amount),
4936
+ amount: (0, import_math17.bn)(amount),
4856
4937
  data
4857
4938
  };
4858
4939
  }
4859
4940
  async getLatestGasPrice() {
4860
4941
  const { latestGasPrice } = await this.operations.getLatestGasPrice();
4861
- return (0, import_math16.bn)(latestGasPrice.gasPrice);
4942
+ return (0, import_math17.bn)(latestGasPrice.gasPrice);
4862
4943
  }
4863
4944
  async estimateGasPrice(blockHorizon) {
4864
4945
  const { estimateGasPrice } = await this.operations.estimateGasPrice({
4865
4946
  blockHorizon: String(blockHorizon)
4866
4947
  });
4867
- return (0, import_math16.bn)(estimateGasPrice.gasPrice);
4948
+ return (0, import_math17.bn)(estimateGasPrice.gasPrice);
4868
4949
  }
4869
4950
  /**
4870
4951
  * Returns Message Proof for given transaction id and the message id from MessageOut receipt.
@@ -4885,15 +4966,37 @@ var _Provider = class {
4885
4966
  */
4886
4967
  async produceBlocks(amount, startTime) {
4887
4968
  const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
4888
- blocksToProduce: (0, import_math16.bn)(amount).toString(10),
4969
+ blocksToProduce: (0, import_math17.bn)(amount).toString(10),
4889
4970
  startTimestamp: startTime ? import_utils22.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
4890
4971
  });
4891
- return (0, import_math16.bn)(latestBlockHeight);
4972
+ return (0, import_math17.bn)(latestBlockHeight);
4892
4973
  }
4893
4974
  // eslint-disable-next-line @typescript-eslint/require-await
4894
4975
  async getTransactionResponse(transactionId) {
4895
4976
  return new TransactionResponse(transactionId, this);
4896
4977
  }
4978
+ /**
4979
+ * Returns Message for given nonce.
4980
+ *
4981
+ * @param nonce - The nonce of the message to retrieve.
4982
+ * @returns A promise that resolves to the Message object.
4983
+ */
4984
+ async getMessageByNonce(nonce) {
4985
+ const { message } = await this.operations.getMessageByNonce({ nonce });
4986
+ if (!message) {
4987
+ return null;
4988
+ }
4989
+ return message;
4990
+ }
4991
+ async getRelayedTransactionStatus(relayedTransactionId) {
4992
+ const { relayedTransactionStatus } = await this.operations.getRelayedTransactionStatus({
4993
+ relayedTransactionId
4994
+ });
4995
+ if (!relayedTransactionStatus) {
4996
+ return null;
4997
+ }
4998
+ return relayedTransactionStatus;
4999
+ }
4897
5000
  };
4898
5001
  var Provider = _Provider;
4899
5002
  _cacheInputs = new WeakSet();
@@ -4912,7 +5015,7 @@ __publicField(Provider, "nodeInfoCache", {});
4912
5015
 
4913
5016
  // src/providers/transaction-summary/get-transaction-summary.ts
4914
5017
  var import_errors15 = require("@fuel-ts/errors");
4915
- var import_math17 = require("@fuel-ts/math");
5018
+ var import_math18 = require("@fuel-ts/math");
4916
5019
  var import_transactions20 = require("@fuel-ts/transactions");
4917
5020
  var import_utils25 = require("@fuel-ts/utils");
4918
5021
  async function getTransactionSummary(params) {
@@ -4936,7 +5039,11 @@ async function getTransactionSummary(params) {
4936
5039
  }
4937
5040
  const receipts = txReceipts.map(processGqlReceipt);
4938
5041
  const {
4939
- consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts, maxGasPerTx }
5042
+ consensusParameters: {
5043
+ feeParameters: { gasPerByte, gasPriceFactor },
5044
+ txParameters: { maxInputs, maxGasPerTx },
5045
+ gasCosts
5046
+ }
4940
5047
  } = provider.getChain();
4941
5048
  const gasPrice = await provider.getLatestGasPrice();
4942
5049
  const transactionInfo = assembleTransactionSummary({
@@ -4945,8 +5052,8 @@ async function getTransactionSummary(params) {
4945
5052
  transaction: decodedTransaction,
4946
5053
  transactionBytes: (0, import_utils25.arrayify)(gqlTransaction.rawPayload),
4947
5054
  gqlTransactionStatus: gqlTransaction.status,
4948
- gasPerByte: (0, import_math17.bn)(gasPerByte),
4949
- gasPriceFactor: (0, import_math17.bn)(gasPriceFactor),
5055
+ gasPerByte: (0, import_math18.bn)(gasPerByte),
5056
+ gasPriceFactor: (0, import_math18.bn)(gasPriceFactor),
4950
5057
  abiMap,
4951
5058
  maxInputs,
4952
5059
  gasCosts,
@@ -4962,7 +5069,7 @@ async function getTransactionSummaryFromRequest(params) {
4962
5069
  const { provider, transactionRequest, abiMap } = params;
4963
5070
  const { receipts } = await provider.call(transactionRequest);
4964
5071
  const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = provider.getGasConfig();
4965
- const maxInputs = provider.getChain().consensusParameters.maxInputs;
5072
+ const maxInputs = provider.getChain().consensusParameters.txParameters.maxInputs;
4966
5073
  const transaction = transactionRequest.toTransaction();
4967
5074
  const transactionBytes = transactionRequest.toTransactionBytes();
4968
5075
  const gasPrice = await provider.getLatestGasPrice();
@@ -4985,7 +5092,11 @@ async function getTransactionsSummaries(params) {
4985
5092
  const { transactionsByOwner } = await provider.operations.getTransactionsByOwner(filters);
4986
5093
  const { edges, pageInfo } = transactionsByOwner;
4987
5094
  const {
4988
- consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts, maxGasPerTx }
5095
+ consensusParameters: {
5096
+ feeParameters: { gasPerByte, gasPriceFactor },
5097
+ txParameters: { maxInputs, maxGasPerTx },
5098
+ gasCosts
5099
+ }
4989
5100
  } = provider.getChain();
4990
5101
  const gasPrice = await provider.getLatestGasPrice();
4991
5102
  const transactions = edges.map((edge) => {
@@ -5144,15 +5255,31 @@ var assets = [
5144
5255
  }
5145
5256
  ];
5146
5257
 
5258
+ // src/providers/transaction-request/helpers.ts
5259
+ var import_math19 = require("@fuel-ts/math");
5260
+ var import_transactions21 = require("@fuel-ts/transactions");
5261
+ var isRequestInputCoin = (input) => input.type === import_transactions21.InputType.Coin;
5262
+ var isRequestInputMessage = (input) => input.type === import_transactions21.InputType.Message;
5263
+ var isRequestInputResource = (input) => isRequestInputCoin(input) || isRequestInputMessage(input);
5264
+ var getAssetAmountInRequestInputs = (inputs, assetId, baseAsset) => inputs.filter(isRequestInputResource).reduce((acc, input) => {
5265
+ if (isRequestInputCoin(input) && input.assetId === assetId) {
5266
+ return acc.add(input.amount);
5267
+ }
5268
+ if (isRequestInputMessage(input) && assetId === baseAsset) {
5269
+ return acc.add(input.amount);
5270
+ }
5271
+ return acc;
5272
+ }, (0, import_math19.bn)(0));
5273
+
5147
5274
  // src/utils/formatTransferToContractScriptData.ts
5148
5275
  var import_abi_coder6 = require("@fuel-ts/abi-coder");
5149
- var import_math18 = require("@fuel-ts/math");
5276
+ var import_math20 = require("@fuel-ts/math");
5150
5277
  var import_utils26 = require("@fuel-ts/utils");
5151
5278
  var asm = __toESM(require("@fuels/vm-asm"));
5152
5279
  var formatTransferToContractScriptData = (params) => {
5153
5280
  const { assetId, amountToTransfer, hexlifiedContractId } = params;
5154
5281
  const numberCoder = new import_abi_coder6.BigNumberCoder("u64");
5155
- const encoded = numberCoder.encode(new import_math18.BN(amountToTransfer).toNumber());
5282
+ const encoded = numberCoder.encode(new import_math20.BN(amountToTransfer).toNumber());
5156
5283
  const scriptData = Uint8Array.from([
5157
5284
  ...(0, import_utils26.arrayify)(hexlifiedContractId),
5158
5285
  ...encoded,
@@ -5181,6 +5308,7 @@ var assembleTransferToContractScript = async (params) => {
5181
5308
  };
5182
5309
 
5183
5310
  // src/account.ts
5311
+ var MAX_FUNDING_ATTEMPTS = 2;
5184
5312
  var Account = class extends import_interfaces.AbstractAccount {
5185
5313
  /**
5186
5314
  * The address associated with the account.
@@ -5338,16 +5466,17 @@ var Account = class extends import_interfaces.AbstractAccount {
5338
5466
  * Adds resources to the transaction enough to fund it.
5339
5467
  *
5340
5468
  * @param request - The transaction request.
5341
- * @param coinQuantities - The coin quantities required to execute the transaction.
5469
+ * @param requiredQuantities - The coin quantities required to execute the transaction.
5342
5470
  * @param fee - The estimated transaction fee.
5343
5471
  * @returns A promise that resolves when the resources are added to the transaction.
5344
5472
  */
5345
5473
  async fund(request, params) {
5346
5474
  const { addedSignatures, estimatedPredicates, maxFee: fee, requiredQuantities } = params;
5347
5475
  const baseAssetId = this.provider.getBaseAssetId();
5476
+ const requiredInBaseAsset = requiredQuantities.find((quantity) => quantity.assetId === baseAssetId)?.amount || (0, import_math21.bn)(0);
5348
5477
  const txRequest = request;
5349
5478
  const requiredQuantitiesWithFee = addAmountToCoinQuantities({
5350
- amount: (0, import_math19.bn)(fee),
5479
+ amount: (0, import_math21.bn)(fee),
5351
5480
  assetId: baseAssetId,
5352
5481
  coinQuantities: requiredQuantities
5353
5482
  });
@@ -5355,21 +5484,17 @@ var Account = class extends import_interfaces.AbstractAccount {
5355
5484
  requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
5356
5485
  quantitiesDict[assetId] = {
5357
5486
  required: amount,
5358
- owned: (0, import_math19.bn)(0)
5487
+ owned: (0, import_math21.bn)(0)
5359
5488
  };
5360
5489
  });
5361
- txRequest.inputs.forEach((input) => {
5362
- const isResource = "amount" in input;
5363
- if (!isResource) {
5364
- return;
5365
- }
5366
- const isCoin2 = "owner" in input;
5490
+ request.inputs.filter(isRequestInputResource).forEach((input) => {
5491
+ const isCoin2 = isRequestInputCoin(input);
5367
5492
  const assetId = isCoin2 ? String(input.assetId) : baseAssetId;
5368
5493
  if (quantitiesDict[assetId]) {
5369
5494
  quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(input.amount);
5370
5495
  }
5371
5496
  });
5372
- const missingQuantities = [];
5497
+ let missingQuantities = [];
5373
5498
  Object.entries(quantitiesDict).forEach(([assetId, { owned, required }]) => {
5374
5499
  if (owned.lt(required)) {
5375
5500
  missingQuantities.push({
@@ -5378,11 +5503,42 @@ var Account = class extends import_interfaces.AbstractAccount {
5378
5503
  });
5379
5504
  }
5380
5505
  });
5381
- const needsToBeFunded = missingQuantities.length;
5382
- if (needsToBeFunded) {
5383
- const excludedIds = cacheTxInputsFromOwner(txRequest.inputs, this.address.toB256());
5384
- const resources = await this.getResourcesToSpend(missingQuantities, excludedIds);
5385
- txRequest.addResources(resources);
5506
+ let needsToBeFunded = missingQuantities.length > 0;
5507
+ let fundingAttempts = 0;
5508
+ while (needsToBeFunded && fundingAttempts < MAX_FUNDING_ATTEMPTS) {
5509
+ const resources = await this.getResourcesToSpend(
5510
+ missingQuantities,
5511
+ cacheTxInputsFromOwner(request.inputs, this.address)
5512
+ );
5513
+ request.addResources(resources);
5514
+ txRequest.shiftPredicateData();
5515
+ txRequest.updatePredicateGasUsed(estimatedPredicates);
5516
+ const requestToReestimate2 = (0, import_ramda4.clone)(txRequest);
5517
+ if (addedSignatures) {
5518
+ Array.from({ length: addedSignatures }).forEach(
5519
+ () => requestToReestimate2.addEmptyWitness()
5520
+ );
5521
+ }
5522
+ const { maxFee: newFee } = await this.provider.estimateTxGasAndFee({
5523
+ transactionRequest: requestToReestimate2
5524
+ });
5525
+ const totalBaseAssetOnInputs = getAssetAmountInRequestInputs(
5526
+ request.inputs,
5527
+ baseAssetId,
5528
+ baseAssetId
5529
+ );
5530
+ const totalBaseAssetRequiredWithFee = requiredInBaseAsset.add(newFee);
5531
+ if (totalBaseAssetOnInputs.gt(totalBaseAssetRequiredWithFee)) {
5532
+ needsToBeFunded = false;
5533
+ } else {
5534
+ missingQuantities = [
5535
+ {
5536
+ amount: totalBaseAssetRequiredWithFee.sub(totalBaseAssetOnInputs),
5537
+ assetId: baseAssetId
5538
+ }
5539
+ ];
5540
+ }
5541
+ fundingAttempts += 1;
5386
5542
  }
5387
5543
  txRequest.shiftPredicateData();
5388
5544
  txRequest.updatePredicateGasUsed(estimatedPredicates);
@@ -5433,7 +5589,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5433
5589
  * @returns A promise that resolves to the transaction response.
5434
5590
  */
5435
5591
  async transfer(destination, amount, assetId, txParams = {}) {
5436
- if ((0, import_math19.bn)(amount).lte(0)) {
5592
+ if ((0, import_math21.bn)(amount).lte(0)) {
5437
5593
  throw new import_errors16.FuelError(
5438
5594
  import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
5439
5595
  "Transfer amount must be a positive number."
@@ -5453,7 +5609,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5453
5609
  * @returns A promise that resolves to the transaction response.
5454
5610
  */
5455
5611
  async transferToContract(contractId, amount, assetId, txParams = {}) {
5456
- if ((0, import_math19.bn)(amount).lte(0)) {
5612
+ if ((0, import_math21.bn)(amount).lte(0)) {
5457
5613
  throw new import_errors16.FuelError(
5458
5614
  import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
5459
5615
  "Transfer amount must be a positive number."
@@ -5463,7 +5619,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5463
5619
  const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
5464
5620
  const { script, scriptData } = await assembleTransferToContractScript({
5465
5621
  hexlifiedContractId: contractAddress.toB256(),
5466
- amountToTransfer: (0, import_math19.bn)(amount),
5622
+ amountToTransfer: (0, import_math21.bn)(amount),
5467
5623
  assetId: assetIdToTransfer
5468
5624
  });
5469
5625
  const request = new ScriptTransactionRequest({
@@ -5474,7 +5630,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5474
5630
  request.addContractInputAndOutput(contractAddress);
5475
5631
  const txCost = await this.provider.getTransactionCost(request, {
5476
5632
  resourcesOwner: this,
5477
- quantitiesToContract: [{ amount: (0, import_math19.bn)(amount), assetId: String(assetIdToTransfer) }]
5633
+ quantitiesToContract: [{ amount: (0, import_math21.bn)(amount), assetId: String(assetIdToTransfer) }]
5478
5634
  });
5479
5635
  this.validateGasLimitAndMaxFee({
5480
5636
  gasUsed: txCost.gasUsed,
@@ -5500,7 +5656,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5500
5656
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
5501
5657
  );
5502
5658
  const amountDataArray = (0, import_utils27.arrayify)(
5503
- "0x".concat((0, import_math19.bn)(amount).toHex().substring(2).padStart(16, "0"))
5659
+ "0x".concat((0, import_math21.bn)(amount).toHex().substring(2).padStart(16, "0"))
5504
5660
  );
5505
5661
  const script = new Uint8Array([
5506
5662
  ...(0, import_utils27.arrayify)(withdrawScript.bytes),
@@ -5510,7 +5666,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5510
5666
  const params = { script, ...txParams };
5511
5667
  const baseAssetId = this.provider.getBaseAssetId();
5512
5668
  const request = new ScriptTransactionRequest(params);
5513
- const quantitiesToContract = [{ amount: (0, import_math19.bn)(amount), assetId: baseAssetId }];
5669
+ const quantitiesToContract = [{ amount: (0, import_math21.bn)(amount), assetId: baseAssetId }];
5514
5670
  const txCost = await this.provider.getTransactionCost(request, { quantitiesToContract });
5515
5671
  this.validateGasLimitAndMaxFee({
5516
5672
  gasUsed: txCost.gasUsed,
@@ -5605,7 +5761,7 @@ var import_utils30 = require("@fuel-ts/utils");
5605
5761
  var import_address5 = require("@fuel-ts/address");
5606
5762
  var import_crypto2 = require("@fuel-ts/crypto");
5607
5763
  var import_hasher2 = require("@fuel-ts/hasher");
5608
- var import_math20 = require("@fuel-ts/math");
5764
+ var import_math22 = require("@fuel-ts/math");
5609
5765
  var import_utils28 = require("@fuel-ts/utils");
5610
5766
  var import_secp256k1 = require("@noble/curves/secp256k1");
5611
5767
  var Signer = class {
@@ -5625,7 +5781,7 @@ var Signer = class {
5625
5781
  privateKey = `0x${privateKey}`;
5626
5782
  }
5627
5783
  }
5628
- const privateKeyBytes = (0, import_math20.toBytes)(privateKey, 32);
5784
+ const privateKeyBytes = (0, import_math22.toBytes)(privateKey, 32);
5629
5785
  this.privateKey = (0, import_utils28.hexlify)(privateKeyBytes);
5630
5786
  this.publicKey = (0, import_utils28.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
5631
5787
  this.compressedPublicKey = (0, import_utils28.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
@@ -5643,8 +5799,8 @@ var Signer = class {
5643
5799
  */
5644
5800
  sign(data) {
5645
5801
  const signature = import_secp256k1.secp256k1.sign((0, import_utils28.arrayify)(data), (0, import_utils28.arrayify)(this.privateKey));
5646
- const r = (0, import_math20.toBytes)(`0x${signature.r.toString(16)}`, 32);
5647
- const s = (0, import_math20.toBytes)(`0x${signature.s.toString(16)}`, 32);
5802
+ const r = (0, import_math22.toBytes)(`0x${signature.r.toString(16)}`, 32);
5803
+ const s = (0, import_math22.toBytes)(`0x${signature.s.toString(16)}`, 32);
5648
5804
  s[0] |= (signature.recovery || 0) << 7;
5649
5805
  return (0, import_utils28.hexlify)((0, import_utils28.concat)([r, s]));
5650
5806
  }
@@ -5916,16 +6072,16 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
5916
6072
  // src/hdwallet/hdwallet.ts
5917
6073
  var import_errors20 = require("@fuel-ts/errors");
5918
6074
  var import_hasher6 = require("@fuel-ts/hasher");
5919
- var import_math21 = require("@fuel-ts/math");
6075
+ var import_math23 = require("@fuel-ts/math");
5920
6076
  var import_utils34 = require("@fuel-ts/utils");
5921
- var import_ethers3 = require("ethers");
6077
+ var import_ethers2 = require("ethers");
5922
6078
 
5923
6079
  // src/mnemonic/mnemonic.ts
5924
6080
  var import_crypto4 = require("@fuel-ts/crypto");
5925
6081
  var import_errors19 = require("@fuel-ts/errors");
5926
6082
  var import_hasher5 = require("@fuel-ts/hasher");
5927
6083
  var import_utils32 = require("@fuel-ts/utils");
5928
- var import_ethers2 = require("ethers");
6084
+ var import_ethers = require("ethers");
5929
6085
 
5930
6086
  // src/wordlists/words/english.ts
5931
6087
  var english = [
@@ -8179,7 +8335,7 @@ var Mnemonic = class {
8179
8335
  assertMnemonic(getWords(phrase));
8180
8336
  const phraseBytes = toUtf8Bytes(getPhrase(phrase));
8181
8337
  const salt = toUtf8Bytes(`mnemonic${passphrase}`);
8182
- return (0, import_ethers2.pbkdf2)(phraseBytes, salt, 2048, 64, "sha512");
8338
+ return (0, import_ethers.pbkdf2)(phraseBytes, salt, 2048, 64, "sha512");
8183
8339
  }
8184
8340
  /**
8185
8341
  * @param phrase - Mnemonic phrase composed by words from the provided wordlist
@@ -8241,7 +8397,7 @@ var Mnemonic = class {
8241
8397
  `Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
8242
8398
  );
8243
8399
  }
8244
- return (0, import_utils32.arrayify)((0, import_ethers2.computeHmac)("sha512", MasterSecret, seedArray));
8400
+ return (0, import_utils32.arrayify)((0, import_ethers.computeHmac)("sha512", MasterSecret, seedArray));
8245
8401
  }
8246
8402
  /**
8247
8403
  * Get the extendKey as defined on BIP-32 from the provided seed
@@ -8266,8 +8422,8 @@ var Mnemonic = class {
8266
8422
  chainCode,
8267
8423
  (0, import_utils32.concat)(["0x00", privateKey])
8268
8424
  ]);
8269
- const checksum = (0, import_ethers2.dataSlice)((0, import_hasher5.sha256)((0, import_hasher5.sha256)(extendedKey)), 0, 4);
8270
- return (0, import_ethers2.encodeBase58)((0, import_utils32.concat)([extendedKey, checksum]));
8425
+ const checksum = (0, import_ethers.dataSlice)((0, import_hasher5.sha256)((0, import_hasher5.sha256)(extendedKey)), 0, 4);
8426
+ return (0, import_ethers.encodeBase58)((0, import_utils32.concat)([extendedKey, checksum]));
8271
8427
  }
8272
8428
  /**
8273
8429
  * Create a new mnemonic using a randomly generated number as entropy.
@@ -8295,7 +8451,7 @@ var MainnetPUB = (0, import_utils34.hexlify)("0x0488b21e");
8295
8451
  var TestnetPRV2 = (0, import_utils34.hexlify)("0x04358394");
8296
8452
  var TestnetPUB = (0, import_utils34.hexlify)("0x043587cf");
8297
8453
  function base58check(data) {
8298
- 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)]));
8454
+ 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)]));
8299
8455
  }
8300
8456
  function getExtendedKeyPrefix(isPublic = false, testnet = false) {
8301
8457
  if (isPublic) {
@@ -8351,7 +8507,7 @@ var HDWallet = class {
8351
8507
  this.publicKey = (0, import_utils34.hexlify)(config.publicKey);
8352
8508
  }
8353
8509
  this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
8354
- this.fingerprint = (0, import_ethers3.dataSlice)((0, import_ethers3.ripemd160)((0, import_hasher6.sha256)(this.publicKey)), 0, 4);
8510
+ this.fingerprint = (0, import_ethers2.dataSlice)((0, import_ethers2.ripemd160)((0, import_hasher6.sha256)(this.publicKey)), 0, 4);
8355
8511
  this.depth = config.depth || this.depth;
8356
8512
  this.index = config.index || this.index;
8357
8513
  this.chainCode = config.chainCode;
@@ -8382,13 +8538,13 @@ var HDWallet = class {
8382
8538
  } else {
8383
8539
  data.set((0, import_utils34.arrayify)(this.publicKey));
8384
8540
  }
8385
- data.set((0, import_math21.toBytes)(index, 4), 33);
8386
- const bytes = (0, import_utils34.arrayify)((0, import_ethers3.computeHmac)("sha512", chainCode, data));
8541
+ data.set((0, import_math23.toBytes)(index, 4), 33);
8542
+ const bytes = (0, import_utils34.arrayify)((0, import_ethers2.computeHmac)("sha512", chainCode, data));
8387
8543
  const IL = bytes.slice(0, 32);
8388
8544
  const IR = bytes.slice(32);
8389
8545
  if (privateKey) {
8390
8546
  const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
8391
- const ki = (0, import_math21.bn)(IL).add(privateKey).mod(N).toBytes(32);
8547
+ const ki = (0, import_math23.bn)(IL).add(privateKey).mod(N).toBytes(32);
8392
8548
  return new HDWallet({
8393
8549
  privateKey: ki,
8394
8550
  chainCode: IR,
@@ -8434,7 +8590,7 @@ var HDWallet = class {
8434
8590
  const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
8435
8591
  const depth = (0, import_utils34.hexlify)(Uint8Array.from([this.depth]));
8436
8592
  const parentFingerprint = this.parentFingerprint;
8437
- const index = (0, import_math21.toHex)(this.index, 4);
8593
+ const index = (0, import_math23.toHex)(this.index, 4);
8438
8594
  const chainCode = this.chainCode;
8439
8595
  const key = this.privateKey != null && !isPublic ? (0, import_utils34.concat)(["0x00", this.privateKey]) : this.publicKey;
8440
8596
  const extendedKey = (0, import_utils34.arrayify)((0, import_utils34.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
@@ -8454,7 +8610,7 @@ var HDWallet = class {
8454
8610
  });
8455
8611
  }
8456
8612
  static fromExtendedKey(extendedKey) {
8457
- const decoded = (0, import_ethers3.toBeHex)((0, import_ethers3.decodeBase58)(extendedKey));
8613
+ const decoded = (0, import_ethers2.toBeHex)((0, import_ethers2.decodeBase58)(extendedKey));
8458
8614
  const bytes = (0, import_utils34.arrayify)(decoded);
8459
8615
  const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
8460
8616
  if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
@@ -9070,7 +9226,7 @@ var StorageAbstract = class {
9070
9226
  var import_abi_coder7 = require("@fuel-ts/abi-coder");
9071
9227
  var import_address10 = require("@fuel-ts/address");
9072
9228
  var import_errors25 = require("@fuel-ts/errors");
9073
- var import_transactions21 = require("@fuel-ts/transactions");
9229
+ var import_transactions22 = require("@fuel-ts/transactions");
9074
9230
  var import_utils36 = require("@fuel-ts/utils");
9075
9231
 
9076
9232
  // src/predicate/utils/getPredicateRoot.ts
@@ -9130,7 +9286,7 @@ var Predicate = class extends Account {
9130
9286
  const request = transactionRequestify(transactionRequestLike);
9131
9287
  const { policies } = BaseTransactionRequest.getPolicyMeta(request);
9132
9288
  request.inputs?.forEach((input) => {
9133
- if (input.type === import_transactions21.InputType.Coin && (0, import_utils36.hexlify)(input.owner) === this.address.toB256()) {
9289
+ if (input.type === import_transactions22.InputType.Coin && (0, import_utils36.hexlify)(input.owner) === this.address.toB256()) {
9134
9290
  input.predicate = (0, import_utils36.hexlify)(this.bytes);
9135
9291
  input.predicateData = (0, import_utils36.hexlify)(this.getPredicateData(policies.length));
9136
9292
  }
@@ -9162,9 +9318,9 @@ var Predicate = class extends Account {
9162
9318
  return new Uint8Array();
9163
9319
  }
9164
9320
  const mainFn = this.interface?.functions.main;
9165
- const paddedCode = new import_transactions21.ByteArrayCoder(this.bytes.length).encode(this.bytes);
9321
+ const paddedCode = new import_transactions22.ByteArrayCoder(this.bytes.length).encode(this.bytes);
9166
9322
  const VM_TX_MEMORY = (0, import_abi_coder7.calculateVmTxMemory)({
9167
- maxInputs: this.provider.getChain().consensusParameters.maxInputs.toNumber()
9323
+ maxInputs: this.provider.getChain().consensusParameters.txParameters.maxInputs.toNumber()
9168
9324
  });
9169
9325
  const OFFSET = VM_TX_MEMORY + import_abi_coder7.SCRIPT_FIXED_SIZE + import_abi_coder7.INPUT_COIN_FIXED_SIZE + import_abi_coder7.WORD_SIZE + paddedCode.byteLength + policiesLength * import_abi_coder7.WORD_SIZE;
9170
9326
  return mainFn?.encodeArguments(this.predicateData, OFFSET) || new Uint8Array();
@@ -9982,7 +10138,7 @@ __publicField(Fuel, "defaultConfig", {});
9982
10138
  calculateGasFee,
9983
10139
  calculateMetadataGasForTxCreate,
9984
10140
  calculateMetadataGasForTxScript,
9985
- calculateTransactionFee,
10141
+ calculateTXFeeForSummary,
9986
10142
  coinQuantityfy,
9987
10143
  deferPromise,
9988
10144
  dispatchFuelConnectorEvent,
@@ -10042,6 +10198,8 @@ __publicField(Fuel, "defaultConfig", {});
10042
10198
  isTypeCreate,
10043
10199
  isTypeMint,
10044
10200
  isTypeScript,
10201
+ isTypeUpgrade,
10202
+ isTypeUpload,
10045
10203
  normalizeJSON,
10046
10204
  outputify,
10047
10205
  processGqlReceipt,