@metamask/transaction-controller 52.0.0 → 52.1.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.
Files changed (38) hide show
  1. package/CHANGELOG.md +14 -1
  2. package/dist/TransactionController.cjs +24 -12
  3. package/dist/TransactionController.cjs.map +1 -1
  4. package/dist/TransactionController.d.cts +3 -0
  5. package/dist/TransactionController.d.cts.map +1 -1
  6. package/dist/TransactionController.d.mts +3 -0
  7. package/dist/TransactionController.d.mts.map +1 -1
  8. package/dist/TransactionController.mjs +25 -13
  9. package/dist/TransactionController.mjs.map +1 -1
  10. package/dist/helpers/GasFeePoller.cjs +73 -1
  11. package/dist/helpers/GasFeePoller.cjs.map +1 -1
  12. package/dist/helpers/GasFeePoller.d.cts +20 -2
  13. package/dist/helpers/GasFeePoller.d.cts.map +1 -1
  14. package/dist/helpers/GasFeePoller.d.mts +20 -2
  15. package/dist/helpers/GasFeePoller.d.mts.map +1 -1
  16. package/dist/helpers/GasFeePoller.mjs +72 -1
  17. package/dist/helpers/GasFeePoller.mjs.map +1 -1
  18. package/dist/utils/feature-flags.cjs +2 -2
  19. package/dist/utils/feature-flags.cjs.map +1 -1
  20. package/dist/utils/feature-flags.d.cts +2 -2
  21. package/dist/utils/feature-flags.d.mts +2 -2
  22. package/dist/utils/feature-flags.mjs +2 -2
  23. package/dist/utils/feature-flags.mjs.map +1 -1
  24. package/dist/utils/gas.cjs +108 -8
  25. package/dist/utils/gas.cjs.map +1 -1
  26. package/dist/utils/gas.d.cts +16 -5
  27. package/dist/utils/gas.d.cts.map +1 -1
  28. package/dist/utils/gas.d.mts +16 -5
  29. package/dist/utils/gas.d.mts.map +1 -1
  30. package/dist/utils/gas.mjs +108 -8
  31. package/dist/utils/gas.mjs.map +1 -1
  32. package/dist/utils/simulation-api.cjs.map +1 -1
  33. package/dist/utils/simulation-api.d.cts +9 -5
  34. package/dist/utils/simulation-api.d.cts.map +1 -1
  35. package/dist/utils/simulation-api.d.mts +9 -5
  36. package/dist/utils/simulation-api.d.mts.map +1 -1
  37. package/dist/utils/simulation-api.mjs.map +1 -1
  38. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -7,6 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [52.1.0]
11
+
12
+ ### Added
13
+
14
+ - Add `enableTxParamsGasFeeUpdates` constructor option ([5394](https://github.com/MetaMask/core/pull/5394))
15
+ - If not set it will default to `false`.
16
+ - Automatically update gas fee properties in `txParams` when the `gasFeeEstimates` are updated via polling.
17
+
18
+ ### Fixed
19
+
20
+ - Fix gas estimation for type 4 transactions ([#5519](https://github.com/MetaMask/core/pull/5519))
21
+
10
22
  ## [52.0.0]
11
23
 
12
24
  ### Changed
@@ -1397,7 +1409,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1397
1409
 
1398
1410
  All changes listed after this point were applied to this package following the monorepo conversion.
1399
1411
 
1400
- [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@52.0.0...HEAD
1412
+ [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@52.1.0...HEAD
1413
+ [52.1.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@52.0.0...@metamask/transaction-controller@52.1.0
1401
1414
  [52.0.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@51.0.0...@metamask/transaction-controller@52.0.0
1402
1415
  [51.0.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@50.0.0...@metamask/transaction-controller@51.0.0
1403
1416
  [50.0.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@49.0.0...@metamask/transaction-controller@50.0.0
@@ -156,7 +156,7 @@ class TransactionController extends base_controller_1.BaseController {
156
156
  * @param options - The controller options.
157
157
  */
158
158
  constructor(options) {
159
- const { disableHistory, disableSendFlowHistory, disableSwaps, getCurrentAccountEIP1559Compatibility, getCurrentNetworkEIP1559Compatibility, getExternalPendingTransactions, getGasFeeEstimates, getNetworkClientRegistry, getNetworkState, getPermittedAccounts, getSavedGasFees, incomingTransactions = {}, isFirstTimeInteractionEnabled, isSimulationEnabled, messenger, pendingTransactions = {}, publicKeyEIP7702, securityProviderRequest, sign, state, testGasFeeFlows, trace, transactionHistoryLimit = 40, hooks, } = options;
159
+ const { disableHistory, disableSendFlowHistory, disableSwaps, enableTxParamsGasFeeUpdates, getCurrentAccountEIP1559Compatibility, getCurrentNetworkEIP1559Compatibility, getExternalPendingTransactions, getGasFeeEstimates, getNetworkClientRegistry, getNetworkState, getPermittedAccounts, getSavedGasFees, incomingTransactions = {}, isFirstTimeInteractionEnabled, isSimulationEnabled, messenger, pendingTransactions = {}, publicKeyEIP7702, securityProviderRequest, sign, state, testGasFeeFlows, trace, transactionHistoryLimit = 40, hooks, } = options;
160
160
  super({
161
161
  name: controllerName,
162
162
  metadata,
@@ -186,6 +186,7 @@ class TransactionController extends base_controller_1.BaseController {
186
186
  __classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").checkForPendingTransactionAndStartPolling();
187
187
  });
188
188
  this.messagingSystem = messenger;
189
+ this.isTxParamsGasFeeUpdatesEnabled = enableTxParamsGasFeeUpdates ?? false;
189
190
  this.getNetworkState = getNetworkState;
190
191
  this.isSendFlowHistoryDisabled = disableSendFlowHistory ?? false;
191
192
  this.isHistoryDisabled = disableHistory ?? false;
@@ -549,7 +550,12 @@ class TransactionController extends base_controller_1.BaseController {
549
550
  const ethQuery = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getEthQuery).call(this, {
550
551
  networkClientId,
551
552
  });
552
- const { estimatedGas, simulationFails } = await (0, gas_1.estimateGas)(transaction, ethQuery);
553
+ const { estimatedGas, simulationFails } = await (0, gas_1.estimateGas)({
554
+ chainId: __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getChainId).call(this, networkClientId),
555
+ ethQuery,
556
+ isSimulationEnabled: __classPrivateFieldGet(this, _TransactionController_isSimulationEnabled, "f").call(this),
557
+ txParams: transaction,
558
+ });
553
559
  return { gas: estimatedGas, simulationFails };
554
560
  }
555
561
  /**
@@ -564,7 +570,12 @@ class TransactionController extends base_controller_1.BaseController {
564
570
  const ethQuery = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getEthQuery).call(this, {
565
571
  networkClientId,
566
572
  });
567
- const { blockGasLimit, estimatedGas, simulationFails } = await (0, gas_1.estimateGas)(transaction, ethQuery);
573
+ const { blockGasLimit, estimatedGas, simulationFails } = await (0, gas_1.estimateGas)({
574
+ chainId: __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getChainId).call(this, networkClientId),
575
+ ethQuery,
576
+ isSimulationEnabled: __classPrivateFieldGet(this, _TransactionController_isSimulationEnabled, "f").call(this),
577
+ txParams: transaction,
578
+ });
568
579
  const gas = (0, gas_1.addGasBuffer)(estimatedGas, blockGasLimit, multiplier);
569
580
  return {
570
581
  gas,
@@ -2036,15 +2047,15 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_me
2036
2047
  (0, logger_1.projectLogger)('Updated simulation data', transactionId, simulationData);
2037
2048
  }, _TransactionController_onGasFeePollerTransactionUpdate = function _TransactionController_onGasFeePollerTransactionUpdate({ transactionId, gasFeeEstimates, gasFeeEstimatesLoaded, layer1GasFee, }) {
2038
2049
  __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_updateTransactionInternal).call(this, { transactionId, skipHistory: true }, (txMeta) => {
2039
- if (gasFeeEstimates) {
2040
- txMeta.gasFeeEstimates = gasFeeEstimates;
2041
- }
2042
- if (gasFeeEstimatesLoaded !== undefined) {
2043
- txMeta.gasFeeEstimatesLoaded = gasFeeEstimatesLoaded;
2044
- }
2045
- if (layer1GasFee) {
2046
- txMeta.layer1GasFee = layer1GasFee;
2047
- }
2050
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
2051
+ (0, GasFeePoller_1.updateTransactionGasFees)({
2052
+ txMeta,
2053
+ gasFeeEstimates,
2054
+ gasFeeEstimatesLoaded,
2055
+ getEIP1559Compatibility: this.getEIP1559Compatibility.bind(this),
2056
+ isTxParamsGasFeeUpdatesEnabled: this.isTxParamsGasFeeUpdatesEnabled,
2057
+ layer1GasFee,
2058
+ });
2048
2059
  });
2049
2060
  }, _TransactionController_getSelectedAccount = function _TransactionController_getSelectedAccount() {
2050
2061
  return this.messagingSystem.call('AccountsController:getSelectedAccount');
@@ -2087,6 +2098,7 @@ _TransactionController_internalEvents = new WeakMap(), _TransactionController_me
2087
2098
  chainId,
2088
2099
  ethQuery,
2089
2100
  isCustomNetwork,
2101
+ isSimulationEnabled: __classPrivateFieldGet(this, _TransactionController_isSimulationEnabled, "f").call(this),
2090
2102
  txMeta: transactionMeta,
2091
2103
  });
2092
2104
  }, _TransactionController_deleteTransaction = function _TransactionController_deleteTransaction(transactionId) {