Skip to content

Commit

Permalink
feat/python: Delegation output fields (#1408)
Browse files Browse the repository at this point in the history
* delegation

* lets not unionify

* review

* specific condition

* lint :(

---------

Co-authored-by: Thibault Martinez <[email protected]>
  • Loading branch information
Brord van Wierst and thibault-martinez authored Oct 11, 2023
1 parent 560026b commit 54e8ee6
Showing 1 changed file with 24 additions and 5 deletions.
29 changes: 24 additions & 5 deletions bindings/python/iota_sdk/types/output.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from typing import Dict, Optional, List, TypeAlias, Union, Any
from dataclasses import dataclass, field
from dataclasses_json import config
from iota_sdk.types.common import HexStr, json
from iota_sdk.types.common import HexStr, json, EpochIndex
from iota_sdk.types.feature import deserialize_features, SenderFeature, IssuerFeature, MetadataFeature, TagFeature
from iota_sdk.types.native_token import NativeToken
from iota_sdk.types.token_scheme import SimpleTokenScheme
Expand All @@ -21,6 +21,7 @@ class OutputType(IntEnum):
Account (4): An account output.
Foundry (5): A foundry output.
Nft (6): An NFT output.
Delegation (7): A delegation output.
"""
Basic = 3
Account = 4
Expand Down Expand Up @@ -223,12 +224,30 @@ class NftOutput:
@json
@dataclass
class DelegationOutput:
"""Describes a delegation output.
"""An output which delegates its contained IOTA coins as voting power to a validator.
Attributes:
type :
The type of output.
amount: The amount of IOTA coins held by the output.
delegated_amount: The amount of delegated IOTA coins.
delegation_id: Unique identifier of the Delegation Output
validator_address: The Account Address of the validator to which this output is delegating.
start_epoch: The index of the first epoch for which this output delegates.
end_epoch: The index of the last epoch for which this output delegates.
unlock_conditions: Define how the output can be unlocked in a transaction.
type: The type of output.
"""
# TODO fields done in #1174
amount: int = field(metadata=config(
encoder=str
))
delegated_amount: int = field(metadata=config(
encoder=str
))
delegation_id: HexStr
validator_address: HexStr
start_epoch: EpochIndex
end_epoch: EpochIndex
unlock_conditions: List[AddressUnlockCondition] = field(metadata=config(
decoder=deserialize_unlock_conditions
))
type: int = field(default_factory=lambda: int(
OutputType.Delegation), init=False)

Expand Down

0 comments on commit 54e8ee6

Please sign in to comment.