Skip to content

Commit

Permalink
fix: dont hide solana in spot trade asset selection
Browse files Browse the repository at this point in the history
  • Loading branch information
woodenfurniture committed Nov 20, 2024
1 parent 16bc15f commit 589822e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,13 @@ import { useModal } from 'hooks/useModal/useModal'
export type TradeAssetSearchModalProps = TradeAssetSearchProps & {
title?: string
onAssetClick: Required<TradeAssetSearchProps>['onAssetClick']
assetFilterPredicate: (asset: Asset) => boolean
chainIdFilterPredicate: (chainId: ChainId) => boolean
assetFilterPredicate?: (asset: Asset) => boolean
chainIdFilterPredicate?: (chainId: ChainId) => boolean
}

type AssetSearchModalBaseProps = TradeAssetSearchModalProps & {
isOpen: boolean
close: () => void
assetFilterPredicate: (asset: Asset) => boolean
chainIdFilterPredicate: (chainId: ChainId) => boolean
}

export const TradeAssetSearchModalBase: FC<AssetSearchModalBaseProps> = ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ type SharedTradeInputBodyProps = {
sellAmountUserCurrency: string | undefined
sellAsset: Asset
sellAccountId: AccountId | undefined
assetFilterPredicate: (asset: Asset) => boolean
chainIdFilterPredicate: (chainId: ChainId) => boolean
assetFilterPredicate?: (asset: Asset) => boolean
chainIdFilterPredicate?: (chainId: ChainId) => boolean
onSwitchAssets: () => void
onChangeIsInputtingFiatSellAmount: (isInputtingFiatSellAmount: boolean) => void
onChangeSellAmountCryptoPrecision: (sellAmountCryptoPrecision: string) => void
Expand Down
22 changes: 3 additions & 19 deletions src/components/MultiHopTrade/components/TradeInput/TradeInput.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import type { ChainId } from '@shapeshiftoss/caip'
import { isLedger } from '@shapeshiftoss/hdwallet-ledger'
import { isArbitrumBridgeTradeQuote } from '@shapeshiftoss/swapper/dist/swappers/ArbitrumBridgeSwapper/getTradeQuote/getTradeQuote'
import type { ThorTradeQuote } from '@shapeshiftoss/swapper/dist/swappers/ThorchainSwapper/types'
import { type Asset, KnownChainIds } from '@shapeshiftoss/types'
import { type Asset } from '@shapeshiftoss/types'
import { positiveOrZero } from '@shapeshiftoss/utils'
import type { FormEvent } from 'react'
import { useCallback, useEffect, useMemo, useState } from 'react'
Expand Down Expand Up @@ -311,22 +310,12 @@ export const TradeInput = ({ isCompact, tradeInputRef, onChangeTab }: TradeInput
[dispatch],
)

const assetFilterPredicate = useCallback((asset: Asset) => {
return asset.chainId !== KnownChainIds.SolanaMainnet
}, [])

const chainIdFilterPredicate = useCallback((chainId: ChainId) => {
return chainId !== KnownChainIds.SolanaMainnet
}, [])

const handleBuyAssetClick = useCallback(() => {
buyAssetSearch.open({
onAssetClick: setBuyAsset,
title: 'trade.tradeTo',
assetFilterPredicate,
chainIdFilterPredicate,
})
}, [assetFilterPredicate, buyAssetSearch, chainIdFilterPredicate, setBuyAsset])
}, [buyAssetSearch, setBuyAsset])

const buyTradeAssetSelect = useMemo(
() => (
Expand All @@ -335,10 +324,9 @@ export const TradeInput = ({ isCompact, tradeInputRef, onChangeTab }: TradeInput
onAssetClick={handleBuyAssetClick}
onAssetChange={setBuyAsset}
onlyConnectedChains={false}
chainIdFilterPredicate={chainIdFilterPredicate}
/>
),
[buyAsset.assetId, handleBuyAssetClick, setBuyAsset, chainIdFilterPredicate],
[buyAsset.assetId, handleBuyAssetClick, setBuyAsset],
)

const bodyContent = useMemo(() => {
Expand All @@ -356,8 +344,6 @@ export const TradeInput = ({ isCompact, tradeInputRef, onChangeTab }: TradeInput
setSellAccountId={setSellAssetAccountId}
onChangeIsInputtingFiatSellAmount={handleIsInputtingFiatSellAmountChange}
onChangeSellAmountCryptoPrecision={handleChangeSellAmountCryptoPrecision}
assetFilterPredicate={assetFilterPredicate}
chainIdFilterPredicate={chainIdFilterPredicate}
>
<TradeAssetInput
// Disable account selection when user set a manual receive address
Expand Down Expand Up @@ -400,8 +386,6 @@ export const TradeInput = ({ isCompact, tradeInputRef, onChangeTab }: TradeInput
sellAsset,
sellAssetAccountId,
translate,
assetFilterPredicate,
chainIdFilterPredicate,
handleChangeSellAmountCryptoPrecision,
handleIsInputtingFiatSellAmountChange,
handleSwitchAssets,
Expand Down

0 comments on commit 589822e

Please sign in to comment.