@@ -26,7 +26,7 @@ import { SearchInput } from "./SearchInput.js";
2626import { SelectChainButton } from "./SelectChainButton.js" ;
2727import { SelectBridgeChain } from "./select-chain.js" ;
2828import type { ActiveWalletInfo , TokenSelection } from "./types.js" ;
29- import { useBridgeChains } from "./use-bridge-chains.js" ;
29+ import { useBridgeChainsWithFilters } from "./use-bridge-chains.js" ;
3030import {
3131 type TokenBalance ,
3232 useTokenBalances ,
@@ -43,6 +43,11 @@ type SelectTokenUIProps = {
4343 selectedToken : TokenSelection | undefined ;
4444 setSelectedToken : ( token : TokenSelection ) => void ;
4545 activeWalletInfo : ActiveWalletInfo | undefined ;
46+ type : "buy" | "sell" ;
47+ selections : {
48+ buyChainId : number | undefined ;
49+ sellChainId : number | undefined ;
50+ } ;
4651} ;
4752
4853function findChain ( chains : BridgeChain [ ] , activeChainId : number | undefined ) {
@@ -58,7 +63,13 @@ const INITIAL_LIMIT = 100;
5863 * @internal
5964 */
6065export function SelectToken ( props : SelectTokenUIProps ) {
61- const chainQuery = useBridgeChains ( props . client ) ;
66+ const chainQuery = useBridgeChainsWithFilters ( {
67+ client : props . client ,
68+ type : props . type ,
69+ buyChainId : props . selections . buyChainId ,
70+ sellChainId : props . selections . sellChainId ,
71+ } ) ;
72+
6273 const [ search , _setSearch ] = useState ( "" ) ;
6374 const debouncedSearch = useDebouncedValue ( search , 500 ) ;
6475 const [ limit , setLimit ] = useState ( INITIAL_LIMIT ) ;
@@ -146,6 +157,11 @@ function SelectTokenUI(
146157 selectedToken : TokenSelection | undefined ;
147158 setSelectedToken : ( token : TokenSelection ) => void ;
148159 showMore : ( ( ) => void ) | undefined ;
160+ type : "buy" | "sell" ;
161+ selections : {
162+ buyChainId : number | undefined ;
163+ sellChainId : number | undefined ;
164+ } ;
149165 } ,
150166) {
151167 const isMobile = useIsMobile ( ) ;
@@ -203,6 +219,8 @@ function SelectTokenUI(
203219 >
204220 < LeftContainer >
205221 < SelectBridgeChain
222+ type = { props . type }
223+ selections = { props . selections }
206224 onBack = { ( ) => setScreen ( "select-token" ) }
207225 client = { props . client }
208226 isMobile = { false }
@@ -269,6 +287,8 @@ function SelectTokenUI(
269287 setScreen ( "select-token" ) ;
270288 } }
271289 selectedChain = { props . selectedChain }
290+ type = { props . type }
291+ selections = { props . selections }
272292 />
273293 ) ;
274294 }
@@ -467,16 +487,16 @@ function TokenSelectionScreen(props: {
467487 </ Container >
468488
469489 { ! props . selectedChain && (
470- < div
490+ < Container
491+ flex = "column"
492+ center = "both"
493+ expand
471494 style = { {
472- display : "flex" ,
473- alignItems : "center" ,
474- justifyContent : "center" ,
475495 minHeight : "300px" ,
476496 } }
477497 >
478498 < Spinner color = "secondaryText" size = "xl" />
479- </ div >
499+ </ Container >
480500 ) }
481501
482502 { props . selectedChain && (
0 commit comments