You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
newPromise(async(resolve,reject)=>{// weird async, to be refactoredthis.setupHandlers(resolve,reject)if(this.cachedProvider&&getLocal(RLOGIN_SELECTED_PROVIDER)){awaitthis.providerController.connectToCachedProvider().catch(()=>{this.showModal();reject();})}else{this.showModal();}});
P.S:
I used getLocal which could be imported from web3modal.
If you do not wish to add this condition here (since RLOGIN_SELECTED_PROVIDER is not used in this file but instead it's used in providers.ts, then you can add this condition in here:
Just make sure to show the modal if it fails.. M suggestion to add it to the connect function is to not have to fail and reject to begin with and avoid it all together.
Good catch! We have another proposal for the implementation. Instead of using WEB3_CONNECT_CACHED_PROVIDER for detecting if there is cached provider or not, we can use our own variable and avoid depending on what web3modal did on localStorage. This way, if you migrated from an old app that was using web3modal, you are going to see the modal back once again. This would be hasCachedProvider = localStorage.getItem("RLOGIN_SELECTED_PROVIDER")
Testing: we can create a cypres/integration/4-web3modal-migration and get this properly tested 😄
The only thing to keep in mind is to also make sure that the getter for cachedProvider will return an appropriate value. Right now it returns "injected" for metamask for example.
When a user that used web3modal (which is very popular) before using rLogin AND the
![Screen Shot 2022-03-11 at 1 27 35](https://user-images.githubusercontent.com/1577655/157773469-3770a60c-867a-4ad5-975c-612d6398635f.png)
cacheProvider
option is set totrue
, callingconnect
will fail:This is a serious bug as any user who used web3modal will fail with rLogin.
The way to avoid it is to also check if RLOGIN_SELECTED_PROVIDER is defined on localstorage before calling:
This should be checked here:
rLogin/src/RLogin.tsx
Line 211 in 4a6babe
So a solution could be something like:
This solution also takes care of: #227
P.S:
I used
getLocal
which could be imported fromweb3modal
.If you do not wish to add this condition here (since
RLOGIN_SELECTED_PROVIDER
is not used in this file but instead it's used inproviders.ts
, then you can add this condition in here:rLogin/src/controllers/providers.ts
Line 219 in 4c3f728
Just make sure to show the modal if it fails.. M suggestion to add it to the connect function is to not have to fail and reject to begin with and avoid it all together.
What we did to avoid it for now is:
The text was updated successfully, but these errors were encountered: