Skip to content

Commit

Permalink
Merge pull request #515 from soroswap/fix/hashOnSdexSwap
Browse files Browse the repository at this point in the history
🩹 Fix copy hash & view on explorer on SDEX swap
  • Loading branch information
chopan123 authored Aug 21, 2024
2 parents 625621f + 23bb85d commit 2161980
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/components/Swap/PendingModalContent/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ interface PendingModalContentProps {
revocationPending?: boolean;
}

interface SuccessfullSwapResponseWithSDEXHash extends SuccessfullSwapResponse {
hash: string;
}

interface ContentArgs {
step: PendingConfirmModalState;
approvalCurrency?: TokenType;
Expand All @@ -130,7 +134,7 @@ interface ContentArgs {
wrapPending: boolean;
tokenApprovalPending: boolean;
revocationPending: boolean;
swapResult?: SuccessfullSwapResponse; //SwapResult
swapResult?: SuccessfullSwapResponseWithSDEXHash; //SwapResult
chainId?: number;
order?: any; //UniswapXOrderDetails
}
Expand Down Expand Up @@ -188,7 +192,7 @@ function getContent(args: ContentArgs): PendingModalStep {
let label: React.ReactNode | null | string = null;

if (swapConfirmed && swapResult) {
label = <CopyTxHash txHash={swapResult?.txHash} />;
label = <CopyTxHash txHash={swapResult.txHash ? swapResult.txHash : swapResult.hash} />;
} else if (swapPending) {
label = `Proceed in your wallet`;
}
Expand Down
3 changes: 2 additions & 1 deletion src/hooks/useSwapCallback.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,8 @@ export function useSwapCallback(
trade.outputAmount?.value ?? '0',
)} ${trade?.outputAmount?.currency.code}`;
sendNotification(notificationMessage, 'Swapped', SnackbarIconType.SWAP, SnackbarContext);
return result!;
if (!result) throw new Error('Cannot create path payment')
return result;
} catch (error: any) {
console.error(error);
throw new Error('Cannot create path payment');
Expand Down

0 comments on commit 2161980

Please sign in to comment.