Skip to content

Commit

Permalink
Merge pull request #69 from etherisc/feature/fixed-policy-flow
Browse files Browse the repository at this point in the history
Fixed assignment of policyFlow to product on approval
  • Loading branch information
matthiaszimmermann committed Sep 15, 2022
2 parents 02a43bd + 62cdd45 commit cc9a08e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"@chainlink/=/home/vscode/.brownie/packages/smartcontractkit/chainlink@1.6.0",
"@etherisc/gif-interface/=/home/vscode/.brownie/packages/etherisc/gif-interface@3f16cfe",
],
"solidity.compileUsingRemoteVersion": "v0.8.2+commit.661d1103",
"peacock.remoteColor": "1D3C43",
"workbench.colorCustomizations": {
"activityBar.activeBackground": "#2c5c67",
Expand Down
14 changes: 13 additions & 1 deletion contracts/modules/ComponentController.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ contract ComponentController is
EnumerableSet.UintSet private _riskpools;
uint256 private _componentCount;

mapping(uint256 /* product id */ => address /* policy flow address */) private _policyFlowByProductId;

modifier onlyComponentOwnerService() {
require(
_msgSender() == _getContractAddress("ComponentOwnerService"),
Expand Down Expand Up @@ -95,10 +97,15 @@ contract ComponentController is
onlyInstanceOperatorService
{
_changeState(id, IComponent.ComponentState.Active);
IComponent component = getComponent(id);

if (isProduct(id)) {
_policyFlowByProductId[id] = IProduct(address(component)).getPolicyFlow();
}

emit LogComponentApproved(id);

// inform component about successful approval
IComponent component = getComponent(id);
component.approvalCallback();
}

Expand Down Expand Up @@ -244,6 +251,11 @@ contract ComponentController is

function isRiskpool(uint256 id) public view returns (bool) { return EnumerableSet.contains(_riskpools, id); }

function getPolicyFlow(uint256 productId) public view returns (address _policyFlow) {
require(isProduct(productId), "ERROR:CCR-011:UNKNOWN_PRODUCT_ID");
_policyFlow = _policyFlowByProductId[productId];
}

function _changeState(uint256 componentId, IComponent.ComponentState newState) internal {
IComponent.ComponentState oldState = _componentState[componentId];

Expand Down
2 changes: 1 addition & 1 deletion contracts/modules/LicenseController.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ contract LicenseController is
{
productId = _component.getComponentId(productAddress);
isAuthorized = _isValidCall(productId);
policyFlow = _getProduct(productId).getPolicyFlow();
policyFlow = _component.getPolicyFlow(productId);
}

function _isValidCall(uint256 productId) internal view returns (bool) {
Expand Down

0 comments on commit cc9a08e

Please sign in to comment.