Version adapter of SampleCampaign-TokenController.sol

This commit is contained in:
eduardo-antuna 2017-08-06 21:56:41 +02:00
parent 2b61f1c0fa
commit 6c8548c80e
1 changed files with 13 additions and 23 deletions

36
contracts/SampleCampaign-TokenController.sol Normal file → Executable file
View File

@ -32,7 +32,7 @@ import "MiniMeToken.sol";
contract Owned { 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 { if (msg.sender != owner) throw; _; } modifier onlyOwner { require (msg.sender == owner); _; }
address public owner; address public owner;
@ -81,13 +81,10 @@ contract Campaign is TokenController, Owned {
address _tokenAddress address _tokenAddress
) { ) {
if ((_endFundingTime < now) || // Cannot end in the past require ((_endFundingTime >= now) && // Cannot end in the past
(_endFundingTime <= _startFundingTime) || (_endFundingTime > _startFundingTime) &&
(_maximumFunding > 10000 ether) || // The Beta is limited (_maximumFunding <= 10000 ether) && // The Beta is limited
(_vaultAddress == 0)) // To prevent burning ETH (_vaultAddress != 0)); // To prevent burning ETH
{
throw;
}
startFundingTime = _startFundingTime; startFundingTime = _startFundingTime;
endFundingTime = _endFundingTime; endFundingTime = _endFundingTime;
maximumFunding = _maximumFunding; maximumFunding = _maximumFunding;
@ -148,28 +145,21 @@ contract Campaign is TokenController, Owned {
function doPayment(address _owner) internal { function doPayment(address _owner) internal {
// First check that the Campaign is allowed to receive this donation // First check that the Campaign is allowed to receive this donation
if ((now<startFundingTime) || require ((now >= startFundingTime) &&
(now>endFundingTime) || (now <= endFundingTime) &&
(tokenContract.controller() == 0) || // Extra check (tokenContract.controller() != 0) && // Extra check
(msg.value == 0) || (msg.value != 0) &&
(totalCollected + msg.value > maximumFunding)) (totalCollected + msg.value <= maximumFunding));
{
throw;
}
//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
if (!vaultAddress.send(msg.value)) { require (vaultAddress.send(msg.value));
throw;
}
// 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
if (!tokenContract.generateTokens(_owner, msg.value)) { require (tokenContract.generateTokens(_owner, msg.value));
throw;
}
return; return;
} }
@ -180,7 +170,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() { function finalizeFunding() {
if (now < endFundingTime) throw; require(now >= endFundingTime);
tokenContract.changeController(0); tokenContract.changeController(0);
} }