|
|
@ -51,7 +51,10 @@ import { |
|
|
|
hexToDecimal, |
|
|
|
hexToDecimal, |
|
|
|
} from '../../../helpers/utils/conversions.util'; |
|
|
|
} from '../../../helpers/utils/conversions.util'; |
|
|
|
import { calcTokenAmount } from '../../../helpers/utils/token-util'; |
|
|
|
import { calcTokenAmount } from '../../../helpers/utils/token-util'; |
|
|
|
import { getURLHostName } from '../../../helpers/utils/util'; |
|
|
|
import { |
|
|
|
|
|
|
|
getURLHostName, |
|
|
|
|
|
|
|
isEqualCaseInsensitive, |
|
|
|
|
|
|
|
} from '../../../helpers/utils/util'; |
|
|
|
import { usePrevious } from '../../../hooks/usePrevious'; |
|
|
|
import { usePrevious } from '../../../hooks/usePrevious'; |
|
|
|
import { useTokenTracker } from '../../../hooks/useTokenTracker'; |
|
|
|
import { useTokenTracker } from '../../../hooks/useTokenTracker'; |
|
|
|
import { useTokenFiatAmount } from '../../../hooks/useTokenFiatAmount'; |
|
|
|
import { useTokenFiatAmount } from '../../../hooks/useTokenFiatAmount'; |
|
|
@ -169,8 +172,9 @@ export default function BuildQuote({ |
|
|
|
shuffledTokensList, |
|
|
|
shuffledTokensList, |
|
|
|
}); |
|
|
|
}); |
|
|
|
const selectedToToken = |
|
|
|
const selectedToToken = |
|
|
|
tokensToSearch.find(({ address }) => address === toToken?.address) || |
|
|
|
tokensToSearch.find(({ address }) => |
|
|
|
toToken; |
|
|
|
isEqualCaseInsensitive(address, toToken?.address), |
|
|
|
|
|
|
|
) || toToken; |
|
|
|
const toTokenIsNotDefault = |
|
|
|
const toTokenIsNotDefault = |
|
|
|
selectedToToken?.address && |
|
|
|
selectedToToken?.address && |
|
|
|
!isSwapsDefaultTokenAddress(selectedToToken?.address, chainId); |
|
|
|
!isSwapsDefaultTokenAddress(selectedToToken?.address, chainId); |
|
|
@ -226,8 +230,8 @@ export default function BuildQuote({ |
|
|
|
} |
|
|
|
} |
|
|
|
if ( |
|
|
|
if ( |
|
|
|
token?.address && |
|
|
|
token?.address && |
|
|
|
!memoizedUsersTokens.find( |
|
|
|
!memoizedUsersTokens.find((usersToken) => |
|
|
|
(usersToken) => usersToken.address === token.address, |
|
|
|
isEqualCaseInsensitive(usersToken.address, token.address), |
|
|
|
) |
|
|
|
) |
|
|
|
) { |
|
|
|
) { |
|
|
|
fetchTokenBalance(token.address, selectedAccountAddress).then( |
|
|
|
fetchTokenBalance(token.address, selectedAccountAddress).then( |
|
|
@ -298,12 +302,12 @@ export default function BuildQuote({ |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
const hideDropdownItemIf = useCallback( |
|
|
|
const hideDropdownItemIf = useCallback( |
|
|
|
(item) => item.address === fromTokenAddress, |
|
|
|
(item) => isEqualCaseInsensitive(item.address, fromTokenAddress), |
|
|
|
[fromTokenAddress], |
|
|
|
[fromTokenAddress], |
|
|
|
); |
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
const tokensWithBalancesFromToken = tokensWithBalances.find( |
|
|
|
const tokensWithBalancesFromToken = tokensWithBalances.find((token) => |
|
|
|
(token) => token.address === fromToken?.address, |
|
|
|
isEqualCaseInsensitive(token.address, fromToken?.address), |
|
|
|
); |
|
|
|
); |
|
|
|
const previousTokensWithBalancesFromToken = usePrevious( |
|
|
|
const previousTokensWithBalancesFromToken = usePrevious( |
|
|
|
tokensWithBalancesFromToken, |
|
|
|
tokensWithBalancesFromToken, |
|
|
@ -314,9 +318,10 @@ export default function BuildQuote({ |
|
|
|
tokensWithBalancesFromToken?.address, |
|
|
|
tokensWithBalancesFromToken?.address, |
|
|
|
chainId, |
|
|
|
chainId, |
|
|
|
); |
|
|
|
); |
|
|
|
const addressesAreTheSame = |
|
|
|
const addressesAreTheSame = isEqualCaseInsensitive( |
|
|
|
tokensWithBalancesFromToken?.address === |
|
|
|
tokensWithBalancesFromToken?.address, |
|
|
|
previousTokensWithBalancesFromToken?.address; |
|
|
|
previousTokensWithBalancesFromToken?.address, |
|
|
|
|
|
|
|
); |
|
|
|
const balanceHasChanged = |
|
|
|
const balanceHasChanged = |
|
|
|
tokensWithBalancesFromToken?.balance !== |
|
|
|
tokensWithBalancesFromToken?.balance !== |
|
|
|
previousTokensWithBalancesFromToken?.balance; |
|
|
|
previousTokensWithBalancesFromToken?.balance; |
|
|
@ -490,7 +495,9 @@ export default function BuildQuote({ |
|
|
|
!Object.keys(topAssets).length) |
|
|
|
!Object.keys(topAssets).length) |
|
|
|
} |
|
|
|
} |
|
|
|
selectPlaceHolderText={t('swapSelect')} |
|
|
|
selectPlaceHolderText={t('swapSelect')} |
|
|
|
hideItemIf={(item) => item.address === selectedToToken?.address} |
|
|
|
hideItemIf={(item) => |
|
|
|
|
|
|
|
isEqualCaseInsensitive(item.address, selectedToToken?.address) |
|
|
|
|
|
|
|
} |
|
|
|
listContainerClassName="build-quote__open-dropdown" |
|
|
|
listContainerClassName="build-quote__open-dropdown" |
|
|
|
autoFocus |
|
|
|
autoFocus |
|
|
|
/> |
|
|
|
/> |
|
|
|