few days before walletconnect has shut there v1 and migrated to v2
i am following the documentation to authenticate with version 2 but it’s not working
error getting:
"web3-provider.min.js:22 WebSocket connection to ‘wss://g.bridge.walletconnect.org/?env=browser&host=localhost%3A3000&protocol=wc&version=1’ failed: "
here is my code
async function login() {
await Moralis.enableWeb3();
let user = Moralis.User.current();
const { message } = await Moralis.Cloud.run('requestMessage', {
address: Moralis.account,
chain: Moralis.chainId,
network: 'evm',
});
if (!user) {
user = await Moralis.authenticate({
provider: wallet_name,
projectId: '0d0f8b6ad7b84c4fd14a0d7ae139bb9f',
showQrModal: true,
// chainId: 1, // OPTIONAL
// newSession: true, // OPTIONAL
// qrModalOptions: { themeMode: 'light' }, // OPTIONAL
signingMessage: message,
})
.then(async function (user) {
user_address = user.get('ethAddress').substring(0, 6);
const chainId = await Moralis.chainId;
const accepted_chains = ['0x61', '0x38'];
if (accepted_chains.includes(chainId)) {
chain = chainId;
} else {
try {
await Moralis.switchNetwork('0x38');
} catch {
alert(
'Could not connect to Metamask. Please try switching chains.'
);
}
}
// Subscribe to onChainChanged events
const unsubscribe = Moralis.onChainChanged(async (chainId) => {
if (accepted_chains.includes(chainId)) {
chain = chainId;
} else {
try {
await Moralis.switchNetwork('0x38');
} catch {
alert(
'Could not connect to Metamask. Please try switching chains.'
);
}
}
});
})
.catch(function (error) {
console.log(error);
});
}
}
can anyone help me out