Skip to content

Add creator-set minimum contributor count before release #422

Description

@Kingsman-99

Description

Some fundraising invoices should only release if a minimum number of unique contributors participated, preventing a single whale from silently funding an invoice that was intended for broad community participation. This issue adds min_contributors: Option<u32> to invoices with enforcement at release time.

Technical Context

Add min_contributors: Option<u32> to the Invoice struct in types.rs and a contributor_count_key(invoice_id) -> u32 storage entry in lib.rs. Increment the counter in pay_invoice only for first-time payers on that invoice (check payment_exists_key(invoice_id, payer)). In release_invoice, if min_contributors is set and contributor_count < min_contributors, panic with InsufficientContributors.

Acceptance Criteria

  • create_invoice accepts optional min_contributors
  • Contributor count is incremented at most once per unique payer per invoice
  • release_invoice panics with InsufficientContributors if count below threshold
  • get_contributor_count(env, invoice_id) -> u32 view function exposed
  • Invoices without min_contributors release with no count check (existing behaviour)
  • Tests: exact count, under count blocked, over count passes, same payer multi-payment counts once
  • All CI checks (cargo test, cargo clippy, cargo fmt) pass and the branch has no merge conflicts

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave programcomplexity: highComplex feature requiring deep knowledge - 200 ptsfeatureNew contract feature or operation

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions