Skip to content

Implement Complete Campaign Logic Contract #12

@0xdevcollins

Description

@0xdevcollins

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

  1. Admin Authorization

    • Verify that the provided admin address is authorized to complete the campaign.
  2. 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.
  3. 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.
  4. Event Emission

    • Emit an event to signal that the campaign has been successfully completed.
  5. 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

  • The complete_campaign function verifies admin authorization correctly.
  • The campaign is successfully retrieved and its status updated to Completed.
  • The updated campaign is stored in the blockchain storage.
  • A campaign completion event is emitted after successfully updating the campaign.
  • All error cases (e.g., unauthorized admin, missing campaign) are handled gracefully.

- All new functionality is covered by tests.

Metadata

Metadata

Assignees

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