Dao.sol
Main DAO smart contract
function execute(
address _target,
bytes calldata _data,
uint256 _value,
uint256 _nonce,
uint256 _timestamp,
bytes[] memory _sigs
) external nonReentrant returns (bool) {
require(checkSubscription(), "DAO: subscription not paid");
require(balanceOf(msg.sender) > 0, "DAO: only for members");
require(
_timestamp + VOTING_DURATION >= block.timestamp,
"DAO: voting is over"
);
bytes32 txHash = getTxHash(_target, _data, _value, _nonce, _timestamp);
require(!executedTx[txHash], "DAO: voting already executed");
require(_checkSigs(_sigs, txHash), "DAO: quorum is not reached");
executedTx[txHash] = true;
executedVotings.push(
ExecutedVoting({
target: _target,
data: _data,
value: _value,
nonce: _nonce,
timestamp: _timestamp,
executionTimestamp: block.timestamp,
txHash: txHash,
sigs: _sigs
})
);
if (_data.length == 0) {
payable(_target).sendValue(_value);
} else {
if (_value == 0) {
_target.functionCall(_data);
} else {
_target.functionCallWithValue(_data, _value);
}
}
emit Executed(
_target,
_data,
_value,
_nonce,
_timestamp,
block.timestamp,
txHash,
_sigs
);
return true;
}Last updated