VotingProcedure
- class cometa.voting_procedures.voting_procedure.VotingProcedure(ptr)[source]
Bases:
objectRepresents a voting procedure in the Cardano governance system.
A voting procedure consists of: - A vote (Yes, No, or Abstain) - An optional anchor that links the vote to arbitrary off-chain JSON metadata
- classmethod new(vote, anchor=None)[source]
Creates a new voting procedure.
- Parameters:
- Returns:
A new VotingProcedure instance.
- Raises:
CardanoError – If creation fails.
- Return type:
Example
>>> procedure = VotingProcedure.new(Vote.YES) >>> procedure = VotingProcedure.new(Vote.NO, anchor=my_anchor)
- classmethod from_cbor(reader)[source]
Deserializes a VotingProcedure from CBOR data.
- Parameters:
reader (CborReader) – A CborReader positioned at the voting procedure data.
- Returns:
A new VotingProcedure deserialized from the CBOR data.
- Raises:
CardanoError – If deserialization fails.
- Return type:
- to_cbor(writer)[source]
Serializes the voting procedure to CBOR format.
- Parameters:
writer (CborWriter) – A CborWriter to write the serialized data to.
- Raises:
CardanoError – If serialization fails.
- Return type:
None
- to_cip116_json(writer)[source]
Serializes the voting procedure to CIP-116 JSON format.
The function writes the full JSON object, including the surrounding braces. Keys are written in the order: “vote”, then “anchor” (if present).
- Parameters:
writer (JsonWriter) – A JsonWriter to write the serialized data to.
- Raises:
CardanoError – If serialization fails.
- Return type:
None
Example
>>> from cometa.voting_procedures import VotingProcedure, Vote >>> from cometa.json import JsonWriter >>> procedure = VotingProcedure.new(Vote.YES) >>> writer = JsonWriter() >>> procedure.to_cip116_json(writer) >>> print(writer.encode()) {"vote":"yes"}