diff --git a/contracts/contracts/coordination/AllowList.sol b/contracts/contracts/coordination/AllowList.sol index fc65e145..53b63d86 100644 --- a/contracts/contracts/coordination/AllowList.sol +++ b/contracts/contracts/coordination/AllowList.sol @@ -1,22 +1,25 @@ pragma solidity ^0.8.0; -import "@openzeppelin/contracts/access/AccessControl.sol"; +import "@openzeppelin/contracts/access/AccessControlDefaultAdminRules.sol"; import "./IAccessController.sol"; import "./Coordinator.sol"; -contract AllowList is AccessControl, IAccessController { + +contract AllowList is AccessControlDefaultAdminRules, IAccessController { Coordinator public coordinator; // mapp mapping(uint256 => mapping(address => bool)) public rituals; - constructor(Coordinator _coordinator) { + constructor( + Coordinator _coordinator, + address _admin + ) AccessControlDefaultAdminRules(0, _admin) { coordinator = _coordinator; } - function bytesToAddress(bytes memory bys) private pure returns (address addr) { - assembly { - addr := mload(add(bys, 20)) - } + function setCoordinator(Coordinator _coordinator) public { + require(hasRole(DEFAULT_ADMIN_ROLE, msg.sender), "Only admin can set coordinator"); + coordinator = _coordinator; } function isEnricoAuthorized( @@ -24,14 +27,14 @@ contract AllowList is AccessControl, IAccessController { bytes memory evidence, bytes memory ciphertextHash ) public view override returns(bool) { - enricoAddress = address(uint160(bytes20(evidence))); + address enricoAddress = address(uint160(bytes20(evidence))); return rituals[ritualID][enricoAddress]; } function authorize(uint256 ritualID, address[] calldata addresses) public { require(coordinator.rituals(ritualId).authority == msg.sender, "Only ritual authority is permitted"); - require(coordinator.getRitualStatus(ritualId) == RitualStatus.ACTIVE, + require(coordinator.getRitualStatus(ritualId) == RitualStatus.FINALIZED, "Only active rituals can add authorizations"); for (uint i=0; i