NativeScriptSet
- class cometa.witness_set.native_script_set.NativeScriptSet(ptr=None)[source]
Bases:
Set[NativeScript]Represents a set of native scripts.
Native scripts form an expression tree and evaluate to either true or false. They are used in Cardano to define spending conditions including multi-signature scripts, time-locks, and other types of scripts.
- classmethod from_cbor(reader)[source]
Deserializes a NativeScriptSet from CBOR data.
- Parameters:
reader (CborReader) – A CborReader positioned at the script set data.
- Returns:
A new NativeScriptSet deserialized from the CBOR data.
- Raises:
CardanoError – If deserialization fails.
- Return type:
- classmethod from_list(scripts)[source]
Creates a NativeScriptSet from an iterable of native script objects.
- Parameters:
scripts (Iterable[NativeScriptLike]) – An iterable of NativeScript or native script type objects.
- Returns:
A new NativeScriptSet containing all the scripts.
- Raises:
CardanoError – If creation fails.
- Return type:
- to_cbor(writer)[source]
Serializes the script set to CBOR format.
- Parameters:
writer (CborWriter) – A CborWriter to write the serialized data to.
- Raises:
CardanoError – If serialization fails.
- Return type:
None
- property use_tag: bool
Whether the set uses Conway era tagged encoding.
- Returns:
True if using tagged encoding, False for legacy array encoding.
- add(script)[source]
Adds a native script to the set.
- Parameters:
script (NativeScriptLike) – The script to add. Can be a NativeScript or any specific native script type (ScriptPubkey, ScriptAll, ScriptAny, ScriptNOfK, ScriptInvalidBefore, ScriptInvalidAfter).
- Raises:
CardanoError – If addition fails.
TypeError – If the script type is not supported.
- Return type:
None
- get(index)[source]
Retrieves a native script at the specified index.
- Parameters:
index (int) – The index of the script to retrieve.
- Returns:
The NativeScript at the specified index.
- Raises:
CardanoError – If retrieval fails.
IndexError – If index is out of bounds.
- Return type:
- __iter__()[source]
Iterates over all scripts in the set.
- Return type:
Iterator[NativeScript]
- __getitem__(index)[source]
Gets a script by index using bracket notation.
- Parameters:
index (int)
- Return type:
- 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
- __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[NativeScript]) – Another iterable to compare with.
- Returns:
True if the sets are disjoint.
- Return type:
bool