@@ -33,19 +33,16 @@ def create_mock_record():
3333 tx_id = TransactionId .from_string ("0.0.1234@1698765432.000000000" )
3434
3535 receipt_proto = transaction_receipt_pb2 .TransactionReceipt ()
36- receipt_proto .status = ResponseCode .SUCCESS .value
36+ receipt_proto .status = ResponseCode .SUCCESS .value
3737
38- receipt = TransactionReceipt (
39- receipt_proto = receipt_proto ,
40- transaction_id = tx_id
41- )
38+ receipt = TransactionReceipt (receipt_proto = receipt_proto , transaction_id = tx_id )
4239
4340 ts = Timestamp (seconds = 1698765432 , nanos = 123456789 )
4441 sched = ScheduleId (0 , 0 , 9999 )
4542
4643 record = TransactionRecord (
4744 transaction_id = tx_id ,
48- transaction_hash = b' \x01 \x02 \x03 \x04 ' * 12 ,
45+ transaction_hash = b" \x01 \x02 \x03 \x04 " * 12 ,
4946 transaction_memo = "Hello from example!" ,
5047 transaction_fee = 50000 ,
5148 receipt = receipt ,
@@ -63,26 +60,25 @@ def create_mock_record():
6360 AssessedCustomFee (
6461 amount = 1000000 ,
6562 fee_collector_account_id = AccountId (shard = 0 , realm = 0 , num = 98 ),
66- effective_payer_account_ids = [AccountId (shard = 0 , realm = 0 , num = 100 )]
63+ effective_payer_account_ids = [AccountId (shard = 0 , realm = 0 , num = 100 )],
6764 )
6865 ],
6966 automatic_token_associations = [
7067 TokenAssociation (
71- token_id = TokenId (shard = 0 , realm = 0 , num = 5678 ),
72- account_id = AccountId (shard = 0 , realm = 0 , num = 1234 )
68+ token_id = TokenId (shard = 0 , realm = 0 , num = 5678 ), account_id = AccountId (shard = 0 , realm = 0 , num = 1234 )
7369 )
7470 ],
7571 parent_consensus_timestamp = ts ,
76- alias = b' \x12 \x34 \x56 \x78 \x9a \xbc ' ,
77- ethereum_hash = b' \xab ' * 32 ,
72+ alias = b" \x12 \x34 \x56 \x78 \x9a \xbc " ,
73+ ethereum_hash = b" \xab " * 32 ,
7874 paid_staking_rewards = [
7975 (AccountId (shard = 0 , realm = 0 , num = 456 ), 500000 ),
80- (AccountId (shard = 0 , realm = 0 , num = 789 ), 250000 )
76+ (AccountId (shard = 0 , realm = 0 , num = 789 ), 250000 ),
8177 ],
82- evm_address = b' \xef ' * 20 ,
78+ evm_address = b" \xef " * 20 ,
8379 contract_create_result = ContractFunctionResult (
8480 contract_id = ContractId (shard = 0 , realm = 0 , contract = 1000 ),
85- contract_call_result = b"Contract created successfully!"
81+ contract_call_result = b"Contract created successfully!" ,
8682 ),
8783 )
8884
@@ -91,6 +87,7 @@ def create_mock_record():
9187
9288 return record
9389
90+
9491def _print_basic_fields (record ):
9592 print ("Basic:" )
9693 print (f" Transaction ID: { record .transaction_id } " )
@@ -112,7 +109,9 @@ def _print_basic_fields(record):
112109def _print_transfer_fields (record ):
113110 print (f" HBAR Transfers: { dict (record .transfers ) if record .transfers else 'None' } " )
114111 print (f" Token Transfers: { dict (record .token_transfers ) if record .token_transfers else 'None' } " )
115- print (f" NFT Transfers: { {k : len (v ) for k , v in record .nft_transfers .items ()} if record .nft_transfers else 'None' } " )
112+ print (
113+ f" NFT Transfers: { {k : len (v ) for k , v in record .nft_transfers .items ()} if record .nft_transfers else 'None' } "
114+ )
116115 print (f" Pending Airdrops: { len (record .new_pending_airdrops )} " )
117116
118117
@@ -123,7 +122,9 @@ def _print_new_fields(record):
123122 print (f" Assessed Custom Fees ({ len (record .assessed_custom_fees )} ):" )
124123 for fee in record .assessed_custom_fees :
125124 token = fee .token_id if fee .token_id else "HBAR"
126- payers = ", " .join (str (p ) for p in fee .effective_payer_account_ids ) if fee .effective_payer_account_ids else "N/A"
125+ payers = (
126+ ", " .join (str (p ) for p in fee .effective_payer_account_ids ) if fee .effective_payer_account_ids else "N/A"
127+ )
127128 print (f" - { fee .amount } { token } → Collector: { fee .fee_collector_account_id } , Payers: { payers } " )
128129 print (f" Automatic Token Associations ({ len (record .automatic_token_associations )} ):" )
129130 for assoc in record .automatic_token_associations :
@@ -136,7 +137,9 @@ def _print_new_fields(record):
136137 print (f" EVM Address (hex): { record .evm_address .hex () if record .evm_address else 'None' } " )
137138 if record .contract_create_result :
138139 print (f" Contract Create Result: { record .contract_create_result .contract_id } " )
139- print (f" Result bytes (first 32): { record .contract_create_result .contract_call_result [:32 ].hex () if record .contract_create_result .contract_call_result else 'None' } ..." )
140+ print (
141+ f" Result bytes (first 32): { record .contract_create_result .contract_call_result [:32 ].hex () if record .contract_create_result .contract_call_result else 'None' } ..."
142+ )
140143 else :
141144 print (" Contract Create Result: None" )
142145
@@ -147,7 +150,8 @@ def print_all_fields(record):
147150 _print_basic_fields (record )
148151 _print_transfer_fields (record )
149152 _print_new_fields (record )
150-
153+
154+
151155def main ():
152156 """Run the TransactionRecord example."""
153157 print ("Creating mock TransactionRecord...\n " )
@@ -157,4 +161,3 @@ def main():
157161
158162if __name__ == "__main__" :
159163 main ()
160-
0 commit comments