Harden set_service_price to require a registered service
Description
set_service_price in contracts/escrow/src/lib.rs accepts a price for any service_id, even one that was never registered, has no metadata, and is disabled. This lets prices accumulate for phantom services and makes the registry and pricing tables drift apart. This issue optionally couples pricing to registration so prices can only attach to real services.
Requirements and context
- Repository scope:
Agentpay-Org/Agentpay-contracts only.
- Add an admin toggle (reusing the
RequireServiceRegistration flag, or a parallel one) so that, when enabled, set_service_price rejects unregistered service_ids with ServiceNotRegistered.
- Optionally also reject pricing a disabled service, mirroring
record_usage's ServiceDisabled gate.
- Keep the default behaviour backward-compatible (no coupling unless the flag is on) and document the interaction with strict-registration mode.
- Emit the
price_set event only after the validation passes.
Suggested execution
- Fork the repo and create a branch
git checkout -b enhancement/contracts-11-price-requires-registration
- Implement changes
- Write code in:
contracts/escrow/src/lib.rs — registration/disabled checks in set_service_price.
- Write comprehensive tests in:
contracts/escrow/src/test.rs — pricing unregistered service rejected when strict, allowed when lax.
- Add documentation: clarify the coupling in
README.md.
- Include NatSpec-style doc comments (
///) matching the existing style in lib.rs.
- Validate security: no behaviour change when the flag is off.
- Test and commit
Test and commit
- Run
cargo fmt --all -- --check, cargo build, and cargo test.
- Cover edge cases: registered+priced, unregistered+strict, disabled service, flag toggled mid-life.
- Include the full
cargo test output and a short security notes section in the PR description.
Example commit message
feat: optionally require service registration before set_service_price
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.
Harden set_service_price to require a registered service
Description
set_service_priceincontracts/escrow/src/lib.rsaccepts a price for anyservice_id, even one that was never registered, has no metadata, and is disabled. This lets prices accumulate for phantom services and makes the registry and pricing tables drift apart. This issue optionally couples pricing to registration so prices can only attach to real services.Requirements and context
Agentpay-Org/Agentpay-contractsonly.RequireServiceRegistrationflag, or a parallel one) so that, when enabled,set_service_pricerejects unregisteredservice_ids withServiceNotRegistered.record_usage'sServiceDisabledgate.price_setevent only after the validation passes.Suggested execution
git checkout -b enhancement/contracts-11-price-requires-registrationcontracts/escrow/src/lib.rs— registration/disabled checks inset_service_price.contracts/escrow/src/test.rs— pricing unregistered service rejected when strict, allowed when lax.README.md.///) matching the existing style inlib.rs.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
feat: optionally require service registration before set_service_priceGuidelines
Community & contribution rewards