@@ -12,6 +12,7 @@ import {
12
12
POLYGON ,
13
13
ROOTSTOCK ,
14
14
MEZO_TESTNET ,
15
+ TEST_NETWORK_BY_CHAIN_ID ,
15
16
} from "@tallyho/tally-background/constants"
16
17
import { EVMNetwork , sameNetwork } from "@tallyho/tally-background/networks"
17
18
import { selectCurrentNetwork } from "@tallyho/tally-background/redux-slices/selectors"
@@ -26,7 +27,7 @@ import TopMenuProtocolListItem from "./TopMenuProtocolListItem"
26
27
import TopMenuProtocolListFooter from "./TopMenuProtocolListFooter"
27
28
import { i18n } from "../../_locales/i18n"
28
29
29
- export const productionNetworkInfo = {
30
+ export const productionNetworkDescription = {
30
31
[ ETHEREUM . chainID ] : i18n . t ( "protocol.mainnet" ) ,
31
32
[ POLYGON . chainID ] : i18n . t ( "protocol.l2" ) ,
32
33
[ OPTIMISM . chainID ] : i18n . t ( "protocol.l2" ) ,
@@ -39,7 +40,7 @@ export const productionNetworkInfo = {
39
40
40
41
const disabledChainIDs = [ ARBITRUM_NOVA . chainID ]
41
42
42
- const testNetworkInfo = {
43
+ const testNetworkDescription = {
43
44
[ MEZO_TESTNET . chainID ] : i18n . t ( "protocol.mezoTestnet" ) ,
44
45
[ SEPOLIA . chainID ] : i18n . t ( "protocol.testnet" ) ,
45
46
[ ARBITRUM_SEPOLIA . chainID ] : i18n . t ( "protocol.testnet" ) ,
@@ -49,21 +50,6 @@ type TopMenuProtocolListProps = {
49
50
onProtocolChange : ( network : EVMNetwork ) => void
50
51
}
51
52
52
- /**
53
- * Places Mezo network above other networks
54
- */
55
- const sortByNetworkPriority = ( a : EVMNetwork , b : EVMNetwork ) => {
56
- const getPriority = ( network : EVMNetwork ) => {
57
- switch ( true ) {
58
- case sameNetwork ( MEZO_TESTNET , network ) :
59
- return 0
60
- default :
61
- return 1
62
- }
63
- }
64
- return getPriority ( a ) - getPriority ( b )
65
- }
66
-
67
53
export default function TopMenuProtocolList ( {
68
54
onProtocolChange,
69
55
} : TopMenuProtocolListProps ) : ReactElement {
@@ -79,7 +65,10 @@ export default function TopMenuProtocolList({
79
65
( network ) => ! isBuiltInNetwork ( network ) ,
80
66
)
81
67
82
- const testNetworks = testnetNetworks . sort ( sortByNetworkPriority )
68
+ const testNetworks = [ ...TEST_NETWORK_BY_CHAIN_ID ] . flatMap (
69
+ ( chainId ) =>
70
+ testnetNetworks . find ( ( network ) => network . chainID === chainId ) ?? [ ] ,
71
+ )
83
72
84
73
return (
85
74
< div className = "container" >
@@ -91,7 +80,7 @@ export default function TopMenuProtocolList({
91
80
key = { network . name }
92
81
network = { network }
93
82
info = {
94
- productionNetworkInfo [ network . chainID ] ||
83
+ productionNetworkDescription [ network . chainID ] ||
95
84
t ( "protocol.compatibleChain" )
96
85
}
97
86
onSelect = { onProtocolChange }
@@ -130,7 +119,7 @@ export default function TopMenuProtocolList({
130
119
isSelected = { sameNetwork ( currentNetwork , network ) }
131
120
key = { network . name }
132
121
network = { network }
133
- info = { testNetworkInfo [ network . chainID ] }
122
+ info = { testNetworkDescription [ network . chainID ] }
134
123
onSelect = { onProtocolChange }
135
124
/>
136
125
) ) }
0 commit comments