-
Notifications
You must be signed in to change notification settings - Fork 7
Description
Overview
This issue is to implement the core logic for campaign creation in our smart contract. The function create_campaign in contracts/boundless/src/logic/campaign.rs currently has a placeholder and needs a complete implementation according to the provided requirements.
Background
Our platform, as described in the README, relies on a robust and secure implementation of smart contracts to manage key functionalities, including campaign management. The Campaign struct in contracts/boundless/src/datatypes.rs and the CampaignManagement trait in contracts/boundless/src/interface.rs have already been defined. The logic needs to:
- Generate a unique campaign ID
- Create a new
Campaignstruct with a status ofStatus::Active - Store the campaign in persistent storage
- Return the campaign ID
Requirements
-
Location: Implementation should be done in
contracts/boundless/src/logic/campaign.rswithin thecreate_campaignfunction. -
Steps to Implement:
- Ensure the user (campaign owner) is authenticated by using
owner.require_auth(). - Generate a unique campaign ID. Consider ways to ensure uniqueness (e.g., based on a counter or timestamp).
- Instantiate a
Campaignstruct with the following fields:id: the newly generated unique IDowner: provided owner addresstitle: provided titledescription: provided descriptionfunding_goal: provided funding goal (goal)escrow_contract_id: provided escrow contract IDmilestones: provided milestonesbackers: should be empty upon creationstatus: set toStatus::Active
- Store the campaign object in persistent storage.
- Return the campaign ID as the result
- Ensure the user (campaign owner) is authenticated by using
Technical Considerations
- Ensure error handling aligns with the project standards. If any step fails, return a proper
BoundlessError. - Verify the uniqueness of campaign IDs to avoid conflicts.
- Maintain code readability and adhere to the coding style outlined in the repository.
Acceptance Criteria
- The
create_campaignfunction generates a unique campaign ID. - A new campaign is instantiated with all provided and required attributes, especially with the status set to
Active. - The campaign is successfully stored in persistent storage.
- The function returns the correct campaign ID upon successful execution.
- Proper error handling is implemented for failure scenarios.