From 8dd5a8963cab992b1b12c64ebcfa273f1265cafb Mon Sep 17 00:00:00 2001 From: Tijesunimi004 Date: Thu, 20 Aug 2026 15:03:35 +0100 Subject: [PATCH] fix(campaign-escrow): reject reject_submission after completion_deadline claim_payment auto-approves a submitted proof once completion_deadline passes, as a safety valve against an unresponsive business. Without a matching check, reject_submission let the business flip an auto-approved submission to Rejected after the deadline, leaving the creator unable to submit_proof again (blocked by the same deadline) or claim_payment (status no longer ProofSubmitted). That defeats the auto-approval guarantee entirely. --- contracts/campaign-escrow/src/lib.rs | 3 +++ contracts/campaign-escrow/src/test.rs | 22 ++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/contracts/campaign-escrow/src/lib.rs b/contracts/campaign-escrow/src/lib.rs index 20fec4d..6f8a145 100644 --- a/contracts/campaign-escrow/src/lib.rs +++ b/contracts/campaign-escrow/src/lib.rs @@ -493,6 +493,9 @@ impl CampaignEscrowContract { if campaign.business != business { return Err(Error::NotCampaignOwner); } + if env.ledger().timestamp() > campaign.completion_deadline { + return Err(Error::ContentDeadlinePassed); + } let mut application = storage::get_application(&env, campaign_id, &creator)?; require_not_frozen(&application)?; diff --git a/contracts/campaign-escrow/src/test.rs b/contracts/campaign-escrow/src/test.rs index e6f070b..c2a80fc 100644 --- a/contracts/campaign-escrow/src/test.rs +++ b/contracts/campaign-escrow/src/test.rs @@ -872,6 +872,28 @@ mod test_deadline_enforcement { assert_eq!(result, Err(Ok(Error::ContentDeadlinePassed))); } + #[test] + fn reject_after_content_deadline_cannot_defeat_auto_approval() { + let (env, contract_id) = setup_env(); + let (client, _admin, _dispute, business, token) = bootstrap(&env, &contract_id, 50); + let id = create_funded_campaign(&env, &client, &business, &token, 10_000_000, 5); + + let creator = Address::generate(&env); + client.apply_to_campaign(&creator, &id, &String::from_str(&env, "pitch")); + client.approve_creator(&business, &id, &creator, &1_000_000); + client.submit_proof(&creator, &id, &String::from_str(&env, "proof")); + + // Move past the content deadline: the submission is now auto-approved. + advance_time(&env, 604_800 + 10); + + let result = client.try_reject_submission(&business, &id, &creator); + assert_eq!(result, Err(Ok(Error::ContentDeadlinePassed))); + + // Auto-approval still lets the creator claim. + let result = client.try_claim_payment(&creator, &id); + assert!(result.is_ok()); + } + #[test] fn create_with_past_deadline() { let (env, contract_id) = setup_env();