-
Notifications
You must be signed in to change notification settings - Fork 333
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
519bd0e
commit 728754b
Showing
3 changed files
with
141 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,22 @@ | ||
from typing import TypedDict | ||
from bittensor.core.chain_data.utils import decode_account_id | ||
|
||
|
||
# Senate / Proposal data | ||
class ProposalVoteData(TypedDict): | ||
""" | ||
This TypedDict represents the data structure for a proposal vote in the Senate. | ||
Attributes: | ||
index (int): The index of the proposal. | ||
threshold (int): The threshold required for the proposal to pass. | ||
ayes (List[str]): List of senators who voted 'aye'. | ||
nays (List[str]): List of senators who voted 'nay'. | ||
end (int): The ending timestamp of the voting period. | ||
""" | ||
|
||
class ProposalVoteData: | ||
index: int | ||
threshold: int | ||
ayes: list[str] | ||
nays: list[str] | ||
end: int | ||
|
||
def __init__(self, proposal_dict: dict) -> None: | ||
self.index = proposal_dict["index"] | ||
self.threshold = proposal_dict["threshold"] | ||
self.ayes = self.decode_ss58_tuples(proposal_dict["ayes"]) | ||
self.nays = self.decode_ss58_tuples(proposal_dict["nays"]) | ||
self.end = proposal_dict["end"] | ||
|
||
@staticmethod | ||
def decode_ss58_tuples(line: tuple): | ||
"""Decodes a tuple of ss58 addresses formatted as bytes tuples.""" | ||
return [decode_account_id(line[x][0]) for x in range(len(line))] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters