-
Notifications
You must be signed in to change notification settings - Fork 2
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
Showing
21 changed files
with
2,741 additions
and
328 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
VITE_WALLET_CONNECT_PROJECT_ID=92fd8c36de7a5e1c7b4f355e9f10268c |
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 @@ | ||
VITE_WALLET_CONNECT_PROJECT_ID=92fd8c36de7a5e1c7b4f355e9f10268c |
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 |
---|---|---|
@@ -1,32 +1,45 @@ | ||
import classes from './index.module.css' | ||
import { FC } from 'react' | ||
import { FC, MouseEventHandler } from 'react' | ||
import { StringUtils } from '../../utils/string.utils' | ||
import { JazzIcon } from '../JazzIcon' | ||
import { useMediaQuery } from 'react-responsive' | ||
import { useWeb3 } from '../../hooks/useWeb3' | ||
import { useWalletConnect } from '../../hooks/useWalletConnect' | ||
|
||
interface Props { | ||
address: string | ||
networkName: string | ||
} | ||
|
||
export const Account: FC<Props> = ({ address, networkName }) => { | ||
const { switchAccount, switchNetwork } = useWalletConnect() | ||
const isXlScreen = useMediaQuery({ query: '(min-width: 1000px)' }) | ||
const { | ||
state: { explorerBaseUrl }, | ||
} = useWeb3() | ||
|
||
const handleSwitchNetwork: MouseEventHandler = e => { | ||
e.preventDefault() | ||
e.stopPropagation() | ||
|
||
switchNetwork() | ||
} | ||
|
||
const url = explorerBaseUrl ? StringUtils.getAccountUrl(explorerBaseUrl, address) : '#' | ||
|
||
return ( | ||
<a href={url} className={classes.account} target="_blank" rel="nofollow noreferrer"> | ||
<JazzIcon size={isXlScreen ? 60 : 30} address={address} /> | ||
<p className={classes.accountDetails}> | ||
<abbr title={address} className={classes.accountAddress}> | ||
{StringUtils.truncateAddress(address)} | ||
</abbr> | ||
<span className={classes.network}>{networkName}</span> | ||
</p> | ||
</a> | ||
<div className={classes.account}> | ||
<JazzIcon onClick={switchAccount} size={isXlScreen ? 60 : 30} address={address} /> | ||
<a className={classes.accountLink} href={url} target="_blank" rel="nofollow noreferrer"> | ||
<p className={classes.accountDetails}> | ||
<abbr title={address} className={classes.accountAddress}> | ||
{StringUtils.truncateAddress(address)} | ||
</abbr> | ||
<span onClick={handleSwitchNetwork} className={classes.network}> | ||
{networkName} | ||
</span> | ||
</p> | ||
</a> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { useContext } from 'react' | ||
import { WalletConnectContext } from '../providers/WalletConnectContext' | ||
|
||
export const useWalletConnect = () => { | ||
const value = useContext(WalletConnectContext) | ||
if (value === undefined) { | ||
throw new Error('[useWalletConnect] Component not wrapped within a Provider') | ||
} | ||
|
||
return value | ||
} |
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
Oops, something went wrong.