From 8eeb60ddcab8f9be8b4ff76231a24434346b57e9 Mon Sep 17 00:00:00 2001
From: gomes <17035424+gomesalexandre@users.noreply.github.com>
Date: Wed, 8 Jan 2025 01:56:43 +0400
Subject: [PATCH 1/2] feat: new swapper flow rate changed modal (#8497)
---
.../components/StepperStep.tsx | 1 -
.../TradeConfirm/ExpandedStepperSteps.tsx | 34 ++++++++++++++++++-
2 files changed, 33 insertions(+), 2 deletions(-)
diff --git a/src/components/MultiHopTrade/components/MultiHopTradeConfirm/components/StepperStep.tsx b/src/components/MultiHopTrade/components/MultiHopTradeConfirm/components/StepperStep.tsx
index 17b08dd0659..f50744a2b55 100644
--- a/src/components/MultiHopTrade/components/MultiHopTradeConfirm/components/StepperStep.tsx
+++ b/src/components/MultiHopTrade/components/MultiHopTradeConfirm/components/StepperStep.tsx
@@ -133,7 +133,6 @@ export const StepperStep = ({
{button}
- {/* {!isLastStep && } */}
)
}
diff --git a/src/components/MultiHopTrade/components/TradeConfirm/ExpandedStepperSteps.tsx b/src/components/MultiHopTrade/components/TradeConfirm/ExpandedStepperSteps.tsx
index 624a48824b4..0db4b809a5f 100644
--- a/src/components/MultiHopTrade/components/TradeConfirm/ExpandedStepperSteps.tsx
+++ b/src/components/MultiHopTrade/components/TradeConfirm/ExpandedStepperSteps.tsx
@@ -8,14 +8,16 @@ import {
StepStatus,
Tag,
Tooltip,
+ usePrevious,
VStack,
} from '@chakra-ui/react'
import type { TradeQuote, TradeRate } from '@shapeshiftoss/swapper'
-import { useMemo } from 'react'
+import { useEffect, useMemo } from 'react'
import { FaInfoCircle } from 'react-icons/fa'
import { useTranslate } from 'react-polyglot'
import { RawText, Text } from 'components/Text'
import { getChainAdapterManager } from 'context/PluginProvider/chainAdapterSingleton'
+import { useModal } from 'hooks/useModal/useModal'
import {
selectFirstHopSellAccountId,
selectSecondHopSellAccountId,
@@ -44,6 +46,7 @@ type ExpandedStepperStepsProps = {
export const ExpandedStepperSteps = ({ activeTradeQuote }: ExpandedStepperStepsProps) => {
const translate = useTranslate()
+ const rateChanged = useModal('rateChanged')
// this is the account we're selling from - assume this is the AccountId of the approval Tx
const firstHopSellAccountId = useAppSelector(selectFirstHopSellAccountId)
const lastHopSellAccountId = useAppSelector(selectSecondHopSellAccountId)
@@ -363,6 +366,35 @@ export const ExpandedStepperSteps = ({ activeTradeQuote }: ExpandedStepperStepsP
])
const { tradeSteps, currentTradeStep } = useStepperSteps()
+
+ const firstHopAmountCryptoBaseUnit = useMemo(
+ () => tradeQuoteFirstHop.buyAmountAfterFeesCryptoBaseUnit,
+ [tradeQuoteFirstHop.buyAmountAfterFeesCryptoBaseUnit],
+ )
+ const prevFirstHopAmountCryptoBaseUnit = usePrevious(firstHopAmountCryptoBaseUnit)
+
+ useEffect(() => {
+ if (currentTradeStep !== StepperStep.FirstHopSwap) return
+
+ if (
+ !(
+ firstHopAmountCryptoBaseUnit &&
+ prevFirstHopAmountCryptoBaseUnit &&
+ firstHopAmountCryptoBaseUnit !== '0' &&
+ prevFirstHopAmountCryptoBaseUnit !== '0'
+ )
+ )
+ return
+ if (firstHopAmountCryptoBaseUnit === prevFirstHopAmountCryptoBaseUnit) return
+
+ rateChanged.open({ prevAmountCryptoBaseUnit: prevFirstHopAmountCryptoBaseUnit })
+ }, [
+ currentTradeStep,
+ firstHopAmountCryptoBaseUnit,
+ prevFirstHopAmountCryptoBaseUnit,
+ rateChanged,
+ ])
+
const isError = activeQuoteError || transactionExecutionStateError
return (
From b8fd619d305552a630c48145ed91ecb507882c82 Mon Sep 17 00:00:00 2001
From: gomes <17035424+gomesalexandre@users.noreply.github.com>
Date: Wed, 8 Jan 2025 01:59:24 +0400
Subject: [PATCH 2/2] fix: new swapper flow cow buy Tx links (#8496)
---
.../components/TradeConfirm/ExpandedStepperSteps.tsx | 1 +
.../MultiHopTrade/components/TradeConfirm/TxLabel.tsx | 4 +++-
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/components/MultiHopTrade/components/TradeConfirm/ExpandedStepperSteps.tsx b/src/components/MultiHopTrade/components/TradeConfirm/ExpandedStepperSteps.tsx
index 0db4b809a5f..c724cca2d8f 100644
--- a/src/components/MultiHopTrade/components/TradeConfirm/ExpandedStepperSteps.tsx
+++ b/src/components/MultiHopTrade/components/TradeConfirm/ExpandedStepperSteps.tsx
@@ -251,6 +251,7 @@ export const ExpandedStepperSteps = ({ activeTradeQuote }: ExpandedStepperStepsP
)}
{firstHopSwap.buyTxHash && firstHopSwap.buyTxHash !== firstHopSwap.sellTxHash && (
{
const { data: maybeSafeTx } = useSafeTxQuery({
maybeSafeTxHash: txHash,
@@ -24,9 +26,9 @@ export const TxLabel = ({
const txLink = getTxLink({
defaultExplorerBaseUrl: explorerBaseUrl,
maybeSafeTx,
- tradeId: txHash,
accountId,
name: swapperName,
+ ...(isBuyTxHash ? { txId: txHash } : { tradeId: txHash }),
})
return txLink ? (