Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[x] Use back OpenZeppelin contracts for crowdsale [x] Remove Crowdsale.sol from QiibeePresale and QiibeeCrowdsale [x] Decouple QiibeeToken from presale and crowdsale contracts [x] Adapt tests [x] Add migration ability to QiibeeToken [x] Add migration tests [x] Update comments in code [ ] Update README.md on how to deploy the contracts and add descriptions of each contract [x] Add more tests [x] Check start on vesting [x] Fix finalize function on tests
- Loading branch information
Federico Martín Alconada Verzini
committed
Nov 21, 2017
1 parent
26d5963
commit d40368c
Showing
28 changed files
with
1,217 additions
and
680 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,4 @@ npm-debug.log | |
.node-xmlhttprequest-sync-[0-9]* | ||
coverage | ||
coverage.json | ||
.private.js | ||
private.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,11 @@ | ||
module.exports = { | ||
port: 8555, | ||
norpc: true, | ||
// testCommand: 'node ../node_modules/.bin/truffle test --network coverage', | ||
testCommand: 'GEN_TESTS_TIMEOUT=400 GEN_TESTS_QTY=40 truffle test --network coverage test/QiibeeToken.js test/QiibeeCrowdsale.js test/QiibeePresale.js test/WhitelistedCrowdsale.js test/QiibeePresaleGenTest.js test/QiibeeCrowdsaleGenTest.js', | ||
copyNodeModules: true, | ||
skipFiles: [ | ||
'test-helpers/Message.sol', | ||
'VestedToken.sol', | ||
'CrowdsaleImpl.sol', | ||
'QiibeePresaleImpl.sol', | ||
'WhitelistedCrowdsaleImpl.sol' | ||
'Crowdsale.sol', | ||
'QiibeeMigrationToken.sol', | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
pragma solidity ^0.4.11; | ||
|
||
import "zeppelin-solidity/contracts/ownership/Ownable.sol"; | ||
import "./QiibeeToken.sol"; | ||
|
||
// interface | ||
contract QiibeeMigrationTokenInterface { | ||
function createToken(address _target, uint256 _amount); | ||
function finalizeMigration(); | ||
function totalSupply() returns (uint256); | ||
} | ||
|
||
contract MigrationAgent is Ownable { | ||
|
||
address public qbxSourceToken; | ||
address public qbxTargetToken; | ||
uint256 public tokenSupply; | ||
|
||
function MigrationAgent(address _qbxSourceToken) { | ||
require(QiibeeToken(_qbxSourceToken).migrationAgent() == address(0)); | ||
tokenSupply = QiibeeToken(_qbxSourceToken).totalSupply(); | ||
qbxSourceToken = _qbxSourceToken; | ||
} | ||
|
||
function safetyInvariantCheck(uint256 _value) internal { | ||
require(QiibeeToken(qbxSourceToken).totalSupply() + QiibeeMigrationTokenInterface(qbxTargetToken).totalSupply() == tokenSupply - _value); | ||
} | ||
|
||
function setTargetToken(address _qbxTargetToken) public onlyOwner { | ||
require(qbxTargetToken == address(0)); //Allow this change once only | ||
qbxTargetToken = _qbxTargetToken; | ||
} | ||
|
||
function migrateFrom(address _from, uint256 _value) public { | ||
require(msg.sender == qbxSourceToken); | ||
require(qbxTargetToken != address(0)); | ||
|
||
safetyInvariantCheck(_value); // qbxSourceToken has already been updated, but corresponding QBX have not been created in the qbxTargetToken contract yet | ||
QiibeeMigrationTokenInterface(qbxTargetToken).createToken(_from, _value); | ||
safetyInvariantCheck(0); // totalSupply invariant must hold | ||
} | ||
|
||
function finalizeMigration() public onlyOwner { | ||
require(qbxTargetToken != address(0)); | ||
require(QiibeeToken(qbxSourceToken).totalSupply() == 0); //only finlize if all tokens have been migrated | ||
safetyInvariantCheck(0); | ||
QiibeeMigrationTokenInterface(qbxTargetToken).finalizeMigration(); | ||
|
||
qbxSourceToken = address(0); | ||
qbxTargetToken = address(0); | ||
tokenSupply = 0; | ||
} | ||
} |
Oops, something went wrong.