-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDistributor.sol
44 lines (33 loc) · 1.11 KB
/
Distributor.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
pragma solidity ^0.4.25;
import "./Roles.sol";
//中间商角色
contract Distributor {
using Roles for Roles.Role;
event DistributorAdded(address indexed account);
event DistributorRemoved(address indexed account);
Roles.Role private _distributors;
constructor (address distributor ) public {
_addDistributor(distributor);
}
modifier onlyDistributor() {
require(isDistributor(msg.sender), "DistributorRole: caller does not have the Distributor role");
_;
}
function isDistributor(address account) public view returns (bool) {
return _distributors.has(account);
}
function addDistributor(address account) public onlyDistributor {
_addDistributor(account);
}
function renounceDistributor() public {
_removeDistributor(msg.sender);
}
function _addDistributor(address account) internal {
_distributors.add(account);
emit DistributorAdded(account);
}
function _removeDistributor(address account) internal {
_distributors.remove(account);
emit DistributorRemoved(account);
}
}