Skip to content

Commit

Permalink
first version of AllowList contract
Browse files Browse the repository at this point in the history
  • Loading branch information
KPrasch committed Jun 21, 2023
1 parent d712d74 commit 06e9014
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions contracts/contracts/coordination/AllowList.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/access/AccessControl.sol";
import "./IAccessController.sol";
import "./Coordinator.sol";

contract AllowList is AccessControl, IAccessController {
Coordinator public coordinator;

// mapp
mapping(uint256 => mapping(address => bool)) public rituals;

constructor(Coordinator _coordinator) {
coordinator = _coordinator;
}

function bytesToAddress(bytes memory bys) private pure returns (address addr) {
assembly {
addr := mload(add(bys, 20))
}
}

function isEnricoAuthorized(
uint256 ritualID,
bytes memory evidence,
bytes memory ciphertextHash
) public view override returns(bool) {
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,
"Only active rituals can add authorizations");
for (uint i=0; i<addresses.length; i++) {
rituals[ritualID][addresses[i]] = true;
}
}

function deauthorize(uint256 ritualID, address[] calldata addresses) public {
require(coordinator.rituals(ritualId).authority == msg.sender,
"Only ritual authority is permitted");
require(coordinator.getRitualStatus(ritualId) == RitualStatus.ACTIVE,
"Only active rituals can add authorizations");
for (uint i=0; i<addresses.length; i++) {
rituals[ritualID][addresses[i]] = false;
}
}
}

0 comments on commit 06e9014

Please sign in to comment.