Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
contracts/contracts/defi/utils/Admin.sol
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
44 lines (36 sloc)
994 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| pragma solidity >=0.8.0 <0.9.0; | |
| //Copyright of DataX Protocol contributors | |
| // SPDX-License-Identifier: BSU-1.1 | |
| contract Admin { | |
| address public admin; | |
| address public pendingAdmin; | |
| constructor() { | |
| admin = msg.sender; | |
| } | |
| modifier adminOnly() { | |
| require(msg.sender == admin, "admin only"); | |
| _; | |
| } | |
| /*********************/ | |
| /**** Admin *****/ | |
| /*********************/ | |
| /** | |
| * Request a new admin to be set for the contract. | |
| * | |
| * @param newAdmin New admin address | |
| */ | |
| function setPendingAdmin(address newAdmin) public adminOnly { | |
| pendingAdmin = newAdmin; | |
| } | |
| /** | |
| * Accept admin transfer from the current admin to the new. | |
| */ | |
| function acceptPendingAdmin() public { | |
| require( | |
| msg.sender == pendingAdmin && pendingAdmin != address(0), | |
| "Caller must be the pending admin" | |
| ); | |
| admin = pendingAdmin; | |
| pendingAdmin = address(0); | |
| } | |
| } |