Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
8254001
Allow multiple onEvent registrations per event
claude Jul 22, 2026
0f0a8e3
Don't drop where-empty registrations at finish
claude Jul 22, 2026
021b096
Store chain-independent registration intents; fix review findings
claude Jul 22, 2026
e954219
Validate where at call site; drop composition-era test fixtures
claude Jul 22, 2026
089b24a
Say "dispatch key" not "signature" in duplicate-event error
claude Jul 22, 2026
6dde622
Validate intent `where` across all matching chains
claude Jul 22, 2026
3932d7e
Capture raw events for where:false events; dedupe raw events per log
claude Jul 23, 2026
eeb6080
Exclude where:false events from raw events; keep handler-less backfill
claude Jul 23, 2026
33de8ce
Simplify duplicate-event message; move dup tests to ReScript
claude Jul 23, 2026
bacd334
Resolve onEvent `where` once per chain; add dispatch-order test
claude Jul 23, 2026
bcf9df7
Add MultiHandlerOrder to Indexer_test expected ABI
claude Jul 23, 2026
483ddad
Resolve registrations at onEvent into one reused registration
claude Jul 23, 2026
6b558bc
Merge branch 'main' into claude/multiple-event-registrations-4lpfgw
DZakh Jul 23, 2026
1f5d6b4
Match exact duplicate-event error messages after base merge
claude Jul 23, 2026
bfcaeeb
Eliminate worker thread from TestIndexer, store entities decoded (#1476)
DZakh Jul 23, 2026
9361917
Merge branch 'main' into claude/multiple-event-registrations-4lpfgw
DZakh Jul 23, 2026
49ff3e9
Merge remote-tracking branch 'origin/main' into claude/multiple-event…
claude Jul 23, 2026
ea3e7af
Point merged tests at InternalTestIndexer.fromUserApi
claude Jul 23, 2026
9b90e52
Pin Noop.EmptyEvent handler to chain 1; drop MultiHandlerOrder fixture
claude Jul 23, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 64 additions & 1 deletion packages/cli/src/config_parsing/system_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1921,12 +1921,75 @@ impl Contract {
events: Vec<Event>,
abi: Abi,
) -> Result<Self> {
// TODO: Validatate that all event names are unique
validate_names_valid_rescript(
&events.iter().map(|e| e.name.clone()).collect(),
"event".to_string(),
)?;

// Codegen keys the generated event modules by name and routing looks
// events up by name, so two events on one contract can't share a name.
// Overloads (same name, different signature) are the usual cause — point
// at the `name` alias as the fix; a byte-identical copy just needs
// removing.
let mut seen_by_name: HashMap<&str, &Event> = HashMap::new();
for event in &events {
if let Some(existing) = seen_by_name.insert(&event.name, event) {
if existing.sighash == event.sighash {
return Err(anyhow!(
"Contract {name} defines the event \"{}\" more than once. \
Please remove the duplicate.",
event.name,
));
}
return Err(anyhow!(
"Contract {name} has two events named \"{}\". Give one of them a \
unique name with the \"name\" field so the generated code and \
the indexer's routing can tell them apart.",
event.name,
));
}
}

// Two events on one contract that share a dispatch key are
// indistinguishable at routing time — one log/instruction would decode
// to both — so reject them here. The key mirrors the runtime `eventId`:
// sighash plus indexed-topic count for EVM, the discriminator for SVM
// (already program-scoped, since these are one program's instructions),
// the sighash for Fuel (a `LogData` logId or a fixed `mint`/`burn`/…).
// Names are unique by the check above, so a collision here is always
// between two differently-named events.
let mut seen_by_dispatch_key: HashMap<String, String> = HashMap::new();
for event in &events {
let dispatch_key = match &event.kind {
EventKind::Params(params) => {
let indexed_count = params.iter().filter(|p| p.indexed).count();
Some(format!("{}_{}", event.sighash, indexed_count))
}
// The router decodes the discriminator to bytes before matching,
// so `0x0f` and `0x0F` collide — lowercase before keying.
EventKind::Svm(svm) => Some(
svm.discriminator
.as_ref()
.map(|d| d.to_lowercase())
.unwrap_or_else(|| "none".to_string()),
Comment on lines +1971 to +1974

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Normalize SVM discriminator keys before duplicate check

When two SVM instructions use the same discriminator bytes with different hex casing, such as 0x0f and 0x0F, this string key treats them as distinct and parsing accepts both. The SVM router decodes discriminator strings to bytes before matching, so a matching instruction then fans out to both indistinguishable registrations even though this parser check is meant to reject dispatch collisions. Normalize/lowercase the discriminator or key on decoded bytes plus length before inserting.

Useful? React with 👍 / 👎.

),
EventKind::Fuel(_) => Some(event.sighash.clone()),
};
if let Some(dispatch_key) = dispatch_key {
if let Some(existing) =
seen_by_dispatch_key.insert(dispatch_key, event.name.clone())
{
return Err(anyhow!(
"Contract {name} has two events the indexer can't tell apart: \
\"{existing}\" and \"{}\". They match the same on-chain data, so \
the indexer can't decide which one a log belongs to. Please remove \
one of them.",
event.name,
));
}
}
}

Ok(Self {
name,
events,
Expand Down
54 changes: 0 additions & 54 deletions packages/envio-tests/test/HandlerRegisterValidation_test.res

This file was deleted.

Loading