diff --git a/contracts/ownership/Ownable.sol b/contracts/ownership/Ownable.sol index 65537ea..85780ef 100644 --- a/contracts/ownership/Ownable.sol +++ b/contracts/ownership/Ownable.sol @@ -15,14 +15,14 @@ contract Ownable is Initializable { address private _owner; /** - * @dev The caller is not the owner. + * @dev The caller account is not authorized to perform an operation. */ - error NotOwner(); + error OwnableUnauthorizedAccount(address account); /** - * @dev Given zero address. + * @dev The owner is not a valid owner account. (eg. `address(0)`) */ - error ZeroAddress(); + error OwnableInvalidOwner(address owner); event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); @@ -46,7 +46,7 @@ contract Ownable is Initializable { */ modifier onlyOwner() { if (!isOwner()) { - revert NotOwner(); + revert OwnableUnauthorizedAccount(msg.sender); } _; } @@ -83,7 +83,7 @@ contract Ownable is Initializable { */ function _transferOwnership(address newOwner) internal { if (newOwner == address(0)) { - revert ZeroAddress(); + revert OwnableInvalidOwner(address(0)); } emit OwnershipTransferred(_owner, newOwner); _owner = newOwner; diff --git a/test/NodeDriver.ts b/test/NodeDriver.ts index 23a04ea..937d2bd 100644 --- a/test/NodeDriver.ts +++ b/test/NodeDriver.ts @@ -40,7 +40,7 @@ describe('NodeDriver', () => { const account = ethers.Wallet.createRandom(); await expect(this.nodeDriverAuth.connect(this.nonOwner).migrateTo(account)).to.be.revertedWithCustomError( this.nodeDriverAuth, - 'NotOwner', + 'OwnableUnauthorizedAccount', ); }); }); @@ -55,7 +55,7 @@ describe('NodeDriver', () => { const address = ethers.Wallet.createRandom(); await expect( this.nodeDriverAuth.connect(this.nonOwner).copyCode(this.sfc, address), - ).to.be.revertedWithCustomError(this.nodeDriverAuth, 'NotOwner'); + ).to.be.revertedWithCustomError(this.nodeDriverAuth, 'OwnableUnauthorizedAccount'); }); }); @@ -69,7 +69,7 @@ describe('NodeDriver', () => { it('Should revert when not owner', async function () { await expect(this.nodeDriverAuth.connect(this.nonOwner).updateNetworkVersion(1)).to.be.revertedWithCustomError( this.nodeDriverAuth, - 'NotOwner', + 'OwnableUnauthorizedAccount', ); }); }); @@ -82,7 +82,7 @@ describe('NodeDriver', () => { it('Should revert when not owner', async function () { await expect(this.nodeDriverAuth.connect(this.nonOwner).advanceEpochs(10)).to.be.revertedWithCustomError( this.nodeDriverAuth, - 'NotOwner', + 'OwnableUnauthorizedAccount', ); }); }); diff --git a/test/SFC.ts b/test/SFC.ts index 201c88c..d18df86 100644 --- a/test/SFC.ts +++ b/test/SFC.ts @@ -292,15 +292,14 @@ describe('SFC', () => { it('Should revert when transferring ownership if not owner', async function () { await expect(this.sfc.connect(this.user).transferOwnership(ethers.ZeroAddress)).to.be.revertedWithCustomError( this.nodeDriverAuth, - 'NotOwner', + 'OwnableUnauthorizedAccount', ); }); it('Should revert when transferring ownership to zero address', async function () { - await expect(this.sfc.transferOwnership(ethers.ZeroAddress)).to.be.revertedWithCustomError( - this.nodeDriverAuth, - 'ZeroAddress', - ); + await expect(this.sfc.transferOwnership(ethers.ZeroAddress)) + .to.be.revertedWithCustomError(this.nodeDriverAuth, 'OwnableInvalidOwner') + .withArgs(ethers.ZeroAddress); }); });