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

17772 Commits

Author SHA1 Message Date
Maarten Zuidhoorn
785e0d0923
[FLASK] Fix regression in transaction confirmation tabs (#20267)
* Fix regression in transaction confirmation tabs

* Fix transaction insights e2e test
2023-08-21 12:03:55 +02:00
Dhruv
ba31f87014
fix/TagUrl to TS (#20519) 2023-08-18 17:59:02 -07:00
Dan J Miller
c32b406989 Merge origin/develop into master-sync 2023-08-18 21:09:08 -02:30
Dan J Miller
c6b83127bc
Merge pull request #20482 from MetaMask/Version-v10.34.5
Version v10.34.5
2023-08-18 20:39:14 -02:30
Michele Esposito
efd34343c8
Use KeyringController messenger events (#20341)
* refactor: use keyring-controller events and unlock methods

* test: add tests for setLocked

* rollback: call trezor dispose directly

* Update app/scripts/metamask-controller.js

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

---------

Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2023-08-18 19:37:38 -02:30
Dhruv
07abc53cce
fix/BannerBase to TS (#20421)
* BannerBase to TS

* snapshot updates

* more snapshot updates

* addressing type definition error

* updating eth-sign-modal snapshot

* Updates to stories, types and adding data-testid

* Updating snapshots

* updating snapshot of blockaid-banner-alert and adding unit test for childrenWrapperProps

* BannerBase updates to stories, adding locale for close button, removing static data-testid in favor of using it at the instance, updating snapshots associated with those changes

* Removing incorrect arg from storybook file

* Updating html element in security provider e2e test to match BannerBase. Also updating snapshot of ConfirmTransaction page

* Fixing e2e tests

---------

Co-authored-by: georgewrmarshall <george.marshall@consensys.net>
2023-08-18 14:52:40 -07:00
Mark Stacey
f83c7ff3ef
Update changelog for v10.34.5 (#20533) 2023-08-18 18:30:40 -02:30
Mark Stacey
ddeaeb5ba5 Fix Sentry breadcrumb collection during initialization (again) (#20532)
Sentry breadcrumb collection during initialization was broken in #20529
because we failed to consider that the `getSentryState` check was also
used for an opt-in check in the `beforeBreadcrumb` hook.

I had assumed that `getSentryState` was only used to get state to add
additional context to an error report. But the function has a second
purpose: to get state for the purposes of checking whether the user has
opted into MetaMetrics. In this second case, `mostRecentRetrievedState`
is sometimes unset (which violates an assumption made in #20529)

The `getMostRecentPersistedState` hook removed in #20529 has been
restored, ensuring that the `getSentryState` function returns Sentry
state after loading state for the first time, but before the first
error has occurred.

This mistake didn't cause e2e tests to fail because multiple errors are
currently thrown in the background upon initialization on `develop`
(relating to Snow scuttling). These errors were early enough that they
happened before the console logs that our breadcrumb test was testing
for. When #20529 was ported onto the v10.34.5 RC, these errors were not
present so the test failed correctly.
2023-08-18 18:26:50 -02:30
Mark Stacey
885a8ce256
Fix Sentry breadcrumb collection during initialization (again) (#20532)
Sentry breadcrumb collection during initialization was broken in #20529
because we failed to consider that the `getSentryState` check was also
used for an opt-in check in the `beforeBreadcrumb` hook.

I had assumed that `getSentryState` was only used to get state to add
additional context to an error report. But the function has a second
purpose: to get state for the purposes of checking whether the user has
opted into MetaMetrics. In this second case, `mostRecentRetrievedState`
is sometimes unset (which violates an assumption made in #20529)

The `getMostRecentPersistedState` hook removed in #20529 has been
restored, ensuring that the `getSentryState` function returns Sentry
state after loading state for the first time, but before the first
error has occurred.

This mistake didn't cause e2e tests to fail because multiple errors are
currently thrown in the background upon initialization on `develop`
(relating to Snow scuttling). These errors were early enough that they
happened before the console logs that our breadcrumb test was testing
for. When #20529 was ported onto the v10.34.5 RC, these errors were not
present so the test failed correctly.
2023-08-18 18:26:27 -02:30
George Marshall
dc6069a3ab
Deprecating ErrorMessage in favor of BannerAlert (#20461) 2023-08-18 13:27:10 -07:00
Mark Stacey
0a3241e30d Fix pre-initialization UI error state capture (#20529)
In the case where an error is thrown in the UI before initialization
has finished, we aren't capturing the application state correctly for
Sentry errors. We had a test case for this, but the test case was
broken due to a mistake in how the `network-store` was setup (it was
not matching the behavior of the real `local-tstore` module).

The pre-initialization state capture logic was updated to rely solely
upon the `localStore` instance used by Sentry to determine whether the
user had opted-in to metrics or not. This simplifies the logic a great
deal, removing the need for the `getMostRecentPersistedState` state
hook. It also ensures that state is captured corretly pre-
initialization in both the background and UI.
2023-08-18 16:35:03 -02:30
Mark Stacey
9cfa9ba6b0
Fix pre-initialization UI error state capture (#20529)
In the case where an error is thrown in the UI before initialization
has finished, we aren't capturing the application state correctly for
Sentry errors. We had a test case for this, but the test case was
broken due to a mistake in how the `network-store` was setup (it was
not matching the behavior of the real `local-tstore` module).

The pre-initialization state capture logic was updated to rely solely
upon the `localStore` instance used by Sentry to determine whether the
user had opted-in to metrics or not. This simplifies the logic a great
deal, removing the need for the `getMostRecentPersistedState` state
hook. It also ensures that state is captured corretly pre-
initialization in both the background and UI.
2023-08-18 16:32:28 -02:30
jainex
3d9457e517
Replacing deprecated Popover with Modal (#20413)
* Replacing deprecated Popover with Modal

* Replacing deprecated Popover with Modal in detected-token-ignored-popover

* Remove unused code

* fix hover problem

* update footerButton size to large

* Lint fix

* UI updates and removing unused CSS

* reset chnages in edit-gas-popover.component.js

---------

Co-authored-by: georgewrmarshall <george.marshall@consensys.net>
2023-08-18 09:54:50 -07:00
Srirag
7f157cabf9
Deprecation message has been added above @mixin H1 (#20500) 2023-08-18 09:54:12 -07:00
Albert Olivé
8df77ed93d
[MMI] Always redirect to MMI portfolio dashboard upon the user clicking on swaps (#20527) 2023-08-18 18:44:23 +02:00
Gauthier Petetin
23249b68b7
feat: github actions to automatically create and close bug report issue (#20391)
* feat(action): github action to create bug report issue at RC cut

* feat(action): github action to close bug report issue once release is ready

* fix(action): replace main by master

* fix(action): create event does not support branch filter

* fix(action): indentation

* fix(action): actionlint erors

* fix(action): actionlint erors 2

* fix(action): actionlint erors 3

* fix(action): replace npm by yarn for consistency
2023-08-18 12:57:04 -03:00
Dan J Miller
016a1ef4e4 Remove GHSA-h755-8qp9-cq8 from advisory exclusions because yarn audit output no longer flags that advisory 2023-08-18 12:58:08 -02:30
Dan J Miller
fa778d5af9 Update snapshot tests for errors.spec.js 2023-08-18 12:55:33 -02:30
Dan J Miller
c2163434db Fix and test log.info calls run for each migration (#20517)
* Fix and test log.info calls run for each migration

In migrator/index.js, log.info is called before an after each migration.
These calls are intended to produce breadcrumbs to be captured by sentry
in cases where errors happen during or shortly after migrations are run.
These calls were not causing any output to the console because the log.setLevel
calls in ui/index.js were setting a 'warn value in local storage that was being
used by logLevel in the background.

This commit fixes the problem by setting the `persist` param of setLevel to
false, so that the background no longer reads the ui's log level.

Tests are added to verify that these logs are captured in sentry breadcrumbs
when there is a migration error due to an invariant state.

* Improve breadcrumb message matching

The test modified in this commit asserts eqaulity of  messages from breadcrumbs
and hard coded expected results. This could cause failures, as sometimes the
messages contain whitespace characters. This commit ensures the assertions only
check that the expected string is within the message string, ignoring extra
characters.
2023-08-18 11:16:42 -02:30
Mark Stacey
3e26da493f Initialize composable observable store after update (#20468)
* Initialize composable observable store after update

The composable observable store now updates state immediately when the
structure is updated. Previously each store would only be updated after
the first state change. This ensures that the composable observable
store state is always complete.

* SUpport falsy controller state

We now use the nullish coalescing operator when checkint store.state, so that we don't accidentally ignore falsy state.

Co-authored-by: Frederik Bolding <frederik.bolding@gmail.com>

* Add test for falsy controller state

* Update state snapshots

A change on `develop` required another state update.

---------

Co-authored-by: Frederik Bolding <frederik.bolding@gmail.com>
2023-08-18 11:16:17 -02:30
Dan J Miller
ca1ddeb59b
Fix and test log.info calls run for each migration (#20517)
* Fix and test log.info calls run for each migration

In migrator/index.js, log.info is called before an after each migration.
These calls are intended to produce breadcrumbs to be captured by sentry
in cases where errors happen during or shortly after migrations are run.
These calls were not causing any output to the console because the log.setLevel
calls in ui/index.js were setting a 'warn value in local storage that was being
used by logLevel in the background.

This commit fixes the problem by setting the `persist` param of setLevel to
false, so that the background no longer reads the ui's log level.

Tests are added to verify that these logs are captured in sentry breadcrumbs
when there is a migration error due to an invariant state.

* Improve breadcrumb message matching

The test modified in this commit asserts eqaulity of  messages from breadcrumbs
and hard coded expected results. This could cause failures, as sometimes the
messages contain whitespace characters. This commit ensures the assertions only
check that the expected string is within the message string, ignoring extra
characters.
2023-08-18 11:15:45 -02:30
Albert Olivé
60f149178c
[MMI] Set approved status in tx controller in MMI logic (#20507)
* fix(custodial-signing): set approved status in tx controller in MMI logic

* Fixed the issue that was not showing custody-confirm-link

---------

Co-authored-by: Shane Terence Odlum <shane.odlum@consensys.net>
2023-08-18 14:38:51 +02:00
Ariella Vu
8807d06535
Security Alert Blockaid: fix propType and add instance to ConfirmApprove page (#20494)
* fix: SecurityProviderBannerAlert propTypes

* feat: add ConfirmApprove BlockaidBannerAlert
2023-08-18 14:06:46 +02:00
Mark Stacey
1d13008121 Fix Sentry breadcrumbs collection during initialization (#20521)
* Fix Sentry MetaMetrics detection

The refactor of the Sentry state in #20491 accidentally broke our opt-
in detection. The opt-in detection has been updated to look for both
types of application state (during and after initialization).

* Continue suppressing breadcrumbs during onboarding

* Fix how onboarding status is retrieved

The check for whether the user had completed onboarding assumed that
the application state was post-initialization UI state. It has been
updated to handle background state and pre-initialization state as
well.

* Remove unnecessary optional chain operators

* Add missing optional chain operator

* Fix JSDoc description parameter type
2023-08-18 06:07:35 -02:30
Mark Stacey
65c13d3490
Fix Sentry breadcrumbs collection during initialization (#20521)
* Fix Sentry MetaMetrics detection

The refactor of the Sentry state in #20491 accidentally broke our opt-
in detection. The opt-in detection has been updated to look for both
types of application state (during and after initialization).

* Continue suppressing breadcrumbs during onboarding

* Fix how onboarding status is retrieved

The check for whether the user had completed onboarding assumed that
the application state was post-initialization UI state. It has been
updated to handle background state and pre-initialization state as
well.

* Remove unnecessary optional chain operators

* Add missing optional chain operator

* Fix JSDoc description parameter type
2023-08-18 05:47:23 -02:30
Mark Stacey
88212a7c82
Require test-deps-depcheck to pass CI (#20386)
The CI job `test-deps-depcheck` was optional, allowing PRs to be merged
that included dependency errors. It is now a required job, ensuring
that no such errors are introduced in the future.
2023-08-17 17:56:10 -02:30
Dan J Miller
01b009c9ad Run yarn dedupe to deal with unused ses dependency in yarn.lock, for v10.34.5 2023-08-17 14:55:15 -02:30
Mark Stacey
2cd60d94e8 Remove invalid tokensChainsCache state (#20495)
Migration #77 would set the `TokenListController.tokensChainsCache`
state to `undefined` if it wasn't already set to anything when that
migration was run. This is probably harmless except that it results
in Sentry errors during migrations, and it results in that property
having a value (at least temporarily) that doesn't match its type.

Migration #77 has been updated to prevent this property from being
set to `undefined` going forward. A new migration has been added to
delete this value for any users already affected by this problem. The
new migration was named "92.1" so that it could run after 92 but before
93, to make backporting this to v10.34.x easier (v10.34.x is currently
on migration 92). "92.1" is still a valid number so this should work
just as well as a whole number.
2023-08-17 14:23:54 -02:30
Mark Stacey
80746e67b5 Improve Sentry state pre-initialization (#20491)
* Improve Sentry state pre-initialization

Previously the masked state snapshot sent to Sentry would be blank for
errors that occured during initialization. Instead we'll now include
some basic information in all cases, and a masked copy of the persisted
state if it happens after the first time the persisted state is read.

* Add test

* Fix crash when persisted state not yet fetched

* Add descriptions for initial state hooks

* Update comments to reflect recent changes

* Re-order imports to follow conventions

* Move initial state hooks back to module-level

The initial state hooks are now setup at the top-level of their module.
This ensures that they're setup prior to later imports. Calling a
function to setup these hooks in the entrypoint module wouldn't
accomplish this even if it was run "before" the imports because ES6
imports always get hoisted to the top of the file.

The `localStore` instance wasn't available statically, so a new state
hook was introduced for retrieving the most recent retrieved persisted
state.

* Fix error e2e tests
2023-08-17 14:22:31 -02:30
Mark Stacey
6c50587878
Add flag to update E2E snapshots (#20514)
The E2E test scripts now have a flag for updating E2E test snapshots.
The flag has been documented as well. This makes it easier to update
snapshots and raises visbility of this feature.
2023-08-17 13:32:45 -02:30
Jyoti Puri
861c30de29
Updating blockaid related packages (#20480) 2023-08-17 20:50:07 +05:30
Mark Stacey
4cf886f710
Initialize composable observable store after update (#20468)
* Initialize composable observable store after update

The composable observable store now updates state immediately when the
structure is updated. Previously each store would only be updated after
the first state change. This ensures that the composable observable
store state is always complete.

* SUpport falsy controller state

We now use the nullish coalescing operator when checkint store.state, so that we don't accidentally ignore falsy state.

Co-authored-by: Frederik Bolding <frederik.bolding@gmail.com>

* Add test for falsy controller state

* Update state snapshots

A change on `develop` required another state update.

---------

Co-authored-by: Frederik Bolding <frederik.bolding@gmail.com>
2023-08-17 12:22:37 -02:30
Frederik Bolding
2529b360be
Track usage of snap exports (#20503)
* Track usage of snap exports

* Fix fencing

* Small change to event name

* Use MetaMetricsEventName
2023-08-17 16:13:40 +02:00
Frederik Bolding
8f178bcc26
Enable snaps in stable (#19134)
* Enable Snaps feature flag in stable

* Run snaps E2Es in stable

* Fix CI config indentation

* Fix CI paths

* Update LavaMoat policies

* Update iframe URL

* Exclude some tests from running in stable e2e

* Disable another test on stable

* Bump to 1.0.1

* Fix config.yml issue due to staleness

* Stop running newly added test

* Update snapshots used for E2E

* Use shallow-git-clone
2023-08-17 15:43:01 +02:00
Albert Olivé
5e617ce808
[MMI] Fix signed messages from non custodial accounts (#20506)
* Alter behaviour in MMI controller to use the original code path for signed messages that are from non custodial accounts

* Improved readability

* Removed unused import

---------

Co-authored-by: Shane Terence Odlum <shane.odlum@consensys.net>
2023-08-17 14:58:26 +02:00
Albert Olivé
486ade85f3
[MMI] Fixed connect mmi button several issues (#20455)
* fixed connect mmi button several issues

* Fixed snapshot

* Improved multiple things

* running yarn dedupe

* Update LavaMoat policies

* For some reason, this.mmiConfigurationController.store.mmiConfiguration?.portfolio sometimes is undefined, added [] if null.
Moved the || {} outside the find method

* minor improvements

---------

Co-authored-by: MetaMask Bot <metamaskbot@users.noreply.github.com>
2023-08-17 14:50:40 +02:00
Mark Stacey
20e16d41be
Improve Sentry state pre-initialization (#20491)
* Improve Sentry state pre-initialization

Previously the masked state snapshot sent to Sentry would be blank for
errors that occured during initialization. Instead we'll now include
some basic information in all cases, and a masked copy of the persisted
state if it happens after the first time the persisted state is read.

* Add test

* Fix crash when persisted state not yet fetched

* Add descriptions for initial state hooks

* Update comments to reflect recent changes

* Re-order imports to follow conventions

* Move initial state hooks back to module-level

The initial state hooks are now setup at the top-level of their module.
This ensures that they're setup prior to later imports. Calling a
function to setup these hooks in the entrypoint module wouldn't
accomplish this even if it was run "before" the imports because ES6
imports always get hoisted to the top of the file.

The `localStore` instance wasn't available statically, so a new state
hook was introduced for retrieving the most recent retrieved persisted
state.

* Fix error e2e tests
2023-08-17 09:29:05 -02:30
Mark Stacey
f033a59b17
Remove invalid tokensChainsCache state (#20495)
Migration #77 would set the `TokenListController.tokensChainsCache`
state to `undefined` if it wasn't already set to anything when that
migration was run. This is probably harmless except that it results
in Sentry errors during migrations, and it results in that property
having a value (at least temporarily) that doesn't match its type.

Migration #77 has been updated to prevent this property from being
set to `undefined` going forward. A new migration has been added to
delete this value for any users already affected by this problem. The
new migration was named "92.1" so that it could run after 92 but before
93, to make backporting this to v10.34.x easier (v10.34.x is currently
on migration 92). "92.1" is still a valid number so this should work
just as well as a whole number.
2023-08-17 09:04:30 -02:30
Mark Stacey
805ce29e11 Add types of hidden properties to Sentry data (#20457)
* Add types of hidden properties to Sentry data

The masked wallet state object sent to Sentry has been updated to
include the type of each property omitted from the mask. This lets us
at least see the full state shape, making it easier to see when errors
are caused by invalid state.

Relates to #20449

* Remove inconsistent state snapshot properties

The state snapshot tests have been updated to exclude properties that
were shown to differ between runs.
2023-08-17 09:01:25 -02:30
Mark Stacey
dc7ebe979e Add additional validation for persisted state metadata (#20462)
Additional validation has been added for persisted state metadata.
Beforehand we just checked that the state itself wasn't falsy. Now we
ensure that the metadata is an object with a valid version as well.
2023-08-17 09:01:25 -02:30
Dan J Miller
915bf2ae88 Capture exception with sentry when invariant conditions are met in migrations (#20427)
* capture exception for sentry when invariant conditions are met in migration 82

* Code cleanup

* Capture exceptions in invariant conditions for migrations 83,84,85,86,89,91,93,94

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

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

* Code cleanup

* Fix SentryObject type declaration

* Stop throwing error if preferences controller is undefined

* Refactor 084 and 086 to remove double negative

* Capture exceptions for invariant states in in migrations 87,88,90 and 92

* lint fix

* log warning in migration 82 when preferences controller is undefined

---------

Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2023-08-17 09:01:05 -02:30
OGPoyraz
6b72316eb6
Fix infinite rerender on network change while active signature request (#20473) 2023-08-17 09:36:30 +02:00
Michele Esposito
3aa5b7d362
Use importAccountWithStrategy from core KeyringController (#19815)
* refactor: use new importaccount from keyring controller

* Update LavaMoat policies

* Update LavaMoat policies

* Update LavaMoat policies

---------

Co-authored-by: MetaMask Bot <metamaskbot@users.noreply.github.com>
2023-08-17 09:11:51 +02:00
Mark Stacey
1ad47c660b Use unflattened state for Sentry (#20428)
The unflattened background state is now attached to any Sentry errors
from the background process. This provides a clearer picture of the
state of the wallet, and unblocks further improvements to Sentry state
which will come in later PRs.
2023-08-16 22:55:07 -02:30
Mark Stacey
d610aad2fd Split Sentry mask into UI and background masks (#20426)
The state mask used to anonymize the Sentry state snapshots has been
split into UI and background masks. This was done to simplify later
refactors. There should be no functional changes.
2023-08-16 22:54:59 -02:30
Mark Stacey
83c8a6be99 Update protobufjs (#20469)
Update `protobufjs` to the latest version. This resolves a security
advisory for this package. The advisory is concerning prototype
pollution, so it likely never affected us due to LavaMoat protections.
2023-08-16 22:54:15 -02:30
Frederik Bolding
e7b113caa2 Bump SES to fix audit failure (#20434)
* Bump SES to fix audit failure

* Freeze Symbol
2023-08-16 22:51:49 -02:30
Mark Stacey
1f508a30d9
Add types of hidden properties to Sentry data (#20457)
* Add types of hidden properties to Sentry data

The masked wallet state object sent to Sentry has been updated to
include the type of each property omitted from the mask. This lets us
at least see the full state shape, making it easier to see when errors
are caused by invalid state.

Relates to #20449

* Remove inconsistent state snapshot properties

The state snapshot tests have been updated to exclude properties that
were shown to differ between runs.
2023-08-16 21:11:17 -02:30
Mark Stacey
b2a56cadc4
Add additional validation for persisted state metadata (#20462)
Additional validation has been added for persisted state metadata.
Beforehand we just checked that the state itself wasn't falsy. Now we
ensure that the metadata is an object with a valid version as well.
2023-08-16 19:45:31 -02:30
Mark Stacey
3ab5c1bf88
Rename BackupController to Backup (#20465)
The backup module has been renamed so that it isn't confused with a
controller. The "backup controller" has never managed any state or
extended the controller base class. It is a module for backing up data,
but it's not a controller.

The backup controller's current inclusion in the `store` and `memstore`
`ComposableObservableStore`s was getting in the way of some other
enhancements to that class (which will come in a later PR).
2023-08-16 16:59:17 -02:30