Skip to content

feat(escrow): bounded admin setter for settlement limit with auth and events - #1204

Open
mimi-esc wants to merge 1 commit into
Liquifact:mainfrom
mimi-esc:feat/settlement-limit-setter
Open

feat(escrow): bounded admin setter for settlement limit with auth and events#1204
mimi-esc wants to merge 1 commit into
Liquifact:mainfrom
mimi-esc:feat/settlement-limit-setter

Conversation

@mimi-esc

Copy link
Copy Markdown

Summary

Adds an admin-guarded, bounded setter for the escrow's settlement-batch ceiling (set_settlement_limit) with a typed error, an event carrying old/new values, and a read view.

Approach

  • Named boundsMIN_SETTLEMENT_LIMIT / MAX_SETTLEMENT_LIMIT / DEFAULT_SETTLEMENT_LIMIT replace the hard-coded MAX_SETTLE_BATCH constant.
  • Reused admin guardset_settlement_limit calls load_escrow_require_admin, matching the existing admin-only setter pattern (set_protocol_fee_bps, set_storage_limit).
  • Typed errorEscrowError::SettlementLimitOutOfRange (stable code 236) for out-of-range values; no leaked internals.
  • EventSettlementLimitUpdated { name, invoice_id, old_limit, new_limit }, emitted only when the stored value actually changes.
  • Read viewsget_settlement_limit() and the existing get_settlement_config() now expose the current ceiling.
  • Wired into behaviorsettle_batch now enforces the configured ceiling instead of the hard-coded MAX_SETTLE_BATCH (default stays 50, so existing behavior is unchanged until an admin tunes it).

Edge cases covered (tests)

  • In-bounds set by admin → applied, event emitted.
  • Out-of-bounds → rejected with SettlementLimitOutOfRange.
  • Non-admin set → rejected.
  • Read view reflects the change (individual getter + bundled config view).
  • Event carries correct old/new values across consecutive changes.
  • settle_batch enforces the configured limit.

Verification

  • cargo fmt -p liquifact_escrow -- --check
  • cargo clippy -p liquifact_escrow --all-targets -- -D warnings
  • cargo test -p liquifact_escrow ✅ (7 new tests pass)
  • cargo build --target wasm32v1-none --release -p liquifact_escrow

Closes #1202

Add an admin-guarded set_settlement_limit entrypoint that bounds the
per-call settlement-batch ceiling to [MIN, MAX] and emits a
SettlementLimitUpdated event carrying the old/new values. Expose the
current value via get_settlement_limit and the bundled
get_settlement_config view, and wire settle_batch to enforce the
configured (rather than hard-coded) ceiling.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
@mikewheeleer

Copy link
Copy Markdown
Contributor

Hi @mimi-esc — this pull request currently has merge conflicts with the latest main branch. Please resolve the conflicts and push the updated branch so it can be merged. Thank you!

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.

bounded admin parameter setter for escrow with auth and events

2 participants