Source Code
Overview
ETH Balance
0 ETH
More Info
ContractCreator
Multichain Info
N/A
Loading...
Loading
Contract Name:
EscrowAIJob
Compiler Version
v0.8.9+commit.e5eed63a
Optimization Enabled:
Yes with 1000 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT pragma solidity ^0.8.2; import "@gnus.ai/contracts-upgradeable-diamond/utils/escrow/ConditionalEscrowUpgradeable.sol"; import "@gnus.ai/contracts-upgradeable-diamond/proxy/utils/Initializable.sol"; import "./GeniusAccessControl.sol"; contract EscrowAIJob is Initializable, ConditionalEscrowUpgradeable, GeniusAccessControl { // one time initialization on, subsequent calls get ignored with initializer function EscrowAIJob_Initialize() public initializer onlySuperAdminRole { __ConditionalEscrow_init(); InitializableStorage.layout()._initialized = false; } function withdrawalAllowed(address payee) public view virtual override returns (bool) { // return super.withdrawalAllowed(payee); // TODO: zkSnark check based on some random seed and macro job index and hashes. //require(_payees.) // logic here for allowing withdrawals to a payee return false; } function addPayees(uint256 escrowID, address[] memory payees, uint256[] memory tokenIDs) internal { } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import { AccessControlEnumerableUpgradeable } from "./AccessControlEnumerableUpgradeable.sol"; import { EnumerableSetUpgradeable } from "../utils/structs/EnumerableSetUpgradeable.sol"; library AccessControlEnumerableStorage { struct Layout { mapping(bytes32 => EnumerableSetUpgradeable.AddressSet) _roleMembers; } bytes32 internal constant STORAGE_SLOT = keccak256('openzepplin.contracts.storage.AccessControlEnumerable'); function layout() internal pure returns (Layout storage l) { bytes32 slot = STORAGE_SLOT; assembly { l.slot := slot } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (access/AccessControlEnumerable.sol) pragma solidity ^0.8.0; import "./IAccessControlEnumerableUpgradeable.sol"; import "./AccessControlUpgradeable.sol"; import "../utils/structs/EnumerableSetUpgradeable.sol"; import { AccessControlEnumerableStorage } from "./AccessControlEnumerableStorage.sol"; import "../proxy/utils/Initializable.sol"; /** * @dev Extension of {AccessControl} that allows enumerating the members of each role. */ abstract contract AccessControlEnumerableUpgradeable is Initializable, IAccessControlEnumerableUpgradeable, AccessControlUpgradeable { using AccessControlEnumerableStorage for AccessControlEnumerableStorage.Layout; function __AccessControlEnumerable_init() internal onlyInitializing { __Context_init_unchained(); __ERC165_init_unchained(); __AccessControl_init_unchained(); __AccessControlEnumerable_init_unchained(); } function __AccessControlEnumerable_init_unchained() internal onlyInitializing { } using EnumerableSetUpgradeable for EnumerableSetUpgradeable.AddressSet; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControlEnumerableUpgradeable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns one of the accounts that have `role`. `index` must be a * value between 0 and {getRoleMemberCount}, non-inclusive. * * Role bearers are not sorted in any particular way, and their ordering may * change at any point. * * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure * you perform all queries on the same block. See the following * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] * for more information. */ function getRoleMember(bytes32 role, uint256 index) public view virtual override returns (address) { return AccessControlEnumerableStorage.layout()._roleMembers[role].at(index); } /** * @dev Returns the number of accounts that have `role`. Can be used * together with {getRoleMember} to enumerate all bearers of a role. */ function getRoleMemberCount(bytes32 role) public view virtual override returns (uint256) { return AccessControlEnumerableStorage.layout()._roleMembers[role].length(); } /** * @dev Overload {_grantRole} to track enumerable memberships */ function _grantRole(bytes32 role, address account) internal virtual override { super._grantRole(role, account); AccessControlEnumerableStorage.layout()._roleMembers[role].add(account); } /** * @dev Overload {_revokeRole} to track enumerable memberships */ function _revokeRole(bytes32 role, address account) internal virtual override { super._revokeRole(role, account); AccessControlEnumerableStorage.layout()._roleMembers[role].remove(account); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import { AccessControlUpgradeable } from "./AccessControlUpgradeable.sol"; library AccessControlStorage { struct Layout { mapping(bytes32 => AccessControlUpgradeable.RoleData) _roles; } bytes32 internal constant STORAGE_SLOT = keccak256('openzepplin.contracts.storage.AccessControl'); function layout() internal pure returns (Layout storage l) { bytes32 slot = STORAGE_SLOT; assembly { l.slot := slot } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (access/AccessControl.sol) pragma solidity ^0.8.0; import "./IAccessControlUpgradeable.sol"; import "../utils/ContextUpgradeable.sol"; import "../utils/StringsUpgradeable.sol"; import "../utils/introspection/ERC165Upgradeable.sol"; import { AccessControlStorage } from "./AccessControlStorage.sol"; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module that allows children to implement role-based access * control mechanisms. This is a lightweight version that doesn't allow enumerating role * members except through off-chain means by accessing the contract event logs. Some * applications may benefit from on-chain enumerability, for those cases see * {AccessControlEnumerable}. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ``` * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ``` * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. */ abstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControlUpgradeable, ERC165Upgradeable { using AccessControlStorage for AccessControlStorage.Layout; function __AccessControl_init() internal onlyInitializing { __Context_init_unchained(); __ERC165_init_unchained(); __AccessControl_init_unchained(); } function __AccessControl_init_unchained() internal onlyInitializing { } struct RoleData { mapping(address => bool) members; bytes32 adminRole; } bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Modifier that checks that an account has a specific role. Reverts * with a standardized message including the required role. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ * * _Available since v4.1._ */ modifier onlyRole(bytes32 role) { _checkRole(role); _; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControlUpgradeable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view virtual override returns (bool) { return AccessControlStorage.layout()._roles[role].members[account]; } /** * @dev Revert with a standard message if `_msgSender()` is missing `role`. * Overriding this function changes the behavior of the {onlyRole} modifier. * * Format of the revert message is described in {_checkRole}. * * _Available since v4.6._ */ function _checkRole(bytes32 role) internal view virtual { _checkRole(role, _msgSender()); } /** * @dev Revert with a standard message if `account` is missing `role`. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ */ function _checkRole(bytes32 role, address account) internal view virtual { if (!hasRole(role, account)) { revert( string( abi.encodePacked( "AccessControl: account ", StringsUpgradeable.toHexString(uint160(account), 20), " is missing role ", StringsUpgradeable.toHexString(uint256(role), 32) ) ) ); } } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) { return AccessControlStorage.layout()._roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been revoked `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) public virtual override { require(account == _msgSender(), "AccessControl: can only renounce roles for self"); _revokeRole(role, account); } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. Note that unlike {grantRole}, this function doesn't perform any * checks on the calling account. * * [WARNING] * ==== * This function should only be called from the constructor when setting * up the initial roles for the system. * * Using this function in any other way is effectively circumventing the admin * system imposed by {AccessControl}. * ==== * * NOTE: This function is deprecated in favor of {_grantRole}. */ function _setupRole(bytes32 role, address account) internal virtual { _grantRole(role, account); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { bytes32 previousAdminRole = getRoleAdmin(role); AccessControlStorage.layout()._roles[role].adminRole = adminRole; emit RoleAdminChanged(role, previousAdminRole, adminRole); } /** * @dev Grants `role` to `account`. * * Internal function without access restriction. */ function _grantRole(bytes32 role, address account) internal virtual { if (!hasRole(role, account)) { AccessControlStorage.layout()._roles[role].members[account] = true; emit RoleGranted(role, account, _msgSender()); } } /** * @dev Revokes `role` from `account`. * * Internal function without access restriction. */ function _revokeRole(bytes32 role, address account) internal virtual { if (hasRole(role, account)) { AccessControlStorage.layout()._roles[role].members[account] = false; emit RoleRevoked(role, account, _msgSender()); } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/IAccessControlEnumerable.sol) pragma solidity ^0.8.0; import "./IAccessControlUpgradeable.sol"; /** * @dev External interface of AccessControlEnumerable declared to support ERC165 detection. */ interface IAccessControlEnumerableUpgradeable is IAccessControlUpgradeable { /** * @dev Returns one of the accounts that have `role`. `index` must be a * value between 0 and {getRoleMemberCount}, non-inclusive. * * Role bearers are not sorted in any particular way, and their ordering may * change at any point. * * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure * you perform all queries on the same block. See the following * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post] * for more information. */ function getRoleMember(bytes32 role, uint256 index) external view returns (address); /** * @dev Returns the number of accounts that have `role`. Can be used * together with {getRoleMember} to enumerate all bearers of a role. */ function getRoleMemberCount(bytes32 role) external view returns (uint256); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol) pragma solidity ^0.8.0; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControlUpgradeable { /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {AccessControl-_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) external view returns (bool); /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {AccessControl-_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) external view returns (bytes32); /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) external; /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) external; /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) external; }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import { OwnableUpgradeable } from "./OwnableUpgradeable.sol"; library OwnableStorage { struct Layout { address _owner; } bytes32 internal constant STORAGE_SLOT = keccak256('openzepplin.contracts.storage.Ownable'); function layout() internal pure returns (Layout storage l) { bytes32 slot = STORAGE_SLOT; assembly { l.slot := slot } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/ContextUpgradeable.sol"; import { OwnableStorage } from "./OwnableStorage.sol"; import "../proxy/utils/Initializable.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 OwnableUpgradeable is Initializable, ContextUpgradeable { using OwnableStorage for OwnableStorage.Layout; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ function __Ownable_init() internal onlyInitializing { __Context_init_unchained(); __Ownable_init_unchained(); } function __Ownable_init_unchained() internal onlyInitializing { _transferOwnership(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return OwnableStorage.layout()._owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { 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 = OwnableStorage.layout()._owner; OwnableStorage.layout()._owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (proxy/utils/Initializable.sol) pragma solidity ^0.8.0; import "../../utils/AddressUpgradeable.sol"; import { InitializableStorage } from "./InitializableStorage.sol"; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. * * [CAUTION] * ==== * Avoid leaving a contract uninitialized. * * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation * contract, which may impact the proxy. To initialize the implementation contract, you can either invoke the * initializer manually, or you can include a constructor to automatically mark it as initialized when it is deployed: * * [.hljs-theme-light.nopadding] * ``` * /// @custom:oz-upgrades-unsafe-allow constructor * constructor() initializer {} * ``` * ==== */ abstract contract Initializable { /** * @dev Modifier to protect an initializer function from being invoked twice. */ modifier initializer() { // If the contract is initializing we ignore whether _initialized is set in order to support multiple // inheritance patterns, but we only do this in the context of a constructor, because in other contexts the // contract may have been reentered. require(InitializableStorage.layout()._initializing ? _isConstructor() : !InitializableStorage.layout()._initialized, "Initializable: contract is already initialized"); bool isTopLevelCall = !InitializableStorage.layout()._initializing; if (isTopLevelCall) { InitializableStorage.layout()._initializing = true; InitializableStorage.layout()._initialized = true; } _; if (isTopLevelCall) { InitializableStorage.layout()._initializing = false; } } /** * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the * {initializer} modifier, directly or indirectly. */ modifier onlyInitializing() { require(InitializableStorage.layout()._initializing, "Initializable: contract is not initializing"); _; } function _isConstructor() private view returns (bool) { return !AddressUpgradeable.isContract(address(this)); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import { Initializable } from "./Initializable.sol"; library InitializableStorage { struct Layout { /* * @dev Indicates that the contract has been initialized. */ bool _initialized; /* * @dev Indicates that the contract is in the process of being initialized. */ bool _initializing; } bytes32 internal constant STORAGE_SLOT = keccak256('openzepplin.contracts.storage.Initializable'); function layout() internal pure returns (Layout storage l) { bytes32 slot = STORAGE_SLOT; assembly { l.slot := slot } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library AddressUpgradeable { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; import "../proxy/utils/Initializable.sol"; /** * @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 ContextUpgradeable is Initializable { function __Context_init() internal onlyInitializing { __Context_init_unchained(); } function __Context_init_unchained() internal onlyInitializing { } 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/escrow/ConditionalEscrow.sol) pragma solidity ^0.8.0; import "./EscrowUpgradeable.sol"; import "../../proxy/utils/Initializable.sol"; /** * @title ConditionalEscrow * @dev Base abstract escrow to only allow withdrawal if a condition is met. * @dev Intended usage: See {Escrow}. Same usage guidelines apply here. */ abstract contract ConditionalEscrowUpgradeable is Initializable, EscrowUpgradeable { function __ConditionalEscrow_init() internal onlyInitializing { __Context_init_unchained(); __Ownable_init_unchained(); __Escrow_init_unchained(); __ConditionalEscrow_init_unchained(); } function __ConditionalEscrow_init_unchained() internal onlyInitializing { } /** * @dev Returns whether an address is allowed to withdraw their funds. To be * implemented by derived contracts. * @param payee The destination address of the funds. */ function withdrawalAllowed(address payee) public view virtual returns (bool); function withdraw(address payable payee) public virtual override { require(withdrawalAllowed(payee), "ConditionalEscrow: payee is not allowed to withdraw"); super.withdraw(payee); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import { EscrowUpgradeable } from "./EscrowUpgradeable.sol"; library EscrowStorage { struct Layout { mapping(address => uint256) _deposits; } bytes32 internal constant STORAGE_SLOT = keccak256('openzepplin.contracts.storage.Escrow'); function layout() internal pure returns (Layout storage l) { bytes32 slot = STORAGE_SLOT; assembly { l.slot := slot } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/escrow/Escrow.sol) pragma solidity ^0.8.0; import "../../access/OwnableUpgradeable.sol"; import "../AddressUpgradeable.sol"; import { EscrowStorage } from "./EscrowStorage.sol"; import "../../proxy/utils/Initializable.sol"; /** * @title Escrow * @dev Base escrow contract, holds funds designated for a payee until they * withdraw them. * * Intended usage: This contract (and derived escrow contracts) should be a * standalone contract, that only interacts with the contract that instantiated * it. That way, it is guaranteed that all Ether will be handled according to * the `Escrow` rules, and there is no need to check for payable functions or * transfers in the inheritance tree. The contract that uses the escrow as its * payment method should be its owner, and provide public methods redirecting * to the escrow's deposit and withdraw. */ contract EscrowUpgradeable is Initializable, OwnableUpgradeable { function initialize() public virtual initializer { __Escrow_init(); } using EscrowStorage for EscrowStorage.Layout; function __Escrow_init() internal onlyInitializing { __Context_init_unchained(); __Ownable_init_unchained(); __Escrow_init_unchained(); } function __Escrow_init_unchained() internal onlyInitializing { } using AddressUpgradeable for address payable; event Deposited(address indexed payee, uint256 weiAmount); event Withdrawn(address indexed payee, uint256 weiAmount); function depositsOf(address payee) public view returns (uint256) { return EscrowStorage.layout()._deposits[payee]; } /** * @dev Stores the sent amount as credit to be withdrawn. * @param payee The destination address of the funds. */ function deposit(address payee) public payable virtual onlyOwner { uint256 amount = msg.value; EscrowStorage.layout()._deposits[payee] += amount; emit Deposited(payee, amount); } /** * @dev Withdraw accumulated balance for a payee, forwarding all gas to the * recipient. * * WARNING: Forwarding all gas opens the door to reentrancy vulnerabilities. * Make sure you trust the recipient, or are either following the * checks-effects-interactions pattern or using {ReentrancyGuard}. * * @param payee The address whose funds will be withdrawn and transferred to. */ function withdraw(address payable payee) public virtual onlyOwner { uint256 payment = EscrowStorage.layout()._deposits[payee]; EscrowStorage.layout()._deposits[payee] = 0; payee.sendValue(payment); emit Withdrawn(payee, payment); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165Upgradeable.sol"; import "../../proxy/utils/Initializable.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 ERC165Upgradeable is Initializable, IERC165Upgradeable { function __ERC165_init() internal onlyInitializing { __ERC165_init_unchained(); } function __ERC165_init_unchained() internal onlyInitializing { } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165Upgradeable).interfaceId; } }
// 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 IERC165Upgradeable { /** * @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 v4.4.1 (utils/Strings.sol) pragma solidity ^0.8.0; /** * @dev String operations. */ library StringsUpgradeable { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/structs/EnumerableSet.sol) pragma solidity ^0.8.0; /** * @dev Library for managing * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive * types. * * Sets have the following properties: * * - Elements are added, removed, and checked for existence in constant time * (O(1)). * - Elements are enumerated in O(n). No guarantees are made on the ordering. * * ``` * contract Example { * // Add the library methods * using EnumerableSet for EnumerableSet.AddressSet; * * // Declare a set state variable * EnumerableSet.AddressSet private mySet; * } * ``` * * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`) * and `uint256` (`UintSet`) are supported. */ library EnumerableSetUpgradeable { // To implement this library for multiple types with as little code // repetition as possible, we write it in terms of a generic Set type with // bytes32 values. // The Set implementation uses private functions, and user-facing // implementations (such as AddressSet) are just wrappers around the // underlying Set. // This means that we can only create new EnumerableSets for types that fit // in bytes32. struct Set { // Storage of set values bytes32[] _values; // Position of the value in the `values` array, plus 1 because index 0 // means a value is not in the set. mapping(bytes32 => uint256) _indexes; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function _add(Set storage set, bytes32 value) private returns (bool) { if (!_contains(set, value)) { set._values.push(value); // The value is stored at length-1, but we add 1 to all indexes // and use 0 as a sentinel value set._indexes[value] = set._values.length; return true; } else { return false; } } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function _remove(Set storage set, bytes32 value) private returns (bool) { // We read and store the value's index to prevent multiple reads from the same storage slot uint256 valueIndex = set._indexes[value]; if (valueIndex != 0) { // Equivalent to contains(set, value) // To delete an element from the _values array in O(1), we swap the element to delete with the last one in // the array, and then remove the last element (sometimes called as 'swap and pop'). // This modifies the order of the array, as noted in {at}. uint256 toDeleteIndex = valueIndex - 1; uint256 lastIndex = set._values.length - 1; if (lastIndex != toDeleteIndex) { bytes32 lastvalue = set._values[lastIndex]; // Move the last value to the index where the value to delete is set._values[toDeleteIndex] = lastvalue; // Update the index for the moved value set._indexes[lastvalue] = valueIndex; // Replace lastvalue's index to valueIndex } // Delete the slot where the moved value was stored set._values.pop(); // Delete the index for the deleted slot delete set._indexes[value]; return true; } else { return false; } } /** * @dev Returns true if the value is in the set. O(1). */ function _contains(Set storage set, bytes32 value) private view returns (bool) { return set._indexes[value] != 0; } /** * @dev Returns the number of values on the set. O(1). */ function _length(Set storage set) private view returns (uint256) { return set._values.length; } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function _at(Set storage set, uint256 index) private view returns (bytes32) { return set._values[index]; } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function _values(Set storage set) private view returns (bytes32[] memory) { return set._values; } // Bytes32Set struct Bytes32Set { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _add(set._inner, value); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) { return _remove(set._inner, value); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) { return _contains(set._inner, value); } /** * @dev Returns the number of values in the set. O(1). */ function length(Bytes32Set storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) { return _at(set._inner, index); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(Bytes32Set storage set) internal view returns (bytes32[] memory) { return _values(set._inner); } // AddressSet struct AddressSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(AddressSet storage set, address value) internal returns (bool) { return _add(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(AddressSet storage set, address value) internal returns (bool) { return _remove(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(AddressSet storage set, address value) internal view returns (bool) { return _contains(set._inner, bytes32(uint256(uint160(value)))); } /** * @dev Returns the number of values in the set. O(1). */ function length(AddressSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(AddressSet storage set, uint256 index) internal view returns (address) { return address(uint160(uint256(_at(set._inner, index)))); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(AddressSet storage set) internal view returns (address[] memory) { bytes32[] memory store = _values(set._inner); address[] memory result; assembly { result := store } return result; } // UintSet struct UintSet { Set _inner; } /** * @dev Add a value to a set. O(1). * * Returns true if the value was added to the set, that is if it was not * already present. */ function add(UintSet storage set, uint256 value) internal returns (bool) { return _add(set._inner, bytes32(value)); } /** * @dev Removes a value from a set. O(1). * * Returns true if the value was removed from the set, that is if it was * present. */ function remove(UintSet storage set, uint256 value) internal returns (bool) { return _remove(set._inner, bytes32(value)); } /** * @dev Returns true if the value is in the set. O(1). */ function contains(UintSet storage set, uint256 value) internal view returns (bool) { return _contains(set._inner, bytes32(value)); } /** * @dev Returns the number of values on the set. O(1). */ function length(UintSet storage set) internal view returns (uint256) { return _length(set._inner); } /** * @dev Returns the value stored at position `index` in the set. O(1). * * Note that there are no guarantees on the ordering of values inside the * array, and it may change when more values are added or removed. * * Requirements: * * - `index` must be strictly less than {length}. */ function at(UintSet storage set, uint256 index) internal view returns (uint256) { return uint256(_at(set._inner, index)); } /** * @dev Return the entire set in an array * * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that * this function has an unbounded cost, and using it as part of a state-changing function may render the function * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block. */ function values(UintSet storage set) internal view returns (uint256[] memory) { bytes32[] memory store = _values(set._inner); uint256[] memory result; assembly { result := store } return result; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /******************************************************************************\ * Author: Nick Mudge <[email protected]> (https://twitter.com/mudgen) * EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535 /******************************************************************************/ interface IDiamondCut { enum FacetCutAction {Add, Replace, Remove} // Add=0, Replace=1, Remove=2 struct FacetCut { address facetAddress; FacetCutAction action; bytes4[] functionSelectors; } /// @notice Add/replace/remove any number of functions and optionally execute /// a function with delegatecall /// @param _diamondCut Contains the facet addresses and function selectors /// @param _init The address of the contract or facet to execute _calldata /// @param _calldata A function call, including function selector and arguments /// _calldata is executed with delegatecall on _init function diamondCut( FacetCut[] calldata _diamondCut, address _init, bytes calldata _calldata ) external; event DiamondCut(FacetCut[] _diamondCut, address _init, bytes _calldata); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /******************************************************************************\ * Author: Nick Mudge <[email protected]> (https://twitter.com/mudgen) * EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535 /******************************************************************************/ import { IDiamondCut } from "../interfaces/IDiamondCut.sol"; // Remember to add the loupe functions from DiamondLoupeFacet to the diamond. // The loupe functions are required by the EIP2535 Diamonds standard error InitializationFunctionReverted(address _initializationContractAddress, bytes _calldata); library LibDiamond { bytes32 constant DIAMOND_STORAGE_POSITION = keccak256("diamond.standard.diamond.storage"); struct DiamondStorage { // maps function selectors to the facets that execute the functions. // and maps the selectors to their position in the selectorSlots array. // func selector => address facet, selector position mapping(bytes4 => bytes32) facets; // array of slots of function selectors. // each slot holds 8 function selectors. mapping(uint256 => bytes32) selectorSlots; // The number of function selectors in selectorSlots uint16 selectorCount; // Used to query if a contract implements an interface. // Used to implement ERC-165. mapping(bytes4 => bool) supportedInterfaces; // owner of the contract address contractOwner; } function diamondStorage() internal pure returns (DiamondStorage storage ds) { bytes32 position = DIAMOND_STORAGE_POSITION; assembly { ds.slot := position } } event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); function setContractOwner(address _newOwner) internal { DiamondStorage storage ds = diamondStorage(); address previousOwner = ds.contractOwner; ds.contractOwner = _newOwner; emit OwnershipTransferred(previousOwner, _newOwner); } function contractOwner() internal view returns (address contractOwner_) { contractOwner_ = diamondStorage().contractOwner; } function enforceIsContractOwner() internal view { require(msg.sender == diamondStorage().contractOwner, "LibDiamond: Must be contract owner"); } event DiamondCut(IDiamondCut.FacetCut[] _diamondCut, address _init, bytes _calldata); bytes32 constant CLEAR_ADDRESS_MASK = bytes32(uint256(0xffffffffffffffffffffffff)); bytes32 constant CLEAR_SELECTOR_MASK = bytes32(uint256(0xffffffff << 224)); // Internal function version of diamondCut // This code is almost the same as the external diamondCut, // except it is using 'Facet[] memory _diamondCut' instead of // 'Facet[] calldata _diamondCut'. // The code is duplicated to prevent copying calldata to memory which // causes an error for a two dimensional array. function diamondCut( IDiamondCut.FacetCut[] memory _diamondCut, address _init, bytes memory _calldata ) internal { DiamondStorage storage ds = diamondStorage(); uint256 originalSelectorCount = ds.selectorCount; uint256 selectorCount = originalSelectorCount; bytes32 selectorSlot; // Check if last selector slot is not full // "selectorCount & 7" is a gas efficient modulo by eight "selectorCount % 8" if (selectorCount & 7 > 0) { // get last selectorSlot // "selectorSlot >> 3" is a gas efficient division by 8 "selectorSlot / 8" selectorSlot = ds.selectorSlots[selectorCount >> 3]; } // loop through diamond cut for (uint256 facetIndex; facetIndex < _diamondCut.length; ) { (selectorCount, selectorSlot) = addReplaceRemoveFacetSelectors( selectorCount, selectorSlot, _diamondCut[facetIndex].facetAddress, _diamondCut[facetIndex].action, _diamondCut[facetIndex].functionSelectors ); unchecked { facetIndex++; } } if (selectorCount != originalSelectorCount) { ds.selectorCount = uint16(selectorCount); } // If last selector slot is not full // "selectorCount & 7" is a gas efficient modulo by eight "selectorCount % 8" if (selectorCount & 7 > 0) { // "selectorSlot >> 3" is a gas efficient division by 8 "selectorSlot / 8" ds.selectorSlots[selectorCount >> 3] = selectorSlot; } emit DiamondCut(_diamondCut, _init, _calldata); initializeDiamondCut(_init, _calldata); } function addReplaceRemoveFacetSelectors( uint256 _selectorCount, bytes32 _selectorSlot, address _newFacetAddress, IDiamondCut.FacetCutAction _action, bytes4[] memory _selectors ) internal returns (uint256, bytes32) { DiamondStorage storage ds = diamondStorage(); require(_selectors.length > 0, "LibDiamondCut: No selectors in facet to cut"); if (_action == IDiamondCut.FacetCutAction.Add) { enforceHasContractCode(_newFacetAddress, "LibDiamondCut: Add facet has no code"); for (uint256 selectorIndex; selectorIndex < _selectors.length; ) { bytes4 selector = _selectors[selectorIndex]; bytes32 oldFacet = ds.facets[selector]; require(address(bytes20(oldFacet)) == address(0), "LibDiamondCut: Can't add function that already exists"); // add facet for selector ds.facets[selector] = bytes20(_newFacetAddress) | bytes32(_selectorCount); // "_selectorCount & 7" is a gas efficient modulo by eight "_selectorCount % 8" // " << 5 is the same as multiplying by 32 ( * 32) uint256 selectorInSlotPosition = (_selectorCount & 7) << 5; // clear selector position in slot and add selector _selectorSlot = (_selectorSlot & ~(CLEAR_SELECTOR_MASK >> selectorInSlotPosition)) | (bytes32(selector) >> selectorInSlotPosition); // if slot is full then write it to storage if (selectorInSlotPosition == 224) { // "_selectorSlot >> 3" is a gas efficient division by 8 "_selectorSlot / 8" ds.selectorSlots[_selectorCount >> 3] = _selectorSlot; _selectorSlot = 0; } _selectorCount++; unchecked { selectorIndex++; } } } else if (_action == IDiamondCut.FacetCutAction.Replace) { enforceHasContractCode(_newFacetAddress, "LibDiamondCut: Replace facet has no code"); for (uint256 selectorIndex; selectorIndex < _selectors.length; ) { bytes4 selector = _selectors[selectorIndex]; bytes32 oldFacet = ds.facets[selector]; address oldFacetAddress = address(bytes20(oldFacet)); // only useful if immutable functions exist require(oldFacetAddress != address(this), "LibDiamondCut: Can't replace immutable function"); require(oldFacetAddress != _newFacetAddress, "LibDiamondCut: Can't replace function with same function"); require(oldFacetAddress != address(0), "LibDiamondCut: Can't replace function that doesn't exist"); // replace old facet address ds.facets[selector] = (oldFacet & CLEAR_ADDRESS_MASK) | bytes20(_newFacetAddress); unchecked { selectorIndex++; } } } else if (_action == IDiamondCut.FacetCutAction.Remove) { require(_newFacetAddress == address(0), "LibDiamondCut: Remove facet address must be address(0)"); // "_selectorCount >> 3" is a gas efficient division by 8 "_selectorCount / 8" uint256 selectorSlotCount = _selectorCount >> 3; // "_selectorCount & 7" is a gas efficient modulo by eight "_selectorCount % 8" uint256 selectorInSlotIndex = _selectorCount & 7; for (uint256 selectorIndex; selectorIndex < _selectors.length; ) { if (selectorInSlotIndex == 0) { // get last selectorSlot selectorSlotCount--; _selectorSlot = ds.selectorSlots[selectorSlotCount]; selectorInSlotIndex = 7; } else { selectorInSlotIndex--; } bytes4 lastSelector; uint256 oldSelectorsSlotCount; uint256 oldSelectorInSlotPosition; // adding a block here prevents stack too deep error { bytes4 selector = _selectors[selectorIndex]; bytes32 oldFacet = ds.facets[selector]; require(address(bytes20(oldFacet)) != address(0), "LibDiamondCut: Can't remove function that doesn't exist"); // only useful if immutable functions exist require(address(bytes20(oldFacet)) != address(this), "LibDiamondCut: Can't remove immutable function"); // replace selector with last selector in ds.facets // gets the last selector // " << 5 is the same as multiplying by 32 ( * 32) lastSelector = bytes4(_selectorSlot << (selectorInSlotIndex << 5)); if (lastSelector != selector) { // update last selector slot position info ds.facets[lastSelector] = (oldFacet & CLEAR_ADDRESS_MASK) | bytes20(ds.facets[lastSelector]); } delete ds.facets[selector]; uint256 oldSelectorCount = uint16(uint256(oldFacet)); // "oldSelectorCount >> 3" is a gas efficient division by 8 "oldSelectorCount / 8" oldSelectorsSlotCount = oldSelectorCount >> 3; // "oldSelectorCount & 7" is a gas efficient modulo by eight "oldSelectorCount % 8" // " << 5 is the same as multiplying by 32 ( * 32) oldSelectorInSlotPosition = (oldSelectorCount & 7) << 5; } if (oldSelectorsSlotCount != selectorSlotCount) { bytes32 oldSelectorSlot = ds.selectorSlots[oldSelectorsSlotCount]; // clears the selector we are deleting and puts the last selector in its place. oldSelectorSlot = (oldSelectorSlot & ~(CLEAR_SELECTOR_MASK >> oldSelectorInSlotPosition)) | (bytes32(lastSelector) >> oldSelectorInSlotPosition); // update storage with the modified slot ds.selectorSlots[oldSelectorsSlotCount] = oldSelectorSlot; } else { // clears the selector we are deleting and puts the last selector in its place. _selectorSlot = (_selectorSlot & ~(CLEAR_SELECTOR_MASK >> oldSelectorInSlotPosition)) | (bytes32(lastSelector) >> oldSelectorInSlotPosition); } if (selectorInSlotIndex == 0) { delete ds.selectorSlots[selectorSlotCount]; _selectorSlot = 0; } unchecked { selectorIndex++; } } _selectorCount = selectorSlotCount * 8 + selectorInSlotIndex; } else { revert("LibDiamondCut: Incorrect FacetCutAction"); } return (_selectorCount, _selectorSlot); } function initializeDiamondCut(address _init, bytes memory _calldata) internal { if (_init == address(0)) { return; } enforceHasContractCode(_init, "LibDiamondCut: _init address has no code"); (bool success, bytes memory error) = _init.delegatecall(_calldata); if (!success) { if (error.length > 0) { // bubble up error /// @solidity memory-safe-assembly assembly { let returndata_size := mload(error) revert(add(32, error), returndata_size) } } else { revert InitializationFunctionReverted(_init, _calldata); } } } function enforceHasContractCode(address _contract, string memory _errorMessage) internal view { uint256 contractSize; assembly { contractSize := extcodesize(_contract) } require(contractSize > 0, _errorMessage); } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.2; import "@gnus.ai/contracts-upgradeable-diamond/access/AccessControlEnumerableUpgradeable.sol"; import "@gnus.ai/contracts-upgradeable-diamond/proxy/utils/Initializable.sol"; import "contracts-starter/contracts/libraries/LibDiamond.sol"; abstract contract GeniusAccessControl is Initializable, AccessControlEnumerableUpgradeable { bytes32 constant public UPGRADER_ROLE = keccak256("UPGRADER_ROLE"); function __GeniusAccessControl_init() internal onlyInitializing onlySuperAdminRole { __AccessControlEnumerable_init_unchained(); __GeniusAccessControl_init_unchained(); } function __GeniusAccessControl_init_unchained() onlyInitializing internal { address superAdmin = _msgSender(); _grantRole(DEFAULT_ADMIN_ROLE, superAdmin); _grantRole(UPGRADER_ROLE, superAdmin); } function renounceRole(bytes32 role, address account) public override(IAccessControlUpgradeable) { require(!(hasRole(DEFAULT_ADMIN_ROLE, account) && (LibDiamond.diamondStorage().contractOwner == account)), "Cannot renounce superAdmin from Admin Role"); super.renounceRole(role, account); } function revokeRole(bytes32 role, address account) public override(IAccessControlUpgradeable) { require(!(hasRole(DEFAULT_ADMIN_ROLE, account) && (LibDiamond.diamondStorage().contractOwner == account)), "Cannot revoke superAdmin from Admin Role"); super.revokeRole(role, account); } modifier onlySuperAdminRole { require(LibDiamond.diamondStorage().contractOwner == msg.sender, "Only SuperAdmin allowed"); _; } }
{ "optimizer": { "enabled": true, "runs": 1000 }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "libraries": {} }
[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"payee","type":"address"},{"indexed":false,"internalType":"uint256","name":"weiAmount","type":"uint256"}],"name":"Deposited","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"payee","type":"address"},{"indexed":false,"internalType":"uint256","name":"weiAmount","type":"uint256"}],"name":"Withdrawn","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"EscrowAIJob_Initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"UPGRADER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"payee","type":"address"}],"name":"deposit","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"payee","type":"address"}],"name":"depositsOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getRoleMember","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleMemberCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","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":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address payable","name":"payee","type":"address"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"payee","type":"address"}],"name":"withdrawalAllowed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"}]
Contract Creation Code
608060405234801561001057600080fd5b50611a2d806100206000396000f3fe6080604052600436106101445760003560e01c80638da5cb5b116100c0578063d547741f11610074578063f2fde38b11610059578063f2fde38b1461041d578063f340fa011461043d578063f72c0d8b1461045057600080fd5b8063d547741f146103a8578063e3a9db1a146103c857600080fd5b806391d14854116100a557806391d148541461030e578063a217fddf14610373578063ca15c8731461038857600080fd5b80638da5cb5b1461029d5780639010d07c146102ee57600080fd5b806336568abe11610117578063685ca194116100fc578063685ca19414610252578063715018a6146102735780638129fc1c1461028857600080fd5b806336568abe1461021257806351cff8d91461023257600080fd5b806301ffc9a7146101495780630dbc00c71461017e578063248a9ca3146101955780632f2ff15d146101f2575b600080fd5b34801561015557600080fd5b5061016961016436600461176f565b610484565b60405190151581526020015b60405180910390f35b34801561018a57600080fd5b506101936104c8565b005b3480156101a157600080fd5b506101e46101b0366004611799565b60009081527f790f2e6a69a6ef47d9d055fc71267d8ba088e4aaa30d0fa0755c430237a51b2f602052604090206001015490565b604051908152602001610175565b3480156101fe57600080fd5b5061019361020d3660046117c7565b61067e565b34801561021e57600080fd5b5061019361022d3660046117c7565b6106c7565b34801561023e57600080fd5b5061019361024d3660046117f7565b6107c4565b34801561025e57600080fd5b5061016961026d3660046117f7565b50600090565b34801561027f57600080fd5b50610193610832565b34801561029457600080fd5b506101936108c6565b3480156102a957600080fd5b507f754cc1ec880200e3f5bd6680f16da4891fd34ff44d9b3863bab54df32cee86f8546001600160a01b03165b6040516001600160a01b039091168152602001610175565b3480156102fa57600080fd5b506102d6610309366004611814565b6109d1565b34801561031a57600080fd5b506101696103293660046117c7565b60009182527f790f2e6a69a6ef47d9d055fc71267d8ba088e4aaa30d0fa0755c430237a51b2f602090815260408084206001600160a01b0393909316845291905290205460ff1690565b34801561037f57600080fd5b506101e4600081565b34801561039457600080fd5b506101e46103a3366004611799565b610a0f565b3480156103b457600080fd5b506101936103c33660046117c7565b610a45565b3480156103d457600080fd5b506101e46103e33660046117f7565b6001600160a01b031660009081527fc8a184c80c7734a8d16664c446e17c91afb0fc2c3d492e67cda4cd0f9f62019d602052604090205490565b34801561042957600080fd5b506101936104383660046117f7565b610b3e565b61019361044b3660046117f7565b610c4b565b34801561045c57600080fd5b506101e47f189ab7a9244df0848122154315af71fe140f3db0fe014031783b0946b8c9d2e381565b60006001600160e01b031982167f5a05180f0000000000000000000000000000000000000000000000000000000014806104c257506104c282610d63565b92915050565b6000805160206119d883398151915254610100900460ff166104fd576000805160206119d88339815191525460ff1615610501565b303b155b6105785760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a656400000000000000000000000000000000000060648201526084015b60405180910390fd5b6000805160206119d883398151915254610100900460ff161580156105b4576000805160206119d8833981519152805461ffff19166101011790555b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c1320546001600160a01b0316331461062d5760405162461bcd60e51b815260206004820152601760248201527f4f6e6c7920537570657241646d696e20616c6c6f776564000000000000000000604482015260640161056f565b610635610dca565b6000805160206119d8833981519152805460ff19169055801561067b5760006000805160206119d88339815191525b80549115156101000261ff00199092169190911790555b50565b60008281527f790f2e6a69a6ef47d9d055fc71267d8ba088e4aaa30d0fa0755c430237a51b2f60205260409020600101546106b881610e62565b6106c28383610e6c565b505050565b6001600160a01b03811660009081527fae9750a683df0e9d689c6fd3459f8c33d91da8761b8ac99c7bad1d255a631846602052604090205460ff16801561074357506001600160a01b0381167fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c600401546001600160a01b0316145b156107b65760405162461bcd60e51b815260206004820152602a60248201527f43616e6e6f742072656e6f756e636520737570657241646d696e2066726f6d2060448201527f41646d696e20526f6c6500000000000000000000000000000000000000000000606482015260840161056f565b6107c08282610ead565b5050565b60405162461bcd60e51b815260206004820152603360248201527f436f6e646974696f6e616c457363726f773a207061796565206973206e6f742060448201527f616c6c6f77656420746f20776974686472617700000000000000000000000000606482015260840161056f565b336108647f754cc1ec880200e3f5bd6680f16da4891fd34ff44d9b3863bab54df32cee86f8546001600160a01b031690565b6001600160a01b0316146108ba5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161056f565b6108c46000610f35565b565b6000805160206119d883398151915254610100900460ff166108fb576000805160206119d88339815191525460ff16156108ff565b303b155b6109715760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a6564000000000000000000000000000000000000606482015260840161056f565b6000805160206119d883398151915254610100900460ff161580156109ad576000805160206119d8833981519152805461ffff19166101011790555b6109b5610fbe565b801561067b5760006000805160206119d8833981519152610664565b60008281527f0a626c3e9de8986f5b7a00bbc89d7b4ba768b895440372b07cda519d5c37a66760205260408120610a089083611046565b9392505050565b60008181527f0a626c3e9de8986f5b7a00bbc89d7b4ba768b895440372b07cda519d5c37a667602052604081206104c290611052565b6001600160a01b03811660009081527fae9750a683df0e9d689c6fd3459f8c33d91da8761b8ac99c7bad1d255a631846602052604090205460ff168015610ac157506001600160a01b0381167fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c600401546001600160a01b0316145b15610b345760405162461bcd60e51b815260206004820152602860248201527f43616e6e6f74207265766f6b6520737570657241646d696e2066726f6d20416460448201527f6d696e20526f6c65000000000000000000000000000000000000000000000000606482015260840161056f565b6107c0828261105c565b33610b707f754cc1ec880200e3f5bd6680f16da4891fd34ff44d9b3863bab54df32cee86f8546001600160a01b031690565b6001600160a01b031614610bc65760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161056f565b6001600160a01b038116610c425760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161056f565b61067b81610f35565b33610c7d7f754cc1ec880200e3f5bd6680f16da4891fd34ff44d9b3863bab54df32cee86f8546001600160a01b031690565b6001600160a01b031614610cd35760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161056f565b6001600160a01b03811660009081527fc8a184c80c7734a8d16664c446e17c91afb0fc2c3d492e67cda4cd0f9f62019d6020526040812080543492839291610d1c90849061184c565b90915550506040518181526001600160a01b038316907f2da466a7b24304f47e87fa2e1e5a81b9831ce54fec19055ce277ca2f39ba42c49060200160405180910390a25050565b60006001600160e01b031982167f7965db0b0000000000000000000000000000000000000000000000000000000014806104c257507f01ffc9a7000000000000000000000000000000000000000000000000000000006001600160e01b03198316146104c2565b6000805160206119d883398151915254610100900460ff16610e425760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b606482015260840161056f565b610e4a6110a0565b610e52611118565b610e5a6110a0565b6108c46110a0565b61067b8133611199565b610e768282611238565b60008281527f0a626c3e9de8986f5b7a00bbc89d7b4ba768b895440372b07cda519d5c37a667602052604090206106c290826112fb565b6001600160a01b0381163314610f2b5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c660000000000000000000000000000000000606482015260840161056f565b6107c08282611310565b7f754cc1ec880200e3f5bd6680f16da4891fd34ff44d9b3863bab54df32cee86f880546001600160a01b038381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6000805160206119d883398151915254610100900460ff166110365760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b606482015260840161056f565b61103e6110a0565b610e5a611118565b6000610a088383611351565b60006104c2825490565b60008281527f790f2e6a69a6ef47d9d055fc71267d8ba088e4aaa30d0fa0755c430237a51b2f602052604090206001015461109681610e62565b6106c28383611310565b6000805160206119d883398151915254610100900460ff166108c45760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b606482015260840161056f565b6000805160206119d883398151915254610100900460ff166111905760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b606482015260840161056f565b6108c433610f35565b60008281527f790f2e6a69a6ef47d9d055fc71267d8ba088e4aaa30d0fa0755c430237a51b2f602090815260408083206001600160a01b038516845290915290205460ff166107c0576111f6816001600160a01b0316601461137b565b61120183602061137b565b604051602001611212929190611894565b60408051601f198184030181529082905262461bcd60e51b825261056f91600401611915565b60008281527f790f2e6a69a6ef47d9d055fc71267d8ba088e4aaa30d0fa0755c430237a51b2f602090815260408083206001600160a01b038516845290915290205460ff166107c05760008281527f790f2e6a69a6ef47d9d055fc71267d8ba088e4aaa30d0fa0755c430237a51b2f602090815260408083206001600160a01b0385168085529252808320805460ff1916600117905551339285917f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9190a45050565b6000610a08836001600160a01b03841661155c565b61131a82826115ab565b60008281527f0a626c3e9de8986f5b7a00bbc89d7b4ba768b895440372b07cda519d5c37a667602052604090206106c2908261166c565b600082600001828154811061136857611368611948565b9060005260206000200154905092915050565b6060600061138a83600261195e565b61139590600261184c565b67ffffffffffffffff8111156113ad576113ad61197d565b6040519080825280601f01601f1916602001820160405280156113d7576020820181803683370190505b5090507f30000000000000000000000000000000000000000000000000000000000000008160008151811061140e5761140e611948565b60200101906001600160f81b031916908160001a9053507f78000000000000000000000000000000000000000000000000000000000000008160018151811061145957611459611948565b60200101906001600160f81b031916908160001a905350600061147d84600261195e565b61148890600161184c565b90505b600181111561150d577f303132333435363738396162636465660000000000000000000000000000000085600f16601081106114c9576114c9611948565b1a60f81b8282815181106114df576114df611948565b60200101906001600160f81b031916908160001a90535060049490941c9361150681611993565b905061148b565b508315610a085760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e74604482015260640161056f565b60008181526001830160205260408120546115a3575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556104c2565b5060006104c2565b60008281527f790f2e6a69a6ef47d9d055fc71267d8ba088e4aaa30d0fa0755c430237a51b2f602090815260408083206001600160a01b038516845290915290205460ff16156107c05760008281527f790f2e6a69a6ef47d9d055fc71267d8ba088e4aaa30d0fa0755c430237a51b2f602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6000610a08836001600160a01b038416600081815260018301602052604081205480156117655760006116a06001836119aa565b85549091506000906116b4906001906119aa565b90508181146117195760008660000182815481106116d4576116d4611948565b90600052602060002001549050808760000184815481106116f7576116f7611948565b6000918252602080832090910192909255918252600188019052604090208390555b855486908061172a5761172a6119c1565b6001900381819060005260206000200160009055905585600101600086815260200190815260200160002060009055600193505050506104c2565b60009150506104c2565b60006020828403121561178157600080fd5b81356001600160e01b031981168114610a0857600080fd5b6000602082840312156117ab57600080fd5b5035919050565b6001600160a01b038116811461067b57600080fd5b600080604083850312156117da57600080fd5b8235915060208301356117ec816117b2565b809150509250929050565b60006020828403121561180957600080fd5b8135610a08816117b2565b6000806040838503121561182757600080fd5b50508035926020909101359150565b634e487b7160e01b600052601160045260246000fd5b6000821982111561185f5761185f611836565b500190565b60005b8381101561187f578181015183820152602001611867565b8381111561188e576000848401525b50505050565b7f416363657373436f6e74726f6c3a206163636f756e74200000000000000000008152600083516118cc816017850160208801611864565b7f206973206d697373696e6720726f6c65200000000000000000000000000000006017918401918201528351611909816028840160208801611864565b01602801949350505050565b6020815260008251806020840152611934816040850160208701611864565b601f01601f19169190910160400192915050565b634e487b7160e01b600052603260045260246000fd5b600081600019048311821515161561197857611978611836565b500290565b634e487b7160e01b600052604160045260246000fd5b6000816119a2576119a2611836565b506000190190565b6000828210156119bc576119bc611836565b500390565b634e487b7160e01b600052603160045260246000fdfe7a9c09dffb400f1c80d0455dcb8e56808aa28f0a58ad6480b85e9ec3328b6d9ba2646970667358221220b09dba3e0d0350f0bea7721930ac61af78c1275277be8768b789dd370d7ab6b164736f6c63430008090033
Deployed Bytecode
0x6080604052600436106101445760003560e01c80638da5cb5b116100c0578063d547741f11610074578063f2fde38b11610059578063f2fde38b1461041d578063f340fa011461043d578063f72c0d8b1461045057600080fd5b8063d547741f146103a8578063e3a9db1a146103c857600080fd5b806391d14854116100a557806391d148541461030e578063a217fddf14610373578063ca15c8731461038857600080fd5b80638da5cb5b1461029d5780639010d07c146102ee57600080fd5b806336568abe11610117578063685ca194116100fc578063685ca19414610252578063715018a6146102735780638129fc1c1461028857600080fd5b806336568abe1461021257806351cff8d91461023257600080fd5b806301ffc9a7146101495780630dbc00c71461017e578063248a9ca3146101955780632f2ff15d146101f2575b600080fd5b34801561015557600080fd5b5061016961016436600461176f565b610484565b60405190151581526020015b60405180910390f35b34801561018a57600080fd5b506101936104c8565b005b3480156101a157600080fd5b506101e46101b0366004611799565b60009081527f790f2e6a69a6ef47d9d055fc71267d8ba088e4aaa30d0fa0755c430237a51b2f602052604090206001015490565b604051908152602001610175565b3480156101fe57600080fd5b5061019361020d3660046117c7565b61067e565b34801561021e57600080fd5b5061019361022d3660046117c7565b6106c7565b34801561023e57600080fd5b5061019361024d3660046117f7565b6107c4565b34801561025e57600080fd5b5061016961026d3660046117f7565b50600090565b34801561027f57600080fd5b50610193610832565b34801561029457600080fd5b506101936108c6565b3480156102a957600080fd5b507f754cc1ec880200e3f5bd6680f16da4891fd34ff44d9b3863bab54df32cee86f8546001600160a01b03165b6040516001600160a01b039091168152602001610175565b3480156102fa57600080fd5b506102d6610309366004611814565b6109d1565b34801561031a57600080fd5b506101696103293660046117c7565b60009182527f790f2e6a69a6ef47d9d055fc71267d8ba088e4aaa30d0fa0755c430237a51b2f602090815260408084206001600160a01b0393909316845291905290205460ff1690565b34801561037f57600080fd5b506101e4600081565b34801561039457600080fd5b506101e46103a3366004611799565b610a0f565b3480156103b457600080fd5b506101936103c33660046117c7565b610a45565b3480156103d457600080fd5b506101e46103e33660046117f7565b6001600160a01b031660009081527fc8a184c80c7734a8d16664c446e17c91afb0fc2c3d492e67cda4cd0f9f62019d602052604090205490565b34801561042957600080fd5b506101936104383660046117f7565b610b3e565b61019361044b3660046117f7565b610c4b565b34801561045c57600080fd5b506101e47f189ab7a9244df0848122154315af71fe140f3db0fe014031783b0946b8c9d2e381565b60006001600160e01b031982167f5a05180f0000000000000000000000000000000000000000000000000000000014806104c257506104c282610d63565b92915050565b6000805160206119d883398151915254610100900460ff166104fd576000805160206119d88339815191525460ff1615610501565b303b155b6105785760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a656400000000000000000000000000000000000060648201526084015b60405180910390fd5b6000805160206119d883398151915254610100900460ff161580156105b4576000805160206119d8833981519152805461ffff19166101011790555b7fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c1320546001600160a01b0316331461062d5760405162461bcd60e51b815260206004820152601760248201527f4f6e6c7920537570657241646d696e20616c6c6f776564000000000000000000604482015260640161056f565b610635610dca565b6000805160206119d8833981519152805460ff19169055801561067b5760006000805160206119d88339815191525b80549115156101000261ff00199092169190911790555b50565b60008281527f790f2e6a69a6ef47d9d055fc71267d8ba088e4aaa30d0fa0755c430237a51b2f60205260409020600101546106b881610e62565b6106c28383610e6c565b505050565b6001600160a01b03811660009081527fae9750a683df0e9d689c6fd3459f8c33d91da8761b8ac99c7bad1d255a631846602052604090205460ff16801561074357506001600160a01b0381167fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c600401546001600160a01b0316145b156107b65760405162461bcd60e51b815260206004820152602a60248201527f43616e6e6f742072656e6f756e636520737570657241646d696e2066726f6d2060448201527f41646d696e20526f6c6500000000000000000000000000000000000000000000606482015260840161056f565b6107c08282610ead565b5050565b60405162461bcd60e51b815260206004820152603360248201527f436f6e646974696f6e616c457363726f773a207061796565206973206e6f742060448201527f616c6c6f77656420746f20776974686472617700000000000000000000000000606482015260840161056f565b336108647f754cc1ec880200e3f5bd6680f16da4891fd34ff44d9b3863bab54df32cee86f8546001600160a01b031690565b6001600160a01b0316146108ba5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161056f565b6108c46000610f35565b565b6000805160206119d883398151915254610100900460ff166108fb576000805160206119d88339815191525460ff16156108ff565b303b155b6109715760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a6564000000000000000000000000000000000000606482015260840161056f565b6000805160206119d883398151915254610100900460ff161580156109ad576000805160206119d8833981519152805461ffff19166101011790555b6109b5610fbe565b801561067b5760006000805160206119d8833981519152610664565b60008281527f0a626c3e9de8986f5b7a00bbc89d7b4ba768b895440372b07cda519d5c37a66760205260408120610a089083611046565b9392505050565b60008181527f0a626c3e9de8986f5b7a00bbc89d7b4ba768b895440372b07cda519d5c37a667602052604081206104c290611052565b6001600160a01b03811660009081527fae9750a683df0e9d689c6fd3459f8c33d91da8761b8ac99c7bad1d255a631846602052604090205460ff168015610ac157506001600160a01b0381167fc8fcad8db84d3cc18b4c41d551ea0ee66dd599cde068d998e57d5e09332c131c600401546001600160a01b0316145b15610b345760405162461bcd60e51b815260206004820152602860248201527f43616e6e6f74207265766f6b6520737570657241646d696e2066726f6d20416460448201527f6d696e20526f6c65000000000000000000000000000000000000000000000000606482015260840161056f565b6107c0828261105c565b33610b707f754cc1ec880200e3f5bd6680f16da4891fd34ff44d9b3863bab54df32cee86f8546001600160a01b031690565b6001600160a01b031614610bc65760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161056f565b6001600160a01b038116610c425760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f6464726573730000000000000000000000000000000000000000000000000000606482015260840161056f565b61067b81610f35565b33610c7d7f754cc1ec880200e3f5bd6680f16da4891fd34ff44d9b3863bab54df32cee86f8546001600160a01b031690565b6001600160a01b031614610cd35760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604482015260640161056f565b6001600160a01b03811660009081527fc8a184c80c7734a8d16664c446e17c91afb0fc2c3d492e67cda4cd0f9f62019d6020526040812080543492839291610d1c90849061184c565b90915550506040518181526001600160a01b038316907f2da466a7b24304f47e87fa2e1e5a81b9831ce54fec19055ce277ca2f39ba42c49060200160405180910390a25050565b60006001600160e01b031982167f7965db0b0000000000000000000000000000000000000000000000000000000014806104c257507f01ffc9a7000000000000000000000000000000000000000000000000000000006001600160e01b03198316146104c2565b6000805160206119d883398151915254610100900460ff16610e425760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b606482015260840161056f565b610e4a6110a0565b610e52611118565b610e5a6110a0565b6108c46110a0565b61067b8133611199565b610e768282611238565b60008281527f0a626c3e9de8986f5b7a00bbc89d7b4ba768b895440372b07cda519d5c37a667602052604090206106c290826112fb565b6001600160a01b0381163314610f2b5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c660000000000000000000000000000000000606482015260840161056f565b6107c08282611310565b7f754cc1ec880200e3f5bd6680f16da4891fd34ff44d9b3863bab54df32cee86f880546001600160a01b038381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6000805160206119d883398151915254610100900460ff166110365760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b606482015260840161056f565b61103e6110a0565b610e5a611118565b6000610a088383611351565b60006104c2825490565b60008281527f790f2e6a69a6ef47d9d055fc71267d8ba088e4aaa30d0fa0755c430237a51b2f602052604090206001015461109681610e62565b6106c28383611310565b6000805160206119d883398151915254610100900460ff166108c45760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b606482015260840161056f565b6000805160206119d883398151915254610100900460ff166111905760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b606482015260840161056f565b6108c433610f35565b60008281527f790f2e6a69a6ef47d9d055fc71267d8ba088e4aaa30d0fa0755c430237a51b2f602090815260408083206001600160a01b038516845290915290205460ff166107c0576111f6816001600160a01b0316601461137b565b61120183602061137b565b604051602001611212929190611894565b60408051601f198184030181529082905262461bcd60e51b825261056f91600401611915565b60008281527f790f2e6a69a6ef47d9d055fc71267d8ba088e4aaa30d0fa0755c430237a51b2f602090815260408083206001600160a01b038516845290915290205460ff166107c05760008281527f790f2e6a69a6ef47d9d055fc71267d8ba088e4aaa30d0fa0755c430237a51b2f602090815260408083206001600160a01b0385168085529252808320805460ff1916600117905551339285917f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9190a45050565b6000610a08836001600160a01b03841661155c565b61131a82826115ab565b60008281527f0a626c3e9de8986f5b7a00bbc89d7b4ba768b895440372b07cda519d5c37a667602052604090206106c2908261166c565b600082600001828154811061136857611368611948565b9060005260206000200154905092915050565b6060600061138a83600261195e565b61139590600261184c565b67ffffffffffffffff8111156113ad576113ad61197d565b6040519080825280601f01601f1916602001820160405280156113d7576020820181803683370190505b5090507f30000000000000000000000000000000000000000000000000000000000000008160008151811061140e5761140e611948565b60200101906001600160f81b031916908160001a9053507f78000000000000000000000000000000000000000000000000000000000000008160018151811061145957611459611948565b60200101906001600160f81b031916908160001a905350600061147d84600261195e565b61148890600161184c565b90505b600181111561150d577f303132333435363738396162636465660000000000000000000000000000000085600f16601081106114c9576114c9611948565b1a60f81b8282815181106114df576114df611948565b60200101906001600160f81b031916908160001a90535060049490941c9361150681611993565b905061148b565b508315610a085760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e74604482015260640161056f565b60008181526001830160205260408120546115a3575081546001818101845560008481526020808220909301849055845484825282860190935260409020919091556104c2565b5060006104c2565b60008281527f790f2e6a69a6ef47d9d055fc71267d8ba088e4aaa30d0fa0755c430237a51b2f602090815260408083206001600160a01b038516845290915290205460ff16156107c05760008281527f790f2e6a69a6ef47d9d055fc71267d8ba088e4aaa30d0fa0755c430237a51b2f602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6000610a08836001600160a01b038416600081815260018301602052604081205480156117655760006116a06001836119aa565b85549091506000906116b4906001906119aa565b90508181146117195760008660000182815481106116d4576116d4611948565b90600052602060002001549050808760000184815481106116f7576116f7611948565b6000918252602080832090910192909255918252600188019052604090208390555b855486908061172a5761172a6119c1565b6001900381819060005260206000200160009055905585600101600086815260200190815260200160002060009055600193505050506104c2565b60009150506104c2565b60006020828403121561178157600080fd5b81356001600160e01b031981168114610a0857600080fd5b6000602082840312156117ab57600080fd5b5035919050565b6001600160a01b038116811461067b57600080fd5b600080604083850312156117da57600080fd5b8235915060208301356117ec816117b2565b809150509250929050565b60006020828403121561180957600080fd5b8135610a08816117b2565b6000806040838503121561182757600080fd5b50508035926020909101359150565b634e487b7160e01b600052601160045260246000fd5b6000821982111561185f5761185f611836565b500190565b60005b8381101561187f578181015183820152602001611867565b8381111561188e576000848401525b50505050565b7f416363657373436f6e74726f6c3a206163636f756e74200000000000000000008152600083516118cc816017850160208801611864565b7f206973206d697373696e6720726f6c65200000000000000000000000000000006017918401918201528351611909816028840160208801611864565b01602801949350505050565b6020815260008251806020840152611934816040850160208701611864565b601f01601f19169190910160400192915050565b634e487b7160e01b600052603260045260246000fd5b600081600019048311821515161561197857611978611836565b500290565b634e487b7160e01b600052604160045260246000fd5b6000816119a2576119a2611836565b506000190190565b6000828210156119bc576119bc611836565b500390565b634e487b7160e01b600052603160045260246000fdfe7a9c09dffb400f1c80d0455dcb8e56808aa28f0a58ad6480b85e9ec3328b6d9ba2646970667358221220b09dba3e0d0350f0bea7721930ac61af78c1275277be8768b789dd370d7ab6b164736f6c63430008090033
Loading...
Loading
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.