Skip to content

fix(stellar): query announcer buckets via Soroban RPC topic filters#43

Merged
truthixify merged 1 commit into
wraith-protocol:developfrom
wheval:fix/stellar-v2-bucketed-getevents-filters
Jun 3, 2026
Merged

fix(stellar): query announcer buckets via Soroban RPC topic filters#43
truthixify merged 1 commit into
wraith-protocol:developfrom
wheval:fix/stellar-v2-bucketed-getevents-filters

Conversation

@wheval

@wheval wheval commented May 31, 2026

Copy link
Copy Markdown

Summary

Updates the Wraith Stellar SDK event ingestion path to use Soroban RPC topic filters for the v2 announcer schema, while continuing to read the legacy v1 announcer stream during the migration window.

Purpose / Motivation

The current fetchAnnouncements() implementation downloads every event from the v1 announcer contract and filters client-side. As announcement volume grows, that wastes bandwidth and RPC cost. Soroban supports indexed topic filters via getEvents; the v2 announcer schema (contracts #24) exposes view_tag_bucket as topic slot 2 so clients can request only the buckets they need.

Changes Made

  • Added event-filters.ts with helpers to build v1 and v2 Soroban RPC filters:
    • v1: ("announce", *, *) on contracts.announcer
    • v2 bucket: ("announce", 2, view_tag_bucket, *) on contracts.announcerV2
    • v2 all: ("announce", 2, *, *)
  • Refactored fetchAnnouncements() to ingest v1 + v2 during transition, dedupe overlapping results, and accept viewTagBuckets for targeted v2 queries
  • Added dual-layout event parsing (3-topic v1 vs 4-topic v2)
  • Extended scanAnnouncements() to accept scheme ID 2 (v2)
  • Documented privacy trade-offs in EVENT_FETCHING.md and fetchAnnouncements JSDoc
  • Added tests for filter construction, v1/v2 parsing, and mixed ingestion

Set contracts.announcerV2 in deployments once the v2 contract from wraith-protocol/contracts#24 is deployed.

How to Test

  1. Install dependencies: npm install
  2. Run Stellar tests:
    npm test -- test/chains/stellar/event-filters.test.ts test/chains/stellar/announcements.test.ts test/chains/stellar/scan.test.ts
  3. Verify filter construction:
    import { buildV2BucketEventFilter } from '@wraith-protocol/sdk/chains/stellar';
    buildV2BucketEventFilter('C...', 42);
    // topics: ("announce", 2, 42, *)

Breaking Changes

None for existing callers. fetchAnnouncements('stellar') remains valid and continues fetching the v1 stream. v2 ingestion is opt-in via contracts.announcerV2 deployment config.

Related Issues

Closes wraith-protocol/contracts#25

Checklist

  • Code builds successfully
  • Tests added/updated
  • Documentation updated

@truthixify truthixify changed the base branch from main to develop June 1, 2026 15:36
@truthixify

Copy link
Copy Markdown
Contributor

Direction is correct, this is the SDK companion to contracts #26's v2 event topic design. The new event-filters.ts and the legacy v1 dual-read approach are what we want.

Same rebase blocker as the other PRs this round. Could you rebase and limit the diff to the v2 topic-filter additions?

git fetch origin
git rebase origin/develop
# during the rebase, keep your event-filters.ts, the scan.test/scan.ts additions, and announcements changes that add bucket-based fetching
# drop any reverting changes to src/chains/stellar/* that you didn't intend to touch (the rest of develop already has JSDoc and range filtering)
git push --force-with-lease

Thanks @wheval.

Rebase onto develop and integrate v2 bucketed getEvents filters without
reverting existing range filtering, streaming, or JSDoc. Adds event-filters
helpers, dual v1/v2 ingestion in fetchAnnouncements, and v2 scheme support
in scanAnnouncements.

Closes wraith-protocol/contracts#25
@wheval wheval force-pushed the fix/stellar-v2-bucketed-getevents-filters branch from 328b391 to 0ccc4ad Compare June 2, 2026 17:53
@wheval

wheval commented Jun 2, 2026

Copy link
Copy Markdown
Author

@truthixify please review

@truthixify

Copy link
Copy Markdown
Contributor

Local test merge into develop is clean now. The event-filters.ts module + tests are the right SDK companion to the v2 announcer schema landed in contracts #41. Merging. Thanks @wheval.

@truthixify truthixify merged commit ccf37ec into wraith-protocol:develop Jun 3, 2026
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.

Update Stellar SDK event fetching to query announcer buckets at RPC layer

2 participants