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

Commit e098d12

Browse files
authored
fix: avoid animations when rendering a historic receipt (#1128)
1 parent 4694ffe commit e098d12

File tree

5 files changed

+38
-6
lines changed

5 files changed

+38
-6
lines changed

lib/modules/pool/actions/add-liquidity/modal/AddLiquidityModal.tsx

+8-2
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,13 @@ export function AddLiquidityModal({
3535
}: Props & Omit<ModalProps, 'children'>) {
3636
const { isDesktop } = useBreakpoints()
3737
const initialFocusRef = useRef(null)
38-
const { transactionSteps, addLiquidityTxHash, hasQuoteContext, setInitialHumanAmountsIn } =
39-
useAddLiquidity()
38+
const {
39+
transactionSteps,
40+
addLiquidityTxHash,
41+
hasQuoteContext,
42+
urlTxHash,
43+
setInitialHumanAmountsIn,
44+
} = useAddLiquidity()
4045
const { pool, chain } = usePool()
4146
const { redirectToPoolPage } = usePoolRedirect(pool)
4247
const { userAddress } = useUserAccount()
@@ -101,6 +106,7 @@ export function AddLiquidityModal({
101106
currentStep={transactionSteps.currentStep}
102107
returnLabel="Return to pool"
103108
returnAction={redirectToPoolPage}
109+
urlTxHash={urlTxHash}
104110
/>
105111
</ModalContent>
106112
</Modal>

lib/modules/pool/actions/remove-liquidity/RemoveLiquidityProvider.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ export function _useRemoveLiquidity(urlTxHash?: Hash) {
254254
previewModalDisclosure,
255255
handler,
256256
wethIsEth,
257+
urlTxHash,
257258
removeLiquidityTxHash,
258259
hasQuoteContext,
259260
amountsOut,

lib/modules/pool/actions/remove-liquidity/modal/RemoveLiquidityModal.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ export function RemoveLiquidityModal({
3535
}: Props & Omit<ModalProps, 'children'>) {
3636
const { isDesktop } = useBreakpoints()
3737
const initialFocusRef = useRef(null)
38-
const { transactionSteps, removeLiquidityTxHash, hasQuoteContext } = useRemoveLiquidity()
38+
const { transactionSteps, removeLiquidityTxHash, urlTxHash, hasQuoteContext } =
39+
useRemoveLiquidity()
3940
const { pool, chain } = usePool()
4041
const { redirectToPoolPage } = usePoolRedirect(pool)
4142
const { userAddress } = useUserAccount()
@@ -99,6 +100,7 @@ export function RemoveLiquidityModal({
99100
currentStep={transactionSteps.currentStep}
100101
returnLabel="Return to pool"
101102
returnAction={redirectToPoolPage}
103+
urlTxHash={urlTxHash}
102104
/>
103105
</ModalContent>
104106
</Modal>

lib/modules/swap/modal/SwapModal.tsx

+10-2
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,15 @@ export function SwapPreviewModal({
3939
const { userAddress } = useUserAccount()
4040
const { stopTokenPricePolling } = useTokens()
4141

42-
const { transactionSteps, swapAction, isWrap, selectedChain, swapTxHash, hasQuoteContext } =
43-
useSwap()
42+
const {
43+
transactionSteps,
44+
swapAction,
45+
isWrap,
46+
selectedChain,
47+
swapTxHash,
48+
urlTxHash,
49+
hasQuoteContext,
50+
} = useSwap()
4451

4552
const swapReceipt = useSwapReceipt({
4653
txHash: swapTxHash,
@@ -97,6 +104,7 @@ export function SwapPreviewModal({
97104
currentStep={transactionSteps.currentStep}
98105
returnLabel="Swap again"
99106
returnAction={onClose}
107+
urlTxHash={urlTxHash}
100108
/>
101109
</ModalContent>
102110
</Modal>

lib/shared/components/modals/ActionModalFooter.tsx

+16-1
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,24 @@ type Props = {
4949
currentStep: TransactionStep
5050
returnLabel: string
5151
returnAction: () => void
52+
urlTxHash?: string
5253
}
5354

54-
export function ActionModalFooter({ isSuccess, currentStep, returnLabel, returnAction }: Props) {
55+
export function ActionModalFooter({
56+
isSuccess,
57+
currentStep,
58+
returnLabel,
59+
returnAction,
60+
urlTxHash,
61+
}: Props) {
62+
// Avoid animations when displaying a historic receipt
63+
if (urlTxHash) {
64+
return (
65+
<ModalFooter>
66+
<SuccessActions returnLabel={returnLabel} returnAction={returnAction} />
67+
</ModalFooter>
68+
)
69+
}
5570
return (
5671
<ModalFooter>
5772
<AnimatePresence mode="wait" initial={false}>

0 commit comments

Comments
 (0)