-
Notifications
You must be signed in to change notification settings - Fork 142
Open
Labels
Blockchain / DLTIssues engineering distributed ledger functionalityIssues engineering distributed ledger functionalityadvancedrequires knowledge of multiple areas in the codebase without defined steps to implement or examplesrequires knowledge of multiple areas in the codebase without defined steps to implement or examplesenhancementNew feature or requestNew feature or requestpythonUses Python programming languageUses Python programming language
Description
Introduce a dedicated StakingInfo SDK to represent the protobuf StakingInfo message in a structured way.
This new class should fully mirror the protobuf representation and provide consistent serialization/deserialization utilities, just like other entities in the SDK.
message StakingInfo {
bool decline_reward = 1;
Timestamp stake_period_start = 2;
int64 pending_reward = 3;
int64 staked_to_me = 4;
oneof staked_id {
AccountID staked_account_id = 5;
int64 staked_node_id = 6;
}
}The class must have following characteristics:
-
Implemented it as a
@dataclass -
Fully represents all protobuf fields
# Required Fields decline_reward: Optional[bool] stake_period_start: Optional[Timestamp] pending_reward: Optional[Hbar] staked_to_me: Optional[Hbar] staked_account_id: Optional[AccountId] staked_node_id: Optional[int]
-
The class should provide below mwthods:
@classmethod from_proto(cls, proto: basic_types_pb2.StakingInfo) -> StakingInfo to_proto(self) -> basic_types_pb2.StakingInfo @classmethod from_bytes(cls, data: bytes) -> StakingInfo to_bytes(self) -> bytes
Proposed Solution
- Create a class (
@dataclass) call StackingInfo located atsrc/hiero_sdk_python/staking_info.py - Add the required fields to the class while preserving
oneofsemantics for staked_account_id vs staked_node_id. - Add the required methods to the class
- Ensure proper validation while creating the protobuff representation from class and vice versa
- Ensure proper deserailize and serialize using from/to bytes method
# eg. from_bytes(cls, data: bytes) -> StackingInfo: proto = basic_types_pb2.StakingInfo.FromString(data) return cls.from_proto(proto) to_bytes(self) -> bytes: return self.to_proto().SerializeToString()
- Add comprehensive unit tests to validate.
Metadata
Metadata
Assignees
Labels
Blockchain / DLTIssues engineering distributed ledger functionalityIssues engineering distributed ledger functionalityadvancedrequires knowledge of multiple areas in the codebase without defined steps to implement or examplesrequires knowledge of multiple areas in the codebase without defined steps to implement or examplesenhancementNew feature or requestNew feature or requestpythonUses Python programming languageUses Python programming language