fix lint on SampleCampaign (#12)

This commit is contained in:
Ricardo Guilherme Schmidt 2023-09-12 15:25:29 -03:00 committed by GitHub
parent a7237e0bc9
commit ed1df75a92
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 15 deletions

View File

@ -25,7 +25,8 @@ pragma solidity ^0.8.0;
/// funds for non-profit causes, but it can be customized for any variety of /// funds for non-profit causes, but it can be customized for any variety of
/// purposes. /// purposes.
import "./MiniMeToken.sol"; import { MiniMeToken } from "./MiniMeToken.sol";
import { TokenController } from "./TokenController.sol";
/// @dev `Owned` is a base level contract that assigns an `owner` that can be /// @dev `Owned` is a base level contract that assigns an `owner` that can be
/// later changed /// later changed
@ -33,7 +34,7 @@ contract Owned {
/// @dev `owner` is the only address that can call a function with this /// @dev `owner` is the only address that can call a function with this
/// modifier /// modifier
modifier onlyOwner() { modifier onlyOwner() {
require(msg.sender == owner); require(msg.sender == owner, "Not authorized");
_; _;
} }
@ -86,7 +87,8 @@ contract Campaign is TokenController, Owned {
require( require(
(_endFundingTime >= block.timestamp) // Cannot end in the past (_endFundingTime >= block.timestamp) // Cannot end in the past
&& (_endFundingTime > _startFundingTime) && (_maximumFunding <= 10_000 ether) // The Beta is limited && (_endFundingTime > _startFundingTime) && (_maximumFunding <= 10_000 ether) // The Beta is limited
&& (_vaultAddress != address(0)) && (_vaultAddress != address(0)),
"Invalid parameters"
); // To prevent burning ETH ); // To prevent burning ETH
startFundingTime = _startFundingTime; startFundingTime = _startFundingTime;
endFundingTime = _endFundingTime; endFundingTime = _endFundingTime;
@ -119,21 +121,15 @@ contract Campaign is TokenController, Owned {
/// @notice Notifies the controller about a transfer, for this Campaign all /// @notice Notifies the controller about a transfer, for this Campaign all
/// transfers are allowed by default and no extra notifications are needed /// transfers are allowed by default and no extra notifications are needed
/// @param _from The origin of the transfer
/// @param _to The destination of the transfer
/// @param _amount The amount of the transfer
/// @return False if the controller does not authorize the transfer /// @return False if the controller does not authorize the transfer
function onTransfer(address _from, address _to, uint256 _amount) public override returns (bool) { function onTransfer(address, address, uint256) public pure override returns (bool) {
return true; return true;
} }
/// @notice Notifies the controller about an approval, for this Campaign all /// @notice Notifies the controller about an approval, for this Campaign all
/// approvals are allowed by default and no extra notifications are needed /// approvals are allowed by default and no extra notifications are needed
/// @param _owner The address that calls `approve()`
/// @param _spender The spender in the `approve()` call
/// @param _amount The amount in the `approve()` call
/// @return False if the controller does not authorize the approval /// @return False if the controller does not authorize the approval
function onApprove(address _owner, address _spender, uint256 _amount) public override returns (bool) { function onApprove(address, address, uint256) public pure override returns (bool) {
return true; return true;
} }
@ -147,18 +143,19 @@ contract Campaign is TokenController, Owned {
require( require(
(block.timestamp >= startFundingTime) && (block.timestamp <= endFundingTime) (block.timestamp >= startFundingTime) && (block.timestamp <= endFundingTime)
&& (tokenContract.controller() != address(0)) // Extra check && (tokenContract.controller() != address(0)) // Extra check
&& (msg.value != 0) && (totalCollected + msg.value <= maximumFunding) && (msg.value != 0) && (totalCollected + msg.value <= maximumFunding),
"Payment rejected"
); );
//Track how much the Campaign has collected //Track how much the Campaign has collected
totalCollected += msg.value; totalCollected += msg.value;
//Send the ether to the vault //Send the ether to the vault
require(vaultAddress.send(msg.value)); require(vaultAddress.send(msg.value), "Vault transfer failed");
// Creates an equal amount of tokens as ether sent. The new tokens are created // Creates an equal amount of tokens as ether sent. The new tokens are created
// in the `_owner` address // in the `_owner` address
require(tokenContract.generateTokens(_owner, msg.value)); require(tokenContract.generateTokens(_owner, msg.value), "Token mint failed");
return; return;
} }
@ -169,7 +166,7 @@ contract Campaign is TokenController, Owned {
/// @dev `finalizeFunding()` can only be called after the end of the funding period. /// @dev `finalizeFunding()` can only be called after the end of the funding period.
function finalizeFunding() external { function finalizeFunding() external {
require(block.timestamp >= endFundingTime); require(block.timestamp >= endFundingTime, "Funding period not over");
tokenContract.changeController(payable(address(0))); tokenContract.changeController(payable(address(0)));
} }