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:

contract DFODependantContract {

    //The DFO DoubleProxy 
    address public doubleProxy;
    
    uint256 public mySpecificParameter;
    
    //Every configuration parameter must have a initial value in constructor and a setter callable by the DFO only
    constructor(address _doubleProxy, uint256 _mySpecificParameterInitialValue) {
    	doubleProxy = _doubleProxy;
    	mySpecificParameter = _mySpecificParameterInitialValue;
    }
    
    //All the functions having this modifier can be called only by the DFO microservices and one-time proposals
    modifier byDFO() {
    require(IMVDFunctionalitiesManager(IMVDProxy(IDoubleProxy(_doubleProxy).proxy()).getMVDFunctionalitiesManagerAddress()).isAuthorizedFunctionality(msg.sender), "Unauthorized.");
            _;
    }
    
    //E.g. mySpecificParameter can be changed only by proposal
    function setMySpecificParameter(uint256 _mySpecificParameter) public byDFO {
    	mySpecificParameter = _mySpecificParameter;
    }
    
    //For security purposes, it is ALWAYS important to let a DFO vote to change the DoubleProxy
    function setDoubleProxy(address newDoubleProxy) public byDFO {
        doubleProxy = newDoubleProxy;
    }
    
    interface IDoubleProxy {
        function proxy() external view returns (address);
    }
    
    interface IMVDProxy {
        function getMVDFunctionalitiesManagerAddress() external view returns(address);
        function getMVDWalletAddress() external view returns (address);
        function getStateHolderAddress() external view returns(address);
        function submit(string calldata codeName, bytes calldata data) external payable returns(bytes memory returnData);
    }
    
    interface IMVDFunctionalitiesManager {
        function getFunctionalityData(string calldata codeName) external view returns(address, uint256, string memory, address, uint256);
        function isAuthorizedFunctionality(address functionality) external view returns(bool);
    }
    
    interface IStateHolder {
        function getUint256(string calldata name) external view returns(uint256);
        function getAddress(string calldata name) external view returns(address);
        function clear(string calldata varName) external returns(string memory oldDataType, bytes memory oldVal);
    }
}

Last updated