@@ -19,12 +19,13 @@ import { TradeAmounts } from 'common/types'
1919import { useDerivedTradeState } from './useDerivedTradeState'
2020import { useTradeState } from './useTradeState'
2121
22- import { ExtendedTradeRawState } from '../types/TradeRawState '
22+ import { ExtendedTradeRawState } from '../types'
2323
2424interface SetupTradeAmountsParams {
2525 onlySell ?: boolean
2626 onAmountsUpdate ?: ( amounts : TradeAmounts ) => void
2727}
28+
2829/**
2930 * Parse sell/buy amount from URL and apply to Limit orders widget
3031 * Example:
@@ -33,9 +34,7 @@ interface SetupTradeAmountsParams {
3334 * In case when both sellAmount and buyAmount specified, the price will be automatically calculated
3435 */
3536// TODO: Break down this large function into smaller functions
36- // TODO: Add proper return type annotation
37- // eslint-disable-next-line max-lines-per-function, @typescript-eslint/explicit-function-return-type
38- export function useSetupTradeAmountsFromUrl ( { onAmountsUpdate, onlySell } : SetupTradeAmountsParams ) {
37+ export function useSetupTradeAmountsFromUrl ( { onAmountsUpdate, onlySell } : SetupTradeAmountsParams ) : void {
3938 const navigate = useNavigate ( )
4039 const { search, pathname } = useLocation ( )
4140 const params = useMemo ( ( ) => new URLSearchParams ( search ) , [ search ] )
@@ -75,8 +74,8 @@ export function useSetupTradeAmountsFromUrl({ onAmountsUpdate, onlySell }: Setup
7574 const buyAmount = getIntOrFloat ( params . get ( TRADE_URL_BUY_AMOUNT_KEY ) )
7675 const update : Partial < Writeable < ExtendedTradeRawState > > = { }
7776
78- const isSellAmountValid = inputCurrency && sellAmount && + sellAmount >= 0
79- const isBuyAmountValid = outputCurrency && buyAmount && + buyAmount >= 0
77+ const isSellAmountValid = inputCurrency && sellAmount && + sellAmount > 0
78+ const isBuyAmountValid = outputCurrency && buyAmount && + buyAmount > 0
8079
8180 const sellCurrencyAmount = isSellAmountValid ? tryParseCurrencyAmount ( sellAmount , inputCurrency ) : null
8281 const buyCurrencyAmount = isBuyAmountValid ? tryParseCurrencyAmount ( buyAmount , outputCurrency ) : null
0 commit comments