|
1 | 1 | 'use client' |
2 | 2 |
|
3 | | -import { |
4 | | - Address, |
5 | | - Avatar, |
6 | | - Identity, |
7 | | - Name, |
8 | | -} from '@coinbase/onchainkit/identity' |
9 | | -import { |
10 | | - ConnectWallet, |
11 | | - Wallet, |
12 | | - WalletDropdown, |
13 | | - WalletDropdownBasename, |
14 | | - WalletDropdownDisconnect, |
15 | | -} from '@coinbase/onchainkit/wallet' |
| 3 | +import { useAccount, useConnect } from 'wagmi' |
| 4 | +import { sdk } from '@farcaster/miniapp-sdk'; |
| 5 | +import { useEffect } from 'react'; |
16 | 6 |
|
17 | 7 | export function WalletComponent() { |
| 8 | + const { isConnected, address } = useAccount() |
| 9 | + const { connect, connectors } = useConnect() |
| 10 | + |
| 11 | + useEffect(() => { |
| 12 | + const checkContext = async () => { |
| 13 | + console.log('isConnected:', isConnected) |
| 14 | + console.log('address:', address) |
| 15 | + console.log("asking for context") |
| 16 | + const context = await sdk.context |
| 17 | + console.log('context:', context) |
| 18 | + if (context) { |
| 19 | + console.log('client:', context.client) |
| 20 | + } |
| 21 | + } |
| 22 | + void checkContext() |
| 23 | + }, [isConnected, address]) |
| 24 | + |
| 25 | + if (isConnected && address) { |
| 26 | + return ( |
| 27 | + <div style={{ |
| 28 | + padding: '0.5rem 1rem', |
| 29 | + border: '1px solid #d1d5db', |
| 30 | + borderRadius: '8px', |
| 31 | + background: 'white', |
| 32 | + color: '#374151', |
| 33 | + fontSize: '0.875rem', |
| 34 | + fontWeight: '500', |
| 35 | + fontFamily: 'monospace' |
| 36 | + }}> |
| 37 | + {address.slice(0, 6)}...{address.slice(-4)} |
| 38 | + </div> |
| 39 | + ) |
| 40 | + } |
| 41 | + |
18 | 42 | return ( |
19 | | - <div style={{ display: 'flex', justifyContent: 'flex-end'}}> |
20 | | - <Wallet> |
21 | | - <ConnectWallet> |
22 | | - <Name /> |
23 | | - </ConnectWallet> |
24 | | - <WalletDropdown> |
25 | | - <Identity> |
26 | | - <Avatar /> |
27 | | - <Name /> |
28 | | - <Address /> |
29 | | - </Identity> |
30 | | - <WalletDropdownBasename /> |
31 | | - <WalletDropdownDisconnect /> |
32 | | - </WalletDropdown> |
33 | | - </Wallet> |
34 | | - </div> |
| 43 | + <button |
| 44 | + type="button" |
| 45 | + onClick={() => { |
| 46 | + console.log('Connecting to wallet...') |
| 47 | + console.log('Connectors:', connectors) |
| 48 | + connect({ connector: connectors[0] }) |
| 49 | + }} |
| 50 | + style={{ |
| 51 | + padding: '0.75rem 1.5rem', |
| 52 | + border: '1px solid #d1d5db', |
| 53 | + borderRadius: '8px', |
| 54 | + background: 'white', |
| 55 | + color: '#374151', |
| 56 | + fontSize: '1rem', |
| 57 | + fontWeight: '500', |
| 58 | + cursor: 'pointer' |
| 59 | + }} |
| 60 | + > |
| 61 | + Connect |
| 62 | + </button> |
35 | 63 | ) |
36 | 64 | } |
0 commit comments