diff --git a/src/Crowdfund.sol b/src/Crowdfund.sol index b3a0291..a2f54f0 100644 --- a/src/Crowdfund.sol +++ b/src/Crowdfund.sol @@ -26,16 +26,8 @@ contract Crowdfund { // Events event CampaignCreated(address indexed creator, uint256 indexed campaignId); - event CampaignEnded( - address indexed creator, - uint256 indexed campaignId, - uint256 indexed amountRaised - ); - event DonationReceived( - uint256 indexed campaignId, - address indexed donator, - uint256 indexed amount - ); + event CampaignEnded(address indexed creator, uint256 indexed campaignId, uint256 indexed amountRaised); + event DonationReceived(uint256 indexed campaignId, address indexed donator, uint256 indexed amount); // Errors error Crowdfund_InvalidCampaign(uint256 id); @@ -59,12 +51,10 @@ contract Crowdfund { /// @param _goal The funding goal of the campaign. /// @param _deadline The deadline for the campaign. /// @return campaignId The ID of the created campaign. - function createCampaign( - string calldata _title, - string calldata _description, - uint256 _goal, - uint256 _deadline - ) public returns (uint256 campaignId) { + function createCampaign(string calldata _title, string calldata _description, uint256 _goal, uint256 _deadline) + public + returns (uint256 campaignId) + { if (_goal == 0) revert Crowdfund_GoalCannotBeZero(); if (_deadline == 0) revert Crowdfund_DeadlineTooShort(); Campaign memory newCampaign = Campaign({ @@ -123,17 +113,11 @@ contract Crowdfund { campaign.isPaidOut = true; totalFunding -= campaign.amountRaised; - (bool success, ) = payable(campaign.benefactor).call{ - value: campaign.amountRaised - }(""); + (bool success,) = payable(campaign.benefactor).call{value: campaign.amountRaised}(""); if (!success) revert Crowdfund_PayoutFailed(); - emit CampaignEnded( - campaign.benefactor, - campaignId, - campaign.amountRaised - ); + emit CampaignEnded(campaign.benefactor, campaignId, campaign.amountRaised); } /// @notice Gets the total number of campaigns. @@ -151,27 +135,21 @@ contract Crowdfund { /// @notice Gets the campaigns created by a specific user. /// @param user The address of the user. /// @return The array of campaign IDs created by the user. - function getUserCampaigns( - address user - ) external view returns (uint256[] memory) { + function getUserCampaigns(address user) external view returns (uint256[] memory) { return userCampaigns[user]; } /// @notice Gets the campaign details by ID. /// @param campaignId The ID of the campaign. /// @return The campaign details. - function getCampaignById( - uint256 campaignId - ) external view returns (Campaign memory) { + function getCampaignById(uint256 campaignId) external view returns (Campaign memory) { return campaigns[campaignId]; } /// @notice Gets the amount raised for a specific campaign. /// @param campaignId The ID of the campaign. /// @return The amount raised for the campaign. - function getCampaignAmountRaised( - uint256 campaignId - ) external view returns (uint256) { + function getCampaignAmountRaised(uint256 campaignId) external view returns (uint256) { return campaigns[campaignId].amountRaised; }