VotingProcedures
- class cometa.voting_procedures.voting_procedures.VotingProcedures(ptr)[source]
Bases:
objectRepresents a map of voting procedures in the Cardano governance system.
This collection maps (Voter, GovernanceActionId) pairs to VotingProcedure objects. It provides a dict-like interface for managing voting procedures.
- classmethod new()[source]
Creates a new empty VotingProcedures map.
- Returns:
A new empty VotingProcedures instance.
- Raises:
CardanoError – If creation fails.
- Return type:
- classmethod from_cbor(reader)[source]
Deserializes VotingProcedures from CBOR data.
- Parameters:
reader (CborReader) – A CborReader positioned at the voting procedures data.
- Returns:
A new VotingProcedures deserialized from the CBOR data.
- Raises:
CardanoError – If deserialization fails.
- Return type:
- to_cbor(writer)[source]
Serializes the voting procedures to CBOR format.
- Parameters:
writer (CborWriter) – A CborWriter to write the serialized data to.
- Raises:
CardanoError – If serialization fails.
- Return type:
None
- insert(voter, governance_action_id, procedure)[source]
Inserts a voting procedure for a specific voter and governance action.
- Parameters:
voter (Voter) – The voter casting the vote.
governance_action_id (GovernanceActionId) – The governance action being voted on.
procedure (VotingProcedure) – The voting procedure containing the vote and optional anchor.
- Raises:
CardanoError – If insertion fails.
- Return type:
None
Example
>>> procedures = VotingProcedures.new() >>> procedures.insert(voter, action_id, VotingProcedure.new(Vote.YES))
- get(voter, governance_action_id)[source]
Retrieves a voting procedure for a specific voter and governance action.
- Parameters:
voter (Voter) – The voter who cast the vote.
governance_action_id (GovernanceActionId) – The governance action that was voted on.
- Returns:
The VotingProcedure if found, None otherwise.
- Return type:
VotingProcedure | None
- __setitem__(key, value)[source]
Sets a voting procedure using dict-like syntax.
- Parameters:
key (Tuple[Voter, GovernanceActionId]) – A tuple of (Voter, GovernanceActionId).
value (VotingProcedure) – The VotingProcedure to store.
- Return type:
None
Example
>>> procedures[voter, action_id] = VotingProcedure.new(Vote.YES)
- __getitem__(key)[source]
Gets a voting procedure using dict-like syntax.
- Parameters:
key (Tuple[Voter, GovernanceActionId]) – A tuple of (Voter, GovernanceActionId).
- Returns:
The VotingProcedure.
- Raises:
KeyError – If the key is not found.
- Return type:
Example
>>> procedure = procedures[voter, action_id]
- get_voters()[source]
Returns a list of all voters in this collection.
- Returns:
A list of Voter objects.
- Return type:
List[Voter]
- get_governance_action_ids_by_voter(voter)[source]
Returns a list of governance action IDs for a specific voter.
- Parameters:
voter (Voter) – The voter to get action IDs for.
- Returns:
A list of GovernanceActionId objects.
- Return type:
List[GovernanceActionId]
- items()[source]
Iterates over all (voter, governance_action_id, voting_procedure) tuples.
- Returns:
An iterator over tuples of (Voter, GovernanceActionId, VotingProcedure).
- Return type:
Iterator[Tuple[Voter, GovernanceActionId, VotingProcedure]]
- to_cip116_json(writer)[source]
Serializes this object to CIP-116 compliant JSON.
- Parameters:
writer (JsonWriter) – The JsonWriter to write the JSON to.
- Raises:
CardanoError – If serialization fails.
- Return type:
None