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

1444 Commits

Author SHA1 Message Date
Elliot Winkler
e951fe6a64
Improve autorebuilding in dev to reduce CPU load (#11886)
On an M1 Mac, when running `yarn start`, CPU can spike to 100% CPU, and
sometimes a bunch of `mdworker` instances will get spawned. This seems
to be caused by the file-watching mechanism used in dev to automatically
regenerate the build when something is changed. More specifically, we
are using an older version of `watchify`, which uses an older version of
`chokidar`, which is the package that actually does the watching. v4.0.0
of `watchify` upgrades `chokidar` to v3.x ([1]), which comes with
"massive CPU & RAM consumption improvements" ([2]). After the upgrade,
CPU usage decreases to 20-40%.

[1]: https://github.com/browserify/watchify/blob/master/CHANGELOG.md#400
[2]: https://github.com/paulmillr/chokidar/releases/tag/3.0.0
2021-10-25 13:56:26 -06:00
Mark Stacey
3068324ae0
Remove unused SEGMENT_LEGACY_WRITE_KEY (#12429)
This key has not been used since #10915, which is where we stopped
using the legacy Segment key.
2021-10-22 10:34:37 -02:30
ryanml
48f4e9845b Merge remote-tracking branch 'origin/develop' into master-sync 2021-10-21 15:05:12 -07:00
Dan J Miller
9d70c60c22
Connect Ledger via WebHID (#12411)
* Connect ledger via webhid if that option is available

* Explicitly setting preference for webhid

* Use ledgerTransportType enum instead of booleans for ledger live and webhid preferences

* Use single setLEdgerTransport preference methods and property

* Temp

* Lint fix

* Unit test fix

* Remove async keyword from setLedgerTransportPreference function definition in preferences controller

* Fix ledgelive setting toggle logic

* Migrate useLedgerLive preference property to ledgerTransportType

* Use shared constants for ledger transport type enums

* Use constant for ledger usb vendor id

* Use correct property to check if ledgerLive preference is set when deciding whether to ask for webhid connection

* Update eth-ledger-bridge-keyring to v0.9.0

* Only show ledger live transaction helper messages if using ledger live

* Only show ledger live part of tutorial if ledger live setting is on

* Fix ledger related prop type errors

* Explicitly use u2f enum instead of empty string as a transport type; default transport type to webhid if available; use constants for u2f and webhid

* Cleanup

* Wrap ledger webhid device request in try/catch

* Clean up

* Lint fix

* Ensure user can easily connect their ledger wallet when they need to.

* Fix locales

* Fix/improve locales changes

* Remove unused isFirefox property from confirm-transaction-base.container.js

* Disable transaction and message signing confirmation if ledger webhid requires connection

* Ensure translation keys for ledger connection options in settings dropdown can be properly detected by verify-locales

* Drop .component from ledger-instruction-field file name

* Move renderLedgerLiveStep to module scope

* Remove ledgerLive from function and message names in ledger-instruction-field

* Wrap ledger connection logic in ledger-instruction-field in try catch

* Clean up signature-request.component.js

* Check whether the signing address, and not the selected address, is a ledger account in singature-request.container

* Ensure ledger instructions and webhid connection button are shown on signature-request-original signatures

* Improve webhid selection handling in select-ledger-transport-type onChange handler

* Move metamask redux focused ledger selectors to metamask duck

* Lint fix

* Use async await in checkWebHidStatusRef.current

* Remove unnecessary use of ref in ledger-instruction-field.js

* Lint fix

* Remove unnecessary try/catch in ledger-instruction-field.js

* Check if from address, not selected address, is from a ledger account in confirm-approve

* Move findKeyringForAddress to metamask duck

* Fix typo in function name

* Ensure isEqualCaseInsensitive handles possible differences in address casing

* Fix Learn More link size in advanced settings tab

* Update app/scripts/migrations/066.js

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

* Update ui/pages/settings/advanced-tab/advanced-tab.component.test.js

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

* Add jsdoc comments for new selectors

* Use jest.spyOn for mocking navigator in ledger webhid migration tests

* Use LEDGER_TRANSPORT_TYPES values to set proptype of ledgerTransportType

* Use LEDGER_TRANSPORT_TYPES values to set proptype of ledgerTransportType

* Fix font size of link in ledger connection description in advanced settings

* Fix return type in setLedgerTransportPreference comment

* Clean up connectHardware code for webhid connection in actions.js

* Update app/scripts/migrations/066.test.js

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

* Update ui/ducks/metamask/metamask.js

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

* Add migration test for when useLedgerLive is true in a browser that supports webhid

* Lint fix

* Fix inline-link size

Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-10-21 16:47:03 -02:30
MetaMask Bot
bfff44b3c1 Version v10.3.0 2021-10-18 21:05:07 +00:00
David Walsh
77f8ec4d3a
Fix 12265 - Update onboarding welcome screen (#12275) 2021-10-13 09:22:51 -05:00
Mark Stacey
e4cf12674e
Simplify Mocha npm scripts (#12313)
The npm scripts used to run Mocha scripts have been greatly simplified.
As we transition more tests from Mocha to Jest it was becoming
increasingly difficult to update the CLI arguments to keep all of these
scripts working correctly. This reorganization should make that process
much simpler.

The base Mocha options are in `.mocharc.js` - all except for the target
tests to run. Those are still given via the CLI. There is a second
config file specifically for the `test:unit:lax` tests (i.e. the Mocha
tests that have no coverage requirements) because it requires a change
to the `ignored` configuration property. We can create an additional
configuration file for each test script we add that needs further
configuration changes.

The `test:unit:path` script used to be used to run Mocha tests at a
given path. Now that can be done using `yarn mocha` instead, so this
script has been removed.

The `yarn watch` command has been broken for some time now, so it has
been removed as well. Mocha tests can still be run with a file watcher
using `yarn mocha --watch <path>` or `yarn test:unit:mocha --watch`.

The README has been updated to remove references about the `watch`
command that was removed. I considered explaining the other test
scripts there as well, but they were difficult to explain I will
attempt to update the README after making further simplifications
instead.
2021-10-12 10:10:33 -02:30
ryanml
018095691f Merge remote-tracking branch 'origin/develop' into master-sync 2021-10-09 16:46:28 -07:00
MetaMask Bot
6ae261e7b0 Version v10.2.2 2021-10-09 17:35:41 +00:00
Mark Stacey
9da60c7a42
Update caniuse-lite (#12312)
`caniuse-lite` has been updated to the latest published version. This
update prevents various console warnings that appear during the build.
2021-10-08 22:47:41 -02:30
MetaMask Bot
ff20a999e0 Version v10.2.1 2021-10-08 21:45:18 +00:00
Alex Donesky
cd26cab8fe use improved-yarn-audit and exclude 1002401 and 1002581 (#12310)
* use improved-yarn-audit and exclude 1002401
2021-10-08 14:40:30 -07:00
Mark Stacey
56f800057b Update immer from v8 to v9 (#12303)
`immer` has been updated to v9. This didn't require any changes on our
part; the only breaking changes are to the TypeScript types [1].

The `@reduxjs/toolkit` library has been updated as well, to ensure that
it's using the updated version of Immer internally as well. This update
makes our patch of that package obsolete, as the problematic pattern
that were were patching out is no longer present.

[1]: https://github.com/immerjs/immer/releases/tag/v9.0.0
2021-10-08 14:40:20 -07:00
Alex Donesky
3b5e33bc4c
use improved-yarn-audit and exclude 1002401 and 1002581 (#12310)
* use improved-yarn-audit and exclude 1002401
2021-10-08 12:18:38 -05:00
Mark Stacey
7a5b48e018
Update immer from v8 to v9 (#12303)
`immer` has been updated to v9. This didn't require any changes on our
part; the only breaking changes are to the TypeScript types [1].

The `@reduxjs/toolkit` library has been updated as well, to ensure that
it's using the updated version of Immer internally as well. This update
makes our patch of that package obsolete, as the problematic pattern
that were were patching out is no longer present.

[1]: https://github.com/immerjs/immer/releases/tag/v9.0.0
2021-10-08 11:50:07 -02:30
Mark Stacey
3a5538bd50
Migrate beta version to the main version field (#12246)
The main `version` field in `package.json` will now include the beta
version (if present) rather than it being passed in via the CLI when
building. The `version` field is now a fully SemVer-compatible version,
with the added restriction that any prerelease portion of the version
must match the format `<build type>.<build version>`.

This brings the build in-line with the future release process we will
be using for the beta version. The plan is for each future release to
enter a "beta phase" where the version would get updated to reflect
that it's a beta, and we would increment this beta version over time as
we update the beta. The manifest gives us a place to store this beta
version. It was also important to replace the automatic minor bump
logic that was being used previously, because the version in beta might
not be a minor bump.

Additionally, the filename logic used for beta builds was updated to
be generic across all build types rather than beta-specific. This will
be useful for Flask builds in the future.
2021-10-06 15:14:48 -02:30
Erik Marks
822ce5b8b0
Fix unit test package scripts (#12278)
This PR fixes our local unit test package scripts. When the state migration unit tests were migrated to Jest in #12106, it left the `test:unit` script in a broken state, because it didn't tell `mocha` to ignore the state migration tests.

Arguably, that script was already broken, since the most reasonably expectation from its name is that it runs _all_ unit tests. The PR makes it so that it does just that, by means of `concurrently`.

Unfortunately, `concurrently` only outputs errors from child processes once (at the time when they exit, https://github.com/open-cli-tools/concurrently/issues/134). This means that we have to search/navigate the output for this combined script to identify the failure. That said, it's better than the status quo.
2021-10-06 07:35:23 -07:00
kumavis
cb174ff8e6
Lavamoat build system integration for WebApp (#12242)
* lavamoat - add lavamoat to webapp background

* test:e2e - add delay to resolve failure

* test:e2e - add delay to resolve failure

* build - add a switch for applying lavamoat, currently off for all

* test/e2e - remove delays added for lavamoat

* Revert "test/e2e - remove delays added for lavamoat"

This reverts commit 79c3479f15c072ed362ba1d4f1af41ea11a17d63.
2021-10-05 12:06:31 -10:00
ryanml
2f9f187d7e Merge remote-tracking branch 'origin/develop' into master-sync 2021-10-01 14:20:46 -07:00
Matthew Epps
53f2c84209
Add client id to GasFeeController (#12221)
* chore: Add client id to GasFeeController

* chore: change EXTENSION_CLIENT_ID to SWAPS_CLIENT_ID in constants file
2021-09-29 10:41:19 -02:30
kumavis
d9d20160d6
LavaMoat Node update and various small enhancements (#12239)
* lavamoat - update lavamoat-node and relevant policy + two handy patches

* test/e2e - add timeout known to be flaky

* lavamoat-viz - rename npm script
2021-09-28 20:56:08 -10:00
Mark Stacey
506fa2d744
Fix Buffer warnings during build (#10495)
The warnings about use of the unsafe Buffer constructor have been
addressed by package updates and patches.

The updates were:
 * `gulp-sourcemaps` was updated from v2 to v3, and was patched to
replace remaining uses of the `Buffer` constructor
   * Upstream PR: https://github.com/gulp-sourcemaps/gulp-sourcemaps/pull/388
 * The transitive dependency `yazl` was updated from v2.4.3 to v2.5.1
in the lockfile.
 * The abandoned packages `combine-source-map` and `inline-source-map`
were patched.
2021-09-27 19:05:35 -02:30
Mark Stacey
2a1d0cfd2c
Update caniuse-lite (#12203)
The dependency `caniuse-lite` has been updated using a Yarn resolution,
because it was pinned to a specific version by some dependencies. All
versions requested in our dependency tree are 1.x so this did not
introduce any breaking changes.

This resolves a frequent console warning that shows up during builds,
and when running tests and the linter.
2021-09-24 11:42:28 -02:30
MetaMask Bot
646f78eb30 Version v10.2.0 2021-09-22 19:18:47 +00:00
Alex Donesky
8eca780746
Merge pull request #12171 from MetaMask/master-sync
sync `master` with `develop`
2021-09-21 12:46:36 -05:00
Thomas Huang
e78e82205a
Jestify migrations/ (#12106)
* Jestify migrations/

* Lint exclude migrations from mocha config, and add inclusion to jest config

* Add migration tests to jest config

* Exclude/ignore migration tests

* Set process.env.IN_TEST to true when running tests locally
2021-09-21 09:28:13 -07:00
Alex
b751cf80b9 Merge remote-tracking branch 'origin/develop' into master-sync 2021-09-21 11:18:59 -05:00
Brad Decker
9204e65c7e fix pubnub dep vulnerabiltiy (#12170) 2021-09-21 10:19:08 -05:00
Brad Decker
c35797453d
fix pubnub dep vulnerabiltiy (#12170) 2021-09-21 10:12:51 -05:00
MetaMask Bot
3f5dcbf697 Version v10.1.1 2021-09-17 09:35:51 -05:00
Alex Donesky
05c4b9691e bump @metamask/controllers to v16.0.0 (#12133) 2021-09-17 09:35:49 -05:00
Alex Donesky
a7561aaef3
bump @metamask/controllers to v16.0.0 (#12133) 2021-09-16 15:42:09 -05:00
kumavis
f472c2615a
CI - add metamaskbot comment "highlights" section for showing relevant storybook changes (#12095)
* ci/announce/highlight - add bot announcement section for "highlights" showing off important diffs + storybook highlights

* ci/announce/highlight - fix announcement message

* Update index.js

* xxx tmp xxx

* ci/announce/highlight - fix dirty file calculation

* ci/announce/highlight - try/catch wrap highlight generation for build stability

* ui - put fox emojis in the mascot component

* ci/announce/highlight - start storybook permalinks

* ci/announce/highlight - fix storybook permalink util

* ci/announce/highlight - fix storybook permalink util

* ci/announce/highlight - small styling fix

* storybook - use any easily predictable story id

* ci/announce/highlight - revert sample commit

* ci/announce/highlight - minimal documentation
2021-09-15 08:55:48 -10:00
Erik Marks
3de3765425
Add build-time code exclusion using code fencing (#12060)
This PR adds build-time code exclusion by means of code fencing. For details, please see the README in `./development/build/transforms`. Note that linting of transformed files as a form of validation is added in a follow-up, #12075.

Hopefully exhaustive tests are added to ensure that the transform works according to its specification. Since these tests are Node-only, they required their own Jest config. The recommended way to work with multiple Jest configs is using the `projects` field in the Jest config, however [that feature breaks coverage collection](https://github.com/facebook/jest/issues/9628). That being the case, I had to set up two separate Jest configs. In order to get both test suites to run in parallel, Jest is now invoked via a script, `./test/run-jest.sh`.

By way of example, this build system feature allows us to add fences like this:

```javascript
this.store.updateStructure({
  ...,
  GasFeeController: this.gasFeeController,
  TokenListController: this.tokenListController,
  ///: BEGIN:ONLY_INCLUDE_IN(beta)
  PluginController: this.pluginController,
  ///: END:ONLY_INCLUDE_IN
});
```

Which at build time are transformed to the following if the build type is not `beta`:

```javascript
this.store.updateStructure({
  ...,
  GasFeeController: this.gasFeeController,
  TokenListController: this.tokenListController,
});
```

Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2021-09-14 10:00:04 -07:00
Alex Donesky
490d3b8d40
Integrate TokensController (#11552)
* Integrate controllers/tokensController

* address rebase issues

* small cleanup

* addressing feedback

* more feedback
2021-09-10 12:37:19 -05:00
Erik Marks
413700afc7
Rationalize build system arguments (#12047)
This rationalizes how arguments are passed to and parsed by the build system. To accomplish this, everything that isn't an environment variable from `.metamaskrc` or our CI environment is now passed as an argument on the command line.

Of such arguments, the `entryTask` is still expected as a positional argument in the first position (i.e. `process.argv[2]`), but everything else must be passed as a named argument. We use `minimist` to parse the arguments, and set defaults to preserve existing behavior.

Arguments are parsed in a new function, `parseArgv`, in `development/build/index.js`. They are assigned to environment variables where convenient, and otherwise returned from `parseArgv` to be passed to other functions invoked in the same file.

This change is motivated by our previous inconsistent handling of arguments to the build system, which will grow increasingly problematic as the build system grows in complexity. (Which it will very shortly, as we introduce Flask builds.)

Miscellaneous changes:
- Adds a build system readme at `development/build/README.md`
- Removes the `beta` package script. Now, we can instead call: `yarn dist --build-type beta`
- Fixes the casing of some log messages and reorders some parameters in the build system
2021-09-09 12:44:57 -07:00
Elliot Winkler
bbe972ca46
Upgrade chromedriver to 93 (#11990)
This allows developers to run the Chrome e2e tests locally without
having to have a custom version of Chrome installed.
2021-09-08 14:54:31 -06:00
David Walsh
7b827ca5e7
Create MetaMask Beta build (#10985) 2021-09-08 15:08:23 -05:00
ryanml
6836789d2c Merge remote-tracking branch 'origin/develop' into master-sync 2021-09-07 14:13:03 -07: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
Elliot Winkler
7daa55a52c Fix 'yarn setup' on M1 Macs (#11887)
There are a few issues encountered when running `yarn setup` on new
Apple Silicon (aka M1, aka arm64) Macs:

* The script halts when attempting to run the install step for
  the `chromedriver` package with the message "Only Mac 64 bits
  supported". This is somewhat misleading as it seems to indicate that
  chromedriver can only be installed on a 64-bit Mac. However, what I
  think is happening is that the installation script for `chromedriver`
  is not able to detect that an arm64 CPU *is* a 64-bit CPU. After
  looking through the `chromedriver` repo, it appears that 87.0.1 is the
  first version that adds a proper check ([1]).

  Note that upgrading chromedriver caused the Chrome-specific tests to
  fail intermittently on CI. I was not able to 100% work out the reason
  for this, but ensuring that X (which provides a way for Chrome to run
  in a GUI setting from the command line) is available seems to fix
  these issues.

* The script also halts when attempting to run the install step for
  the `electron` package. This happens because for the version of
  `electron` we are using (9.4.2), there is no available binary for
  arm64. It appears that Electron 11.x was the first version to support
  arm64 Macs ([2]). This is a bit trickier to resolve because we don't
  explicitly rely on `electron` — that's brought in by `react-devtools`.
  The first version of `react-devtools` that relies on `electron` 11.x
  is 4.11.0 ([3]).

[1]: 469dd0a6ee
[2]: https://www.electronjs.org/blog/apple-silicon
[3]: https://github.com/facebook/react/blob/main/packages/react-devtools/CHANGELOG.md#4110-april-9-2021
2021-09-01 14:56:34 -07:00
MetaMask Bot
a70b9c346b Version v10.1.0 2021-09-01 17:50:44 +00:00
Dan J Miller
9cf7413e4b 1559 ledger (#11951)
* EIP-1559 - Provide support for Ledger

* Update ui/selectors/selectors.js

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

* Add shared constants for hw types

* bump eth-ledger-bridge-keyring to v0.7.0

Co-authored-by: David Walsh <davidwalsh83@gmail.com>
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
Co-authored-by: Alex <adonesky@gmail.com>
2021-09-01 10:43:42 -07:00
Elliot Winkler
8ffebb294b
Fix 'yarn setup' on M1 Macs (#11887)
There are a few issues encountered when running `yarn setup` on new
Apple Silicon (aka M1, aka arm64) Macs:

* The script halts when attempting to run the install step for
  the `chromedriver` package with the message "Only Mac 64 bits
  supported". This is somewhat misleading as it seems to indicate that
  chromedriver can only be installed on a 64-bit Mac. However, what I
  think is happening is that the installation script for `chromedriver`
  is not able to detect that an arm64 CPU *is* a 64-bit CPU. After
  looking through the `chromedriver` repo, it appears that 87.0.1 is the
  first version that adds a proper check ([1]).

  Note that upgrading chromedriver caused the Chrome-specific tests to
  fail intermittently on CI. I was not able to 100% work out the reason
  for this, but ensuring that X (which provides a way for Chrome to run
  in a GUI setting from the command line) is available seems to fix
  these issues.

* The script also halts when attempting to run the install step for
  the `electron` package. This happens because for the version of
  `electron` we are using (9.4.2), there is no available binary for
  arm64. It appears that Electron 11.x was the first version to support
  arm64 Macs ([2]). This is a bit trickier to resolve because we don't
  explicitly rely on `electron` — that's brought in by `react-devtools`.
  The first version of `react-devtools` that relies on `electron` 11.x
  is 4.11.0 ([3]).

[1]: 469dd0a6ee
[2]: https://www.electronjs.org/blog/apple-silicon
[3]: https://github.com/facebook/react/blob/main/packages/react-devtools/CHANGELOG.md#4110-april-9-2021
2021-09-01 10:40:40 -06:00
Dan J Miller
a4c0133bc5
1559 ledger (#11951)
* EIP-1559 - Provide support for Ledger

* Update ui/selectors/selectors.js

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

* Add shared constants for hw types

* bump eth-ledger-bridge-keyring to v0.7.0

Co-authored-by: David Walsh <davidwalsh83@gmail.com>
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
Co-authored-by: Alex <adonesky@gmail.com>
2021-09-01 11:25:06 -05:00
Erik Marks
8a8ce3a0c0
@metamask/controllers@15.0.0 (#11975)
Adds the latest version of `@metamask/controllers`, and updates our usage of the `ApprovalController`, which has been migrated to `BaseControllerV2`. Of [the new `controllers` release](https://github.com/MetaMask/controllers/releases/tag/v15.0.0), only the `ApprovalController` migration should be breaking.

This is the first time we use events on the `ControllerMessenger` to update the badge, so I turned the messenger into a property on the main `MetaMaskController` in order to subscribe to events on it in `background.js`. I confirmed that the badge does indeed update during local QA.

As it turns out, [MetaMask/controllers#571](https://github.com/MetaMask/controllers/pull/571) was breaking for a single unit test case, which is now handled during setup and teardown for the related test suite (`metamask-controller.test.js`).
2021-08-31 12:27:13 -07:00
ryanml
06f1f09e2f Merge remote-tracking branch 'origin/develop' into master-sync 2021-08-26 09:44:23 -07:00
MetaMask Bot
da30254ba4 Version v10.0.3 2021-08-25 18:59:57 +00:00
ryanml
a44d863093
Adding yarn scripts for changelog validation (#11868) 2021-08-18 08:59:48 -07:00
ryanml
352e1dd74c Merge remote-tracking branch 'origin/develop' into master-sync 2021-08-18 08:36:19 -07:00