Walletconnect - blocked by CORS policy

thanks for the info.
any idea what is eth_blockNumber? it keeps generating requests to moralis server
image

it looks like it tries to get the last block number, it could do that in order to know when it passed a number of block in order to check if the transaction made it to the chain

anyone can help to solve this?

you say that it makes continuous requests to that wallet connect RCP endpoint?

it will get rate limited if it happens to make a lot requests

yeahā€¦ i understand the needs of rate limit at moralis firewall side.
But I donā€™t understand why this only happens when connect via walletconnect. No such issue with browser extension metamask. I tried tokenpocket browser no issue as well

when using metamask extension, a different RPC url will be used, the one that is added in metamask configuration, and also, metamask may not make the same number of requests

I donā€™t know now why walletconnect would make so many requests to that RPC url, you donā€™t even need to connect to the RPC in order to authenticate, only when you want to make a transaction

1 Like

Hey Kimā€¦was having the same issue. Took me the whole day to get a solution.
Not the best but its workingā€¦

There is a problem with the Wallet_connect web3 provider.
https://github.com/WalletConnect/walletconnect-monorepo/releases/download/1.7.8/web3-provider.min.js

async _updateLatestBlock() {
	const t = await this._fetchLatestBlock();
	this._newPotentialLatest(t)
}

I just saved the file locally and edited this function with a little wait time. The function was called to often so the Request Rate Limit error was caused.

async _updateLatestBlock() {
        console.log("Updating latest Block");
        const waitFor = delay => new Promise(resolve => setTimeout(resolve, delay));
        await waitFor(1500);
	const t = await this._fetchLatestBlock();
	this._newPotentialLatest(t)
}

Not the best solutionā€¦but it works.

3 Likes

I realised walletconnect will start this RPC request as soon as I press ā€œConnectā€ on metamask and will continue do so until I disconnect (localstorage.clear and moralis.user.logout).
My understanding is that walletconnect try query the latest update constantly from the node (moralis in this case) while moralisā€™s firewall (cloudflare) configured to limit the request.

thanks for the workaround. I tried and I even increased it to 60000. 0 Errors! but not usable. Update is too much delay.

Iā€™m now using your workaround and set the delay to 5000 and keep my finger crossed!!

did this work for you ? i have the same issue

what directory did you save this file to? how do i edit it in the npm package.

thanks for this solution, but does that mean if i run npm i on a production version, i wont be able to see the changes?

You could use your own version of the WalletConnect package in your project or patch the change (in node_modules) with something like patch-package.

I ended up using a custom connector and lived happily ever after!

1 Like

Can you please explain, what the custom connector?

A custom connector could be this:
https://v1docs.moralis.io/moralis-dapp/users/web3-login/custom-auth-any-eip1193-provider

Hi @osborn1900, can you share code snippet how you implemented this custom one?
I am using metamask for browser and for mobiles using wallet connect in my React and Next JS dApp.

configuration : moralis-v1 sdk, react-moralis, walletConnect

Hey, I downloaded this file and made the changes, but where do I need to keep this file. I am using @walletconnect/web3-provider package. I am stuck in this @Martinpriv @kim @osborn1900

@DeathStar Did you find a solution bro?

Yes @pushpit07 I did find the solution and its working now.