* Initial migration to Solidity 0.6.x - v3.0 first steps (#2063) * Initial migration, missing GSN, 721, 777 and Crowdsales. * Add _beforeTokenOperation and _afterTokenOperation. * Add documentation for hooks. * Add hooks doc * Add missing drafts * Add back ERC721 with hooks * Bring back ERC777 * Notes on hooks * Bring back GSN * Make functions virtual * Make GSN overrides explicit * Fix ERC20Pausable tests * Remove virtual from some view functions * Update linter * Delete examples * Remove unnecessary virtual * Remove roles from Pausable * Remove roles * Remove users of roles * Adapt ERC20 tests * Fix ERC721 tests * Add all ERC721 hooks * Add ERC777 hooks * Fix remaining tests * Bump compiler version * Move 721BurnableMock into mocks directory * Remove _before hooks * Fix tests * Upgrade linter * Put modifiers last * Remove _beforeTokenApproval and _beforeOperatorApproval hooks
78 lines
2.4 KiB
Solidity
78 lines
2.4 KiB
Solidity
pragma solidity ^0.6.0;
|
|
|
|
import "../GSN/Context.sol";
|
|
/**
|
|
* @dev 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 Ownable is Context {
|
|
address private _owner;
|
|
|
|
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
|
|
|
|
/**
|
|
* @dev Initializes the contract setting the deployer as the initial owner.
|
|
*/
|
|
constructor () internal {
|
|
address msgSender = _msgSender();
|
|
_owner = msgSender;
|
|
emit OwnershipTransferred(address(0), msgSender);
|
|
}
|
|
|
|
/**
|
|
* @dev Returns the address of the current owner.
|
|
*/
|
|
function owner() public view returns (address) {
|
|
return _owner;
|
|
}
|
|
|
|
/**
|
|
* @dev Throws if called by any account other than the owner.
|
|
*/
|
|
modifier onlyOwner() {
|
|
require(isOwner(), "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.
|
|
*
|
|
* NOTE: Renouncing ownership will leave the contract without an owner,
|
|
* thereby removing any functionality that is only available to the owner.
|
|
*/
|
|
function renounceOwnership() public virtual onlyOwner {
|
|
emit OwnershipTransferred(_owner, address(0));
|
|
_owner = address(0);
|
|
}
|
|
|
|
/**
|
|
* @dev Transfers ownership of the contract to a new account (`newOwner`).
|
|
* Can only be called by the current owner.
|
|
*/
|
|
function transferOwnership(address newOwner) public virtual onlyOwner {
|
|
_transferOwnership(newOwner);
|
|
}
|
|
|
|
/**
|
|
* @dev Transfers ownership of the contract to a new account (`newOwner`).
|
|
*/
|
|
function _transferOwnership(address newOwner) internal virtual {
|
|
require(newOwner != address(0), "Ownable: new owner is the zero address");
|
|
emit OwnershipTransferred(_owner, newOwner);
|
|
_owner = newOwner;
|
|
}
|
|
}
|