Skip to content

Commit

Permalink
Merge branch 'master' into fix/OpenZeppelin#1205
Browse files Browse the repository at this point in the history
  • Loading branch information
nventuro committed Dec 7, 2018
2 parents 46aac62 + b7d56d5 commit 1f4775f
Show file tree
Hide file tree
Showing 161 changed files with 4,016 additions and 5,556 deletions.
5 changes: 0 additions & 5 deletions .env.example

This file was deleted.

11 changes: 7 additions & 4 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
{
"extends" : [
"standard",
"plugin:promise/recommended"
"plugin:promise/recommended",
],
"plugins": [
"promise"
"mocha-no-only",
"promise",
],
"env": {
"browser" : true,
"node" : true,
"mocha" : true,
"jest" : true
"jest" : true,
},
"globals" : {
"artifacts": false,
"contract": false,
"assert": false,
"web3": false
"web3": false,
},
"rules": {

Expand Down Expand Up @@ -49,6 +50,8 @@
"semi": ["error", "always"],
"space-before-function-paren": ["error", "always"],

"mocha-no-only/mocha-no-only": ["error"],

"promise/always-return": "off",
"promise/avoid-new": "off",
}
Expand Down
5 changes: 3 additions & 2 deletions .soliumrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
"extends": "solium:all",
"plugins": ["security"],
"rules": {
"arg-overflow": "off",
"blank-lines": "off",
"error-reason": "off",
"indentation": ["error", 2],
"indentation": ["error", 4],
"lbrace": "off",
"linebreak-style": ["error", "unix"],
"max-len": ["error", 79],
"max-len": ["error", 120],
"no-constant": ["error"],
"no-empty-blocks": "off",
"quotes": ["error", "double"],
Expand Down
23 changes: 10 additions & 13 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,26 @@ jobs:
# --elopio - 20180531
fast_finish: true
allow_failures:
- env: SOLIDITY_COVERAGE=true
- env: SOLC_NIGHTLY=true
include:
# Run the unit test suite three times in parallel.
# The first one gets results faster and is the only one required to pass.
# The second one generates the coverage report.
# The third one is to keep us informed about possible issues with the
# upcoming solidity release.
- stage: tests
name: "unit tests"
name: "Linter"
script: npm run lint

- stage: tests
name: "Unit tests"
script: npm run test

- stage: tests
name: "unit tests with coverage"
name: "Unit tests with coverage report"
script: npm run test
env: SOLIDITY_COVERAGE=true

- stage: tests
name: "unit tests with solc nightly"
name: "Unit tests using solc nightly"
script: npm run test
env: SOLC_NIGHTLY=true
# solidity and javascript style tests.
- stage: tests
name: "static tests"
script: npm run lint

- stage: update docs
if: tag =~ ^v[0-9]+\.[0-9]+\.[0-9]+$
addons:
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# <img src="logo.png" alt="OpenZeppelin" width="400px">

[![NPM Package](https://img.shields.io/npm/v/openzeppelin-solidity.svg?style=flat-square)](https://www.npmjs.org/package/openzeppelin-solidity)
[![Build Status](https://img.shields.io/travis/OpenZeppelin/openzeppelin-solidity.svg?branch=master&style=flat-square)](https://travis-ci.org/OpenZeppelin/openzeppelin-solidity)
[![Coverage Status](https://img.shields.io/coveralls/github/OpenZeppelin/openzeppelin-solidity/master.svg?style=flat-square)](https://coveralls.io/github/OpenZeppelin/openzeppelin-solidity?branch=master)
[![Build Status](https://travis-ci.com/OpenZeppelin/openzeppelin-solidity.svg?branch=master)](https://travis-ci.com/OpenZeppelin/openzeppelin-solidity)
[![Coverage Status](https://coveralls.io/repos/github/OpenZeppelin/openzeppelin-solidity/badge.svg?branch=master)](https://coveralls.io/github/OpenZeppelin/openzeppelin-solidity?branch=master)

**OpenZeppelin is a library for secure smart contract development.** It provides implementations of standards like ERC20 and ERC721 which you can deploy as-is or extend to suit your needs, as well as Solidity components to build custom contracts and more complex decentralized systems.

Expand Down
4 changes: 2 additions & 2 deletions RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Draft the release notes in our [GitHub releases](https://github.com/OpenZeppelin

Before publishing on npm you need to generate the build artifacts. This is not done automatically at the moment because of a bug in Truffle. Since some of the contracts should not be included in the package, this is a _hairy_ process that you need to do with care.

1. Delete the `contracts/mocks` and `contracts/examples` directories.
1. Delete the `contracts/mocks`, `contracts/examples` and `build` directories.
2. Run `truffle compile`. (Note that the Truffle process may never exit and you will have to interrupt it.)
3. Recover the directories using `git checkout`. It doesn't matter if you do this now or later.

Expand Down Expand Up @@ -70,7 +70,7 @@ Draft the release notes in GitHub releases. Try to be consistent with our previo

Before publishing on npm you need to generate the build artifacts. This is not done automatically at the moment because of a bug in Truffle. Since some of the contracts should not be included in the package, this is a _hairy_ process that you need to do with care.

1. Delete the `contracts/mocks` and `contracts/examples` directories.
1. Delete the `contracts/mocks`, `contracts/examples` and `build` directories.
2. Run `truffle compile`. (Note that the Truffle process may never exit and you will have to interrupt it.)
3. Recover the directories using `git checkout`. It doesn't matter if you do this now or later.

Expand Down
58 changes: 27 additions & 31 deletions contracts/access/Roles.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,40 +5,36 @@ pragma solidity ^0.4.24;
* @dev Library for managing addresses assigned to a Role.
*/
library Roles {
struct Role {
mapping (address => bool) bearer;
}
struct Role {
mapping (address => bool) bearer;
}

/**
* @dev give an account access to this role
*/
function add(Role storage role, address account) internal {
require(account != address(0));
require(!has(role, account));
/**
* @dev give an account access to this role
*/
function add(Role storage role, address account) internal {
require(account != address(0));
require(!has(role, account));

role.bearer[account] = true;
}
role.bearer[account] = true;
}

/**
* @dev remove an account's access to this role
*/
function remove(Role storage role, address account) internal {
require(account != address(0));
require(has(role, account));
/**
* @dev remove an account's access to this role
*/
function remove(Role storage role, address account) internal {
require(account != address(0));
require(has(role, account));

role.bearer[account] = false;
}
role.bearer[account] = false;
}

/**
* @dev check if an account has this role
* @return bool
*/
function has(Role storage role, address account)
internal
view
returns (bool)
{
require(account != address(0));
return role.bearer[account];
}
/**
* @dev check if an account has this role
* @return bool
*/
function has(Role storage role, address account) internal view returns (bool) {
require(account != address(0));
return role.bearer[account];
}
}
56 changes: 28 additions & 28 deletions contracts/access/roles/CapperRole.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,41 @@ pragma solidity ^0.4.24;
import "../Roles.sol";

contract CapperRole {
using Roles for Roles.Role;
using Roles for Roles.Role;

event CapperAdded(address indexed account);
event CapperRemoved(address indexed account);
event CapperAdded(address indexed account);
event CapperRemoved(address indexed account);

Roles.Role private cappers;
Roles.Role private _cappers;

constructor() internal {
_addCapper(msg.sender);
}
constructor () internal {
_addCapper(msg.sender);
}

modifier onlyCapper() {
require(isCapper(msg.sender));
_;
}
modifier onlyCapper() {
require(isCapper(msg.sender));
_;
}

function isCapper(address account) public view returns (bool) {
return cappers.has(account);
}
function isCapper(address account) public view returns (bool) {
return _cappers.has(account);
}

function addCapper(address account) public onlyCapper {
_addCapper(account);
}
function addCapper(address account) public onlyCapper {
_addCapper(account);
}

function renounceCapper() public {
_removeCapper(msg.sender);
}
function renounceCapper() public {
_removeCapper(msg.sender);
}

function _addCapper(address account) internal {
cappers.add(account);
emit CapperAdded(account);
}
function _addCapper(address account) internal {
_cappers.add(account);
emit CapperAdded(account);
}

function _removeCapper(address account) internal {
cappers.remove(account);
emit CapperRemoved(account);
}
function _removeCapper(address account) internal {
_cappers.remove(account);
emit CapperRemoved(account);
}
}
56 changes: 28 additions & 28 deletions contracts/access/roles/MinterRole.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,41 @@ pragma solidity ^0.4.24;
import "../Roles.sol";

contract MinterRole {
using Roles for Roles.Role;
using Roles for Roles.Role;

event MinterAdded(address indexed account);
event MinterRemoved(address indexed account);
event MinterAdded(address indexed account);
event MinterRemoved(address indexed account);

Roles.Role private minters;
Roles.Role private _minters;

constructor() internal {
_addMinter(msg.sender);
}
constructor () internal {
_addMinter(msg.sender);
}

modifier onlyMinter() {
require(isMinter(msg.sender));
_;
}
modifier onlyMinter() {
require(isMinter(msg.sender));
_;
}

function isMinter(address account) public view returns (bool) {
return minters.has(account);
}
function isMinter(address account) public view returns (bool) {
return _minters.has(account);
}

function addMinter(address account) public onlyMinter {
_addMinter(account);
}
function addMinter(address account) public onlyMinter {
_addMinter(account);
}

function renounceMinter() public {
_removeMinter(msg.sender);
}
function renounceMinter() public {
_removeMinter(msg.sender);
}

function _addMinter(address account) internal {
minters.add(account);
emit MinterAdded(account);
}
function _addMinter(address account) internal {
_minters.add(account);
emit MinterAdded(account);
}

function _removeMinter(address account) internal {
minters.remove(account);
emit MinterRemoved(account);
}
function _removeMinter(address account) internal {
_minters.remove(account);
emit MinterRemoved(account);
}
}
Loading

0 comments on commit 1f4775f

Please sign in to comment.