* Error handling in ERC20 and ERC721 * Added message string for require. * Fixed solhint errors. * Updated PR as per issue #1709 * changes as per #1709 and openzeppelin forum. * Changes in require statement * Changes in require statement * build pipeline fix * Changes as per @nventuro's comment. * Update revert reason strings. * Fianal update of revert reason strings. * WIP: Updating reason strings in test cases * WIP: Added changes to ERC20 and ERC721 * Fixes linting errors in *.tes.js files * Achieved 100% code coverage * Updated the test cases with shouldFail.reverting.withMessage() * Fix package-lock. * address review comments * fix linter issues * fix remaining revert reasons
37 lines
982 B
Solidity
37 lines
982 B
Solidity
pragma solidity ^0.5.7;
|
|
|
|
/**
|
|
* @title Roles
|
|
* @dev Library for managing addresses assigned to a Role.
|
|
*/
|
|
library Roles {
|
|
struct Role {
|
|
mapping (address => bool) bearer;
|
|
}
|
|
|
|
/**
|
|
* @dev Give an account access to this role.
|
|
*/
|
|
function add(Role storage role, address account) internal {
|
|
require(!has(role, account), "Roles: account already has role");
|
|
role.bearer[account] = true;
|
|
}
|
|
|
|
/**
|
|
* @dev Remove an account's access to this role.
|
|
*/
|
|
function remove(Role storage role, address account) internal {
|
|
require(has(role, account), "Roles: account does not have role");
|
|
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), "Roles: account is the zero address");
|
|
return role.bearer[account];
|
|
}
|
|
}
|