-
Notifications
You must be signed in to change notification settings - Fork 562
add modifier onlyOwner in Ownable #185
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,20 @@ import "./interface/IOwnable.sol"; | |
|
||
abstract contract Ownable is IOwnable { | ||
/// @dev Owner of the contract (purpose: OpenSea compatibility) | ||
address public override owner; | ||
address private _owner; | ||
|
||
/// @dev Reverts if caller is not the owner. | ||
modifier onlyOwner() { | ||
if (msg.sender != _owner) { | ||
revert Ownable__NotAuthorized(); | ||
} | ||
_; | ||
} | ||
|
||
/// @dev Returns the owner of the contract. | ||
function owner() public view returns (address) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if i remember correctly, |
||
return _owner; | ||
} | ||
|
||
/// @dev Lets a contract admin set a new owner for the contract. The new owner must be a contract admin. | ||
function setOwner(address _newOwner) external override { | ||
|
@@ -23,8 +36,8 @@ abstract contract Ownable is IOwnable { | |
|
||
/// @dev Lets a contract admin set a new owner for the contract. The new owner must be a contract admin. | ||
function _setupOwner(address _newOwner) internal { | ||
address _prevOwner = owner; | ||
owner = _newOwner; | ||
address _prevOwner = _owner; | ||
_owner = _newOwner; | ||
|
||
emit OwnerUpdated(_prevOwner, _newOwner); | ||
} | ||
|
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ function owner() external view returns (address) | |
|
||
|
||
|
||
|
||
*Returns the owner of the contract.* | ||
|
||
|
||
#### Returns | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm expecting to see a change in the interface as well but im not seeing it in this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interface should remain the same. It has a function:
owner()
, which was previously overridden by the owner variable which was public.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah yes you're right