Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/contracts/contracts/Zengo.sol
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ contract ZengoDAO is Constants, ZengoStorage, GStates, PermissionsEnumerable, Co
newProposal.votingIterationCount = 0;
newProposal.verificationState = Structs.VerificationState(0);
newProposal.streetAddress = _streetAddress;
newProposal.createdAt = block.timestamp;
newProposal.latitude = _latitude;
newProposal.longitude = _longitude;
proposalEvidence[GOVERNANCE_CYCLE][proposalCount] = newEvidence;
Expand Down
1 change: 1 addition & 0 deletions apps/contracts/contracts/lib/Structs.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ library Structs {
address proposer;
uint8 votingIterationCount;
uint256 proposalId;
uint256 createdAt;
int256 latitude;
int256 longitude;
string title;
Expand Down
137 changes: 41 additions & 96 deletions apps/contracts/contracts/storage/ZengoStorage.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,17 @@ contract ZengoStorage {
mapping(address => Structs.Moderator) public moderatorStruct;

mapping(uint256 => mapping(address => uint256)) public votingPoints;
mapping(uint256 => mapping(uint256 => Structs.Vote[]))
public voteIterations;

mapping(uint256 => mapping(uint256 => Structs.Evidence))
public proposalEvidence;
mapping(uint256 => mapping(uint256 => mapping(uint8 => Structs.Evidence[])))
public votingIterationEvidence;

mapping(uint256 => mapping(uint256 => mapping(uint8 => mapping(address => Structs.VerificationState))))
public vote;
mapping(uint256 => mapping(uint256 => mapping(uint8 => mapping(address => bool))))
public hasVoted;
mapping(uint256 => mapping(uint256 => mapping(uint8 => mapping(Structs.VerificationState => uint256))))
public voteCount;

function getModeratorInfo(
address _moderator
) public view returns (Structs.Moderator memory) {
mapping(uint256 => mapping(uint256 => Structs.Vote[])) public voteIterations;

mapping(uint256 => mapping(uint256 => Structs.Evidence)) public proposalEvidence;
mapping(uint256 => mapping(uint256 => mapping(uint8 => Structs.Evidence[]))) public votingIterationEvidence;

mapping(uint256 => mapping(uint256 => mapping(uint8 => mapping(address => Structs.VerificationState)))) public vote;
mapping(uint256 => mapping(uint256 => mapping(uint8 => mapping(address => bool)))) public hasVoted;
mapping(uint256 => mapping(uint256 => mapping(uint8 => mapping(Structs.VerificationState => uint256)))) public
voteCount;

function getModeratorInfo(address _moderator) public view returns (Structs.Moderator memory) {
require(moderators[_moderator], "Given address is not a Moderator");
return moderatorStruct[_moderator];
}
Expand All @@ -50,32 +43,21 @@ contract ZengoStorage {
}

function getModerators() public view returns (Structs.Moderator[] memory) {
Structs.Moderator[]
memory moderatorsStructArray = new Structs.Moderator[](
Structs.Moderator[] memory moderatorsStructArray = new Structs.Moderator[](
moderatorList.length
);
for (uint256 i = 0; i < moderatorList.length; i++) {
moderatorsStructArray[i].moderatorType = moderatorStruct[
moderatorList[i]
].moderatorType;
moderatorsStructArray[i].position = moderatorStruct[
moderatorList[i]
].position;
moderatorsStructArray[i].organization = moderatorStruct[
moderatorList[i]
].organization;
moderatorsStructArray[i].moderatorType = moderatorStruct[moderatorList[i]].moderatorType;
moderatorsStructArray[i].position = moderatorStruct[moderatorList[i]].position;
moderatorsStructArray[i].organization = moderatorStruct[moderatorList[i]].organization;
}
return moderatorsStructArray;
}

function getAllProposals()
public
view
returns (
Structs.Proposal[] memory,
Structs.Vote[] memory,
Structs.Evidence[] memory
)
returns (Structs.Proposal[] memory, Structs.Vote[] memory, Structs.Evidence[] memory)
{
Structs.Proposal[] memory proposalsArray = new Structs.Proposal[](
proposalCount + 1
Expand All @@ -90,70 +72,33 @@ contract ZengoStorage {
uint256 eCount = 0;

for (uint256 i = 0; i < proposalCount + 1; i++) {
proposalsArray[i].votingIterationCount = proposals[
GOVERNANCE_CYCLE
][i].votingIterationCount;
proposalsArray[i].proposalId = proposals[GOVERNANCE_CYCLE][i]
.proposalId;
proposalsArray[i].votingIterationCount = proposals[GOVERNANCE_CYCLE][i].votingIterationCount;
proposalsArray[i].proposalId = proposals[GOVERNANCE_CYCLE][i].proposalId;
proposalsArray[i].title = proposals[GOVERNANCE_CYCLE][i].title;
proposalsArray[i].proposalDescription = proposals[GOVERNANCE_CYCLE][
i
].proposalDescription;
proposalsArray[i].proposalType = proposals[GOVERNANCE_CYCLE][i]
.proposalType;
proposalsArray[i].proposer = proposals[GOVERNANCE_CYCLE][i]
.proposer;
proposalsArray[i].isEligibleForFunding = proposals[
GOVERNANCE_CYCLE
][i].isEligibleForFunding;
proposalsArray[i].isVerified = proposals[GOVERNANCE_CYCLE][i]
.isVerified;
proposalsArray[i].verificationState = proposals[GOVERNANCE_CYCLE][i]
.verificationState;
proposalsArray[i].streetAddress = proposals[GOVERNANCE_CYCLE][i]
.streetAddress;
proposalsArray[i].latitude = proposals[GOVERNANCE_CYCLE][i]
.latitude;
proposalsArray[i].longitude = proposals[GOVERNANCE_CYCLE][i]
.longitude;
for (
uint256 j = 0;
j < proposals[GOVERNANCE_CYCLE][i].votingIterationCount;
j++
) {
voteIterationsArray[count].votingIteration = voteIterations[
GOVERNANCE_CYCLE
][i][j].votingIteration;
voteIterationsArray[count].proposalId = voteIterations[
GOVERNANCE_CYCLE
][i][j].proposalId;
voteIterationsArray[count].totalVotes = voteIterations[
GOVERNANCE_CYCLE
][i][j].totalVotes;
voteIterationsArray[count].inProgress = voteIterations[
GOVERNANCE_CYCLE
][i][j].inProgress;
voteIterationsArray[count].resultState = voteIterations[
GOVERNANCE_CYCLE
][i][j].resultState;
proposalsArray[i].proposalDescription = proposals[GOVERNANCE_CYCLE][i].proposalDescription;
proposalsArray[i].proposalType = proposals[GOVERNANCE_CYCLE][i].proposalType;
proposalsArray[i].proposer = proposals[GOVERNANCE_CYCLE][i].proposer;
proposalsArray[i].isEligibleForFunding = proposals[GOVERNANCE_CYCLE][i].isEligibleForFunding;
proposalsArray[i].isVerified = proposals[GOVERNANCE_CYCLE][i].isVerified;
proposalsArray[i].verificationState = proposals[GOVERNANCE_CYCLE][i].verificationState;
proposalsArray[i].streetAddress = proposals[GOVERNANCE_CYCLE][i].streetAddress;
proposalsArray[i].latitude = proposals[GOVERNANCE_CYCLE][i].latitude;
proposalsArray[i].longitude = proposals[GOVERNANCE_CYCLE][i].longitude;
proposalsArray[i].createdAt = proposals[GOVERNANCE_CYCLE][i].createdAt;
for (uint256 j = 0; j < proposals[GOVERNANCE_CYCLE][i].votingIterationCount; j++) {
voteIterationsArray[count].votingIteration = voteIterations[GOVERNANCE_CYCLE][i][j].votingIteration;
voteIterationsArray[count].proposalId = voteIterations[GOVERNANCE_CYCLE][i][j].proposalId;
voteIterationsArray[count].totalVotes = voteIterations[GOVERNANCE_CYCLE][i][j].totalVotes;
voteIterationsArray[count].inProgress = voteIterations[GOVERNANCE_CYCLE][i][j].inProgress;
voteIterationsArray[count].resultState = voteIterations[GOVERNANCE_CYCLE][i][j].resultState;
count++;
for (
uint256 k = 0;
k < voteIterations[GOVERNANCE_CYCLE][i][j].evidenceCount;
k++
) {
evidencesArray[eCount]
.evidenceDescription = votingIterationEvidence[
GOVERNANCE_CYCLE
][i][uint8(j)][k].evidenceDescription;
evidencesArray[eCount]
.evidenceUri = votingIterationEvidence[
GOVERNANCE_CYCLE
][i][uint8(j)][k].evidenceUri;
evidencesArray[eCount]
.evidenceTimestamp = votingIterationEvidence[
GOVERNANCE_CYCLE
][i][uint8(j)][k].evidenceTimestamp;
for (uint256 k = 0; k < voteIterations[GOVERNANCE_CYCLE][i][j].evidenceCount; k++) {
evidencesArray[eCount].evidenceDescription =
votingIterationEvidence[GOVERNANCE_CYCLE][i][uint8(j)][k].evidenceDescription;
evidencesArray[eCount].evidenceUri =
votingIterationEvidence[GOVERNANCE_CYCLE][i][uint8(j)][k].evidenceUri;
evidencesArray[eCount].evidenceTimestamp =
votingIterationEvidence[GOVERNANCE_CYCLE][i][uint8(j)][k].evidenceTimestamp;
eCount++;
}
}
Expand Down