-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve compatibility with MetaMask and allow web3 provider selection #7503
Comments
This is such a well-written issue, holy cow. |
This implements the spec changes needed for better compatibility with Brave: brave/brave-browser#7503 It makes it so both extensions can co-exist.
Verification passed on
Clean profile:
Upgrade Profile
Verification passed on
Clean profile:
Upgrade Profile
Verification PASSED on
Basically went through all the cases that @GeetaSarvadnya outlined above and @bbondy outlined via #7503 (comment). I had more detailed notes but lost them when attempting to update this post and hit a merge conflict. After I refreshed, everything was gone. Notes were basically similar to @GeetaSarvadnya. |
@bbondy: I don't see new pref name |
Objective
In Brave, if the user has MetaMask installed, we currently show an infobar on a Dapp page that asks the user to disable one of either Crypto Wallets or MetaMask.
This is over disabling functionality that we don’t need to, when really we should just be asking which web3 provider they want to use for that page. The current implementation also allows for various edge cases where users can be in a stuck broken state when trying to use Dapps.
This is intended to allow Crypto Wallets to remain enabled, and to improve the frustrations that users encounter by having two web3 providers installed. It also enables us to keep other future functionality enabled as we enhance Crypto Wallets for things like exchange integrations.
Future enhancements / iterations
Explicitly not part of this spec:
Targeted platforms
Description
The work can be cleanly divided into 4 areas:
Settings work
The old settings switch to turn off Crypto Wallets will be removed. See the next section on Migration work to see how the existing user choice will be handled.
The options for the drop down menu will be:
Ask
,None
,Crypto Wallets
, andMetaMask
if it is installed. The default will beAsk
until an explicit option is set. The new preference will be stored with the pref name ofbrave.wallet.web3_provider
in per-profile prefs which are visible in chrome://prefs-internals/. If the user explicitly uses Brave wallet first and opts in and the setting is set to Brave, then even installing MetaMask later won’t change the setting from Brave.If
Ask
is selected, UI will be shown as per the section on Infobar workIf
None
is selected, the entire extension will always be lazy loaded, even if it is installed.If
Crypto Wallets
is selected, only Crypto Wallets will be used as a web3 provider.If
MetaMask
is selected, only MetaMask will be used as a web3 provider.Migration work
Some users in the past had seen the old infobar and selected either to use MetaMask or Crypto Wallets. We have only in the past actively disabled Crypto Wallets, so no one will have MetaMask disabled by us.
A one time migration will be done to determine which value should be used for the new setting
brave.wallet.web3_provider
.An automated test will be added for each of these migration cases to ensure they work correctly.
Migration code will be added in
chrome/browser/prefs/browser_prefs.cc
viaMigrateObsoleteBrowserPrefs
.Infobar work
If MetaMask is not installed, the existing UX will continue to be valid:
If MetaMask is installed, the existing infobar UX highlighted in the Objective section will be repurposed to the following.
Closing the infobar will use neither provider, it will keep the setting mentioned in the last section to “Ask”.
If the user’s setting is “None”, no infobar will be shown.
Depending on which option is selected, the setting mentioned above will be set to either “Crypto Wallets” or “MetaMask”. “None” can only be set from the settings page.
Adding an API to obtain the web3 provider
A new API will be exposed to both Crypto Wallets and MetaMask:
chrome.cryptoWallets.getWeb3Provider((extensionId) => {})
The other APIs available within
chrome.cryptoWallets
will NOT be accessible to MetaMask.It will return the
extensionId
for the provider to use or a blank string.A web3 provider should only inject existing MetaMask code that provides web3 to the page if its extensionId matches the return value from
chrome.cryptoWallets.getWeb3Provider
.Possible values for the
extensionId
in the above callback will be:nkbihfbeogaeaoehlefnkodbefgpgknn
(metamask)odbfpeeihdkbihmopkbjmoonfanlbfcl
(Brave)QA plan
Test plan being added in wiki here
https://github.com/brave/qa-resources/wiki/%5BWIP%5D-Multiple-Web3-provider-support-test
Open Questions
None at this time.
The text was updated successfully, but these errors were encountered: