Skip to content

Commit 8299e63

Browse files
committed
trying new wallet button
1 parent 043ab32 commit 8299e63

2 files changed

Lines changed: 60 additions & 31 deletions

File tree

components/Providers.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import { AppConfig, OnchainKitProvider } from "@coinbase/onchainkit";
44
import { base } from "wagmi/chains";
55
import { PropsWithChildren } from "react";
6-
import { createConfig, http, WagmiProvider } from "wagmi";
6+
import { createConfig, http, injected, WagmiProvider } from "wagmi";
77
import { baseAccount } from 'wagmi/connectors';
88
import { farcasterMiniApp as miniAppConnector } from '@farcaster/miniapp-wagmi-connector'
99

@@ -19,7 +19,8 @@ const onchainKitConfig: AppConfig = {
1919

2020
export const config = createConfig({
2121
chains: [base],
22-
connectors: [miniAppConnector(), baseAccount()],
22+
// connectors: [miniAppConnector(), baseAccount()],
23+
connectors: [injected()],
2324
transports: {
2425
[base.id]: http(),
2526
},

components/Wallet.tsx

Lines changed: 57 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,64 @@
11
'use client'
22

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';
166

177
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+
1842
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>
3563
)
3664
}

0 commit comments

Comments
 (0)