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
95146069
Commit
95146069
authored
Sep 07, 2018
by
Nicolás Venturo
Committed by
Francisco Giordano
Sep 07, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added events to the role contracts. (#1302)
* Added events to the role contracts. * Fixed linter error.
parent
84e63bbf
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
32 additions
and
0 deletions
+32
-0
CapperRole.sol
contracts/access/roles/CapperRole.sol
+5
-0
MinterRole.sol
contracts/access/roles/MinterRole.sol
+5
-0
PauserRole.sol
contracts/access/roles/PauserRole.sol
+5
-0
SignerRole.sol
contracts/access/roles/SignerRole.sol
+5
-0
PublicRole.behavior.js
test/access/roles/PublicRole.behavior.js
+12
-0
No files found.
contracts/access/roles/CapperRole.sol
View file @
95146069
...
...
@@ -6,6 +6,9 @@ import "../Roles.sol";
contract CapperRole {
using Roles for Roles.Role;
event CapperAdded(address indexed account);
event CapperRemoved(address indexed account);
Roles.Role private cappers;
constructor() public {
...
...
@@ -23,6 +26,7 @@ contract CapperRole {
function addCapper(address _account) public onlyCapper {
cappers.add(_account);
emit CapperAdded(_account);
}
function renounceCapper() public {
...
...
@@ -31,5 +35,6 @@ contract CapperRole {
function _removeCapper(address _account) internal {
cappers.remove(_account);
emit CapperRemoved(_account);
}
}
contracts/access/roles/MinterRole.sol
View file @
95146069
...
...
@@ -6,6 +6,9 @@ import "../Roles.sol";
contract MinterRole {
using Roles for Roles.Role;
event MinterAdded(address indexed account);
event MinterRemoved(address indexed account);
Roles.Role private minters;
constructor() public {
...
...
@@ -23,6 +26,7 @@ contract MinterRole {
function addMinter(address _account) public onlyMinter {
minters.add(_account);
emit MinterAdded(_account);
}
function renounceMinter() public {
...
...
@@ -31,5 +35,6 @@ contract MinterRole {
function _removeMinter(address _account) internal {
minters.remove(_account);
emit MinterRemoved(_account);
}
}
contracts/access/roles/PauserRole.sol
View file @
95146069
...
...
@@ -6,6 +6,9 @@ import "../Roles.sol";
contract PauserRole {
using Roles for Roles.Role;
event PauserAdded(address indexed account);
event PauserRemoved(address indexed account);
Roles.Role private pausers;
constructor() public {
...
...
@@ -23,6 +26,7 @@ contract PauserRole {
function addPauser(address _account) public onlyPauser {
pausers.add(_account);
emit PauserAdded(_account);
}
function renouncePauser() public {
...
...
@@ -31,5 +35,6 @@ contract PauserRole {
function _removePauser(address _account) internal {
pausers.remove(_account);
emit PauserRemoved(_account);
}
}
contracts/access/roles/SignerRole.sol
View file @
95146069
...
...
@@ -6,6 +6,9 @@ import "../Roles.sol";
contract SignerRole {
using Roles for Roles.Role;
event SignerAdded(address indexed account);
event SignerRemoved(address indexed account);
Roles.Role private signers;
constructor() public {
...
...
@@ -23,6 +26,7 @@ contract SignerRole {
function addSigner(address _account) public onlySigner {
signers.add(_account);
emit SignerAdded(_account);
}
function renounceSigner() public {
...
...
@@ -31,5 +35,6 @@ contract SignerRole {
function _removeSigner(address _account) internal {
signers.remove(_account);
emit SignerRemoved(_account);
}
}
test/access/roles/PublicRole.behavior.js
View file @
95146069
const
expectEvent
=
require
(
'../../helpers/expectEvent'
);
require
(
'chai'
)
.
should
();
...
...
@@ -22,6 +24,11 @@ function shouldBehaveLikePublicRole (authorized, otherAuthorized, [anyone], role
(
await
this
.
contract
[
`is
${
rolename
}
`
](
anyone
)).
should
.
equal
(
true
);
});
it
(
`emits a
${
rolename
}
Added event`
,
async
function
()
{
const
{
logs
}
=
await
this
.
contract
[
`add
${
rolename
}
`
](
anyone
,
{
from
:
authorized
});
expectEvent
.
inLogs
(
logs
,
`
${
rolename
}
Added`
,
{
account
:
anyone
});
});
it
(
'adds role to an already-assigned account'
,
async
function
()
{
await
this
.
contract
[
`add
${
rolename
}
`
](
authorized
,
{
from
:
authorized
});
(
await
this
.
contract
[
`is
${
rolename
}
`
](
authorized
)).
should
.
equal
(
true
);
...
...
@@ -39,6 +46,11 @@ function shouldBehaveLikePublicRole (authorized, otherAuthorized, [anyone], role
(
await
this
.
contract
[
`is
${
rolename
}
`
](
otherAuthorized
)).
should
.
equal
(
true
);
});
it
(
`emits a
${
rolename
}
Removed event`
,
async
function
()
{
const
{
logs
}
=
await
this
.
contract
[
`remove
${
rolename
}
`
](
authorized
);
expectEvent
.
inLogs
(
logs
,
`
${
rolename
}
Removed`
,
{
account
:
authorized
});
});
it
(
'doesn
\'
t revert when removing from an unassigned account'
,
async
function
()
{
await
this
.
contract
[
`remove
${
rolename
}
`
](
anyone
);
});
...
...
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