From 538d0c377329ecf1c2ce25839985a84c70a7772c Mon Sep 17 00:00:00 2001 From: Brord van Wierst Date: Mon, 11 Sep 2023 15:00:28 +0200 Subject: [PATCH 1/4] staking feature in python --- bindings/python/iota_sdk/types/feature.py | 33 +++++++++++++++++++---- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/bindings/python/iota_sdk/types/feature.py b/bindings/python/iota_sdk/types/feature.py index 043c1faf2f..6dce4af449 100644 --- a/bindings/python/iota_sdk/types/feature.py +++ b/bindings/python/iota_sdk/types/feature.py @@ -18,12 +18,14 @@ class FeatureType(IntEnum): Metadata (2): The metadata feature. Tag (3): The tag feature. BlockIssuer (4): The block issuer feature. + Staking (5): The staking feature. """ Sender = 0 Issuer = 1 Metadata = 2 Tag = 3 BlockIssuer = 4 + Staking = 5 @json @@ -37,7 +39,7 @@ class Feature(): @json @dataclass class SenderFeature(Feature): - """Sender feature. + """Identifies the validated sender of an output. Attributes: address: A given sender address. """ @@ -51,7 +53,7 @@ class SenderFeature(Feature): @json @dataclass class IssuerFeature(Feature): - """Issuer feature. + """Identifies the validated issuer of the UTXO state machine. Attributes: address: A given issuer address. """ @@ -65,7 +67,7 @@ class IssuerFeature(Feature): @json @dataclass class MetadataFeature(Feature): - """Metadata feature. + """Defines metadata, arbitrary binary data, that will be stored in the output. Attributes: data: Some hex encoded metadata. """ @@ -79,7 +81,7 @@ class MetadataFeature(Feature): @json @dataclass class TagFeature(Feature): - """Tag feature. + """Makes it possible to tag outputs with an index, so they can be retrieved through an indexer API. Attributes: tag: A hex encoded tag used to index the output. """ @@ -90,7 +92,7 @@ class TagFeature(Feature): @json @dataclass class BlockIssuer(Feature): - """Block issuer feature. + """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. @@ -100,3 +102,24 @@ class BlockIssuer(Feature): # TODO Replace with a list of PublicKey types public_keys: List[HexStr] type: int = field(default_factory=lambda: int(FeatureType.BlockIssuer), init=False) + +@json +@dataclass +class StakingFeature(Feature): + """Stakes IOTA coins to become eligible for committee selection, validate the network and receive Mana rewards. + Attributes: + staked_amount: The amount of IOTA coins that are locked and staked in the containing account. + fixed_cost: The fixed cost of the validator, which it receives as part of its Mana rewards. + start_epoch: The epoch index in which the staking started. + end_epoch: The epoch index in which the staking ends. + """ + staked_amount: HexStr + fixed_cost: HexStr + # TODO Replace with an EpochIndex types + start_epoch: HexStr + # TODO Replace with an EpochIndex types + end_epoch: HexStr + type: int = field( + default_factory=lambda: int( + FeatureType.Staking), + init=False) From 5a92126e1ffd1df8b80f1091cef85a59156b1710 Mon Sep 17 00:00:00 2001 From: Brord van Wierst Date: Mon, 11 Sep 2023 15:10:45 +0200 Subject: [PATCH 2/4] fix --- bindings/python/iota_sdk/types/feature.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bindings/python/iota_sdk/types/feature.py b/bindings/python/iota_sdk/types/feature.py index 57268abf24..8b74103b14 100644 --- a/bindings/python/iota_sdk/types/feature.py +++ b/bindings/python/iota_sdk/types/feature.py @@ -119,9 +119,9 @@ class StakingFeature(Feature): """ staked_amount: HexStr fixed_cost: HexStr - # TODO Replace with an EpochIndex types + # TODO Replace with an EpochIndex type start_epoch: HexStr - # TODO Replace with an EpochIndex types + # TODO Replace with an EpochIndex type end_epoch: HexStr type: int = field( default_factory=lambda: int( From ce779a9e008c56098880665cc6a66e8245a3653a Mon Sep 17 00:00:00 2001 From: Brord van Wierst Date: Mon, 11 Sep 2023 15:28:41 +0200 Subject: [PATCH 3/4] amount to str type --- bindings/python/iota_sdk/types/feature.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bindings/python/iota_sdk/types/feature.py b/bindings/python/iota_sdk/types/feature.py index 8b74103b14..a3483707ad 100644 --- a/bindings/python/iota_sdk/types/feature.py +++ b/bindings/python/iota_sdk/types/feature.py @@ -117,8 +117,8 @@ class StakingFeature(Feature): start_epoch: The epoch index in which the staking started. end_epoch: The epoch index in which the staking ends. """ - staked_amount: HexStr - fixed_cost: HexStr + staked_amount: str + fixed_cost: str # TODO Replace with an EpochIndex type start_epoch: HexStr # TODO Replace with an EpochIndex type From e51515a960d98d6861c0bd60f12010bfa012b572 Mon Sep 17 00:00:00 2001 From: Brord van Wierst Date: Mon, 11 Sep 2023 15:32:40 +0200 Subject: [PATCH 4/4] fmt --- bindings/python/iota_sdk/types/feature.py | 1 + 1 file changed, 1 insertion(+) diff --git a/bindings/python/iota_sdk/types/feature.py b/bindings/python/iota_sdk/types/feature.py index a3483707ad..842c012837 100644 --- a/bindings/python/iota_sdk/types/feature.py +++ b/bindings/python/iota_sdk/types/feature.py @@ -107,6 +107,7 @@ class BlockIssuer(Feature): FeatureType.BlockIssuer), init=False) + @json @dataclass class StakingFeature(Feature):