detect-provider
detect-provider copied to clipboard
fix: mustBeMetaMask should not detect brave as MetaMask
Brave Wallet's window.ethereum
sets isMetaMask
to true, hence using the mustBeMetaMask
option here will falsely detect Brave as MM, see:
https://github.com/brave/brave-core/blob/ae4c9dab752c588fc7b5921863f862777a19589d/components/brave_wallet/renderer/js_ethereum_provider.cc#L254-L256
This is a non-standard behavior of Brave as opposed to most MetaMask impersonators setting isMetaMask
to false, hence requires explicit handling. Thankfully, a isBraveWallet
property is also exposed (https://github.com/brave/brave-core/pull/12794), which we can check for to guard against wrongly detecting Brave as MM.