diff --git a/app/src/js/components/AppLayout.tsx b/app/src/js/components/AppLayout.tsx index af326be..3303472 100644 --- a/app/src/js/components/AppLayout.tsx +++ b/app/src/js/components/AppLayout.tsx @@ -8,7 +8,7 @@ import Form from './Form/Form'; const AppLayout = () => ( - NFT WebUI + ERC20 WebUI diff --git a/app/src/js/components/MetamaskConnect.tsx b/app/src/js/components/MetamaskConnect.tsx index cc76119..b7788dd 100644 --- a/app/src/js/components/MetamaskConnect.tsx +++ b/app/src/js/components/MetamaskConnect.tsx @@ -11,11 +11,10 @@ export enum ChainId { Rinkeby = '0x4', Goerli = '0x5', Kovan = '0x2a', + Hardhat = '0x7a69', } const MetamaskConnect = () => { - const [chainId, setChainId] = React.useState(); - const { status, connect, @@ -23,6 +22,10 @@ const MetamaskConnect = () => { chainId: currentChainId, switchChain, } = useMetaMask(); + const [chainId, setChainId] = React.useState( + currentChainId as ChainId, + ); + const disabled = ['initializing', 'unavailable', 'connecting', 'connected'].includes( status, @@ -53,6 +56,18 @@ const MetamaskConnect = () => { return undefined; }; + React.useEffect(() => { + if (currentChainId && chainId && currentChainId !== chainId) { + switchChain(chainId); + } + }, [chainId, switchChain]); + + React.useEffect(() => { + if (!chainId) { + setChainId(currentChainId as ChainId); + } + }, [currentChainId]); + return (