From d483a362ceaa7c6260af626e399a6038109a23ae Mon Sep 17 00:00:00 2001 From: songwongtp <16089160+songwongtp@users.noreply.github.com> Date: Fri, 16 Feb 2024 14:03:06 +0700 Subject: [PATCH 1/5] fix: expedited with params --- CHANGELOG.md | 1 + src/lib/components/Expedited.tsx | 103 +++++++++++++----- .../components/VoteThresholdBar.tsx | 4 +- src/lib/pages/proposal-details/utils.ts | 10 -- 4 files changed, 76 insertions(+), 42 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ad16c1a15..d157d35b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -77,6 +77,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Bug fixes +- [#792](https://github.com/alleslabs/celatone-frontend/pull/792) Expedited with network params - [#789](https://github.com/alleslabs/celatone-frontend/pull/789) Remove loading overlay on pool list page causing the page look like flicking - [#783](https://github.com/alleslabs/celatone-frontend/pull/783) Fix link used for Osmosis Pool JSON To poolmanager - [#780](https://github.com/alleslabs/celatone-frontend/pull/780) Fix proposal vote table, scroll to top on table diff --git a/src/lib/components/Expedited.tsx b/src/lib/components/Expedited.tsx index e4423319c..45db3ae59 100644 --- a/src/lib/components/Expedited.tsx +++ b/src/lib/components/Expedited.tsx @@ -1,38 +1,81 @@ -import { Flex, Text, Highlight } from "@chakra-ui/react"; +import { Flex, SkeletonText, Text } from "@chakra-ui/react"; + +import { useProposalParams } from "lib/services/proposalService"; +import type { Option } from "lib/types"; +import { formatPrettyPercent, formatSeconds } from "lib/utils"; import { CustomIcon } from "./icon"; import { Tooltip } from "./Tooltip"; -const ExpeditedText = ( - - - An expedited governance proposal is required to pass a high quorum - threshold of 66.6% within the first 24 hours of voting in order to pass. - - -); +const ExpeditedText = ({ + quorum, + threshold, + votingPeriod, + isLoading, +}: { + quorum: Option; + threshold: Option; + votingPeriod: Option; + isLoading: boolean; +}) => { + if (isLoading) + ; + + return ( + + An expedited governance proposal is required to{" "} + + pass a quorum of {quorum ? formatPrettyPercent(quorum, 1, true) : "N/A"}{" "} + and a high threshold of{" "} + {threshold ? formatPrettyPercent(threshold, 1, true) : "N/A"} within{" "} + {formatSeconds(votingPeriod)} voting period + {" "} + in order to pass. + + ); +}; interface ExpeditedProps { isActiveExpedited: boolean; } -export const Expedited = ({ isActiveExpedited }: ExpeditedProps) => ( - - - - - Expedited - - - -); + +export const Expedited = ({ isActiveExpedited }: ExpeditedProps) => { + const { data: params, isLoading } = useProposalParams(); + const quorum = params?.expeditedQuorum || params?.quorum; + const threshold = params?.expeditedThreshold || params?.threshold; + const votingPeriod = params?.expeditedVotingPeriod || params?.votingPeriod; + + return ( + + } + > + + + + Expedited + + + + ); +}; diff --git a/src/lib/pages/proposal-details/components/VoteThresholdBar.tsx b/src/lib/pages/proposal-details/components/VoteThresholdBar.tsx index ccebaaa8b..297d3423c 100644 --- a/src/lib/pages/proposal-details/components/VoteThresholdBar.tsx +++ b/src/lib/pages/proposal-details/components/VoteThresholdBar.tsx @@ -1,8 +1,8 @@ import { Flex, Text } from "@chakra-ui/react"; -import { formatPrettyPercent, normalizeVotesInfo } from "../utils"; +import { normalizeVotesInfo } from "../utils"; import type { ProposalVotesInfo } from "lib/types"; -import { divWithDefault } from "lib/utils"; +import { divWithDefault, formatPrettyPercent } from "lib/utils"; interface BarSectionProps { percent: string; diff --git a/src/lib/pages/proposal-details/utils.ts b/src/lib/pages/proposal-details/utils.ts index 7bde55d4a..4fb3250b2 100644 --- a/src/lib/pages/proposal-details/utils.ts +++ b/src/lib/pages/proposal-details/utils.ts @@ -89,13 +89,3 @@ export const getVoteResult = ( resultColor: "error.main", }; }; - -export const formatPrettyPercent = (ratio: number, fp = 2, fixedFp = false) => { - const lowestPercent = 10 ** -fp; - - const percent = ratio * 100; - if (percent > 0 && percent < lowestPercent) return `<${lowestPercent}%`; - - const rounded = big(percent).round(fp); - return `${fixedFp ? rounded.toFixed(fp) : rounded.toNumber()}%`; -}; From 8fec614803561e9fd533b4c62cb40ea4b691e94b Mon Sep 17 00:00:00 2001 From: songwongtp <16089160+songwongtp@users.noreply.github.com> Date: Fri, 16 Feb 2024 15:35:42 +0700 Subject: [PATCH 2/5] fix: expedited mobile --- .../table/proposals/ProposalsTableMobileCard.tsx | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/lib/components/table/proposals/ProposalsTableMobileCard.tsx b/src/lib/components/table/proposals/ProposalsTableMobileCard.tsx index f9671285f..9b33f6b05 100644 --- a/src/lib/components/table/proposals/ProposalsTableMobileCard.tsx +++ b/src/lib/components/table/proposals/ProposalsTableMobileCard.tsx @@ -3,6 +3,7 @@ import { Flex, Text } from "@chakra-ui/react"; import { MobileCardTemplate } from "../MobileCardTemplate"; import { MobileLabel } from "../MobileLabel"; import { useInternalNavigate } from "lib/app-provider"; +import { Expedited } from "lib/components/Expedited"; import { ExplorerLink } from "lib/components/ExplorerLink"; import type { Proposal } from "lib/types"; import { ProposalStatus } from "lib/types"; @@ -51,6 +52,17 @@ export const ProposalsTableMobileCard = ({ {proposal.title} + {proposal.isExpedited && ( + + + + )} {proposal.types.length ? ( proposal.types.map((msgType, index) => ( From a865f19f1ca3b29c49cbca1b0a8637c5aa97d421 Mon Sep 17 00:00:00 2001 From: songwongtp <16089160+songwongtp@users.noreply.github.com> Date: Fri, 16 Feb 2024 15:44:56 +0700 Subject: [PATCH 3/5] fix: expedited span --- src/lib/components/Expedited.tsx | 3 ++- .../proposal-details/components/proposal-top/index.tsx | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/lib/components/Expedited.tsx b/src/lib/components/Expedited.tsx index 45db3ae59..5aa2e8538 100644 --- a/src/lib/components/Expedited.tsx +++ b/src/lib/components/Expedited.tsx @@ -62,7 +62,7 @@ export const Expedited = ({ isActiveExpedited }: ExpeditedProps) => { /> } > - + { color={isActiveExpedited ? "accent.main" : "gray.400"} /> diff --git a/src/lib/pages/proposal-details/components/proposal-top/index.tsx b/src/lib/pages/proposal-details/components/proposal-top/index.tsx index 5bfeca15b..bfaeeb591 100644 --- a/src/lib/pages/proposal-details/components/proposal-top/index.tsx +++ b/src/lib/pages/proposal-details/components/proposal-top/index.tsx @@ -6,7 +6,7 @@ import { DotSeparator } from "lib/components/DotSeparator"; import { Expedited } from "lib/components/Expedited"; import { ExplorerLink } from "lib/components/ExplorerLink"; import { CustomIcon } from "lib/components/icon"; -import type { ProposalData } from "lib/types"; +import { ProposalStatus, type ProposalData } from "lib/types"; import { formatUTC, openNewTab } from "lib/utils"; import { ProposalInfo } from "./proposal-info"; @@ -22,6 +22,9 @@ export const ProposalTop = ({ proposalData }: ProposalTopProps) => { const openApiPage = () => openNewTab(`${endpoint}/${encodeURIComponent(proposalData.id)}/info`); + const isDepositOrVoting = + proposalData.status === ProposalStatus.DEPOSIT_PERIOD || + proposalData.status === ProposalStatus.VOTING_PERIOD; return ( { verticalAlign: "middle", }} > - + )} From ebac99f795114c18f91d711f9fa8b37da80bdf50 Mon Sep 17 00:00:00 2001 From: songwongtp <16089160+songwongtp@users.noreply.github.com> Date: Fri, 16 Feb 2024 15:48:33 +0700 Subject: [PATCH 4/5] fix: expedited span --- src/lib/pages/proposal-details/components/proposal-top/index.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/lib/pages/proposal-details/components/proposal-top/index.tsx b/src/lib/pages/proposal-details/components/proposal-top/index.tsx index bfaeeb591..50b34f4e4 100644 --- a/src/lib/pages/proposal-details/components/proposal-top/index.tsx +++ b/src/lib/pages/proposal-details/components/proposal-top/index.tsx @@ -60,7 +60,6 @@ export const ProposalTop = ({ proposalData }: ProposalTopProps) => { style={{ display: "inline-block", marginLeft: "8px", - marginBottom: "2px", verticalAlign: "middle", }} > From ae7296b48d5203953cddef1f55ac43b1b5bcdf21 Mon Sep 17 00:00:00 2001 From: songwongtp <16089160+songwongtp@users.noreply.github.com> Date: Sat, 17 Feb 2024 17:18:40 +0700 Subject: [PATCH 5/5] fix: mobile nav proposal --- src/lib/layout/mobile/NavDrawer.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/layout/mobile/NavDrawer.tsx b/src/lib/layout/mobile/NavDrawer.tsx index a9a355bc4..1404e8ee0 100644 --- a/src/lib/layout/mobile/NavDrawer.tsx +++ b/src/lib/layout/mobile/NavDrawer.tsx @@ -77,7 +77,7 @@ export const NavDrawer = () => { ...(govConfig.enabled ? [ { - name: "Proposal", + name: "Proposals", slug: "/proposals", icon: "proposal" as IconKeys, },