mirror of
https://github.com/hanzoai/shadcn.git
synced 2026-10-30 18:22:59 +00:00
The docs site pulled in RainbowKit, which bundles a WalletConnect connector. That connector phoned pulse.walletconnect.org on every page load — third-party telemetry from a documentation page — and it could not have worked anyway: the project id fell back to the literal 'YOUR_PROJECT_ID'. The browser wallet already speaks EIP-1193, so wagmi's injected connector is all the identity demo needs: the extension is the only party in the flow, with no bridge service and no vendor id. ConnectWallet replaces RainbowKit's modal using our own Button. wagmi and viem stay — they are how the page reads and writes contracts. Verified: a clean build exports 8,879 files and the shipped JS contains no walletconnect reference.
41 lines
1.1 KiB
TypeScript
41 lines
1.1 KiB
TypeScript
"use client"
|
|
|
|
import { useAccount, useConnect, useDisconnect } from "wagmi"
|
|
|
|
import { Button } from "@/registry/default/ui/button"
|
|
|
|
const short = (address: string) => `${address.slice(0, 6)}…${address.slice(-4)}`
|
|
|
|
/**
|
|
* Connect the wallet the browser already has, over EIP-1193. There is no
|
|
* third-party modal and no bridge service in the page — the extension is the
|
|
* only party involved.
|
|
*/
|
|
export function ConnectWallet() {
|
|
const { address, isConnected } = useAccount()
|
|
const { connect, connectors, isPending } = useConnect()
|
|
const { disconnect } = useDisconnect()
|
|
|
|
if (isConnected && address) {
|
|
return (
|
|
<div className="flex items-center gap-3">
|
|
<span className="font-mono text-sm">{short(address)}</span>
|
|
<Button variant="outline" size="sm" onClick={() => disconnect()}>
|
|
Disconnect
|
|
</Button>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
const injected = connectors[0]
|
|
|
|
return (
|
|
<Button
|
|
onClick={() => injected && connect({ connector: injected })}
|
|
disabled={!injected || isPending}
|
|
>
|
|
{isPending ? "Connecting…" : "Connect Wallet"}
|
|
</Button>
|
|
)
|
|
}
|