generated from blockmatic-icebox/powerstack
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d261327
commit 6a2ce8d
Showing
14 changed files
with
118 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
'use client' | ||
import { useConnect, useConnectors } from 'wagmi' | ||
import { Button } from './ui/button' | ||
|
||
export function ConnectWalletButton() { | ||
const connectors = useConnectors() | ||
const { connect } = useConnect() | ||
|
||
const handleConnect = async () => { | ||
// Find the WalletConnect connector | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
const injectedConnector = connectors.find(connector => connector.id === 'injected') | ||
if (injectedConnector) { | ||
await connect({ connector: injectedConnector }) | ||
} | ||
} | ||
|
||
return ( | ||
<div> | ||
<Button onClick={handleConnect} disabled={false}> | ||
Connect Wallet | ||
</Button> | ||
{/* {error && <p style={{ color: 'red' }}>{error.message}</p>} */} | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
'use client' | ||
import { useAccount, useConnect, useConnectors } from 'wagmi' | ||
import { Button } from './ui/button' | ||
import { formatAddress } from '@/lib/utils' | ||
import { useEffect, useState } from 'react' | ||
|
||
export function ConnectWalletButton() { | ||
const connectors = useConnectors() | ||
const { connect } = useConnect() | ||
const { address } = useAccount() | ||
|
||
const [formattedAddress, setFormattedAddress] = useState('') | ||
|
||
const handleConnect = async () => { | ||
// Find the WalletConnect connector | ||
const injectedConnector = connectors.find( | ||
connector => connector.id === 'injected' | ||
) | ||
if (injectedConnector) { | ||
await connect({ connector: injectedConnector }) | ||
} | ||
} | ||
|
||
// https://nextjs.org/docs/messages/react-hydration-error | ||
useEffect(() => { | ||
setFormattedAddress(address ? formatAddress(address) : 'Connect Wallet') | ||
}, [address]) | ||
|
||
return ( | ||
<div> | ||
<Button onClick={handleConnect} disabled={false}> | ||
{formattedAddress} | ||
</Button> | ||
{/* {error && <p style={{ color: 'red' }}>{error.message}</p>} */} | ||
</div> | ||
) | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters