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

fix: bring back exception if invalid address passed in eth_accounts #30213

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

ffmcgee725
Copy link
Member

@ffmcgee725 ffmcgee725 commented Feb 7, 2025

This commit fixes the following issue which is currently a release blocker for v12.12.9

The eth accounts and permitted chains caveat validation in this PR was originally removed as part of the CAIP-25 Permission Migration PR here, but is being restored in order to fix a regression in the API behavior. Originally, making a wallet_requestPermissions request with invalid caveat values for eth_accounts or endowment:permitted-chains would result in an immediate error returned back to the dapp specifying which value was invalid, i.e. not found in the wallet. This PR restores that behavior.
Additionally, the changes in this PR are temporary and will be removed as part of a follow up refactor that cleans up the CAIP-25 approval/request permission flow.

Description

Open in GitHub Codespaces

Related issues

Fixes:

Manual testing steps

Unlock MM
Open test dapp console
Paste the following command
See error

Screenshots/Recordings

Before

After

Screen.Recording.2025-02-07.at.19.54.15.mov

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.

@ffmcgee725 ffmcgee725 requested a review from jiexi February 7, 2025 18:59
@ffmcgee725 ffmcgee725 marked this pull request as ready for review February 7, 2025 19:00
* @param {string[]} accounts - The accounts associated with the caveat.
* @param {() => Record<string, import('@metamask/keyring-internal-api').InternalAccount>} getInternalAccounts -
* Gets all AccountsController InternalAccounts.
* TODO: Remove this function once permission refactor/factory differ work is merged into main
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* TODO: Remove this function once permission refactor/factory differ work is merged into main
* TODO: Remove this function once the CAIP-25 permission refactor/factory differ work is merged into main

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved in c9df79b

Comment on lines 1676 to 1678
PermissionSpecifications.validateCaveatAccounts.mockImplementation(
() => ({}),
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to specify anything at all for validateCaveatAccounts? The default mock already does not throw

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in this case we do, otherwise the mock from the previous block persists and we throw the accounts error instead of the chains one

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

odd... well being extra explicit in tests is fine with me. can we make this return undefined instead of empty object? (nit)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved in 7a9a4a3

@ffmcgee725 ffmcgee725 requested a review from jiexi February 7, 2025 19:15
@metamaskbot
Copy link
Collaborator

❌ API Spec Test Failed. View the report here.

@metamaskbot
Copy link
Collaborator

❌ API Spec Test Failed. View the report here.

@metamaskbot
Copy link
Collaborator

Builds ready [84df286]
Page Load Metrics (1743 ± 70 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint49420381674308148
domContentLoaded14872021171815173
load15342040174314770
domInteractive2593372110
backgroundConnect116027168
firstReactRender1695362512
getState558232010
initialActions00000
loadScripts10681516124912560
setupStore663212110
uiStartup17192404202520598
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 363 Bytes (0.01%)
  • ui: 0 Bytes (0.00%)
  • common: 841 Bytes (0.01%)

@metamaskbot
Copy link
Collaborator

Builds ready [6a7ef36]
Page Load Metrics (1725 ± 42 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint23118771652336161
domContentLoaded1590182316867737
load1604187917258742
domInteractive2486392010
backgroundConnect10109422813
firstReactRender1793342512
getState55820199
initialActions01000
loadScripts1101136912138239
setupStore75917178
uiStartup17942320197413665
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 365 Bytes (0.01%)
  • ui: 0 Bytes (0.00%)
  • common: 841 Bytes (0.01%)

@metamaskbot
Copy link
Collaborator

Builds ready [7a9a4a3]
Page Load Metrics (1515 ± 45 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint29317751461283136
domContentLoaded1361171814968642
load1369177915159545
domInteractive1795472512
backgroundConnect86323157
firstReactRender1482402512
getState3509105
initialActions01000
loadScripts959129910917838
setupStore7511095
uiStartup15392171172214369
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 365 Bytes (0.01%)
  • ui: 0 Bytes (0.00%)
  • common: 841 Bytes (0.01%)

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

Successfully merging this pull request may close these issues.

3 participants