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

Cleanup of Ownership directory #2120

Merged
merged 11 commits into from
Mar 16, 2020
2 changes: 1 addition & 1 deletion contracts/mocks/OwnableInterfaceId.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ import "../ownership/Ownable.sol";
contract OwnableInterfaceId {
nventuro marked this conversation as resolved.
Show resolved Hide resolved
function getInterfaceId() public pure returns (bytes4) {
Ownable i;
return i.owner.selector ^ i.isOwner.selector ^ i.renounceOwnership.selector ^ i.transferOwnership.selector;
return i.owner.selector ^ i.renounceOwnership.selector ^ i.transferOwnership.selector;
}
}
12 changes: 4 additions & 8 deletions contracts/ownership/Ownable.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import "../GSN/Context.sol";
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
Expand Down Expand Up @@ -35,17 +38,10 @@ contract Ownable is Context {
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(isOwner(), "Ownable: caller is not the owner");
require(_owner == _msgSender(), "Ownable: caller is not the owner");
_;
}

/**
* @dev Returns true if the caller is the current owner.
*/
function isOwner() public view returns (bool) {
return _msgSender() == _owner;
}

/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
Expand Down
2 changes: 0 additions & 2 deletions test/ownership/Ownable.behavior.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@ function shouldBehaveLikeOwnable (owner, [other]) {
});

it('changes owner after transfer', async function () {
expect(await this.ownable.isOwner({ from: other })).to.equal(false);
const receipt = await this.ownable.transferOwnership(other, { from: owner });
expectEvent(receipt, 'OwnershipTransferred');

expect(await this.ownable.owner()).to.equal(other);
expect(await this.ownable.isOwner({ from: other })).to.equal(true);
});

it('should prevent non-owners from transferring', async function () {
Expand Down