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
+
10
3
pragma solidity ^ 0.6.0 ;
11
4
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
+ */
12
14
contract CommunityDrivenGovernance {
13
-
14
15
string private _metadataLink;
15
16
17
+ /**
18
+ * @dev Contract constructor
19
+ * @param metadataLink Link to the metadata of the Proposal
20
+ */
16
21
constructor (string memory metadataLink ) public {
17
22
_metadataLink = metadataLink;
18
23
}
19
24
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
+ {
21
34
return _metadataLink;
22
35
}
23
36
24
- function onStart (address , address ) public {
25
- }
37
+ function onStart (address , address ) public {}
26
38
27
- function onStop (address ) public {
28
- }
39
+ function onStop (address ) public {}
29
40
41
+ /**
42
+ * @dev Trigger for the finalization of a proposal.
43
+ * @param proposal Address for the proposal
44
+ * @param result
45
+ */
30
46
function proposalEnd (address proposal , bool result ) public {
31
- if (! result) {
47
+ if (! result) {
32
48
return ;
33
49
}
34
50
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
+ );
39
66
}
40
67
}
41
68
}
42
69
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 ) {
45
72
assembly {
46
73
x := mload (add (bs, add (0x20 , 0 )))
47
74
}
@@ -50,21 +77,45 @@ contract CommunityDrivenGovernance {
50
77
}
51
78
52
79
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 );
54
85
}
55
86
56
87
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 );
62
110
}
63
111
64
112
interface IMVDFunctionalityProposal {
65
- function getProposer () external view returns (address );
113
+ function getProposer () external view returns (address );
66
114
}
67
115
68
116
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