Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CFE-37] Feature: current bonded token link #833

Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Features

- [#833](https://github.com/alleslabs/celatone-frontend/pull/833) Add link to transactions page to current bonded token component
- [#832](https://github.com/alleslabs/celatone-frontend/pull/832) Add bonded token changes delegation related transactions
- [#831](https://github.com/alleslabs/celatone-frontend/pull/831) Update zod schema to apply with new validator delegation related txs api spec
- [#828](https://github.com/alleslabs/celatone-frontend/pull/828) Add validator detail voting power overview section with data from APIs
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { Box, Flex, Heading, Text } from "@chakra-ui/react";
import { Box, Button, Flex, Heading, Text } from "@chakra-ui/react";
import type { BigSource } from "big.js";
import type { ScriptableContext, TooltipModel } from "chart.js";

import { useInternalNavigate } from "lib/app-provider";
import { LineChart } from "lib/components/chart/LineChart";
import { CustomIcon } from "lib/components/icon";
import { Loading } from "lib/components/Loading";
import { ErrorFetching } from "lib/components/state";
import { useValidatorHistoricalPowers } from "lib/services/validatorService";
Expand All @@ -17,13 +19,17 @@ interface VotingPowerChartProps {
validatorAddress: ValidatorAddr;
singleStakingDenom: Option<string>;
assetInfos: Option<AssetInfos>;
isOverview?: boolean;
}

export const VotingPowerChart = ({
validatorAddress,
singleStakingDenom,
assetInfos,
isOverview,
}: VotingPowerChartProps) => {
const navigate = useInternalNavigate();

const { data: historicalPowers, isLoading } =
useValidatorHistoricalPowers(validatorAddress);

Expand Down Expand Up @@ -115,27 +121,52 @@ export const VotingPowerChart = ({
rounded={8}
w="100%"
>
<Flex gap={2} direction="column" w={250} minW={250}>
<Heading variant="h6">
{singleStakingDenom
? "Current Bonded Token"
: "Current Voting Powers"}
</Heading>
<Heading variant="h5" fontWeight={600}>
{currentPrice} {currency}
</Heading>
<Text variant="body1">
<Text
as="span"
fontWeight={700}
color={diffInLast24Hr >= 0 ? "success.main" : "error.main"}
>
{diffInLast24Hr >= 0
? `+${handleFormatValue(diffInLast24Hr)}`
: `-${handleFormatValue(-diffInLast24Hr)}`}
</Text>{" "}
{currency} in last 24 hr
</Text>
<Flex gap={6} direction="column" w={250} minW={250}>
<Flex gap={2} direction="column">
<Heading variant="h6">
{singleStakingDenom
? "Current Bonded Token"
: "Current Voting Powers"}
</Heading>
<Heading variant="h5" fontWeight={600}>
{currentPrice} {currency}
</Heading>
<Text variant="body1">
<Text
as="span"
fontWeight={700}
color={diffInLast24Hr >= 0 ? "success.main" : "error.main"}
>
{diffInLast24Hr >= 0
? `+${handleFormatValue(diffInLast24Hr)}`
: `-${handleFormatValue(-diffInLast24Hr)}`}
</Text>{" "}
{currency} in last 24 hr
</Text>
</Flex>
{isOverview && (
<Box>
Poafs1 marked this conversation as resolved.
Show resolved Hide resolved
<Button
variant="ghost-secondary"
p="unset"
size="md"
pl={2}
onClick={() =>
navigate({
pathname: "/validators/[validatorAddress]/[tab]",
query: {
validatorAddress,
tab: "bonded-token-changes",
},
options: { shallow: true },
})
}
>
See all related transactions
<CustomIcon name="chevron-right" boxSize={3} />
</Button>
</Box>
)}
</Flex>
<Box w="100%" h="272px" id="voting-power-chart-container">
<LineChart
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export const ValidatorOverview = ({
validatorAddress={validatorAddress}
singleStakingDenom={singleStakingDenom}
assetInfos={assetInfos}
isOverview
/>
</>
)}
Expand Down