add flatten file

This commit is contained in:
Roman Storm 2017-11-09 21:57:40 -08:00
parent 1cfd3a0142
commit 600ecb1c42
1 changed files with 161 additions and 0 deletions

View File

@ -0,0 +1,161 @@
pragma solidity ^0.4.18;
/*
* ERC20Basic
* Simpler version of ERC20 interface
* see https://github.com/ethereum/EIPs/issues/20
*/
contract ERC20Basic {
uint public totalSupply;
function balanceOf(address who) constant returns (uint);
function transfer(address to, uint value);
event Transfer(address indexed from, address indexed to, uint value);
}
/**
* Math operations with safety checks
*/
contract SafeMath {
function safeMul(uint a, uint b) internal returns (uint) {
uint c = a * b;
assert(a == 0 || c / a == b);
return c;
}
function safeSub(uint a, uint b) internal returns (uint) {
assert(b <= a);
return a - b;
}
function safeAdd(uint a, uint b) internal returns (uint) {
uint c = a + b;
assert(c>=a && c>=b);
return c;
}
function assert(bool assertion) internal {
if (!assertion) throw;
}
}
// Build and Tested by Roman Storm rstormsf@gmail.com
/*
* Basic token
* Basic version of StandardToken, with no allowances
*/
contract BasicToken is ERC20Basic, SafeMath {
mapping(address => uint) balances;
function transfer(address _to, uint _value) {
if (balances[msg.sender] < _value) {
throw;
}
balances[msg.sender] = safeSub(balances[msg.sender], _value);
balances[_to] = safeAdd(balances[_to], _value);
Transfer(msg.sender, _to, _value);
}
function balanceOf(address _owner) constant returns (uint balance) {
return balances[_owner];
}
}
/*
* Ownable
*
* Base contract with an owner.
* Provides onlyOwner modifier, which prevents function from running if it is called by anyone other than the owner.
*/
contract Ownable {
address public owner;
function Ownable() {
owner = msg.sender;
}
modifier onlyOwner() {
if (msg.sender == owner)
_;
}
function transfer(address newOwner) onlyOwner {
if (newOwner != address(0)) owner = newOwner;
}
}
contract PresaleOracles is Ownable {
uint256 public startTime;
uint256 public endTime;
uint256 public cap;
uint256 public rate;
bool public isInitialized = false;
uint256 public totalInvestedInWei;
mapping(address => uint256) public investorBalances;
mapping(address => bool) public whitelist;
uint256 public investorsLength;
address public vault;
// TESTED by Roman Storm
function () public payable {
buy();
}
//TESTED by Roman Storm
function Presale() public {
}
//TESTED by Roman Storm
function initialize(uint256 _startTime, uint256 _endTime, uint256 _cap, address _vault) public onlyOwner {
require(!isInitialized);
require(_startTime != 0);
require(_endTime != 0);
require(_endTime > _startTime);
require(_cap != 0);
require(_vault != 0x0);
startTime = _startTime;
endTime = _endTime;
cap = _cap;
isInitialized = true;
vault = _vault;
}
//TESTED by Roman Storm
function buy() public payable {
require(whitelist[msg.sender]);
require(msg.value > 0);
require(isInitialized);
require(getTime() >= startTime && getTime() <= endTime);
require(totalInvestedInWei + msg.value <= cap);
address investor = msg.sender;
investorBalances[investor] += msg.value;
totalInvestedInWei += msg.value;
forwardFunds(msg.value);
}
//TESTED by Roman Storm
function forwardFunds(uint256 _amount) internal {
vault.transfer(_amount);
}
function claimTokens(address _token) public onlyOwner {
if (_token == 0x0) {
owner.transfer(this.balance);
return;
}
BasicToken token = BasicToken(_token);
uint256 balance = token.balanceOf(this);
token.transfer(owner, balance);
}
function whitelistInvestor(address _newInvestor) public onlyOwner {
if(!whitelist[_newInvestor]) {
whitelist[_newInvestor] = true;
investorsLength++;
}
}
function whitelistInvestors(address[] _investors) external onlyOwner {
require(_investors.length <= 250);
for(uint8 i=0; i<_investors.length;i++) {
address newInvestor = _investors[i];
if(!whitelist[newInvestor]) {
whitelist[newInvestor] = true;
investorsLength++;
}
}
}
function blacklistInvestor(address _investor) public onlyOwner {
if(whitelist[_investor]) {
delete whitelist[_investor];
if(investorsLength != 0) {
investorsLength--;
}
}
}
function getTime() internal view returns(uint256) {
return now;
}
}