From bdf7701198f8eaad9443dce4b375279deaa00d2d Mon Sep 17 00:00:00 2001 From: Peiman <25097709+Rickk137@users.noreply.github.com> Date: Wed, 11 Oct 2023 16:13:11 +0300 Subject: [PATCH] SOV-3010: Individual Proposal page (#583) * SOV-2922: voting proposals page (#552) * SOV-2922: voting proposals page * Create proud-rivers-give.md * chore: added changes from comments * chore: remove condition for past proposals * chore: added tooltip + added view button * chore: update proposal link + new proposal btn * feat: ProposalPage added * Create pink-buckets-rhyme.md * feat: update proposal page * feat: vote query * feat: resolve PR comments * feat: update cast vote in proposal * update proposal query * fix: mobile view * update gql * fix: proposal result issue * fix: show loading on proposal page * fix: cast vote error message * SOV-3009: voting actions (#597) * SOV-3009: voting actions * Create yellow-tips-sip.md * chore: fixes from comments * chore: update proposal status * chore: update proposal status * chore: update from comments * fix: proposal execution --------- Co-authored-by: Victor Creed * fix: execution eta * SOV-3196: add voting tooltips to Voting proposals page (#603) * SOV-3196: add voting tooltips to Voting proposals page * Create angry-mails-enjoy.md * chore: force deployment * chore: force deployment --------- Co-authored-by: Victor Creed <69458664+creed-victor@users.noreply.github.com> * SOV-3211-3207: Bitocracy proposal issues (#614) * fix: bitocracy proposal title * Create many-fishes-hang.md * fix: define title limit * fix: update proposal title * SOV-3195: add voting power section (#600) * SOV-3195: add voting power section * chore: add a tooltip for VP * chore: refactoring * Create giant-ducks-laugh.md * chore: updates from comments * fix: proposal status hook * chore: remove hrefExternal in view proposal button --------- Co-authored-by: Victor Creed * SOV-3225: Proposal row click (#625) * Fix individual proposal opening * Fix review remarks * Change title tooltip trigger to hover * Create fresh-goats-begin.md * SOV-3011: Voting - Proposal CSV export (#627) * SOV-3011: add CSV export * chore: update text in proposal CSV file * SOV-3239: Support/Reject button in Cast your vote (#616) * feat: support reject proposal * Create olive-olives-obey.md * fix: refetch when voting is done * fix: casting issue * fix: hide when loading * fix: resolve PR comments * fix: casting vote issue * chore: increase gas limit --------- Co-authored-by: Victor Creed <69458664+creed-victor@users.noreply.github.com> --------- Co-authored-by: Pietro Maximoff <74987028+pietro-maximoff@users.noreply.github.com> Co-authored-by: Victor Creed Co-authored-by: Victor Creed <69458664+creed-victor@users.noreply.github.com> Co-authored-by: tiltom --- .../ProposalVotingResults/index.tsx | 141 ------------------ .../5_pages/BitocracyPage/BitocracyPage.tsx | 24 --- .../ProposalStatus/ProposalStatus.tsx | 2 +- 3 files changed, 1 insertion(+), 166 deletions(-) delete mode 100644 apps/frontend/src/app/3_organisms/ProposalVotingResults/index.tsx diff --git a/apps/frontend/src/app/3_organisms/ProposalVotingResults/index.tsx b/apps/frontend/src/app/3_organisms/ProposalVotingResults/index.tsx deleted file mode 100644 index 90f4420f6..000000000 --- a/apps/frontend/src/app/3_organisms/ProposalVotingResults/index.tsx +++ /dev/null @@ -1,141 +0,0 @@ -import React, { FC, useMemo } from 'react'; - -import { t } from 'i18next'; - -import { - Bar, - Button, - ButtonStyle, - HelperButton, - Paragraph, - ParagraphSize, -} from '@sovryn/ui'; -import { Decimal } from '@sovryn/utils'; - -import { useBlockNumber } from '../../../hooks/useBlockNumber'; -import { translations } from '../../../locales/i18n'; -import { Proposal } from '../../../utils/graphql/rsk/generated'; -import { decimalic, formatValue } from '../../../utils/math'; - -export type ProposalVotingResultsProps = { - proposal: Proposal; - onExportCSV?: () => void; -}; - -export const ProposalVotingResults: FC = ({ - proposal, - onExportCSV, -}) => { - const currentBlock = useBlockNumber().value; - const { votesFor, votesAgainst, endBlock, emittedBy, quorum } = proposal; - const { majorityPercentageVotes, quorumPercentageVotes } = emittedBy; - - const { support, turnout, votes } = useMemo(() => { - const votes = Decimal.fromBigNumberString(votesFor).add( - Decimal.fromBigNumberString(votesAgainst), - ); - - const support = Decimal.fromBigNumberString(votesFor) - .div(votes) - .mul(100) - .toNumber(); - - const turnout = votes - .div( - Decimal.fromBigNumberString(quorum).div( - decimalic(quorumPercentageVotes).div(100), - ), - ) - .mul(100) - .toNumber(); - - return { - votes, - support, - turnout, - }; - }, [quorum, quorumPercentageVotes, votesAgainst, votesFor]); - - return ( -
-
- - {t(translations.proposalVotingResults.title)} - - {currentBlock < endBlock ? ( - - {t(translations.proposalVotingResults.inProgress)} - - ) : ( -
- -
-
- {t(translations.proposalVotingResults.support.title)}{' '} - - - {t(translations.proposalVotingResults.support.required)} - - - {t(translations.proposalVotingResults.support.requiredValue, { - value: formatValue(majorityPercentageVotes, 3), - })} - - - {t(translations.proposalVotingResults.support.current)} - - - {t(translations.proposalVotingResults.support.currentValue, { - value: formatValue(support, 3), - })} - - - } - /> -
- -
- -
-
- {t(translations.proposalVotingResults.quorum.title)}{' '} - - - {t(translations.proposalVotingResults.quorum.required)} - - - {t(translations.proposalVotingResults.quorum.requiredValue, { - value: formatValue(Decimal.fromBigNumberString(quorum), 4), - percent: formatValue(quorumPercentageVotes, 3), - })} - - - {t(translations.proposalVotingResults.quorum.current)} - - - {t(translations.proposalVotingResults.quorum.currentValue, { - value: formatValue(votes, 4), - percent: formatValue(turnout, 3), - })} - - - } - /> -
- -
-
- ); -}; diff --git a/apps/frontend/src/app/5_pages/BitocracyPage/BitocracyPage.tsx b/apps/frontend/src/app/5_pages/BitocracyPage/BitocracyPage.tsx index 6a2ac07c0..772b81aab 100644 --- a/apps/frontend/src/app/5_pages/BitocracyPage/BitocracyPage.tsx +++ b/apps/frontend/src/app/5_pages/BitocracyPage/BitocracyPage.tsx @@ -11,36 +11,17 @@ import { ParagraphSize, } from '@sovryn/ui'; -import { ProposalVotingResults } from '../../3_organisms/ProposalVotingResults'; import { useAccount } from '../../../hooks/useAccount'; -import { translations } from '../../../locales/i18n'; import { sharedState } from '../../../store/rxjs/shared-state'; import { useGetPersonalStakingStatistics } from '../StakePage/components/PersonalStakingStatistics/hooks/useGetPersonalStakingStatistics'; import { Proposals } from './components/Proposals/Proposals'; import { useGetProposals } from './hooks/useGetProposals'; -import { Proposal } from '../../../utils/graphql/rsk/generated'; // TODO: This is just a temporary solution until we merge new proposal PR. const isNewProposalEnabled = false; const pageTranslations = translations.bitocracyPage; -// DUMMY DATA, REMOVE WHEN REAL DATA IS AVAILABLE -const proposal = { - id: '0x6496df39d000478a7a7352c01e0e713835051ccd-32', - votesFor: '25642394317449679336562867', - votesAgainst: '9204395962492958076500991', - endBlock: 5505959, - startBlock: 5505952, - quorum: '20928484835262004265672060', - majorityPercentage: '73249696923417014929852210', - emittedBy: { - id: '0x6496df39d000478a7a7352c01e0e713835051ccd', - majorityPercentageVotes: 70, - quorumPercentageVotes: 20, - }, -} as Proposal; - const BitocracyPage: FC = () => { const { account } = useAccount(); const { votingPower } = useGetPersonalStakingStatistics(); @@ -92,11 +73,6 @@ const BitocracyPage: FC = () => { )} - -
- -
-
); diff --git a/apps/frontend/src/app/5_pages/BitocracyPage/components/ProposalStatus/ProposalStatus.tsx b/apps/frontend/src/app/5_pages/BitocracyPage/components/ProposalStatus/ProposalStatus.tsx index a698973a7..7669fe857 100644 --- a/apps/frontend/src/app/5_pages/BitocracyPage/components/ProposalStatus/ProposalStatus.tsx +++ b/apps/frontend/src/app/5_pages/BitocracyPage/components/ProposalStatus/ProposalStatus.tsx @@ -1,4 +1,4 @@ -import React, { FC, useMemo } from 'react'; +import React, { FC } from 'react'; import classNames from 'classnames'; import { t } from 'i18next';