Skip to content

Commit

Permalink
Merge pull request #88 from TokenMarketNet/feat/centrallyissuedtoken
Browse files Browse the repository at this point in the history
Feat/centrallyissuedtoken
  • Loading branch information
miohtama committed Nov 27, 2017
2 parents c199c08 + 9468c1e commit c2db5d3
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 13 deletions.
74 changes: 67 additions & 7 deletions contracts/CentrallyIssuedToken.sol
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
/**
* This smart contract code is Copyright 2017 TokenMarket Ltd. For more information see https://tokenmarket.net
*
* Licensed under the Apache License, version 2.0: https://github.com/TokenMarketNet/ico/blob/master/LICENSE.txt
*/

pragma solidity ^0.4.6;

import "./BurnableToken.sol";
Expand All @@ -22,17 +16,83 @@ import "./UpgradeableToken.sol";
*/
contract CentrallyIssuedToken is BurnableToken, UpgradeableToken {

// Token meta information
string public name;
string public symbol;
uint public decimals;

function CentrallyIssuedToken(address _owner, string _name, string _symbol, uint _totalSupply, uint _decimals) UpgradeableToken(_owner) {
// Token release switch
bool public released = false;

// The date before the release must be finalized or upgrade path will be forced
uint public releaseFinalizationDate;

/** Name and symbol were updated. */
event UpdatedTokenInformation(string newName, string newSymbol);

function CentrallyIssuedToken(address _owner, string _name, string _symbol, uint _totalSupply, uint _decimals, uint _releaseFinalizationDate) UpgradeableToken(_owner) {
name = _name;
symbol = _symbol;
totalSupply = _totalSupply;
decimals = _decimals;

// Allocate initial balance to the owner
balances[_owner] = _totalSupply;

releaseFinalizationDate = _releaseFinalizationDate;
}

/**
* Owner can update token information here.
*
* It is often useful to conceal the actual token association, until
* the token operations, like central issuance or reissuance have been completed.
* In this case the initial token can be supplied with empty name and symbol information.
*
* This function allows the token owner to rename the token after the operations
* have been completed and then point the audience to use the token contract.
*/
function setTokenInformation(string _name, string _symbol) {

if(msg.sender != upgradeMaster) {
throw;
}

if(bytes(name).length > 0 || bytes(symbol).length > 0) {
// Information already set
// Allow owner to set this information only once
throw;
}

name = _name;
symbol = _symbol;
UpdatedTokenInformation(name, symbol);
}


/**
* Kill switch for the token in the case of distribution issue.
*
*/
function transfer(address _to, uint _value) returns (bool success) {

if(now > releaseFinalizationDate) {
if(!released) {
throw;
}
}

return super.transfer(_to, _value);
}

/**
* One way function to perform the final token release.
*/
function releaseTokenTransfer() {
if(msg.sender != upgradeMaster) {
throw;
}

released = true;
}
}
6 changes: 5 additions & 1 deletion ico/tests/contracts/test_burn.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Burn functionality."""

import datetime
import pytest
from ethereum.tester import TransactionFailed
from web3.contract import Contract
Expand All @@ -12,10 +13,13 @@ def token(chain, team_multisig):
"Token",
"TKN",
1000000,
0
0,
int((datetime.datetime(2017, 4, 22, 16, 0) - datetime.datetime(1970, 1, 1)).total_seconds())
]
contract, hash = chain.provider.deploy_contract('CentrallyIssuedToken', deploy_args=args)
assert contract.call().balanceOf(team_multisig) == 1000000

contract.transact({"from": team_multisig}).releaseTokenTransfer()
return contract


Expand Down
5 changes: 4 additions & 1 deletion ico/tests/contracts/test_issuer.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Payment forwarder."""
import pytest
import datetime

from ethereum.tester import TransactionFailed
from web3.contract import Contract
Expand All @@ -9,13 +10,15 @@
def token(chain, team_multisig) -> Contract:
"""Create the token contract."""

args = [team_multisig, "Foobar", "FOOB", 1000000, 0]
args = [team_multisig, "Foobar", "FOOB", 1000000, 0, int((datetime.datetime(2017, 4, 22, 16, 0) - datetime.datetime(1970, 1, 1)).total_seconds())]

tx = {
"from": team_multisig
}

contract, hash = chain.provider.deploy_contract('CentrallyIssuedToken', deploy_args=args, deploy_transaction=tx)

contract.transact({"from": team_multisig}).releaseTokenTransfer()
return contract


Expand Down
7 changes: 4 additions & 3 deletions ico/tests/contracts/test_time_vault.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@ def token(chain, team_multisig):
"Token",
"TKN",
1000000,
0
0,
int((datetime.datetime(2017, 4, 22, 16, 0) - datetime.datetime(1970, 1, 1)).total_seconds())
]
contract, hash = chain.provider.deploy_contract('CentrallyIssuedToken', deploy_args=args)
assert contract.call().balanceOf(team_multisig) == 1000000

contract.transact({"from": team_multisig}).releaseTokenTransfer()
return contract


Expand Down Expand Up @@ -67,5 +70,3 @@ def test_unlock(chain, token: Contract, team_multisig: str, vault: Contract, unl

assert token.call().balanceOf(team_multisig) == 1000000
assert token.call().balanceOf(vault.address) == 0


6 changes: 5 additions & 1 deletion ico/tests/contracts/test_token_vault.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Token core functionality."""

import datetime
import enum
import pytest
from ethereum.tester import TransactionFailed
Expand All @@ -21,10 +22,13 @@ def token(chain, team_multisig):
"Token",
"TKN",
1000000,
0
0,
int((datetime.datetime(2017, 4, 22, 16, 0) - datetime.datetime(1970, 1, 1)).total_seconds())
]
contract, hash = chain.provider.deploy_contract('CentrallyIssuedToken', deploy_args=args)
assert contract.call().balanceOf(team_multisig) == 1000000

contract.transact({"from": team_multisig}).releaseTokenTransfer()
return contract


Expand Down

0 comments on commit c2db5d3

Please sign in to comment.