From 94573e03676b1da128a911446e4c3676756ed4ac Mon Sep 17 00:00:00 2001 From: plubber <51789398+ericHgorski@users.noreply.github.com> Date: Wed, 4 Dec 2024 10:14:20 -0500 Subject: [PATCH] [FRE-1260] Refactor SwapExecutionPage to use route data for asset denoms (#529) --- .changeset/dirty-bobcats-own.md | 5 +++++ .../SwapExecutionPage/SwapExecutionPageRouteDetailed.tsx | 3 ++- .../SwapExecutionPage/SwapExecutionPageRouteSimple.tsx | 8 +++----- packages/widget/src/utils/clientType.ts | 6 ++++++ 4 files changed, 16 insertions(+), 6 deletions(-) create mode 100644 .changeset/dirty-bobcats-own.md diff --git a/.changeset/dirty-bobcats-own.md b/.changeset/dirty-bobcats-own.md new file mode 100644 index 00000000..1b736d55 --- /dev/null +++ b/.changeset/dirty-bobcats-own.md @@ -0,0 +1,5 @@ +--- +'@skip-go/widget': patch +--- + +Refactor SwapExecutionPage to use route data for asset denoms diff --git a/packages/widget/src/pages/SwapExecutionPage/SwapExecutionPageRouteDetailed.tsx b/packages/widget/src/pages/SwapExecutionPage/SwapExecutionPageRouteDetailed.tsx index 2832d465..279a1657 100644 --- a/packages/widget/src/pages/SwapExecutionPage/SwapExecutionPageRouteDetailed.tsx +++ b/packages/widget/src/pages/SwapExecutionPage/SwapExecutionPageRouteDetailed.tsx @@ -51,7 +51,7 @@ export const SwapExecutionPageRouteDetailed = ({ operations, statusData, onClickEditDestinationWallet: _onClickEditDestinationWallet, - swapExecutionState + swapExecutionState, }: SwapExecutionPageRouteProps) => { const { data: swapVenues } = useAtomValue(skipSwapVenuesAtom); const { data: bridges } = useAtomValue(skipBridgesAtom); @@ -87,6 +87,7 @@ export const SwapExecutionPageRouteDetailed = ({ return _onClickEditDestinationWallet; }, [isSignRequired, chainAddresses, swapExecutionState, _onClickEditDestinationWallet]); + return ( diff --git a/packages/widget/src/pages/SwapExecutionPage/SwapExecutionPageRouteSimple.tsx b/packages/widget/src/pages/SwapExecutionPage/SwapExecutionPageRouteSimple.tsx index c5ea7e5e..70825058 100644 --- a/packages/widget/src/pages/SwapExecutionPage/SwapExecutionPageRouteSimple.tsx +++ b/packages/widget/src/pages/SwapExecutionPage/SwapExecutionPageRouteSimple.tsx @@ -21,7 +21,7 @@ export const SwapExecutionPageRouteSimple = ({ operations, statusData, onClickEditDestinationWallet: _onClickEditDestinationWallet, - swapExecutionState + swapExecutionState, }: SwapExecutionPageRouteProps) => { const theme = useTheme(); const { route } = useAtomValue(swapExecutionStateAtom); @@ -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, diff --git a/packages/widget/src/utils/clientType.ts b/packages/widget/src/utils/clientType.ts index 996fc9f9..88c38bf7 100644 --- a/packages/widget/src/utils/clientType.ts +++ b/packages/widget/src/utils/clientType.ts @@ -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