Skip to content

Commit

Permalink
Revert "🐛 fix: Add confirm signature race condition handler (#1144)"
Browse files Browse the repository at this point in the history
This reverts commit 5e42b68.
  • Loading branch information
drptbl committed Jun 20, 2024
1 parent 9e8ac48 commit 894106e
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions wallets/metamask/src/pages/NotificationPage/page.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { Page } from '@playwright/test'
import { getNotificationPageAndWaitForLoad } from '../../utils/getNotificationPageAndWaitForLoad'
import { waitFor } from '../../utils/waitFor'
import {
type GasSetting,
approvePermission,
Expand Down Expand Up @@ -30,22 +31,17 @@ export class NotificationPage {
await connectToDapp(notificationPage, accounts)
}

// TODO: Revisit this logic in the future to see if we can increase the performance by utilizing `Promise.race`.
private async beforeMessageSignature(extensionId: string) {
const notificationPage = await getNotificationPageAndWaitForLoad(this.page.context(), extensionId)
const scrollDownButton = notificationPage.locator(Selectors.SignaturePage.structuredMessage.scrollDownButton)

let isScrollButtonVisible = false

const scrollButtonPromise = scrollDownButton
.waitFor({ state: 'visible' })
.then(async () => {
isScrollButtonVisible = true
await scrollDownButton.click()
return true
})
.catch(() => false)

await Promise.race([scrollButtonPromise, notificationPage.waitForLoadState('load').then(() => false)])
// TODO: Make this configurable.
// Most of the time, this function will be used to sign structured messages, so we check for the scroll button first.
const isScrollButtonVisible = await waitFor(
() => notificationPage.locator(Selectors.SignaturePage.structuredMessage.scrollDownButton).isVisible(),
1_500,
false
)

return {
notificationPage,
Expand Down

0 comments on commit 894106e

Please sign in to comment.