-
Notifications
You must be signed in to change notification settings - Fork 659
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a Owned2Step #375
Comments
Something like this could work ... // SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.0;
import {Ownable} from "./Ownable.sol";
/// @notice 2 Step Ownable
/// @author Solmate
abstract contract Ownable2Step is Ownable {
/*//////////////////////////////////////////////////////////////
EVENTS
//////////////////////////////////////////////////////////////*/
event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);
/*//////////////////////////////////////////////////////////////
OWNERSHIP STORAGE
//////////////////////////////////////////////////////////////*/
address public pendingOwner;
modifier onlyPendingOwner() virtual {
require(msg.sender == pendingOwner, "UNAUTHORIZED");
_;
}
/*//////////////////////////////////////////////////////////////
OWNERSHIP LOGIC
//////////////////////////////////////////////////////////////*/
/**
* @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;
owner = newOwner;
emit OwnershipTransferred(msg.sender, newOwner);
}
/**
* @dev The new owner accepts the ownership transfer.
*/
function acceptOwnership() public virtual onlyPendingOwner {
_transferOwnership(msg.sender);
}
} |
Open
3 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A contract which I thinks improve a lot the owner UX of a contract in OZ is Ownable2Step so I was wondering if we could make the solmate version of it with Owned
The text was updated successfully, but these errors were encountered: