1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-22 18:00:18 +01:00
metamask-extension/ui/pages
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
..
add-nft UX: Icon: Stop using fa-times (#17811) 2023-02-27 10:42:02 -06:00
asset NFT: Replaced all the instances of collectibles with NFTs (#17741) 2023-02-17 00:53:29 +05:30
confirm-add-suggested-token Use PageContainerFooter to render footer on all confirmation pages (#17316) 2023-01-23 20:52:12 +05:30
confirm-approve update text component color to use box color (#18246) 2023-03-23 13:00:37 -07:00
confirm-contract-interaction Convert Transaction constants to typescript (#17149) 2023-01-18 08:47:29 -06:00
confirm-decrypt-message fix(17542): fix fiat currency display in few txn actions (#18011) 2023-03-08 16:05:55 +00:00
confirm-deploy-contract Extract out confirm-data and confirm-hex-data components from confirm-transaction-base.component.js (#17822) 2023-03-09 10:38:37 +05:30
confirm-encryption-public-key fix(17542): fix fiat currency display in few txn actions (#18011) 2023-03-08 16:05:55 +00:00
confirm-import-token Added storybook check to CI (#17092) 2023-01-21 00:57:46 +05:30
confirm-send-ether Extract out confirm-data and confirm-hex-data components from confirm-transaction-base.component.js (#17822) 2023-03-09 10:38:37 +05:30
confirm-send-token Added storybook check to CI (#17092) 2023-01-21 00:57:46 +05:30
confirm-signature-request NetworkController: Split network into networkId and networkStatus (#17556) 2023-03-30 16:49:12 -06:00
confirm-token-transaction-base Fix #18199 : Add fallbacks for confirmation title on NFT transfers (#18269) 2023-03-30 14:07:29 -02:30
confirm-transaction Fix #17948 - Allow editing of NFT sends (#17970) 2023-03-09 15:02:08 -06:00
confirm-transaction-base NetworkController: Split network into networkId and networkStatus (#17556) 2023-03-30 16:49:12 -06:00
confirm-transaction-switch Convert Transaction constants to typescript (#17149) 2023-01-18 08:47:29 -06:00
confirmation Migrate network configurations (previously frequentRpcListDetail) from PreferencesController to NetworkController (#17421) 2023-03-09 15:00:28 -06:00
connected-accounts Added storybook check to CI (#17092) 2023-01-21 00:57:46 +05:30
connected-sites Added storybook check to CI (#17092) 2023-01-21 00:57:46 +05:30
create-account Upgrading the Import Account modal (#17763) 2023-03-06 09:48:28 -08:00
desktop-error Move desktop code to flask build type (#17960) 2023-03-06 19:35:00 +00:00
desktop-pairing Update snapshot 2023-03-28 10:36:53 +02:00
error Add more tracking for MetaMask (#15462) 2022-08-11 19:33:33 +02:00
home Revert "What's new - OpenSea security provider (#16831)" (#17968) 2023-03-22 12:51:37 -04:00
import-token NFTs: Remove feature flag for release (#17401) 2023-03-13 14:29:37 -05:00
institutional [MMI] Created institutional-entity-done-page component (#18096) 2023-03-30 08:33:12 +02:00
keychains update text component color to use box color (#18246) 2023-03-23 13:00:37 -07:00
lock Various test files converting to @testing-library/react. (#15470) 2022-08-08 13:28:49 -07:00
mobile-sync Refactor KeyringTypes constant (#17490) 2023-03-21 12:13:22 -02:30
notifications UX: Icons: Remove usage of chevron fa- icons (#17668) 2023-02-16 07:26:14 -06:00
onboarding-flow Welcome onboarding unit test (#18248) 2023-03-29 14:00:34 +08:00
permissions-connect [FLASK] Redesign key management modal (#18263) 2023-03-29 15:17:57 -04:00
routes UX: Multichain: Account Menu List (#17947) 2023-03-22 15:30:08 +05:30
send Refactor KeyringTypes constant (#17490) 2023-03-21 12:13:22 -02:30
settings Adding terms of use link for opensea (#18381) 2023-03-30 22:25:02 +04:00
swaps Use tokenList to get token details, when available, in getTokenStanda… (#17891) 2023-03-08 14:05:45 -03:30
token-allowance Refactor KeyringTypes constant (#17490) 2023-03-21 12:13:22 -02:30
token-details Migrate network configurations (previously frequentRpcListDetail) from PreferencesController to NetworkController (#17421) 2023-03-09 15:00:28 -06:00
unlock-page UX: Remove legacy metametrics modal (#17817) 2023-02-23 13:58:09 -06:00
index.js Renamed metametrics.new.js to metametrics.js (#14327) 2022-04-01 14:11:12 -05:00
pages.scss Add extension desktop UI (#17748) 2023-02-23 16:39:48 +00:00