From ed12a0ca340bf1958e4c8331c5e8150ab2119418 Mon Sep 17 00:00:00 2001
From: songwongtp <16089160+songwongtp@users.noreply.github.com>
Date: Thu, 20 Jun 2024 15:17:56 +0700
Subject: [PATCH 1/5] fix: bugbash proposal lite
---
CHANGELOG.md | 1 +
.../components/VoteQuorumCircle.tsx | 3 ++-
.../proposal-overview/ProposalMessages.tsx | 2 +-
.../status-summary/SummaryStatusTime.tsx | 6 ++---
src/lib/services/proposal/lcd.ts | 4 +++-
src/lib/services/types/proposal.ts | 22 ++++++++++---------
6 files changed, 22 insertions(+), 16 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b00298145..f441fe8b2 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -101,6 +101,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Bug fixes
+- [#985](https://github.com/alleslabs/celatone-frontend/pull/985) Fix proposal details lite version bugs
- [#984](https://github.com/alleslabs/celatone-frontend/pull/984) Exclude non block number from searching block in lite
- [#974](https://github.com/alleslabs/celatone-frontend/pull/974) Fix tx by account addr lcd to support new cosmos sdk
- [#976](https://github.com/alleslabs/celatone-frontend/pull/976) Support save accounts in lite version
diff --git a/src/lib/pages/proposal-details/components/VoteQuorumCircle.tsx b/src/lib/pages/proposal-details/components/VoteQuorumCircle.tsx
index fcf778f39..1cee413ec 100644
--- a/src/lib/pages/proposal-details/components/VoteQuorumCircle.tsx
+++ b/src/lib/pages/proposal-details/components/VoteQuorumCircle.tsx
@@ -1,4 +1,5 @@
import { Circle, Heading, Text } from "@chakra-ui/react";
+import { isNull } from "lodash";
import type { Nullable, Ratio } from "lib/types";
import { formatPrettyPercent } from "lib/utils";
@@ -64,7 +65,7 @@ export const VoteQuorumCircle = ({
fontWeight={600}
color={totalRatio ? "text.main" : "text.dark"}
>
- {totalRatio ? formatPrettyPercent(totalRatio, 1) : "N/A"}
+ {!isNull(totalRatio) ? formatPrettyPercent(totalRatio, 1) : "N/A"}
diff --git a/src/lib/pages/proposal-details/components/proposal-overview/ProposalMessages.tsx b/src/lib/pages/proposal-details/components/proposal-overview/ProposalMessages.tsx
index b7dd4c5df..5a2999f77 100644
--- a/src/lib/pages/proposal-details/components/proposal-overview/ProposalMessages.tsx
+++ b/src/lib/pages/proposal-details/components/proposal-overview/ProposalMessages.tsx
@@ -69,7 +69,7 @@ export const ProposalMessages = ({ messages }: ProposalMessagesProps) => {
>
{messages.map((item, i) => (
diff --git a/src/lib/pages/proposal-details/components/proposal-overview/status-summary/SummaryStatusTime.tsx b/src/lib/pages/proposal-details/components/proposal-overview/status-summary/SummaryStatusTime.tsx
index 9290cf78b..0fd9a43aa 100644
--- a/src/lib/pages/proposal-details/components/proposal-overview/status-summary/SummaryStatusTime.tsx
+++ b/src/lib/pages/proposal-details/components/proposal-overview/status-summary/SummaryStatusTime.tsx
@@ -22,6 +22,8 @@ const getResolvedPrefix = (status: ProposalStatus) => {
};
export const SummaryStatusTime = ({ proposalData }: StatusTimeProps) => {
+ const endTime = proposalData.resolvedTimestamp ?? proposalData.votingEndTime;
+
if (proposalData.status === ProposalStatus.DEPOSIT_PERIOD)
return (
@@ -46,9 +48,7 @@ export const SummaryStatusTime = ({ proposalData }: StatusTimeProps) => {
{getResolvedPrefix(proposalData.status)}
{" at "}
- {proposalData.resolvedTimestamp
- ? formatUTC(proposalData.resolvedTimestamp)
- : "N/A"}
+ {endTime ? formatUTC(endTime) : "N/A"}
);
};
diff --git a/src/lib/services/proposal/lcd.ts b/src/lib/services/proposal/lcd.ts
index d06be8e36..d355f979b 100644
--- a/src/lib/services/proposal/lcd.ts
+++ b/src/lib/services/proposal/lcd.ts
@@ -89,4 +89,6 @@ export const getProposalVotesInfoLcd = async (
`${endpoint}/cosmos/gov/v1/proposals/${encodeURIComponent(id)}/tally`
),
axios.get(`${endpoint}/cosmos/staking/v1beta1/pool`),
- ]).then((data) => parseWithError(zProposalVotesInfoResponseLcd, data));
+ ]).then(([tallyRes, poolRes]) =>
+ parseWithError(zProposalVotesInfoResponseLcd, [tallyRes.data, poolRes.data])
+ );
diff --git a/src/lib/services/types/proposal.ts b/src/lib/services/types/proposal.ts
index d4959ca4d..82d8890dd 100644
--- a/src/lib/services/types/proposal.ts
+++ b/src/lib/services/types/proposal.ts
@@ -147,10 +147,12 @@ export const zProposalVotesInfoResponse = z
export const zProposalVotesInfoResponseLcd = z
.tuple([
z.object({
- yes_count: zBig,
- abstain_count: zBig,
- no_count: zBig,
- no_with_veto_count: zBig,
+ tally: z.object({
+ yes_count: zBig,
+ abstain_count: zBig,
+ no_count: zBig,
+ no_with_veto_count: zBig,
+ }),
}),
z.object({
pool: z.object({
@@ -160,10 +162,10 @@ export const zProposalVotesInfoResponseLcd = z
}),
])
.transform(([tally, pool]) => ({
- yes: tally.yes_count,
- abstain: tally.abstain_count,
- no: tally.no_count,
- noWithVeto: tally.no_with_veto_count,
+ yes: tally.tally.yes_count,
+ abstain: tally.tally.abstain_count,
+ no: tally.tally.no_count,
+ noWithVeto: tally.tally.no_with_veto_count,
totalVotingPower: pool.pool.bonded_tokens,
}));
@@ -232,8 +234,8 @@ export const zProposalDataResponseLcd = z
submit_time: zUtcDate,
deposit_end_time: zUtcDate,
total_deposit: zCoin.array(),
- voting_start_time: zUtcDate,
- voting_end_time: zUtcDate,
+ voting_start_time: zUtcDate.nullable(),
+ voting_end_time: zUtcDate.nullable(),
metadata: z.string(),
title: z.string(),
summary: z.string(),
From e98890cffe2449aeed9e4f6e831db2c402e095e8 Mon Sep 17 00:00:00 2001
From: songwongtp <16089160+songwongtp@users.noreply.github.com>
Date: Thu, 20 Jun 2024 15:44:54 +0700
Subject: [PATCH 2/5] fix: remove deposit tx
---
.../components/proposal-top/index.tsx | 3 +-
.../deposit-period/DepositPeriodSection.tsx | 1 +
.../DepositorsTableHeader.tsx | 10 ++-
.../depositors-table/DepositorsTableRow.tsx | 62 +++++++++++--------
.../deposit-period/depositors-table/index.tsx | 12 +++-
5 files changed, 55 insertions(+), 33 deletions(-)
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 cb9546b26..9db6bcc4a 100644
--- a/src/lib/pages/proposal-details/components/proposal-top/index.tsx
+++ b/src/lib/pages/proposal-details/components/proposal-top/index.tsx
@@ -71,7 +71,7 @@ export const ProposalTop = ({ proposalData }: ProposalTopProps) => {
{
fontWeight={500}
whiteSpace="nowrap"
lineHeight="24px"
+ mt="1px"
>
Proposal Messages:
diff --git a/src/lib/pages/proposal-details/components/vote-details/deposit-period/DepositPeriodSection.tsx b/src/lib/pages/proposal-details/components/vote-details/deposit-period/DepositPeriodSection.tsx
index 72fdc48a8..3abaefa5d 100644
--- a/src/lib/pages/proposal-details/components/vote-details/deposit-period/DepositPeriodSection.tsx
+++ b/src/lib/pages/proposal-details/components/vote-details/deposit-period/DepositPeriodSection.tsx
@@ -89,6 +89,7 @@ export const DepositPeriodSection = ({
>
diff --git a/src/lib/pages/proposal-details/components/vote-details/deposit-period/depositors-table/DepositorsTableHeader.tsx b/src/lib/pages/proposal-details/components/vote-details/deposit-period/depositors-table/DepositorsTableHeader.tsx
index e184ad635..d4d1f300a 100644
--- a/src/lib/pages/proposal-details/components/vote-details/deposit-period/depositors-table/DepositorsTableHeader.tsx
+++ b/src/lib/pages/proposal-details/components/vote-details/deposit-period/depositors-table/DepositorsTableHeader.tsx
@@ -5,15 +5,21 @@ import { TableHeader } from "lib/components/table";
interface DepositorsTableHeaderProps {
templateColumns: GridProps["templateColumns"];
+ showTransaction: boolean;
}
export const DepositorsTableHeader = ({
templateColumns,
+ showTransaction,
}: DepositorsTableHeaderProps) => (
Depositor
- Transaction Hash
- Timestamp
+ {showTransaction && (
+ <>
+ Transaction Hash
+ Timestamp
+ >
+ )}
Deposited Amount
);
diff --git a/src/lib/pages/proposal-details/components/vote-details/deposit-period/depositors-table/DepositorsTableRow.tsx b/src/lib/pages/proposal-details/components/vote-details/deposit-period/depositors-table/DepositorsTableRow.tsx
index f77f16a5f..96e74ef19 100644
--- a/src/lib/pages/proposal-details/components/vote-details/deposit-period/depositors-table/DepositorsTableRow.tsx
+++ b/src/lib/pages/proposal-details/components/vote-details/deposit-period/depositors-table/DepositorsTableRow.tsx
@@ -9,11 +9,13 @@ import { dateFromNow, formatUTC } from "lib/utils";
interface DepositorsTableRowProps {
proposalDeposit: ProposalDeposit;
templateColumns: string;
+ showTransaction: boolean;
}
export const DepositorsTableRow = ({
proposalDeposit,
templateColumns,
+ showTransaction,
}: DepositorsTableRowProps) => (
-
- {proposalDeposit.txHash ? (
-
- ) : (
-
- N/A
-
- )}
-
-
- {proposalDeposit.timestamp ? (
-
- {formatUTC(proposalDeposit.timestamp)}
-
- ({dateFromNow(proposalDeposit.timestamp)})
-
-
- ) : (
-
- N/A
-
- )}
-
+ {showTransaction && (
+ <>
+
+ {proposalDeposit.txHash ? (
+
+ ) : (
+
+ N/A
+
+ )}
+
+
+ {proposalDeposit.timestamp ? (
+
+
+ {formatUTC(proposalDeposit.timestamp)}
+
+
+ ({dateFromNow(proposalDeposit.timestamp)})
+
+
+ ) : (
+
+ N/A
+
+ )}
+
+ >
+ )}
diff --git a/src/lib/pages/proposal-details/components/vote-details/deposit-period/depositors-table/index.tsx b/src/lib/pages/proposal-details/components/vote-details/deposit-period/depositors-table/index.tsx
index f4599a6ad..312feed5f 100644
--- a/src/lib/pages/proposal-details/components/vote-details/deposit-period/depositors-table/index.tsx
+++ b/src/lib/pages/proposal-details/components/vote-details/deposit-period/depositors-table/index.tsx
@@ -10,16 +10,18 @@ import { DepositorsTableRow } from "./DepositorsTableRow";
interface DepositorsTableProps {
depositors: ProposalDeposit[];
isDepositsLoading: boolean;
+ showTransaction: boolean;
isPruned: boolean;
}
-const templateColumns = `1.5fr 1.5fr 2fr 1fr`;
-
export const DepositorsTable = ({
depositors,
isDepositsLoading,
+ showTransaction,
isPruned,
}: DepositorsTableProps) => {
+ const templateColumns = `1.5fr ${showTransaction ? "1.5fr 2fr " : ""}1fr`;
+
if (isDepositsLoading) return ;
if (isPruned)
@@ -32,12 +34,16 @@ export const DepositorsTable = ({
return (
-
+
{depositors.map((each) => (
))}
From 6a9229aaa416a50ec5b03ba59f606ef3a5c8ef9f Mon Sep 17 00:00:00 2001
From: songwongtp <16089160+songwongtp@users.noreply.github.com>
Date: Thu, 20 Jun 2024 16:55:43 +0700
Subject: [PATCH 3/5] fix: deposit table
---
.../deposit-period/depositors-table/DepositorsTableHeader.tsx | 2 +-
.../deposit-period/depositors-table/DepositorsTableRow.tsx | 2 +-
.../vote-details/deposit-period/depositors-table/index.tsx | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/lib/pages/proposal-details/components/vote-details/deposit-period/depositors-table/DepositorsTableHeader.tsx b/src/lib/pages/proposal-details/components/vote-details/deposit-period/depositors-table/DepositorsTableHeader.tsx
index d4d1f300a..d64b9065c 100644
--- a/src/lib/pages/proposal-details/components/vote-details/deposit-period/depositors-table/DepositorsTableHeader.tsx
+++ b/src/lib/pages/proposal-details/components/vote-details/deposit-period/depositors-table/DepositorsTableHeader.tsx
@@ -20,6 +20,6 @@ export const DepositorsTableHeader = ({
Timestamp
>
)}
- Deposited Amount
+ Deposited Amount
);
diff --git a/src/lib/pages/proposal-details/components/vote-details/deposit-period/depositors-table/DepositorsTableRow.tsx b/src/lib/pages/proposal-details/components/vote-details/deposit-period/depositors-table/DepositorsTableRow.tsx
index 96e74ef19..cf06c08fe 100644
--- a/src/lib/pages/proposal-details/components/vote-details/deposit-period/depositors-table/DepositorsTableRow.tsx
+++ b/src/lib/pages/proposal-details/components/vote-details/deposit-period/depositors-table/DepositorsTableRow.tsx
@@ -62,7 +62,7 @@ export const DepositorsTableRow = ({
>
)}
-
+
diff --git a/src/lib/pages/proposal-details/components/vote-details/deposit-period/depositors-table/index.tsx b/src/lib/pages/proposal-details/components/vote-details/deposit-period/depositors-table/index.tsx
index 312feed5f..0d78bd768 100644
--- a/src/lib/pages/proposal-details/components/vote-details/deposit-period/depositors-table/index.tsx
+++ b/src/lib/pages/proposal-details/components/vote-details/deposit-period/depositors-table/index.tsx
@@ -20,7 +20,7 @@ export const DepositorsTable = ({
showTransaction,
isPruned,
}: DepositorsTableProps) => {
- const templateColumns = `1.5fr ${showTransaction ? "1.5fr 2fr " : ""}1fr`;
+ const templateColumns = showTransaction ? "1.5fr 1.5fr 2fr 1fr" : "240px 1fr";
if (isDepositsLoading) return ;
From 5bd4d341d282c1d28ab8d2660e4d72cd6b8341b9 Mon Sep 17 00:00:00 2001
From: songwongtp <16089160+songwongtp@users.noreply.github.com>
Date: Thu, 20 Jun 2024 17:21:48 +0700
Subject: [PATCH 4/5] fix: add mt
---
.../pages/proposal-details/components/proposal-top/index.tsx | 2 +-
1 file changed, 1 insertion(+), 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 9db6bcc4a..e728af777 100644
--- a/src/lib/pages/proposal-details/components/proposal-top/index.tsx
+++ b/src/lib/pages/proposal-details/components/proposal-top/index.tsx
@@ -111,7 +111,7 @@ export const ProposalTop = ({ proposalData }: ProposalTopProps) => {
))}
) : (
-
+
(No Message)
)}
From 4d3a1612cce7c41c39c89938a1e06184b1005b29 Mon Sep 17 00:00:00 2001
From: songwongtp <16089160+songwongtp@users.noreply.github.com>
Date: Thu, 20 Jun 2024 17:41:02 +0700
Subject: [PATCH 5/5] fix: mt
---
.../pages/proposal-details/components/proposal-top/index.tsx | 2 +-
1 file changed, 1 insertion(+), 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 e728af777..3755e61a1 100644
--- a/src/lib/pages/proposal-details/components/proposal-top/index.tsx
+++ b/src/lib/pages/proposal-details/components/proposal-top/index.tsx
@@ -111,7 +111,7 @@ export const ProposalTop = ({ proposalData }: ProposalTopProps) => {
))}
) : (
-
+
(No Message)
)}