- SDK Version: 7.3.0
- Platform: React
- Browser Console Screenshots:
Google login works fine, please help us resolve this
const chainConfig = {
displayName: "Polygon Mainnet",
chainNamespace: CHAIN_NAMESPACES.EIP155,
chainId: "0x89",
//chainId: "0x13881",
rpcTarget: process.env.REACT_APP_POLYGON_RPC_URL,
blockExplorer: "https://polygonscan.com/",
ticker: "MATIC",
tickerName: "Matic",
decimals: 18,
};
const web3AuthHandler = async () => {
const web3AuthInstance = new Web3Auth({
chainConfig,
// get your client id from https://dashboard.web3auth.io
clientId: process.env.REACT_APP_WEB3_AUTH,
});
await web3AuthInstance.initModal();
setWeb3Auth(web3AuthInstance);
};
const connectHanlder = async () => {
try {
if (web3Auth) {
const web3authProvider = await web3Auth.connect()
if (web3authProvider) {
hotjar.initialize(3306401, 6);
setIsConnecting(true)
const web3Provider = new ethers.providers.Web3Provider(web3authProvider);
//const web3 = new Web3(web3authProvider);
const signerVal = web3Provider.getSigner();
const address = await signerVal.getAddress();
const accountInfo = await web3Auth.getUserInfo();
const isSocialLogin = Object.keys(accountInfo).length !== 0
const biconomySmartAccountConfig = {
signer: signerVal,
chainId: ChainId.POLYGON_MAINNET,
bundler: bundler,
paymaster: paymaster,
rpcUrl: process.env.REACT_APP_POLYGON_RPC_URL,
};
let biconomySmartAccount = new BiconomySmartAccount(
biconomySmartAccountConfig
);
biconomySmartAccount = await biconomySmartAccount.init();
const scwAddress = await biconomySmartAccount.getSmartAccountAddress()
setEoaAddress(address?.toLowerCase())
setSmartAccount(biconomySmartAccount);
setProvider(web3Provider);
setSigner(signerVal)
setIsConnected(true);
setSocailLogin(isSocialLogin)
//setWeb3Val(web3);
isSocialLogin ? setSocialInfo(accountInfo) : setSocialInfo(null)
if (scwAddress?.length) {
if (searchParams.get("referralID")?.length) {
connectWalletAddress(scwAddress, searchParams.get("referralID"), isSocialLogin, accountInfo, address?.toLowerCase(), connectWalletCallBack)
} else {
connectWalletAddress(scwAddress, "", isSocialLogin, accountInfo, address?.toLowerCase(), connectWalletCallBack);
}
}
setIsConnecting(false)
return scwAddress;
}
} else return
} catch (err) {
setIsConnecting(false)
//console.log(err, "here")
}
};
useEffect(() => {
async function init() {
await web3AuthHandler();
}
init();
}, []);