vega-frontend-monorepo/libs/web3/src/lib/web3-connect-store.ts
m.ray 7ea7edc1e2
feat(#2565): orderbook populate limit (#2690)
Co-authored-by: asiaznik <artur@vegaprotocol.io>
2023-01-25 11:38:26 -08:00

25 lines
696 B
TypeScript

import { create } from 'zustand';
import type { Web3ReactHooks } from '@web3-react/core';
import type { Connector } from '@web3-react/types';
interface State {
isOpen: boolean;
connectors: [Connector, Web3ReactHooks][];
desiredChainId?: number;
}
interface Actions {
initialize: (connectors: State['connectors'], desiredChainId: number) => void;
open: () => void;
close: () => void;
}
export const useWeb3ConnectStore = create<State & Actions>((set) => ({
isOpen: false,
connectors: [],
initialize: (connectors, desiredChainId) => {
set({ connectors, desiredChainId });
},
open: () => set(() => ({ isOpen: true })),
close: () => set(() => ({ isOpen: false })),
}));