-
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.
- Loading branch information
1 parent
82baf60
commit d345a43
Showing
14 changed files
with
384 additions
and
16 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
47 changes: 47 additions & 0 deletions
47
apps/laboratory/src/pages/library/verify-domain-mismatch.tsx
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,47 @@ | ||
import { createWeb3Modal } from '@web3modal/wagmi/react' | ||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query' | ||
import { useEffect, useState } from 'react' | ||
import { WagmiProvider } from 'wagmi' | ||
import { AppKitButtons } from '../../components/AppKitButtons' | ||
import { WagmiTests } from '../../components/Wagmi/WagmiTests' | ||
import { ThemeStore } from '../../utils/StoreUtil' | ||
import { ConstantsUtil } from '../../utils/ConstantsUtil' | ||
import { WagmiModalInfo } from '../../components/Wagmi/WagmiModalInfo' | ||
import { getWagmiConfig } from '../../utils/WagmiConstants' | ||
|
||
// Special project ID with verify enabled on localhost | ||
const projectId = 'e4eae1aad4503db9966a04fd045a7e4d' | ||
|
||
const queryClient = new QueryClient() | ||
|
||
const wagmiConfig = getWagmiConfig('default', { | ||
projectId | ||
}) | ||
|
||
const modal = createWeb3Modal({ | ||
wagmiConfig, | ||
projectId, | ||
metadata: ConstantsUtil.Metadata, | ||
termsConditionsUrl: 'https://walletconnect.com/terms', | ||
privacyPolicyUrl: 'https://walletconnect.com/privacy' | ||
}) | ||
|
||
ThemeStore.setModal(modal) | ||
|
||
export default function Wagmi() { | ||
const [ready, setReady] = useState(false) | ||
|
||
useEffect(() => { | ||
setReady(true) | ||
}, []) | ||
|
||
return ready ? ( | ||
<WagmiProvider config={wagmiConfig}> | ||
<QueryClientProvider client={queryClient}> | ||
<AppKitButtons /> | ||
<WagmiModalInfo /> | ||
<WagmiTests /> | ||
</QueryClientProvider> | ||
</WagmiProvider> | ||
) : null | ||
} |
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,55 @@ | ||
import { createWeb3Modal } from '@web3modal/wagmi/react' | ||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query' | ||
import { useEffect, useState } from 'react' | ||
import { WagmiProvider } from 'wagmi' | ||
import { AppKitButtons } from '../../components/AppKitButtons' | ||
import { WagmiTests } from '../../components/Wagmi/WagmiTests' | ||
import { ThemeStore } from '../../utils/StoreUtil' | ||
import { WagmiModalInfo } from '../../components/Wagmi/WagmiModalInfo' | ||
import { getWagmiConfig } from '../../utils/WagmiConstants' | ||
|
||
const metadata = { | ||
name: 'Evil Web3Modal', | ||
description: 'Evil Web3Modal Laboratory', | ||
url: 'https://malicious-app-verify-simulation.vercel.app/', | ||
icons: ['https://avatars.githubusercontent.com/u/37784886'], | ||
verifyUrl: '' | ||
} | ||
|
||
// Special project ID with https://malicious-app-verify-simulation.vercel.app/ as the verified domain and this domain is marked as a scam | ||
const projectId = '9d176efa3150a1df0a76c8c138b6b657' | ||
|
||
const queryClient = new QueryClient() | ||
|
||
const wagmiConfig = getWagmiConfig('default', { | ||
projectId, | ||
metadata | ||
}) | ||
|
||
const modal = createWeb3Modal({ | ||
wagmiConfig, | ||
projectId, | ||
metadata, | ||
termsConditionsUrl: 'https://walletconnect.com/terms', | ||
privacyPolicyUrl: 'https://walletconnect.com/privacy' | ||
}) | ||
|
||
ThemeStore.setModal(modal) | ||
|
||
export default function Wagmi() { | ||
const [ready, setReady] = useState(false) | ||
|
||
useEffect(() => { | ||
setReady(true) | ||
}, []) | ||
|
||
return ready ? ( | ||
<WagmiProvider config={wagmiConfig}> | ||
<QueryClientProvider client={queryClient}> | ||
<AppKitButtons /> | ||
<WagmiModalInfo /> | ||
<WagmiTests /> | ||
</QueryClientProvider> | ||
</WagmiProvider> | ||
) : null | ||
} |
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,56 @@ | ||
import { createWeb3Modal } from '@web3modal/wagmi/react' | ||
import { QueryClient, QueryClientProvider } from '@tanstack/react-query' | ||
import { useEffect, useState } from 'react' | ||
import { WagmiProvider } from 'wagmi' | ||
import { AppKitButtons } from '../../components/AppKitButtons' | ||
import { WagmiTests } from '../../components/Wagmi/WagmiTests' | ||
import { ThemeStore } from '../../utils/StoreUtil' | ||
import { WagmiModalInfo } from '../../components/Wagmi/WagmiModalInfo' | ||
import { getWagmiConfig } from '../../utils/WagmiConstants' | ||
|
||
const metadata = { | ||
name: 'Web3Modal', | ||
description: 'Web3Modal Laboratory', | ||
// Allow localhost | ||
url: 'http://localhost:3000', | ||
icons: ['https://avatars.githubusercontent.com/u/37784886'], | ||
verifyUrl: '' | ||
} | ||
|
||
// Special project ID with verify enabled on localhost | ||
const projectId = 'e4eae1aad4503db9966a04fd045a7e4d' | ||
|
||
const queryClient = new QueryClient() | ||
|
||
const wagmiConfig = getWagmiConfig('default', { | ||
projectId, | ||
metadata | ||
}) | ||
|
||
const modal = createWeb3Modal({ | ||
wagmiConfig, | ||
projectId, | ||
metadata, | ||
termsConditionsUrl: 'https://walletconnect.com/terms', | ||
privacyPolicyUrl: 'https://walletconnect.com/privacy' | ||
}) | ||
|
||
ThemeStore.setModal(modal) | ||
|
||
export default function Wagmi() { | ||
const [ready, setReady] = useState(false) | ||
|
||
useEffect(() => { | ||
setReady(true) | ||
}, []) | ||
|
||
return ready ? ( | ||
<WagmiProvider config={wagmiConfig}> | ||
<QueryClientProvider client={queryClient}> | ||
<AppKitButtons /> | ||
<WagmiModalInfo /> | ||
<WagmiTests /> | ||
</QueryClientProvider> | ||
</WagmiProvider> | ||
) : null | ||
} |
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
12 changes: 12 additions & 0 deletions
12
apps/laboratory/tests/shared/fixtures/w3m-verify-domain-mismatch-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,12 @@ | ||
import type { ModalFixture } from './w3m-fixture' | ||
import { ModalPage } from '../pages/ModalPage' | ||
import { timingFixture } from './timing-fixture' | ||
|
||
export const testMVerifyDomainMismatch = timingFixture.extend<ModalFixture>({ | ||
library: ['wagmi', { option: true }], | ||
modalPage: async ({ page, library }, use) => { | ||
const modalPage = new ModalPage(page, library, 'verify-domain-mismatch') | ||
await modalPage.load() | ||
await use(modalPage) | ||
} | ||
}) |
12 changes: 12 additions & 0 deletions
12
apps/laboratory/tests/shared/fixtures/w3m-verify-evil-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,12 @@ | ||
import type { ModalFixture } from './w3m-fixture' | ||
import { ModalPage } from '../pages/ModalPage' | ||
import { timingFixture } from './timing-fixture' | ||
|
||
export const testMVerifyEvil = timingFixture.extend<ModalFixture>({ | ||
library: ['wagmi', { option: true }], | ||
modalPage: async ({ page, library }, use) => { | ||
const modalPage = new ModalPage(page, library, 'verify-evil') | ||
await modalPage.load() | ||
await use(modalPage) | ||
} | ||
}) |
12 changes: 12 additions & 0 deletions
12
apps/laboratory/tests/shared/fixtures/w3m-verify-valid-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,12 @@ | ||
import type { ModalFixture } from './w3m-fixture' | ||
import { ModalPage } from '../pages/ModalPage' | ||
import { timingFixture } from './timing-fixture' | ||
|
||
export const testMVerifyValid = timingFixture.extend<ModalFixture>({ | ||
library: ['wagmi', { option: true }], | ||
modalPage: async ({ page, library }, use) => { | ||
const modalPage = new ModalPage(page, library, 'verify-valid') | ||
await modalPage.load() | ||
await use(modalPage) | ||
} | ||
}) |
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,38 @@ | ||
import type { Page } from '@playwright/test' | ||
|
||
/* | ||
* This function makes requests to the intercept URL be handled by the base URL | ||
* This allows the browser APIs to think interceptUrl is the URL the page is on | ||
*/ | ||
// eslint-disable-next-line max-params | ||
export async function routeInterceptUrl( | ||
page: Page, | ||
interceptUrl: string, | ||
baseUrl: string, | ||
path: string | ||
) { | ||
await page.route(`${interceptUrl}/**/*`, async (route, request) => { | ||
// eslint-disable-next-line init-declarations | ||
let url: string | ||
if (request.url() === `${interceptUrl}/`) { | ||
url = `${baseUrl}${path}` | ||
} else { | ||
url = request.url().replace(interceptUrl, baseUrl) | ||
} | ||
const response = await fetch(url, { | ||
method: request.method(), | ||
headers: request.headers(), | ||
body: request.postData() | ||
}) | ||
const headers: Record<string, string> = {} | ||
response.headers.forEach((value: string, key: string) => { | ||
headers[key] = value | ||
}) | ||
const body = Buffer.from(await response.arrayBuffer()) | ||
await route.fulfill({ | ||
status: response.status, | ||
headers, | ||
body | ||
}) | ||
}) | ||
} |
Oops, something went wrong.