@metamask-previews/transaction-controller 55.0.2-preview-a578ea2 → 55.0.2-preview-780c8df

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.
package/CHANGELOG.md CHANGED
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ### Added
11
+
12
+ - Add automatic update `txParams` gas values when controller `updateTransactionGasFees` method is called with `userFeeLevel` ([#5800](https://github.com/MetaMask/core/pull/5800))
13
+
10
14
  ## [55.0.2]
11
15
 
12
16
  ### Fixed
@@ -741,13 +741,33 @@ class TransactionController extends base_controller_1.BaseController {
741
741
  throw new Error(`Cannot update transaction as no transaction metadata found`);
742
742
  }
743
743
  (0, utils_2.validateIfTransactionUnapproved)(transactionMeta, 'updateTransactionGasFees');
744
+ // Initialize gas fee values that will be used in the transaction update
745
+ let finalGasPrice = gasPrice;
746
+ let finalMaxFeePerGas = maxFeePerGas;
747
+ let finalMaxPriorityFeePerGas = maxPriorityFeePerGas;
748
+ const isTransactionGasFeeEstimatesExists = transactionMeta.gasFeeEstimates;
749
+ const isAutomaticGasFeeUpdateEnabled = __classPrivateFieldGet(this, _TransactionController_isAutomaticGasFeeUpdateEnabled, "f").call(this, transactionMeta);
750
+ const shouldUpdateTxParamsGasFees = isTransactionGasFeeEstimatesExists &&
751
+ isAutomaticGasFeeUpdateEnabled &&
752
+ userFeeLevel;
753
+ if (shouldUpdateTxParamsGasFees) {
754
+ (0, GasFeePoller_1.applyTransactionGasEstimatesToTransaction)({
755
+ txMeta: transactionMeta,
756
+ userFeeLevel: userFeeLevel,
757
+ });
758
+ // Ignore the provided gas fee values when userFeeLevel is specified because
759
+ // the gas fee values are updated directly in transactionMeta in the applyTransactionGasEstimatesToTransaction
760
+ finalGasPrice = undefined;
761
+ finalMaxFeePerGas = undefined;
762
+ finalMaxPriorityFeePerGas = undefined;
763
+ }
744
764
  let transactionGasFees = {
745
765
  txParams: {
746
766
  gas,
747
767
  gasLimit,
748
- gasPrice,
749
- maxPriorityFeePerGas,
750
- maxFeePerGas,
768
+ gasPrice: finalGasPrice,
769
+ maxPriorityFeePerGas: finalMaxPriorityFeePerGas,
770
+ maxFeePerGas: finalMaxFeePerGas,
751
771
  },
752
772
  defaultGasEstimates,
753
773
  estimateUsed,
@@ -2041,7 +2061,7 @@ async function _TransactionController_approveTransaction(transactionId, traceCon
2041
2061
  (0, logger_1.projectLogger)('Updated simulation data', transactionId, simulationData);
2042
2062
  }, _TransactionController_onGasFeePollerTransactionUpdate = function _TransactionController_onGasFeePollerTransactionUpdate({ transactionId, gasFeeEstimates, gasFeeEstimatesLoaded, layer1GasFee, }) {
2043
2063
  __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updateTransactionInternal).call(this, { transactionId, skipHistory: true }, (txMeta) => {
2044
- (0, GasFeePoller_1.updateTransactionGasFees)({
2064
+ (0, GasFeePoller_1.applyGasFeeEstimatesToTransaction)({
2045
2065
  txMeta,
2046
2066
  gasFeeEstimates,
2047
2067
  gasFeeEstimatesLoaded,