Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
O
openzeppelin-contracts-upgradeable
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
俞永鹏
openzeppelin-contracts-upgradeable
Commits
bd2f1773
Commit
bd2f1773
authored
Jan 15, 2018
by
Matt Condon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: solium errors - function-order only
parent
e60aee61
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
90 additions
and
91 deletions
+90
-91
Bounty.sol
contracts/Bounty.sol
+6
-6
CappedCrowdsale.sol
contracts/crowdsale/CappedCrowdsale.sol
+7
-7
Crowdsale.sol
contracts/crowdsale/Crowdsale.sol
+16
-17
RefundableCrowdsale.sol
contracts/crowdsale/RefundableCrowdsale.sol
+9
-9
ReentrancyMock.sol
contracts/mocks/ReentrancyMock.sol
+4
-4
RBAC.sol
contracts/ownership/rbac/RBAC.sol
+24
-24
PullPayment.sol
contracts/payment/PullPayment.sol
+10
-10
SplitPayment.sol
contracts/payment/SplitPayment.sol
+14
-14
No files found.
contracts/Bounty.sol
View file @
bd2f1773
...
@@ -35,12 +35,6 @@ contract Bounty is PullPayment, Destructible {
...
@@ -35,12 +35,6 @@ contract Bounty is PullPayment, Destructible {
}
}
/**
/**
* @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.
* @dev Sends the contract funds to the researcher that proved the contract is broken.
* @param target contract
* @param target contract
*/
*/
...
@@ -53,6 +47,12 @@ contract Bounty is PullPayment, Destructible {
...
@@ -53,6 +47,12 @@ contract Bounty is PullPayment, Destructible {
claimed = true;
claimed = true;
}
}
/**
* @dev Internal function to deploy the target contract.
* @return A target contract address
*/
function deployContract() internal returns(address);
}
}
...
...
contracts/crowdsale/CappedCrowdsale.sol
View file @
bd2f1773
...
@@ -18,13 +18,6 @@ contract CappedCrowdsale is Crowdsale {
...
@@ -18,13 +18,6 @@ contract CappedCrowdsale is Crowdsale {
cap = _cap;
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
// overriding Crowdsale#hasEnded to add cap logic
// @return true if crowdsale event has ended
// @return true if crowdsale event has ended
function hasEnded() public view returns (bool) {
function hasEnded() public view returns (bool) {
...
@@ -32,4 +25,11 @@ contract CappedCrowdsale is Crowdsale {
...
@@ -32,4 +25,11 @@ contract CappedCrowdsale is Crowdsale {
return super.hasEnded() || capReached;
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;
}
}
}
contracts/crowdsale/Crowdsale.sol
View file @
bd2f1773
...
@@ -54,22 +54,11 @@ contract Crowdsale {
...
@@ -54,22 +54,11 @@ contract Crowdsale {
wallet = _wallet;
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
// fallback function can be used to buy tokens
function () external payable {
function () external payable {
buyTokens(msg.sender);
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
// low level token purchase function
function buyTokens(address beneficiary) public payable {
function buyTokens(address beneficiary) public payable {
require(beneficiary != address(0));
require(beneficiary != address(0));
...
@@ -89,6 +78,22 @@ contract Crowdsale {
...
@@ -89,6 +78,22 @@ contract Crowdsale {
forwardFunds();
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
// send ether to the fund collection wallet
// override to create custom fund forwarding mechanisms
// override to create custom fund forwarding mechanisms
function forwardFunds() internal {
function forwardFunds() internal {
...
@@ -102,10 +107,4 @@ contract Crowdsale {
...
@@ -102,10 +107,4 @@ contract Crowdsale {
return withinPeriod && nonZeroPurchase;
return withinPeriod && nonZeroPurchase;
}
}
// @return true if crowdsale event has ended
function hasEnded() public view returns (bool) {
return now > endTime;
}
}
}
contracts/crowdsale/RefundableCrowdsale.sol
View file @
bd2f1773
...
@@ -27,13 +27,6 @@ contract RefundableCrowdsale is FinalizableCrowdsale {
...
@@ -27,13 +27,6 @@ contract RefundableCrowdsale is FinalizableCrowdsale {
goal = _goal;
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
// if crowdsale is unsuccessful, investors can claim refunds here
function claimRefund() public {
function claimRefund() public {
require(isFinalized);
require(isFinalized);
...
@@ -42,6 +35,10 @@ contract RefundableCrowdsale is FinalizableCrowdsale {
...
@@ -42,6 +35,10 @@ contract RefundableCrowdsale is FinalizableCrowdsale {
vault.refund(msg.sender);
vault.refund(msg.sender);
}
}
function goalReached() public view returns (bool) {
return weiRaised >= goal;
}
// vault finalization task, called when owner calls finalize()
// vault finalization task, called when owner calls finalize()
function finalization() internal {
function finalization() internal {
if (goalReached()) {
if (goalReached()) {
...
@@ -53,8 +50,11 @@ contract RefundableCrowdsale is FinalizableCrowdsale {
...
@@ -53,8 +50,11 @@ contract RefundableCrowdsale is FinalizableCrowdsale {
super.finalization();
super.finalization();
}
}
function goalReached() public view returns (bool) {
// We're overriding the fund forwarding from Crowdsale.
return weiRaised >= goal;
// In addition to sending the funds, we want to call
// the RefundVault deposit function
function forwardFunds() internal {
vault.deposit.value(msg.value)(msg.sender);
}
}
}
}
contracts/mocks/ReentrancyMock.sol
View file @
bd2f1773
...
@@ -12,8 +12,8 @@ contract ReentrancyMock is ReentrancyGuard {
...
@@ -12,8 +12,8 @@ contract ReentrancyMock is ReentrancyGuard {
counter = 0;
counter = 0;
}
}
function c
ount() private
{
function c
allback() external nonReentrant
{
count
er += 1
;
count
()
;
}
}
function countLocalRecursive(uint256 n) public nonReentrant {
function countLocalRecursive(uint256 n) public nonReentrant {
...
@@ -38,8 +38,8 @@ contract ReentrancyMock is ReentrancyGuard {
...
@@ -38,8 +38,8 @@ contract ReentrancyMock is ReentrancyGuard {
attacker.callSender(func);
attacker.callSender(func);
}
}
function c
allback() external nonReentrant
{
function c
ount() private
{
count
()
;
count
er += 1
;
}
}
}
}
contracts/ownership/rbac/RBAC.sol
View file @
bd2f1773
...
@@ -37,30 +37,6 @@ contract RBAC {
...
@@ -37,30 +37,6 @@ contract RBAC {
}
}
/**
/**
* @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
* @dev reverts if addr does not have role
* @param addr address
* @param addr address
* @param roleName the name of the role
* @param roleName the name of the role
...
@@ -112,6 +88,30 @@ contract RBAC {
...
@@ -112,6 +88,30 @@ contract RBAC {
}
}
/**
/**
* @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)
* @dev modifier to scope access to a single role (uses msg.sender as addr)
* @param roleName the name of the role
* @param roleName the name of the role
* // reverts
* // reverts
...
...
contracts/payment/PullPayment.sol
View file @
bd2f1773
...
@@ -16,16 +16,6 @@ contract PullPayment {
...
@@ -16,16 +16,6 @@ contract PullPayment {
uint256 public totalPayments;
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.
* @dev withdraw accumulated balance, called by payee.
*/
*/
function withdrawPayments() public {
function withdrawPayments() public {
...
@@ -40,4 +30,14 @@ contract PullPayment {
...
@@ -40,4 +30,14 @@ contract PullPayment {
assert(payee.send(payment));
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);
}
}
}
contracts/payment/SplitPayment.sol
View file @
bd2f1773
...
@@ -30,19 +30,9 @@ contract SplitPayment {
...
@@ -30,19 +30,9 @@ contract SplitPayment {
}
}
/**
/**
* @dev Add a new payee to the contract.
* @dev payable fallback
* @param _payee The address of the payee to add.
* @param _shares The number of shares owned by the payee.
*/
*/
function addPayee(address _payee, uint256 _shares) internal {
function () public payable {}
require(_payee != address(0));
require(_shares > 0);
require(shares[_payee] == 0);
payees.push(_payee);
shares[_payee] = _shares;
totalShares = totalShares.add(_shares);
}
/**
/**
* @dev Claim your share of the balance.
* @dev Claim your share of the balance.
...
@@ -65,7 +55,17 @@ contract SplitPayment {
...
@@ -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);
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment