diff --git a/wallets/metamask/src/metamask.ts b/wallets/metamask/src/metamask.ts index f0b70eddf..e4783970f 100644 --- a/wallets/metamask/src/metamask.ts +++ b/wallets/metamask/src/metamask.ts @@ -47,13 +47,13 @@ export class MetaMask { if (!this.extensionId) { throw NO_EXTENSION_ID_ERROR } - await this.notificationPage.signPersonalMessage(this.extensionId) + await this.notificationPage.signSimpleMessage(this.extensionId) } async rejectSignature() { if (!this.extensionId) { throw NO_EXTENSION_ID_ERROR } - await this.notificationPage.rejectPersonalMessage(this.extensionId) + await this.notificationPage.rejectSimpleMessage(this.extensionId) } } diff --git a/wallets/metamask/src/pages/NotificationPage/actions/index.ts b/wallets/metamask/src/pages/NotificationPage/actions/index.ts index 32887b91c..0045b804d 100644 --- a/wallets/metamask/src/pages/NotificationPage/actions/index.ts +++ b/wallets/metamask/src/pages/NotificationPage/actions/index.ts @@ -1,2 +1,2 @@ export * from './connectToDapp' -export * from './personalSign' +export * from './signSimpleMessage' diff --git a/wallets/metamask/src/pages/NotificationPage/actions/personalSign.ts b/wallets/metamask/src/pages/NotificationPage/actions/signSimpleMessage.ts similarity index 61% rename from wallets/metamask/src/pages/NotificationPage/actions/personalSign.ts rename to wallets/metamask/src/pages/NotificationPage/actions/signSimpleMessage.ts index c865a1d5d..734957595 100644 --- a/wallets/metamask/src/pages/NotificationPage/actions/personalSign.ts +++ b/wallets/metamask/src/pages/NotificationPage/actions/signSimpleMessage.ts @@ -2,19 +2,22 @@ import type { BrowserContext } from '@playwright/test' import { getNotificationPage } from '../../../utils/getNotificationPage' import Selectors from '../selectors' -const signPersonalMessage = async (context: BrowserContext, extensionId: string) => { +const signMessage = async (context: BrowserContext, extensionId: string) => { const notificationPage = await getNotificationPage(context, extensionId) await notificationPage.locator(Selectors.SignaturePage.signButton).click() } -const rejectPersonalMessage = async (context: BrowserContext, extensionId: string) => { +const rejectMessage = async (context: BrowserContext, extensionId: string) => { const notificationPage = await getNotificationPage(context, extensionId) await notificationPage.locator(Selectors.SignaturePage.rejectButton).click() } -export const personalSign = { - sign: signPersonalMessage, - reject: rejectPersonalMessage +// Used for: +// - `personal_sign` +// - `eth_signTypedData` +export const signSimpleMessage = { + sign: signMessage, + reject: rejectMessage } diff --git a/wallets/metamask/src/pages/NotificationPage/page.ts b/wallets/metamask/src/pages/NotificationPage/page.ts index 2952b0a38..97dee01f5 100644 --- a/wallets/metamask/src/pages/NotificationPage/page.ts +++ b/wallets/metamask/src/pages/NotificationPage/page.ts @@ -1,5 +1,5 @@ import type { Page } from '@playwright/test' -import { connectToDapp, personalSign } from './actions' +import { connectToDapp, signSimpleMessage } from './actions' export class NotificationPage { readonly page: Page @@ -12,11 +12,11 @@ export class NotificationPage { await connectToDapp(this.page.context(), extensionId) } - async signPersonalMessage(extensionId: string) { - await personalSign.sign(this.page.context(), extensionId) + async signSimpleMessage(extensionId: string) { + await signSimpleMessage.sign(this.page.context(), extensionId) } - async rejectPersonalMessage(extensionId: string) { - await personalSign.reject(this.page.context(), extensionId) + async rejectSimpleMessage(extensionId: string) { + await signSimpleMessage.reject(this.page.context(), extensionId) } } diff --git a/wallets/metamask/test/e2e/metamask/confirmSignature.spec.ts b/wallets/metamask/test/e2e/metamask/confirmSignature.spec.ts index 8066a0c97..653bf9112 100644 --- a/wallets/metamask/test/e2e/metamask/confirmSignature.spec.ts +++ b/wallets/metamask/test/e2e/metamask/confirmSignature.spec.ts @@ -29,3 +29,21 @@ test('should confirm `personal_sign`', async ({ context, metamaskPage, page, ext '0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266' ) }) + +test('should confirm `eth_signTypedData`', async ({ context, metamaskPage, page, extensionId }) => { + const metamask = new MetaMask(context, metamaskPage, connectedSetup.walletPassword, extensionId) + + await page.goto('https://metamask.github.io/test-dapp/') + + await page.locator('#signTypedData').click() + + await metamask.confirmSignature() + + await expect(page.locator('#signTypedDataResult')).toHaveText( + '0xd75eece0d337f4e425f87bd112c849561956afe4f154cdd07d1d4cba7a979b481ba6ceede5c0eb9daa66bec4eea6e7ecfee5496274ef2a93b69abd97531519b21c' + ) + + await page.locator('#signTypedDataVerify').click() + + await expect(page.locator('#signTypedDataVerifyResult')).toHaveText('0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266') +}) diff --git a/wallets/metamask/test/e2e/metamask/rejectSignature.spec.ts b/wallets/metamask/test/e2e/metamask/rejectSignature.spec.ts index 7ffcb3280..5d1d4d8bf 100644 --- a/wallets/metamask/test/e2e/metamask/rejectSignature.spec.ts +++ b/wallets/metamask/test/e2e/metamask/rejectSignature.spec.ts @@ -21,3 +21,17 @@ test('should reject `personal_sign`', async ({ context, metamaskPage, page, exte ) await expect(page.locator('#personalSignResult')).toHaveText('') }) + +test('should reject `eth_signTypedData`', async ({ context, metamaskPage, page, extensionId }) => { + const metamask = new MetaMask(context, metamaskPage, connectedSetup.walletPassword, extensionId) + + await page.goto('https://metamask.github.io/test-dapp/') + + await page.locator('#signTypedData').click() + + await metamask.rejectSignature() + + await expect(page.locator('#signTypedDataResult')).toHaveText( + 'Error: MetaMask Message Signature: User denied message signature.' + ) +})