zellic-audit
Initial commit
f998fcd
raw
history blame
11.2 kB
{
"language": "Solidity",
"sources": {
"@openzeppelin/contracts/access/Ownable.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the deployer as the initial owner.\n */\n constructor() {\n _transferOwnership(_msgSender());\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions anymore. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby removing any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n"
},
"@openzeppelin/contracts/utils/Context.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n}\n"
},
"contracts/base/Errors.sol": {
"content": "//SPDX-License-Identifier: MIT\r\npragma solidity ^0.8.11;\r\n\r\n/// @notice An error used to indicate that an action could not be completed because either the `msg.sender` or\r\n/// `msg.origin` is not authorized.\r\nerror Unauthorized();\r\n\r\n/// @notice An error used to indicate that an action could not be completed because the contract either already existed\r\n/// or entered an illegal condition which is not recoverable from.\r\nerror IllegalState();\r\n\r\n/// @notice An error used to indicate that an action could not be completed because of an illegal argument was passed\r\n/// to the function.\r\nerror IllegalArgument();"
},
"contracts/interfaces/IWhitelist.sol": {
"content": "//SPDX-License-Identifier: MIT\r\npragma solidity ^0.8.11;\r\n\r\nimport \"../base/Errors.sol\";\r\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\r\nimport \"../libraries/Sets.sol\";\r\n\r\n/// @title Whitelist\r\n/// @author Mellow Finance\r\ninterface IWhitelist {\r\n /// @dev Emitted when a contract is added to the whitelist.\r\n ///\r\n /// @param account The account that was added to the whitelist.\r\n event AccountAdded(address account);\r\n\r\n /// @dev Emitted when a contract is removed from the whitelist.\r\n ///\r\n /// @param account The account that was removed from the whitelist.\r\n event AccountRemoved(address account);\r\n\r\n /// @dev Emitted when the whitelist is deactivated.\r\n event WhitelistDisabled();\r\n\r\n /// @dev Returns the list of addresses that are whitelisted for the given contract address.\r\n ///\r\n /// @return addresses The addresses that are whitelisted to interact with the given contract.\r\n function getAddresses() external view returns (address[] memory addresses);\r\n\r\n /// @dev Returns the disabled status of a given whitelist.\r\n ///\r\n /// @return disabled A flag denoting if the given whitelist is disabled.\r\n function disabled() external view returns (bool);\r\n\r\n /// @dev Adds an contract to the whitelist.\r\n ///\r\n /// @param caller The address to add to the whitelist.\r\n function add(address caller) external;\r\n\r\n /// @dev Adds a contract to the whitelist.\r\n ///\r\n /// @param caller The address to remove from the whitelist.\r\n function remove(address caller) external;\r\n\r\n /// @dev Disables the whitelist of the target whitelisted contract.\r\n ///\r\n /// This can only occur once. Once the whitelist is disabled, then it cannot be reenabled.\r\n function disable() external;\r\n\r\n /// @dev Checks that the `msg.sender` is whitelisted when it is not an EOA.\r\n ///\r\n /// @param account The account to check.\r\n ///\r\n /// @return whitelisted A flag denoting if the given account is whitelisted.\r\n function isWhitelisted(address account) external view returns (bool);\r\n}\r\n"
},
"contracts/libraries/Sets.sol": {
"content": "//SPDX-License-Identifier: MIT\r\npragma solidity ^0.8.11;\r\n\r\n/// @title Sets\r\n/// @author Mellow Finance\r\nlibrary Sets {\r\n using Sets for AddressSet;\r\n\r\n /// @notice A data structure holding an array of values with an index mapping for O(1) lookup.\r\n struct AddressSet {\r\n address[] values;\r\n mapping(address => uint256) indexes;\r\n }\r\n\r\n /// @dev Add a value to a Set\r\n ///\r\n /// @param self The Set.\r\n /// @param value The value to add.\r\n ///\r\n /// @return Whether the operation was successful (unsuccessful if the value is already contained in the Set)\r\n function add(AddressSet storage self, address value) internal returns (bool) {\r\n if (self.contains(value)) {\r\n return false;\r\n }\r\n self.values.push(value);\r\n self.indexes[value] = self.values.length;\r\n return true;\r\n }\r\n\r\n /// @dev Remove a value from a Set\r\n ///\r\n /// @param self The Set.\r\n /// @param value The value to remove.\r\n ///\r\n /// @return Whether the operation was successful (unsuccessful if the value was not contained in the Set)\r\n function remove(AddressSet storage self, address value) internal returns (bool) {\r\n uint256 index = self.indexes[value];\r\n if (index == 0) {\r\n return false;\r\n }\r\n\r\n // Normalize the index since we know that the element is in the set.\r\n index--;\r\n\r\n uint256 lastIndex = self.values.length - 1;\r\n\r\n if (index != lastIndex) {\r\n address lastValue = self.values[lastIndex];\r\n self.values[index] = lastValue;\r\n self.indexes[lastValue] = index + 1;\r\n }\r\n\r\n self.values.pop();\r\n\r\n delete self.indexes[value];\r\n\r\n return true;\r\n }\r\n\r\n /// @dev Returns true if the value exists in the Set\r\n ///\r\n /// @param self The Set.\r\n /// @param value The value to check.\r\n ///\r\n /// @return True if the value is contained in the Set, False if it is not.\r\n function contains(AddressSet storage self, address value) internal view returns (bool) {\r\n return self.indexes[value] != 0;\r\n }\r\n}"
},
"contracts/whitelist.sol": {
"content": "pragma solidity ^0.8.11;\r\n\r\nimport \"./base/Errors.sol\";\r\nimport \"./interfaces/IWhitelist.sol\";\r\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\r\nimport \"./libraries/Sets.sol\";\r\n\r\n/// @title Whitelist\r\n/// @author Mellow Finance\r\ncontract Whitelist is IWhitelist, Ownable {\r\n using Sets for Sets.AddressSet;\r\n Sets.AddressSet addresses;\r\n\r\n /// @inheritdoc IWhitelist\r\n bool public override disabled;\r\n\r\n constructor() Ownable() {}\r\n\r\n /// @inheritdoc IWhitelist\r\n function getAddresses() external view returns (address[] memory) {\r\n return addresses.values;\r\n }\r\n\r\n /// @inheritdoc IWhitelist\r\n function add(address caller) external override {\r\n _onlyAdmin();\r\n if (disabled) {\r\n revert IllegalState();\r\n }\r\n addresses.add(caller);\r\n emit AccountAdded(caller);\r\n }\r\n\r\n /// @inheritdoc IWhitelist\r\n function remove(address caller) external override {\r\n _onlyAdmin();\r\n if (disabled) {\r\n revert IllegalState();\r\n }\r\n addresses.remove(caller);\r\n emit AccountRemoved(caller);\r\n }\r\n\r\n /// @inheritdoc IWhitelist\r\n function disable() external override {\r\n _onlyAdmin();\r\n disabled = true;\r\n emit WhitelistDisabled();\r\n }\r\n\r\n /// @inheritdoc IWhitelist\r\n function isWhitelisted(address account) external view override returns (bool) {\r\n return disabled || addresses.contains(account);\r\n }\r\n\r\n /// @dev Reverts if the caller is not the contract owner.\r\n function _onlyAdmin() internal view {\r\n if (msg.sender != owner()) {\r\n revert Unauthorized();\r\n }\r\n }\r\n}"
}
},
"settings": {
"optimizer": {
"enabled": true,
"runs": 200
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"metadata": {
"useLiteralContent": true
},
"libraries": {}
}
}