Skip to content

feat: implement new vote#30

Merged
sleepdefic1t merged 8 commits intoSolar-network:masterfrom
c0nsol3:new-vote
Jun 30, 2022
Merged

feat: implement new vote#30
sleepdefic1t merged 8 commits intoSolar-network:masterfrom
c0nsol3:new-vote

Conversation

@c0nsol3
Copy link
Copy Markdown
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.

Comment thread solar_crypto/transactions/builder/vote.py
Comment thread solar_crypto/transactions/builder/vote.py Outdated
Comment thread solar_crypto/constants.py Outdated
Comment thread solar_crypto/transactions/builder/vote.py Outdated
Comment thread tests/transactions/builder/test_vote.py Outdated
Comment thread solar_crypto/transactions/builder/vote.py
@c0nsol3
Copy link
Copy Markdown
Contributor Author

c0nsol3 commented Jun 26, 2022

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

Copy link
Copy Markdown
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
Copy Markdown
Contributor Author

c0nsol3 commented Jun 30, 2022

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

Copy link
Copy Markdown
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.

Comment thread tests/transactions/builder/test_vote.py Outdated
@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.

4 participants