Skip to content

Commit 46c0dea

Browse files
committed
Add NatSpec for Community Driven Governance, Deploy Governance Rules and Deploy Proposals Manager
1 parent 40f3680 commit 46c0dea

File tree

3 files changed

+435
-155
lines changed

3 files changed

+435
-155
lines changed
+82-31
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,74 @@
1-
/* Description:
2-
* DFO Protocol - Community-Driven Governance.
3-
* This is the well-known Functionality provided by the DFO protocol, which is triggered when a Proposal is finalized (whether it is successful or not).
4-
* In case the Proposal Survey is successful (result value set to true), its proposer will receive an amount of Voting Tokens as a reward.
5-
* The reward amount is initially decided during the DFO Creation and can be changed with a proposal changing the value of the surveySingleReward variable set into the DFO StateHolder.
6-
*/
7-
/* Discussion:
8-
* https://gitcoin.co/grants/154/decentralized-flexible-organization
9-
*/
1+
// SPDX-License-Identifier: BSD-2
2+
103
pragma solidity ^0.6.0;
114

5+
/*
6+
* @title DFO Protocol - Community-Driven Governance.
7+
* @dev This is the well-known Functionality provided by the DFO protocol, which is triggered when a Proposal
8+
* is finalized (whether it is successful or not).
9+
* In case the Proposal Survey is successful (result value set to true), its proposer will receive
10+
* an amount of Voting Tokens as a reward.
11+
* The reward amount is initially decided during the DFO Creation and can be changed with a proposal
12+
* changing the value of the surveySingleReward variable set into the DFO StateHolder.
13+
*/
1214
contract CommunityDrivenGovernance {
13-
1415
string private _metadataLink;
1516

17+
/**
18+
* @dev Contract constructor
19+
* @param metadataLink Link to the metadata of the Proposal
20+
*/
1621
constructor(string memory metadataLink) public {
1722
_metadataLink = metadataLink;
1823
}
1924

20-
function getMetadataLink() public view returns(string memory) {
25+
/**
26+
* @dev GETTER for the metadataLink
27+
* @return metadataLink Link to the metadata of the Proposal
28+
*/
29+
function getMetadataLink()
30+
public
31+
view
32+
returns (string memory metadataLink)
33+
{
2134
return _metadataLink;
2235
}
2336

24-
function onStart(address, address) public {
25-
}
37+
function onStart(address, address) public {}
2638

27-
function onStop(address) public {
28-
}
39+
function onStop(address) public {}
2940

41+
/**
42+
* @dev Trigger for the finalization of a proposal.
43+
* @param proposal Address for the proposal
44+
* @param result
45+
*/
3046
function proposalEnd(address proposal, bool result) public {
31-
if(!result) {
47+
if (!result) {
3248
return;
3349
}
3450
IMVDProxy proxy = IMVDProxy(msg.sender);
35-
if(IMVDFunctionalitiesManager(proxy.getMVDFunctionalitiesManagerAddress()).hasFunctionality("getSurveySingleReward")) {
36-
uint256 surveySingleReward = toUint256(proxy.read("getSurveySingleReward", bytes("")));
37-
if(surveySingleReward > 0) {
38-
proxy.transfer(IMVDFunctionalityProposal(proposal).getProposer(), surveySingleReward, proxy.getToken());
51+
if (
52+
IMVDFunctionalitiesManager(
53+
proxy.getMVDFunctionalitiesManagerAddress()
54+
)
55+
.hasFunctionality("getSurveySingleReward")
56+
) {
57+
uint256 surveySingleReward = toUint256(
58+
proxy.read("getSurveySingleReward", bytes(""))
59+
);
60+
if (surveySingleReward > 0) {
61+
proxy.transfer(
62+
IMVDFunctionalityProposal(proposal).getProposer(),
63+
surveySingleReward,
64+
proxy.getToken()
65+
);
3966
}
4067
}
4168
}
4269

43-
function toUint256(bytes memory bs) private pure returns(uint256 x) {
44-
if(bs.length >= 32) {
70+
function toUint256(bytes memory bs) private pure returns (uint256 x) {
71+
if (bs.length >= 32) {
4572
assembly {
4673
x := mload(add(bs, add(0x20, 0)))
4774
}
@@ -50,21 +77,45 @@ contract CommunityDrivenGovernance {
5077
}
5178

5279
interface IVotingToken {
53-
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
80+
function transferFrom(
81+
address sender,
82+
address recipient,
83+
uint256 amount
84+
) external returns (bool);
5485
}
5586

5687
interface IMVDProxy {
57-
function getToken() external view returns(address);
58-
function getMVDFunctionalitiesManagerAddress() external view returns(address);
59-
function transfer(address receiver, uint256 value, address token) external;
60-
function hasFunctionality(string calldata codeName) external view returns(bool);
61-
function read(string calldata codeName, bytes calldata data) external view returns(bytes memory returnData);
88+
function getToken() external view returns (address);
89+
90+
function getMVDFunctionalitiesManagerAddress()
91+
external
92+
view
93+
returns (address);
94+
95+
function transfer(
96+
address receiver,
97+
uint256 value,
98+
address token
99+
) external;
100+
101+
function hasFunctionality(string calldata codeName)
102+
external
103+
view
104+
returns (bool);
105+
106+
function read(string calldata codeName, bytes calldata data)
107+
external
108+
view
109+
returns (bytes memory returnData);
62110
}
63111

64112
interface IMVDFunctionalityProposal {
65-
function getProposer() external view returns(address);
113+
function getProposer() external view returns (address);
66114
}
67115

68116
interface IMVDFunctionalitiesManager {
69-
function hasFunctionality(string calldata codeName) external view returns(bool);
70-
}
117+
function hasFunctionality(string calldata codeName)
118+
external
119+
view
120+
returns (bool);
121+
}

0 commit comments

Comments
 (0)