Skip to content
Draft
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
33 changes: 31 additions & 2 deletions apps/explorer/src/comps/ConnectWallet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { cx } from '#lib/css'
import { filterSupportedInjectedConnectors } from '#lib/wallets.ts'
import LucideLogOut from '~icons/lucide/log-out'
import LucideWalletCards from '~icons/lucide/wallet-cards'
import LucideFingerprint from '~icons/lucide/fingerprint'

export function ConnectWallet({
showAddChain = true,
Expand Down Expand Up @@ -45,22 +46,50 @@ function ConnectWalletInner({
() => filterSupportedInjectedConnectors(connectors),
[connectors],
)
const passkeyConnector = React.useMemo(
() => connectors.find((c) => c.id === 'webAuthn'),
[connectors],
)
const switchChain = useSwitchChain()
const chains = useChains()
const isSupported = chains.some((c) => c.id === chain?.id)

if (!injectedConnectors.length)
const hasConnectorOptions = injectedConnectors.length > 0 || passkeyConnector

if (!hasConnectorOptions)
return (
<div className="text-[12px] -tracking-[2%] flex items-center whitespace-nowrap select-none">
No wallet found.
</div>
)
if (!address || connector?.id === 'webAuthn')
if (!address)
return (
<div className="flex items-center gap-1.5">
<span className="text-[12px] text-tertiary whitespace-nowrap font-sans">
Connect
</span>
{passkeyConnector && (
<button
type="button"
onClick={() => {
setPendingId('webAuthn')
connect.mutate(
{ connector: passkeyConnector },
{
onSettled: () => setPendingId(null),
},
)
}}
className={cx(
'flex gap-[8px] items-center text-[12px] bg-base-alt rounded text-primary py-[6px] px-[10px] cursor-pointer press-down border border-card-border transition-colors',
'hover:bg-base-alt/80',
pendingId === 'webAuthn' && connect.isPending && 'animate-pulse',
)}
>
<LucideFingerprint className="size-[12px]" />
Passkey
</button>
)}
{injectedConnectors.map((connector) => (
<button
type="button"
Expand Down
6 changes: 6 additions & 0 deletions apps/explorer/src/wagmi.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
serialize,
webSocket,
} from 'wagmi'
import { KeyManager, webAuthn } from 'wagmi/tempo'

const TEMPO_ENV = import.meta.env.VITE_TEMPO_ENV

Expand Down Expand Up @@ -101,6 +102,11 @@ export function getWagmiConfig() {
ssr: true,
batch: { multicall: false },
chains: [chain, tempoLocalnet],
connectors: [
webAuthn({
keyManager: KeyManager.http('https://keys.tempo.xyz'),
}),
],
storage: createStorage({ storage: cookieStorage }),
transports: {
[chain.id]: transport,
Expand Down
Loading