2022-06-01 14:21:36 +00:00
|
|
|
import type { ReactNode } from 'react';
|
|
|
|
import { t } from '@vegaprotocol/react-helpers';
|
|
|
|
import { Button, Splash } from '@vegaprotocol/ui-toolkit';
|
|
|
|
import { useVegaWallet } from '@vegaprotocol/wallet';
|
|
|
|
import { useGlobalStore } from '../../stores';
|
|
|
|
|
|
|
|
interface VegaWalletContainerProps {
|
|
|
|
children: ReactNode;
|
|
|
|
}
|
|
|
|
|
|
|
|
export const VegaWalletContainer = ({ children }: VegaWalletContainerProps) => {
|
|
|
|
const store = useGlobalStore();
|
|
|
|
const { keypair } = useVegaWallet();
|
|
|
|
|
|
|
|
if (!keypair) {
|
|
|
|
return (
|
|
|
|
<Splash>
|
|
|
|
<div className="text-center">
|
2022-08-31 04:35:46 +00:00
|
|
|
<p className="mb-4" data-testid="connect-vega-wallet-text">
|
2022-06-01 14:21:36 +00:00
|
|
|
{t('Connect your Vega wallet')}
|
|
|
|
</p>
|
|
|
|
<Button
|
|
|
|
onClick={() => store.setVegaWalletConnectDialog(true)}
|
|
|
|
data-testid="vega-wallet-connect"
|
|
|
|
>
|
|
|
|
{t('Connect')}
|
|
|
|
</Button>
|
|
|
|
</div>
|
|
|
|
</Splash>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return <>{children}</>;
|
|
|
|
};
|