fix: use correct address for log (#3481)

This commit is contained in:
Matthias Seitz
2023-06-30 02:44:11 +02:00
committed by GitHub
parent c3ea430e4a
commit 3dcc76e2b0

View File

@ -35,6 +35,11 @@ impl CallKind {
pub fn is_any_create(&self) -> bool {
matches!(self, CallKind::Create | CallKind::Create2)
}
/// Returns true if the call is a delegate of some sorts
pub fn is_delegate(&self) -> bool {
matches!(self, CallKind::DelegateCall | CallKind::CallCode)
}
}
impl std::fmt::Display for CallKind {
@ -204,6 +209,17 @@ pub(crate) struct CallTraceNode {
}
impl CallTraceNode {
/// Returns the call context's execution address
///
/// See `Inspector::call` impl of [TracingInspector](crate::tracing::TracingInspector)
pub(crate) fn execution_address(&self) -> Address {
if self.trace.kind.is_delegate() {
self.trace.caller
} else {
self.trace.address
}
}
/// Pushes all steps onto the stack in reverse order
/// so that the first step is on top of the stack
pub(crate) fn push_steps_on_stack<'a>(
@ -393,7 +409,7 @@ impl CallTraceNode {
.logs
.iter()
.map(|log| CallLogFrame {
address: Some(self.trace.address),
address: Some(self.execution_address()),
topics: Some(log.topics.clone()),
data: Some(log.data.clone().into()),
})