Then, you can get “userInfo” from the web3Auth context. But, I had to do a weird hack to get the fully updated web3AuthInstance. I had to use a useEffect with wagmi’s “walletClient” in the dependency array:
import { useWalletClient } from "wagmi";
import { useWeb3Auth } from "@/app/provider/ContextProvider";
const { data: walletClient } = useWalletClient();
let web3Auth = useWeb3Auth();
useEffect(() => {
const getUserInfo = async () => {
try {
var userInfo = await web3Auth?.getUserInfo();
} catch (e) {
console.log("Cannot get userInfo first time, likely web3Auth not fully updated");
}
console.log("/app, userInfo", userInfo);
};
getUserInfo();
}, [walletClient]);
I would appreciate any feedback if there is a better way, particularly in getting the fully updated web3AuthInstance. Thanks.