Skip to content

Commit

Permalink
[FRE-1260] Refactor SwapExecutionPage to use route data for asset den…
Browse files Browse the repository at this point in the history
…oms (#529)
  • Loading branch information
ericHgorski authored Dec 4, 2024
1 parent e0bc1a7 commit 94573e0
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/dirty-bobcats-own.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@skip-go/widget': patch
---

Refactor SwapExecutionPage to use route data for asset denoms
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const SwapExecutionPageRouteDetailed = ({
operations,
statusData,
onClickEditDestinationWallet: _onClickEditDestinationWallet,
swapExecutionState
swapExecutionState,
}: SwapExecutionPageRouteProps) => {
const { data: swapVenues } = useAtomValue(skipSwapVenuesAtom);
const { data: bridges } = useAtomValue(skipBridgesAtom);
Expand Down Expand Up @@ -87,6 +87,7 @@ export const SwapExecutionPageRouteDetailed = ({
return _onClickEditDestinationWallet;
}, [isSignRequired, chainAddresses, swapExecutionState, _onClickEditDestinationWallet]);


return (
<StyledSwapExecutionPageRoute>
<Column>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const SwapExecutionPageRouteSimple = ({
operations,
statusData,
onClickEditDestinationWallet: _onClickEditDestinationWallet,
swapExecutionState
swapExecutionState,
}: SwapExecutionPageRouteProps) => {
const theme = useTheme();
const { route } = useAtomValue(swapExecutionStateAtom);
Expand All @@ -33,17 +33,15 @@ export const SwapExecutionPageRouteSimple = ({
const sourceStatus = swapExecutionState === SwapExecutionState.confirmed ? "completed" : status?.[firstOperation.transferIndex]?.status;
const destinationStatus = swapExecutionState === SwapExecutionState.confirmed ? "completed" : status?.[lastOperation.transferIndex]?.status;

const sourceDenom = firstOperation.denomIn;
const destinationDenom = lastOperation.denomOut;

const source = {
denom: sourceDenom,
denom: firstOperation.denomIn,
tokenAmount: firstOperation.amountIn,
chainId: firstOperation.fromChainID ?? firstOperation.chainID,
usdValue: route?.usdAmountIn,
};
const destination = {
denom: destinationDenom,
denom: lastOperation.denomOut,
tokenAmount: lastOperation.amountOut,
chainId: lastOperation.toChainID ?? lastOperation.chainID,
usdValue: route?.usdAmountOut,
Expand Down
6 changes: 6 additions & 0 deletions packages/widget/src/utils/clientType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,12 @@ function getOperationDetailsAndType(operation: SkipClientOperation) {
operationDetails as EvmSwap
).fromChainID;
break;
// special case needed for axelar transfers where the source denom is not the first operation denom
case OperationType.axelarTransfer:
(operationDetails as Transfer).denomIn = (
operationDetails as AxelarTransfer
).ibcTransferToAxelar?.denomIn ?? (operationDetails as Transfer).denomIn;
break;
case OperationType.bankSend:
(operationDetails as Transfer).denomIn = (
operationDetails as BankSend
Expand Down

0 comments on commit 94573e0

Please sign in to comment.