Verified contractExactAGPL-3.0-or-later
MemberRegistry
Address0x6e87e044a5de62ef22ca59e99e1c1f06f4b523a7
- Balance
0 ETH
- Transactions
1
- Compiler
solc 0.8.17
- Same code
1 more contract
Details
- Compiler
- solc 0.8.17+commit.8df45f5f
- Language
- solidity
- Optimization
- Yes, 2,000 runs
- EVM version
- london
- License
- AGPL-3.0-or-later
- Match
- Exactcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 25,071,159
- Creation transaction
- 0x0c6bdd6607…7637681d0a
20 files
- src/framework/member/MemberRegistry.solmain12.09 KB
- lib/ens-contracts/contracts/registry/ENS.sol1.79 KB
- lib/openzeppelin-contracts-upgradeable/contracts/interfaces/IERC1967Upgradeable.sol678 B
- lib/openzeppelin-contracts-upgradeable/contracts/interfaces/draft-IERC1822Upgradeable.sol890 B
- lib/openzeppelin-contracts-upgradeable/contracts/proxy/ERC1967/ERC1967UpgradeUpgradeable.sol6.8 KB
- lib/openzeppelin-contracts-upgradeable/contracts/proxy/beacon/IBeaconUpgradeable.sol461 B
- lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol6.64 KB
- lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/UUPSUpgradeable.sol4.92 KB
- lib/openzeppelin-contracts-upgradeable/contracts/utils/AddressUpgradeable.sol9.38 KB
- lib/openzeppelin-contracts-upgradeable/contracts/utils/ContextUpgradeable.sol1.48 KB
- lib/openzeppelin-contracts-upgradeable/contracts/utils/StorageSlotUpgradeable.sol4.12 KB
- src/common/dao/IDAO.sol4.85 KB
- src/common/permission/auth/DaoAuthorizableUpgradeable.sol2.01 KB
- src/common/permission/auth/auth.sol1.59 KB
- src/common/utils/versioning/IProtocolVersion.sol822 B
- src/common/utils/versioning/ProtocolVersion.sol732 B
- src/framework/member/IMemberRegistry.sol6.35 KB
- src/framework/utils/RegistryUtils.sol1.3 KB
- src/framework/utils/ens/ENSDomain.sol2.68 KB
- src/framework/utils/ens/IResolver.sol1.32 KB
src/framework/member/MemberRegistry.sol
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity ^0.8.17;
import {ENS} from "@ensdomains/ens-contracts/contracts/registry/ENS.sol";
import {UUPSUpgradeable} from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
import {ProtocolVersion} from "@aragon/osx-commons-contracts/src/utils/versioning/ProtocolVersion.sol";
import {
DaoAuthorizableUpgradeable
} from "@aragon/osx-commons-contracts/src/permission/auth/DaoAuthorizableUpgradeable.sol";
import {IDAO} from "@aragon/osx-commons-contracts/src/dao/IDAO.sol";
import {isSubdomainValid} from "../utils/RegistryUtils.sol";
import {IMemberRegistry} from "./IMemberRegistry.sol";
import {IResolver} from "../utils/ens/IResolver.sol";
import {ENSDomain} from "../utils/ens/ENSDomain.sol";
/// @title MemberRegistry
/// @author Aragon X - 2026
/// @notice Permissionless member self-registration via ENS subdomain claims. Owns the parent
/// ENS node, manages subdomain lifecycle (claim, release, move), and grants per-node
/// resolver approval so members can manage their own ENS records natively.
/// @dev The ENS registry and resolver are trusted, known mainnet contracts. No reentrancy
/// guard is needed — the contract is the sole caller of its own ENS operations.
/// @custom:security-contact [email protected]
contract MemberRegistry is IMemberRegistry, UUPSUpgradeable, DaoAuthorizableUpgradeable, ProtocolVersion {
/// @notice The ID of the permission required to call `_authorizeUpgrade`.
bytes32 public constant UPGRADE_REGISTRY_PERMISSION_ID = keccak256("UPGRADE_REGISTRY_PERMISSION");
/// @notice The ID of the permission required to call `evict`.
bytes32 public constant EVICT_SUBDOMAIN_PERMISSION_ID = keccak256("EVICT_SUBDOMAIN_PERMISSION");
// State
/// @notice The ENS registry contract.
ENS public ens;
/// @notice The namehash of the parent domain (e.g., `namehash("members.dao.eth")`).
bytes32 public parentNode;
/// @notice The parent domain string (e.g., `"members.dao.eth"`). Pre-image of `parentNode`.
string public parentDomain;
/// @notice The resolver address (must support per-node `approve()`).
address public resolver;
/// @notice Maps a member address to its claimed labelhash. `bytes32(0)` means not registered.
mapping(address => bytes32) public memberLabel;
/// @notice Maps a member address to its claimed subdomain string (for events and display).
mapping(address => string) public memberSubdomain;
/// @notice Maps a labelhash to the member who owns it. `address(0)` means available.
mapping(bytes32 => address) public labelOwner;
// Lifecycle
/// @dev Disallow initializing the implementation contract.
/// @custom:oz-upgrades-unsafe-allow constructor
constructor() {
_disableInitializers();
}
/// @notice Initializes the registry.
/// @param _managementDao The DAO management permissions.
/// @param _ens The ENS registry contract.
/// @param _domain The parent domain this registry manages (e.g., `"members.dao.eth"`).
/// @param _resolver The resolver address. Must support per-node `approve()`.
function initialize(IDAO _managementDao, ENS _ens, string memory _domain, address _resolver) external initializer {
// Verify the management DAO is not the zero address — without it, no permission
// checks (revoke, upgrade) can ever succeed.
if (address(_managementDao) == address(0)) revert InvalidManagementDao(address(_managementDao));
__DaoAuthorizableUpgradeable_init(_managementDao);
// Verify the ENS registry is valid (root node must have an owner).
if (_ens.owner(bytes32(0)) == address(0)) revert InvalidENSRegistry(address(_ens));
// Verify the parent domain is not empty.
else if (bytes(_domain).length == 0) revert InvalidDomain(_domain);
// Verify the resolver supports per-node approval (reverts if missing).
IResolver(_resolver).isApprovedFor(address(this), bytes32(0), address(0));
ens = _ens;
parentDomain = _domain;
parentNode = ENSDomain.namehash(_domain);
resolver = _resolver;
}
// External functions
/// @inheritdoc IMemberRegistry
function register(string calldata subdomain) external {
bytes32 label = _register(subdomain, msg.sender);
_setResolverAddr(label, msg.sender);
emit Registered(msg.sender, subdomain);
}
/// @inheritdoc IMemberRegistry
function register(string calldata subdomain, Records calldata records) external {
bytes32 label = _register(subdomain, msg.sender);
_applyRecords(label, records);
emit Registered(msg.sender, subdomain);
}
/// @inheritdoc IMemberRegistry
function release() external {
string memory subdomain = _release(msg.sender);
emit Released(msg.sender, subdomain);
}
/// @inheritdoc IMemberRegistry
function evict(string calldata subdomain, address newController) external auth(EVICT_SUBDOMAIN_PERMISSION_ID) {
bytes32 label = keccak256(bytes(subdomain));
address member = labelOwner[label];
if (member == address(0)) revert SubdomainNotRegistered(subdomain);
if (newController == member) revert InvalidNewController(newController);
_release(member);
emit SubdomainEvicted(member, msg.sender, subdomain);
if (newController == address(0)) return;
// Re-assign the same subdomain to the new controller. Goes through `_register` so the
// AlreadyRegistered guard and subdomain validation apply uniformly with `register()`.
_register(subdomain, newController);
_setResolverAddr(label, newController);
emit Registered(newController, subdomain);
}
/// @inheritdoc IMemberRegistry
function move(string calldata newSubdomain) external {
(bytes32 newLabel, string memory oldSubdomain) = _move(newSubdomain);
_setResolverAddr(newLabel, msg.sender);
emit ProfileMoved(msg.sender, oldSubdomain, newSubdomain);
}
/// @inheritdoc IMemberRegistry
function move(string calldata newSubdomain, Records calldata records) external {
(bytes32 newLabel, string memory oldSubdomain) = _move(newSubdomain);
_applyRecords(newLabel, records);
emit ProfileMoved(msg.sender, oldSubdomain, newSubdomain);
}
// Views
/// @notice Returns true if the member has a registered subdomain.
function isRegistered(address member) external view returns (bool) {
return memberLabel[member] != bytes32(0);
}
// Internal
uint256 internal constant MIN_SUBDOMAIN_LENGTH = 3;
uint256 internal constant MAX_SUBDOMAIN_LENGTH = 50;
/// @dev Core registration logic. Sets up the subnode for `member` but does NOT set resolver
/// records. The caller must set records and emit the event after this returns.
function _register(string calldata subdomain, address member) internal returns (bytes32 label) {
_requireValidSubdomain(subdomain);
label = keccak256(bytes(subdomain));
if (memberLabel[member] != bytes32(0)) revert AlreadyRegistered(member);
else if (labelOwner[label] != address(0)) revert SubdomainAlreadyTaken(subdomain);
memberLabel[member] = label;
memberSubdomain[member] = subdomain;
labelOwner[label] = member;
_assignSubnode(member, label);
}
/// @dev Core move logic. Sets up the new subnode but does NOT set resolver records.
/// The caller must set records and emit the event after this returns.
function _move(string calldata newSubdomain) internal returns (bytes32 newLabel, string memory oldSubdomain) {
_requireValidSubdomain(newSubdomain);
if (memberLabel[msg.sender] == bytes32(0)) revert NotRegistered(msg.sender);
newLabel = keccak256(bytes(newSubdomain));
if (labelOwner[newLabel] != address(0)) revert SubdomainAlreadyTaken(newSubdomain);
bytes32 oldLabel = memberLabel[msg.sender];
oldSubdomain = memberSubdomain[msg.sender];
delete labelOwner[oldLabel];
memberLabel[msg.sender] = newLabel;
memberSubdomain[msg.sender] = newSubdomain;
labelOwner[newLabel] = msg.sender;
_releaseSubnode(msg.sender, oldLabel);
_assignSubnode(msg.sender, newLabel);
}
/// @dev Clears member state and releases the ENS subnode. Returns the subdomain string for events.
function _release(address member) internal returns (string memory subdomain) {
if (memberLabel[member] == bytes32(0)) revert NotRegistered(member);
bytes32 label = memberLabel[member];
subdomain = memberSubdomain[member];
delete memberLabel[member];
delete memberSubdomain[member];
delete labelOwner[label];
_releaseSubnode(member, label);
}
/// @dev Validates the subdomain: 3–50 chars, only [0-9a-z-], no leading or trailing `-`.
function _requireValidSubdomain(string calldata subdomain) internal pure {
uint256 len = bytes(subdomain).length;
if (len < MIN_SUBDOMAIN_LENGTH || len > MAX_SUBDOMAIN_LENGTH) {
revert InvalidSubdomain(subdomain);
}
// Leading/trailing dashes are not allowed
if (bytes(subdomain)[0] == 0x2d || bytes(subdomain)[len - 1] == 0x2d) {
revert InvalidSubdomain(subdomain);
}
if (!isSubdomainValid(subdomain)) {
revert InvalidSubdomain(subdomain);
}
}
/// @dev Claims an ENS subnode: set owner, resolver, and per-node approval for the member.
/// Does not set any resolver records -- the caller handles that via _applyRecords or _setResolverAddr.
function _assignSubnode(address member, bytes32 label) internal {
bytes32 subnode = keccak256(abi.encodePacked(parentNode, label));
ens.setSubnodeOwner(parentNode, label, address(this));
ens.setResolver(subnode, resolver);
IResolver(resolver).approve(subnode, member, true);
}
/// @dev Releases an ENS subnode: revoke approval, clear records, zero addr, release node.
/// @dev setAddr(address(0)) is intentionally kept after clearRecords -- clearRecords bumps the
/// resolver version counter (invalidating all records), but zeroing addr explicitly ensures no
/// stale forward resolution regardless of resolver implementation details.
function _releaseSubnode(address member, bytes32 label) internal {
bytes32 subnode = keccak256(abi.encodePacked(parentNode, label));
IResolver(resolver).approve(subnode, member, false);
IResolver(resolver).clearRecords(subnode);
IResolver(resolver).setAddr(subnode, address(0));
ens.setSubnodeOwner(parentNode, label, address(0));
}
/// @dev Sets the addr record on a subnode.
function _setResolverAddr(bytes32 label, address addr) internal {
IResolver(resolver).setAddr(keccak256(abi.encodePacked(parentNode, label)), addr);
}
/// @dev Applies resolver records to a subnode: addr, text records, and contenthash.
/// addr defaults to msg.sender if records.addr is address(0).
function _applyRecords(bytes32 label, Records calldata records) internal {
bytes32 subnode = keccak256(abi.encodePacked(parentNode, label));
IResolver r = IResolver(resolver);
r.setAddr(subnode, records.addr != address(0) ? records.addr : msg.sender);
for (uint256 i; i < records.textRecords.length; i++) {
r.setText(subnode, records.textRecords[i].key, records.textRecords[i].value);
}
if (records.contenthash.length > 0) {
r.setContenthash(subnode, records.contenthash);
}
}
/// @notice Authorizes UUPS upgrades. Caller must have `UPGRADE_REGISTRY_PERMISSION_ID`.
function _authorizeUpgrade(address) internal virtual override auth(UPGRADE_REGISTRY_PERMISSION_ID) {}
/// @notice Reserved storage gap for future upgrades.
uint256[43] private __gap;
}
lib/ens-contracts/contracts/registry/ENS.sol
pragma solidity >=0.8.4;
interface ENS {
// Logged when the owner of a node assigns a new owner to a subnode.
event NewOwner(bytes32 indexed node, bytes32 indexed label, address owner);
// Logged when the owner of a node transfers ownership to a new account.
event Transfer(bytes32 indexed node, address owner);
// Logged when the resolver for a node changes.
event NewResolver(bytes32 indexed node, address resolver);
// Logged when the TTL of a node changes
event NewTTL(bytes32 indexed node, uint64 ttl);
// Logged when an operator is added or removed.
event ApprovalForAll(
address indexed owner,
address indexed operator,
bool approved
);
function setRecord(
bytes32 node,
address owner,
address resolver,
uint64 ttl
) external;
function setSubnodeRecord(
bytes32 node,
bytes32 label,
address owner,
address resolver,
uint64 ttl
) external;
function setSubnodeOwner(
bytes32 node,
bytes32 label,
address owner
) external returns (bytes32);
function setResolver(bytes32 node, address resolver) external;
function setOwner(bytes32 node, address owner) external;
function setTTL(bytes32 node, uint64 ttl) external;
function setApprovalForAll(address operator, bool approved) external;
function owner(bytes32 node) external view returns (address);
function resolver(bytes32 node) external view returns (address);
function ttl(bytes32 node) external view returns (uint64);
function recordExists(bytes32 node) external view returns (bool);
function isApprovedForAll(
address owner,
address operator
) external view returns (bool);
}
lib/openzeppelin-contracts-upgradeable/contracts/interfaces/IERC1967Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (interfaces/IERC1967.sol)
pragma solidity ^0.8.0;
/**
* @dev ERC-1967: Proxy Storage Slots. This interface contains the events defined in the ERC.
*
* _Available since v4.8.3._
*/
interface IERC1967Upgradeable {
/**
* @dev Emitted when the implementation is upgraded.
*/
event Upgraded(address indexed implementation);
/**
* @dev Emitted when the admin account has changed.
*/
event AdminChanged(address previousAdmin, address newAdmin);
/**
* @dev Emitted when the beacon is changed.
*/
event BeaconUpgraded(address indexed beacon);
}
lib/openzeppelin-contracts-upgradeable/contracts/interfaces/draft-IERC1822Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)
pragma solidity ^0.8.0;
/**
* @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified
* proxy whose upgrades are fully controlled by the current implementation.
*/
interface IERC1822ProxiableUpgradeable {
/**
* @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation
* address.
*
* IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
* bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
* function revert if invoked through a proxy.
*/
function proxiableUUID() external view returns (bytes32);
}
lib/openzeppelin-contracts-upgradeable/contracts/proxy/ERC1967/ERC1967UpgradeUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (proxy/ERC1967/ERC1967Upgrade.sol)
pragma solidity ^0.8.2;
import "../beacon/IBeaconUpgradeable.sol";
import "../../interfaces/IERC1967Upgradeable.sol";
import "../../interfaces/draft-IERC1822Upgradeable.sol";
import "../../utils/AddressUpgradeable.sol";
import "../../utils/StorageSlotUpgradeable.sol";
import {Initializable} from "../utils/Initializable.sol";
/**
* @dev This abstract contract provides getters and event emitting update functions for
* https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.
*
* _Available since v4.1._
*/
abstract contract ERC1967UpgradeUpgradeable is Initializable, IERC1967Upgradeable {
// This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1
bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;
/**
* @dev Storage slot with the address of the current implementation.
* This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is
* validated in the constructor.
*/
bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
function __ERC1967Upgrade_init() internal onlyInitializing {
}
function __ERC1967Upgrade_init_unchained() internal onlyInitializing {
}
/**
* @dev Returns the current implementation address.
*/
function _getImplementation() internal view returns (address) {
return StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value;
}
/**
* @dev Stores a new address in the EIP1967 implementation slot.
*/
function _setImplementation(address newImplementation) private {
require(AddressUpgradeable.isContract(newImplementation), "ERC1967: new implementation is not a contract");
StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
}
/**
* @dev Perform implementation upgrade
*
* Emits an {Upgraded} event.
*/
function _upgradeTo(address newImplementation) internal {
_setImplementation(newImplementation);
emit Upgraded(newImplementation);
}
/**
* @dev Perform implementation upgrade with additional setup call.
*
* Emits an {Upgraded} event.
*/
function _upgradeToAndCall(address newImplementation, bytes memory data, bool forceCall) internal {
_upgradeTo(newImplementation);
if (data.length > 0 || forceCall) {
AddressUpgradeable.functionDelegateCall(newImplementation, data);
}
}
/**
* @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.
*
* Emits an {Upgraded} event.
*/
function _upgradeToAndCallUUPS(address newImplementation, bytes memory data, bool forceCall) internal {
// Upgrades from old implementations will perform a rollback test. This test requires the new
// implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing
// this special case will break upgrade paths from old UUPS implementation to new ones.
if (StorageSlotUpgradeable.getBooleanSlot(_ROLLBACK_SLOT).value) {
_setImplementation(newImplementation);
} else {
try IERC1822ProxiableUpgradeable(newImplementation).proxiableUUID() returns (bytes32 slot) {
require(slot == _IMPLEMENTATION_SLOT, "ERC1967Upgrade: unsupported proxiableUUID");
} catch {
revert("ERC1967Upgrade: new implementation is not UUPS");
}
_upgradeToAndCall(newImplementation, data, forceCall);
}
}
/**
* @dev Storage slot with the admin of the contract.
* This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is
* validated in the constructor.
*/
bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
/**
* @dev Returns the current admin.
*/
function _getAdmin() internal view returns (address) {
return StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value;
}
/**
* @dev Stores a new address in the EIP1967 admin slot.
*/
function _setAdmin(address newAdmin) private {
require(newAdmin != address(0), "ERC1967: new admin is the zero address");
StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value = newAdmin;
}
/**
* @dev Changes the admin of the proxy.
*
* Emits an {AdminChanged} event.
*/
function _changeAdmin(address newAdmin) internal {
emit AdminChanged(_getAdmin(), newAdmin);
_setAdmin(newAdmin);
}
/**
* @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.
* This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.
*/
bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;
/**
* @dev Returns the current beacon.
*/
function _getBeacon() internal view returns (address) {
return StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value;
}
/**
* @dev Stores a new beacon in the EIP1967 beacon slot.
*/
function _setBeacon(address newBeacon) private {
require(AddressUpgradeable.isContract(newBeacon), "ERC1967: new beacon is not a contract");
require(
AddressUpgradeable.isContract(IBeaconUpgradeable(newBeacon).implementation()),
"ERC1967: beacon implementation is not a contract"
);
StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value = newBeacon;
}
/**
* @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does
* not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).
*
* Emits a {BeaconUpgraded} event.
*/
function _upgradeBeaconToAndCall(address newBeacon, bytes memory data, bool forceCall) internal {
_setBeacon(newBeacon);
emit BeaconUpgraded(newBeacon);
if (data.length > 0 || forceCall) {
AddressUpgradeable.functionDelegateCall(IBeaconUpgradeable(newBeacon).implementation(), data);
}
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[50] private __gap;
}
lib/openzeppelin-contracts-upgradeable/contracts/proxy/beacon/IBeaconUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)
pragma solidity ^0.8.0;
/**
* @dev This is the interface that {BeaconProxy} expects of its beacon.
*/
interface IBeaconUpgradeable {
/**
* @dev Must return an address that can be used as a delegate call target.
*
* {BeaconProxy} will check that this address is a contract.
*/
function implementation() external view returns (address);
}
lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol)
pragma solidity ^0.8.2;
import "../../utils/AddressUpgradeable.sol";
/**
* @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
* behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
* external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
* function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
*
* The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
* reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
* case an upgrade adds a module that needs to be initialized.
*
* For example:
*
* [.hljs-theme-light.nopadding]
* ```solidity
* contract MyToken is ERC20Upgradeable {
* function initialize() initializer public {
* __ERC20_init("MyToken", "MTK");
* }
* }
*
* contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
* function initializeV2() reinitializer(2) public {
* __ERC20Permit_init("MyToken");
* }
* }
* ```
*
* TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
* possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
*
* CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
* that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
*
* [CAUTION]
* ====
* Avoid leaving a contract uninitialized.
*
* An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
* contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
* the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
*
* [.hljs-theme-light.nopadding]
* ```
* /// @custom:oz-upgrades-unsafe-allow constructor
* constructor() {
* _disableInitializers();
* }
* ```
* ====
*/
abstract contract Initializable {
/**
* @dev Indicates that the contract has been initialized.
* @custom:oz-retyped-from bool
*/
uint8 private _initialized;
/**
* @dev Indicates that the contract is in the process of being initialized.
*/
bool private _initializing;
/**
* @dev Triggered when the contract has been initialized or reinitialized.
*/
event Initialized(uint8 version);
/**
* @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
* `onlyInitializing` functions can be used to initialize parent contracts.
*
* Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a
* constructor.
*
* Emits an {Initialized} event.
*/
modifier initializer() {
bool isTopLevelCall = !_initializing;
require(
(isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),
"Initializable: contract is already initialized"
);
_initialized = 1;
if (isTopLevelCall) {
_initializing = true;
}
_;
if (isTopLevelCall) {
_initializing = false;
emit Initialized(1);
}
}
/**
* @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
* contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
* used to initialize parent contracts.
*
* A reinitializer may be used after the original initialization step. This is essential to configure modules that
* are added through upgrades and that require initialization.
*
* When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
* cannot be nested. If one is invoked in the context of another, execution will revert.
*
* Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
* a contract, executing them in the right order is up to the developer or operator.
*
* WARNING: setting the version to 255 will prevent any future reinitialization.
*
* Emits an {Initialized} event.
*/
modifier reinitializer(uint8 version) {
require(!_initializing && _initialized < version, "Initializable: contract is already initialized");
_initialized = version;
_initializing = true;
_;
_initializing = false;
emit Initialized(version);
}
/**
* @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
* {initializer} and {reinitializer} modifiers, directly or indirectly.
*/
modifier onlyInitializing() {
require(_initializing, "Initializable: contract is not initializing");
_;
}
/**
* @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
* Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
* to any version. It is recommended to use this to lock implementation contracts that are designed to be called
* through proxies.
*
* Emits an {Initialized} event the first time it is successfully executed.
*/
function _disableInitializers() internal virtual {
require(!_initializing, "Initializable: contract is initializing");
if (_initialized != type(uint8).max) {
_initialized = type(uint8).max;
emit Initialized(type(uint8).max);
}
}
/**
* @dev Returns the highest version that has been initialized. See {reinitializer}.
*/
function _getInitializedVersion() internal view returns (uint8) {
return _initialized;
}
/**
* @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
*/
function _isInitializing() internal view returns (bool) {
return _initializing;
}
}
lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/UUPSUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/UUPSUpgradeable.sol)
pragma solidity ^0.8.0;
import "../../interfaces/draft-IERC1822Upgradeable.sol";
import "../ERC1967/ERC1967UpgradeUpgradeable.sol";
import {Initializable} from "./Initializable.sol";
/**
* @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an
* {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy.
*
* A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is
* reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing
* `UUPSUpgradeable` with a custom implementation of upgrades.
*
* The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism.
*
* _Available since v4.1._
*/
abstract contract UUPSUpgradeable is Initializable, IERC1822ProxiableUpgradeable, ERC1967UpgradeUpgradeable {
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable state-variable-assignment
address private immutable __self = address(this);
/**
* @dev Check that the execution is being performed through a delegatecall call and that the execution context is
* a proxy contract with an implementation (as defined in ERC1967) pointing to self. This should only be the case
* for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a
* function through ERC1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to
* fail.
*/
modifier onlyProxy() {
require(address(this) != __self, "Function must be called through delegatecall");
require(_getImplementation() == __self, "Function must be called through active proxy");
_;
}
/**
* @dev Check that the execution is not being performed through a delegate call. This allows a function to be
* callable on the implementing contract but not through proxies.
*/
modifier notDelegated() {
require(address(this) == __self, "UUPSUpgradeable: must not be called through delegatecall");
_;
}
function __UUPSUpgradeable_init() internal onlyInitializing {
}
function __UUPSUpgradeable_init_unchained() internal onlyInitializing {
}
/**
* @dev Implementation of the ERC1822 {proxiableUUID} function. This returns the storage slot used by the
* implementation. It is used to validate the implementation's compatibility when performing an upgrade.
*
* IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
* bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
* function revert if invoked through a proxy. This is guaranteed by the `notDelegated` modifier.
*/
function proxiableUUID() external view virtual override notDelegated returns (bytes32) {
return _IMPLEMENTATION_SLOT;
}
/**
* @dev Upgrade the implementation of the proxy to `newImplementation`.
*
* Calls {_authorizeUpgrade}.
*
* Emits an {Upgraded} event.
*
* @custom:oz-upgrades-unsafe-allow-reachable delegatecall
*/
function upgradeTo(address newImplementation) public virtual onlyProxy {
_authorizeUpgrade(newImplementation);
_upgradeToAndCallUUPS(newImplementation, new bytes(0), false);
}
/**
* @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call
* encoded in `data`.
*
* Calls {_authorizeUpgrade}.
*
* Emits an {Upgraded} event.
*
* @custom:oz-upgrades-unsafe-allow-reachable delegatecall
*/
function upgradeToAndCall(address newImplementation, bytes memory data) public payable virtual onlyProxy {
_authorizeUpgrade(newImplementation);
_upgradeToAndCallUUPS(newImplementation, data, true);
}
/**
* @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by
* {upgradeTo} and {upgradeToAndCall}.
*
* Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}.
*
* ```solidity
* function _authorizeUpgrade(address) internal override onlyOwner {}
* ```
*/
function _authorizeUpgrade(address newImplementation) internal virtual;
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[50] private __gap;
}
lib/openzeppelin-contracts-upgradeable/contracts/utils/AddressUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library AddressUpgradeable {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
*
* Furthermore, `isContract` will also return true if the target contract within
* the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
* which only has an effect at the end of a transaction.
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
* the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
*
* _Available since v4.8._
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata,
string memory errorMessage
) internal view returns (bytes memory) {
if (success) {
if (returndata.length == 0) {
// only check isContract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
require(isContract(target), "Address: call to non-contract");
}
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
/**
* @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason or using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
function _revert(bytes memory returndata, string memory errorMessage) private pure {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
lib/openzeppelin-contracts-upgradeable/contracts/utils/ContextUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.4) (utils/Context.sol)
pragma solidity ^0.8.0;
import {Initializable} from "../proxy/utils/Initializable.sol";
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract ContextUpgradeable is Initializable {
function __Context_init() internal onlyInitializing {
}
function __Context_init_unchained() internal onlyInitializing {
}
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[50] private __gap;
}
lib/openzeppelin-contracts-upgradeable/contracts/utils/StorageSlotUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/StorageSlot.sol)
// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.
pragma solidity ^0.8.0;
/**
* @dev Library for reading and writing primitive types to specific storage slots.
*
* Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
* This library helps with reading and writing to such slots without the need for inline assembly.
*
* The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
*
* Example usage to set ERC1967 implementation slot:
* ```solidity
* contract ERC1967 {
* bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
*
* function _getImplementation() internal view returns (address) {
* return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
* }
*
* function _setImplementation(address newImplementation) internal {
* require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
* StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
* }
* }
* ```
*
* _Available since v4.1 for `address`, `bool`, `bytes32`, `uint256`._
* _Available since v4.9 for `string`, `bytes`._
*/
library StorageSlotUpgradeable {
struct AddressSlot {
address value;
}
struct BooleanSlot {
bool value;
}
struct Bytes32Slot {
bytes32 value;
}
struct Uint256Slot {
uint256 value;
}
struct StringSlot {
string value;
}
struct BytesSlot {
bytes value;
}
/**
* @dev Returns an `AddressSlot` with member `value` located at `slot`.
*/
function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `BooleanSlot` with member `value` located at `slot`.
*/
function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `Bytes32Slot` with member `value` located at `slot`.
*/
function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `Uint256Slot` with member `value` located at `slot`.
*/
function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `StringSlot` with member `value` located at `slot`.
*/
function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `StringSlot` representation of the string storage pointer `store`.
*/
function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := store.slot
}
}
/**
* @dev Returns an `BytesSlot` with member `value` located at `slot`.
*/
function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := slot
}
}
/**
* @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`.
*/
function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {
/// @solidity memory-safe-assembly
assembly {
r.slot := store.slot
}
}
}
src/common/dao/IDAO.sol
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity ^0.8.8;
/// @title IDAO
/// @author Aragon X - 2022-2024
/// @notice The interface required for DAOs within the Aragon App DAO framework.
/// @custom:security-contact [email protected]
interface IDAO {
/// @notice Checks if an address has permission on a contract via a permission identifier and considers if `ANY_ADDRESS` was used in the granting process.
/// @param _where The address of the contract.
/// @param _who The address of a EOA or contract to give the permissions.
/// @param _permissionId The permission identifier.
/// @param _data The optional data passed to the `PermissionCondition` registered.
/// @return Returns true if the address has permission, false if not.
function hasPermission(
address _where,
address _who,
bytes32 _permissionId,
bytes memory _data
) external view returns (bool);
/// @notice Updates the DAO metadata (e.g., an IPFS hash).
/// @param _metadata The IPFS hash of the new metadata object.
function setMetadata(bytes calldata _metadata) external;
/// @notice Emitted when the DAO metadata is updated.
/// @param metadata The IPFS hash of the new metadata object.
event MetadataSet(bytes metadata);
/// @notice Emitted when a standard callback is registered.
/// @param interfaceId The ID of the interface.
/// @param callbackSelector The selector of the callback function.
/// @param magicNumber The magic number to be registered for the callback function selector.
event StandardCallbackRegistered(
bytes4 interfaceId,
bytes4 callbackSelector,
bytes4 magicNumber
);
/// @notice Deposits (native) tokens to the DAO contract with a reference string.
/// @param _token The address of the token or address(0) in case of the native token.
/// @param _amount The amount of tokens to deposit.
/// @param _reference The reference describing the deposit reason.
function deposit(address _token, uint256 _amount, string calldata _reference) external payable;
/// @notice Emitted when a token deposit has been made to the DAO.
/// @param sender The address of the sender.
/// @param token The address of the deposited token.
/// @param amount The amount of tokens deposited.
/// @param _reference The reference describing the deposit reason.
event Deposited(
address indexed sender,
address indexed token,
uint256 amount,
string _reference
);
/// @notice Emitted when a native token deposit has been made to the DAO.
/// @dev This event is intended to be emitted in the `receive` function and is therefore bound by the gas limitations for `send`/`transfer` calls introduced by [ERC-2929](https://eips.ethereum.org/EIPS/eip-2929).
/// @param sender The address of the sender.
/// @param amount The amount of native tokens deposited.
event NativeTokenDeposited(address sender, uint256 amount);
/// @notice Setter for the trusted forwarder verifying the meta transaction.
/// @param _trustedForwarder The trusted forwarder address.
function setTrustedForwarder(address _trustedForwarder) external;
/// @notice Getter for the trusted forwarder verifying the meta transaction.
/// @return The trusted forwarder address.
function getTrustedForwarder() external view returns (address);
/// @notice Emitted when a new TrustedForwarder is set on the DAO.
/// @param forwarder the new forwarder address.
event TrustedForwarderSet(address forwarder);
/// @notice Checks whether a signature is valid for a provided hash according to [ERC-1271](https://eips.ethereum.org/EIPS/eip-1271).
/// @param _hash The hash of the data to be signed.
/// @param _signature The signature byte array associated with `_hash`.
/// @return Returns the `bytes4` magic value `0x1626ba7e` if the signature is valid and `0xffffffff` if not.
function isValidSignature(bytes32 _hash, bytes memory _signature) external returns (bytes4);
/// @notice Registers an ERC standard having a callback by registering its [ERC-165](https://eips.ethereum.org/EIPS/eip-165) interface ID and callback function signature.
/// @param _interfaceId The ID of the interface.
/// @param _callbackSelector The selector of the callback function.
/// @param _magicNumber The magic number to be registered for the function signature.
function registerStandardCallback(
bytes4 _interfaceId,
bytes4 _callbackSelector,
bytes4 _magicNumber
) external;
/// @notice Removed function being left here to not corrupt the IDAO interface ID. Any call will revert.
/// @dev Introduced in v1.0.0. Removed in v1.4.0.
function setSignatureValidator(address) external;
}
src/common/permission/auth/DaoAuthorizableUpgradeable.sol
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity ^0.8.8;
import {ContextUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol";
import {IDAO} from "../../dao/IDAO.sol";
import {_auth} from "./auth.sol";
/// @title DaoAuthorizableUpgradeable
/// @author Aragon X - 2022-2023
/// @notice An abstract contract providing a meta-transaction compatible modifier for upgradeable or cloneable contracts to authorize function calls through an associated DAO.
/// @dev Make sure to call `__DaoAuthorizableUpgradeable_init` during initialization of the inheriting contract.
/// @custom:security-contact [email protected]
abstract contract DaoAuthorizableUpgradeable is ContextUpgradeable {
/// @notice The associated DAO managing the permissions of inheriting contracts.
IDAO private dao_;
/// @notice Initializes the contract by setting the associated DAO.
/// @param _dao The associated DAO address.
// solhint-disable-next-line func-name-mixedcase
function __DaoAuthorizableUpgradeable_init(IDAO _dao) internal onlyInitializing {
dao_ = _dao;
}
/// @notice Returns the DAO contract.
/// @return The DAO contract.
function dao() public view returns (IDAO) {
return dao_;
}
/// @notice A modifier to make functions on inheriting contracts authorized. Permissions to call the function are checked through the associated DAO's permission manager.
/// @param _permissionId The permission identifier required to call the method this modifier is applied to.
modifier auth(bytes32 _permissionId) {
_auth(dao_, address(this), _msgSender(), _permissionId, _msgData());
_;
}
/// @notice This empty reserved space is put in place to allow future versions to add new variables without shifting down storage in the inheritance chain (see [OpenZeppelin's guide about storage gaps](https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps)).
uint256[49] private __gap;
}
src/common/permission/auth/auth.sol
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity ^0.8.8;
import {IDAO} from "../../dao/IDAO.sol";
/// @title DAO Authorization Utilities
/// @author Aragon X - 2022-2024
/// @notice Provides utility functions for verifying if a caller has specific permissions in an associated DAO.
/// @custom:security-contact [email protected]
/// @notice Thrown if a call is unauthorized in the associated DAO.
/// @param dao The associated DAO.
/// @param where The context in which the authorization reverted.
/// @param who The address (EOA or contract) missing the permission.
/// @param permissionId The permission identifier.
error DaoUnauthorized(address dao, address where, address who, bytes32 permissionId);
/// @notice A free function checking if a caller is granted permissions on a target contract via a permission identifier that redirects the approval to a `PermissionCondition` if this was specified in the setup.
/// @param _where The address of the target contract for which `who` receives permission.
/// @param _who The address (EOA or contract) owning the permission.
/// @param _permissionId The permission identifier.
/// @param _data The optional data passed to the `PermissionCondition` registered.
function _auth(
IDAO _dao,
address _where,
address _who,
bytes32 _permissionId,
bytes calldata _data
) view {
if (!_dao.hasPermission(_where, _who, _permissionId, _data))
revert DaoUnauthorized({
dao: address(_dao),
where: _where,
who: _who,
permissionId: _permissionId
});
}
src/common/utils/versioning/IProtocolVersion.sol
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity ^0.8.8;
/// @title IProtocolVersion
/// @author Aragon X - 2022-2023
/// @notice An interface defining the semantic Aragon OSx protocol version number.
/// @custom:security-contact [email protected]
interface IProtocolVersion {
/// @notice Returns the semantic Aragon OSx protocol version number that the implementing contract is associated with.
/// @return _version Returns the semantic Aragon OSx protocol version number.
/// @dev This version number is not to be confused with the `release` and `build` numbers found in the `Version.Tag` struct inside the `PluginRepo` contract being used to version plugin setup and associated plugin implementation contracts.
function protocolVersion() external view returns (uint8[3] memory _version);
}
src/common/utils/versioning/ProtocolVersion.sol
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity ^0.8.8;
import {IProtocolVersion} from "./IProtocolVersion.sol";
/// @title ProtocolVersion
/// @author Aragon X - 2023
/// @notice An abstract, stateless, non-upgradeable contract providing the current Aragon OSx protocol version number.
/// @dev Do not add any new variables to this contract that would shift down storage in the inheritance chain.
/// @custom:security-contact [email protected]
abstract contract ProtocolVersion is IProtocolVersion {
// IMPORTANT: Do not add any storage variable, see the above notice.
/// @inheritdoc IProtocolVersion
function protocolVersion() public pure returns (uint8[3] memory) {
return [1, 4, 0];
}
}
src/framework/member/IMemberRegistry.sol
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity ^0.8.17;
/// @title IMemberRegistry
/// @notice Permissionless member self-registration via ENS subdomain claims.
/// Members claim a subdomain under a configurable parent domain, manage their own
/// resolver records (text, avatar, etc.) via per-node approval, and can release or
/// move their subdomain at any time.
/// @custom:security-contact [email protected]
interface IMemberRegistry {
/// @notice A key-value pair for an ENS text record.
struct TextRecord {
string key;
string value;
}
/// @notice A bundle of ENS resolver records to set atomically during register or move.
/// @param textRecords Text records to set (avatar, description, url, etc.)
/// @param addr The address record. Use address(0) to default to msg.sender.
/// @param contenthash The contenthash (IPFS, Swarm, etc.). Empty bytes = don't set.
struct Records {
TextRecord[] textRecords;
address addr;
bytes contenthash;
}
/// @notice Emitted when a member registers and claims a subdomain.
event Registered(address indexed member, string subdomain);
/// @notice Emitted when a member voluntarily releases their subdomain.
event Released(address indexed member, string subdomain);
/// @notice Emitted when governance forcibly evicts a member's subdomain.
event SubdomainEvicted(address indexed member, address indexed evictor, string subdomain);
/// @notice Emitted when a member moves their subdomain (release old + claim new).
event ProfileMoved(address indexed member, string oldSubdomain, string newSubdomain);
/// @notice Thrown if the subdomain is invalid: shorter than 3 characters, longer than 50,
/// starts or ends with `-`, or contains characters outside [0-9a-z-].
error InvalidSubdomain(string subdomain);
/// @notice Thrown if the member is already registered.
error AlreadyRegistered(address member);
/// @notice Thrown if the member is not registered.
error NotRegistered(address member);
/// @notice Thrown if the requested subdomain label is already taken.
error SubdomainAlreadyTaken(string subdomain);
/// @notice Thrown if the subdomain has no current owner (evict target unknown).
error SubdomainNotRegistered(string subdomain);
/// @notice Thrown if the new controller passed to `evict` already controls the subdomain
/// being evicted (no-op transfer is rejected to surface caller mistakes).
error InvalidNewController(address newController);
/// @notice Thrown if the ENS registry address is not a valid ENS registry.
error InvalidENSRegistry(address ens);
/// @notice Thrown if the parent domain is empty.
error InvalidDomain(string domain);
/// @notice Thrown if the management DAO address is the zero address.
error InvalidManagementDao(address dao);
/// @notice Register as a member by claiming a subdomain. Permissionless.
/// One subdomain per address. Reverts if already registered (release first).
/// @param subdomain The subdomain label to claim (e.g., "alice").
function register(string calldata subdomain) external;
/// @notice Register as a member with initial resolver records set atomically. Permissionless.
/// One subdomain per address. Reverts if already registered (release first).
/// @param subdomain The subdomain label to claim (e.g., "alice").
/// @param records Resolver records to set on the new subnode (text, addr, contenthash).
/// addr=address(0) defaults to msg.sender. Empty contenthash is skipped.
function register(string calldata subdomain, Records calldata records) external;
/// @notice Voluntarily release your subdomain. Permissionless.
/// Only releases the caller's own subdomain. Reverts if not registered.
function release() external;
/// @notice Forcibly evict a subdomain, optionally re-assigning it to a new controller. Governed.
/// Requires EVICT_SUBDOMAIN_PERMISSION_ID on this contract (OSx permission system).
/// If `newController` is the zero address, the subdomain is fully released (records
/// cleared, subnode released). If `newController` is non-zero, the same subdomain is
/// re-assigned to it as if it had called `register` itself: ENS subnode re-created,
/// addr record set to `newController`, per-node resolver approval granted to it.
/// Reverts if the subdomain is unknown, if `newController` already controls it, or
/// if `newController` is already registered with a different subdomain.
/// @param subdomain The subdomain label to evict (e.g., "alice").
/// @param newController Address that should control the subdomain after the eviction, or
/// `address(0)` to release without reassignment.
function evict(string calldata subdomain, address newController) external;
/// @notice Move your subdomain. Releases the old label and claims the new one atomically.
/// Only moves the caller's own subdomain. Reverts if not registered or new label taken.
/// @param newSubdomain The new subdomain label to claim.
function move(string calldata newSubdomain) external;
/// @notice Move your subdomain and carry over resolver records atomically.
/// Only moves the caller's own subdomain. Reverts if not registered or new label taken.
/// @param newSubdomain The new subdomain label to claim.
/// @param records Resolver records to set on the new subnode (text, addr, contenthash).
/// addr=address(0) keeps the default (msg.sender). Empty contenthash is skipped.
function move(string calldata newSubdomain, Records calldata records) external;
/// @notice The parent domain string this registry manages (e.g., `"members.dao.eth"`).
/// Pre-image of `parentNode()`.
function parentDomain() external view returns (string memory);
/// @notice The namehash of the parent domain. Equal to `namehash(parentDomain())`.
function parentNode() external view returns (bytes32);
/// @notice Returns true if `member` has a registered subdomain.
function isRegistered(address member) external view returns (bool);
}
src/framework/utils/RegistryUtils.sol
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity ^0.8.8;
/// @notice Validates that a subdomain name is composed only from characters in the allowed character set:
/// - the lowercase letters `a-z`
/// - the digits `0-9`
/// - the hyphen `-`
/// @dev This function allows empty (zero-length) subdomains. If this should not be allowed, make sure to add a respective check when using this function in your code.
/// @param subDomain The name of the DAO.
/// @return `true` if the name is valid or `false` if at least one char is invalid.
/// @dev Aborts on the first invalid char found.
/// @custom:security-contact [email protected]
function isSubdomainValid(string calldata subDomain) pure returns (bool) {
bytes calldata nameBytes = bytes(subDomain);
uint256 nameLength = nameBytes.length;
for (uint256 i; i < nameLength; i++) {
uint8 char = uint8(nameBytes[i]);
// if char is between a-z
if (char > 96 && char < 123) {
continue;
}
// if char is between 0-9
if (char > 47 && char < 58) {
continue;
}
// if char is -
if (char == 45) {
continue;
}
// invalid if one char doesn't work with the rules above
return false;
}
return true;
}
src/framework/utils/ens/ENSDomain.sol
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity ^0.8.17;
/// @title ENSDomain
/// @notice Pure-string utilities for working with ENS domain names: namehash (EIP-137)
/// and splitting at the first dot. Single source of truth used by the contract,
/// deploy scripts and tests.
library ENSDomain {
/// @notice Returns the namehash of `domain` (e.g., `"members.dao.eth"`).
/// @dev Returns `bytes32(0)` for an empty input. Does not validate label characters —
/// callers must enforce any character/length rules separately.
function namehash(string memory domain) internal pure returns (bytes32 result) {
bytes memory b = bytes(domain);
if (b.length == 0) return bytes32(0);
uint256 end = b.length;
for (uint256 i = b.length; i > 0; i--) {
if (b[i - 1] == ".") {
result = keccak256(abi.encodePacked(result, _labelHash(b, i, end)));
end = i - 1;
}
}
result = keccak256(abi.encodePacked(result, _labelHash(b, 0, end)));
}
/// @notice Splits a domain at its first dot.
/// @dev Total function — never reverts. Examples:
/// - `"members.dao.eth"` → `("members", "dao.eth")`
/// - `"eth"` → `("eth", "")` (no dot: whole input is the label, no parent)
/// - `""` → `("", "")` (empty input)
///
/// The "no parent" case composes correctly with `namehash`, since
/// `namehash("") == bytes32(0)` is the EIP-137 recursion base.
function splitDomain(string memory domain) internal pure returns (string memory label, string memory parent) {
bytes memory b = bytes(domain);
for (uint256 i = 0; i < b.length; i++) {
if (b[i] == ".") {
label = new string(i);
parent = new string(b.length - i - 1);
bytes memory lb = bytes(label);
bytes memory pb = bytes(parent);
for (uint256 j = 0; j < i; j++) {
lb[j] = b[j];
}
for (uint256 j = i + 1; j < b.length; j++) {
pb[j - i - 1] = b[j];
}
return (label, parent);
}
}
// No dot: the whole input is the label, parent is empty.
return (domain, "");
}
function _labelHash(bytes memory b, uint256 start, uint256 end) private pure returns (bytes32) {
bytes memory label = new bytes(end - start);
for (uint256 i = start; i < end; i++) {
label[i - start] = b[i];
}
return keccak256(label);
}
}
src/framework/utils/ens/IResolver.sol
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity ^0.8.17;
/// @title IResolver
/// @notice Minimal resolver interface for MemberRegistry.
/// Covers what the registry calls during subnode lifecycle and record migration.
/// Members call the full PublicResolver directly for additional record management.
/// @custom:security-contact [email protected]
interface IResolver {
/// @notice Set the address record for a node.
function setAddr(bytes32 node, address addr) external;
/// @notice Set a text record for a node.
function setText(bytes32 node, string calldata key, string calldata value) external;
/// @notice Set the contenthash for a node.
function setContenthash(bytes32 node, bytes calldata hash) external;
/// @notice Approve a delegate to manage resolver records for a specific node.
/// @dev Per-node delegation. Available in ens-contracts >= v0.0.19.
function approve(bytes32 node, address delegate, bool approved) external;
/// @notice Invalidate all resolver records for a node by incrementing the version counter.
function clearRecords(bytes32 node) external;
/// @notice Check if a delegate is approved for a node by a given owner.
function isApprovedFor(address owner, bytes32 node, address delegate) external view returns (bool);
}
Compiler settingsShow
{
"viaIR": false,
"metadata": {
"bytecodeHash": "ipfs",
"useLiteralContent": false
},
"optimizer": {
"runs": 2000,
"enabled": true
},
"evmVersion": "london",
"remappings": [
"@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
"@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/",
"@ensdomains/ens-contracts/=lib/ens-contracts/",
"forge-std/=lib/forge-std/src/",
"@aragon/osx-commons-contracts/src/=src/common/",
"ds-test/=lib/openzeppelin-contracts-upgradeable/lib/forge-std/lib/ds-test/src/",
"ens-contracts/=lib/ens-contracts/contracts/",
"erc4626-tests/=lib/openzeppelin-contracts-upgradeable/lib/erc4626-tests/",
"openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/",
"openzeppelin-contracts/=lib/openzeppelin-contracts/",
"openzeppelin/=lib/openzeppelin-contracts-upgradeable/contracts/"
]
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.