Skip to content

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 3 commits into from
Jul 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions contracts/feature/Ownable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member

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


/// @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) {
Copy link
Member

Choose a reason for hiding this comment

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

if i remember correctly, owner is a standard that things like Opensea fetches, i think this should be fine, but we should make sure its still compatible? @jakeloo @nkrishang do you know?

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 {
Expand All @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion docs/Multiwrap.md
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ function owner() external view returns (address)




*Returns the owner of the contract.*


#### Returns
Expand Down
2 changes: 1 addition & 1 deletion docs/Ownable.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function owner() external view returns (address)



*Owner of the contract (purpose: OpenSea compatibility)*
*Returns the owner of the contract.*


#### Returns
Expand Down
2 changes: 1 addition & 1 deletion docs/Pack.md
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ function owner() external view returns (address)




*Returns the owner of the contract.*


#### Returns
Expand Down
2 changes: 1 addition & 1 deletion docs/SignatureDrop.md
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,7 @@ function owner() external view returns (address)




*Returns the owner of the contract.*


#### Returns
Expand Down
2 changes: 1 addition & 1 deletion docs/ThirdwebContract.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function owner() external view returns (address)




*Returns the owner of the contract.*


#### Returns
Expand Down