Skip to content

Refactor Connection UI for Multichain#31326

Merged
adonesky1 merged 84 commits intosip-26from
ad/chain-agnostic-permission-connection-ui-from-top
Apr 2, 2025
Merged

Refactor Connection UI for Multichain#31326
adonesky1 merged 84 commits intosip-26from
ad/chain-agnostic-permission-connection-ui-from-top

Conversation

@adonesky1
Copy link
Copy Markdown
Contributor

@adonesky1 adonesky1 commented Mar 26, 2025

Description

Open in GitHub Codespaces

Related issues

Fixes:

Manual testing steps

const EXTENSION_ID = 'pmeejofbihagkmnpoeoghmdmpaonndpl'; // replace this with your local extension ID
const extensionPort = chrome.runtime.connect(EXTENSION_ID)



// EVM only, no accounts requested
// default account: last selected EVM account
// default chains: the selected chain
// existing default EVM chain logic (ONLY APPLIES TO EIP-1193 FLOW since no longer possible to request empty scopes)
extensionPort.postMessage({
    type: 'caip-x',
    data: {
        "jsonrpc": "2.0",
        method: 'wallet_createSession',
        params: {
            optionalScopes: {
                'eip155:1': {
                    methods: [],
                    notifications: []
                },
            },
        },
    }
})


// Solana only, 2 accounts requested
// default accounts: selected accounts that exist/valid. If none, last selected account for that namespace
// default chains: the selected chain
extensionPort.postMessage({
    type: 'caip-x',
    data: {
        "jsonrpc": "2.0",
        method: 'wallet_createSession',
        params: {
            optionalScopes: {
                'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp': {
                    methods: [], 
                    notifications: [],
                    accounts: ['solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp:<solana_account_1>',
                                'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp:<solana_account_2>']
                }
            },
        },
    }
})

// Solana only, no accounts requested
// default accounts: Last selected account for that namespace
extensionPort.postMessage({
    type: 'caip-x',
    data: {
        "jsonrpc": "2.0",
        method: 'wallet_createSession',
        params: {
            optionalScopes: {
                'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp': {
                    methods: [], 
                    notifications: [],
                    accounts: []
                }
            },
        },
    }
})

// EVM and Solana, 2 solana accounts requested
// for provided, selected accounts that exist/valid. At least one account for each namespace (the last selected for that namespace)
extensionPort.postMessage({
    type: 'caip-x',
    data: {
        "jsonrpc": "2.0",
        method: 'wallet_createSession',
        params: {
            optionalScopes: {
                'eip155:1': {
                    methods: [],
                    notifications: []
                },
                'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp': {
                    methods: [],
                    notifications: [],
                    accounts: ['solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp:<solana_account_1>',
                                'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp:<solana_account_2>']
                }
            },
        },
    }
})

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.

@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.

@metamaskbot metamaskbot added the team-wallet-api-platform-deprecated DEPRECATED: please use "team-wallet-integrations" instead label Mar 26, 2025
@socket-security
Copy link
Copy Markdown

socket-security bot commented Mar 26, 2025

New dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/@metamask/chain-agnostic-permission@0.3.0 Transitive: environment +1 1.35 MB metamaskbot

View full report↗︎

@adonesky1 adonesky1 force-pushed the ad/chain-agnostic-permission-connection-ui-from-top branch from 599939d to 4813edc Compare March 26, 2025 18:14
@adonesky1
Copy link
Copy Markdown
Contributor Author

TODO: add functionality to auto add chains when account is manually added without matching chains permitted

@metamaskbot
Copy link
Copy Markdown
Collaborator

Builds ready [fce561f]
UI Startup Metrics (1220 ± 55 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyHomeuiStartup1220110213805512521334
load10709791233541131996
domContentLoaded10639681229551138991
domInteractive16134251627
firstPaint7881571258404242985
backgroundConnect8451678
firstReactRender19154141928
getState12447869
initialActions001001
loadScripts80770593350843887
setupStore8520279
WebpackHomeuiStartup948807120182949963
load81069593358833909
domContentLoaded80467792658828898
domInteractive15123871336
firstPaint50268918340826884
backgroundConnect16114171437
firstReactRender14123941321
getState6313269
initialActions001000
loadScripts80267692557827888
setupStore8414189
FirefoxBrowserifyHomeuiStartup13501154187514613971692
load12111039172013812641504
domContentLoaded12111038172013812641504
domInteractive9935164258895
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect2013139132029
firstReactRender22186352227
getState7445578
initialActions001001
loadScripts11931026168813712431479
setupStore7438667
WebpackHomeuiStartup9778211565161891988
load8547081326141814933
domContentLoaded8547081325141814932
domInteractive116351872415698
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect201380112135
firstReactRender19163741926
getState83941079
initialActions001001
loadScripts8376931303137821925
setupStore9559978

@jiexi jiexi marked this pull request as ready for review April 2, 2025 21:06
@jiexi jiexi requested review from a team as code owners April 2, 2025 21:06
@adonesky1 adonesky1 merged commit eb839d2 into sip-26 Apr 2, 2025
153 of 154 checks passed
@adonesky1 adonesky1 deleted the ad/chain-agnostic-permission-connection-ui-from-top branch April 2, 2025 21:06
@github-actions github-actions bot locked and limited conversation to collaborators Apr 2, 2025
@metamaskbot
Copy link
Copy Markdown
Collaborator

Builds ready [8c7078e]
UI Startup Metrics (1207 ± 63 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyHomeuiStartup1207109014626312431325
load10599601319601150988
domContentLoaded10539561315601157980
domInteractive16133541625
firstPaint7681381169409222983
backgroundConnect7430568
firstReactRender18144841922
getState10432768
initialActions001001
loadScripts802706104360840889
setupStore7422278
WebpackHomeuiStartup21101689259621222502476
load16281316203416317251898
domContentLoaded16211313202616117211878
domInteractive171272111447
firstPaint186633636424878
backgroundConnect2712364362562
firstReactRender209523611157595
getState1332942989
initialActions316134
loadScripts16171311202315917201869
setupStore20625834208
FirefoxBrowserifyHomeuiStartup13721203186914214171720
load12321066171913412701551
domContentLoaded12321066171813412701551
domInteractive9840202299099
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect19135162038
firstReactRender22194752229
getState8339678
initialActions001001
loadScripts12151053169713312561528
setupStore6426267
WebpackHomeuiStartup15251335224318115741994
load13141157198316913661734
domContentLoaded13141156198316913661734
domInteractive9335173259096
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect21144662240
firstReactRender34285243645
getState8429579
initialActions002111
loadScripts12951142196116913461718
setupStore8543688

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

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.

[Bug]: When connecting to a dapp from a Solana account, no network or account is automatically selected

3 participants