|
|
@ -95,9 +95,12 @@ export default function BuildQuote ({ |
|
|
|
symbol: fromTokenSymbol, |
|
|
|
symbol: fromTokenSymbol, |
|
|
|
string: fromTokenString, |
|
|
|
string: fromTokenString, |
|
|
|
decimals: fromTokenDecimals, |
|
|
|
decimals: fromTokenDecimals, |
|
|
|
|
|
|
|
balance: rawFromTokenBalance, |
|
|
|
} = selectedFromToken || {} |
|
|
|
} = selectedFromToken || {} |
|
|
|
|
|
|
|
|
|
|
|
const prevFromTokenString = usePrevious(fromTokenString) |
|
|
|
const fromTokenBalance = rawFromTokenBalance && calcTokenAmount(rawFromTokenBalance, fromTokenDecimals).toString(10) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const prevFromTokenBalance = usePrevious(fromTokenBalance) |
|
|
|
|
|
|
|
|
|
|
|
const swapFromTokenFiatValue = useTokenFiatAmount( |
|
|
|
const swapFromTokenFiatValue = useTokenFiatAmount( |
|
|
|
fromTokenAddress, |
|
|
|
fromTokenAddress, |
|
|
@ -158,10 +161,10 @@ export default function BuildQuote ({ |
|
|
|
}, [dispatch, fromToken, ethBalance]) |
|
|
|
}, [dispatch, fromToken, ethBalance]) |
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
useEffect(() => { |
|
|
|
if (prevFromTokenString !== fromTokenString) { |
|
|
|
if (prevFromTokenBalance !== fromTokenBalance) { |
|
|
|
onInputChange(inputValue, fromTokenString) |
|
|
|
onInputChange(inputValue, fromTokenBalance) |
|
|
|
} |
|
|
|
} |
|
|
|
}, [onInputChange, prevFromTokenString, inputValue, fromTokenString]) |
|
|
|
}, [onInputChange, prevFromTokenBalance, inputValue, fromTokenBalance]) |
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
useEffect(() => { |
|
|
|
dispatch(resetSwapsPostFetchState()) |
|
|
|
dispatch(resetSwapsPostFetchState()) |
|
|
@ -176,7 +179,7 @@ export default function BuildQuote ({ |
|
|
|
className="build-quote__max-button" |
|
|
|
className="build-quote__max-button" |
|
|
|
onClick={() => { |
|
|
|
onClick={() => { |
|
|
|
dispatch(setMaxMode(true)) |
|
|
|
dispatch(setMaxMode(true)) |
|
|
|
onInputChange(fromTokenString || '0', fromTokenString) |
|
|
|
onInputChange(fromTokenBalance || '0', fromTokenBalance) |
|
|
|
}} |
|
|
|
}} |
|
|
|
>{t('max')} |
|
|
|
>{t('max')} |
|
|
|
</div> |
|
|
|
</div> |
|
|
@ -186,7 +189,7 @@ export default function BuildQuote ({ |
|
|
|
itemsToSearch={tokensToSearch} |
|
|
|
itemsToSearch={tokensToSearch} |
|
|
|
onInputChange={(value) => { |
|
|
|
onInputChange={(value) => { |
|
|
|
dispatch(setMaxMode(false)) |
|
|
|
dispatch(setMaxMode(false)) |
|
|
|
onInputChange(value, fromTokenString, fromTokenDecimals) |
|
|
|
onInputChange(value, fromTokenBalance) |
|
|
|
}} |
|
|
|
}} |
|
|
|
inputValue={inputValue} |
|
|
|
inputValue={inputValue} |
|
|
|
leftValue={inputValue && swapFromFiatValue} |
|
|
|
leftValue={inputValue && swapFromFiatValue} |
|
|
|