@0x/contracts-zero-ex: Use immutable owner in Puppet instead of Ownable.
This commit is contained in:
committed by
Lawrence Forman
parent
af45409959
commit
030cb285da
@@ -23,9 +23,8 @@ import "@0x/contracts-utils/contracts/src/v06/interfaces/IOwnableV06.sol";
|
|||||||
|
|
||||||
|
|
||||||
/// @dev A contract that can execute arbitrary calls from its owner.
|
/// @dev A contract that can execute arbitrary calls from its owner.
|
||||||
interface IPuppet is
|
interface IPuppet {
|
||||||
IOwnableV06
|
|
||||||
{
|
|
||||||
/// @dev Execute an arbitrary call. Only an authority can call this.
|
/// @dev Execute an arbitrary call. Only an authority can call this.
|
||||||
/// @param target The call target.
|
/// @param target The call target.
|
||||||
/// @param callData The call data.
|
/// @param callData The call data.
|
||||||
@@ -55,4 +54,8 @@ interface IPuppet is
|
|||||||
|
|
||||||
/// @dev Allows the puppet to receive ETH.
|
/// @dev Allows the puppet to receive ETH.
|
||||||
receive() external payable;
|
receive() external payable;
|
||||||
|
|
||||||
|
/// @dev Fetch the immutable owner/deployer of this contract.
|
||||||
|
/// @return owner_ The immutable owner/deployer/
|
||||||
|
function owner() external view returns (address owner_);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,19 +20,39 @@ pragma solidity ^0.6.5;
|
|||||||
pragma experimental ABIEncoderV2;
|
pragma experimental ABIEncoderV2;
|
||||||
|
|
||||||
import "@0x/contracts-utils/contracts/src/v06/errors/LibRichErrorsV06.sol";
|
import "@0x/contracts-utils/contracts/src/v06/errors/LibRichErrorsV06.sol";
|
||||||
import "@0x/contracts-utils/contracts/src/v06/OwnableV06.sol";
|
import "@0x/contracts-utils/contracts/src/v06/errors/LibOwnableRichErrorsV06.sol";
|
||||||
import "../errors/LibPuppetRichErrors.sol";
|
import "../errors/LibPuppetRichErrors.sol";
|
||||||
import "./IPuppet.sol";
|
import "./IPuppet.sol";
|
||||||
|
|
||||||
|
|
||||||
/// @dev A contract that can execute arbitrary calls from its owner.
|
/// @dev A contract that can execute arbitrary calls from its owner.
|
||||||
contract Puppet is
|
contract Puppet is
|
||||||
IPuppet,
|
IPuppet
|
||||||
OwnableV06
|
|
||||||
{
|
{
|
||||||
// solhint-disable no-unused-vars,indent,no-empty-blocks
|
// solhint-disable no-unused-vars,indent,no-empty-blocks
|
||||||
using LibRichErrorsV06 for bytes;
|
using LibRichErrorsV06 for bytes;
|
||||||
|
|
||||||
|
// solhint-disable
|
||||||
|
/// @dev Store the owner/deployer as an immutable to make this contract stateless.
|
||||||
|
address public override immutable owner;
|
||||||
|
// solhint-enable
|
||||||
|
|
||||||
|
constructor() public {
|
||||||
|
// The deployer is the owner.
|
||||||
|
owner = msg.sender;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @dev Allows only the (immutable) owner to call a function.
|
||||||
|
modifier onlyOwner() virtual {
|
||||||
|
if (msg.sender != owner) {
|
||||||
|
LibOwnableRichErrorsV06.OnlyOwnerError(
|
||||||
|
msg.sender,
|
||||||
|
owner
|
||||||
|
).rrevert();
|
||||||
|
}
|
||||||
|
_;
|
||||||
|
}
|
||||||
|
|
||||||
/// @dev Execute an arbitrary call. Only an authority can call this.
|
/// @dev Execute an arbitrary call. Only an authority can call this.
|
||||||
/// @param target The call target.
|
/// @param target The call target.
|
||||||
/// @param callData The call data.
|
/// @param callData The call data.
|
||||||
|
|||||||
Reference in New Issue
Block a user