diff --git a/src/ui/component/TokenSelect/index.tsx b/src/ui/component/TokenSelect/index.tsx index 9d9785e9eda..e973954a964 100644 --- a/src/ui/component/TokenSelect/index.tsx +++ b/src/ui/component/TokenSelect/index.tsx @@ -10,7 +10,7 @@ import { ReactComponent as SvgIconArrowDownTriangle } from '@/ui/assets/swap/arr import { useTokens } from '@/ui/utils/portfolio/token'; import { useRabbySelector } from '@/ui/store'; import { uniqBy } from 'lodash'; -import { SWAP_SUPPORT_CHAINS } from '@/constant'; +import { CHAINS_ENUM } from '@/constant'; import useSearchToken from '@/ui/hooks/useSearchToken'; import useSortToken from '@/ui/hooks/useSortTokens'; import { useAsync } from 'react-use'; @@ -52,14 +52,12 @@ const Text = styled.span` ${ellipsis()} `; -export interface TokenSelectProps { +interface CommonProps { token?: TokenItem; onChange?(amount: string): void; onTokenChange(token: TokenItem): void; - chainId?: string; useSwapTokenList?: boolean; excludeTokens?: TokenItem['id'][]; - type?: ComponentProps['type']; placeholder?: string; hideChainIcon?: boolean; value?: string; @@ -75,8 +73,21 @@ export interface TokenSelectProps { | React.ReactNode; disabledTips?: React.ReactNode; drawerHeight?: string | number; + supportChains?: CHAINS_ENUM[]; +} + +interface BridgeFromProps extends CommonProps { + type: 'bridgeFrom'; + chainId?: string; } +interface OtherProps extends CommonProps { + type: Exclude['type'], 'bridgeFrom'>; + chainId: string; +} + +type TokenSelectProps = BridgeFromProps | OtherProps; + const defaultExcludeTokens = []; const TokenSelect = ({ @@ -94,6 +105,7 @@ const TokenSelect = ({ useSwapTokenList = false, disabledTips = 'Not supported', drawerHeight, + supportChains, }: TokenSelectProps) => { const [queryConds, setQueryConds] = useState({ keyword: '', @@ -229,7 +241,7 @@ const TokenSelect = ({ {typeof tokenRender === 'function' ? tokenRender?.({ token, openTokenModal: handleSelectToken }) : tokenRender} - {queryConds.chainServerId && ( + {type === 'bridgeFrom' && !queryConds.chainServerId ? null : ( )} @@ -293,7 +305,7 @@ const TokenSelect = ({ /> )} - {queryConds.chainServerId && ( + {type === 'bridgeFrom' && !queryConds.chainServerId ? null : ( )} diff --git a/src/ui/views/Bridge/Component/BridgeToken.tsx b/src/ui/views/Bridge/Component/BridgeToken.tsx index f009a7d0114..1416b7ad91a 100644 --- a/src/ui/views/Bridge/Component/BridgeToken.tsx +++ b/src/ui/views/Bridge/Component/BridgeToken.tsx @@ -201,6 +201,7 @@ export const BridgeToken = ({ placeholder={t('page.swap.search-by-name-address')} disabledTips={t('page.bridge.insufficient-balance')} tokenRender={(p) => } + supportChains={supportedChains} /> )} diff --git a/src/ui/views/Swap/Component/Main.tsx b/src/ui/views/Swap/Component/Main.tsx index 2f7f247728d..93928ed8f34 100644 --- a/src/ui/views/Swap/Component/Main.tsx +++ b/src/ui/views/Swap/Component/Main.tsx @@ -526,6 +526,7 @@ export const Main = () => { placeholder={t('page.swap.search-by-name-address')} excludeTokens={receiveToken?.id ? [receiveToken?.id] : undefined} tokenRender={(p) => } + supportChains={SWAP_SUPPORT_CHAINS} /> { placeholder={t('page.swap.search-by-name-address')} excludeTokens={payToken?.id ? [payToken?.id] : undefined} tokenRender={(p) => } + supportChains={SWAP_SUPPORT_CHAINS} useSwapTokenList />