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

180 Commits

Author SHA1 Message Date
Elliot Winkler
1304ec7af5
Convert shared/constants/metametrics to TS (#18353)
We want to convert NetworkController to TypeScript in order to be able
to compare differences in the controller between in this repo and the
core repo. To do this, however, we need to convert the dependencies of
the controller to TypeScript.

As a part of this effort, this commit converts
`shared/constants/metametrics` to TypeScript. Note that simple objects
have been largely replaced with enums. There are some cases where I even
split up some of these objects into multiple enums.

Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2023-04-03 09:31:04 -06:00
Pedro Figueiredo
fbd68d4a3f
Introduce action metrics for mv3 service worker restart (#18346)
* fix dapp interaction e2e test

* wip

* add sentry post request mock

* fix console errors

* fix scripting console error and remove e2e test unnecessary check

* clean up

* remove e2e test

* stop skipping  test

* fixing build mv3 job

* fixing unit tests

* fixing unit tests

* fixing unit tests

* update coverages

* revert skip mv3 e2e test

* remove IN_TEST on the npm script

* remove console.log

* revert aria label changes

* revert aria label changes

* revert permission changes

* revert permission changes

* implement sw restart delay tracking

* fix rebase
2023-03-31 14:22:33 +01:00
Elliot Winkler
ed3cc404f2
NetworkController: Split network into networkId and networkStatus (#17556)
The `network` store of the network controller crams two types of data
into one place. It roughly tracks whether we have enough information to
make requests to the network and whether the network is capable of
receiving requests, but it also stores the ID of the network (as
obtained via `net_version`).

Generally we shouldn't be using the network ID for anything, as it has
been completely replaced by chain ID, which all custom RPC endpoints
have been required to support for over a year now. However, as the
network ID is used in various places within the extension codebase,
removing it entirely would be a non-trivial effort. So, minimally, this
commit splits `network` into two stores: `networkId` and
`networkStatus`. But it also expands the concept of network status.

Previously, the network was in one of two states: "loading" and
"not-loading". But now it can be in one of four states:

- `available`: The network is able to receive and respond to requests.
- `unavailable`: The network is not able to receive and respond to
  requests for unknown reasons.
- `blocked`: The network is actively blocking requests based on the
  user's geolocation. (This is specific to Infura.)
- `unknown`: We don't know whether the network can receive and respond
  to requests, either because we haven't checked or we tried to check
  and were unsuccessful.

This commit also changes how the network status is determined —
specifically, how many requests are used to determine that status, when
they occur, and whether they are awaited. Previously, the network
controller would make 2 to 3 requests during the course of running
`lookupNetwork`.

* First, if it was an Infura network, it would make a request for
  `eth_blockNumber` to determine whether Infura was blocking requests or
  not, then emit an appropriate event. This operation was not awaited.
* Then, regardless of the network, it would fetch the network ID via
  `net_version`. This operation was awaited.
* Finally, regardless of the network, it would fetch the latest block
  via `eth_getBlockByNumber`, then use the result to determine whether
  the network supported EIP-1559. This operation was awaited.

Now:

* One fewer request is made, specifically `eth_blockNumber`, as we don't
  need to make an extra request to determine whether Infura is blocking
  requests; we can reuse `eth_getBlockByNumber`;
* All requests are awaited, which makes `lookupNetwork` run fully
  in-band instead of partially out-of-band; and
* Both requests for `net_version` and `eth_getBlockByNumber` are
  performed in parallel to make `lookupNetwork` run slightly faster.
2023-03-30 16:49:12 -06:00
vthomas13
16fa967740
Revert "What's new - OpenSea security provider (#16831)" (#17968)
This reverts commit 932282e638.
2023-03-22 12:51:37 -04:00
Matthew Walsh
bf29922488
Use core message managers and create sign controller (#18163) 2023-03-20 13:19:50 +00:00
Guillaume Roux
d6f58bceb0
[FLASK] snaps-monorepo@0.31.0 (#18142)
* allow SnapController to call `ApprovalController:updateRequestState` action

* combine popups

* show only autorship pill on result

* lint

* update `snaps-monorepo@0.31.0` and regen policies

* dedupe deps and fix fencing

* fix update button text

* fix fencing

* Update a bunch of e2es

* address requested changes

* update policy

* bump key-tree

* fix lint

* Update RPC E2E

* fix locales

* Remove wrong instance of window handle polling

* design changes and address pr comments

* remove unused imports

* fix lint

* fix fencing

* remove unused locales

* fence things

* re-add redirection

* bump test-snaps version

* Fix update e2e

* fix redirecting logic and address requested changes

* force update metamask state on approved

* move force update

---------

Co-authored-by: Frederik Bolding <frederik.bolding@gmail.com>
2023-03-17 12:00:05 +01:00
Thomas Huang
eafffb1af5
Remove console.log of expected action from actions test (#18130) 2023-03-14 06:09:16 -05:00
António Regadas
c022d2eb9a
[MMI] Move mmi actions to extension (#18057)
* MMI adds actions and background files to the institution/ folder

* MMI lint fix

* MMI lint fix

* MMI import path fixed to be relative

* MMI import path fixed

* MMI adds the relative path to isErrorWithMessage

* MMI adds the tests for mmi actions

* MMI lint fix

* adds tests to mmi actions

* prettier fix

* MMI prettier and adds test

* MMI prettier

* MMI lint fix

* MMI prettier fix

* MMI rename folder
2023-03-14 10:57:05 +00:00
Alex Donesky
23ca4460cf
Migrate network configurations (previously frequentRpcListDetail) from PreferencesController to NetworkController (#17421) 2023-03-09 15:00:28 -06:00
Hassan Malik
7086494b72
[FLASK] BREAKING - snaps-monorepo@0.30.0 (#17718)
* updated snap permission to wallet_snap, updated tests and added migration

* updated snap packages

* yarn.lock fix

* fixed errors

* override policy

* update policy

* undo override

* updated localization message descriptions

* updated lavamoat policy

* more policy updates

* update permission controller version

* update policy

* update fixture builder

* updated code to include permission value to satisfy wallet_snap permission description call

* fix import issue

* update test-snaps version

* added missing actions, added snap permission dedupe function

* prettier fix

* fix fencing

* add more fencing

* prettier fix

* fix fencing (again)

* added new action and selector and updated view snap accordingly

* update test snaps website version

* unfence request variable

* add fencing

* add optional chaining to fix type error

* update migration #

* remove old migration

* prettier fix

* fix migration test

* fix fencing

* added missing fencing

* updated code to workaround fencing

* update test-snaps site version and remove snap confirm test

* update snap packages

* update policies

* fix merge marker issue

* update test

* more fixes

* fix permissions

* update test

* fixed test

* Bump test-snaps and iframe-execution-environment

* remove unused snap permission from fixture builder

* update policies

* undo comment removal, update selector implementation

* removed unnecessary function, updated migration, updated caveat action

* remove optional chaining

* fix type issue

* more type fixes

* fix migration test

* remove isFlask check, make migration logic more robust

* update coverage

* Update LavaMoat policies

* Update test/e2e/snaps/enums.js

* add extra bail condition

* Revert "add extra bail condition"

This reverts commit b45c53dcfc6e6e35a5e283d4955d6d6ea9ca5965.

* Revert "Revert "add extra bail condition""

This reverts commit cd2ded677935c9cdab0c02b6af55474c83727f60.

* fix test

* add SnapController entry to state object

* updated permission name and caveat type with hardcoded values

* add extra test for non-flask scenario

* update lavamoat policies

* fix locale messages

* change coverage target

* re-enable rpc snap test

* revert locale message change

* fix el message

* reverted changes

---------

Co-authored-by: Frederik Bolding <frederik.bolding@gmail.com>
2023-03-08 13:29:23 -05:00
Matthew Walsh
d0417da3d0
Move desktop code to flask build type (#17960) 2023-03-06 19:35:00 +00:00
HowardBraham
694773f17a
Upgrading the Import Account modal (#17763)
Co-authored-by: georgewrmarshall <george.marshall@consensys.net>
Co-authored-by: NidhiKJha <nidhi.kumari@consensys.net>
Co-authored-by: montelaidev <monte.lai@consensys.net>
2023-03-06 09:48:28 -08:00
Alaa Hadad
5998ae21aa
Buy crypto by redirecting to onramp experience on pdapp instead of deposit popover (#17689)
* feat: disable deposit popover and replace it with global redirect to onramp on pdapp

* feat: remove legacy code for hardcoded onramp providers

* fix: remove unused visuals and components related to legacy code of deposit popover

* fix: remove unused messages

* feat: use a custom hook for all onramps related methods and variables

* fix: modify the custom hook implementation to include test networks

* fix: remove deprecated file buy-url

* fix: remove references for deleted deposit logos

* fix: network-controller failing unit test

* fix: snapshot loading-swaps-quotes-stories-metadata.test.js.snap

* fix: storybook tests

* fix: remove unused constatns related to buyable onramp chains

* fix: remove unused variables and fix eslint

* adding unit test for useRamps custom hook

* feat: add comment on the proper usage of useRamps within confirm-page-container component

* fix: add unit tests for buy button in token-overview page

* fix: add unit test for open the buy crypto URL for a buyable chain ID in token page

* feat: add unit test coverage for eth-overview page

* fix: update locales
2023-03-01 12:45:27 +04:00
Filip Sekulic
932282e638
What's new - OpenSea security provider (#16831) 2023-02-27 10:20:22 -06:00
João Tavares
bde74756d3
Add extension desktop UI (#17748)
* feat: add desktop enable button component

This component will be added
to the experimental page. Users
will then be able to initialize
a desktop connection

* feat: add desktop pairing page

* feat: add desktop deep-linking shared lib

* test: add initial entries to render helper

Allow specifying initialEntries for
MemoryRouter. This change will allow
testing pages that use the useParam
hook.

* feat: add desktop error page

Error page for any desktop pairing
related issue

* feat: add desktop routes to route component

* feat: add enable desktop button to experimental tab

* feat: add desktop icon when paired in dev mode

* feat: disable ledger live control when desktop enabled

* feat: register desktop error actions on ui init

* fix: add missing code fencing

* chore: remove enable desktop rpc middleware

Now that we are adding the UI
there's no need for this rpc middleware
(as it was used to test desktop background
code)

* fix: display experimental tab for desktop
2023-02-23 16:39:48 +00:00
David Walsh
24e0a9030b
UX: Move Portfolio link to its own button (#17722) 2023-02-21 09:32:08 -06:00
Nidhi Kumari
33cc8d587a
NFT: Replaced all the instances of collectibles with NFTs (#17741)
* replaced all the instances of collectibles with nfts

* updated actions

* updated e2e seeder

* updated confirm Approve test

* updated test dapp change

* updated test dapp change

* nit fix

* nit fix

* updated casing and snapshots

* updated casinG

* added migrations

* updated ,igration

* updated 078.test

* updated tests for 078 migration

* updated migration

* updated 078 index.js
2023-02-17 00:53:29 +05:30
Monte Lai
cdc1bce688
SRP hold to reveal (#17232)
* refactor class to functional component

* update messages

* fix: use classnames

* feat: add hold to reveal modal

* feat: add new zendesk url for secret recovery phrase and noncustodial wallet

* update: clipboard to clear copied text after delay

* fix: remove save to csv

* feat: update styles for reveal seed page

* fix: update reveal seed snapshot

* add test to check for modal

* fix: lint

* fix: unused messages locale

* fix: use new banner component

* fix: use new button from design system

* fix: update snapshot

* fix: lint

* revert text

* fix: lint

* fix: remove --copy-only

* fix: marginBottom prop value

* fix: iconName and prop error

* --made the QR code slightly smaller so it's less likely to have a scrollbar
--updated the snapshots

* fix: error message not displaying

* SRP hold to reveal using more DS components (#17583)

* Updating to add DS components and remove CSS

* Fixing rendered html and removing some unneeded props

* fix: set block to true

---------

Co-authored-by: Monte <monte.lai@consensys.net>

* fix: add descriptions to messages

* Update ui/components/ui/export-text-container/export-text-container.component.js

fix: lint

Co-authored-by: HowardBraham <HowardBraham@users.noreply.github.com>

* fix: remove using displayWarning in requestRevealSeedWords

* fix: update test to remove displayError

* fix: update design system enums

* fix: messages descriptions

* fix: banner to banneralert

* fix: update preview

* add additional tests

* fix: use jest instead of sinon

* add test if long press isn't completed

* add test if password is wrong

---------

Co-authored-by: Howard Braham <howrad@gmail.com>
Co-authored-by: George Marshall <george.marshall@consensys.net>
2023-02-15 10:07:33 -08:00
Nidhi Kumari
9b0e71f27f
Updated messages/strings to replace Collectibles with NFTs (#17659)
* updated json files to use NFT

* Update locale strings

* fixed lint errors

* updated json files

* updated removeCollectibleMessage and newNftAddedMessage

* updated test for nfts
2023-02-10 21:06:58 +05:30
Harry
b4ecc4c3f5
Disable eth_sign by default, allow users to toggle it back on (#17308)
* Added translation for eth sign toggle

* Disabled the ability to call eth_sign by default. Added ability within advanced settings to renable support for eth_sign

* Add test case for eth_sign being enabled and disabled

* Modified copy

* Moved rpc method preference to its own object within store

* Complete work on moving rpc method preference into its own object within store

* Fix with prettier

* Fix lint

* Fix a unit test

* Fix test

* Renamed function and object keys to be more intuitive

* Fix e2e test

* Enabled eth_sign through preferences fixture

* Fix lint

* Fix e2e test

Wait for the notification popup to close, leaving 2 window handles the extension and the test dapp

* Fix e2e test

* Fix unit test

Enable eth_sign method

* Lint fix

---------

Co-authored-by: PeterYinusa <peter.yinusa@consensys.net>
Co-authored-by: Dan J Miller <danjm.com@gmail.com>
2023-02-06 13:17:50 -03:30
Brad Decker
31897b542d
Convert actions.js to typescript (#17446) 2023-02-03 11:56:44 -06:00
Danica Shen
6b076fa346
feature: convert ui/ducks/app/app.ts to typescript (#17454)
Co-authored-by: Pedro Figueiredo <pedro.figueiredo@consensys.net>
2023-02-03 08:59:07 -06:00
Brad Decker
02b2d7fa42
Dead and redundant code removal (#17512) 2023-02-02 16:00:05 -06:00
Brad Decker
deb9343ff0
Convert store.js to typescript and redux toolkit (#17508) 2023-02-02 13:32:44 -06:00
Brad Decker
85a52d49db
Convert action-queue to TypeScript (#17509) 2023-02-02 13:14:56 -06:00
vthomas13
532a10f9f5
Adding browser outdated notification (#17027)
* Adding browser outdated notification

* updating dependency

* adding unit tests for util function

* adding unit tests for selectors, lintfix

* Added Tests, refactored notification delay logic

* lint:fix

* adding test coverage for method parameter

* Update app/scripts/controllers/app-state.js

adding documentation details

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

* moving declaration into test

* Update app/scripts/controllers/app-state.test.js

spacing in test file

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

* Update jest.config.js

removing duplicate entries

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

* using async submitRequestToBackground method

* removing unused import

* removing unnecessary link syntax in notification

* adding opera and edge and associated tests

* handling the undefined case in bowser.satisfies

* setOutdatedBrowserWarningLastShown try/catch

* lint:fix

* Removing try/catch and letting errors bubble up

Removing deprecated displayWarning method

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

* taking out forceMetamaskUpdateState call

* excludint app-state test from mocha test suite

* Added note: Jest files should match Mocha excluded

* syntax error, lint:fix

---------

Co-authored-by: Mark Stacey <markjstacey@gmail.com>
2023-02-02 13:56:41 -05:00
Brad Decker
3f50243cef
Allow background to handle forgotten password flow (#17501) 2023-02-02 10:46:22 -06:00
ryanml
7f9977b7d2
Convert ui/store/actionConstants.js -> Typescript (#17442) 2023-02-01 22:16:59 -07:00
Mark Stacey
55d8ec0572
Document displayWarning as deprecated (#17465)
The `displayWarning` action creator will show the error in various
different places in the UI. This is confusing for users, we should stop
doing this.

Instead we can consider each error case separately. If there is a
scenario where it's appropriate to tell a user about an error, we
should build that case into the relevant UI and use localized error
messages.
2023-01-30 09:37:04 -03:30
Mark Stacey
506ee16648
Document callback-style background calls as deprecated (#17376)
We've been migrating from callback-based to async background calls for
a number of years now. The async calls are easier to read, and less
likely to be misused (especially when it comes to error handling).

The `callBackgroundMethod` method, used to make a callback-based
background call, has been marked as deprecated. Hopefully this will
discourage further use.
2023-01-26 12:27:15 -03:30
David Walsh
29d4799f46
Fix #17388 - Remove dismiss button from NFT notification (#17389) 2023-01-25 13:28:15 -06:00
Vladimir Saric
f988dc1c5e
Enable the Token Allowance flow by default for all users (#16740) 2023-01-23 21:49:55 +05:30
Filip Sekulic
27d34166fe
Security provider check (OpenSea) (#16584) 2023-01-23 20:02:01 +05:30
Nidhi Kumari
180eabea06
Added toaster for removed NFTs (#17297)
* added notification for remove nfts

* reverted names for tabs

* updated default key

* updated snapshot

* updated remove nft toast to danger
2023-01-23 17:23:44 +05:30
David Walsh
cb6ee2b3fe
Use async/await instead of Promise.resolve (#16221) 2023-01-20 14:20:18 -06:00
Brad Decker
92f6ea6f6b
Relocate conversion utils to shared/modules/conversion.utils.js (#17319) 2023-01-20 11:04:37 -06:00
ryanml
a19a5d60d3
Convert shared/constants/hardware-wallets.js -> Typescript (#17310) 2023-01-20 09:14:40 -06:00
Brad Decker
5f6d2ba6b0
Convert Transaction constants to typescript (#17149) 2023-01-18 08:47:29 -06:00
Niranjana Binoy
a0bb4a6c5a
Toggle option to enable/disable balance and Token rate checking for using third-party API (#16772) 2023-01-17 10:23:04 -05:00
Michal
49c8b279be
harden export account (#17241)
harden export account
2023-01-17 15:01:12 +00:00
David Walsh
105762b0ed
Fix 16842 - Update NFT error message so that it's caught properly and displayed (#17165)
Co-authored-by: Nidhi Kumari <nidhi.kumari@consensys.net>
2023-01-13 09:33:01 -06:00
Olusegun Akintayo
13de51e748
Security and Privacy Settings Re-org (#16756) 2022-12-19 18:46:36 +01:00
Jyoti Puri
8125473dc5
Removing flag for EIP1559 V2 support (#16446) 2022-12-09 00:07:06 +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
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
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
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
Filip Sekulic
17c1fef9be
Token allowance screen updated (#16157) 2022-11-07 12:21:38 -06:00