Commit 3aaa3fef authored by Moody Salem's avatar Moody Salem

fix: wrap/unwrap should not show computed trade details

parent bc243e1c
...@@ -33,11 +33,13 @@ export default function useWrapCallback( ...@@ -33,11 +33,13 @@ export default function useWrapCallback(
return useMemo(() => { return useMemo(() => {
if (!wethContract || !chainId || !inputCurrency || !outputCurrency) return NOT_APPLICABLE if (!wethContract || !chainId || !inputCurrency || !outputCurrency) return NOT_APPLICABLE
const weth = WETH9[chainId]
if (!weth) return NOT_APPLICABLE
const hasInputAmount = Boolean(inputAmount?.greaterThan('0')) const hasInputAmount = Boolean(inputAmount?.greaterThan('0'))
const sufficientBalance = inputAmount && balance && !balance.lessThan(inputAmount) const sufficientBalance = inputAmount && balance && !balance.lessThan(inputAmount)
if (inputCurrency.isNative && outputCurrency.equals(WETH9[chainId])) { if (inputCurrency.isNative && weth.equals(outputCurrency)) {
return { return {
wrapType: WrapType.WRAP, wrapType: WrapType.WRAP,
execute: execute:
...@@ -53,7 +55,7 @@ export default function useWrapCallback( ...@@ -53,7 +55,7 @@ export default function useWrapCallback(
: undefined, : undefined,
inputError: sufficientBalance ? undefined : hasInputAmount ? 'Insufficient ETH balance' : 'Enter ETH amount', inputError: sufficientBalance ? undefined : hasInputAmount ? 'Insufficient ETH balance' : 'Enter ETH amount',
} }
} else if (WETH9[chainId].equals(inputCurrency) && outputCurrency.isNative) { } else if (weth.equals(inputCurrency) && outputCurrency.isNative) {
return { return {
wrapType: WrapType.UNWRAP, wrapType: WrapType.UNWRAP,
execute: execute:
......
...@@ -122,6 +122,7 @@ export default function Swap({ history }: RouteComponentProps) { ...@@ -122,6 +122,7 @@ export default function Swap({ history }: RouteComponentProps) {
inputError: wrapInputError, inputError: wrapInputError,
} = useWrapCallback(currencies[Field.INPUT], currencies[Field.OUTPUT], typedValue) } = useWrapCallback(currencies[Field.INPUT], currencies[Field.OUTPUT], typedValue)
const showWrap: boolean = wrapType !== WrapType.NOT_APPLICABLE const showWrap: boolean = wrapType !== WrapType.NOT_APPLICABLE
console.log(showWrap)
const { address: recipientAddress } = useENSAddress(recipient) const { address: recipientAddress } = useENSAddress(recipient)
const parsedAmounts = useMemo( const parsedAmounts = useMemo(
...@@ -428,6 +429,7 @@ export default function Swap({ history }: RouteComponentProps) { ...@@ -428,6 +429,7 @@ export default function Swap({ history }: RouteComponentProps) {
</> </>
) : null} ) : null}
{showWrap ? null : (
<Row style={{ justifyContent: !trade ? 'center' : 'space-between' }}> <Row style={{ justifyContent: !trade ? 'center' : 'space-between' }}>
<RowFixed> <RowFixed>
{[V3TradeState.VALID, V3TradeState.SYNCING, V3TradeState.NO_ROUTE_FOUND].includes(v3TradeState) && {[V3TradeState.VALID, V3TradeState.SYNCING, V3TradeState.NO_ROUTE_FOUND].includes(v3TradeState) &&
...@@ -492,6 +494,7 @@ export default function Swap({ history }: RouteComponentProps) { ...@@ -492,6 +494,7 @@ export default function Swap({ history }: RouteComponentProps) {
</RowFixed> </RowFixed>
) : null} ) : null}
</Row> </Row>
)}
<BottomGrouping> <BottomGrouping>
{swapIsUnsupported ? ( {swapIsUnsupported ? (
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment