Skip to content

RuledCondition ​

Abstract contract · src/common/permission/condition/extensions/RuledCondition.sol

Explained in: RuledCondition (the rule engine)

Author: Aragon X - 2024

Inherits: PermissionConditionUpgradeable

An abstract contract to create conditional permissions using rules.

Functions ​

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[]

isGranted ​

solidity
function isGranted(
    address _where,
    address _who,
    bytes32 _permissionId,
    bytes _data
) 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.
_databytesOptional data passed to the PermissionCondition implementation.
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.

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.

Enums ​

Op ​

solidity
enum Op {
    NONE,
    EQ,
    NEQ,
    GT,
    LT,
    GTE,
    LTE,
    RET,
    NOT,
    AND,
    OR,
    XOR,
    IF_ELSE
}
OptionValue
NONE0
EQ1
NEQ2
GT3
LT4
GTE5
LTE6
RET7
NOT8
AND9
OR10
XOR11
IF_ELSE12

Structs ​

Rule ​

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