From 174571455006805af4e113ff0c73b6d6a2211c21 Mon Sep 17 00:00:00 2001 From: GoldWolf <144475973+GoldWolf115@users.noreply.github.com> Date: Tue, 24 Oct 2023 02:02:50 -0700 Subject: [PATCH] Fix past elections total staked value (#4578) * fix/past-election#4090 * fix/past_elections --- .../src/app/pages/Election/PastElections/PastElections.tsx | 5 +++-- .../components/election/pastElection/PastElectionTabs.tsx | 2 +- .../PastElectionsList/PastElectionsListRow.tsx | 3 ++- .../council/queries/__generated__/council.generated.tsx | 5 +++-- packages/ui/src/council/queries/council.graphql | 1 + packages/ui/src/council/types/PastElection.ts | 7 ++++--- 6 files changed, 14 insertions(+), 9 deletions(-) diff --git a/packages/ui/src/app/pages/Election/PastElections/PastElections.tsx b/packages/ui/src/app/pages/Election/PastElections/PastElections.tsx index 06e10b778a..34a371dd2b 100644 --- a/packages/ui/src/app/pages/Election/PastElections/PastElections.tsx +++ b/packages/ui/src/app/pages/Election/PastElections/PastElections.tsx @@ -49,7 +49,8 @@ export const PastElections = () => { Round Election ended at - Total staked + Total Candidates staked + Total Votes staked Revealed votes Total candidates @@ -65,7 +66,7 @@ export const PastElections = () => { return } -export const PastElectionsColLayout = '48px 176px 156px 100px 100px' +export const PastElectionsColLayout = '48px 176px 140px 140px 100px 100px' const PastElectionsListHeaders = styled(ListHeaders)` grid-column-gap: 24px; diff --git a/packages/ui/src/council/components/election/pastElection/PastElectionTabs.tsx b/packages/ui/src/council/components/election/pastElection/PastElectionTabs.tsx index 1390d92b78..6c72c49062 100644 --- a/packages/ui/src/council/components/election/pastElection/PastElectionTabs.tsx +++ b/packages/ui/src/council/components/election/pastElection/PastElectionTabs.tsx @@ -62,7 +62,7 @@ export const PastElectionTabs = ({ election }: PastElectionTabsProps) => { revealed: !!myVote, member: votingResult.candidate.member, sumOfAllStakes: votingResult.totalStake, - totalStake: election.totalStake, + totalStake: election.totalVoteStake, votes: votingResult.votes.length, index: index + 1, myVotes: [], diff --git a/packages/ui/src/council/components/election/pastElection/PastElectionsList/PastElectionsListRow.tsx b/packages/ui/src/council/components/election/pastElection/PastElectionsList/PastElectionsListRow.tsx index 7db781f159..a12d25081e 100644 --- a/packages/ui/src/council/components/election/pastElection/PastElectionsList/PastElectionsListRow.tsx +++ b/packages/ui/src/council/components/election/pastElection/PastElectionsList/PastElectionsListRow.tsx @@ -29,7 +29,8 @@ export const PastElectionsListRow = ({ election }: PastElectionsListRowProps) => ) : ( <> )} - + + diff --git a/packages/ui/src/council/queries/__generated__/council.generated.tsx b/packages/ui/src/council/queries/__generated__/council.generated.tsx index b912f0ad1e..8186b0f3e5 100644 --- a/packages/ui/src/council/queries/__generated__/council.generated.tsx +++ b/packages/ui/src/council/queries/__generated__/council.generated.tsx @@ -394,7 +394,7 @@ export type PastElectionRoundFieldsFragment = { endedAtTime?: any | null endedAtNetwork?: Types.Network | null candidates: Array<{ __typename: 'Candidate'; stake: string }> - castVotes: Array<{ __typename: 'CastVote'; voteForId?: string | null }> + castVotes: Array<{ __typename: 'CastVote'; voteForId?: string | null; stake: string }> } export type PastElectionRoundDetailedFieldsFragment = { @@ -1132,7 +1132,7 @@ export type GetPastElectionsQuery = { endedAtTime?: any | null endedAtNetwork?: Types.Network | null candidates: Array<{ __typename: 'Candidate'; stake: string }> - castVotes: Array<{ __typename: 'CastVote'; voteForId?: string | null }> + castVotes: Array<{ __typename: 'CastVote'; voteForId?: string | null; stake: string }> }> } @@ -1635,6 +1635,7 @@ export const PastElectionRoundFieldsFragmentDoc = gql` } castVotes { voteForId + stake } } ` diff --git a/packages/ui/src/council/queries/council.graphql b/packages/ui/src/council/queries/council.graphql index 2ff730dbfb..641c6aed20 100644 --- a/packages/ui/src/council/queries/council.graphql +++ b/packages/ui/src/council/queries/council.graphql @@ -116,6 +116,7 @@ fragment PastElectionRoundFields on ElectionRound { } castVotes { voteForId + stake } } diff --git a/packages/ui/src/council/types/PastElection.ts b/packages/ui/src/council/types/PastElection.ts index 4faa5c584c..c39c134f3a 100644 --- a/packages/ui/src/council/types/PastElection.ts +++ b/packages/ui/src/council/types/PastElection.ts @@ -16,10 +16,11 @@ export interface PastElection { id: string cycleId: number finishedAtBlock?: Block - totalStake: BN + totalCandidatesStake: BN totalCandidates: number revealedVotes: number totalVotes: number + totalVoteStake: BN } export interface PastElectionWithDetails extends PastElection { @@ -30,17 +31,17 @@ export const asPastElection = (fields: PastElectionRoundFieldsFragment): PastEle id: fields.id, cycleId: fields.cycleId, finishedAtBlock: maybeAsBlock(fields.endedAtBlock, fields.endedAtTime, fields.endedAtNetwork), - totalStake: sumStakes(fields.candidates), + totalCandidatesStake: sumStakes(fields.candidates), totalCandidates: fields.candidates.length, revealedVotes: fields.castVotes.filter((castVote) => castVote.voteForId).length, totalVotes: fields.castVotes.length, + totalVoteStake: sumStakes(fields.castVotes), }) export const asPastElectionWithDetails = ( fields: PastElectionRoundDetailedFieldsFragment ): PastElectionWithDetails => ({ ...asPastElection(fields), - totalStake: sumStakes(fields.castVotes), votingResults: fields.candidates.map((candidate) => { const candidateVotes = fields.castVotes.filter(({ voteForId }) => voteForId === candidate.id)