Added RichErrors to Ownable

This commit is contained in:
James Towle
2019-06-10 20:51:53 -07:00
committed by Amir Bandeali
parent 55246c5d87
commit a0602c8863
2 changed files with 36 additions and 4 deletions

View File

@@ -0,0 +1,28 @@
pragma solidity ^0.5.9;
import "./RichErrors.sol";
contract MixinOwnableRichErrors is
RichErrors
{
// bytes4(keccak256("OnlyOwnerError(address,address)"))
bytes4 internal constant ONLY_OWNER_SELECTOR =
0x1de45ad1;
// solhint-disable func-name-mixedcase
function OnlyOwnerError(
address sender,
address owner
)
internal
pure
returns (bytes memory)
{
return abi.encodeWithSelector(
ONLY_OWNER_SELECTOR,
sender,
owner
);
}
}

View File

@@ -1,9 +1,11 @@
pragma solidity ^0.5.9;
import "./interfaces/IOwnable.sol";
import "./MixinOwnableRichErrors.sol";
contract Ownable is
MixinOwnableRichErrors,
IOwnable
{
address public owner;
@@ -15,10 +17,12 @@ contract Ownable is
}
modifier onlyOwner() {
require(
msg.sender == owner,
"ONLY_CONTRACT_OWNER"
);
if (msg.sender != owner) {
_rrevert(OnlyOwnerError(
msg.sender,
owner
));
}
_;
}