Skip to content

fix(events): emit events on completion, funding, release, and dispute resolution (#96) - #231

Open
Vyacheslav-Tomashevskiy wants to merge 1 commit into
vespera-labs:mainfrom
Vyacheslav-Tomashevskiy:fix/emit-missing-events-96
Open

fix(events): emit events on completion, funding, release, and dispute resolution (#96)#231
Vyacheslav-Tomashevskiy wants to merge 1 commit into
vespera-labs:mainfrom
Vyacheslav-Tomashevskiy:fix/emit-missing-events-96

Conversation

@Vyacheslav-Tomashevskiy

Copy link
Copy Markdown

Closes #96.

Off-chain indexers could not track several state changes because the functions that move funds or flip status emitted no events. This adds the missing events with naming consistent with the existing ones in each contract.

agent_registry

  • New TransactionCompleted event (topic txn_done, topics: transaction_id, agent; data: completed_agreements).
  • complete_transaction now publishes it with the agent's running completed-agreements total.

escrow

  • EscrowFunded — emitted by fund_escrow (topic escrow_funded; depositor, amount).
  • EscrowReleased — emitted by the full-release branch of approve_release once the 2-of-3 threshold executes (topic escrow_released; recipient, amount).
  • DisputeResolved — emitted by resolve_dispute (topic dispute_resolved; resolver, recipient, amount, refunded). The refunded boolean distinguishes a refund to the depositor (true) from a release to the beneficiary (false), satisfying the "refund vs release distinguished" criterion. The status branch was refactored to derive refunded once (behaviour unchanged).

Field naming mirrors the existing events (escrow_id as the indexed topic; amount/recipient as in PartialRelease).

Acceptance criteria

  • complete_transaction emits a new TransactionCompleted event with relevant fields
  • escrow emits events on funding, full release, and dispute resolution (refund vs release distinguished)
  • Event field naming consistent with existing events in each contract
  • Tests assert the new events are published

Tests

Added targeted tests that assert each new event fires (and, for full release, that no release event fires before the threshold). cargo test: agent_registry 24 passed, escrow 50 passed; rustfmt --check clean on the touched files; cargo clippy no warnings.

Note: the escrow test module did not compile on mainsetup_test returns a 6-tuple but several call sites still destructured 5 elements. I added the missing _admin binding at those sites so the suite (and the new tests) compile and run. This is a minimal, mechanical fix limited to test code.

Scope

Only the four state-changing functions named in the issue are touched. Out-of-scope items (standardizing topics across all contracts, event-schema docs) are left alone.

… resolution (vespera-labs#96)

Off-chain indexers could not track several fund movements and status
changes because the corresponding functions emitted no events.

agent_registry:
- add TransactionCompleted event; complete_transaction now emits it with
  the agent's running completed_agreements count.

escrow:
- add EscrowFunded (fund_escrow), EscrowReleased (full-release branch of
  approve_release), and DisputeResolved (resolve_dispute) events.
- DisputeResolved carries a `refunded` flag distinguishing a refund to the
  depositor from a release to the beneficiary, plus resolver/recipient/amount.
- field naming kept consistent with existing events (escrow_id topic,
  amount/recipient like PartialRelease).

Tests assert each new event is published (agent_registry: 24 pass,
escrow: 50 pass). Also restore the escrow test suite to a compiling state
by aligning the remaining 5-tuple setup_test call sites with the current
6-tuple signature.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Vyacheslav-Tomashevskiy

Copy link
Copy Markdown
Author

This closes #96. All four acceptance criteria are implemented with tests (agent_registry 24 pass, escrow 50 pass, fmt/clippy clean), and the diff is limited to the four functions named in the issue plus the missing event definitions.

For the record on assignment: #96 was assigned via GrantFox on 2026-06-18, but no PR has been opened against it in the 13 days since (the only prior attempt, #160, was closed unmerged). I put up a complete, tested implementation so it doesn't stay open — happy to defer or rework if the original assignee is still active.

RTC wallet for any bounty payout: RTCd1554f0f35576faf01d386a6be1c947f560dd0b7

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.

[Contracts] Emit missing events on state-changing functions in agent_registry and escrow

1 participant