Skip to content

Update Fundraising Campaign Creation Backend API #8

@mubarak23

Description

@mubarak23

We need to enhance the existing fundraising campaign creation API to support campaign updates after creation. This will allow campaign creators to modify certain aspects of their fundraising campaigns while maintaining blockchain integrity and audit trails.
Background
Currently, our campaign creation API only supports initial campaign creation via the create_campaign Cairo contract function. Users have requested the ability to update campaign details post-creation for better campaign management.
Requirements
New API Endpoint

Method: PUT
Path: /api/v1/campaigns/{campaign_id}
Authentication: Required (JWT token + campaign ownership verification)
Request Body
json{
  "target_amount": "string",          // Optional: New fundraising goal
  "description": "string",            // Optional: Campaign description
  "end_date": "ISO 8601 timestamp",   // Optional: Campaign end date
  "image_url": "string",              // Optional: Campaign banner image
  "tags": ["string"],                 // Optional: Campaign categories/tags
  "social_links": {                   // Optional: Social media links
    "twitter": "string",
    "discord": "string",
    "website": "string"
  }
}

Response Format
json{
  "success": true,
  "data": {
    "campaign_id": "string",
    "campaign_ref": "string",
    "target_amount": "string",
    "description": "string",
    "end_date": "ISO 8601 timestamp",
    "image_url": "string",
    "tags": ["string"],
    "social_links": {},
    "updated_at": "ISO 8601 timestamp",
    "update_count": 5,
    "transaction_hash": "string"       // If blockchain update required
  }
}

Update Rules & Constraints
Updatable Fields

Target Amount: Can be increased only (never decreased)
Description: Full text updates allowed
End Date: Can be extended only (never shortened)
Image URL: Full updates allowed
Tags: Add/remove tags (max 10 tags)
Social Links: Full updates allowed

Non-Updatable Fields

campaign_ref - Immutable identifier
donation_token - Cannot change token type
creator_address - Campaign ownership cannot transfer
created_at - Historical timestamp

Business Rules

Only campaign creator can update their campaigns
Maximum 3 updates per campaign per day
Cannot update campaigns that have ended
Cannot update campaigns with >90% funding (to prevent bait-and-switch)
Target amount increases require new blockchain transaction
Must maintain audit trail of all changes

Implementation Details

Updates campaign target amount on blockchain

fn update_campaign_target(
ref self: TContractState,
campaign_id: u256,
new_target_amount: u256
) -> bool;

Campaign exists and is active
User owns the campaign
Update limits not exceeded (3 per day)
Target amount only increases
End date only extends forward
Image URL is valid and accessible
Tags are within allowed categories
Social links are valid URLs

API Behavior
Partial Updates

Support partial updates (only provided fields are updated)
Return complete campaign object after update
Validate each field independently

Blockchain vs Database Updates

Blockchain Required: Target amount changes
Database Only: Description, image, tags, social links, end date
Hybrid: Updates affecting both systems

Error Handling

400 Bad Request: Invalid field values, constraint violations
401 Unauthorized: Invalid or missing authentication
403 Forbidden: User doesn't own campaign, update limits exceeded
404 Not Found: Campaign doesn't exist
409 Conflict: Campaign ended, over-funded, concurrent updates
422 Unprocessable: Business rule violations
500 Internal Server Error: Blockchain or database failures

Metadata

Metadata

Assignees

Labels

onlydust-waveContribute to awesome OSS repos during OnlyDust's open source week

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions