Skip to content

Commit

Permalink
format: run forge fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
khayss committed Oct 4, 2024
1 parent bde7879 commit 97b40e4
Showing 1 changed file with 11 additions and 33 deletions.
44 changes: 11 additions & 33 deletions src/Crowdfund.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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({
Expand Down Expand Up @@ -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.
Expand All @@ -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;
}

Expand Down

0 comments on commit 97b40e4

Please sign in to comment.