Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions e2e/private-zones-sign-in.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { expect, test } from '@playwright/test'

test('private zone guides sign in through the shared docs login', async ({ page }) => {
const client = await page.context().newCDPSession(page)
await client.send('WebAuthn.enable')
const { authenticatorId } = await client.send('WebAuthn.addVirtualAuthenticator', {
options: {
protocol: 'ctap2',
transport: 'internal',
hasResidentKey: true,
hasUserVerification: true,
isUserVerified: true,
},
})

try {
await page.goto('/docs/guide/private-zones/deposit-to-a-zone')

const accountStep = page
.locator('[data-active][data-completed]')
.filter({ hasText: 'Create or use a passkey account on the public chain.' })
.first()
await accountStep.getByRole('button', { name: 'Sign in' }).click()

await expect(accountStep.getByRole('button', { name: 'Sign out' })).toBeVisible()
} finally {
await client.send('WebAuthn.removeVirtualAuthenticator', { authenticatorId }).catch(() => {})
}
})
5 changes: 2 additions & 3 deletions src/components/guides/zones/DepositToZone.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ import {
} from '../../../lib/private-zones.ts'
import { useRootWebAuthnAccount } from '../../../lib/useRootWebAuthnAccount.ts'
import { useZoneAuthorization, type ZoneAuthClientLike } from '../../../lib/useZoneAuthorization.ts'
import { Button, ExplorerLink, Logout, Step } from '../Demo'
import { SignInButtons } from '../EmbedPasskeys'
import { Button, ExplorerLink, Login, Logout, Step } from '../Demo'
import { pathUsd } from '../tokens'

const ZONE_LABEL = 'Zone A'
Expand Down Expand Up @@ -52,7 +51,7 @@ export function DepositToZone() {
<Step
active={!connected}
completed={connected}
actions={connected ? <Logout /> : <SignInButtons />}
actions={connected ? <Logout /> : <Login />}
error={undefined}
number={1}
title="Create or use a passkey account on the public chain."
Expand Down
5 changes: 2 additions & 3 deletions src/components/guides/zones/SendTokensAcrossZones.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ import {
} from '../../../lib/private-zones.ts'
import { useRootWebAuthnAccount } from '../../../lib/useRootWebAuthnAccount.ts'
import { useZoneAuthorization, type ZoneAuthClientLike } from '../../../lib/useZoneAuthorization.ts'
import { Button, ExplorerLink, Logout, ReceiptHash, Step } from '../Demo'
import { SignInButtons } from '../EmbedPasskeys'
import { Button, ExplorerLink, Login, Logout, ReceiptHash, Step } from '../Demo'
import { pathUsd } from '../tokens'
import { useStickyStepCompletion } from './useStickyStepCompletion.ts'

Expand Down Expand Up @@ -81,7 +80,7 @@ export function SendTokensAcrossZones() {
<Step
active={!connected}
completed={connected}
actions={connected ? <Logout /> : <SignInButtons />}
actions={connected ? <Logout /> : <Login />}
error={undefined}
number={1}
title="Create or use a passkey account on the public chain."
Expand Down
5 changes: 2 additions & 3 deletions src/components/guides/zones/SendTokensWithinZone.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ import {
} from '../../../lib/private-zones.ts'
import { useRootWebAuthnAccount } from '../../../lib/useRootWebAuthnAccount.ts'
import { useZoneAuthorization, type ZoneAuthClientLike } from '../../../lib/useZoneAuthorization.ts'
import { Button, ExplorerLink, FAKE_RECIPIENT, Logout, ReceiptHash, Step } from '../Demo'
import { SignInButtons } from '../EmbedPasskeys'
import { Button, ExplorerLink, FAKE_RECIPIENT, Login, Logout, ReceiptHash, Step } from '../Demo'
import { pathUsd } from '../tokens'
import { useStickyStepCompletion } from './useStickyStepCompletion.ts'

Expand Down Expand Up @@ -42,7 +41,7 @@ export function SendTokensWithinZone() {
<Step
active={!connected}
completed={connected}
actions={connected ? <Logout /> : <SignInButtons />}
actions={connected ? <Logout /> : <Login />}
error={undefined}
number={1}
title="Create or use a passkey account on the public chain."
Expand Down
5 changes: 2 additions & 3 deletions src/components/guides/zones/SwapAcrossZones.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ import {
} from '../../../lib/private-zones.ts'
import { useRootWebAuthnAccount } from '../../../lib/useRootWebAuthnAccount.ts'
import { useZoneAuthorization, type ZoneAuthClientLike } from '../../../lib/useZoneAuthorization.ts'
import { Button, ExplorerLink, Logout, ReceiptHash, Step } from '../Demo'
import { SignInButtons } from '../EmbedPasskeys'
import { Button, ExplorerLink, Login, Logout, ReceiptHash, Step } from '../Demo'
import { betaUsd, pathUsd } from '../tokens'
import { useStickyStepCompletion } from './useStickyStepCompletion.ts'

Expand Down Expand Up @@ -105,7 +104,7 @@ export function SwapAcrossZones() {
<Step
active={!connected}
completed={connected}
actions={connected ? <Logout /> : <SignInButtons />}
actions={connected ? <Logout /> : <Login />}
error={undefined}
number={1}
title="Create or use a passkey account on the public chain."
Expand Down
5 changes: 2 additions & 3 deletions src/components/guides/zones/WithdrawFromZone.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ import {
} from '../../../lib/private-zones.ts'
import { useRootWebAuthnAccount } from '../../../lib/useRootWebAuthnAccount.ts'
import { useZoneAuthorization, type ZoneAuthClientLike } from '../../../lib/useZoneAuthorization.ts'
import { Button, ExplorerLink, Logout, Step } from '../Demo'
import { SignInButtons } from '../EmbedPasskeys'
import { Button, ExplorerLink, Login, Logout, Step } from '../Demo'
import { pathUsd } from '../tokens'
import { useStickyStepCompletion } from './useStickyStepCompletion.ts'

Expand Down Expand Up @@ -74,7 +73,7 @@ export function WithdrawFromZone() {
<Step
active={!connected}
completed={connected}
actions={connected ? <Logout /> : <SignInButtons />}
actions={connected ? <Logout /> : <Login />}
error={undefined}
number={1}
title="Create or use a passkey account on the public chain."
Expand Down
6 changes: 4 additions & 2 deletions src/lib/useRootWebAuthnAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ export function useRootWebAuthnAccount() {
const { address, connector } = useConnection()

return useQuery({
enabled: Boolean(address && connector?.id === 'webAuthn'),
queryKey: ['root-webauthn-account', address],
enabled: Boolean(
address && (connector?.id === 'webAuthn' || connector?.id === 'xyz.tempo'),
),
queryKey: ['root-webauthn-account', connector?.id, address],
queryFn: async () => {
if (!address) throw new Error('account address not ready')
if (!connector) throw new Error('connector not ready')
Expand Down
Loading