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

Switching chains with uppercase chain ID hex does not work #25707

Closed
yrliou opened this issue Sep 29, 2022 · 2 comments · Fixed by brave/brave-core#15329
Closed

Switching chains with uppercase chain ID hex does not work #25707

yrliou opened this issue Sep 29, 2022 · 2 comments · Fixed by brave/brave-core#15329

Comments

@yrliou
Copy link
Member

yrliou commented Sep 29, 2022

Description

Try to switch to Avalanche network via wallet_switchEthereumChain API fails when chain_id param is 0xA86A, and only works if it is passed as 0xa86a.

Steps to Reproduce

Problem 1:

  1. Open devtool and run window.ethereum.request({method:'wallet_switchEthereumChain', params: [{chainId: '0xA86A'}]})

Problem 2:

  1. Go to brave://settings/wallet/networks and edit the chain ID to be 0xa86A instead of 0xa86a. Save.

Actual result:

Problem 1:

image
And only window.ethereum.request({method:'wallet_switchEthereumChain', params: [{chainId: '0xa86a'}]}) works.

Problem 2:

Gives an error like this: "Request for method 'eth_chainId' on https://api.avax.network/ext/bc/C/rpc failed"

Expected result:

Problem 1:

Wallet panel should prompt user the request for switching to Avalanche network.

Problem 2:

It should save with no errors.

Reproduces how often:

Always

Desktop Brave version:

Android Device details:

  • Install type (ARM, x86):
  • Device type (Phone, Tablet, Phablet):
  • Android version:

Version/Channel Information:

  • Can you reproduce this issue with the current release?
  • Can you reproduce this issue with the beta channel?
  • Can you reproduce this issue with the nightly channel?

Other Additional Information:

  • Does the issue resolve itself when disabling Brave Shields?
  • Does the issue resolve itself when disabling Brave Rewards?
  • Is the issue reproducible on the latest version of Chrome?

Miscellaneous Information:

@yrliou yrliou added OS/Android Fixes related to Android browser functionality OS/Desktop QA/Yes release-notes/exclude feature/web3/wallet Integrating Ethereum+ wallet support feature/web3/wallet/dapps feature/web3/wallet/core priority/P3 The next thing for us to work on. It'll ride the trains. labels Sep 29, 2022
@yrliou yrliou added this to Web3 Sep 29, 2022
@yrliou yrliou moved this to Backlog in Web3 Sep 29, 2022
@bbondy bbondy self-assigned this Oct 3, 2022
@bbondy bbondy changed the title wallet_switchEthereumChain failed for Avalanche network if chain_id is uppercase Switching chains with uppercase chain ID hex does not work Oct 3, 2022
@bbondy bbondy moved this from Backlog to In Review in Web3 Oct 3, 2022
bbondy added a commit to brave/brave-core that referenced this issue Oct 6, 2022
Fix brave/brave-browser#25707

This fixes handling of chain IDs so comparisons are done case
insensitive.  Any adding to data structures happen in a lowercase way.
Data structure lookups happen via lowercase values. And return values
from functions use lowercase always.

This fixes several issues including custom chains in settings with
uppercase values failing to add the chain due to a comparison with
eth_chainId and also wallet_switchEthereumChain with uppercase values.
Repository owner moved this from In Review to Done in Web3 Oct 7, 2022
@bbondy bbondy added this to the 1.46.x - Nightly milestone Oct 7, 2022
@srirambv
Copy link
Contributor

Verification passed on the following devices running 1.46.70 x64 beta build

  • Verified steps from issue description
  • Verified running window.ethereum.request({method:'wallet_switchEthereumChain', params: [{chainId: '0xA86A'}]}) prompts to switch network
  • Verified able to approve or cancel the network switch request
Oppo Reno 5 (Android 12) Samsung Tab A (Android 10)
image image

@srirambv
Copy link
Contributor

Verification passed on

Brave 1.46.81 Chromium: 107.0.5304.68 (Official Build) beta (64-bit)
Revision a4e93e89d3b3df1be22214603fba846ad0183ca5-refs/branch-heads/5304@{#991}
OS Linux
  • Verified steps from issue description
  • Verified running window.ethereum.request({method:'wallet_switchEthereumChain', params: [{chainId: '0xA86A'}]}) prompts to switch network
  • Verified able to approve or cancel the network switch request
  • Verified able to save changes to network without any errors
25707.mp4

Verification passed on

Brave 1.46.81 Chromium: 107.0.5304.68 (Official Build) beta (64-bit)
Revision a4e93e89d3b3df1be22214603fba846ad0183ca5-refs/branch-heads/5304@{#991}
OS Windows 11 Version 22H2 (Build 22621.674)
  • Verified steps from issue description
  • Verified running window.ethereum.request({method:'wallet_switchEthereumChain', params: [{chainId: '0xA86A'}]}) prompts to switch network
  • Verified able to approve or cancel the network switch request
  • Verified able to save changes to network without any errors
25707.mp4

Verification passed on

Brave 1.46.81 Chromium: 107.0.5304.68 (Official Build) beta (arm64)
Revision a4e93e89d3b3df1be22214603fba846ad0183ca5-refs/branch-heads/5304@{#991}
OS macOS Version 13.0 (Build 22A380)
  • Verified steps from issue description
  • Verified running window.ethereum.request({method:'wallet_switchEthereumChain', params: [{chainId: '0xA86A'}]}) prompts to switch network
  • Verified able to approve or cancel the network switch request
  • Verified able to save changes to network without any errors
25707.mov

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

Successfully merging a pull request may close this issue.

3 participants