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
-
Admin Authorization:
- Verify that the provided admin address is authorized to cancel the campaign.
-
Campaign Retrieval:
- Retrieve the campaign using the given
campaign_id from storage.
-
Status Update:
- Update the campaign's status to
Failed.
-
Storage Update:
- Save the updated campaign back to storage.
-
Event Emission:
- Emit a cancellation event after successfully updating the campaign status.
-
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.
Overview
Implement the
cancel_campaignfunction in theCampaignManagementtrait for theBoundlessContract. This new functionality will handle the cancellation of a campaign by updating its status and ensuring proper event emission.Background
The
cancel_campaignmethod is defined in theCampaignManagementtrait incontracts/boundless/src/interface.rs. The campaign information is structured according to the definitions incontracts/boundless/src/datatypes.rs, where each campaign has astatusthat needs to be updated upon cancellation. The cancellation should reflect as aFailedstatus and emit an appropriate event to notify the system.Requirements
Admin Authorization:
Campaign Retrieval:
campaign_idfrom storage.Status Update:
Failed.Storage Update:
Event Emission:
Error Handling:
Technical Considerations
Statusenum for setting the campaign status toFailed.BoundlessError.Acceptance Criteria
cancel_campaignfunction is fully implemented as outlined.Failedwhen cancelled.- All new functionality is covered by tests.