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: connection Flow to use CAIP25 Permission format #29824

Merged
merged 60 commits into from
Jan 29, 2025

Conversation

ffmcgee725
Copy link
Member

@ffmcgee725 ffmcgee725 commented Jan 21, 2025

For part of our collaboration with the Snaps team to enable Non EVM multichain API we are refactoring the connection flow UI.

The first step to enable this to modify what the connection confirmation UI components receive from the ApprovalController.
Currently they receive an object like this:

{
    "eth_accounts": {
        "caveats": [
            {
                "type": "restrictReturnedAccounts",
                "value": []
            }
        ]
    },
    "endowment:permitted-chains": {
        "caveats": [
            {
                "type": "restrictNetworkSwitching",
                "value": []
            }
        ]
    }
}

Basically the params for a wallet_requestPermission request.

We want to change this so that instead they receive (and know how to interpret) a CAIP25 formatted request like:

{
    "eip155:1": {
        "accounts": []  // there may be accounts here but often will not be
    },
    "eip155:10": {
        "accounts": []
    },
}

Description

Open in GitHub Codespaces

Related issues

Fixes:

Manual testing steps

  1. Send the following request
await window.ethereum.request({
 "method": "wallet_requestPermissions",
 "params": [
  {
    
    "eth_accounts": {
        "caveats": [
            {
                "type": "restrictReturnedAccounts",
                "value": []
            }
        ]
    },
    "endowment:permitted-chains": {
        "caveats": [
            {
                "type": "restrictNetworkSwitching",
                "value": []
            }
        ]
    }
  }
],
});


  1. Wallet extension UI should prompt user to give permissions to accounts / chains and edit if desired or confirm to proceed.

Screenshots/Recordings

Screen.Recording.2025-01-23.at.17.18.17.mov

NOTE: Don't mind different screens in the UI, this vid is outdated and all UI screens are same as main branch

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.

@ffmcgee725 ffmcgee725 changed the base branch from jl/caip-multichain-migrate-core to main January 23, 2025 16:13
@ffmcgee725 ffmcgee725 force-pushed the jc/caip25-permission-refactor branch from 5218ea4 to f771a58 Compare January 23, 2025 16:13
@ffmcgee725 ffmcgee725 changed the title Refactor Connection Flow to use CAIP25 Permission format Refactor: Connection Flow to use CAIP25 Permission format Jan 23, 2025
@ffmcgee725 ffmcgee725 changed the title Refactor: Connection Flow to use CAIP25 Permission format refactor: Connection Flow to use CAIP25 Permission format Jan 23, 2025
@ffmcgee725 ffmcgee725 changed the title refactor: Connection Flow to use CAIP25 Permission format refactor: connection Flow to use CAIP25 Permission format Jan 23, 2025
@metamaskbot
Copy link
Collaborator

Builds ready [1ed1218]
Page Load Metrics (2023 ± 121 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint27924151747628302
domContentLoaded153823971987250120
load158224232023252121
domInteractive189643199
backgroundConnect9162413617
firstReactRender1795512813
getState689262512
initialActions01000
loadScripts110118501472210101
setupStore96920199
uiStartup198330562379291140
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 507 Bytes (0.01%)
  • ui: 893 Bytes (0.01%)
  • common: -433 Bytes (-0.00%)

@ffmcgee725 ffmcgee725 requested a review from adonesky1 January 29, 2025 17:52
Copy link
Contributor

@adonesky1 adonesky1 left a comment

Choose a reason for hiding this comment

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

LGTM

@ffmcgee725 ffmcgee725 enabled auto-merge January 29, 2025 20:15
@ffmcgee725 ffmcgee725 added this pull request to the merge queue Jan 29, 2025
@metamaskbot
Copy link
Collaborator

Builds ready [a66eac3]
Page Load Metrics (1663 ± 58 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint14761986166012459
domContentLoaded14621926162911254
load14771986166312258
domInteractive24118462914
backgroundConnect885322512
firstReactRender1694412713
getState46916178
initialActions00000
loadScripts10361470117310852
setupStore86013147
uiStartup16932140190712660
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 499 Bytes (0.01%)
  • ui: 890 Bytes (0.01%)
  • common: -433 Bytes (-0.00%)

Merged via the queue into main with commit e041dc8 Jan 29, 2025
70 checks passed
@ffmcgee725 ffmcgee725 deleted the jc/caip25-permission-refactor branch January 29, 2025 23:03
@github-actions github-actions bot locked and limited conversation to collaborators Jan 29, 2025
@metamaskbot metamaskbot added the release-12.12.0 Issue or pull request that will be included in release 12.12.0 label Jan 29, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
release-12.12.0 Issue or pull request that will be included in release 12.12.0 sip26 team-wallet-api-platform
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants