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

3377 Commits

Author SHA1 Message Date
Guillaume Roux
3cfef11f71
[FLASK] Resolve snap_dialog approval on close (#16801) 2022-12-21 20:15:52 +01:00
weizman
5d320ceec6
Integrate new LavaMoat scuttling protection feature (#16994)
Co-authored-by: kumavis <kumavis@users.noreply.github.com>
Co-authored-by: kumavis <aaron@kumavis.me>
Co-authored-by: Brad Decker <bhdecker84@gmail.com>
2022-12-21 12:54:30 -06:00
Zachary Belford
6f6984fa58
Moved subscribe and filter into network controller (#16693)
Our middleware for handling subscription and filter-related methods (`eth-json-rpc-filters`) currently lives in our RPC pipeline ahead of the network stack. This commit moves this middleware to the network client middleware instead. There are two reasons for this change. First, this middleware wraps RPC methods that are supported by the network. Second, it is necessary for this middleware to live with the network client so that it will aid us in unifying the NetworkController in this repo and the NetworkController in the `controllers` repo.

Co-authored-by: Elliot Winkler <elliot.winkler@gmail.com>
2022-12-20 10:28:09 -07:00
Jyoti Puri
c61d44a3be
Making add un-approved transaction idempotent (#16995) 2022-12-20 18:01:37 +05:30
Guillaume Roux
85f260c22d
[FLASK] Use custom UI for dialogs (#16973)
* update dialog templates to use custom UI

* add TODO comments

* Fix showDialog hook and destructuring

* Regen LavaMoat policies

* Re-add legacy snap confirmation for now

* Fix circular dependency issue

* Revert change to token-util

* Fix lint

Co-authored-by: Frederik Bolding <frederik.bolding@gmail.com>
2022-12-20 11:44:22 +01:00
Frederik Bolding
abe0204171
[FLASK] snaps-monorepo@0.27.1 (#16981)
* snaps-monorepo@0.27.0

* Regen LavaMoat policies

* Remove unused constructor arg

* snaps-monorepo@0.27.1
2022-12-20 11:44:05 +01:00
Olusegun Akintayo
13de51e748
Security and Privacy Settings Re-org (#16756) 2022-12-19 18:46:36 +01:00
Mark Stacey
3e98758719
Rename the network controller module (#16974)
The network controller module has been renamed from `network.js` to
`network-controller.js`. All of our newer controllers have "controller"
in the module names, so this aligns better with that convention. It
also brings the test module name into alignment (it's already called
"network-controller.test.js").
2022-12-16 16:37:06 -03:30
Mark Stacey
dbe77289d3
Make initializeProvider and lookupNetwork async (#16881)
* Make `initializeProvider` and `lookupNetwork` async

These two methods were "synchronous" previously, but initiated an
asynchronous operation. They have both been made `async` to bring them
more in-line with the mobile controller API, and to make them easier
to test.

This should include zero functional changes. These methods are still
being invoked without an `await`, to preserve the same behaviour they
had previously.

This relates to https://github.com/MetaMask/controllers/issues/971

* Move 'net_version' query to private function

* Fix error made when resolving conflicts

* Refactor to improve readability
2022-12-16 13:03:22 -03:30
Dan J Miller
ba3914e9fe
Sanitize privacy sensitive data before sending to sentry. (#16780)
* Sanitize privacy sensitive data before sending to sentry.

Temp

Near complete

Complete

* Temp

* Fix url error message rewrite

* Add unit tests and cleanup code

* Improvements

* Update app/scripts/lib/setupSentry.js

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

* Update app/scripts/lib/setupSentry.js

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

* Update app/scripts/lib/setupSentry.js

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

* Fix syntax of doc comments

* Catch errors caused by invalid urls in sanitizeUrlsFromErrorMessages

* Ensure our allowlist matches multiple subdomains

* Ensure sanitizeUrlsFromErrorMessages correctly matches hostnames

* Update app/scripts/lib/setupSentry.js

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

* Improve test descriptions

* fix

Co-authored-by: Ariella Vu <20778143+digiwand@users.noreply.github.com>
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2022-12-16 11:56:23 -03:30
Frederik Bolding
0511d6f0b1
[FLASK] Bump snaps iframe-execution-environment (#16932) 2022-12-14 11:48:50 +01:00
Alex Donesky
5d285f7be5
fix cached detected token results (#16866) 2022-12-14 12:26:08 +05:30
Brad Decker
e83111cc7e
Nock some endpoints to improve test perf (#16940) 2022-12-13 14:20:24 -06:00
Elliot Winkler
dd59792392
Remove if to expose more network client tests (#16906)
This commit affects the network client tests, which were added in a
previous PR to test the behavior of `createInfuraClient`, a function
called that sets up a portion of the middleware stack in the JSON-RPC
layer.

An `if` statement appears in the tests which limits the execution of
certain tests. However, this seems to have been added for debugging
purposes and is not actually needed.

Co-authored-by: Brad Decker <bhdecker84@gmail.com>
2022-12-13 12:49:58 -07:00
Mark Stacey
69e5d6da4a
Make certain network controller methods private (#16883)
Five network controller methods have been renamed to start with an
underscore:
* `getLatestBlock`
* `setNetworkState`
* `setNetworkEIPSupport`
* `clearNetworkDetails`
* `setProviderConfig`

All of these methods were used solely within the network controller.
The leading underscore now documents these methods as being private.

A few tests required updates as well because they were stubbing out one
of these methods.

This should include zero functional changes.

This relates to https://github.com/MetaMask/controllers/issues/971
2022-12-13 15:43:54 -03:30
Mark Stacey
06d87fb98b
Refactor how network state is passed to transaction controller (#16922)
The network state is now passed to the TransactionController via a
getter function and a subscription function, instead of passing one of
the network controller stores directly.

This way of passing the state makes further refactoring easier, as we
don't have to change the input when the store is changed or replaced.
It's also more aligned with our conventions today.

This change was made as part of a larger refactor of the network
controller, as part of the effort to merge the mobile and extension
network controllers.
2022-12-13 15:43:12 -03:30
Ariella Vu
be6edb4bc8
scripts/ui: add tabs.query promise error handler (#16915) 2022-12-14 01:21:32 +07:00
Mark Stacey
75177c5998
Make setProviderType synchronous (#16879)
The network controller method `setProviderType` was marked as `async`
despite doing nothing async internally. The `async` has been dropped.

This should have zero functional impact.

This relates to https://github.com/MetaMask/controllers/issues/971
2022-12-13 13:57:48 -03:30
Mark Stacey
5df6f653af
Remove unused verifyNetwork method (#16882)
The network controller method `verifyNetwork` has been deleted. It was
unused.

This relates to https://github.com/MetaMask/controllers/issues/971
2022-12-13 13:57:28 -03:30
Mark Stacey
6d64951938
Move infuraProjectId to network controller constructor (#16884)
The network controller `setInfuraProjectId` method has been deleted.
The Infura project ID is only ever set upon construction, so it is now
passed in as a constructor parameter instead.

Rather than adding this as a second parameter, the network controller
now uses an "options bag" for constructor parameters. The initial state
was the first parameter, but it's now passed in as the `state` option
instead.

These changes make the API more similar to the mobile network
controller API.

This should have zero functional changes.

This relates to https://github.com/MetaMask/controllers/issues/971

Co-authored-by: legobeat <109787230+legobeat@users.noreply.github.com>
2022-12-13 12:09:21 -03:30
Mark Stacey
048b7e4cb6
Fix shared mocks in RPC network client test (#16856)
* Fix shared mocks in RPC network client test

Some of the provider api unit tests were inadvertently sharing test
mocks. A `params` object used for mock RPC calls was being shared
between tests and between calls within individual tests. They have been
updated to generate a fresh `params` object for each mock RPC call.

* Explicitly set blockParam to undefined
2022-12-12 13:49:22 -03:30
Ariella Vu
4d4e487ffc
Handle extension unloaded and reloaded error: "Extension context invalidated" during dapp use for chromium browsers (#16306)
* dapp: handle ext unloaded or reloaded error

* dapp: handle ext unloaded or reloaded error pt. 2
- use const
- mention case is unsupported in Firefox

Co-authored-by: legobeat <109787230+legobeat@users.noreply.github.com>
2022-12-12 19:24:12 +07:00
Jyoti Puri
8125473dc5
Removing flag for EIP1559 V2 support (#16446) 2022-12-09 00:07:06 +05:30
David Walsh
7d3b1d08da
NFTs: Update COLLECTIBLES_V1 to NFTS_V1 (#16851) 2022-12-08 11:37:47 -06:00
David Walsh
ead5076b86
Privacy - Update metametrics copy during onboarding (#16825) 2022-12-07 12:56:57 -06:00
Brad Decker
f7014a79fc
remove network name from analytics (#16781) 2022-12-03 09:57:48 -06:00
Alex Donesky
f162c58f5a
Allow adding networks with the same chainId as a preloaded/default network via wallet_AddEthereumChain API (#16733)
* allow adding networks with the same chainId as an existing network via API

Co-authored-by: Kurush Dubash <kurush@alchemyapi.io>
2022-12-02 21:14:27 -06:00
Jyoti Puri
154172d5f8
Network request in background should not start until onboarding is completed (#16773) 2022-12-02 23:29:03 +05:30
Jyoti Puri
a5e70cbd71
Adding middleware to filter out duplicate requests from DAPP (#16730) 2022-12-02 21:08:12 +05:30
Pedro Figueiredo
d096560d85
Give the user ability to opt out of get balance batch request for all loaded accounts (#16746) 2022-12-01 21:16:04 +00:00
Erik Marks
a861cc6dae
[FLASK] Add snap alerts and prompts via snap_dialog RPC method (#16048)
Co-authored-by: Guillaume Roux <guillaumeroux123@gmail.com>
Co-authored-by: Frederik Bolding <frederik.bolding@gmail.com>
2022-12-01 16:46:06 +01:00
Dan J Miller
91e275e0d1
Use NETWORK_EVENTS.NETWORK_DID_CHANGE to trigger network change callback in assetsContractController (#16760) 2022-12-01 11:03:38 -03:30
Brad Decker
b3895b6840
remove rpc urls from metrics (#16710) 2022-11-30 09:52:25 -06:00
Frederik Bolding
dfb6210910
[FLASK] snaps-monorepo@0.25.0 (#16673)
* snaps-monorepo@0.25.0

* Regen LavaMoat policies

* Bump test-snaps

* [FLASK] Add Snaps JSON-RPC handler permission (#16670)

* Add Snaps JSON-RPC handler permission

* Add copy and icon

* Fix test

Co-authored-by: Maarten Zuidhoorn <maarten@zuidhoorn.com>
2022-11-30 13:19:33 +01:00
Jyoti Puri
ba25ad4073
Not use hardware keyring classes when initializing KeyringController in extension MV3 version (#16684) 2022-11-29 22:34:11 +05:30
Jyoti Puri
ea882d4588
DAPP action replay improvements (#16250) 2022-11-29 22:33:13 +05:30
Brad Decker
6c6b4aca1e
fix issue preventing switching to localhost (#16707) 2022-11-29 10:01:23 -06:00
Elliot Winkler
51cffa15dd
Migrate to new controller packages (#16547)
* Migrate to new controller packages

`@metamask/controllers` is deprecated, and most of the controllers that
lived here are now located in their own package ([1]). This commit
replaces `@metamask/controllers` in `package.json` with references to
these packages and updates `import` lines to match.

[1]: https://github.com/MetaMask/controllers/pull/831

* Support GitHub registry for draft PRs (#16549)

* Add additional allowed host to lockfile linter

* Update LavaMoat policies

* Add policy exception for nanoid

* Add additional nanoid overrides

* Update LavaMoat policies again

* Bump controller packages

* Update lavamoat

* Bump controller packages

* Update packages to v1.0.0

* Expand gitignore comment

* Unpin controller dependencies, using ^ range instead

Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2022-11-24 16:29:07 -03:30
Mark Stacey
943453cfb2
Simplify MV3 initialization (#16559)
* Simplify MV3 initialization

The MV3 initialization logic was complicated and introduced race
difficult-to-reproduce race conditions when dapps connect during
initialization.

It seems that problems were encountered after the UI tried to connect
before the background was initialized. To address this, the
initialization step was _delayed_ until after the first connection.
That first connection was then passed into the initialization function,
and setup properly after initialization had begun.

However, this special treatment is only given for the first connection.
Subsequent connections that still occur during initialization would
fail. This also results in the initialization being needlessly delayed,
which is concerning given that our main performance goal is to speed it
up.

* Setup connect listeners before controller initialization

* Add comments

* Add comment explaining isInitialized step
2022-11-24 10:02:05 -03:30
David Walsh
266d7d93d5
Fix #15050 - MV3: Keep the user logged in when service worker restarts (#15558) 2022-11-23 18:49:24 -06:00
weizman
42b8971571
Integrating snow into metamask (#15580) 2022-11-24 02:36:19 +02:00
Jyoti Puri
82dc628fa3
Remove callback from being saved in controller state (#16627) 2022-11-23 23:30:05 +05:30
Olusegun Akintayo
086a7d0483
Keep memstore contents after service worker restarts (#15913)
* Add all controllers in memstore to store
Add methods to controller to reset memstore
Reset memstore when popup or tab is closed.

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

* When profile is loaded, set isFirstTime to true..
After resetting the controllers, set the flag to false.

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

* Remove console.logs

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

* For some reason programmatically computing the store is not working.

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

* Proper check for browser.storage

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

* do a list of rest methods instead of reset controllers.

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

* Mock controller resetStates and localstore get/set

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

* Comments about TLC

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

* bind this.

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

* use globalThis instead of locastore to store first time state.

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

* Test to check that resetStates is not called a second time

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

* Set init state in GasFeeController and other controllers so that their
state is persisted accross SW restarts

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

* Revert localstore changes

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

* wrap the reset states changes in MV3 flag

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

* Remove localstore from metamask-controller

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

* Always reset state on MMController start in MV2.

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

* Use relative path for import of isManifestV3

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

* Fix unit test

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

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>
2022-11-22 20:56:26 +04:00
Frederik Bolding
ee543598d3
[FLASK] Clear notification state on restore (#16503) 2022-11-22 13:32:15 +01:00
Frederik Bolding
de955f3faa
[FLASK] snaps-monorepo@0.24.1 (#16525)
* snaps-monorepo@0.24.0

* Fix imports and regen LavaMoat policies

* Bump iframe-execution-environment

* Fix tests

* Add permissions

* Bump patch

* Bump test-snaps

* [FLASK] Fix update e2e test to catch snaps with caveats (#16546)

* changed snap to update to bip32

* small changes to test

* Fix lint

* Fix E2E

* Update copy

* Update icon

Co-authored-by: Bowen Sanders <bowensanders@gmail.com>
2022-11-22 13:07:08 +01:00
David Walsh
b675a12dbf
Use async/await for extension functions (#15722) 2022-11-21 08:51:11 -06:00
David Walsh
9530797a7a
Create constants for all keyring types (#16575) 2022-11-21 08:23:35 -06:00
Niranjana Binoy
8f18e04b97
Updating tokensChainsCache[chainId].data to object from array in user state (#16535) 2022-11-18 13:35:42 -05:00
Ariella Vu
e01b067d0c
Minor scripts/ui.js file cleanup (#16566)
* clean:ui: mv comments

* clean:ui: fix typo recieved -> received

* clean:ui: rn handle -> keepAliveInterval

* clean:ui: rn timeoutHandle -> ackTimeoutToDisplayError

* clean: replace "Xs" w/ variable name

* clean:ui: rm duplicate comment

* add EXTENSION_MESSAGES.CONNECTION_READY const

* clean:ui: bit more clean up
2022-11-18 20:57:01 +07:00
Ariella Vu
2966b9f665
MV3: support Service Worker restart for phishing warning pages (#16488)
* dapp: fix phishing Could not establish connection

* dapp: only call phishing keep alive timer on load

Co-authored-by: Jyoti Puri <jyotipuri@gmail.com>

Co-authored-by: Jyoti Puri <jyotipuri@gmail.com>
2022-11-17 22:22:52 +07:00