Skip to content

PluginUUPSUpgradeable ​

Abstract contract · src/lib/PluginUUPSUpgradeable.sol

Author: Aragon X - 2022-2024

Inherits: IPlugin, ERC165Upgradeable, UUPSUpgradeable, DaoAuthorizableUpgradeable, ProtocolVersion

An abstract, upgradeable contract to inherit from when creating a plugin being deployed via the UUPS pattern (see ERC-1822).

security-contact: sirt@aragon.org

Functions ​

dao ​

solidity
function dao() external view returns (IDAO)

Selector: 0x4162169f

Returns the DAO contract.

getCurrentTargetConfig ​

solidity
function getCurrentTargetConfig() external view returns (IPlugin.TargetConfig)

Selector: 0xc98425ee

Returns the currently set target contract.

ReturnsTypeDescription
[0]IPlugin.TargetConfig

getTargetConfig ​

solidity
function getTargetConfig() external view returns (IPlugin.TargetConfig)

Selector: 0xdd63c06f

A convenient function to get current target config only if its target is not address(0), otherwise dao().

ReturnsTypeDescription
[0]IPlugin.TargetConfig

implementation ​

solidity
function implementation() external view returns (address)

Selector: 0x5c60da1b

Returns the address of the implementation contract in the proxy storage slot slot the UUPS proxy is pointing to.

pluginType ​

solidity
function pluginType() external pure returns (IPlugin.PluginType)

Selector: 0x41de6830

Returns the plugin's type

ReturnsTypeDescription
[0]IPlugin.PluginType

protocolVersion ​

solidity
function protocolVersion() external pure returns (uint8[3])

Selector: 0x2ae9c600

Returns the semantic Aragon OSx protocol version number that the implementing contract is associated with.

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.

ReturnsTypeDescription
[0]uint8[3]Returns the semantic Aragon OSx protocol version number.

proxiableUUID ​

solidity
function proxiableUUID() external view returns (bytes32)

Selector: 0x52d1902d

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.

setTargetConfig ​

solidity
function setTargetConfig(IPlugin.TargetConfig _targetConfig) external

Selector: 0xbb225da2

Dev: Sets the target to a new target (newTarget). The caller must have the SET_TARGET_CONFIG_PERMISSION_ID permission.

ParameterTypeDescription
_targetConfigIPlugin.TargetConfigThe target Config containing the address and operation type.

supportsInterface ​

solidity
function supportsInterface(bytes4 _interfaceId) external view returns (bool)

Selector: 0x01ffc9a7

Checks if an interface is supported by this or its parent contract.

ParameterTypeDescription
_interfaceIdbytes4The ID of the interface.

upgradeTo ​

solidity
function upgradeTo(address newImplementation) external

Selector: 0x3659cfe6

Dev: Upgrade the implementation of the proxy to newImplementation.

Calls {_authorizeUpgrade}.

Emits an {Upgraded} event.

oz-upgrades-unsafe-allow-reachable: delegatecall

upgradeToAndCall ​

solidity
function upgradeToAndCall(address newImplementation, bytes data) external payable

Selector: 0x4f1ef286

Dev: Upgrade the implementation of the proxy to newImplementation, and subsequently execute the function call encoded in data.

Calls {_authorizeUpgrade}.

Emits an {Upgraded} event.

oz-upgrades-unsafe-allow-reachable: delegatecall

Events ​

AdminChanged ​

solidity
event AdminChanged(address previousAdmin, address newAdmin)

Dev: Emitted when the admin account has changed.

BeaconUpgraded ​

solidity
event BeaconUpgraded(address indexed beacon)

Dev: Emitted when the beacon is changed.

Initialized ​

solidity
event Initialized(uint8 version)

Dev: Triggered when the contract has been initialized or reinitialized.

TargetSet ​

solidity
event TargetSet(IPlugin.TargetConfig newTargetConfig)

Emitted each time the TargetConfig is set.

ParameterTypeDescription
newTargetConfigIPlugin.TargetConfig

Upgraded ​

solidity
event Upgraded(address indexed implementation)

Dev: Emitted when the implementation is upgraded.

Errors ​

AlreadyInitialized ​

solidity
error AlreadyInitialized()

Thrown when initialize is called after it has already been executed.

DaoUnauthorized ​

solidity
error DaoUnauthorized(address dao, address where, address who, bytes32 permissionId)

Thrown if a call is unauthorized in the associated DAO.

ParameterTypeDescription
daoaddressThe associated DAO.
whereaddressThe context in which the authorization reverted.
whoaddressThe address (EOA or contract) missing the permission.
permissionIdbytes32The permission identifier.

DelegateCallFailed ​

solidity
error DelegateCallFailed()

Thrown when delegatecall fails.

InvalidTargetConfig ​

solidity
error InvalidTargetConfig(IPlugin.TargetConfig targetConfig)

Thrown when target is of type 'IDAO', but operation is delegateCall.

ParameterTypeDescription
targetConfigIPlugin.TargetConfigThe target config to update it to.

Constants ​

Public, so each is also readable through a generated getter.

SET_TARGET_CONFIG_PERMISSION_ID ​

solidity
bytes32 public constant SET_TARGET_CONFIG_PERMISSION_ID =
        keccak256("SET_TARGET_CONFIG_PERMISSION");

Value: 0x568cc693d84eb1901f8bcecba154cbdef23ca3cf67efc0a0b698528a06c660f7

The ID of the permission required to call the setTargetConfig function.

UPGRADE_PLUGIN_PERMISSION_ID ​

solidity
bytes32 public constant UPGRADE_PLUGIN_PERMISSION_ID = keccak256("UPGRADE_PLUGIN_PERMISSION");

Value: 0x821b6e3a557148015a918c89e5d092e878a69854a2d1a410635f771bd5a8a3f5

The ID of the permission required to call the _authorizeUpgrade function.

Enums ​

Operation ​

Inherited from IPlugin.

solidity
enum Operation {
    Call,
    DelegateCall
}

Specifies the type of operation to perform.

OptionValue
Call0
DelegateCall1

PluginType ​

Inherited from IPlugin.

solidity
enum PluginType {
    UUPS,
    Cloneable,
    Constructable
}

Types of plugin implementations available within OSx.

OptionValue
UUPS0
Cloneable1
Constructable2

Structs ​

TargetConfig ​

Inherited from IPlugin.

solidity
struct TargetConfig {
    address target;
    IPlugin.Operation operation;
}

Configuration for the target contract that the plugin will interact with, including the address and operation type.

Dev: By default, the plugin typically targets the associated DAO and performs a Call operation. However, this configuration allows the plugin to specify a custom executor and select either Call or DelegateCall based on the desired execution context.

FieldTypeDescription
targetaddressThe address of the target contract, typically the associated DAO but configurable to a custom executor.
operationIPlugin.OperationThe type of operation (Call or DelegateCall) to execute on the target, as defined by Operation.