Skip to content

Commit 55bf415

Browse files
authored
feat(forge): modify events in forge inspect to return event signature (#8561)
* feat(forge): add `eventIdentifiers` to `forge inspect` * chore: remove quotes from output * fix: test * fix: output 32 bytes of the event identifier * fix: add back `0x` prefix * chore: modify forge inspect <contract> events instead of implementing a new cmd
1 parent 2cb388d commit 55bf415

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

crates/forge/bin/cmd/inspect.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use alloy_primitives::Address;
1+
use alloy_primitives::{hex, keccak256, Address};
22
use clap::Parser;
33
use comfy_table::{presets::ASCII_MARKDOWN, Table};
44
use eyre::{Context, Result};
@@ -133,7 +133,7 @@ impl InspectArgs {
133133
let mut out = serde_json::Map::new();
134134
if let Some(abi) = &artifact.abi {
135135
let abi = &abi;
136-
// Print the signature of all errors
136+
// Print the signature of all errors.
137137
for er in abi.errors.iter().flat_map(|(_, errors)| errors) {
138138
let types = er.inputs.iter().map(|p| p.ty.clone()).collect::<Vec<_>>();
139139
let sig = format!("{:x}", er.selector());
@@ -150,13 +150,13 @@ impl InspectArgs {
150150
let mut out = serde_json::Map::new();
151151
if let Some(abi) = &artifact.abi {
152152
let abi = &abi;
153-
154-
// print the signature of all events including anonymous
153+
// Print the topic of all events including anonymous.
155154
for ev in abi.events.iter().flat_map(|(_, events)| events) {
156155
let types = ev.inputs.iter().map(|p| p.ty.clone()).collect::<Vec<_>>();
156+
let topic = hex::encode(keccak256(ev.signature()));
157157
out.insert(
158158
format!("{}({})", ev.name, types.join(",")),
159-
format!("{:?}", ev.signature()).into(),
159+
format!("0x{topic}").into(),
160160
);
161161
}
162162
}

0 commit comments

Comments
 (0)