Skip to content

Add beneficiary rotation entrypoint to change sme_address before settlement #249

@mikewheeleer

Description

@mikewheeleer

Description

InvoiceEscrow.sme_address is fixed at init and is the sole authority for withdraw, settle, and record_sme_collateral_commitment, yet docs/ESCROW_BENEFICIARY_ROTATION.md describes a rotation flow that has no on-chain entrypoint. Add a governed rotate_beneficiary so the SME beneficiary can be updated (e.g. for assignment/factoring) without redeploying.

Requirements and context

  • Scoped to the LiquiFact escrow Soroban contract.
  • Require dual consent: current sme_address auth and admin auth; only allowed in non-terminal states (status 0 or 1).
  • Reject rotation to the same address; emit a BeneficiaryRotated #[contractevent].
  • Invariant: after rotation, only the new SME may withdraw/settle; collateral metadata ownership transfers with it.
  • Align behavior with docs/ESCROW_BENEFICIARY_ROTATION.md.
  • Must be secure, tested, and documented.

Suggested execution

  • Fork the repo and create a branch:
    • git checkout -b feature/rotate-beneficiary
  • Implement changes:
    • escrow/src/lib.rs
    • Tests: escrow/src/tests/admin.rs
    • Docs: docs/ESCROW_BENEFICIARY_ROTATION.md
    • Include rustdoc/NatSpec-style doc comments on public functions
    • Validate security assumptions (auth, overflow, storage TTL, double-spend)

Test and commit

  • Run tests: cargo test
  • Cover edge cases (zero amounts, overflow, unauthorized callers, double-spend, state-machine misuse)
  • Include test output and security notes in the PR

Example commit message

feat(escrow): governed beneficiary rotation entrypoint

Guidelines

  • Minimum 95% test coverage on new/changed code
  • Clear documentation
  • Timeframe: 96 hours from assignment

Metadata

Metadata

Assignees

Type

No fields configured for Task.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions