Update docs
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
// OpenZeppelin Contracts (last updated v4.7.0) (access/AccessControl.sol)
|
||||
// OpenZeppelin Contracts (last updated v4.8.0) (access/AccessControl.sol)
|
||||
|
||||
pragma solidity ^0.8.0;
|
||||
|
||||
@ -110,7 +110,7 @@ abstract contract AccessControl is Context, IAccessControl, ERC165 {
|
||||
string(
|
||||
abi.encodePacked(
|
||||
"AccessControl: account ",
|
||||
Strings.toHexString(uint160(account), 20),
|
||||
Strings.toHexString(account),
|
||||
" is missing role ",
|
||||
Strings.toHexString(uint256(role), 32)
|
||||
)
|
||||
|
||||
57
contracts/access/Ownable2Step.sol
Normal file
57
contracts/access/Ownable2Step.sol
Normal file
@ -0,0 +1,57 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
// OpenZeppelin Contracts (last updated v4.8.0) (access/Ownable2Step.sol)
|
||||
|
||||
pragma solidity ^0.8.0;
|
||||
|
||||
import "./Ownable.sol";
|
||||
|
||||
/**
|
||||
* @dev Contract module which provides access control mechanism, where
|
||||
* there is an account (an owner) that can be granted exclusive access to
|
||||
* specific functions.
|
||||
*
|
||||
* By default, the owner account will be the one that deploys the contract. This
|
||||
* can later be changed with {transferOwnership} and {acceptOwnership}.
|
||||
*
|
||||
* This module is used through inheritance. It will make available all functions
|
||||
* from parent (Ownable).
|
||||
*/
|
||||
abstract contract Ownable2Step is Ownable {
|
||||
address private _pendingOwner;
|
||||
|
||||
event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);
|
||||
|
||||
/**
|
||||
* @dev Returns the address of the pending owner.
|
||||
*/
|
||||
function pendingOwner() public view virtual returns (address) {
|
||||
return _pendingOwner;
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.
|
||||
* Can only be called by the current owner.
|
||||
*/
|
||||
function transferOwnership(address newOwner) public virtual override onlyOwner {
|
||||
_pendingOwner = newOwner;
|
||||
emit OwnershipTransferStarted(owner(), newOwner);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.
|
||||
* Internal function without access restriction.
|
||||
*/
|
||||
function _transferOwnership(address newOwner) internal virtual override {
|
||||
delete _pendingOwner;
|
||||
super._transferOwnership(newOwner);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev The new owner accepts the ownership transfer.
|
||||
*/
|
||||
function acceptOwnership() external {
|
||||
address sender = _msgSender();
|
||||
require(pendingOwner() == sender, "Ownable2Step: caller is not the new owner");
|
||||
_transferOwnership(sender);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user