diff --git a/src/components/Body/index.tsx b/src/components/Body/index.tsx index c497309..e7f39bc 100644 --- a/src/components/Body/index.tsx +++ b/src/components/Body/index.tsx @@ -55,14 +55,14 @@ function Body() { const [tenderlyForkId, setTenderlyForkId] = useState(""); useEffect(() => { - const session = getCachedSession(); + const { session, _showAddress } = getCachedSession(); if (session) { let _connector = new WalletConnect({ session }); if (_connector.peerMeta) { try { setConnector(_connector); - setShowAddress(_connector.accounts[0]); + setShowAddress(_showAddress ? _showAddress : _connector.accounts[0]); setAddress(_connector.accounts[0]); setUri(_connector.uri); setPeerMeta(_connector.peerMeta); @@ -86,6 +86,9 @@ function Body() { setProvider( new ethers.providers.JsonRpcProvider(process.env.REACT_APP_PROVIDER_URL) ); + + const storedTenderlyForkId = localStorage.getItem("tenderlyForkId"); + setTenderlyForkId(storedTenderlyForkId ? storedTenderlyForkId : ""); }, []); useEffect(() => { @@ -95,15 +98,14 @@ function Body() { // eslint-disable-next-line }, [connector]); - useEffect(() => { - const storedTenderlyForkId = localStorage.getItem("tenderlyForkId"); - setTenderlyForkId(storedTenderlyForkId ? storedTenderlyForkId : ""); - }, []); - useEffect(() => { localStorage.setItem("tenderlyForkId", tenderlyForkId); }, [tenderlyForkId]); + useEffect(() => { + localStorage.setItem("showAddress", showAddress); + }, [showAddress]); + const resolveAndValidateAddress = async () => { let isValid; let _address = address; @@ -143,6 +145,9 @@ function Body() { const getCachedSession = () => { const local = localStorage ? localStorage.getItem("walletconnect") : null; + const _showAddress = localStorage + ? localStorage.getItem("showAddress") + : null; let session = null; if (local) { @@ -152,7 +157,7 @@ function Body() { throw error; } } - return session; + return { session, _showAddress }; }; const initWalletConnect = async () => {