Skip to content

Commit

Permalink
Handle transaction submitted
Browse files Browse the repository at this point in the history
  • Loading branch information
davidcoderistov committed Oct 17, 2022
1 parent 25c191c commit 3c64386
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/components/SwapInterface/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export default function SwapInterface ({ onConnectWallet }: SwapInterfaceProps)
const [toToken, setToToken] = useState<Token | null>(null)
const [fromBalance, setFromBalance, trySetFromBalance] = useBalance()
const [toBalance, setToBalance, trySetToBalance] = useBalance()
const [swapInfo, swapDetails, tryFetchSwapDetails, tryFetchSwapDetailsDebounced] = useSwapDetails()
const [swapInfo, swapDetails, tryFetchSwapDetails, tryFetchSwapDetailsDebounced, setSwapDetailsOpen] = useSwapDetails()
const [currToken, setCurrToken] = useState<'from' | 'to'>('from')

const handleSelectToken = (token: Token) => {
Expand Down Expand Up @@ -180,6 +180,19 @@ export default function SwapInterface ({ onConnectWallet }: SwapInterfaceProps)
setSwapOpen(false)
}

const handleTransactionSubmitted = () => {
setSelectTokenOpen(false)
setSwapDetailsOpen(false)
setType('from')
setFromToken(null)
setToToken(null)
setFromBalance(undefined)
setToBalance(undefined)
setCurrToken('from')
setFromInputValue('')
setToInputValue('')
}

const hasInputValue = (inputValue: string) => {
return inputValue.trim().length > 0 && parseFloat(inputValue) > 0
}
Expand Down Expand Up @@ -267,6 +280,7 @@ export default function SwapInterface ({ onConnectWallet }: SwapInterfaceProps)
slippage: swapDetails?.slippage ?? '',
minimum: swapDetails?.minimumReceived ?? '',
}}
onTransactionSubmitted={handleTransactionSubmitted}
onClose={handleCloseSwapModal} />
</Box>
)
Expand Down

0 comments on commit 3c64386

Please sign in to comment.