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
* 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
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.
* updated ethereum logo icon
* Updating eth logo (#18631)
* Updating eth logo
* Removing border from eth logo identicon
* Removing old eth logo
* updated snapshot and lint errors
* updated eth logo from svg to png
---------
Co-authored-by: George Marshall <george.marshall@consensys.net>
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
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
* 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
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
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
* 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
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
* 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>
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.
* 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>
This helps us more easily compare the unit tests for NetworkController
in this repo and the NetworkController in the `core` repo.
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
Co-authored-by: legobeat <109787230+legobeat@users.noreply.github.com>
* Ensure that all networkConfiguration object in networkController state have an id
* Lint fix
* Update app/scripts/migrations/084.ts
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
* Add unit tests for error cases
* Simplify code
* Remove unnecessary any typing
* Fix network controller type checking
* Lint fix
* Improve typing
---------
Co-authored-by: legobeat <109787230+legobeat@users.noreply.github.com>
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
Converting this controller to TypeScript furthers the goal of getting
this whole codebase converted, of course, but it also helps in comparing
the differences between this version of the NetworkController and the
version in the `core` repo more easily, which will ultimately help us in
coalescing the two implementations.
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
Co-authored-by: legobeat <109787230+legobeat@users.noreply.github.com>
The announcement controller has been updated to v2.0.1. The breaking
change in v2 was the migration to the BaseControllerV2 API. This
affected the constructor, as well as some methods/properties that we do
not use.
* use session storage, instead of chrome.runtime.onStartup and globalThis, for firstTimeLoaded architecture
* Ensure account tracker accounts remain defined upon service worker restart
* lint fix
* Simplify code
* Only call browser.storage.session in mv3
* Only call browser.storage.session.set after resetStates in mv3
* fix metamask controller reset states unit tests
* fix test
* fix test
* Actually fix tests
* lint fix
* Added confirm add institutional feature page
* Finished implementing component
* Added all institutional ducks
* Fixed tests
* Removed ducks and console log
* Fixed snapshots
* Fixed messages json
* Changed method name and using useEffect
* Replace useEffect hook with a simple if statement to check if connectRequest exists and add null return statement to avoid warnings
* Remove unneeded dependency
* Added back useEffect and added a extra check to return null if connectRequest is false
* Fixed eslint problem
* Fixed all issues commented in the pr
* Update `@metamask/swappable-obj-proxy`
The package `@metamask/swappable-obj-proxy` has been updated to the
latest version. The breaking changes include moving the package under
the `@metamask` scope and converting it to TypeScript.
* Update policy
The package `safe-event-emitter` has been updated to v2. This update
includes renaming the package to be scoped under `@metamask`, and it
includes a TypeScript migration.
* Add permission cell component
Add storybook and handling for revoked permission colors
* Fix things after conflict resolve after rebase
* Add code refactoring and minor UI changes
* Add permission cell component to snap-update flow
* Update storybook
* Add unit tests for permission cell
* Update component padding
* Fix spacing between permission cells
* Fix main icon color for approved permissions
* Update width value with constant