Skip to content

Commit

Permalink
fix: solium errors - function-order only
Browse files Browse the repository at this point in the history
  • Loading branch information
shrugs committed Jan 15, 2018
1 parent e60aee6 commit bd2f177
Show file tree
Hide file tree
Showing 8 changed files with 90 additions and 91 deletions.
12 changes: 6 additions & 6 deletions contracts/Bounty.sol
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,6 @@ contract Bounty is PullPayment, Destructible {
return target;
}

/**
* @dev Internal function to deploy the target contract.
* @return A target contract address
*/
function deployContract() internal returns(address);

/**
* @dev Sends the contract funds to the researcher that proved the contract is broken.
* @param target contract
Expand All @@ -53,6 +47,12 @@ contract Bounty is PullPayment, Destructible {
claimed = true;
}

/**
* @dev Internal function to deploy the target contract.
* @return A target contract address
*/
function deployContract() internal returns(address);

}


Expand Down
14 changes: 7 additions & 7 deletions contracts/crowdsale/CappedCrowdsale.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@ contract CappedCrowdsale is Crowdsale {
cap = _cap;
}

// overriding Crowdsale#validPurchase to add extra cap logic
// @return true if investors can buy at the moment
function validPurchase() internal view returns (bool) {
bool withinCap = weiRaised.add(msg.value) <= cap;
return super.validPurchase() && withinCap;
}

// overriding Crowdsale#hasEnded to add cap logic
// @return true if crowdsale event has ended
function hasEnded() public view returns (bool) {
bool capReached = weiRaised >= cap;
return super.hasEnded() || capReached;
}

// overriding Crowdsale#validPurchase to add extra cap logic
// @return true if investors can buy at the moment
function validPurchase() internal view returns (bool) {
bool withinCap = weiRaised.add(msg.value) <= cap;
return super.validPurchase() && withinCap;
}

}
33 changes: 16 additions & 17 deletions contracts/crowdsale/Crowdsale.sol
Original file line number Diff line number Diff line change
Expand Up @@ -54,22 +54,11 @@ contract Crowdsale {
wallet = _wallet;
}

// creates the token to be sold.
// override this method to have crowdsale of a specific mintable token.
function createTokenContract() internal returns (MintableToken) {
return new MintableToken();
}

// fallback function can be used to buy tokens
function () external payable {
buyTokens(msg.sender);
}

// Override this method to have a way to add business logic to your crowdsale when buying
function getTokenAmount(uint256 weiAmount) internal view returns(uint256) {
return weiAmount.mul(rate);
}

// low level token purchase function
function buyTokens(address beneficiary) public payable {
require(beneficiary != address(0));
Expand All @@ -89,6 +78,22 @@ contract Crowdsale {
forwardFunds();
}

// @return true if crowdsale event has ended
function hasEnded() public view returns (bool) {
return now > endTime;
}

// creates the token to be sold.
// override this method to have crowdsale of a specific mintable token.
function createTokenContract() internal returns (MintableToken) {
return new MintableToken();
}

// Override this method to have a way to add business logic to your crowdsale when buying
function getTokenAmount(uint256 weiAmount) internal view returns(uint256) {
return weiAmount.mul(rate);
}

// send ether to the fund collection wallet
// override to create custom fund forwarding mechanisms
function forwardFunds() internal {
Expand All @@ -102,10 +107,4 @@ contract Crowdsale {
return withinPeriod && nonZeroPurchase;
}

// @return true if crowdsale event has ended
function hasEnded() public view returns (bool) {
return now > endTime;
}


}
18 changes: 9 additions & 9 deletions contracts/crowdsale/RefundableCrowdsale.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,6 @@ contract RefundableCrowdsale is FinalizableCrowdsale {
goal = _goal;
}

// We're overriding the fund forwarding from Crowdsale.
// In addition to sending the funds, we want to call
// the RefundVault deposit function
function forwardFunds() internal {
vault.deposit.value(msg.value)(msg.sender);
}

// if crowdsale is unsuccessful, investors can claim refunds here
function claimRefund() public {
require(isFinalized);
Expand All @@ -42,6 +35,10 @@ contract RefundableCrowdsale is FinalizableCrowdsale {
vault.refund(msg.sender);
}

function goalReached() public view returns (bool) {
return weiRaised >= goal;
}

// vault finalization task, called when owner calls finalize()
function finalization() internal {
if (goalReached()) {
Expand All @@ -53,8 +50,11 @@ contract RefundableCrowdsale is FinalizableCrowdsale {
super.finalization();
}

function goalReached() public view returns (bool) {
return weiRaised >= goal;
// We're overriding the fund forwarding from Crowdsale.
// In addition to sending the funds, we want to call
// the RefundVault deposit function
function forwardFunds() internal {
vault.deposit.value(msg.value)(msg.sender);
}

}
8 changes: 4 additions & 4 deletions contracts/mocks/ReentrancyMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ contract ReentrancyMock is ReentrancyGuard {
counter = 0;
}

function count() private {
counter += 1;
function callback() external nonReentrant {
count();
}

function countLocalRecursive(uint256 n) public nonReentrant {
Expand All @@ -38,8 +38,8 @@ contract ReentrancyMock is ReentrancyGuard {
attacker.callSender(func);
}

function callback() external nonReentrant {
count();
function count() private {
counter += 1;
}

}
48 changes: 24 additions & 24 deletions contracts/ownership/rbac/RBAC.sol
Original file line number Diff line number Diff line change
Expand Up @@ -36,30 +36,6 @@ contract RBAC {
addRole(msg.sender, ROLE_ADMIN);
}

/**
* @dev add a role to an address
* @param addr address
* @param roleName the name of the role
*/
function addRole(address addr, string roleName)
internal
{
roles[roleName].add(addr);
RoleAdded(addr, roleName);
}

/**
* @dev remove a role from an address
* @param addr address
* @param roleName the name of the role
*/
function removeRole(address addr, string roleName)
internal
{
roles[roleName].remove(addr);
RoleRemoved(addr, roleName);
}

/**
* @dev reverts if addr does not have role
* @param addr address
Expand Down Expand Up @@ -111,6 +87,30 @@ contract RBAC {
removeRole(addr, roleName);
}

/**
* @dev add a role to an address
* @param addr address
* @param roleName the name of the role
*/
function addRole(address addr, string roleName)
internal
{
roles[roleName].add(addr);
RoleAdded(addr, roleName);
}

/**
* @dev remove a role from an address
* @param addr address
* @param roleName the name of the role
*/
function removeRole(address addr, string roleName)
internal
{
roles[roleName].remove(addr);
RoleRemoved(addr, roleName);
}

/**
* @dev modifier to scope access to a single role (uses msg.sender as addr)
* @param roleName the name of the role
Expand Down
20 changes: 10 additions & 10 deletions contracts/payment/PullPayment.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,6 @@ contract PullPayment {
mapping(address => uint256) public payments;
uint256 public totalPayments;

/**
* @dev Called by the payer to store the sent amount as credit to be pulled.
* @param dest The destination address of the funds.
* @param amount The amount to transfer.
*/
function asyncSend(address dest, uint256 amount) internal {
payments[dest] = payments[dest].add(amount);
totalPayments = totalPayments.add(amount);
}

/**
* @dev withdraw accumulated balance, called by payee.
*/
Expand All @@ -40,4 +30,14 @@ contract PullPayment {

assert(payee.send(payment));
}

/**
* @dev Called by the payer to store the sent amount as credit to be pulled.
* @param dest The destination address of the funds.
* @param amount The amount to transfer.
*/
function asyncSend(address dest, uint256 amount) internal {
payments[dest] = payments[dest].add(amount);
totalPayments = totalPayments.add(amount);
}
}
28 changes: 14 additions & 14 deletions contracts/payment/SplitPayment.sol
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,9 @@ contract SplitPayment {
}

/**
* @dev Add a new payee to the contract.
* @param _payee The address of the payee to add.
* @param _shares The number of shares owned by the payee.
* @dev payable fallback
*/
function addPayee(address _payee, uint256 _shares) internal {
require(_payee != address(0));
require(_shares > 0);
require(shares[_payee] == 0);

payees.push(_payee);
shares[_payee] = _shares;
totalShares = totalShares.add(_shares);
}
function () public payable {}

/**
* @dev Claim your share of the balance.
Expand All @@ -65,7 +55,17 @@ contract SplitPayment {
}

/**
* @dev payable fallback
* @dev Add a new payee to the contract.
* @param _payee The address of the payee to add.
* @param _shares The number of shares owned by the payee.
*/
function () public payable {}
function addPayee(address _payee, uint256 _shares) internal {
require(_payee != address(0));
require(_shares > 0);
require(shares[_payee] == 0);

payees.push(_payee);
shares[_payee] = _shares;
totalShares = totalShares.add(_shares);
}
}

0 comments on commit bd2f177

Please sign in to comment.