2022-03-31 01:08:25 +00:00
|
|
|
import { t } from '@vegaprotocol/react-helpers';
|
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-31 01:08:25 +00:00
|
|
|
{isConnected ? t('Disconnect Vega wallet') : t('Connect Vega wallet')}
|
2022-03-11 00:28:48 +00:00
|
|
|
</button>
|
|
|
|
);
|
|
|
|
};
|