// SPDX-License-Identifier: MIT
pragma solidity 0.8.22;
import "./interfaces/v0.8.x/IAdminACLV0.sol";
import {IAdminACLV0_Extended} from "./interfaces/v0.8.x/IAdminACLV0_Extended.sol";
import "@openzeppelin-4.7/contracts/access/Ownable.sol";
import "@openzeppelin-4.7/contracts/utils/introspection/ERC165.sol";
/**
* @title Admin ACL contract, V0.
* @author Art Blocks Inc.
* @notice Privileged Roles and Ownership:
* This contract has a single superAdmin that passes all ACL checks. All checks
* for any other address will return false.
* The superAdmin can be changed by the current superAdmin.
* Care must be taken to ensure that the admin ACL contract is secure behind a
* multi-sig or other secure access control mechanism.
*/
contract AdminACLV0 is IAdminACLV0, IAdminACLV0_Extended, ERC165 {
string public AdminACLType = "AdminACLV0";
/// superAdmin is the only address that passes any and all ACL checks
address public superAdmin;
constructor() {
superAdmin = msg.sender;
}
/**
* @notice Allows superAdmin change the superAdmin address.
* @param _newSuperAdmin The new superAdmin address.
* @param _genArt721CoreAddressesToUpdate Array of genArt721Core
* addresses to update to the new superAdmin, for indexing purposes only.
* @dev this function is gated to only superAdmin address.
*/
function changeSuperAdmin(
address _newSuperAdmin,
address[] calldata _genArt721CoreAddressesToUpdate
) external {
require(msg.sender == superAdmin, "Only superAdmin");
address previousSuperAdmin = superAdmin;
superAdmin = _newSuperAdmin;
emit SuperAdminTransferred(
previousSuperAdmin,
_newSuperAdmin,
_genArt721CoreAddressesToUpdate
);
}
/**
* Calls transferOwnership on other contract from this contract.
* This is useful for updating to a new AdminACL contract.
* @dev this function is gated to only superAdmin address.
* @dev This implementation requires that the new AdminACL contract
* broadcasts support of IAdminACLV0 via ERC165 interface detection.
*/
function transferOwnershipOn(
address _contract,
address _newAdminACL
) external {
require(msg.sender == superAdmin, "Only superAdmin");
// ensure new AdminACL contract supports IAdminACLV0
require(
ERC165(_newAdminACL).supportsInterface(
type(IAdminACLV0).interfaceId
),
"AdminACLV0: new admin ACL does not support IAdminACLV0"
);
Ownable(_contract).transferOwnership(_newAdminACL);
}
/**
* @notice Calls renounceOwnership on other contract from this contract.
* @dev this function is gated to only superAdmin address.
*/
function renounceOwnershipOn(address _contract) external {
require(msg.sender == superAdmin, "Only superAdmin");
Ownable(_contract).renounceOwnership();
}
/**
* @notice Checks if sender `_sender` is allowed to call function with selector
* `_selector` on contract `_contract`. Returns true if sender is superAdmin.
*/
function allowed(
address _sender,
address /*_contract*/,
bytes4 /*_selector*/
) external view returns (bool) {
return superAdmin == _sender;
}
/**
* @inheritdoc ERC165
*/
function supportsInterface(
bytes4 interfaceId
) public view virtual override(ERC165) returns (bool) {
return
interfaceId == type(IAdminACLV0).interfaceId ||
// @dev IAdminACLV0_Extended added after original deployments, so do not rely on it
// being present in all AdminACLV0 contracts.
interfaceId == type(IAdminACLV0_Extended).interfaceId ||
super.supportsInterface(interfaceId);
}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)
pragma solidity ^0.8.0;
import "./IERC165.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*
* Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
*/
abstract contract ERC165 is IERC165 {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}
// SPDX-License-Identifier: LGPL-3.0-only
// Created By: Art Blocks Inc.
pragma solidity ^0.8.0;
interface IAdminACLV0 {
/**
* @notice Token ID `_tokenId` minted to `_to`.
* @param previousSuperAdmin The previous superAdmin address.
* @param newSuperAdmin The new superAdmin address.
* @param genArt721CoreAddressesToUpdate Array of genArt721Core
* addresses to update to the new superAdmin, for indexing purposes only.
*/
event SuperAdminTransferred(
address indexed previousSuperAdmin,
address indexed newSuperAdmin,
address[] genArt721CoreAddressesToUpdate
);
/// Type of the Admin ACL contract, e.g. "AdminACLV0"
function AdminACLType() external view returns (string memory);
/// super admin address
function superAdmin() external view returns (address);
/**
* @notice Calls transferOwnership on other contract from this contract.
* This is useful for updating to a new AdminACL contract.
* @dev this function should be gated to only superAdmin-like addresses.
*/
function transferOwnershipOn(
address _contract,
address _newAdminACL
) external;
/**
* @notice Calls renounceOwnership on other contract from this contract.
* @dev this function should be gated to only superAdmin-like addresses.
*/
function renounceOwnershipOn(address _contract) external;
/**
* @notice Checks if sender `_sender` is allowed to call function with selector
* `_selector` on contract `_contract`.
*/
function allowed(
address _sender,
address _contract,
bytes4 _selector
) external returns (bool);
}
// SPDX-License-Identifier: LGPL-3.0-only
// Created By: Art Blocks Inc.
pragma solidity ^0.8.0;
import "./IAdminACLV0.sol";
interface IAdminACLV0_Extended is IAdminACLV0 {
/**
* @notice Allows superAdmin change the superAdmin address.
* @param _newSuperAdmin The new superAdmin address.
* @param _genArt721CoreAddressesToUpdate Array of genArt721Core
* addresses to update to the new superAdmin, for indexing purposes only.
* @dev this function is gated to only superAdmin address.
*/
function changeSuperAdmin(
address _newSuperAdmin,
address[] calldata _genArt721CoreAddressesToUpdate
) external;
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)
pragma solidity ^0.8.0;
import "../utils/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.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* 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.
*/
abstract 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() {
_transferOwnership(_msgSender());
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
require(owner() == _msgSender(), "Ownable: caller is not the 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 {
_transferOwnership(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 {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
{
"compilationTarget": {
"contracts/AdminACLV0.sol": "AdminACLV0"
},
"evmVersion": "paris",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs"
},
"optimizer": {
"enabled": true,
"runs": 10
},
"remappings": []
}
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousSuperAdmin","type":"address"},{"indexed":true,"internalType":"address","name":"newSuperAdmin","type":"address"},{"indexed":false,"internalType":"address[]","name":"genArt721CoreAddressesToUpdate","type":"address[]"}],"name":"SuperAdminTransferred","type":"event"},{"inputs":[],"name":"AdminACLType","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_sender","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"bytes4","name":"","type":"bytes4"}],"name":"allowed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_newSuperAdmin","type":"address"},{"internalType":"address[]","name":"_genArt721CoreAddressesToUpdate","type":"address[]"}],"name":"changeSuperAdmin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_contract","type":"address"}],"name":"renounceOwnershipOn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"superAdmin","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_contract","type":"address"},{"internalType":"address","name":"_newAdminACL","type":"address"}],"name":"transferOwnershipOn","outputs":[],"stateMutability":"nonpayable","type":"function"}]