Skip to content

Conversation

@andreibancioiu
Copy link
Collaborator

@andreibancioiu andreibancioiu commented Oct 22, 2025

@andreibancioiu andreibancioiu self-assigned this Oct 22, 2025

from multiversx_sdk import VoteType
from rich import print

Copy link
Collaborator Author

@andreibancioiu andreibancioiu Oct 22, 2025

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.

@andreibancioiu andreibancioiu marked this pull request as ready for review October 28, 2025 11:00
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())
Copy link
Collaborator Author

@andreibancioiu andreibancioiu Oct 28, 2025

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):
Copy link
Collaborator Author

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

Copy link
Contributor

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.

Copy link
Contributor

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 :)

raduchis
raduchis previously approved these changes Oct 29, 2025

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)

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.

Copy link
Collaborator Author

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

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

Choose a reason for hiding this comment

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

👍

popenta
popenta previously approved these changes Oct 29, 2025

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):
Copy link
Contributor

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):
Copy link
Contributor

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 :)

@andreibancioiu andreibancioiu dismissed stale reviews from popenta and raduchis via f169fd2 October 31, 2025 09:05
@andreibancioiu andreibancioiu merged commit b26054f into main Oct 31, 2025
2 checks passed
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