Skip to content

fix: issue where user rejected request errors are not correctly handled in either wallet_switchEthereumChain nor wallet_addEthereumChain calls#25269

Merged
adonesky1 merged 1 commit intodevelopfrom
ad/fix/switch-ethereum-chain-error
Jun 12, 2024
Merged

fix: issue where user rejected request errors are not correctly handled in either wallet_switchEthereumChain nor wallet_addEthereumChain calls#25269
adonesky1 merged 1 commit intodevelopfrom
ad/fix/switch-ethereum-chain-error

Conversation

@adonesky1
Copy link
Copy Markdown
Contributor

@adonesky1 adonesky1 commented Jun 12, 2024

Description

A bug was introduced in #24415, where user rejected request errors are not correctly handled in either wallet_switchEthereumChain nor wallet_addEthereumChain calls.

Open in GitHub Codespaces

Related issues

Fixes: Regression in API error handling found on a local run of the new API testing tool, will link report when available.

Manual testing steps

wallet_addEthereumChain

  1. Go to https://docs.metamask.io/wallet/reference/wallet_addethereumchain/
  2. Submit the prepopulated wallet_addEthereumChain request
  3. Confirm the request to add Gnosis Chain
  4. But click "Cancel" on the second request to switch to the newly added chain
  5. You should see null as the response

wallet_switchEthereumChain

  1. Make sure the wallet is on a chain other than gnosis
  2. Go to https://docs.metamask.io/wallet/reference/wallet_switchethereumchain/
  3. Submit the prepopulated switchEthereumChain request (for chainId: 0x64)
  4. Click cancel on the request to switch to gnosis chain
  5. you should see:
{
  "code": 4001,
  "message": "User rejected the request.",
  "stack": "{\n  \"code\": 4001,\n  \"message\": \"User rejected the request.\",\n  \"stack\": \"Error: User rejected the request.\\n  
 }

in the response

Screenshots/Recordings

Before

After

Pre-merge author checklist

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

…d in either wallet_switchEthereumChain nor wallet_addEthereumChain calls
@adonesky1 adonesky1 requested a review from a team as a code owner June 12, 2024 19:05
@github-actions
Copy link
Copy Markdown
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@adonesky1 adonesky1 requested review from jiexi and shanejonas June 12, 2024 19:05
@adonesky1 adonesky1 changed the title Fix issue where user rejected request errors are not correctly handled in either wallet_switchEthereumChain nor wallet_addEthereumChain calls fix: issue where user rejected request errors are not correctly handled in either wallet_switchEthereumChain nor wallet_addEthereumChain calls Jun 12, 2024
@adonesky1 adonesky1 added the team-wallet-api-platform-deprecated DEPRECATED: please use "team-wallet-integrations" instead label Jun 12, 2024
@codecov
Copy link
Copy Markdown

codecov bot commented Jun 12, 2024

Codecov Report

Attention: Patch coverage is 50.00000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 65.61%. Comparing base (e407384) to head (6dd5a0c).

Files Patch % Lines
...method-middleware/handlers/ethereum-chain-utils.js 50.00% 3 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop   #25269      +/-   ##
===========================================
- Coverage    65.62%   65.61%   -0.01%     
===========================================
  Files         1372     1372              
  Lines        54512    54519       +7     
  Branches     14281    14282       +1     
===========================================
+ Hits         35769    35770       +1     
- Misses       18743    18749       +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@metamaskbot
Copy link
Copy Markdown
Collaborator

Builds ready [6dd5a0c]
Page Load Metrics (130 ± 156 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint7211088115
domContentLoaded9211121
load421545130325156
domInteractive9211121

@adonesky1 adonesky1 merged commit d8e0cd1 into develop Jun 12, 2024
@adonesky1 adonesky1 deleted the ad/fix/switch-ethereum-chain-error branch June 12, 2024 20:39
@github-actions github-actions bot locked and limited conversation to collaborators Jun 12, 2024
@metamaskbot metamaskbot added the release-12.1.0 Issue or pull request that will be included in release 12.1.0 label Jun 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-12.1.0 Issue or pull request that will be included in release 12.1.0 team-wallet-api-platform-deprecated DEPRECATED: please use "team-wallet-integrations" instead

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants