diff --git a/.env.base b/.env.base index e682c284bc7..6906bbf56d0 100644 --- a/.env.base +++ b/.env.base @@ -59,7 +59,12 @@ REACT_APP_FEATURE_DYNAMIC_LP_ASSETS=false # Fetch read-only assets from various providers (Zapper only for now) REACT_APP_FEATURE_READ_ONLY_ASSETS=true -# swapper feature flags - other .env files will override these +# Swapper chain-specific flags. Use me if you're working on a swapper which brings first time swapper support for a chain, +# meaning we don't want to enable the selection for said chain in prod just yet +# Or alternatively, if we know that a given chain is very unstable and we may want to disable it in swapper altogether. +REACT_APP_FEATURE_SWAPPER_SOLANA=false + +# Swapper feature flags - other .env files will override these REACT_APP_FEATURE_CHAINFLIP=false REACT_APP_FEATURE_CHAINFLIP_DCA=false REACT_APP_FEATURE_COWSWAP=true diff --git a/.env.dev b/.env.dev index f0c0c65c1c8..bffd81bdc37 100644 --- a/.env.dev +++ b/.env.dev @@ -1,4 +1,9 @@ -# feature flags +# Swapper chain-specific flags. Use me if you're working on a swapper which brings first time swapper support for a chain, +# meaning we don't want to enable the selection for said chain in prod just yet +# Or alternatively, if we know that a given chain is very unstable and we may want to disable it in swapper altogether. +REACT_APP_FEATURE_SWAPPER_SOLANA=true + +# Swapper feature flags REACT_APP_FEATURE_CHAINFLIP=true REACT_APP_FEATURE_CHAINFLIP_DCA=false REACT_APP_FEATURE_PUBLIC_TRADE_ROUTE=true diff --git a/.env.develop b/.env.develop index bd9af55adc1..8e2651a7df1 100644 --- a/.env.develop +++ b/.env.develop @@ -1,4 +1,10 @@ -# feature flags +# Swapper chain-specific flags. Use me if you're working on a swapper which brings first time swapper support for a chain, +# meaning we don't want to enable the selection for said chain in prod just yet +# Or alternatively, if we know that a given chain is very unstable and we may want to disable it in swapper altogether. + +REACT_APP_FEATURE_SWAPPER_SOLANA=true + +# Swapper feature flags REACT_APP_FEATURE_LIMIT_ORDERS=true REACT_APP_FEATURE_CHAINFLIP=true REACT_APP_FEATURE_CHAINFLIP_DCA=false diff --git a/src/components/Modals/TradeAssetSearch/TradeAssetSearchModal.tsx b/src/components/Modals/TradeAssetSearch/TradeAssetSearchModal.tsx index fd694f59748..295ac0d9203 100644 --- a/src/components/Modals/TradeAssetSearch/TradeAssetSearchModal.tsx +++ b/src/components/Modals/TradeAssetSearch/TradeAssetSearchModal.tsx @@ -17,13 +17,15 @@ import { useModal } from 'hooks/useModal/useModal' export type TradeAssetSearchModalProps = TradeAssetSearchProps & { title?: string onAssetClick: Required['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 = ({ diff --git a/src/components/MultiHopTrade/components/SharedTradeInput/SharedTradeInputBody.tsx b/src/components/MultiHopTrade/components/SharedTradeInput/SharedTradeInputBody.tsx index 7f5c422e62a..a10d9702aab 100644 --- a/src/components/MultiHopTrade/components/SharedTradeInput/SharedTradeInputBody.tsx +++ b/src/components/MultiHopTrade/components/SharedTradeInput/SharedTradeInputBody.tsx @@ -38,8 +38,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 diff --git a/src/components/MultiHopTrade/components/TradeInput/TradeInput.tsx b/src/components/MultiHopTrade/components/TradeInput/TradeInput.tsx index fbf55289d3b..12c182383bf 100644 --- a/src/components/MultiHopTrade/components/TradeInput/TradeInput.tsx +++ b/src/components/MultiHopTrade/components/TradeInput/TradeInput.tsx @@ -1,7 +1,9 @@ +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 } from '@shapeshiftoss/types' +import { KnownChainIds } from '@shapeshiftoss/types' import { positiveOrZero } from '@shapeshiftoss/utils' import type { FormEvent } from 'react' import { useCallback, useEffect, useMemo, useState } from 'react' @@ -19,6 +21,7 @@ import { useInputOutputDifferenceDecimalPercentage } from 'components/MultiHopTr import { TradeInputTab, TradeRoutePaths } from 'components/MultiHopTrade/types' import { WalletActions } from 'context/WalletProvider/actions' import { useErrorHandler } from 'hooks/useErrorToast/useErrorToast' +import { useFeatureFlag } from 'hooks/useFeatureFlag/useFeatureFlag' import { useModal } from 'hooks/useModal/useModal' import { useWallet } from 'hooks/useWallet/useWallet' import { fromBaseUnit } from 'lib/math' @@ -301,12 +304,33 @@ export const TradeInput = ({ isCompact, tradeInputRef, onChangeTab }: TradeInput [dispatch], ) + const isSolanaSwapperEnabled = useFeatureFlag('SolanaSwapper') + const assetFilterPredicate = useCallback( + (asset: Asset) => { + if (asset.chainId === KnownChainIds.SolanaMainnet) return isSolanaSwapperEnabled + + return true + }, + [isSolanaSwapperEnabled], + ) + + const chainIdFilterPredicate = useCallback( + (chainId: ChainId) => { + if (chainId === KnownChainIds.SolanaMainnet) return isSolanaSwapperEnabled + + return true + }, + [isSolanaSwapperEnabled], + ) + const handleBuyAssetClick = useCallback(() => { buyAssetSearch.open({ onAssetClick: setBuyAsset, title: 'trade.tradeTo', + assetFilterPredicate, + chainIdFilterPredicate, }) - }, [buyAssetSearch, setBuyAsset]) + }, [assetFilterPredicate, buyAssetSearch, chainIdFilterPredicate, setBuyAsset]) const buyTradeAssetSelect = useMemo( () => ( @@ -315,9 +339,10 @@ export const TradeInput = ({ isCompact, tradeInputRef, onChangeTab }: TradeInput onAssetClick={handleBuyAssetClick} onAssetChange={setBuyAsset} onlyConnectedChains={false} + chainIdFilterPredicate={chainIdFilterPredicate} /> ), - [buyAsset.assetId, handleBuyAssetClick, setBuyAsset], + [buyAsset.assetId, handleBuyAssetClick, setBuyAsset, chainIdFilterPredicate], ) const bodyContent = useMemo(() => { @@ -335,6 +360,8 @@ export const TradeInput = ({ isCompact, tradeInputRef, onChangeTab }: TradeInput setSellAccountId={setSellAssetAccountId} onChangeIsInputtingFiatSellAmount={handleIsInputtingFiatSellAmountChange} onChangeSellAmountCryptoPrecision={handleChangeSellAmountCryptoPrecision} + assetFilterPredicate={assetFilterPredicate} + chainIdFilterPredicate={chainIdFilterPredicate} >