Skip to content

Conversation

@Mrtenz
Copy link
Member

@Mrtenz Mrtenz commented Nov 5, 2025

This fixes a bug where dynamic permissions would be revoked when updating a Snap. For example, if a Snap dynamically requested accounts through the endowment:caip25 permission, that permission would be deemed unused, since the Snap can't request it in the manifest.

To solve it, I've added some logic that checks if dynamic permissions are present in the old permissions, checks if the desired permissions has at least one of the "dependencies" of the dynamic permission (e.g., endowment:caip25 requires endowment:ethereum-provider to be useful), and adds it back to the desired permissions.


Note

Ensures dynamic permissions persist on Snap update when dependencies remain requested, and are revoked when none are used.

  • SnapController:
    • Add #getDesiredPermissions to retain dynamic permissions if any dependency in DYNAMIC_PERMISSION_DEPENDENCIES is still desired.
    • Update #calculatePermissionsChange to use desired permissions including dynamic ones; adjust unused/new permissions logic.
  • Constants:
    • Introduce DYNAMIC_PERMISSION_DEPENDENCIES mapping (e.g., endowment:caip25endowment:ethereum-provider).
  • Tests:
    • Add tests verifying dynamic permission retention/revocation during update scenarios.
  • Misc:
    • Minor coverage metric change in coverage.json.

Written by Cursor Bugbot for commit 0ee3f2a. This will update automatically on new commits. Configure here.

@@ -1,5 +1,5 @@
{
"branches": 94.87,
"branches": 94.77,
Copy link
Member Author

Choose a reason for hiding this comment

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

The ?? [] branch is not covered, but it's not easy to do without adding mock data to DYNAMIC_PERMISSION_DEPENDENCIES.

@codecov
Copy link

codecov bot commented Nov 5, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.28%. Comparing base (fe87c3a) to head (0ee3f2a).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3726   +/-   ##
=======================================
  Coverage   98.27%   98.28%           
=======================================
  Files         418      418           
  Lines       12146    12158   +12     
  Branches     1875     1877    +2     
=======================================
+ Hits        11937    11949   +12     
  Misses        209      209           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Mrtenz Mrtenz marked this pull request as ready for review November 5, 2025 15:52
@Mrtenz Mrtenz requested a review from a team as a code owner November 5, 2025 15:52
@Mrtenz Mrtenz added this pull request to the merge queue Nov 6, 2025
Merged via the queue into main with commit 0970e9e Nov 6, 2025
121 checks passed
@Mrtenz Mrtenz deleted the mrtenz/keep-dynamic-permissions-on-update branch November 6, 2025 10:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants