Skip to content
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

Add isBraveWallet property to window.ethereum #21949

Closed
josheleonard opened this issue Mar 28, 2022 · 10 comments · Fixed by brave/brave-core#12794
Closed

Add isBraveWallet property to window.ethereum #21949

josheleonard opened this issue Mar 28, 2022 · 10 comments · Fixed by brave/brave-core#12794

Comments

@josheleonard
Copy link

josheleonard commented Mar 28, 2022

Description

A standard being used by web3 apps is to check that an injected wallet is present using window.ethereum[is<WalletName>]
eg. window.ethereum.isMetaMask

We already set window.ethereum.isMetaMask to true for compatibility with MetaMask

We should also set window.ethereum.isBraveWallet to true, so that web apps can detect that Brave Wallet is available for connecting

Actual result:

window.ethereum.isMetaMask is true
window.ethereum.isBraveWallet is undefined

Expected result:

window.ethereum.isMetaMask is true
window.ethereum.isBraveWallet is true

Miscellaneous Information:

Example of a library checking for injected providers: https://github.com/Web3Modal/web3modal/blob/master/src/providers/injected/index.ts

@kjozwiak
Copy link
Member

kjozwiak commented Apr 5, 2022

Above requires 1.38.82 or newer for 1.38.x verification.

@LaurenWags LaurenWags added the feature/web3/wallet Integrating Ethereum+ wallet support label Apr 7, 2022
@srirambv
Copy link
Contributor

Brave 1.38.106 Chromium: 101.0.4951.41 (Official Build)
Revision 93c720db8323b3ec10d056025ab95c23a31997c9-refs/branch-heads/4951@{#904}
OS ☑️ Linux ☑️ Windows 11 Version 22H2
(Build 22598.200)
☑️ macOS Version 12.0.1
(Build 21C52)
21949-Linux.mp4
21949-Windows.mov
21949-macOS.mov

@srirambv srirambv removed the OS/Android Fixes related to Android browser functionality label Apr 27, 2022
avinassh pushed a commit to avinassh/brave-browser-hardening that referenced this issue May 29, 2022
 - Added the ability to redirect an AMP page to its canonical non-AMP version. ([#20458](brave/brave-browser#20458))
 - Added "Select network" field in the Brave Wallet "Add custom asset" modal. ([#21656](brave/brave-browser#21656))
 - Added isBraveWallet property to window.ethereum. ([#21949](brave/brave-browser#21949))
 - Added the ability to copy Brave Wallet transaction hash from "Transactions" on the "Portfolio" page. ([#19886](brave/brave-browser#19886))
 - Added confirmation screen after transaction is approved for Brave Wallet. ([#21733](brave/brave-browser#21733))
 - Added bottom padding to the Brave Wallet swap container. ([#21340](brave/brave-browser#21340))
 - Added loading skeletons for various areas within Brave Wallet. ([#21339](brave/brave-browser#21339))
 - Implemented balance updater interval for Brave Wallet. ([#21304](brave/brave-browser#21304))
 - Updated design for Brave Shields. ([#18630](brave/brave-browser#18630))
 - Updated IPFS node to go-ipfs v0.12.0. ([#21219](brave/brave-browser#21219))
 - Updated adblocking to execute all cosmetic scriptlets even if one fails. ([#21932](brave/brave-browser#21932))
 - Updated wording on Brave Wallet backup reminder banner. ([#21312](brave/brave-browser#21312))
 - Updated Brave Wallet swap capability to prevent unnecessarily encountering "Too many decimal places" error. ([#21527](brave/brave-browser#21527))
 - Updated URL for Brave Wallet Ropsten Test Faucet network. ([#21240](brave/brave-browser#21240))
 - Updated Brave Wallet password field to be cleared when an incorrect password is entered. ([#21010](brave/brave-browser#21010))
 - Updated "Portfolio" page of Brave Wallet to return all EVM network tokens. ([#20854](brave/brave-browser#20854))
 - Updated UI to increase spacing between "Assets" and "Transactions" on "Accounts" subview page of Brave Wallet. ([#21532](brave/brave-browser#21532))
 - Updated link text color to blue for Brave Wallet onboarding screen. ([#20302](brave/brave-browser#20302))
 - Updated alignment of options available from the Brave Wallet "More" menu. ([#19680](brave/brave-browser#19680))
 - Renamed "Monthly Contributions" to "Monthly Tips" for Brave Rewards. ([#20564](brave/brave-browser#20564))
 - Removed redirect after adding an account to Brave Wallet from the portfolio asset details screen. ([#19138](brave/brave-browser#19138))
 - Removed referral code from P3A reports. ([#21460](brave/brave-browser#21460))
 - Fixed unexpected storage cleanup on site close when "Clear cookies and site data when you close all windows" is enabled under brave://settings/cookies. ([#22493](brave/brave-browser#22493))
 - Fixed unblocked cookie consent dialogs on some websites when the brave://flags/#brave-adblock-cookie-list-default is enabled. ([#22032](brave/brave-browser#22032))
 - Fixed inability to solve Brave Rewards CAPTCHA in certain cases. ([#22180](brave/brave-browser#22180))
 - Fixed inability to import MetaMask wallet to Brave Wallet. ([#22492](brave/brave-browser#22492))
 - Fixed failed second sign request (eth_signTypedData_v4) for Loopring.io L2 activation when using Brave Wallet. ([#22070](brave/brave-browser#22070))
 - Fixed data on "Portfolio" page of Brave Wallet not being properly displayed due to parsing error. ([#21941](brave/brave-browser#21941))
 - Fixed broken placeholder icons for ERC721 tokens on Brave Wallet "Account" page. ([#21549](brave/brave-browser#21549))
 - Fixed "JSON data is not expected" when trying to import a crypto wallet into Brave Wallet in certain cases. ([#19526](brave/brave-browser#19526))
 - Fixed Brave Wallet network selector list being partially blurred on page load. ([#21423](brave/brave-browser#21423))
 - Fixed Brave Wallet "Add Custom Asset" modal incorrectly being populated with previously added custom token details. ([#21337](brave/brave-browser#21337))
 - Fixed EIP-1559 gas oracle incorrectly firing on non-EIP-1559 networks for Brave Wallet. ([#21107](brave/brave-browser#21107))
 - Fixed Brave Wallet percentage selector remaining selected when input value was updated. ([#20315](brave/brave-browser#20315))
 - Fixed Speedreader icon incorrectly disappearing in certain cases. ([#18243](brave/brave-browser#18243))
 - Fixed inability to exit reader mode when Speedreader is disabled. ([#18242](brave/brave-browser#18242))
 - Upgraded Chromium to 101.0.4951.41. ([#22431](brave/brave-browser#22431)) ([Changelog for 101.0.4951.41](https://chromium.googlesource.com/chromium/src/+log/100.0.4896.127..101.0.4951.41?pretty=fuller&n=1000))
@PvanHengel
Copy link

Hi - we are trying to use this from iOS Mobile, and it does not seem to be set I see @srirambv and @avinassh posted about this, but I have the latest version and it does not seem to be working? Any update on iOS / Android? Is there another way to detect we are using the brave wallet?

@josheleonard
Copy link
Author

Hi - we are trying to use this from iOS Mobile, and it does not seem to be set I see @srirambv and @avinassh posted about this, but I have the latest version and it does not seem to be working? Any update on iOS / Android? Is there another way to detect we are using the brave wallet?

You can try this method for detecting Brave. I verified that isBraveWallet detection is working on Android.

@StephenHeaps
Copy link

Hi - we are trying to use this from iOS Mobile, and it does not seem to be set I see @srirambv and @avinassh posted about this, but I have the latest version and it does not seem to be working? Any update on iOS / Android? Is there another way to detect we are using the brave wallet?

Hey @PvanHengel, thanks for the report. We've opened an issue on the iOS repo to track this.
brave/brave-ios#6059

@devstein
Copy link

devstein commented Mar 15, 2023

Hi -- I updated my browser yesterday and now window.ethereum.isBraveWallet is no longer working. It's breaking connect modals like Picket. Here is the error

window.ethereum.isBraveWallet
VM98:14 Uncaught TypeError: Illegal invocation: Function must be called on an object of type JSEthereumProvider
    at Reflect.get (<anonymous>)
    at Object.get (<anonym

Edit: I meant window.ethereum.isBraveWallet not window.ethereum.isBraveWallet()

@josheleonard
Copy link
Author

Hi -- I updated my browser yesterday and now window.ethereum.isBraveWallet is no longer working. It's breaking connect modals like Picket. Here is the error

window.ethereum.isBraveWallet()
VM98:14 Uncaught TypeError: Illegal invocation: Function must be called on an object of type JSEthereumProvider
    at Reflect.get (<anonymous>)
    at Object.get (<anonym

Hi @devstein,
window.ethereum.isBraveWallet is not a function and is only available when Brave Wallet is the selected "Default Ethereum wallet" option on the brave://settings/web3 settings page.

What version of Brave are you using?
I verified that brave wallet was detected on picketapi.com with version v1.49.120(MacOS)
I was not able to reproduce the error message on picketapi.com

@devstein
Copy link

devstein commented Mar 15, 2023

Hi @josheleonard thank you! Setting brave as the default wallet in brave://settings/web3 fixed it for me. When did this behavior change? window.ethereum.isBraveWallet used to be undefined rather than throw an error. I've been using Brave and window.ethereum.isBraveWallet for almost a year without issue.

For Brave version, I'm also on v1.49.120 (MacOS)

For context, this new behavior also breaks RainbowKit

@josheleonard
Copy link
Author

josheleonard commented Mar 16, 2023

@devstein , this may have been caused by this PR: brave/brave-core#15498
@yrliou is looking into this now

@yrliou
Copy link
Member

yrliou commented Mar 17, 2023

@devstein I can't seem to reproduce on v1.49.120 for that error, what Default Ethereum wallet setting did you have as the brave://settings/web3 before?
I tested with it set as extension and have metamask installed, can connect without issue and running window.ethereum.isBraveWallet in the console returns undefined for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment