ProtocolOwnedUpgradeable

Git Source

Title: ProtocolOwnedUpgradeable

Governance gate for an upgradeable dotNS contract whose bootstrap owner is the owner of its DotnsProtocolRegistry: substrate Root, or that owner while one is set.

@custom:function owner returns the protocol registry's owner, so every contract of a deployment shares one bootstrap owner, and renouncing it on the registry leaves Root as the only governance of all of them in the same transaction. This contract keeps no owner, adds no storage and has no transferOwnership or renounceOwnership: the bootstrap owner is renounced on the protocol registry. The protocol registry address must be fixed at initialisation, because whoever controls it controls this gate. The gate follows @custom:contract BootstrapOwnableUpgradeable: it checks Root first, through @custom:function SystemUtils.tryCallerIsRoot, and reads msg.sender only when the caller is not Root, so a function behind it must not read msg.sender either. Root passes only when it called this contract directly. A contract that inherited OwnableUpgradeable can switch to this base: the old owner sits in ERC-7201 namespaced storage, so no slot moves, and nothing reads it afterwards. That slot still holds the old owner, so an implementation must never inherit OwnableUpgradeable again: it would read the old owner back.

Functions

onlyRootOrOwner

Restricts a call to Root, or to the bootstrap owner while one is set.

modifier onlyRootOrOwner() ;

owner

Returns the bootstrap owner, read from the protocol registry.

function owner() public view returns (address owner_);

Returns

NameTypeDescription
owner_addressThe protocol registry's owner, or zero once it is renounced.

_checkRootOrOwner

Internal check behind @custom:modifier onlyRootOrOwner.

Reverts with OwnableUnauthorizedAccount when the caller is neither Root nor the owner. Once the owner is renounced, @custom:function owner is zero and no account passes.

function _checkRootOrOwner() internal view;

onlyRootOrMaintainer

Restricts a call to Root, or to the maintainer account while one is set.

modifier onlyRootOrMaintainer() ;

_checkRootOrMaintainer

Passes Root and the maintainer account, and reports which one called.

The maintainer account is the address under DotnsConstants.MAINTAINER in the protocol registry; unset, it reads zero and no caller passes as maintainer. Checks Root first and reads msg.sender only on the maintainer branch, otherwise

Note: reverts: NotRootOrMaintainer. A caller uses the result to hold the maintainer to the direction that cannot disrupt what is under way.

function _checkRootOrMaintainer() internal view returns (bool root);

Returns

NameTypeDescription
rootboolTrue for Root, false for the maintainer account.

_requireProtocolRegistry

Reverts with ZeroProtocolRegistry for a zero protocol registry.

Initialisers call it before storing the registry: a follower bound to no registry would have no bootstrap owner.

function _requireProtocolRegistry(address registry) internal pure;

Parameters

NameTypeDescription
registryaddressProtocol registry an initialiser received.

_protocolRegistryAddress

Returns the protocol registry that holds the bootstrap owner.

function _protocolRegistryAddress() internal view virtual returns (address registry);

Returns

NameTypeDescription
registryaddressAddress set at initialisation.

Errors

OwnableUnauthorizedAccount

Thrown when the caller is neither Root nor the bootstrap owner.

error OwnableUnauthorizedAccount(address account);

Parameters

NameTypeDescription
accountaddressThe caller.

ZeroProtocolRegistry

Thrown by an initialiser given a zero protocol registry.

error ZeroProtocolRegistry();

NotRootOrMaintainer

Thrown when the caller is neither Root nor the maintainer account.

error NotRootOrMaintainer(address account);

Parameters

NameTypeDescription
accountaddressThe caller.

MaintainerNotAllowed

Thrown when the maintainer moves a value in the direction that would disrupt what is already under way; only Root can.

error MaintainerNotAllowed();