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

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

Potentially problematic release.


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

Files changed (54) hide show
  1. package/README.md +15 -12
  2. package/dist/account.d.ts +1 -1
  3. package/dist/account.d.ts.map +1 -1
  4. package/dist/index.global.js +1624 -1618
  5. package/dist/index.global.js.map +1 -1
  6. package/dist/index.js +366 -207
  7. package/dist/index.js.map +1 -1
  8. package/dist/index.mjs +347 -190
  9. package/dist/index.mjs.map +1 -1
  10. package/dist/providers/__generated__/operations.d.ts +203 -80
  11. package/dist/providers/__generated__/operations.d.ts.map +1 -1
  12. package/dist/providers/message.d.ts +2 -2
  13. package/dist/providers/message.d.ts.map +1 -1
  14. package/dist/providers/provider.d.ts +30 -29
  15. package/dist/providers/provider.d.ts.map +1 -1
  16. package/dist/providers/resource.d.ts +0 -1
  17. package/dist/providers/resource.d.ts.map +1 -1
  18. package/dist/providers/transaction-request/helpers.d.ts +8 -0
  19. package/dist/providers/transaction-request/helpers.d.ts.map +1 -0
  20. package/dist/providers/transaction-request/script-transaction-request.d.ts +2 -3
  21. package/dist/providers/transaction-request/script-transaction-request.d.ts.map +1 -1
  22. package/dist/providers/transaction-request/transaction-request.d.ts +5 -6
  23. package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
  24. package/dist/providers/transaction-request/utils.d.ts +2 -1
  25. package/dist/providers/transaction-request/utils.d.ts.map +1 -1
  26. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts +2 -2
  27. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts.map +1 -1
  28. package/dist/providers/transaction-summary/calculate-tx-fee-for-summary.d.ts +20 -0
  29. package/dist/providers/transaction-summary/calculate-tx-fee-for-summary.d.ts.map +1 -0
  30. package/dist/providers/transaction-summary/get-transaction-summary.d.ts.map +1 -1
  31. package/dist/providers/transaction-summary/index.d.ts +1 -1
  32. package/dist/providers/transaction-summary/index.d.ts.map +1 -1
  33. package/dist/providers/transaction-summary/operations.d.ts +4 -0
  34. package/dist/providers/transaction-summary/operations.d.ts.map +1 -1
  35. package/dist/providers/transaction-summary/status.d.ts +5 -1
  36. package/dist/providers/transaction-summary/status.d.ts.map +1 -1
  37. package/dist/providers/transaction-summary/types.d.ts +6 -1
  38. package/dist/providers/transaction-summary/types.d.ts.map +1 -1
  39. package/dist/providers/utils/gas.d.ts +7 -6
  40. package/dist/providers/utils/gas.d.ts.map +1 -1
  41. package/dist/test-utils/launchNode.d.ts.map +1 -1
  42. package/dist/test-utils/resources.d.ts +4 -0
  43. package/dist/test-utils/resources.d.ts.map +1 -0
  44. package/dist/test-utils/transactionRequest.d.ts +5 -0
  45. package/dist/test-utils/transactionRequest.d.ts.map +1 -0
  46. package/dist/test-utils.global.js +1628 -1621
  47. package/dist/test-utils.global.js.map +1 -1
  48. package/dist/test-utils.js +343 -196
  49. package/dist/test-utils.js.map +1 -1
  50. package/dist/test-utils.mjs +328 -181
  51. package/dist/test-utils.mjs.map +1 -1
  52. package/package.json +17 -17
  53. package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts +0 -22
  54. package/dist/providers/transaction-summary/calculate-transaction-fee.d.ts.map +0 -1
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,11 @@ 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
+ // TODO: Validade if it will be simpler to pass only required props
2770
+ feeParameters: { gasPerByte },
2771
+ txParameters: { maxGasPerTx }
2772
+ } = consensusParameters;
2729
2773
  const witnessesLength = this.toTransaction().witnesses.reduce(
2730
2774
  (acc, wit) => acc + wit.dataLength,
2731
2775
  0
@@ -2813,10 +2857,10 @@ var transactionRequestify = (obj) => {
2813
2857
  };
2814
2858
  var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
2815
2859
  (acc, input) => {
2816
- if (input.type === import_transactions10.InputType.Coin && input.owner === owner) {
2860
+ if (input.type === import_transactions10.InputType.Coin && input.owner === owner.toB256()) {
2817
2861
  acc.utxos.push(input.id);
2818
2862
  }
2819
- if (input.type === import_transactions10.InputType.Message && input.recipient === owner) {
2863
+ if (input.type === import_transactions10.InputType.Message && input.recipient === owner.toB256()) {
2820
2864
  acc.messages.push(input.nonce);
2821
2865
  }
2822
2866
  return acc;
@@ -2829,40 +2873,40 @@ var cacheTxInputsFromOwner = (inputs, owner) => inputs.reduce(
2829
2873
 
2830
2874
  // src/providers/transaction-response/transaction-response.ts
2831
2875
  var import_errors13 = require("@fuel-ts/errors");
2832
- var import_math15 = require("@fuel-ts/math");
2876
+ var import_math16 = require("@fuel-ts/math");
2833
2877
  var import_transactions18 = require("@fuel-ts/transactions");
2834
2878
  var import_utils20 = require("@fuel-ts/utils");
2835
2879
 
2836
2880
  // src/providers/transaction-summary/assemble-transaction-summary.ts
2837
- var import_math14 = require("@fuel-ts/math");
2881
+ var import_math15 = require("@fuel-ts/math");
2838
2882
  var import_transactions16 = require("@fuel-ts/transactions");
2839
2883
  var import_utils18 = require("@fuel-ts/utils");
2840
2884
 
2841
- // src/providers/transaction-summary/calculate-transaction-fee.ts
2885
+ // src/providers/transaction-summary/calculate-tx-fee-for-summary.ts
2842
2886
  var import_math11 = require("@fuel-ts/math");
2843
2887
  var import_transactions11 = require("@fuel-ts/transactions");
2844
2888
  var import_utils16 = require("@fuel-ts/utils");
2845
- var calculateTransactionFee = (params) => {
2889
+ var calculateTXFeeForSummary = (params) => {
2846
2890
  const {
2847
2891
  gasPrice,
2848
2892
  rawPayload,
2849
2893
  tip,
2894
+ totalFee,
2850
2895
  consensusParameters: { gasCosts, feeParams, maxGasPerTx }
2851
2896
  } = params;
2897
+ if (totalFee) {
2898
+ return totalFee;
2899
+ }
2852
2900
  const gasPerByte = (0, import_math11.bn)(feeParams.gasPerByte);
2853
2901
  const gasPriceFactor = (0, import_math11.bn)(feeParams.gasPriceFactor);
2854
2902
  const transactionBytes = (0, import_utils16.arrayify)(rawPayload);
2855
2903
  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
2904
  const { type, witnesses, inputs, policies } = transaction;
2864
2905
  let metadataGas = (0, import_math11.bn)(0);
2865
2906
  let gasLimit = (0, import_math11.bn)(0);
2907
+ if (type !== import_transactions11.TransactionType.Create && type !== import_transactions11.TransactionType.Script) {
2908
+ return (0, import_math11.bn)(0);
2909
+ }
2866
2910
  if (type === import_transactions11.TransactionType.Create) {
2867
2911
  const { bytecodeWitnessIndex, storageSlots } = transaction;
2868
2912
  const contractBytesSize = (0, import_math11.bn)((0, import_utils16.arrayify)(witnesses[bytecodeWitnessIndex].data).length);
@@ -2899,23 +2943,13 @@ var calculateTransactionFee = (params) => {
2899
2943
  witnessLimit,
2900
2944
  maxGasPerTx
2901
2945
  });
2902
- const minFee = calculateGasFee({
2903
- gasPrice,
2904
- gas: minGas,
2905
- priceFactor: gasPriceFactor,
2906
- tip
2907
- });
2908
2946
  const maxFee = calculateGasFee({
2909
2947
  gasPrice,
2910
2948
  gas: maxGas,
2911
2949
  priceFactor: gasPriceFactor,
2912
2950
  tip
2913
2951
  });
2914
- return {
2915
- minFee,
2916
- maxFee,
2917
- fee: maxFee
2918
- };
2952
+ return maxFee;
2919
2953
  };
2920
2954
 
2921
2955
  // src/providers/transaction-summary/operations.ts
@@ -3050,6 +3084,8 @@ var TransactionTypeName = /* @__PURE__ */ ((TransactionTypeName2) => {
3050
3084
  TransactionTypeName2["Create"] = "Create";
3051
3085
  TransactionTypeName2["Mint"] = "Mint";
3052
3086
  TransactionTypeName2["Script"] = "Script";
3087
+ TransactionTypeName2["Upgrade"] = "Upgrade";
3088
+ TransactionTypeName2["Upload"] = "Upload";
3053
3089
  return TransactionTypeName2;
3054
3090
  })(TransactionTypeName || {});
3055
3091
  var TransactionStatus = /* @__PURE__ */ ((TransactionStatus2) => {
@@ -3115,6 +3151,12 @@ function isTypeCreate(transactionType) {
3115
3151
  function isTypeScript(transactionType) {
3116
3152
  return isType(transactionType, "Script" /* Script */);
3117
3153
  }
3154
+ function isTypeUpgrade(transactionType) {
3155
+ return isType(transactionType, "Upgrade" /* Upgrade */);
3156
+ }
3157
+ function isTypeUpload(transactionType) {
3158
+ return isType(transactionType, "Upload" /* Upload */);
3159
+ }
3118
3160
  function hasSameAssetId(a) {
3119
3161
  return (b) => a.assetId === b.assetId;
3120
3162
  }
@@ -3461,6 +3503,7 @@ var extractBurnedAssetsFromReceipts = (receipts) => {
3461
3503
 
3462
3504
  // src/providers/transaction-summary/status.ts
3463
3505
  var import_errors12 = require("@fuel-ts/errors");
3506
+ var import_math14 = require("@fuel-ts/math");
3464
3507
  var getTransactionStatusName = (gqlStatus) => {
3465
3508
  switch (gqlStatus) {
3466
3509
  case "FailureStatus":
@@ -3482,6 +3525,8 @@ var processGraphqlStatus = (gqlTransactionStatus) => {
3482
3525
  let time;
3483
3526
  let blockId;
3484
3527
  let status;
3528
+ let totalFee;
3529
+ let totalGas;
3485
3530
  let isStatusFailure = false;
3486
3531
  let isStatusSuccess = false;
3487
3532
  let isStatusPending = false;
@@ -3492,11 +3537,15 @@ var processGraphqlStatus = (gqlTransactionStatus) => {
3492
3537
  time = gqlTransactionStatus.time;
3493
3538
  blockId = gqlTransactionStatus.block.id;
3494
3539
  isStatusSuccess = true;
3540
+ totalFee = (0, import_math14.bn)(gqlTransactionStatus.totalFee);
3541
+ totalGas = (0, import_math14.bn)(gqlTransactionStatus.totalGas);
3495
3542
  break;
3496
3543
  case "FailureStatus":
3497
3544
  time = gqlTransactionStatus.time;
3498
3545
  blockId = gqlTransactionStatus.block.id;
3499
3546
  isStatusFailure = true;
3547
+ totalFee = (0, import_math14.bn)(gqlTransactionStatus.totalFee);
3548
+ totalGas = (0, import_math14.bn)(gqlTransactionStatus.totalGas);
3500
3549
  break;
3501
3550
  case "SubmittedStatus":
3502
3551
  time = gqlTransactionStatus.time;
@@ -3509,6 +3558,8 @@ var processGraphqlStatus = (gqlTransactionStatus) => {
3509
3558
  time,
3510
3559
  blockId,
3511
3560
  status,
3561
+ totalFee,
3562
+ totalGas,
3512
3563
  isStatusFailure,
3513
3564
  isStatusSuccess,
3514
3565
  isStatusPending
@@ -3544,8 +3595,10 @@ function assembleTransactionSummary(params) {
3544
3595
  maxInputs
3545
3596
  });
3546
3597
  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({
3598
+ const tip = (0, import_math15.bn)(transaction.policies?.find((policy) => policy.type === import_transactions16.PolicyType.Tip)?.data);
3599
+ const { isStatusFailure, isStatusPending, isStatusSuccess, blockId, status, time, totalFee } = processGraphqlStatus(gqlTransactionStatus);
3600
+ const fee = calculateTXFeeForSummary({
3601
+ totalFee,
3549
3602
  gasPrice,
3550
3603
  rawPayload,
3551
3604
  tip,
@@ -3558,7 +3611,6 @@ function assembleTransactionSummary(params) {
3558
3611
  }
3559
3612
  }
3560
3613
  });
3561
- const { isStatusFailure, isStatusPending, isStatusSuccess, blockId, status, time } = processGraphqlStatus(gqlTransactionStatus);
3562
3614
  const mintedAssets = extractMintedAssetsFromReceipts(receipts);
3563
3615
  const burnedAssets = extractBurnedAssetsFromReceipts(receipts);
3564
3616
  let date;
@@ -3567,6 +3619,7 @@ function assembleTransactionSummary(params) {
3567
3619
  }
3568
3620
  const transactionSummary = {
3569
3621
  id,
3622
+ tip,
3570
3623
  fee,
3571
3624
  gasUsed,
3572
3625
  operations,
@@ -3580,6 +3633,8 @@ function assembleTransactionSummary(params) {
3580
3633
  isTypeMint: isTypeMint(transaction.type),
3581
3634
  isTypeCreate: isTypeCreate(transaction.type),
3582
3635
  isTypeScript: isTypeScript(transaction.type),
3636
+ isTypeUpgrade: isTypeUpgrade(transaction.type),
3637
+ isTypeUpload: isTypeUpload(transaction.type),
3583
3638
  isStatusFailure,
3584
3639
  isStatusSuccess,
3585
3640
  isStatusPending,
@@ -3611,7 +3666,7 @@ var TransactionResponse = class {
3611
3666
  /** Current provider */
3612
3667
  provider;
3613
3668
  /** Gas used on the transaction */
3614
- gasUsed = (0, import_math15.bn)(0);
3669
+ gasUsed = (0, import_math16.bn)(0);
3615
3670
  /** The graphql Transaction with receipts object. */
3616
3671
  gqlTransaction;
3617
3672
  abis;
@@ -3696,7 +3751,7 @@ var TransactionResponse = class {
3696
3751
  const receipts = txReceipts.map(processGqlReceipt) || [];
3697
3752
  const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
3698
3753
  const gasPrice = await this.provider.getLatestGasPrice();
3699
- const maxInputs = this.provider.getChain().consensusParameters.maxInputs;
3754
+ const maxInputs = this.provider.getChain().consensusParameters.txParameters.maxInputs;
3700
3755
  const transactionSummary = assembleTransactionSummary({
3701
3756
  id: this.id,
3702
3757
  receipts,
@@ -3832,33 +3887,60 @@ var mergeQuantities = (...coinQuantities) => {
3832
3887
  var MAX_RETRIES = 10;
3833
3888
  var processGqlChain = (chain) => {
3834
3889
  const { name, daHeight, consensusParameters, latestBlock } = chain;
3835
- const { contractParams, feeParams, predicateParams, scriptParams, txParams, gasCosts } = consensusParameters;
3890
+ const {
3891
+ contractParams,
3892
+ feeParams,
3893
+ predicateParams,
3894
+ scriptParams,
3895
+ txParams,
3896
+ gasCosts,
3897
+ baseAssetId,
3898
+ chainId,
3899
+ version
3900
+ } = consensusParameters;
3836
3901
  return {
3837
3902
  name,
3838
- baseChainHeight: (0, import_math16.bn)(daHeight),
3903
+ baseChainHeight: (0, import_math17.bn)(daHeight),
3839
3904
  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,
3905
+ version,
3906
+ chainId: (0, import_math17.bn)(chainId),
3907
+ baseAssetId,
3908
+ feeParameters: {
3909
+ version: feeParams.version,
3910
+ gasPerByte: (0, import_math17.bn)(feeParams.gasPerByte),
3911
+ gasPriceFactor: (0, import_math17.bn)(feeParams.gasPriceFactor)
3912
+ },
3913
+ contractParameters: {
3914
+ version: contractParams.version,
3915
+ contractMaxSize: (0, import_math17.bn)(contractParams.contractMaxSize),
3916
+ maxStorageSlots: (0, import_math17.bn)(contractParams.maxStorageSlots)
3917
+ },
3918
+ txParameters: {
3919
+ version: txParams.version,
3920
+ maxInputs: (0, import_math17.bn)(txParams.maxInputs),
3921
+ maxOutputs: (0, import_math17.bn)(txParams.maxOutputs),
3922
+ maxWitnesses: (0, import_math17.bn)(txParams.maxWitnesses),
3923
+ maxGasPerTx: (0, import_math17.bn)(txParams.maxGasPerTx),
3924
+ maxSize: (0, import_math17.bn)(txParams.maxSize),
3925
+ maxBytecodeSubsections: (0, import_math17.bn)(txParams.maxBytecodeSubsections)
3926
+ },
3927
+ predicateParameters: {
3928
+ version: predicateParams.version,
3929
+ maxPredicateLength: (0, import_math17.bn)(predicateParams.maxPredicateLength),
3930
+ maxPredicateDataLength: (0, import_math17.bn)(predicateParams.maxPredicateDataLength),
3931
+ maxGasPerPredicate: (0, import_math17.bn)(predicateParams.maxGasPerPredicate),
3932
+ maxMessageDataLength: (0, import_math17.bn)(predicateParams.maxMessageDataLength)
3933
+ },
3934
+ scriptParameters: {
3935
+ version: scriptParams.version,
3936
+ maxScriptLength: (0, import_math17.bn)(scriptParams.maxScriptLength),
3937
+ maxScriptDataLength: (0, import_math17.bn)(scriptParams.maxScriptDataLength)
3938
+ },
3856
3939
  gasCosts
3857
3940
  },
3858
- gasCosts,
3859
3941
  latestBlock: {
3860
3942
  id: latestBlock.id,
3861
- height: (0, import_math16.bn)(latestBlock.height),
3943
+ height: (0, import_math17.bn)(latestBlock.height),
3862
3944
  time: latestBlock.header.time,
3863
3945
  transactions: latestBlock.transactions.map((i) => ({
3864
3946
  id: i.id
@@ -3952,7 +4034,12 @@ var _Provider = class {
3952
4034
  * Returns some helpful parameters related to gas fees.
3953
4035
  */
3954
4036
  getGasConfig() {
3955
- const { maxGasPerTx, maxGasPerPredicate, gasPriceFactor, gasPerByte, gasCosts } = this.getChain().consensusParameters;
4037
+ const {
4038
+ txParameters: { maxGasPerTx },
4039
+ predicateParameters: { maxGasPerPredicate },
4040
+ feeParameters: { gasPriceFactor, gasPerByte },
4041
+ gasCosts
4042
+ } = this.getChain().consensusParameters;
3956
4043
  return {
3957
4044
  maxGasPerTx,
3958
4045
  maxGasPerPredicate,
@@ -4001,7 +4088,18 @@ var _Provider = class {
4001
4088
  createOperations() {
4002
4089
  const fetchFn = _Provider.getFetchFn(this.options);
4003
4090
  const gqlClient = new import_graphql_request.GraphQLClient(this.url, {
4004
- fetch: (url, requestInit) => fetchFn(url, requestInit, this.options)
4091
+ fetch: (url, requestInit) => fetchFn(url, requestInit, this.options),
4092
+ responseMiddleware: (response) => {
4093
+ if ("response" in response) {
4094
+ const graphQlResponse = response.response;
4095
+ if (Array.isArray(graphQlResponse?.errors)) {
4096
+ throw new import_errors14.FuelError(
4097
+ import_errors14.FuelError.CODES.INVALID_REQUEST,
4098
+ graphQlResponse.errors.map((err) => err.message).join("\n\n")
4099
+ );
4100
+ }
4101
+ }
4102
+ }
4005
4103
  });
4006
4104
  const executeQuery = (query, vars) => {
4007
4105
  const opDefinition = query.definitions.find((x) => x.kind === "OperationDefinition");
@@ -4029,21 +4127,6 @@ var _Provider = class {
4029
4127
  } = await this.operations.getVersion();
4030
4128
  return nodeVersion;
4031
4129
  }
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
4130
  /**
4048
4131
  * Returns the block number.
4049
4132
  *
@@ -4051,7 +4134,7 @@ var _Provider = class {
4051
4134
  */
4052
4135
  async getBlockNumber() {
4053
4136
  const { chain } = await this.operations.getChain();
4054
- return (0, import_math16.bn)(chain.latestBlock.height, 10);
4137
+ return (0, import_math17.bn)(chain.latestBlock.height, 10);
4055
4138
  }
4056
4139
  /**
4057
4140
  * Returns the chain information.
@@ -4061,8 +4144,8 @@ var _Provider = class {
4061
4144
  async fetchNode() {
4062
4145
  const { nodeInfo } = await this.operations.getNodeInfo();
4063
4146
  const processedNodeInfo = {
4064
- maxDepth: (0, import_math16.bn)(nodeInfo.maxDepth),
4065
- maxTx: (0, import_math16.bn)(nodeInfo.maxTx),
4147
+ maxDepth: (0, import_math17.bn)(nodeInfo.maxDepth),
4148
+ maxTx: (0, import_math17.bn)(nodeInfo.maxTx),
4066
4149
  nodeVersion: nodeInfo.nodeVersion,
4067
4150
  utxoValidation: nodeInfo.utxoValidation,
4068
4151
  vmBacktrace: nodeInfo.vmBacktrace
@@ -4166,9 +4249,9 @@ var _Provider = class {
4166
4249
  encodedTransactions: encodedTransaction,
4167
4250
  utxoValidation: utxoValidation || false
4168
4251
  });
4169
- const [{ receipts: rawReceipts, status }] = dryRunStatuses;
4252
+ const [{ receipts: rawReceipts, status: dryRunStatus }] = dryRunStatuses;
4170
4253
  const receipts = rawReceipts.map(processGqlReceipt);
4171
- return { receipts, dryrunStatus: status };
4254
+ return { receipts, dryRunStatus };
4172
4255
  }
4173
4256
  /**
4174
4257
  * Verifies whether enough gas is available to complete transaction.
@@ -4179,7 +4262,7 @@ var _Provider = class {
4179
4262
  async estimatePredicates(transactionRequest) {
4180
4263
  const shouldEstimatePredicates = Boolean(
4181
4264
  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()
4265
+ (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
4266
  )
4184
4267
  );
4185
4268
  if (!shouldEstimatePredicates) {
@@ -4194,7 +4277,7 @@ var _Provider = class {
4194
4277
  } = response;
4195
4278
  if (inputs) {
4196
4279
  inputs.forEach((input, index) => {
4197
- if ("predicateGasUsed" in input && (0, import_math16.bn)(input.predicateGasUsed).gt(0)) {
4280
+ if ("predicateGasUsed" in input && (0, import_math17.bn)(input.predicateGasUsed).gt(0)) {
4198
4281
  transactionRequest.inputs[index].predicateGasUsed = input.predicateGasUsed;
4199
4282
  }
4200
4283
  });
@@ -4222,7 +4305,7 @@ var _Provider = class {
4222
4305
  let receipts = [];
4223
4306
  const missingContractIds = [];
4224
4307
  let outputVariables = 0;
4225
- let dryrunStatus;
4308
+ let dryRunStatus;
4226
4309
  for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
4227
4310
  const {
4228
4311
  dryRun: [{ receipts: rawReceipts, status }]
@@ -4231,7 +4314,7 @@ var _Provider = class {
4231
4314
  utxoValidation: false
4232
4315
  });
4233
4316
  receipts = rawReceipts.map(processGqlReceipt);
4234
- dryrunStatus = status;
4317
+ dryRunStatus = status;
4235
4318
  const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
4236
4319
  const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
4237
4320
  if (hasMissingOutputs) {
@@ -4253,7 +4336,7 @@ var _Provider = class {
4253
4336
  receipts,
4254
4337
  outputVariables,
4255
4338
  missingContractIds,
4256
- dryrunStatus
4339
+ dryRunStatus
4257
4340
  };
4258
4341
  }
4259
4342
  /**
@@ -4271,7 +4354,7 @@ var _Provider = class {
4271
4354
  receipts: [],
4272
4355
  outputVariables: 0,
4273
4356
  missingContractIds: [],
4274
- dryrunStatus: void 0
4357
+ dryRunStatus: void 0
4275
4358
  }));
4276
4359
  const allRequests = (0, import_ramda3.clone)(transactionRequests);
4277
4360
  const serializedTransactionsMap = /* @__PURE__ */ new Map();
@@ -4296,7 +4379,7 @@ var _Provider = class {
4296
4379
  const { receipts: rawReceipts, status } = dryRunResults.dryRun[i];
4297
4380
  const result = results[requestIdx];
4298
4381
  result.receipts = rawReceipts.map(processGqlReceipt);
4299
- result.dryrunStatus = status;
4382
+ result.dryRunStatus = status;
4300
4383
  const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(
4301
4384
  result.receipts
4302
4385
  );
@@ -4333,7 +4416,7 @@ var _Provider = class {
4333
4416
  });
4334
4417
  const results = dryRunStatuses.map(({ receipts: rawReceipts, status }) => {
4335
4418
  const receipts = rawReceipts.map(processGqlReceipt);
4336
- return { receipts, dryrunStatus: status };
4419
+ return { receipts, dryRunStatus: status };
4337
4420
  });
4338
4421
  return results;
4339
4422
  }
@@ -4352,12 +4435,12 @@ var _Provider = class {
4352
4435
  gasPrice = await this.estimateGasPrice(10);
4353
4436
  }
4354
4437
  const minFee = calculateGasFee({
4355
- gasPrice: (0, import_math16.bn)(gasPrice),
4438
+ gasPrice: (0, import_math17.bn)(gasPrice),
4356
4439
  gas: minGas,
4357
4440
  priceFactor: gasPriceFactor,
4358
4441
  tip: transactionRequest.tip
4359
4442
  }).add(1);
4360
- let gasLimit = (0, import_math16.bn)(0);
4443
+ let gasLimit = (0, import_math17.bn)(0);
4361
4444
  if (transactionRequest.type === import_transactions19.TransactionType.Script) {
4362
4445
  gasLimit = transactionRequest.gasLimit;
4363
4446
  if (transactionRequest.gasLimit.eq(0)) {
@@ -4370,7 +4453,7 @@ var _Provider = class {
4370
4453
  }
4371
4454
  const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
4372
4455
  const maxFee = calculateGasFee({
4373
- gasPrice: (0, import_math16.bn)(gasPrice),
4456
+ gasPrice: (0, import_math17.bn)(gasPrice),
4374
4457
  gas: maxGas,
4375
4458
  priceFactor: gasPriceFactor,
4376
4459
  tip: transactionRequest.tip
@@ -4433,9 +4516,9 @@ var _Provider = class {
4433
4516
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
4434
4517
  const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
4435
4518
  txRequestClone.fundWithFakeUtxos(allQuantities, baseAssetId, resourcesOwner?.address);
4436
- txRequestClone.maxFee = (0, import_math16.bn)(0);
4519
+ txRequestClone.maxFee = (0, import_math17.bn)(0);
4437
4520
  if (isScriptTransaction) {
4438
- txRequestClone.gasLimit = (0, import_math16.bn)(0);
4521
+ txRequestClone.gasLimit = (0, import_math17.bn)(0);
4439
4522
  }
4440
4523
  if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
4441
4524
  resourcesOwner.populateTransactionPredicateData(txRequestClone);
@@ -4452,9 +4535,10 @@ var _Provider = class {
4452
4535
  transactionRequest: signedRequest
4453
4536
  });
4454
4537
  let receipts = [];
4538
+ let dryRunStatus;
4455
4539
  let missingContractIds = [];
4456
4540
  let outputVariables = 0;
4457
- let gasUsed = (0, import_math16.bn)(0);
4541
+ let gasUsed = (0, import_math17.bn)(0);
4458
4542
  txRequestClone.updatePredicateGasUsed(signedRequest.inputs);
4459
4543
  txRequestClone.maxFee = maxFee;
4460
4544
  if (isScriptTransaction) {
@@ -4462,10 +4546,7 @@ var _Provider = class {
4462
4546
  if (signatureCallback) {
4463
4547
  await signatureCallback(txRequestClone);
4464
4548
  }
4465
- const result = await this.estimateTxDependencies(txRequestClone);
4466
- receipts = result.receipts;
4467
- outputVariables = result.outputVariables;
4468
- missingContractIds = result.missingContractIds;
4549
+ ({ receipts, missingContractIds, outputVariables, dryRunStatus } = await this.estimateTxDependencies(txRequestClone));
4469
4550
  gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
4470
4551
  txRequestClone.gasLimit = gasUsed;
4471
4552
  ({ maxFee, maxGas, minFee, minGas, gasPrice } = await this.estimateTxGasAndFee({
@@ -4485,7 +4566,8 @@ var _Provider = class {
4485
4566
  outputVariables,
4486
4567
  missingContractIds,
4487
4568
  addedSignatures,
4488
- estimatedPredicates: txRequestClone.inputs
4569
+ estimatedPredicates: txRequestClone.inputs,
4570
+ dryRunStatus
4489
4571
  };
4490
4572
  }
4491
4573
  async getResourcesForTransaction(owner, transactionRequestLike, quantitiesToContract = []) {
@@ -4521,10 +4603,10 @@ var _Provider = class {
4521
4603
  return coins.map((coin) => ({
4522
4604
  id: coin.utxoId,
4523
4605
  assetId: coin.assetId,
4524
- amount: (0, import_math16.bn)(coin.amount),
4606
+ amount: (0, import_math17.bn)(coin.amount),
4525
4607
  owner: import_address3.Address.fromAddressOrString(coin.owner),
4526
- blockCreated: (0, import_math16.bn)(coin.blockCreated),
4527
- txCreatedIdx: (0, import_math16.bn)(coin.txCreatedIdx)
4608
+ blockCreated: (0, import_math17.bn)(coin.blockCreated),
4609
+ txCreatedIdx: (0, import_math17.bn)(coin.txCreatedIdx)
4528
4610
  }));
4529
4611
  }
4530
4612
  /**
@@ -4561,9 +4643,9 @@ var _Provider = class {
4561
4643
  switch (coin.__typename) {
4562
4644
  case "MessageCoin":
4563
4645
  return {
4564
- amount: (0, import_math16.bn)(coin.amount),
4646
+ amount: (0, import_math17.bn)(coin.amount),
4565
4647
  assetId: coin.assetId,
4566
- daHeight: (0, import_math16.bn)(coin.daHeight),
4648
+ daHeight: (0, import_math17.bn)(coin.daHeight),
4567
4649
  sender: import_address3.Address.fromAddressOrString(coin.sender),
4568
4650
  recipient: import_address3.Address.fromAddressOrString(coin.recipient),
4569
4651
  nonce: coin.nonce
@@ -4571,11 +4653,11 @@ var _Provider = class {
4571
4653
  case "Coin":
4572
4654
  return {
4573
4655
  id: coin.utxoId,
4574
- amount: (0, import_math16.bn)(coin.amount),
4656
+ amount: (0, import_math17.bn)(coin.amount),
4575
4657
  assetId: coin.assetId,
4576
4658
  owner: import_address3.Address.fromAddressOrString(coin.owner),
4577
- blockCreated: (0, import_math16.bn)(coin.blockCreated),
4578
- txCreatedIdx: (0, import_math16.bn)(coin.txCreatedIdx)
4659
+ blockCreated: (0, import_math17.bn)(coin.blockCreated),
4660
+ txCreatedIdx: (0, import_math17.bn)(coin.txCreatedIdx)
4579
4661
  };
4580
4662
  default:
4581
4663
  return null;
@@ -4592,13 +4674,13 @@ var _Provider = class {
4592
4674
  async getBlock(idOrHeight) {
4593
4675
  let variables;
4594
4676
  if (typeof idOrHeight === "number") {
4595
- variables = { height: (0, import_math16.bn)(idOrHeight).toString(10) };
4677
+ variables = { height: (0, import_math17.bn)(idOrHeight).toString(10) };
4596
4678
  } else if (idOrHeight === "latest") {
4597
4679
  variables = { height: (await this.getBlockNumber()).toString(10) };
4598
4680
  } else if (idOrHeight.length === 66) {
4599
4681
  variables = { blockId: idOrHeight };
4600
4682
  } else {
4601
- variables = { blockId: (0, import_math16.bn)(idOrHeight).toString(10) };
4683
+ variables = { blockId: (0, import_math17.bn)(idOrHeight).toString(10) };
4602
4684
  }
4603
4685
  const { block } = await this.operations.getBlock(variables);
4604
4686
  if (!block) {
@@ -4606,7 +4688,7 @@ var _Provider = class {
4606
4688
  }
4607
4689
  return {
4608
4690
  id: block.id,
4609
- height: (0, import_math16.bn)(block.height),
4691
+ height: (0, import_math17.bn)(block.height),
4610
4692
  time: block.header.time,
4611
4693
  transactionIds: block.transactions.map((tx) => tx.id)
4612
4694
  };
@@ -4621,7 +4703,7 @@ var _Provider = class {
4621
4703
  const { blocks: fetchedData } = await this.operations.getBlocks(params);
4622
4704
  const blocks = fetchedData.edges.map(({ node: block }) => ({
4623
4705
  id: block.id,
4624
- height: (0, import_math16.bn)(block.height),
4706
+ height: (0, import_math17.bn)(block.height),
4625
4707
  time: block.header.time,
4626
4708
  transactionIds: block.transactions.map((tx) => tx.id)
4627
4709
  }));
@@ -4636,7 +4718,7 @@ var _Provider = class {
4636
4718
  async getBlockWithTransactions(idOrHeight) {
4637
4719
  let variables;
4638
4720
  if (typeof idOrHeight === "number") {
4639
- variables = { blockHeight: (0, import_math16.bn)(idOrHeight).toString(10) };
4721
+ variables = { blockHeight: (0, import_math17.bn)(idOrHeight).toString(10) };
4640
4722
  } else if (idOrHeight === "latest") {
4641
4723
  variables = { blockHeight: (await this.getBlockNumber()).toString() };
4642
4724
  } else {
@@ -4648,7 +4730,7 @@ var _Provider = class {
4648
4730
  }
4649
4731
  return {
4650
4732
  id: block.id,
4651
- height: (0, import_math16.bn)(block.height, 10),
4733
+ height: (0, import_math17.bn)(block.height, 10),
4652
4734
  time: block.header.time,
4653
4735
  transactionIds: block.transactions.map((tx) => tx.id),
4654
4736
  transactions: block.transactions.map(
@@ -4697,7 +4779,7 @@ var _Provider = class {
4697
4779
  contract: import_address3.Address.fromAddressOrString(contractId).toB256(),
4698
4780
  asset: (0, import_utils22.hexlify)(assetId)
4699
4781
  });
4700
- return (0, import_math16.bn)(contractBalance.amount, 10);
4782
+ return (0, import_math17.bn)(contractBalance.amount, 10);
4701
4783
  }
4702
4784
  /**
4703
4785
  * Returns the balance for the given owner for the given asset ID.
@@ -4711,7 +4793,7 @@ var _Provider = class {
4711
4793
  owner: import_address3.Address.fromAddressOrString(owner).toB256(),
4712
4794
  assetId: (0, import_utils22.hexlify)(assetId)
4713
4795
  });
4714
- return (0, import_math16.bn)(balance.amount, 10);
4796
+ return (0, import_math17.bn)(balance.amount, 10);
4715
4797
  }
4716
4798
  /**
4717
4799
  * Returns balances for the given owner.
@@ -4729,7 +4811,7 @@ var _Provider = class {
4729
4811
  const balances = result.balances.edges.map((edge) => edge.node);
4730
4812
  return balances.map((balance) => ({
4731
4813
  assetId: balance.assetId,
4732
- amount: (0, import_math16.bn)(balance.amount)
4814
+ amount: (0, import_math17.bn)(balance.amount)
4733
4815
  }));
4734
4816
  }
4735
4817
  /**
@@ -4751,15 +4833,15 @@ var _Provider = class {
4751
4833
  sender: message.sender,
4752
4834
  recipient: message.recipient,
4753
4835
  nonce: message.nonce,
4754
- amount: (0, import_math16.bn)(message.amount),
4836
+ amount: (0, import_math17.bn)(message.amount),
4755
4837
  data: message.data
4756
4838
  }),
4757
4839
  sender: import_address3.Address.fromAddressOrString(message.sender),
4758
4840
  recipient: import_address3.Address.fromAddressOrString(message.recipient),
4759
4841
  nonce: message.nonce,
4760
- amount: (0, import_math16.bn)(message.amount),
4842
+ amount: (0, import_math17.bn)(message.amount),
4761
4843
  data: import_transactions19.InputMessageCoder.decodeData(message.data),
4762
- daHeight: (0, import_math16.bn)(message.daHeight)
4844
+ daHeight: (0, import_math17.bn)(message.daHeight)
4763
4845
  }));
4764
4846
  }
4765
4847
  /**
@@ -4812,59 +4894,59 @@ var _Provider = class {
4812
4894
  } = result.messageProof;
4813
4895
  return {
4814
4896
  messageProof: {
4815
- proofIndex: (0, import_math16.bn)(messageProof.proofIndex),
4897
+ proofIndex: (0, import_math17.bn)(messageProof.proofIndex),
4816
4898
  proofSet: messageProof.proofSet
4817
4899
  },
4818
4900
  blockProof: {
4819
- proofIndex: (0, import_math16.bn)(blockProof.proofIndex),
4901
+ proofIndex: (0, import_math17.bn)(blockProof.proofIndex),
4820
4902
  proofSet: blockProof.proofSet
4821
4903
  },
4822
4904
  messageBlockHeader: {
4823
4905
  id: messageBlockHeader.id,
4824
- daHeight: (0, import_math16.bn)(messageBlockHeader.daHeight),
4825
- transactionsCount: (0, import_math16.bn)(messageBlockHeader.transactionsCount),
4906
+ daHeight: (0, import_math17.bn)(messageBlockHeader.daHeight),
4907
+ transactionsCount: Number(messageBlockHeader.transactionsCount),
4826
4908
  transactionsRoot: messageBlockHeader.transactionsRoot,
4827
- height: (0, import_math16.bn)(messageBlockHeader.height),
4909
+ height: (0, import_math17.bn)(messageBlockHeader.height),
4828
4910
  prevRoot: messageBlockHeader.prevRoot,
4829
4911
  time: messageBlockHeader.time,
4830
4912
  applicationHash: messageBlockHeader.applicationHash,
4831
- messageReceiptCount: (0, import_math16.bn)(messageBlockHeader.messageReceiptCount),
4913
+ messageReceiptCount: Number(messageBlockHeader.messageReceiptCount),
4832
4914
  messageOutboxRoot: messageBlockHeader.messageOutboxRoot,
4833
- consensusParametersVersion: messageBlockHeader.consensusParametersVersion,
4915
+ consensusParametersVersion: Number(messageBlockHeader.consensusParametersVersion),
4834
4916
  eventInboxRoot: messageBlockHeader.eventInboxRoot,
4835
- stateTransitionBytecodeVersion: messageBlockHeader.stateTransitionBytecodeVersion
4917
+ stateTransitionBytecodeVersion: Number(messageBlockHeader.stateTransitionBytecodeVersion)
4836
4918
  },
4837
4919
  commitBlockHeader: {
4838
4920
  id: commitBlockHeader.id,
4839
- daHeight: (0, import_math16.bn)(commitBlockHeader.daHeight),
4840
- transactionsCount: (0, import_math16.bn)(commitBlockHeader.transactionsCount),
4921
+ daHeight: (0, import_math17.bn)(commitBlockHeader.daHeight),
4922
+ transactionsCount: Number(commitBlockHeader.transactionsCount),
4841
4923
  transactionsRoot: commitBlockHeader.transactionsRoot,
4842
- height: (0, import_math16.bn)(commitBlockHeader.height),
4924
+ height: (0, import_math17.bn)(commitBlockHeader.height),
4843
4925
  prevRoot: commitBlockHeader.prevRoot,
4844
4926
  time: commitBlockHeader.time,
4845
4927
  applicationHash: commitBlockHeader.applicationHash,
4846
- messageReceiptCount: (0, import_math16.bn)(commitBlockHeader.messageReceiptCount),
4928
+ messageReceiptCount: Number(commitBlockHeader.messageReceiptCount),
4847
4929
  messageOutboxRoot: commitBlockHeader.messageOutboxRoot,
4848
- consensusParametersVersion: commitBlockHeader.consensusParametersVersion,
4930
+ consensusParametersVersion: Number(commitBlockHeader.consensusParametersVersion),
4849
4931
  eventInboxRoot: commitBlockHeader.eventInboxRoot,
4850
- stateTransitionBytecodeVersion: commitBlockHeader.stateTransitionBytecodeVersion
4932
+ stateTransitionBytecodeVersion: Number(commitBlockHeader.stateTransitionBytecodeVersion)
4851
4933
  },
4852
4934
  sender: import_address3.Address.fromAddressOrString(sender),
4853
4935
  recipient: import_address3.Address.fromAddressOrString(recipient),
4854
4936
  nonce,
4855
- amount: (0, import_math16.bn)(amount),
4937
+ amount: (0, import_math17.bn)(amount),
4856
4938
  data
4857
4939
  };
4858
4940
  }
4859
4941
  async getLatestGasPrice() {
4860
4942
  const { latestGasPrice } = await this.operations.getLatestGasPrice();
4861
- return (0, import_math16.bn)(latestGasPrice.gasPrice);
4943
+ return (0, import_math17.bn)(latestGasPrice.gasPrice);
4862
4944
  }
4863
4945
  async estimateGasPrice(blockHorizon) {
4864
4946
  const { estimateGasPrice } = await this.operations.estimateGasPrice({
4865
4947
  blockHorizon: String(blockHorizon)
4866
4948
  });
4867
- return (0, import_math16.bn)(estimateGasPrice.gasPrice);
4949
+ return (0, import_math17.bn)(estimateGasPrice.gasPrice);
4868
4950
  }
4869
4951
  /**
4870
4952
  * Returns Message Proof for given transaction id and the message id from MessageOut receipt.
@@ -4885,15 +4967,37 @@ var _Provider = class {
4885
4967
  */
4886
4968
  async produceBlocks(amount, startTime) {
4887
4969
  const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
4888
- blocksToProduce: (0, import_math16.bn)(amount).toString(10),
4970
+ blocksToProduce: (0, import_math17.bn)(amount).toString(10),
4889
4971
  startTimestamp: startTime ? import_utils22.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
4890
4972
  });
4891
- return (0, import_math16.bn)(latestBlockHeight);
4973
+ return (0, import_math17.bn)(latestBlockHeight);
4892
4974
  }
4893
4975
  // eslint-disable-next-line @typescript-eslint/require-await
4894
4976
  async getTransactionResponse(transactionId) {
4895
4977
  return new TransactionResponse(transactionId, this);
4896
4978
  }
4979
+ /**
4980
+ * Returns Message for given nonce.
4981
+ *
4982
+ * @param nonce - The nonce of the message to retrieve.
4983
+ * @returns A promise that resolves to the Message object.
4984
+ */
4985
+ async getMessageByNonce(nonce) {
4986
+ const { message } = await this.operations.getMessageByNonce({ nonce });
4987
+ if (!message) {
4988
+ return null;
4989
+ }
4990
+ return message;
4991
+ }
4992
+ async getRelayedTransactionStatus(relayedTransactionId) {
4993
+ const { relayedTransactionStatus } = await this.operations.getRelayedTransactionStatus({
4994
+ relayedTransactionId
4995
+ });
4996
+ if (!relayedTransactionStatus) {
4997
+ return null;
4998
+ }
4999
+ return relayedTransactionStatus;
5000
+ }
4897
5001
  };
4898
5002
  var Provider = _Provider;
4899
5003
  _cacheInputs = new WeakSet();
@@ -4912,7 +5016,7 @@ __publicField(Provider, "nodeInfoCache", {});
4912
5016
 
4913
5017
  // src/providers/transaction-summary/get-transaction-summary.ts
4914
5018
  var import_errors15 = require("@fuel-ts/errors");
4915
- var import_math17 = require("@fuel-ts/math");
5019
+ var import_math18 = require("@fuel-ts/math");
4916
5020
  var import_transactions20 = require("@fuel-ts/transactions");
4917
5021
  var import_utils25 = require("@fuel-ts/utils");
4918
5022
  async function getTransactionSummary(params) {
@@ -4936,7 +5040,11 @@ async function getTransactionSummary(params) {
4936
5040
  }
4937
5041
  const receipts = txReceipts.map(processGqlReceipt);
4938
5042
  const {
4939
- consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts, maxGasPerTx }
5043
+ consensusParameters: {
5044
+ feeParameters: { gasPerByte, gasPriceFactor },
5045
+ txParameters: { maxInputs, maxGasPerTx },
5046
+ gasCosts
5047
+ }
4940
5048
  } = provider.getChain();
4941
5049
  const gasPrice = await provider.getLatestGasPrice();
4942
5050
  const transactionInfo = assembleTransactionSummary({
@@ -4945,8 +5053,8 @@ async function getTransactionSummary(params) {
4945
5053
  transaction: decodedTransaction,
4946
5054
  transactionBytes: (0, import_utils25.arrayify)(gqlTransaction.rawPayload),
4947
5055
  gqlTransactionStatus: gqlTransaction.status,
4948
- gasPerByte: (0, import_math17.bn)(gasPerByte),
4949
- gasPriceFactor: (0, import_math17.bn)(gasPriceFactor),
5056
+ gasPerByte: (0, import_math18.bn)(gasPerByte),
5057
+ gasPriceFactor: (0, import_math18.bn)(gasPriceFactor),
4950
5058
  abiMap,
4951
5059
  maxInputs,
4952
5060
  gasCosts,
@@ -4962,7 +5070,7 @@ async function getTransactionSummaryFromRequest(params) {
4962
5070
  const { provider, transactionRequest, abiMap } = params;
4963
5071
  const { receipts } = await provider.call(transactionRequest);
4964
5072
  const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = provider.getGasConfig();
4965
- const maxInputs = provider.getChain().consensusParameters.maxInputs;
5073
+ const maxInputs = provider.getChain().consensusParameters.txParameters.maxInputs;
4966
5074
  const transaction = transactionRequest.toTransaction();
4967
5075
  const transactionBytes = transactionRequest.toTransactionBytes();
4968
5076
  const gasPrice = await provider.getLatestGasPrice();
@@ -4985,7 +5093,11 @@ async function getTransactionsSummaries(params) {
4985
5093
  const { transactionsByOwner } = await provider.operations.getTransactionsByOwner(filters);
4986
5094
  const { edges, pageInfo } = transactionsByOwner;
4987
5095
  const {
4988
- consensusParameters: { gasPerByte, gasPriceFactor, maxInputs, gasCosts, maxGasPerTx }
5096
+ consensusParameters: {
5097
+ feeParameters: { gasPerByte, gasPriceFactor },
5098
+ txParameters: { maxInputs, maxGasPerTx },
5099
+ gasCosts
5100
+ }
4989
5101
  } = provider.getChain();
4990
5102
  const gasPrice = await provider.getLatestGasPrice();
4991
5103
  const transactions = edges.map((edge) => {
@@ -5144,15 +5256,31 @@ var assets = [
5144
5256
  }
5145
5257
  ];
5146
5258
 
5259
+ // src/providers/transaction-request/helpers.ts
5260
+ var import_math19 = require("@fuel-ts/math");
5261
+ var import_transactions21 = require("@fuel-ts/transactions");
5262
+ var isRequestInputCoin = (input) => input.type === import_transactions21.InputType.Coin;
5263
+ var isRequestInputMessage = (input) => input.type === import_transactions21.InputType.Message;
5264
+ var isRequestInputResource = (input) => isRequestInputCoin(input) || isRequestInputMessage(input);
5265
+ var getAssetAmountInRequestInputs = (inputs, assetId, baseAsset) => inputs.filter(isRequestInputResource).reduce((acc, input) => {
5266
+ if (isRequestInputCoin(input) && input.assetId === assetId) {
5267
+ return acc.add(input.amount);
5268
+ }
5269
+ if (isRequestInputMessage(input) && assetId === baseAsset) {
5270
+ return acc.add(input.amount);
5271
+ }
5272
+ return acc;
5273
+ }, (0, import_math19.bn)(0));
5274
+
5147
5275
  // src/utils/formatTransferToContractScriptData.ts
5148
5276
  var import_abi_coder6 = require("@fuel-ts/abi-coder");
5149
- var import_math18 = require("@fuel-ts/math");
5277
+ var import_math20 = require("@fuel-ts/math");
5150
5278
  var import_utils26 = require("@fuel-ts/utils");
5151
5279
  var asm = __toESM(require("@fuels/vm-asm"));
5152
5280
  var formatTransferToContractScriptData = (params) => {
5153
5281
  const { assetId, amountToTransfer, hexlifiedContractId } = params;
5154
5282
  const numberCoder = new import_abi_coder6.BigNumberCoder("u64");
5155
- const encoded = numberCoder.encode(new import_math18.BN(amountToTransfer).toNumber());
5283
+ const encoded = numberCoder.encode(new import_math20.BN(amountToTransfer).toNumber());
5156
5284
  const scriptData = Uint8Array.from([
5157
5285
  ...(0, import_utils26.arrayify)(hexlifiedContractId),
5158
5286
  ...encoded,
@@ -5181,6 +5309,7 @@ var assembleTransferToContractScript = async (params) => {
5181
5309
  };
5182
5310
 
5183
5311
  // src/account.ts
5312
+ var MAX_FUNDING_ATTEMPTS = 2;
5184
5313
  var Account = class extends import_interfaces.AbstractAccount {
5185
5314
  /**
5186
5315
  * The address associated with the account.
@@ -5338,16 +5467,17 @@ var Account = class extends import_interfaces.AbstractAccount {
5338
5467
  * Adds resources to the transaction enough to fund it.
5339
5468
  *
5340
5469
  * @param request - The transaction request.
5341
- * @param coinQuantities - The coin quantities required to execute the transaction.
5470
+ * @param requiredQuantities - The coin quantities required to execute the transaction.
5342
5471
  * @param fee - The estimated transaction fee.
5343
5472
  * @returns A promise that resolves when the resources are added to the transaction.
5344
5473
  */
5345
5474
  async fund(request, params) {
5346
5475
  const { addedSignatures, estimatedPredicates, maxFee: fee, requiredQuantities } = params;
5347
5476
  const baseAssetId = this.provider.getBaseAssetId();
5477
+ const requiredInBaseAsset = requiredQuantities.find((quantity) => quantity.assetId === baseAssetId)?.amount || (0, import_math21.bn)(0);
5348
5478
  const txRequest = request;
5349
5479
  const requiredQuantitiesWithFee = addAmountToCoinQuantities({
5350
- amount: (0, import_math19.bn)(fee),
5480
+ amount: (0, import_math21.bn)(fee),
5351
5481
  assetId: baseAssetId,
5352
5482
  coinQuantities: requiredQuantities
5353
5483
  });
@@ -5355,21 +5485,17 @@ var Account = class extends import_interfaces.AbstractAccount {
5355
5485
  requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
5356
5486
  quantitiesDict[assetId] = {
5357
5487
  required: amount,
5358
- owned: (0, import_math19.bn)(0)
5488
+ owned: (0, import_math21.bn)(0)
5359
5489
  };
5360
5490
  });
5361
- txRequest.inputs.forEach((input) => {
5362
- const isResource = "amount" in input;
5363
- if (!isResource) {
5364
- return;
5365
- }
5366
- const isCoin2 = "owner" in input;
5491
+ request.inputs.filter(isRequestInputResource).forEach((input) => {
5492
+ const isCoin2 = isRequestInputCoin(input);
5367
5493
  const assetId = isCoin2 ? String(input.assetId) : baseAssetId;
5368
5494
  if (quantitiesDict[assetId]) {
5369
5495
  quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(input.amount);
5370
5496
  }
5371
5497
  });
5372
- const missingQuantities = [];
5498
+ let missingQuantities = [];
5373
5499
  Object.entries(quantitiesDict).forEach(([assetId, { owned, required }]) => {
5374
5500
  if (owned.lt(required)) {
5375
5501
  missingQuantities.push({
@@ -5378,11 +5504,42 @@ var Account = class extends import_interfaces.AbstractAccount {
5378
5504
  });
5379
5505
  }
5380
5506
  });
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);
5507
+ let needsToBeFunded = missingQuantities.length > 0;
5508
+ let fundingAttempts = 0;
5509
+ while (needsToBeFunded && fundingAttempts < MAX_FUNDING_ATTEMPTS) {
5510
+ const resources = await this.getResourcesToSpend(
5511
+ missingQuantities,
5512
+ cacheTxInputsFromOwner(request.inputs, this.address)
5513
+ );
5514
+ request.addResources(resources);
5515
+ txRequest.shiftPredicateData();
5516
+ txRequest.updatePredicateGasUsed(estimatedPredicates);
5517
+ const requestToReestimate2 = (0, import_ramda4.clone)(txRequest);
5518
+ if (addedSignatures) {
5519
+ Array.from({ length: addedSignatures }).forEach(
5520
+ () => requestToReestimate2.addEmptyWitness()
5521
+ );
5522
+ }
5523
+ const { maxFee: newFee } = await this.provider.estimateTxGasAndFee({
5524
+ transactionRequest: requestToReestimate2
5525
+ });
5526
+ const totalBaseAssetOnInputs = getAssetAmountInRequestInputs(
5527
+ request.inputs,
5528
+ baseAssetId,
5529
+ baseAssetId
5530
+ );
5531
+ const totalBaseAssetRequiredWithFee = requiredInBaseAsset.add(newFee);
5532
+ if (totalBaseAssetOnInputs.gt(totalBaseAssetRequiredWithFee)) {
5533
+ needsToBeFunded = false;
5534
+ } else {
5535
+ missingQuantities = [
5536
+ {
5537
+ amount: totalBaseAssetRequiredWithFee.sub(totalBaseAssetOnInputs),
5538
+ assetId: baseAssetId
5539
+ }
5540
+ ];
5541
+ }
5542
+ fundingAttempts += 1;
5386
5543
  }
5387
5544
  txRequest.shiftPredicateData();
5388
5545
  txRequest.updatePredicateGasUsed(estimatedPredicates);
@@ -5433,7 +5590,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5433
5590
  * @returns A promise that resolves to the transaction response.
5434
5591
  */
5435
5592
  async transfer(destination, amount, assetId, txParams = {}) {
5436
- if ((0, import_math19.bn)(amount).lte(0)) {
5593
+ if ((0, import_math21.bn)(amount).lte(0)) {
5437
5594
  throw new import_errors16.FuelError(
5438
5595
  import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
5439
5596
  "Transfer amount must be a positive number."
@@ -5453,7 +5610,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5453
5610
  * @returns A promise that resolves to the transaction response.
5454
5611
  */
5455
5612
  async transferToContract(contractId, amount, assetId, txParams = {}) {
5456
- if ((0, import_math19.bn)(amount).lte(0)) {
5613
+ if ((0, import_math21.bn)(amount).lte(0)) {
5457
5614
  throw new import_errors16.FuelError(
5458
5615
  import_errors16.ErrorCode.INVALID_TRANSFER_AMOUNT,
5459
5616
  "Transfer amount must be a positive number."
@@ -5463,7 +5620,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5463
5620
  const assetIdToTransfer = assetId ?? this.provider.getBaseAssetId();
5464
5621
  const { script, scriptData } = await assembleTransferToContractScript({
5465
5622
  hexlifiedContractId: contractAddress.toB256(),
5466
- amountToTransfer: (0, import_math19.bn)(amount),
5623
+ amountToTransfer: (0, import_math21.bn)(amount),
5467
5624
  assetId: assetIdToTransfer
5468
5625
  });
5469
5626
  const request = new ScriptTransactionRequest({
@@ -5474,7 +5631,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5474
5631
  request.addContractInputAndOutput(contractAddress);
5475
5632
  const txCost = await this.provider.getTransactionCost(request, {
5476
5633
  resourcesOwner: this,
5477
- quantitiesToContract: [{ amount: (0, import_math19.bn)(amount), assetId: String(assetIdToTransfer) }]
5634
+ quantitiesToContract: [{ amount: (0, import_math21.bn)(amount), assetId: String(assetIdToTransfer) }]
5478
5635
  });
5479
5636
  this.validateGasLimitAndMaxFee({
5480
5637
  gasUsed: txCost.gasUsed,
@@ -5500,7 +5657,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5500
5657
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
5501
5658
  );
5502
5659
  const amountDataArray = (0, import_utils27.arrayify)(
5503
- "0x".concat((0, import_math19.bn)(amount).toHex().substring(2).padStart(16, "0"))
5660
+ "0x".concat((0, import_math21.bn)(amount).toHex().substring(2).padStart(16, "0"))
5504
5661
  );
5505
5662
  const script = new Uint8Array([
5506
5663
  ...(0, import_utils27.arrayify)(withdrawScript.bytes),
@@ -5510,7 +5667,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5510
5667
  const params = { script, ...txParams };
5511
5668
  const baseAssetId = this.provider.getBaseAssetId();
5512
5669
  const request = new ScriptTransactionRequest(params);
5513
- const quantitiesToContract = [{ amount: (0, import_math19.bn)(amount), assetId: baseAssetId }];
5670
+ const quantitiesToContract = [{ amount: (0, import_math21.bn)(amount), assetId: baseAssetId }];
5514
5671
  const txCost = await this.provider.getTransactionCost(request, { quantitiesToContract });
5515
5672
  this.validateGasLimitAndMaxFee({
5516
5673
  gasUsed: txCost.gasUsed,
@@ -5605,7 +5762,7 @@ var import_utils30 = require("@fuel-ts/utils");
5605
5762
  var import_address5 = require("@fuel-ts/address");
5606
5763
  var import_crypto2 = require("@fuel-ts/crypto");
5607
5764
  var import_hasher2 = require("@fuel-ts/hasher");
5608
- var import_math20 = require("@fuel-ts/math");
5765
+ var import_math22 = require("@fuel-ts/math");
5609
5766
  var import_utils28 = require("@fuel-ts/utils");
5610
5767
  var import_secp256k1 = require("@noble/curves/secp256k1");
5611
5768
  var Signer = class {
@@ -5625,7 +5782,7 @@ var Signer = class {
5625
5782
  privateKey = `0x${privateKey}`;
5626
5783
  }
5627
5784
  }
5628
- const privateKeyBytes = (0, import_math20.toBytes)(privateKey, 32);
5785
+ const privateKeyBytes = (0, import_math22.toBytes)(privateKey, 32);
5629
5786
  this.privateKey = (0, import_utils28.hexlify)(privateKeyBytes);
5630
5787
  this.publicKey = (0, import_utils28.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
5631
5788
  this.compressedPublicKey = (0, import_utils28.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
@@ -5643,8 +5800,8 @@ var Signer = class {
5643
5800
  */
5644
5801
  sign(data) {
5645
5802
  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);
5803
+ const r = (0, import_math22.toBytes)(`0x${signature.r.toString(16)}`, 32);
5804
+ const s = (0, import_math22.toBytes)(`0x${signature.s.toString(16)}`, 32);
5648
5805
  s[0] |= (signature.recovery || 0) << 7;
5649
5806
  return (0, import_utils28.hexlify)((0, import_utils28.concat)([r, s]));
5650
5807
  }
@@ -5916,16 +6073,16 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
5916
6073
  // src/hdwallet/hdwallet.ts
5917
6074
  var import_errors20 = require("@fuel-ts/errors");
5918
6075
  var import_hasher6 = require("@fuel-ts/hasher");
5919
- var import_math21 = require("@fuel-ts/math");
6076
+ var import_math23 = require("@fuel-ts/math");
5920
6077
  var import_utils34 = require("@fuel-ts/utils");
5921
- var import_ethers3 = require("ethers");
6078
+ var import_ethers2 = require("ethers");
5922
6079
 
5923
6080
  // src/mnemonic/mnemonic.ts
5924
6081
  var import_crypto4 = require("@fuel-ts/crypto");
5925
6082
  var import_errors19 = require("@fuel-ts/errors");
5926
6083
  var import_hasher5 = require("@fuel-ts/hasher");
5927
6084
  var import_utils32 = require("@fuel-ts/utils");
5928
- var import_ethers2 = require("ethers");
6085
+ var import_ethers = require("ethers");
5929
6086
 
5930
6087
  // src/wordlists/words/english.ts
5931
6088
  var english = [
@@ -8179,7 +8336,7 @@ var Mnemonic = class {
8179
8336
  assertMnemonic(getWords(phrase));
8180
8337
  const phraseBytes = toUtf8Bytes(getPhrase(phrase));
8181
8338
  const salt = toUtf8Bytes(`mnemonic${passphrase}`);
8182
- return (0, import_ethers2.pbkdf2)(phraseBytes, salt, 2048, 64, "sha512");
8339
+ return (0, import_ethers.pbkdf2)(phraseBytes, salt, 2048, 64, "sha512");
8183
8340
  }
8184
8341
  /**
8185
8342
  * @param phrase - Mnemonic phrase composed by words from the provided wordlist
@@ -8241,7 +8398,7 @@ var Mnemonic = class {
8241
8398
  `Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
8242
8399
  );
8243
8400
  }
8244
- return (0, import_utils32.arrayify)((0, import_ethers2.computeHmac)("sha512", MasterSecret, seedArray));
8401
+ return (0, import_utils32.arrayify)((0, import_ethers.computeHmac)("sha512", MasterSecret, seedArray));
8245
8402
  }
8246
8403
  /**
8247
8404
  * Get the extendKey as defined on BIP-32 from the provided seed
@@ -8266,8 +8423,8 @@ var Mnemonic = class {
8266
8423
  chainCode,
8267
8424
  (0, import_utils32.concat)(["0x00", privateKey])
8268
8425
  ]);
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]));
8426
+ const checksum = (0, import_ethers.dataSlice)((0, import_hasher5.sha256)((0, import_hasher5.sha256)(extendedKey)), 0, 4);
8427
+ return (0, import_ethers.encodeBase58)((0, import_utils32.concat)([extendedKey, checksum]));
8271
8428
  }
8272
8429
  /**
8273
8430
  * Create a new mnemonic using a randomly generated number as entropy.
@@ -8295,7 +8452,7 @@ var MainnetPUB = (0, import_utils34.hexlify)("0x0488b21e");
8295
8452
  var TestnetPRV2 = (0, import_utils34.hexlify)("0x04358394");
8296
8453
  var TestnetPUB = (0, import_utils34.hexlify)("0x043587cf");
8297
8454
  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)]));
8455
+ 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
8456
  }
8300
8457
  function getExtendedKeyPrefix(isPublic = false, testnet = false) {
8301
8458
  if (isPublic) {
@@ -8351,7 +8508,7 @@ var HDWallet = class {
8351
8508
  this.publicKey = (0, import_utils34.hexlify)(config.publicKey);
8352
8509
  }
8353
8510
  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);
8511
+ this.fingerprint = (0, import_ethers2.dataSlice)((0, import_ethers2.ripemd160)((0, import_hasher6.sha256)(this.publicKey)), 0, 4);
8355
8512
  this.depth = config.depth || this.depth;
8356
8513
  this.index = config.index || this.index;
8357
8514
  this.chainCode = config.chainCode;
@@ -8382,13 +8539,13 @@ var HDWallet = class {
8382
8539
  } else {
8383
8540
  data.set((0, import_utils34.arrayify)(this.publicKey));
8384
8541
  }
8385
- data.set((0, import_math21.toBytes)(index, 4), 33);
8386
- const bytes = (0, import_utils34.arrayify)((0, import_ethers3.computeHmac)("sha512", chainCode, data));
8542
+ data.set((0, import_math23.toBytes)(index, 4), 33);
8543
+ const bytes = (0, import_utils34.arrayify)((0, import_ethers2.computeHmac)("sha512", chainCode, data));
8387
8544
  const IL = bytes.slice(0, 32);
8388
8545
  const IR = bytes.slice(32);
8389
8546
  if (privateKey) {
8390
8547
  const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
8391
- const ki = (0, import_math21.bn)(IL).add(privateKey).mod(N).toBytes(32);
8548
+ const ki = (0, import_math23.bn)(IL).add(privateKey).mod(N).toBytes(32);
8392
8549
  return new HDWallet({
8393
8550
  privateKey: ki,
8394
8551
  chainCode: IR,
@@ -8434,7 +8591,7 @@ var HDWallet = class {
8434
8591
  const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
8435
8592
  const depth = (0, import_utils34.hexlify)(Uint8Array.from([this.depth]));
8436
8593
  const parentFingerprint = this.parentFingerprint;
8437
- const index = (0, import_math21.toHex)(this.index, 4);
8594
+ const index = (0, import_math23.toHex)(this.index, 4);
8438
8595
  const chainCode = this.chainCode;
8439
8596
  const key = this.privateKey != null && !isPublic ? (0, import_utils34.concat)(["0x00", this.privateKey]) : this.publicKey;
8440
8597
  const extendedKey = (0, import_utils34.arrayify)((0, import_utils34.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
@@ -8454,7 +8611,7 @@ var HDWallet = class {
8454
8611
  });
8455
8612
  }
8456
8613
  static fromExtendedKey(extendedKey) {
8457
- const decoded = (0, import_ethers3.toBeHex)((0, import_ethers3.decodeBase58)(extendedKey));
8614
+ const decoded = (0, import_ethers2.toBeHex)((0, import_ethers2.decodeBase58)(extendedKey));
8458
8615
  const bytes = (0, import_utils34.arrayify)(decoded);
8459
8616
  const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
8460
8617
  if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
@@ -9070,7 +9227,7 @@ var StorageAbstract = class {
9070
9227
  var import_abi_coder7 = require("@fuel-ts/abi-coder");
9071
9228
  var import_address10 = require("@fuel-ts/address");
9072
9229
  var import_errors25 = require("@fuel-ts/errors");
9073
- var import_transactions21 = require("@fuel-ts/transactions");
9230
+ var import_transactions22 = require("@fuel-ts/transactions");
9074
9231
  var import_utils36 = require("@fuel-ts/utils");
9075
9232
 
9076
9233
  // src/predicate/utils/getPredicateRoot.ts
@@ -9130,7 +9287,7 @@ var Predicate = class extends Account {
9130
9287
  const request = transactionRequestify(transactionRequestLike);
9131
9288
  const { policies } = BaseTransactionRequest.getPolicyMeta(request);
9132
9289
  request.inputs?.forEach((input) => {
9133
- if (input.type === import_transactions21.InputType.Coin && (0, import_utils36.hexlify)(input.owner) === this.address.toB256()) {
9290
+ if (input.type === import_transactions22.InputType.Coin && (0, import_utils36.hexlify)(input.owner) === this.address.toB256()) {
9134
9291
  input.predicate = (0, import_utils36.hexlify)(this.bytes);
9135
9292
  input.predicateData = (0, import_utils36.hexlify)(this.getPredicateData(policies.length));
9136
9293
  }
@@ -9162,9 +9319,9 @@ var Predicate = class extends Account {
9162
9319
  return new Uint8Array();
9163
9320
  }
9164
9321
  const mainFn = this.interface?.functions.main;
9165
- const paddedCode = new import_transactions21.ByteArrayCoder(this.bytes.length).encode(this.bytes);
9322
+ const paddedCode = new import_transactions22.ByteArrayCoder(this.bytes.length).encode(this.bytes);
9166
9323
  const VM_TX_MEMORY = (0, import_abi_coder7.calculateVmTxMemory)({
9167
- maxInputs: this.provider.getChain().consensusParameters.maxInputs.toNumber()
9324
+ maxInputs: this.provider.getChain().consensusParameters.txParameters.maxInputs.toNumber()
9168
9325
  });
9169
9326
  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
9327
  return mainFn?.encodeArguments(this.predicateData, OFFSET) || new Uint8Array();
@@ -9982,7 +10139,7 @@ __publicField(Fuel, "defaultConfig", {});
9982
10139
  calculateGasFee,
9983
10140
  calculateMetadataGasForTxCreate,
9984
10141
  calculateMetadataGasForTxScript,
9985
- calculateTransactionFee,
10142
+ calculateTXFeeForSummary,
9986
10143
  coinQuantityfy,
9987
10144
  deferPromise,
9988
10145
  dispatchFuelConnectorEvent,
@@ -10042,6 +10199,8 @@ __publicField(Fuel, "defaultConfig", {});
10042
10199
  isTypeCreate,
10043
10200
  isTypeMint,
10044
10201
  isTypeScript,
10202
+ isTypeUpgrade,
10203
+ isTypeUpload,
10045
10204
  normalizeJSON,
10046
10205
  outputify,
10047
10206
  processGqlReceipt,