1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-10-22 19:26:13 +02:00
Commit Graph

58 Commits

Author SHA1 Message Date
igorms-cons
f5e86d0351
Feat/settings search (#13214)
* fix error with color variable - fix rebase

* clean list search & fuse threshold decreased

* update search-icon , fix tests

* nice to have highlighting text & cleaning

* unit test on settings & search input ui up on expanded view

* fix color variable in alert scss

* setting search input padding right up

* fix dom warning

* util/search test added & Dom element warning fix

* renaming files

* fix color text in settings search

* settings search highlight text refacto & fix ui

* fix settings-search test & renaming

* Fix styling on search field for edge cases, update components and e2e

E2E tests update for search feature

Update components from class to functional component

		#

Fix storybook for search box

Fix styling

Fix unit tests

fix: remove z-index

Fix unit tests

Co-authored-by: amerkadicE <amer.kadic@endava.com>
2022-02-22 17:28:21 -03:30
Erik Marks
35ac762e10
Add Snaps via Flask (#13462)
This PR adds `snaps` under Flask build flags to the extension. This branch is mostly equivalent to the current production version of Flask, excepting some bug fixes and tweaks.

Closes #11626
2022-02-14 16:02:51 -08:00
Jyoti Puri
11c61a3ead
EIP-1559 V2 UI/UX improvements (#13419) 2022-01-31 11:21:43 +05:30
Jyoti Puri
a0e97f4681
EIP-1559 v2 - small fixes (#13392) 2022-01-26 23:48:43 +05:30
Jyoti Puri
119e5497ff
UI fixes in EIP-1559 V2 screens (#13367) 2022-01-22 05:53:02 +05:30
Alex Donesky
4826c8c95e
Feat/collectibles send flow (#13048)
* Add collectibles send flow
2022-01-10 10:23:53 -06:00
Mark Stacey
3732c5f71e
Add JSDoc ESLint rules (#12112)
ESLint rules have been added to enforce our JSDoc conventions. These
rules were introduced by updating `@metamask/eslint-config` to v9.

Some of the rules have been disabled because the effort to fix all lint
errors was too high. It might be easiest to enable these rules one
directory at a time, or one rule at a time.

Most of the changes in this PR were a result of running
`yarn lint:fix`. There were a handful of manual changes that seemed
obvious and simple to make. Anything beyond that and the rule was left
disabled.
2022-01-07 12:27:33 -03:30
Elliot Winkler
af971cd5b6
Remove dupe Prettier config from ESLint config (#13234)
The ESLint config for the extension explicitly includes support for
Prettier. However, this is already being provided by our global ESLint
config (`@metamask/eslint-config`). Therefore there is no need to
include it here. In fact, this is causing weird issues where the `curly`
option is getting overridden somehow. After this change, these syntaxes
are invalid:

``` javascript
if (foo) return;
```

``` javascript
if (foo) return 'bar';
```
2022-01-06 15:56:51 -07:00
Jyoti Puri
0c531f8b01
EIP-1559 V2 UI fixes (#13222) 2022-01-07 04:10:31 +05:30
Jyoti Puri
f5dcd12293
using 1559 V2 for cancel speed up flows (#13019) 2022-01-06 08:17:26 +05:30
Alex Donesky
1b6e58c417
Feat/collectibles the return (#12970)
* Wire collectibles frontend UI with controller data
2021-12-13 17:41:10 -06:00
Mark Stacey
ba54a3d83b
Update ESLint config to v8 (#12886)
The ESLint config has been updated to v8. The breaking changes are:

* The Prettier rule `quoteProps` has been changed from `consistent` to
`as-needed`, meaning that if one key requires quoting, only that key is
quoted rather than all keys.
* The ESLint rule `no-shadow` has been made more strict. It now
prevents globals from being shadowed as well.

Most of these changes were applied with `yarn lint:fix`. Only the
shadowing changes required manual fixing (shadowing variable names were
either replaced with destructuring or renamed).

The dependency `globalThis` was added to the list of dynamic
dependencies in the build system, where it should have been already.
This was causing `depcheck` to fail because the new lint rules required
removing the one place where `globalThis` had been erroneously imported
previously.

A rule requiring a newline between multiline blocks and expressions has
been disabled temporarily to make this PR smaller and to avoid
introducing conflicts with other PRs.
2021-12-09 15:36:24 -03:30
Olusegun Akintayo
a7da8333a0
"eth_signTypedData" presents fields that do not appear in 'types' filed (#12905)
* Premilimary Sanitize data logic.

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

* sanitizeData v2

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

* sanitizeData: take 3

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

* Sanitize Data take 4

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

* Lint fixes

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

* Check that version is v4 before sanitizing.

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

* sanitize arrays.

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

* Tests to check that typeless data are not shwon

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

* Lint Fixes

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

* Do not check value types, Iterate through the message, and ensure each property of the message is declared as a type

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

* Check that if data type is not defined, it is a solidity type.

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

* Lint Fixes

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

* Code cleanup

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

* Move sanitizeData to utils
Tests for sanitizeData in utils

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

* Lint fixes

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

* Fix unit tests for signaturerequest

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

* Remove unused type
include fixedMxN and ufixedMxN checks.

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

* move fixtures to before each

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

* invert if condition to avoid indentations.

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

* Lint fixes

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

* We should exclude types with [] at the beginning or middle as well:

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

* cache nestedType

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

* Throw error for undefined/invalid types definition

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

* Throw if base type and types are not defined.

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>
2021-12-09 00:56:09 +04:00
Erik Marks
31cf7c10a4
Permission System 2.0 (#12243)
# Permission System 2.0

## Background

This PR migrates the extension permission system to [the new `PermissionController`](https://github.com/MetaMask/snaps-skunkworks/tree/main/packages/controllers/src/permissions).
The original permission system, based on [`rpc-cap`](https://github.com/MetaMask/rpc-cap), introduced [`ZCAP-LD`](https://w3c-ccg.github.io/zcap-ld/)-like permissions to our JSON-RPC stack.
We used it to [implement](https://github.com/MetaMask/metamask-extension/pull/7004) what we called "LoginPerSite" in [version 7.7.0](https://github.com/MetaMask/metamask-extension/releases/tag/v7.7.0) of the extension, which enabled the user to choose which accounts, if any, should be exposed to each dapp.
While that was a worthwhile feature in and of itself, we wanted a permission _system_ in order to enable everything we are going to with Snaps.
Unfortunately, the original permission system was difficult to use, and necessitated the creation of the original `PermissionsController` (note the "s"), which was more or less a wrapper for `rpc-cap`.

With this PR, we shake off the yoke of the original permission system, in favor of the modular, self-contained, ergonomic, and more mature permission system 2.0.

Note that [the `PermissionController` readme](https://github.com/MetaMask/snaps-skunkworks/tree/main/packages/controllers/src/permissions/README.md) explains how the new permission system works.

The `PermissionController` and `SubjectMetadataController` are currently shipped via `@metamask/snap-controllers`. This is a temporary state of affairs, and we'll move them to `@metamask/controllers` once they've landed in prod.

## Changes in Detail

First, the changes in this PR are not as big as they seem. Roughly half of the additions in this PR are fixtures in the test for the new migration (number 68), and a significant portion of the remaining ~2500 lines are due to find-and-replace changes in other test fixtures and UI files.

- The extension `PermissionsController` has been deleted, and completely replaced with the new `PermissionController` from [`@metamask/snap-controllers`](https://www.npmjs.com/package/@metamask/snap-controllers).
- The original `PermissionsController` "domain metadata" functionality is now managed by the new `SubjectMetadataController`, also from [`@metamask/snap-controllers`](https://www.npmjs.com/package/@metamask/snap-controllers).
- The permission activity and history log controller has been renamed `PermissionLogController` and has its own top-level state key, but is otherwise functionally equivalent to the existing implementation.
- Migration number 68 has been added to account for the new state changes.
- The tests in `app/scripts/controllers/permissions` have been migrated from `mocha` to `jest`.

Reviewers should focus their attention on the following files:

- `app/scripts/`
  - `metamask-controller.js`
    - This is where most of the integration work for the new `PermissionController` occurs.
      Some functions that were internal to the original controller were moved here.
  - `controllers/permissions/`
    - `selectors.js`
      - These selectors are for `ControllerMessenger` selector subscriptions. The actual subscriptions occur in `metamask-controller.js`. See the `ControllerMessenger` implementation for details.
    - `specifications.js`
      - The caveat and permission specifications are required by the new `PermissionController`, and are used to specify the `eth_accounts` permission and its JSON-RPC method implementation.
        See the `PermissionController` readme for details.
  - `migrations/068.js`
    - The new state should be cross-referenced with the controllers that manage it.
      The accompanying tests should also be thoroughly reviewed.

Some files may appear new but have just moved and/or been renamed:

- `app/scripts/lib/rpc-method-middleware/handlers/request-accounts.js`
  - This was previously implemented in `controllers/permissions/permissionsMethodMiddleware.js`.
- `test/mocks/permissions.js`
  - A truncated version of `test/mocks/permission-controller.js`.

Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-12-06 19:16:49 -08:00
Mark Stacey
7226357422
Fix isMainnet propType error (#12951)
A propType error was showing up during e2e tests with a `testDev`
build. It was caused by `process.env.IN_TEST` being treated as a
boolean, when in fact it is either the string `'true'` or a boolean.

`IN_TEST` has been updated to always be a boolean. `loose-envify` has
no trouble injecting boolean values, so there's no reason to treat this
as a string.
2021-12-02 14:46:46 -03:30
Alex Donesky
9e2935dd55
Revert "Feat/collectibles display (#12873)" (#12934)
This reverts commit 81ea24f08a.
2021-12-01 17:46:26 -06:00
Alex Donesky
81ea24f08a
Feat/collectibles display (#12873)
* Wiring up Collectibles lists/items

* wip

* more wip

* more more wip

* yet more wip

* wippp

* more wipppp

* closer

* wroking

* more wip

* cleanup

* cleanup

* add-collectible form validation

* update default ipfs-gateway

* update refresh button

* fix proptypes issue + add more padding to asset background

* css tweaking

* more cleanup

* more cleanup

* more cleanup

* add migration

* address feedback

* fix migration + cleanup

* bumping controllers version + adapting new collectiblesController shape

* fix yarn dedupe
2021-12-01 10:10:17 -06:00
Mark Stacey
7929a92c66
Clear the clipboard after the seed phrase is pasted (#12828)
* Clear the clipboard after the seed phrase is pasted

On the "Import" page of the import onboarding flow, we now clear the
clipboard after the secret recovery phrase is pasted. This ensures that
the SRP isn't accidentally pasted somewhere else by the user, which can
be an easy and disastrous mistake to make.

* Clear clipboard during new onboarding flow as well
2021-11-24 13:39:12 -03:30
kumavis
d9d1a831a6
ci - enforce yarn lock deduplications (#12737)
* ci - test for yarn lock deduplications

* deps - update yarn.lock and patches

* lavamoat - update policy

* test - ui/helpers/utils/optimism/buildUnserializedTransaction - test against json obj

* lint fix

* patch-package - patch @babel/runtime for lavamoat support

* patch-package - fix additional @babel/runtime lockdown incompats

* patch-package - cleanup sass patch
2021-11-23 09:17:27 -10:00
Niranjana Binoy
582882b3ed
Adding the AdvancedGasFeePopover template (#12780) 2021-11-23 23:16:33 +05:30
Jyoti Puri
0daefe9ea0
Adding edit gas fee modal (#12624)
Edit transaction screen changes for EIP-1559 V2
2021-11-18 23:24:58 +05:30
Dan J Miller
9fa15dda6f
Support for Layer 2 networks with transaction fees on both layers (#12658)
* Support for Layer 2 networks with transaction fees on both layers

* Use  variable name in transaction-breakdown

* Add comment on code source to ui/helpers/utils/optimism/fetchEstimatedL1Fee.js

* Fix unit tests

* Ensure values passed to  are defined

* Fix activity log
2021-11-11 13:16:45 -03:30
Mark Stacey
faebdd0ccd
Add platform-specific build type manifest modifications (#12638)
The build system now supports platform-specific modifications to the
manifest for each build type. The need to customize the `id` on Firefox
motivated this change.

To support this, a new directory was made in each build type directory
for manifest changes. The images currently in this directory were moved
into an `images` subdirectory.

This new `manifest` directory can include each manifest file currently
in `app/manifest`. The `_base.json` file is assumed to exist, but the
platform manifest modifications are optional.
2021-11-10 19:33:59 -03:30
Olusegun Akintayo
95e3be4a85
UX improvements to the "Permission Request" section on the approve screen (#12553)
* UX improvements to the "Permission Request" section on the approve screen

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

* Fix locales.

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

* Check that hidden elements are hidden in test

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

* Lint fixes

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>
2021-11-03 02:15:05 +04:00
Erik Marks
a2d3d942ec
Exclude files from builds by build type (#12521)
This PR enables the exclusion of JavaScript and JSON source by `buildType`, and enables the running of `eslint` under LavaMoat. 80-90% of the changes in this PR are `.patch` files and LavaMoat policy additions.

The file exclusion is designed to work in conjunction with our code fencing. If you forget to fence an import statement of an excluded file, the application will now error on boot. **This PR commits us to a particular naming convention for files intended only for certain builds.** Continue reading for details.

### Code Fencing and ESLint

When a file is modified by the code fencing transform, we run ESLint on it to ensure that we fail early for syntax-related issues. This PR adds the first code fences that will be actually be removed in production builds. As a consequence, this was also the first time we attempted to run ESLint under LavaMoat. Making that work required a lot of manual labor because of ESLint's use of dynamic imports, but the manual changes necessary were ultimately quite minor.

### File Exclusion

For all builds, any file in `app/`, `shared/` or `ui/` in a sub-directory matching `**/${otherBuildType}/**` (where `otherBuildType` is any build type except `main`) will be added to the list of excluded files, regardless of its file extension. For example, if we want to add one or more pages to the UI settings in Flask, we'd create the folder `ui/pages/settings/flask`, add any necessary files or sub-folders there, and fence the import statements for anything in that folder. If we wanted the same thing for Beta, we would name the directory `ui/pages/settings/beta`.

As it happens, we already organize some of our source files in this way, namely the logo JSON for Beta and Flask builds. See `ui/helpers/utils/build-types.js` to see how this works in practice.

Because the list of ignored filed is only passed to `browserify.exclude()`, any files not bundled by `browserify` will be ignored. For our purposes, this is mostly relevant for `.scss`. Since we don't have anything like code fencing for SCSS, we'll have to consider how to handle our styles separately.
2021-11-01 20:20:31 -07:00
Mark Stacey
90e55a445e
Add static files for the Flask build (#12518)
Static files have been added for the Flask build. This includes logos
of each size and variety that we use, and it includes the 3D model JSON
file.

Closes #12427
2021-10-28 23:05:58 -02:30
Mark Stacey
e067379f48
Remove the partially-applied dark mode styles used for beta (#12489)
The beta build currently has a couple of UI elements (the horizontal
logo and the app header) set to "dark mode", even though nothing else
in our UI supports dark mode yet. These styles have been removed. We
should make the entire UI support dark mode all at once at a later
date.

Also the horizontal logo used for beta was named incorrectly; the dark
and non-dark logos were swapped. They have been switched back so that
the logo that ends with `-dark` is for dark mode.
2021-10-28 17:29:20 -02:30
David Walsh
6e928c661e
Create function for hardware keyring checking (#12457) 2021-10-27 18:54:18 -05:00
Akintayo A. Olusegun
03e3edb00c
Refactor checking if address is contract into a new module. (#12354)
* Refactor checking if address is contract into a new module.
Tests for new module.

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

* addressIsContract is an async function, use await when calling it.

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

* Lint fixes

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

* Mock ethQuery
change variable names
refactor in transaction.utils.
fix possible boolean destructiring.

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

* Refactor isContractAddress boolean checks.

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>

* Lint fixes

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>
2021-10-20 16:12:07 +01:00
Alex Donesky
aa070edd3f
Fixing address truncation papercuts (#12330)
* fixing address truncation papercuts
2021-10-13 12:54:48 -05:00
Alex Donesky
b242d950a0
add optional chaining in isLegacyTransaction method to prevent blow up of useGasFeeInputs use on view quote page (#12316) 2021-10-11 09:06:19 -05:00
Jyoti Puri
fc41321470
Support for type 0 transaction (#12252)
Support for type 0 transaction
2021-10-06 23:59:57 +05:30
David Walsh
2e2bd0fce5
Prevent fox mesh JSON warning (#12200)
* Prevent fox mesh JSON warning

* Update ui/helpers/utils/build-types.js

Co-authored-by: Mark Stacey <markjstacey@gmail.com>

* Fix lint

Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-09-27 12:40:05 -10:00
Niranjana Binoy
c076faeb8f
adding checksum conversion (#12209) 2021-09-27 09:58:12 -04:00
Alex Donesky
2a9fbffb6c
Replace hardcoded sent ether label on confirm screen (#11802)
* Replace hardcoded sent ether label on confirm screen

* replace transaction type SENT_ETHER with network agnostic SENDING_NATIVE_ASSET

* remove sentEther translation base

* make backwards compatible with lingering transaction of legacy sentEther type

* update localalization files

* fixup legacy sentEther transaction type

* changing new transaction type away from localization string

* revert migration tests

* update fixtures and test data

* update name of new transaction type

* add migration

* remove legacy SENT_ETHER from transaction types enum object
2021-09-15 16:54:51 -05:00
ryanml
069ebaf463 Using design system breakpoint values across ui/ 2021-09-11 11:00:46 -07:00
Niranjana Binoy
0c2af43d3a
changing token address to lowercase for dynamic token list (#12071) 2021-09-10 23:55:23 -04:00
Niranjana Binoy
eb987a47b5
Integrating the TokenListController to Extension (#11398) 2021-09-09 16:56:27 -04:00
David Walsh
7b827ca5e7
Create MetaMask Beta build (#10985) 2021-09-08 15:08:23 -05:00
Alex Donesky
e8ab578ed0
bump @metamask/controllers to v15.0.2 and remove AbortController workaround in e2e tests (#11988)
* bump @metamask/controllers to v15.0.1 and remove AbortController workaround in e2e tests

* remove old abortcontroller polyfill

* bump @metamask/controllers to v15.0.2
2021-09-03 09:34:21 -05:00
ryanml
472cf17bda
Adding UI helpers for URL parsing (#11899) 2021-08-24 15:28:16 -07:00
ryanml
38b581cdfa
Return an empty string when date is not provided [Date display utils] (#11831) 2021-08-13 08:22:12 -07:00
Dan J Miller
bfde5a1d77
Fixes updates on the confirm screen. (#11788)
* Fixes updates on the confirm screen.

* Better handling of internal send transactions

* maxFee -> maxFeePerGas property name fix

* Remove redundant setEstimateToUse call in onManualChange

* Fix unit tests

* rebase error fix

* Fixes to speedup loading and transaction breakdown priority fee

* Fix lint and unit tests

* Ensure gas price based transaction that have been customized (e.g. speed up and retry) are properly initialized in useGasFeeInputs

* Clean up

* Link fix
2021-08-06 14:31:30 -05:00
Dan J Miller
0cf5019486
Use bignumber for number comparisons in useGasFeeInput (#11776)
* Use bignumber for number comparisons in useGasFeeInput

* fix
2021-08-05 13:52:56 -02:30
Dan J Miller
aaa15cbe03
Add support for EIP1559 transactions to transaction breakdown (#11622)
* Add support for EIP1559 transactions to transaction breakdown

* Use userPreferencedCurrencyDisplay for effective gas price in transaction breakdown

* Hide eip1559 gas properties in transaction breakdown on non-1559 networks

* Add comment explaining gasPrice and effectiveGasPrice usage in transaction breakdown container.
2021-07-28 15:00:34 -02:30
Dan J Miller
9a81b826c5
Only show dapp suggested gas fee warning if user has not edited the fee (#11621) 2021-07-27 20:01:53 -02:30
ryanml
d092e4bdbe
Fixing type issue with auto-filled custom token decimals value (#11604) 2021-07-26 07:08:10 -07:00
Brad Decker
da9fb4636b
move conversion utils to shared folder (#11451) 2021-07-06 12:48:49 -05:00
Alex Donesky
a4a5580785
Update controllers with conversionRate change with minimal required changes in extension (#11361)
* updating controllers with conversionRate change with minimal required changes in extension

* swapping showFiat selector in places where possible

* adding invalid conversion protection

* lint fixes

* adjusting list-item styling logic
2021-06-23 18:28:49 -05:00
ryanml
2bfc3a093f
Using values from shared/constants/time to represent timing values (#11241) 2021-06-10 12:27:03 -07:00