Skip to content

Commit

Permalink
fix: regression
Browse files Browse the repository at this point in the history
  • Loading branch information
gomesalexandre committed Jan 24, 2024
1 parent ca8d8ba commit 2a8f818
Showing 1 changed file with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { useFeatureFlag } from 'hooks/useFeatureFlag/useFeatureFlag'
import { useIsSnapInstalled } from 'hooks/useIsSnapInstalled/useIsSnapInstalled'
import { useModal } from 'hooks/useModal/useModal'
import { useWallet } from 'hooks/useWallet/useWallet'
import { useWalletSupportsChain } from 'hooks/useWalletSupportsChain/useWalletSupportsChain'
import { parseAddressInputWithChainId } from 'lib/address/address'
import { selectInputBuyAsset } from 'state/slices/tradeInputSlice/selectors'
import { tradeInput } from 'state/slices/tradeInputSlice/tradeInputSlice'
Expand All @@ -38,21 +39,28 @@ export const ManualAddressEntry: FC = memo((): JSX.Element | null => {
const isYatSupported = isYatFeatureEnabled && isYatSupportedByReceiveChain

const isSnapInstalled = useIsSnapInstalled()
const walletSupportsBuyAssetChain = useWalletSupportsChain({
chainId: buyAssetChainId,
wallet,
isSnapInstalled,
})
const activeQuote = useAppSelector(selectActiveQuote)
const isHolisticRecipientAddressEnabled = useFeatureFlag('HolisticRecipientAddress')
const shouldShowManualReceiveAddressInput = useMemo(() => {
// Use old "wallet does not support chain" when the flag is off so we always display this
if (!isHolisticRecipientAddressEnabled) return !walletSupportsBuyAssetChain
// If the flag is on, we want to display this if the wallet doesn't support the buy asset chain,
// but stop displaying it as soon as we have a quote
return !walletSupportsBuyAssetChain && !activeQuote
}, [activeQuote, isHolisticRecipientAddressEnabled, walletSupportsBuyAssetChain])

const useReceiveAddressArgs = useMemo(
() => ({
fetchUnchainedAddress: Boolean(wallet && isLedger(wallet)),
}),
[wallet],
)

const isHolisticRecipientAddressEnabled = useFeatureFlag('HolisticRecipientAddress')
const activeQuote = useAppSelector(selectActiveQuote)
const { manualReceiveAddress } = useReceiveAddress(useReceiveAddressArgs)
// If we have a quote, then we were able to get it, meaning we do have a receive address, either wallet default or custom
// If the flag is on however, we should hide this as soon as we get a quote, since the new recipient address component will kick in
// in <ReceiveSummary />
const shouldShowManualReceiveAddressInput = !activeQuote || !isHolisticRecipientAddressEnabled

const chainAdapterManager = getChainAdapterManager()
const buyAssetChainName = chainAdapterManager.get(buyAssetChainId)?.getDisplayName()
Expand Down

0 comments on commit 2a8f818

Please sign in to comment.