forked from project-serum/oyster-swap
-
Notifications
You must be signed in to change notification settings - Fork 0
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
d1bc348
commit 3be4993
Showing
13 changed files
with
733 additions
and
16,023 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,33 @@ | ||
import React, { FunctionComponent } from 'react'; | ||
import { Button, Dropdown, Menu } from 'antd'; | ||
import { useWallet } from '../context/wallet'; | ||
import { ExplorerLink } from './explorerLink'; | ||
|
||
export const WalletConnect: FunctionComponent = ({ children }) => { | ||
const { connected, wallet, select, connect, disconnect } = useWallet(); | ||
const publicKey = (connected && wallet?.publicKey?.toBase58()) || ''; | ||
|
||
const menu = ( | ||
<Menu style={{ textAlign: 'right' }}> | ||
{connected && <ExplorerLink type="address" address={publicKey} style={{ padding: 12 }} />} | ||
<Menu.Item key="3" onClick={select}> | ||
Change Wallet | ||
</Menu.Item> | ||
{connected && <Menu.Item key="2" style={{ color: 'rgba(255, 0, 0, 0.7)' }} onClick={disconnect}> | ||
Disconnect | ||
</Menu.Item>} | ||
</Menu> | ||
); | ||
|
||
if (connected) { | ||
return <Dropdown overlay={menu} trigger={['hover']}> | ||
<div style={{ cursor: 'pointer' }}>{children}</div> | ||
</Dropdown>; | ||
} | ||
|
||
return ( | ||
<Dropdown.Button onClick={connected ? disconnect : connect} overlay={menu}> | ||
{connected ? 'Disconnect' : 'Connect'} | ||
</Dropdown.Button> | ||
); | ||
} |
Oops, something went wrong.