Refactor event topics into named constants with a consistent scheme
Description
Event topics in contracts/escrow/src/lib.rs are scattered inline symbol_short! literals — "usage", "settled", "price_set", "price_rm", "paused", "svc_reg", "owner_chg", "meta_clr" — with no central registry. The abbreviation style is inconsistent (price_rm vs price_set, meta_clr vs owner_chg), some are truncated to fit the 9-char limit in ad-hoc ways, and a typo in one literal would silently emit an undiscoverable topic. This issue centralises every topic into named constants so the scheme is consistent, auditable, and reused.
Requirements and context
- Repository scope:
Agentpay-Org/Agentpay-contracts only.
- Define a module-level set of topic constants (e.g.
const TOPIC_USAGE: Symbol = symbol_short!("usage");) for every emitted event and route all env.events().publish calls through them.
- This is a pure refactor — the emitted topics and payloads must be byte-for-byte identical to today so existing indexers are unaffected; only the source representation changes.
- Add a comment block documenting the topic scheme and the 9-char
symbol_short! constraint so future events follow it.
- The existing test suite must pass unchanged; add a regression test asserting a representative event still publishes the exact same topic.
Suggested execution
- Fork the repo and create a branch
git checkout -b refactor/contracts-event-topic-constants
- Implement changes
- Write code in:
contracts/escrow/src/lib.rs — topic constants + replace inline literals.
- Write comprehensive tests in:
contracts/escrow/src/test.rs — existing tests pass; assert one event's topic is unchanged after the refactor.
- Add documentation: note the topic-constant convention in a module comment.
- Include NatSpec-style doc comments (
///) on the constants block.
- Validate security: no topic or payload changed; no silent typo introduced.
- Test and commit
Test and commit
- Run
cargo fmt --all -- --check, cargo build, and cargo test.
- Cover edge cases: every existing event topic matches its prior literal exactly.
- Include the full
cargo test output and a short security notes section in the PR description.
Example commit message
refactor: centralise event topics into named symbol constants
Guidelines
- Minimum 95 percent test coverage for impacted modules.
- Clear, reviewer-focused documentation.
- Timeframe: 96 hours.
Community & contribution rewards
- 💬 Join the AgentPay community on Discord for questions, reviews, and faster merges: https://discord.gg/eXvRKkgcv
- ⭐ This is a GrantFox OSS / Official Campaign task and may be rewarded. When your PR is merged you'll be prompted to rate the project — if this issue and the maintainers helped you ship, we'd be grateful for a 5-star rating. Clear questions in Discord and tidy, well-tested PRs are the fastest path to a merge and a reward.
Refactor event topics into named constants with a consistent scheme
Description
Event topics in
contracts/escrow/src/lib.rsare scattered inlinesymbol_short!literals —"usage","settled","price_set","price_rm","paused","svc_reg","owner_chg","meta_clr"— with no central registry. The abbreviation style is inconsistent (price_rmvsprice_set,meta_clrvsowner_chg), some are truncated to fit the 9-char limit in ad-hoc ways, and a typo in one literal would silently emit an undiscoverable topic. This issue centralises every topic into named constants so the scheme is consistent, auditable, and reused.Requirements and context
Agentpay-Org/Agentpay-contractsonly.const TOPIC_USAGE: Symbol = symbol_short!("usage");) for every emitted event and route allenv.events().publishcalls through them.symbol_short!constraint so future events follow it.Suggested execution
git checkout -b refactor/contracts-event-topic-constantscontracts/escrow/src/lib.rs— topic constants + replace inline literals.contracts/escrow/src/test.rs— existing tests pass; assert one event's topic is unchanged after the refactor.///) on the constants block.Test and commit
cargo fmt --all -- --check,cargo build, andcargo test.cargo testoutput and a short security notes section in the PR description.Example commit message
refactor: centralise event topics into named symbol constantsGuidelines
Community & contribution rewards