Skip to content

Latest commit

 

History

History
347 lines (300 loc) · 10.6 KB

ProxyOwnable.md

File metadata and controls

347 lines (300 loc) · 10.6 KB

ProxyOwnable.sol

View Source: contracts/utils/ProxyOwnable.sol

↘ Derived Contracts: ModulesProxyRegistry

ProxyOwnable contract

Contract module which provides a basic access control mechanism, where there is an account (an owner) that can be granted exclusive access to specific functions.

  • 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.

Contract Members

Constants & Variables

bytes32 private constant KEY_OWNER;

Events

event ProxyOwnershipTransferred(address indexed previousOwner, address indexed newOwner);

Modifiers

onlyProxyOwner

Throws if called by any account other than the owner.

modifier onlyProxyOwner() internal

Functions


constructor

Initializes the contract setting the deployer as the initial owner.

function () internal nonpayable
Source Code
constructor() internal {
        _setProxyOwner(msg.sender);
    }

_setProxyOwner

Set address of the owner.

function _setProxyOwner(address _owner) internal nonpayable

Arguments

Name Type Description
_owner address Address of the owner.
Source Code
function _setProxyOwner(address _owner) internal {
        require(_owner != address(0), "ProxyOwnable::setProxyOwner: invalid address");
        emit ProxyOwnershipTransferred(getProxyOwner(), _owner);

        bytes32 key = KEY_OWNER;
        assembly {
            sstore(key, _owner)
        }
    }

setProxyOwner

Set address of the owner (only owner can call this function)

function setProxyOwner(address _owner) public nonpayable onlyProxyOwner 

Arguments

Name Type Description
_owner address Address of the owner.
Source Code
function setProxyOwner(address _owner) public onlyProxyOwner {
        _setProxyOwner(_owner);
    }

getProxyOwner

Return address of the owner.

function getProxyOwner() public view
returns(_owner address)
Source Code
function getProxyOwner() public view returns (address _owner) {
        bytes32 key = KEY_OWNER;
        assembly {
            _owner := sload(key)
        }
    }

Contracts