@metamask/transaction-controller 60.1.0 → 60.2.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.
package/CHANGELOG.md CHANGED
@@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [60.2.0]
11
+
12
+ ### Added
13
+
14
+ - Add `isGasFeeIncluded` to `TransactionMeta`, `TransactionBatchRequest` and `addTransaction` options so the client can signal that MetaMask is compensated for the gas fee by the transaction ([#6428](https://github.com/MetaMask/core/pull/6428))
15
+ - Add optional `gasUsed` property to `TransactionMeta`, returned by the transaction simulation result ([#6410](https://github.com/MetaMask/core/pull/6410))
16
+
10
17
  ## [60.1.0]
11
18
 
12
19
  ### Added
@@ -1782,7 +1789,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1782
1789
 
1783
1790
  All changes listed after this point were applied to this package following the monorepo conversion.
1784
1791
 
1785
- [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@60.1.0...HEAD
1792
+ [Unreleased]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@60.2.0...HEAD
1793
+ [60.2.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@60.1.0...@metamask/transaction-controller@60.2.0
1786
1794
  [60.1.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@60.0.0...@metamask/transaction-controller@60.1.0
1787
1795
  [60.0.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@59.2.0...@metamask/transaction-controller@60.0.0
1788
1796
  [59.2.0]: https://github.com/MetaMask/core/compare/@metamask/transaction-controller@59.1.0...@metamask/transaction-controller@59.2.0
@@ -367,6 +367,7 @@ class TransactionController extends base_controller_1.BaseController {
367
367
  * @param options.batchId - A custom ID for the batch this transaction belongs to.
368
368
  * @param options.deviceConfirmedOn - An enum to indicate what device confirmed the transaction.
369
369
  * @param options.disableGasBuffer - Whether to disable the gas estimation buffer.
370
+ * @param options.isGasFeeIncluded - Whether MetaMask will be compensated for the gas fee by the transaction.
370
371
  * @param options.method - RPC method that requested the transaction.
371
372
  * @param options.nestedTransactions - Params for any nested transactions encoded in the data.
372
373
  * @param options.origin - The origin of the transaction request, such as a dApp hostname.
@@ -384,7 +385,7 @@ class TransactionController extends base_controller_1.BaseController {
384
385
  */
385
386
  async addTransaction(txParams, options) {
386
387
  (0, logger_1.projectLogger)('Adding transaction', txParams, options);
387
- const { actionId, assetsFiatValues, batchId, deviceConfirmedOn, disableGasBuffer, method, nestedTransactions, networkClientId, origin, publishHook, requireApproval, securityAlertResponse, sendFlowHistory, swaps = {}, traceContext, type, } = options;
388
+ const { actionId, assetsFiatValues, batchId, deviceConfirmedOn, disableGasBuffer, isGasFeeIncluded, method, nestedTransactions, networkClientId, origin, publishHook, requireApproval, securityAlertResponse, sendFlowHistory, swaps = {}, traceContext, type, } = options;
388
389
  txParams = (0, utils_2.normalizeTransactionParams)(txParams);
389
390
  if (!__classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").has(networkClientId)) {
390
391
  throw new Error(`Network client not found - ${networkClientId}`);
@@ -436,6 +437,7 @@ class TransactionController extends base_controller_1.BaseController {
436
437
  deviceConfirmedOn,
437
438
  disableGasBuffer,
438
439
  id: (0, uuid_1.v1)(),
440
+ isGasFeeIncluded,
439
441
  isFirstTimeInteraction: undefined,
440
442
  nestedTransactions,
441
443
  networkClientId,
@@ -2120,11 +2122,12 @@ async function _TransactionController_approveTransaction(transactionId, traceCon
2120
2122
  },
2121
2123
  tokenBalanceChanges: [],
2122
2124
  };
2125
+ let gasUsed;
2123
2126
  let gasFeeTokens = [];
2124
2127
  let isGasFeeSponsored = false;
2125
2128
  const isBalanceChangesSkipped = __classPrivateFieldGet(this, _TransactionController_skipSimulationTransactionIds, "f").has(transactionId);
2126
2129
  if (__classPrivateFieldGet(this, _TransactionController_isSimulationEnabled, "f").call(this) && !isBalanceChangesSkipped) {
2127
- simulationData = await __classPrivateFieldGet(this, _TransactionController_trace, "f").call(this, { name: 'Simulate', parentContext: traceContext }, () => (0, balance_changes_1.getBalanceChanges)({
2130
+ const balanceChangesResult = await __classPrivateFieldGet(this, _TransactionController_trace, "f").call(this, { name: 'Simulate', parentContext: traceContext }, () => (0, balance_changes_1.getBalanceChanges)({
2128
2131
  blockTime,
2129
2132
  chainId,
2130
2133
  ethQuery: __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getEthQuery).call(this, { networkClientId }),
@@ -2132,6 +2135,8 @@ async function _TransactionController_approveTransaction(transactionId, traceCon
2132
2135
  nestedTransactions,
2133
2136
  txParams,
2134
2137
  }));
2138
+ simulationData = balanceChangesResult.simulationData;
2139
+ gasUsed = balanceChangesResult.gasUsed;
2135
2140
  if (blockTime &&
2136
2141
  prevSimulationData &&
2137
2142
  (0, ResimulateHelper_1.hasSimulationDataChanged)(prevSimulationData, simulationData)) {
@@ -2164,6 +2169,7 @@ async function _TransactionController_approveTransaction(transactionId, traceCon
2164
2169
  }, (txMeta) => {
2165
2170
  txMeta.gasFeeTokens = gasFeeTokens;
2166
2171
  txMeta.isGasFeeSponsored = isGasFeeSponsored;
2172
+ txMeta.gasUsed = gasUsed;
2167
2173
  if (!isBalanceChangesSkipped) {
2168
2174
  txMeta.simulationData = simulationData;
2169
2175
  }