RewardAddressList

class cometa.common.reward_address_list.RewardAddressList(ptr=None)[source]

Bases: Sequence[RewardAddress]

Represents a list of reward addresses.

Reward addresses are used to distribute staking rewards in the Cardano proof-of-stake protocol.

Example

>>> from cometa import RewardAddressList, RewardAddress
>>> addr_list = RewardAddressList()
>>> addr_list.add(RewardAddress.from_bech32("stake_test1..."))
>>> len(addr_list)
1
__init__(ptr=None)[source]
Return type:

None

__enter__()[source]
Return type:

RewardAddressList

__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 reward addresses in the list.

Return type:

int

__iter__()[source]

Iterates over all reward addresses in the list.

Return type:

Iterator[‘RewardAddress’]

__getitem__(index)[source]

Gets a reward address by index using bracket notation.

Parameters:

index (int)

Return type:

RewardAddress

__bool__()[source]

Returns True if the list is not empty.

Return type:

bool

classmethod from_list(addresses)[source]

Creates a RewardAddressList from a Python list of RewardAddress objects.

Parameters:

addresses (list[RewardAddress]) – A list of RewardAddress objects.

Returns:

A new RewardAddressList containing all the addresses.

Raises:

CardanoError – If creation fails.

Return type:

RewardAddressList

add(address)[source]

Adds a reward address to the end of the list.

Parameters:

address (RewardAddress) – The RewardAddress to add.

Raises:

CardanoError – If addition fails.

Return type:

None

get(index)[source]

Retrieves a reward address at the specified index.

Parameters:

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

Returns:

The RewardAddress at the specified index.

Raises:
  • CardanoError – If retrieval fails.

  • IndexError – If index is out of bounds.

Return type:

RewardAddress

append(address)[source]

Appends a reward address to the list.

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

Parameters:

address (RewardAddress) – The RewardAddress to append.

Return type:

None

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

Returns the index of the first occurrence of value.

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

Returns:

The number of occurrences.

Return type:

int