When I switch accounts from my MetaMask I get to confirm whether the address is my account and connect it. However, on the second instance my function gets fired upon onAccountsChanged
event, I get the following error:
Here is my onAccountsChanged
event:
function monitorAccount(){
Moralis.onAccountsChanged(async function (accounts) {
const confirmed = confirm("Link this address to your account?");
if (confirmed) {
await Moralis.link(accounts[0]);
document.getElementById("address").innerHTML = accounts[0];
if(chainID == 137){
updateTableBalances();
} else {
updateTableBalances(true);
}
}
});
}
Really what I want is a smooth seamless experience where depending on the account switched to, I re-populate a table comprising on the user’s balances and show their current account address on the page (which is working thus far).