CertificateSet

class cometa.certificates.certificate_set.CertificateSet(ptr)[source]

Bases: Set[Certificate]

Represents a set of Cardano certificates.

This is a collection type that holds multiple Certificate objects. It is typically used within transactions to include multiple certificate operations in a single transaction.

__init__(ptr)[source]
Return type:

None

__enter__()[source]
Return type:

CertificateSet

__exit__(exc_type, exc_val, exc_tb)[source]
Return type:

None

__repr__()[source]

Return repr(self).

Return type:

str

__len__()[source]

Returns the number of certificates in the set.

Return type:

int

__iter__()[source]

Iterates over the certificates in the set.

Return type:

Iterator[Certificate]

__getitem__(index)[source]

Gets a certificate at the specified index.

Parameters:

index (int)

Return type:

Certificate

classmethod new()[source]

Creates a new empty certificate set.

Returns:

A new CertificateSet instance.

Raises:

CardanoError – If creation fails.

Return type:

CertificateSet

classmethod from_cbor(reader)[source]

Deserializes a CertificateSet from CBOR data.

Parameters:

reader (CborReader) – A CborReader positioned at the set data.

Returns:

A new CertificateSet deserialized from the CBOR data.

Raises:

CardanoError – If deserialization fails.

Return type:

CertificateSet

classmethod from_list(certificates)[source]

Creates a CertificateSet from an iterable of Certificate objects.

Parameters:

certificates (Iterable[Union[Certificate, CertificateUnion]]) – An iterable of Certificate or specific certificate type objects.

Returns:

A new CertificateSet containing all the certificates.

Raises:

CardanoError – If creation fails.

Return type:

CertificateSet

to_cbor(writer)[source]

Serializes the certificate set to CBOR format.

Parameters:

writer (CborWriter) – A CborWriter to write the serialized data to.

Raises:

CardanoError – If serialization fails.

Return type:

None

get(index)[source]

Gets the certificate at the specified index.

Parameters:

index (int) – The index of the certificate to retrieve.

Returns:

The Certificate at the specified index.

Raises:

CardanoError – If retrieval fails.

Return type:

Certificate

add(certificate)[source]

Adds a certificate to the set.

Parameters:

certificate (Union[Certificate, CertificateUnion]) – The Certificate to add. Can be either a Certificate instance or any specific certificate type (e.g., StakeRegistrationCert), which will be automatically converted.

Raises:

CardanoError – If adding fails.

Return type:

None

Example

>>> cert_set = CertificateSet.new()
>>> stake_reg = StakeRegistrationCert.new(credential)
>>> cert_set.add(stake_reg)  # Automatic conversion
to_cip116_json(writer)[source]

Serializes this certificate set to CIP-116 compliant JSON.

Parameters:

writer (JsonWriter) – The JsonWriter to write the JSON to.

Raises:

CardanoError – If serialization fails.

Return type:

None

__contains__(item)[source]

Checks if an item is in the set.

Parameters:

item (object)

Return type:

bool

isdisjoint(other)[source]

Returns True if the set has no elements in common with other.

Parameters:

other (Iterable[Certificate]) – Another iterable to compare with.

Returns:

True if the sets are disjoint.

Return type:

bool