Error: Moralis auth failed

Thank you for your help! I appreciate it!
I am refactoring my code currently but so far did not get it work with walletconnect which I am relying on in my mobile dapp.
Earlier it was working fine with the authenticate function by passing in the walletconnect object.
I tried it with
await enableWeb3({ throwOnError: true, provider: 'walletconnect' });
but unfortunately walletconnect does not pop up. Did you manage it?

just curios, what for you need that authentication? getting the user wallet address would be enough?

I would like it to work on mobile as it used to, that means after the authentication is done through walletconnect and the inner metamask I get the user object with the signature and and all the relevant data related to the session which I can use for further authroization for my third party API.
And also I use const connector = useWalletConnect() for all my smart contract interaction in my app which is working fine and wouldnt want to reqwrite all that logic.

is it possible maybe for you to share a code snippet from your modified react native boilerplate? so I can see what I am missing… I guess I adjusted everything what I need to the client, upgraded the versions, but walletconnect does not pop up on when trying crypto auth as before

I have not tried it in that boilerplate - I will see if I can get it working properly.

Did you try making the authentication changes before upgrading?

Yes I did the changes first before upgrading. I needed to refactor the MoralisDappProvider and the CryptoAuth.js to use the new authentication method. I used the versions of the packages that my working web client is also using:
“moralis-v1”: “^1.11.0”,
“react-moralis”: “^1.4.2”,
I am curious if you can get it working and thanks in advance!:slight_smile:

Can you show your package.json (before the moralis / react-moralis upgrades)? Or at least the current one.

yes, sure, I use the basic package.json that is being used by the react native boilerplate moralis project as well.

Then I updated these dependencies:
“react-moralis”: “^1.4.2”, from 0.2.7
“moralis-v1”: “^1.11.0”,

What have you done so far? There are a lot of conflicts with updating to the newer versions - like you mentioned there are quite a few modifications that need to be done. It seems a newer version of moralis is needed as enableWeb3 doesn’t work properly but it may be easier to get the address from the wallet directly with WalletConnect without involving Moralis.

I guess I found the main problem! though there is no fix just yet, but as you also say the moralis version is the key. Not react-moralis… But here is the problem… moralis version cannot be upgraded from 0.0.99 because newer versions are completely different and there is no react native support further, all the moralis/react-native dependencies will break.
I can adjust a signingMessage to the authenticate function like this and it works fine with walletconnect and metamask:

const msg= 'My little signingMessage'
const handleCryptoLogin = () => {
    authenticate({ connector, signingMessage: msg })
      .then(() => {
        if (authError) {
          setErrortext(authError.message);
          setVisible(true);
        } else {
          if (isAuthenticated) {
            navigation.replace("DrawerNavigationRoutes");
          }
        }
      })
      .catch(() => {});
  };

And now there is only one thing I need to figure out, how to get the signingMessage from my parse server which can be done according to the doc through moralis-v1 dependency is needed here but it does not break anything:

Moralis.start({ appId: '001', serverUrl: 'https://myparseserver.com/server'})

const { message } = await Moralis.Cloud.run('requestMessage', {
  address: '0x31835bra1F5088Fc991a9b77dfFE67E1cfC7538',
  chain: parseInt("0x5", 16),
  networkType: 'evm',
})

 Moralis.Cloud.run('requestMessage', {
  address: '0x31835bra1F5088Fc991a9b77dfFE67E1cfC7538',
  chain: parseInt("0x5", 16),
  networkType: 'evm',
}).then(x => console.log(x));

But I get this error now:
‘Unhandled promise rejection [ReferenceError: Can’t find variable: localStorage]’

I am stuck but I think I only need to get this from the server, pass the message to this authenticate function and it will work just fine. If I can get the request message working, I think I would write my own cloud function and invoke it via url directly to call my parse server, that should also work if I am correct?
What you think?