-
Notifications
You must be signed in to change notification settings - Fork 5k
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
feat(snaps): Add support for custom network per Snap #26389
Conversation
New and removed dependencies detected. Learn more about Socket for GitHub ↗︎
🚮 Removed packages: npm/@metamask/[email protected] |
🚨 Potential security issues detected. Learn more about Socket for GitHub ↗︎ To accept the risk, merge this PR and you will not be notified again.
Next stepsWhat is new author?A new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package. Scrutinize new collaborator additions to packages because they now have the ability to publish code into your dependency tree. Packages should avoid frequent or unnecessary additions or changes to publishing rights. Take a deeper look at the dependencyTake 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 packageIf 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 riskTo ignore an alert, reply with a comment starting with
|
38edd7a
to
7f2494b
Compare
Quality Gate passedIssues Measures |
@@ -26,7 +26,7 @@ buildTypes: | |||
- SEGMENT_WRITE_KEY_REF: SEGMENT_PROD_WRITE_KEY | |||
- ALLOW_LOCAL_SNAPS: false | |||
- REQUIRE_SNAPS_ALLOWLIST: true | |||
- IFRAME_EXECUTION_ENVIRONMENT_URL: https://execution.metamask.io/iframe/6.5.0/index.html | |||
- IFRAME_EXECUTION_ENVIRONMENT_URL: http://localhost:6363 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be reverted before merge
@@ -350,7 +350,7 @@ | |||
"@metamask/rpc-errors": "^6.2.1", | |||
"@metamask/safe-event-emitter": "^3.1.1", | |||
"@metamask/scure-bip39": "^2.0.3", | |||
"@metamask/selected-network-controller": "^15.0.2", | |||
"@metamask/selected-network-controller": "npm:@metamask-previews/selected-network-controller@17.0.0-preview-55328a6", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be reverted before merge
@@ -214,7 +216,11 @@ export async function switchChain( | |||
permissionedChainIds === undefined || | |||
!permissionedChainIds.includes(chainId) | |||
) { | |||
await requestPermittedChainsPermission([chainId]); | |||
if (isSnapId(origin)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we test this functionality?
requestData: { | ||
approvedChainIds: chainIds, | ||
}, | ||
approvedPermissions: { | ||
[PermissionNames.permittedChains]: { | ||
caveats: [ | ||
CaveatFactories[CaveatTypes.restrictNetworkSwitching]( | ||
chainIds, | ||
), | ||
], | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems a bit strange that we have to specify the chain IDs twice 🤔 Seems like the permission specification strictly uses requestData
export const version = 126; | ||
|
||
/** | ||
* This migration adds the `permittedChains` permission to all Snaps that have |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* This migration adds the `permittedChains` permission to all Snaps that have | |
* This migration adds the `endowment:permittedChains` permission to all Snaps that have |
As well as others 😄
permissionKeys.includes(SnapEndowments.EthereumProvider) && | ||
!permissionKeys.includes(PermissionNames.permittedChains); | ||
if (!needsMigration) { | ||
return accumulator; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't this delete any subjects that don't need the migration?
expect(newStorage.meta).toStrictEqual({ version }); | ||
}); | ||
|
||
it('adds the network endowment to Snaps with the `endowment:ethereum-provider` permission', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should test that it doesn't touch Snaps that don't have the permission
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. |
This PR was closed because there has been no follow up activity in the last 14 days. Thank you for your contributions. |
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:
wallet_switchEthereumChain
snaps#2634.Todo
selected-network-controller
.Manual testing steps
CHAIN_PERMISSIONS=true
.wallet_switchEthereumChain
in a Snap.Screenshots/Recordings
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist