Methods

The operations that can be performed on the ProposalManager contract are listed here.

Read Operations

function list(bytes32[] calldata proposalIds) external view returns(Proposal[] memory);

Pass one or more Proposal ids in this function for it to return, for each passed id, its Proposal struct containing the Proposal data.

function votes(bytes32[] calldata proposalIds, address[] calldata voters, bytes32[][] calldata items) external view returns(uint256[][] memory accepts, uint256[][] memory refuses);

Pass one or more Proposal ids, one or more voter addresses and an array of bytes32 tokens in this function for it to retrieve the number of accept and refuse votes for each Proposal. The bytes32 key is defined as: bytes32 item = keccak256(abi.encode(proposalId, proposalVote.collections[z], proposalVote.objectIds[z]));

function weight(bytes32 code) external view returns(uint256);

Pass the bytes32 key that corresponds to a proposalId, _collection and objectId in this function for it to retrieve the weight amount of the token (objectId). The bytes32 key is defined as: bytes32 key = keccak256(abi.encodePacked(proposalId, collections[z],objectIds[z]));

function configuration() external view returns(ProposalConfiguration memory);

Retrieve the governance rules defined by the ProposalConfiguration struct.

function lastProposalId() external view returns(bytes32);

Retrieve the last Proposal id created by the Proposal Manager.

function lastVoteBlock(address voter) external view returns (uint256);

Retrieve the last block where a vote is sent by a user.

Write Operations

function batchCreate(ProposalCodes[] calldata codeSequences) external returns(bytes32[] memory createdProposalIds);

This function is used to create a Proposal. It takes a ProposalCodes, i.e. an array of ProposalCode, and returns the id of the created proposal.

function vote(address erc20Address, bytes memory permitSignature, bytes32 proposalId, uint256 accept, uint256 refuse, address voter, bool terminate) external;

This function is used to vote with an ERC20 token. Pass the tokenAddress, the eventual permit signature (if you want to use the Permit operation), the id of the Proposal to vote in, the number of accept votes and refuse votes, the address of the voter (which can be different from the address of the msg.sender) and the terminate bool, which indicates if, after the vote, the terminate function should be called on the Proposal.

function batchVote(bytes[] calldata data) external payable;

This function is used to vote in batch mode using ERC20 tokens. Each element in the bytes[] data array must contain the tokenAddress, the eventual permit signature (if you want to use the Permit operation), the id of the Proposal to vote in, the number of accept votes and refuse votes, the address of the voter (which can be different from the address of the msg.sender) and the terminate bool, which indicates if, after the vote, the terminate function should be called on the Proposal.

function withdrawAll(bytes32[] memory proposalIds, address voterOrReceiver, bool afterTermination) external;

This function is used to withdraw all the votes expressed by an address. It takes as input the ids of the Proposals from which you are withdrawing votes (proposalIds), the address receiver of the withdrawn tokens (voterOrReceiver). If passed as address(0) the msg.sender is taken as receiver. If afterTermination is true, the voterOrReceiver must be populated different from address(0). And a boolean parameter (afterTermination) that represents if the Proposals from which you are withdrawing votes are terminated, i.e. can no longer be voted (true) or not (false).

function terminate(bytes32[] calldata proposalIds) external;

This function is used to terminate and eventually execute the code of one or more Proposals, represented by their Proposal ids.

function setConfiguration(ProposalConfiguration calldata newValue) external returns(ProposalConfiguration memory oldValue);

This function can be used to change the current Proposal Manager ProposalConfiguration containing the governance rules. The function takes as input the new ProposalConfiguration struct.

Last updated