Skip to content

Commit

Permalink
fix: replace missing return value from swap callback (Uniswap#574)
Browse files Browse the repository at this point in the history
  • Loading branch information
just-toby authored Apr 5, 2023
1 parent c60952f commit 1ccd497
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/components/Swap/SwapActionButton/SwapButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import { useUniversalRouterSwapCallback } from 'hooks/useUniversalRouter'
import { useAtomValue } from 'jotai/utils'
import { useCallback, useEffect, useState } from 'react'
import { feeOptionsAtom, Field, swapEventHandlersAtom } from 'state/swap'
import { TransactionType } from 'state/transactions'
import invariant from 'tiny-invariant'

import ActionButton from '../../ActionButton'
import { SummaryDialog } from '../Summary'
Expand Down Expand Up @@ -77,6 +79,16 @@ export default function SwapButton({ disabled }: { disabled: boolean }) {
response.response.wait(1).then((receipt) => {
setOldestValidBlock(receipt.blockNumber)
})

invariant(trade)
// onSubmit expects the TransactionInfo to be returned if the transaction was submitted.
return {
type: TransactionType.SWAP,
response: response.response,
tradeType: trade.tradeType,
trade,
slippageTolerance: slippage.allowed,
}
})

// Only close the review modal if the swap submitted (ie no-throw).
Expand All @@ -86,7 +98,7 @@ export default function SwapButton({ disabled }: { disabled: boolean }) {
} catch (e) {
throwAsync(e)
}
}, [onSubmit, setOldestValidBlock, swapCallback, throwAsync])
}, [onSubmit, setOldestValidBlock, slippage.allowed, swapCallback, throwAsync, trade])

const onReviewSwapClick = useConditionalHandler(useAtomValue(swapEventHandlersAtom).onReviewSwapClick)
const collapseToolbar = useCollapseToolbar()
Expand Down

0 comments on commit 1ccd497

Please sign in to comment.