Cant Get Is Authenticated and isAuthenticated functions to work when using Wallet Connect

serverURL: https://yvwgzdhsrqkj.moralisweb3.com:2053/server

Code:

function WalletConnectAuthentication() {

  var user = Moralis.Web3.authenticate({ provider: "walletconnect" });
  Moralis.Web3.getSigningData = () => 'Welcome to SpacePath Marketplace! Please sign in to create an account.';

};

Function above is targeteted by an onClick event listener

useEffect(() => {

    if(isAuthenticating){
      setVisibleModal(true);
      setAuthenticaionChecker(false);
      setLoadingMessage("Authenticating through WalletConnect")
    };
    if(isAuthenticated){
      setVisibleModal(false);
      setAuthenticaionChecker(false);
    };
}, [visibleModal, visibleErrorModal, isAuthenticating, isAuthenticated]);

The useEffect works when I use the default authenticate function, but not when I make the provider WalletConnect

Wallet Connect also displays an error when I close out the QR code. If anyone knows how to fix these issues that would be great.

1 Like

Hey @thutch

Thank you for the report. I’ve tested and have the same problem: isAuthenticating doesn’t work with walletConnect. You can create your own state of authenticating event. Something like setLoading() but the Moralis dev team will fix it as soon is it possible :man_mechanic:

Wallet Connect also displays an error when I close out the QR code. If anyone knows how to fix these issues that would be great.

We will add better walletconnect supporting. You need to use try and await for catching error.

  async function WalletConnectAuthentication() {
    try {
      var user = await Moralis.Web3.authenticate({ provider: "walletconnect" });
    } catch (error) {
      if (error == "Error: User closed modal") {
        alert("You have closed modal");
      } else {
        alert(error);
      }
    }
  }

Happy BUIDLing :mage:

Thanks for the help. Appreciate the quick response.

Is there any way to specify the getSigningData function with walletconnect?

Hi, you can check this out over here - https://docs.moralis.io/moralis-server/users/crypto-login#changing-sign-in-message

Hope this helps.