Skip to content

Commit 61601fb

Browse files
authored
firehose: remove 'to' address on eth trx when root call is CREATE (#4085)
Co-authored-by: Stéphane Duchesneau <[email protected]>
1 parent b960ea8 commit 61601fb

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

chain/ethereum/src/codec.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff 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),

0 commit comments

Comments
 (0)