// SPDX-License-Identifier: Apache-2.0 pragma solidity 0.8.2; import "@etherisc/gif-interface/contracts/modules/IRegistry.sol"; contract WithRegistry { /* * We can consider the registry address as immutable here as it contains the * root data structure for the whole GIF Instance. * We can therefore ensure that a policy flow cannot overwrite the address * neither by chance nor by intention. */ IRegistry public immutable registry; modifier onlyInstanceOperator() { require( msg.sender == getContractFromRegistry("InstanceOperatorService"), "ERROR:ACM-001:NOT_INSTANCE_OPERATOR" ); _; } modifier onlyOracleService() { require( msg.sender == getContractFromRegistry("OracleService"), "ERROR:ACM-004:NOT_ORACLE_SERVICE" ); _; } modifier onlyOracleOwner() { require( msg.sender == getContractFromRegistry("OracleOwnerService"), "ERROR:ACM-005:NOT_ORACLE_OWNER" ); _; } modifier onlyProductOwner() { require( msg.sender == getContractFromRegistry("ProductOwnerService"), "ERROR:ACM-006:NOT_PRODUCT_OWNER" ); _; } constructor(address _registry) { registry = IRegistry(_registry); } function getContractFromRegistry(bytes32 _contractName) public // override view returns (address _addr) { _addr = registry.getContract(_contractName); } function getContractInReleaseFromRegistry(bytes32 _release, bytes32 _contractName) internal view returns (address _addr) { _addr = registry.getContractInRelease(_release, _contractName); } function getReleaseFromRegistry() internal view returns (bytes32 _release) { _release = registry.getRelease(); } }