@@ -138,6 +138,7 @@ def set_confirmed(self):
138138class EthereumTxManager (models .Manager ):
139139 def create_from_tx_dict (self , tx : Dict [str , Any ], tx_receipt : Optional [Dict [str , Any ]] = None ,
140140 ethereum_block : Optional [EthereumBlock ] = None ) -> 'EthereumTx' :
141+ data = HexBytes (tx .get ('data' ) or tx .get ('input' ))
141142 return super ().create (
142143 block = ethereum_block ,
143144 tx_hash = HexBytes (tx ['hash' ]).hex (),
@@ -148,7 +149,7 @@ def create_from_tx_dict(self, tx: Dict[str, Any], tx_receipt: Optional[Dict[str,
148149 logs = tx_receipt and [clean_receipt_log (log ) for log in tx_receipt .get ('logs' , list ())],
149150 status = tx_receipt and tx_receipt .get ('status' ),
150151 transaction_index = tx_receipt and tx_receipt ['transactionIndex' ],
151- data = HexBytes ( tx . get ( ' data' ) or tx . get ( 'input' )) ,
152+ data = data if data else None ,
152153 nonce = tx ['nonce' ],
153154 to = tx .get ('to' ),
154155 value = tx ['value' ],
@@ -328,6 +329,13 @@ def _trace_address_to_str(self, trace_address) -> str:
328329 return ',' .join ([str (address ) for address in trace_address ])
329330
330331 def build_from_trace (self , trace : Dict [str , Any ], ethereum_tx : EthereumTx ) -> 'InternalTx' :
332+ """
333+ Build a InternalTx object from trace, but it doesn't insert it on database
334+ :param trace:
335+ :param ethereum_tx:
336+ :return: InternalTx not inserted
337+ """
338+ data = trace ['action' ].get ('input' ) or trace ['action' ].get ('init' )
331339 tx_type = EthereumTxType .parse (trace ['type' ])
332340 call_type = EthereumTxCallType .parse_call_type (trace ['action' ].get ('callType' ))
333341 trace_address_str = self ._trace_address_to_str (trace ['traceAddress' ])
@@ -336,7 +344,7 @@ def build_from_trace(self, trace: Dict[str, Any], ethereum_tx: EthereumTx) -> 'I
336344 trace_address = trace_address_str ,
337345 _from = trace ['action' ].get ('from' ),
338346 gas = trace ['action' ].get ('gas' , 0 ),
339- data = trace [ 'action' ]. get ( 'input' ) or trace [ 'action' ]. get ( 'init' ) ,
347+ data = data if data else None ,
340348 to = trace ['action' ].get ('to' ) or trace ['action' ].get ('address' ),
341349 value = trace ['action' ].get ('value' ) or trace ['action' ].get ('balance' , 0 ),
342350 gas_used = (trace .get ('result' ) or {}).get ('gasUsed' , 0 ),
0 commit comments