1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-22 01:47:00 +01:00
Commit Graph

5027 Commits

Author SHA1 Message Date
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
igorms-cons
e41ac173d1
display hex data on send screen fixed (#12709) 2021-12-09 06:56:49 -03:30
Dan J Miller
e45560859c
Support EIP-1559 on Trezor Model One (#13023)
* Support EIP-1559 on Trezor Model One

* Update unit tests

* Fix unit test

* Run yarn lavamoat:auto
2021-12-08 23:16:54 -03:30
Jyoti Puri
8c5fdf779c
Fixing EIP-1559 V2 advance gas fee inputs validations (#13013) 2021-12-09 04:26:10 +05:30
Mark Stacey
5076e5057f
Remove nodeify (#13003)
The `nodeify` utility is no longer needed for the background API.
Instead each method is assumed to be either synchronous or Promise-
returning.

The error handling was updated to at least log the error in the case
where a method fall fails after the connection is broken.
2021-12-08 18:06:53 -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
Etienne Dusseault
d2843c3bb4
toggle-button (#12817) 2021-12-08 12:51:25 -08:00
Etienne Dusseault
7b2812475a
Fix error-message component to match new Storybook format (#12815)
* error-message

* Updating prop type descriptions

Co-authored-by: georgewrmarshall <george.marshall@consensys.net>
2021-12-08 12:50:58 -08:00
Etienne Dusseault
c3e7952656
Fix dropdown component for new Storybook format (#12816)
* dropdown

* Updating default props, proptype descriptions and removing required as doesn't do anything

Co-authored-by: georgewrmarshall <george.marshall@consensys.net>
2021-12-08 12:49:27 -08:00
Etienne Dusseault
363f81db11
Fix signature-request for new Storybook format (#12755)
* signature request storybook

* remove clearConfirmTransaction

* fix text
2021-12-08 12:32:59 -08:00
Etienne Dusseault
08ed32dfe6
Fix form-field for new Storybook format (#12756)
* form-field

* add proptype
2021-12-08 12:32:27 -08:00
George Marshall
f4a9c57728
Identicon size fix (#13014)
* Fixing Identicon size

* Reverting to use classnames function
2021-12-08 11:54:22 -08:00
g. nicholas d'andrea
4ed7c8c559
Fix tx-insight accreditation styling (#13009)
* Fix tx-insight accreditation styling

- Ensure "Etherscan" appears capitalized
- Ensure messages are separated by newline
- Handle case where server returns `fetchedVia` that frontend doesn't
  support

* Revert "Fix tx-insight accreditation styling"

This reverts commit f7121d23cf9e5cf37e18444793933c36b66d9028.

* New Fix tx-insight accreditation styling

Co-authored-by: Dan Miller <danjm.com@gmail.com>
2021-12-08 13:21:49 -03:30
Dan J Miller
5e9ea9d8fa
Add what's new notification for transaction insights (#13000)
* Add what's new notification for transaction insights

* locales file lint fix
2021-12-08 10:47:01 -03:30
Etienne Dusseault
1794ee8b72
Fix metamask-translation component for new Storybook format (#12892)
* metamask-translation

* Replacing broken ArgsTable with manual markdown table

* Grammer fix

Co-authored-by: georgewrmarshall <george.marshall@consensys.net>
2021-12-07 14:29:12 -08:00
Alaa Hadad
a858b85899
Tx decoding accreditation (#12918)
* feature: adding support for truffle and etherscan accreditation

* Fix scss linting

* fix styling and classnames

* Switch font size to rem

* Update ui/components/app/transaction-decoding/components/ui/accreditation/accreditation.component.js

Co-authored-by: George Marshall <georgewrmarshall@gmail.com>

* Update ui/components/app/transaction-decoding/components/ui/accreditation/index.scss

Co-authored-by: George Marshall <georgewrmarshall@gmail.com>

* Update ui/components/app/transaction-decoding/components/ui/accreditation/accreditation.component.js

Co-authored-by: George Marshall <georgewrmarshall@gmail.com>

* Update ui/components/app/transaction-decoding/components/ui/accreditation/accreditation.component.js

Co-authored-by: George Marshall <georgewrmarshall@gmail.com>

* Fix linting

Co-authored-by: g. nicholas d'andrea <gnidan@trufflesuite.com>
Co-authored-by: Dan J Miller <danjm.com@gmail.com>
Co-authored-by: George Marshall <georgewrmarshall@gmail.com>
Co-authored-by: g. nicholas d'andrea <gnidan@users.noreply.github.com>
2021-12-07 16:13:14 -03:30
Dan J Miller
f5a086ded9
Update tx-insights url (#12997) 2021-12-07 15:42:46 -03:30
George Marshall
80134137ba
Updating storybook documentation guidelines (#12957)
* Updating storybook documentation guidelines

* Grammer fixes
2021-12-07 10:24:06 -08:00
igorms-cons
981db6e0ea
Fix confirmed transaction time (#12633) 2021-12-07 12:16:40 -06:00
Etienne Dusseault
5205f02de6
Fix Actionable message for new Storybook format (#12874)
* actionable-message

* remove usage table

* Updating stories

* linting fix

Co-authored-by: georgewrmarshall <george.marshall@consensys.net>
2021-12-07 10:01:17 -08:00
Etienne Dusseault
09ba8d689e
Fix icon component for new Storybook format (#12887)
* icon

* removed unused var

* Updating proptype comments and adding missing stories

Co-authored-by: georgewrmarshall <george.marshall@consensys.net>
2021-12-07 10:01:02 -08:00
Etienne Dusseault
61935835a0
Fix identicon component for new Storybook format (#12888)
* identicon

* Upating identicon story and withBorder prop to work dynamically

Co-authored-by: georgewrmarshall <george.marshall@consensys.net>
2021-12-07 09:58:52 -08:00
Etienne Dusseault
51fa7734fd
text-field (#12889) 2021-12-07 09:57:23 -08:00
Etienne Dusseault
5273aa334e
Fix account-list-item component for new Storybook format (#12893)
* account-list-item

* Updates

Co-authored-by: georgewrmarshall <george.marshall@consensys.net>
2021-12-07 09:45:04 -08:00
Etienne Dusseault
068e97314e
Fix dropdown-input-pair component to for new Storybook format (#12895)
* input pair

* proptype comments

* Update

Co-authored-by: georgewrmarshall <george.marshall@consensys.net>
2021-12-07 09:44:25 -08:00
Etienne Dusseault
c0f03d827d
Fix popover component to for new Storybook format (#12896)
* popover

* add proptype comments

* Update

* updating use state var name

Co-authored-by: georgewrmarshall <george.marshall@consensys.net>
2021-12-07 09:38:33 -08:00
Etienne Dusseault
de4b54c230
info-tooltip (#12901) 2021-12-07 09:37:39 -08:00
Etienne Dusseault
bd17160e2a
Fix slider component to for new Storybook format (#12897)
* slider

* removing args table as it doesn't work with mui withStyles

Co-authored-by: georgewrmarshall <george.marshall@consensys.net>
2021-12-07 09:37:07 -08:00
Etienne Dusseault
d5b85c0e54
Fix radio-group component to for new Storybook format (#12900)
* radio-group

* tweak proptype descs
2021-12-07 09:36:16 -08:00
Matthew Epps
311ea021f3
Optimize rest of swaps flow (#12939) 2021-12-07 11:33:13 -06:00
Etienne Dusseault
f9eaf2f005
Updating PulseLoader story format (#12818) 2021-12-07 08:40:38 -08:00
Etienne Dusseault
ac463bee71
Fix transaction-detail-item for new Storybook format (#12820) 2021-12-07 08:40:05 -08:00
Etienne Dusseault
9e59c3db77
Fix transaction-detail for new Storybook format (#12819) 2021-12-07 08:39:44 -08:00
Dan J Miller
7212dcf098
Tx insights fixes (#12988)
* Ensure that function representation on hex and data tabs are consistent

* Don't show redundant hex tab when deploying contract

* Show standard pointer cursor on error messages in tx-decoder component

* Don't show activity log for incoming transactions

* Update localization

* Fix error message
2021-12-07 11:42:34 -03:30
Daniel
c8b697687f
Swaps UI redesign for the View Quote page (#12950)
* Update EIP-1559 UI on the View Quote page (WIP)

* UI redesign for the View Quote page in Swaps, update tests,  refactoring

* Update styles for the View Quote page

* Improve scrolling and styling for the View Quote page

* Update snapshots

* Fix a scrolling issue

* Use Ethereum mainnet for swaps API calls if it's Rinkeby

* UI / content updates on the View Quote page

* Remove unused content in Swaps

* Fix an ESLint issue

* Update UTs with the latest content

* Renaming

* Remove 2 more unused content strings
2021-12-07 00:21:26 -03:30
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
Etienne Dusseault
9fcfbe7609
Fix unlock-page component for new Storybook format (#12894)
* unlock-page

* Updating comments and removing broken args table

Co-authored-by: georgewrmarshall <george.marshall@consensys.net>
2021-12-06 15:08:13 -08:00
ryanml
bab48c809a
Clear the clipboard after seed phrase is pasted (Restore vault) (#12987) 2021-12-06 12:17:56 -07:00
Jyoti Puri
2af45a656f
Adding validations for advance gas fee input fields (#12879) 2021-12-07 00:17:26 +05:30
Jyoti Puri
6fc9b6b7a2
Using EIP-1559 V2 for approve transaction flow (#12906) 2021-12-06 22:09:35 +05:30
Jyoti Puri
a6bb503e52
Adding tooltips in edit gas fee network status section (#12916) 2021-12-06 21:32:23 +05:30
Alex Donesky
2dd8689d8a
fix gas-tooltip fonts (#12968) 2021-12-06 09:40:30 -06:00
Jyoti Puri
9dd5af3523
Implementing design feedbacks in EIP-1559 V2 flow (#12943) 2021-12-06 21:10:20 +05:30
Mark Stacey
b983971bfd
Disable remote-redux-devtools in non-dev builds (#12956)
`remote-redux-devtools` is now explicitly excluded and disabled in non-
dev builds, and in the `testDev` build. This was causing console errors
in the `testDev` build during e2e tests, which would cause certain
tests to fail.

This was already only supposed to be enabled for development builds,
but this library used the `NODE_ENV` environment variable to make that
determination. This gives us more control over when it's disabled.
2021-12-06 11:55:40 -03:30
Mark Stacey
b75ef5f0eb
Remove redundant EIP_1559_V2_ENABLED comparison (#12954)
A redundant comparison for the `EIP_1559_V2_ENABLED` variable has been
removed. This variable is a boolean, so it can be treated as a boolean
directly in most cases.

One such comparison has been preserved for the purpose of allowing unit
testing, because `process.env` entries are always strings in Node.js. A
comment was added to explain this.
2021-12-06 11:23:02 -03:30
George Marshall
6d34d85f6e
Textarea UI component (#12688)
* Initial Textarea component

* added no-scroll class and css

* added tests

* removed comment from prettier, updated README title

* updated tests

* added resize tests

* fixed grammar

* updated scss

* changes per linter

* updated title to match new folder structure for storybook

* reverted unintended change

Co-authored-by: hmalik88 <hassan.malik@consensys.net>
Co-authored-by: Hassan Malik <41640681+hmalik88@users.noreply.github.com>
2021-12-03 11:54:29 -05:00
Jyoti Puri
cd4ddffd9c
Adding gas limit section on advance gas fee modal (#12865) 2021-12-03 21:29:48 +05:30
Alex Donesky
6542d16349
1559 v2 tooltips (#12750)
* add tooltips
2021-12-03 09:44:23 -06:00
Mark Stacey
91af73b211
Remove invalid disableRipple prop (#12948)
The `disableRipple` prop was resulting in a React error in development
builds because it was unrecognized by React. This prop dates back to
when we were using the `@material-ui` Button class. It no longer serves
any purpose, so it has been removed.
2021-12-03 11:22:14 -03:30
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