Skip to content

SPPRuleCondition ​

Contract · src/utils/SPPRuleCondition.sol

Explained in: Staged Proposal Processor (SPP)

Author: Aragon X - 2024

Inherits: DaoAuthorizableUpgradeable, RuledCondition

The SPP Condition that must be granted for createProposal function of StagedProposalProcessor.

Dev: This contract must be deployed either with clonable or new keyword.

Constructor ​

constructor ​

solidity
constructor(address _dao, RuledCondition.Rule[] _rules)

Disables the initializers on the implementation contract to prevent it from being left uninitialized.

oz-upgrades-unsafe-allow: constructor

ParameterTypeDescription
_daoaddress
_rulesRuledCondition.Rule[]

Functions ​

dao ​

solidity
function dao() external view returns (IDAO)

Selector: 0x4162169f

Returns the DAO contract.

decodeRuleValue ​

solidity
function decodeRuleValue(uint256 _x) external pure returns (uint32 a, uint32 b, uint32 c)

Selector: 0x1498b514

Decodes rule indices into three uint32.

ParameterTypeDescription
_xuint256The value to decode.
ReturnsTypeDescription
auint32The first 32-bit segment.
buint32The second 32-bit segment.
cuint32The third 32-bit segment.

encodeIfElse ​

solidity
function encodeIfElse(
    uint256 startingRuleIndex,
    uint256 successRuleIndex,
    uint256 failureRuleIndex
) external pure returns (uint240)

Selector: 0x23e8cefc

Encodes rule indices into a uint240 value.

ParameterTypeDescription
startingRuleIndexuint256The index of the starting rule to evaluate.
successRuleIndexuint256The index of the rule to evaluate if the evaluation of startingRuleIndex was true.
failureRuleIndexuint256The index of the rule to evaluate if the evaluation of startingRuleIndex was false.

encodeLogicalOperator ​

solidity
function encodeLogicalOperator(
    uint256 ruleIndex1,
    uint256 ruleIndex2
) external pure returns (uint240)

Selector: 0xd09e5361

Encodes two rule indexes into a uint240 value. Useful for logical operators such as AND/OR/XOR and others.

ParameterTypeDescription
ruleIndex1uint256The first index to evaluate.
ruleIndex2uint256The second index to evaluate.

getRules ​

solidity
function getRules() external view returns (RuledCondition.Rule[])

Selector: 0x45e2984a

Retrieves the current rules stored in this contract.

ReturnsTypeDescription
[0]RuledCondition.Rule[]

initialize ​

solidity
function initialize(address _dao, RuledCondition.Rule[] _rules) external

Selector: 0xe87c7fa8

Initializes the component.

ParameterTypeDescription
_daoaddressThe IDAO interface of the associated DAO.
_rulesRuledCondition.Rule[]The rules that decide who can create a proposal on StagedProposalProcessor.

isGranted ​

solidity
function isGranted(
    address _where,
    address _who,
    bytes32 _permissionId,
    bytes
) external view returns (bool isPermitted)

Selector: 0x2675fdd0

Checks if a call is permitted.

ParameterTypeDescription
_whereaddressThe address of the target contract.
_whoaddressThe address (EOA or contract) for which the permissions are checked.
_permissionIdbytes32The permission identifier.
[3]bytes
ReturnsTypeDescription
isPermittedboolReturns true if the call is permitted.

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.

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.
ReturnsTypeDescription
[0]boolReturns true if the interface is supported.

updateRules ​

solidity
function updateRules(RuledCondition.Rule[] _rules) external

Selector: 0x8306b5f1

Updates the rules that will be used as a check upon proposal creation on StagedProposalProcessor.

ParameterTypeDescription
_rulesRuledCondition.Rule[]The rules that decide who can create a proposal on StagedProposalProcessor.

Events ​

Initialized ​

solidity
event Initialized(uint8 version)

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

RulesUpdated ​

solidity
event RulesUpdated(RuledCondition.Rule[] rules)

Emitted when the rules are updated.

ParameterTypeDescription
rulesRuledCondition.Rule[]The new rules that replaces old rules.

Errors ​

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.

Constants ​

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

UPDATE_RULES_PERMISSION_ID ​

solidity
bytes32 public constant UPDATE_RULES_PERMISSION_ID = keccak256("UPDATE_RULES_PERMISSION");

Value: 0xd3d98e95f3486fc234d80c098cf0d2a0a3fb187833d7e9cc930f8c4f8335a0e7

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

Enums ​

Op ​

Inherited from RuledCondition.

solidity
enum Op {
    NONE,
    EQ,
    NEQ,
    GT,
    LT,
    GTE,
    LTE,
    RET,
    NOT,
    AND,
    OR,
    XOR,
    IF_ELSE
}

Represents various operations that can be performed in a rule.

OptionValueDescription
NONE0No operation.
EQ1Equal to operation.
NEQ2Not equal to operation.
GT3Greater than operation.
LT4Less than operation.
GTE5Greater than or equal to operation.
LTE6Less than or equal to operation.
RET7Return the evaluation result.
NOT8Logical NOT operation.
AND9Logical AND operation.
OR10Logical OR operation.
XOR11Logical XOR operation.
IF_ELSE12Conditional evaluation with IF-ELSE logic.

Structs ​

Rule ​

Inherited from RuledCondition.

solidity
struct Rule {
    uint8 id;
    uint8 op;
    uint240 value;
    bytes32 permissionId;
}

Represents a rule used in the condition contract.

FieldTypeDescription
iduint8The ID representing the identifier of the rule.
opuint8The operation to apply, as defined in the Op enum.
valueuint240The value associated with this rule, which could be an address, timestamp, etc.
permissionIdbytes32The specific permission ID to use for evaluating this rule. If set to 0x, the passed permission ID will be used.