NativeScriptList
- class cometa.scripts.native_scripts.native_script_list.NativeScriptList(ptr=None)[source]
Bases:
Sequence[NativeScript]Represents a list of native scripts.
Native scripts form an expression tree and evaluate to either true or false. This list is used for script_all, script_any, and script_n_of_k constructs.
- classmethod from_cbor(reader)[source]
Deserializes a NativeScriptList from CBOR data.
- Parameters:
reader (CborReader) – A CborReader positioned at the script list data.
- Returns:
A new NativeScriptList deserialized from the CBOR data.
- Raises:
CardanoError – If deserialization fails.
- Return type:
- classmethod from_list(scripts)[source]
Creates a NativeScriptList from an iterable of native script objects.
- Parameters:
scripts (Iterable[Any]) – An iterable of NativeScript or native script type objects.
- Returns:
A new NativeScriptList containing all the scripts.
- Raises:
CardanoError – If creation fails.
- Return type:
- to_cbor(writer)[source]
Serializes the script list to CBOR format.
- Parameters:
writer (CborWriter) – A CborWriter to write the serialized data to.
- Raises:
CardanoError – If serialization fails.
- Return type:
None
- add(script)[source]
Adds a native script to the list.
- Parameters:
script (Any) – 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 list.
- Return type:
Iterator[NativeScript]
- __getitem__(index)[source]
Gets a script by index using bracket notation.
- Parameters:
index (int)
- Return type:
- index(value, start=0, stop=None)[source]
Returns the index of the first occurrence of value.
- Parameters:
value (NativeScript) – The value to search for.
start (int) – Start searching from this index.
stop (Optional[int]) – Stop searching at this index.
- Returns:
The index of the first occurrence.
- Raises:
ValueError – If the value is not found.
- Return type:
int
- count(value)[source]
Returns the number of occurrences of value.
- Parameters:
value (NativeScript) – The value to count.
- Returns:
The number of occurrences.
- Return type:
int