Skip to content

Add remove_service_price to clear a configured price and revert a service to free #35

Description

@mikewheeleer

Implement a price-removal entrypoint for services

Description

set_service_price in contracts/escrow/src/lib.rs can write or overwrite a price under DataKey::ServicePrice(service_id), but there is no way to remove the entry — the only way to make a previously-priced service free again is to write 0, which leaves a dangling stored key paying ledger rent and is semantically ambiguous (an explicit zero price vs. no price configured both read back as 0 from get_service_price). This issue adds an explicit removal entrypoint so operators can fully retire a price.

Requirements and context

  • Repository scope: Agentpay-Org/Agentpay-contracts only.
  • Add remove_service_price(env, service_id): admin-gated via the existing Admin + require_auth() pattern, calling env.storage().persistent().remove(&DataKey::ServicePrice(service_id)). Idempotent — removing an absent price is a no-op.
  • Document that after removal get_service_price and compute_billing read back as the 0 default, identical to a never-priced service.
  • Emit a price_removed(service_id) event (additive) so indexers can distinguish a removal from a set to zero.
  • Honour the pause gate consistently with the other admin mutations.

Suggested execution

  • Fork the repo and create a branch
  • git checkout -b feature/contracts-remove-service-price
  • Implement changes
    • Write code in: contracts/escrow/src/lib.rsremove_service_price entrypoint + event.
    • Write comprehensive tests in: contracts/escrow/src/test.rs — set then remove returns get_service_price == 0; remove on never-priced service is a no-op; non-admin caller panics; event fires.
    • Add documentation: clarify the zero-vs-removed distinction in README.md.
    • Include NatSpec-style doc comments (///) matching the existing style in lib.rs.
    • Validate security: only admin can remove, no fund/billing inconsistency after removal.
  • Test and commit

Test and commit

  • Run cargo fmt --all -- --check, cargo build, and cargo test.
  • Cover edge cases: remove then re-set, remove an unregistered service's price, compute_billing after removal.
  • Include the full cargo test output and a short security notes section in the PR description.

Example commit message

feat: add remove_service_price to clear a configured 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.

Metadata

Metadata

Assignees

No fields configured for Feature.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions