Skip to content

Commit

Permalink
connect wallet working
Browse files Browse the repository at this point in the history
  • Loading branch information
LeonmanRolls committed Jan 12, 2025
1 parent 051bfa9 commit 2d32bfc
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"dev:https": "next dev --experimental-https --port 443",
"dev:nlocal": "NEXT_PUBLIC_PROVIDER=http://localhost:8545 NEXT_PUBLIC_AVUP_ENDPOINT=http://localhost:8787 pnpm dev",
"dev:localname": "NEXT_PUBLIC_PROVIDER=\"http://$(\"hostname\"):8545\" && NEXT_PUBLIC_AVUP_ENDPOINT=\"http://$(\"hostname\"):8787\" && NEXT_PUBLIC_GRAPH_URI=\"http://$(\"hostname\"):8000/subgraphs/name/graphprotocol/ens\" && pnpm dev",
"dev:glocal": "rm -rf .next && NEXT_PUBLIC_GRAPH_URI=http://localhost:8000/subgraphs/name/graphprotocol/ens NEXT_PUBLIC_ETH_NODE=anvil pnpm dev:nlocal",
"dev:glocal": "SWC_CACHE=false rm -rf .next && NEXT_PUBLIC_GRAPH_URI=http://localhost:8000/subgraphs/name/graphprotocol/ens NEXT_PUBLIC_ETH_NODE=anvil pnpm dev:nlocal",
"dev:gonline": "NEXT_PUBLIC_GRAPH_URI=https://api.studio.thegraph.com/query/49574/ensholesky/version/latest pnpm dev",
"build": "next build",
"build:preview": "NEXT_PUBLIC_ENSJS_DEBUG=true next build --profile",
Expand Down
21 changes: 15 additions & 6 deletions playwright/fixtures/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,25 @@ export class Login {
await expect(this.page.getByText('Confirm connection in the extension')).toBeVisible({
timeout: 15000,
})
console.log('isConnected', this.wallet.isConnected())
// await this.page.waitForTimeout(10000)
// this isn't actually what the user experiences, just a quirk in headless-web3-provider
expect(this.wallet.getPendingRequestCount(Web3RequestKind.RequestPermissions)).toEqual(1)
// expect(this.wallet.getPendingRequestCount(Web3RequestKind.RequestPermissions)).toEqual(1)
await this.wallet.authorize(Web3RequestKind.RequestPermissions)
expect(this.wallet.getPendingRequestCount(Web3RequestKind.RequestPermissions)).toEqual(0)
await expect
.poll(() => this.wallet.getPendingRequestCount(Web3RequestKind.RequestAccounts))
.toEqual(1)
// expect(this.wallet.getPendingRequestCount(Web3RequestKind.RequestPermissions)).toEqual(0)
// await expect
// .poll(() => this.wallet.getPendingRequestCount(Web3RequestKind.RequestAccounts))
// .toEqual(1)
await this.wallet.authorize(Web3RequestKind.RequestAccounts)
const pendingRequests = await this.wallet.getPendingRequestCount()
console.log('pendingRequests', pendingRequests)
console.log('isConnected', this.wallet.isConnected())
expect(this.wallet.getPendingRequestCount(Web3RequestKind.RequestAccounts)).toEqual(0)
await expect(this.getProfileButton).toBeVisible()
// await this.page.waitForTimeout(20000)
// await expect.poll(() => this.getProfileButton.isVisible())

// await expect(this.getProfileButton).toBeVisible()
await expect.poll(() => this.getProfileButton.isVisible()).toBe(true)
}

async switchTo(user: User) {
Expand Down
18 changes: 16 additions & 2 deletions src/constants/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export type SupportedChain =
| typeof localhostWithEns

export const getChainsFromUrl = () => {
console.log('getChainsFromUrl')
if (typeof window === 'undefined') {
return [
...(isLocalProvider ? ([localhostWithEns] as const) : ([] as const)),
Expand All @@ -67,8 +68,21 @@ export const getChainsFromUrl = () => {
if (chainParam === 'holesky') return [holeskyWithEns, sepoliaWithEns, mainnetWithEns]
}

if (!hostname.includes('app.ens.domains')) return [mainnetWithEns, holeskyWithEns, sepoliaWithEns]
if (segments.length !== 4) return [mainnetWithEns, holeskyWithEns, sepoliaWithEns]
if (!hostname.includes('app.ens.domains'))
return [
...(isLocalProvider ? ([localhostWithEns] as const) : ([] as const)),
mainnetWithEns,
holeskyWithEns,
sepoliaWithEns,
]

if (segments.length !== 4)
return [
...(isLocalProvider ? ([localhostWithEns] as const) : ([] as const)),
mainnetWithEns,
holeskyWithEns,
sepoliaWithEns,
]

return match(segments[0])
.with('sepolia', () => [
Expand Down

0 comments on commit 2d32bfc

Please sign in to comment.