Skip to content

fix(indexer): match resolutionParser to the real on-chain event shape#666

Merged
Mimah97 merged 2 commits into
Vatix-Protocol:devfrom
melopaul:fix/589-resolution-parser-event-shape
Jun 30, 2026
Merged

fix(indexer): match resolutionParser to the real on-chain event shape#666
Mimah97 merged 2 commits into
Vatix-Protocol:devfrom
melopaul:fix/589-resolution-parser-event-shape

Conversation

@melopaul

Copy link
Copy Markdown

Summary

  • resolutionParser's topic constant ("market_resolved") never matched a real event, for the same root cause as marketCreatedParser (see Wire market_created parser into ingestion loop #590): Soroban's #[contractevent] macro snake-cases the full struct name including its Event suffix, so MarketResolvedEvent (contracts/market/src/events.rs) actually publishes under market_resolved_event — confirmed directly against the contract's own test_emit_market_resolved unit test. Every market_resolved event was being silently skipped in production.
  • The "canonical on-chain tuple" shape the parser targeted was also a guess that doesn't match the real event. MarketResolvedEvent carries market_id as topics[1] (u32, a #[topic] field) with only { outcome: bool, resolved_at: u64 } in the value — not a 3-element tuple packed into the value. parseResolutionPayload now reads market_id from the topic for this shape, which matches this issue's "u32 bool u64 payload" description precisely: a u32 topic plus bool/u64 value fields, not a single tuple.
  • The pre-existing legacy ScvVec 3-tuple and legacy ScvMap (with market_id/outcome/oracle all in the value) code paths are left intact for backward compatibility. Shape detection now branches on whether the value is an array, a map containing market_id (legacy), or a map without it (the real on-chain shape).

Why

Same class of bug as #590: the backend assumed a topic-naming convention that doesn't match what Soroban's #[contractevent] macro actually generates, and the payload shape was guessed rather than read from the contract source.

Test plan

  • Updated apps/indexer/src/resolutionParser.test.ts with the real topic and new real-shape test vectors (topic-derived market_id, missing-topic error case), alongside the existing legacy tuple/map coverage.
  • Fixed apps/indexer/src/ingestion.test.ts's RESOLUTION_TOPIC fixture constant to the real topic so the end-to-end ingestion test still exercises a matching event.
  • npx vitest run apps/indexer/src — all pass except 3 pre-existing, unrelated failures already present on dev (collateralDepositedParser.test.ts, storage.test.ts).
  • Updated docs/indexer-event-mapping.md and apps/indexer/fixtures/contract-event-vectors.json to document the corrected topic and payload shape.

Closes #589

itodo001 and others added 2 commits June 29, 2026 00:17
resolutionParser's topic constant ("market_resolved") never matched a
real event for the same reason as market_created: Soroban's
#[contractevent] macro snake-cases the full struct name including its
"Event" suffix, so MarketResolvedEvent (contracts/market/src/events.rs)
actually publishes under "market_resolved_event" — confirmed against
the contract's own test_emit_market_resolved unit test. Every
market_resolved event was silently skipped in production.

The "canonical on-chain tuple" shape the parser targeted was also a
guess that doesn't match the real event: MarketResolvedEvent carries
market_id as topics[1] (u32, a #[topic] field), with only
{ outcome: bool, resolved_at: u64 } in the value — not a 3-element
tuple packed into the value. parseResolutionPayload now reads
market_id from the topic for this shape, matching the issue's "u32
bool u64 payload" description exactly (u32 topic + bool/u64 value
fields, not a single tuple).

The pre-existing legacy ScvVec-tuple and legacy ScvMap (with
market_id/outcome/oracle in the value) code paths are left intact for
backward compatibility — detection now branches on whether the value
is an array, a map with "market_id", or a map without it (the real
shape).

Updated resolutionParser.test.ts and ingestion.test.ts's resolution
fixture to the real topic, and added new real-shape test vectors.
Updated docs/indexer-event-mapping.md and contract-event-vectors.json
to match.

Closes Vatix-Protocol#589
@Mimah97 Mimah97 merged commit b553bbf into Vatix-Protocol:dev Jun 30, 2026
1 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix resolutionParser for u32 bool u64 payload

3 participants