hi, i am working in multiple wallet authentication using react moralis, metamask and coinbase is working fine but walletconnect is not working although while scanning with QR code it’s connecting but while sign in it’s connecting to by default coinbase if i sign in then it’s showing error
can anyone please help me out from this
let moralisAuth;
function getWallet() {
if (typeof web3 !== "undefined") {
//authenticate({ signingMessage: "Please Sign In" });
setIsAuthOpen(true);
} else {
setIsModalOpen(true);
}
}
function activateInjectedProvider(providerName) {
const { ethereum } = window;
if (!ethereum?.providers) {
return undefined;
}
let provider;
switch (providerName) {
case "Coinbase":
provider = ethereum.providers.find(
({ isCoinbaseWallet }) => isCoinbaseWallet
);
break;
case "Metamask":
provider = ethereum.providers.find(({ isMetaMask }) => isMetaMask);
break;
default:
return;
}
if (provider) {
ethereum.setSelectedProvider(provider);
}
}
const handleAuth = async (
provider:
| "metamask"
| "coinbase"
| "walletconnect"
| "magicLink"
| "web3Auth" = "metamask"
) => {
activateInjectedProvider(provider);
try {
setAuthError(null);
setIsAuthenticating(true);
// Enable web3 to get user address and chain
await enableWeb3({ throwOnError: true, provider });
const { account, chainId } = Moralis;
if (!account) {
throw new Error(
"Connecting to chain failed, as no connected account was found"
);
}
if (!chainId) {
throw new Error(
"Connecting to chain failed, as no connected chain was found"
);
}
// Get message to sign from the auth api
const { message } = await Moralis.Cloud.run("requestMessage", {
address: account,
chain: parseInt(chainId, 16),
networkType: "evm",
});
// Authenticate and login via parse
await authenticate({
signingMessage: message,
throwOnError: true,
});
} catch (error) {
setAuthError(error);
alert(error);
} finally {
setIsAuthenticating(false);
setIsAuthOpen(false);
}
};