-
-
Notifications
You must be signed in to change notification settings - Fork 195
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ feat(metamask): Add support for transactions (#997)
- Loading branch information
1 parent
d6af806
commit 2cd47a9
Showing
8 changed files
with
92 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export * from './connectToDapp' | ||
export * from './signSimpleMessage' | ||
export * from './signStructuredMessage' | ||
export * from './transaction' | ||
export * from './network' |
15 changes: 15 additions & 0 deletions
15
wallets/metamask/src/pages/NotificationPage/actions/transaction.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import type { Page } from '@playwright/test' | ||
import Selectors from '../selectors' | ||
|
||
const confirmTransaction = async (notificationPage: Page) => { | ||
await notificationPage.locator(Selectors.TransactionPage.confirmButton).click() | ||
} | ||
|
||
const rejectTransaction = async (notificationPage: Page) => { | ||
await notificationPage.locator(Selectors.TransactionPage.rejectButton).click() | ||
} | ||
|
||
export const transaction = { | ||
confirm: confirmTransaction, | ||
reject: rejectTransaction | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 3 additions & 1 deletion
4
wallets/metamask/src/pages/NotificationPage/selectors/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
import NetworkPage from './networkPage' | ||
import SignaturePage from './signaturePage' | ||
import TransactionPage from './transactionPage' | ||
|
||
export default { | ||
SignaturePage, | ||
NetworkPage | ||
NetworkPage, | ||
TransactionPage | ||
} |
6 changes: 6 additions & 0 deletions
6
wallets/metamask/src/pages/NotificationPage/selectors/transactionPage.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { createDataTestSelector } from '../../../utils/selectors/createDataTestSelector' | ||
|
||
export default { | ||
confirmButton: `.page-container__footer ${createDataTestSelector('page-container-footer-next')}`, | ||
rejectButton: `.page-container__footer ${createDataTestSelector('page-container-footer-cancel')}` | ||
} |
19 changes: 19 additions & 0 deletions
19
wallets/metamask/test/e2e/metamask/confirmTransaction.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { testWithMetaMask } from '../testWithMetaMask' | ||
|
||
const test = testWithMetaMask | ||
|
||
const { expect } = test | ||
|
||
test('should confirm contract deployment', async ({ page, metamask }) => { | ||
await page.locator('#addEthereumChain').click() | ||
|
||
await metamask.approveNewNetwork() | ||
await metamask.approveSwitchNetwork() | ||
|
||
await expect(page.locator('#tokenAddresses')).toBeEmpty() | ||
await page.locator('#createToken').click() | ||
|
||
await metamask.confirmTransaction() | ||
|
||
await expect(page.locator('#tokenAddresses')).toContainText(/^0x/) | ||
}) |
19 changes: 19 additions & 0 deletions
19
wallets/metamask/test/e2e/metamask/rejectTransaction.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { testWithMetaMask } from '../testWithMetaMask' | ||
|
||
const test = testWithMetaMask | ||
|
||
const { expect } = test | ||
|
||
test('should reject contract deployment', async ({ page, metamask }) => { | ||
await page.locator('#addEthereumChain').click() | ||
|
||
await metamask.approveNewNetwork() | ||
await metamask.approveSwitchNetwork() | ||
|
||
await expect(page.locator('#tokenAddresses')).toBeEmpty() | ||
await page.locator('#createToken').click() | ||
|
||
await metamask.rejectTransaction() | ||
|
||
await expect(page.locator('#tokenAddresses')).toHaveText('Creation Failed') | ||
}) |