Reorder state changes and event emission for consistency (#2719)
Co-authored-by: Francisco Giordano <frangio.1@gmail.com>
This commit is contained in:
@ -25,9 +25,7 @@ abstract contract Ownable is Context {
|
|||||||
* @dev Initializes the contract setting the deployer as the initial owner.
|
* @dev Initializes the contract setting the deployer as the initial owner.
|
||||||
*/
|
*/
|
||||||
constructor() {
|
constructor() {
|
||||||
address msgSender = _msgSender();
|
_setOwner(_msgSender());
|
||||||
_owner = msgSender;
|
|
||||||
emit OwnershipTransferred(address(0), msgSender);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -53,8 +51,7 @@ abstract contract Ownable is Context {
|
|||||||
* thereby removing any functionality that is only available to the owner.
|
* thereby removing any functionality that is only available to the owner.
|
||||||
*/
|
*/
|
||||||
function renounceOwnership() public virtual onlyOwner {
|
function renounceOwnership() public virtual onlyOwner {
|
||||||
emit OwnershipTransferred(_owner, address(0));
|
_setOwner(address(0));
|
||||||
_owner = address(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -63,7 +60,12 @@ abstract contract Ownable is Context {
|
|||||||
*/
|
*/
|
||||||
function transferOwnership(address newOwner) public virtual onlyOwner {
|
function transferOwnership(address newOwner) public virtual onlyOwner {
|
||||||
require(newOwner != address(0), "Ownable: new owner is the zero address");
|
require(newOwner != address(0), "Ownable: new owner is the zero address");
|
||||||
emit OwnershipTransferred(_owner, newOwner);
|
_setOwner(newOwner);
|
||||||
|
}
|
||||||
|
|
||||||
|
function _setOwner(address newOwner) private {
|
||||||
|
address oldOwner = _owner;
|
||||||
_owner = newOwner;
|
_owner = newOwner;
|
||||||
|
emit OwnershipTransferred(oldOwner, newOwner);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user