Skip to content

Commit

Permalink
Merge branch '2.0' into feat/transaction-capabilities
Browse files Browse the repository at this point in the history
  • Loading branch information
thibault-martinez authored Oct 17, 2023
2 parents 9f5d035 + 087d241 commit 10ac6db
Show file tree
Hide file tree
Showing 10 changed files with 139 additions and 137 deletions.
1 change: 1 addition & 0 deletions bindings/python/iota_sdk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 *
Expand Down
2 changes: 1 addition & 1 deletion bindings/python/iota_sdk/types/address.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
57 changes: 57 additions & 0 deletions bindings/python/iota_sdk/types/block_issuer_key.py
Original file line number Diff line number Diff line change
@@ -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))
2 changes: 1 addition & 1 deletion bindings/python/iota_sdk/types/context_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 4 additions & 4 deletions bindings/python/iota_sdk/types/feature.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion bindings/python/iota_sdk/types/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion bindings/python/iota_sdk/types/payload.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion bindings/python/iota_sdk/types/unlock.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion bindings/python/iota_sdk/types/unlock_condition.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading

0 comments on commit 10ac6db

Please sign in to comment.