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.
Explicitly not part of this spec:
The work can be cleanly divided into 4 areas:
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
, and MetaMask
if it is installed. The default will be Ask
until an explicit option is set. The new preference will be stored with the pref name of brave.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 work
If 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.
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
via MigrateObsoleteBrowserPrefs
.
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)Test plan being added in wiki here
https://github.com/brave/qa-resources/wiki/%5BWIP%5D-Multiple-Web3-provider-support-test
None at this time.
This is such a well-written issue, holy cow.
Verification passed on
Brave | 1.5.109 Chromium: 80.0.3987.132 (Official Build) beta (64-bit)
-- | --
Revision | fcea73228632975e052eb90fcf6cd1752d3b42b4-refs/branch-heads/3987@{#974}
OS | Windows 10 OS Version 1803 (Build 17134.1006)
Clean profile:
Ask
, None
and Crypto Wallets
options when MM isn't installed. By default, the Ask
option is selectedAsk
, None
, Crypto Wallets
and Metamask
options when MM is installed. By default, the Ask
option is selectedAsk
Ask
to Crypto Wallet
when MM is installed and Use Crypto Wallet
option is selected from the infobar on Dapp pageMetamask
option is not shown in the dropdown when MM is removed from braveNone
is selected in settingsAsk
to MetaMask
when MM is installed and Use MetaMask
option is selected from the infobar on Dapp pageCrypto Wallet
from web3 provider dropdown, verified that the infobar is not shown on the Dapp page and only Crypto Wallets
will be used as a web3 provider.MetaMask
from web3 provider dropdown, verified that the infobar is not shown on the Dapp page and only MetaMask
will be used as a web3 provider.Crypto Wallet
on Dapp page when MM is not installed. Also verified that click on Setup
navigates to brave://wallets which allows creating CW and option Crypto Wallet
will be selected in web3 provider dropdownUse Crypto Wallet
and Use MetaMask
options in Dapp page and default option Ask
in settings remained unchangedUse Crypto Wallet
and Use MetaMask
options in Dapp page and default option Ask
in settings remained unchangedSetup CW to interact with this app and others like it
and default option Ask
in settings remained unchangedAsk
option in the dropdown as expected.Ask
option in the dropdown as expected.Setup
and create a crypto wallet (download component + create wallet), verified that the Web3 provider is showing Crypto Wallet
option in the dropdown as expected.Upgrade Profile
Crypto Wallet
is selected in the web3 provider dropdown instead of Ask
- Logged https://github.com/brave/brave-browser/issues/8656Crypto Wallets
is disabled in 1.4.x and MetaMask is installed, after upgrade to 1.5.x, the default option is set to MetaMask
in the web3 provider dropdown.Crypto Wallets
is disabled in 1.4.x and MetaMask is not installed, after upgrade to 1.5.x, the default option is set to None
in the web3 provider dropdown in settings.Crypto Wallet
is selected in the web3 provider dropdownCrypto Wallet
is selected in the web3 provider dropdownCrypto Wallet
selected in the dropdown instead of Ask
- added scenario in https://github.com/brave/brave-browser/issues/8656Crypto Wallet
selected in the dropdown instead of Ask
- added scenario in https://github.com/brave/brave-browser/issues/8656Use MetaMask
option from infobar and then upgrade to 1.5.x. after upgrade verified that MetaMask
is selected in the web3 provider dropdown.Use CryptoWallet
option from infobar in 1.4.x and then upgrade to 1.5.x. after upgrade verified that Crypto wallet
is selected in the web3 provider dropdown.Setup
in the infobar which enables Cryptowallet (just component download) and then upgrade to 1.5.x, after upgrade verified that Crypto wallet
is selected in the web3 provider dropdown.Verification passed on
Brave | 1.5.111 Chromium: 80.0.3987.132 (Official Build) (64-bit)
-- | --
Revision | fcea73228632975e052eb90fcf6cd1752d3b42b4-refs/branch-heads/3987@{#974}
OS | Linux
Clean profile:
Ask
, None
and Crypto Wallets
options when MM isn't installed. By default, the Ask
option is selectedVerified that the drop-down menu shows Ask
, None
, Crypto Wallets
and Metamask
options when MM is installed. By default, the Ask
option is selected
Verified that the infobar is shown on a Dapp page to use Web3 providers when MM is installed in brave and the default option is Ask
Verified that the infobar is not removed until one of the Web3 provider is selected on Dapp page
Ask
to Crypto Wallet
when MM is installed and Use Crypto Wallet
option is selected from the infobar on Dapp pageMetamask
option is not shown in the dropdown when MM is removed from braveNone
is selected in settingsMetaMask
when MM is installed and Use MetaMask option is selected from the infobar on Dapp pageCrypto Wallet
from web3 provider dropdown, verified that the infobar is not shown on the Dapp page and only Crypto Wallets
will be used as a web3 provider.MetaMask
from web3 provider dropdown, verified that the infobar is not shown on the Dapp page and only MetaMask
will be used as a web3 provider.Crypto Wallet
on Dapp page when MM is not installed. Also verified that click on Setup
navigates to brave://wallets which allows creating CW and option Crypto Wallet
will be selected in web3 provider dropdownUse Crypto Wallet
and Use MetaMask
options in Dapp page and default option Ask
in settings remained unchangedUse Crypto Wallet
and Use MetaMask
options in Dapp page and default option Ask
in settings remained unchangedSetup CW to interact with this app and others like it
and default option Ask
in settings remained unchangedAsk
option in the dropdown as expected.Ask
option in the dropdown as expected.Setup
and create a crypto wallet (download component + create wallet), verified that the Web3 provider is showing Crypto Wallet
option in the dropdown as expected.Upgrade Profile
Crypto Wallet
is selected in the web3 provider dropdown instead of Ask
- Encountered #8656Crypto Wallets
is disabled in 1.4.x and MetaMask is installed, after upgrade to 1.5.x, the default option is set to MetaMask
in the web3 provider dropdown.Crypto Wallets
is disabled in 1.4.x and MetaMask is not installed, after upgrade to 1.5.x, the default option is set to None
in the web3 provider dropdown in settings.CryptoWallets
is enabled and wallet created in 1.4.x and MetaMask is not installed, after upgrade t 1.5.x, the default option Crypto Wallet
is selected in the web3 provider dropdownCryptoWallets
is enabled (just component download don't create wallet) and MetaMask is not installed in 1.4.x, after upgrade to 1.5.x, the option Crypto Wallet
is selected in the web3 provider dropdownCrypto Wallet
selected in the dropdown instead of Ask
- Encountered https://github.com/brave/brave-browser/issues/8656Use MetaMask
option from infobar and then upgrade to 1.5.x. after upgrade verified that MetaMask
is selected in the web3 provider dropdown.Use CryptoWallet
option from infobar in 1.4.x and then upgrade to 1.5.x. after upgrade verified that Crypto wallet
is selected in the web3 provider dropdown.Setup
in the infobar which enables Cryptowallet (just component download) and then upgrade to 1.5.x, after upgrade verified that Crypto wallet
is selected in the web3 provider dropdown.Verification PASSED on macOS 10.15.3 x64 Catalina
using the following build:
Brave | 1.5.112 Chromium: 80.0.3987.132Â (Official Build)Â (64-bit)
-- | --
Revision | fcea73228632975e052eb90fcf6cd1752d3b42b4-refs/branch-heads/3987@{#974}
OS | macOS Version 10.15.3 (Build 19D76)
Basically went through all the cases that @GeetaSarvadnya outlined above and @bbondy outlined via https://github.com/brave/brave-browser/issues/7503#issue-541101168. 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 brave.wallet.web3_provider
in chrome://prefs-internals/
- I have verified in both clean and upgraded profiles. let me know if I am missing anything.
Most helpful comment
This is such a well-written issue, holy cow.