Overview
Implement the logic for completing a campaign in the Boundless smart contract. This feature will mark a campaign as completed by changing its status and emitting an event to notify listeners. 🚀
Background
The function to be implemented is defined in contracts/boundless/src/logic/campaign.rs under the CampaignManagement trait. The goal is to update the campaign status to Completed in storage, after performing necessary checks such as verifying the admin's authorization.
Requirements
-
Admin Authorization
- Verify that the provided
admin address is authorized to complete the campaign.
-
Campaign Retrieval
- Retrieve the campaign from storage using the provided
campaign_id.
- Handle cases where the campaign does not exist or is in an unexpected state.
-
Status Update
- Update the campaign's status to
Completed as defined by the Status enum in datatypes.rs.
- Save the updated campaign back to storage.
-
Event Emission
- Emit an event to signal that the campaign has been successfully completed.
-
Error Handling
- Use appropriate error handling by returning a
BoundlessError if any of the checks fail or other issues are encountered.
Technical Considerations
- Ensure that the logic respects the integrity of data stored in
Campaign and related data types.
- Maintain consistency with the existing contract coding style and error handling as observed in other functions.
- Double-check that the event emission methodology aligns with other events defined in the project for uniformity.
Acceptance Criteria
- All new functionality is covered by tests.
Overview
Implement the logic for completing a campaign in the Boundless smart contract. This feature will mark a campaign as completed by changing its status and emitting an event to notify listeners. 🚀
Background
The function to be implemented is defined in
contracts/boundless/src/logic/campaign.rsunder theCampaignManagementtrait. The goal is to update the campaign status toCompletedin storage, after performing necessary checks such as verifying the admin's authorization.Requirements
Admin Authorization
adminaddress is authorized to complete the campaign.Campaign Retrieval
campaign_id.Status Update
Completedas defined by theStatusenum indatatypes.rs.Event Emission
Error Handling
BoundlessErrorif any of the checks fail or other issues are encountered.Technical Considerations
Campaignand related data types.Acceptance Criteria
complete_campaignfunction verifies admin authorization correctly.Completed.- All new functionality is covered by tests.