Skip to content

feat(storage): emit state-change event - #431

Merged
mikewheeleer merged 2 commits into
Agentpay-Org:mainfrom
Jagadeeshftw:feature/storage-02-event
Jul 28, 2026
Merged

feat(storage): emit state-change event#431
mikewheeleer merged 2 commits into
Agentpay-Org:mainfrom
Jagadeeshftw:feature/storage-02-event

Conversation

@Jagadeeshftw

Copy link
Copy Markdown
Contributor

Summary

set_agent_allowed and set_agent_blocked write DataKey::AgentAllowed/DataKey::AgentBlocked but were the only per-agent boolean setters that emitted no event — every sibling setter (set_allowlist_enabled, set_require_service_registration, etc.) already publishes a cfg_set event on write.

  • set_agent_allowed now emits agt_alw(agent, allowed) after the storage write.
  • set_agent_blocked now emits agt_blk(agent, blocked) after the storage write.
  • Both topics are 7 characters, well under the symbol_short! 9-char limit, and distinct from every existing topic (no collision).
  • No change to fund movement, authorization, or existing return values.

Tests added

  • test_set_agent_allowed_emits_agt_alw_event — payload correctness on first call
  • test_set_agent_allowed_emits_event_on_every_toggle — a second, independent call emits its own event with the new value
  • test_set_agent_blocked_emits_agt_blk_event — payload correctness on first call
  • test_set_agent_blocked_emits_event_on_every_toggle — same for the blocklist setter
  • test_agt_alw_and_agt_blk_topics_do_not_collide — the two new topics are captured independently and never conflated

Closes #287

Validation

  • cargo fmt --all -- --check
  • cargo clippy --all-targets -- -D warnings
  • cargo test -p escrow — 357 passed (5 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/storage-02-event branch from 9cc2191 to 0a7971a Compare July 28, 2026 21:17
@mikewheeleer
mikewheeleer merged commit 36e9184 into Agentpay-Org:main Jul 28, 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 storage state changes

2 participants