Skip to content

Commit

Permalink
Token unlock update
Browse files Browse the repository at this point in the history
  • Loading branch information
maciukaite committed Oct 31, 2017
1 parent 7c88f4b commit 8e12399
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 14 deletions.
12 changes: 6 additions & 6 deletions MigratableToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ contract MigrateAgent {
}

contract MigratableToken is Token {

MigrateAgent public migrateAgent;

//Total migrated tokens
Expand Down Expand Up @@ -55,10 +55,10 @@ contract MigratableToken is Token {
Set migrating agent and start migrating
*/
function setMigrateAgent(MigrateAgent _agent)
external
onlyOwner
notZeroAddress(_agent)
afterCrowdsale
external
onlyOwner
notZeroAddress(_agent)
afterCrowdsale
{
//cannot interrupt migrating
require(getMigrateState() != MigrateState.Migrating);
Expand All @@ -72,7 +72,7 @@ contract MigratableToken is Token {
Migrating status
*/
function getMigrateState() public constant returns (MigrateState) {
if (block.number <= ICO_END) {
if (block.number <= crowdsaleEndBlock) {
//Migration is not allowed on funding
return MigrateState.NotAllowed;
} else if (address(migrateAgent) == address(0)) {
Expand Down
26 changes: 22 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,18 @@ Total supply of tokens is 100 million.
<br>
<br>
```javascript
uint256 public constant ICO_END = 222222222;
uint256 public crowdsaleEndBlock = 222222222;
```
A block number that indicates when the Crowdsale ends.
<br>
<br>
```javascript
uint256 public constant crowdsaleMaxEndBlock = 444444444;
```
A block number that indicates the max possible end block number.
<br>
<br>
```javascript
mapping (address => uint256) balances;
```
An array that saves balances of the users.
Expand Down Expand Up @@ -260,6 +266,18 @@ To decrease allowed value is better to use this function to avoid 2 calls (and w
Allows trusted address burning a specific amount of his tokens. This function is intended to be called after the Crowdsale to burn the unsold tokens.
<br>
<br>
```javascript
function updateCrowdsaleEndBlock (uint256 _crowdsaleEndBlock) {
//Crowdsale must be active
require(block.number <= crowdsaleEndBlock);
//Transfers can only be unlocked earlier
require(_crowdsaleEndBlock < crowdsaleMaxEndBlock);
crowdsaleEndBlock = _crowdsaleEndBlock;
}
```
Allows owner setting the new end block number to extend/close Crowdsale.
<br>
<br>
```javascript
function transferOwnership(address _newOwner) public afterCrowdsale {
super.transferOwnership(_newOwner);
Expand All @@ -279,7 +297,7 @@ This function prohibits pausing the contract when the Crowdsale is active.
#### **Modifiers**
```javascript
modifier canTransferOnCrowdsale (address _address) {
if (block.number <= ICO_END) {
if (block.number <= crowdsaleEndBlock) {
//Require the end of funding or msg.sender to be trusted
require(trusted[_address]);
}
Expand All @@ -291,7 +309,7 @@ Only trusted addresses can call functions that are marked with this modifier.
<br>
```javascript
modifier afterCrowdsale {
require(block.number > ICO_END);
require(block.number > crowdsaleEndBlock);
_;
}
```
Expand Down Expand Up @@ -1044,7 +1062,7 @@ Set a reference to the new Token. This is only possible when the migration has n
<br>
```javascript
function getMigrateState() public constant returns (MigrateState) {
if (block.number <= ICO_END) {
if (block.number <= crowdsaleEndBlock) {
//Migration is not allowed on funding
return MigrateState.NotAllowed;
} else if (address(migrateAgent) == address(0)) {
Expand Down
18 changes: 14 additions & 4 deletions Token.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ contract Token is ERC20, Pausable {
//Total amount of Gee
uint256 public _totalSupply = 100 * (10**6) * (10**8);

//Iend of crowdsale
uint256 public constant ICO_END = 222222222;
//end of crowdsale
uint256 public crowdsaleEndBlock = 222222222;
//end of crowdsale
uint256 public constant crowdsaleMaxEndBlock = 444444444;

//Balances for each account
mapping (address => uint256) balances;
Expand Down Expand Up @@ -142,6 +144,14 @@ contract Token is ERC20, Pausable {
return true;
}

function updateCrowdsaleEndBlock (uint256 _crowdsaleEndBlock) {
//Crowdsale must be active
require(block.number <= crowdsaleEndBlock);
//Transfers can only be unlocked earlier
require(_crowdsaleEndBlock < crowdsaleMaxEndBlock);
crowdsaleEndBlock = _crowdsaleEndBlock;
}

//Override transferOwnership()
function transferOwnership(address _newOwner) public afterCrowdsale {
super.transferOwnership(_newOwner);
Expand All @@ -153,7 +163,7 @@ contract Token is ERC20, Pausable {
}

modifier canTransferOnCrowdsale (address _address) {
if (block.number <= ICO_END) {
if (block.number <= crowdsaleEndBlock) {
//Require the end of funding or msg.sender to be trusted
require(trusted[_address]);
}
Expand All @@ -162,7 +172,7 @@ contract Token is ERC20, Pausable {

//Some functions should work only after the Crowdsale
modifier afterCrowdsale {
require(block.number > ICO_END);
require(block.number > crowdsaleEndBlock);
_;
}

Expand Down

0 comments on commit 8e12399

Please sign in to comment.