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

3336 Commits

Author SHA1 Message Date
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
Filip Sekulic
3746ad9451
Add transaction security check toggle (#16271)
Co-authored-by: Brad Decker <bhdecker84@gmail.com>
2022-11-17 08:13:02 -06:00
David Walsh
4ce6487160
BETA - Add beta banner to all screens (#16307)
* Add beta home banner to home screen

* Move the beta home notification to the app-header

* Updates to formatting

* Add beta home banner to home screen

* Move the beta home notification to the app-header

* Updates to formatting

* Update ui/components/app/app-header/index.scss

Co-authored-by: George Marshall <george.marshall@consensys.net>

* Update ui/components/app/app-header/index.scss

Co-authored-by: George Marshall <george.marshall@consensys.net>

* Update ui/components/app/app-header/index.scss

Co-authored-by: George Marshall <george.marshall@consensys.net>

* Move banner to top of page

* Move to own folder, update styles

* Swith to BOX component

* Address feedback

* Add tests

* Update name of component

* Fix tests

* Fix proptype errors

* Fixups

* Remove unrelated changes

* Remove unwanted string changes

* Update beta component name and text

* Update mock data

Co-authored-by: George Marshall <george.marshall@consensys.net>
2022-11-16 11:41:15 -06:00
David Walsh
54429f531e
Remove unnecessary await (#16482) 2022-11-16 08:52:35 -06:00
Brad Decker
0688c3d9ad
persist user traits for comparison (#16506) 2022-11-16 08:17:55 -06:00
Dan J Miller
42b357456f
Configure smart transactions controller to support goerli (#16500) 2022-11-16 10:32:57 -03:30
Mark Stacey
4f66dc948f
Update @metamask/controllers to v33 (#16493)
The controllers package has been updated to v33. The only breaking
change in this release was to rename the term "collectible" to "NFT"
wherever it appeared in the API.

Changes in this PR have been kept minimal; additional renaming can be
done in separate PRs. This PR only updates the controller names,
controller state, controller methods, and any direct references to
these things. NFTs are still called "collectibles" in most places.
2022-11-15 15:19:42 -03:30
Ariella Vu
a87c1750b0
MV3: Update service worker restart logic and keep-alive logic for dapp support (#16075)
* dapp: add debug statements

* dapp: add retry logic [debug]

* dapp: keep SW alive on rpc request

* Revert "dapp: add debug statements"

This reverts commit ea21786f7f66c712eea02405cd68fe925d227ffa.

* dapp: try to set up ext streams asap on reset

* dapp: apply keep alive logic to phishingPageStream

* dapp:put keep-alive logic behind isManifestV3 flag

* Re-activate streams after a period of service worker in-activity

* dapp: rm extra function

* dapp: update phishing onDisconnect

* dapp: fix eslint missing global chrome

* add EXTENSION_MESSAGES const

* use EXTENSION_MESSAGES more generic comment

* update comment

* dapp: clean timeout and interval

* Fix DAPP action replay

* execute DAPP action replay for only MV3

* fix

* fix

* fix

* comment out DAPP action replay code

* fix

* fix

* fix

* scripts/background: use browser polyfill

* Revert "scripts/background: use browser polyfill"

This reverts commit 2ab6234d11b3b11e10dd993d454eeaad63bfc886.

* scripts/background: use browser polyfill

* script/background: check lastError

* dapp: use EXTENSION_MESSAGES

* scripts/background: send ready msg to all tabs

* dapp: update onMessage handler comment and name

* dapp: return values onMessage listener
see: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/runtime/onMessage#addlistener_syntax

* dapp: mv onMessage listener

* dapp: add onMessage setupPhishingExtStreams

* dapp: rn reset -> destroy streams

* dapp: rn reset -> destroy for phishing streams

* dapp: clean comment

* dapp: rm unused comments
planning to be readded in follow-up PR: #16250

* dapp: onMessage return Promise|undefined

* dapp:clean: add missing undefined return type

* dapp: use new checkForErrorAndLog for Chrome API
handy stackoverflow: https://stackoverflow.com/a/28432087/4053142

* dapp:fix: return tabs.query result

* dapp:eslint: return undefined
fix Expected to return a value at the end of arrow
function.eslintconsistent-return

* background: do not query tabs w/out url

* background: rm Could not establish... catch
- no longer needed after improved tabs query

* dapp:clean: rm unused checkForError... for now...

* dapp: prevent setupExtensionStreams called twice
- calling connect will trigger disconnect and may cause issues
- only setup streams if they are not connected

* dapp: handle onDisconnect lastError
- throwing errors from contentscript will break the dapp, so only warn
- not handling lastError when it's found will also break the dapp

* background: update tabs.query url comment

* background: update tabs.query url comment 2

* dapp: fix SW restart for multi dapp support
- ref: https://stackoverflow.com/a/54686484/4053142

* dapp:clean: rm extra "." from console.warn

* clean: comments for dapp and background

* Adding catch block (#16454)

* fix: FireFox provider injection

* lib/util: fix invalid checkForErrorAndWarn export

* bg: add explanation for tabs.sendMessage catch

* dapp: add browser-runtime.utils

* runtime.utils: add checkForLastErrorAndLog

Co-authored-by: Jyoti Puri <jyotipuri@gmail.com>
Co-authored-by: legobeat <109787230+legobeat@users.noreply.github.com>
2022-11-15 00:18:08 +07:00
Dan J Miller
5a28a7bd6d
Call onbootcleanup at the end of the tx controller constructor (#16449)
* Call onbootcleanup at the end of the tx controller constructor

* Update app/scripts/controllers/transactions/index.js

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

Co-authored-by: Frederik Bolding <frederik.bolding@gmail.com>
2022-11-10 09:58:27 -03:30
Peter Yinusa
6cca9892b2
refactor sentryHooks object (#16435) 2022-11-09 19:28:32 +00:00
David Drazic
5e746dcc2f
[FLASK] Add snap cronjobs (#16239)
* Add Cronjob controller configuration

* Add Cronjob permission icon and description

* Add lint fix changes

* Add missing action to the allow-list

* Fix permission

* Fix icon and message

Co-authored-by: Frederik Bolding <frederik.bolding@gmail.com>
2022-11-09 13:18:47 +01:00
Olusegun Akintayo
aba3b94c1a
Fix orphaned data warning (#16413) 2022-11-08 16:38:48 -06:00
Jyoti Puri
6c0930899d
Make event tracking idempotent using unique messageId (#16267) 2022-11-08 23:38:08 +05:30
Filip Sekulic
f3efe5a0bd
Add improved token allowance experience toggle (#16291) 2022-11-08 11:21:38 -06:00
Frederik Bolding
de3068d932
[FLASK] snaps-monorepo@0.23.0 (#16394)
* snaps-monorepo@0.23.0

* Regen LavaMoat policies

* Update iframe-execution-environment

* Fix tests

* Bump luxon

* Fix lint

* Update test-snaps

* Bump post-message-stream

* Fix E2E
2022-11-08 10:31:22 +01:00
Jyoti Puri
e7deab4b9b
Persisting segment events in MetaMetricsController store (#16198) 2022-11-08 04:33:03 +05:30
Jyoti Puri
83ec64ddd2
Fix approve transaction call in _onBootCleanUp (#16382) 2022-11-04 23:17:53 +05:30
dragana8
02b34dcd4a
[Bug]: Balance does not update on duplicate chainId network #13690 (#14245) 2022-11-04 11:29:45 -05:00
Niranjana Binoy
39037684d4
Fix: To differentiate between which chrome alarm is triggered (#16360) 2022-11-04 11:23:56 -04:00
Olusegun Akintayo
107525bb1d
Show error message if service worker did not load (respond to the UI) (#15774)
* Show error message if service worker did not load (respond to the UI)
after 1 minute.

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

* Remove console.log

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

* New Error message design

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

* Fix tests

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

* Use lastTimeStamp instead of keeping track of message ids

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

* Do not initial channe every second.

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

* New logic to check if SW is stuck

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

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>
2022-11-03 21:25:13 +04:00
Alex Donesky
aa59f7f89c
ensure that we default users with browser language code 'zh' to the supported 'zh_CN' language code (#16329) 2022-10-31 16:48:51 -05:00
Mark Stacey
25fae8d32e
Increase provider rate limited to 5 minutes (#16308)
The metric event for provider methods has been increased from 1 minute
to 5 minutes. This will reduce the event rate, ensuring a maximum of
one event is tracked for each method call every five minutes.
2022-10-31 15:24:01 -02:30
Erik Marks
a8c1756816
Remove 3box feature and delete ThreeBoxController (#14571)
* Remove 3box feature and delete ThreeBoxController

Lint locale messages

lavamoat policy updates

* Restore 3Box user trait with value `false`

The 3Box user trait has been restored and hard-coded as `false`. This
ensures that users don't get stuck in our metrics as having this trait.

A deprecation comment has been left in various places for this trait.

* Remove unused state

* Remove additional 3box-related things

* Run `yarn-deduplicate`

* Restore migration that was lost while rebasing

* Remove obsolete override

* Remove additional unused resolutions/dependencies

* Update LavaMoat policies

* Remove obsolete security advisory ignore entries

* Remove 3Box fixture builder method

* Update unit tests

Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2022-10-31 13:50:50 -02:30
Jyoti Puri
17af3bb11e
Making permission and approval controller methods idempotent (#15848) 2022-10-31 11:22:31 +05:30
ryanml
6c84e9604c
Enable "Add Popular Network" feature by default for all users (#16172)
* Enable "Add Popular Network" feature by default

* Fixing e2e tests

* Attempt to fix e2e tests

* Revert "Attempt to fix e2e tests"

This reverts commit d88e8944b8df8f7c3075753f8d8b3480439f8e30.

* Get e2e tests passing

Co-authored-by: Dan J Miller <danjm.com@gmail.com>
2022-10-27 07:55:30 -02:30
Jyoti Puri
68642ee47a
Updating controller dependency (#16033)
* Updating controller dependency

* fix

* fix

* fix

* fix

* fixes

* Lavamoat auto

* Update URLs for phishing detection testcase

* update lavamoat files

* call phishingController.test synchronously again

* bump @metamask/controllers to v32.0.1

* lint

* update policy files

* bump controllers version again

* modify update phishing list strategy

* revert back to use isOutOfDate, but without blocking substream

* possible way to fix e2e tests?

* enable testing

* Remove promise return from setupController in background.js, as it is no longer used

* Ensure updatePhishingLists is called in MM contrller constructer, so that phishing lists are updated right away

Co-authored-by: seaona <mariona@gmx.es>
Co-authored-by: Alex <adonesky@gmail.com>
Co-authored-by: Dan Miller <danjm.com@gmail.com>
2022-10-25 02:24:02 -02:30
Frederik Bolding
863cda6c88
[FLASK] Clear snap state on restore (#16228)
* Clear snap state on restore

* Fix lint
2022-10-24 14:08:08 +02:00
Frederik Bolding
d640c9a924
[FLASK] snaps-monorepo@0.22.2 (#16161)
* snaps-monorepo@0.22.2

* Update LavaMoat policies

* Fix eth_accounts permission for Snaps

* Update iframe execution environment

* Dedupe yarn.lock and rerun LavaMoat policy gen

* Add policy override for nanoid
2022-10-11 18:56:34 +02:00
Jyoti Puri
6995174cbc
MV3 Segment Fix (#16020) 2022-10-11 20:34:32 +05:30
Niranjana Binoy
d4c39006a2
Data from TokenListController gets cleared when the service worker restarts (#16109) 2022-10-11 10:21:31 -04:00
Alex Donesky
20986e17b7
Persist state in metaRPCHandler so that we are sure state is persisted before sending back response to actions (#15978)
* persist state in metaRPCHandler so that we are sure state is persisted before sending back response to actions
2022-10-10 17:10:44 -05:00
Mark Stacey
f6f8edfd15
Update eth-json-rpc-middleware to v9.0.1 (#16096)
This update includes fixes for our `block-ref` and `retry-on-empty`
middleware.

The `block-ref` middleware resolves the block reference `latest` to a
specific block number, the latest one we are aware of. This is meant to
protect against situations where the network gives inconsistent answers
for what the latest block number is due to some nodes being out-of-sync
with each other (this was a frequent problem years ago with Infura).

It was broken in that the `latest` resolution was failing, and we were
submitting an additional redundant request to Infura for each request.

The `retry-on-empty` middleware is meant to retry certain methods
when they return an empty response. This was also meant to deal with
network synchronization issues that were more common years ago. This
middleware works by making a "child" request over and over until either
a retry limit is reached, or a non-empty response is received.

It was broken in that the final response recieved was thrown away, so
it's as though the middleware was not used. Except that it did result
in additional redundant network requests.

As a result of this update we should see that the extension is more
resilient to certain network synchronization issues. But this is
difficult to test, and these issues may not happen in production
anymore today.

We should see a reduction in requests to Infura as well. This should
be easier to test.
2022-10-10 13:16:58 -02:30
Frederik Bolding
7604009405
[FLASK] Fix wrong action name for wallet_getSnaps hook (#16125) 2022-10-07 20:35:53 +02:00
Frederik Bolding
7ba0f78a84
[FLASK] snaps-skunkworks@0.22.0 (#16069)
* snaps-skunkworks@0.22.0

* Update LavaMoat policies

* Bump execution environment and fix a breaking change

* Fix caveat and permissions

* Fix test

* Exclude keyring endowment for now

* Fix test

* Fix snap_confirm missing title
2022-10-07 10:02:35 +02:00
Jyoti Puri
3271b812e3
Removing use of window object from sentry code (#16022) 2022-10-05 22:47:58 +05:30
Niranjana Binoy
29c2b136b8
Replace setInterval with chrome alarms for MetaMetrics FinalizeEventFragment (#16003) 2022-10-04 13:03:50 -04:00
Alex Donesky
fc38f11580
ensure phishing-detection page preload works in MV3 (#16029)
* ensure phishing-detection page preload works in MV3

* remove stored flag for FireFox in MV3 solution
2022-10-04 10:14:46 -05:00
Elliot Winkler
d7a812f42f
Add remaining tests for createInfuraClient (#15717)
Add tests for the `block-tracker-inspector` middleware — which makes
sure that the block tracker never has a reference to the latest block
which is less than a block number that shows up in an RPC method's
response — and the Infura middleware — which takes care of sending the
request to Infura, and will retry the request up to 5 times if Infura
sends back a certain type of error.

Note that the `retry-on-empty` middleware is not tested because it
currently has a [bug][1] which is making it ineffective.

[1]: https://github.com/MetaMask/eth-json-rpc-middleware/issues/139
2022-09-29 10:39:35 -06:00
Olusegun Akintayo
7b94ac5eca
Fix 3box replacement for MV3 (#15851)
* refactor backup controller to return the data to be backed up
    and do the actual backup in the UI.

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

* Move export-utils to ui/helpers as it's only used in the UI now.

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

* use context to call event tracker.

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

* Don't make backup function inline.

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

Signed-off-by: Akintayo A. Olusegun <akintayo.segun@gmail.com>
2022-09-29 07:34:20 +04:00
ryanml
0bc1eeaf37
Deprecating the Rinkeby, Ropsten, and Kovan test networks (#15989)
* Deprecating Rinkeby, setting default debug network to Goerli

* Deprecating Ropsten and Kovan

* Conflict fix

* Remove unused localization, test fixes

* Add migration for moving used deprecated testnets to custom networks

* Fix migrator test

* Add more unit tests

* Migration updates provider type to rpc if deprecated network is selected

* Migration fully and correctly updates the provider if selected network is a deprecated testnet

* Continue to show deprecation warning on each of rinkeby, ropsten and kovan

* Add rpcUrl deprecation message to loading screen

* Removing mayBeFauceting prop

Co-authored-by: Dan Miller <danjm.com@gmail.com>
2022-09-28 20:26:01 -07:00
Nicolas Ferro
18ca016cf0
Ability to buy tokens with Wyre (#15992) 2022-09-28 09:41:56 -05:00
Dan J Miller
9e865970ed
Simplfy _buildEventFragmentProperties so that necessary objects and data are defined when it is called during onBootCleanup (#16001) 2022-09-28 09:08:22 -02:30