Skip to content

Commit

Permalink
Python/staking feature (#1196)
Browse files Browse the repository at this point in the history
* staking feature in python

* fix

* amount to str type

* fmt

---------

Co-authored-by: Thibault Martinez <[email protected]>
  • Loading branch information
Brord van Wierst and thibault-martinez authored Sep 11, 2023
1 parent 4789f3f commit 7d98236
Showing 1 changed file with 29 additions and 5 deletions.
34 changes: 29 additions & 5 deletions bindings/python/iota_sdk/types/feature.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,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
Expand All @@ -38,7 +40,7 @@ class Feature():
@json
@dataclass
class SenderFeature(Feature):
"""Sender feature.
"""Identifies the validated sender of an output.
Attributes:
address: A given sender address.
"""
Expand All @@ -52,7 +54,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.
"""
Expand All @@ -66,7 +68,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.
"""
Expand All @@ -80,7 +82,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.
"""
Expand All @@ -91,7 +93,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.
Expand All @@ -104,3 +106,25 @@ class BlockIssuer(Feature):
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: str
fixed_cost: str
# TODO Replace with an EpochIndex type
start_epoch: HexStr
# TODO Replace with an EpochIndex type
end_epoch: HexStr
type: int = field(
default_factory=lambda: int(
FeatureType.Staking),
init=False)

0 comments on commit 7d98236

Please sign in to comment.