Skip to content

Commit

Permalink
Fix swaps core logic lint errors (#38)
Browse files Browse the repository at this point in the history
Fix lint errors in the swaps core logic PR, #25
  • Loading branch information
Gudahtt authored and danjm committed Oct 6, 2020
1 parent 829444e commit 596fd0f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 8 deletions.
22 changes: 16 additions & 6 deletions ui/app/pages/swaps/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,23 @@ export default function Swap () {
}

const clearTemporaryTokenRef = useRef()
useEffect(() => {
clearTemporaryTokenRef.current = () => {
if (destinationTokenAddedForSwap && (!isAwaitingSwapRoute || conversionError)) {
dispatch(removeToken(destinationTokenInfo?.address))
useEffect(
() => {
clearTemporaryTokenRef.current = () => {
if (destinationTokenAddedForSwap && (!isAwaitingSwapRoute || conversionError)) {
dispatch(removeToken(destinationTokenInfo?.address))
}
}
}
}, [fetchParams, destinationTokenAddedForSwap, conversionError, dispatch, isAwaitingSwapRoute])
},
[
conversionError,
dispatch,
destinationTokenAddedForSwap,
destinationTokenInfo,
fetchParams,
isAwaitingSwapRoute,
],
)
useEffect(() => {
return () => {
clearTemporaryTokenRef.current()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React, { useState, useEffect, useRef } from 'react'
import PropTypes from 'prop-types'
import Fuse from 'fuse.js'
import InputAdornment from '@material-ui/core/InputAdornment'
import { usePrevious } from '../../../../hooks/usePrevious'
import TextField from '../../../../components/ui/text-field'
import { usePrevious } from '../../../../hooks/usePrevious'

Expand Down
10 changes: 9 additions & 1 deletion ui/app/pages/swaps/swaps.util.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,15 @@ const QUOTE_VALIDATORS = [
{
property: 'approvalNeeded',
type: 'object',
validator: (approvalTx) => approvalTx === null || approvalTx && validHex(approvalTx.data) && isValidAddress(approvalTx.to) && isValidAddress(approvalTx.from),
validator: (approvalTx) => (
approvalTx === null ||
(
approvalTx &&
validHex(approvalTx.data) &&
isValidAddress(approvalTx.to) &&
isValidAddress(approvalTx.from)
)
),
},
{
property: 'sourceAmount',
Expand Down

0 comments on commit 596fd0f

Please sign in to comment.