Skip to content

Commit

Permalink
Merge pull request #687 from etherisc/hotfix/walletconnect-reenable
Browse files Browse the repository at this point in the history
Hotfix/walletconnect reenable
  • Loading branch information
doerfli authored Dec 15, 2023
2 parents 0c4bba1 + 34f09be commit 07b8291
Show file tree
Hide file tree
Showing 9 changed files with 136 additions and 170 deletions.
144 changes: 56 additions & 88 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@
"react-redux": "^8.1.3",
"redis": "^4.6.11",
"redis-om": "^0.4.3",
"viem": "^1.19.11",
"wagmi": "^1.4.10"
"viem": "^1.20.0",
"wagmi": "^1.4.12"
},
"devDependencies": {
"@etherisc/gif-interface": "2.0.0-rc.1-0",
Expand Down
46 changes: 23 additions & 23 deletions src/components/account/account.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default function Account() {
const signer = useSelector((state: RootState) => state.chain.signer);
const { isConnected, isWalletConnect } = useSelector((state: RootState) => state.chain);
const address = useSelector((state: RootState) => state.account.address);
// const { data: walletClient } = useWalletClient();
const { data: walletClient } = useWalletClient();

const [ loggedIn, setLoggedIn ] = useState(false);

Expand All @@ -41,30 +41,30 @@ export default function Account() {


// handle wallet connect connection state (login/logout)
// useEffect(() => {
// console.log("walletClient changed", walletClient);
// async function login() {
// console.log("wallet connect login");
// // const signer = await getEthersSigner({ chainId: parseInt(CHAIN_ID || "1") });
// // if (signer === undefined) {
// // return;
// // }
// // const provider = signer.provider;
// // dispatch(connectChain(await getChainState(provider, true)));
// // setAccountRedux(signer, dispatch);
useEffect(() => {
console.log("walletClient changed", walletClient);
async function login() {
console.log("wallet connect login");
const signer = await getEthersSigner({ chainId: parseInt(CHAIN_ID || "1") });
if (signer === undefined) {
return;
}
const provider = signer.provider;
dispatch(connectChain(await getChainState(provider, true)));
setAccountRedux(signer, dispatch);

// // provider.on("block", (blockNumber: number) => {
// // getAndUpdateBlock(dispatch, provider, blockNumber);
// // });
// }
provider.on("block", (blockNumber: number) => {
getAndUpdateBlock(dispatch, provider, blockNumber);
});
}

// if (walletClient !== undefined && ! loggedIn) {
// login();
// } else if (walletClient === undefined && loggedIn && isWalletConnect) {
// console.log("wallet connect logout")
// dispatch(disconnectChain());
// }
// }, [walletClient, loggedIn, dispatch, isWalletConnect]);
if (walletClient !== undefined && ! loggedIn) {
login();
} else if (walletClient === undefined && loggedIn && isWalletConnect) {
console.log("wallet connect logout")
dispatch(disconnectChain());
}
}, [walletClient, loggedIn, dispatch, isWalletConnect]);


if (! loggedIn) {
Expand Down
4 changes: 2 additions & 2 deletions src/components/account/login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ export default function Login() {
<Grid item xs={12} sx={{ p: 1 }}>
<LoginWithMetaMaskButton closeDialog={() => setShowLoginDialog(false)} />
</Grid>
{/* <Grid item xs={12} sx={{ p: 1 }}>
<Grid item xs={12} sx={{ p: 1 }}>
<LoginWithWalletConnectV2Button closeDialog={() => setShowLoginDialog(false)} />
</Grid> */}
</Grid>
</Grid>
</DialogContentText>
</DialogContent>
Expand Down
Loading

0 comments on commit 07b8291

Please sign in to comment.