Skip to content

fix(contracts): reject identical payer and beneficiary with InvalidParties error - #2073

Open
ranjan1969x wants to merge 1 commit into
DistinctCodes:mainfrom
ranjan1969x:feat/escrow-parties-validation-2003
Open

ranjan1969x wants to merge 1 commit into
DistinctCodes:mainfrom
ranjan1969x:feat/escrow-parties-validation-2003

Conversation

@ranjan1969x

Copy link
Copy Markdown

Summary

Enforces party distinction on escrow creation by rejecting payer == beneficiary with a new Error::InvalidParties (#22), documents the single-use ID and persistent storage retention rules in contracts/README.md, and synchronizes TypeScript shared error codes and client enums.

Changes

  • Smart Contract (contracts/payment_escrow/src/lib.rs):
    • Added InvalidParties = 22 variant to pub enum Error.
    • Added validation check if payer == beneficiary { return Err(Error::InvalidParties); } to create.
  • Documentation (contracts/README.md):
    • Added InvalidParties (#22) to the Error Codes table.
    • Documented Parties Validation and ID Uniqueness Rules (IDs are single-use for the entire lifetime of the contract; resolved escrows permanently retain their storage entry to prevent ID reuse and guarantee idempotency).
  • TypeScript Integration:
    • Updated contracts/shared/error-codes.ts with InvalidParties = 22 and name mapping.
    • Updated ContractError enum in backend/src/payments/soroban/escrow-contract.client.ts.
  • Tests:
    • Added unit test identical_payer_and_beneficiary_is_rejected in contracts/payment_escrow/tests/edge_cases.rs.
    • Added unit test id_reuse_after_release_is_rejected verifying that re-creating an escrow with a released ID is rejected with AlreadyExists.

Verification

  • cargo test --workspace (31/31 contract tests passing, 100% green)
  • npm test -- src/payments/soroban/ (9 test suites passed, 78/78 tests green)

Closes #2003

…rties error

Reject escrow creation when payer == beneficiary with Error::InvalidParties (DistinctCodes#22).
Document id uniqueness and persistent retention rules in contracts/README.md,
synchronize shared TypeScript error codes and client enum, and add test coverage
for party validation and post-release id reuse.

Closes DistinctCodes#2003
@vercel

vercel Bot commented Nov 8, 2026

Copy link
Copy Markdown

@ranjan1969x is attempting to deploy a commit to the naijabuz's projects Team on Vercel.

A member of the Team first needs to authorize it.

This branch has not been deployed

No deployments
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.

Escrow create accepts payer == beneficiary and the id-reuse rule is undocumented

1 participant