99from hiero_sdk_python .account .account_id import AccountId
1010from hiero_sdk_python .crypto .public_key import PublicKey
1111from hiero_sdk_python .Duration import Duration
12- from hiero_sdk_python .hapi . services . basic_types_pb2 import StakingInfo
12+ from hiero_sdk_python .staking_info import StakingInfo
1313from hiero_sdk_python .hapi .services .crypto_get_info_pb2 import CryptoGetInfoResponse
1414from hiero_sdk_python .hbar import Hbar
1515from hiero_sdk_python .timestamp import Timestamp
@@ -56,9 +56,8 @@ class AccountInfo:
5656 account_memo : Optional [str ] = None
5757 owned_nfts : Optional [int ] = None
5858 max_automatic_token_associations : Optional [int ] = None
59- staked_account_id : Optional [AccountId ] = None
60- staked_node_id : Optional [int ] = None
61- decline_staking_reward : Optional [bool ] = None
59+ staking_info : Optional [StakingInfo ] = None
60+
6261
6362 @classmethod
6463 def _from_proto (cls , proto : CryptoGetInfoResponse .AccountInfo ) -> "AccountInfo" :
@@ -100,20 +99,14 @@ def _from_proto(cls, proto: CryptoGetInfoResponse.AccountInfo) -> "AccountInfo":
10099 account_memo = proto .memo ,
101100 owned_nfts = proto .ownedNfts ,
102101 max_automatic_token_associations = proto .max_automatic_token_associations ,
102+ staking_info = (
103+ StakingInfo ._from_proto (proto .staking_info )
104+ if proto .HasField ("staking_info" )
105+ else None
106+ )
103107 )
104108
105- staking_info = proto .staking_info if proto .HasField ('staking_info' ) else None
106-
107- if staking_info :
108- account_info .staked_account_id = (
109- AccountId ._from_proto (staking_info .staked_account_id )
110- if staking_info .HasField ('staked_account_id' ) else None
111- )
112- account_info .staked_node_id = (
113- staking_info .staked_node_id
114- if staking_info .HasField ('staked_node_id' ) else None
115- )
116- account_info .decline_staking_reward = staking_info .decline_reward
109+
117110
118111 return account_info
119112
@@ -147,11 +140,11 @@ def _to_proto(self) -> CryptoGetInfoResponse.AccountInfo:
147140 memo = self .account_memo ,
148141 ownedNfts = self .owned_nfts ,
149142 max_automatic_token_associations = self .max_automatic_token_associations ,
150- staking_info = StakingInfo (
151- staked_account_id = self .staked_account_id ._to_proto () if self . staked_account_id else None ,
152- staked_node_id = self . staked_node_id if self .staked_node_id else None ,
153- decline_reward = self . decline_staking_reward
154- ),
143+ staking_info = (
144+ self .staking_info ._to_proto ()
145+ if self .staking_info is not None
146+ else None
147+ ),
155148 )
156149
157150 def __str__ (self ) -> str :
@@ -166,8 +159,7 @@ def __str__(self) -> str:
166159 (self .account_memo , "Memo" ),
167160 (self .owned_nfts , "Owned NFTs" ),
168161 (self .max_automatic_token_associations , "Max Automatic Token Associations" ),
169- (self .staked_account_id , "Staked Account ID" ),
170- (self .staked_node_id , "Staked Node ID" ),
162+ (self .staking_info , "Staked Info" ),
171163 (self .proxy_received , "Proxy Received" ),
172164 (self .expiration_time , "Expiration Time" ),
173165 (self .auto_renew_period , "Auto Renew Period" ),
@@ -182,9 +174,6 @@ def __str__(self) -> str:
182174
183175 if self .receiver_signature_required is not None :
184176 lines .append (f"Receiver Signature Required: { self .receiver_signature_required } " )
185-
186- if self .decline_staking_reward is not None :
187- lines .append (f"Decline Staking Reward: { self .decline_staking_reward } " )
188177
189178 if self .token_relationships :
190179 lines .append (f"Token Relationships: { len (self .token_relationships )} " )
@@ -202,7 +191,6 @@ def __repr__(self) -> str:
202191 f"receiver_signature_required={ self .receiver_signature_required !r} , "
203192 f"owned_nfts={ self .owned_nfts !r} , "
204193 f"account_memo={ self .account_memo !r} , "
205- f"staked_node_id={ self .staked_node_id !r} , "
206- f"staked_account_id={ self .staked_account_id !r} "
194+ f"staked_info={ self .staking_info !r} , "
207195 f")"
208196 )
0 commit comments