Skip to content

Commit

Permalink
chore: enable wallet features by default (#2382)
Browse files Browse the repository at this point in the history
Co-authored-by: enesozturk <[email protected]>
  • Loading branch information
svenvoskamp and enesozturk authored Jun 11, 2024
1 parent 8b10b51 commit e900656
Show file tree
Hide file tree
Showing 31 changed files with 246 additions and 159 deletions.
2 changes: 1 addition & 1 deletion apps/demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"tailwind-merge": "2.2.1",
"vaul": "0.9.0",
"viem": "2.10.3",
"wagmi": "2.9.9",
"wagmi": "2.9.10",
"zustand": "4.5.2"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion apps/laboratory/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"@walletconnect/utils": "2.13.1",
"valtio": "1.11.2",
"viem": "2.10.3",
"wagmi": "2.9.9",
"wagmi": "2.9.10",
"@wagmi/connectors": "5.0.8"
},
"devDependencies": {
Expand Down
3 changes: 1 addition & 2 deletions apps/laboratory/src/pages/library/ethers-all.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ const modal = createWeb3Modal({
privacyPolicyUrl: 'https://walletconnect.com/privacy',
siweConfig,
enableOnramp: true,
customWallets: ConstantsUtil.CustomWallets,
enableWalletFeatures: true
customWallets: ConstantsUtil.CustomWallets
})

ThemeStore.setModal(modal)
Expand Down
39 changes: 0 additions & 39 deletions apps/laboratory/src/pages/library/ethers-wallet.tsx

This file was deleted.

3 changes: 1 addition & 2 deletions apps/laboratory/src/pages/library/wagmi-all.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ const modal = createWeb3Modal({
privacyPolicyUrl: 'https://walletconnect.com/privacy',
siweConfig,
enableOnramp: true,
customWallets: ConstantsUtil.CustomWallets,
enableWalletFeatures: true
customWallets: ConstantsUtil.CustomWallets
})

ThemeStore.setModal(modal)
Expand Down
46 changes: 0 additions & 46 deletions apps/laboratory/src/pages/library/wagmi-wallet.tsx

This file was deleted.

18 changes: 4 additions & 14 deletions apps/laboratory/src/utils/DataUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,9 @@ export const wagmiSdkOptions = [
description: 'Configuration using wagmi and implementing sign in with ethereum'
},
{
title: 'Email',
title: 'Email & Social',
link: '/library/wagmi-email/',
description: 'Configuration using wagmi and implementing email login'
},
{
title: 'Wallet',
link: '/library/wagmi-wallet/',
description: 'Configuration using wagmi and implementing social wallet'
description: 'Configuration using wagmi and implementing email and social login'
}
]

Expand All @@ -53,14 +48,9 @@ export const ethersSdkOptions = [
description: 'Configuration using ethers and implementing sign in with ethereum'
},
{
title: 'Email',
title: 'Email and Social',
link: '/library/ethers-email/',
description: 'Configuration using ethers and implementing email login'
},
{
title: 'Wallet',
link: '/library/ethers-wallet/',
description: 'Configuration using ethers and implementing social wallet'
description: 'Configuration using ethers and implementing email and social login'
}
]

Expand Down
40 changes: 26 additions & 14 deletions apps/laboratory/tests/email.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { expect } from '@playwright/test'
import { testMEmail } from './shared/fixtures/w3m-email-fixture'
import { SECURE_WEBSITE_URL } from './shared/constants'
import type { ModalWalletPage } from './shared/pages/ModalWalletPage'
import type { ModalWalletValidator } from './shared/validators/ModalWalletValidator'

testMEmail.beforeEach(async ({ modalValidator }) => {
await modalValidator.expectConnected()
Expand All @@ -26,23 +28,33 @@ testMEmail('it should reject sign', async ({ modalPage, modalValidator }) => {

testMEmail('it should switch network and sign', async ({ modalPage, modalValidator }) => {
let targetChain = 'Polygon'
await modalPage.switchNetwork(targetChain)
await modalValidator.expectSwitchedNetwork(targetChain)
await modalPage.closeModal()
await modalPage.sign()
await modalPage.approveSign()
await modalValidator.expectAcceptedSign()
const walletModalPage = modalPage as ModalWalletPage
const walletModalValidator = modalValidator as ModalWalletValidator
await walletModalPage.openAccount()
await walletModalPage.openSettings()
await walletModalPage.switchNetwork(targetChain)
await walletModalValidator.expectSwitchedNetwork(targetChain)
await walletModalPage.closeModal()
await walletModalPage.sign()
await walletModalPage.approveSign()
await walletModalValidator.expectAcceptedSign()

targetChain = 'Ethereum'
await modalPage.switchNetwork(targetChain)
await modalValidator.expectSwitchedNetwork(targetChain)
await modalPage.closeModal()
await modalPage.sign()
await modalPage.approveSign()
await modalValidator.expectAcceptedSign()
await walletModalPage.openAccount()
await walletModalPage.openSettings()
await walletModalPage.switchNetwork(targetChain)
await walletModalValidator.expectSwitchedNetwork(targetChain)
await walletModalPage.closeModal()
await walletModalPage.sign()
await walletModalPage.approveSign()
await walletModalValidator.expectAcceptedSign()
})

testMEmail('it should disconnect correctly', async ({ modalPage, modalValidator }) => {
await modalPage.disconnect()
await modalValidator.expectDisconnected()
const walletModalPage = modalPage as ModalWalletPage
const walletModalValidator = modalValidator as ModalWalletValidator
await walletModalPage.openAccount()
await walletModalPage.openSettings()
await walletModalPage.disconnect()
await walletModalValidator.expectDisconnected()
})
6 changes: 2 additions & 4 deletions apps/laboratory/tests/shared/fixtures/w3m-email-fixture.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import type { ModalFixture } from './w3m-fixture'
import { ModalPage } from '../pages/ModalPage'
import { ModalValidator } from '../validators/ModalValidator'
import { Email } from '../utils/email'
import { ModalWalletValidator } from '../validators/ModalWalletValidator'
import { timingFixture } from './timing-fixture'
Expand All @@ -9,7 +7,7 @@ import { ModalWalletPage } from '../pages/ModalWalletPage'
export const testMEmail = timingFixture.extend<ModalFixture>({
library: ['wagmi', { option: true }],
modalPage: async ({ page, library, context }, use, testInfo) => {
const modalPage = new ModalPage(page, library, 'email')
const modalPage = new ModalWalletPage(page, library, 'email')
await modalPage.load()

const mailsacApiKey = process.env['MAILSAC_API_KEY']
Expand All @@ -23,7 +21,7 @@ export const testMEmail = timingFixture.extend<ModalFixture>({
await use(modalPage)
},
modalValidator: async ({ modalPage }, use) => {
const modalValidator = new ModalValidator(modalPage.page)
const modalValidator = new ModalWalletValidator(modalPage.page)
await use(modalValidator)
}
})
Expand Down
2 changes: 2 additions & 0 deletions apps/laboratory/tests/shared/pages/ModalPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,8 @@ export class ModalPage {

async clickWalletUpgradeCard(context: BrowserContext) {
await this.page.getByTestId('account-button').click()

await this.page.getByTestId('w3m-profile-button').click()
await this.page.getByTestId('w3m-wallet-upgrade-card').click()

const page = await doActionAndWaitForNewPage(
Expand Down
2 changes: 1 addition & 1 deletion apps/laboratory/tests/shared/pages/ModalWalletPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export class ModalWalletPage extends ModalPage {
constructor(
public override readonly page: Page,
public override readonly library: string,
public override readonly flavor: 'wallet' | 'all' = 'wallet'
public override readonly flavor: 'email' | 'all' = 'email'
) {
super(page, library, flavor)
}
Expand Down
1 change: 0 additions & 1 deletion apps/laboratory/tests/shared/validators/ModalValidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ export class ModalValidator {
// We use Chakra Toast and it's not quite straightforward to set the `data-testid` attribute on the toast element.
await expect(this.page.getByText(ConstantsUtil.SigningFailedToastTitle)).toBeVisible()
}

async expectSwitchedNetwork(network: string) {
const switchNetworkButton = this.page.getByTestId('w3m-account-select-network')
await expect(switchNetworkButton).toBeVisible()
Expand Down
2 changes: 1 addition & 1 deletion apps/laboratory/tests/siwe-email.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ testMEmailSiwe('it should switch network and sign', async ({ modalPage, modalVal
await modalWalletPage.switchNetwork(targetChain)
await modalWalletPage.promptSiwe()
await modalWalletPage.approveSign()
await modalWalletValidator.expectSwitchedNetwork(targetChain)
await modalWalletValidator.expectSwitchedNetwork(targetChain, true)
await modalWalletPage.closeModal()

await modalWalletPage.sign()
Expand Down
2 changes: 1 addition & 1 deletion examples/next-wagmi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"react": "18.2.0",
"react-dom": "18.2.0",
"viem": "2.10.3",
"wagmi": "2.9.9"
"wagmi": "2.9.10"
},
"devDependencies": {
"@types/node": "20.11.5",
Expand Down
2 changes: 1 addition & 1 deletion examples/react-wagmi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"react-dom": "18.2.0",
"vite": "5.2.11",
"viem": "2.10.3",
"wagmi": "2.9.9"
"wagmi": "2.9.10"
},
"devDependencies": {
"@vitejs/plugin-react": "4.2.1",
Expand Down
Loading

0 comments on commit e900656

Please sign in to comment.