Skip to content

Commit dc56077

Browse files
authored
Revert "feat: add Add to wallet button, show USD amounts and fix small-number rounding" (#2708)
1 parent 4cf6366 commit dc56077

File tree

3 files changed

+28
-144
lines changed

3 files changed

+28
-144
lines changed

src/components/transactions/Switch/BaseSwitchModalContent.tsx

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -715,17 +715,6 @@ export const BaseSwitchModalContent = ({
715715
.multipliedBy(1 - safeSlippage)
716716
.decimalPlaces(switchRates.destDecimals, BigNumber.ROUND_UP)
717717
.toString()}
718-
amountUsd={Number(switchRates.srcUSD)}
719-
outAmountUSD={Number(
720-
switchRates.provider === 'cowprotocol' ? switchRates.destSpotInUsd : switchRates.destUSD
721-
)}
722-
addToken={{
723-
address: selectedOutputToken.aToken ?? selectedOutputToken.address,
724-
symbol: selectedOutputToken.symbol,
725-
decimals: selectedOutputToken.decimals,
726-
aToken: selectedOutputToken.aToken ? true : false,
727-
}}
728-
modalType={modalType}
729718
/>
730719
);
731720
}

src/components/transactions/Switch/SwitchTxSuccessView.tsx

Lines changed: 28 additions & 131 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
import { normalize } from '@aave/math-utils';
22
import { Trans } from '@lingui/macro';
3-
import { Box, Button, CircularProgress, Divider, Typography } from '@mui/material';
3+
import { Box, CircularProgress, Divider, Typography } from '@mui/material';
44
import { BigNumber } from 'ethers';
55
import { useEffect, useMemo, useRef, useState } from 'react';
6-
import { WalletIcon } from 'src/components/icons/WalletIcon';
76
import { DarkTooltip } from 'src/components/infoTooltips/DarkTooltip';
87
import { FormattedNumber } from 'src/components/primitives/FormattedNumber';
9-
import { Base64Token, ExternalTokenIcon, TokenIcon } from 'src/components/primitives/TokenIcon';
8+
import { ExternalTokenIcon } from 'src/components/primitives/TokenIcon';
109
import { TextWithTooltip, TextWithTooltipProps } from 'src/components/TextWithTooltip';
1110
import { useCowOrderToast } from 'src/hooks/useCowOrderToast';
12-
import { ModalType } from 'src/hooks/useModal';
13-
import { useWeb3Context } from 'src/libs/hooks/useWeb3Context';
14-
import { ERC20TokenType } from 'src/libs/web3-data-provider/Web3Provider';
1511
import { networkConfigs } from 'src/ui-config/networksConfig';
1612
import { parseUnits } from 'viem';
1713

@@ -42,10 +38,6 @@ export type SwitchTxSuccessViewProps = {
4238
chainId: number;
4339
destDecimals: number;
4440
srcDecimals: number;
45-
amountUsd: number;
46-
outAmountUSD: number;
47-
addToken?: ERC20TokenType;
48-
modalType: ModalType;
4941
};
5042

5143
export const SwitchWithSurplusTooltip = ({
@@ -91,14 +83,8 @@ export const SwitchTxSuccessView = ({
9183
chainId,
9284
destDecimals,
9385
srcDecimals,
94-
amountUsd,
95-
outAmountUSD,
96-
addToken,
97-
modalType,
9886
}: SwitchTxSuccessViewProps) => {
9987
const { trackOrder, setHasActiveOrders } = useCowOrderToast();
100-
const { addERC20Token } = useWeb3Context();
101-
const [base64, setBase64] = useState<string>('');
10288

10389
// Do polling each 10 seconds until the order get's filled
10490
const [orderStatus, setOrderStatus] = useState<'succeed' | 'failed' | 'open'>('open');
@@ -210,9 +196,6 @@ export const SwitchTxSuccessView = ({
210196
) : undefined;
211197
}, [provider, txHashOrOrderId]);
212198

213-
const shouldShowATokenCta = modalType === ModalType.CollateralSwap && addToken?.aToken;
214-
const watchedTokenSymbol = shouldShowATokenCta ? '' : addToken?.symbol ?? '';
215-
216199
return (
217200
<View
218201
txHash={txHashOrOrderId}
@@ -244,6 +227,7 @@ export const SwitchTxSuccessView = ({
244227
border: '1px solid',
245228
borderColor: 'divider',
246229
p: 3,
230+
mb: 4,
247231
width: '80%',
248232
}}
249233
>
@@ -273,40 +257,22 @@ export const SwitchTxSuccessView = ({
273257
enterTouchDelay={100}
274258
leaveTouchDelay={500}
275259
>
276-
<>
277-
<Box>
278-
<Typography fontWeight={600}>
279-
<FormattedNumber
280-
value={inAmount}
281-
variant="main14"
282-
visibleDecimals={4}
283-
compact={false}
284-
/>
285-
</Typography>
286-
</Box>
287-
</>
260+
<Box>
261+
<Typography fontWeight={600}>
262+
{Number(inAmount).toLocaleString(undefined, {
263+
minimumFractionDigits: 2,
264+
maximumFractionDigits: Number(inAmount) < 0.01 ? 4 : 2,
265+
})}{' '}
266+
</Typography>
267+
</Box>
288268
</DarkTooltip>
289-
290-
<Typography fontWeight={600}>{symbol}</Typography>
291-
</Box>
292-
</Box>
293-
{amountUsd && amountUsd > 0 && (
294-
<Box display="flex" justifyContent="flex-end" mb={'12px'}>
295-
<Typography>
296-
<FormattedNumber
297-
value={amountUsd}
298-
symbol="USD"
299-
symbolsColor="text.muted"
300-
variant="caption"
301-
color="text.muted"
302-
visibleDecimals={2}
303-
compact={false}
304-
/>
269+
<Typography fontWeight={600} sx={{ color: 'text.secondary' }}>
270+
{symbol}
305271
</Typography>
306272
</Box>
307-
)}
273+
</Box>
308274
<Divider sx={{ my: 1 }} />
309-
<Box display="flex" justifyContent="space-between" alignItems="center" mb={1} mt={'12px'}>
275+
<Box display="flex" justifyContent="space-between" alignItems="center" mb={0.5}>
310276
<Typography color="text.secondary">
311277
{provider == 'cowprotocol' && (orderStatus == 'open' || orderStatus == 'failed')
312278
? 'Receive'
@@ -331,100 +297,31 @@ export const SwitchTxSuccessView = ({
331297
enterTouchDelay={100}
332298
leaveTouchDelay={500}
333299
>
334-
<>
335-
<Box>
336-
<Typography fontWeight={600}>
337-
<FormattedNumber
338-
value={outFinalAmount}
339-
variant="main14"
340-
visibleDecimals={4}
341-
compact={false}
342-
/>
343-
</Typography>
344-
</Box>
345-
</>
300+
<Box>
301+
<Typography fontWeight={600}>
302+
{Number(outFinalAmount).toLocaleString(undefined, {
303+
minimumFractionDigits: 2,
304+
maximumFractionDigits: Number(outFinalAmount) < 0.01 ? 4 : 2,
305+
})}
306+
</Typography>
307+
</Box>
346308
</DarkTooltip>
347-
348-
<Typography fontWeight={600}>{outSymbol}</Typography>
349-
</Box>
350-
</Box>
351-
{outAmountUSD && outAmountUSD > 0 && (
352-
<Box display="flex" justifyContent="flex-end">
353-
<Typography>
354-
<FormattedNumber
355-
value={outAmountUSD}
356-
symbol="USD"
357-
symbolsColor="text.muted"
358-
variant="caption"
359-
color="text.muted"
360-
visibleDecimals={2}
361-
compact={false}
362-
/>
309+
<Typography fontWeight={600} sx={{ color: 'text.secondary' }}>
310+
{outSymbol}
363311
</Typography>
364312
</Box>
365-
)}
313+
</Box>
366314
{surplusDisplay && (
367315
<Typography
368316
variant="helperText"
369317
fontWeight={500}
370-
sx={{ float: 'right', color: 'text.secondary', mt: '4px' }}
318+
sx={{ float: 'right', color: 'text.secondary' }}
319+
mt={0.5}
371320
>
372321
{surplusDisplay}
373322
</Typography>
374323
)}
375324
</Box>
376-
{shouldShowATokenCta && (
377-
<Box
378-
sx={(theme) => ({
379-
border: theme.palette.mode === 'dark' ? `1px solid ${theme.palette.divider}` : 'none',
380-
background: theme.palette.mode === 'dark' ? 'none' : '#F7F7F9',
381-
borderRadius: 2,
382-
display: 'flex',
383-
flexDirection: 'column',
384-
alignItems: 'center',
385-
justifyContent: 'center',
386-
mt: 4,
387-
388-
width: '80%',
389-
})}
390-
>
391-
<TokenIcon
392-
symbol={addToken.symbol}
393-
aToken={addToken.aToken || false}
394-
sx={{ fontSize: '32px', mt: '12px', mb: '8px' }}
395-
/>
396-
<Typography variant="description" color="text.primary" sx={{ mx: '24px' }}>
397-
<Trans>
398-
Add {addToken.aToken ? 'aToken ' : 'token '} to wallet to track your balance.
399-
</Trans>
400-
</Typography>
401-
<Button
402-
onClick={() => {
403-
addERC20Token({
404-
address: addToken.address,
405-
decimals: addToken.decimals,
406-
symbol: watchedTokenSymbol,
407-
image: !/_/.test(addToken.symbol) ? base64 : undefined,
408-
});
409-
}}
410-
variant="outlined"
411-
size="medium"
412-
sx={{ mt: '8px', mb: '12px' }}
413-
>
414-
{addToken.symbol && !/_/.test(addToken.symbol) && (
415-
<Base64Token
416-
symbol={addToken.symbol}
417-
onImageGenerated={setBase64}
418-
aToken={addToken.aToken}
419-
/>
420-
)}
421-
<WalletIcon sx={{ width: '20px', height: '20px', mr: '4px' }} />
422-
<Typography variant="buttonM" ml="4px">
423-
<Trans>Add to wallet</Trans>
424-
</Typography>
425-
</Button>
426-
</Box>
427-
)}
428325
</View>
429326
);
430327
};

src/locales/en/messages.po

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,6 @@ msgid "All proposals"
639639
msgstr "All proposals"
640640

641641
#: src/components/transactions/FlowCommons/Success.tsx
642-
#: src/components/transactions/Switch/SwitchTxSuccessView.tsx
643642
msgid "Add to wallet"
644643
msgstr "Add to wallet"
645644

@@ -2194,7 +2193,6 @@ msgid "Interest rate rebalance conditions were not met"
21942193
msgstr "Interest rate rebalance conditions were not met"
21952194

21962195
#: src/components/transactions/FlowCommons/Success.tsx
2197-
#: src/components/transactions/Switch/SwitchTxSuccessView.tsx
21982196
msgid "Add {0} to wallet to track your balance."
21992197
msgstr "Add {0} to wallet to track your balance."
22002198

0 commit comments

Comments
 (0)