@@ -33,12 +33,14 @@ import { IconProps } from "../../components/icon/types";
3333import { ChainIdHelper } from "@keplr-wallet/cosmos" ;
3434import { COMMON_HOVER_OPACITY } from "../../styles/constant" ;
3535
36- const TOP_CHAIN_IDS = [
37- "cosmoshub-4" ,
38- "osmosis-1" ,
39- "celestia" ,
40- "injective-1" ,
41- ] as const ;
36+ const priority = ( chainId : string ) => {
37+ const id = ChainIdHelper . parse ( chainId ) . identifier ;
38+ if ( id === "cosmoshub" ) return 0 ;
39+ if ( id === "osmosis" ) return 1 ;
40+ if ( id === "celestia" ) return 2 ;
41+ if ( id === "injective" ) return 3 ;
42+ return 4 ;
43+ } ;
4244
4345type StakeCurrencyItem = {
4446 key : string ;
@@ -64,24 +66,13 @@ export const StakeExplorePage: FunctionComponent = observer(() => {
6466
6567 const showBackButton = searchParams . get ( "showBackButton" ) === "true" ;
6668
67- const topChainIdentifierSet = useMemo (
68- ( ) =>
69- new Set (
70- TOP_CHAIN_IDS . map ( ( chainId ) => ChainIdHelper . parse ( chainId ) . identifier )
71- ) ,
72- [ ]
73- ) ;
74-
7569 const stakeCurrencyItems = useMemo < StakeCurrencyItem [ ] > ( ( ) => {
7670 const items : StakeCurrencyItem [ ] = [ ] ;
7771 for ( const chainInfo of chainStore . chainInfos ) {
7872 if ( chainInfo . isTestnet || ! chainInfo . stakeCurrency ) {
7973 continue ;
8074 }
8175 const key = `${ chainInfo . chainIdentifier } /${ chainInfo . stakeCurrency . coinMinimalDenom } ` ;
82- if ( topChainIdentifierSet . has ( chainInfo . chainIdentifier ) ) {
83- continue ;
84- }
8576 items . push ( {
8677 key,
8778 chainInfo : chainInfo ,
@@ -98,9 +89,6 @@ export const StakeExplorePage: FunctionComponent = observer(() => {
9889 const chainIdentifier = ChainIdHelper . parse (
9990 modularChainInfo . chainId
10091 ) . identifier ;
101- if ( topChainIdentifierSet . has ( chainIdentifier ) ) {
102- continue ;
103- }
10492
10593 const modularChainInfoImpl = chainStore . getModularChainInfoImpl (
10694 modularChainInfo . chainId
@@ -128,62 +116,16 @@ export const StakeExplorePage: FunctionComponent = observer(() => {
128116 }
129117 }
130118
131- return items . sort ( ( a , b ) =>
132- a . currency . coinDenom . localeCompare ( b . currency . coinDenom )
133- ) ;
134- } , [ chainStore , topChainIdentifierSet ] ) ;
135-
136- const topItems = useMemo < StakeCurrencyItem [ ] > ( ( ) => {
137- const items : StakeCurrencyItem [ ] = [ ] ;
138-
139- TOP_CHAIN_IDS . forEach ( ( chainId ) => {
140- if ( ! chainStore . hasChain ( chainId ) ) {
141- return ;
142- }
143- const chainInfo = chainStore . getChain ( chainId ) ;
144- const stakeCurrency =
145- chainInfo . stakeCurrency ?? chainInfo . currencies [ 0 ] ?? undefined ;
146- if ( ! stakeCurrency ) {
147- return ;
119+ return items . sort ( ( a , b ) => {
120+ const diff =
121+ priority ( a . chainInfo . chainId ) - priority ( b . chainInfo . chainId ) ;
122+ if ( diff !== 0 ) {
123+ return diff ;
148124 }
149-
150- items . push ( {
151- key : `${ chainInfo . chainIdentifier } /${ stakeCurrency . coinMinimalDenom } ` ,
152- chainInfo : chainInfo ,
153- currency : stakeCurrency ,
154- } ) ;
125+ return a . currency . coinDenom . localeCompare ( b . currency . coinDenom ) ;
155126 } ) ;
156-
157- return items ;
158127 } , [ chainStore ] ) ;
159128
160- const assetCards = [
161- ...topItems . map ( ( item ) => (
162- < AssetCard
163- key = { item . key }
164- chainId = { item . chainInfo . chainId }
165- chainInfo = { item . chainInfo }
166- currency = { item . currency }
167- onClick = { ( ) => {
168- setDepositInitialSearch ( item . chainInfo . chainName ) ;
169- setIsOpenDepositModal ( true ) ;
170- } }
171- />
172- ) ) ,
173- ...stakeCurrencyItems . map ( ( item ) => (
174- < AssetCard
175- key = { item . key }
176- chainId = { item . chainInfo . chainId }
177- chainInfo = { item . chainInfo }
178- currency = { item . currency }
179- onClick = { ( ) => {
180- setDepositInitialSearch ( item . chainInfo . chainName ) ;
181- setIsOpenDepositModal ( true ) ;
182- } }
183- />
184- ) ) ,
185- ] ;
186-
187129 return (
188130 < MainHeaderLayout >
189131 < Box paddingX = "1rem" paddingY = "1.25rem" >
@@ -229,7 +171,20 @@ export const StakeExplorePage: FunctionComponent = observer(() => {
229171
230172 < Gutter size = "1.25rem" />
231173
232- < CollapsibleGrid items = { assetCards } />
174+ < CollapsibleGrid
175+ items = { stakeCurrencyItems . map ( ( item ) => (
176+ < AssetCard
177+ key = { item . key }
178+ chainId = { item . chainInfo . chainId }
179+ chainInfo = { item . chainInfo }
180+ currency = { item . currency }
181+ onClick = { ( ) => {
182+ setDepositInitialSearch ( item . chainInfo . chainName ) ;
183+ setIsOpenDepositModal ( true ) ;
184+ } }
185+ />
186+ ) ) }
187+ />
233188 </ Box >
234189
235190 < Modal
0 commit comments