From f4b047f5403dc47a8fffae47954cba205df51eba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thoralf=20M=C3=BCller?= Date: Mon, 11 Sep 2023 12:29:31 +0200 Subject: [PATCH 1/2] Python: add BlockIssuanceCreditInput, fixes --- bindings/python/iota_sdk/__init__.py | 1 + .../python/iota_sdk/client/_high_level_api.py | 1 + .../python/iota_sdk/types/context_input.py | 23 +++++++++++++++++++ bindings/python/iota_sdk/types/feature.py | 6 ++++- 4 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 bindings/python/iota_sdk/types/context_input.py diff --git a/bindings/python/iota_sdk/__init__.py b/bindings/python/iota_sdk/__init__.py index d59e9e0a47..2c6aaf12de 100644 --- a/bindings/python/iota_sdk/__init__.py +++ b/bindings/python/iota_sdk/__init__.py @@ -17,6 +17,7 @@ from .types.burn import * from .types.client_options import * from .types.common import * +from .types.context_input import * from .types.event import * from .types.feature import * from .types.filter_options import * diff --git a/bindings/python/iota_sdk/client/_high_level_api.py b/bindings/python/iota_sdk/client/_high_level_api.py index 77f16c4a0b..931cbb5cfb 100644 --- a/bindings/python/iota_sdk/client/_high_level_api.py +++ b/bindings/python/iota_sdk/client/_high_level_api.py @@ -3,6 +3,7 @@ from typing import List, Optional from dataclasses import dataclass +from iota_sdk.types.block import Block from iota_sdk.types.common import HexStr, json from iota_sdk.types.output import OutputWithMetadata from iota_sdk.types.output_id import OutputId diff --git a/bindings/python/iota_sdk/types/context_input.py b/bindings/python/iota_sdk/types/context_input.py new file mode 100644 index 0000000000..cb7280104b --- /dev/null +++ b/bindings/python/iota_sdk/types/context_input.py @@ -0,0 +1,23 @@ +# Copyright 2023 IOTA Stiftung +# SPDX-License-Identifier: Apache-2.0 + +from __future__ import annotations +from dataclasses import dataclass +from enum import IntEnum +from iota_sdk.types.common import HexStr, json + + +class ContextInputType(IntEnum): + """Context input types. + """ + BlockIssuanceCredit = 1 + + +@json +@dataclass +class BlockIssuanceCreditContextInput: + """A Block Issuance Credit (BIC) Context Input provides the VM with context for the value of + the BIC vector of a specific slot. + """ + type: int + account_id: HexStr diff --git a/bindings/python/iota_sdk/types/feature.py b/bindings/python/iota_sdk/types/feature.py index 043c1faf2f..24a9cc56ef 100644 --- a/bindings/python/iota_sdk/types/feature.py +++ b/bindings/python/iota_sdk/types/feature.py @@ -4,6 +4,7 @@ from enum import IntEnum from dataclasses import dataclass, field +from typing import List from iota_sdk.types.address import Ed25519Address, AccountAddress, NFTAddress from iota_sdk.types.common import HexStr, json @@ -99,4 +100,7 @@ class BlockIssuer(Feature): expiry_slot: str # TODO Replace with a list of PublicKey types public_keys: List[HexStr] - type: int = field(default_factory=lambda: int(FeatureType.BlockIssuer), init=False) + type: int = field( + default_factory=lambda: int( + FeatureType.BlockIssuer), + init=False) From 82156b2f098a777abf6cfb5d7f2280f711ac6dbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thoralf=20M=C3=BCller?= Date: Mon, 11 Sep 2023 12:34:16 +0200 Subject: [PATCH 2/2] Add ContextInput base class --- bindings/python/iota_sdk/types/context_input.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/bindings/python/iota_sdk/types/context_input.py b/bindings/python/iota_sdk/types/context_input.py index cb7280104b..ac7b57efea 100644 --- a/bindings/python/iota_sdk/types/context_input.py +++ b/bindings/python/iota_sdk/types/context_input.py @@ -2,7 +2,7 @@ # SPDX-License-Identifier: Apache-2.0 from __future__ import annotations -from dataclasses import dataclass +from dataclasses import dataclass, field from enum import IntEnum from iota_sdk.types.common import HexStr, json @@ -15,9 +15,20 @@ class ContextInputType(IntEnum): @json @dataclass -class BlockIssuanceCreditContextInput: +class ContextInput(): + """Base class for context inputs. + """ + type: int + + +@json +@dataclass +class BlockIssuanceCreditContextInput(ContextInput): """A Block Issuance Credit (BIC) Context Input provides the VM with context for the value of the BIC vector of a specific slot. """ - type: int account_id: HexStr + type: int = field( + default_factory=lambda: int( + ContextInputType.BlockIssuanceCredit), + init=False)