_hostIsProposalCommand paramater

The boolean parameter _hostIsProposalCommand is set as true or false at the time of Proposal Manager initialization.

This parameter indicates whether the Proposal Manager's host address is a smart contract that implements the IExternalProposalsManagerCommands interface and has methods that override some of those of the Proposal Manager to create custom logic (_hostIsProposalCommand is true) or not (_hostIsProposalCommand is false). The IExternalProposalsManagerCommands interface is in the IProposalsManager.sol contract.

Why this possibility of customization?

The Proposal Manager is a Component that can be used by multiple types of on-chain organizations such as Root Layers and subDAOs (which make up the Governance Layer). However, different types of organizations may have different requirements and need to integrate custom logic into the Proposal Manager.

If _hostIsProposalCommand is true, the contract that hosts the Proposal Manager must implement the following three methods provided by IExternalProposalsManagerCommands:

  • createProposalCodeSequence

  • proposalCanBeFinalized

  • isVotable

The first one is called in the Proposal Manager's batchCreate function and allows to create custom logic when a Proposal is created:

_hostIsProposalCommand ? IExternalProposalsManagerCommands(host).createProposalCodeSequence(proposalId, proposalCodes.codes, msg.sender) :
(ProposalsManagerLibrary.createCodeSequence(proposalCodes.codes), standardConfiguration);

The second is called at voting and vote withdrawal time and defines whether the Proposal can still be voted or not according to custom logic:

if(_hostIsProposalCommand) {
    bytes memory response = IExternalProposalsManagerCommands(host).isVotable(proposalId, proposal, from, voter, voteOrWithtraw);
    if(response.length > 0) {
        return abi.decode(response, (bool));
    }

The third is called at termination time and defines if the Proposal can be finalized or not according to custom logic:

if(_hostIsProposalCommand) {
    proposal.terminationBlock = IExternalProposalsManagerCommands(host).proposalCanBeFinalized(proposalId, proposal, validationPassed, result) ? block.number : proposal.terminationBlock;
    return;
}

Examples

In a Root Layer, _hostIsProposalCommand is passed as false.The host of the Proposal Manager is the Organization contract (i.e., the Root Layer itself) which does not import IExternalProposalsManagerCommands. Consequently, the operation of the Proposal Manager in a Root Layer follows the standard operation.

In a subDAO, _hostIsProposalCommand is passed as true. The Proposal Manager host is the subDAO contract that imports IExternalProposalsManagerCommands.

A subDAO presents custom logic concerning a Root Layer; in particular, it allows for creating Proposals starting from pre-defined Proposal models. In fact, in a subDAO, it is not possible to write from scratch the code of a Proposal because the Proposals that users can create are only those provided by the models. Moreover, the Surveyless Proposals of the subDAO are perpetual; they never end, and once they reach a certain hard cap, they can be triggered to make the voted change.

The subDAO contract has the three methods of the IExternalProposalsManagerCommands described above:

  • createProposalCodeSequence -> is used to create the Proposal from a Proposal model. codeSequenceInput.location contains the modelIndex of the model and codeSequenceInput.bytecode contains the preset values and/or initialization data of the Proposal.

  • isVotable -> used to define that a surveyless Proposal, i.e., Proposals with pre-set values, is always votable because it is perpetual, and voters can always make the withdrawal of votes.

  • proposalCanBeFinalized -> used to define that a surveyless Proposal can be finalized, i.e., the code must be executed, and the change triggered but it must never end because it is perpetual. In contrast, a survey, when triggered, must end.

All this logic is already implemented in the subDAO contract.

Last updated