Skip to content

Commit

Permalink
MainZone: add authorization filter
Browse files Browse the repository at this point in the history
  • Loading branch information
anukul committed Nov 2, 2023
1 parent eb23cab commit dcbba6b
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/zone/extensions/IMainZone.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,26 @@ interface IMainZone {

event SecondaryZoneSet(address indexed newSecondayZone);

event FilterUpdated(address indexed actor, Filter filter);

struct RangeFilter {
uint gt;
uint lt;
}

struct TokenFilter {
address token;
RangeFilter amount;
}

struct Filter {
address offerer;
TokenFilter[] offer;
TokenFilter consideration;
RangeFilter deadline;
RangeFilter nonce;
}

/**
* @notice Get the secondary zone address that performs additional validation for this zone.
*
Expand Down Expand Up @@ -37,4 +57,8 @@ interface IMainZone {
* @notice Restricted function to resume regular validation functionality.
*/
function unpause() external;

function setAuthorizationFilter(address actor, Filter calldata filter) external;

function authorizationFilter(address actor) external view returns (Filter memory);
}
11 changes: 11 additions & 0 deletions src/zone/extensions/MainZone.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ contract MainZone is Zone, IMainZone, AccessControlDefaultAdminRules, Pausable {

address public secondaryZone;

mapping (address => Filter) public filters;

constructor(address admin) AccessControlDefaultAdminRules(2 days, admin) {}

function pause() external onlyRole(DEFAULT_ADMIN_ROLE) {
Expand Down Expand Up @@ -97,4 +99,13 @@ contract MainZone is Zone, IMainZone, AccessControlDefaultAdminRules, Pausable {
}
}
}

function setAuthorizationFilter(address actor, Filter calldata filter) external onlyRole(DEFAULT_ADMIN_ROLE) {
filters[actor] = filter;
emit FilterUpdated(actor, filter);
}

function authorizationFilter(address actor) external view returns (Filter memory) {
return filters[actor];
}
}

0 comments on commit dcbba6b

Please sign in to comment.