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

refactor: Support permitted chains on permission confirmation page #30443

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

Conversation

Gudahtt
Copy link
Member

@Gudahtt Gudahtt commented Feb 19, 2025

Description

The permissions confirmation page currently ignores the requestedChainIds prop when the connection is confirmed. This hasn't resulted in a bug because this page is only used for snap permissions. Permission requests for eth_account or endowment:permitted-chains are handled by the "ChooseAccount" or "ConnectPage" components (the former if a snap is also requested alongside, the latter otherwise).

This PR fixes the problem regardless, as it's confusing for the component to have this prop but to ignore it when processing the confirmation.

This was extracted from #27782

Open in GitHub Codespaces

Related issues

See this comment for some additional context: https://github.com/MetaMask/metamask-extension/pull/27782/files#r1936463248

Manual testing steps

N/A, the impacted functionality is unreachable.

Screenshots/Recordings

N/A

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.

@Gudahtt Gudahtt force-pushed the fix-permission-connect-requested-chains branch 3 times, most recently from 4efb57b to ea31a68 Compare February 24, 2025 16:38
@Gudahtt Gudahtt marked this pull request as ready for review February 24, 2025 16:59
@metamaskbot
Copy link
Collaborator

Builds ready [ea31a68]
Page Load Metrics (1677 ± 85 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint26018141498400192
domContentLoaded13912174164817986
load14392203167717885
domInteractive28117512914
backgroundConnect971332110
firstReactRender157824168
getState568212110
initialActions01000
loadScripts10081609121214469
setupStore86319189
uiStartup16722503192419795
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: -53 Bytes (-0.00%)
  • common: 0 Bytes (0.00%)

@Gudahtt Gudahtt requested a review from ffmcgee725 February 24, 2025 17:25
const requestedSessionsScopes = getRequestedSessionScopes(
_request.permission,
const requestedCaip25CaveatValue = getRequestedCaip25CaveatValue(
_request.permissions,
Copy link
Member Author

Choose a reason for hiding this comment

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

Looks like this was the main problem - there is no _request.permission. It's _request.permissions. This always blanked out the requested chain IDs in the request.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, we came across and fixed this in the extension part of CAIP-25 merger refactor, but I haven't been able to get it reviewed and merged to main since the recent developments with the team unfortunately 😭

permissions?: PermissionsRequest,
): Pick<Caip25CaveatValue, 'requiredScopes' | 'optionalScopes'> {
): Caip25CaveatValue {
Copy link
Member

@ffmcgee725 ffmcgee725 Feb 25, 2025

Choose a reason for hiding this comment

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

ty for this fix 🙏🏾 amidst the multiple requests to change how this function worked, I eventually must have forgotten to update the actual return value to include isMultichainOrigin 🤦🏾

ffmcgee725
ffmcgee725 previously approved these changes Feb 25, 2025
Copy link
Member

@ffmcgee725 ffmcgee725 left a comment

Choose a reason for hiding this comment

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

lgtm! 🚀

@Gudahtt Gudahtt added the needs-dev-review PR needs reviews from other engineers (in order to receive required approvals) label Feb 25, 2025
@Gudahtt Gudahtt enabled auto-merge February 25, 2025 15:17
itsyoboieltr
itsyoboieltr previously approved these changes Feb 25, 2025
@Gudahtt Gudahtt added this pull request to the merge queue Feb 25, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 25, 2025
@Gudahtt Gudahtt added this pull request to the merge queue Feb 25, 2025
@Gudahtt Gudahtt removed this pull request from the merge queue due to a manual request Feb 25, 2025
The permissions confirmation page currently ignores the
`requestedChainIds` prop when the connection is confirmed. This hasn't
resulted in a bug because this page is only used for snap permissions.
Permission requests for `eth_account` or `endowment:permitted-chains`
are handled by the "ChooseAccount" or "ConnectPage" components (the
former if a snap is also requested alongside, the latter otherwise).

This PR fixes the problem regardless, as it's confusing for the
component to have this prop but to ignore it when processing the
confirmation.

This was extracted from #27782
@Gudahtt Gudahtt force-pushed the fix-permission-connect-requested-chains branch from ea31a68 to e7bda56 Compare February 25, 2025 19:42
@Gudahtt Gudahtt dismissed stale reviews from itsyoboieltr and ffmcgee725 via 4ec183d February 25, 2025 19:50
@Gudahtt
Copy link
Member Author

Gudahtt commented Feb 25, 2025

A lint error was introduced on merge due to the changes in import order in connect-page.tsx in this recently merged PR: #30164

Just an unused import. It has been removed in 4ec183d, read for re-review

@metamaskbot
Copy link
Collaborator

Builds ready [4ec183d]
Page Load Metrics (1776 ± 90 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint15602211178218388
domContentLoaded15292113174617082
load15372211177618790
domInteractive25112442813
backgroundConnect10102302512
firstReactRender1383252010
getState54012105
initialActions01000
loadScripts11351590130813263
setupStore75517178
uiStartup17702348200317685
Bundle size diffs
  • background: 0 Bytes (0.00%)
  • ui: -53 Bytes (-0.00%)
  • common: 0 Bytes (0.00%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-dev-review PR needs reviews from other engineers (in order to receive required approvals) team-wallet-api-platform team-wallet-framework
Projects
Status: Review finalised - Ready to be merged
Development

Successfully merging this pull request may close these issues.

4 participants