DFO-Based Smart Contracts
A DFO can have multiple external Smart Contracts that execute complex routines. In order to allow the modification of the configuration parameters of these SmartContracts, it is necessary that, during the deployment phase, the latter know the DoubleProxy of the DFO to which they refer:
1
contract DFODependantContract {
2
3
//The DFO DoubleProxy
4
address public doubleProxy;
5
6
uint256 public mySpecificParameter;
7
8
//Every configuration parameter must have a initial value in constructor and a setter callable by the DFO only
9
constructor(address _doubleProxy, uint256 _mySpecificParameterInitialValue) {
10
doubleProxy = _doubleProxy;
11
mySpecificParameter = _mySpecificParameterInitialValue;
12
}
13
14
//All the functions having this modifier can be called only by the DFO microservices and one-time proposals
15
modifier byDFO() {
16
require(IMVDFunctionalitiesManager(IMVDProxy(IDoubleProxy(_doubleProxy).proxy()).getMVDFunctionalitiesManagerAddress()).isAuthorizedFunctionality(msg.sender), "Unauthorized.");
17
_;
18
}
19
20
//E.g. mySpecificParameter can be changed only by proposal
21
function setMySpecificParameter(uint256 _mySpecificParameter) public byDFO {
22
mySpecificParameter = _mySpecificParameter;
23
}
24
25
//For security purposes, it is ALWAYS important to let a DFO vote to change the DoubleProxy
26
function setDoubleProxy(address newDoubleProxy) public byDFO {
27
doubleProxy = newDoubleProxy;
28
}
29
30
interface IDoubleProxy {
31
function proxy() external view returns (address);
32
}
33
34
interface IMVDProxy {
35
function getMVDFunctionalitiesManagerAddress() external view returns(address);
36
function getMVDWalletAddress() external view returns (address);
37
function getStateHolderAddress() external view returns(address);
38
function submit(string calldata codeName, bytes calldata data) external payable returns(bytes memory returnData);
39
}
40
41
interface IMVDFunctionalitiesManager {
42
function getFunctionalityData(string calldata codeName) external view returns(address, uint256, string memory, address, uint256);
43
function isAuthorizedFunctionality(address functionality) external view returns(bool);
44
}
45
46
interface IStateHolder {
47
function getUint256(string calldata name) external view returns(uint256);
48
function getAddress(string calldata name) external view returns(address);
49
function clear(string calldata varName) external returns(string memory oldDataType, bytes memory oldVal);
50
}
51
}
Copied!
Copy link