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

[PS] Implement Permission System #5062

Merged
merged 113 commits into from
Feb 2, 2023
Merged

[PS] Implement Permission System #5062

merged 113 commits into from
Feb 2, 2023

Conversation

Cal-L
Copy link
Contributor

@Cal-L Cal-L commented Sep 29, 2022

Development & PR Process

  1. Follow MetaMask Mobile Coding Standards
  2. Add release-xx label to identify the PR slated for a upcoming release (will be used in release discussion)
  3. Add needs-dev-review label when work is completed
  4. Add needs-qa label when dev review is completed
  5. Add QA Passed label when QA has signed off

Description

Implements Permission System, an account access management system.

High level touch points

  • PermissionController
  • Permission Utils
    • Permission specs get validated
    • Permission gets decorated with caveats when middleware is created
  • Subjects/hosts now → future (snaps, sdk, walletconnect)
  • Base - Account selection, AccountSelectorList, useAccounts hook, ENS optimization
  • HOC - AccountConnect, AccountPermissions

UI Changes

  • Bottom Navigation Bar with Wallet & Browser tabs
  • Removal of Wallet & Browser from side drawer
  • Browser URL bar with new UI & new network icon that toggles to wallet / Permissions Button once connected to the dapp.
  • New Bottom Sheet where dapps accounts access can be controlled.
  • Toast Notification on active account & network change

Test Cases
https://www.notion.so/Test-Cases-6c6726b6ff9e4c40b829ee0140b7997a

Bug Report
https://github.com/MetaMask/mobile-planning/issues/528

Screenshots/Recordings

Simulator Screen Recording - iPhone 13 - 2022-12-21 at 17 09 21

Issue

Check #4754 for test cases, designs, knowledge shares & bug reports

Checklist

  • There is a related GitHub issue
  • Tests are included if applicable
  • Any added code is fully documented

@Cal-L Cal-L requested a review from a team as a code owner September 29, 2022 00:10
@Cal-L Cal-L marked this pull request as draft September 29, 2022 00:11
@github-actions
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.

@Cal-L Cal-L force-pushed the feature/4754-permission-system branch 3 times, most recently from 6657b46 to 9968d31 Compare October 5, 2022 20:42
Cal-L and others added 16 commits October 5, 2022 14:36
* Fix image styling

* Update constant name

* Replace wallet navbar with PickerNetwork
* Create AccountSelectionList

* Create temp loader component

* Create temp sheet actions component

* Fix AvatarGroup positioning

* Provide reserved overlay spacing for bottom sheet

* Fix sheet header typo

* Make analytics params optional

* Rename AccountSelectorList

* Create new account selector

* Add AccountSelector to navigation stack

* Replace all account selection logic

* Improve caching logic for ENS name fetch. Introduce 1 hour cache to optimize for network calls. Fetching from middle out beginning with selected account.

* Add lodash debounce to prevent taps in quick succession on bottom sheet

* Throw away any debounce innvocation when bottom sheet is unmounted

* Introduce loading to account selector. Readd test IDS

* Remove old account list

* Clean up useAccounts

* Update snapshots

* Fix logic after pulling from main

* Update snapshots
* Add new logos

* Update styles. Add missing exports.
* Add new logos

* Update styles. Add missing exports.

* Patch controllers. Introduce react-native-get-random-values
* Add new logos

* Update styles. Add missing exports.

* Patch controllers. Introduce react-native-get-random-values

* Organize account hooks and utils

* Export ENS cache. Update account util to return ENS name.

* Update account selector

* Remove account selector styles
* Add new logos

* Update styles. Add missing exports.

* Patch controllers. Introduce react-native-get-random-values

* Organize account hooks and utils

* Export ENS cache. Update account util to return ENS name.

* Update account selector

* Remove account selector styles

* Hook up permission system controller logic
* Add new logos

* Update styles. Add missing exports.

* Patch controllers. Introduce react-native-get-random-values

* Organize account hooks and utils

* Export ENS cache. Update account util to return ENS name.

* Update account selector

* Remove account selector styles

* Hook up permission system controller logic

* Connect PS to browser. Pass from address to transactions.
* Add new logos

* Update styles. Add missing exports.

* Patch controllers. Introduce react-native-get-random-values

* Organize account hooks and utils

* Export ENS cache. Update account util to return ENS name.

* Update account selector

* Remove account selector styles

* Hook up permission system controller logic

* Connect PS to browser. Pass from address to transactions.

* Create first time connect sheet
* Add new logos

* Update styles. Add missing exports.

* Patch controllers. Introduce react-native-get-random-values

* Organize account hooks and utils

* Export ENS cache. Update account util to return ENS name.

* Update account selector

* Remove account selector styles

* Hook up permission system controller logic

* Connect PS to browser. Pass from address to transactions.

* Create first time connect sheet

* Create permissions sheet
* Add new logos

* Update styles. Add missing exports.

* Patch controllers. Introduce react-native-get-random-values

* Organize account hooks and utils

* Export ENS cache. Update account util to return ENS name.

* Update account selector

* Remove account selector styles

* Hook up permission system controller logic

* Connect PS to browser. Pass from address to transactions.

* Create first time connect sheet

* Create permissions sheet

* Add translations to permission system

* (BottomTabBar): implement new BottomTabBar

* (ActivityView): move nav stack to wallet

* (Transactions): update navigation header

* (ActivityView): fix back button onPress

* (ActivityView): fix getNavbarOptions args

* (BrowserBottomBar): remove bottomPadding

* (Transactions): fix empty screen height

* (Transactions): setup main modal stack navigator

Co-authored-by: Cal Leung <cleun007@gmail.com>
* Add new logos

* Update styles. Add missing exports.

* Patch controllers. Introduce react-native-get-random-values

* Organize account hooks and utils

* Export ENS cache. Update account util to return ENS name.

* Update account selector

* Remove account selector styles

* Hook up permission system controller logic

* Connect PS to browser. Pass from address to transactions.

* Create first time connect sheet

* Create permissions sheet

* Add translations to permission system

* (BottomTabBar): implement new BottomTabBar

* (ActivityView): move nav stack to wallet

* (Transactions): update navigation header

* (ActivityView): fix back button onPress

* (ActivityView): fix getNavbarOptions args

* (BrowserBottomBar): remove bottomPadding

* (Transactions): fix empty screen height

* (Transactions): setup main modal stack navigator

* (BrowserNav): implement new PS browser navbar

* (Navbar): fix AccountRightButton onPress event

Co-authored-by: Cal Leung <cleun007@gmail.com>
* Feature/4768 action selector sheet (#4891)

* Create AccountSelectionList

* Create temp loader component

* Create temp sheet actions component

* Fix AvatarGroup positioning

* Provide reserved overlay spacing for bottom sheet

* Fix sheet header typo

* Make analytics params optional

* Rename AccountSelectorList

* Create new account selector

* Add AccountSelector to navigation stack

* Replace all account selection logic

* Improve caching logic for ENS name fetch. Introduce 1 hour cache to optimize for network calls. Fetching from middle out beginning with selected account.

* Add lodash debounce to prevent taps in quick succession on bottom sheet

* Throw away any debounce innvocation when bottom sheet is unmounted

* Introduce loading to account selector. Readd test IDS

* Remove old account list

* Clean up useAccounts

* Update snapshots

* Fix logic after pulling from main

* Update snapshots

* [PS] Connect ps to browser (#5051)

* Add new logos

* Update styles. Add missing exports.

* Patch controllers. Introduce react-native-get-random-values

* Organize account hooks and utils

* Export ENS cache. Update account util to return ENS name.

* Update account selector

* Remove account selector styles

* Hook up permission system controller logic

* Connect PS to browser. Pass from address to transactions.

* Update toast copy

* Fix misc

* Hide invalid fiat balance

* Comment permission util for clarity

* Move account type out of Toast

* Update imports

* Replace account depedency in browser tab

* Update styles

* Prevent auto account selection on account creation

* Remove spacing from toast translation strings

* Update browser icon

* Remove all permissions when deleting wallet

* Fix AvatarNetwork showfallback

* Open separate browser from warning

* Remove unnecessary padding on browser

* Show account switch toast when switching between tabs

* Fix unrecognized network logos

* Update snapshots

* Pull full screen modal/sheets to Root modal flow in nav stack

* Fix browser tab test

* Fix test

* Fix NetworkList test

* Remove redundant useAccounts
* (Navigation): update route names

* (BrowserUrlBar): use getURLProtocol to check SSL

* (BrowserUrlBar): test margins

* (Browser): fix Android url bar onPress
@Cal-L Cal-L force-pushed the feature/4754-permission-system branch from 9968d31 to 0d8c597 Compare October 5, 2022 21:36
cortisiko and others added 15 commits January 23, 2023 18:57
* fix network casing name in educational network info modal

* fix no network avatar for frequent networks
* updated browser tests to run on thje permission system

* Returning values to original state

* Solve account approval modal issues and option menu test issues

* Update network text value

* updating failing tests

* Merge latest changes an returning config values to default

* Update

* Add AddContact.js file

* update AddContact page object + fix linting issue

---------

Co-authored-by: Curtis <Curtis.David7@gmail.com>
* [IMPROVEMENT] Refactor ProtectYourWallet section in the security section (#5600)

* [FIX] Analytics event interface (#5613)

* Fix analytics events

* Bump version and build numbers

* Revert "Bump version and build numbers"

This reverts commit 247789b.

* Handle ENS Address Error (#5605)

* resolving ens address

* lint

* cleaner name

* Bump versions to make prod build for testing

* Revert "Bump versions to make prod build for testing"

This reverts commit 43d0dad.

Co-authored-by: Plasma Corral <32695229+plasmacorral@users.noreply.github.com>

* [FIX] Make Prettier work in wdio directory (#5612)

* make Prettier work in wdio directory

- remove wdio from the Prettier exclude file
- add Gherkin Prettier pluggin for .feature
- update `yarn format` script to take .feature files into account
- first pass of js and feature files formating in wdio dir using `yarn format`

* format after branch update from main

* extract eslint config to deal with it in another PR

- create an eslint ignore file and use it as default instead of prettier ignore with eslint (on both scripts, lint and fix)
- add the wdio dir back in .eslintignore to deal with it in another eslint only PR
- remove useless ignore lines as already ignored by the android line

* [FIX] SRP Quiz content and translations (#5626)

* [IMPROVEMENT] Refactor Personal Signature (#5551)

* personal signature refactor

* Fix currency display (#5623)

* [FEAT] Add friction to SRP reveal (#5579)

* Add base modals

* Add navigation for dev purposes

* Update Main Nav

* Update navigation

* Add new Route

* Update quiz files

* Update modals

* Add QuizStage enum

* Add interfaces

* Update styles

* Update quiz components

* Update IQuizInformationProps interface

* Rename files

* Add quiz flow

* Revert AccountView changes

* Add Quiz to security settings

* Update title interface and style

* Update QuizContent

* Update styles

* Update dep arrays

* Add quiz structure

* Move QuizStage to type file

* Update QuizContent component

* Add method to dismiss modal

* Revert Podfile.lock

* Fix typo

* Remove unnecessary comments

* Fix structure error

* Add analytic events

* Fix small content issues

* Add image to quiz intro

* Add image to quiz intro

* Add link to zendesk article

* Remove quiz structure cobject

* Bump version and build number

* Ignore advisories

* Revert "Bump version and build number"

This reverts commit b9833bb.

* Revert "Ignore advisories"

This reverts commit 17d68eb.

* Remove message

* Update dependencies array

* Use Routes for RevealPrivateCredentialView

* Remove unused interfaces

* Move SRP guide method to QuizModal

* Update dependency array

* Refactor switch-case statement

* Fix nav bug

* Dismiss Quiz if the app goes to the background

* E2e appium folder structure change (#5632)

* Re-arranged wdio file structure

Re-arranged wdio file structure & refactor imports

* Added missing Address Input ID

* Commented out failing test

* Removed ignored test

* rename folder to "Accounts"

* move lockResetPassword out of onboarding folder

---------

Co-authored-by: Curtis <Curtis.David7@gmail.com>

* fix import path

* fix e2e after merging main.

* fix linting

* Remove unused files. Fix personal sign

---------

Co-authored-by: Gustavo Antunes <17601467+gantunesr@users.noreply.github.com>
Co-authored-by: Sylva Elendu <iamsylvaelendu@gmail.com>
Co-authored-by: Plasma Corral <32695229+plasmacorral@users.noreply.github.com>
Co-authored-by: Nicolas MASSART <NicolasMassart@users.noreply.github.com>
Co-authored-by: Cal Leung <cleun007@gmail.com>
Co-authored-by: yande <110056475+Andepande@users.noreply.github.com>
* Change ImportPrivateKey to TS file

* Add QR scanner screen to import stack

* Change ts to tsx

* Refactor import private key

* Don't show alert when importing account from account selector

* Fix deleting last imported account when in connected flow

* Fix dismissing keyboard when selecting top right nav button on webview

* Fix contrast for private key QR code

* Disable Permission System for WalletConnect and MMSDK

* Fix undefined origin issue

* fix browser title bar misalignment

* fix networkinfo avatar letter

* Resolve PR comments

---------

Co-authored-by: João Loureiro <joao.loureiro@consensys.net>
* place analytics events

* rename permission connect request events

add source property

* update analytics

* fix import

* safeguarding when there are no active tabs

* rename event properties

* update source field

* update request completed properties

* fix networklist test
@Cal-L Cal-L added release-6.0.0 Issue or pull request that will be included in release 6.0.0 and removed release-5.14.0 Issue or pull request that will be included in release 5.14.0 labels Feb 1, 2023
Copy link
Member

@cortisiko cortisiko left a comment

Choose a reason for hiding this comment

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

This feature is QA passed 🌮 🌮 . The e2e tests were updated to reflect changes in this feature. they all passed. See iOS test run and android test run.

Test coverage:

  • See my feature file with most of my test scenarios for this feature.
  • Removing networks while connected to a dapp and ensuring the network defaults back to mainnet. I also ensured transactions were successful after network removal.
  • dapp and regular transactions (send, swap, approve tokens, deploy contracts, mint nfts)

@cortisiko cortisiko added QA Passed A successful QA run through has been done and removed QA in Progress QA has started on the feature. labels Feb 2, 2023
Copy link
Contributor

@owencraston owencraston left a comment

Choose a reason for hiding this comment

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

Reviewed latest changes with @Cal-L and it all looks good to me. Just left a few comments for future improvements.

@Cal-L Cal-L merged commit f9bd113 into main Feb 2, 2023
@Cal-L Cal-L deleted the feature/4754-permission-system branch February 2, 2023 23:35
@github-actions github-actions bot locked and limited conversation to collaborators Feb 2, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
QA Passed A successful QA run through has been done release-6.0.0 Issue or pull request that will be included in release 6.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants