Skip to content
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

Support ERC173 #2874

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
29 changes: 29 additions & 0 deletions contracts/access/IERC173.sol
@@ -0,0 +1,29 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
* @dev Interface of the ERC173 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-173[EIP].
*
* For an implementation, see {Ownable}.
*/
interface IERC173 {
/**
* @dev Emitted when ownership of a contract changes.
*/
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

/**
* @notice Returns the address of the owner.
* @return The address of the owner.
*/
function owner() external view returns (address);

/**
* @notice Set the address of the new owner of the contract.
* @dev Set newOwner to address(0) to renounce any ownership.
* @param newOwner The address of the new owner of the contract.
*/
function transferOwnership(address newOwner) external;
}
9 changes: 4 additions & 5 deletions contracts/access/Ownable.sol
Expand Up @@ -2,6 +2,7 @@

pragma solidity ^0.8.0;

import "./IERC173.sol";
import "../utils/Context.sol";

/**
Expand All @@ -16,11 +17,9 @@ import "../utils/Context.sol";
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
abstract contract Ownable is Context, IERC173 {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also the whole point of this would be to implement supportsInterface here, but not sure how welcome is it to add it (similar to how it is done in token/ERC721/ERC721.sol for example).

address private _owner;

event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
Expand All @@ -31,7 +30,7 @@ abstract contract Ownable is Context {
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
function owner() public view virtual override returns (address) {
return _owner;
}

Expand All @@ -58,7 +57,7 @@ abstract contract Ownable is Context {
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
function transferOwnership(address newOwner) public virtual override onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
Expand Down