AssetIdList

class cometa.assets.asset_id_list.AssetIdList(ptr=None)[source]

Bases: Sequence[AssetId]

Represents a list of asset identifiers.

Example

>>> id_list = AssetIdList()
>>> id_list.add(AssetId.new_lovelace())
>>> len(id_list)
1
__init__(ptr=None)[source]
Return type:

None

classmethod from_list(ids)[source]

Creates an AssetIdList from an iterable of AssetId objects.

Parameters:

ids (Iterable[AssetId]) – An iterable of AssetId objects.

Returns:

A new AssetIdList containing all the IDs.

Raises:

CardanoError – If creation fails.

Return type:

AssetIdList

__enter__()[source]
Return type:

AssetIdList

__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 ID to the list.

Parameters:

element (AssetId) – The asset ID to add.

Raises:

CardanoError – If the operation fails.

Return type:

None

get(index)[source]

Retrieves an asset ID by index.

Parameters:

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

Returns:

The AssetId at the specified index.

Raises:
  • CardanoError – If retrieval fails.

  • IndexError – If index is out of bounds.

Return type:

AssetId

__len__()[source]

Returns the number of elements in the list.

Return type:

int

__iter__()[source]

Iterates over all asset IDs in the list.

Return type:

Iterator[AssetId]

__getitem__(index)[source]

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

Parameters:

index (int)

Return type:

AssetId

__bool__()[source]

Returns True if the list is not empty.

Return type:

bool

__contains__(item)[source]

Checks if an asset ID is in the list.

Parameters:

item (AssetId)

Return type:

bool

append(element)[source]

Appends an asset ID to the list.

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

Parameters:

element (AssetId) – The asset ID to append.

Return type:

None

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

Returns the index of the first occurrence of value.

Parameters:
  • value (AssetId) – 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 (AssetId) – The value to count.

Returns:

The number of occurrences.

Return type:

int