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 {
/// @dev `owner` is the only address that can call a function with this
/// modifier
modifier onlyOwner { if (msg.sender != owner) throw; _; }
modifier onlyOwner { require (msg.sender == owner); _; }
address public owner;
@ -81,13 +81,10 @@ contract Campaign is TokenController, Owned {
address _tokenAddress
) {
if ((_endFundingTime < now) || // Cannot end in the past
(_endFundingTime <= _startFundingTime) ||
(_maximumFunding > 10000 ether) || // The Beta is limited
(_vaultAddress == 0)) // To prevent burning ETH
{
throw;
}
require ((_endFundingTime >= now) && // Cannot end in the past
(_endFundingTime > _startFundingTime) &&
(_maximumFunding <= 10000 ether) && // The Beta is limited
(_vaultAddress != 0)); // To prevent burning ETH
startFundingTime = _startFundingTime;
endFundingTime = _endFundingTime;
maximumFunding = _maximumFunding;
@ -148,28 +145,21 @@ contract Campaign is TokenController, Owned {
function doPayment(address _owner) internal {
// First check that the Campaign is allowed to receive this donation
if ((now<startFundingTime) ||
(now>endFundingTime) ||
(tokenContract.controller() == 0) || // Extra check
(msg.value == 0) ||
(totalCollected + msg.value > maximumFunding))
{
throw;
}
require ((now >= startFundingTime) &&
(now <= endFundingTime) &&
(tokenContract.controller() != 0) && // Extra check
(msg.value != 0) &&
(totalCollected + msg.value <= maximumFunding));
//Track how much the Campaign has collected
totalCollected += msg.value;
//Send the ether to the vault
if (!vaultAddress.send(msg.value)) {
throw;
}
require (vaultAddress.send(msg.value));
// Creates an equal amount of tokens as ether sent. The new tokens are created
// in the `_owner` address
if (!tokenContract.generateTokens(_owner, msg.value)) {
throw;
}
require (tokenContract.generateTokens(_owner, msg.value));
return;
}
@ -180,7 +170,7 @@ contract Campaign is TokenController, Owned {
/// @dev `finalizeFunding()` can only be called after the end of the funding period.
function finalizeFunding() {
if (now < endFundingTime) throw;
require(now >= endFundingTime);
tokenContract.changeController(0);
}