Skip to content

Commit 484a6f7

Browse files
committed
Revert "feat: use accounts SDK for demo connectors (#216)"
This reverts commit 0d2aaf7.
1 parent 222c19f commit 484a6f7

6 files changed

Lines changed: 227 additions & 252 deletions

File tree

pnpm-lock.yaml

Lines changed: 197 additions & 213 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/ConnectWallet.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use client'
22
import * as React from 'react'
33
import { useChains, useConnect, useConnection, useConnectors, useSwitchChain } from 'wagmi'
4-
import { Button, Logout, TEMPO_CONNECTOR_ID } from './guides/Demo'
4+
import { Button, Logout } from './guides/Demo'
55
import { filterSupportedInjectedConnectors } from './lib/wallets'
66

77
export function ConnectWallet({ showAddChain = true }: { showAddChain?: boolean }) {
@@ -19,7 +19,7 @@ export function ConnectWallet({ showAddChain = true }: { showAddChain?: boolean
1919
return (
2020
<div className="flex items-center text-[14px] -tracking-[2%]">No browser wallets found.</div>
2121
)
22-
if (!address || connector?.id === TEMPO_CONNECTOR_ID)
22+
if (!address || connector?.id === 'webAuthn')
2323
return (
2424
<div className="flex gap-2">
2525
{injectedConnectors.map((connector) => (

src/components/guides/Demo.tsx

Lines changed: 10 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ import { alphaUsd } from './tokens'
2121

2222
export { alphaUsd, betaUsd, pathUsd, thetaUsd } from './tokens'
2323

24-
export const TEMPO_CONNECTOR_ID = 'xyz.tempo'
25-
2624
export const FAKE_RECIPIENT = '0xbeefcafe54750903ac1c8909323af7beb21ea2cb'
2725
export const FAKE_RECIPIENT_2 = '0xdeadbeef54750903ac1c8909323af7beb21ea2cb'
2826

@@ -112,14 +110,14 @@ export function Container(
112110

113111
if (source === 'webAuthn') {
114112
const webAuthnConnection = connections.find(
115-
(c) => c.connector.id === 'webAuthn' || c.connector.id === TEMPO_CONNECTOR_ID,
113+
(c) => c.connector.id === 'webAuthn' || c.connector.id === 'xyz.tempo',
116114
)
117115
return webAuthnConnection?.accounts[0]
118116
}
119117

120118
if (source === 'wallet') {
121119
const walletConnection = connections.find(
122-
(c) => c.connector.id !== 'webAuthn' && c.connector.id !== TEMPO_CONNECTOR_ID,
120+
(c) => c.connector.id !== 'webAuthn' && c.connector.id !== 'xyz.tempo',
123121
)
124122
return walletConnection?.accounts[0]
125123
}
@@ -371,32 +369,14 @@ export function Login() {
371369
Check prompt
372370
</Button>
373371
) : (
374-
<div className="flex gap-1">
375-
<Button
376-
variant="accent"
377-
className="font-normal text-[14px] -tracking-[2%]"
378-
onClick={() => connect.connect({ connector })}
379-
type="button"
380-
>
381-
Sign in
382-
</Button>
383-
<Button
384-
variant="default"
385-
className="font-normal text-[14px] -tracking-[2%]"
386-
onClick={() =>
387-
connect.connect({
388-
connector,
389-
capabilities: {
390-
name: 'Tempo Docs',
391-
method: 'register',
392-
},
393-
})
394-
}
395-
type="button"
396-
>
397-
Sign up
398-
</Button>
399-
</div>
372+
<Button
373+
variant="accent"
374+
className="font-normal text-[14px] -tracking-[2%]"
375+
onClick={() => connect.connect({ connector })}
376+
type="button"
377+
>
378+
Sign in
379+
</Button>
400380
)}
401381
</div>
402382
)

src/components/guides/EmbedPasskeys.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ export function SignInButtons() {
4141
connect.connect({
4242
connector,
4343
capabilities: {
44-
name: 'Tempo Docs',
45-
method: 'register',
44+
label: 'Tempo Docs',
45+
type: 'sign-up',
4646
},
4747
})
4848
}}

src/components/guides/steps/wallet/ConnectWallet.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
import LucideCheck from '~icons/lucide/check'
1313
import LucideWalletCards from '~icons/lucide/wallet-cards'
1414
import { filterSupportedInjectedConnectors } from '../../../lib/wallets'
15-
import { Button, Step, StringFormatter, TEMPO_CONNECTOR_ID, useCopyToClipboard } from '../../Demo'
15+
import { Button, Step, StringFormatter, useCopyToClipboard } from '../../Demo'
1616
import type { DemoStepProps } from '../types'
1717

1818
export function ConnectWallet(props: DemoStepProps) {
@@ -31,7 +31,7 @@ export function ConnectWallet(props: DemoStepProps) {
3131
const isSupported = chains.some((c) => c.id === chain?.id)
3232
const [copied, copyToClipboard] = useCopyToClipboard()
3333

34-
const walletConnection = connections.find((c) => c.connector.id !== TEMPO_CONNECTOR_ID)
34+
const walletConnection = connections.find((c) => c.connector.id !== 'webAuthn')
3535
const walletAddress = walletConnection?.accounts[0]
3636
const walletConnector = walletConnection?.connector
3737
const hasNonWebAuthnWallet = Boolean(walletAddress)

src/wagmi.config.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
useConnectors,
1414
webSocket,
1515
} from 'wagmi'
16-
import { webAuthn } from 'accounts/wagmi'
16+
import { KeyManager, webAuthn } from 'wagmi/tempo'
1717
import { alphaUsd, betaUsd, pathUsd, thetaUsd } from './components/guides/tokens'
1818

1919
const feeToken = '0x20c0000000000000000000000000000000000001'
@@ -25,6 +25,13 @@ const chain =
2525
? tempoDevnet.extend({ feeToken })
2626
: tempoModerato.extend({ feeToken })
2727

28+
const rpId = (() => {
29+
const hostname = globalThis.location?.hostname
30+
if (!hostname) return undefined
31+
const parts = hostname.split('.')
32+
return parts.length > 2 ? parts.slice(-2).join('.') : hostname
33+
})()
34+
2835
export function getConfig(options: getConfig.Options = {}) {
2936
const { multiInjectedProviderDiscovery = false } = options
3037
return createConfig({
@@ -46,8 +53,12 @@ export function getConfig(options: getConfig.Options = {}) {
4653
feePayerUrl: 'https://sponsor.moderato.tempo.xyz',
4754
}),
4855
webAuthn({
49-
authUrl: 'https://keys.tempo.xyz',
50-
rdns: 'webAuthn',
56+
grantAccessKey: {
57+
// @ts-expect-error - TODO: migrate to webAuthn on Accounts SDK
58+
chainId: BigInt(chain.id),
59+
},
60+
keyManager: KeyManager.http('https://keys.tempo.xyz'),
61+
rpId,
5162
}),
5263
],
5364
multiInjectedProviderDiscovery,

0 commit comments

Comments
 (0)