Skip to content

Commit

Permalink
fix: use toToken from execution if present
Browse files Browse the repository at this point in the history
  • Loading branch information
chybisov committed Nov 9, 2022
1 parent 519c253 commit 3afa3e5
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 29 deletions.
2 changes: 1 addition & 1 deletion packages/widget/src/components/StepActions/StepActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export const StepDetailsContent: React.FC<{ step: Step }> = ({ step }) => {
step.execution?.toToken?.decimals ?? step.action.toToken.decimals,
),
})}{' '}
{step.action.toToken.symbol}
{step.execution?.toToken?.symbol ?? step.action.toToken.symbol}
</Typography>
);
};
Expand Down
22 changes: 7 additions & 15 deletions packages/widget/src/pages/SwapHistoryPage/SwapHistoryItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ export const SwapHistoryItem: React.FC<{
const startedAt = new Date(
route.steps[0].execution?.process[0].startedAt ?? 0,
);
const fromToken = { ...route.fromToken, amount: route.fromAmount };
const toToken = {
...(route.steps.at(-1)?.execution?.toToken ?? route.toToken),
amount: route.steps.at(-1)?.execution?.toAmount ?? route.toAmount,
};
return (
<Card onClick={handleClick}>
<Box
Expand All @@ -45,22 +50,9 @@ export const SwapHistoryItem: React.FC<{
</Typography>
</Box>
<Box py={1}>
<Token
token={{ ...route.fromToken, amount: route.fromAmount }}
px={2}
pt={1}
connected
/>
<Token token={fromToken} px={2} pt={1} connected />
<TokenDivider />
<Token
token={{
...route.toToken,
amount: route.steps.at(-1)?.execution?.toAmount ?? route.toAmount,
}}
px={2}
pt={0.5}
pb={1}
/>
<Token token={toToken} px={2} pt={0.5} pb={1} />
</Box>
</Card>
);
Expand Down
25 changes: 12 additions & 13 deletions packages/widget/src/pages/SwapPage/StatusBottomSheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,17 @@ export const StatusBottomSheet: React.FC<RouteExecution> = ({
const ref = useRef<BottomSheetBase>(null);
const { getChainById } = useChains();
const { setValue } = useFormContext();

const toToken = {
...(route.steps.at(-1)?.execution?.toToken ?? route.toToken),
amount:
route.steps.at(-1)?.execution?.toAmount ??
route.steps.at(-1)?.estimate.toAmount ??
route.toAmount,
};

const { token, refetch, refetchNewBalance, refetchAllBalances } =
useTokenBalance(route.toToken, route.toAddress);
useTokenBalance(toToken, route.toAddress);

const clearFromAmount = () => {
refetchAllBalances();
Expand Down Expand Up @@ -114,17 +123,7 @@ export const StatusBottomSheet: React.FC<RouteExecution> = ({
{title}
</Typography>
{status === 'success' ? (
<Token
token={{
...route.toToken,
amount:
route.steps.at(-1)?.execution?.toAmount ??
route.steps.at(-1)?.estimate.toAmount ??
route.toAmount,
}}
py={1}
disableDescription
/>
<Token token={toToken} py={1} disableDescription />
) : null}
</IconContainer>
<Typography py={1}>{message}</Typography>
Expand All @@ -141,7 +140,7 @@ export const StatusBottomSheet: React.FC<RouteExecution> = ({
</Box>
{status === 'success' ? (
<Box mt={2}>
<Button variant="text" fullWidth onClick={handleSeeDetails}>
<Button variant="text" onClick={handleSeeDetails} fullWidth>
{t('button.seeDetails')}
</Button>
</Box>
Expand Down

0 comments on commit 3afa3e5

Please sign in to comment.