Democratic
This abstract smart contract should be inherited by any contract that wants to use our implementation of the Democratic Ownership
Each time the owners of the smart contract who inherits from Democrtic.sol want to execute a restricted function, they first need to go through the voting process in the DemocraticOwnership.sol smart contract and then call the UpdateSC() function so that the democratia() modifier allows a restricted function call.
Inheritances​
This contract inherits from the Context.sol implementation from Openzeppelin.
Interfaces​
This contract use IDOSC.sol to interact with the DemocraticOwnership.sol smart contract.
State Variables, Enums and Structs​
address public immutable doscAdd : address of the Democratic Ownership.
address public lastAuthorizedAddress : last owner address that is authorized to call restricted functions.
uint256 public lastChangingTime : last block timestamp until a restricted call is authorized.
Modifiers​
demokratia()​
This modifier is used to identify if a restricted call is possible and if the user who calls the function is authorized.
modifier demokratia() {
require(lastAuthorizedAddress == _msgSender(), "You are not authorized to change");
require(lastChangingTime >= block.timestamp, "Time for changes expired");
_;
}
Functions​
constructor(address _doscAdd) (internal)​
_doscAdd: Address of the democratic ownership smart contract deployed.
The constructor only instantiate the doscAdd state variable.
updateSC() (external)​
This function uses the doscAdd state variable and the IDOSC interface to update the following 2 state variables: lastAuthorizedAddress and lastChangingTime.
function updateSC() external {
IDOSC dosc = IDOSC(doscAdd);
lastAuthorizedAddress = dosc.readAuthorizedAddress();
lastChangingTime = dosc.readEndChangeTime();
}