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