MezzGuard

Git Source

Inherits: BaseGuard, Initializable, Credentialed, CommonValidation, IMezzGuard

Author: Daniel Yamagata & Jerry Qi & Naveen Ailawadi

A base contract inherited by guards used in Mezzanine. A 'Guard' refers to Safe Guards.

Mezzanine guards are set up such that adding, swapping, or removing owners, setting a guard, or enabling a module is disabled via the multi-signature funcitonality of the 'controlled'. Instead, particular functions in departments and the treasury must be used to access these functions. Specifically, access control is managed such that only an 'ancestor' or governance can call these functions

State Variables

MezzGuardStorageLocation

bytes32 private constant MezzGuardStorageLocation = 0xe3d6cd3491c5540f279d53d4dae5705fec2cdb498a14a972c3514ce2c3f77200;

Functions

_getMezzGuardStorage

function _getMezzGuardStorage() internal pure returns (MezzGuardStorage storage $);

constructor

constructor();

onlyController

init

Initializes the Mezz Guard's state. Sets the defaults from the deployer

Mezz Guards are initialized atomically as they are deployed

Parameters

Name
Type
Description

initControlled

address

initController

address

contractListDefaults

address[]

The default contracts to add to the contract list

selectorListDefaults

DataTypes.GuardSelector[]

The default selectors to add to the selector list

<none>

bytes

__MezzGuard_init

Initializes the Mezz Guard's state. Sets the defaults from the deployer

addSelectorToList

Adds a guard selector to the selector list, which will either enable or disable the function to be called by 'controlled'. A guard selector is made up of an address and a function selector

Parameters

Name
Type
Description

selectorToAdd

DataTypes.GuardSelector

The contract address and function selector pair to be added to the list

_addSelectorToList

Adds the selector to the list. Updates the index for the selector. Reverts if the selector is already on the list

removeSelectorFromList

Removes a guard selector from the selector list, which will either enable or disable the function to be called by 'controlled'. A guard selector is made up of an address and a function selector.

Parameters

Name
Type
Description

selectorToRemove

DataTypes.GuardSelector

A contract address and function selector pair to be removed from the list

addContractToList

Adds a contract to the contract list, which will either enable or disable the function to be called by 'controlled'

_addContractToList

Adds the contract to the list. Reverts if the contract is already on the list

removeContractFromList

Removes a contract from the contract list. Any contract removed from the list will be either enabled or disabled for the 'controlled' to interact with depending on whether the guard is a whitelist or blacklist guard, respectively. This is true no matter the function selector

onList

Returns true if '_to' or the function selector of '_data' for '_to' is on either the contract list or selector list. Otherwise, returns false.

checkAfterExecution

Called by a Safe after the execution of a transaction. Reverts if the transaction failed

Reference: https://github.com/safe-global/safe-smart-account/blob/f03dfae65fd1d085224b00a10755c509a4eaacfe/contracts/Safe.sol#L215-L217

checkModuleTransaction

Safe modules are always disabled in the initial version of Mezzanine

getSelectorList

Returns the selectors list which may either be whitelisted or blacklisted depending on the guard

getContractList

Returns the contracts list which may be either whitelisted or blacklisted depending on the guard

getControlled

Returns

Name
Type
Description

<none>

address

The controlled, which is a team whose guard is likely to be 'this'

getController

Returns

Name
Type
Description

<none>

address

The address which has admin control over the guard. The 'controller' can add or remove functions on both the '_selectorList' and '_contractList'.

coreId

Returns the coreId of the implementation as a bytes32

The core ID is the keccak256 hash of the contract name followed by a version under the following syntax: "mezzanine.coreId.ContractName.vX" For example, the core ID of the 2nd version of the Treasury would be the following: keccak256(abi.encodePacked("mezzanine.coreId.Treasury.v2"))

version

Returns the version of the implementation as a uint256

supportsInterface

ERC165 support

_checkTransaction

*Reverts under the following scenarios:

  • The '_operation' is a delegate call

  • The '_data' is an add owner, remove owner, or swap owner on the msg.sender

  • The '_data' is a set guard

  • The '_data' is to enable a module*

_onSelectorList

Returns true if the index of '_listInfo' is not 0, false otherwise

_onContractList

Returns true if the '_to' is on the '_contractList', false otherwise

_validateCallerIsController

Validates that the caller is '__controller();

__controller

Returns the '_controller'. Can be overridden to return an arbitrary address

Structs

MezzGuardStorage

Last updated