AssetNameList

class cometa.assets.asset_name_list.AssetNameList(ptr=None)[source]

Bases: Sequence[AssetName]

Represents a list of asset names.

Example

>>> name_list = AssetNameList()
>>> name_list.add(AssetName.from_string("Token1"))
>>> name_list.add(AssetName.from_string("Token2"))
>>> len(name_list)
2
__init__(ptr=None)[source]
Return type:

None

classmethod from_list(names)[source]

Creates an AssetNameList from an iterable of AssetName objects.

Parameters:

names (Iterable[AssetName]) – An iterable of AssetName objects.

Returns:

A new AssetNameList containing all the names.

Raises:

CardanoError – If creation fails.

Return type:

AssetNameList

__enter__()[source]
Return type:

AssetNameList

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

None

__repr__()[source]

Return repr(self).

Return type:

str

add(element)[source]

Adds an asset name to the list.

Parameters:

element (AssetName) – The asset name to add.

Raises:

CardanoError – If the operation fails.

Return type:

None

get(index)[source]

Retrieves an asset name by index.

Parameters:

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

Returns:

The AssetName at the specified index.

Raises:
  • CardanoError – If retrieval fails.

  • IndexError – If index is out of bounds.

Return type:

AssetName

__len__()[source]

Returns the number of elements in the list.

Return type:

int

__iter__()[source]

Iterates over all asset names in the list.

Return type:

Iterator[AssetName]

__getitem__(index)[source]

Gets an asset name by index using bracket notation. Supports negative indices.

Parameters:

index (int)

Return type:

AssetName

__bool__()[source]

Returns True if the list is not empty.

Return type:

bool

__contains__(item)[source]

Checks if an asset name is in the list.

Parameters:

item (AssetName)

Return type:

bool

append(element)[source]

Appends an asset name to the list.

This is an alias for add() to match Python list semantics.

Parameters:

element (AssetName) – The asset name to append.

Return type:

None

index(value, start=0, stop=None)[source]

Returns the index of the first occurrence of value.

Parameters:
  • value (AssetName) – The value to search for.

  • start (int) – Start searching from this index.

  • stop (int | None) – 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 (AssetName) – The value to count.

Returns:

The number of occurrences.

Return type:

int