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: implement new vote #30

Merged
merged 8 commits into from
Jun 30, 2022
Merged

Conversation

c0nsol3
Copy link
Contributor

@c0nsol3 c0nsol3 commented Jun 13, 2022

Example usage:

from solar_crypto.transactions.builder.vote import Vote

transaction = Vote()
transaction.set_nonce(1)

# specify vote weights
# transaction.set_votes({"fun": 35.3, "deadlock": 64.7}) 

# specify a list of votes
# transaction.set_votes(["+fun", "+deadlock", "+dpos.info"])

# unvote
transaction.set_votes({})

transaction.sign("passphrase")

return client.transactions.create([transaction.to_dict()])

In a separate PR I'll bump the lib version add create CHANGELOG file to track changes for each release.

solar_crypto/constants.py Outdated Show resolved Hide resolved
solar_crypto/transactions/builder/vote.py Outdated Show resolved Hide resolved
tests/transactions/builder/test_vote.py Outdated Show resolved Hide resolved
solar_crypto/transactions/builder/vote.py Show resolved Hide resolved
@c0nsol3
Copy link
Contributor Author

c0nsol3 commented Jun 26, 2022

Thank you everyone for your feedback. @sleepdefic1t please have a look at my latest changes.

Copy link
Collaborator

@sleepdefic1t sleepdefic1t left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned here and here:

  • the final vote % must be 100%, and
  • non-decimal integers (e.g., 50/25/25) must also be accepted for vote %

These must be both:

  • enforced/permitted in the code's src, and
  • checked in tests (pass and fail)

@c0nsol3
Copy link
Contributor Author

c0nsol3 commented Jun 30, 2022

I've made these additional checks in the latest commit.

Copy link
Collaborator

@sleepdefic1t sleepdefic1t left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The final vote % must be 100%.

Please add an additional check, and test case, to enforce that values less than 100% are also rejected.

@sleepdefic1t sleepdefic1t merged commit 74dc032 into Solar-network:master Jun 30, 2022
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.

None yet

4 participants