-
Notifications
You must be signed in to change notification settings - Fork 1
Governance additions (vote via legacy delegation, vote via liquid staking) #4
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
Conversation
|
|
||
| from multiversx_sdk import VoteType | ||
| from rich import print | ||
|
|
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.
Unfortunate delta on GitHub. Actually, this is a new file.
The file vote_on_onchain_governance.py was renamed to vote_directly.py.
| def _get_past_vote(self, voter: str, contract: str, function: str, event_identifier: str, proposal: int) -> Optional[OnChainVote]: | ||
| url = f"accounts/{voter}/transactions" | ||
| size = MAX_NUM_TRANSACTIONS_TO_FETCH_OF_TYPE_VOTE | ||
| reasonably_recent_timestamp = int((datetime.now(timezone.utc) - timedelta(days=30)).timestamp()) |
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.
Workaround (limitations): one month, at most 10 votes 🤞
|
|
||
| def vote_on_governance(self, sender: AccountWrapper, proposal: int, choice: int, power: int, proof: bytes, gas_price: int) -> Transaction: | ||
| governance_contract = Address.new_from_bech32(self.configuration.governance_contract) | ||
| def get_direct_voting_power(self, voter: Address): |
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.
Maybe we should move some of the functions below to sdk-py? CC: @popenta
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.
will think about it, but I am not sure it's necessary.
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.
actually, it might be a good idea :)
|
|
||
| previous_vote = entrypoint.get_direct_vote(address, proposal) | ||
| if previous_vote: | ||
| print(f"\tprevious vote at {format_time(previous_vote.timestamp)}:", previous_vote.vote_type) |
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 voted previously, should be skipped. The transaction is going to fail on a second vote on the same proposal.
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.
Fixed.
| if previous_vote: | ||
| print(f"\tprevious vote at {format_time(previous_vote.timestamp)}:", previous_vote.vote_type) | ||
| print(f"\t[red]has already voted![/red]") | ||
| continue |
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 previous_vote: | ||
| print(f"\tprevious vote at {format_time(previous_vote.timestamp)}:", previous_vote.vote_type) | ||
| print(f"\t[red]has already voted![/red]") | ||
| continue |
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.
👍
|
|
||
| def vote_on_governance(self, sender: AccountWrapper, proposal: int, choice: int, power: int, proof: bytes, gas_price: int) -> Transaction: | ||
| governance_contract = Address.new_from_bech32(self.configuration.governance_contract) | ||
| def get_direct_voting_power(self, voter: Address): |
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.
will think about it, but I am not sure it's necessary.
|
|
||
| def vote_on_governance(self, sender: AccountWrapper, proposal: int, choice: int, power: int, proof: bytes, gas_price: int) -> Transaction: | ||
| governance_contract = Address.new_from_bech32(self.configuration.governance_contract) | ||
| def get_direct_voting_power(self, voter: Address): |
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.
actually, it might be a good idea :)
vote_on_governance.pyfor voting viahttps://github.com/multiversx/mx-exchange-sc/tree/governance-v2-merkle-proof/dex/governancevote_on_onchain_governance.pytovote_directly.pyvote_via_legacy_delegation.pyandvote_via_liquid_staking.py