Skip to content

feat(adapters): implement LayerZero V2 parse_event - #6

Merged
Patrick-Ehimen merged 4 commits into
mainfrom
feat/layerzero-v2-adapter
Jul 16, 2026
Merged

Patrick-Ehimen merged 4 commits into
mainfrom
feat/layerzero-v2-adapter

Conversation

@Patrick-Ehimen

Copy link
Copy Markdown
Member

Summary

  • Implements parse_event on the LayerZeroV2 adapter using alloy's sol! macro to decode PacketSent logs from the LZ V2 Endpoint contract (0x1a44076050125825900e736c501f859c50fE728c)
  • Slices encodedPacket at fixed byte offsets per PacketV1Codec layout to extract srcEid, dstEid, sender, receiver, and GUID — the GUID is stored as correlation_id and is the key the stitcher uses in Step 3 to join source + destination events
  • Adds eid_to_chain() lookup mapping LZ endpoint IDs → internal ChainId for all 7 indexed EVM chains
  • Adds uuid and chrono as direct indexer deps since parse_event now constructs real CrossChainEvent values
  • Tests in layerzero_v2_tests.rs (wired via #[path])

Test plan

  • cargo clippy --workspace --all-targets -- -D warnings — clean
  • cargo test -p indexer — 4/4 pass
    • parses_valid_packet_sent — all fields map correctly end-to-end
    • rejects_wrong_topic — returns None without touching packet bytes
    • returns_none_for_short_packet — no panic on truncated encodedPacket
    • unknown_eid_gives_none_dest_chain — unmapped chain produces dest_chain: None, event is not dropped

Decodes PacketSent logs from the LZ V2 Endpoint contract using alloy sol!
macro. Slices encodedPacket at fixed offsets per PacketV1Codec layout to
extract srcEid, dstEid, sender, receiver, and GUID (stored as correlation_id).
Adds endpoint ID → ChainId lookup for all 7 indexed EVM chains.

Also adds uuid and chrono as direct indexer deps since parse_event
constructs CrossChainEvent values that need Uuid::new_v4() and Utc::now().
Four tests: happy path (all fields), wrong topic returns None, truncated
packet returns None without panic, unknown dst eid produces dest_chain: None.
Tests live in a separate file wired via #[path] to keep the adapter module clean.
Relocates layerzero_v2_tests.rs → src/adapters/tests/layerzero_v2.rs and
updates the #[path] reference. All 4 tests still pass. Also commits Cargo.lock
update from adding uuid and chrono as direct indexer deps.
@Patrick-Ehimen
Patrick-Ehimen merged commit 8891255 into main Jul 16, 2026
5 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.

1 participant