Skip to content

feat(snaps): Add support for custom network per Snap #26389

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

Draft
wants to merge 24 commits into
base: main
Choose a base branch
from

Conversation

Mrtenz
Copy link
Member

@Mrtenz Mrtenz commented Aug 13, 2024

Description

Like with websites, we want to support a custom network per Snap rather than relying on the globally selected network. For Snaps, the permission for the network to switch to is automatically granted.

Blocked by:

Todo

  • Revert execution environment URL.
  • Remove preview version for selected-network-controller.

Open in GitHub Codespaces

Manual testing steps

  1. Build the extension with CHAIN_PERMISSIONS=true.
  2. Use wallet_switchEthereumChain in a Snap.
  3. The Snap should now use the new network, without any permission requests.

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.

@metamaskbot metamaskbot added the INVALID-PR-TEMPLATE PR's body doesn't match template label Aug 13, 2024
Copy link

socket-security bot commented Aug 13, 2024

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

Package New capabilities Transitives Size Publisher
npm/@types/nanoid@3.0.0 None 0 1.63 kB types

View full report↗︎

Copy link

socket-security bot commented Aug 13, 2024

🚨 Potential security issues detected. Learn more about Socket for GitHub ↗︎

To accept the risk, merge this PR and you will not be notified again.

Alert Package NoteSourceCI
Deprecated npm/@types/nanoid@3.0.0
  • Reason: This is a stub types definition. nanoid provides its own type definitions, so you do not need this installed.
⚠︎

View full report↗︎

Next steps

What is a deprecated package?

The maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.

Research the state of the package and determine if there are non-deprecated versions that can be used, or if it should be replaced with a new, supported solution.

Take a deeper look at the dependency

Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support [AT] socket [DOT] dev.

Remove the package

If you happen to install a dependency that Socket reports as Known Malware you should immediately remove it and select a different dependency. For other alert types, you may may wish to investigate alternative packages or consider if there are other ways to mitigate the specific risk posed by the dependency.

Mark a package as acceptable risk

To ignore an alert, reply with a comment starting with @SocketSecurity ignore followed by a space separated list of ecosystem/package-name@version specifiers. e.g. @SocketSecurity ignore npm/foo@1.0.0 or ignore all packages with @SocketSecurity ignore-all

  • @SocketSecurity ignore npm/@types/nanoid@3.0.0

@metamaskbot metamaskbot added the team-snaps-platform Snaps Platform team label Aug 13, 2024
@Mrtenz Mrtenz changed the title Add support for custom network per Snap feat(snaps): Add support for custom network per Snap Aug 14, 2024
@Mrtenz Mrtenz force-pushed the mrtenz/snap-networks branch from 38edd7a to 7f2494b Compare August 15, 2024 08:29
Copy link

Copy link
Contributor

This PR has been automatically marked as stale because it has not had recent activity in the last 60 days. It will be closed in 14 days. Thank you for your contributions.

@github-actions github-actions bot added the stale issues and PRs marked as stale label Oct 28, 2024
Copy link
Contributor

This PR was closed because there has been no follow up activity in the last 14 days. Thank you for your contributions.

@github-actions github-actions bot closed this Nov 11, 2024
@Mrtenz Mrtenz reopened this Jan 15, 2025
@Mrtenz Mrtenz removed the stale issues and PRs marked as stale label Jan 15, 2025
@Mrtenz Mrtenz force-pushed the mrtenz/snap-networks branch from 6453f80 to cf763b1 Compare January 17, 2025 12:42
Copy link
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.

@Mrtenz Mrtenz changed the base branch from develop to main January 17, 2025 12:42
@FrederikBolding
Copy link
Member

@adonesky1 or @jiexi should review this PR too

@FrederikBolding FrederikBolding requested a review from jiexi January 17, 2025 13:32
@Mrtenz Mrtenz force-pushed the mrtenz/snap-networks branch from 0110271 to b74b5a8 Compare January 21, 2025 13:33
@metamaskbot
Copy link
Collaborator

Builds ready [b74b5a8]
Page Load Metrics (1927 ± 202 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint30630261663678326
domContentLoaded150529691899411197
load152230321927421202
domInteractive25188513617
backgroundConnect781272512
firstReactRender1575462311
getState55214147
initialActions01000
loadScripts107819871395291140
setupStore65114136
uiStartup169832082208492236
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 54 Bytes (0.00%)
  • ui: 0 Bytes (0.00%)
  • common: 0 Bytes (0.00%)

@Mrtenz Mrtenz force-pushed the mrtenz/snap-networks branch from aa7b725 to 507a83f Compare April 7, 2025 12:34
@metamaskbot
Copy link
Collaborator

Builds ready [507a83f]
UI Startup Metrics (1231 ± 61 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyHomeuiStartup1231109314736112631348
load10769501254621141982
domContentLoaded10709441241611146993
domInteractive17136581629
firstPaint780821249408241973
backgroundConnect11613713910
firstReactRender21137482139
getState13541878
initialActions001000
loadScripts81669198461846936
setupStore8424379
WebpackHomeuiStartup21891695263922823772513
load17331290227421518542175
domContentLoaded17261285226921518502171
domInteractive1812134151442
firstPaint163673836426393
backgroundConnect3611276403668
firstReactRender145524291097596
getState1642653179
initialActions319136
loadScripts17171276226521318382166
setupStore2262793979
FirefoxBrowserifyHomeuiStartup14091214194415614511775
load12661073177915113111619
domContentLoaded12651072177815113111618
domInteractive10237317409097
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect2817247242836
firstReactRender22194842228
getState8439589
initialActions002001
loadScripts12391052175314712821594
setupStore7451767
WebpackHomeuiStartup15261343206715915881935
load13181165183314913881703
domContentLoaded13171165183314913881702
domInteractive9240197229098
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect25175062742
firstReactRender35286163848
getState9466789
initialActions102111
loadScripts12951142181214813701680
setupStore8523389
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 1.29 MiB (24.96%)
  • ui: 9 Bytes (0%)
  • common: 130 Bytes (0%)

@Mrtenz Mrtenz requested review from jiexi and adonesky1 April 7, 2025 13:32
@metamaskbot
Copy link
Collaborator

Builds ready [1673965]
UI Startup Metrics (1231 ± 68 ms)
PlatformBuildTypePageMetricMean (ms)Min (ms)Max (ms)Std Dev (ms)P 75 (ms)P 95 (ms)
ChromeBrowserifyHomeuiStartup1231110215126812651333
load10829681315651144986
domContentLoaded10749641307671164993
domInteractive16124551627
firstPaint728961200435196975
backgroundConnect116748910
firstReactRender20154252131
getState12532779
initialActions001000
loadScripts821703105566853907
setupStore8517278
WebpackHomeuiStartup22681867269418324022551
load17911359230018818732182
domContentLoaded17841351229618718672177
domInteractive181383131555
firstPaint174653506827389
backgroundConnect3912281424165
firstReactRender188564261196190
getState1842092869
initialActions318146
loadScripts17671347228217018552035
setupStore24627337448
FirefoxBrowserifyHomeuiStartup13901174199616514451793
load12471049185015813141615
domContentLoaded12471049185015813141615
domInteractive10038159238998
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect25165682643
firstReactRender22193432428
getState8453779
initialActions001001
loadScripts12241027182715712951583
setupStore6413267
WebpackHomeuiStartup15581351206716616201976
load13441148179915414081749
domContentLoaded13441147179915414081749
domInteractive9940176268995
firstPaintNaNNaNNaNNaNNaNNaN
backgroundConnect26185472845
firstReactRender36295463848
getState8432489
initialActions102111
loadScripts13211127176815313861710
setupStore8542589
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 1.3 MiB (25.04%)
  • ui: 12 Bytes (0%)
  • common: 400 Bytes (0%)

@adonesky1
Copy link
Contributor

adonesky1 commented Apr 21, 2025

Could you explain a bit more directly in the PR description how to:

Use wallet_switchEthereumChain in a Snap.

?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
INVALID-PR-TEMPLATE PR's body doesn't match template team-snaps-platform Snaps Platform team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants