diff --git a/frontend/src/core/hooks/useTxInfo.js b/frontend/src/core/hooks/useTxInfo.js new file mode 100644 index 00000000..77a9bef4 --- /dev/null +++ b/frontend/src/core/hooks/useTxInfo.js @@ -0,0 +1,21 @@ +import { useQuery } from "react-query"; +import { TxInfoService } from "../services"; +import { queryCacheProps } from "./hookCommon"; +import { useToast } from "."; + +const useTxInfo = (transaction) => { + const toast = useToast(); + const getTxInfo = async () => { + const data = await TxInfoService.getTxInfo(transaction); + return data; + } + const { data, isLoading, isFetchedAfterMount, refetch, isError, error } = + useQuery(["txinfo", {transaction}], getTxInfo, { + ...queryCacheProps, + onError: (error) => toast(error, "error"), + }); + + return { data, isFetchedAfterMount, isLoading, refetch, isError, error }; +} + +export default useTxInfo; \ No newline at end of file diff --git a/frontend/src/core/services/txinfo.service.js b/frontend/src/core/services/txinfo.service.js new file mode 100644 index 00000000..f4825b96 --- /dev/null +++ b/frontend/src/core/services/txinfo.service.js @@ -0,0 +1,11 @@ +import { http } from "../utils"; + +const API = process.env.NEXT_PUBLIC_MOONSTREAM_API_URL; + +export const getTxInfo = (tx) => { + http({ + method: "POST", + url: `${API}/txinfo/ethereum_blockchain`, + tx + }) +} \ No newline at end of file