Skip to content

feat(events): emit state-change event - #432

Merged
mikewheeleer merged 2 commits into
Agentpay-Org:mainfrom
Jagadeeshftw:feature/events-05-event
Jul 29, 2026
Merged

feat(events): emit state-change event#432
mikewheeleer merged 2 commits into
Agentpay-Org:mainfrom
Jagadeeshftw:feature/events-05-event

Conversation

@Jagadeeshftw

Copy link
Copy Markdown
Contributor

Summary

propose_admin_transfer and cancel_admin_transfer write DataKey::PendingAdmin (set / remove respectively) but were the only two admin-facing entrypoints that emit no event — accept_admin_transfer (step 2 of the same handover flow) already emits admin_chg.

  • propose_admin_transfer now emits admin_prp(admin, new_admin) after the storage write, including on a re-proposal that overwrites a still-pending entry.
  • cancel_admin_transfer now emits admin_can(admin, cancelled) after the storage write, where cancelled: Option<Address> is the pending address that was cleared — None when the call was a documented no-op, so indexers can distinguish a deliberate no-op cancel from a call that never happened.
  • Both topics are 9 characters, at the symbol_short! limit, and distinct from every existing topic (no collision, verified against docs/escrow/events.md's catalog).
  • No change to authorization, the two-step handover semantics, or accept_admin_transfer's existing admin_chg event.

Tests added

  • test_propose_admin_transfer_emits_admin_prp_event — payload correctness
  • test_repropose_admin_transfer_emits_event_with_new_target — re-proposing emits a fresh event with the new target
  • test_cancel_admin_transfer_emits_admin_can_event_with_cancelled_target — cancelling a pending proposal reports the cancelled address
  • test_cancel_admin_transfer_noop_emits_event_with_none — the no-op path still emits, with None

Closes #292

Validation

  • cargo fmt --all -- --check
  • cargo clippy --all-targets -- -D warnings
  • cargo test -p escrow — 356 passed (4 new), 1 pre-existing failure unrelated to this change (test_transfer_service_ownership_genuine_transfer_emits_event, fails identically on main)

env.events().all() reflects only the most recent contract invocation, not
a running total across separate calls (consistent with every other event
test in this file). The test compared post-transfer event count against a
pre-transfer count captured after a *different* call (set_service_metadata),
expecting accumulation that never happens, so it failed on every run
regardless of contract behavior. Fixed to assert directly on this call's
own event count.
@Jagadeeshftw
Jagadeeshftw force-pushed the feature/events-05-event branch from b3d4b61 to 533a9b5 Compare July 28, 2026 21:18
@mikewheeleer

Copy link
Copy Markdown
Contributor

solid PR @Jagadeeshftw — green build, merging 🙌

@mikewheeleer
mikewheeleer merged commit 655685a into Agentpay-Org:main Jul 29, 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.

Emit a dedicated event when events state changes

2 participants