Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
- Contract name:
- Decoder
- Optimization enabled
- true
- Compiler version
- v0.8.9+commit.e5eed63a
- Optimization runs
- 200
- EVM Version
- default
- Verified at
- 2025-02-28T09:28:36.338401Z
Contract source code
// Sources flattened with hardhat v2.22.17 https://hardhat.org // SPDX-License-Identifier: MIT // File contracts/interfaces/IDataCube.sol // Original license: SPDX_License_Identifier: MIT pragma solidity ^0.8.0; /// @notice Interface for HEX interface IDataCube { /// @notice this event is emitted when admin mints NFT HEX /// @param to receiver of new HEX /// @param tokenId id of new HEX /// @param quality quality of new HEX /// @param season BattlePass season of new HEX event HEXMinted( address indexed to, uint256 indexed tokenId, uint8 quality, uint256 season); /// @notice this event is emitted when HEX is burnt /// @param HEXTokenId id of NFT HEX /// @param HEXBackendTokenId if of backend nonNFT HEX event HEXBurnt( uint256 indexed HEXTokenId, uint256 HEXBackendTokenId); function version() external view returns (uint32); /// @notice during decoding, ValidatorLicenseContract calls this function to open HEX and mint GameItem /// @dev data cube will be burned. Emits "Burnt" event. Calls "mintFromCube" function from GameItemContract via IGameItem interface /// @param _HEXTokenId token id of specific HEX /// @param _HLTokenId token id of specific Hacker License /// @param _HEXQuality HEX quality /// @param _receiver receiver's address of new item /// @param _HEXBackendTokenId backend token id of specific HEX /// @param _data metadata URL function open( uint256 _HEXTokenId, uint256 _HLTokenId, uint8 _HEXQuality, address _receiver, uint256 _HEXBackendTokenId, string memory _data) external; /// @notice gets quality of specific HEX /// @return uint8 quality parameter of specific HEX function getCubeQuality(uint256 _tokenID) external view returns(uint8); /// @notice gets initial owner of specific HEX /// @return address of initial owner of specific HEX function getCubeInitialOwner(uint256 _tokenID) external view returns(address); function getFeeDependsOnQuality(uint8 _quality) external view returns(uint256); function burn(uint256 _tokenID) external; } // File contracts/interfaces/IGameItem.sol // Original license: SPDX_License_Identifier: MIT pragma solidity ^0.8.0; /// @notice Interface for GameItemContract interface IGameItem { /// @notice this event is emitted when NFT GameItem is minted /// @param to new owner of GameItem /// @param tokenId id ow new GameItem /// @param quality quality(0-4) of new GameItem /// @param hacker the hacker who minted this item /// @param licenseId the id of hacker license who minted this item event Minted( address indexed to, uint256 indexed tokenId, uint8 quality, address hacker, uint256 licenseId); event MintedForUser( address indexed to, uint256 indexed tokenId, uint8 quality, uint256 financialWalletPayment, address hacker, uint256 licenseId); function version() external view returns (uint32); /// @notice gets creator's address of specific GameItem /// @param _tokenId token id of specific GameItem /// @return minter's address function getItemCreator(uint256 _tokenId) external view returns (address); /// @notice returns hacker address of specific GameItem /// @param _tokenId token id of specific GameItem /// @return hacker's address function getItemHacker(uint256 _tokenId) external view returns (address); /// @notice returns hacker address of specific GameItem /// @param _tokenId token id of specific GameItem /// @return hacker's address function getItemValidator(uint256 _tokenId) external view returns (uint256); /// @notice gets quality of specific GameItem /// @param _tokenId token id of specific GameItem /// @return uint8 parameter. quality of GameItem function getItemQuality(uint256 _tokenId) external view returns (uint8); /// @notice gets season of specific GameItem /// @param _tokenId token id of specific GameItem /// @return uint256 parameter. season id function getItemSeason(uint256 _tokenId) external view returns (uint256); /// @notice gets market state of specific GameItem /// @param _tokenId token id of specific GameItem /// @return uint8 parameter. Market state of GameItem function getItemState(uint256 _tokenId) external view returns (uint8); /// @notice changes market state of specific GameItem /// @param _tokenId token id of specific GameItem /// @param _state (0-2) new item state function changeItemState(uint256 _tokenId, uint8 _state) external; /// @notice mints new GameItem /// @dev can be called only via DataCubeContract or ValidatorLicenseContract /// @dev emits "Minted" event /// @param _receiver receiver's address of new GameItem /// @param _HLTokenId token id of specific ValidatorLicense /// @param _seasonId token id of season /// @param _HEXQuality quality of new GameItem /// @param _metadataURL URL to metadata storage function mintFromCube( address _receiver, uint256 _HLTokenId, uint256 _seasonId, uint8 _HEXQuality, string memory _metadataURL) external; /// @notice mints new GameItem /// @dev can be called by user, with signature /// @dev sends GUNs to this contract address /// @param _HLTokenId token id of specific ValidatorLicense /// @param _seasonId token id of season /// @param _quality quality of new GameItem /// @param _price price(in GUNs) od DataCube decoding /// @param _metadataURL URL to metadata storage function mintForUser( uint256 _HLTokenId, uint256 _seasonId, uint8 _quality, uint256 _price, string memory _metadataURL, address receiver ) payable external; function burn(uint256 _tokenId) external; function bridgeBurn(uint256 _tokenId) external; function bridgeMint(address to, uint256 _tokenId) external; } // File contracts/interfaces/ILicenseStorage.sol // Original license: SPDX_License_Identifier: MIT pragma solidity ^0.8.0; interface ILicenseStorage { function version() external view returns (uint32); /// @notice initializes storage for specific HL, depends on rarity /// @param _tokenId token id of specific ValidatorLicense /// @param _rarity rarity of ValidatorLicense function initializeStorage(uint256 _tokenId, uint8 _rarity) payable external; /// @notice withdraws payment from specific HL storage during decoding process /// @param _tokenId token id of specific ValidatorLicense /// @param _amount amount of GUNs that will be transferred /// @param _to payment receiver function getPaymentFromLicenseStorage(uint256 _tokenId, uint256 _amount, address payable _to) external payable returns (bool); function getStorageCurrentValue(uint256 _tokenId) external view returns (uint256); function getStorageThreshold() external view returns (uint256); } // File contracts/interfaces/IValidatorLicense.sol // Original license: SPDX_License_Identifier: MIT pragma solidity ^0.8.0; /// @notice Interface for HackerLicense interface IValidatorLicense { /// @notice this event is emitted when admin mints HackerLicense /// @param account receiver of HackerLicense /// @param tokenId id of new HackerLicense /// @param rarity rarity of new HackerLicense /// @param activeMode - state of activation switcher event HackerLicenseMinted(address indexed account, uint256 indexed tokenId, uint8 indexed rarity, bool activeMode); /// @notice this event is emitted when hacker activates HackerLicense /// @param account owner(hacker) of HackerLicense event HackerLicenseActivated(address indexed account, uint256 indexed tokenId); /// @notice this event is emitted when hacker deactivates HackerLicense /// @param account owner(hacker) of HackerLicense event HackerLicenseDeactivated(address indexed account, uint256 indexed tokenId); function version() external view returns (uint32); /// @notice gets mode(activated or deactivated) of specific HackerLicense /// @param _tokenId token id of specific HackerLicense /// @return bool mode of specific HackerLicense function isActive(uint256 _tokenId) external view returns (bool); /// @notice gets rarity of specific HackerLicense /// @param _tokenId token id of specific HackerLicense /// @return uint8 rarity parameter of specific HackerLicense function getLicenseRarity(uint256 _tokenId) external view returns (uint8); function deactivateByLicenseStorage(uint256 _tokenId) external; /// TODO: SHOULD BE REMOVED WHEN BACKWARD-COMPATIBILITY WONT BE NECESSARY /// @notice gets mode(activated or deactivated) of specific ValidatorLicense /// @param _tokenID token id of specific ValidatorLicense /// @return bool mode of specific ValidatorLicense function getLicenseMode(uint256 _tokenID) external view returns(bool); } // File openzeppelin-contracts-upgradeable/access/IAccessControlUpgradeable.sol // Original license: SPDX_License_Identifier: MIT // OpenZeppelin Contracts v4.4.0 (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; } // File openzeppelin-contracts-upgradeable/proxy/utils/Initializable.sol // Original license: SPDX_License_Identifier: MIT // OpenZeppelin Contracts v4.4.0 (proxy/utils/Initializable.sol) pragma solidity ^0.8.0; /** * @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 a proxied contract can't have 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 Indicates that the contract has been initialized. */ bool private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Modifier to protect an initializer function from being invoked twice. */ modifier initializer() { require(_initializing || !_initialized, "Initializable: contract is already initialized"); bool isTopLevelCall = !_initializing; if (isTopLevelCall) { _initializing = true; _initialized = true; } _; if (isTopLevelCall) { _initializing = false; } } } // File openzeppelin-contracts-upgradeable/utils/ContextUpgradeable.sol // Original license: SPDX_License_Identifier: MIT // OpenZeppelin Contracts v4.4.0 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract ContextUpgradeable is Initializable { function __Context_init() internal initializer { __Context_init_unchained(); } function __Context_init_unchained() internal initializer { } function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } uint256[50] private __gap; } // File openzeppelin-contracts-upgradeable/utils/introspection/IERC165Upgradeable.sol // Original license: SPDX_License_Identifier: MIT // OpenZeppelin Contracts v4.4.0 (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); } // File openzeppelin-contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol // Original license: SPDX_License_Identifier: MIT // OpenZeppelin Contracts v4.4.0 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; /** * @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 initializer { __ERC165_init_unchained(); } function __ERC165_init_unchained() internal initializer { } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165Upgradeable).interfaceId; } uint256[50] private __gap; } // File openzeppelin-contracts-upgradeable/utils/StringsUpgradeable.sol // Original license: SPDX_License_Identifier: MIT // OpenZeppelin Contracts v4.4.0 (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); } } // File openzeppelin-contracts-upgradeable/access/AccessControlUpgradeable.sol // Original license: SPDX_License_Identifier: MIT // OpenZeppelin Contracts v4.4.0 (access/AccessControl.sol) pragma solidity ^0.8.0; /** * @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 { function __AccessControl_init() internal initializer { __Context_init_unchained(); __ERC165_init_unchained(); __AccessControl_init_unchained(); } function __AccessControl_init_unchained() internal initializer { } struct RoleData { mapping(address => bool) members; bytes32 adminRole; } mapping(bytes32 => RoleData) private _roles; 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, _msgSender()); _; } /** * @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 override returns (bool) { return _roles[role].members[account]; } /** * @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 { 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 override returns (bytes32) { return _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); _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)) { _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)) { _roles[role].members[account] = false; emit RoleRevoked(role, account, _msgSender()); } } uint256[49] private __gap; } // File openzeppelin-contracts-upgradeable/security/PausableUpgradeable.sol // Original license: SPDX_License_Identifier: MIT // OpenZeppelin Contracts v4.4.0 (security/Pausable.sol) pragma solidity ^0.8.0; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract PausableUpgradeable is Initializable, ContextUpgradeable { /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. */ function __Pausable_init() internal initializer { __Context_init_unchained(); __Pausable_init_unchained(); } function __Pausable_init_unchained() internal initializer { _paused = false; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { require(!paused(), "Pausable: paused"); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { require(paused(), "Pausable: not paused"); _; } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } uint256[49] private __gap; } // File contracts/PlatformSettings.sol // Original license: SPDX_License_Identifier: MIT pragma solidity ^0.8.0; /// @title A platform settings for OTG contracts /// @notice Admin can use this contract for granting and revoking roles, pause and unpause platform, set new wallets for fee receiving /// @dev This contract inherits 'Initializable', 'AccessControlUpgradeable', 'PausableUpgradeable' contracts form openzeppelin library contract PlatformSettings is Initializable, AccessControlUpgradeable, PausableUpgradeable{ bytes32 public constant SECONDARY_ADMIN_ROLE = keccak256("SECONDARY_ADMIN_ROLE"); bytes32 public constant BACKEND_ROLE = keccak256("BACKEND_ROLE"); uint256 public constant gunDecimals = 10**18; uint256 public constant PERCENT_DENOMINATOR = 100; // address of main admin address public initialAdmin; // address of financial wallet (withdraws GUNs from contract) address payable public financialWallet; // percentage that represents validator fee during decoding process uint256 public validatorFeePercentageForDecoding; // percentage that represents platform fee during decoding process uint256 public platformFeePercentageForDecoding; bytes32 public constant BRIDGE_ROLE = keccak256("BRIDGE_ROLE"); bytes32 public constant DECODER_ROLE = keccak256("DECODER_ROLE"); /// @notice this event is emitted when new financial wallet is set /// @param newWallet address of new financial wallet event ChangedFinancialWallet( address indexed newWallet ); error InvalidRole(address caller, bytes32 role); error IncorrectFeeDistribution(); error AlreadyHasRole(address account, bytes32 role); error AlreadyHasNotRole(address account, bytes32 role); /// @notice A disposable function for initializing contract /// @param _admin address of initial admin of contract /// @dev Grants caller with admin role /// @dev Also calls initializers of AccessControl and Pausable contracts. /// @dev Sets caller as an initialAdmin and financeWallet(wallet for receiving fees and royalties) /// @dev Sets initial fee percentage for decoding process function initialize( address _admin )public initializer{ __AccessControl_init(); __Pausable_init_unchained(); _setupRole(DEFAULT_ADMIN_ROLE, _admin); initialAdmin = _admin; financialWallet = payable(msg.sender); validatorFeePercentageForDecoding = 50; platformFeePercentageForDecoding = 50; } // *********************** MODIFIERS ********************************************* /// @notice verifies if message sender is an admin or secondary admin modifier onlyAdmin{ if(!(hasRole(DEFAULT_ADMIN_ROLE, msg.sender) || hasRole(SECONDARY_ADMIN_ROLE,msg.sender))){ revert InvalidRole(msg.sender, SECONDARY_ADMIN_ROLE); } _; } // *********************** VIEW FUNCTIONS ********************************************* function version() public pure returns (uint32){ //version in format aaa.bbb.ccc => aaa*1E6+bbb*1E3+ccc; return uint32(2_001_011); } // *********************** FUNCTIONS ********************************************* /// @notice checks account for admin roles function isAdmin(address account) public view returns(bool){ return (hasRole(DEFAULT_ADMIN_ROLE, account)||hasRole(SECONDARY_ADMIN_ROLE, account)); } /// @notice checks account for backend role function isBackendRole(address account) public view returns(bool){ return hasRole(BACKEND_ROLE, account); } function isBridgeRole(address account) public view returns(bool){ return hasRole(BRIDGE_ROLE, account); } function isDecoderRole(address account) public view returns(bool){ return hasRole(DECODER_ROLE, account); } /// @notice checks account for admin roles or if platform is not paused function isAdminOrNotPaused(address caller) public view returns(bool){ return(!paused()||hasRole(DEFAULT_ADMIN_ROLE,caller)||hasRole(SECONDARY_ADMIN_ROLE,caller)); } /// TODO check if this function must exist /// @notice returns a number, that represents amount of fee, which validator will receive after decoding process function getValidatorFeeForDecoding(uint256 _price)public view returns(uint256){ if((platformFeePercentageForDecoding + validatorFeePercentageForDecoding)!=100){ revert IncorrectFeeDistribution(); } return (_price* gunDecimals * validatorFeePercentageForDecoding)/PERCENT_DENOMINATOR; } /// TODO check if this function must exist /// @notice returns a number, that represents amount of fee, which financialWallet will receive after decoding process function getPlatformFeeForDecoding(uint256 _price)public view returns(uint256){ if((platformFeePercentageForDecoding + validatorFeePercentageForDecoding)!=100){ revert IncorrectFeeDistribution(); } return (_price* gunDecimals * platformFeePercentageForDecoding)/PERCENT_DENOMINATOR; } /// @notice suspends most functions in contracts /// @dev Caller must be admin function pause() public onlyAdmin{ _pause(); } /// @notice restores most functions in contracts /// @dev Caller must be admin function unpause() public onlyAdmin{ _unpause(); } /// @notice sets new address as a payable financialWallet /// @dev caller must be admin, emits 'ChangedFinancialWallet' function setNewFinancialWallet(address _newWalletAddress) public onlyAdmin{ financialWallet = payable(_newWalletAddress); emit ChangedFinancialWallet(_newWalletAddress); } /// @notice granting secondary admin role to a specific address /// @param account address of a specific account function grantSecondaryAdminRole(address account) public onlyRole(DEFAULT_ADMIN_ROLE){ if(hasRole(SECONDARY_ADMIN_ROLE, account)){ revert AlreadyHasRole(account, SECONDARY_ADMIN_ROLE); } grantRole(SECONDARY_ADMIN_ROLE, account); } /// @notice revoking secondary admin role from a specific address /// @param account address of a specific account function revokeSecondaryAdminRole(address account) public onlyRole(DEFAULT_ADMIN_ROLE){ if(!hasRole(SECONDARY_ADMIN_ROLE, account)){ revert AlreadyHasNotRole(account, SECONDARY_ADMIN_ROLE); } revokeRole(SECONDARY_ADMIN_ROLE, account); } /// @notice granting backend admin role from a specific address /// @param account address of a specific account function grantBackendRole(address account) public onlyRole(DEFAULT_ADMIN_ROLE){ if(hasRole(BACKEND_ROLE, account)){ revert AlreadyHasRole(account, BACKEND_ROLE); } grantRole(BACKEND_ROLE, account); } /// @notice revoking backend admin role from a specific address /// @param account address of a specific account function revokeBackendRole(address account) public onlyRole(DEFAULT_ADMIN_ROLE){ if(!hasRole(BACKEND_ROLE, account)){ revert AlreadyHasNotRole(account, BACKEND_ROLE); } revokeRole(BACKEND_ROLE, account); } function grantBridgeRole(address account) public onlyRole(DEFAULT_ADMIN_ROLE){ if(hasRole(BRIDGE_ROLE, account)){ revert AlreadyHasRole(account, BRIDGE_ROLE); } grantRole(BRIDGE_ROLE, account); } function revokeBridgeRole(address account) public onlyRole(DEFAULT_ADMIN_ROLE){ if(!hasRole(BRIDGE_ROLE, account)){ revert AlreadyHasNotRole(account, BRIDGE_ROLE); } revokeRole(BRIDGE_ROLE, account); } function grantDecoderRole(address account) public onlyRole(DEFAULT_ADMIN_ROLE){ if(hasRole(DECODER_ROLE, account)){ revert AlreadyHasRole(account, DECODER_ROLE); } grantRole(DECODER_ROLE, account); } function revokeDecoderRole(address account) public onlyRole(DEFAULT_ADMIN_ROLE){ if(!hasRole(DECODER_ROLE, account)){ revert AlreadyHasNotRole(account, DECODER_ROLE); } revokeRole(DECODER_ROLE, account); } /// TODO maybe it will be better, to set validatorFeePercentageForDecoding and platformFeePercentageForDecoding with one function /// @notice Sets a number, that represents amount of fee, which validator will receive after /// @dev caller must be admin function setValidatorFeePercentageForDecoding(uint256 _percentage) public onlyAdmin{ validatorFeePercentageForDecoding = _percentage; } /// @notice Sets a number, that represents amount of fee, which financialWallet will receive after /// @dev caller must be admin function setPlatformFeePercentageForDecoding(uint256 _percentage) public onlyAdmin{ platformFeePercentageForDecoding = _percentage; } // TODO DEPRECATED, will be deleted sooner function getValidatorFeePercentageForDecoding() external view returns(uint256){ return(validatorFeePercentageForDecoding); } // TODO DEPRECATED, will be deleted sooner function getPlatformFeePercentageForDecoding() external view returns(uint256){ return(platformFeePercentageForDecoding); } } // File openzeppelin-contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol // Original license: SPDX_License_Identifier: MIT // OpenZeppelin Contracts v4.4.0 (utils/cryptography/ECDSA.sol) pragma solidity ^0.8.0; /** * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations. * * These functions can be used to verify that a message was signed by the holder * of the private keys of a given address. */ library ECDSAUpgradeable { enum RecoverError { NoError, InvalidSignature, InvalidSignatureLength, InvalidSignatureS, InvalidSignatureV } function _throwError(RecoverError error) private pure { if (error == RecoverError.NoError) { return; // no error: do nothing } else if (error == RecoverError.InvalidSignature) { revert("ECDSA: invalid signature"); } else if (error == RecoverError.InvalidSignatureLength) { revert("ECDSA: invalid signature length"); } else if (error == RecoverError.InvalidSignatureS) { revert("ECDSA: invalid signature 's' value"); } else if (error == RecoverError.InvalidSignatureV) { revert("ECDSA: invalid signature 'v' value"); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature` or error string. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. * * Documentation for signature generation: * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js] * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers] * * _Available since v4.3._ */ function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) { // Check the signature length // - case 65: r,s,v signature (standard) // - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._ if (signature.length == 65) { bytes32 r; bytes32 s; uint8 v; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. assembly { r := mload(add(signature, 0x20)) s := mload(add(signature, 0x40)) v := byte(0, mload(add(signature, 0x60))) } return tryRecover(hash, v, r, s); } else if (signature.length == 64) { bytes32 r; bytes32 vs; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. assembly { r := mload(add(signature, 0x20)) vs := mload(add(signature, 0x40)) } return tryRecover(hash, r, vs); } else { return (address(0), RecoverError.InvalidSignatureLength); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature`. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. */ function recover(bytes32 hash, bytes memory signature) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, signature); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately. * * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures] * * _Available since v4.3._ */ function tryRecover( bytes32 hash, bytes32 r, bytes32 vs ) internal pure returns (address, RecoverError) { bytes32 s; uint8 v; assembly { s := and(vs, 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) v := add(shr(255, vs), 27) } return tryRecover(hash, v, r, s); } /** * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately. * * _Available since v4.2._ */ function recover( bytes32 hash, bytes32 r, bytes32 vs ) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, r, vs); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `v`, * `r` and `s` signature fields separately. * * _Available since v4.3._ */ function tryRecover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address, RecoverError) { // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most // signatures from current libraries generate a unique signature with an s-value in the lower half order. // // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept // these malleable signatures as well. if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) { return (address(0), RecoverError.InvalidSignatureS); } if (v != 27 && v != 28) { return (address(0), RecoverError.InvalidSignatureV); } // If the signature is valid (and not malleable), return the signer address address signer = ecrecover(hash, v, r, s); if (signer == address(0)) { return (address(0), RecoverError.InvalidSignature); } return (signer, RecoverError.NoError); } /** * @dev Overload of {ECDSA-recover} that receives the `v`, * `r` and `s` signature fields separately. */ function recover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, v, r, s); _throwError(error); return recovered; } /** * @dev Returns an Ethereum Signed Message, created from a `hash`. This * produces hash corresponding to the one signed with the * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] * JSON-RPC method as part of EIP-191. * * See {recover}. */ function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) { // 32 is the length in bytes of hash, // enforced by the type signature above return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash)); } /** * @dev Returns an Ethereum Signed Message, created from `s`. This * produces hash corresponding to the one signed with the * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] * JSON-RPC method as part of EIP-191. * * See {recover}. */ function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", StringsUpgradeable.toString(s.length), s)); } /** * @dev Returns an Ethereum Signed Typed Data, created from a * `domainSeparator` and a `structHash`. This produces hash corresponding * to the one signed with the * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] * JSON-RPC method as part of EIP-712. * * See {recover}. */ function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash)); } } // File openzeppelin-contracts-upgradeable/utils/cryptography/draft-EIP712Upgradeable.sol // Original license: SPDX_License_Identifier: MIT // OpenZeppelin Contracts v4.4.0 (utils/cryptography/draft-EIP712.sol) pragma solidity ^0.8.0; /** * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data. * * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible, * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding * they need in their contracts using a combination of `abi.encode` and `keccak256`. * * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA * ({_hashTypedDataV4}). * * The implementation of the domain separator was designed to be as efficient as possible while still properly updating * the chain id to protect against replay attacks on an eventual fork of the chain. * * NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask]. * * _Available since v3.4._ */ abstract contract EIP712Upgradeable is Initializable { /* solhint-disable var-name-mixedcase */ bytes32 private _HASHED_NAME; bytes32 private _HASHED_VERSION; bytes32 private constant _TYPE_HASH = keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"); /* solhint-enable var-name-mixedcase */ /** * @dev Initializes the domain separator and parameter caches. * * The meaning of `name` and `version` is specified in * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]: * * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol. * - `version`: the current major version of the signing domain. * * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart * contract upgrade]. */ function __EIP712_init(string memory name, string memory version) internal initializer { __EIP712_init_unchained(name, version); } function __EIP712_init_unchained(string memory name, string memory version) internal initializer { bytes32 hashedName = keccak256(bytes(name)); bytes32 hashedVersion = keccak256(bytes(version)); _HASHED_NAME = hashedName; _HASHED_VERSION = hashedVersion; } /** * @dev Returns the domain separator for the current chain. */ function _domainSeparatorV4() internal view returns (bytes32) { return _buildDomainSeparator(_TYPE_HASH, _EIP712NameHash(), _EIP712VersionHash()); } function _buildDomainSeparator( bytes32 typeHash, bytes32 nameHash, bytes32 versionHash ) private view returns (bytes32) { return keccak256(abi.encode(typeHash, nameHash, versionHash, block.chainid, address(this))); } /** * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this * function returns the hash of the fully encoded EIP712 message for this domain. * * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example: * * ```solidity * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode( * keccak256("Mail(address to,string contents)"), * mailTo, * keccak256(bytes(mailContents)) * ))); * address signer = ECDSA.recover(digest, signature); * ``` */ function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) { return ECDSAUpgradeable.toTypedDataHash(_domainSeparatorV4(), structHash); } /** * @dev The hash of the name parameter for the EIP712 domain. * * NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs * are a concern. */ function _EIP712NameHash() internal virtual view returns (bytes32) { return _HASHED_NAME; } /** * @dev The hash of the version parameter for the EIP712 domain. * * NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs * are a concern. */ function _EIP712VersionHash() internal virtual view returns (bytes32) { return _HASHED_VERSION; } uint256[50] private __gap; } // File contracts/utils/EIP712Custom.sol // contracts/Market.sol // Original license: SPDX_License_Identifier: MIT pragma solidity ^0.8.0; /// @title Contract for game Item sale /// @notice User can use this contract for selling and buying game Items /// @dev this's an upgradeable contract with creating item for sale, selling and unlisting gameItem from sale /// @dev Marketplace is inheriting from IMarketplace and EIP712Upgradeable contract EIP712Custom is EIP712Upgradeable { error IncorrectSigner(address signer); error DeadlineExpired(uint256 deadline, uint256 currentTimestamp); } // File openzeppelin-contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol // Original license: SPDX_License_Identifier: MIT // OpenZeppelin Contracts v4.4.0 (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721Upgradeable is IERC165Upgradeable { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } // File openzeppelin-contracts-upgradeable/token/ERC721/extensions/IERC721MetadataUpgradeable.sol // Original license: SPDX_License_Identifier: MIT // OpenZeppelin Contracts v4.4.0 (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.0; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721MetadataUpgradeable is IERC721Upgradeable { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // File openzeppelin-contracts-upgradeable/token/ERC721/IERC721ReceiverUpgradeable.sol // Original license: SPDX_License_Identifier: MIT // OpenZeppelin Contracts v4.4.0 (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721ReceiverUpgradeable { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } // File openzeppelin-contracts-upgradeable/utils/AddressUpgradeable.sol // Original license: SPDX_License_Identifier: MIT // OpenZeppelin Contracts v4.4.0 (utils/Address.sol) pragma solidity ^0.8.0; /** * @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 * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 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); } } } } // File openzeppelin-contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol // Original license: SPDX_License_Identifier: MIT // OpenZeppelin Contracts v4.4.0 (token/ERC721/ERC721.sol) pragma solidity ^0.8.0; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721Upgradeable is Initializable, ContextUpgradeable, ERC165Upgradeable, IERC721Upgradeable, IERC721MetadataUpgradeable { using AddressUpgradeable for address; using StringsUpgradeable for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ function __ERC721_init(string memory name_, string memory symbol_) internal initializer { __Context_init_unchained(); __ERC165_init_unchained(); __ERC721_init_unchained(name_, symbol_); } function __ERC721_init_unchained(string memory name_, string memory symbol_) internal initializer { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165Upgradeable, IERC165Upgradeable) returns (bool) { return interfaceId == type(IERC721Upgradeable).interfaceId || interfaceId == type(IERC721MetadataUpgradeable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721Upgradeable.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721Upgradeable.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint( address to, uint256 tokenId, bytes memory _data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721Upgradeable.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) internal virtual { require(ERC721Upgradeable.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721Upgradeable.ownerOf(tokenId), to, tokenId); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits a {ApprovalForAll} event. */ function _setApprovalForAll( address owner, address operator, bool approved ) internal virtual { require(owner != operator, "ERC721: approve to caller"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721ReceiverUpgradeable(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721ReceiverUpgradeable.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} uint256[44] private __gap; } // File openzeppelin-contracts-upgradeable/token/ERC721/extensions/ERC721BurnableUpgradeable.sol // Original license: SPDX_License_Identifier: MIT // OpenZeppelin Contracts v4.4.0 (token/ERC721/extensions/ERC721Burnable.sol) pragma solidity ^0.8.0; /** * @title ERC721 Burnable Token * @dev ERC721 Token that can be irreversibly burned (destroyed). */ abstract contract ERC721BurnableUpgradeable is Initializable, ContextUpgradeable, ERC721Upgradeable { function __ERC721Burnable_init() internal initializer { __Context_init_unchained(); __ERC165_init_unchained(); __ERC721Burnable_init_unchained(); } function __ERC721Burnable_init_unchained() internal initializer { } /** * @dev Burns `tokenId`. See {ERC721-_burn}. * * Requirements: * * - The caller must own `tokenId` or be an approved operator. */ function burn(uint256 tokenId) public virtual { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721Burnable: caller is not owner nor approved"); _burn(tokenId); } uint256[50] private __gap; } // File contracts/Decoder.sol // Original license: SPDX_License_Identifier: MIT pragma solidity ^0.8.0; /// @title contract for decode functions /// @notice User or admin can decode hex in eight different ways /// @dev This contract is inherits 'EIP712Upgradeable' contract from openzeppelin library /// Abbreviations: HEX - HEX; HL - HackerLicense; GI - GameItem contract Decoder is EIP712Custom { uint256 public constant PERCENT_DENOMINATOR = 100; // address of PlatformSettings contract address public platformSettingsContractAddress; // address of HackerLicenseContract address public validatorLicenseContractAddress; // address of HEX address public dataCubeContractAddress; // address of GameItemContract address public gameItemContractAddress; // address of LicenseStorage contract address public licenseStorageAddress; event DecodedHEX(uint256 indexed HLTokenId, address indexed receiver, uint256 indexed HEXTokenId, uint256 HEXBackendTokenId, uint256 hackerFeeFromUser, uint256 platformFee, uint256 hackerFeeFromHackerLicense, uint8 hexQuality); event Decoded(uint256 indexed HLTokenId, address indexed receiver, uint256 HEXBackendTokenId, uint256 hackerFeeFromUser, uint256 platformFee, uint256 hackerFeeFromHackerLicense); event CreateItemFromParts(uint256 indexed HackerLicenseId, address indexed receiver, uint256[4] partsIDs, uint256 hackerFeeFromUser, uint256 platformFee, uint256 hackerFeeFromHackerLicense); error ContractsIsPaused(); error InvalidRole(address caller, bytes32 role); error CallerNotOwner(address caller, address owner, uint256 tokenId); error InactiveLicense(); error IncorrectValue(uint256 value, uint256 price); error IncorrectFeeDistribution(); error UnsuccessfulPaymentError(); error UnauthorizedSigner(address signer); error PriceValueMismatchError(); /// @notice A disposable function for initializing contract /// @param _platformSettingsContractAddress address of PlatformSettings contract /// @param _hackerLicense address of HackerLicense /// @param _HEXContractAddress address of HEX /// @param _gameItemContractAddress address of GameItemContract /// @param _licenseStorageAddress address of LicenseStorage Contract /// @dev calls initializer from EIP712Upgradeable contract function initialize( address _platformSettingsContractAddress, address _hackerLicense, address _HEXContractAddress, address _gameItemContractAddress, address _licenseStorageAddress ) public initializer { __EIP712_init('Decoder', '1'); platformSettingsContractAddress = _platformSettingsContractAddress; validatorLicenseContractAddress = _hackerLicense; dataCubeContractAddress = _HEXContractAddress; gameItemContractAddress = _gameItemContractAddress; licenseStorageAddress = _licenseStorageAddress; } // *********************** MODIFIERS ********************************************* /// @notice verifies if switch "_paused" in PlatformSettings contract is off modifier whenNotPaused{ if (PlatformSettings(platformSettingsContractAddress).paused()) { revert ContractsIsPaused(); } _; } /// @notice verifies if message sender is an admin or secondary admin modifier onlyAdmin{ if (!(PlatformSettings(platformSettingsContractAddress).hasRole(PlatformSettings(platformSettingsContractAddress).DEFAULT_ADMIN_ROLE(), msg.sender) || PlatformSettings(platformSettingsContractAddress).hasRole(PlatformSettings(platformSettingsContractAddress).SECONDARY_ADMIN_ROLE(), msg.sender))) { revert InvalidRole(msg.sender, PlatformSettings(platformSettingsContractAddress).SECONDARY_ADMIN_ROLE()); } _; } // *********************** VIEW FUNCTIONS ********************************************* function version() public pure returns (uint32){ //version in format aaa.bbb.ccc => aaa*1E6+bbb*1E3+ccc; return uint32(2_001_011); } // *********************** Decode functions with VLicense ********************************************* /// @notice Decodes NFT HEX and burns it; mints new NFT GI; sends fee to HackerLicense owner and financial wallet; withdraws payment from HackerLicense storage of GUNs /// @dev verifies signer via 'hashTypedDataV4' function from 'EIP712Upgradeable' contract and 'recover' function from 'ECDSAUpgradeable' contract /// @dev distributes fee to HackerLicense owner and financial wallet via 'call' function /// @dev withdraws payment from 'LicenseStorage' contract via function 'getPaymentFromLicenseStorage' /// @dev calls function 'open' via 'IHEX' interface /// @dev emits 'NFTCubeDecodedForNFTItemWithVL' /// @dev Requirements: /// @dev - signer must have backend role from 'PlatformSettings' contract /// @dev - function must be executed earlier than signature expires /// @dev - parameter season must be the same as NFT HEX season /// @dev - caller must be owner of NFT HEX /// @dev - HackerLicense must be activated /// @dev - message value of GUNs must be equal to price(with decimals) /// @param _HEXTokenId token id of NFT HEX, that will be opened and burned during decoding process /// @param _HLTokenId token id of HackerLicense, that takes part in decoding process /// @param _seasonId id of HEX season /// @param _HEXQuality quality of HEX, represents enumeration of rarity /// @param _price price of decoding process for caller /// @param _HEXBackendTokenId token id of backend nonNFT HEX /// @param _metadataURL link to metadata storage /// @param _deadline expire date of signature; unix time used /// @param _signature signed typed data function decodeHEX( uint256 _HEXTokenId, uint256 _HLTokenId, uint256 _seasonId, uint8 _HEXQuality, uint256 _price, uint256 _HEXBackendTokenId, string memory _metadataURL, uint256 _deadline, bytes memory _signature ) payable public whenNotPaused { // verifying signature { bytes32 __digest = _hashTypedDataV4(keccak256( abi.encode( keccak256("DecodeNFTCubeForNFTItemWithVL(uint256 _DCTokenID,uint256 _VLTokenID,uint256 _seasonID,uint8 _DCQuality,uint256 _price,uint256 _DCBackendTokenID,string _metadataURL,uint256 _deadline)"), _HEXTokenId, _HLTokenId, _seasonId, _HEXQuality, _price, _HEXBackendTokenId, keccak256(bytes(_metadataURL)), _deadline ) )); address __signer = ECDSAUpgradeable.recover(__digest, _signature); if (!PlatformSettings(platformSettingsContractAddress).isBackendRole(__signer)) { revert IncorrectSigner(__signer); } } // function must be executed earlier than signature expires IDataCube dataCubeContract = IDataCube(dataCubeContractAddress); if (block.timestamp > _deadline) { revert DeadlineExpired(_deadline, block.timestamp); } // Checking NFT-HEX owner if (IERC721Upgradeable(dataCubeContractAddress).ownerOf(_HEXTokenId) != msg.sender) { revert CallerNotOwner(msg.sender, IERC721Upgradeable(dataCubeContractAddress).ownerOf(_HEXTokenId), _HEXTokenId); } // Checking HackerLicense validity if (IValidatorLicense(validatorLicenseContractAddress).isActive(_HLTokenId) != true) { revert InactiveLicense(); } uint8 hexQuality = dataCubeContract.getCubeQuality(_HEXTokenId); uint256 licenseStorageFee = dataCubeContract.getFeeDependsOnQuality(hexQuality); // Fee distribution feeDistribution(_price, _HLTokenId, licenseStorageFee); // Opening HEX via 'DataCubeContract' IDataCube(dataCubeContractAddress).open( _HEXTokenId, _HLTokenId, _HEXQuality, msg.sender, _HEXBackendTokenId, _metadataURL); emit DecodedHEX( _HLTokenId, msg.sender, _HEXTokenId, _HEXBackendTokenId, (_price * PlatformSettings(platformSettingsContractAddress).validatorFeePercentageForDecoding()) / PERCENT_DENOMINATOR, (_price * PlatformSettings(platformSettingsContractAddress).platformFeePercentageForDecoding()) / PERCENT_DENOMINATOR, licenseStorageFee, hexQuality); } /// @notice Decodes nonNFT HEX; mints new NFT GI; sends fee to HackerLicense owner and platform(financial) wallet; withdraws payment from HackerLicense storage of GUNs /// @dev verifies signer via 'hashTypedDataV4' function from 'EIP712Upgradeable' contract and 'recover' function from 'ECDSAUpgradeable' contract /// @dev distributes fee to HackerLicense owner and financial wallet via 'call' function /// @dev withdraws payment from 'LicenseStorage' contract via function 'getPaymentFromLicenseStorage' /// @dev calls function 'mintFromCube' via 'IGameItem' interface /// @dev emits 'Decoded' /// @dev Requirements: /// @dev - signer must have backend role from 'PlatformSettings' contract /// @dev - function must be executed earlier than signature expires /// @dev - HackerLicense must be activated /// @dev - message value of GUNs must be equal to price(with decimals) /// @param _HLTokenId token id of HackerLicense, that takes part in decoding process /// @param _seasonId id of HEX season /// @param _HEXQuality quality of HEX, represents enumeration of rarity /// @param _price price of decoding process for caller /// @param _HexBackendTokenId token id of backend nonNFT HEX /// @param _metadataURL link to metadata storage /// @param _deadline expire date of signature; unix time used /// @param _signature signed typed data function decode( uint256 _HLTokenId, uint256 _seasonId, uint8 _HEXQuality, uint256 _price, uint256 _HexBackendTokenId, string memory _metadataURL, uint256 _deadline, bytes memory _signature ) payable public whenNotPaused { // verifying signature { bytes32 __digest = _hashTypedDataV4(keccak256( abi.encode( keccak256("DecodeCubeForNFTItemWithVL(uint256 _VLTokenID,uint256 _seasonID,uint8 _DCQuality,uint256 _price,uint256 _DCBackendTokenID,string _metadataURL,uint256 _deadline)"), _HLTokenId, _seasonId, _HEXQuality, _price, _HexBackendTokenId, keccak256(bytes(_metadataURL)), _deadline ) )); address __signer = ECDSAUpgradeable.recover(__digest, _signature); if (!PlatformSettings(platformSettingsContractAddress).isBackendRole(__signer)) { revert UnauthorizedSigner(__signer); } } if (block.timestamp > _deadline) { revert DeadlineExpired(_deadline, block.timestamp); } if (!IValidatorLicense(validatorLicenseContractAddress).isActive(_HLTokenId)) { revert InactiveLicense(); } uint256 licenseStorageFee = IDataCube(dataCubeContractAddress).getFeeDependsOnQuality(_HEXQuality); { // Checking receiver`s balance if (msg.value != _price) { revert PriceValueMismatchError(); } uint256 hackerPayment = (_price * PlatformSettings(platformSettingsContractAddress).validatorFeePercentageForDecoding()) / PERCENT_DENOMINATOR; uint256 platformPayment = (_price * PlatformSettings(platformSettingsContractAddress).platformFeePercentageForDecoding()) / PERCENT_DENOMINATOR; // Checking fee distribution (bool successHackerPayment,) = IERC721Upgradeable(validatorLicenseContractAddress).ownerOf(_HLTokenId).call{value: hackerPayment}(""); (bool successPlatform,) = PlatformSettings(platformSettingsContractAddress).financialWallet().call{value: platformPayment}(""); // Checkiing license payment bool successfulPayment = ILicenseStorage(licenseStorageAddress).getPaymentFromLicenseStorage(_HLTokenId, licenseStorageFee, PlatformSettings(platformSettingsContractAddress).financialWallet()); if (!successfulPayment || !successPlatform || !successHackerPayment) { revert UnsuccessfulPaymentError(); } } // MInt Item directly via 'GameItem' without agent HEX Contract IGameItem(gameItemContractAddress).mintFromCube( msg.sender, _HLTokenId, _seasonId, _HEXQuality, _metadataURL); emit Decoded( _HLTokenId, msg.sender, _HexBackendTokenId, (_price * PlatformSettings(platformSettingsContractAddress).validatorFeePercentageForDecoding()) / PERCENT_DENOMINATOR, (_price * PlatformSettings(platformSettingsContractAddress).platformFeePercentageForDecoding()) / PERCENT_DENOMINATOR, licenseStorageFee); } // *********************** Decode functions without VLicense ********************************************* /// @notice Create item from itemParts; emits event about new GI; sends fee to HackerLicense owner and financial wallet; withdraws payment from HackerLicense storage of GUNs /// @dev verifies signer via 'hashTypedDataV4' function from 'EIP712Upgradeable' contract and 'recover' function from 'ECDSAUpgradeable' contract /// @dev distributes fee to HackerLicense owner and financial wallet via 'call' function /// @dev withdraws payment from 'LicenseStorage' contract via function 'getPaymentFromLicenseStorage' /// @dev emits 'createItemFromParts' /// @dev Requirements: /// @dev - signer must have backend role from 'PlatformSettings' contract /// @dev - function must be executed earlier than signature expires /// @dev - HackerLicense must be activated /// @dev - message value of GUNs must be equal to price(with decimals) /// @param _HackerLicenseId token id of HackerLicense, that takes part in decoding process /// @param _seasonId id of HEX season /// @param _partsIds quality of HEX, represents enumeration of rarity /// @param _price price of decoding process for caller /// @param _metadataURL link to metadata storage /// @param _deadline expire date of signature; unix time used /// @param _signature signed typed data function createItemFromParts( uint256 _HackerLicenseId, uint256 _seasonId, uint256[4] memory _partsIds, uint256 _price, string memory _metadataURL, uint256 _deadline, bytes memory _signature ) payable public whenNotPaused { // verifying signature { bytes32 __digest = _hashTypedDataV4(keccak256( abi.encode( keccak256("createItemFromParts(uint256 _VLTokenID,uint256 _seasonID,uint256[4] _partsIDs,uint256 _price,string _metadataURL,uint256 _deadline)"), _HackerLicenseId, _seasonId, keccak256(abi.encodePacked(_partsIds)), _price, keccak256(bytes(_metadataURL)), _deadline ) )); address __signer = ECDSAUpgradeable.recover(__digest, _signature); if (!PlatformSettings(platformSettingsContractAddress).isBackendRole(__signer)) { revert IncorrectSigner(__signer); } } // function must be executed earlier than signature expires if (block.timestamp > _deadline) { revert DeadlineExpired(_deadline, block.timestamp); } // Checking HackerLicense validity if (IValidatorLicense(validatorLicenseContractAddress).isActive(_HackerLicenseId) != true) { revert InactiveLicense(); } uint8 quality = IGameItem(gameItemContractAddress).getItemQuality(_partsIds[0]); for (uint256 i = 0; i < 4; i++) { IERC721Upgradeable(gameItemContractAddress).transferFrom(msg.sender, address(this), _partsIds[i]); IGameItem(gameItemContractAddress).burn(_partsIds[i]); } uint256 licenseStorageFee = IDataCube(dataCubeContractAddress).getFeeDependsOnQuality(quality); feeDistribution(_price, _HackerLicenseId, licenseStorageFee); IGameItem(gameItemContractAddress).mintFromCube(msg.sender, _HackerLicenseId, _seasonId, quality, _metadataURL); emit CreateItemFromParts( _HackerLicenseId, msg.sender, _partsIds, (_price * PlatformSettings(platformSettingsContractAddress).validatorFeePercentageForDecoding()) / PERCENT_DENOMINATOR, (_price * PlatformSettings(platformSettingsContractAddress).platformFeePercentageForDecoding()) / PERCENT_DENOMINATOR, licenseStorageFee); } function feeDistribution(uint256 _price, uint256 _HackerLicenseId, uint256 _licenseStorageFee) internal virtual { // Checking receiver`s balance if (msg.value != _price) { revert IncorrectValue(msg.value, _price); } uint256 validatorPayment = (_price * PlatformSettings(platformSettingsContractAddress).validatorFeePercentageForDecoding()) / PERCENT_DENOMINATOR; uint256 platformPayment = (_price * PlatformSettings(platformSettingsContractAddress).platformFeePercentageForDecoding()) / PERCENT_DENOMINATOR; // Checking fee distribution if ((validatorPayment + platformPayment) != _price) { revert IncorrectFeeDistribution(); } (bool successValidator,) = IERC721Upgradeable(validatorLicenseContractAddress).ownerOf(_HackerLicenseId).call{value: validatorPayment}(""); if (!successValidator) { revert UnsuccessfulPaymentError(); } (bool successPlatform,) = PlatformSettings(platformSettingsContractAddress).financialWallet().call{value: platformPayment}(""); if (!successPlatform) { revert UnsuccessfulPaymentError(); } // Checking license payment bool successfulPayment = ILicenseStorage(licenseStorageAddress).getPaymentFromLicenseStorage(_HackerLicenseId, _licenseStorageFee, PlatformSettings(platformSettingsContractAddress).financialWallet()); if (!successfulPayment) { revert UnsuccessfulPaymentError(); } } }
Contract ABI
[{"type":"error","name":"CallerNotOwner","inputs":[{"type":"address","name":"caller","internalType":"address"},{"type":"address","name":"owner","internalType":"address"},{"type":"uint256","name":"tokenId","internalType":"uint256"}]},{"type":"error","name":"ContractsIsPaused","inputs":[]},{"type":"error","name":"DeadlineExpired","inputs":[{"type":"uint256","name":"deadline","internalType":"uint256"},{"type":"uint256","name":"currentTimestamp","internalType":"uint256"}]},{"type":"error","name":"InactiveLicense","inputs":[]},{"type":"error","name":"IncorrectFeeDistribution","inputs":[]},{"type":"error","name":"IncorrectSigner","inputs":[{"type":"address","name":"signer","internalType":"address"}]},{"type":"error","name":"IncorrectValue","inputs":[{"type":"uint256","name":"value","internalType":"uint256"},{"type":"uint256","name":"price","internalType":"uint256"}]},{"type":"error","name":"InvalidRole","inputs":[{"type":"address","name":"caller","internalType":"address"},{"type":"bytes32","name":"role","internalType":"bytes32"}]},{"type":"error","name":"PriceValueMismatchError","inputs":[]},{"type":"error","name":"UnauthorizedSigner","inputs":[{"type":"address","name":"signer","internalType":"address"}]},{"type":"error","name":"UnsuccessfulPaymentError","inputs":[]},{"type":"event","name":"CreateItemFromParts","inputs":[{"type":"uint256","name":"HackerLicenseId","internalType":"uint256","indexed":true},{"type":"address","name":"receiver","internalType":"address","indexed":true},{"type":"uint256[4]","name":"partsIDs","internalType":"uint256[4]","indexed":false},{"type":"uint256","name":"hackerFeeFromUser","internalType":"uint256","indexed":false},{"type":"uint256","name":"platformFee","internalType":"uint256","indexed":false},{"type":"uint256","name":"hackerFeeFromHackerLicense","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"Decoded","inputs":[{"type":"uint256","name":"HLTokenId","internalType":"uint256","indexed":true},{"type":"address","name":"receiver","internalType":"address","indexed":true},{"type":"uint256","name":"HEXBackendTokenId","internalType":"uint256","indexed":false},{"type":"uint256","name":"hackerFeeFromUser","internalType":"uint256","indexed":false},{"type":"uint256","name":"platformFee","internalType":"uint256","indexed":false},{"type":"uint256","name":"hackerFeeFromHackerLicense","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"DecodedHEX","inputs":[{"type":"uint256","name":"HLTokenId","internalType":"uint256","indexed":true},{"type":"address","name":"receiver","internalType":"address","indexed":true},{"type":"uint256","name":"HEXTokenId","internalType":"uint256","indexed":true},{"type":"uint256","name":"HEXBackendTokenId","internalType":"uint256","indexed":false},{"type":"uint256","name":"hackerFeeFromUser","internalType":"uint256","indexed":false},{"type":"uint256","name":"platformFee","internalType":"uint256","indexed":false},{"type":"uint256","name":"hackerFeeFromHackerLicense","internalType":"uint256","indexed":false},{"type":"uint8","name":"hexQuality","internalType":"uint8","indexed":false}],"anonymous":false},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"PERCENT_DENOMINATOR","inputs":[]},{"type":"function","stateMutability":"payable","outputs":[],"name":"createItemFromParts","inputs":[{"type":"uint256","name":"_HackerLicenseId","internalType":"uint256"},{"type":"uint256","name":"_seasonId","internalType":"uint256"},{"type":"uint256[4]","name":"_partsIds","internalType":"uint256[4]"},{"type":"uint256","name":"_price","internalType":"uint256"},{"type":"string","name":"_metadataURL","internalType":"string"},{"type":"uint256","name":"_deadline","internalType":"uint256"},{"type":"bytes","name":"_signature","internalType":"bytes"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"dataCubeContractAddress","inputs":[]},{"type":"function","stateMutability":"payable","outputs":[],"name":"decode","inputs":[{"type":"uint256","name":"_HLTokenId","internalType":"uint256"},{"type":"uint256","name":"_seasonId","internalType":"uint256"},{"type":"uint8","name":"_HEXQuality","internalType":"uint8"},{"type":"uint256","name":"_price","internalType":"uint256"},{"type":"uint256","name":"_HexBackendTokenId","internalType":"uint256"},{"type":"string","name":"_metadataURL","internalType":"string"},{"type":"uint256","name":"_deadline","internalType":"uint256"},{"type":"bytes","name":"_signature","internalType":"bytes"}]},{"type":"function","stateMutability":"payable","outputs":[],"name":"decodeHEX","inputs":[{"type":"uint256","name":"_HEXTokenId","internalType":"uint256"},{"type":"uint256","name":"_HLTokenId","internalType":"uint256"},{"type":"uint256","name":"_seasonId","internalType":"uint256"},{"type":"uint8","name":"_HEXQuality","internalType":"uint8"},{"type":"uint256","name":"_price","internalType":"uint256"},{"type":"uint256","name":"_HEXBackendTokenId","internalType":"uint256"},{"type":"string","name":"_metadataURL","internalType":"string"},{"type":"uint256","name":"_deadline","internalType":"uint256"},{"type":"bytes","name":"_signature","internalType":"bytes"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"gameItemContractAddress","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"initialize","inputs":[{"type":"address","name":"_platformSettingsContractAddress","internalType":"address"},{"type":"address","name":"_hackerLicense","internalType":"address"},{"type":"address","name":"_HEXContractAddress","internalType":"address"},{"type":"address","name":"_gameItemContractAddress","internalType":"address"},{"type":"address","name":"_licenseStorageAddress","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"licenseStorageAddress","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"platformSettingsContractAddress","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"validatorLicenseContractAddress","inputs":[]},{"type":"function","stateMutability":"pure","outputs":[{"type":"uint32","name":"","internalType":"uint32"}],"name":"version","inputs":[]}]
Contract Creation Code
0x608060405234801561001057600080fd5b50612aea806100206000396000f3fe60806040526004361061009c5760003560e01c80636744be5d116100645780636744be5d146101515780636c8d5990146101715780639e6c2959146101915780639fe79eab146101b4578063af29e2ec146101c7578063c6a319fa146101da57600080fd5b80631459457a146100a157806328da249f146100c357806335f0d886146100d657806354fd4d50146101135780635686f69e14610131575b600080fd5b3480156100ad57600080fd5b506100c16100bc366004612468565b6101fa565b005b6100c16100d13660046125b4565b61030c565b3480156100e257600080fd5b506038546100f6906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b34801561011f57600080fd5b50604051621e8873815260200161010a565b34801561013d57600080fd5b506037546100f6906001600160a01b031681565b34801561015d57600080fd5b506036546100f6906001600160a01b031681565b34801561017d57600080fd5b506039546100f6906001600160a01b031681565b34801561019d57600080fd5b506101a6606481565b60405190815260200161010a565b6100c16101c2366004612665565b610a16565b6100c16101d536600461270c565b61139d565b3480156101e657600080fd5b506035546100f6906001600160a01b031681565b600054610100900460ff1680610213575060005460ff16155b6102385760405162461bcd60e51b815260040161022f906127e4565b60405180910390fd5b600054610100900460ff1615801561025a576000805461ffff19166101011790555b61029c604051806040016040528060078152602001662232b1b7b232b960c91b815250604051806040016040528060018152602001603160f81b815250611a5f565b603580546001600160a01b03199081166001600160a01b0389811691909117909255603680548216888416179055603780548216878416179055603880548216868416179055603980549091169184169190911790558015610304576000805461ff00191690555b505050505050565b603560009054906101000a90046001600160a01b03166001600160a01b0316635c975abb6040518163ffffffff1660e01b815260040160206040518083038186803b15801561035a57600080fd5b505afa15801561036e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103929190612832565b156103b05760405163487ea6bb60e11b815260040160405180910390fd5b8251602080850191909120604080517f4af6f8c53667f6c79f7f2ca1c9a09fcee62a7ace5796f2d7049c3e6212a893959381019390935282018b9052606082018a90526080820189905260ff881660a083015260c0820187905260e08201869052610100820152610120810183905260009061044690610140015b60405160208183030381529060405280519060200120611ad7565b905060006104548284611b2b565b6035546040516310736f8560e01b81526001600160a01b0380841660048301529293509116906310736f859060240160206040518083038186803b15801561049b57600080fd5b505afa1580156104af573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104d39190612832565b6104fb576040516333ffff9b60e01b81526001600160a01b038216600482015260240161022f565b50506037546001600160a01b031642831015610533576040516302a07ebf60e31b81526004810184905242602482015260440161022f565b6037546040516331a9108f60e11b8152600481018c905233916001600160a01b031690636352211e9060240160206040518083038186803b15801561057757600080fd5b505afa15801561058b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105af919061285b565b6001600160a01b03161461066c576037546040516331a9108f60e11b8152600481018c905233916001600160a01b031690636352211e9060240160206040518083038186803b15801561060157600080fd5b505afa158015610615573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610639919061285b565b60405163f604c2ef60e01b81526001600160a01b03928316600482015291166024820152604481018b905260640161022f565b6036546040516382afd23b60e01b8152600481018b90526001600160a01b03909116906382afd23b9060240160206040518083038186803b1580156106b057600080fd5b505afa1580156106c4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106e89190612832565b151560011461070a576040516309f47f6760e41b815260040160405180910390fd5b60405163629dc9d760e01b8152600481018b90526000906001600160a01b0383169063629dc9d79060240160206040518083038186803b15801561074d57600080fd5b505afa158015610761573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107859190612878565b604051635320584160e11b815260ff821660048201529091506000906001600160a01b0384169063a640b0829060240160206040518083038186803b1580156107cd57600080fd5b505afa1580156107e1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108059190612895565b9050610812888c83611b4f565b603754604051633baaf36160e01b81526001600160a01b0390911690633baaf3619061084c908f908f908e9033908e908e906004016128fb565b600060405180830381600087803b15801561086657600080fd5b505af115801561087a573d6000803e3d6000fd5b505050508b336001600160a01b03168c7f4d56e8f9a9a4da1ce84c3511455c31f941cb0880b0c7a5655a671d8ee53372db8a6064603560009054906101000a90046001600160a01b03166001600160a01b0316633632d5fd6040518163ffffffff1660e01b815260040160206040518083038186803b1580156108fc57600080fd5b505afa158015610910573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109349190612895565b61093e908f612959565b6109489190612978565b60355460408051634c7e1f3b60e11b815290516064926001600160a01b0316916398fc3e76916004808301926020929190829003018186803b15801561098d57600080fd5b505afa1580156109a1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109c59190612895565b8f6109d09190612959565b6109da9190612978565b604080519384526020840192909252908201526060810186905260ff8716608082015260a00160405180910390a4505050505050505050505050565b603560009054906101000a90046001600160a01b03166001600160a01b0316635c975abb6040518163ffffffff1660e01b815260040160206040518083038186803b158015610a6457600080fd5b505afa158015610a78573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a9c9190612832565b15610aba5760405163487ea6bb60e11b815260040160405180910390fd5b8251602080850191909120604080517fb879e3a2e48146c5264a620bed124132076dde6de9826f29be9ee4b9997258a59381019390935282018a90526060820189905260ff8816608083015260a0820187905260c0820186905260e08201526101008101839052600090610b31906101200161042b565b90506000610b3f8284611b2b565b6035546040516310736f8560e01b81526001600160a01b0380841660048301529293509116906310736f859060240160206040518083038186803b158015610b8657600080fd5b505afa158015610b9a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bbe9190612832565b610be65760405163e74c68bb60e01b81526001600160a01b038216600482015260240161022f565b505081421115610c12576040516302a07ebf60e31b81526004810183905242602482015260440161022f565b6036546040516382afd23b60e01b8152600481018a90526001600160a01b03909116906382afd23b9060240160206040518083038186803b158015610c5657600080fd5b505afa158015610c6a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c8e9190612832565b610cab576040516309f47f6760e41b815260040160405180910390fd5b603754604051635320584160e11b815260ff881660048201526000916001600160a01b03169063a640b0829060240160206040518083038186803b158015610cf257600080fd5b505afa158015610d06573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d2a9190612895565b9050853414610d4c5760405163b645c46360e01b815260040160405180910390fd5b60006064603560009054906101000a90046001600160a01b03166001600160a01b0316633632d5fd6040518163ffffffff1660e01b815260040160206040518083038186803b158015610d9e57600080fd5b505afa158015610db2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dd69190612895565b610de09089612959565b610dea9190612978565b905060006064603560009054906101000a90046001600160a01b03166001600160a01b03166398fc3e766040518163ffffffff1660e01b815260040160206040518083038186803b158015610e3e57600080fd5b505afa158015610e52573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e769190612895565b610e80908a612959565b610e8a9190612978565b6036546040516331a9108f60e11b8152600481018e90529192506000916001600160a01b0390911690636352211e9060240160206040518083038186803b158015610ed457600080fd5b505afa158015610ee8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f0c919061285b565b6001600160a01b03168360405160006040518083038185875af1925050503d8060008114610f56576040519150601f19603f3d011682016040523d82523d6000602084013e610f5b565b606091505b505090506000603560009054906101000a90046001600160a01b03166001600160a01b03166388339f9c6040518163ffffffff1660e01b815260040160206040518083038186803b158015610faf57600080fd5b505afa158015610fc3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fe7919061285b565b6001600160a01b03168360405160006040518083038185875af1925050503d8060008114611031576040519150601f19603f3d011682016040523d82523d6000602084013e611036565b606091505b505090506000603960009054906101000a90046001600160a01b03166001600160a01b0316635ce5b4448f88603560009054906101000a90046001600160a01b03166001600160a01b03166388339f9c6040518163ffffffff1660e01b815260040160206040518083038186803b1580156110b057600080fd5b505afa1580156110c4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110e8919061285b565b6040516001600160e01b031960e086901b168152600481019390935260248301919091526001600160a01b03166044820152606401602060405180830381600087803b15801561113757600080fd5b505af115801561114b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061116f9190612832565b905080158061117c575081155b80611185575082155b156111a35760405163665b0f0f60e01b815260040160405180910390fd5b505060385460405163a869f99360e01b81526001600160a01b03909116935063a869f99392506111e0915033908d908d908d908b9060040161299a565b600060405180830381600087803b1580156111fa57600080fd5b505af115801561120e573d6000803e3d6000fd5b50505050336001600160a01b0316897f5dd790ea820e17948e0d843da1880f139f35f469da4a7cdbdeb53fb5e2bc4298876064603560009054906101000a90046001600160a01b03166001600160a01b0316633632d5fd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561128f57600080fd5b505afa1580156112a3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112c79190612895565b6112d1908c612959565b6112db9190612978565b60355460408051634c7e1f3b60e11b815290516064926001600160a01b0316916398fc3e76916004808301926020929190829003018186803b15801561132057600080fd5b505afa158015611334573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113589190612895565b611362908d612959565b61136c9190612978565b60408051938452602084019290925290820152606081018590526080015b60405180910390a3505050505050505050565b603560009054906101000a90046001600160a01b03166001600160a01b0316635c975abb6040518163ffffffff1660e01b815260040160206040518083038186803b1580156113eb57600080fd5b505afa1580156113ff573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114239190612832565b156114415760405163487ea6bb60e11b815260040160405180910390fd5b60006114d27fc8125d18d04f28e7262209a306bc1d0bee25ed7261d804fee2a621c94838059e89898960405160200161147a91906129db565b60408051808303601f1901815282825280516020918201208b518c83012091840196909652908201939093526060810191909152608081019290925260a0820188905260c082015260e081018590526101000161042b565b905060006114e08284611b2b565b6035546040516310736f8560e01b81526001600160a01b0380841660048301529293509116906310736f859060240160206040518083038186803b15801561152757600080fd5b505afa15801561153b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061155f9190612832565b611587576040516333ffff9b60e01b81526001600160a01b038216600482015260240161022f565b5050814211156115b3576040516302a07ebf60e31b81526004810183905242602482015260440161022f565b6036546040516382afd23b60e01b8152600481018990526001600160a01b03909116906382afd23b9060240160206040518083038186803b1580156115f757600080fd5b505afa15801561160b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061162f9190612832565b1515600114611651576040516309f47f6760e41b815260040160405180910390fd5b6038548551604051636b0abcb960e11b815260048101919091526000916001600160a01b03169063d61579729060240160206040518083038186803b15801561169957600080fd5b505afa1580156116ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116d19190612878565b905060005b60048110156117fd576038546001600160a01b03166323b872dd33308a856004811061170457611704612a0f565b60200201516040516001600160e01b031960e086901b1681526001600160a01b0393841660048201529290911660248301526044820152606401600060405180830381600087803b15801561175857600080fd5b505af115801561176c573d6000803e3d6000fd5b50506038546001600160a01b031691506342966c68905088836004811061179557611795612a0f565b60200201516040518263ffffffff1660e01b81526004016117b891815260200190565b600060405180830381600087803b1580156117d257600080fd5b505af11580156117e6573d6000803e3d6000fd5b5050505080806117f590612a25565b9150506116d6565b50603754604051635320584160e11b815260ff831660048201526000916001600160a01b03169063a640b0829060240160206040518083038186803b15801561184557600080fd5b505afa158015611859573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061187d9190612895565b905061188a868a83611b4f565b60385460405163a869f99360e01b81526001600160a01b039091169063a869f993906118c29033908d908d9088908c9060040161299a565b600060405180830381600087803b1580156118dc57600080fd5b505af11580156118f0573d6000803e3d6000fd5b50505050336001600160a01b0316897f53bb613d82455fb8ce57213b03c2b898ddd720f7f7c1650c6c9b94e878f45e13896064603560009054906101000a90046001600160a01b03166001600160a01b0316633632d5fd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561197157600080fd5b505afa158015611985573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119a99190612895565b6119b3908c612959565b6119bd9190612978565b60355460408051634c7e1f3b60e11b815290516064926001600160a01b0316916398fc3e76916004808301926020929190829003018186803b158015611a0257600080fd5b505afa158015611a16573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a3a9190612895565b611a44908d612959565b611a4e9190612978565b8660405161138a9493929190612a40565b600054610100900460ff1680611a78575060005460ff16155b611a945760405162461bcd60e51b815260040161022f906127e4565b600054610100900460ff16158015611ab6576000805461ffff19166101011790555b611ac08383611fff565b8015611ad2576000805461ff00191690555b505050565b6000611b25611ae4612089565b8360405161190160f01b6020820152602281018390526042810182905260009060620160405160208183030381529060405280519060200120905092915050565b92915050565b6000806000611b3a8585612109565b91509150611b4781612179565b509392505050565b823414611b7857604051635928816d60e11b81523460048201526024810184905260440161022f565b60006064603560009054906101000a90046001600160a01b03166001600160a01b0316633632d5fd6040518163ffffffff1660e01b815260040160206040518083038186803b158015611bca57600080fd5b505afa158015611bde573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c029190612895565b611c0c9086612959565b611c169190612978565b905060006064603560009054906101000a90046001600160a01b03166001600160a01b03166398fc3e766040518163ffffffff1660e01b815260040160206040518083038186803b158015611c6a57600080fd5b505afa158015611c7e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ca29190612895565b611cac9087612959565b611cb69190612978565b905084611cc38284612a86565b14611ce157604051635d616c1360e01b815260040160405180910390fd5b6036546040516331a9108f60e11b8152600481018690526000916001600160a01b031690636352211e9060240160206040518083038186803b158015611d2657600080fd5b505afa158015611d3a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d5e919061285b565b6001600160a01b03168360405160006040518083038185875af1925050503d8060008114611da8576040519150601f19603f3d011682016040523d82523d6000602084013e611dad565b606091505b5050905080611dcf5760405163665b0f0f60e01b815260040160405180910390fd5b6035546040805163220ce7e760e21b815290516000926001600160a01b0316916388339f9c916004808301926020929190829003018186803b158015611e1457600080fd5b505afa158015611e28573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e4c919061285b565b6001600160a01b03168360405160006040518083038185875af1925050503d8060008114611e96576040519150601f19603f3d011682016040523d82523d6000602084013e611e9b565b606091505b5050905080611ebd5760405163665b0f0f60e01b815260040160405180910390fd5b6039546035546040805163220ce7e760e21b815290516000936001600160a01b0390811693635ce5b444938c938c93909216916388339f9c91600480820192602092909190829003018186803b158015611f1657600080fd5b505afa158015611f2a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f4e919061285b565b6040516001600160e01b031960e086901b168152600481019390935260248301919091526001600160a01b03166044820152606401602060405180830381600087803b158015611f9d57600080fd5b505af1158015611fb1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fd59190612832565b905080611ff55760405163665b0f0f60e01b815260040160405180910390fd5b5050505050505050565b600054610100900460ff1680612018575060005460ff16155b6120345760405162461bcd60e51b815260040161022f906127e4565b600054610100900460ff16158015612056576000805461ffff19166101011790555b82516020808501919091208351918401919091206001919091556002558015611ad2576000805461ff0019169055505050565b60006121047f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f6120b860015490565b6002546040805160208101859052908101839052606081018290524660808201523060a082015260009060c0016040516020818303038152906040528051906020012090509392505050565b905090565b6000808251604114156121405760208301516040840151606085015160001a61213487828585612337565b94509450505050612172565b82516040141561216a576020830151604084015161215f868383612424565b935093505050612172565b506000905060025b9250929050565b600081600481111561218d5761218d612a9e565b14156121965750565b60018160048111156121aa576121aa612a9e565b14156121f85760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e61747572650000000000000000604482015260640161022f565b600281600481111561220c5761220c612a9e565b141561225a5760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e67746800604482015260640161022f565b600381600481111561226e5761226e612a9e565b14156122c75760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b606482015260840161022f565b60048160048111156122db576122db612a9e565b14156123345760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c604482015261756560f01b606482015260840161022f565b50565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a083111561236e575060009050600361241b565b8460ff16601b1415801561238657508460ff16601c14155b15612397575060009050600461241b565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa1580156123eb573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381166124145760006001925092505061241b565b9150600090505b94509492505050565b6000806001600160ff1b03831660ff84901c601b0161244587828885612337565b935093505050935093915050565b6001600160a01b038116811461233457600080fd5b600080600080600060a0868803121561248057600080fd5b853561248b81612453565b9450602086013561249b81612453565b935060408601356124ab81612453565b925060608601356124bb81612453565b915060808601356124cb81612453565b809150509295509295909350565b60ff8116811461233457600080fd5b634e487b7160e01b600052604160045260246000fd5b6040516080810167ffffffffffffffff81118282101715612521576125216124e8565b60405290565b600082601f83011261253857600080fd5b813567ffffffffffffffff80821115612553576125536124e8565b604051601f8301601f19908116603f0116810190828211818310171561257b5761257b6124e8565b8160405283815286602085880101111561259457600080fd5b836020870160208301376000602085830101528094505050505092915050565b60008060008060008060008060006101208a8c0312156125d357600080fd5b8935985060208a0135975060408a0135965060608a01356125f3816124d9565b955060808a0135945060a08a0135935060c08a013567ffffffffffffffff8082111561261e57600080fd5b61262a8d838e01612527565b945060e08c013593506101008c013591508082111561264857600080fd5b506126558c828d01612527565b9150509295985092959850929598565b600080600080600080600080610100898b03121561268257600080fd5b8835975060208901359650604089013561269b816124d9565b9550606089013594506080890135935060a089013567ffffffffffffffff808211156126c657600080fd5b6126d28c838d01612527565b945060c08b0135935060e08b01359150808211156126ef57600080fd5b506126fc8b828c01612527565b9150509295985092959890939650565b6000806000806000806000610140888a03121561272857600080fd5b87359650602080890135965089605f8a011261274357600080fd5b61274b6124fe565b8060c08b018c81111561275d57600080fd5b60408c015b818110156127795780358452928401928401612762565b50909750359550505060e088013567ffffffffffffffff8082111561279d57600080fd5b6127a98b838c01612527565b94506101008a013593506101208a01359150808211156127c857600080fd5b506127d58a828b01612527565b91505092959891949750929550565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b60006020828403121561284457600080fd5b8151801515811461285457600080fd5b9392505050565b60006020828403121561286d57600080fd5b815161285481612453565b60006020828403121561288a57600080fd5b8151612854816124d9565b6000602082840312156128a757600080fd5b5051919050565b6000815180845260005b818110156128d4576020818501810151868301820152016128b8565b818111156128e6576000602083870101525b50601f01601f19169290920160200192915050565b86815285602082015260ff8516604082015260018060a01b038416606082015282608082015260c060a0820152600061293760c08301846128ae565b98975050505050505050565b634e487b7160e01b600052601160045260246000fd5b600081600019048311821515161561297357612973612943565b500290565b60008261299557634e487b7160e01b600052601260045260246000fd5b500490565b60018060a01b038616815284602082015283604082015260ff8316606082015260a0608082015260006129d060a08301846128ae565b979650505050505050565b60008183825b6004811015612a005781518352602092830192909101906001016129e1565b50505060808201905092915050565b634e487b7160e01b600052603260045260246000fd5b6000600019821415612a3957612a39612943565b5060010190565b60e08101818660005b6004811015612a68578151835260209283019290910190600101612a49565b5050508460808301528360a08301528260c083015295945050505050565b60008219821115612a9957612a99612943565b500190565b634e487b7160e01b600052602160045260246000fdfea2646970667358221220ae550d78e3d3647e2bc8d0a4717ab2d429ddd79adec33df8e6254e8c4c20a72264736f6c63430008090033
Deployed ByteCode
0x60806040526004361061009c5760003560e01c80636744be5d116100645780636744be5d146101515780636c8d5990146101715780639e6c2959146101915780639fe79eab146101b4578063af29e2ec146101c7578063c6a319fa146101da57600080fd5b80631459457a146100a157806328da249f146100c357806335f0d886146100d657806354fd4d50146101135780635686f69e14610131575b600080fd5b3480156100ad57600080fd5b506100c16100bc366004612468565b6101fa565b005b6100c16100d13660046125b4565b61030c565b3480156100e257600080fd5b506038546100f6906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b34801561011f57600080fd5b50604051621e8873815260200161010a565b34801561013d57600080fd5b506037546100f6906001600160a01b031681565b34801561015d57600080fd5b506036546100f6906001600160a01b031681565b34801561017d57600080fd5b506039546100f6906001600160a01b031681565b34801561019d57600080fd5b506101a6606481565b60405190815260200161010a565b6100c16101c2366004612665565b610a16565b6100c16101d536600461270c565b61139d565b3480156101e657600080fd5b506035546100f6906001600160a01b031681565b600054610100900460ff1680610213575060005460ff16155b6102385760405162461bcd60e51b815260040161022f906127e4565b60405180910390fd5b600054610100900460ff1615801561025a576000805461ffff19166101011790555b61029c604051806040016040528060078152602001662232b1b7b232b960c91b815250604051806040016040528060018152602001603160f81b815250611a5f565b603580546001600160a01b03199081166001600160a01b0389811691909117909255603680548216888416179055603780548216878416179055603880548216868416179055603980549091169184169190911790558015610304576000805461ff00191690555b505050505050565b603560009054906101000a90046001600160a01b03166001600160a01b0316635c975abb6040518163ffffffff1660e01b815260040160206040518083038186803b15801561035a57600080fd5b505afa15801561036e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103929190612832565b156103b05760405163487ea6bb60e11b815260040160405180910390fd5b8251602080850191909120604080517f4af6f8c53667f6c79f7f2ca1c9a09fcee62a7ace5796f2d7049c3e6212a893959381019390935282018b9052606082018a90526080820189905260ff881660a083015260c0820187905260e08201869052610100820152610120810183905260009061044690610140015b60405160208183030381529060405280519060200120611ad7565b905060006104548284611b2b565b6035546040516310736f8560e01b81526001600160a01b0380841660048301529293509116906310736f859060240160206040518083038186803b15801561049b57600080fd5b505afa1580156104af573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104d39190612832565b6104fb576040516333ffff9b60e01b81526001600160a01b038216600482015260240161022f565b50506037546001600160a01b031642831015610533576040516302a07ebf60e31b81526004810184905242602482015260440161022f565b6037546040516331a9108f60e11b8152600481018c905233916001600160a01b031690636352211e9060240160206040518083038186803b15801561057757600080fd5b505afa15801561058b573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105af919061285b565b6001600160a01b03161461066c576037546040516331a9108f60e11b8152600481018c905233916001600160a01b031690636352211e9060240160206040518083038186803b15801561060157600080fd5b505afa158015610615573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610639919061285b565b60405163f604c2ef60e01b81526001600160a01b03928316600482015291166024820152604481018b905260640161022f565b6036546040516382afd23b60e01b8152600481018b90526001600160a01b03909116906382afd23b9060240160206040518083038186803b1580156106b057600080fd5b505afa1580156106c4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106e89190612832565b151560011461070a576040516309f47f6760e41b815260040160405180910390fd5b60405163629dc9d760e01b8152600481018b90526000906001600160a01b0383169063629dc9d79060240160206040518083038186803b15801561074d57600080fd5b505afa158015610761573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107859190612878565b604051635320584160e11b815260ff821660048201529091506000906001600160a01b0384169063a640b0829060240160206040518083038186803b1580156107cd57600080fd5b505afa1580156107e1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108059190612895565b9050610812888c83611b4f565b603754604051633baaf36160e01b81526001600160a01b0390911690633baaf3619061084c908f908f908e9033908e908e906004016128fb565b600060405180830381600087803b15801561086657600080fd5b505af115801561087a573d6000803e3d6000fd5b505050508b336001600160a01b03168c7f4d56e8f9a9a4da1ce84c3511455c31f941cb0880b0c7a5655a671d8ee53372db8a6064603560009054906101000a90046001600160a01b03166001600160a01b0316633632d5fd6040518163ffffffff1660e01b815260040160206040518083038186803b1580156108fc57600080fd5b505afa158015610910573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109349190612895565b61093e908f612959565b6109489190612978565b60355460408051634c7e1f3b60e11b815290516064926001600160a01b0316916398fc3e76916004808301926020929190829003018186803b15801561098d57600080fd5b505afa1580156109a1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109c59190612895565b8f6109d09190612959565b6109da9190612978565b604080519384526020840192909252908201526060810186905260ff8716608082015260a00160405180910390a4505050505050505050505050565b603560009054906101000a90046001600160a01b03166001600160a01b0316635c975abb6040518163ffffffff1660e01b815260040160206040518083038186803b158015610a6457600080fd5b505afa158015610a78573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a9c9190612832565b15610aba5760405163487ea6bb60e11b815260040160405180910390fd5b8251602080850191909120604080517fb879e3a2e48146c5264a620bed124132076dde6de9826f29be9ee4b9997258a59381019390935282018a90526060820189905260ff8816608083015260a0820187905260c0820186905260e08201526101008101839052600090610b31906101200161042b565b90506000610b3f8284611b2b565b6035546040516310736f8560e01b81526001600160a01b0380841660048301529293509116906310736f859060240160206040518083038186803b158015610b8657600080fd5b505afa158015610b9a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bbe9190612832565b610be65760405163e74c68bb60e01b81526001600160a01b038216600482015260240161022f565b505081421115610c12576040516302a07ebf60e31b81526004810183905242602482015260440161022f565b6036546040516382afd23b60e01b8152600481018a90526001600160a01b03909116906382afd23b9060240160206040518083038186803b158015610c5657600080fd5b505afa158015610c6a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c8e9190612832565b610cab576040516309f47f6760e41b815260040160405180910390fd5b603754604051635320584160e11b815260ff881660048201526000916001600160a01b03169063a640b0829060240160206040518083038186803b158015610cf257600080fd5b505afa158015610d06573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d2a9190612895565b9050853414610d4c5760405163b645c46360e01b815260040160405180910390fd5b60006064603560009054906101000a90046001600160a01b03166001600160a01b0316633632d5fd6040518163ffffffff1660e01b815260040160206040518083038186803b158015610d9e57600080fd5b505afa158015610db2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dd69190612895565b610de09089612959565b610dea9190612978565b905060006064603560009054906101000a90046001600160a01b03166001600160a01b03166398fc3e766040518163ffffffff1660e01b815260040160206040518083038186803b158015610e3e57600080fd5b505afa158015610e52573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e769190612895565b610e80908a612959565b610e8a9190612978565b6036546040516331a9108f60e11b8152600481018e90529192506000916001600160a01b0390911690636352211e9060240160206040518083038186803b158015610ed457600080fd5b505afa158015610ee8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f0c919061285b565b6001600160a01b03168360405160006040518083038185875af1925050503d8060008114610f56576040519150601f19603f3d011682016040523d82523d6000602084013e610f5b565b606091505b505090506000603560009054906101000a90046001600160a01b03166001600160a01b03166388339f9c6040518163ffffffff1660e01b815260040160206040518083038186803b158015610faf57600080fd5b505afa158015610fc3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fe7919061285b565b6001600160a01b03168360405160006040518083038185875af1925050503d8060008114611031576040519150601f19603f3d011682016040523d82523d6000602084013e611036565b606091505b505090506000603960009054906101000a90046001600160a01b03166001600160a01b0316635ce5b4448f88603560009054906101000a90046001600160a01b03166001600160a01b03166388339f9c6040518163ffffffff1660e01b815260040160206040518083038186803b1580156110b057600080fd5b505afa1580156110c4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110e8919061285b565b6040516001600160e01b031960e086901b168152600481019390935260248301919091526001600160a01b03166044820152606401602060405180830381600087803b15801561113757600080fd5b505af115801561114b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061116f9190612832565b905080158061117c575081155b80611185575082155b156111a35760405163665b0f0f60e01b815260040160405180910390fd5b505060385460405163a869f99360e01b81526001600160a01b03909116935063a869f99392506111e0915033908d908d908d908b9060040161299a565b600060405180830381600087803b1580156111fa57600080fd5b505af115801561120e573d6000803e3d6000fd5b50505050336001600160a01b0316897f5dd790ea820e17948e0d843da1880f139f35f469da4a7cdbdeb53fb5e2bc4298876064603560009054906101000a90046001600160a01b03166001600160a01b0316633632d5fd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561128f57600080fd5b505afa1580156112a3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112c79190612895565b6112d1908c612959565b6112db9190612978565b60355460408051634c7e1f3b60e11b815290516064926001600160a01b0316916398fc3e76916004808301926020929190829003018186803b15801561132057600080fd5b505afa158015611334573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113589190612895565b611362908d612959565b61136c9190612978565b60408051938452602084019290925290820152606081018590526080015b60405180910390a3505050505050505050565b603560009054906101000a90046001600160a01b03166001600160a01b0316635c975abb6040518163ffffffff1660e01b815260040160206040518083038186803b1580156113eb57600080fd5b505afa1580156113ff573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114239190612832565b156114415760405163487ea6bb60e11b815260040160405180910390fd5b60006114d27fc8125d18d04f28e7262209a306bc1d0bee25ed7261d804fee2a621c94838059e89898960405160200161147a91906129db565b60408051808303601f1901815282825280516020918201208b518c83012091840196909652908201939093526060810191909152608081019290925260a0820188905260c082015260e081018590526101000161042b565b905060006114e08284611b2b565b6035546040516310736f8560e01b81526001600160a01b0380841660048301529293509116906310736f859060240160206040518083038186803b15801561152757600080fd5b505afa15801561153b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061155f9190612832565b611587576040516333ffff9b60e01b81526001600160a01b038216600482015260240161022f565b5050814211156115b3576040516302a07ebf60e31b81526004810183905242602482015260440161022f565b6036546040516382afd23b60e01b8152600481018990526001600160a01b03909116906382afd23b9060240160206040518083038186803b1580156115f757600080fd5b505afa15801561160b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061162f9190612832565b1515600114611651576040516309f47f6760e41b815260040160405180910390fd5b6038548551604051636b0abcb960e11b815260048101919091526000916001600160a01b03169063d61579729060240160206040518083038186803b15801561169957600080fd5b505afa1580156116ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116d19190612878565b905060005b60048110156117fd576038546001600160a01b03166323b872dd33308a856004811061170457611704612a0f565b60200201516040516001600160e01b031960e086901b1681526001600160a01b0393841660048201529290911660248301526044820152606401600060405180830381600087803b15801561175857600080fd5b505af115801561176c573d6000803e3d6000fd5b50506038546001600160a01b031691506342966c68905088836004811061179557611795612a0f565b60200201516040518263ffffffff1660e01b81526004016117b891815260200190565b600060405180830381600087803b1580156117d257600080fd5b505af11580156117e6573d6000803e3d6000fd5b5050505080806117f590612a25565b9150506116d6565b50603754604051635320584160e11b815260ff831660048201526000916001600160a01b03169063a640b0829060240160206040518083038186803b15801561184557600080fd5b505afa158015611859573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061187d9190612895565b905061188a868a83611b4f565b60385460405163a869f99360e01b81526001600160a01b039091169063a869f993906118c29033908d908d9088908c9060040161299a565b600060405180830381600087803b1580156118dc57600080fd5b505af11580156118f0573d6000803e3d6000fd5b50505050336001600160a01b0316897f53bb613d82455fb8ce57213b03c2b898ddd720f7f7c1650c6c9b94e878f45e13896064603560009054906101000a90046001600160a01b03166001600160a01b0316633632d5fd6040518163ffffffff1660e01b815260040160206040518083038186803b15801561197157600080fd5b505afa158015611985573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119a99190612895565b6119b3908c612959565b6119bd9190612978565b60355460408051634c7e1f3b60e11b815290516064926001600160a01b0316916398fc3e76916004808301926020929190829003018186803b158015611a0257600080fd5b505afa158015611a16573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a3a9190612895565b611a44908d612959565b611a4e9190612978565b8660405161138a9493929190612a40565b600054610100900460ff1680611a78575060005460ff16155b611a945760405162461bcd60e51b815260040161022f906127e4565b600054610100900460ff16158015611ab6576000805461ffff19166101011790555b611ac08383611fff565b8015611ad2576000805461ff00191690555b505050565b6000611b25611ae4612089565b8360405161190160f01b6020820152602281018390526042810182905260009060620160405160208183030381529060405280519060200120905092915050565b92915050565b6000806000611b3a8585612109565b91509150611b4781612179565b509392505050565b823414611b7857604051635928816d60e11b81523460048201526024810184905260440161022f565b60006064603560009054906101000a90046001600160a01b03166001600160a01b0316633632d5fd6040518163ffffffff1660e01b815260040160206040518083038186803b158015611bca57600080fd5b505afa158015611bde573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c029190612895565b611c0c9086612959565b611c169190612978565b905060006064603560009054906101000a90046001600160a01b03166001600160a01b03166398fc3e766040518163ffffffff1660e01b815260040160206040518083038186803b158015611c6a57600080fd5b505afa158015611c7e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611ca29190612895565b611cac9087612959565b611cb69190612978565b905084611cc38284612a86565b14611ce157604051635d616c1360e01b815260040160405180910390fd5b6036546040516331a9108f60e11b8152600481018690526000916001600160a01b031690636352211e9060240160206040518083038186803b158015611d2657600080fd5b505afa158015611d3a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d5e919061285b565b6001600160a01b03168360405160006040518083038185875af1925050503d8060008114611da8576040519150601f19603f3d011682016040523d82523d6000602084013e611dad565b606091505b5050905080611dcf5760405163665b0f0f60e01b815260040160405180910390fd5b6035546040805163220ce7e760e21b815290516000926001600160a01b0316916388339f9c916004808301926020929190829003018186803b158015611e1457600080fd5b505afa158015611e28573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e4c919061285b565b6001600160a01b03168360405160006040518083038185875af1925050503d8060008114611e96576040519150601f19603f3d011682016040523d82523d6000602084013e611e9b565b606091505b5050905080611ebd5760405163665b0f0f60e01b815260040160405180910390fd5b6039546035546040805163220ce7e760e21b815290516000936001600160a01b0390811693635ce5b444938c938c93909216916388339f9c91600480820192602092909190829003018186803b158015611f1657600080fd5b505afa158015611f2a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f4e919061285b565b6040516001600160e01b031960e086901b168152600481019390935260248301919091526001600160a01b03166044820152606401602060405180830381600087803b158015611f9d57600080fd5b505af1158015611fb1573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fd59190612832565b905080611ff55760405163665b0f0f60e01b815260040160405180910390fd5b5050505050505050565b600054610100900460ff1680612018575060005460ff16155b6120345760405162461bcd60e51b815260040161022f906127e4565b600054610100900460ff16158015612056576000805461ffff19166101011790555b82516020808501919091208351918401919091206001919091556002558015611ad2576000805461ff0019169055505050565b60006121047f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f6120b860015490565b6002546040805160208101859052908101839052606081018290524660808201523060a082015260009060c0016040516020818303038152906040528051906020012090509392505050565b905090565b6000808251604114156121405760208301516040840151606085015160001a61213487828585612337565b94509450505050612172565b82516040141561216a576020830151604084015161215f868383612424565b935093505050612172565b506000905060025b9250929050565b600081600481111561218d5761218d612a9e565b14156121965750565b60018160048111156121aa576121aa612a9e565b14156121f85760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e61747572650000000000000000604482015260640161022f565b600281600481111561220c5761220c612a9e565b141561225a5760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e67746800604482015260640161022f565b600381600481111561226e5761226e612a9e565b14156122c75760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b606482015260840161022f565b60048160048111156122db576122db612a9e565b14156123345760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c604482015261756560f01b606482015260840161022f565b50565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a083111561236e575060009050600361241b565b8460ff16601b1415801561238657508460ff16601c14155b15612397575060009050600461241b565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa1580156123eb573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b0381166124145760006001925092505061241b565b9150600090505b94509492505050565b6000806001600160ff1b03831660ff84901c601b0161244587828885612337565b935093505050935093915050565b6001600160a01b038116811461233457600080fd5b600080600080600060a0868803121561248057600080fd5b853561248b81612453565b9450602086013561249b81612453565b935060408601356124ab81612453565b925060608601356124bb81612453565b915060808601356124cb81612453565b809150509295509295909350565b60ff8116811461233457600080fd5b634e487b7160e01b600052604160045260246000fd5b6040516080810167ffffffffffffffff81118282101715612521576125216124e8565b60405290565b600082601f83011261253857600080fd5b813567ffffffffffffffff80821115612553576125536124e8565b604051601f8301601f19908116603f0116810190828211818310171561257b5761257b6124e8565b8160405283815286602085880101111561259457600080fd5b836020870160208301376000602085830101528094505050505092915050565b60008060008060008060008060006101208a8c0312156125d357600080fd5b8935985060208a0135975060408a0135965060608a01356125f3816124d9565b955060808a0135945060a08a0135935060c08a013567ffffffffffffffff8082111561261e57600080fd5b61262a8d838e01612527565b945060e08c013593506101008c013591508082111561264857600080fd5b506126558c828d01612527565b9150509295985092959850929598565b600080600080600080600080610100898b03121561268257600080fd5b8835975060208901359650604089013561269b816124d9565b9550606089013594506080890135935060a089013567ffffffffffffffff808211156126c657600080fd5b6126d28c838d01612527565b945060c08b0135935060e08b01359150808211156126ef57600080fd5b506126fc8b828c01612527565b9150509295985092959890939650565b6000806000806000806000610140888a03121561272857600080fd5b87359650602080890135965089605f8a011261274357600080fd5b61274b6124fe565b8060c08b018c81111561275d57600080fd5b60408c015b818110156127795780358452928401928401612762565b50909750359550505060e088013567ffffffffffffffff8082111561279d57600080fd5b6127a98b838c01612527565b94506101008a013593506101208a01359150808211156127c857600080fd5b506127d58a828b01612527565b91505092959891949750929550565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b60006020828403121561284457600080fd5b8151801515811461285457600080fd5b9392505050565b60006020828403121561286d57600080fd5b815161285481612453565b60006020828403121561288a57600080fd5b8151612854816124d9565b6000602082840312156128a757600080fd5b5051919050565b6000815180845260005b818110156128d4576020818501810151868301820152016128b8565b818111156128e6576000602083870101525b50601f01601f19169290920160200192915050565b86815285602082015260ff8516604082015260018060a01b038416606082015282608082015260c060a0820152600061293760c08301846128ae565b98975050505050505050565b634e487b7160e01b600052601160045260246000fd5b600081600019048311821515161561297357612973612943565b500290565b60008261299557634e487b7160e01b600052601260045260246000fd5b500490565b60018060a01b038616815284602082015283604082015260ff8316606082015260a0608082015260006129d060a08301846128ae565b979650505050505050565b60008183825b6004811015612a005781518352602092830192909101906001016129e1565b50505060808201905092915050565b634e487b7160e01b600052603260045260246000fd5b6000600019821415612a3957612a39612943565b5060010190565b60e08101818660005b6004811015612a68578151835260209283019290910190600101612a49565b5050508460808301528360a08301528260c083015295945050505050565b60008219821115612a9957612a99612943565b500190565b634e487b7160e01b600052602160045260246000fdfea2646970667358221220ae550d78e3d3647e2bc8d0a4717ab2d429ddd79adec33df8e6254e8c4c20a72264736f6c63430008090033