2019-03-14 23:41:04 -07:00
|
|
|
pragma solidity ^0.5.3;
|
|
|
|
|
|
|
|
import "./RoleManager.sol";
|
|
|
|
import "./AccountManager.sol";
|
|
|
|
import "./VoterManager.sol";
|
|
|
|
import "./NodeManager.sol";
|
|
|
|
import "./OrgManager.sol";
|
2019-03-15 02:26:57 -07:00
|
|
|
import "./PermissionsUpgradable.sol";
|
2019-03-14 23:41:04 -07:00
|
|
|
|
|
|
|
contract PermissionsImplementation {
|
|
|
|
AccountManager private accounts;
|
|
|
|
RoleManager private roles;
|
|
|
|
VoterManager private voter;
|
|
|
|
NodeManager private nodes;
|
|
|
|
OrgManager private org;
|
2019-03-19 02:15:51 -07:00
|
|
|
PermissionsUpgradable private permUpgradable;
|
|
|
|
|
2019-03-14 23:41:04 -07:00
|
|
|
string private adminOrg;
|
|
|
|
string private adminRole;
|
|
|
|
string private orgAdminRole;
|
|
|
|
|
2019-04-08 07:26:13 -07:00
|
|
|
|
2019-03-14 23:41:04 -07:00
|
|
|
uint private fullAccess = 3;
|
|
|
|
|
|
|
|
// checks if first time network boot up has happened or not
|
|
|
|
bool private networkBoot = false;
|
|
|
|
|
2019-03-15 02:26:57 -07:00
|
|
|
modifier onlyProxy
|
|
|
|
{
|
|
|
|
require(msg.sender == permUpgradable.getPermInterface(), "can be called by proxy only");
|
|
|
|
_;
|
|
|
|
}
|
2019-04-08 01:57:36 -07:00
|
|
|
// Modifiers
|
2019-03-14 23:41:04 -07:00
|
|
|
// Checks if the given network boot up is pending exists
|
2019-03-28 02:53:11 -07:00
|
|
|
modifier networkBootStatus(bool _status)
|
2019-03-14 23:41:04 -07:00
|
|
|
{
|
2019-03-28 02:53:11 -07:00
|
|
|
require(networkBoot == _status, "Incorrect network boot status");
|
2019-03-14 23:41:04 -07:00
|
|
|
_;
|
|
|
|
}
|
|
|
|
modifier networkAdmin(address _account) {
|
|
|
|
require(isNetworkAdmin(_account) == true, "Not an network admin");
|
|
|
|
_;
|
|
|
|
}
|
|
|
|
|
|
|
|
modifier orgAdmin(address _account, string memory _orgId) {
|
2019-04-04 03:25:43 -07:00
|
|
|
require(isOrgAdmin(_account, _orgId) == true, "Not an org admin");
|
2019-03-14 23:41:04 -07:00
|
|
|
_;
|
|
|
|
}
|
|
|
|
|
|
|
|
modifier orgNotExists(string memory _orgId) {
|
2019-03-28 02:53:11 -07:00
|
|
|
require(checkOrgExists(_orgId) != true, "Org already exists");
|
2019-03-14 23:41:04 -07:00
|
|
|
_;
|
|
|
|
}
|
|
|
|
|
2019-04-03 07:25:01 -07:00
|
|
|
|
2019-03-14 23:41:04 -07:00
|
|
|
modifier orgExists(string memory _orgId) {
|
2019-03-28 02:53:11 -07:00
|
|
|
require(checkOrgExists(_orgId) == true, "Org does not exists");
|
2019-03-14 23:41:04 -07:00
|
|
|
_;
|
|
|
|
}
|
|
|
|
|
|
|
|
modifier orgApproved(string memory _orgId) {
|
2019-03-28 02:53:11 -07:00
|
|
|
require(checkOrgApproved(_orgId) == true, "Org not approved");
|
2019-03-14 23:41:04 -07:00
|
|
|
_;
|
|
|
|
}
|
|
|
|
|
2019-03-15 02:26:57 -07:00
|
|
|
constructor (address _permUpgradable) public {
|
2019-03-19 02:15:51 -07:00
|
|
|
permUpgradable = PermissionsUpgradable(_permUpgradable);
|
2019-03-15 02:26:57 -07:00
|
|
|
}
|
2019-03-14 23:41:04 -07:00
|
|
|
|
2019-04-08 01:57:36 -07:00
|
|
|
// initial set up related functions
|
|
|
|
// set policy related attributes
|
2019-03-14 23:41:04 -07:00
|
|
|
function setPolicy(string calldata _nwAdminOrg, string calldata _nwAdminRole, string calldata _oAdminRole) external
|
2019-03-15 02:26:57 -07:00
|
|
|
onlyProxy
|
2019-03-28 02:53:11 -07:00
|
|
|
networkBootStatus(false)
|
2019-03-14 23:41:04 -07:00
|
|
|
{
|
|
|
|
adminOrg = _nwAdminOrg;
|
|
|
|
adminRole = _nwAdminRole;
|
|
|
|
orgAdminRole = _oAdminRole;
|
|
|
|
}
|
|
|
|
|
|
|
|
function init(address _orgManager, address _rolesManager, address _acctManager, address _voterManager, address _nodeManager) external
|
2019-03-15 02:26:57 -07:00
|
|
|
onlyProxy
|
2019-03-28 02:53:11 -07:00
|
|
|
networkBootStatus(false)
|
2019-03-14 23:41:04 -07:00
|
|
|
{
|
|
|
|
org = OrgManager(_orgManager);
|
|
|
|
roles = RoleManager(_rolesManager);
|
|
|
|
accounts = AccountManager(_acctManager);
|
|
|
|
voter = VoterManager(_voterManager);
|
|
|
|
nodes = NodeManager(_nodeManager);
|
|
|
|
|
|
|
|
org.addAdminOrg(adminOrg);
|
|
|
|
roles.addRole(adminRole, adminOrg, fullAccess, true);
|
|
|
|
accounts.setDefaults(adminRole, orgAdminRole);
|
|
|
|
}
|
|
|
|
|
|
|
|
function addAdminNodes(string calldata _enodeId) external
|
2019-03-15 02:26:57 -07:00
|
|
|
onlyProxy
|
2019-03-28 02:53:11 -07:00
|
|
|
networkBootStatus(false)
|
2019-03-14 23:41:04 -07:00
|
|
|
{
|
2019-03-28 02:53:11 -07:00
|
|
|
nodes.addAdminNode(_enodeId, adminOrg);
|
2019-03-14 23:41:04 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function addAdminAccounts(address _acct) external
|
2019-03-15 02:26:57 -07:00
|
|
|
onlyProxy
|
2019-03-28 02:53:11 -07:00
|
|
|
networkBootStatus(false)
|
2019-03-14 23:41:04 -07:00
|
|
|
{
|
|
|
|
// add the account as a voter for the admin org
|
2019-03-28 02:53:11 -07:00
|
|
|
updateVoterList(adminOrg, _acct, true);
|
2019-03-14 23:41:04 -07:00
|
|
|
// add the account as an account with full access into the admin org
|
|
|
|
accounts.addNWAdminAccount(_acct, adminOrg);
|
|
|
|
}
|
|
|
|
|
|
|
|
// update the network boot status as true
|
|
|
|
function updateNetworkBootStatus() external
|
2019-03-15 02:26:57 -07:00
|
|
|
onlyProxy
|
2019-03-28 02:53:11 -07:00
|
|
|
networkBootStatus(false)
|
2019-03-14 23:41:04 -07:00
|
|
|
returns (bool)
|
|
|
|
{
|
|
|
|
networkBoot = true;
|
|
|
|
return networkBoot;
|
|
|
|
}
|
|
|
|
|
2019-04-08 01:57:36 -07:00
|
|
|
function addOrg(string calldata _orgId, string calldata _enodeId, address _account, address _caller) external
|
2019-03-15 02:26:57 -07:00
|
|
|
onlyProxy
|
2019-03-28 02:53:11 -07:00
|
|
|
networkBootStatus(true)
|
2019-03-19 02:15:51 -07:00
|
|
|
networkAdmin(_caller)
|
2019-03-14 23:41:04 -07:00
|
|
|
{
|
2019-04-08 23:58:30 -07:00
|
|
|
voter.addVotingItem(adminOrg, _orgId, _enodeId, _account, 1);
|
|
|
|
org.addOrg(_orgId);
|
2019-04-08 07:26:13 -07:00
|
|
|
nodes.addNode(_enodeId, _orgId);
|
|
|
|
require(validateAccount(_account, _orgId) == true, "Operation cannot be performed");
|
|
|
|
accounts.assignAccountRole(_account, _orgId, orgAdminRole);
|
2019-03-14 23:41:04 -07:00
|
|
|
}
|
|
|
|
|
2019-04-08 23:58:30 -07:00
|
|
|
function approveOrg(string calldata _orgId, string calldata _enodeId, address _account, address _caller) external
|
2019-03-15 02:26:57 -07:00
|
|
|
onlyProxy
|
2019-03-19 02:15:51 -07:00
|
|
|
networkAdmin(_caller)
|
2019-03-14 23:41:04 -07:00
|
|
|
{
|
2019-03-28 02:53:11 -07:00
|
|
|
require(checkOrgStatus(_orgId, 1) == true, "Nothing to approve");
|
|
|
|
if ((processVote(adminOrg, _caller, 1))) {
|
2019-03-14 23:41:04 -07:00
|
|
|
org.approveOrg(_orgId);
|
2019-03-28 21:27:13 -07:00
|
|
|
roles.addRole(orgAdminRole, _orgId, fullAccess, true);
|
2019-03-28 02:53:11 -07:00
|
|
|
nodes.approveNode(_enodeId, _orgId);
|
2019-04-08 01:57:36 -07:00
|
|
|
accounts.approveOrgAdminAccount(_account);
|
2019-03-14 23:41:04 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-08 23:58:30 -07:00
|
|
|
// // function for adding a new master org
|
|
|
|
// function addOrg(string calldata _orgId, string calldata _enodeId, address _account, address _caller) external
|
|
|
|
// {
|
|
|
|
// //debugNo = 1;
|
|
|
|
// org.addOrg(_orgId);
|
|
|
|
// addOrgImpl(_orgId, _enodeId, _account, _caller);
|
|
|
|
// }
|
|
|
|
|
|
|
|
// function addOrgImpl(string memory _orgId, string memory _enodeId, address _account, address _caller) internal
|
|
|
|
// onlyProxy
|
|
|
|
// networkBootStatus(true)
|
|
|
|
// networkAdmin(_caller)
|
|
|
|
// {
|
|
|
|
// voter.addVotingItem(adminOrg, _orgId, _enodeId, _account, 1);
|
|
|
|
// nodes.addNode(_enodeId, _orgId);
|
|
|
|
// require(validateAccount(_account, _orgId) == true, "Operation cannot be performed");
|
|
|
|
// accounts.assignAccountRole(_account, _orgId, orgAdminRole);
|
|
|
|
// }
|
2019-04-04 03:25:43 -07:00
|
|
|
|
2019-04-08 23:58:30 -07:00
|
|
|
// function for adding a new master org
|
|
|
|
function addSubOrg(string calldata _pOrg, string calldata _orgId, string calldata _enodeId, address _account, address _caller) external
|
|
|
|
orgExists(_pOrg)
|
|
|
|
orgAdmin(_caller, _pOrg)
|
2019-04-03 07:25:01 -07:00
|
|
|
{
|
2019-04-08 23:58:30 -07:00
|
|
|
org.addSubOrg(_pOrg, _orgId);
|
|
|
|
string memory pid = string(abi.encodePacked(_pOrg, ".", _orgId));
|
|
|
|
if (bytes(_enodeId).length > 0) {
|
|
|
|
nodes.addNode(_enodeId, pid);
|
|
|
|
}
|
|
|
|
if (_account != address(0)) {
|
|
|
|
require(validateAccount(_account, pid) == true, "Operation cannot be performed");
|
|
|
|
accounts.assignAccountRole(_account, pid, orgAdminRole);
|
|
|
|
}
|
2019-04-03 07:25:01 -07:00
|
|
|
}
|
|
|
|
|
2019-04-08 23:58:30 -07:00
|
|
|
// function approveOrgImpl(string memory _orgId, string memory _enodeId, address _account, address _caller) internal
|
|
|
|
// onlyProxy
|
|
|
|
// networkAdmin(_caller)
|
|
|
|
// {
|
|
|
|
// require(checkOrgStatus(_orgId, 1) == true, "Nothing to approve");
|
|
|
|
// if ((processVote(adminOrg, _caller, 1))) {
|
|
|
|
// org.approveOrg(_orgId);
|
|
|
|
// roles.addRole(orgAdminRole, _orgId, fullAccess, true);
|
|
|
|
// nodes.approveNode(_enodeId, _orgId);
|
|
|
|
// accounts.approveOrgAdminAccount(_account);
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
// function approveOrg(string calldata _orgId, string calldata _enodeId, address _account, address _caller) external
|
|
|
|
// {
|
|
|
|
// approveOrgImpl(_orgId, _enodeId, _account, _caller);
|
|
|
|
// }
|
|
|
|
|
|
|
|
// function approveSubOrg(string calldata _pOrg, string calldata _orgId, string calldata _enodeId, address _account, address _caller) external
|
|
|
|
// {
|
|
|
|
// approveOrgImpl(string(abi.encodePacked(_pOrg, ".", _orgId)), _enodeId, _account, _caller);
|
|
|
|
// }
|
|
|
|
|
2019-04-01 03:22:41 -07:00
|
|
|
function updateOrgStatus(string calldata _orgId, uint _status, address _caller) external
|
2019-03-28 02:53:11 -07:00
|
|
|
onlyProxy
|
2019-04-01 03:22:41 -07:00
|
|
|
networkAdmin(_caller)
|
2019-03-28 02:53:11 -07:00
|
|
|
{
|
|
|
|
uint pendingOp;
|
|
|
|
pendingOp = org.updateOrg(_orgId, _status);
|
|
|
|
voter.addVotingItem(adminOrg, _orgId, "", address(0), pendingOp);
|
|
|
|
}
|
|
|
|
|
2019-04-01 03:22:41 -07:00
|
|
|
function approveOrgStatus(string calldata _orgId, uint _status, address _caller) external
|
2019-03-28 02:53:11 -07:00
|
|
|
onlyProxy
|
2019-04-01 03:22:41 -07:00
|
|
|
networkAdmin(_caller)
|
2019-03-28 02:53:11 -07:00
|
|
|
{
|
2019-04-03 07:25:01 -07:00
|
|
|
require((_status == 3 || _status == 5), "Operation not allowed");
|
2019-03-28 02:53:11 -07:00
|
|
|
uint pendingOp;
|
|
|
|
if (_status == 3) {
|
|
|
|
pendingOp = 2;
|
|
|
|
}
|
|
|
|
else if (_status == 5) {
|
|
|
|
pendingOp = 3;
|
|
|
|
}
|
|
|
|
require(checkOrgStatus(_orgId, _status) == true, "Operation not allowed");
|
2019-04-02 19:13:05 -07:00
|
|
|
if ((processVote(adminOrg, _caller, pendingOp))) {
|
2019-03-28 02:53:11 -07:00
|
|
|
org.approveOrgStatusUpdate(_orgId, _status);
|
|
|
|
}
|
|
|
|
}
|
2019-03-14 23:41:04 -07:00
|
|
|
|
|
|
|
// Role related functions
|
2019-04-04 03:25:43 -07:00
|
|
|
function addNewRole(string calldata _roleId, string calldata _orgId, uint _access, bool _voter, address _caller) external
|
2019-03-15 02:26:57 -07:00
|
|
|
onlyProxy
|
2019-03-14 23:41:04 -07:00
|
|
|
orgApproved(_orgId)
|
2019-03-27 04:07:01 -07:00
|
|
|
orgAdmin(_caller, _orgId)
|
2019-03-14 23:41:04 -07:00
|
|
|
{
|
|
|
|
//add new roles can be created by org admins only
|
|
|
|
roles.addRole(_roleId, _orgId, _access, _voter);
|
|
|
|
}
|
|
|
|
|
2019-04-03 07:25:01 -07:00
|
|
|
function removeRole(string calldata _roleId, string calldata _orgId, address _caller) external
|
2019-03-15 02:26:57 -07:00
|
|
|
onlyProxy
|
2019-03-14 23:41:04 -07:00
|
|
|
orgApproved(_orgId)
|
2019-03-29 01:47:14 -07:00
|
|
|
orgAdmin(_caller, _orgId)
|
2019-03-14 23:41:04 -07:00
|
|
|
{
|
2019-04-05 02:16:08 -07:00
|
|
|
require(((keccak256(abi.encodePacked(_roleId)) != keccak256(abi.encodePacked(adminRole))) &&
|
|
|
|
(keccak256(abi.encodePacked(_roleId)) != keccak256(abi.encodePacked(orgAdminRole)))), "Admin roles cannot be removed");
|
2019-03-14 23:41:04 -07:00
|
|
|
roles.removeRole(_roleId, _orgId);
|
2019-04-04 03:25:43 -07:00
|
|
|
}
|
2019-03-14 23:41:04 -07:00
|
|
|
|
2019-04-08 01:57:36 -07:00
|
|
|
// Account related functions
|
2019-03-19 02:15:51 -07:00
|
|
|
function assignOrgAdminAccount(string calldata _orgId, address _account, address _caller) external
|
2019-03-15 02:26:57 -07:00
|
|
|
onlyProxy
|
2019-03-14 23:41:04 -07:00
|
|
|
orgExists(_orgId)
|
2019-03-28 02:53:11 -07:00
|
|
|
networkAdmin(_caller)
|
2019-03-14 23:41:04 -07:00
|
|
|
{
|
2019-04-05 02:16:08 -07:00
|
|
|
require(validateAccount(_account, _orgId) == true, "Operation cannot be performed");
|
2019-03-14 23:41:04 -07:00
|
|
|
// check if orgAdmin already exists if yes then op cannot be performed
|
2019-03-28 02:53:11 -07:00
|
|
|
require(checkOrgAdminExists(_orgId) != true, "org admin exists");
|
2019-03-14 23:41:04 -07:00
|
|
|
// assign the account org admin role and propose voting
|
|
|
|
accounts.assignAccountRole(_account, _orgId, orgAdminRole);
|
|
|
|
//add voting item
|
|
|
|
voter.addVotingItem(adminOrg, _orgId, "", _account, 4);
|
|
|
|
}
|
|
|
|
|
2019-03-19 02:15:51 -07:00
|
|
|
function approveOrgAdminAccount(address _account, address _caller) external
|
2019-03-15 02:26:57 -07:00
|
|
|
onlyProxy
|
2019-03-19 02:15:51 -07:00
|
|
|
networkAdmin(_caller)
|
2019-03-14 23:41:04 -07:00
|
|
|
{
|
2019-03-19 02:15:51 -07:00
|
|
|
require(isNetworkAdmin(_caller) == true, "can be called from network admin only");
|
2019-03-28 02:53:11 -07:00
|
|
|
if ((processVote(adminOrg, _caller, 4))) {
|
2019-03-14 23:41:04 -07:00
|
|
|
accounts.approveOrgAdminAccount(_account);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-04 03:25:43 -07:00
|
|
|
function assignAccountRole(address _acct, string memory _orgId, string memory _roleId, address _caller) public
|
2019-03-15 02:26:57 -07:00
|
|
|
onlyProxy
|
2019-03-27 04:07:01 -07:00
|
|
|
orgAdmin(_caller, _orgId)
|
2019-03-28 02:53:11 -07:00
|
|
|
orgApproved(_orgId)
|
2019-03-14 23:41:04 -07:00
|
|
|
{
|
|
|
|
require(validateAccount(_acct, _orgId) == true, "Operation cannot be performed");
|
2019-03-28 02:53:11 -07:00
|
|
|
require(roleExists(_roleId, _orgId) == true, "role does not exists");
|
|
|
|
bool newRoleVoter = isVoterRole(_roleId, _orgId);
|
2019-04-03 07:25:01 -07:00
|
|
|
// // check the role of the account. if the current role is voter and new role is also voter
|
|
|
|
// // voterlist change is not required. else voter list needs to be changed
|
2019-03-14 23:41:04 -07:00
|
|
|
string memory acctRole = accounts.getAccountRole(_acct);
|
|
|
|
if (keccak256(abi.encodePacked(acctRole)) == keccak256(abi.encodePacked("NONE"))) {
|
|
|
|
//new account
|
|
|
|
if (newRoleVoter) {
|
|
|
|
// add to voter list
|
2019-03-28 02:53:11 -07:00
|
|
|
updateVoterList(_orgId, _acct, true);
|
2019-03-14 23:41:04 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2019-03-28 02:53:11 -07:00
|
|
|
bool currRoleVoter = isVoterRole(acctRole, _orgId);
|
2019-03-14 23:41:04 -07:00
|
|
|
if (!(currRoleVoter && newRoleVoter)) {
|
|
|
|
if (newRoleVoter) {
|
|
|
|
// add to voter list
|
2019-03-28 02:53:11 -07:00
|
|
|
updateVoterList(_orgId, _acct, true);
|
2019-03-14 23:41:04 -07:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
// delete from voter list
|
2019-03-28 02:53:11 -07:00
|
|
|
updateVoterList(_orgId, _acct, false);
|
2019-03-14 23:41:04 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
accounts.assignAccountRole(_acct, _orgId, _roleId);
|
2019-04-04 03:25:43 -07:00
|
|
|
}
|
2019-03-14 23:41:04 -07:00
|
|
|
|
2019-04-08 01:57:36 -07:00
|
|
|
|
|
|
|
// Node related functions
|
2019-03-27 04:07:01 -07:00
|
|
|
function addNode(string calldata _orgId, string calldata _enodeId, address _caller) external
|
2019-03-15 02:26:57 -07:00
|
|
|
onlyProxy
|
2019-03-14 23:41:04 -07:00
|
|
|
orgApproved(_orgId)
|
2019-03-27 04:07:01 -07:00
|
|
|
orgAdmin(_caller, _orgId)
|
2019-03-14 23:41:04 -07:00
|
|
|
{
|
|
|
|
// check that the node is not part of another org
|
|
|
|
nodes.addOrgNode(_enodeId, _orgId);
|
|
|
|
}
|
|
|
|
|
2019-04-08 01:57:36 -07:00
|
|
|
function updateNodeStatus(string calldata _orgId, string calldata _enodeId, uint _status, address _caller) external
|
|
|
|
onlyProxy
|
|
|
|
orgExists(_orgId)
|
|
|
|
orgAdmin(_caller, _orgId)
|
|
|
|
{
|
|
|
|
nodes.updateNodeStatus(_enodeId, _orgId, _status);
|
|
|
|
}
|
2019-04-04 03:25:43 -07:00
|
|
|
|
2019-04-08 01:57:36 -07:00
|
|
|
// Get network boot status
|
|
|
|
function getNetworkBootStatus() external view
|
|
|
|
returns (bool)
|
2019-03-14 23:41:04 -07:00
|
|
|
{
|
2019-04-08 01:57:36 -07:00
|
|
|
return networkBoot;
|
|
|
|
}
|
2019-04-04 03:25:43 -07:00
|
|
|
|
2019-04-08 01:57:36 -07:00
|
|
|
// Voter related functions
|
|
|
|
function updateVoterList(string memory _orgId, address _account, bool _add) internal
|
2019-03-14 23:41:04 -07:00
|
|
|
{
|
2019-04-08 01:57:36 -07:00
|
|
|
if (_add) {
|
|
|
|
voter.addVoter(_orgId, _account);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
voter.deleteVoter(_orgId, _account);
|
|
|
|
}
|
2019-03-14 23:41:04 -07:00
|
|
|
}
|
|
|
|
|
2019-04-08 01:57:36 -07:00
|
|
|
function processVote(string memory _orgId, address _caller, uint _pendingOp) internal
|
|
|
|
returns (bool)
|
|
|
|
{
|
|
|
|
return voter.processVote(_orgId, _caller, _pendingOp);
|
|
|
|
}
|
|
|
|
|
|
|
|
function getPendingOp(string calldata _orgId) external view
|
|
|
|
returns (string memory, string memory, address, uint)
|
|
|
|
{
|
|
|
|
return voter.getPendingOpDetails(_orgId);
|
|
|
|
}
|
|
|
|
|
|
|
|
// helper functions
|
2019-03-15 02:26:57 -07:00
|
|
|
function isNetworkAdmin(address _account) public view
|
|
|
|
returns (bool)
|
2019-03-14 23:41:04 -07:00
|
|
|
{
|
|
|
|
return (keccak256(abi.encodePacked(accounts.getAccountRole(_account))) == keccak256(abi.encodePacked(adminRole)));
|
|
|
|
}
|
|
|
|
|
2019-04-04 03:25:43 -07:00
|
|
|
function isOrgAdmin(address _account, string memory _orgId) public view
|
2019-03-15 02:26:57 -07:00
|
|
|
returns (bool)
|
2019-03-14 23:41:04 -07:00
|
|
|
{
|
2019-04-08 23:58:30 -07:00
|
|
|
return (accounts.checkOrgAdmin(_account, _orgId, org.getUltimateParent(_orgId)));
|
2019-03-14 23:41:04 -07:00
|
|
|
}
|
|
|
|
|
2019-03-15 02:26:57 -07:00
|
|
|
function validateAccount(address _account, string memory _orgId) public view
|
|
|
|
returns (bool)
|
2019-03-14 23:41:04 -07:00
|
|
|
{
|
2019-04-08 23:58:30 -07:00
|
|
|
return (accounts.valAcctAccessChange(_account, _orgId, org.getUltimateParent(_orgId)));
|
2019-04-04 03:25:43 -07:00
|
|
|
}
|
2019-03-14 23:41:04 -07:00
|
|
|
|
2019-03-28 02:53:11 -07:00
|
|
|
function checkOrgExists(string memory _orgId) internal view
|
|
|
|
returns (bool)
|
|
|
|
{
|
|
|
|
return org.checkOrgExists(_orgId);
|
|
|
|
}
|
|
|
|
|
2019-04-03 07:25:01 -07:00
|
|
|
|
2019-03-28 02:53:11 -07:00
|
|
|
function checkOrgApproved(string memory _orgId) internal view
|
|
|
|
returns (bool)
|
|
|
|
{
|
|
|
|
return org.checkOrgStatus(_orgId, 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
function checkOrgStatus(string memory _orgId, uint _status) internal view
|
|
|
|
returns (bool)
|
|
|
|
{
|
|
|
|
return org.checkOrgStatus(_orgId, _status);
|
|
|
|
}
|
2019-04-03 07:25:01 -07:00
|
|
|
|
2019-03-28 02:53:11 -07:00
|
|
|
function checkOrgAdminExists(string memory _orgId) internal view
|
|
|
|
returns (bool)
|
|
|
|
{
|
2019-04-09 20:10:35 -07:00
|
|
|
return accounts.orgAdminExists(_orgId);
|
2019-03-28 02:53:11 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function roleExists(string memory _roleId, string memory _orgId) internal view
|
|
|
|
returns (bool)
|
|
|
|
{
|
2019-04-09 20:10:35 -07:00
|
|
|
return roles.roleExists(_roleId, _orgId, org.getUltimateParent(_orgId));
|
2019-03-28 02:53:11 -07:00
|
|
|
}
|
2019-04-03 07:25:01 -07:00
|
|
|
|
2019-03-28 02:53:11 -07:00
|
|
|
function isVoterRole(string memory _roleId, string memory _orgId) internal view
|
|
|
|
returns (bool)
|
|
|
|
{
|
2019-04-09 20:10:35 -07:00
|
|
|
return roles.isVoterRole(_roleId, _orgId, org.getUltimateParent(_orgId));
|
2019-03-28 02:53:11 -07:00
|
|
|
}
|
|
|
|
|
2019-03-14 23:41:04 -07:00
|
|
|
}
|