2022-03-14 13:18:11 +00:00
|
|
|
import { useVegaWallet } from '@vegaprotocol/wallet';
|
2022-03-11 00:28:48 +00:00
|
|
|
|
|
|
|
interface VegaWalletButtonProps {
|
|
|
|
setConnectDialog: (isOpen: boolean) => void;
|
|
|
|
}
|
|
|
|
|
|
|
|
export const VegaWalletButton = ({
|
|
|
|
setConnectDialog,
|
|
|
|
}: VegaWalletButtonProps) => {
|
|
|
|
const { disconnect, keypairs } = useVegaWallet();
|
|
|
|
const isConnected = keypairs !== null;
|
|
|
|
|
|
|
|
const handleClick = () => {
|
|
|
|
if (isConnected) {
|
|
|
|
disconnect();
|
|
|
|
} else {
|
|
|
|
setConnectDialog(true);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
return (
|
2022-03-24 18:08:57 +00:00
|
|
|
<button
|
|
|
|
onClick={handleClick}
|
|
|
|
className="ml-auto inline-block text-ui sm:text-body-large"
|
|
|
|
>
|
2022-03-11 00:28:48 +00:00
|
|
|
{isConnected ? 'Disconnect' : 'Connect Vega wallet'}
|
|
|
|
</button>
|
|
|
|
);
|
|
|
|
};
|