Verified contractPartialUNLICENSED
HybridControlledAuthority
Address0xa7287701f7ab8f38ef57cdb2a2a69a40128ec89c
- Balance
0 ETH
- Transactions
172
- Compiler
solc 0.8.31
- Same code
Only this contract
Details
- Compiler
- solc 0.8.31+commit.fd3a2265
- Language
- solidity
- Optimization
- Yes, 0 runs
- EVM version
- paris
- Via IR
- yes
- License
- UNLICENSED
- Match
- Partialcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 24,978,155
- Creation transaction
- 0xfff92d5ce2…ddae16902d
96 files
The source code is large: one file is shown at a time. Choose a file in the list.
- project/contracts/HybridControlledAuthority.solmain9.5 KB
- npm/@openzeppelin/[email protected]/proxy/utils/Initializable.sol9.28 KB
- npm/@openzeppelin/[email protected]/access/AccessControl.sol7.03 KB
- npm/@openzeppelin/[email protected]/access/IAccessControl.sol3.34 KB
- npm/@openzeppelin/[email protected]/access/extensions/AccessControlEnumerable.sol3.4 KB
- npm/@openzeppelin/[email protected]/access/extensions/IAccessControlEnumerable.sol1.28 KB
- npm/@openzeppelin/[email protected]/interfaces/IERC1967.sol637 B
- npm/@openzeppelin/[email protected]/proxy/ERC1967/ERC1967Proxy.sol1.72 KB
- npm/@openzeppelin/[email protected]/proxy/ERC1967/ERC1967Utils.sol6.24 KB
- npm/@openzeppelin/[email protected]/proxy/Proxy.sol2.67 KB
- npm/@openzeppelin/[email protected]/proxy/beacon/IBeacon.sol473 B
- npm/@openzeppelin/[email protected]/proxy/utils/Initializable.sol9.28 KB
- npm/@openzeppelin/[email protected]/utils/Address.sol6 KB
- npm/@openzeppelin/[email protected]/utils/Arrays.sol20.91 KB
- npm/@openzeppelin/[email protected]/utils/Comparators.sol443 B
- npm/@openzeppelin/[email protected]/utils/Context.sol963 B
- npm/@openzeppelin/[email protected]/utils/Errors.sol896 B
- npm/@openzeppelin/[email protected]/utils/Panic.sol1.97 KB
- npm/@openzeppelin/[email protected]/utils/SlotDerivation.sol5.32 KB
- npm/@openzeppelin/[email protected]/utils/StorageSlot.sol4.18 KB
- npm/@openzeppelin/[email protected]/utils/Strings.sol19.28 KB
- npm/@openzeppelin/[email protected]/utils/introspection/ERC165.sol879 B
- npm/@openzeppelin/[email protected]/utils/introspection/IERC165.sol871 B
- npm/@openzeppelin/[email protected]/utils/math/Math.sol32.15 KB
- npm/@openzeppelin/[email protected]/utils/math/SafeCast.sol34.94 KB
- npm/@openzeppelin/[email protected]/utils/math/SignedMath.sol2.61 KB
- npm/@openzeppelin/[email protected]/utils/structs/EnumerableSet.sol29.63 KB
- npm/[email protected]/console.sol69 KB
- project/contracts/HybridControlledEngineProxiedServer.sol5.01 KB
- project/contracts/HybridControlledEngineServer.sol5.45 KB
- project/contracts/authz/Authorization.sol4.9 KB
- project/contracts/authz/interfaces/IAdminAuthority.sol937 B
- project/contracts/authz/interfaces/IControlAuthority.sol912 B
- project/contracts/authz/interfaces/IHybridControlAuthority.sol1.05 KB
- project/contracts/hce/ControllableAHKD.sol32.52 KB
- project/contracts/hce/ControllablePing.sol4.77 KB
- project/contracts/hce/HybridControlEngine.sol23.48 KB
- project/contracts/hce/erc20/libs/ChainedListLibrary.sol3.96 KB
- project/contracts/hce/erc20/libs/IERC20.sol2.74 KB
- project/contracts/hce/erc20/libs/StringUtils.sol572 B
- project/contracts/hce/erc20/libs/TokenHolderActivationServerLibrary.sol17.85 KB
- project/contracts/hce/erc20/modules/BlackListServer.sol8.28 KB
- project/contracts/hce/erc20/modules/FreezingServer.sol8.06 KB
- project/contracts/hce/erc20/modules/TokenHolderActivationServer.sol36.83 KB
- project/contracts/hce/erc20/modules/WhitelistServer.sol7.45 KB
- project/contracts/hce/erc20/modules/interfaces/IBlackListServer.sol1.7 KB
- project/contracts/hce/erc20/modules/interfaces/IFreezingServer.sol1.65 KB
- project/contracts/hce/erc20/modules/interfaces/ITokenHolderActivationServer.sol6.94 KB
- project/contracts/hce/erc20/modules/interfaces/IWhitelistServer.sol1.26 KB
- project/contracts/hce/interfaces/ICFCCExtendedERC20.sol2.41 KB
- project/contracts/hce/interfaces/IControllable.sol506 B
- project/contracts/hce/interfaces/IControllablePing.sol531 B
- project/contracts/hce/interfaces/IHybridControlEngine.sol3.97 KB
- project/contracts/hce/interfaces/IHybridControlEngineDesk.sol602 B
- project/contracts/hce/interfaces/ISurchargedERC20.sol3.37 KB
- project/contracts/proxy/UpgradeableProxy.sol5.16 KB
- project/contracts/proxy/interfaces/IControllableProxy.sol367 B
- project/contracts/proxy/libs/Address.sol8.31 KB
- project/contracts/proxy/libs/ERC1967Proxy.sol1.29 KB
- project/contracts/proxy/libs/ERC1967Upgrade.sol3.38 KB
- project/contracts/proxy/libs/Proxy.sol3.25 KB
- project/contracts/proxy/libs/StorageSlot.sol2.67 KB
- project/contracts/testingOnly/StubAuthority.sol4.53 KB
- project/contracts/testingOnly/StubControllable.sol4.71 KB
- project/contracts/testingOnly/interfaces/IStubControllable.sol207 B
- project/lib/forge-std/src/Base.sol2.25 KB
- project/lib/forge-std/src/StdAssertions.sol25.49 KB
- project/lib/forge-std/src/StdChains.sol14.71 KB
- project/lib/forge-std/src/StdCheats.sol31.86 KB
- project/lib/forge-std/src/StdConstants.sol1.88 KB
- project/lib/forge-std/src/StdError.sol1.03 KB
- project/lib/forge-std/src/StdInvariant.sol3.96 KB
- project/lib/forge-std/src/StdJson.sol9.64 KB
- project/lib/forge-std/src/StdMath.sol1.61 KB
- project/lib/forge-std/src/StdStorage.sol17.96 KB
- project/lib/forge-std/src/StdStyle.sol10.48 KB
- project/lib/forge-std/src/StdToml.sol9.64 KB
- project/lib/forge-std/src/StdUtils.sol9.49 KB
- project/lib/forge-std/src/Test.sol1.08 KB
- project/lib/forge-std/src/Vm.sol132.44 KB
- project/lib/forge-std/src/console.sol69.1 KB
- project/lib/forge-std/src/console2.sol131 B
- project/lib/forge-std/src/interfaces/IMulticall3.sol2.14 KB
- project/lib/forge-std/src/safeconsole.sol408.93 KB
- project/test/HybridControlledAuthority.t.sol7.54 KB
- project/test/HybridControlledEngineProxiedServer.t.sol8.77 KB
- project/test/HybridControlledEngineServer.t.sol10.65 KB
- project/test/authz/Authorization.t.sol3.69 KB
- project/test/hce/ControllableAHKD.t.sol84.77 KB
- project/test/hce/erc20/modules/BlackListServer.t.sol7.13 KB
- project/test/hce/erc20/modules/FreezingServer.t.sol8.28 KB
- project/test/hce/erc20/modules/TokenHolderActivationServer.t.sol24.72 KB
- project/test/hce/erc20/modules/WhitelistServer.t.sol7.71 KB
- project/test/helpers/StubAuthorityHelper.sol4.55 KB
- project/test/helpers/StubAuthorityInvalid.sol4.55 KB
- project/test/helpers/TestUtils.sol1.44 KB
project/contracts/HybridControlledAuthority.sol
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.28 ;
import {IAccessControl} from "@openzeppelin/contracts/access/AccessControl.sol";
import "@openzeppelin/contracts/access/extensions/AccessControlEnumerable.sol";
import "./authz/interfaces/IControlAuthority.sol";
import "./authz/interfaces/IHybridControlAuthority.sol";
import "./hce/interfaces/IControllable.sol";
import "./hce/HybridControlEngine.sol";
contract HybridControlledAuthority is IControlAuthority, IHybridControlAuthority, IControllable, HybridControlEngine, AccessControlEnumerable {
// ------------------- Constants ----------------------------------
string constant ERROR_403 = "[HCA]403/" ;
string constant ERROR_404 = "[HCA]404/" ;
bytes32 constant ADMIN_ROLE = keccak256("ADMIN_ROLE");
// ------------------- Structures ---------------------------------
struct Entitlement {
bytes32[] roles ;
address[] users ;
}
struct AuthorityStructure {
bytes32[] transcientAuthorities ;
bytes32[] elevatedAuthorities ;
Entitlement[] genesisEntitlement ;
AuthorizationMatrix[] authorizationMatrixes ;
}
// ------------------- Properties ----------------------------------
IControlAuthority private controlAuthority;
string public identifier ;
mapping(bytes32 => bool ) internal isTranscientRole ;
mapping(bytes32 => bool ) internal isElevatedRole ;
// ------------------- Errors / Events -----------------------------
// ------------------- Modifiers -----------------------------------
// ------------------- Constructors --------------------------------
constructor(AuthorityStructure memory _controlStructure) {
executionContract = address(this) ;
authorityContract = this ;
_grantRole(ADMIN_ROLE, address(this));
// No admin, purposedly
_grantRole(DEFAULT_ADMIN_ROLE, address(0)) ;
for ( uint256 i = 0 ; i < _controlStructure.genesisEntitlement.length; i++ ) {
_grantRoles( _controlStructure.genesisEntitlement[i].roles, _controlStructure.genesisEntitlement[i].users ) ;
}
for ( uint256 i=0; i < _controlStructure.authorizationMatrixes.length; i++ ) {
if ( _controlStructure.authorizationMatrixes[i].method == IHybridControlEngine.changeAuthorizationMatrixes.selector ||
_controlStructure.authorizationMatrixes[i].method == IHybridControlEngine.changeExecutionContract.selector ) {
policyAuthorizationMatrix = _controlStructure.authorizationMatrixes[i].matrix ;
isModifiable = true ;
} else {
authorizationMatrix[_controlStructure.authorizationMatrixes[i].method] = _controlStructure.authorizationMatrixes[i].matrix ;
}
}
for ( uint256 i=0; i < _controlStructure.elevatedAuthorities.length; i++ ) {
isElevatedRole[_controlStructure.elevatedAuthorities[i]] = true ;
}
}
/**
* @dev Returns the current Control Authority
*/
function getControlAuthority() external view override returns (IControlAuthority) {
return controlAuthority ;
}
/**
* @dev Change the control authority
* @param _controlAuthority Address of the new Control Authority
* Used to conform with the IControllable interface, but this contract is its ownn authority
*/
function setControlAuthority( IControlAuthority _controlAuthority ) external override onlyElevatedRiskController() returns (IControlAuthority) {
}
// ------------------- Getters / Setters ---------------------------
modifier onlyElevatedRiskController() {
require ( false, string.concat(ERROR_403, "00") ) ;
_;
}
// ------------------- Methods -------------------------------------
/**
* @dev Check wether an EOA is given the requested role
* @param _role role tested
* @param _account account tested
*/
function hasRole( bytes32 _role, address _account ) public view override(AccessControl, IAccessControl, IControlAuthority) returns (bool hasIt ) {
hasIt = false ;
if ( isTranscientRole[ _role ] ) {
try authorityContract.hasRole( _role, _account ) returns (bool b ) {
hasIt = b ;
}
catch ( bytes memory reason ) {
revert(string.concat( ERROR_404, "99 - ", string(reason))) ;
}
} else {
hasIt = super.hasRole(_role, address(_account)) ;
}
}
/**
* @dev Check wether an EOA is given the requested role
* @param _role role tested
* @param _scope scope, when role is restricted on a certain scope of work (or scope of action)
* @param _account account tested
*/
function hasRoleOverScope( bytes32 _role, bytes32 _scope, address _account ) external view returns (bool hasIt) {
return hasRole( _role, _account ) ;
}
/**
* @dev Grant the gven roles to the given adddresses
* @param _roles roles to be granted
* @param _addresses addresses of the accounts to be granted roles. Address can be an EOA or a smart contract
*/
function _grantRoles( bytes32[] memory _roles, address[] memory _addresses ) internal {
for (uint j = 0; j < _roles.length; j++) {
require( !isElevatedRole[_roles[j]], string.concat( ERROR_404, "93") ) ;
_setRoleAdmin(_roles[j], ADMIN_ROLE);
for (uint i = 0; i < _addresses.length; i++) {
_grantRole(_roles[j], _addresses[i]);
}
}
}
/**
* @dev External function, restricted to Admin Role, to grant roles to addresses
* @param _roles roles to be granted
* @param _addresses addresses of the accounts to be granted roles. Address can be an EOA or a smart contract
*/
function grantRoles( bytes32[] memory _roles, address[] calldata _addresses ) external override onlyRole(ADMIN_ROLE) {
_grantRoles(_roles, _addresses);
}
/**
* @dev External function, restricted to Admin Role, to grant role to a specific address
* @param _role role to be granted
* @param _address address to be granted roles. Address can be an EOA or a smart contract
*/
function grantRole( bytes32 _role, address _address ) public
override(AccessControl, IAccessControl) onlyRole(ADMIN_ROLE) {
require( !isElevatedRole[_role], string.concat( ERROR_404, "94") ) ;
_setRoleAdmin(_role, ADMIN_ROLE);
_grantRole(_role, _address);
}
/**
* @dev External function, restricted to Admin Role to revoke a role for a particular account
* @param _role role to be revoked
* @param _address address of the account. Address can be an EOA or a smart contract
*/
function revokeRole( bytes32 _role, address _address ) public
override(AccessControl, IAccessControl) onlyRole(ADMIN_ROLE) {
require( !isElevatedRole[_role], string.concat( ERROR_404, "95") ) ;
_revokeRole(_role, _address);
}
/**
* @dev External function, restricted to Admin Role to revoke a role for a particular account
* @param _roles roles to be revoked
* @param _addresses addresses of the account. Address can be an EOA or a smart contract
*/
function revokeRoles( bytes32[] memory _roles, address[] calldata _addresses ) external override onlyRole(ADMIN_ROLE) {
for (uint j = 0; j < _roles.length; j++) {
require( !isElevatedRole[_roles[j]], string.concat( ERROR_404, "96") ) ;
for (uint i = 0; i < _addresses.length; i++) {
_revokeRole(_roles[j], _addresses[i]);
}
}
}
/**
* @dev External function, restricted to Admin Role to grant a role marked as elevated for a list of accounts
* @param _role elevated role to be granted
* @param _addresses addresses of the account. Address can be an EOA or a smart contract
*/
function grantElevatedRole( bytes32 _role, address[] memory _addresses ) external override onlyRole(ADMIN_ROLE) {
require( isElevatedRole[_role], string.concat( ERROR_404, "98") ) ;
_setRoleAdmin(_role, ADMIN_ROLE);
for ( uint j = 0; j < _addresses.length;j++ ) {
_grantRole(_role, _addresses[j]);
}
}
/**
* @dev External function, restricted to Admin Role to revoke a role marked as elevated for a list of accounts
* @param _role elevated role to be revoked
* @param _addresses addresses of the account. Address can be an EOA or a smart contract
*/
function revokeElevatedRole( bytes32 _role, address[] memory _addresses ) external override onlyRole(ADMIN_ROLE) {
require( isElevatedRole[_role], string.concat( ERROR_404, "97") ) ;
for ( uint j = 0; j < _addresses.length;j++ ) {
_revokeRole(_role, _addresses[j]);
}
}
/**
* @dev External function, restricted to Admin Role to mark a role as elevated
* @param _role role to be elevated
*/
function elevateRole( bytes32 _role ) external override onlyRole(ADMIN_ROLE) {
require( !isElevatedRole[_role], string.concat( ERROR_404, "92") ) ;
isElevatedRole[_role] = true ;
}
}
Compiler settingsShow
{
"viaIR": true,
"optimizer": {
"runs": 0,
"enabled": true
},
"evmVersion": "paris",
"remappings": [
"project/:@openzeppelin/contracts-upgradeable/=npm/@openzeppelin/[email protected]/",
"project/:@openzeppelin/contracts/=npm/@openzeppelin/[email protected]/",
"project/:forge-std/=project/lib/forge-std/src/",
"project/:hardhat/=npm/[email protected]/"
]
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.