Skip to content

Commit 1fb7c02

Browse files
authored
fix: doubled toasts, receive address pre-selection (#777)
1 parent 828eed3 commit 1fb7c02

File tree

5 files changed

+13
-38
lines changed

5 files changed

+13
-38
lines changed
File renamed without changes.

apps/next/src/pages/Portfolio/components/PortfolioHome/components/PortolioDetails/components/PortfolioActionButtons.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import { useNextUnifiedBridgeContext } from '@/pages/Bridge/contexts';
3333
import { chainIdToCaip } from '@core/common';
3434
import { FaExplosion } from 'react-icons/fa6';
3535
import { NoScrollStack } from '@/components/NoScrollStack';
36+
import { getAddressTypeForToken } from '@/lib/getAddressTypeForToken';
3637

3738
const ICON_SIZE = 20;
3839

@@ -155,8 +156,15 @@ export const PortfolioActionButtons = ({
155156
icon={<QrCodeIcon size={ICON_SIZE} />}
156157
label={t('Receive')}
157158
onClick={() => {
158-
capture('TokenReceiveClicked', { addressType: 'C' });
159-
history.push(`/receive?accId=${activeAccount?.id}`);
159+
const addressType = token ? getAddressTypeForToken(token) : 'C';
160+
161+
capture('TokenReceiveClicked', { addressType });
162+
163+
const params = new URLSearchParams({
164+
addressType,
165+
accId: activeAccount?.id ?? '',
166+
});
167+
history.push(`/receive?${params.toString()}`);
160168
}}
161169
/>
162170
</OfflineTooltip>

apps/next/src/pages/Send/Send.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import { useTokensForAccount } from '@/hooks/useTokensForAccount';
3030
import { getAddressByType } from '@/utils/getAddressByType';
3131

3232
import { SendBody } from './components/SendBody';
33-
import { getAddressTypeForToken } from './lib/getAddressTypeForToken';
33+
import { getAddressTypeForToken } from '../../lib/getAddressTypeForToken';
3434

3535
const POLLED_BALANCES = [TokenType.NATIVE, TokenType.ERC20];
3636

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
1-
import { useHistory } from 'react-router-dom';
21
import { useTranslation } from 'react-i18next';
3-
import { ChevronRightIcon, IconButton, toast } from '@avalabs/k2-alpine';
2+
import { toast } from '@avalabs/k2-alpine';
43

54
import {
6-
getExplorerAddressByNetwork,
75
isMissingBtcWalletPolicyError,
86
isUserRejectionError,
9-
openNewTab,
107
} from '@core/common';
118
import { NetworkWithCaipId } from '@core/types';
129
import { useAnalyticsContext } from '@core/ui';
13-
import { useConfettiContext } from '@/components/Confetti';
1410

1511
const TOAST_ID = 'send-result';
1612

@@ -19,8 +15,6 @@ export const useTransactionCallbacks = (
1915
fromAddress?: string,
2016
) => {
2117
const { t } = useTranslation();
22-
const { replace } = useHistory();
23-
const { triggerConfetti } = useConfettiContext();
2418
const { captureEncrypted } = useAnalyticsContext();
2519

2620
return {
@@ -41,13 +35,6 @@ export const useTransactionCallbacks = (
4135
chainId: network?.chainId,
4236
});
4337
}
44-
// Redirect to home page
45-
replace('/');
46-
triggerConfetti();
47-
toast.success(t('Transaction successful'), {
48-
id: TOAST_ID,
49-
action: <ExplorerLink network={network} hash={hash} />,
50-
});
5138
},
5239
// When transaction could not be sent to the network or failed immediately
5340
onSendFailure: (err: unknown) => {
@@ -63,24 +50,3 @@ export const useTransactionCallbacks = (
6350
},
6451
};
6552
};
66-
67-
const ExplorerLink = ({
68-
network,
69-
hash,
70-
}: {
71-
network: NetworkWithCaipId;
72-
hash: string;
73-
}) => (
74-
<IconButton
75-
size="small"
76-
sx={{ color: 'background.default', padding: 0 }}
77-
onClick={() => {
78-
toast.dismiss(TOAST_ID);
79-
openNewTab({
80-
url: getExplorerAddressByNetwork(network, hash, 'tx'),
81-
});
82-
}}
83-
>
84-
<ChevronRightIcon size={18} />
85-
</IconButton>
86-
);

apps/next/src/utils/getChainLabelAndIconByAddressType.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export const getChainLabelAndIconByAddressType = memoize(
2424
Icon: AvalancheColorIcon,
2525
};
2626
case 'AVM':
27+
case 'PVM':
2728
return {
2829
label: 'Avalanche X/P-Chain',
2930
Icon: FixedXPChainIcon,

0 commit comments

Comments
 (0)