Permalink
Browse files

transferOrigin changed to refundTokens

totalSupply added
  • Loading branch information...
conejoninja committed Jun 5, 2018
1 parent 9db3db6 commit fd7d4b168da610b76c19cd43954be56a01cd9a03
Showing with 34 additions and 18 deletions.
  1. +1 −2 contracts/ERC20.sol
  2. +1 −1 contracts/ICO.sol
  3. +32 −15 contracts/Tokens.sol
@@ -6,7 +6,6 @@ contract ERC20 {
function transfer(address _to, uint256 _amount) public returns (bool success);
function transferFrom(address _from, address _to, uint256 _amount) public returns (bool success);
function allowance(address _owner, address _spender) public constant returns (uint256 remaining);

function transferOrigin(address _to, uint256 _amount) public returns (bool success);
function totalSupply() public constant returns (uint);
}

@@ -264,7 +264,7 @@ contract ICO is HardcodedWallets {
// Before transfering the ETHs to the investor, get back the tokens bought on ICO
uint256 tokenAmount = SCRefundVault.getTokensAcquired(msg.sender);
emit GetBackTokensOnRefund(msg.sender, this, tokenAmount); // Event Log
if (!SCTokens.transferOrigin(this, tokenAmount)) {
if (!SCTokens.refundTokens(msg.sender, this, tokenAmount)) {
error('claimRefund: unable to transfer investor tokens to ICO contract before refunding');
return false;
}
@@ -18,8 +18,7 @@ contract Tokens is HardcodedWallets, ERC20 {

mapping (address => uint256) balances;
mapping (address => mapping (address => uint256)) allowed;
uint256 public initialSupply; // Initial and total token supply
uint256 public totalSupply; // initialSupply differ from totalSupply when there is a mint functionality
uint256 public _totalSupply;

// Public variables of the token, all used for display
string public name;
@@ -62,8 +61,7 @@ contract Tokens is HardcodedWallets, ERC20 {
decimals = 18; // 18 decimal places, the same as ETH

// initialSupply = 2000000000 ether; // 2018-04-21: ICO summary.docx: ...Dicho valor generaría un Total Supply de 2.000 millones de TRT.
initialSupply = 1350000000 ether; // 2018-05-10: alvaro.ariet@lacomunity.com ...tenemos una emisión de 1.350 millones de Tokens
totalSupply = initialSupply;
_totalSupply = 1350000000 ether; // 2018-05-10: alvaro.ariet@lacomunity.com ...tenemos una emisión de 1.350 millones de Tokens

timelockEndTime = timestamp().add(45 days); // Default timelock

@@ -72,11 +70,20 @@ contract Tokens is HardcodedWallets, ERC20 {
SCComplianceService = ComplianceService(addressSCComplianceService);

// Token distribution
balances[_addressSCEscrow] = totalSupply;
emit Transfer(0x0, _addressSCEscrow, totalSupply);
balances[_addressSCEscrow] = _totalSupply;
emit Transfer(0x0, _addressSCEscrow, _totalSupply);

}

/**
* @notice Get the token total supply
*/
function totalSupply() public constant returns (uint) {

return _totalSupply - balances[address(0)];

}

/**
* @notice Get the token balance of a wallet with address _owner
*/
@@ -194,20 +201,30 @@ contract Tokens is HardcodedWallets, ERC20 {
* @notice This is out of ERC20 standard but it is necessary to build market escrow contracts of assets
* @notice Send _amount amount of tokens to from tx.origin to address _to
*/
function transferOrigin(address _to, uint256 _amount) public notTimeLocked stopInEmergency returns (bool success) {
if (balances[tx.origin] < _amount) {
error('transferOrigin: the amount to transfer is higher than your token balance');
return false;
}

if(!SCComplianceService.validate(tx.origin, _to, _amount)) {
function refundTokens(address _from, address _to, uint256 _amount) public notTimeLocked stopInEmergency returns (bool success) {
if (tx.origin != _from) {
error('refundTokens: tx.origin did not request the refund directly');
return false;
}

if (addressSCICO != _to) {
error('refundTokens: _to address is not the current ICO address');
return false;
}

if (balances[_from] < _amount) {
error('refundTokens: the amount to transfer is higher than your token balance');
return false;
}

if(!SCComplianceService.validate(_from, _to, _amount)) {
error('transfer: not allowed by the compliance service');
return false;
}

balances[tx.origin] = balances[tx.origin].sub(_amount);
balances[_from] = balances[_from].sub(_amount);
balances[_to] = balances[_to].add(_amount);
emit Transfer(tx.origin, _to, _amount); // Event log
emit Transfer(_from, _to, _amount); // Event log

return true;
}

0 comments on commit fd7d4b1

Please sign in to comment.