@metamask-previews/transaction-controller 62.20.0-preview-384cfdfef → 62.20.0-preview-15dd7d63f

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,9 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
- ### Added
10
+ ### Changed
11
11
 
12
- - Add `perpsAcrossDeposit` and `predictAcrossDeposit` transaction types for Across MetaMask Pay submissions ([#7886](https://github.com/MetaMask/core/pull/7886))
12
+ - Add extra parameters in types and change `addTransaction` behavior ([#8052](https://github.com/MetaMask/core/pull/8052))
13
+ - Add optional `excludeNativeTokenForFee` in `TransactionMeta` type.
14
+ - Add optional `actionId` and optional `excludeNativeTokenForFee` in `TransactionBatchRequest` type.
15
+ - Add optional `excludeNativeTokenForFee` to `AddTransactionOptions` type.
16
+ - Changed `isGasFeeTokenIgnoredIfBalance` to be false if `excludeNativeTokenForFee` is passed in `addTransaction`.
13
17
 
14
18
  ## [62.20.0]
15
19
 
@@ -384,7 +384,7 @@ class TransactionController extends base_controller_1.BaseController {
384
384
  */
385
385
  async addTransaction(txParams, options) {
386
386
  (0, logger_1.projectLogger)('Adding transaction', txParams, options);
387
- const { actionId, assetsFiatValues, batchId, deviceConfirmedOn, disableGasBuffer, gasFeeToken, isGasFeeIncluded, isGasFeeSponsored, isStateOnly, method, nestedTransactions, networkClientId, origin, publishHook, requestId, requiredAssets, requireApproval, securityAlertResponse, skipInitialGasEstimate, swaps = {}, traceContext, type, } = options;
387
+ const { actionId, assetsFiatValues, batchId, deviceConfirmedOn, disableGasBuffer, gasFeeToken, excludeNativeTokenForFee, isGasFeeIncluded, isGasFeeSponsored, isStateOnly, method, nestedTransactions, networkClientId, origin, publishHook, requestId, requiredAssets, requireApproval, securityAlertResponse, skipInitialGasEstimate, swaps = {}, traceContext, type, } = options;
388
388
  // eslint-disable-next-line no-param-reassign
389
389
  txParams = (0, utils_2.normalizeTransactionParams)(txParams);
390
390
  if (!__classPrivateFieldGet(this, _TransactionController_multichainTrackingHelper, "f").has(networkClientId)) {
@@ -422,6 +422,10 @@ class TransactionController extends base_controller_1.BaseController {
422
422
  const dappSuggestedGasFees = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_generateDappSuggestedGasFees).call(this, txParams, origin);
423
423
  const transactionType = type ?? (await (0, transaction_type_1.determineTransactionType)(txParams, ethQuery)).type;
424
424
  const existingTransactionMeta = __classPrivateFieldGet(this, _TransactionController_instances, "m", _TransactionController_getTransactionWithActionId).call(this, actionId);
425
+ // Original behavior was that this was set to 'true' whenever a gasFeeToken was passed.
426
+ // 'excludeNativeTokenForFee' optionnally overrides this behavior to prevent native token from
427
+ // being used when another gasFeeToken is set.
428
+ const isGasFeeTokenIgnoredIfBalance = Boolean(gasFeeToken) && !excludeNativeTokenForFee;
425
429
  // If a request to add a transaction with the same actionId is submitted again, a new transaction will not be created for it.
426
430
  let addedTransactionMeta = existingTransactionMeta
427
431
  ? (0, lodash_1.cloneDeep)(existingTransactionMeta)
@@ -435,9 +439,13 @@ class TransactionController extends base_controller_1.BaseController {
435
439
  deviceConfirmedOn,
436
440
  disableGasBuffer,
437
441
  id: (0, uuid_1.v1)(),
438
- isGasFeeTokenIgnoredIfBalance: Boolean(gasFeeToken),
442
+ isGasFeeTokenIgnoredIfBalance,
439
443
  isGasFeeIncluded,
440
444
  isGasFeeSponsored,
445
+ // To avoid the property to be set as undefined.
446
+ ...(excludeNativeTokenForFee === undefined
447
+ ? {}
448
+ : { excludeNativeTokenForFee }),
441
449
  isFirstTimeInteraction: undefined,
442
450
  isStateOnly,
443
451
  nestedTransactions,