Skip to main content

Guardian

Guardian

Dev note

Contract module which provides access control mechanism, where there is an account (an guardian) that can be granted exclusive access to specific functions.

The initial guardian is specified at deployment time in the constructor for Guardian. This can later be changed with {transferGuardian} and {acceptGuardian}.

This module is used through inheritance. It will make available all functions from parent (Guardian).

Modified from the OpenZeppelin Contracts library (5.0.0)

Addresses

ChainAddress

Functions

constructor

constructor(address initialGuardian) internal
Dev note

Initializes the contract setting the address provided by the deployer as the initial guardian.

transferGuardian

function transferGuardian(address newGuardian) public virtual
Dev note

Starts the guardianship transfer of the contract to a new account. Replaces the pending transfer if there is one. Can only be called by the current guardian.

_transferGuardian

function _transferGuardian(address newGuardian) internal virtual
Dev note

Transfers guardianship of the contract to a new account (newGuardian) and deletes any pending guardian. Internal function without access restriction.

acceptGuardian

function acceptGuardian() public virtual
Dev note

The new guardian accepts the guardianship transfer.

_checkGuardian

function _checkGuardian() internal view virtual
Dev note

Throws if the sender is not the guardian.

pendingGuardian

function pendingGuardian() public view virtual returns (address)
Dev note

Returns the address of the pending guardian.

guardian

function guardian() public view virtual returns (address)
Dev note

Returns the address of the current guardian.

Modifiers

onlyGuardian

modifier onlyGuardian()
Dev note

Throws if called by any account other than the guardian.