diff --git a/bindings/python/iota_sdk/__init__.py b/bindings/python/iota_sdk/__init__.py index ffcd2c2305..b62c123995 100644 --- a/bindings/python/iota_sdk/__init__.py +++ b/bindings/python/iota_sdk/__init__.py @@ -18,6 +18,7 @@ from .types.block.wrapper import * from .types.block.validation import * from .types.block_builder_options import * +from .types.block_issuer_key import * from .types.burn import * from .types.client_options import * from .types.common import * diff --git a/bindings/python/iota_sdk/types/address.py b/bindings/python/iota_sdk/types/address.py index c70ec342af..1884bf4b40 100644 --- a/bindings/python/iota_sdk/types/address.py +++ b/bindings/python/iota_sdk/types/address.py @@ -93,7 +93,7 @@ def deserialize_address(d: Dict[str, Any]) -> Address: def deserialize_addresses( dicts: List[Dict[str, Any]]) -> List[Address]: """ - Takes a list of dictionaries as input and returns a list with specific instances of a classes based on the value of the 'type' key in the dictionary. + Takes a list of dictionaries as input and returns a list with specific instances of classes based on the value of the 'type' key in the dictionary. Arguments: * `dicts`: A list of dictionaries that are expected to have a key called 'type' which specifies the type of the returned value. diff --git a/bindings/python/iota_sdk/types/block_issuer_key.py b/bindings/python/iota_sdk/types/block_issuer_key.py new file mode 100644 index 0000000000..fcf3326788 --- /dev/null +++ b/bindings/python/iota_sdk/types/block_issuer_key.py @@ -0,0 +1,57 @@ +# Copyright 2023 IOTA Stiftung +# SPDX-License-Identifier: Apache-2.0 + +from enum import IntEnum +from dataclasses import dataclass, field +from typing import Any, Dict, List, TypeAlias +from iota_sdk.types.common import HexStr, json + + +class BlockIssuerKeyType(IntEnum): + """BlockIssuerKey type variants. + + Attributes: + ED25519 (0): Ed25519 block issuer key. + """ + ED25519 = 0 + + +@json +@dataclass +class Ed25519BlockIssuerKey: + """A Block Issuer Key backed by an Ed25519 Public Key. + Attributes: + public_key: The hex encoded Ed25519 public key. + """ + public_key: HexStr + type: int = field( + default_factory=lambda: int( + BlockIssuerKeyType.ED25519), + init=False) + + +BlockIssuerKey: TypeAlias = Ed25519BlockIssuerKey + + +def deserialize_block_issuer_key(d: Dict[str, Any]) -> BlockIssuerKey: + """ + Takes a dictionary as input and returns an instance of a specific class based on the value of the 'type' key in the dictionary. + + Arguments: + * `d`: A dictionary that is expected to have a key called 'type' which specifies the type of the returned value. + """ + block_issuer_key_type = d['type'] + if block_issuer_key_type == block_issuer_key_type.ED25519: + return Ed25519BlockIssuerKey.from_dict(d) + raise Exception(f'invalid block issuer key type: {block_issuer_key_type}') + + +def deserialize_block_issuer_keys( + dicts: List[Dict[str, Any]]) -> List[BlockIssuerKey]: + """ + Takes a list of dictionaries as input and returns a list with specific instances of classes based on the value of the 'type' key in the dictionary. + + Arguments: + * `dicts`: A list of dictionaries that are expected to have a key called 'type' which specifies the type of the returned value. + """ + return list(map(deserialize_block_issuer_key, dicts)) diff --git a/bindings/python/iota_sdk/types/context_input.py b/bindings/python/iota_sdk/types/context_input.py index fcdd6a3f35..61d3f7cebb 100644 --- a/bindings/python/iota_sdk/types/context_input.py +++ b/bindings/python/iota_sdk/types/context_input.py @@ -89,7 +89,7 @@ def deserialize_context_input(d: Dict[str, Any]) -> ContextInput: def deserialize_context_inputs( dicts: List[Dict[str, Any]]) -> List[ContextInput]: """ - Takes a list of dictionaries as input and returns a list with specific instances of a classes based on the value of the 'type' key in the dictionary. + Takes a list of dictionaries as input and returns a list with specific instances of classes based on the value of the 'type' key in the dictionary. Arguments: * `dicts`: A list of dictionaries that are expected to have a key called 'type' which specifies the type of the returned value. diff --git a/bindings/python/iota_sdk/types/feature.py b/bindings/python/iota_sdk/types/feature.py index b980f28232..7b392f2ca1 100644 --- a/bindings/python/iota_sdk/types/feature.py +++ b/bindings/python/iota_sdk/types/feature.py @@ -6,6 +6,7 @@ from dataclasses import dataclass, field from dataclasses_json import config from iota_sdk.types.address import Address, deserialize_address +from iota_sdk.types.block_issuer_key import BlockIssuerKey from iota_sdk.types.common import EpochIndex, HexStr, json, SlotIndex @@ -93,11 +94,10 @@ class BlockIssuerFeature: """Contains the public keys to verify block signatures and allows for unbonding the issuer deposit. Attributes: expiry_slot: The slot index at which the Block Issuer Feature expires and can be removed. - public_keys: The Block Issuer Keys. + block_issuer_keys: The Block Issuer Keys. """ expiry_slot: SlotIndex - # TODO Replace with a list of PublicKey types - public_keys: List[HexStr] + block_issuer_keys: List[BlockIssuerKey] type: int = field( default_factory=lambda: int( FeatureType.BlockIssuer), @@ -157,7 +157,7 @@ def deserialize_feature(d: Dict[str, Any]) -> Feature: def deserialize_features(dicts: List[Dict[str, Any]]) -> List[Feature]: """ - Takes a list of dictionaries as input and returns a list with specific instances of a classes based on the value of the 'type' key in the dictionary. + Takes a list of dictionaries as input and returns a list with specific instances of classes based on the value of the 'type' key in the dictionary. Arguments: * `dicts`: A list of dictionaries that are expected to have a key called 'type' which specifies the type of the returned value. diff --git a/bindings/python/iota_sdk/types/output.py b/bindings/python/iota_sdk/types/output.py index 6d6b21b500..6a6ea8add0 100644 --- a/bindings/python/iota_sdk/types/output.py +++ b/bindings/python/iota_sdk/types/output.py @@ -279,7 +279,7 @@ def deserialize_output(d: Dict[str, Any]) -> Output: def deserialize_outputs(dicts: List[Dict[str, Any]]) -> List[Output]: """ - Takes a list of dictionaries as input and returns a list with specific instances of a classes based on the value of the 'type' key in the dictionary. + Takes a list of dictionaries as input and returns a list with specific instances of classes based on the value of the 'type' key in the dictionary. Arguments: * `dicts`: A list of dictionaries that are expected to have a key called 'type' which specifies the type of the returned value. diff --git a/bindings/python/iota_sdk/types/payload.py b/bindings/python/iota_sdk/types/payload.py index 9e14206a7d..f2db60d367 100644 --- a/bindings/python/iota_sdk/types/payload.py +++ b/bindings/python/iota_sdk/types/payload.py @@ -76,7 +76,7 @@ def deserialize_payload(d: Dict[str, Any]) -> Payload: def deserialize_payloads( dicts: List[Dict[str, Any]]) -> List[Payload]: """ - Takes a list of dictionaries as input and returns a list with specific instances of a classes based on the value of the 'type' key in the dictionary. + Takes a list of dictionaries as input and returns a list with specific instances of classes based on the value of the 'type' key in the dictionary. Arguments: * `dicts`: A list of dictionaries that are expected to have a key called 'type' which specifies the type of the returned value. diff --git a/bindings/python/iota_sdk/types/unlock.py b/bindings/python/iota_sdk/types/unlock.py index 2851b9085b..83abb597aa 100644 --- a/bindings/python/iota_sdk/types/unlock.py +++ b/bindings/python/iota_sdk/types/unlock.py @@ -100,7 +100,7 @@ def deserialize_unlock(d: Dict[str, Any]) -> Union[SignatureUnlock, def deserialize_unlocks(dicts: List[Dict[str, Any]]) -> List[Union[SignatureUnlock, ReferenceUnlock, AccountUnlock, NftUnlock]]: """ - Takes a list of dictionaries as input and returns a list with specific instances of a classes based on the value of the 'type' key in the dictionary. + Takes a list of dictionaries as input and returns a list with specific instances of classes based on the value of the 'type' key in the dictionary. Arguments: * `dicts`: A list of dictionaries that are expected to have a key called 'type' which specifies the type of the returned value. diff --git a/bindings/python/iota_sdk/types/unlock_condition.py b/bindings/python/iota_sdk/types/unlock_condition.py index f45f102625..92972d95ed 100644 --- a/bindings/python/iota_sdk/types/unlock_condition.py +++ b/bindings/python/iota_sdk/types/unlock_condition.py @@ -177,7 +177,7 @@ def deserialize_unlock_condition(d: Dict[str, Any]) -> UnlockCondition: def deserialize_unlock_conditions( dicts: List[Dict[str, Any]]) -> List[UnlockCondition]: """ - Takes a list of dictionaries as input and returns a list with specific instances of a classes based on the value of the 'type' key in the dictionary. + Takes a list of dictionaries as input and returns a list with specific instances of classes based on the value of the 'type' key in the dictionary. Arguments: * `dicts`: A list of dictionaries that are expected to have a key called 'type' which specifies the type of the returned value.