diff --git a/app/scripts/controllers/transactions/index.js b/app/scripts/controllers/transactions/index.js index 2a9759c0f221..d8fe676aab75 100644 --- a/app/scripts/controllers/transactions/index.js +++ b/app/scripts/controllers/transactions/index.js @@ -763,7 +763,7 @@ export default class TransactionController extends EventEmitter { * actionId is fix used for making this action idempotent to deal with scenario when * action is invoked multiple times with same parameters in MV3 due to service worker re-activation. * - * @param method + * @param txMethodType * @param txParams * @param origin * @param transactionType @@ -772,7 +772,7 @@ export default class TransactionController extends EventEmitter { * @returns {txMeta} */ async addUnapprovedTransaction( - method, + txMethodType, txParams, origin, transactionType, @@ -852,10 +852,10 @@ export default class TransactionController extends EventEmitter { ? addHexPrefix(txMeta.txParams.value) : '0x0'; - if (method) { + if (txMethodType && this.securityProviderRequest) { const flagAsDangerous = await this.securityProviderRequest( txMeta, - method, + txMethodType, ); txMeta.flagAsDangerous = flagAsDangerous; diff --git a/app/scripts/controllers/transactions/index.test.js b/app/scripts/controllers/transactions/index.test.js index 28f44ab3ddae..c2bcfe2b8fa3 100644 --- a/app/scripts/controllers/transactions/index.test.js +++ b/app/scripts/controllers/transactions/index.test.js @@ -1320,6 +1320,32 @@ describe('Transaction Controller', function () { txController.txStateManager.getTransactions().length; assert.equal(transactionCount1 + 1, transactionCount2); }); + + it('should add multiple transactions when called with different actionId and txMethodType defined', async function () { + const txMeta = await txController.addUnapprovedTransaction( + 'eth_sendTransaction', + { + from: selectedAddress, + to: recipientAddress, + }, + ); + await txController.approveTransaction(txMeta.id); + await txController.createSpeedUpTransaction( + txMeta.id, + {}, + { actionId: 12345 }, + ); + const transactionCount1 = + txController.txStateManager.getTransactions().length; + await txController.createSpeedUpTransaction( + txMeta.id, + {}, + { actionId: 11111 }, + ); + const transactionCount2 = + txController.txStateManager.getTransactions().length; + assert.equal(transactionCount1 + 1, transactionCount2); + }); }); describe('#signTransaction', function () { diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index 6deaaa2f8327..e5e98824038a 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -4574,7 +4574,7 @@ export default class MetamaskController extends EventEmitter { chainId, currentLocale, ); - return await flagAsDangerous; + return flagAsDangerous; } catch (err) { log.error(err.message); throw err;