Merge pull request #55 from nfnty/endblock
contracts: Refactor `stopBlock` to `endBlock`
This commit is contained in:
commit
8773ad94b9
|
@ -37,16 +37,16 @@ contract ContributionWallet {
|
|||
|
||||
// Public variables
|
||||
address public multisig;
|
||||
uint public finalBlock;
|
||||
uint public endBlock;
|
||||
StatusContribution public contribution;
|
||||
|
||||
// @dev Constructor initializes public variables
|
||||
// @param _multisig The address of the multisig that will receive the funds
|
||||
// @param _finalBlock Block after which the multisig can request the funds
|
||||
// @param _endBlock Block after which the multisig can request the funds
|
||||
// @param _contribution Address of the StatusContribution contract
|
||||
function ContributionWallet(address _multisig, uint _finalBlock, address _contribution) {
|
||||
function ContributionWallet(address _multisig, uint _endBlock, address _contribution) {
|
||||
multisig = _multisig;
|
||||
finalBlock = _finalBlock;
|
||||
endBlock = _endBlock;
|
||||
contribution = StatusContribution(_contribution);
|
||||
}
|
||||
|
||||
|
@ -56,7 +56,7 @@ contract ContributionWallet {
|
|||
// @dev Withdraw function sends all the funds to the wallet if conditions are correct
|
||||
function withdraw() public {
|
||||
if (msg.sender != multisig) throw; // Only the multisig can request it
|
||||
if (block.number <= finalBlock && // Allow after final block
|
||||
if (block.number <= endBlock && // Allow after end block
|
||||
contribution.finalized() == 0) throw; // Allow when sale is finalized
|
||||
multisig.transfer(this.balance);
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ contract StatusContribution is Owned, TokenController {
|
|||
MiniMeToken public SGT;
|
||||
MiniMeToken public SNT;
|
||||
uint public startBlock;
|
||||
uint public stopBlock;
|
||||
uint public endBlock;
|
||||
uint public sgtPreferenceBlocks;
|
||||
uint public sgtLimit;
|
||||
|
||||
|
@ -73,7 +73,7 @@ contract StatusContribution is Owned, TokenController {
|
|||
|
||||
modifier contributionOpen() {
|
||||
if ((getBlockNumber() < startBlock) ||
|
||||
(getBlockNumber() >= stopBlock) ||
|
||||
(getBlockNumber() > endBlock) ||
|
||||
(finalized > 0) ||
|
||||
(address(SNT) == 0x0 ))
|
||||
throw;
|
||||
|
@ -87,7 +87,7 @@ contract StatusContribution is Owned, TokenController {
|
|||
/// period starts This initializes most of the parameters
|
||||
/// @param _sntAddress Address of the SNT token contract
|
||||
/// @param _startBlock Block when the contribution period starts
|
||||
/// @param _stopBlock Maximum block that the contribution period can be longed
|
||||
/// @param _endBlock The last block that the contribution period is active
|
||||
/// @param _dynamicCeiling Address of the contract that controls the ceiling
|
||||
/// @param _destEthDevs Destination address where the contribution ether is sent
|
||||
/// @param _destTokensDevs Address where the tokens for the dev are sent
|
||||
|
@ -102,7 +102,7 @@ contract StatusContribution is Owned, TokenController {
|
|||
function initialize(
|
||||
address _sntAddress,
|
||||
uint _startBlock,
|
||||
uint _stopBlock,
|
||||
uint _endBlock,
|
||||
uint _sgtPreferenceBlocks,
|
||||
uint _sgtLimit,
|
||||
address _dynamicCeiling,
|
||||
|
@ -127,9 +127,10 @@ contract StatusContribution is Owned, TokenController {
|
|||
if (SNT.decimals() != 18) throw; // Same amount of decimals as ETH
|
||||
|
||||
if (_startBlock < getBlockNumber()) throw;
|
||||
if (_stopBlock < _startBlock) throw;
|
||||
if (_startBlock >= _endBlock) throw;
|
||||
startBlock = _startBlock;
|
||||
stopBlock = _stopBlock;
|
||||
endBlock = _endBlock;
|
||||
|
||||
sgtLimit = _sgtLimit;
|
||||
sgtPreferenceBlocks = _sgtPreferenceBlocks;
|
||||
|
||||
|
@ -300,14 +301,14 @@ contract StatusContribution is Owned, TokenController {
|
|||
/// controller.
|
||||
function finalize() public initialized {
|
||||
if (getBlockNumber() < startBlock) throw;
|
||||
if (msg.sender != owner && getBlockNumber() < stopBlock) throw;
|
||||
if (msg.sender != owner && getBlockNumber() <= endBlock) throw;
|
||||
if (finalized > 0) throw;
|
||||
|
||||
// Do not allow terminate until all revealed.
|
||||
if (!dynamicCeiling.allRevealed()) throw;
|
||||
|
||||
// Allow premature finalization if final limit is reached
|
||||
if (getBlockNumber () < stopBlock) {
|
||||
if (getBlockNumber() <= endBlock) {
|
||||
var (,,lastLimit) = dynamicCeiling.points(dynamicCeiling.revealedPoints().sub(1));
|
||||
|
||||
if (totalCollected() < lastLimit - 1 ether) throw;
|
||||
|
|
|
@ -37,7 +37,7 @@ contract("StatusContribution", (accounts) => {
|
|||
[1002000, web3.toWei(15)],
|
||||
];
|
||||
const startBlock = 1000000;
|
||||
const stopBlock = 1003000;
|
||||
const endBlock = 1003000;
|
||||
const sgtPreferenceBlocks = 2000;
|
||||
const sgtLimit = web3.toWei(0.1);
|
||||
|
||||
|
@ -54,7 +54,7 @@ contract("StatusContribution", (accounts) => {
|
|||
statusContribution = await StatusContributionMock.new();
|
||||
contributionWallet = await ContributionWallet.new(
|
||||
multisigStatus.address,
|
||||
stopBlock,
|
||||
endBlock,
|
||||
statusContribution.address);
|
||||
devTokensHolder = await DevTokensHolder.new(
|
||||
multisigDevs.address,
|
||||
|
@ -77,7 +77,7 @@ contract("StatusContribution", (accounts) => {
|
|||
await statusContribution.initialize(
|
||||
snt.address,
|
||||
startBlock,
|
||||
stopBlock,
|
||||
endBlock,
|
||||
sgtPreferenceBlocks,
|
||||
sgtLimit,
|
||||
dynamicCeiling.address,
|
||||
|
|
|
@ -39,7 +39,7 @@ contract("StatusContribution", (accounts) => {
|
|||
];
|
||||
const startBlock = 1000000;
|
||||
const sgtPreferenceBlocks = 2000;
|
||||
const stopBlock = 1030000;
|
||||
const endBlock = 1030000;
|
||||
const sgtLimit = web3.toWei(0.1);
|
||||
|
||||
it("Should deploy Contribution contracts", async () => {
|
||||
|
@ -56,7 +56,7 @@ contract("StatusContribution", (accounts) => {
|
|||
statusContribution = await StatusContributionMock.new();
|
||||
contributionWallet = await ContributionWallet.new(
|
||||
multisigStatus.address,
|
||||
stopBlock,
|
||||
endBlock,
|
||||
statusContribution.address);
|
||||
devTokensHolder = await DevTokensHolder.new(
|
||||
multisigDevs.address,
|
||||
|
@ -79,7 +79,7 @@ contract("StatusContribution", (accounts) => {
|
|||
await statusContribution.initialize(
|
||||
snt.address,
|
||||
startBlock,
|
||||
stopBlock,
|
||||
endBlock,
|
||||
sgtPreferenceBlocks,
|
||||
sgtLimit,
|
||||
dynamicCeiling.address,
|
||||
|
|
Loading…
Reference in New Issue