Skip to content

feat(contracts): add structured contract events with indexed topics - #49

Merged
meshackyaro merged 3 commits into
workman-labs:developmentfrom
Chigybillionz:feat/45-structured-contract-events
Aug 30, 2026
Merged

feat(contracts): add structured contract events with indexed topics#49
meshackyaro merged 3 commits into
workman-labs:developmentfrom
Chigybillionz:feat/45-structured-contract-events

Conversation

@Chigybillionz

Copy link
Copy Markdown
Contributor
feat(contracts): structured contract events with indexed topics across escrow, reputation & loyalty

Summary

Adds a complete event layer to all three core contracts. Every state-changing entry point now emits exactly one typed event with indexable topics, enabling the on-chain ingestion pipeline (#22) to filter by appointment, worker, or client without scanning every ledger. Failed operations emit nothing.

Issue

Closes #45 

Root Cause

None of the three contracts published events on state changes, making contract state invisible off-chain and blocking the ingestion pipeline.
---
Solution Implemented

Added  #[contractevent]  structs with topic annotations to each contract, emitting via  .publish(&env)  after all state mutations. Topics use a two-symbol prefix ( contract/action ) followed by  #[topic]  fields for indexed filtering. Data uses  Map<Symbol, Val>  format for stable field names.
---
Key Changes

- 16 new event types across 3 contracts with deterministic topic ordering
- SEP-41-compatible  Transfer  and  Burn  events on loyalty-token
- Full event catalogue documented in contracts README with indexer filtering examples
- Comprehensive event tests including adversarial (no-event-on-failure) assertions

Affected Files

-  contracts/escrow/src/lib.rs  — 11 event structs + publish calls
-  contracts/reputation/src/lib.rs  — 1 event struct + publish call
-  contracts/loyalty-token/src/lib.rs  — 4 event structs + publish calls
-  contracts/escrow/src/test.rs  — event assertions
-  contracts/reputation/src/test.rs  — event assertions
-  contracts/loyalty-token/src/test.rs  — event assertions
-  README.md  — event catalogue documentation
---
Trade-offs / Considerations

-  approve  does not emit an event — SEP-41 does not define one, and adding it would deviate from standard tooling expectations
- CI cargo caching was already in place ( Swatinem/rust-cache@v2  in  .github/workflows/soroban-ci.yml ), so no changes needed
- The WASM target is  wasm32v1-none  (not  wasm32-unknown-unknown ) per Soroban SDK requirements on Rust 1.82+

Testing

-  cargo fmt --check  — pass
-  cargo clippy --workspace -- -D warnings  — pass
-  cargo test --workspace  — 286/286 pass
-  cargo build --workspace --target wasm32v1-none --release  — pass
---
CI Verification

All CI-equivalent local checks pass. The repository's  .github/workflows/soroban-ci.yml  runs  cargo fmt --check ,  cargo clippy -- -D warnings ,  cargo test , and  soroban contract build  — all validated locally.
---
Please verify my work

Chigybillionz and others added 3 commits August 23, 2026 12:45
Publish a consistent, documented event on every state-changing entry point
across escrow (11 events), reputation (1 event), and loyalty-token (4 events).
Topics are chosen so an off-chain indexer can filter by appointment_id, worker,
or client address without scanning every ledger. SEP-41 conventions followed
for loyalty-token transfer/burn events. Full event catalogue documented in README.

Closes workman-labs#45

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
@Chigybillionz

Copy link
Copy Markdown
Contributor Author

please comfirm this my branch

@meshackyaro
meshackyaro merged commit 1a4dfa2 into workman-labs:development Aug 30, 2026
1 check 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.

2 participants