@@ -6,6 +6,7 @@ import "../modules/IAccess.sol";
66import "../modules/IComponentEvents.sol " ;
77import "../modules/IRegistry.sol " ;
88import "../services/IComponentOwnerService.sol " ;
9+ import "../services/IInstanceService.sol " ;
910import "@openzeppelin/contracts/access/Ownable.sol " ;
1011
1112
@@ -17,20 +18,14 @@ abstract contract Component is
1718{
1819 bytes32 private _componentName;
1920 uint256 private _componentId;
20- ComponentType private _componentType;
21- ComponentState private _componentState;
21+ IComponent.ComponentType private _componentType;
2222
2323 bytes32 private _requiredRole;
2424
2525 IRegistry private _registry;
2626 IAccess private _access;
2727 IComponentOwnerService private _componentOwnerService;
28-
29- event LogComponentCreated (
30- bytes32 componentName ,
31- ComponentType componentType ,
32- address componentAddress ,
33- address registryAddress );
28+ IInstanceService private _instanceService;
3429
3530 modifier onlyInstanceOperatorService () {
3631 require (
@@ -55,7 +50,7 @@ abstract contract Component is
5550
5651 constructor (
5752 bytes32 name ,
58- ComponentType componentType ,
53+ IComponent. ComponentType componentType ,
5954 address registry
6055 )
6156 Ownable ()
@@ -68,7 +63,6 @@ abstract contract Component is
6863
6964 _componentName = name;
7065 _componentType = componentType;
71- _componentState = ComponentState.Created;
7266 _requiredRole = _getRequiredRole ();
7367
7468 emit LogComponentCreated (
@@ -79,17 +73,16 @@ abstract contract Component is
7973 }
8074
8175 function setId (uint256 id ) external override onlyComponent { _componentId = id; }
82- function setState (ComponentState state ) external override onlyComponent { _componentState = state; }
8376
8477 function getName () public override view returns (bytes32 ) { return _componentName; }
8578 function getId () public override view returns (uint256 ) { return _componentId; }
86- function getType () public override view returns (ComponentType) { return _componentType; }
87- function getState () public override view returns (ComponentState) { return _componentState ; }
79+ function getType () public override view returns (IComponent. ComponentType) { return _componentType; }
80+ function getState () public override view returns (IComponent. ComponentState) { return _instanceService. getComponentState (_componentId) ; }
8881 function getOwner () public override view returns (address ) { return owner (); }
8982
90- function isProduct () public override view returns (bool ) { return _componentType == ComponentType.Product; }
91- function isOracle () public override view returns (bool ) { return _componentType == ComponentType.Oracle; }
92- function isRiskpool () public override view returns (bool ) { return _componentType == ComponentType.Riskpool; }
83+ function isProduct () public override view returns (bool ) { return _componentType == IComponent. ComponentType.Product; }
84+ function isOracle () public override view returns (bool ) { return _componentType == IComponent. ComponentType.Oracle; }
85+ function isRiskpool () public override view returns (bool ) { return _componentType == IComponent. ComponentType.Riskpool; }
9386
9487 function getRequiredRole () public override view returns (bytes32 ) { return _requiredRole; }
9588
@@ -121,6 +114,10 @@ abstract contract Component is
121114 return IAccess (_getContractAddress ("Access " ));
122115 }
123116
117+ function _getInstanceService () internal returns (IInstanceService) {
118+ return IInstanceService (_getContractAddress ("InstanceService " ));
119+ }
120+
124121 function _getComponentOwnerService () internal returns (IComponentOwnerService) {
125122 return IComponentOwnerService (_getContractAddress ("ComponentOwnerService " ));
126123 }
0 commit comments