Skip to content

Commit 3132105

Browse files
committed
try preferred connector approach
1 parent 15f936f commit 3132105

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

components/Wallet.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
import { useAccount } from 'wagmi'
44
import { useConnect } from 'wagmi'
55
import { useDisconnect } from 'wagmi'
6+
import { config } from './Providers'
67

78

89
export function WalletComponent() {
910
const { isConnected, address } = useAccount()
10-
const { connect, connectors } = useConnect()
11+
const { connect, connectors } = useConnect({ config })
1112
const { disconnect } = useDisconnect()
1213

1314
console.log('connectors:', connectors)
@@ -34,11 +35,20 @@ export function WalletComponent() {
3435
</div>
3536
)
3637
}
38+
39+
3740

3841
return (
3942
<button
4043
type="button"
41-
onClick={() => connect({ connector: connectors[0] })}
44+
onClick={() => {
45+
const preferredConnector = connectors.find(c =>
46+
c.name.toLowerCase().includes('base') ||
47+
c.name.toLowerCase().includes('farcaster')
48+
) || connectors[0]
49+
50+
connect({ connector: preferredConnector })
51+
}}
4252
style={{
4353
padding: '0.5rem 1rem',
4454
border: '1px solid #d1d5db',

0 commit comments

Comments
 (0)