StagedProposalProcessor API

The contracts are currently being audited, DO NOT USE IN PRODUCTION.

Core

StagedProposalProcessor

Functions
ProtocolVersion
DaoAuthorizableUpgradeable
ProposalUpgradeable
Errors

initialize(contract IDAO _dao, address _trustedForwarder, struct StagedProposalProcessor.Stage[] _stages, bytes _pluginMetadata, struct IPlugin.TargetConfig _targetConfig) external

Initializes the component.

This method is required to support [ERC-1822](https://eips.ethereum.org/EIPS/eip-1822).

updateStages(struct StagedProposalProcessor.Stage[] _stages) external

Allows to update stage configuration.

Requires the caller to have the UPDATE_STAGES_PERMISSION_ID permission. Reverts if the provided _stages array is empty.

reportProposalResult(uint256 _proposalId, uint16 _stageId, enum StagedProposalProcessor.ResultType _resultType, bool _tryAdvance) external

Reports and records the result for a proposal at a specific stage.

This function can be called by any address even if it is not included in the stage configuration. _canProposalAdvance function ensures that only records from addresses in the stage configuration are used. If _tryAdvance is true, the proposal will attempt to advance to the next stage if eligible. Requires the caller to have the EXECUTE_PERMISSION_ID permission to execute the final stage.

customProposalParamsABI() → string external

The human-readable abi format for extra params included in data of createProposal.

This plugin inherits from IProposal, requiring an override for this function.

setTrustedForwarder(address _forwarder) public

Sets a new trusted forwarder address.

Requires the caller to have the SET_TRUSTED_FORWARDER_PERMISSION_ID permission.

createProposal(bytes _metadata, struct Action[] _actions, uint128 _allowFailureMap, uint64 _startDate, bytes[][] _proposalParams) → uint256 proposalId public

Creates a new proposal in this StagedProposalProcessor plugin.

Requires the caller to have the CREATE_PROPOSAL_PERMISSION_ID permission. Also creates proposals for non-manual bodies in the first stage of the proposal process.

createProposal(bytes _metadata, struct Action[] _actions, uint64 _startDate, uint64, bytes _data) → uint256 proposalId public

Creates a new proposal.

Calls a public function that requires the CREATE_PERMISSION_ID permission.

advanceProposal(uint256 _proposalId) public

Advances the specified proposal to the next stage if allowed.

This function checks whether the proposal exists and can advance based on its current state. If the proposal is in the final stage, the caller must have the EXECUTE_PERMISSION_ID permission to execute it.

cancel(uint256 _proposalId) public

Cancels the proposal.

The proposal can be canceled only if it’s allowed in the stage configuration. The caller must have the CANCEL_PERMISSION_ID permission to cancel it.

edit(uint256 _proposalId, bytes _metadata, struct Action[] _actions) public

Edits the proposal.

The proposal can be editable only if it’s allowed in the stage configuration. The caller must have the EDIT_PERMISSION_ID permission to cancel it and stage must be advanceable.

execute(uint256 _proposalId) public

Executes a proposal.

Requires the EXECUTE_PERMISSION_ID permission.

supportsInterface(bytes4 _interfaceId) → bool public

Checks if this or the parent contract supports an interface by its ID.

canProposalAdvance(uint256 _proposalId) → bool public

Determines whether the specified proposal can be advanced to the next stage.

Reverts if the proposal with the given _proposalId does not exist.

canExecute(uint256 _proposalId) → bool public

Checks if a proposal can be executed.

state(uint256 _proposalId) → enum StagedProposalProcessor.ProposalState public

Current state of a proposal.

getTrustedForwarder() → address public

Retrieves the address of the trusted forwarder.

getProposal(uint256 _proposalId) → struct StagedProposalProcessor.Proposal public

Retrieves all information associated with a proposal by its ID.

getBodyResult(uint256 _proposalId, uint16 _stageId, address _body) → enum StagedProposalProcessor.ResultType public

Retrieves the result type submitted by a body for a specific proposal and stage.

getBodyProposalId(uint256 _proposalId, uint16 _stageId, address _body) → uint256 public

Retrieves the sub proposal id.

getCurrentConfigIndex() → uint16 public

Retrieves the current configuration index at which the current configurations of stages are stored.

getStages(uint256 _index) → struct StagedProposalProcessor.Stage[] public

Retrieves the stages stored on the _index in the stages configuration.

getCreateProposalParams(uint256 _proposalId, uint16 _stageId, uint256 _index) → bytes public

Retrieves the data parameter encoded for a sub-body’s createProposal function in a specific stage. Excludes sub-bodies from the first stage, as their parameters are not stored for efficiency.

getProposalTally(uint256 _proposalId, uint16 _stageId) → uint256 approvals, uint256 vetoes public

Calculates and retrieves the number of approvals and vetoes for a proposal on the stage.

hasSucceeded(uint256 _proposalId) → bool public

Whether proposal succeeded or not.

Note that this must not include time window checks and only make a decision based on the thresholds.

hasExecutePermission(address _account) → bool public

Checks whether the caller has the required permission to execute a proposal at the last stage.

hasAdvancePermission(address _account) → bool public

Checks whether the caller has the required permission to advance a proposal.

_updateStages(struct StagedProposalProcessor.Stage[] _stages) internal

Internal function to update stage configuration.

It’s a caller’s responsibility not to call this in case _stages are empty. This function can not be overridden as it’s crucial to not allow duplicating bodies in the same stage, because proposal creation and report functions depend on this assumption.

_executeProposal(uint256 _proposalId) internal

Internal function that executes the proposal’s actions.

_processProposalResult(uint256 _proposalId, uint16 _stageId, enum StagedProposalProcessor.ResultType _resultType) internal

Records the result by the caller.

Assumes that bodies are not duplicated in the same stage. See _updateStages function.

_createBodyProposals(uint256 _proposalId, uint16 _stageId, uint64 _startDate, bytes[] _stageProposalParams) internal

Creates proposals on the non-manual bodies of the stageId.

Assumes that bodies are not duplicated in the same stage. See _updateStages function.

_advanceProposal(uint256 _proposalId) internal

Advances a proposal to the next stage or executes it if it is in the final stage.

Assumes the proposal is eligible to advance. If the proposal is not in the final stage, it creates proposals for the sub-bodies in the next stage. If the proposal is in the final stage, it triggers execution.

_setTrustedForwarder(address _forwarder) internal

Sets a new trusted forwarder address and emits the event.

_getProposalTally(uint256 _proposalId, uint16 _stageId) → uint256 approvals, uint256 vetoes internal

Internal function to calculate and retrieve the number of approvals and vetoes for a proposal in the _stageId.

Assumes that bodies are not duplicated in the same stage. See _updateStages function. This function ensures that only records from addresses in the stage configuration are used.

_msgSender() → address internal

Retrieves the original sender address, considering if the call was made through a trusted forwarder.

If the msg.sender is the trusted forwarder, extracts the original sender from the calldata.

_thresholdsMet(uint256 _proposalId, uint16 _stageId, uint256 _approvalThreshold, uint256 _vetoThreshold) → bool internal

Internal helper function that decides if the stage’s thresholds are satisfied.

_encodeStateBitmap(enum StagedProposalProcessor.ProposalState _proposalState) → bytes32 internal

Encodes a ProposalState into a bytes32 representation where each bit enabled corresponds the underlying position in the ProposalState enum.

ProposalAdvanced(uint256 indexed proposalId, uint16 indexed stageId) event

Emitted when the proposal is advanced to the next stage.

ProposalCanceled(uint256 indexed proposalId, uint16 indexed stageId, address indexed sender) event

Emitted when the proposal gets cancelled.

ProposalEdited(uint256 indexed proposalId, uint16 indexed stageId, address indexed sender, bytes metadata, struct Action[] actions) event

Emitted when the proposal gets edited.

ProposalResultReported(uint256 indexed proposalId, uint16 indexed stageId, address indexed body) event

Emitted when a body reports results by calling reportProposalResult.

SubProposalCreated(uint256 indexed proposalId, uint16 indexed stageId, address indexed body, uint256 bodyProposalId) event

Emitted when this plugin successfully creates a proposal on sub-body.

SubProposalNotCreated(uint256 indexed proposalId, uint16 indexed stageId, address indexed body, bytes reason) event

Emitted when this plugin fails in creating a proposal on sub-body.

StagesUpdated(struct StagedProposalProcessor.Stage[] stages) event

Emitted when the stage configuration is updated for a proposal process.

TrustedForwarderUpdated(address indexed forwarder) event

Emitted when the trusted forwarder is updated.

StagedProposalProcessorSetup

Release 1, Build 1

Errors
PluginUpgradeableSetup

constructor() public

Constructs the PluginUpgradeableSetup by storing the SPP implementation address.

The implementation address is used to deploy UUPS proxies referencing it and to verify the plugin on the respective block explorers.

prepareInstallation(address _dao, bytes _installationParams) → address spp, struct IPluginSetup.PreparedSetupData preparedSetupData external

Prepares the installation of a plugin.

prepareUpdate(address _dao, uint16 _fromBuild, struct IPluginSetup.SetupPayload _payload) → bytes, struct IPluginSetup.PreparedSetupData external

Prepares the update of a plugin.

The default implementation for the initial build 1 that reverts because no earlier build exists.

prepareUninstallation(address _dao, struct IPluginSetup.SetupPayload _payload) → struct PermissionLib.MultiTargetPermission[] permissions external

Prepares the uninstallation of a plugin.

CONDITION_IMPLEMENTATION() → address public

The address of the condition implementation contract.

SPPRuleCondition

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

Events
RuledCondition

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

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

initialize(address _dao, struct RuledCondition.Rule[] _rules) public

Initializes the component.

isGranted(address _where, address _who, bytes32 _permissionId, bytes) → bool isPermitted external

Checks if a call is permitted.

_updateRules(struct RuledCondition.Rule[] _rules) internal

Internal function that updates the rules.

updateRules(struct RuledCondition.Rule[] _rules) public

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

UPDATE_RULES_PERMISSION_ID() → bytes32 public

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

Permissions

bytes32 CREATE_PROPOSAL_PERMISSION_ID internal constant

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

bytes32 SET_TRUSTED_FORWARDER_PERMISSION_ID internal constant

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

bytes32 UPDATE_STAGES_PERMISSION_ID internal constant

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

bytes32 EXECUTE_PROPOSAL_PERMISSION_ID internal constant

The ID of the permission required to execute the proposal if it’s on the last stage.

It is important to use a different identifier than {keccak256("EXECUTE_PERMISSION")} to ensure that it can still be granted with ANY_ADDR. Refer to the DAO.sol function - {isPermissionRestrictedForAnyAddr} for more details.

bytes32 EXECUTE_PERMISSION_ID internal constant

The ID of the permission required to execute the proposal on the dao.

bytes32 CANCEL_PERMISSION_ID internal constant

The ID of the permission required to cancel the proposal.

bytes32 ADVANCE_PERMISSION_ID internal constant

The ID of the permission required to advance the proposal.

bytes32 EDIT_PERMISSION_ID internal constant

The ID of the permission required to edit the proposal.

bytes32 UPDATE_RULES_PERMISSION_ID internal constant

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

bytes32 SET_TARGET_CONFIG_PERMISSION_ID internal constant

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

bytes32 SET_METADATA_PERMISSION_ID internal constant

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