Skip to content

Commit 18bc2b5

Browse files
Use a string representation for opcode
1 parent ac78782 commit 18bc2b5

File tree

4 files changed

+218
-255
lines changed

4 files changed

+218
-255
lines changed

crates/evm-tracing-client/src/formatters/call_tracer.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,12 @@ impl super::ResponseFormatter for Formatter {
5555
call_type,
5656
} => CallTracerInner::Call {
5757
call_type: match call_type {
58-
CallType::Call => MarshalledOpcode::call_opcode(),
59-
CallType::CallCode => MarshalledOpcode::callcode_opcode(),
58+
CallType::Call => MarshalledOpcode::from("CALL"),
59+
CallType::CallCode => MarshalledOpcode::from("CALLCODE"),
6060
CallType::DelegateCall => {
61-
MarshalledOpcode::delegatecall_opcode()
61+
MarshalledOpcode::from("DELEGATECALL")
6262
}
63-
CallType::StaticCall => MarshalledOpcode::staticcall_opcode(),
63+
CallType::StaticCall => MarshalledOpcode::from("STATICCALL"),
6464
},
6565
to,
6666
input,
@@ -88,13 +88,13 @@ impl super::ResponseFormatter for Formatter {
8888
CreateResult::Error { .. } => None,
8989
},
9090
value,
91-
call_type: MarshalledOpcode::create_opcode(),
91+
call_type: MarshalledOpcode::from("CREATE"),
9292
},
9393
BlockscoutCallInner::SelfDestruct { balance, to } => {
9494
CallTracerInner::SelfDestruct {
9595
value: balance,
9696
to,
97-
call_type: MarshalledOpcode::selfdestruct_opcode(),
97+
call_type: MarshalledOpcode::from("SELFDESTRUCT"),
9898
}
9999
}
100100
},

crates/evm-tracing-client/src/types/mod.rs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -79,18 +79,14 @@ pub enum ContextType {
7979
impl ContextType {
8080
/// Obtain context type from opcode.
8181
pub fn from(opcode: MarshalledOpcode) -> Option<Self> {
82-
if let Some(opcode_known_name) = opcode.known_name() {
83-
return match &opcode_known_name.to_uppercase()[..] {
84-
"CREATE" | "CREATE2" => Some(ContextType::Create),
85-
"CALL" => Some(ContextType::Call(CallType::Call)),
86-
"CALLCODE" => Some(ContextType::Call(CallType::CallCode)),
87-
"DELEGATECALL" => Some(ContextType::Call(CallType::DelegateCall)),
88-
"STATICCALL" => Some(ContextType::Call(CallType::StaticCall)),
89-
_ => None,
90-
};
82+
match &opcode.to_string()[..] {
83+
"CREATE" | "CREATE2" => Some(ContextType::Create),
84+
"CALL" => Some(ContextType::Call(CallType::Call)),
85+
"CALLCODE" => Some(ContextType::Call(CallType::CallCode)),
86+
"DELEGATECALL" => Some(ContextType::Call(CallType::DelegateCall)),
87+
"STATICCALL" => Some(ContextType::Call(CallType::StaticCall)),
88+
_ => None,
9189
}
92-
93-
None
9490
}
9591
}
9692

0 commit comments

Comments
 (0)