Allow rLogin to add supported providers without relying on web3modal #90
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
summary
Adds a method for RSK to add providers to rLogin without having to wait for web3modal to approve and release commits.
initial approach
The initial method was to import and maintain the JSON file locally. However, this wasn't easy and required maintaining multiple files. Our rLogin module connects to web3Modal's ProviderController, which relies on two functions in the utils file that imports the JSON list.
this solution
This approach is a bit different. Since we are only concerned with renaming injected providers, we check them.
After receiving the array of providers, via the steps above, the
checkRLoginInjectedProviders
function checks the first provider if it is named "Web3" or "Metamask". The first provider is always "injected" (if available). If it is named 'Web3' it means that it is not one of web3modal's injected providers and is a default. We can use this to check against our local list.Since it is only checking injected providers named 'web3' & 'Metamask', if web3modal approves a PR with one of our providers, we use web3modals. Then, rLogin needs to clean up the provider in the future. No conflict exists, just extra weight.
Why check for isMetamask?
Math wallet also exposes the
isMetamask
flag and therefore we should run through our local list. This isn't great, but they are exposing this flag for some reason.how to test
I am not sure how to best test this without releasing it. There is currently an issue with MathWallet so it is not a good choice. Read the description on #92. I was unable to investigate further.
The best way to test is with ngrok with the RLogin Sample Apps using npm link. This is not the sample app in this repo since it has an absolute link to http:localhost:3005/main.js which will be broken. When I fired it up with the two dapp browsers, it looks like this: