-
Notifications
You must be signed in to change notification settings - Fork 26
Full Transparency to Voting History feature to be implemented within the Livepeer Explorer #300
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
Closed
Closed
Changes from all commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
78021a1
init setup
liamdoyle95 157d853
Intergration
liamdoyle95 1979dbd
Test data is fetching and renders
liamdoyle95 77bda06
Temp limit to fetches and updated UI
liamdoyle95 15d3ff6
updated styling to Livepeer CSS
liamdoyle95 e64faa6
Total Votes added
liamdoyle95 bab08c0
voting popover logic
liamdoyle95 1e9ab0d
Fix
liamdoyle95 b3cd403
Voting Popover UI fix
liamdoyle95 4337560
Fetches most recent ENS name
liamdoyle95 8b28694
ENS name fix and link
liamdoyle95 d12df34
Loading Spinner, ENS and Popover
liamdoyle95 57284a8
formatAddress
liamdoyle95 ae01af4
Address for popover
liamdoyle95 48da46b
Removed on popover
liamdoyle95 0334e3a
remove qodo
liamdoyle95 b8904ac
.env.example
liamdoyle95 64ae030
queries, fetch votes, fomratAddress, chains moved to retrespective pl…
liamdoyle95 eafc541
cleanup: factor out duplicate vote so reusable between voting components
liamdoyle95 b5c5b42
Reduced duplicated code and fixed UX issue.
liamdoyle95 fb3f7a0
Missed link for mobile voter
liamdoyle95 c5634eb
Removed technical debt no longer needed. Added No Votes
liamdoyle95 6b53e24
Cleanup
liamdoyle95 2f8ede0
Vote hooks, hydration fix
liamdoyle95 b8299fd
treasuryProposals.ts file removed and queries moved into queries fold…
liamdoyle95 8d93c30
treasuryProposals within apollo
liamdoyle95 8b0f5a8
removed useVotes and optimised other hooks
liamdoyle95 0b4e58f
Only fetch Ens name for votes
liamdoyle95 3c4b760
more changes
37eb398
address import changes and typing
ec61856
useInfuraVoterVotes
liamdoyle95 db7bb3d
PR ready
liamdoyle95 18ee2f6
yarn restore
liamdoyle95 afeb09a
lint error fix
liamdoyle95 e51794f
fixed import and relative import errors
fbcd076
VoteTx, Padding UI
liamdoyle95 7e941a2
Merge branch 'AddVotingTransparency' of https://github.com/liamdoyle9…
liamdoyle95 2697e76
Table UI align left
liamdoyle95 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| import { gql } from "@apollo/client"; | ||
|
|
||
| export const ENS_QUERY = gql` | ||
| query getENS($address: String!) { | ||
| domains(where: { resolvedAddress: $address } | ||
| orderBy: registration__registrationDate | ||
| orderDirection: desc | ||
| ) { | ||
| name | ||
| resolvedAddress { | ||
| id | ||
| } | ||
| createdAt | ||
| } | ||
| } | ||
| `; | ||
|
|
||
| export const GET_PROPOSALS_BY_IDS = gql` | ||
| query getProposalsByIds($ids: [String!]!) { | ||
| treasuryProposals(where: { id_in: $ids }) { | ||
| id | ||
| description | ||
| voteStart | ||
| voteEnd | ||
| } | ||
| } | ||
| `; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| "use client"; | ||
|
|
||
| import React from "react"; | ||
| import { Box, Heading, Text, Link, Badge } from "@livepeer/design-system"; | ||
| import { ArrowTopRightIcon } from "@modulz/radix-icons"; | ||
| import { VOTING_SUPPORT, Vote } from "@lib/api/types/votes"; | ||
| import { formatAddress } from "utils/formatAddress"; | ||
| import { formatLpt } from "@lib/utils"; | ||
|
|
||
| interface VoteDetailItemProps { | ||
| vote: Vote; | ||
| } | ||
|
|
||
| const Index: React.FC<VoteDetailItemProps> = ({ vote }) => { | ||
| const support = VOTING_SUPPORT[vote.choiceID] || VOTING_SUPPORT["2"]; | ||
| return ( | ||
| <Box | ||
| css={{ | ||
| backgroundColor: "$neutral4", | ||
| padding: "$4", | ||
| borderRadius: "$2", | ||
| marginTop: "$2", | ||
| }} | ||
| > | ||
| <Heading as="h2" css={{ fontSize: "$3", mb: "$2", color: "$white" }}> | ||
| <Link | ||
| href={`https://explorer.livepeer.org/treasury/${vote.proposalId}`} | ||
| target="_blank" | ||
| css={{ | ||
| color: "$green11", | ||
| textDecoration: "none", | ||
| "&:hover": { textDecoration: "underline" }, | ||
| }} | ||
| > | ||
| {vote.proposalTitle} | ||
| </Link> | ||
| </Heading> | ||
|
|
||
| <Text css={{ mb: "$1" }}> | ||
| <Text as="span" css={{ color: "$white", fontWeight: 600 }}> | ||
| Proposal ID: | ||
| </Text>{" "} | ||
| <Text as="span" css={{ color: "$neutral11" }}> | ||
| {formatAddress(vote.proposalId)} | ||
| </Text> | ||
| </Text> | ||
|
|
||
| <Text css={{ mb: "$1", display: "inline-flex", alignItems: "center" }}> | ||
| <Text | ||
| as="span" | ||
| css={{ color: "$white", fontWeight: 600, marginRight: "$1" }} | ||
| > | ||
| Support: | ||
| </Text> | ||
| <Text as="span" css={{ color: "$neutral11", ...support.style }}> | ||
| {support.text} | ||
| </Text> | ||
| </Text> | ||
|
|
||
| <Text css={{ mb: "$1" }}> | ||
| <Text as="span" css={{ color: "$white", fontWeight: 600 }}> | ||
| Weight: | ||
| </Text>{" "} | ||
| <Text as="span" css={{ color: "$neutral11" }}> | ||
| {formatLpt(vote.weight)} | ||
| </Text> | ||
| </Text> | ||
|
|
||
| <Text css={{ mb: "$1" }}> | ||
| <Text as="span" css={{ color: "$white", fontWeight: 600 }}> | ||
| Reason: | ||
| </Text>{" "} | ||
| <Text as="span" css={{ color: "$neutral11" }}> | ||
| {vote.reason || "No reason provided"} | ||
| </Text> | ||
| </Text> | ||
|
|
||
| <Box css={{ textAlign: "start", mt: "$2" }}> | ||
| {vote.transactionHash ? ( | ||
| <Link | ||
| href={`https://arbiscan.io/tx/${vote.transactionHash}#eventlog`} | ||
| target="_blank" | ||
| onClickCapture={(e) => e.stopPropagation()} | ||
| css={{ | ||
| display: "inline-block", | ||
| transition: "transform 0.2s ease", | ||
| "&:hover": { transform: "scale(1.1)" }, | ||
| }} | ||
| > | ||
| <Badge css={{ cursor: "pointer" }} variant="primary" size="1"> | ||
| {formatAddress(vote.transactionHash)} | ||
| <Box | ||
| css={{ ml: "$1", width: 15, height: 15 }} | ||
| as={ArrowTopRightIcon} | ||
| /> | ||
| </Badge> | ||
| </Link> | ||
| ) : ( | ||
| <Text css={{ color: "$neutral9" }}>N/A</Text> | ||
| )} | ||
| </Box> | ||
| </Box> | ||
| ); | ||
| }; | ||
|
|
||
| export default Index; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| import React from "react"; | ||
| import { createPortal } from "react-dom"; | ||
| import { Box, Button } from "@livepeer/design-system"; | ||
|
|
||
| interface VoteModalProps { | ||
| onClose: () => void; | ||
| children: React.ReactNode; | ||
| } | ||
|
|
||
| const Index: React.FC<VoteModalProps> = ({ onClose, children }) => | ||
| createPortal( | ||
| <Box | ||
| css={{ | ||
| position: "fixed", | ||
| inset: 0, | ||
| display: "flex", | ||
| alignItems: "center", | ||
| justifyContent: "center", | ||
| backgroundColor: "rgba(0, 0, 0, 0.5)", | ||
| backdropFilter: "blur(4px)", | ||
| zIndex: 9999, | ||
| }} | ||
| onClick={(e) => e.stopPropagation()} | ||
| > | ||
| <Box | ||
| css={{ | ||
| position: "relative", | ||
| backgroundColor: "$neutral3", | ||
| borderRadius: "$2", | ||
| width: "90%", | ||
| maxHeight: "90vh", | ||
| display: "flex", | ||
| flexDirection: "column", | ||
| "@bp2": { width: "50%" }, | ||
| }} | ||
| onClick={(e) => e.stopPropagation()} | ||
| > | ||
| <Box | ||
| css={{ | ||
| position: "sticky", | ||
| top: 0, | ||
| right: 0, | ||
| zIndex: 10, | ||
| backgroundColor: "$neutral3", | ||
| px: "$4", | ||
| py: "$2", | ||
| display: "flex", | ||
| justifyContent: "flex-end", | ||
| }} | ||
| > | ||
| <Button | ||
| variant="gray" | ||
| css={{ | ||
| "&:hover": { backgroundColor: "$red6" }, | ||
| }} | ||
| onClick={onClose} | ||
| > | ||
| Close | ||
| </Button> | ||
| </Box> | ||
|
|
||
| <Box | ||
| css={{ | ||
| overflowY: "auto", | ||
| px: "$4", | ||
| py: "$2", | ||
| maxHeight: "calc(90vh - 56px)", | ||
| }} | ||
| > | ||
| {children} | ||
| </Box> | ||
| </Box> | ||
| </Box>, | ||
| document.body | ||
| ); | ||
|
|
||
| export default Index; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| 'use client'; | ||
|
|
||
| import React from 'react'; | ||
| import Spinner from '@components/Spinner'; | ||
| import { Flex, Text } from '@livepeer/design-system'; | ||
| import VoteModal from '../VoteModal'; | ||
| import VoteDetail from '../VoteDetail'; | ||
| import { useInfuraVoterVotes } from '../../../hooks/TreasuryVotes/useInfuraVoterVotes'; | ||
|
|
||
| interface VoterPopoverProps { | ||
| voter: string; | ||
| onClose: () => void; | ||
| } | ||
|
|
||
| const Index: React.FC<VoterPopoverProps> = ({ voter, onClose }) => { | ||
| const { votes, isLoading } = useInfuraVoterVotes(voter); | ||
|
|
||
| return ( | ||
| <VoteModal onClose={onClose}> | ||
| {isLoading ? ( | ||
| <Flex css={{ justifyContent: 'center', alignItems: 'center', height: '150px' }}> | ||
| <Spinner /> | ||
| </Flex> | ||
| ) : votes.length > 0 ? ( | ||
| votes.map((vote, idx) => ( | ||
| <VoteDetail key={vote.transactionHash ?? idx} vote={vote} /> | ||
| )) | ||
| ) : ( | ||
| <Text css={{ color: '$neutral11', textAlign: 'center', mt: '$4' }}> | ||
| No votes found for this voter. | ||
| </Text> | ||
| )} | ||
| </VoteModal> | ||
| ); | ||
| }; | ||
|
|
||
| export default Index; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| import React from "react"; | ||
| import { Box, Flex, Text } from "@livepeer/design-system"; | ||
| import { Vote } from "../../../../lib/api/types/votes"; | ||
| import { VoteView } from "./VoteItem"; | ||
|
|
||
| export interface VoteTableProps { | ||
| votes: Vote[]; | ||
| counts: { yes: number; no: number; abstain: number }; | ||
| formatWeight: (weight: string) => string; | ||
| onSelect: (voter: string) => void; | ||
| } | ||
|
|
||
| export const DesktopVoteTable: React.FC<VoteTableProps> = ({ | ||
| votes, | ||
| counts, | ||
| formatWeight, | ||
| onSelect, | ||
| }) => ( | ||
| <Box | ||
| css={{ display: "none", "@bp2": { display: "block" }, overflowX: "auto" }} | ||
| > | ||
| <Text | ||
| css={{ | ||
| textAlign: "center", | ||
| fontSize: "$3", | ||
| fontWeight: 500, | ||
| color: "$white", | ||
| mb: "$2", | ||
| }} | ||
| > | ||
| Vote Results | ||
| </Text> | ||
| <Flex | ||
| css={{ | ||
| justifyContent: "center", | ||
| mb: "$4", | ||
| fontWeight: 700, | ||
| fontSize: "$3", | ||
| color: "$white", | ||
| }} | ||
| > | ||
| <Text css={{ mr: "$1", color: "$green9" }}>Yes ({counts.yes})</Text> | ||
| <Text>|</Text> | ||
| <Text css={{ mx: "$1", color: "$red9" }}>No ({counts.no})</Text> | ||
| <Text>|</Text> | ||
| <Text css={{ ml: "$1", color: "$yellow9" }}> | ||
| Abstain ({counts.abstain}) | ||
| </Text> | ||
| </Flex> | ||
|
|
||
| <Text | ||
| css={{ | ||
| textAlign: "center", | ||
| fontSize: "$2", | ||
| color: "$neutral11", | ||
| mb: "$2", | ||
| }} | ||
| > | ||
| Click on a vote to view a voters proposal voting history. | ||
| </Text> | ||
| <Box as="table" css={{ width: "100%", borderCollapse: "collapse" }}> | ||
| <Box as="thead"> | ||
| <Box as="tr" css={{ backgroundColor: "$neutral4" }}> | ||
| {["Voter", "Support", "Weight", "Reason", "Vote Txn"].map((label) => ( | ||
| <Box | ||
| key={label} | ||
| as="th" | ||
| css={{ | ||
| textAlign: "left", | ||
| textTransform: "uppercase", | ||
| fontSize: "$1", | ||
| color: "$neutral11", | ||
| borderBottom: "1px solid $neutral5", | ||
| padding: "$2 $3", | ||
| }} | ||
| > | ||
| {label} | ||
| </Box> | ||
| ))} | ||
| </Box> | ||
| </Box> | ||
| <Box as="tbody"> | ||
| {votes.map((vote) => { | ||
| return ( | ||
| <VoteView | ||
| key={vote.choiceID} | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| vote={vote} | ||
| onSelect={onSelect} | ||
| formatWeight={formatWeight} | ||
| isMobile={false} | ||
| /> | ||
| ); | ||
| })} | ||
| </Box> | ||
| </Box> | ||
| </Box> | ||
| ); | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using array index as fallback React key causes component state loss when votes list is sorted or reordered