Skip to content
This repository was archived by the owner on Oct 15, 2024. It is now read-only.

fix: receipt animations #1128

Merged
merged 1 commit into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,13 @@ export function AddLiquidityModal({
}: Props & Omit<ModalProps, 'children'>) {
const { isDesktop } = useBreakpoints()
const initialFocusRef = useRef(null)
const { transactionSteps, addLiquidityTxHash, hasQuoteContext, setInitialHumanAmountsIn } =
useAddLiquidity()
const {
transactionSteps,
addLiquidityTxHash,
hasQuoteContext,
urlTxHash,
setInitialHumanAmountsIn,
} = useAddLiquidity()
const { pool, chain } = usePool()
const { redirectToPoolPage } = usePoolRedirect(pool)
const { userAddress } = useUserAccount()
Expand Down Expand Up @@ -101,6 +106,7 @@ export function AddLiquidityModal({
currentStep={transactionSteps.currentStep}
returnLabel="Return to pool"
returnAction={redirectToPoolPage}
urlTxHash={urlTxHash}
/>
</ModalContent>
</Modal>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ export function _useRemoveLiquidity(urlTxHash?: Hash) {
previewModalDisclosure,
handler,
wethIsEth,
urlTxHash,
removeLiquidityTxHash,
hasQuoteContext,
amountsOut,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ export function RemoveLiquidityModal({
}: Props & Omit<ModalProps, 'children'>) {
const { isDesktop } = useBreakpoints()
const initialFocusRef = useRef(null)
const { transactionSteps, removeLiquidityTxHash, hasQuoteContext } = useRemoveLiquidity()
const { transactionSteps, removeLiquidityTxHash, urlTxHash, hasQuoteContext } =
useRemoveLiquidity()
const { pool, chain } = usePool()
const { redirectToPoolPage } = usePoolRedirect(pool)
const { userAddress } = useUserAccount()
Expand Down Expand Up @@ -99,6 +100,7 @@ export function RemoveLiquidityModal({
currentStep={transactionSteps.currentStep}
returnLabel="Return to pool"
returnAction={redirectToPoolPage}
urlTxHash={urlTxHash}
/>
</ModalContent>
</Modal>
Expand Down
12 changes: 10 additions & 2 deletions lib/modules/swap/modal/SwapModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,15 @@ export function SwapPreviewModal({
const { userAddress } = useUserAccount()
const { stopTokenPricePolling } = useTokens()

const { transactionSteps, swapAction, isWrap, selectedChain, swapTxHash, hasQuoteContext } =
useSwap()
const {
transactionSteps,
swapAction,
isWrap,
selectedChain,
swapTxHash,
urlTxHash,
hasQuoteContext,
} = useSwap()

const swapReceipt = useSwapReceipt({
txHash: swapTxHash,
Expand Down Expand Up @@ -97,6 +104,7 @@ export function SwapPreviewModal({
currentStep={transactionSteps.currentStep}
returnLabel="Swap again"
returnAction={onClose}
urlTxHash={urlTxHash}
/>
</ModalContent>
</Modal>
Expand Down
17 changes: 16 additions & 1 deletion lib/shared/components/modals/ActionModalFooter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,24 @@ type Props = {
currentStep: TransactionStep
returnLabel: string
returnAction: () => void
urlTxHash?: string
}

export function ActionModalFooter({ isSuccess, currentStep, returnLabel, returnAction }: Props) {
export function ActionModalFooter({
isSuccess,
currentStep,
returnLabel,
returnAction,
urlTxHash,
}: Props) {
// Avoid animations when displaying a historic receipt
if (urlTxHash) {
return (
<ModalFooter>
<SuccessActions returnLabel={returnLabel} returnAction={returnAction} />
</ModalFooter>
)
}
return (
<ModalFooter>
<AnimatePresence mode="wait" initial={false}>
Expand Down
Loading