Skip to content
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

feat: check for custom min voting power when voting #614

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

wa0x6e
Copy link
Contributor

@wa0x6e wa0x6e commented Aug 11, 2024

Summary

Closes: #597

This PR add support for custom minimum required voting power for offchain voting.

Until now, we allowed anyone with voting power > 0 to cast the vote, and it'll just fail on the backend with an error.

With this PR, we will validate the voting power before allowing user to cast the vote, preventing user frustration and unnecessary actions.

How to test

Go to snapshot.org, and create some proposals with the following conditions (need to edit space settings before creating each proposals):

A. A regular proposal, with basic voting validation (anyone with non-null vp can vote)
B. A proposal with custom minimum voting power (need at least X vp to vote)

Now, try to vote on each of these proposals, by opening the vote modal.

In case of A:

  1. you should be able to vote if your account has vp > 0
  2. if your vp === 0, it should show the warning message that you don't have enough vp, and disable the voting form

In case of B:

  1. When your vp === 0, it should show the warning message that you don't have enough vp, and disable the voting form
  2. When your vp > 0, but < X, it should show that you need at least X vp to vote, and disable the voting form
  3. When your vp >= X, you should be able to vote

@wa0x6e wa0x6e marked this pull request as draft August 11, 2024 04:36
@wa0x6e wa0x6e changed the title feat: check for custom min voting power when voting feat: check for custom min voting power when voting and proposing Aug 11, 2024
@wa0x6e wa0x6e changed the title feat: check for custom min voting power when voting and proposing feat: check for custom min voting power when voting Aug 11, 2024
@wa0x6e wa0x6e marked this pull request as ready for review August 11, 2024 16:08
@wa0x6e wa0x6e requested a review from ChaituVR August 11, 2024 16:09
@wa0x6e
Copy link
Contributor Author

wa0x6e commented Aug 11, 2024

@ChaituVR Does that feature work like that ? For now, it's just comparing the user voting power with the minScore in the vote validation object.

Not sure how and where we should take the "custom strategies" into account.

@ChaituVR
Copy link
Member

@ChaituVR Does that feature work like that ? For now, it's just comparing the user voting power with the minScore in the vote validation object.

Not sure how and where we should take the "custom strategies" into account.

yep we should check strategies too, we should allow vote only if user minScore based on custom strategies, we can use same logic as here https://github.com/snapshot-labs/snapshot-sequencer/blob/master/src/writer/vote.ts#L49-L76

@wa0x6e wa0x6e marked this pull request as draft August 12, 2024 07:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat: support custom minimum voting power score when voting on offchain proposals
2 participants