diff --git a/legends_crowdfund.sol b/legends_crowdfund.sol index 81a712f..f1e413e 100644 --- a/legends_crowdfund.sol +++ b/legends_crowdfund.sol @@ -7,7 +7,7 @@ import "./legends_token.sol"; * @title LegendsCrowdfund */ contract LegendsCrowdfund { - + address public creator; address public exitAddress; @@ -40,7 +40,7 @@ contract LegendsCrowdfund { } _; } - + modifier recipientIsValid(address recipient) { if (recipient == 0 || recipient == address(this)) { throw; @@ -88,12 +88,12 @@ contract LegendsCrowdfund { * @param recipient Address that tokens should be attributed to. */ function purchaseMembership(address recipient) external payable saleActive hasValue recipientIsValid(recipient) { - + // Attempt to send the ETH to the exit address. if (!exitAddress.send(msg.value)) { throw; } - + // Update ETH amounts. recipientETH[recipient] += msg.value; totalETH += msg.value; diff --git a/legends_token.sol b/legends_token.sol index 9069d11..5ffe87e 100644 --- a/legends_token.sol +++ b/legends_token.sol @@ -7,12 +7,16 @@ import "./erc20.sol"; * @title LegendsToken */ contract LegendsToken is ERC20 { + string public name = 'VIP'; //The Token's name: e.g. DigixDAO Tokens + uint8 public decimals = 18; // 1Token ¨= 1$ (1ETH ¨= 10$) + string public symbol = 'VIP'; //An identifier: e.g. REP + string public version = 'VIP_0.1'; mapping (address => uint) ownerVIP; mapping (address => mapping (address => uint)) allowed; uint public totalVIP; uint public start; - + address public legendsCrowdfund; bool public testing; @@ -23,7 +27,7 @@ contract LegendsToken is ERC20 { } _; } - + modifier isActive() { if (block.timestamp < start) { throw; @@ -45,20 +49,6 @@ contract LegendsToken is ERC20 { _; } - modifier senderHasSufficient(uint VIP) { - if (ownerVIP[msg.sender] < VIP) { - throw; - } - _; - } - - modifier transferApproved(address from, uint VIP) { - if (allowed[from][msg.sender] < VIP || ownerVIP[from] < VIP) { - throw; - } - _; - } - modifier allowanceIsZero(address spender, uint value) { // To change the approve amount you first have to reduce the addresses´ // allowance to zero by calling `approve(_spender,0)` if it is not @@ -89,7 +79,7 @@ contract LegendsToken is ERC20 { testing = _testing; totalVIP = ownerVIP[_preallocation] = 25000 ether; } - + /** * @dev Add to token balance on address. Must be from crowdfund. * @param recipient Address to add tokens to. @@ -118,22 +108,30 @@ contract LegendsToken is ERC20 { /** * @dev Implements ERC20 transfer() */ - function transfer(address _to, uint256 _value) isActive recipientIsValid(_to) senderHasSufficient(_value) returns (bool success) { - ownerVIP[msg.sender] -= _value; - ownerVIP[_to] += _value; - Transfer(msg.sender, _to, _value); - return true; + function transfer(address _to, uint256 _value) isActive recipientIsValid(_to) returns (bool success) { + if (ownerVIP[msg.sender] >= _value) { + ownerVIP[msg.sender] -= _value; + ownerVIP[_to] += _value; + Transfer(msg.sender, _to, _value); + return true; + } else { + return false; + } } /** * @dev Implements ERC20 transferFrom() */ - function transferFrom(address _from, address _to, uint256 _value) isActive recipientIsValid(_to) transferApproved(_from, _value) returns (bool success) { - ownerVIP[_to] += _value; - ownerVIP[_from] -= _value; - allowed[_from][msg.sender] -= _value; - Transfer(_from, _to, _value); - return true; + function transferFrom(address _from, address _to, uint256 _value) isActive recipientIsValid(_to) returns (bool success) { + if (allowed[_from][msg.sender] >= _value && ownerVIP[_from] >= _value) { + ownerVIP[_to] += _value; + ownerVIP[_from] -= _value; + allowed[_from][msg.sender] -= _value; + Transfer(_from, _to, _value); + return true; + } else { + return false; + } } /**