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

feat: Snaps settings #8084

Merged
merged 7 commits into from
Dec 14, 2023
Merged

feat: Snaps settings #8084

merged 7 commits into from
Dec 14, 2023

Conversation

owencraston
Copy link
Contributor

@owencraston owencraston commented Dec 13, 2023

Description

  • This PR adds a settings page for each snap that allows users to read the granted permissions, remove the snap, read the description and title.

  • The designs for this feature can be found here

This PR does not...

  • Render specific snap icons
  • Show the connected sites and allow the user to disconnect from them
  • install origin and snap version are not clickable
  • There are also small UX differences between the designs and my version due to limitations of the existing designs system components

2. What is the improvement/solution?

  • Create a stack navigator for the snaps settings and put it inside the app/components/Nav/Main/MainNavigator.js. This stack will then live in the SettingsFlow stack navigator

  • Removes the old placement for the snaps workflows inside the DrawerView.

  • Add the entry point to the SnapsSettingsList inside the settings screen under the Networks section

  • Renamed the old SnapsDev screen to SnapsSettingsList.tsx and had it render a list of SnapElements. This is the component that shows the snap name and id. When clicked it takes the user to the Settings page for a specific snap.

  • Modified the SnapElement component to render a a Cell. This cell contains the snap name, snap id, a default icon for all snaps. I did not render the specific snap icon in this PR.

  • Clicking on the SnapElement is brings you to a specific SnapSettings screen. This screen contains

    • A SnapDetails
    • A SnapDescription
    • A SnapPermissions which renders the list of permissions in a human readable way. More on this later.
    • And lastly this screen renders a Remove Snap section that contains a red button that when pressed calls SnapController.removeSnap(snap.id); and navigation.goBack();
    Screenshot 2023-05-30 at 4 49 25 PM
  • The app/components/Views/Snaps contains all of these screens and components and matches the desired file structure for components of this nature. Each component lives within its own folder, each of which have a styles.ts file. index.ts file, the component itself and a test folder.

    • Every component and screen are thoroughly tested.
Screenshot 2023-12-13 at 10 22 43 AM 4/d43f23bd-b14f-4130-9c58-ae36489b8652">

New Components

SnapDescription (Low Complexity)

  • a trivial component that takes in the name and description of a snap and renders it in a nice box with a border
    The designs:
Screenshot 2023-05-30 at 5 28 26 PM

My Version:
Screenshot 2023-05-30 at 5 28 35 PM

SnapElement (Low Complexity)

  • A list element that renders a Cell with the Snap name and id, a placeholder icon and navigates to the SnapSettings screen of that specific snap when clicked.
    The designs:
Screenshot 2023-05-30 at 5 30 57 PM

My version:
Screenshot 2023-05-30 at 5 30 43 PM

SnapVersionBadge (Low Complexity)

  • A trivial component that renders the snap version with a v prefix and has an icon beside it. As of now clicking this button does nothing but in the future it will most likely link to other versions of that snap.
    The designs:
Screenshot 2023-05-30 at 5 29 52 PM

My version:
Screenshot 2023-05-30 at 5 29 44 PM

SnapDetails (Medium Complexity)

  • A component that renders the Snap name/id, a toggle button to enable/disable the snap, the install origin and date as well as the version badge mentioned below.
    The designs:
Screenshot 2023-05-30 at 5 26 33 PM

My Version:
Screenshot 2023-05-30 at 5 26 47 PM

Related issues

Progresses: https://github.com/MetaMask/accounts-planning/issues/143

Manual testing steps

  1. checkout this branch
  2. run yarn setup
  3. open the .js.env
  4. modify the METAMASK_BUILD_TYPE to export METAMASK_BUILD_TYPE="flask"
  5. in your terminal run source .js.env and then run yarn watch:clean
  6. in xcode select the flask variant and press play
  7. open http://metamask.github.io/snaps/test-snaps/1.1.0 in the browser
Screenshot 2023-12-08 at 12 04 41 AM
  1. create a wallet
  2. navigate to the browser
  3. open this url: https://metamask.github.io/snaps/test-snaps/1.1.0/
  4. install a snap, I usually install the bip32/bip44 snap
  5. the install flow should appear with 3 steps including the a success screen
  6. click the Get Public key button on the snap site, you should get a result
  7. navigate to settings/snaps
  8. you should see a list of all your installed snaps
  9. clicking on an installed snap should bring you to the settings page for that snap
  10. from this page you should see...
    • the description and name of the snap
    • all of the permissions it uses and when they were granted
    • the ability to disable the snap
    • the ability to remove the snap
  11. Clicking remove snap should remove it from the list

Before

  • Only the list of snaps was available.
  • There was no way to delete a snap or view more details about it

Simulator Screenshot - iPhone 13 Pro - 2023-12-13 at 10 02 11

After

Screen.Recording.2023-12-13.at.9.59.44.AM.mov

Pre-merge author checklist

  • I’ve followed MetaMask Coding Standards.
  • I've clearly explained what problem this PR is solving and how it is solved.
  • I've linked related issues
  • I've included manual testing steps
  • I've included screenshots/recordings if applicable
  • I’ve included tests if applicable
  • I’ve documented my code using JSDoc format if applicable
  • I’ve applied the right labels on the PR (see labeling guidelines). Not required for external contributors.
  • I’ve properly set the pull request status:
    • In case it's not yet "ready for review", I've set it to "draft".
    • In case it's "ready for review", I've changed it from "draft" to "non-draft".

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.

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.

@owencraston owencraston changed the title snaps settings feat: Snaps settings Dec 13, 2023
@codecov-commenter
Copy link

codecov-commenter commented Dec 13, 2023

Codecov Report

Attention: 3 lines in your changes are missing coverage. Please review.

Comparison is base (f71c426) 39.27% compared to head (03ac749) 39.39%.

❗ Current head 03ac749 differs from pull request most recent head 5bb9912. Consider uploading reports for the commit 5bb9912 to get more accurate results

Files Patch % Lines
...mponents/Views/Snaps/SnapSettings/SnapSettings.tsx 94.44% 0 Missing and 1 partial ⚠️
...Views/Snaps/components/SnapDetails/SnapDetails.tsx 91.66% 0 Missing and 1 partial ⚠️
...Views/Snaps/components/SnapElement/SnapElement.tsx 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8084      +/-   ##
==========================================
+ Coverage   39.27%   39.39%   +0.12%     
==========================================
  Files        1208     1220      +12     
  Lines       29738    29800      +62     
  Branches     2828     2831       +3     
==========================================
+ Hits        11679    11740      +61     
  Misses      17371    17371              
- Partials      688      689       +1     

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

@owencraston owencraston marked this pull request as ready for review December 13, 2023 17:31
@owencraston owencraston requested a review from a team as a code owner December 13, 2023 17:31
Copy link
Contributor

E2E test started on Bitrise: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/d39298f3-d5c3-4cd0-9b71-524e65d2f609
You can also kick off another Bitrise E2E smoke test by removing and re-applying the (Run Smoke E2E) label

Copy link
Contributor

@Jonathansoufer Jonathansoufer left a comment

Choose a reason for hiding this comment

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

Good job ! Few comments that need to be addressed before approval.

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

E2E test started on Bitrise: https://app.bitrise.io/app/be69d4368ee7e86d/pipelines/f5e6fdcf-0904-4318-8a86-ba0d7600bea3
You can also kick off another Bitrise E2E smoke test by removing and re-applying the (Run Smoke E2E) label

Jonathansoufer
Jonathansoufer previously approved these changes Dec 13, 2023
Copy link
Contributor

@Jonathansoufer Jonathansoufer left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Member

@gantunesr gantunesr left a comment

Choose a reason for hiding this comment

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

LGTM. Ship the last melon 🍈

Copy link

sonarcloud bot commented Dec 14, 2023

Quality Gate Passed Quality Gate passed

The SonarCloud Quality Gate passed, but some issues were introduced.

1 New issue
0 Security Hotspots
95.6% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarCloud

@owencraston owencraston merged commit 0e816f7 into main Dec 14, 2023
25 of 26 checks passed
@owencraston owencraston deleted the feat/snaps-settings branch December 14, 2023 01:54
@github-actions github-actions bot locked and limited conversation to collaborators Dec 14, 2023
@metamaskbot metamaskbot added the release-7.15.0 Issue or pull request that will be included in release 7.15.0 label Dec 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
INVALID-PR-TEMPLATE PR's body doesn't match template release-7.15.0 Issue or pull request that will be included in release 7.15.0 team-accounts
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants