Some comments in contracts

This commit is contained in:
Jordi Baylina 2017-05-22 18:55:02 +02:00
parent 6a7ac47894
commit 83ae2e9beb
3 changed files with 88 additions and 7 deletions

View File

@ -16,6 +16,7 @@ contract ContributionWallet {
// @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 _contribution Address of the StatusContribution contract
function ContributionWallet(address _multisig, uint _finalBlock, address _contribution) {
multisig = _multisig;
finalBlock = _finalBlock;

View File

@ -1,5 +1,31 @@
pragma solidity ^0.4.11;
/*
Copyright 2017, Jordi Baylina
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/// @title StatusContribution Contract
/// @author Jordi Baylina
/// @dev This contract will be the SNT controller during the contribution period.
/// This contract will determine the rules during this period.
/// Final users, will generally not interact directly with this contract. ETH will
/// be sent to the SNT token contract. The ETH is sent to this contract and from here,
/// ETH is sent to the contribution walled and SNTs are mined according to the defined
/// rules.
import "./Owned.sol";
import "./MiniMeToken.sol";
import "./DynamicCeiling.sol";
@ -51,6 +77,23 @@ contract StatusContribution is Owned, SafeMath {
}
/// @notice This method should be called by the owner before the contribution
/// 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 _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
/// @param _destTokensSecondarySale Address where the tokens for the secondary sell
/// are going to be sent
/// @param _sgt Address of the SGT token contract
/// @param _destTokensSgt Address of the exchanger SGT-SNT where the SNT are sent
/// to be distributed to the SGT holders.
/// @param _maxSGTSupply Quantity of SGT tokens that would represent 10% of status.
/// @param _sntController Token controller for the SNT that will be transfered after
/// the contribution finalizes.
function initialize(
address _sntAddress,
uint _startBlock,
@ -66,7 +109,7 @@ contract StatusContribution is Owned, SafeMath {
address _destTokensSgt,
uint _maxSGTSupply,
address _sntController
) {
) onlyOwner {
// Initialize only once
if (address(SNT) != 0x0 ) throw;
@ -106,17 +149,31 @@ contract StatusContribution is Owned, SafeMath {
sntController = _sntController;
}
function setGuaranteedAddress(address th, uint limit) initialized onlyOwner {
/// @notice Sets the limit for a guaranteed address. All the guaranteed addresses
/// will be able to get SNTs during the contribution period with his own
/// specific limit.
/// This method should be called by the owner after the initialization
/// and before the contribution starts.
/// @param _th Guaranteed address
/// @param _limit Particular limit for the guaranteed address. Set to 0 to remove
/// the guaranteed address
function setGuaranteedAddress(address _th, uint _limit) initialized onlyOwner {
if (getBlockNumber() >= startBlock) throw;
if (limit > failSafe) throw;
guaranteedBuyersLimit[th] = limit;
GuaranteedAddress(th, limit);
if (_limit > failSafe) throw;
guaranteedBuyersLimit[_th] = _limit;
GuaranteedAddress(_th, _limit);
}
/// @notice If any body sends Ether directly to this contract, cosidere he is
/// getting SNTs.
function () payable {
proxyPayment(msg.sender);
}
/// @notice This method will generally be called by the SNT token contract to
/// adquire SNTs. Or directly from third parties that want po adquire SNTs in
/// behalf of a token holder.
/// @param _th SNT holder where the SNTs will be minted.
function proxyPayment(address _th) payable initialized contributionOpen returns (bool) {
if (guaranteedBuyersLimit[_th] > 0) {
buyGuaranteed(_th);
@ -187,9 +244,15 @@ contract StatusContribution is Owned, SafeMath {
NewSale(_th, _toFund, tokensGenerated, _guaranteed);
}
function finalize() initialized onlyOwner {
/// @notice This method will can be called by the owner before the contribution period
/// end or by any body after the `endBlock`. This method finalizes the contribution period
/// by creating the remaining tokens and transferin the controller to the configured
/// controller.
function finalize() initialized {
if (getBlockNumber() < startBlock) throw;
if ((msg.sender != owner)&&(getBlockNumber() < stopBlock )) throw;
if (finalized>0) throw;
// Do not allow terminate until all revealed.
@ -257,6 +320,11 @@ contract StatusContribution is Owned, SafeMath {
return safeMul(p, 10**16);
}
//////////
// MiniMe Controller functions
//////////
function onTransfer(address , address , uint ) returns(bool) {
return false;
}
@ -265,14 +333,26 @@ contract StatusContribution is Owned, SafeMath {
return false;
}
//////////
// Constant functions
//////////
/// @return Total tokens issued in weis.
function tokensIssued() constant returns (uint) {
return SNT.totalSupply();
}
/// @return Total Ether collected.
function totalCollected() constant returns (uint) {
return safeAdd(totalNormalCollected, totalGuaranteedCollected);
}
//////////
// Testing specific methods
//////////
/// @notice This function is overrided by the test Mocks.
function getBlockNumber() internal constant returns (uint) {
return block.number;
}

View File

@ -39,5 +39,5 @@ var minimeFactoryAbi = [{"constant":false,"inputs":[{"name":"_parentToken","type
var minimeFactory = eth.contract(minimeFactoryAbi).at("0x94bda9e40d82a09b8965e2082e5d286593246927");
var sgtAbi = [{"constant":true,"inputs":[],"name":"name","outputs":[{"name":"","type":"string"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_amount","type":"uint256"}],"name":"approve","outputs":[{"name":"success","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"creationBlock","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_from","type":"address"},{"name":"_to","type":"address"},{"name":"_amount","type":"uint256"}],"name":"transferFrom","outputs":[{"name":"success","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"name":"","type":"uint8"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_newController","type":"address"}],"name":"changeController","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"},{"name":"_blockNumber","type":"uint256"}],"name":"balanceOfAt","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"version","outputs":[{"name":"","type":"string"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_cloneTokenName","type":"string"},{"name":"_cloneDecimalUnits","type":"uint8"},{"name":"_cloneTokenSymbol","type":"string"},{"name":"_snapshotBlock","type":"uint256"},{"name":"_transfersEnabled","type":"bool"}],"name":"createCloneToken","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"}],"name":"balanceOf","outputs":[{"name":"balance","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"parentToken","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_owner","type":"address"},{"name":"_amount","type":"uint256"}],"name":"generateTokens","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"name":"","type":"string"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_blockNumber","type":"uint256"}],"name":"totalSupplyAt","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"data","type":"uint256[]"}],"name":"multiMint","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_to","type":"address"},{"name":"_amount","type":"uint256"}],"name":"transfer","outputs":[{"name":"success","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"transfersEnabled","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"parentSnapShotBlock","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_spender","type":"address"},{"name":"_amount","type":"uint256"},{"name":"_extraData","type":"bytes"}],"name":"approveAndCall","outputs":[{"name":"success","type":"bool"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_owner","type":"address"},{"name":"_amount","type":"uint256"}],"name":"destroyTokens","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"_owner","type":"address"},{"name":"_spender","type":"address"}],"name":"allowance","outputs":[{"name":"remaining","type":"uint256"}],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"tokenFactory","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"_transfersEnabled","type":"bool"}],"name":"enableTransfers","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[],"name":"controller","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"inputs":[{"name":"_tokenFactory","type":"address"}],"payable":false,"type":"constructor"},{"payable":true,"type":"fallback"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_from","type":"address"},{"indexed":true,"name":"_to","type":"address"},{"indexed":false,"name":"_amount","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_cloneToken","type":"address"},{"indexed":false,"name":"_snapshotBlock","type":"uint256"}],"name":"NewCloneToken","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"_owner","type":"address"},{"indexed":true,"name":"_spender","type":"address"},{"indexed":false,"name":"_amount","type":"uint256"}],"name":"Approval","type":"event"}];
var sgt = eth.contract(sgtAbi).at("0xd248b0d48e44aaf9c49aea0312be7e13a6dc1468")
var sgt = eth.contract(sgtAbi).at("0x4bdA828F1fE628973c39366263B78B7cd9d6D8fe")