-
Notifications
You must be signed in to change notification settings - Fork 261
Expand file tree
/
Copy pathResolver.sol
More file actions
36 lines (28 loc) · 1.06 KB
/
Resolver.sol
File metadata and controls
36 lines (28 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.11;
import { AccessControlEnumerable } from "@openzeppelin-v5/contracts/access/extensions/AccessControlEnumerable.sol";
import { IResolver } from "../interfaces/utils/IResolver.sol";
/**
* @title Resolver contract
* @author Superfluid
* @dev A simple implementation of IResolver using OZ AccessControl
*
* NOTE:
* Relevant events for indexing:
* - OZ Access Control events `RoleGranted`/`RoleRevoked`: admin add/remove
* - IResolver event `Set`: resolver name updates
*/
contract Resolver is IResolver, AccessControlEnumerable {
mapping(string => address) private _registry;
constructor() {
_grantRole(DEFAULT_ADMIN_ROLE, msg.sender);
}
function set(string calldata name, address target) external override {
require(hasRole(DEFAULT_ADMIN_ROLE, _msgSender()), "Caller is not an admin");
_registry[name] = target;
emit Set(name, target);
}
function get(string calldata name) external view override returns (address) {
return _registry[name];
}
}