This commit is contained in:
Roman Storm 2020-10-20 23:31:09 -07:00
parent e4f463f876
commit 628a023fc6
No known key found for this signature in database
GPG Key ID: 522F2A785F34E71F

View File

@ -18,16 +18,10 @@ contract GovernanceAggregator {
Governance.ProposalState state; Governance.ProposalState state;
} }
function getAllProposals( function getAllProposals(Governance governance) public view returns (Proposal[] memory proposals) {
Governance governance, proposals = new Proposal[](governance.proposalCount());
uint256 from,
uint256 to
) public view returns (Proposal[] memory proposals) {
uint256 proposalCount = governance.proposalCount();
to = to == 0 ? proposalCount : to;
proposals = new Proposal[](proposalCount);
for (from; from < to; from++) { for (uint256 i = 0; i < proposals.length; i++) {
( (
address proposer, address proposer,
address target, address target,
@ -37,9 +31,9 @@ contract GovernanceAggregator {
uint256 againstVotes, uint256 againstVotes,
bool executed, bool executed,
bool extended bool extended
) = governance.proposals(from); ) = governance.proposals(i + 1);
proposals[from] = Proposal({ proposals[i] = Proposal({
proposer: proposer, proposer: proposer,
target: target, target: target,
startTime: startTime, startTime: startTime,
@ -48,7 +42,7 @@ contract GovernanceAggregator {
againstVotes: againstVotes, againstVotes: againstVotes,
executed: executed, executed: executed,
extended: extended, extended: extended,
state: governance.state(from) state: governance.state(i + 1)
}); });
} }
} }