From 7eaeff731cb864073894d60ca9d8aa90fb1e7521 Mon Sep 17 00:00:00 2001 From: Vinicius Stevam <45455812+vinistevam@users.noreply.github.com> Date: Fri, 15 Nov 2024 16:48:14 +0000 Subject: [PATCH] fix: Fix race condition validating ERC20 transfer (blockaid) (#28487) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## **Description** Fixed race condition when validating ERC20 transfer and enabled ERC20 transfer blockaid e2e. [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/28487?quickstart=1) ## **Related issues** Fixes: https://github.com/MetaMask/metamask-extension/issues/28434 ## **Manual testing steps** 1. Go to this the test dapp 2. Click and reject (fast ) all types of requests in the section: PPOM - Malicious Transactions and Signatures 3. Should not get stuck in the loader ## **Screenshots/Recordings** ### **Before** [all PPOM signatures.webm](https://github.com/user-attachments/assets/b59a965a-f5e9-44e6-93a5-9058cd164933) ### **After** ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I’ve included tests if applicable - [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. --- app/scripts/lib/ppom/security-alerts-api.ts | 2 +- app/scripts/metamask-controller.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/scripts/lib/ppom/security-alerts-api.ts b/app/scripts/lib/ppom/security-alerts-api.ts index 258526f1b7c4..d0b6bc812b1a 100644 --- a/app/scripts/lib/ppom/security-alerts-api.ts +++ b/app/scripts/lib/ppom/security-alerts-api.ts @@ -51,7 +51,7 @@ async function request(endpoint: string, options?: RequestInit) { ); } - return response.json(); + return await response.json(); } function getUrl(endpoint: string) { diff --git a/app/scripts/metamask-controller.js b/app/scripts/metamask-controller.js index a275c4d17e5a..1f0e72c67c12 100644 --- a/app/scripts/metamask-controller.js +++ b/app/scripts/metamask-controller.js @@ -5133,7 +5133,7 @@ export default class MetamaskController extends EventEmitter { securityAlertId, securityAlertResponse, ) { - updateSecurityAlertResponse({ + await updateSecurityAlertResponse({ appStateController: this.appStateController, method, securityAlertId,