Skip to content

feat(invoice-escrow): implement multi-token escrow funding support with accepted_tokens validation #379

Description

@chizzy192

Context & Problem Statement

Enterprises dealing with international invoices frequently accept multiple stablecoins (e.g. USDC, EURC, USDS) for settlement. Currently, each escrow is strictly locked to a single payment asset at creation time.

This issue implements multi-token funding support where the seller specifies a list of accepted_tokens: Vec<Address>. Contributors can fund with any accepted token, and the first contribution locks the asset for all remaining payment, distribution, and refund accounting.

Architectural Motivation & Technical Requirements

  • In contracts/invoice-escrow/src/types.rs:
    • Add accepted_tokens: Vec<Address> to EscrowData.
  • In contracts/invoice-escrow/src/lib.rs:
    • In create_escrow, accept accepted_tokens: Vec<Address>, ensuring it is non-empty and contains payment_token.
    • In fund_escrow, accept funding_token: Address, validating that funding_token is included in accepted_tokens.
    • Lock data.token = funding_token upon initial contribution.
    • Subsequent funding and settlement calls strictly enforce data.token.
  • In contracts/invoice-escrow/src/errors.rs:
    • Add TokenNotAccepted with unique discriminant.
  • In contracts/invoice-escrow/src/test.rs:
    • Test creation with multi-token whitelist.
    • Test funding with accepted token (succeeds) vs unaccepted token (fails).
    • Test locked token consistency across multiple funding transactions.

Acceptance Criteria

  • create_escrow validates non-empty accepted_tokens.
  • fund_escrow locks token asset on first contribution.
  • All 7 unit test scenarios pass.
  • cargo test -p invoice-escrow passes.

Target Branch: dev
Estimated Effort: 13–24 hours | Delivery: 6–7 days
Difficulty: Hard

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions