Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Core: Registry proposal #214

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions packages/erc3k/contracts/IERC3000Registry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,12 @@ abstract contract IERC3000Registry is ERC3000Interface {
*/
function setMetadata(bytes memory metadata) virtual public;
event SetMetadata(IERC3000Executor indexed executor, bytes metadata);

/**
* @notice defines a new owner of a given name
* @param _name The name the new owner should get applied
* @param _newOwner The address of the new owner
*/
function setOwner(string calldata _name, address _newOwner) virtual external;
event NewOwner(string indexed name, address newOwner);
}
14 changes: 10 additions & 4 deletions packages/govern-core/contracts/GovernRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import "erc3k/contracts/IERC3000Registry.sol";
import "@aragon/govern-contract-utils/contracts/erc165/ERC165.sol";

contract GovernRegistry is IERC3000Registry {
mapping(string => bool) public nameUsed;
mapping(string => address) public owners;

function register(
IERC3000Executor _executor,
Expand All @@ -21,9 +21,8 @@ contract GovernRegistry is IERC3000Registry {
bytes calldata _initialMetadata
) override external
{
require(!nameUsed[_name], "registry: name used");

nameUsed[_name] = true;
require(!owners[_name] || owners[_name] == msg.sender, "registry: only owner");
owners[_name] = msg.sender;

emit Registered(_executor, _queue, _token, msg.sender, _name);
_setMetadata(_executor, _initialMetadata);
Expand All @@ -36,4 +35,11 @@ contract GovernRegistry is IERC3000Registry {
function _setMetadata(IERC3000Executor _executor, bytes memory _metadata) internal {
emit SetMetadata(_executor, _metadata);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe now the metadata should be related to the owner address instead of the executor?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, agreed. I thought already before it is strange that anyone can change the metadata of a registered Executor.

}

function setOwner(string calldata _name, address _newOwner) override external {
require(owners[_name] == msg.sender, "registry: only owner");
owners[_name] = _newOwner;

emit NewOwner(_name, _newOwner);
}
}