Skip to content

Support per-service owner authorization for self-service settlement #13

Description

@mikewheeleer

Allow a service owner to settle their own service without full admin

Description

settle in contracts/escrow/src/lib.rs requires the global admin's require_auth(), so the owner stored in ServiceMetadata.owner cannot trigger settlement for their own service — every settlement funnels through the central admin key. This issue lets the registered service owner authorize settlement for their own service, decentralising the operational load.

Requirements and context

  • Repository scope: Agentpay-Org/Agentpay-contracts only.
  • Modify settle so it accepts either the admin OR the ServiceMetadata(service_id).owner for that specific service, with the appropriate require_auth().
  • Reject settlement when no metadata/owner is set and the caller is not admin, with a clear typed error.
  • Keep the pause gate and counter-drain semantics unchanged; emit the settled event identically.
  • Document the authorization matrix (admin vs. owner) clearly.

Suggested execution

  • Fork the repo and create a branch
  • git checkout -b feature/contracts-13-owner-settle
  • Implement changes
    • Write code in: contracts/escrow/src/lib.rs — owner-or-admin auth branch in settle.
    • Write comprehensive tests in: contracts/escrow/src/test.rs — owner settles own service, owner cannot settle another service, admin always can.
    • Add documentation: document the auth matrix in README.md.
    • Include NatSpec-style doc comments (///) matching the existing style in lib.rs.
    • Validate security: owner of service A cannot settle service B; no metadata means admin-only.
  • Test and commit

Test and commit

  • Run cargo fmt --all -- --check, cargo build, and cargo test.
  • Cover edge cases: missing metadata, wrong owner, paused contract, admin override.
  • Include the full cargo test output and a short security notes section in the PR description.

Example commit message

feat: allow service owner to settle their own service

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

No fields configured for Feature.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions