11from hiero_sdk_python .account .account_create_transaction import AccountCreateTransaction
22from hiero_sdk_python .account .account_id import AccountId
3+ from hiero_sdk_python .query .account_info_query import AccountInfoQuery
34from hiero_sdk_python .hbar import Hbar
45from hiero_sdk_python .response_code import ResponseCode
56from hiero_sdk_python .transaction .transaction_receipt import TransactionReceipt
67from tck .handlers .registry import rpc_method
7- from tck .param .account import CreateAccountParams
8- from tck .response .account import CreateAccountResponse
8+ from tck .param .account import CreateAccountParams , GetAccountInfoParams
9+ from tck .response .account import (
10+ CreateAccountResponse ,
11+ GetAccountInfoResponse ,
12+ StakingInfoResponse ,
13+ TokenRelationshipResponse ,
14+ )
915from tck .util .client_utils import get_client
1016from tck .util .constants import DEFAULT_GRPC_TIMEOUT
1117from tck .util .key_utils import get_key_from_string
@@ -24,9 +30,7 @@ def _build_create_account_transaction(params: CreateAccountParams) -> AccountCre
2430 transaction .set_receiver_signature_required (params .receiverSignatureRequired )
2531
2632 if params .maxAutoTokenAssociations is not None :
27- transaction .set_max_automatic_token_associations (
28- params .maxAutoTokenAssociations
29- )
33+ transaction .set_max_automatic_token_associations (params .maxAutoTokenAssociations )
3034
3135 if params .stakedAccountId is not None :
3236 transaction .set_staked_account_id (AccountId .from_string (params .stakedAccountId ))
@@ -66,3 +70,66 @@ def create_account(params: CreateAccountParams) -> CreateAccountResponse:
6670 account_id = str (receipt .account_id )
6771
6872 return CreateAccountResponse (account_id , ResponseCode (receipt .status ).name )
73+
74+
75+ def _build_account_info_response (info ) -> GetAccountInfoResponse :
76+ staking_info_response = None
77+ if info .staking_info :
78+ staking_info_response = StakingInfoResponse (
79+ declineStakingReward = info .staking_info .decline_staking_reward ,
80+ stakePeriodStart = str (info .staking_info .stake_period_start )
81+ if info .staking_info .stake_period_start
82+ else None ,
83+ pendingReward = str (info .staking_info .pending_reward .to_tinybars ())
84+ if info .staking_info .pending_reward
85+ else None ,
86+ stakedToMe = str (info .staking_info .staked_to_me .to_tinybars ()) if info .staking_info .staked_to_me else None ,
87+ stakedAccountId = str (info .staking_info .staked_account_id ) if info .staking_info .staked_account_id else None ,
88+ stakedNodeId = str (info .staking_info .staked_node_id ) if info .staking_info .staked_node_id else None ,
89+ )
90+
91+ token_relationships_response = []
92+ if info .token_relationships :
93+ for rel in info .token_relationships :
94+ token_relationships_response .append (
95+ TokenRelationshipResponse (
96+ tokenId = str (rel .token_id ) if rel .token_id else None ,
97+ symbol = rel .symbol ,
98+ balance = str (rel .balance ) if rel .balance is not None else None ,
99+ kycStatus = str (rel .kyc_status ) if rel .kyc_status is not None else None ,
100+ freezeStatus = str (rel .freeze_status ) if rel .freeze_status is not None else None ,
101+ decimals = str (rel .decimals ) if rel .decimals is not None else None ,
102+ automaticAssociation = rel .automatic_association ,
103+ )
104+ )
105+
106+ return GetAccountInfoResponse (
107+ accountId = str (info .account_id ) if info .account_id else None ,
108+ contractAccountId = info .contract_account_id ,
109+ isDeleted = info .is_deleted ,
110+ proxyReceived = str (info .proxy_received .to_tinybars ()) if info .proxy_received else None ,
111+ key = info .key .to_bytes ().hex () if info .key else None ,
112+ balance = str (info .balance .to_tinybars ()) if info .balance else None ,
113+ isReceiverSignatureRequired = info .receiver_signature_required ,
114+ expirationTime = str (info .expiration_time ) if info .expiration_time else None ,
115+ autoRenewPeriod = str (info .auto_renew_period .seconds ) if info .auto_renew_period else None ,
116+ tokenRelationships = token_relationships_response if token_relationships_response else None ,
117+ accountMemo = info .account_memo ,
118+ ownedNfts = str (info .owned_nfts ) if info .owned_nfts is not None else None ,
119+ maxAutomaticTokenAssociations = str (info .max_automatic_token_associations )
120+ if info .max_automatic_token_associations is not None
121+ else None ,
122+ stakingInfo = staking_info_response ,
123+ )
124+
125+
126+ @rpc_method ("getAccountInfo" )
127+ def get_account_info (params : GetAccountInfoParams ) -> GetAccountInfoResponse :
128+ client = get_client (params .sessionId )
129+
130+ query = AccountInfoQuery ()
131+ if params .accountId :
132+ query .set_account_id (AccountId .from_string (params .accountId ))
133+
134+ info = query .execute (client )
135+ return _build_account_info_response (info )
0 commit comments