Skip to content

Commit

Permalink
Applied reqested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
filipsekulic committed Dec 12, 2022
1 parent 504ce81 commit 06e642f
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 5 deletions.
8 changes: 4 additions & 4 deletions app/scripts/controllers/transactions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -772,7 +772,7 @@ export default class TransactionController extends EventEmitter {
* @returns {txMeta}
*/
async addUnapprovedTransaction(
method,
txMethodType,
txParams,
origin,
transactionType,
Expand Down Expand Up @@ -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;
Expand Down
26 changes: 26 additions & 0 deletions app/scripts/controllers/transactions/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down
2 changes: 1 addition & 1 deletion app/scripts/metamask-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 06e642f

Please sign in to comment.