forked from astroport-fi/astroport-classic-frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGovStakeNotification.tsx
41 lines (35 loc) · 1.07 KB
/
GovStakeNotification.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import React, { FC, useEffect } from "react";
import { TxInfo } from "@terra-money/terra.js";
import { Text } from "@chakra-ui/react";
import num from "libs/num";
import { useQueryClient } from "react-query";
import {
useContracts,
useTokenInfo,
handleTinyAmount,
getEventsByType,
} from "modules/common";
import { ONE_TOKEN } from "constants/constants";
type Props = {
txInfo: TxInfo;
};
const GovStakeNotification: FC<Props> = ({ txInfo }) => {
const queryClient = useQueryClient();
const { astroToken, xAstroToken } = useContracts();
const { getSymbol } = useTokenInfo();
const eventsByType = getEventsByType(txInfo);
const amount = eventsByType?.wasm.amount[0];
const displayAmount = handleTinyAmount(
num(amount).div(ONE_TOKEN).dp(6).toNumber()
);
useEffect(() => {
queryClient.invalidateQueries("balance");
queryClient.invalidateQueries("supply");
}, []);
return (
<Text textStyle={["small", "medium"]}>
Staked {displayAmount} {getSymbol(astroToken)} to {getSymbol(xAstroToken)}
</Text>
);
};
export default GovStakeNotification;