@@ -45,50 +45,58 @@ def check_error(trx):
4545
4646
4747def get_trx_results (trx ):
48+ # init variables for instruction owner checks
49+ accounts = trx ["transaction" ]["message" ]["accountKeys" ]
50+ evm_loader_instructions = []
51+ for idx , instruction in enumerate (trx ["transaction" ]["message" ]["instructions" ]):
52+ if accounts [instruction ["programIdIndex" ]] == evm_loader_id :
53+ evm_loader_instructions .append (idx )
54+
4855 slot = trx ['slot' ]
4956 block_number = hex (slot )
50- # block_hash = '0x%064x'%slot
5157 got_result = False
5258 logs = []
5359 status = "0x1"
5460 gas_used = 0
5561 return_value = bytes
5662 log_index = 0
5763 for inner in (trx ['meta' ]['innerInstructions' ]):
58- for event in inner ['instructions' ]:
59- log = base58 .b58decode (event ['data' ])
60- instruction = log [:1 ]
61- if (int ().from_bytes (instruction , "little" ) == 7 ): # OnEvent evmInstruction code
62- address = log [1 :21 ]
63- count_topics = int ().from_bytes (log [21 :29 ], 'little' )
64- topics = []
65- pos = 29
66- for _ in range (count_topics ):
67- topic_bin = log [pos :pos + 32 ]
68- topics .append ('0x' + topic_bin .hex ())
69- pos += 32
70- data = log [pos :]
71- rec = {
72- 'address' : '0x' + address .hex (),
73- 'topics' : topics ,
74- 'data' : '0x' + data .hex (),
75- 'transactionLogIndex' : hex (0 ),
76- 'transactionIndex' : hex (inner ['index' ]),
77- 'blockNumber' : block_number ,
78- # 'transactionHash': trxId, # set when transaction found
79- 'logIndex' : hex (log_index ),
80- # 'blockHash': block_hash # set when transaction found
81- }
82- logs .append (rec )
83- log_index += 1
84- elif int ().from_bytes (instruction , "little" ) == 6 : # OnReturn evmInstruction code
85- got_result = True
86- if log [1 ] < 0xd0 :
87- status = "0x1"
88- else :
89- status = "0x0"
90- gas_used = int .from_bytes (log [2 :10 ], 'little' )
91- return_value = log [10 :].hex ()
64+ if inner ["index" ] in evm_loader_instructions :
65+ for event in inner ['instructions' ]:
66+ if accounts [event ['programIdIndex' ]] == evm_loader_id :
67+ log = base58 .b58decode (event ['data' ])
68+ instruction = log [:1 ]
69+ if (int ().from_bytes (instruction , "little" ) == 7 ): # OnEvent evmInstruction code
70+ address = log [1 :21 ]
71+ count_topics = int ().from_bytes (log [21 :29 ], 'little' )
72+ topics = []
73+ pos = 29
74+ for _ in range (count_topics ):
75+ topic_bin = log [pos :pos + 32 ]
76+ topics .append ('0x' + topic_bin .hex ())
77+ pos += 32
78+ data = log [pos :]
79+ rec = {
80+ 'address' : '0x' + address .hex (),
81+ 'topics' : topics ,
82+ 'data' : '0x' + data .hex (),
83+ 'transactionLogIndex' : hex (0 ),
84+ 'transactionIndex' : hex (inner ['index' ]),
85+ 'blockNumber' : block_number ,
86+ # 'transactionHash': trxId, # set when transaction found
87+ 'logIndex' : hex (log_index ),
88+ # 'blockHash': block_hash # set when transaction found
89+ }
90+ logs .append (rec )
91+ log_index += 1
92+ elif int ().from_bytes (instruction , "little" ) == 6 : # OnReturn evmInstruction code
93+ got_result = True
94+ if log [1 ] < 0xd0 :
95+ status = "0x1"
96+ else :
97+ status = "0x0"
98+ gas_used = int .from_bytes (log [2 :10 ], 'little' )
99+ return_value = log [10 :].hex ()
92100
93101 if got_result :
94102 return (logs , status , gas_used , return_value , slot )
0 commit comments