Skip to content

feat: approve_submission emits no event, breaking off-chain indexing of proof approvals #62

Description

@JamesVictor-O

Problem

Every meaningful state transition in campaign-escrow publishes a typed event — except approve_submission, which is silent (lib.rs:432-453):

pub fn approve_submission(
    env: Env,
    business: Address,
    campaign_id: CampaignId,
    creator: Address,
) -> Result<(), Error> {
    require_not_paused(&env)?;
    business.require_auth();
    let campaign = storage::get_campaign(&env, campaign_id)?;
    if campaign.business != business {
        return Err(Error::NotCampaignOwner);
    }
    let mut application = storage::get_application(&env, campaign_id, &creator)?;
    require_not_frozen(&application)?;
    if application.status != ApplicationStatus::ProofSubmitted {
        return Err(Error::InvalidStatus);
    }
    application.proof_approved = true;
    storage::set_application(&env, &application);
    Ok(())   // no event published
}

Compare its sibling reject_submission (lib.rs:457-485), which publishes events::SubmissionRejected on the equivalent transition. contracts/campaign-escrow/src/events.rs defines events for every other transition (CampaignCreated, CampaignFunded, CreatorApplied, CreatorApproved, ProofSubmitted, SubmissionRejected, PaymentReleased, CampaignCancelled, SurplusReclaimed, ...) but nothing for a submission being approved.

Concrete failure scenario

An indexer or frontend subscribed to contract events has no way to detect "business approved this proof" — it can only see the eventual PaymentReleased once the creator claims, or has to poll get_application for every pending submission on every campaign to notice the proof_approved flip. That defeats the point of having an event-driven interface for every other transition in the same contract, and specifically breaks any UI that wants to show "your submission was approved, come claim your payment" before the creator happens to check back.

Expected behaviour

Add a SubmissionApproved { campaign_id: CampaignId, creator: Address } event (mirroring SubmissionRejected's shape) and publish it from approve_submission.

Files

  • contracts/campaign-escrow/src/events.rs — add SubmissionApproved
  • contracts/campaign-escrow/src/lib.rs — publish it in approve_submission

Acceptance criteria

  • SubmissionApproved event added to events.rs, consistent with the existing event structs' shape/derives
  • approve_submission publishes it on success
  • A test asserts the event is emitted with the correct campaign_id/creator

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions