Skip to content

refactor(settlement): extract shared check helper - #440

Merged
mikewheeleer merged 1 commit into
Agentpay-Org:mainfrom
thlpkee20-wq:refactor/settlement-01-helper
Jul 29, 2026
Merged

refactor(settlement): extract shared check helper#440
mikewheeleer merged 1 commit into
Agentpay-Org:mainfrom
thlpkee20-wq:refactor/settlement-01-helper

Conversation

@thlpkee20-wq

Copy link
Copy Markdown
Contributor

Summary

  • settle and settle_all each repeated the same "caller is admin or the service's ServiceMetadata.owner" check inline, including duplicated error handling for a missing ServiceMetadata entry.
  • Extracted into a private require_settlement_authorized helper. Each entrypoint passes its own existing rejection code (settleNotPendingAdmin, settle_allUnauthorized), so behaviour and typed error codes are unchanged — no ABI change.
  • Added 4 regression tests covering the unauthorized and missing-ServiceMetadata rejection paths for both settle and settle_all, which had no direct test coverage before this extraction.

Test plan

cargo fmt --check
cargo clippy --all-targets -- -D warnings
cargo test --workspace
test result: ok. 362 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 4.62s

Closes #300

settle and settle_all each repeated the same "caller is admin or the
service's ServiceMetadata.owner" check inline, including duplicated
error handling for a missing ServiceMetadata entry. Extracted into
require_settlement_authorized, which takes the caller-specific
rejection code as a parameter so each entrypoint keeps its existing
typed error (settle: NotPendingAdmin, settle_all: Unauthorized) --
no ABI or rejection-behaviour change. Added regression tests for the
unauthorized and missing-metadata paths on both entrypoints, which
had no direct coverage before this extraction.

Closes Agentpay-Org#300
@mikewheeleer

Copy link
Copy Markdown
Contributor

clean work @thlpkee20-wq — CI green, merging 🎉

@mikewheeleer
mikewheeleer merged commit 1448a0e into Agentpay-Org:main Jul 29, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extract the repeated settlement check into a shared helper

2 participants