File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -195,7 +195,19 @@ impl<'a> TryInto<web3::types::Transaction> for TransactionTraceAt<'a> {
195195 . from
196196 . try_decode_proto ( "transaction from address" ) ?,
197197 ) ,
198- to : Some ( self . trace . to . try_decode_proto ( "transaction to address" ) ?) ,
198+ to : match self . trace . calls . len ( ) {
199+ 0 => Some ( self . trace . to . try_decode_proto ( "transaction to address" ) ?) ,
200+ _ => {
201+ match CallType :: from_i32 ( self . trace . calls [ 0 ] . call_type ) . ok_or_else ( || {
202+ format_err ! ( "invalid call type: {}" , self . trace. calls[ 0 ] . call_type, )
203+ } ) ? {
204+ CallType :: Create => {
205+ None // we don't want the 'to' address on a transaction that creates the contract, to align with RPC behavior
206+ }
207+ _ => Some ( self . trace . to . try_decode_proto ( "transaction to" ) ?) ,
208+ }
209+ }
210+ } ,
199211 value : self . trace . value . as_ref ( ) . map_or ( U256 :: zero ( ) , |x| x. into ( ) ) ,
200212 gas_price : self . trace . gas_price . as_ref ( ) . map ( |x| x. into ( ) ) ,
201213 gas : U256 :: from ( self . trace . gas_limit ) ,
You can’t perform that action at this time.
0 commit comments