Skip to content

Implement cancel_campaign in CampaignManagement contract logic #13

@0xdevcollins

Description

@0xdevcollins

Overview

Implement the cancel_campaign function in the CampaignManagement trait for the BoundlessContract. This new functionality will handle the cancellation of a campaign by updating its status and ensuring proper event emission.

Background

The cancel_campaign method is defined in the CampaignManagement trait in contracts/boundless/src/interface.rs. The campaign information is structured according to the definitions in contracts/boundless/src/datatypes.rs, where each campaign has a status that needs to be updated upon cancellation. The cancellation should reflect as a Failed status and emit an appropriate event to notify the system.

Requirements

  1. Admin Authorization:

    • Verify that the provided admin address is authorized to cancel the campaign.
  2. Campaign Retrieval:

    • Retrieve the campaign using the given campaign_id from storage.
  3. Status Update:

    • Update the campaign's status to Failed.
  4. Storage Update:

    • Save the updated campaign back to storage.
  5. Event Emission:

    • Emit a cancellation event after successfully updating the campaign status.
  6. Error Handling:

    • Ensure proper error handling for scenarios such as unauthorized admin or non-existent campaign.

Technical Considerations

  • Use the provided Status enum for setting the campaign status to Failed.
  • Follow existing patterns in the Boundless codebase for error handling, as defined by BoundlessError.
  • Be mindful of security checks, especially when validating admin privileges.

Acceptance Criteria

  • The cancel_campaign function is fully implemented as outlined.
  • The campaign status reliably updates to Failed when cancelled.
  • A cancellation event is emitted after the campaign is cancelled.

- All new functionality is covered by tests.

Metadata

Metadata

Labels

contractgood first issueGood for newcomersonlydust-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