3box profiles (#9)

* Fix auth

* Added 3box profile info

* Added player names in list

* Added hasura action to fetch verified accounts on 3Box

* Added usernames

* fix router
This commit is contained in:
Pacien Boisson
2020-05-13 10:02:21 +02:00
committed by GitHub
parent 7747ff69d0
commit 214f3f65c2
37 changed files with 9547 additions and 331 deletions

View File

@@ -8,16 +8,18 @@ import {useApolloClient} from '@apollo/react-hooks';
import config from '../config';
import { did } from '@the-game/utils';
import {loginLoading, login, getTokenFromStore} from '../apollo/auth';
import {loginLoading, login, logout, getTokenFromStore} from '../apollo/auth';
type Web3ContextType = {
ethersProvider: Web3Provider | null,
connectWeb3: () => void;
connectWeb3: () => Promise<void>;
disconnect: () => void,
}
export const Web3Context = createContext<Web3ContextType>({
ethersProvider: null,
connectWeb3: () => {},
connectWeb3: async () => {},
disconnect: () => undefined,
});
const providerOptions = {
@@ -75,6 +77,11 @@ const Web3ContextProvider: React.FC = props => {
}
}, [apolloClient, connectDID]);
const disconnect = useCallback(async () => {
web3Modal.clearCachedProvider();
logout(apolloClient);
}, [apolloClient]);
useEffect(() => {
if(web3Modal.cachedProvider) {
connectWeb3().catch(console.error);
@@ -82,7 +89,7 @@ const Web3ContextProvider: React.FC = props => {
}, [connectWeb3]);
return (
<Web3Context.Provider value={{ ethersProvider, connectWeb3 }}>
<Web3Context.Provider value={{ ethersProvider, connectWeb3, disconnect }}>
{props.children}
</Web3Context.Provider>
);