[audit]#5 add claim ownership to ownable contract
This commit is contained in:
@@ -8,7 +8,6 @@
|
|||||||
pragma solidity 0.6.9;
|
pragma solidity 0.6.9;
|
||||||
pragma experimental ABIEncoderV2;
|
pragma experimental ABIEncoderV2;
|
||||||
|
|
||||||
|
|
||||||
interface IDODO {
|
interface IDODO {
|
||||||
function init(
|
function init(
|
||||||
address supervisor,
|
address supervisor,
|
||||||
@@ -24,6 +23,8 @@ interface IDODO {
|
|||||||
|
|
||||||
function transferOwnership(address newOwner) external;
|
function transferOwnership(address newOwner) external;
|
||||||
|
|
||||||
|
function claimOwnership() external;
|
||||||
|
|
||||||
function sellBaseToken(uint256 amount, uint256 minReceiveQuote) external returns (uint256);
|
function sellBaseToken(uint256 amount, uint256 minReceiveQuote) external returns (uint256);
|
||||||
|
|
||||||
function buyBaseToken(uint256 amount, uint256 maxPayQuote) external returns (uint256);
|
function buyBaseToken(uint256 amount, uint256 maxPayQuote) external returns (uint256);
|
||||||
|
|||||||
@@ -16,9 +16,12 @@ pragma experimental ABIEncoderV2;
|
|||||||
*/
|
*/
|
||||||
contract Ownable {
|
contract Ownable {
|
||||||
address public _OWNER_;
|
address public _OWNER_;
|
||||||
|
address public _NEW_OWNER_;
|
||||||
|
|
||||||
// ============ Events ============
|
// ============ Events ============
|
||||||
|
|
||||||
|
event OwnershipTransferPrepared(address indexed previousOwner, address indexed newOwner);
|
||||||
|
|
||||||
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
|
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
|
||||||
|
|
||||||
// ============ Modifiers ============
|
// ============ Modifiers ============
|
||||||
@@ -37,7 +40,14 @@ contract Ownable {
|
|||||||
|
|
||||||
function transferOwnership(address newOwner) external onlyOwner {
|
function transferOwnership(address newOwner) external onlyOwner {
|
||||||
require(newOwner != address(0), "INVALID_OWNER");
|
require(newOwner != address(0), "INVALID_OWNER");
|
||||||
emit OwnershipTransferred(_OWNER_, newOwner);
|
emit OwnershipTransferPrepared(_OWNER_, newOwner);
|
||||||
_OWNER_ = newOwner;
|
_NEW_OWNER_ = newOwner;
|
||||||
|
}
|
||||||
|
|
||||||
|
function claimOwnership() external {
|
||||||
|
require(msg.sender == _NEW_OWNER_, "INVALID_CLAIM");
|
||||||
|
emit OwnershipTransferred(_OWNER_, _NEW_OWNER_);
|
||||||
|
_OWNER_ = _NEW_OWNER_;
|
||||||
|
_NEW_OWNER_ = address(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user