-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: smart account creation (#2027)
Co-authored-by: Luka Isailovic <[email protected]>
- Loading branch information
1 parent
da854da
commit 75855d6
Showing
48 changed files
with
699 additions
and
214 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
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
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
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
63 changes: 63 additions & 0 deletions
63
apps/laboratory/tests/shared/fixtures/w3m-smart-account-fixture.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,63 @@ | ||
import { test as base } from '@playwright/test' | ||
import type { ModalFixture } from './w3m-fixture' | ||
import { DeviceRegistrationPage } from '../pages/DeviceRegistrationPage' | ||
import { Email } from '../utils/email' | ||
import { ModalWalletPage } from '../pages/ModalWalletPage' | ||
import { ModalWalletValidator } from '../validators/ModalWalletValidator' | ||
|
||
const mailsacApiKey = process.env['MAILSAC_API_KEY'] | ||
if (!mailsacApiKey) { | ||
throw new Error('MAILSAC_API_KEY is not set') | ||
} | ||
|
||
// Test Modal + Smart Account | ||
export const testModalSmartAccount = base.extend<ModalFixture>({ | ||
library: ['wagmi', { option: true }], | ||
modalPage: async ({ page, library, context }, use, testInfo) => { | ||
const modalPage = new ModalWalletPage(page, library) | ||
await modalPage.load() | ||
|
||
const email = new Email(mailsacApiKey) | ||
|
||
const tempEmail = email.getEmailAddressToUse(testInfo.parallelIndex) | ||
|
||
await email.deleteAllMessages(tempEmail) | ||
await modalPage.loginWithEmail(tempEmail) | ||
|
||
let messageId = await email.getLatestMessageId(tempEmail) | ||
|
||
if (!messageId) { | ||
throw new Error('No messageId found') | ||
} | ||
let emailBody = await email.getEmailBody(tempEmail, messageId) | ||
let otp = '' | ||
if (email.isApproveEmail(emailBody)) { | ||
const url = email.getApproveUrlFromBody(emailBody) | ||
|
||
await email.deleteAllMessages(tempEmail) | ||
|
||
const drp = new DeviceRegistrationPage(await context.newPage(), url) | ||
drp.load() | ||
await drp.approveDevice() | ||
await drp.close() | ||
|
||
messageId = await email.getLatestMessageId(tempEmail) | ||
|
||
emailBody = await email.getEmailBody(tempEmail, messageId) | ||
if (!email.isApproveEmail(emailBody)) { | ||
otp = email.getOtpCodeFromBody(emailBody) | ||
} | ||
} | ||
if (otp.length !== 6) { | ||
otp = email.getOtpCodeFromBody(emailBody) | ||
} | ||
await modalPage.enterOTP(otp) | ||
await modalPage.switchNetwork('Sepolia') | ||
await modalPage.page.waitForTimeout(1500) | ||
await use(modalPage) | ||
}, | ||
modalValidator: async ({ modalPage }, use) => { | ||
const modalValidator = new ModalWalletValidator(modalPage.page) | ||
await use(modalValidator) | ||
} | ||
}) |
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* eslint-disable no-await-in-loop */ | ||
import type { Page } from '@playwright/test' | ||
import { ModalPage } from './ModalPage' | ||
|
||
export class ModalWalletPage extends ModalPage { | ||
constructor( | ||
public override readonly page: Page, | ||
public override readonly library: string | ||
) { | ||
super(page, library, 'wallet') | ||
} | ||
|
||
async openSettings() { | ||
await this.page.getByTestId('account-button').click() | ||
await this.page.getByTestId('wui-profile-button').click() | ||
} | ||
|
||
override async switchNetwork(network: string) { | ||
await this.openSettings() | ||
await this.page.getByTestId('account-switch-network-button').click() | ||
await this.page.getByTestId(`w3m-network-switch-${network}`).click() | ||
await this.page.getByTestId('w3m-header-close').click() | ||
await this.page.waitForTimeout(2000) | ||
} | ||
|
||
async togglePreferredAccountType() { | ||
await this.openSettings() | ||
await this.page.getByTestId('account-toggle-preferred-account-type').click() | ||
await this.page.getByTestId('w3m-header-close').click() | ||
await this.page.waitForTimeout(2000) | ||
} | ||
} |
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
Oops, something went wrong.