-
-
-
-
+
+
+ Welcome to trading!
+
+
+
-
-
-
-
-
-
+
);
}
-interface VegaWalletButtonProps {
- setConnectDialog: (isOpen: boolean) => void;
-}
-
-const VegaWalletButton = ({ setConnectDialog }: VegaWalletButtonProps) => {
- const { disconnect, keypairs } = useVegaWallet();
- const isConnected = keypairs !== null;
-
- const handleClick = () => {
- if (isConnected) {
- disconnect();
- } else {
- setConnectDialog(true);
- }
- };
-
- return (
-
- );
-};
-
export default VegaTradingApp;
-
-/**
- * Wrapper to interact with the vega wallet out side of the provider itself.
- */
-function VegaWalletManager() {
- // Get keys from vega wallet immediately
- useEagerConnect();
-
- // Do other global stuff with vega wallet here
-
- return null;
-}
-
-function useEagerConnect() {
- const { connect } = useVegaWallet();
-
- useEffect(() => {
- const cfg = LocalStorage.getItem(WALLET_CONFIG);
- const cfgObj = JSON.parse(cfg);
-
- // No stored config, user has never connected or manually cleared storage
- if (!cfgObj || !cfgObj.connector) {
- return;
- }
-
- // Use the connector string in local storage to find the right connector to auto
- // connect to
- const connector = Connectors[cfgObj.connector];
-
- // Developer hasn't provided this connector
- if (!connector) {
- throw new Error(`Connector ${cfgObj?.connector} not configured`);
- }
-
- connect(Connectors[cfgObj.connector]);
- }, [connect]);
-}