clawchain/dex-app/components/notifications/TransactionStarted.tsx
2026-05-15 19:18:10 +03:00

53 lines
989 B
TypeScript

import { FC, useCallback } from "react";
import { useClawDEX } from "modules/common";
import useTxInfo from "hooks/useTxInfo";
type Props = {
onClose: () => void;
txHash: string;
txType?: string;
data?: any;
};
const TransactionStarted: FC<Props> = ({ onClose, txHash, txType, data }) => {
const { addNotification } = useClawDEX();
const handleSuccess = useCallback(
(_, txInfo) => {
addNotification({
notification: {
type: "succeed",
txHash,
txInfo,
txType,
data,
},
});
onClose();
},
[txHash]
);
const handleError = useCallback(
(_, txInfo) => {
addNotification({
notification: {
type: "failed",
txInfo,
txHash,
txType,
},
});
onClose();
},
[txHash]
);
useTxInfo({ txHash, onSuccess: handleSuccess, onError: handleError });
return null;
};
export default TransactionStarted;