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

3550 Commits

Author SHA1 Message Date
Mark Stacey
9847179f54
Set network status to "unknown" when ID is invalid (#19068)
We now set the network status to "unknown" rather than "unavailable"
when the network ID is invalid. This better reflects what we know when
this happens, and it makes the network controller better aligned with
the core network controller.

This was accomplished by using a regular error for the network ID
assertion rather than using `assert` directly. `assert` would throw an
error with a `code` property, which resutled in us treating it like an
RPC error.

This isn't tested, but it was found in the course of porting unit tests
from core to extension. It will be covered by these tests, which will
be added in the next PR.

This change should have no functional impact because we treat these two
network statuses as equivalent. The distinction between unknown and
unavailable is useful only for debugging.
2023-05-09 15:44:14 -02:30
Vinicius Stevam
da8cb0bbc0
Fix fail to reject multiple approval requests (#19050) 2023-05-08 11:09:46 +01:00
Brad Decker
b60b9f441f
Bundle size reduction: Upgrading ethereumjs/tx and ethereumjs/common (#18302)
* upgrade ethereumjs/tx and deps

* Yarn dedupe

---------

Co-authored-by: Dan J Miller <danjm.com@gmail.com>
2023-05-05 10:55:41 -05:00
Albert Olivé
33f9d6f480
[MMI] Applied code fencing in transactions and pending tx tracker controllers (#17909)
* Applied code fencing in trabsactions and pending tx tracker controllers

* remove unneeded URL from the comment

* Added test

* Added useful comment

* Fixing code fences

---------

Co-authored-by: António Regadas <apregadas@gmail.com>
2023-05-05 15:58:40 +02:00
Matthew Walsh
f62d8fce61
Use core signature controller (#18654) 2023-05-05 13:05:52 +01:00
Pedro Figueiredo
bfbe10ba28
e2e test for action metrics (#18347)
* e2e test for action metrics

* add tests to implementing sw restart delay tracking

* wip

* wip

* wip

* wip

* remove unneeded code

* remove scuttling changes contemplated in #18989
2023-05-04 10:38:09 +04:00
witmicko
8d2803c179
limit connections (#18355)
limit background connections
2023-05-03 16:39:56 +01:00
Frederik Bolding
910b9e713f
Use separate versions for Flask and Stable snaps (#18875)
* Use separate versions for Flask and Stable snaps

* Update LM policy override

* Add deps to depcheck

* Improve import
2023-05-03 15:16:43 +02:00
OGPoyraz
cbcb46f704
fix: prevent cancel and speedup transactions to call accept approval (#18846) 2023-05-03 13:07:03 +02:00
Mark Stacey
d1cea85f33
Rename provider to providerConfig (#18907)
* Rename `provider` to `providerConfig`

The network controller `provider` state has been renamed to
 `providerConfig`. This better reflects what this state is, and makes
this controller more closely aligned with the core network controller.

All references to the provider configuration have been updated to
prefer `providerConfig` over `provider`, to make the distinction clear
between a provider and provider config.

Closes #18902

* Add migration
2023-05-02 13:23:20 -02:30
Frederik Bolding
4d015de43e
Fence snaps endowments and permissions for stable/flask (#18847)
* Fence snaps endowments and permissions for stable/flask

* Fix lint

* Fix tests

* Actually fix tests

* Fix another test
2023-05-02 14:51:16 +02:00
Mark Stacey
483ffdb5c0
Simplify network controller unit test setup (#18901)
* Simplify network controller unit test setup

The network controller unit tests have been refactored to simplify the
setup steps related to the controller messenger. The messenger is now
constructed by the `withController` helper function, rather than being
manually setup in each test that references it.

Relates to https://github.com/MetaMask/core/issues/1197

* Bring tests closer in alignment to core

The function to build default controller constructor parameters has
been removed, bringing these tests closer in alignment to the core
tests.
2023-05-02 09:02:57 -02:30
Victorien Gauch
7f585a19b7
fix(18709): fix error when switching to linea testnet using wallet_sw… (#18710)
* fix(18709): fix error when switching to linea testnet using wallet_switchEthereumChain

* fix: update condition to get network config
2023-04-28 10:04:10 -02:30
Andrew Peters
bbb35dbe8d
update ses@0.18.4 (#17521)
* update ses import directory
* agoric references removed
* domainTaming set to unsafe

---------

Co-authored-by: legobeat <109787230+legobeat@users.noreply.github.com>
2023-04-27 21:31:52 +09:00
Bernardo Garces Chapero
1253c768c7
Return state when calling EncryptionPublicKeyController.cancelEncryptionPublicKey (#18845)
* returns state

* adds unit test
2023-04-27 11:39:37 +01:00
Jyoti Puri
e0919d529e
Fix for wrong type being assigned to the transaction (#18818)
Co-authored-by: legobeat <109787230+legobeat@users.noreply.github.com>
2023-04-27 13:46:36 +09:00
OGPoyraz
6d0f3a0b26
Consume Decrypt Message Manager from @metamask/message-manager (#18379) 2023-04-26 17:02:33 +02:00
Olaf Tomalka
95c37e1ba3
feat: add yaml feature management (#18125)
* feat: add yaml feature management

Add yaml feature file per build type.
Also add method to parse yaml and set
enabled features env to true. The build
process will then replace any process.env[feature]
that exists on the config by its value

* chore: add example for desktop

* Added initial draft of build features

* [TMP] Sync between computers

* Is able to succesfully build stable extension with snaps feature

* Removing var context from builds.yml

* Add asssets to builds.yml

* Minor bug fixes and removing debug logs

* [WIP] Test changes

* Removed TODOs

* Fix regession bug

Also
* remove debug logs
* merge Variables.set and Variables.setMany with an overload

* Fix build, lint and a bunch of issues

* Update LavaMoat policies

* Re-add desktop build type

* Fix some tests

* Fix desktop build

* Define some env variables used by MV3

* Fix lint

* Fix remove-fenced-code tests

* Fix README typo

* Move new code

* Fix missing asset copy

* Move Jest env setup

* Fix path for test after rebase

* Fix code fences

* Fix fencing and LavaMoat policies

* Fix MMI code-fencing after rebase

* Fix MMI code fencing after merge

* Fix more MMI code fencing

---------

Co-authored-by: cryptotavares <joao.tavares@consensys.net>
Co-authored-by: Frederik Bolding <frederik.bolding@gmail.com>
Co-authored-by: Brad Decker <bhdecker84@gmail.com>
2023-04-25 16:32:51 +02:00
Nidhi Kumari
0efd00b755
UX Multichain: Added product tour component (#18571)
* adding product tour component

* updated control for prevIcon

* updated app-header and product tour

* updated css

* updated message strings

* updated tests

* removed console statement

* added selector for product tour

* updated test

* updated test

* updated state with steps

* Update ui/components/multichain/product-tour-popover/product-tour-popover.js

Co-authored-by: Garrett Bear <gwhisten@gmail.com>

* Update ui/components/multichain/product-tour-popover/product-tour-popover.js

Co-authored-by: Garrett Bear <gwhisten@gmail.com>

* Update ui/components/multichain/product-tour-popover/product-tour-popover.js

Co-authored-by: Garrett Bear <gwhisten@gmail.com>

* Update ui/components/multichain/product-tour-popover/product-tour-popover.js

Co-authored-by: Garrett Bear <gwhisten@gmail.com>

* Update ui/components/multichain/product-tour-popover/product-tour-popover.js

Co-authored-by: Garrett Bear <gwhisten@gmail.com>

* Update ui/components/multichain/product-tour-popover/product-tour-popover.js

Co-authored-by: Garrett Bear <gwhisten@gmail.com>

* Update ui/components/multichain/product-tour-popover/product-tour-popover.js

Co-authored-by: Garrett Bear <gwhisten@gmail.com>

* Update ui/components/multichain/product-tour-popover/product-tour-popover.js

Co-authored-by: Garrett Bear <gwhisten@gmail.com>

* Update ui/components/multichain/product-tour-popover/product-tour-popover.js

Co-authored-by: Garrett Bear <gwhisten@gmail.com>

* Update ui/components/multichain/product-tour-popover/product-tour-popover.scss

Co-authored-by: Garrett Bear <gwhisten@gmail.com>

* fixed lint errors

* updated lint error

* added changes for rtl support

* added changes for rtl support

* fixed lint errors

* Some suggestions (#18676)

* updated messages and indentation

* fixed popup close on my final step

* updated rtl classname condition

---------

Co-authored-by: Garrett Bear <gwhisten@gmail.com>
Co-authored-by: George Marshall <george.marshall@consensys.net>
2023-04-21 20:58:18 +05:30
Bernardo Garces Chapero
8632acbba3
Update tokens controller (#18459)
* update tokens controller
2023-04-21 09:05:27 +01:00
Jyoti Puri
7f00c2f313
Fixing issue with gasLimit in transaction being 0 (#18682) 2023-04-21 11:17:38 +05:30
Elliot Winkler
73b9c1095a
Update NC setProviderType to clear rpcUrl/nickname (#18675)
In the core version of NetworkController, `setProviderType` sets
`rpcTarget` (its name for `rpcUrl`) and `nickname` to `undefined`.
While it would be better to completely remove these properties, it would
be better to follow suit so that we can make the tests between the two
versions of the controllers more alike.
2023-04-20 15:50:59 -02:30
Elliot Winkler
24eae1d3c6
Use fake provider for NetworkController unit tests (#18628)
* Use fake provider for NetworkController unit tests

In the unit tests for NetworkController, it's important to prevent
network requests from occurring. Currently we do that by using Nock.
However, the `core` version of NetworkController uses a fake provider
object. This is arguably a better approach for unit tests because it
prevents us from having to think about the behavior that a specific
middleware may have. For instance, the Infura middleware intercepts
`eth_chainId` to return a static result, and the block cache middleware
replaces the `latest` block tag with the latest block number, making an
extra call to `eth_blockNumber` in doing so. We have to account for
these kinds of behaviors when using Nock, but we do not need to do this
when using a fake provider.

This should make it easier to compare the difference between the unit
tests in this repo vs. in the `core` repo, which should ultimately help
us merge the two controllers together.

* Rename fake-provider-engine to fake-provider

* Rearrange imports

* Move fake-provider and fake-block-tracker into a directory and exclude it from coverage

* Make FakeBlockTracker inert, and fix JSDocs

* Remove generics from FakeProvider

* Call beforeCompleting (and beforeResolving) using async/await

* Fix signature of sendAsync; align other signatures within FakeProvider

* No need to check whether error is not a string

* Don't exclude the provider-api-tests directory from coverage

* Make sure to mock both net_version and eth_getBlockByNumber when testing network status

* Fix FakeProvider so that none of the methods have optional callbacks
2023-04-20 15:21:41 -02:30
Mark Stacey
3776f4ad4c
Remove mobile sync feature (#18692)
The mobile sync feature has been removed. It has been disabled for
years. When we enable sync again, it will be using a different
implementation. This has already been removed on the mobile side.
2023-04-20 14:29:30 -02:30
Mark Stacey
8e52ed3fac
Make upsertNetworkConfiguration async (#18606)
The network controller method `upsertNetworkConfiguration` has been
made async. It makes one async call internally, which is the optional
step of setting the given network as the active network.

If the `setActive` option is set to `true`, this function will not
resolve until after the network switch has completed. If the
`setActive` option is `false`, this change will not have any functional
impact.

Relates to https://github.com/MetaMask/metamask-extension/issues/18587
2023-04-19 20:24:50 -02:30
Dan J Miller
7ca9383785
Fix swaps controller: update provider after networkIdStore state update (#18670)
* Fix swaps controller: update provider after networkIdStore state update

* Listen for changes on networkController.store, instead of networkController.networkIdStore, in the swaps controller

* Fix unit tests
2023-04-19 18:15:26 -02:30
Elliot Winkler
a876eaba23
removeNetworkConfiguration validates given ID (#18650)
In the `core` version of NetworkController, `removeNetworkConfiguration`
throws an error if the given network configuration ID doesn't match an
existing network configuration. This commits adds the same check for
consistency. It also makes some minor changes to the implementation and
tests for `removeNetworkConfiguration` for consistency as well.
2023-04-19 09:47:33 -06:00
Dan J Miller
7bc13e90f8
Rename migration 83 to 84 and rename migration 84 to 83 (#18655)
Co-authored-by: legobeat <109787230+legobeat@users.noreply.github.com>
2023-04-19 11:38:16 -02:30
Brad Decker
7fa7c05586
use network did change instead of state update for assetsContractController (#18629) 2023-04-18 14:03:12 -02:30
Mark Stacey
1fe28ee15a
Make setActiveNetwork async (#18605)
The network controller method `setActiveNetwork` is now async, and the
asynchronous `_setProviderConfig` step is now awaited. The function
will not resolve until the network has finished switching.

This change affects the `eth_switchEthereumChain` and
`eth_addEthereumChain` middleware, and it affects any network switching
performed in our UI.

Relates to https://github.com/MetaMask/metamask-extension/issues/18587
2023-04-18 13:25:05 -02:30
Dan J Miller
e6f73f5fe9
Pass correct params to fetchEstimatedL1Fee in the swaps controller (#18634) 2023-04-18 12:15:18 -02:30
Vinicius Stevam
ae0af1b283
Adopt security provider request from core (#18520) 2023-04-18 08:33:32 +01:00
Jyoti Puri
00d2d43d45
Fix error in console on rejecting signature request (#18614) 2023-04-18 05:58:28 +05:30
Mark Stacey
e5835ac459
Make resetConnection async (#18601)
The network controller method `resetConnection` is now async. This has
no functional impact.

Relates to https://github.com/MetaMask/metamask-extension/issues/18587
2023-04-17 15:45:22 -02:30
Mark Stacey
b87c1b8526
Make setProviderType async (#18604)
The network controller method `setProviderType` is now async, and the
async operation `_setProviderConfig` called at the end of the method is
now awaited.

Because the only async operation was the last step, this should have no
impact upon the flow of execution. The only functional change is that
now any callers have the option of waiting until the network switch
operation has completed.

One such change was made, in the `switch-ethereum-chain` middleware. As
a result, an error thrown while the network is switching will now
be thrown in this middleware and returned to the dapp as an internal
error.

Relates to https://github.com/MetaMask/metamask-extension/issues/18587
2023-04-17 15:45:01 -02:30
Mark Stacey
39dff02a04
Consolidate network stores (#18595)
* Consolidate network stores

The network controller used to have multiple different state stores,
which were composed together to form the main controller state store.
They have been consolidated into a single store. This required few
changes because most state access was already being done through the
composed store.

Fixes https://github.com/MetaMask/metamask-extension/issues/18303

* Add JSDoc comment
2023-04-17 13:24:13 -02:30
Mark Stacey
3588e6d28e
Make network controller internal fields private (#18607)
Internal network controller methods and fields are now private fields,
using the JavaScript `#` syntax rather than the `private` TypeScript
keyword or a leading underscore.

The one reference to a private field was in the preferences controller
unit tests. Fortunately it was being used to create a test fixture that
was unused. The unnecessary test fixtures have been removed from that
test suite.

Fixes https://github.com/MetaMask/metamask-extension/issues/18588
2023-04-17 12:45:33 -02:30
Frederik Bolding
47f4f4008b
[FLASK] Remove unused snaps code (#18565)
* Remove unused code after snap_confirm was removed

* Remove more unused code

* Fix lint
2023-04-17 12:55:08 +02:00
OGPoyraz
867d637f06
fix: add metrics event to sign controller (#18318)
Co-authored-by: legobeat <109787230+legobeat@users.noreply.github.com>
2023-04-17 11:21:33 +02:00
Jyoti Puri
cc71fda686
Fix issue with requests with empty data being forwarded to opensea (#18598) 2023-04-17 09:54:25 +05:30
Mark Stacey
73efd2edeb
Make rollbackToPreviousProvider async (#18599)
The network controller method `rollbackToPreviousProvider` is now
async. It will resolve when the network switch has completed.

Relates to https://github.com/MetaMask/metamask-extension/issues/18587
2023-04-15 10:31:59 -02:30
Mark Stacey
e6d1b052f0
Make _setProviderConfig async (#18600)
The network controller internal method `_setProviderConfig` has been
made async, the async `_switchNetwork` operation is now `await`-ed.

Since the `_switchNetwork` call was the last operation, this has zero
functional impact.

Relates to https://github.com/MetaMask/metamask-extension/issues/18587
2023-04-14 19:10:32 -02:30
Mark Stacey
b9ff4e8798
Remove the network controller previousProviderStore (#18593)
* Remove the network controller `previousProviderStore`

The `previousProvider` network controller state has been replaced with
a private internal property. This was only used internally, it did not
need to be part of state.

This relates to https://github.com/MetaMask/metamask-extension/issues/18303

* Remove redundant tests
2023-04-14 16:24:57 -02:30
Matthew Walsh
fa32c5deb9
Disable rate limiting for signature approval requests (#18594) 2023-04-14 18:33:53 +01:00
Mark Stacey
d85d2318a3
Make _switchNetwork async (#18597)
The network controller internal method `_switchNetwork` has been made
async, and the `lookupNetwork` call is now awaited. Because this method
is only used internally, and because the `await`-ed async operation was
the last operation in this function, this change has no functional
impact whatsoever.

Relates to https://github.com/MetaMask/metamask-extension/issues/18587
2023-04-14 14:53:57 -02:30
vthomas13
40e4a3653f
Updating Terms of Use, Adding popover and onboarding flow check (#18221)
* WIP commit

* Moving copy out of messages.json, styling changes

* handling scroll button click and disable logic

* moving scrollButton up to popover component, adding logic for accepting terms of use in popover and onboarding flows

* adding terms of use to e2e wallet creation/import

* adjusting failing unit test

* fixing QR code e2e

* updating welcome test

* setting app state in fixtures

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

removing console log

Co-authored-by: Nidhi Kumari <nidhi.kumari@consensys.net>

* Update ui/components/app/terms-of-use-popup/terms-of-use-popup.stories.js

adding args to ToU popup storybook

Co-authored-by: Nidhi Kumari <nidhi.kumari@consensys.net>

* Update ui/components/app/terms-of-use-popup/terms-of-use-popup.js

Co-authored-by: Nidhi Kumari <nidhi.kumari@consensys.net>

* updating DS components in terms of use

* popover styling changes

* adding metametrics tracking

* editing scrollbutton behavior

* adding unit test

* code fencing

---------

Co-authored-by: Nidhi Kumari <nidhi.kumari@consensys.net>
2023-04-14 12:51:13 -04:00
Elliot Winkler
26db0aee46
Convert NetworkController net client tests to TS (#18490)
In order to be able to better compare differences between the version of
NetworkController in this repo and the version in the `core` repo before
we replace this version with the `core` version, this commit converts
the NetworkController network client tests to TypeScript.

The added types here are copied from the `core` repo. We plan on
making more improvements on the `core` side at some point to polish the
tests and types and reduce some of the duplication, but for now we're
just trying to keep things as similar as possible.
2023-04-14 10:21:29 -06:00
Vinicius Stevam
a3af0b53e3
Trigger unlock popup in appStateController using ApprovalController (#18386) 2023-04-14 05:50:17 +01:00
David Walsh
eb51460cae
UX: Multichain: App header (#18363)
* UX: Multichain: App header

* Export app header, provide required information, put feature flag in place

* Provide available data

* Implement account picker -- centered and opens account popover

* Remove backgrounds, use isUnlocked

* Fix placement of the global menu

* Show logo when unlocked

* Add selector for getting current network, provide props to AvatarNetwork and PickerNetwork

* Wire up the network menu to the header

* fixed ui for all the screens

* updated story for header

* fixed import and header settings

* updated lint error

* fixed tests

* updated header

* removed test

* updated snapshot test

* updated network menu

* updated changes

* removed comment from menu bar

* updated css

* updated test for network list menu

* updated stylesheet

* updated ButtonIcon import

---------

Co-authored-by: NidhiKJha <menidhikjha@gmail.com>
2023-04-13 22:24:03 +05:30
Bernardo Garces Chapero
6ed72d6934
Refactor eth_getEncryptionPublicKey handling (#18319)
* add EncryptionPublicKeyController

* update message-managers package
2023-04-13 09:24:59 +01:00