Skip to content

Commit

Permalink
🩹 Fix copy hash & view on explorer on SDEX swap
Browse files Browse the repository at this point in the history
  • Loading branch information
MattPoblete committed Aug 14, 2024
1 parent 95c44b2 commit 23bb85d
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 @@ -229,7 +229,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);
// If error comes from throw new Error("Try increasing slippage"); throw that error
Expand Down

0 comments on commit 23bb85d

Please sign in to comment.