-
Notifications
You must be signed in to change notification settings - Fork 7
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
Snapshot proposal enhancement #1291
Conversation
…er casting the vote
…on to the Snapshot vote section
✅ Deploy Preview for fractal-framework-interface-dev ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
@@ -43,9 +43,15 @@ export default function SnapshotProposalVotes({ proposal }: ISnapshotProposalVot | |||
colSpan={4} | |||
rowGap={4} | |||
> | |||
{choices.map(choice => { | |||
{choices.map((choice, i) => { | |||
const votesBreakdownChoice = |
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.
The format of votesBreakdown
might be different based on snapshot proposal type, which now I think is rather bad thing. So all this crazy conditioning coming from active dev work and hot fixing arising edge cases
I'll do a follow-up PR that will cleanup extendedSnapshotProposal
drilling and will move that to context, but also will cleanup generating votesBreakdown
and then we should have more straightforward rendering.
justifyContent="space-between" | ||
> | ||
<IconButton | ||
aria-label={`Reduce vote weight for ${label}`} |
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.
We currently are not translating aria-labels
|
||
const client = new ApolloClient({ | ||
uri: 'https://hub.snapshot.org/graphql', | ||
cache: new InMemoryCache(), | ||
defaultOptions, |
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.
Essentially, this disables the caching, cause otherwise snapshot proposal details re-fetching was returning cached results, and we wanna avoid that in order to display immediate UX feedback to user once he casted the vote on Snapshot proposal
@@ -28,6 +28,9 @@ const useCastVote = ({ | |||
setPending?: React.Dispatch<React.SetStateAction<boolean>>; | |||
extendedSnapshotProposal?: ExtendedSnapshotProposal; | |||
}) => { | |||
const [selectedChoice, setSelectedChoice] = useState<number>(); |
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.
If we'd decide to use same "selected vote option" pattern for on-chain proposals - we could easily use this same state field
setSelectedChoice(undefined); | ||
if (onSuccess) { | ||
// Need to refetch votes after timeout so that Snapshot API has enough time to record the vote | ||
setTimeout(() => onSuccess(), 3000); |
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.
Not always, but I was facing the situation where refetching was triggered before Snapshot indexer was picking up the vote
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.
LGTM
Description
This PR enhances Snapshot weighted voting support, fixing bunch of bugs around displaying such a proposal and it's results.
It also adds informational message for when vote already casted on Snapshot proposal that it's recorded but user can still re-cast the vote
Notes
Currently WIP on snapshot weighted voting casting vote
Issue / Notion doc (if applicable)
Close #1287
Close #1286
Close #1290
Testing
Screenshots (if applicable)