github.com/Tri-stone/burrow@v0.25.0/tests/jobs_fixtures/app33-evm_connection_edb_permissions_and_roles_layer/permissions.sol (about)

     1  
     2  pragma solidity >=0.4.0;
     3  
     4  /**
     5  * Interface for managing Secure Native authorizations.
     6  * @dev This interface describes the functions exposed by the SNative permissions layer in burrow.
     7  * @dev These functions can be accessed as if this contract were deployed at a special address (0x0A758FEB535243577C1A79AE55BED8CA03E226EC).
     8  * @dev This special address is defined as the last 20 bytes of the sha3 hash of the the contract name.
     9  * @dev To instantiate the contract use:
    10  * @dev Permissions permissions = Permissions(address(keccak256("Permissions")));
    11  */
    12  contract Permissions {
    13      /**
    14      * @notice Adds a role to an account
    15      * @param Account account address
    16      * @param Role role name
    17      * @return result whether role was added
    18      */
    19      function addRole(address Account, string memory Role) public view returns (bool Result);
    20  
    21      /**
    22      * @notice Removes a role from an account
    23      * @param Account account address
    24      * @param Role role name
    25      * @return result whether role was removed
    26      */
    27      function removeRole(address Account, string memory Role) public view returns (bool Result);
    28  
    29      /**
    30      * @notice Indicates whether an account has a role
    31      * @param Account account address
    32      * @param Role role name
    33      * @return result whether account has role
    34      */
    35      function hasRole(address Account, string memory Role) public view returns (bool Result);
    36  
    37      /**
    38      * @notice Sets the permission flags for an account. Makes them explicitly set (on or off).
    39      * @param Account account address
    40      * @param Permission the base permissions flags to set for the account
    41      * @param Set whether to set or unset the permissions flags at the account level
    42      * @return result the effective permissions flags on the account after the call
    43      */
    44      function setBase(address Account, uint64 Permission, bool Set) public view returns (uint64 Result);
    45  
    46      /**
    47      * @notice Unsets the permissions flags for an account. Causes permissions being unset to fall through to global permissions.
    48      * @param Account account address
    49      * @param Permission the permissions flags to unset for the account
    50      * @return result the effective permissions flags on the account after the call
    51      */
    52      function unsetBase(address Account, uint64 Permission) public view returns (uint64 Result);
    53  
    54      /**
    55      * @notice Indicates whether an account has a subset of permissions set
    56      * @param Account account address
    57      * @param Permission the permissions flags (mask) to check whether enabled against base permissions for the account
    58      * @return result whether account has the passed permissions flags set
    59      */
    60      function hasBase(address Account, uint64 Permission) public view returns (bool Result);
    61  
    62      /**
    63      * @notice Sets the global (default) permissions flags for the entire chain
    64      * @param Permission the permissions flags to set
    65      * @param Set whether to set (or unset) the permissions flags
    66      * @return result the global permissions flags after the call
    67      */
    68      function setGlobal(uint64 Permission, bool Set) public view returns (uint64 Result);
    69  }
    70  
    71  contract permSNative {
    72    Permissions perm = Permissions(address(uint256(keccak256("Permissions"))));
    73  
    74    function hasBase(address addr, uint64 permFlag) public view returns (bool) {
    75      return perm.hasBase(addr, permFlag);
    76    }
    77  
    78    function setBase(address addr, uint64 permFlag, bool value) public view returns (uint64) {
    79      return perm.setBase(addr, permFlag, value);
    80    }
    81  
    82    function unsetBase(address addr, uint64 permFlag) public view returns (uint64) {
    83      return perm.unsetBase(addr, permFlag);
    84    }
    85  
    86    // not currently tested
    87    function setGlobal(uint64 permFlag, bool value) public view returns (int pf) {
    88      return perm.setGlobal(permFlag, value);
    89    }
    90  
    91    function hasRole(address addr, string memory role) public view returns (bool val) {
    92      return perm.hasRole(addr, role);
    93    }
    94  
    95    function addRole(address addr, string memory role) public view returns (bool added) {
    96      return perm.addRole(addr, role);
    97    }
    98  
    99    function removeRole(address addr, string memory role) public view returns (bool removed) {
   100      return perm.removeRole(addr, role);
   101    }
   102  }