Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Sentry] feat: network controller upgrade + network editing UI #26433

Merged
merged 521 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from 250 commits
Commits
Show all changes
521 commits
Select commit Hold shift + click to select a range
adb718f
convert `SecurityTab` to use the new network schema
bergeron Aug 25, 2024
5a57505
convert `bridge/selectors.ts` to use the new network schema
bergeron Aug 25, 2024
1b403bf
update mmi controller to maintain undefined check
bergeron Aug 25, 2024
2801946
Fix migration to prefer selected network id on duplicated url
bergeron Aug 25, 2024
83ebebf
Put e2e test state back on schema 74
bergeron Aug 25, 2024
c1f3d11
convert `PrivacySettings` to use the new network schema
bergeron Aug 25, 2024
b28ce66
convert `LoadingNetworkScreen` to use the new network schema
bergeron Aug 25, 2024
7e09e7a
remove `getNetworkConfigurations` selector
bergeron Aug 25, 2024
ed42fd4
remove more old network ui from settings
bergeron Aug 25, 2024
a05ae68
remove unused reference to `getNetworkConfigurations`
bergeron Aug 25, 2024
6e71f80
comment on `MultiRpcEditModal` about not using deprecated state
bergeron Aug 25, 2024
dd10297
lint `DropdownEditor`
bergeron Aug 25, 2024
b690a78
fix some unit tests
bergeron Aug 26, 2024
6bc1714
fix: update the multi-rpc modal with the new state
salimtb Aug 26, 2024
c7f1bea
fix: fix add-custom-network.spec test
salimtb Aug 26, 2024
a07e934
Merge branch 'develop' into brian/network-controller-v20-merging-in-v21
salimtb Aug 26, 2024
f9e20fe
fix: fix popular network component error
salimtb Aug 26, 2024
5dad8f8
fix: fix errors on network form
salimtb Aug 26, 2024
3e17598
fix: add test-id on rpc editor component
salimtb Aug 26, 2024
5383b12
fix: fix selector tests
salimtb Aug 26, 2024
7e814c0
fix: fix test ui/ducks/bridge/selectors.test.ts
salimtb Aug 26, 2024
626e346
fix: skip some test on add-ethereum-chain + add todo once the work is…
salimtb Aug 26, 2024
6739050
fix: fix selector test
salimtb Aug 26, 2024
62562fb
fix: fix test selected account component
salimtb Aug 26, 2024
255f62e
fix: restore skipped tests
salimtb Aug 26, 2024
61b2c14
fix: fix test address-copy-button
salimtb Aug 26, 2024
3d14996
feat: call multiRpc migration modal
salimtb Aug 26, 2024
821ad4c
fix typescript errors in `NetworkListItem`
bergeron Aug 26, 2024
218301c
fix typescript errors in `NetworkListMenu`
bergeron Aug 26, 2024
7b28e0c
update network form validation to allow testsnet symbols like 'Sepoli…
bergeron Aug 26, 2024
2306d2a
fix: fix migration modal script
salimtb Aug 26, 2024
aa585ab
fix: execute migrations
salimtb Aug 26, 2024
fc75a82
Merge branch 'brian/network-controller-v20-merging-in-v21' of github.…
bergeron Aug 27, 2024
f7b5ae5
tweaks to add-ethereum-chain
bergeron Aug 27, 2024
e9e05b8
fix: remove migration
salimtb Aug 27, 2024
eede333
fix: remove migration + add select rpc url test
salimtb Aug 27, 2024
487d6b3
fix: hide migration modal in case non conflicts
salimtb Aug 27, 2024
cb1109f
remove console.log
bergeron Aug 27, 2024
80b671e
cleanup pr
bergeron Aug 28, 2024
83de3c7
bump network controller to new preview release
bergeron Aug 28, 2024
429a2fb
tweaks for add-ethereum-chain
bergeron Aug 28, 2024
c970a6d
lint
bergeron Aug 28, 2024
4e23820
add back missing migration
bergeron Aug 28, 2024
1036384
Update LavaMoat policies
metamaskbot Aug 28, 2024
58d06d5
fix a request queuing e2e test
bergeron Aug 28, 2024
7d09e93
fix: fix switch to active network error
salimtb Aug 28, 2024
f8825f3
fix: fix custom rpc history test
salimtb Aug 28, 2024
5a86e85
make 'show test networks' toggle enabled when on test network
bergeron Aug 28, 2024
ef2ad36
move aurora deprecation button to use new network controller API
bergeron Aug 28, 2024
46b36c0
fix: fix storybook tests
salimtb Aug 28, 2024
2fbde59
Merge branch 'develop' of github.com:MetaMask/metamask-extension into…
bergeron Aug 28, 2024
255237d
Merge branch 'brian/network-controller-v20-merging-in-v21' of github.…
bergeron Aug 28, 2024
a7e17c1
Update LavaMoat policies
metamaskbot Aug 28, 2024
58da3a6
fix trickier edge cases in migration
bergeron Aug 28, 2024
465ebb9
Merge branch 'brian/network-controller-v20-merging-in-v21' of github.…
bergeron Aug 28, 2024
2800b4b
Merge branch 'develop' of github.com:MetaMask/metamask-extension into…
bergeron Aug 28, 2024
1c8fb4c
merge https://github.com/MetaMask/metamask-extension/pull/26726
bergeron Aug 28, 2024
2aa075f
migration fixes
bergeron Aug 29, 2024
08d5025
Update LavaMoat policies
metamaskbot Aug 29, 2024
afd32f7
simplify multi rpc modal
bergeron Aug 29, 2024
cf03fc3
update add-ethereum-chain snapshot
bergeron Aug 29, 2024
36fb7b6
Merge branch 'brian/network-controller-v20-merging-in-v21' of github.…
bergeron Aug 29, 2024
7e782d2
update multi rpc modal unit test
bergeron Aug 29, 2024
d3d2e57
.
bergeron Aug 29, 2024
fe89d37
fix: fix multi rpc migration UI
salimtb Aug 29, 2024
e3fc53e
fix: make rpc name ellipsis
salimtb Aug 29, 2024
7a85c44
minor todos
bergeron Aug 29, 2024
385ee74
Merge branch 'brian/network-controller-v20-merging-in-v21' of github.…
bergeron Aug 29, 2024
c74802e
remove already implemented todo
bergeron Aug 29, 2024
90057c0
add comments and remove debugging statements
bergeron Aug 29, 2024
81fc8f7
add migration todo
bergeron Aug 29, 2024
7daea5d
fix sentry e2e tests
bergeron Aug 29, 2024
1e96ba9
Merge branch 'develop' of github.com:MetaMask/metamask-extension into…
bergeron Aug 29, 2024
f657f8f
remove e2e test for networks in settings page
bergeron Aug 29, 2024
8e4b395
Merge branch 'develop' of github.com:MetaMask/metamask-extension into…
bergeron Aug 29, 2024
698c644
fix for `Cannot perform 'get' on a proxy that has been revoked`
bergeron Aug 29, 2024
095768d
fix block explorer e2e tests
bergeron Aug 30, 2024
03c9ac6
Merge branch 'develop' of github.com:MetaMask/metamask-extension into…
bergeron Aug 30, 2024
9e666dd
fix metamask-controller unit tests
bergeron Aug 30, 2024
5126b66
fix: fix integration tests
salimtb Aug 30, 2024
506cf36
fix: fix display network name on confirmation page
salimtb Aug 30, 2024
f55a84f
fix: fix linter
salimtb Aug 30, 2024
749736a
feat: update migration modal title
salimtb Aug 30, 2024
a7592f6
migration: improve duplicate detection
bergeron Sep 1, 2024
ad32ff1
migration logic for selected network controller
bergeron Sep 1, 2024
eaf8ddb
Merge branch 'develop' of github.com:MetaMask/metamask-extension into…
bergeron Sep 1, 2024
26f8703
Update LavaMoat policies
metamaskbot Sep 1, 2024
a6d6c62
fix e2e test for adding network during onboarding
bergeron Sep 1, 2024
73e3bde
fix e2e test for updating a network
bergeron Sep 1, 2024
1e0880e
fix not sending rpc requests before onboarding
bergeron Sep 1, 2024
67fca16
fix not sending rpc requests before onboarding
bergeron Sep 1, 2024
8fb8ab3
fix backup / restore of network state
bergeron Sep 1, 2024
c594c37
fix a bunch of typescript errors
bergeron Sep 2, 2024
d99afa9
update `<AddRpcUrlModal />` snapshot
bergeron Sep 2, 2024
948e139
`yarn verify-locales:fix`
bergeron Sep 2, 2024
1416fa6
attempt to fix `ElementClickInterceptedError` only reproducing in CI
bergeron Sep 2, 2024
4fb5d45
fix mmi build
bergeron Sep 2, 2024
b3a97da
fix QA report of token balances not updating on RPC switch
bergeron Sep 2, 2024
b1e0fa0
fix: add e2e tests for multi select rpc
salimtb Sep 2, 2024
af8d6b3
fix: remove only
salimtb Sep 2, 2024
d4d7d99
fix `wallet_switchEthereumChain` when network does not exist
bergeron Sep 2, 2024
9672843
Merge branch 'brian/network-controller-v20-merging-in-v21' of github.…
bergeron Sep 2, 2024
e82c0be
Merge branch 'develop' of github.com:MetaMask/metamask-extension into…
bergeron Sep 2, 2024
0b38bd5
fix: add unit test for fix wallet_switchEthereumChain when network do…
salimtb Sep 2, 2024
d5aee22
Merge branch 'develop' of github.com:MetaMask/metamask-extension into…
bergeron Sep 3, 2024
96c51f9
fix: fix e2e test and add test id
salimtb Sep 3, 2024
1069090
fix: fix linter
salimtb Sep 3, 2024
00ac8a8
fix: move e2e tests to another PR
salimtb Sep 3, 2024
0461159
Merge branch 'develop' into brian/network-controller-v20-merging-in-v21
salimtb Sep 3, 2024
e22af30
Merge branch 'develop' into brian/network-controller-v20-merging-in-v21
bergeron Sep 3, 2024
583cb72
include `rpcUrl` in metric
bergeron Sep 3, 2024
e866694
Merge branch 'develop' of github.com:MetaMask/metamask-extension into…
bergeron Sep 3, 2024
9a888d5
update snapshot
bergeron Sep 3, 2024
6b27fbd
Merge branch 'brian/network-controller-v20-merging-in-v21' of github.…
bergeron Sep 3, 2024
c161b70
Merge branch 'develop' of github.com:MetaMask/metamask-extension into…
bergeron Sep 4, 2024
e319334
Update LavaMoat policies
metamaskbot Sep 4, 2024
fb230f4
move from preview package to real published network controller
bergeron Sep 4, 2024
0d4002d
Merge branch 'brian/network-controller-v20-merging-in-v21' of github.…
bergeron Sep 4, 2024
3bde858
remove unused patch
bergeron Sep 4, 2024
4c139c0
Update LavaMoat policies
metamaskbot Sep 4, 2024
e4766ff
Merge branch 'develop' of github.com:MetaMask/metamask-extension into…
bergeron Sep 4, 2024
e9814ac
Merge branch 'develop' into brian/network-controller-v20-merging-in-v21
bergeron Sep 4, 2024
b3b2e6c
Merge branch 'develop' of github.com:MetaMask/metamask-extension into…
bergeron Sep 5, 2024
d843376
fix confirmation unit test from develop merge
bergeron Sep 5, 2024
5f8f50f
fix getAllEnabledNetworks selector
bergeron Sep 5, 2024
c069de7
fix getAllEnabledNetworks unit test
bergeron Sep 5, 2024
07da268
Merge branch 'develop' of github.com:MetaMask/metamask-extension into…
bergeron Sep 5, 2024
49e8b3d
fix `wallet_addEthereumChain` unit test after develop merge
bergeron Sep 5, 2024
450a503
fix react hook consistent order
bergeron Sep 5, 2024
6ed4dce
Merge branch 'develop' of github.com:MetaMask/metamask-extension into…
bergeron Sep 5, 2024
ae608b2
`[Hex]` -> `Hex[]` in `NetworkOrderController`
bergeron Sep 6, 2024
60b62b9
Implement respecting custom block explorer in notification
bergeron Sep 6, 2024
3716b6c
use `TEST_CHAINS` constant in `NetworkOrderController`
bergeron Sep 6, 2024
15ac698
refactor function chain into variable in `NetworkOrderController`
bergeron Sep 6, 2024
d440651
Don't initiate approval flow if the rpc + block explorer already exis…
bergeron Sep 6, 2024
a7dadf4
fix switch ethereum chain unit test
bergeron Sep 6, 2024
2f64e87
Merge branch 'develop' of github.com:MetaMask/metamask-extension into…
bergeron Sep 9, 2024
6dc153b
add rpc modal - string length check unnecessary
bergeron Sep 9, 2024
388e008
redo yarn.lock
bergeron Sep 9, 2024
2a487f2
fix `getCurrentNetwork` selector to include rpc url for built-in infu…
bergeron Sep 9, 2024
7b3d12b
fix nft storybook to use new network state
bergeron Sep 9, 2024
70edd8c
fix sentry e2e tests
bergeron Sep 10, 2024
6274306
Merge branch 'develop' of github.com:MetaMask/metamask-extension into…
bergeron Sep 10, 2024
358247d
Merge branch 'develop' of github.com:MetaMask/metamask-extension into…
bergeron Sep 10, 2024
5668fe4
Merge branch 'develop' of github.com:MetaMask/metamask-extension into…
bergeron Sep 10, 2024
bab2341
update migration to point domains to the default rpc endpoint
bergeron Sep 10, 2024
ebee7ce
ellipsis long network names in network menu
bergeron Sep 10, 2024
8ed559d
remove storybook for deleted component
bergeron Sep 10, 2024
db211e2
Fix static code analysis typescript:S6443 - React state setter functi…
bergeron Sep 10, 2024
bdafe4f
see whether privacy snapshot changes are still needed
bergeron Sep 10, 2024
1388914
patch https://github.com/MetaMask/core/pull/4679
bergeron Sep 11, 2024
7529ef8
Merge branch 'develop' of github.com:MetaMask/metamask-extension into…
bergeron Sep 11, 2024
b1e2c65
make chain id required in `ConfirmDeleteNetwork`
bergeron Sep 11, 2024
838529c
update `mock-state.json` to be more like product state
bergeron Sep 11, 2024
702a3e2
make `network-list-item.test.tsx` mock state more like product state
bergeron Sep 11, 2024
d677059
Update LavaMoat policies
metamaskbot Sep 11, 2024
1f04901
Merge branch 'brian/network-controller-v20-merging-in-v21' of github.…
bergeron Sep 11, 2024
c46638a
update `add-ethereum-chain` to use `currentChainIdForDomain` instead …
bergeron Sep 11, 2024
5b01c2e
lint
bergeron Sep 11, 2024
9dab651
remove unused hook
bergeron Sep 11, 2024
fe62f44
remove redundant css + tweaks to post upgrade multi rpc modal
bergeron Sep 11, 2024
ff9b2b7
update test snapshot
bergeron Sep 11, 2024
75da0f3
remove unised import
bergeron Sep 11, 2024
a60226b
move dropdown-editor to ui/components
bergeron Sep 11, 2024
1f4c3c8
give add rpc/block explorer modals their own css, instead of dependin…
bergeron Sep 11, 2024
2c7cf17
update snapshot with new css class
bergeron Sep 11, 2024
d376823
fix usage of react testing library snapshot to work with modal
bergeron Sep 11, 2024
1477ed2
give select rpc url its own css instead of relying on old network set…
bergeron Sep 11, 2024
4740f76
fix select rpc url snapshot and unit tests to use new css class
bergeron Sep 12, 2024
f685416
Merge branch 'develop' of github.com:MetaMask/metamask-extension into…
bergeron Sep 12, 2024
0534ba7
simplify `NetworkDisplay` to how it was before, now that `getCurrentN…
bergeron Sep 12, 2024
ddb46c5
remove commented out code
bergeron Sep 12, 2024
1fc2a81
Merge branch 'develop' into brian/network-controller-v20-merging-in-v21
bergeron Sep 12, 2024
943be09
Merge branch 'develop' into brian/network-controller-v20-merging-in-v21
bergeron Sep 12, 2024
affb750
attempt to fix flaky e2e test with stale element
bergeron Sep 12, 2024
d69e1b8
Merge branch 'brian/network-controller-v20-merging-in-v21' of github.…
bergeron Sep 12, 2024
2d18c86
Merge branch 'develop' of github.com:MetaMask/metamask-extension into…
bergeron Sep 12, 2024
f57dc52
experiment with performance via `createDeepEqualSelector`
bergeron Sep 12, 2024
65fa687
experiment with performance via `createSelector`
bergeron Sep 13, 2024
ad8b239
temporarily remove re-runs for changed files to experiment
bergeron Sep 13, 2024
77e8b0c
increase e2e timeout
bergeron Sep 13, 2024
c0f0a2e
Default RPCs: Autofocus Network, RPC, and Block Explorer form fields …
darkwing Sep 13, 2024
acae126
merge develop
bergeron Sep 13, 2024
9ea5dbf
revert filterE2eChangedFiles experiment
bergeron Sep 13, 2024
aef9ad9
increase e2e timeout
bergeron Sep 13, 2024
06bd21a
fix confirmation unit test after develop merge
bergeron Sep 13, 2024
8b8e6ea
Merge branch 'develop' into brian/increase-e2e-timeout
bergeron Sep 13, 2024
ecf368c
Merge branch 'develop' of github.com:MetaMask/metamask-extension into…
bergeron Sep 16, 2024
554dbd9
Merge branch 'develop' into brian/increase-e2e-timeout
bergeron Sep 16, 2024
b615600
improve handling of migration edge case where selectedNetworkClientId…
bergeron Sep 16, 2024
71d7f85
improve link from scam warning to network editor
bergeron Sep 16, 2024
c7dd1c6
incorporate PR 26323 into `network-list-menu`
bergeron Sep 16, 2024
6e32f73
remove selected-network-controller patch and use release 18.0.1 instead
bergeron Sep 16, 2024
a48477e
fix typos in comments
bergeron Sep 16, 2024
709b595
`yarn dedupe`
bergeron Sep 16, 2024
ed206a7
Update LavaMoat policies
metamaskbot Sep 16, 2024
de6461f
15 minutes, plus 3 minutes for every changed file, up to a maximum of…
HowardBraham Sep 16, 2024
317514f
fix test-lint-shellcheck
HowardBraham Sep 16, 2024
a991b10
Merge branch 'develop' into brian/increase-e2e-timeout
bergeron Sep 16, 2024
029095a
Merge branch 'brian/increase-e2e-timeout' into brian/network-controll…
bergeron Sep 16, 2024
97104e2
fix block explorer mock in `build-quote.test.js`
bergeron Sep 16, 2024
0a9d97f
undo changes from https://github.com/MetaMask/metamask-extension/pull…
bergeron Sep 16, 2024
d5da99d
Merge branch 'develop' into brian/network-controller-v20-merging-in-v21
bergeron Sep 16, 2024
6c5dfdd
Merge branch 'develop' into brian/network-controller-v20-merging-in-v21
bergeron Sep 17, 2024
8648ae0
use `cloneDeep` instead of spread operator
bergeron Sep 17, 2024
d90a359
Merge branch 'develop' of github.com:MetaMask/metamask-extension into…
bergeron Sep 17, 2024
1175992
Merge branch 'develop' into brian/network-controller-v20-merging-in-v21
bergeron Sep 17, 2024
acd0e28
Merge branch 'develop' into brian/network-controller-v20-merging-in-v21
bergeron Sep 17, 2024
ea8c8f2
add comment
bergeron Sep 17, 2024
17375fa
Merge branch 'develop' into brian/network-controller-v20-merging-in-v21
bergeron Sep 17, 2024
d9bda85
Merge branch 'develop' into brian/network-controller-v20-merging-in-v21
bergeron Sep 17, 2024
a1f9578
Merge branch 'develop' of github.com:MetaMask/metamask-extension into…
bergeron Sep 18, 2024
4574bd2
Merge branch 'develop' into brian/network-controller-v20-merging-in-v21
bergeron Sep 18, 2024
5301d55
Merge branch 'develop' of github.com:MetaMask/metamask-extension into…
bergeron Sep 18, 2024
cb2809f
Merge branch 'brian/network-controller-v20-merging-in-v21' of github.…
bergeron Sep 18, 2024
6fd99eb
update nft unit test snapshot
bergeron Sep 18, 2024
e294209
update nft unit test snapshot
bergeron Sep 18, 2024
d75e942
add comment in migration
bergeron Sep 18, 2024
e1db1c3
update unit test mocks to not modify child state by reference
bergeron Sep 18, 2024
66c729b
Merge branch 'develop' into brian/network-controller-v20-merging-in-v21
bergeron Sep 18, 2024
b1b0466
capture an exception if the network controller is not defined or not …
bergeron Sep 18, 2024
294e9f0
capture an exception if the transaction controller is not defined or …
bergeron Sep 18, 2024
e057661
Merge branch 'brian/network-controller-v20-merging-in-v21' of github.…
bergeron Sep 18, 2024
1cbd990
fix onboarding e2e tests after new validation added to migration
bergeron Sep 18, 2024
74f01a3
improve handling of duplicate endpoints across chains
bergeron Sep 19, 2024
0c40b3e
update comment in network stub
bergeron Sep 19, 2024
5070138
remove eslint rule disable
bergeron Sep 19, 2024
2908f06
remove unnecessary async in unit test
bergeron Sep 19, 2024
396c47c
improve handling of case where selected network points to an invalid …
bergeron Sep 19, 2024
3b9df92
Merge branch 'develop' into brian/network-controller-v20-merging-in-v21
bergeron Sep 19, 2024
b2ed30b
memoize `getNetworkConfigurationsByChainId`
bergeron Sep 19, 2024
1b5623f
Merge branch 'develop' of github.com:MetaMask/metamask-extension into…
bergeron Sep 19, 2024
f8e317e
Merge branch 'brian/network-controller-v20-merging-in-v21' of github.…
bergeron Sep 19, 2024
ecaf414
make tie breaker fall back to custom network instead of infura
bergeron Sep 19, 2024
edb289e
Merge branch 'develop' into brian/network-controller-v20-merging-in-v21
bergeron Sep 19, 2024
4c16c6c
Merge branch 'develop' of github.com:MetaMask/metamask-extension into…
bergeron Sep 19, 2024
5baf8a2
Merge branch 'develop' into brian/network-controller-v20-merging-in-v21
bergeron Sep 19, 2024
f6c9ce7
Merge branch 'develop' into brian/network-controller-v20-merging-in-v21
bergeron Sep 19, 2024
402a86d
Merge branch 'brian/network-controller-v20-merging-in-v21' of github.…
bergeron Sep 19, 2024
1e55528
remove existing key from url
bergeron Sep 19, 2024
4cb408c
fix return type of action
bergeron Sep 19, 2024
63dbc1a
remove commented out code
bergeron Sep 19, 2024
4cf9c89
Merge branch 'develop' of github.com:MetaMask/metamask-extension into…
bergeron Sep 19, 2024
cd0d24e
remove unused import
bergeron Sep 19, 2024
7019816
add unit test clicking save button on network form
bergeron Sep 19, 2024
6b91c98
Merge branch 'develop' into brian/network-controller-v20-merging-in-v21
bergeron Sep 19, 2024
18e0533
increase code coverage further
bergeron Sep 19, 2024
05f1449
Merge branch 'brian/network-controller-v20-merging-in-v21' of github.…
bergeron Sep 19, 2024
7c909d4
unit test coverage for `updateNetwork`
bergeron Sep 19, 2024
9107a7b
.
bergeron Sep 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 23 additions & 5 deletions .storybook/test-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ import { draftTransactionInitialState } from '../ui/ducks/send';
import { KeyringType } from '../shared/constants/keyring';
import { NetworkStatus } from '@metamask/network-controller';
import { EthAccountType } from '@metamask/keyring-api';
import { CHAIN_IDS } from '../shared/constants/network';
import {
CHAIN_IDS,
LINEA_MAINNET_DISPLAY_NAME,
} from '../shared/constants/network';
import { copyable, divider, heading, panel, text } from '@metamask/snaps-sdk';
import { getJsxElementFromComponent } from '@metamask/snaps-utils';
import { FirstTimeFlowType } from '../shared/constants/onboarding';
Expand Down Expand Up @@ -1218,23 +1221,37 @@ const state = {
accounts: ['0x9d0ba4ddac06032527b140912ec808ab9451b788'],
},
],
...mockNetworkState({
...mockNetworkState(
{
id: 'test-networkConfigurationId-1',
rpcUrl: 'https://testrpc.com',
chainId: '0x1',
nickname: 'mainnet',
name: 'mainnet',
blockExplorerUrl: 'https://etherscan.io',
metadata: {
EIPS: { 1559: true },
status: NetworkStatus.Available,
}
}, {
},
},
{
id: 'test-networkConfigurationId-2',
rpcUrl: 'https://testrpc2.com',
chainId: '0xe708',
nickname: LINEA_MAINNET_DISPLAY_NAME,
name: LINEA_MAINNET_DISPLAY_NAME,
blockExplorerUrl: 'https://lineascan.build',
metadata: { EIPS: { 1559: true }, status: NetworkStatus.Available },
},
{
id: 'test-networkConfigurationId-3',
rpcUrl: 'http://localhost:8545',
chainId: '0x539',
name: 'test network',
ticker: 'ETH',
nickname: 'Localhost 8545',
}),
},
),
accountTokens: {
'0x64a845a5b02460acf8a3d84503b0d68d028b4bb4': {
'0x1': [
Expand Down Expand Up @@ -1278,6 +1295,7 @@ const state = {
ipfsGateway: 'dweb.link',
migratedPrivacyMode: false,
selectedAddress: '0x9d0ba4ddac06032527b140912ec808ab9451b788',
selectedNetworkClientId: 'test-networkConfigurationId-1',
metaMetricsId:
'0xc2377d11fec1c3b7dd88c4854240ee5e3ed0d9f63b00456d98d80320337b827f',
currentCurrency: 'usd',
Expand Down
65 changes: 60 additions & 5 deletions app/_locales/en/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added app/images/networks1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions app/scripts/controllers/metametrics.js
Original file line number Diff line number Diff line change
Expand Up @@ -795,12 +795,12 @@ export default class MetaMetricsController {
[MetaMetricsUserTrait.LedgerConnectionType]:
metamaskState.ledgerTransportType,
[MetaMetricsUserTrait.NetworksAdded]: Object.values(
metamaskState.networkConfigurations,
metamaskState.networkConfigurationsByChainId,
).map((networkConfiguration) => networkConfiguration.chainId),
[MetaMetricsUserTrait.NetworksWithoutTicker]: Object.values(
metamaskState.networkConfigurations,
metamaskState.networkConfigurationsByChainId,
)
.filter(({ ticker }) => !ticker)
.filter(({ nativeCurrency }) => !nativeCurrency)
.map(({ chainId }) => chainId),
[MetaMetricsUserTrait.NftAutodetectionEnabled]:
metamaskState.useNftDetection,
Expand Down
50 changes: 21 additions & 29 deletions app/scripts/controllers/mmi-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import {
} from '@metamask/message-manager';
import { NetworkController } from '@metamask/network-controller';
import { InternalAccount } from '@metamask/keyring-api';
import { toHex } from '@metamask/controller-utils';
import { toChecksumHexAddress } from '../../../shared/modules/hexstring-utils';
import { CHAIN_IDS } from '../../../shared/constants/network';
import { CONNECT_HARDWARE_ROUTE } from '../../../ui/helpers/constants/routes';
import {
MMIControllerOptions,
Expand Down Expand Up @@ -759,15 +759,9 @@ export default class MMIController extends EventEmitter {
this.custodyController.getAccountDetails(address);
const extensionId = this.extension.runtime.id;

const { networkConfigurations: networkConfigurationsById } =
this.networkController.state;
const networkConfigurations = Object.values(networkConfigurationsById);

const networks = [
...networkConfigurations,
{ chainId: CHAIN_IDS.MAINNET },
{ chainId: CHAIN_IDS.SEPOLIA },
];
const networks = Object.values(
this.networkController.state.networkConfigurationsByChainId,
);

return handleMmiPortfolio({
keyringAccounts,
Expand Down Expand Up @@ -853,26 +847,24 @@ export default class MMIController extends EventEmitter {
internalAccount.id,
);
}
const selectedChainId = parseInt(
getCurrentChainId({ metamask: this.networkController.state }),
16,
);
if (selectedChainId !== chainId && chainId === 1) {
await this.networkController.setActiveNetwork('mainnet');
} else if (selectedChainId !== chainId) {
const { networkConfigurations } = this.networkController.state;

const foundNetworkConfiguration = Object.values(
networkConfigurations,
).find(
(networkConfiguration) =>
parseInt(networkConfiguration.chainId, 16) === chainId,
);

if (foundNetworkConfiguration !== undefined) {
await this.networkController.setActiveNetwork(
foundNetworkConfiguration.id,
);
const selectedChainId = getCurrentChainId({
metamask: this.networkController.state,
});

if (selectedChainId !== toHex(chainId)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Int the removed code there is a condition && chainId === 1. Why is that condition not needed any more?

Copy link
Contributor Author

@bergeron bergeron Sep 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The built in infura network configurations are now in state, where they were not before. Therefore you don't need a special condition to call:

await this.networkController.setActiveNetwork('mainnet');

Since the infura/mainnet network client id now lives in networkConfigurationsByChainId as a regular network.

That said, I don't know how to test mmi properly.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bergeron I can test this in mmi. Do you have the steps on how to test it manually?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how to test MMI, or how it handles custom networks. But the PR description describes the main flows under Manual testing steps.

const networkConfiguration =
this.networkController.state.networkConfigurationsByChainId[
toHex(chainId)
];

const { networkClientId } =
networkConfiguration?.rpcEndpoints?.[
networkConfiguration.defaultRpcEndpointIndex
] ?? {};

if (networkClientId) {
await this.networkController.setActiveNetwork(networkClientId);
}
}

Expand Down
Loading