Implement metadata removal for retired services
Description
set_service_metadata in contracts/escrow/src/lib.rs can write or overwrite a ServiceMetadata entry, and get_service_metadata returns Option<ServiceMetadata>, but there is no way to clear an entry once written. When a service is retired with unregister_service, its description and owner linger under DataKey::ServiceMetadata, paying ledger rent and showing up as a phantom owner in dashboards. This issue adds an explicit metadata-removal entrypoint so a retirement can be clean.
Requirements and context
- Repository scope:
Agentpay-Org/Agentpay-contracts only.
- Add
clear_service_metadata(env, service_id): admin-gated via the existing pattern, calling remove(&DataKey::ServiceMetadata(service_id)). Idempotent — clearing an absent entry is a no-op.
- After clearing,
get_service_metadata must read back as None, matching the never-set state.
- Emit a
meta_clear(service_id) event (additive) so indexers can prune their view.
- Document the relationship with
unregister_service (registration and metadata are independent slots; clearing one does not touch the other).
Suggested execution
- Fork the repo and create a branch
git checkout -b enhancement/contracts-clear-service-metadata
- Implement changes
- Write code in:
contracts/escrow/src/lib.rs — clear_service_metadata entrypoint + event.
- Write comprehensive tests in:
contracts/escrow/src/test.rs — set then clear returns None; clear on never-set is a no-op; registration flag untouched; non-admin caller panics.
- Add documentation: clarify metadata vs. registration lifecycle in
README.md.
- Include NatSpec-style doc comments (
///) matching the existing style in lib.rs.
- Validate security: only admin can clear, no accidental registration removal.
- Test and commit
Test and commit
- Run
cargo fmt --all -- --check, cargo build, and cargo test.
- Cover edge cases: clear then re-set, clear after unregister, usage history preserved.
- Include the full
cargo test output and a short security notes section in the PR description.
Example commit message
feat: add clear_service_metadata for clean service retirement
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.
Implement metadata removal for retired services
Description
set_service_metadataincontracts/escrow/src/lib.rscan write or overwrite aServiceMetadataentry, andget_service_metadatareturnsOption<ServiceMetadata>, but there is no way to clear an entry once written. When a service is retired withunregister_service, its description and owner linger underDataKey::ServiceMetadata, paying ledger rent and showing up as a phantom owner in dashboards. This issue adds an explicit metadata-removal entrypoint so a retirement can be clean.Requirements and context
Agentpay-Org/Agentpay-contractsonly.clear_service_metadata(env, service_id): admin-gated via the existing pattern, callingremove(&DataKey::ServiceMetadata(service_id)). Idempotent — clearing an absent entry is a no-op.get_service_metadatamust read back asNone, matching the never-set state.meta_clear(service_id)event (additive) so indexers can prune their view.unregister_service(registration and metadata are independent slots; clearing one does not touch the other).Suggested execution
git checkout -b enhancement/contracts-clear-service-metadatacontracts/escrow/src/lib.rs—clear_service_metadataentrypoint + event.contracts/escrow/src/test.rs— set then clear returnsNone; clear on never-set is a no-op; registration flag untouched; non-admin caller panics.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: add clear_service_metadata for clean service retirementGuidelines
Community & contribution rewards