github.com/kisexp/xdchain@v0.0.0-20211206025815-490d6b732aa7/permission/v1/contract/PermissionsInterface.sol (about)

     1  pragma solidity ^0.5.3;
     2  
     3  import "./PermissionsImplementation.sol";
     4  import "./PermissionsUpgradable.sol";
     5  
     6  /** @title Permissions Interface Contract
     7    * @notice This contract is the interface for permissions implementation
     8      contract. for any call, it forwards the call to the implementation
     9      contract
    10    */
    11  contract PermissionsInterface {
    12      PermissionsImplementation private permImplementation;
    13      PermissionsUpgradable private permUpgradable;
    14      address private permImplUpgradeable;
    15  
    16      /** @notice constructor
    17        * @param _permImplUpgradeable permissions upgradable contract address
    18        */
    19      constructor(address _permImplUpgradeable) public {
    20          permImplUpgradeable = _permImplUpgradeable;
    21      }
    22  
    23      /** @notice confirms that the caller is the address of upgradable
    24          contract
    25        */
    26      modifier onlyUpgradeable {
    27          require(msg.sender == permImplUpgradeable, "invalid caller");
    28          _;
    29      }
    30  
    31      /** @notice interface for setting the permissions policy in implementation
    32        * @param _nwAdminOrg network admin organization id
    33        * @param _nwAdminRole default network admin role id
    34        * @param _oAdminRole default organization admin role id
    35        */
    36      function setPolicy(string calldata _nwAdminOrg, string calldata _nwAdminRole,
    37          string calldata _oAdminRole) external {
    38          permImplementation.setPolicy(_nwAdminOrg, _nwAdminRole, _oAdminRole);
    39      }
    40  
    41      /** @notice interface to initializes the breadth and depth values for
    42          sub organization management
    43        * @param _breadth controls the number of sub org a parent org can have
    44        * @param _depth controls the depth of nesting allowed for sub orgs
    45        */
    46      function init(uint256 _breadth, uint256 _depth) external {
    47          permImplementation.init(_breadth, _depth);
    48      }
    49  
    50      /** @notice interface to add new node to an admin organization
    51        * @param _enodeId full enode id of the node to be added
    52        */
    53      function addAdminNode(string calldata _enodeId) external {
    54          permImplementation.addAdminNode(_enodeId);
    55      }
    56  
    57      /** @notice interface to add accounts to an admin organization
    58        * @param _acct account address to be added
    59        */
    60      function addAdminAccount(address _acct) external {
    61          permImplementation.addAdminAccount(_acct);
    62      }
    63  
    64      /** @notice interface to update network boot up status
    65        * @return bool true or false
    66        */
    67      function updateNetworkBootStatus() external
    68      returns (bool)
    69      {
    70          return permImplementation.updateNetworkBootStatus();
    71      }
    72  
    73      /** @notice interface to fetch network boot status
    74        * @return bool network boot status
    75        */
    76      function getNetworkBootStatus() external view returns (bool){
    77          return permImplementation.getNetworkBootStatus();
    78      }
    79  
    80      /** @notice interface to add a new organization to the network
    81        * @param _orgId unique organization id
    82        * @param _enodeId full enode id linked to the organization
    83        * @param _account account id. this will have the org admin privileges
    84        */
    85      function addOrg(string calldata _orgId, string calldata _enodeId,
    86          address _account) external {
    87          permImplementation.addOrg(_orgId, _enodeId, _account, msg.sender);
    88      }
    89  
    90      /** @notice interface to approve a newly added organization
    91        * @param _orgId unique organization id
    92        * @param _enodeId full enode id linked to the organization
    93        * @param _account account id this will have the org admin privileges
    94        */
    95      function approveOrg(string calldata _orgId, string calldata _enodeId,
    96          address _account) external {
    97          permImplementation.approveOrg(_orgId, _enodeId, _account, msg.sender);
    98      }
    99  
   100      /** @notice interface to add sub org under an org
   101        * @param _pOrgId parent org id under which the sub org is being added
   102        * @param _orgId unique id for the sub organization
   103        * @param _enodeId full enode id linked to the sjb organization
   104        */
   105      function addSubOrg(string calldata _pOrgId, string calldata _orgId,
   106          string calldata _enodeId) external {
   107          permImplementation.addSubOrg(_pOrgId, _orgId, _enodeId, msg.sender);
   108      }
   109  
   110      /** @notice interface to update the org status
   111        * @param _orgId unique id of the organization
   112        * @param _action 1 for suspending an org and 2 for revoke of suspension
   113        */
   114      function updateOrgStatus(string calldata _orgId, uint256 _action) external {
   115          permImplementation.updateOrgStatus(_orgId, _action, msg.sender);
   116      }
   117  
   118      /** @notice interface to approve org status change
   119        * @param _orgId unique id for the sub organization
   120        * @param _action 1 for suspending an org and 2 for revoke of suspension
   121        */
   122      function approveOrgStatus(string calldata _orgId, uint256 _action) external {
   123          permImplementation.approveOrgStatus(_orgId, _action, msg.sender);
   124      }
   125  
   126      /** @notice interface to add a new role definition to an organization
   127        * @param _roleId unique id for the role
   128        * @param _orgId unique id of the organization to which the role belongs
   129        * @param _access account access type for the role
   130        * @param _voter bool indicates if the role is voter role or not
   131        * @param _admin bool indicates if the role is an admin role
   132        * @dev account access type can have of the following four values:
   133              0 - Read only
   134              1 - Transact access
   135              2 - Contract deployment access. Can transact as well
   136              3 - Full access
   137        */
   138      function addNewRole(string calldata _roleId, string calldata _orgId,
   139          uint256 _access, bool _voter, bool _admin) external {
   140          permImplementation.addNewRole(_roleId, _orgId, _access, _voter, _admin, msg.sender);
   141      }
   142  
   143      /** @notice interface to remove a role definition from an organization
   144        * @param _roleId unique id for the role
   145        * @param _orgId unique id of the organization to which the role belongs
   146        */
   147      function removeRole(string calldata _roleId, string calldata _orgId) external {
   148          permImplementation.removeRole(_roleId, _orgId, msg.sender);
   149      }
   150  
   151      /** @notice interface to assign network admin/org admin role to an account
   152          this can be executed by network admin accounts only
   153        * @param _orgId unique id of the organization to which the account belongs
   154        * @param _account account id
   155        * @param _roleId role id to be assigned to the account
   156        */
   157      function assignAdminRole(string calldata _orgId, address _account,
   158          string calldata _roleId) external {
   159          permImplementation.assignAdminRole(_orgId, _account, _roleId, msg.sender);
   160  
   161      }
   162      /** @notice interface to approve network admin/org admin role assigment
   163          this can be executed by network admin accounts only
   164        * @param _orgId unique id of the organization to which the account belongs
   165        * @param _account account id
   166        */
   167      function approveAdminRole(string calldata _orgId, address _account) external {
   168          permImplementation.approveAdminRole(_orgId, _account, msg.sender);
   169  
   170      }
   171  
   172      /** @notice interface to update account status
   173          this can be executed by org admin accounts only
   174        * @param _orgId unique id of the organization to which the account belongs
   175        * @param _account account id
   176        * @param _action 1-suspending 2-activating back 3-blacklisting
   177        */
   178      function updateAccountStatus(string calldata _orgId, address _account,
   179          uint256 _action) external {
   180          permImplementation.updateAccountStatus(_orgId, _account, _action, msg.sender);
   181      }
   182  
   183      /** @notice interface to add a new node to the organization
   184        * @param _orgId unique id of the organization to which the account belongs
   185        * @param _enodeId full enode id being dded to the org
   186        */
   187      function addNode(string calldata _orgId, string calldata _enodeId) external {
   188          permImplementation.addNode(_orgId, _enodeId, msg.sender);
   189  
   190      }
   191  
   192      /** @notice interface to update node status
   193        * @param _orgId unique id of the organization to which the account belongs
   194        * @param _enodeId full enode id being dded to the org
   195        * @param _action 1-deactivate, 2-activate back, 3-blacklist the node
   196        */
   197      function updateNodeStatus(string calldata _orgId, string calldata _enodeId,
   198          uint256 _action) external {
   199          permImplementation.updateNodeStatus(_orgId, _enodeId, _action, msg.sender);
   200      }
   201  
   202      /** @notice interface to initiate blacklisted node recovery
   203        * @param _orgId unique id of the organization to which the account belongs
   204        * @param _enodeId full enode id being recovered
   205        */
   206      function startBlacklistedNodeRecovery(string calldata _orgId, string calldata _enodeId)
   207      external {
   208          permImplementation.startBlacklistedNodeRecovery(_orgId, _enodeId, msg.sender);
   209      }
   210  
   211      /** @notice interface to approve blacklisted node recoevry
   212        * @param _orgId unique id of the organization to which the account belongs
   213        * @param _enodeId full enode id being recovered
   214        */
   215      function approveBlacklistedNodeRecovery(string calldata _orgId, string calldata _enodeId)
   216      external {
   217          permImplementation.approveBlacklistedNodeRecovery(_orgId, _enodeId, msg.sender);
   218      }
   219  
   220      /** @notice interface to initiate blacklisted account recovery
   221        * @param _orgId unique id of the organization to which the account belongs
   222        * @param _account account id being recovered
   223        */
   224      function startBlacklistedAccountRecovery(string calldata _orgId, address _account)
   225      external {
   226          permImplementation.startBlacklistedAccountRecovery(_orgId, _account, msg.sender);
   227      }
   228  
   229      /** @notice interface to approve blacklisted node recovery
   230        * @param _orgId unique id of the organization to which the account belongs
   231        * @param _account account id being recovered
   232        */
   233      function approveBlacklistedAccountRecovery(string calldata _orgId, address _account)
   234      external {
   235          permImplementation.approveBlacklistedAccountRecovery(_orgId, _account, msg.sender);
   236      }
   237  
   238      /** @notice interface to fetch detail of any pending approval activities
   239          for network admin organization
   240        * @param _orgId unique id of the organization to which the account belongs
   241        */
   242      function getPendingOp(string calldata _orgId) external view
   243      returns (string memory, string memory, address, uint256) {
   244          return permImplementation.getPendingOp(_orgId);
   245      }
   246  
   247      /** @notice sets the permissions implementation contract address
   248          can be called from upgradable contract only
   249        * @param _permImplementation permissions implementation contract address
   250        */
   251      function setPermImplementation(address _permImplementation) external
   252      onlyUpgradeable {
   253          permImplementation = PermissionsImplementation(_permImplementation);
   254      }
   255  
   256      /** @notice returns the address of permissions implementation contract
   257        * @return permissions implementation contract address
   258        */
   259      function getPermissionsImpl() external view returns (address) {
   260          return address(permImplementation);
   261      }
   262  
   263      /** @notice interface to assigns a role id to the account give
   264        * @param _account account id
   265        * @param _orgId organization id to which the account belongs
   266        * @param _roleId role id to be assigned to the account
   267        */
   268      function assignAccountRole(address _account, string calldata _orgId,
   269          string calldata _roleId) external {
   270          permImplementation.assignAccountRole(_account, _orgId, _roleId, msg.sender);
   271  
   272      }
   273  
   274      /** @notice interface to check if passed account is an network admin account
   275        * @param _account account id
   276        * @return true/false
   277        */
   278      function isNetworkAdmin(address _account) external view returns (bool) {
   279          return permImplementation.isNetworkAdmin(_account);
   280      }
   281  
   282      /** @notice interface to check if passed account is an org admin account
   283        * @param _account account id
   284        * @param _orgId organization id
   285        * @return true/false
   286        */
   287      function isOrgAdmin(address _account, string calldata _orgId)
   288      external view returns (bool) {
   289          return permImplementation.isOrgAdmin(_account, _orgId);
   290      }
   291  
   292      /** @notice interface to validate the account for access change operation
   293        * @param _account account id
   294        * @param _orgId organization id
   295        * @return true/false
   296        */
   297      function validateAccount(address _account, string calldata _orgId)
   298      external view returns (bool) {
   299          return permImplementation.validateAccount(_account, _orgId);
   300      }
   301  
   302  }