Skip to content

Commit

Permalink
fix: use execution token if present
Browse files Browse the repository at this point in the history
  • Loading branch information
chybisov committed Nov 8, 2022
1 parent b96ec48 commit 4e71609
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 47 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 @@ -121,7 +121,7 @@ export const StepDetailsContent: React.FC<{ step: Step }> = ({ step }) => {
{t('format.number', {
value: formatTokenAmount(
step.execution?.toAmount ?? step.estimate.toAmount,
step.action.toToken.decimals,
step.execution?.toToken?.decimals ?? step.action.toToken.decimals,
),
})}{' '}
{step.action.toToken.symbol}
Expand Down
44 changes: 21 additions & 23 deletions packages/widget/src/pages/SwapDetailsPage/SwapDetailsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,29 +83,27 @@ export const SwapDetailsPage: React.FC = () => {
}).format(startedAt)}
</Typography>
</Box>
{routeExecution?.route.steps.map((step, index, steps) => (
<Fragment key={step.id}>
<Step
step={step}
fromToken={
index === 0
? { ...step.action.fromToken, amount: step.action.fromAmount }
: undefined
}
toToken={
index === steps.length - 1
? {
...step.action.toToken,
amount: step.execution?.toAmount ?? step.estimate.toAmount,
}
: undefined
}
/>
{steps.length > 1 && index !== steps.length - 1 ? (
<StepDivider />
) : null}
</Fragment>
))}
{routeExecution?.route.steps.map((step, index, steps) => {
const fromToken =
index === 0
? { ...step.action.fromToken, amount: step.action.fromAmount }
: undefined;
const toToken =
index === steps.length - 1
? {
...(step.execution?.toToken ?? step.action?.toToken),
amount: step.execution?.toAmount ?? step.estimate.toAmount,
}
: undefined;
return (
<Fragment key={step.id}>
<Step step={step} fromToken={fromToken} toToken={toToken} />
{steps.length > 1 && index !== steps.length - 1 ? (
<StepDivider />
) : null}
</Fragment>
);
})}
<Card mt={2}>
<Box
sx={{
Expand Down
44 changes: 21 additions & 23 deletions packages/widget/src/pages/SwapPage/SwapPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,29 +67,27 @@ export const SwapPage: React.FC = () => {

return (
<Container>
{route?.steps.map((step, index, steps) => (
<Fragment key={step.id}>
<Step
step={step}
fromToken={
index === 0
? { ...step.action.fromToken, amount: step.action.fromAmount }
: undefined
}
toToken={
index === steps.length - 1
? {
...step.action.toToken,
amount: step.execution?.toAmount ?? step.estimate.toAmount,
}
: undefined
}
/>
{steps.length > 1 && index !== steps.length - 1 ? (
<StepDivider />
) : null}
</Fragment>
))}
{route?.steps.map((step, index, steps) => {
const fromToken =
index === 0
? { ...step.action.fromToken, amount: step.action.fromAmount }
: undefined;
const toToken =
index === steps.length - 1
? {
...(step.execution?.toToken ?? step.action?.toToken),
amount: step.execution?.toAmount ?? step.estimate.toAmount,
}
: undefined;
return (
<Fragment key={step.id}>
<Step step={step} fromToken={fromToken} toToken={toToken} />
{steps.length > 1 && index !== steps.length - 1 ? (
<StepDivider />
) : null}
</Fragment>
);
})}
{status === 'idle' || status === 'error' ? (
<>
<GasSufficiencyMessage route={route} mt={2} />
Expand Down

0 comments on commit 4e71609

Please sign in to comment.