restruct contract repo

This commit is contained in:
mingda
2020-10-23 01:16:52 +08:00
parent 5f10f065e4
commit e8182dd1a1
53 changed files with 775 additions and 2575 deletions

View File

@@ -17,6 +17,7 @@ pragma experimental ABIEncoderV2;
contract InitializableOwnable {
address public _OWNER_;
address public _NEW_OWNER_;
bool internal _INITIALIZED_;
// ============ Events ============
@@ -26,6 +27,11 @@ contract InitializableOwnable {
// ============ Modifiers ============
modifier notInitialized() {
require(!_INITIALIZED_, "DODO_INITIALIZED");
_;
}
modifier onlyOwner() {
require(msg.sender == _OWNER_, "NOT_OWNER");
_;
@@ -33,13 +39,18 @@ contract InitializableOwnable {
// ============ Functions ============
function transferOwnership(address newOwner) external onlyOwner {
function initOwner(address newOwner) public notInitialized{
_INITIALIZED_ = true;
_OWNER_ = newOwner;
}
function transferOwnership(address newOwner) public onlyOwner {
require(newOwner != address(0), "INVALID_OWNER");
emit OwnershipTransferPrepared(_OWNER_, newOwner);
_NEW_OWNER_ = newOwner;
}
function claimOwnership() external {
function claimOwnership() public {
require(msg.sender == _NEW_OWNER_, "INVALID_CLAIM");
emit OwnershipTransferred(_OWNER_, _NEW_OWNER_);
_OWNER_ = _NEW_OWNER_;