{
  "language": "Solidity",
  "sources": {
    "contracts/Artist.sol": {
      "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity ^0.8.7;\n\n/*\n ██████  ██████  ██    ██ ███    ██ ██████  \n██      ██    ██ ██    ██ ████   ██ ██   ██ \n███████ ██    ██ ██    ██ ██ ██  ██ ██   ██ \n     ██ ██    ██ ██    ██ ██  ██ ██ ██   ██ \n███████  ██████   ██████  ██   ████ ██████ \n*/\n\nimport {IERC2981Upgradeable, IERC165Upgradeable} from '@openzeppelin/contracts-upgradeable/interfaces/IERC2981Upgradeable.sol';\nimport {ERC721Upgradeable} from '@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol';\nimport {OwnableUpgradeable} from '@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol';\nimport {Strings} from '@openzeppelin/contracts/utils/Strings.sol';\nimport {CountersUpgradeable} from '@openzeppelin/contracts-upgradeable/utils/CountersUpgradeable.sol';\n\n// This contract is a combination of Mirror.xyz's Editions.sol and Zora's SingleEditionMintable.sol\n\n/**\n * @title Artist\n * @author SoundXYZ\n */\ncontract Artist is ERC721Upgradeable, IERC2981Upgradeable, OwnableUpgradeable {\n    // todo (optimization): link Strings as a deployed library\n    using Strings for uint256;\n    using CountersUpgradeable for CountersUpgradeable.Counter;\n\n    // ============ Structs ============\n\n    struct Edition {\n        // The account that will receive sales revenue.\n        address payable fundingRecipient;\n        // The price at which each token will be sold, in ETH.\n        uint256 price;\n        // The number of tokens sold so far.\n        uint32 numSold;\n        // The maximum number of tokens that can be sold.\n        uint32 quantity;\n        // Royalty amount in bps\n        uint32 royaltyBPS;\n        // start timestamp of auction (in seconds since unix epoch)\n        uint32 startTime;\n        // end timestamp of auction (in seconds since unix epoch)\n        uint32 endTime;\n    }\n\n    // ============ Storage ============\n\n    string internal baseURI;\n\n    CountersUpgradeable.Counter private atTokenId;\n    CountersUpgradeable.Counter private atEditionId;\n\n    // Mapping of edition id to descriptive data.\n    mapping(uint256 => Edition) public editions;\n    // Mapping of token id to edition id.\n    mapping(uint256 => uint256) public tokenToEdition;\n    // The amount of funds that have been deposited for a given edition.\n    mapping(uint256 => uint256) public depositedForEdition;\n    // The amount of funds that have already been withdrawn for a given edition.\n    mapping(uint256 => uint256) public withdrawnForEdition;\n\n    // ============ Events ============\n\n    event EditionCreated(\n        uint256 indexed editionId,\n        address fundingRecipient,\n        uint256 price,\n        uint32 quantity,\n        uint32 royaltyBPS,\n        uint32 startTime,\n        uint32 endTime\n    );\n\n    event EditionPurchased(\n        uint256 indexed editionId,\n        uint256 indexed tokenId,\n        // `numSold` at time of purchase represents the \"serial number\" of the NFT.\n        uint32 numSold,\n        // The account that paid for and received the NFT.\n        address indexed buyer\n    );\n\n    // ============ Methods ============\n\n    /**\n      @param _owner Owner of edition\n      @param _name Name of artist\n    */\n    function initialize(\n        address _owner,\n        uint256 _artistId,\n        string memory _name,\n        string memory _symbol,\n        string memory _baseURI\n    ) public initializer {\n        __ERC721_init(_name, _symbol);\n        __Ownable_init();\n\n        // Set ownership to original sender of contract call\n        transferOwnership(_owner);\n\n        // E.g. https://sound.xyz/api/metadata/[artistId]/\n        baseURI = string(abi.encodePacked(_baseURI, _artistId.toString(), '/'));\n\n        // Set token id start to be 1 not 0\n        atTokenId.increment();\n        // Set edition id start to be 1 not 0\n        atEditionId.increment();\n    }\n\n    function createEdition(\n        address payable _fundingRecipient,\n        uint256 _price,\n        uint32 _quantity,\n        uint32 _royaltyBPS,\n        uint32 _startTime,\n        uint32 _endTime\n    ) external onlyOwner {\n        editions[atEditionId.current()] = Edition({\n            fundingRecipient: _fundingRecipient,\n            price: _price,\n            numSold: 0,\n            quantity: _quantity,\n            royaltyBPS: _royaltyBPS,\n            startTime: _startTime,\n            endTime: _endTime\n        });\n\n        emit EditionCreated(\n            atEditionId.current(),\n            _fundingRecipient,\n            _price,\n            _quantity,\n            _royaltyBPS,\n            _startTime,\n            _endTime\n        );\n\n        atEditionId.increment();\n    }\n\n    function buyEdition(uint256 _editionId) external payable {\n        // Check that the edition exists. Note: this is redundant\n        // with the next check, but it is useful for clearer error messaging.\n        require(editions[_editionId].quantity > 0, 'Edition does not exist');\n        // Check that there are still tokens available to purchase.\n        require(editions[_editionId].numSold < editions[_editionId].quantity, 'This edition is already sold out.');\n        // Check that the sender is paying the correct amount.\n        require(msg.value >= editions[_editionId].price, 'Must send enough to purchase the edition.');\n        // Don't allow purchases before the start time\n        require(editions[_editionId].startTime < block.timestamp, \"Auction hasn't started\");\n        // Don't allow purchases after the end time\n        require(editions[_editionId].endTime > block.timestamp, 'Auction has ended');\n\n        // Mint a new token for the sender, using the `tokenId`.\n        _mint(msg.sender, atTokenId.current());\n        // Update the deposited total for the edition\n        depositedForEdition[_editionId] += msg.value;\n        // Increment the number of tokens sold for this edition.\n        editions[_editionId].numSold++;\n        // Store the mapping of token id to the edition being purchased.\n        tokenToEdition[atTokenId.current()] = _editionId;\n\n        emit EditionPurchased(_editionId, atTokenId.current(), editions[_editionId].numSold, msg.sender);\n\n        atTokenId.increment();\n    }\n\n    // ============ Operational Methods ============\n\n    function withdrawFunds(uint256 _editionId) external {\n        // Compute the amount available for withdrawing from this edition.\n        uint256 remainingForEdition = depositedForEdition[_editionId] - withdrawnForEdition[_editionId];\n\n        // Set the amount withdrawn to the amount deposited.\n        withdrawnForEdition[_editionId] = depositedForEdition[_editionId];\n        // Send the amount that was remaining for the edition, to the funding recipient.\n        _sendFunds(editions[_editionId].fundingRecipient, remainingForEdition);\n    }\n\n    function setStartTime(uint256 _editionId, uint32 _startTime) external onlyOwner {\n        editions[_editionId].startTime = _startTime;\n    }\n\n    function setEndTime(uint256 _editionId, uint32 _endTime) external onlyOwner {\n        editions[_editionId].endTime = _endTime;\n    }\n\n    // ============ NFT Methods ============\n\n    // Returns e.g. https://sound.xyz/api/metadata/[artistId]/[editionId]/[tokenId]\n    function tokenURI(uint256 _tokenId) public view override returns (string memory) {\n        require(_exists(_tokenId), 'ERC721Metadata: URI query for nonexistent token');\n\n        // Concatenate the components, baseURI, editionId and tokenId, to create URI.\n        return string(abi.encodePacked(baseURI, tokenToEdition[_tokenId].toString(), '/', _tokenId.toString()));\n    }\n\n    // Returns e.g. https://sound.xyz/api/metadata/[artistId]/storefront\n    function contractURI() public view returns (string memory) {\n        // Concatenate the components, baseURI, editionId and tokenId, to create URI.\n        return string(abi.encodePacked(baseURI, 'storefront'));\n    }\n\n    // ============ Extensions =================\n\n    /**\n        @dev Get token ids for a given edition id\n        @param _editionId edition id\n     */\n    function getTokenIdsOfEdition(uint256 _editionId) public view returns (uint256[] memory) {\n        uint256[] memory tokenIdsOfEdition = new uint256[](editions[_editionId].numSold);\n        uint256 index = 0;\n\n        for (uint256 id = 1; id < atTokenId.current(); id++) {\n            if (tokenToEdition[id] == _editionId) {\n                tokenIdsOfEdition[index] = id;\n                index++;\n            }\n        }\n        return tokenIdsOfEdition;\n    }\n\n    /**\n        @dev Get owners of a given edition id\n        @param _editionId edition id\n     */\n    function getOwnersOfEdition(uint256 _editionId) public view returns (address[] memory) {\n        address[] memory ownersOfEdition = new address[](editions[_editionId].numSold);\n        uint256 index = 0;\n\n        for (uint256 id = 1; id < atTokenId.current(); id++) {\n            if (tokenToEdition[id] == _editionId) {\n                ownersOfEdition[index] = ERC721Upgradeable.ownerOf(id);\n                index++;\n            }\n        }\n        return ownersOfEdition;\n    }\n\n    /**\n        @dev Get royalty information for token\n        @param _editionId edition id\n        @param _salePrice Sale price for the token\n     */\n    function royaltyInfo(uint256 _editionId, uint256 _salePrice)\n        external\n        view\n        override\n        returns (address fundingRecipient, uint256 royaltyAmount)\n    {\n        Edition memory edition = editions[_editionId];\n\n        if (edition.fundingRecipient == address(0x0)) {\n            return (edition.fundingRecipient, 0);\n        }\n\n        uint256 royaltyBPS = uint256(edition.royaltyBPS);\n\n        return (edition.fundingRecipient, (_salePrice * royaltyBPS) / 10_000);\n    }\n\n    function totalSupply() external view returns (uint256) {\n        return atTokenId.current() - 1; // because atTokenId is 1-indexed\n    }\n\n    function supportsInterface(bytes4 _interfaceId)\n        public\n        view\n        override(ERC721Upgradeable, IERC165Upgradeable)\n        returns (bool)\n    {\n        return\n            type(IERC2981Upgradeable).interfaceId == _interfaceId || ERC721Upgradeable.supportsInterface(_interfaceId);\n    }\n\n    // ============ Private Methods ============\n\n    function _sendFunds(address payable _recipient, uint256 _amount) private {\n        require(address(this).balance >= _amount, 'Insufficient balance for send');\n\n        (bool success, ) = _recipient.call{value: _amount}('');\n        require(success, 'Unable to send value: recipient may have reverted');\n    }\n}\n"
    },
    "@openzeppelin/contracts-upgradeable/interfaces/IERC2981Upgradeable.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (interfaces/IERC2981.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/introspection/IERC165Upgradeable.sol\";\n\n/**\n * @dev Interface for the NFT Royalty Standard.\n *\n * A standardized way to retrieve royalty payment information for non-fungible tokens (NFTs) to enable universal\n * support for royalty payments across all NFT marketplaces and ecosystem participants.\n *\n * _Available since v4.5._\n */\ninterface IERC2981Upgradeable is IERC165Upgradeable {\n    /**\n     * @dev Returns how much royalty is owed and to whom, based on a sale price that may be denominated in any unit of\n     * exchange. The royalty amount is denominated and should be paid in that same unit of exchange.\n     */\n    function royaltyInfo(uint256 tokenId, uint256 salePrice)\n        external\n        view\n        returns (address receiver, uint256 royaltyAmount);\n}\n"
    },
    "@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/ERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC721Upgradeable.sol\";\nimport \"./IERC721ReceiverUpgradeable.sol\";\nimport \"./extensions/IERC721MetadataUpgradeable.sol\";\nimport \"../../utils/AddressUpgradeable.sol\";\nimport \"../../utils/ContextUpgradeable.sol\";\nimport \"../../utils/StringsUpgradeable.sol\";\nimport \"../../utils/introspection/ERC165Upgradeable.sol\";\nimport \"../../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including\n * the Metadata extension, but not including the Enumerable extension, which is available separately as\n * {ERC721Enumerable}.\n */\ncontract ERC721Upgradeable is Initializable, ContextUpgradeable, ERC165Upgradeable, IERC721Upgradeable, IERC721MetadataUpgradeable {\n    using AddressUpgradeable for address;\n    using StringsUpgradeable for uint256;\n\n    // Token name\n    string private _name;\n\n    // Token symbol\n    string private _symbol;\n\n    // Mapping from token ID to owner address\n    mapping(uint256 => address) private _owners;\n\n    // Mapping owner address to token count\n    mapping(address => uint256) private _balances;\n\n    // Mapping from token ID to approved address\n    mapping(uint256 => address) private _tokenApprovals;\n\n    // Mapping from owner to operator approvals\n    mapping(address => mapping(address => bool)) private _operatorApprovals;\n\n    /**\n     * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.\n     */\n    function __ERC721_init(string memory name_, string memory symbol_) internal onlyInitializing {\n        __ERC721_init_unchained(name_, symbol_);\n    }\n\n    function __ERC721_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing {\n        _name = name_;\n        _symbol = symbol_;\n    }\n\n    /**\n     * @dev See {IERC165-supportsInterface}.\n     */\n    function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165Upgradeable, IERC165Upgradeable) returns (bool) {\n        return\n            interfaceId == type(IERC721Upgradeable).interfaceId ||\n            interfaceId == type(IERC721MetadataUpgradeable).interfaceId ||\n            super.supportsInterface(interfaceId);\n    }\n\n    /**\n     * @dev See {IERC721-balanceOf}.\n     */\n    function balanceOf(address owner) public view virtual override returns (uint256) {\n        require(owner != address(0), \"ERC721: address zero is not a valid owner\");\n        return _balances[owner];\n    }\n\n    /**\n     * @dev See {IERC721-ownerOf}.\n     */\n    function ownerOf(uint256 tokenId) public view virtual override returns (address) {\n        address owner = _owners[tokenId];\n        require(owner != address(0), \"ERC721: invalid token ID\");\n        return owner;\n    }\n\n    /**\n     * @dev See {IERC721Metadata-name}.\n     */\n    function name() public view virtual override returns (string memory) {\n        return _name;\n    }\n\n    /**\n     * @dev See {IERC721Metadata-symbol}.\n     */\n    function symbol() public view virtual override returns (string memory) {\n        return _symbol;\n    }\n\n    /**\n     * @dev See {IERC721Metadata-tokenURI}.\n     */\n    function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {\n        _requireMinted(tokenId);\n\n        string memory baseURI = _baseURI();\n        return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : \"\";\n    }\n\n    /**\n     * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each\n     * token will be the concatenation of the `baseURI` and the `tokenId`. Empty\n     * by default, can be overridden in child contracts.\n     */\n    function _baseURI() internal view virtual returns (string memory) {\n        return \"\";\n    }\n\n    /**\n     * @dev See {IERC721-approve}.\n     */\n    function approve(address to, uint256 tokenId) public virtual override {\n        address owner = ERC721Upgradeable.ownerOf(tokenId);\n        require(to != owner, \"ERC721: approval to current owner\");\n\n        require(\n            _msgSender() == owner || isApprovedForAll(owner, _msgSender()),\n            \"ERC721: approve caller is not token owner nor approved for all\"\n        );\n\n        _approve(to, tokenId);\n    }\n\n    /**\n     * @dev See {IERC721-getApproved}.\n     */\n    function getApproved(uint256 tokenId) public view virtual override returns (address) {\n        _requireMinted(tokenId);\n\n        return _tokenApprovals[tokenId];\n    }\n\n    /**\n     * @dev See {IERC721-setApprovalForAll}.\n     */\n    function setApprovalForAll(address operator, bool approved) public virtual override {\n        _setApprovalForAll(_msgSender(), operator, approved);\n    }\n\n    /**\n     * @dev See {IERC721-isApprovedForAll}.\n     */\n    function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {\n        return _operatorApprovals[owner][operator];\n    }\n\n    /**\n     * @dev See {IERC721-transferFrom}.\n     */\n    function transferFrom(\n        address from,\n        address to,\n        uint256 tokenId\n    ) public virtual override {\n        //solhint-disable-next-line max-line-length\n        require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: caller is not token owner nor approved\");\n\n        _transfer(from, to, tokenId);\n    }\n\n    /**\n     * @dev See {IERC721-safeTransferFrom}.\n     */\n    function safeTransferFrom(\n        address from,\n        address to,\n        uint256 tokenId\n    ) public virtual override {\n        safeTransferFrom(from, to, tokenId, \"\");\n    }\n\n    /**\n     * @dev See {IERC721-safeTransferFrom}.\n     */\n    function safeTransferFrom(\n        address from,\n        address to,\n        uint256 tokenId,\n        bytes memory data\n    ) public virtual override {\n        require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: caller is not token owner nor approved\");\n        _safeTransfer(from, to, tokenId, data);\n    }\n\n    /**\n     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n     * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n     *\n     * `data` is additional data, it has no specified format and it is sent in call to `to`.\n     *\n     * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.\n     * implement alternative mechanisms to perform token transfer, such as signature-based.\n     *\n     * Requirements:\n     *\n     * - `from` cannot be the zero address.\n     * - `to` cannot be the zero address.\n     * - `tokenId` token must exist and be owned by `from`.\n     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n     *\n     * Emits a {Transfer} event.\n     */\n    function _safeTransfer(\n        address from,\n        address to,\n        uint256 tokenId,\n        bytes memory data\n    ) internal virtual {\n        _transfer(from, to, tokenId);\n        require(_checkOnERC721Received(from, to, tokenId, data), \"ERC721: transfer to non ERC721Receiver implementer\");\n    }\n\n    /**\n     * @dev Returns whether `tokenId` exists.\n     *\n     * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.\n     *\n     * Tokens start existing when they are minted (`_mint`),\n     * and stop existing when they are burned (`_burn`).\n     */\n    function _exists(uint256 tokenId) internal view virtual returns (bool) {\n        return _owners[tokenId] != address(0);\n    }\n\n    /**\n     * @dev Returns whether `spender` is allowed to manage `tokenId`.\n     *\n     * Requirements:\n     *\n     * - `tokenId` must exist.\n     */\n    function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {\n        address owner = ERC721Upgradeable.ownerOf(tokenId);\n        return (spender == owner || isApprovedForAll(owner, spender) || getApproved(tokenId) == spender);\n    }\n\n    /**\n     * @dev Safely mints `tokenId` and transfers it to `to`.\n     *\n     * Requirements:\n     *\n     * - `tokenId` must not exist.\n     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n     *\n     * Emits a {Transfer} event.\n     */\n    function _safeMint(address to, uint256 tokenId) internal virtual {\n        _safeMint(to, tokenId, \"\");\n    }\n\n    /**\n     * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is\n     * forwarded in {IERC721Receiver-onERC721Received} to contract recipients.\n     */\n    function _safeMint(\n        address to,\n        uint256 tokenId,\n        bytes memory data\n    ) internal virtual {\n        _mint(to, tokenId);\n        require(\n            _checkOnERC721Received(address(0), to, tokenId, data),\n            \"ERC721: transfer to non ERC721Receiver implementer\"\n        );\n    }\n\n    /**\n     * @dev Mints `tokenId` and transfers it to `to`.\n     *\n     * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible\n     *\n     * Requirements:\n     *\n     * - `tokenId` must not exist.\n     * - `to` cannot be the zero address.\n     *\n     * Emits a {Transfer} event.\n     */\n    function _mint(address to, uint256 tokenId) internal virtual {\n        require(to != address(0), \"ERC721: mint to the zero address\");\n        require(!_exists(tokenId), \"ERC721: token already minted\");\n\n        _beforeTokenTransfer(address(0), to, tokenId);\n\n        _balances[to] += 1;\n        _owners[tokenId] = to;\n\n        emit Transfer(address(0), to, tokenId);\n\n        _afterTokenTransfer(address(0), to, tokenId);\n    }\n\n    /**\n     * @dev Destroys `tokenId`.\n     * The approval is cleared when the token is burned.\n     *\n     * Requirements:\n     *\n     * - `tokenId` must exist.\n     *\n     * Emits a {Transfer} event.\n     */\n    function _burn(uint256 tokenId) internal virtual {\n        address owner = ERC721Upgradeable.ownerOf(tokenId);\n\n        _beforeTokenTransfer(owner, address(0), tokenId);\n\n        // Clear approvals\n        _approve(address(0), tokenId);\n\n        _balances[owner] -= 1;\n        delete _owners[tokenId];\n\n        emit Transfer(owner, address(0), tokenId);\n\n        _afterTokenTransfer(owner, address(0), tokenId);\n    }\n\n    /**\n     * @dev Transfers `tokenId` from `from` to `to`.\n     *  As opposed to {transferFrom}, this imposes no restrictions on msg.sender.\n     *\n     * Requirements:\n     *\n     * - `to` cannot be the zero address.\n     * - `tokenId` token must be owned by `from`.\n     *\n     * Emits a {Transfer} event.\n     */\n    function _transfer(\n        address from,\n        address to,\n        uint256 tokenId\n    ) internal virtual {\n        require(ERC721Upgradeable.ownerOf(tokenId) == from, \"ERC721: transfer from incorrect owner\");\n        require(to != address(0), \"ERC721: transfer to the zero address\");\n\n        _beforeTokenTransfer(from, to, tokenId);\n\n        // Clear approvals from the previous owner\n        _approve(address(0), tokenId);\n\n        _balances[from] -= 1;\n        _balances[to] += 1;\n        _owners[tokenId] = to;\n\n        emit Transfer(from, to, tokenId);\n\n        _afterTokenTransfer(from, to, tokenId);\n    }\n\n    /**\n     * @dev Approve `to` to operate on `tokenId`\n     *\n     * Emits an {Approval} event.\n     */\n    function _approve(address to, uint256 tokenId) internal virtual {\n        _tokenApprovals[tokenId] = to;\n        emit Approval(ERC721Upgradeable.ownerOf(tokenId), to, tokenId);\n    }\n\n    /**\n     * @dev Approve `operator` to operate on all of `owner` tokens\n     *\n     * Emits an {ApprovalForAll} event.\n     */\n    function _setApprovalForAll(\n        address owner,\n        address operator,\n        bool approved\n    ) internal virtual {\n        require(owner != operator, \"ERC721: approve to caller\");\n        _operatorApprovals[owner][operator] = approved;\n        emit ApprovalForAll(owner, operator, approved);\n    }\n\n    /**\n     * @dev Reverts if the `tokenId` has not been minted yet.\n     */\n    function _requireMinted(uint256 tokenId) internal view virtual {\n        require(_exists(tokenId), \"ERC721: invalid token ID\");\n    }\n\n    /**\n     * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.\n     * The call is not executed if the target address is not a contract.\n     *\n     * @param from address representing the previous owner of the given token ID\n     * @param to target address that will receive the tokens\n     * @param tokenId uint256 ID of the token to be transferred\n     * @param data bytes optional data to send along with the call\n     * @return bool whether the call correctly returned the expected magic value\n     */\n    function _checkOnERC721Received(\n        address from,\n        address to,\n        uint256 tokenId,\n        bytes memory data\n    ) private returns (bool) {\n        if (to.isContract()) {\n            try IERC721ReceiverUpgradeable(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) {\n                return retval == IERC721ReceiverUpgradeable.onERC721Received.selector;\n            } catch (bytes memory reason) {\n                if (reason.length == 0) {\n                    revert(\"ERC721: transfer to non ERC721Receiver implementer\");\n                } else {\n                    /// @solidity memory-safe-assembly\n                    assembly {\n                        revert(add(32, reason), mload(reason))\n                    }\n                }\n            }\n        } else {\n            return true;\n        }\n    }\n\n    /**\n     * @dev Hook that is called before any token transfer. This includes minting\n     * and burning.\n     *\n     * Calling conditions:\n     *\n     * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be\n     * transferred to `to`.\n     * - When `from` is zero, `tokenId` will be minted for `to`.\n     * - When `to` is zero, ``from``'s `tokenId` will be burned.\n     * - `from` and `to` are never both zero.\n     *\n     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n     */\n    function _beforeTokenTransfer(\n        address from,\n        address to,\n        uint256 tokenId\n    ) internal virtual {}\n\n    /**\n     * @dev Hook that is called after any transfer of tokens. This includes\n     * minting and burning.\n     *\n     * Calling conditions:\n     *\n     * - when `from` and `to` are both non-zero.\n     * - `from` and `to` are never both zero.\n     *\n     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n     */\n    function _afterTokenTransfer(\n        address from,\n        address to,\n        uint256 tokenId\n    ) internal virtual {}\n\n    /**\n     * @dev This empty reserved space is put in place to allow future versions to add new\n     * variables without shifting down storage in the inheritance chain.\n     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n     */\n    uint256[44] private __gap;\n}\n"
    },
    "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/ContextUpgradeable.sol\";\nimport \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {\n    address private _owner;\n\n    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n    /**\n     * @dev Initializes the contract setting the deployer as the initial owner.\n     */\n    function __Ownable_init() internal onlyInitializing {\n        __Ownable_init_unchained();\n    }\n\n    function __Ownable_init_unchained() internal onlyInitializing {\n        _transferOwnership(_msgSender());\n    }\n\n    /**\n     * @dev Throws if called by any account other than the owner.\n     */\n    modifier onlyOwner() {\n        _checkOwner();\n        _;\n    }\n\n    /**\n     * @dev Returns the address of the current owner.\n     */\n    function owner() public view virtual returns (address) {\n        return _owner;\n    }\n\n    /**\n     * @dev Throws if the sender is not the owner.\n     */\n    function _checkOwner() internal view virtual {\n        require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n    }\n\n    /**\n     * @dev Leaves the contract without owner. It will not be possible to call\n     * `onlyOwner` functions anymore. Can only be called by the current owner.\n     *\n     * NOTE: Renouncing ownership will leave the contract without an owner,\n     * thereby removing any functionality that is only available to the owner.\n     */\n    function renounceOwnership() public virtual onlyOwner {\n        _transferOwnership(address(0));\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     * Can only be called by the current owner.\n     */\n    function transferOwnership(address newOwner) public virtual onlyOwner {\n        require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n        _transferOwnership(newOwner);\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     * Internal function without access restriction.\n     */\n    function _transferOwnership(address newOwner) internal virtual {\n        address oldOwner = _owner;\n        _owner = newOwner;\n        emit OwnershipTransferred(oldOwner, newOwner);\n    }\n\n    /**\n     * @dev This empty reserved space is put in place to allow future versions to add new\n     * variables without shifting down storage in the inheritance chain.\n     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n     */\n    uint256[49] private __gap;\n}\n"
    },
    "@openzeppelin/contracts/utils/Strings.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n    bytes16 private constant _HEX_SYMBOLS = \"0123456789abcdef\";\n    uint8 private constant _ADDRESS_LENGTH = 20;\n\n    /**\n     * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n     */\n    function toString(uint256 value) internal pure returns (string memory) {\n        // Inspired by OraclizeAPI's implementation - MIT licence\n        // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\n\n        if (value == 0) {\n            return \"0\";\n        }\n        uint256 temp = value;\n        uint256 digits;\n        while (temp != 0) {\n            digits++;\n            temp /= 10;\n        }\n        bytes memory buffer = new bytes(digits);\n        while (value != 0) {\n            digits -= 1;\n            buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\n            value /= 10;\n        }\n        return string(buffer);\n    }\n\n    /**\n     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n     */\n    function toHexString(uint256 value) internal pure returns (string memory) {\n        if (value == 0) {\n            return \"0x00\";\n        }\n        uint256 temp = value;\n        uint256 length = 0;\n        while (temp != 0) {\n            length++;\n            temp >>= 8;\n        }\n        return toHexString(value, length);\n    }\n\n    /**\n     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n     */\n    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n        bytes memory buffer = new bytes(2 * length + 2);\n        buffer[0] = \"0\";\n        buffer[1] = \"x\";\n        for (uint256 i = 2 * length + 1; i > 1; --i) {\n            buffer[i] = _HEX_SYMBOLS[value & 0xf];\n            value >>= 4;\n        }\n        require(value == 0, \"Strings: hex length insufficient\");\n        return string(buffer);\n    }\n\n    /**\n     * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.\n     */\n    function toHexString(address addr) internal pure returns (string memory) {\n        return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);\n    }\n}\n"
    },
    "@openzeppelin/contracts-upgradeable/utils/CountersUpgradeable.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Counters.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @title Counters\n * @author Matt Condon (@shrugs)\n * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number\n * of elements in a mapping, issuing ERC721 ids, or counting request ids.\n *\n * Include with `using Counters for Counters.Counter;`\n */\nlibrary CountersUpgradeable {\n    struct Counter {\n        // This variable should never be directly accessed by users of the library: interactions must be restricted to\n        // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add\n        // this feature: see https://github.com/ethereum/solidity/issues/4637\n        uint256 _value; // default: 0\n    }\n\n    function current(Counter storage counter) internal view returns (uint256) {\n        return counter._value;\n    }\n\n    function increment(Counter storage counter) internal {\n        unchecked {\n            counter._value += 1;\n        }\n    }\n\n    function decrement(Counter storage counter) internal {\n        uint256 value = counter._value;\n        require(value > 0, \"Counter: decrement overflow\");\n        unchecked {\n            counter._value = value - 1;\n        }\n    }\n\n    function reset(Counter storage counter) internal {\n        counter._value = 0;\n    }\n}\n"
    },
    "@openzeppelin/contracts-upgradeable/utils/introspection/IERC165Upgradeable.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165Upgradeable {\n    /**\n     * @dev Returns true if this contract implements the interface defined by\n     * `interfaceId`. See the corresponding\n     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n     * to learn more about how these ids are created.\n     *\n     * This function call must use less than 30 000 gas.\n     */\n    function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n"
    },
    "@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/IERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165Upgradeable.sol\";\n\n/**\n * @dev Required interface of an ERC721 compliant contract.\n */\ninterface IERC721Upgradeable is IERC165Upgradeable {\n    /**\n     * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\n     */\n    event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n\n    /**\n     * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\n     */\n    event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n\n    /**\n     * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\n     */\n    event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n    /**\n     * @dev Returns the number of tokens in ``owner``'s account.\n     */\n    function balanceOf(address owner) external view returns (uint256 balance);\n\n    /**\n     * @dev Returns the owner of the `tokenId` token.\n     *\n     * Requirements:\n     *\n     * - `tokenId` must exist.\n     */\n    function ownerOf(uint256 tokenId) external view returns (address owner);\n\n    /**\n     * @dev Safely transfers `tokenId` token from `from` to `to`.\n     *\n     * Requirements:\n     *\n     * - `from` cannot be the zero address.\n     * - `to` cannot be the zero address.\n     * - `tokenId` token must exist and be owned by `from`.\n     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n     *\n     * Emits a {Transfer} event.\n     */\n    function safeTransferFrom(\n        address from,\n        address to,\n        uint256 tokenId,\n        bytes calldata data\n    ) external;\n\n    /**\n     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n     * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n     *\n     * Requirements:\n     *\n     * - `from` cannot be the zero address.\n     * - `to` cannot be the zero address.\n     * - `tokenId` token must exist and be owned by `from`.\n     * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.\n     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n     *\n     * Emits a {Transfer} event.\n     */\n    function safeTransferFrom(\n        address from,\n        address to,\n        uint256 tokenId\n    ) external;\n\n    /**\n     * @dev Transfers `tokenId` token from `from` to `to`.\n     *\n     * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.\n     *\n     * Requirements:\n     *\n     * - `from` cannot be the zero address.\n     * - `to` cannot be the zero address.\n     * - `tokenId` token must be owned by `from`.\n     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transferFrom(\n        address from,\n        address to,\n        uint256 tokenId\n    ) external;\n\n    /**\n     * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n     * The approval is cleared when the token is transferred.\n     *\n     * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\n     *\n     * Requirements:\n     *\n     * - The caller must own the token or be an approved operator.\n     * - `tokenId` must exist.\n     *\n     * Emits an {Approval} event.\n     */\n    function approve(address to, uint256 tokenId) external;\n\n    /**\n     * @dev Approve or remove `operator` as an operator for the caller.\n     * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\n     *\n     * Requirements:\n     *\n     * - The `operator` cannot be the caller.\n     *\n     * Emits an {ApprovalForAll} event.\n     */\n    function setApprovalForAll(address operator, bool _approved) external;\n\n    /**\n     * @dev Returns the account approved for `tokenId` token.\n     *\n     * Requirements:\n     *\n     * - `tokenId` must exist.\n     */\n    function getApproved(uint256 tokenId) external view returns (address operator);\n\n    /**\n     * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n     *\n     * See {setApprovalForAll}\n     */\n    function isApprovedForAll(address owner, address operator) external view returns (bool);\n}\n"
    },
    "@openzeppelin/contracts-upgradeable/token/ERC721/IERC721ReceiverUpgradeable.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @title ERC721 token receiver interface\n * @dev Interface for any contract that wants to support safeTransfers\n * from ERC721 asset contracts.\n */\ninterface IERC721ReceiverUpgradeable {\n    /**\n     * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\n     * by `operator` from `from`, this function is called.\n     *\n     * It must return its Solidity selector to confirm the token transfer.\n     * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.\n     *\n     * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.\n     */\n    function onERC721Received(\n        address operator,\n        address from,\n        uint256 tokenId,\n        bytes calldata data\n    ) external returns (bytes4);\n}\n"
    },
    "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/IERC721MetadataUpgradeable.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC721Upgradeable.sol\";\n\n/**\n * @title ERC-721 Non-Fungible Token Standard, optional metadata extension\n * @dev See https://eips.ethereum.org/EIPS/eip-721\n */\ninterface IERC721MetadataUpgradeable is IERC721Upgradeable {\n    /**\n     * @dev Returns the token collection name.\n     */\n    function name() external view returns (string memory);\n\n    /**\n     * @dev Returns the token collection symbol.\n     */\n    function symbol() external view returns (string memory);\n\n    /**\n     * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.\n     */\n    function tokenURI(uint256 tokenId) external view returns (string memory);\n}\n"
    },
    "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary AddressUpgradeable {\n    /**\n     * @dev Returns true if `account` is a contract.\n     *\n     * [IMPORTANT]\n     * ====\n     * It is unsafe to assume that an address for which this function returns\n     * false is an externally-owned account (EOA) and not a contract.\n     *\n     * Among others, `isContract` will return false for the following\n     * types of addresses:\n     *\n     *  - an externally-owned account\n     *  - a contract in construction\n     *  - an address where a contract will be created\n     *  - an address where a contract lived, but was destroyed\n     * ====\n     *\n     * [IMPORTANT]\n     * ====\n     * You shouldn't rely on `isContract` to protect against flash loan attacks!\n     *\n     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n     * constructor.\n     * ====\n     */\n    function isContract(address account) internal view returns (bool) {\n        // This method relies on extcodesize/address.code.length, which returns 0\n        // for contracts in construction, since the code is only stored at the end\n        // of the constructor execution.\n\n        return account.code.length > 0;\n    }\n\n    /**\n     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n     * `recipient`, forwarding all available gas and reverting on errors.\n     *\n     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n     * of certain opcodes, possibly making contracts go over the 2300 gas limit\n     * imposed by `transfer`, making them unable to receive funds via\n     * `transfer`. {sendValue} removes this limitation.\n     *\n     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n     *\n     * IMPORTANT: because control is transferred to `recipient`, care must be\n     * taken to not create reentrancy vulnerabilities. Consider using\n     * {ReentrancyGuard} or the\n     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n     */\n    function sendValue(address payable recipient, uint256 amount) internal {\n        require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n        (bool success, ) = recipient.call{value: amount}(\"\");\n        require(success, \"Address: unable to send value, recipient may have reverted\");\n    }\n\n    /**\n     * @dev Performs a Solidity function call using a low level `call`. A\n     * plain `call` is an unsafe replacement for a function call: use this\n     * function instead.\n     *\n     * If `target` reverts with a revert reason, it is bubbled up by this\n     * function (like regular Solidity function calls).\n     *\n     * Returns the raw returned data. To convert to the expected return value,\n     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n     *\n     * Requirements:\n     *\n     * - `target` must be a contract.\n     * - calling `target` with `data` must not revert.\n     *\n     * _Available since v3.1._\n     */\n    function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n        return functionCall(target, data, \"Address: low-level call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n     * `errorMessage` as a fallback revert reason when `target` reverts.\n     *\n     * _Available since v3.1._\n     */\n    function functionCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, 0, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but also transferring `value` wei to `target`.\n     *\n     * Requirements:\n     *\n     * - the calling contract must have an ETH balance of at least `value`.\n     * - the called Solidity function must be `payable`.\n     *\n     * _Available since v3.1._\n     */\n    function functionCallWithValue(\n        address target,\n        bytes memory data,\n        uint256 value\n    ) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n     * with `errorMessage` as a fallback revert reason when `target` reverts.\n     *\n     * _Available since v3.1._\n     */\n    function functionCallWithValue(\n        address target,\n        bytes memory data,\n        uint256 value,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        require(address(this).balance >= value, \"Address: insufficient balance for call\");\n        require(isContract(target), \"Address: call to non-contract\");\n\n        (bool success, bytes memory returndata) = target.call{value: value}(data);\n        return verifyCallResult(success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but performing a static call.\n     *\n     * _Available since v3.3._\n     */\n    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n        return functionStaticCall(target, data, \"Address: low-level static call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n     * but performing a static call.\n     *\n     * _Available since v3.3._\n     */\n    function functionStaticCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal view returns (bytes memory) {\n        require(isContract(target), \"Address: static call to non-contract\");\n\n        (bool success, bytes memory returndata) = target.staticcall(data);\n        return verifyCallResult(success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\n     * revert reason using the provided one.\n     *\n     * _Available since v4.3._\n     */\n    function verifyCallResult(\n        bool success,\n        bytes memory returndata,\n        string memory errorMessage\n    ) internal pure returns (bytes memory) {\n        if (success) {\n            return returndata;\n        } else {\n            // Look for revert reason and bubble it up if present\n            if (returndata.length > 0) {\n                // The easiest way to bubble the revert reason is using memory via assembly\n                /// @solidity memory-safe-assembly\n                assembly {\n                    let returndata_size := mload(returndata)\n                    revert(add(32, returndata), returndata_size)\n                }\n            } else {\n                revert(errorMessage);\n            }\n        }\n    }\n}\n"
    },
    "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\nimport \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract ContextUpgradeable is Initializable {\n    function __Context_init() internal onlyInitializing {\n    }\n\n    function __Context_init_unchained() internal onlyInitializing {\n    }\n    function _msgSender() internal view virtual returns (address) {\n        return msg.sender;\n    }\n\n    function _msgData() internal view virtual returns (bytes calldata) {\n        return msg.data;\n    }\n\n    /**\n     * @dev This empty reserved space is put in place to allow future versions to add new\n     * variables without shifting down storage in the inheritance chain.\n     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n     */\n    uint256[50] private __gap;\n}\n"
    },
    "@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev String operations.\n */\nlibrary StringsUpgradeable {\n    bytes16 private constant _HEX_SYMBOLS = \"0123456789abcdef\";\n    uint8 private constant _ADDRESS_LENGTH = 20;\n\n    /**\n     * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n     */\n    function toString(uint256 value) internal pure returns (string memory) {\n        // Inspired by OraclizeAPI's implementation - MIT licence\n        // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol\n\n        if (value == 0) {\n            return \"0\";\n        }\n        uint256 temp = value;\n        uint256 digits;\n        while (temp != 0) {\n            digits++;\n            temp /= 10;\n        }\n        bytes memory buffer = new bytes(digits);\n        while (value != 0) {\n            digits -= 1;\n            buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));\n            value /= 10;\n        }\n        return string(buffer);\n    }\n\n    /**\n     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n     */\n    function toHexString(uint256 value) internal pure returns (string memory) {\n        if (value == 0) {\n            return \"0x00\";\n        }\n        uint256 temp = value;\n        uint256 length = 0;\n        while (temp != 0) {\n            length++;\n            temp >>= 8;\n        }\n        return toHexString(value, length);\n    }\n\n    /**\n     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n     */\n    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n        bytes memory buffer = new bytes(2 * length + 2);\n        buffer[0] = \"0\";\n        buffer[1] = \"x\";\n        for (uint256 i = 2 * length + 1; i > 1; --i) {\n            buffer[i] = _HEX_SYMBOLS[value & 0xf];\n            value >>= 4;\n        }\n        require(value == 0, \"Strings: hex length insufficient\");\n        return string(buffer);\n    }\n\n    /**\n     * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.\n     */\n    function toHexString(address addr) internal pure returns (string memory) {\n        return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);\n    }\n}\n"
    },
    "@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165Upgradeable.sol\";\nimport \"../../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n *\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\n */\nabstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable {\n    function __ERC165_init() internal onlyInitializing {\n    }\n\n    function __ERC165_init_unchained() internal onlyInitializing {\n    }\n    /**\n     * @dev See {IERC165-supportsInterface}.\n     */\n    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n        return interfaceId == type(IERC165Upgradeable).interfaceId;\n    }\n\n    /**\n     * @dev This empty reserved space is put in place to allow future versions to add new\n     * variables without shifting down storage in the inheritance chain.\n     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n     */\n    uint256[50] private __gap;\n}\n"
    },
    "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/utils/Initializable.sol)\n\npragma solidity ^0.8.2;\n\nimport \"../../utils/AddressUpgradeable.sol\";\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * contract MyToken is ERC20Upgradeable {\n *     function initialize() initializer public {\n *         __ERC20_init(\"MyToken\", \"MTK\");\n *     }\n * }\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n *     function initializeV2() reinitializer(2) public {\n *         __ERC20Permit_init(\"MyToken\");\n *     }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n *     _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n    /**\n     * @dev Indicates that the contract has been initialized.\n     * @custom:oz-retyped-from bool\n     */\n    uint8 private _initialized;\n\n    /**\n     * @dev Indicates that the contract is in the process of being initialized.\n     */\n    bool private _initializing;\n\n    /**\n     * @dev Triggered when the contract has been initialized or reinitialized.\n     */\n    event Initialized(uint8 version);\n\n    /**\n     * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n     * `onlyInitializing` functions can be used to initialize parent contracts. Equivalent to `reinitializer(1)`.\n     */\n    modifier initializer() {\n        bool isTopLevelCall = !_initializing;\n        require(\n            (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\n            \"Initializable: contract is already initialized\"\n        );\n        _initialized = 1;\n        if (isTopLevelCall) {\n            _initializing = true;\n        }\n        _;\n        if (isTopLevelCall) {\n            _initializing = false;\n            emit Initialized(1);\n        }\n    }\n\n    /**\n     * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n     * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n     * used to initialize parent contracts.\n     *\n     * `initializer` is equivalent to `reinitializer(1)`, so a reinitializer may be used after the original\n     * initialization step. This is essential to configure modules that are added through upgrades and that require\n     * initialization.\n     *\n     * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n     * a contract, executing them in the right order is up to the developer or operator.\n     */\n    modifier reinitializer(uint8 version) {\n        require(!_initializing && _initialized < version, \"Initializable: contract is already initialized\");\n        _initialized = version;\n        _initializing = true;\n        _;\n        _initializing = false;\n        emit Initialized(version);\n    }\n\n    /**\n     * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n     * {initializer} and {reinitializer} modifiers, directly or indirectly.\n     */\n    modifier onlyInitializing() {\n        require(_initializing, \"Initializable: contract is not initializing\");\n        _;\n    }\n\n    /**\n     * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n     * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n     * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n     * through proxies.\n     */\n    function _disableInitializers() internal virtual {\n        require(!_initializing, \"Initializable: contract is initializing\");\n        if (_initialized < type(uint8).max) {\n            _initialized = type(uint8).max;\n            emit Initialized(type(uint8).max);\n        }\n    }\n}\n"
    },
    "contracts/test-contracts/ArtistCreatorUpgradeTest.sol": {
      "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity ^0.8.7;\n\n/*\n ██████  ██████  ██    ██ ███    ██ ██████  \n██      ██    ██ ██    ██ ████   ██ ██   ██ \n███████ ██    ██ ██    ██ ██ ██  ██ ██   ██ \n     ██ ██    ██ ██    ██ ██  ██ ██ ██   ██ \n███████  ██████   ██████  ██   ████ ██████ \n*/\n\nimport '@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol';\nimport '@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol';\nimport '@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol';\nimport '@openzeppelin/contracts-upgradeable/utils/CountersUpgradeable.sol';\nimport '@openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol';\nimport '@openzeppelin/contracts/proxy/beacon/BeaconProxy.sol';\nimport '@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol';\nimport '../Artist.sol';\n\ncontract ArtistCreatorUpgradeTest is Initializable, UUPSUpgradeable, OwnableUpgradeable {\n    using CountersUpgradeable for CountersUpgradeable.Counter;\n    using ECDSAUpgradeable for bytes32;\n\n    // ============ Storage ============\n\n    bytes32 public constant MINTER_TYPEHASH = keccak256('Deployer(address artistWallet)');\n    CountersUpgradeable.Counter private atArtistId;\n    // address used for signature verification, changeable by owner\n    address public admin;\n    bytes32 public DOMAIN_SEPARATOR;\n    address public beaconAddress;\n    // registry of created contracts\n    address[] public artistContracts;\n\n    // ============ Events ============\n\n    /// Emitted when an Artist is created\n    event CreatedArtist(uint256 artistId, string name, string symbol, address indexed artistAddress);\n\n    // ============ Functions ============\n\n    /// Initializes factory\n    function initialize() public initializer {\n        __Ownable_init_unchained();\n\n        // set admin for artist deployment authorization\n        admin = msg.sender;\n        DOMAIN_SEPARATOR = keccak256(abi.encode(keccak256('EIP712Domain(uint256 chainId)'), block.chainid));\n\n        // set up beacon with msg.sender as the owner\n        UpgradeableBeacon _beacon = new UpgradeableBeacon(address(new Artist()));\n        _beacon.transferOwnership(msg.sender);\n        beaconAddress = address(_beacon);\n\n        // Set artist id start to be 1 not 0\n        atArtistId.increment();\n    }\n\n    /// Creates a new artist contract as a factory with a deterministic address\n    /// Important: None of these fields (except the Url fields with the same hash) can be changed after calling\n    /// @param _name Name of the artist\n    function createArtist(\n        bytes calldata signature,\n        string memory _name,\n        string memory _symbol,\n        string memory _baseURI\n    ) public returns (address) {\n        require((getSigner(signature) == admin), 'invalid authorization signature');\n\n        BeaconProxy proxy = new BeaconProxy(\n            beaconAddress,\n            abi.encodeWithSelector(\n                Artist(address(0)).initialize.selector,\n                msg.sender,\n                atArtistId.current(),\n                _name,\n                _symbol,\n                _baseURI\n            )\n        );\n\n        // add to registry\n        artistContracts.push(address(proxy));\n\n        emit CreatedArtist(atArtistId.current(), _name, _symbol, address(proxy));\n\n        atArtistId.increment();\n\n        return address(proxy);\n    }\n\n    /// Get signer address of signature\n    function getSigner(bytes calldata signature) public view returns (address) {\n        require(admin != address(0), 'whitelist not enabled');\n        // Verify EIP-712 signature by recreating the data structure\n        // that we signed on the client side, and then using that to recover\n        // the address that signed the signature for this data.\n        bytes32 digest = keccak256(\n            abi.encodePacked('\\x19\\x01', DOMAIN_SEPARATOR, keccak256(abi.encode(MINTER_TYPEHASH, msg.sender)))\n        );\n        // Use the recover method to see what address was used to create\n        // the signature on this data.\n        // Note that if the digest doesn't exactly match what was signed we'll\n        // get a random recovered address.\n        address recoveredAddress = digest.recover(signature);\n        return recoveredAddress;\n    }\n\n    /// Sets the admin for authorizing artist deployment\n    /// @param _newAdmin address of new admin\n    function setAdmin(address _newAdmin) external {\n        require(owner() == _msgSender() || admin == _msgSender(), 'invalid authorization');\n        admin = _newAdmin;\n    }\n\n    function _authorizeUpgrade(address) internal override onlyOwner {}\n\n    function markOfTheBeast() public pure returns (uint256) {\n        return 666;\n    }\n}\n"
    },
    "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (proxy/utils/UUPSUpgradeable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../interfaces/draft-IERC1822Upgradeable.sol\";\nimport \"../ERC1967/ERC1967UpgradeUpgradeable.sol\";\nimport \"./Initializable.sol\";\n\n/**\n * @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an\n * {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy.\n *\n * A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is\n * reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing\n * `UUPSUpgradeable` with a custom implementation of upgrades.\n *\n * The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism.\n *\n * _Available since v4.1._\n */\nabstract contract UUPSUpgradeable is Initializable, IERC1822ProxiableUpgradeable, ERC1967UpgradeUpgradeable {\n    function __UUPSUpgradeable_init() internal onlyInitializing {\n    }\n\n    function __UUPSUpgradeable_init_unchained() internal onlyInitializing {\n    }\n    /// @custom:oz-upgrades-unsafe-allow state-variable-immutable state-variable-assignment\n    address private immutable __self = address(this);\n\n    /**\n     * @dev Check that the execution is being performed through a delegatecall call and that the execution context is\n     * a proxy contract with an implementation (as defined in ERC1967) pointing to self. This should only be the case\n     * for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a\n     * function through ERC1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to\n     * fail.\n     */\n    modifier onlyProxy() {\n        require(address(this) != __self, \"Function must be called through delegatecall\");\n        require(_getImplementation() == __self, \"Function must be called through active proxy\");\n        _;\n    }\n\n    /**\n     * @dev Check that the execution is not being performed through a delegate call. This allows a function to be\n     * callable on the implementing contract but not through proxies.\n     */\n    modifier notDelegated() {\n        require(address(this) == __self, \"UUPSUpgradeable: must not be called through delegatecall\");\n        _;\n    }\n\n    /**\n     * @dev Implementation of the ERC1822 {proxiableUUID} function. This returns the storage slot used by the\n     * implementation. It is used to validate that the this implementation remains valid after an upgrade.\n     *\n     * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\n     * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\n     * function revert if invoked through a proxy. This is guaranteed by the `notDelegated` modifier.\n     */\n    function proxiableUUID() external view virtual override notDelegated returns (bytes32) {\n        return _IMPLEMENTATION_SLOT;\n    }\n\n    /**\n     * @dev Upgrade the implementation of the proxy to `newImplementation`.\n     *\n     * Calls {_authorizeUpgrade}.\n     *\n     * Emits an {Upgraded} event.\n     */\n    function upgradeTo(address newImplementation) external virtual onlyProxy {\n        _authorizeUpgrade(newImplementation);\n        _upgradeToAndCallUUPS(newImplementation, new bytes(0), false);\n    }\n\n    /**\n     * @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call\n     * encoded in `data`.\n     *\n     * Calls {_authorizeUpgrade}.\n     *\n     * Emits an {Upgraded} event.\n     */\n    function upgradeToAndCall(address newImplementation, bytes memory data) external payable virtual onlyProxy {\n        _authorizeUpgrade(newImplementation);\n        _upgradeToAndCallUUPS(newImplementation, data, true);\n    }\n\n    /**\n     * @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by\n     * {upgradeTo} and {upgradeToAndCall}.\n     *\n     * Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}.\n     *\n     * ```solidity\n     * function _authorizeUpgrade(address) internal override onlyOwner {}\n     * ```\n     */\n    function _authorizeUpgrade(address newImplementation) internal virtual;\n\n    /**\n     * @dev This empty reserved space is put in place to allow future versions to add new\n     * variables without shifting down storage in the inheritance chain.\n     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n     */\n    uint256[50] private __gap;\n}\n"
    },
    "@openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/cryptography/ECDSA.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../StringsUpgradeable.sol\";\n\n/**\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\n *\n * These functions can be used to verify that a message was signed by the holder\n * of the private keys of a given address.\n */\nlibrary ECDSAUpgradeable {\n    enum RecoverError {\n        NoError,\n        InvalidSignature,\n        InvalidSignatureLength,\n        InvalidSignatureS,\n        InvalidSignatureV\n    }\n\n    function _throwError(RecoverError error) private pure {\n        if (error == RecoverError.NoError) {\n            return; // no error: do nothing\n        } else if (error == RecoverError.InvalidSignature) {\n            revert(\"ECDSA: invalid signature\");\n        } else if (error == RecoverError.InvalidSignatureLength) {\n            revert(\"ECDSA: invalid signature length\");\n        } else if (error == RecoverError.InvalidSignatureS) {\n            revert(\"ECDSA: invalid signature 's' value\");\n        } else if (error == RecoverError.InvalidSignatureV) {\n            revert(\"ECDSA: invalid signature 'v' value\");\n        }\n    }\n\n    /**\n     * @dev Returns the address that signed a hashed message (`hash`) with\n     * `signature` or error string. This address can then be used for verification purposes.\n     *\n     * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n     * this function rejects them by requiring the `s` value to be in the lower\n     * half order, and the `v` value to be either 27 or 28.\n     *\n     * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n     * verification to be secure: it is possible to craft signatures that\n     * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n     * this is by receiving a hash of the original message (which may otherwise\n     * be too long), and then calling {toEthSignedMessageHash} on it.\n     *\n     * Documentation for signature generation:\n     * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]\n     * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]\n     *\n     * _Available since v4.3._\n     */\n    function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {\n        // Check the signature length\n        // - case 65: r,s,v signature (standard)\n        // - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._\n        if (signature.length == 65) {\n            bytes32 r;\n            bytes32 s;\n            uint8 v;\n            // ecrecover takes the signature parameters, and the only way to get them\n            // currently is to use assembly.\n            /// @solidity memory-safe-assembly\n            assembly {\n                r := mload(add(signature, 0x20))\n                s := mload(add(signature, 0x40))\n                v := byte(0, mload(add(signature, 0x60)))\n            }\n            return tryRecover(hash, v, r, s);\n        } else if (signature.length == 64) {\n            bytes32 r;\n            bytes32 vs;\n            // ecrecover takes the signature parameters, and the only way to get them\n            // currently is to use assembly.\n            /// @solidity memory-safe-assembly\n            assembly {\n                r := mload(add(signature, 0x20))\n                vs := mload(add(signature, 0x40))\n            }\n            return tryRecover(hash, r, vs);\n        } else {\n            return (address(0), RecoverError.InvalidSignatureLength);\n        }\n    }\n\n    /**\n     * @dev Returns the address that signed a hashed message (`hash`) with\n     * `signature`. This address can then be used for verification purposes.\n     *\n     * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n     * this function rejects them by requiring the `s` value to be in the lower\n     * half order, and the `v` value to be either 27 or 28.\n     *\n     * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n     * verification to be secure: it is possible to craft signatures that\n     * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n     * this is by receiving a hash of the original message (which may otherwise\n     * be too long), and then calling {toEthSignedMessageHash} on it.\n     */\n    function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {\n        (address recovered, RecoverError error) = tryRecover(hash, signature);\n        _throwError(error);\n        return recovered;\n    }\n\n    /**\n     * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.\n     *\n     * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]\n     *\n     * _Available since v4.3._\n     */\n    function tryRecover(\n        bytes32 hash,\n        bytes32 r,\n        bytes32 vs\n    ) internal pure returns (address, RecoverError) {\n        bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);\n        uint8 v = uint8((uint256(vs) >> 255) + 27);\n        return tryRecover(hash, v, r, s);\n    }\n\n    /**\n     * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.\n     *\n     * _Available since v4.2._\n     */\n    function recover(\n        bytes32 hash,\n        bytes32 r,\n        bytes32 vs\n    ) internal pure returns (address) {\n        (address recovered, RecoverError error) = tryRecover(hash, r, vs);\n        _throwError(error);\n        return recovered;\n    }\n\n    /**\n     * @dev Overload of {ECDSA-tryRecover} that receives the `v`,\n     * `r` and `s` signature fields separately.\n     *\n     * _Available since v4.3._\n     */\n    function tryRecover(\n        bytes32 hash,\n        uint8 v,\n        bytes32 r,\n        bytes32 s\n    ) internal pure returns (address, RecoverError) {\n        // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\n        // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\n        // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most\n        // signatures from current libraries generate a unique signature with an s-value in the lower half order.\n        //\n        // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value\n        // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or\n        // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept\n        // these malleable signatures as well.\n        if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\n            return (address(0), RecoverError.InvalidSignatureS);\n        }\n        if (v != 27 && v != 28) {\n            return (address(0), RecoverError.InvalidSignatureV);\n        }\n\n        // If the signature is valid (and not malleable), return the signer address\n        address signer = ecrecover(hash, v, r, s);\n        if (signer == address(0)) {\n            return (address(0), RecoverError.InvalidSignature);\n        }\n\n        return (signer, RecoverError.NoError);\n    }\n\n    /**\n     * @dev Overload of {ECDSA-recover} that receives the `v`,\n     * `r` and `s` signature fields separately.\n     */\n    function recover(\n        bytes32 hash,\n        uint8 v,\n        bytes32 r,\n        bytes32 s\n    ) internal pure returns (address) {\n        (address recovered, RecoverError error) = tryRecover(hash, v, r, s);\n        _throwError(error);\n        return recovered;\n    }\n\n    /**\n     * @dev Returns an Ethereum Signed Message, created from a `hash`. This\n     * produces hash corresponding to the one signed with the\n     * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n     * JSON-RPC method as part of EIP-191.\n     *\n     * See {recover}.\n     */\n    function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {\n        // 32 is the length in bytes of hash,\n        // enforced by the type signature above\n        return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n32\", hash));\n    }\n\n    /**\n     * @dev Returns an Ethereum Signed Message, created from `s`. This\n     * produces hash corresponding to the one signed with the\n     * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n     * JSON-RPC method as part of EIP-191.\n     *\n     * See {recover}.\n     */\n    function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {\n        return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n\", StringsUpgradeable.toString(s.length), s));\n    }\n\n    /**\n     * @dev Returns an Ethereum Signed Typed Data, created from a\n     * `domainSeparator` and a `structHash`. This produces hash corresponding\n     * to the one signed with the\n     * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]\n     * JSON-RPC method as part of EIP-712.\n     *\n     * See {recover}.\n     */\n    function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {\n        return keccak256(abi.encodePacked(\"\\x19\\x01\", domainSeparator, structHash));\n    }\n}\n"
    },
    "@openzeppelin/contracts/proxy/beacon/BeaconProxy.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/beacon/BeaconProxy.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IBeacon.sol\";\nimport \"../Proxy.sol\";\nimport \"../ERC1967/ERC1967Upgrade.sol\";\n\n/**\n * @dev This contract implements a proxy that gets the implementation address for each call from an {UpgradeableBeacon}.\n *\n * The beacon address is stored in storage slot `uint256(keccak256('eip1967.proxy.beacon')) - 1`, so that it doesn't\n * conflict with the storage layout of the implementation behind the proxy.\n *\n * _Available since v3.4._\n */\ncontract BeaconProxy is Proxy, ERC1967Upgrade {\n    /**\n     * @dev Initializes the proxy with `beacon`.\n     *\n     * If `data` is nonempty, it's used as data in a delegate call to the implementation returned by the beacon. This\n     * will typically be an encoded function call, and allows initializing the storage of the proxy like a Solidity\n     * constructor.\n     *\n     * Requirements:\n     *\n     * - `beacon` must be a contract with the interface {IBeacon}.\n     */\n    constructor(address beacon, bytes memory data) payable {\n        _upgradeBeaconToAndCall(beacon, data, false);\n    }\n\n    /**\n     * @dev Returns the current beacon address.\n     */\n    function _beacon() internal view virtual returns (address) {\n        return _getBeacon();\n    }\n\n    /**\n     * @dev Returns the current implementation address of the associated beacon.\n     */\n    function _implementation() internal view virtual override returns (address) {\n        return IBeacon(_getBeacon()).implementation();\n    }\n\n    /**\n     * @dev Changes the proxy to use a new beacon. Deprecated: see {_upgradeBeaconToAndCall}.\n     *\n     * If `data` is nonempty, it's used as data in a delegate call to the implementation returned by the beacon.\n     *\n     * Requirements:\n     *\n     * - `beacon` must be a contract.\n     * - The implementation returned by `beacon` must be a contract.\n     */\n    function _setBeacon(address beacon, bytes memory data) internal virtual {\n        _upgradeBeaconToAndCall(beacon, data, false);\n    }\n}\n"
    },
    "@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/UpgradeableBeacon.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IBeacon.sol\";\nimport \"../../access/Ownable.sol\";\nimport \"../../utils/Address.sol\";\n\n/**\n * @dev This contract is used in conjunction with one or more instances of {BeaconProxy} to determine their\n * implementation contract, which is where they will delegate all function calls.\n *\n * An owner is able to change the implementation the beacon points to, thus upgrading the proxies that use this beacon.\n */\ncontract UpgradeableBeacon is IBeacon, Ownable {\n    address private _implementation;\n\n    /**\n     * @dev Emitted when the implementation returned by the beacon is changed.\n     */\n    event Upgraded(address indexed implementation);\n\n    /**\n     * @dev Sets the address of the initial implementation, and the deployer account as the owner who can upgrade the\n     * beacon.\n     */\n    constructor(address implementation_) {\n        _setImplementation(implementation_);\n    }\n\n    /**\n     * @dev Returns the current implementation address.\n     */\n    function implementation() public view virtual override returns (address) {\n        return _implementation;\n    }\n\n    /**\n     * @dev Upgrades the beacon to a new implementation.\n     *\n     * Emits an {Upgraded} event.\n     *\n     * Requirements:\n     *\n     * - msg.sender must be the owner of the contract.\n     * - `newImplementation` must be a contract.\n     */\n    function upgradeTo(address newImplementation) public virtual onlyOwner {\n        _setImplementation(newImplementation);\n        emit Upgraded(newImplementation);\n    }\n\n    /**\n     * @dev Sets the implementation contract address for this beacon\n     *\n     * Requirements:\n     *\n     * - `newImplementation` must be a contract.\n     */\n    function _setImplementation(address newImplementation) private {\n        require(Address.isContract(newImplementation), \"UpgradeableBeacon: implementation is not a contract\");\n        _implementation = newImplementation;\n    }\n}\n"
    },
    "@openzeppelin/contracts-upgradeable/interfaces/draft-IERC1822Upgradeable.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\n * proxy whose upgrades are fully controlled by the current implementation.\n */\ninterface IERC1822ProxiableUpgradeable {\n    /**\n     * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\n     * address.\n     *\n     * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\n     * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\n     * function revert if invoked through a proxy.\n     */\n    function proxiableUUID() external view returns (bytes32);\n}\n"
    },
    "@openzeppelin/contracts-upgradeable/proxy/ERC1967/ERC1967UpgradeUpgradeable.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)\n\npragma solidity ^0.8.2;\n\nimport \"../beacon/IBeaconUpgradeable.sol\";\nimport \"../../interfaces/draft-IERC1822Upgradeable.sol\";\nimport \"../../utils/AddressUpgradeable.sol\";\nimport \"../../utils/StorageSlotUpgradeable.sol\";\nimport \"../utils/Initializable.sol\";\n\n/**\n * @dev This abstract contract provides getters and event emitting update functions for\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\n *\n * _Available since v4.1._\n *\n * @custom:oz-upgrades-unsafe-allow delegatecall\n */\nabstract contract ERC1967UpgradeUpgradeable is Initializable {\n    function __ERC1967Upgrade_init() internal onlyInitializing {\n    }\n\n    function __ERC1967Upgrade_init_unchained() internal onlyInitializing {\n    }\n    // This is the keccak-256 hash of \"eip1967.proxy.rollback\" subtracted by 1\n    bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\n\n    /**\n     * @dev Storage slot with the address of the current implementation.\n     * This is the keccak-256 hash of \"eip1967.proxy.implementation\" subtracted by 1, and is\n     * validated in the constructor.\n     */\n    bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n\n    /**\n     * @dev Emitted when the implementation is upgraded.\n     */\n    event Upgraded(address indexed implementation);\n\n    /**\n     * @dev Returns the current implementation address.\n     */\n    function _getImplementation() internal view returns (address) {\n        return StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n    }\n\n    /**\n     * @dev Stores a new address in the EIP1967 implementation slot.\n     */\n    function _setImplementation(address newImplementation) private {\n        require(AddressUpgradeable.isContract(newImplementation), \"ERC1967: new implementation is not a contract\");\n        StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n    }\n\n    /**\n     * @dev Perform implementation upgrade\n     *\n     * Emits an {Upgraded} event.\n     */\n    function _upgradeTo(address newImplementation) internal {\n        _setImplementation(newImplementation);\n        emit Upgraded(newImplementation);\n    }\n\n    /**\n     * @dev Perform implementation upgrade with additional setup call.\n     *\n     * Emits an {Upgraded} event.\n     */\n    function _upgradeToAndCall(\n        address newImplementation,\n        bytes memory data,\n        bool forceCall\n    ) internal {\n        _upgradeTo(newImplementation);\n        if (data.length > 0 || forceCall) {\n            _functionDelegateCall(newImplementation, data);\n        }\n    }\n\n    /**\n     * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\n     *\n     * Emits an {Upgraded} event.\n     */\n    function _upgradeToAndCallUUPS(\n        address newImplementation,\n        bytes memory data,\n        bool forceCall\n    ) internal {\n        // Upgrades from old implementations will perform a rollback test. This test requires the new\n        // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\n        // this special case will break upgrade paths from old UUPS implementation to new ones.\n        if (StorageSlotUpgradeable.getBooleanSlot(_ROLLBACK_SLOT).value) {\n            _setImplementation(newImplementation);\n        } else {\n            try IERC1822ProxiableUpgradeable(newImplementation).proxiableUUID() returns (bytes32 slot) {\n                require(slot == _IMPLEMENTATION_SLOT, \"ERC1967Upgrade: unsupported proxiableUUID\");\n            } catch {\n                revert(\"ERC1967Upgrade: new implementation is not UUPS\");\n            }\n            _upgradeToAndCall(newImplementation, data, forceCall);\n        }\n    }\n\n    /**\n     * @dev Storage slot with the admin of the contract.\n     * This is the keccak-256 hash of \"eip1967.proxy.admin\" subtracted by 1, and is\n     * validated in the constructor.\n     */\n    bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\n\n    /**\n     * @dev Emitted when the admin account has changed.\n     */\n    event AdminChanged(address previousAdmin, address newAdmin);\n\n    /**\n     * @dev Returns the current admin.\n     */\n    function _getAdmin() internal view returns (address) {\n        return StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value;\n    }\n\n    /**\n     * @dev Stores a new address in the EIP1967 admin slot.\n     */\n    function _setAdmin(address newAdmin) private {\n        require(newAdmin != address(0), \"ERC1967: new admin is the zero address\");\n        StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\n    }\n\n    /**\n     * @dev Changes the admin of the proxy.\n     *\n     * Emits an {AdminChanged} event.\n     */\n    function _changeAdmin(address newAdmin) internal {\n        emit AdminChanged(_getAdmin(), newAdmin);\n        _setAdmin(newAdmin);\n    }\n\n    /**\n     * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\n     * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\n     */\n    bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\n\n    /**\n     * @dev Emitted when the beacon is upgraded.\n     */\n    event BeaconUpgraded(address indexed beacon);\n\n    /**\n     * @dev Returns the current beacon.\n     */\n    function _getBeacon() internal view returns (address) {\n        return StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value;\n    }\n\n    /**\n     * @dev Stores a new beacon in the EIP1967 beacon slot.\n     */\n    function _setBeacon(address newBeacon) private {\n        require(AddressUpgradeable.isContract(newBeacon), \"ERC1967: new beacon is not a contract\");\n        require(\n            AddressUpgradeable.isContract(IBeaconUpgradeable(newBeacon).implementation()),\n            \"ERC1967: beacon implementation is not a contract\"\n        );\n        StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value = newBeacon;\n    }\n\n    /**\n     * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\n     * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\n     *\n     * Emits a {BeaconUpgraded} event.\n     */\n    function _upgradeBeaconToAndCall(\n        address newBeacon,\n        bytes memory data,\n        bool forceCall\n    ) internal {\n        _setBeacon(newBeacon);\n        emit BeaconUpgraded(newBeacon);\n        if (data.length > 0 || forceCall) {\n            _functionDelegateCall(IBeaconUpgradeable(newBeacon).implementation(), data);\n        }\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n     * but performing a delegate call.\n     *\n     * _Available since v3.4._\n     */\n    function _functionDelegateCall(address target, bytes memory data) private returns (bytes memory) {\n        require(AddressUpgradeable.isContract(target), \"Address: delegate call to non-contract\");\n\n        // solhint-disable-next-line avoid-low-level-calls\n        (bool success, bytes memory returndata) = target.delegatecall(data);\n        return AddressUpgradeable.verifyCallResult(success, returndata, \"Address: low-level delegate call failed\");\n    }\n\n    /**\n     * @dev This empty reserved space is put in place to allow future versions to add new\n     * variables without shifting down storage in the inheritance chain.\n     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n     */\n    uint256[50] private __gap;\n}\n"
    },
    "@openzeppelin/contracts-upgradeable/proxy/beacon/IBeaconUpgradeable.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\n */\ninterface IBeaconUpgradeable {\n    /**\n     * @dev Must return an address that can be used as a delegate call target.\n     *\n     * {BeaconProxy} will check that this address is a contract.\n     */\n    function implementation() external view returns (address);\n}\n"
    },
    "@openzeppelin/contracts-upgradeable/utils/StorageSlotUpgradeable.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Library for reading and writing primitive types to specific storage slots.\n *\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\n * This library helps with reading and writing to such slots without the need for inline assembly.\n *\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\n *\n * Example usage to set ERC1967 implementation slot:\n * ```\n * contract ERC1967 {\n *     bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n *\n *     function _getImplementation() internal view returns (address) {\n *         return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n *     }\n *\n *     function _setImplementation(address newImplementation) internal {\n *         require(Address.isContract(newImplementation), \"ERC1967: new implementation is not a contract\");\n *         StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n *     }\n * }\n * ```\n *\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\n */\nlibrary StorageSlotUpgradeable {\n    struct AddressSlot {\n        address value;\n    }\n\n    struct BooleanSlot {\n        bool value;\n    }\n\n    struct Bytes32Slot {\n        bytes32 value;\n    }\n\n    struct Uint256Slot {\n        uint256 value;\n    }\n\n    /**\n     * @dev Returns an `AddressSlot` with member `value` located at `slot`.\n     */\n    function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            r.slot := slot\n        }\n    }\n\n    /**\n     * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\n     */\n    function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            r.slot := slot\n        }\n    }\n\n    /**\n     * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\n     */\n    function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            r.slot := slot\n        }\n    }\n\n    /**\n     * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\n     */\n    function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            r.slot := slot\n        }\n    }\n}\n"
    },
    "@openzeppelin/contracts/proxy/beacon/IBeacon.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\n */\ninterface IBeacon {\n    /**\n     * @dev Must return an address that can be used as a delegate call target.\n     *\n     * {BeaconProxy} will check that this address is a contract.\n     */\n    function implementation() external view returns (address);\n}\n"
    },
    "@openzeppelin/contracts/proxy/Proxy.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\n * be specified by overriding the virtual {_implementation} function.\n *\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\n * different contract through the {_delegate} function.\n *\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\n */\nabstract contract Proxy {\n    /**\n     * @dev Delegates the current call to `implementation`.\n     *\n     * This function does not return to its internal call site, it will return directly to the external caller.\n     */\n    function _delegate(address implementation) internal virtual {\n        assembly {\n            // Copy msg.data. We take full control of memory in this inline assembly\n            // block because it will not return to Solidity code. We overwrite the\n            // Solidity scratch pad at memory position 0.\n            calldatacopy(0, 0, calldatasize())\n\n            // Call the implementation.\n            // out and outsize are 0 because we don't know the size yet.\n            let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\n\n            // Copy the returned data.\n            returndatacopy(0, 0, returndatasize())\n\n            switch result\n            // delegatecall returns 0 on error.\n            case 0 {\n                revert(0, returndatasize())\n            }\n            default {\n                return(0, returndatasize())\n            }\n        }\n    }\n\n    /**\n     * @dev This is a virtual function that should be overridden so it returns the address to which the fallback function\n     * and {_fallback} should delegate.\n     */\n    function _implementation() internal view virtual returns (address);\n\n    /**\n     * @dev Delegates the current call to the address returned by `_implementation()`.\n     *\n     * This function does not return to its internal call site, it will return directly to the external caller.\n     */\n    function _fallback() internal virtual {\n        _beforeFallback();\n        _delegate(_implementation());\n    }\n\n    /**\n     * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\n     * function in the contract matches the call data.\n     */\n    fallback() external payable virtual {\n        _fallback();\n    }\n\n    /**\n     * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\n     * is empty.\n     */\n    receive() external payable virtual {\n        _fallback();\n    }\n\n    /**\n     * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\n     * call, or as part of the Solidity `fallback` or `receive` functions.\n     *\n     * If overridden should call `super._beforeFallback()`.\n     */\n    function _beforeFallback() internal virtual {}\n}\n"
    },
    "@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)\n\npragma solidity ^0.8.2;\n\nimport \"../beacon/IBeacon.sol\";\nimport \"../../interfaces/draft-IERC1822.sol\";\nimport \"../../utils/Address.sol\";\nimport \"../../utils/StorageSlot.sol\";\n\n/**\n * @dev This abstract contract provides getters and event emitting update functions for\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\n *\n * _Available since v4.1._\n *\n * @custom:oz-upgrades-unsafe-allow delegatecall\n */\nabstract contract ERC1967Upgrade {\n    // This is the keccak-256 hash of \"eip1967.proxy.rollback\" subtracted by 1\n    bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\n\n    /**\n     * @dev Storage slot with the address of the current implementation.\n     * This is the keccak-256 hash of \"eip1967.proxy.implementation\" subtracted by 1, and is\n     * validated in the constructor.\n     */\n    bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n\n    /**\n     * @dev Emitted when the implementation is upgraded.\n     */\n    event Upgraded(address indexed implementation);\n\n    /**\n     * @dev Returns the current implementation address.\n     */\n    function _getImplementation() internal view returns (address) {\n        return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n    }\n\n    /**\n     * @dev Stores a new address in the EIP1967 implementation slot.\n     */\n    function _setImplementation(address newImplementation) private {\n        require(Address.isContract(newImplementation), \"ERC1967: new implementation is not a contract\");\n        StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n    }\n\n    /**\n     * @dev Perform implementation upgrade\n     *\n     * Emits an {Upgraded} event.\n     */\n    function _upgradeTo(address newImplementation) internal {\n        _setImplementation(newImplementation);\n        emit Upgraded(newImplementation);\n    }\n\n    /**\n     * @dev Perform implementation upgrade with additional setup call.\n     *\n     * Emits an {Upgraded} event.\n     */\n    function _upgradeToAndCall(\n        address newImplementation,\n        bytes memory data,\n        bool forceCall\n    ) internal {\n        _upgradeTo(newImplementation);\n        if (data.length > 0 || forceCall) {\n            Address.functionDelegateCall(newImplementation, data);\n        }\n    }\n\n    /**\n     * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\n     *\n     * Emits an {Upgraded} event.\n     */\n    function _upgradeToAndCallUUPS(\n        address newImplementation,\n        bytes memory data,\n        bool forceCall\n    ) internal {\n        // Upgrades from old implementations will perform a rollback test. This test requires the new\n        // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\n        // this special case will break upgrade paths from old UUPS implementation to new ones.\n        if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\n            _setImplementation(newImplementation);\n        } else {\n            try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\n                require(slot == _IMPLEMENTATION_SLOT, \"ERC1967Upgrade: unsupported proxiableUUID\");\n            } catch {\n                revert(\"ERC1967Upgrade: new implementation is not UUPS\");\n            }\n            _upgradeToAndCall(newImplementation, data, forceCall);\n        }\n    }\n\n    /**\n     * @dev Storage slot with the admin of the contract.\n     * This is the keccak-256 hash of \"eip1967.proxy.admin\" subtracted by 1, and is\n     * validated in the constructor.\n     */\n    bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\n\n    /**\n     * @dev Emitted when the admin account has changed.\n     */\n    event AdminChanged(address previousAdmin, address newAdmin);\n\n    /**\n     * @dev Returns the current admin.\n     */\n    function _getAdmin() internal view returns (address) {\n        return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\n    }\n\n    /**\n     * @dev Stores a new address in the EIP1967 admin slot.\n     */\n    function _setAdmin(address newAdmin) private {\n        require(newAdmin != address(0), \"ERC1967: new admin is the zero address\");\n        StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\n    }\n\n    /**\n     * @dev Changes the admin of the proxy.\n     *\n     * Emits an {AdminChanged} event.\n     */\n    function _changeAdmin(address newAdmin) internal {\n        emit AdminChanged(_getAdmin(), newAdmin);\n        _setAdmin(newAdmin);\n    }\n\n    /**\n     * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\n     * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\n     */\n    bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\n\n    /**\n     * @dev Emitted when the beacon is upgraded.\n     */\n    event BeaconUpgraded(address indexed beacon);\n\n    /**\n     * @dev Returns the current beacon.\n     */\n    function _getBeacon() internal view returns (address) {\n        return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\n    }\n\n    /**\n     * @dev Stores a new beacon in the EIP1967 beacon slot.\n     */\n    function _setBeacon(address newBeacon) private {\n        require(Address.isContract(newBeacon), \"ERC1967: new beacon is not a contract\");\n        require(\n            Address.isContract(IBeacon(newBeacon).implementation()),\n            \"ERC1967: beacon implementation is not a contract\"\n        );\n        StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\n    }\n\n    /**\n     * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\n     * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\n     *\n     * Emits a {BeaconUpgraded} event.\n     */\n    function _upgradeBeaconToAndCall(\n        address newBeacon,\n        bytes memory data,\n        bool forceCall\n    ) internal {\n        _setBeacon(newBeacon);\n        emit BeaconUpgraded(newBeacon);\n        if (data.length > 0 || forceCall) {\n            Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\n        }\n    }\n}\n"
    },
    "@openzeppelin/contracts/interfaces/draft-IERC1822.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\n * proxy whose upgrades are fully controlled by the current implementation.\n */\ninterface IERC1822Proxiable {\n    /**\n     * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\n     * address.\n     *\n     * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\n     * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\n     * function revert if invoked through a proxy.\n     */\n    function proxiableUUID() external view returns (bytes32);\n}\n"
    },
    "@openzeppelin/contracts/utils/Address.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n    /**\n     * @dev Returns true if `account` is a contract.\n     *\n     * [IMPORTANT]\n     * ====\n     * It is unsafe to assume that an address for which this function returns\n     * false is an externally-owned account (EOA) and not a contract.\n     *\n     * Among others, `isContract` will return false for the following\n     * types of addresses:\n     *\n     *  - an externally-owned account\n     *  - a contract in construction\n     *  - an address where a contract will be created\n     *  - an address where a contract lived, but was destroyed\n     * ====\n     *\n     * [IMPORTANT]\n     * ====\n     * You shouldn't rely on `isContract` to protect against flash loan attacks!\n     *\n     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n     * constructor.\n     * ====\n     */\n    function isContract(address account) internal view returns (bool) {\n        // This method relies on extcodesize/address.code.length, which returns 0\n        // for contracts in construction, since the code is only stored at the end\n        // of the constructor execution.\n\n        return account.code.length > 0;\n    }\n\n    /**\n     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n     * `recipient`, forwarding all available gas and reverting on errors.\n     *\n     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n     * of certain opcodes, possibly making contracts go over the 2300 gas limit\n     * imposed by `transfer`, making them unable to receive funds via\n     * `transfer`. {sendValue} removes this limitation.\n     *\n     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n     *\n     * IMPORTANT: because control is transferred to `recipient`, care must be\n     * taken to not create reentrancy vulnerabilities. Consider using\n     * {ReentrancyGuard} or the\n     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n     */\n    function sendValue(address payable recipient, uint256 amount) internal {\n        require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n        (bool success, ) = recipient.call{value: amount}(\"\");\n        require(success, \"Address: unable to send value, recipient may have reverted\");\n    }\n\n    /**\n     * @dev Performs a Solidity function call using a low level `call`. A\n     * plain `call` is an unsafe replacement for a function call: use this\n     * function instead.\n     *\n     * If `target` reverts with a revert reason, it is bubbled up by this\n     * function (like regular Solidity function calls).\n     *\n     * Returns the raw returned data. To convert to the expected return value,\n     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n     *\n     * Requirements:\n     *\n     * - `target` must be a contract.\n     * - calling `target` with `data` must not revert.\n     *\n     * _Available since v3.1._\n     */\n    function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n        return functionCall(target, data, \"Address: low-level call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n     * `errorMessage` as a fallback revert reason when `target` reverts.\n     *\n     * _Available since v3.1._\n     */\n    function functionCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, 0, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but also transferring `value` wei to `target`.\n     *\n     * Requirements:\n     *\n     * - the calling contract must have an ETH balance of at least `value`.\n     * - the called Solidity function must be `payable`.\n     *\n     * _Available since v3.1._\n     */\n    function functionCallWithValue(\n        address target,\n        bytes memory data,\n        uint256 value\n    ) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n     * with `errorMessage` as a fallback revert reason when `target` reverts.\n     *\n     * _Available since v3.1._\n     */\n    function functionCallWithValue(\n        address target,\n        bytes memory data,\n        uint256 value,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        require(address(this).balance >= value, \"Address: insufficient balance for call\");\n        require(isContract(target), \"Address: call to non-contract\");\n\n        (bool success, bytes memory returndata) = target.call{value: value}(data);\n        return verifyCallResult(success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but performing a static call.\n     *\n     * _Available since v3.3._\n     */\n    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n        return functionStaticCall(target, data, \"Address: low-level static call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n     * but performing a static call.\n     *\n     * _Available since v3.3._\n     */\n    function functionStaticCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal view returns (bytes memory) {\n        require(isContract(target), \"Address: static call to non-contract\");\n\n        (bool success, bytes memory returndata) = target.staticcall(data);\n        return verifyCallResult(success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but performing a delegate call.\n     *\n     * _Available since v3.4._\n     */\n    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n        return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n     * but performing a delegate call.\n     *\n     * _Available since v3.4._\n     */\n    function functionDelegateCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        require(isContract(target), \"Address: delegate call to non-contract\");\n\n        (bool success, bytes memory returndata) = target.delegatecall(data);\n        return verifyCallResult(success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\n     * revert reason using the provided one.\n     *\n     * _Available since v4.3._\n     */\n    function verifyCallResult(\n        bool success,\n        bytes memory returndata,\n        string memory errorMessage\n    ) internal pure returns (bytes memory) {\n        if (success) {\n            return returndata;\n        } else {\n            // Look for revert reason and bubble it up if present\n            if (returndata.length > 0) {\n                // The easiest way to bubble the revert reason is using memory via assembly\n                /// @solidity memory-safe-assembly\n                assembly {\n                    let returndata_size := mload(returndata)\n                    revert(add(32, returndata), returndata_size)\n                }\n            } else {\n                revert(errorMessage);\n            }\n        }\n    }\n}\n"
    },
    "@openzeppelin/contracts/utils/StorageSlot.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Library for reading and writing primitive types to specific storage slots.\n *\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\n * This library helps with reading and writing to such slots without the need for inline assembly.\n *\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\n *\n * Example usage to set ERC1967 implementation slot:\n * ```\n * contract ERC1967 {\n *     bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n *\n *     function _getImplementation() internal view returns (address) {\n *         return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n *     }\n *\n *     function _setImplementation(address newImplementation) internal {\n *         require(Address.isContract(newImplementation), \"ERC1967: new implementation is not a contract\");\n *         StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n *     }\n * }\n * ```\n *\n * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._\n */\nlibrary StorageSlot {\n    struct AddressSlot {\n        address value;\n    }\n\n    struct BooleanSlot {\n        bool value;\n    }\n\n    struct Bytes32Slot {\n        bytes32 value;\n    }\n\n    struct Uint256Slot {\n        uint256 value;\n    }\n\n    /**\n     * @dev Returns an `AddressSlot` with member `value` located at `slot`.\n     */\n    function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            r.slot := slot\n        }\n    }\n\n    /**\n     * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\n     */\n    function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            r.slot := slot\n        }\n    }\n\n    /**\n     * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\n     */\n    function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            r.slot := slot\n        }\n    }\n\n    /**\n     * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\n     */\n    function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            r.slot := slot\n        }\n    }\n}\n"
    },
    "@openzeppelin/contracts/access/Ownable.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n    address private _owner;\n\n    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n    /**\n     * @dev Initializes the contract setting the deployer as the initial owner.\n     */\n    constructor() {\n        _transferOwnership(_msgSender());\n    }\n\n    /**\n     * @dev Throws if called by any account other than the owner.\n     */\n    modifier onlyOwner() {\n        _checkOwner();\n        _;\n    }\n\n    /**\n     * @dev Returns the address of the current owner.\n     */\n    function owner() public view virtual returns (address) {\n        return _owner;\n    }\n\n    /**\n     * @dev Throws if the sender is not the owner.\n     */\n    function _checkOwner() internal view virtual {\n        require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n    }\n\n    /**\n     * @dev Leaves the contract without owner. It will not be possible to call\n     * `onlyOwner` functions anymore. Can only be called by the current owner.\n     *\n     * NOTE: Renouncing ownership will leave the contract without an owner,\n     * thereby removing any functionality that is only available to the owner.\n     */\n    function renounceOwnership() public virtual onlyOwner {\n        _transferOwnership(address(0));\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     * Can only be called by the current owner.\n     */\n    function transferOwnership(address newOwner) public virtual onlyOwner {\n        require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n        _transferOwnership(newOwner);\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     * Internal function without access restriction.\n     */\n    function _transferOwnership(address newOwner) internal virtual {\n        address oldOwner = _owner;\n        _owner = newOwner;\n        emit OwnershipTransferred(oldOwner, newOwner);\n    }\n}\n"
    },
    "@openzeppelin/contracts/utils/Context.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n    function _msgSender() internal view virtual returns (address) {\n        return msg.sender;\n    }\n\n    function _msgData() internal view virtual returns (bytes calldata) {\n        return msg.data;\n    }\n}\n"
    },
    "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/ERC1967/ERC1967Proxy.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../Proxy.sol\";\nimport \"./ERC1967Upgrade.sol\";\n\n/**\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\n * implementation address that can be changed. This address is stored in storage in the location specified by\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\n * implementation behind the proxy.\n */\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\n    /**\n     * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\n     *\n     * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\n     * function call, and allows initializing the storage of the proxy like a Solidity constructor.\n     */\n    constructor(address _logic, bytes memory _data) payable {\n        _upgradeToAndCall(_logic, _data, false);\n    }\n\n    /**\n     * @dev Returns the current implementation address.\n     */\n    function _implementation() internal view virtual override returns (address impl) {\n        return ERC1967Upgrade._getImplementation();\n    }\n}\n"
    },
    "contracts/ArtistCreatorV3.sol": {
      "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity ^0.8.14;\n\n/*\n               ^###############################################&5               \n               ?@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&               \n   !PPPPPPPPPPP&@@@@@@@@@@@@?!!!!!!!!!!7&@@@@@@@@@@@@@@@@@@@@@@@@BPPPPPPPPPPJ   \n   B@@@@@@@@@@@@@@@@@@@@@@@&            #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@.  \n   B@@@@@@@@@@@@@@@@@@@@@@@&            ~55555555555&@@@@@@@@@@@@@@@@@@@@@@@@.  \n   B@@@@@@@@@@@@@@@@@@@@@@@&                        J@@@@@@@@@@@@@@@@@@@@@@@@.  \n   B@@@@@@@@@@@@@@@@@@@@@@@&~::::::::::::::::::::::.~B######################P   \n   B@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@7                           \n   5@&&&&&&&&&&&&&&&&&&&&&&@@@@@@@@@@@@@@@@@@@@@@@@@5                           \n    .......................!@@@@@@@@@@@@@@@@@@@@@@@@@&&&&&&&&&&&&&&&&&&&&&&&B   \n                           .@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&   \n   7BBBBBBBBBBBBBBBBBBBBBBBY:^^^^^^^^^^^^^^^^^^^^^^^B@@@@@@@@@@@@@@@@@@@@@@@&   \n   B@@@@@@@@@@@@@@@@@@@@@@@&                        Y@@@@@@@@@@@@@@@@@@@@@@@&   \n   B@@@@@@@@@@@@@@@@@@@@@@@@PJYYYYYYYYY?            5@@@@@@@@@@@@@@@@@@@@@@@&   \n   B@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@:           Y@@@@@@@@@@@@@@@@@@@@@@@&   \n   !GGGGGGGGGGG&@@@@@@@@@@@@@@@@@@@@@@@@5~~~~~~~~~~~#@@@@@@@@@@@@BGGGGGGGGGGJ   \n               J@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@G               \n               ~&&&&#&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&?                 \n\n*/\n\nimport '@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol';\nimport '@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol';\nimport '@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol';\nimport '@openzeppelin/contracts-upgradeable/utils/CountersUpgradeable.sol';\nimport '@openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol';\nimport '@openzeppelin/contracts/proxy/beacon/BeaconProxy.sol';\n\n/// @title The Artist Creator factory contract\n/// @author Sound.xyz - @gigamesh & @vigneshka\ncontract ArtistCreatorV3 is Initializable, UUPSUpgradeable, OwnableUpgradeable {\n    using CountersUpgradeable for CountersUpgradeable.Counter;\n    using ECDSAUpgradeable for bytes32;\n\n    // ============ Storage ============\n\n    // Typehash of the signed message provided to createArtist\n    bytes32 public constant MINTER_TYPEHASH = keccak256('Deployer(address artistWallet)');\n    // ID for each Artist proxy // DEPRECATED in ArtistCreatorV2\n    CountersUpgradeable.Counter private atArtistId;\n    // Address used for signature verification, changeable by owner\n    address public admin;\n    // Domain separator is used to prevent replay attacks using signatures from different networks\n    bytes32 public DOMAIN_SEPARATOR;\n    // The address of UpgradeableBeacon, which was deployed in the initialize function of ArtistCreator.sol\n    address public beaconAddress;\n    // Array of the Artist proxies // DEPRECATED in ArtistCreatorV2\n    address[] public artistContracts;\n\n    // ============ Events ============\n\n    /// Emitted when an Artist is created\n    event CreatedArtist(uint256 artistId, string name, string symbol, address indexed artistAddress);\n\n    // ============ Functions ============\n\n    /// @notice Creates a new artist contract as a factory with a deterministic address\n    /// @param _name Name of the artist\n    function createArtist(\n        bytes calldata signature,\n        string memory _name,\n        string memory _symbol,\n        string memory _baseURI\n    ) public returns (address) {\n        require((getSigner(signature) == admin), 'invalid authorization signature');\n\n        bytes32 salt = bytes32(uint256(uint160(_msgSender())));\n\n        // salted contract creation using create2\n        BeaconProxy proxy = new BeaconProxy{salt: salt}(\n            beaconAddress,\n            // 0x5f1e6f6d is the initialize function selector on ArtistV6 (hash of \"function initialize(address, string, string, string)\")\n            abi.encodeWithSelector(0x5f1e6f6d, _msgSender(), _name, _symbol, _baseURI)\n        );\n\n        // the first parameter, artistId, is deprecated\n        emit CreatedArtist(0, _name, _symbol, address(proxy));\n\n        return address(proxy);\n    }\n\n    /// @notice Gets signer address of signature\n    /// @param signature Signature of the message\n    function getSigner(bytes calldata signature) public view returns (address) {\n        require(admin != address(0), 'whitelist not enabled');\n        // Verify EIP-712 signature by recreating the data structure\n        // that we signed on the client side, and then using that to recover\n        // the address that signed the signature for this data.\n        bytes32 digest = keccak256(\n            abi.encodePacked('\\x19\\x01', DOMAIN_SEPARATOR, keccak256(abi.encode(MINTER_TYPEHASH, _msgSender())))\n        );\n        // Use the recover method to see what address was used to create\n        // the signature on this data.\n        // Note that if the digest doesn't exactly match what was signed we'll\n        // get a random recovered address.\n        address recoveredAddress = digest.recover(signature);\n        return recoveredAddress;\n    }\n\n    /// @notice Sets the admin for authorizing artist deployment\n    /// @param _newAdmin address of new admin\n    function setAdmin(address _newAdmin) external {\n        require(owner() == _msgSender() || admin == _msgSender(), 'invalid authorization');\n        admin = _newAdmin;\n    }\n\n    /// @notice Authorizes upgrades\n    /// @dev DO NOT REMOVE!\n    function _authorizeUpgrade(address) internal override onlyOwner {}\n}\n"
    },
    "contracts/ArtistCreatorV2.sol": {
      "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity ^0.8.14;\n\n/*\n               ^###############################################&5               \n               ?@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&               \n   !PPPPPPPPPPP&@@@@@@@@@@@@?!!!!!!!!!!7&@@@@@@@@@@@@@@@@@@@@@@@@BPPPPPPPPPPJ   \n   B@@@@@@@@@@@@@@@@@@@@@@@&            #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@.  \n   B@@@@@@@@@@@@@@@@@@@@@@@&            ~55555555555&@@@@@@@@@@@@@@@@@@@@@@@@.  \n   B@@@@@@@@@@@@@@@@@@@@@@@&                        J@@@@@@@@@@@@@@@@@@@@@@@@.  \n   B@@@@@@@@@@@@@@@@@@@@@@@&~::::::::::::::::::::::.~B######################P   \n   B@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@7                           \n   5@&&&&&&&&&&&&&&&&&&&&&&@@@@@@@@@@@@@@@@@@@@@@@@@5                           \n    .......................!@@@@@@@@@@@@@@@@@@@@@@@@@&&&&&&&&&&&&&&&&&&&&&&&B   \n                           .@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&   \n   7BBBBBBBBBBBBBBBBBBBBBBBY:^^^^^^^^^^^^^^^^^^^^^^^B@@@@@@@@@@@@@@@@@@@@@@@&   \n   B@@@@@@@@@@@@@@@@@@@@@@@&                        Y@@@@@@@@@@@@@@@@@@@@@@@&   \n   B@@@@@@@@@@@@@@@@@@@@@@@@PJYYYYYYYYY?            5@@@@@@@@@@@@@@@@@@@@@@@&   \n   B@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@:           Y@@@@@@@@@@@@@@@@@@@@@@@&   \n   !GGGGGGGGGGG&@@@@@@@@@@@@@@@@@@@@@@@@5~~~~~~~~~~~#@@@@@@@@@@@@BGGGGGGGGGGJ   \n               J@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@G               \n               ~&&&&#&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&?                 \n\n*/\n\nimport '@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol';\nimport '@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol';\nimport '@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol';\nimport '@openzeppelin/contracts-upgradeable/utils/CountersUpgradeable.sol';\nimport '@openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol';\nimport '@openzeppelin/contracts/proxy/beacon/BeaconProxy.sol';\n\n/// @title The Artist Creator factory contract\n/// @author Sound.xyz - @gigamesh & @vigneshka\ncontract ArtistCreatorV2 is Initializable, UUPSUpgradeable, OwnableUpgradeable {\n    using CountersUpgradeable for CountersUpgradeable.Counter;\n    using ECDSAUpgradeable for bytes32;\n\n    // ============ Storage ============\n\n    // Typehash of the signed message provided to createArtist\n    bytes32 public constant MINTER_TYPEHASH = keccak256('Deployer(address artistWallet)');\n    // ID for each Artist proxy // DEPRECATED in ArtistCreatorV2\n    CountersUpgradeable.Counter private atArtistId;\n    // Address used for signature verification, changeable by owner\n    address public admin;\n    // Domain separator is used to prevent replay attacks using signatures from different networks\n    bytes32 public DOMAIN_SEPARATOR;\n    // The address of UpgradeableBeacon, which was deployed in the initialize function of ArtistCreator.sol\n    address public beaconAddress;\n    // Array of the Artist proxies // DEPRECATED in ArtistCreatorV2\n    address[] public artistContracts;\n\n    // ============ Events ============\n\n    /// Emitted when an Artist is created\n    event CreatedArtist(uint256 artistId, string name, string symbol, address indexed artistAddress);\n\n    // ============ Functions ============\n\n    /// @notice Creates a new artist contract as a factory with a deterministic address\n    /// @param _name Name of the artist\n    function createArtist(\n        bytes calldata signature,\n        string memory _name,\n        string memory _symbol,\n        string memory _baseURI\n    ) public returns (address) {\n        require((getSigner(signature) == admin), 'invalid authorization signature');\n\n        bytes32 salt = bytes32(uint256(uint160(_msgSender())));\n\n        // salted contract creation using create2\n        BeaconProxy proxy = new BeaconProxy{salt: salt}(\n            beaconAddress,\n            // 0x5f1e6f6d is the initialize function selector on ArtistV5 (hash of \"function initialize(address, string, string, string)\")\n            abi.encodeWithSelector(0x5f1e6f6d, _msgSender(), _name, _symbol, _baseURI)\n        );\n\n        // the first parameter, artistId, is deprecated\n        emit CreatedArtist(0, _name, _symbol, address(proxy));\n\n        return address(proxy);\n    }\n\n    /// @notice Gets signer address of signature\n    /// @param signature Signature of the message\n    function getSigner(bytes calldata signature) public view returns (address) {\n        require(admin != address(0), 'whitelist not enabled');\n        // Verify EIP-712 signature by recreating the data structure\n        // that we signed on the client side, and then using that to recover\n        // the address that signed the signature for this data.\n        bytes32 digest = keccak256(\n            abi.encodePacked('\\x19\\x01', DOMAIN_SEPARATOR, keccak256(abi.encode(MINTER_TYPEHASH, _msgSender())))\n        );\n        // Use the recover method to see what address was used to create\n        // the signature on this data.\n        // Note that if the digest doesn't exactly match what was signed we'll\n        // get a random recovered address.\n        address recoveredAddress = digest.recover(signature);\n        return recoveredAddress;\n    }\n\n    /// @notice Sets the admin for authorizing artist deployment\n    /// @param _newAdmin address of new admin\n    function setAdmin(address _newAdmin) external {\n        require(owner() == _msgSender() || admin == _msgSender(), 'invalid authorization');\n        admin = _newAdmin;\n    }\n\n    /// @notice Authorizes upgrades\n    /// @dev DO NOT REMOVE!\n    function _authorizeUpgrade(address) internal override onlyOwner {}\n}\n"
    },
    "contracts/test-contracts/TEST_ArtistV6.sol": {
      "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity ^0.8.14;\n\n/*\n               ^###############################################&5               \n               ?@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&               \n   !PPPPPPPPPPP&@@@@@@@@@@@@?!!!!!!!!!!7&@@@@@@@@@@@@@@@@@@@@@@@@BPPPPPPPPPPJ   \n   B@@@@@@@@@@@@@@@@@@@@@@@&            #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@.  \n   B@@@@@@@@@@@@@@@@@@@@@@@&            ~55555555555&@@@@@@@@@@@@@@@@@@@@@@@@.  \n   B@@@@@@@@@@@@@@@@@@@@@@@&                        J@@@@@@@@@@@@@@@@@@@@@@@@.  \n   B@@@@@@@@@@@@@@@@@@@@@@@&~::::::::::::::::::::::.~B######################P   \n   B@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@7                           \n   5@&&&&&&&&&&&&&&&&&&&&&&@@@@@@@@@@@@@@@@@@@@@@@@@5                           \n    .......................!@@@@@@@@@@@@@@@@@@@@@@@@@&&&&&&&&&&&&&&&&&&&&&&&B   \n                           .@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&   \n   7BBBBBBBBBBBBBBBBBBBBBBBY:^^^^^^^^^^^^^^^^^^^^^^^B@@@@@@@@@@@@@@@@@@@@@@@&   \n   B@@@@@@@@@@@@@@@@@@@@@@@&                        Y@@@@@@@@@@@@@@@@@@@@@@@&   \n   B@@@@@@@@@@@@@@@@@@@@@@@@PJYYYYYYYYY?            5@@@@@@@@@@@@@@@@@@@@@@@&   \n   B@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@:           Y@@@@@@@@@@@@@@@@@@@@@@@&   \n   !GGGGGGGGGGG&@@@@@@@@@@@@@@@@@@@@@@@@5~~~~~~~~~~~#@@@@@@@@@@@@BGGGGGGGGGGJ   \n               J@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@G               \n               ~&&&&#&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&?                 \n\n*/\n\nimport '@openzeppelin/contracts-upgradeable/interfaces/IERC2981Upgradeable.sol';\nimport '@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol';\nimport '@openzeppelin/contracts-upgradeable/utils/CountersUpgradeable.sol';\nimport '@openzeppelin/contracts/utils/cryptography/ECDSA.sol';\nimport '@openzeppelin/contracts/utils/Strings.sol';\nimport '../auxillary/AccessManager.sol';\n\n/// @title Artist\n/// @author SoundXYZ - @gigamesh & @vigneshka\n/// @notice This contract is used to create & sell song NFTs for the artist who owns the contract.\n/// @dev Started as a fork of Mirror's Editions.sol https://github.com/mirror-xyz/editions-v1/blob/main/contracts/Editions.sol\ncontract TEST_ArtistV6 is ERC721Upgradeable, IERC2981Upgradeable, AccessManager {\n    // ================================\n    // STORAGE\n    // ================================\n\n    // The permissioned typehash (used for checking signature validity)\n    bytes32 public constant PERMISSIONED_SALE_TYPEHASH =\n        keccak256('EditionInfo(address contractAddress,address buyerAddress,uint256 editionId,uint256 ticketNumber)');\n    // Domain separator - used to prevent replay attacks using signatures from different networks\n    bytes32 public immutable DOMAIN_SEPARATOR;\n    // The default baseURI for the contract\n    string internal baseURI;\n\n    CountersUpgradeable.Counter public atTokenId; // DEPRECATED IN V3\n    CountersUpgradeable.Counter public atEditionId;\n\n    // Mapping of edition id to descriptive data.\n    mapping(uint256 => Edition) public editions;\n    // <DEPRECATED IN V3> Mapping of token id to edition id.\n    mapping(uint256 => uint256) public _tokenToEdition;\n    // The amount of funds that have been deposited for a given edition.\n    mapping(uint256 => uint256) public depositedForEdition;\n    // The amount of funds that have already been withdrawn for a given edition.\n    mapping(uint256 => uint256) public withdrawnForEdition;\n    // Used to track which tokens have been claimed. editionId -> index -> bit array\n    mapping(uint256 => mapping(uint256 => uint256)) ticketNumbers;\n\n    uint256 public someNumber;\n\n    // ================================\n    // TYPES\n    // ================================\n\n    struct Edition {\n        // The account that will receive sales revenue.\n        address payable fundingRecipient;\n        // The price at which each token will be sold, in ETH.\n        uint256 price;\n        // The number of tokens sold so far.\n        uint32 numSold;\n        // The maximum number of tokens that can be sold.\n        uint32 quantity;\n        // Royalty amount in bps\n        uint32 royaltyBPS;\n        // start timestamp of auction (in seconds since unix epoch)\n        uint32 startTime;\n        // end timestamp of auction (in seconds since unix epoch)\n        uint32 endTime;\n        // quantity of permissioned tokens\n        uint32 permissionedQuantity;\n        // whitelist signer address\n        address signerAddress;\n        // base uri for the edition\n        string baseURI;\n    }\n\n    using CountersUpgradeable for CountersUpgradeable.Counter;\n    using ECDSA for bytes32;\n\n    enum TimeType {\n        START,\n        END\n    }\n\n    // ================================\n    // EVENTS\n    // ================================\n\n    event EditionCreated(\n        uint256 indexed editionId,\n        address fundingRecipient,\n        uint256 price,\n        uint32 quantity,\n        uint32 royaltyBPS,\n        uint32 startTime,\n        uint32 endTime,\n        uint32 permissionedQuantity,\n        address signerAddress\n    );\n\n    event EditionPurchased(\n        uint256 indexed editionId,\n        uint256 indexed tokenId,\n        // `numSold` at time of purchase represents the \"serial number\" of the NFT.\n        uint32 numSold,\n        // The account that paid for and received the NFT.\n        address indexed buyer,\n        uint256 ticketNumber\n    );\n\n    event AuctionTimeSet(TimeType timeType, uint256 editionId, uint32 indexed newTime);\n\n    event SignerAddressSet(uint256 editionId, address indexed signerAddress);\n\n    event PermissionedQuantitySet(uint256 editionId, uint32 permissionedQuantity);\n\n    event BaseURISet(uint256 editionId, string baseURI);\n\n    // ================================\n    // PUBLIC & EXTERNAL WRITABLE FUNCTIONS\n    // ================================\n\n    /// @notice Contract constructor\n    constructor() {\n        DOMAIN_SEPARATOR = keccak256(abi.encode(keccak256('EIP712Domain(uint256 chainId)'), block.chainid));\n    }\n\n    /// @notice Initializes the contract\n    /// @param _owner Owner of edition\n    /// @param _name Name of artist\n    /// @param _symbol Symbol for the artist\n    /// @param _baseURI Default base URI for all editions\n    function initialize(\n        address _owner,\n        string memory _name,\n        string memory _symbol,\n        string memory _baseURI\n    ) public initializer {\n        __ERC721_init(_name, _symbol);\n        __AccessManager_init();\n\n        // Set ownership to original sender of contract call\n        transferOwnership(_owner);\n\n        // baseURI override only for testnets\n        if (block.chainid != 1) {\n            baseURI = _baseURI;\n        }\n\n        // Set edition id start to be 1 not 0\n        atEditionId.increment();\n    }\n\n    /// @notice Creates a new edition.\n    /// @param _fundingRecipient The account that will receive sales revenue.\n    /// @param _price The price at which each token will be sold, in ETH.\n    /// @param _quantity The maximum number of tokens that can be sold.\n    /// @param _royaltyBPS The royalty amount in bps.\n    /// @param _startTime The start time of the auction, in seconds since unix epoch.\n    /// @param _endTime The end time of the auction, in seconds since unix epoch.\n    /// @param _permissionedQuantity The quantity of tokens that require a signature to buy.\n    /// @param _signerAddress signer address.\n    /// @param _editionId The expected edition ID\n    /// @param _baseURI The base URI for the edition\n    function createEdition(\n        address payable _fundingRecipient,\n        uint256 _price,\n        uint32 _quantity,\n        uint32 _royaltyBPS,\n        uint32 _startTime,\n        uint32 _endTime,\n        uint32 _permissionedQuantity,\n        address _signerAddress,\n        uint256 _editionId,\n        string memory _baseURI\n    ) external checkPermission(ADMIN_ROLE) {\n        require(_quantity > 0, 'Must set quantity');\n        require(_fundingRecipient != address(0), 'Must set fundingRecipient');\n        require(_endTime > _startTime, 'End time must be greater than start time');\n        require(_editionId == atEditionId.current(), 'Wrong edition ID');\n\n        if (_permissionedQuantity > 0) {\n            require(_signerAddress != address(0), 'Signer address cannot be 0');\n        }\n\n        editions[atEditionId.current()] = Edition({\n            fundingRecipient: _fundingRecipient,\n            price: _price,\n            numSold: 0,\n            quantity: _quantity,\n            royaltyBPS: _royaltyBPS,\n            startTime: _startTime,\n            endTime: _endTime,\n            permissionedQuantity: _permissionedQuantity,\n            signerAddress: _signerAddress,\n            baseURI: _baseURI\n        });\n\n        emit EditionCreated(\n            atEditionId.current(),\n            _fundingRecipient,\n            _price,\n            _quantity,\n            _royaltyBPS,\n            _startTime,\n            _endTime,\n            _permissionedQuantity,\n            _signerAddress\n        );\n\n        atEditionId.increment();\n    }\n\n    /// @notice Creates a new token for the given edition, and assigns it to the buyer\n    /// @param _editionId The id of the edition to purchase\n    /// @param _signature A signed message for authorizing permissioned purchases\n    /// @param _ticketNumber Ticket number required for validating this buyer hasn't already bought.\n    function buyEdition(\n        uint256 _editionId,\n        bytes calldata _signature,\n        uint256 _ticketNumber\n    ) external payable {\n        // Caching variables locally to reduce reads\n        uint256 price = editions[_editionId].price;\n        uint32 quantity = editions[_editionId].quantity;\n        uint32 numSold = editions[_editionId].numSold;\n        uint32 newNumSold = numSold + 1;\n        uint32 startTime = editions[_editionId].startTime;\n        uint32 endTime = editions[_editionId].endTime;\n        uint32 permissionedQuantity = editions[_editionId].permissionedQuantity;\n\n        // Check that the edition exists. Note: this is redundant\n        // with the next check, but it is useful for clearer error messaging.\n        require(quantity > 0, 'Edition does not exist');\n        // Check that the sender is paying the correct amount.\n        require(msg.value >= price, 'Must send enough to purchase the edition.');\n        // Don't allow purchases after the end time\n        require(endTime > block.timestamp, 'Auction has ended');\n\n        // If the public auction hasn't started...\n        if (startTime > block.timestamp) {\n            // Check that permissioned tokens are still available\n            require(numSold < permissionedQuantity, 'No permissioned tokens available & open auction not started');\n\n            // Check that the signature is valid.\n            require(\n                getSigner(_signature, _editionId, _ticketNumber) == editions[_editionId].signerAddress,\n                'Invalid signer'\n            );\n        } else {\n            // Check that there are still tokens available to purchase.\n            // Only need to check this for the public sale (after the start time)\n            // so we can accomodate open editions\n            require(numSold < quantity, 'This edition is already sold out.');\n        }\n\n        // Create the token id by packing editionId in the top bits\n        uint256 tokenId;\n        unchecked {\n            tokenId = (_editionId << 128) | newNumSold;\n            // Increment the number of tokens sold for this edition.\n            editions[_editionId].numSold = newNumSold;\n        }\n\n        // If fundingRecipient is the owner (artist's wallet), update the edition's balance & don't send the funds\n        if (editions[_editionId].fundingRecipient == owner()) {\n            // Update the deposited total for the edition\n            depositedForEdition[_editionId] += msg.value;\n        } else {\n            // Send funds to the funding recipient.\n            _sendFunds(editions[_editionId].fundingRecipient, msg.value);\n        }\n\n        // Mint a new token for the sender, using the `tokenId`.\n        _mint(msg.sender, tokenId);\n\n        emit EditionPurchased(_editionId, tokenId, newNumSold, msg.sender, _ticketNumber);\n    }\n\n    /// @notice Withdraws from the Artist to the fundingRecipient for an edition\n    /// @param _editionId The id of the edition to withdraw from\n    function withdrawFunds(uint256 _editionId) external {\n        // Compute the amount available for withdrawing from this edition.\n        uint256 remainingForEdition = depositedForEdition[_editionId] - withdrawnForEdition[_editionId];\n\n        // Set the amount withdrawn to the amount deposited.\n        withdrawnForEdition[_editionId] = depositedForEdition[_editionId];\n\n        // Send the amount that was remaining for the edition, to the funding recipient.\n        _sendFunds(editions[_editionId].fundingRecipient, remainingForEdition);\n    }\n\n    /// @notice Sets the start time for an edition\n    /// @param _editionId The id of the edition to set the start time for\n    /// @param _startTime The start time to set (in seconds since unix epoch)\n    function setStartTime(uint256 _editionId, uint32 _startTime) external checkPermission(ADMIN_ROLE) {\n        editions[_editionId].startTime = _startTime;\n        emit AuctionTimeSet(TimeType.START, _editionId, _startTime);\n    }\n\n    /// @notice Sets the end time for an edition\n    /// @param _editionId The id of the edition to set the end time for\n    /// @param _endTime The end time to set (in seconds since unix epoch)\n    function setEndTime(uint256 _editionId, uint32 _endTime) external checkPermission(ADMIN_ROLE) {\n        editions[_editionId].endTime = _endTime;\n        emit AuctionTimeSet(TimeType.END, _editionId, _endTime);\n    }\n\n    /// @notice Sets the signature address of an edition\n    /// @param _editionId The edition id to set the signature address for\n    /// @param _newSignerAddress The address that will be used to sign purchases\n    function setSignerAddress(uint256 _editionId, address _newSignerAddress) external checkPermission(ADMIN_ROLE) {\n        require(_newSignerAddress != address(0), 'Signer address cannot be 0');\n\n        editions[_editionId].signerAddress = _newSignerAddress;\n        emit SignerAddressSet(_editionId, _newSignerAddress);\n    }\n\n    /// @notice Sets the permissioned quantity for an edition\n    /// @param _editionId The edition id to set the permissioned quantity for\n    /// @param _permissionedQuantity The new permissiond quantity\n    function setPermissionedQuantity(uint256 _editionId, uint32 _permissionedQuantity)\n        external\n        checkPermission(ADMIN_ROLE)\n    {\n        // Prevent setting to permissioned quantity when there is no signer address\n        require(editions[_editionId].signerAddress != address(0), 'Edition must have a signer');\n\n        editions[_editionId].permissionedQuantity = _permissionedQuantity;\n        emit PermissionedQuantitySet(_editionId, _permissionedQuantity);\n    }\n\n    /// @notice Sets a new owner, only callable by current owner or the soundRecoveryAddress (ie: gnosis safe)\n    /// @param _newOwner The new owner of the contract\n    function setOwnerOverride(address _newOwner) external {\n        require(_msgSender() == soundRecoveryAddress() || _msgSender() == owner(), 'unauthorized');\n\n        super._transferOwnership(_newOwner);\n    }\n\n    /// @notice Sets the base URI for an edition\n    /// @param _editionId The target edition's id\n    /// @param _baseURI The new base URI\n    function setEditionBaseURI(uint256 _editionId, string calldata _baseURI) external checkPermission(ADMIN_ROLE) {\n        require(\n            editions[_editionId].quantity > 0 || editions[_editionId].permissionedQuantity > 0,\n            'Nonexistent edition'\n        );\n\n        editions[_editionId].baseURI = _baseURI;\n\n        emit BaseURISet(_editionId, _baseURI);\n    }\n\n    // ================================\n    // VIEW FUNCTIONS\n    // ================================\n\n    /// @notice Returns token URI (metadata URL). e.g. https://sound.xyz/api/metadata/[contractAddress]/[tokenId]/metadata.json\n    /// @dev Concatenate the baseURI and tokenId, to create URI.\n    function tokenURI(uint256 _tokenId) public view override returns (string memory) {\n        require(_exists(_tokenId), 'ERC721Metadata: URI query for nonexistent token');\n\n        uint256 editionId = tokenToEdition(_tokenId);\n\n        string memory editionBaseURI = editions[editionId].baseURI;\n\n        // If the edition has a baseURI, it means this edition is on permastorage\n        // Using 3 as the length in case it gets accidentally set to empty space\n        if (bytes(editionBaseURI).length > 3) {\n            return string.concat(editionBaseURI, Strings.toString(_tokenId), '/metadata.json');\n        }\n\n        return string.concat(_contractBaseURI(), Strings.toString(_tokenId));\n    }\n\n    /// @notice Returns contract URI used by Opensea. e.g. https://sound.xyz/api/metadata/[contractAddress]/storefront\n    function contractURI() public view returns (string memory) {\n        return string.concat(_contractBaseURI(), 'storefront');\n    }\n\n    /// @notice Get royalty information for token\n    /// @param _tokenId token id\n    /// @param _salePrice Sale price for the token\n    function royaltyInfo(uint256 _tokenId, uint256 _salePrice)\n        external\n        view\n        override\n        returns (address fundingRecipient, uint256 royaltyAmount)\n    {\n        uint256 editionId = tokenToEdition(_tokenId);\n        Edition memory edition = editions[editionId];\n\n        if (edition.fundingRecipient == address(0x0)) {\n            return (edition.fundingRecipient, 0);\n        }\n\n        uint256 royaltyBPS = uint256(edition.royaltyBPS);\n\n        return (edition.fundingRecipient, (_salePrice * royaltyBPS) / 10_000);\n    }\n\n    /// @notice The total number of tokens created by this contract\n    function totalSupply() external view returns (uint256) {\n        uint256 total = 0;\n        for (uint256 id = 1; id < atEditionId.current(); id++) {\n            total += editions[id].numSold;\n        }\n        return total;\n    }\n\n    /// @notice Informs other contracts which interfaces this contract supports\n    /// @param _interfaceId The interface id to check\n    /// @dev https://eips.ethereum.org/EIPS/eip-165\n    function supportsInterface(bytes4 _interfaceId)\n        public\n        view\n        override(ERC721Upgradeable, IERC165Upgradeable)\n        returns (bool)\n    {\n        return\n            type(IERC2981Upgradeable).interfaceId == _interfaceId || ERC721Upgradeable.supportsInterface(_interfaceId);\n    }\n\n    /// @notice returns the number of editions for this artist\n    function editionCount() external view returns (uint256) {\n        return atEditionId.current() - 1; // because atEditionId is incremented after each edition is created\n    }\n\n    /// @notice Returns the edition id for a given token id\n    /// @param _tokenId token id\n    function tokenToEdition(uint256 _tokenId) public view returns (uint256) {\n        // Check the top bits to see if the edition id is there\n        uint256 editionId = _tokenId >> 128;\n\n        // If edition ID is 0, then this edition was created before the V3 upgrade\n        if (editionId == 0) {\n            // get edition ID from storage\n            return _tokenToEdition[_tokenId];\n        }\n\n        return editionId;\n    }\n\n    /// @notice Returns a list of owner addresses for a given list of token ids\n    /// @param _tokenIds List of token ids\n    function ownersOfTokenIds(uint256[] calldata _tokenIds) external view returns (address[] memory) {\n        address[] memory owners = new address[](_tokenIds.length);\n        for (uint256 i = 0; i < _tokenIds.length; i++) {\n            owners[i] = ownerOf(_tokenIds[i]);\n        }\n        return owners;\n    }\n\n    /// @notice Returns the claimed ticket numbers for a given edition and list of ticket numbers (indexes)\n    /// @param _editionId Edition id\n    /// @param _ticketNumbers List of ticket numbers (indexes)\n    function checkTicketNumbers(uint256 _editionId, uint256[] calldata _ticketNumbers)\n        external\n        view\n        returns (bool[] memory)\n    {\n        bool[] memory claimed = new bool[](_ticketNumbers.length);\n\n        for (uint256 i = 0; i < _ticketNumbers.length; i++) {\n            (uint256 storedBit, , , ) = _getBitForTicketNumber(_editionId, _ticketNumbers[i]);\n            claimed[i] = storedBit == 1;\n        }\n\n        return claimed;\n    }\n\n    /// @notice Returns the address (ie: gnosis safe) authorized to change ownership of the contract\n    function soundRecoveryAddress() public view virtual returns (address) {\n        if (block.chainid == 1) {\n            return 0x858a92511485715Cfb754f397a7894b7724c7Abd;\n        } else if (block.chainid == 4) {\n            return 0xee35E946Dd73EF78d352454c3F915e2cA0a09d87;\n        } else {\n            revert('unsupported chain');\n        }\n    }\n\n    // ================================\n    // PRIVATE FUNCTIONS\n    // ================================\n\n    /// @notice Sends funds to an address\n    /// @param _recipient The address to send funds to\n    /// @param _amount The amount of funds to send\n    function _sendFunds(address payable _recipient, uint256 _amount) private {\n        require(address(this).balance >= _amount, 'Insufficient balance for send');\n\n        (bool success, ) = _recipient.call{value: _amount}('');\n        require(success, 'Unable to send value: recipient may have reverted');\n    }\n\n    /// @notice Gets signer address to validate permissioned purchase\n    /// @param _signature signed message\n    /// @param _editionId edition id\n    /// @param _ticketNumber ticket number to check\n    /// @return address of signer\n    /// @dev https://eips.ethereum.org/EIPS/eip-712\n    function getSigner(\n        bytes calldata _signature,\n        uint256 _editionId,\n        uint256 _ticketNumber\n    ) private returns (address) {\n        // Check that the ticket number is within the reserved range for the edition\n        // permissionedQuantity is uint32, so ticketNumber can't exceed max uint32\n        require(_ticketNumber < 2**32, 'Ticket number exceeds max');\n\n        // gets the stored bit\n        (\n            uint256 storedBit,\n            uint256 localGroup,\n            uint256 localGroupOffset,\n            uint256 ticketNumbersIdx\n        ) = _getBitForTicketNumber(_editionId, _ticketNumber);\n\n        require(storedBit == 0, 'Invalid ticket number or NFT already claimed');\n\n        // Flip the bit to 1 to indicate that the ticket has been claimed\n        ticketNumbers[_editionId][ticketNumbersIdx] = localGroup | (uint256(1) << localGroupOffset);\n\n        bytes32 digest = keccak256(\n            abi.encodePacked(\n                '\\x19\\x01',\n                DOMAIN_SEPARATOR,\n                keccak256(abi.encode(PERMISSIONED_SALE_TYPEHASH, address(this), msg.sender, _editionId, _ticketNumber))\n            )\n        );\n        return digest.recover(_signature);\n    }\n\n    /// @notice Gets the bit variables associated with a ticket number\n    /// @param _editionId edition id\n    /// @param _ticketNumber ticket number\n    function _getBitForTicketNumber(uint256 _editionId, uint256 _ticketNumber)\n        private\n        view\n        returns (\n            uint256,\n            uint256,\n            uint256,\n            uint256\n        )\n    {\n        uint256 localGroup; // the bit array for this ticket number\n        uint256 ticketNumbersIdx; // the index of the the local group\n        uint256 localGroupOffset; // the offset/index for the ticket number in the local group\n        uint256 storedBit; // the stored bit at this ticket number's index within the local group\n        unchecked {\n            ticketNumbersIdx = _ticketNumber / 256;\n            localGroupOffset = _ticketNumber % 256;\n        }\n\n        // cache the local group for efficiency\n        localGroup = ticketNumbers[_editionId][ticketNumbersIdx];\n\n        // gets the stored bit\n        storedBit = (localGroup >> localGroupOffset) & uint256(1);\n\n        return (storedBit, localGroup, localGroupOffset, ticketNumbersIdx);\n    }\n\n    function _contractBaseURI() private view returns (string memory) {\n        string memory contractAddress = Strings.toHexString(uint256(uint160(address(this))), 20);\n        if (block.chainid == 1) {\n            return string.concat('https://metadata.sound.xyz/v1/', contractAddress, '/');\n        } else {\n            return string.concat(baseURI, contractAddress, '/');\n        }\n    }\n\n    function setSomeNumber(uint256 _someNumber) external {\n        someNumber = _someNumber;\n    }\n}\n"
    },
    "@openzeppelin/contracts/utils/cryptography/ECDSA.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/cryptography/ECDSA.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../Strings.sol\";\n\n/**\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\n *\n * These functions can be used to verify that a message was signed by the holder\n * of the private keys of a given address.\n */\nlibrary ECDSA {\n    enum RecoverError {\n        NoError,\n        InvalidSignature,\n        InvalidSignatureLength,\n        InvalidSignatureS,\n        InvalidSignatureV\n    }\n\n    function _throwError(RecoverError error) private pure {\n        if (error == RecoverError.NoError) {\n            return; // no error: do nothing\n        } else if (error == RecoverError.InvalidSignature) {\n            revert(\"ECDSA: invalid signature\");\n        } else if (error == RecoverError.InvalidSignatureLength) {\n            revert(\"ECDSA: invalid signature length\");\n        } else if (error == RecoverError.InvalidSignatureS) {\n            revert(\"ECDSA: invalid signature 's' value\");\n        } else if (error == RecoverError.InvalidSignatureV) {\n            revert(\"ECDSA: invalid signature 'v' value\");\n        }\n    }\n\n    /**\n     * @dev Returns the address that signed a hashed message (`hash`) with\n     * `signature` or error string. This address can then be used for verification purposes.\n     *\n     * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n     * this function rejects them by requiring the `s` value to be in the lower\n     * half order, and the `v` value to be either 27 or 28.\n     *\n     * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n     * verification to be secure: it is possible to craft signatures that\n     * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n     * this is by receiving a hash of the original message (which may otherwise\n     * be too long), and then calling {toEthSignedMessageHash} on it.\n     *\n     * Documentation for signature generation:\n     * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]\n     * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]\n     *\n     * _Available since v4.3._\n     */\n    function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {\n        // Check the signature length\n        // - case 65: r,s,v signature (standard)\n        // - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._\n        if (signature.length == 65) {\n            bytes32 r;\n            bytes32 s;\n            uint8 v;\n            // ecrecover takes the signature parameters, and the only way to get them\n            // currently is to use assembly.\n            /// @solidity memory-safe-assembly\n            assembly {\n                r := mload(add(signature, 0x20))\n                s := mload(add(signature, 0x40))\n                v := byte(0, mload(add(signature, 0x60)))\n            }\n            return tryRecover(hash, v, r, s);\n        } else if (signature.length == 64) {\n            bytes32 r;\n            bytes32 vs;\n            // ecrecover takes the signature parameters, and the only way to get them\n            // currently is to use assembly.\n            /// @solidity memory-safe-assembly\n            assembly {\n                r := mload(add(signature, 0x20))\n                vs := mload(add(signature, 0x40))\n            }\n            return tryRecover(hash, r, vs);\n        } else {\n            return (address(0), RecoverError.InvalidSignatureLength);\n        }\n    }\n\n    /**\n     * @dev Returns the address that signed a hashed message (`hash`) with\n     * `signature`. This address can then be used for verification purposes.\n     *\n     * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n     * this function rejects them by requiring the `s` value to be in the lower\n     * half order, and the `v` value to be either 27 or 28.\n     *\n     * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n     * verification to be secure: it is possible to craft signatures that\n     * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n     * this is by receiving a hash of the original message (which may otherwise\n     * be too long), and then calling {toEthSignedMessageHash} on it.\n     */\n    function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {\n        (address recovered, RecoverError error) = tryRecover(hash, signature);\n        _throwError(error);\n        return recovered;\n    }\n\n    /**\n     * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.\n     *\n     * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]\n     *\n     * _Available since v4.3._\n     */\n    function tryRecover(\n        bytes32 hash,\n        bytes32 r,\n        bytes32 vs\n    ) internal pure returns (address, RecoverError) {\n        bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);\n        uint8 v = uint8((uint256(vs) >> 255) + 27);\n        return tryRecover(hash, v, r, s);\n    }\n\n    /**\n     * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.\n     *\n     * _Available since v4.2._\n     */\n    function recover(\n        bytes32 hash,\n        bytes32 r,\n        bytes32 vs\n    ) internal pure returns (address) {\n        (address recovered, RecoverError error) = tryRecover(hash, r, vs);\n        _throwError(error);\n        return recovered;\n    }\n\n    /**\n     * @dev Overload of {ECDSA-tryRecover} that receives the `v`,\n     * `r` and `s` signature fields separately.\n     *\n     * _Available since v4.3._\n     */\n    function tryRecover(\n        bytes32 hash,\n        uint8 v,\n        bytes32 r,\n        bytes32 s\n    ) internal pure returns (address, RecoverError) {\n        // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\n        // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\n        // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most\n        // signatures from current libraries generate a unique signature with an s-value in the lower half order.\n        //\n        // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value\n        // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or\n        // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept\n        // these malleable signatures as well.\n        if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\n            return (address(0), RecoverError.InvalidSignatureS);\n        }\n        if (v != 27 && v != 28) {\n            return (address(0), RecoverError.InvalidSignatureV);\n        }\n\n        // If the signature is valid (and not malleable), return the signer address\n        address signer = ecrecover(hash, v, r, s);\n        if (signer == address(0)) {\n            return (address(0), RecoverError.InvalidSignature);\n        }\n\n        return (signer, RecoverError.NoError);\n    }\n\n    /**\n     * @dev Overload of {ECDSA-recover} that receives the `v`,\n     * `r` and `s` signature fields separately.\n     */\n    function recover(\n        bytes32 hash,\n        uint8 v,\n        bytes32 r,\n        bytes32 s\n    ) internal pure returns (address) {\n        (address recovered, RecoverError error) = tryRecover(hash, v, r, s);\n        _throwError(error);\n        return recovered;\n    }\n\n    /**\n     * @dev Returns an Ethereum Signed Message, created from a `hash`. This\n     * produces hash corresponding to the one signed with the\n     * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n     * JSON-RPC method as part of EIP-191.\n     *\n     * See {recover}.\n     */\n    function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {\n        // 32 is the length in bytes of hash,\n        // enforced by the type signature above\n        return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n32\", hash));\n    }\n\n    /**\n     * @dev Returns an Ethereum Signed Message, created from `s`. This\n     * produces hash corresponding to the one signed with the\n     * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n     * JSON-RPC method as part of EIP-191.\n     *\n     * See {recover}.\n     */\n    function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {\n        return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n\", Strings.toString(s.length), s));\n    }\n\n    /**\n     * @dev Returns an Ethereum Signed Typed Data, created from a\n     * `domainSeparator` and a `structHash`. This produces hash corresponding\n     * to the one signed with the\n     * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]\n     * JSON-RPC method as part of EIP-712.\n     *\n     * See {recover}.\n     */\n    function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {\n        return keccak256(abi.encodePacked(\"\\x19\\x01\", domainSeparator, structHash));\n    }\n}\n"
    },
    "contracts/auxillary/AccessManager.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.14;\n\nimport '@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol';\nimport '@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol';\n\n/// @title AccessManager\n/// @author OpenZeppelin & Sound.xyz (@gigma)\n/// @notice Grants ownership to the deployer, and allows them to grant or revoke roles for other accounts.\n/// @dev Forked from OpenZeppelin Contracts (OwnableUpgradeable & AccessControl)\ncontract AccessManager is Initializable, ContextUpgradeable {\n    // The admin role identifier\n    bytes32 public constant ADMIN_ROLE = keccak256('ADMIN');\n\n    address private _owner;\n\n    // Track registered admins\n    mapping(bytes32 => mapping(address => bool)) private _roles;\n\n    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n    event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n    event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n    // =====================\n    // Ownership functions\n    // =====================\n\n    /**\n     * @dev Initializes the contract setting the deployer as the initial owner.\n     */\n    function __AccessManager_init() internal onlyInitializing {\n        __Context_init_unchained();\n        __AccessManager_init_unchained();\n    }\n\n    function __AccessManager_init_unchained() internal onlyInitializing {\n        _transferOwnership(_msgSender());\n    }\n\n    /**\n     * @dev Returns the address of the current owner.\n     */\n    function owner() public view returns (address) {\n        return _owner;\n    }\n\n    /**\n     * @dev Throws if called by any account other than the owner.\n     */\n    modifier onlyOwner() {\n        require(owner() == _msgSender(), 'Ownable: caller is not the owner');\n        _;\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     * Can only be called by the current owner.\n     */\n    function transferOwnership(address newOwner) public onlyOwner {\n        require(newOwner != address(0), 'Ownable: new owner is the zero address');\n        _transferOwnership(newOwner);\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     * Internal function without access restriction.\n     */\n    function _transferOwnership(address newOwner) internal {\n        address oldOwner = _owner;\n        _owner = newOwner;\n        emit OwnershipTransferred(oldOwner, newOwner);\n    }\n\n    // =====================\n    // Role functions\n    // =====================\n\n    /// @notice Register an account as an admin\n    /// @param role The role to grant to the given account\n    /// @param account The account to register\n    function grantRole(bytes32 role, address account) external onlyOwner {\n        if (!hasRole(role, account)) {\n            _roles[role][account] = true;\n            emit RoleGranted(role, account, _msgSender());\n        }\n    }\n\n    /// @notice Revoke a role from an account\n    /// @param role The role to revoke\n    /// @param account The account to revoke the role from\n    function revokeRole(bytes32 role, address account) external onlyOwner {\n        if (hasRole(role, account)) {\n            _roles[role][account] = false;\n            emit RoleRevoked(role, account, _msgSender());\n        }\n    }\n\n    /// @notice Check if an account has a role\n    /// @param role The role to check\n    /// @param account The account to check\n    function hasRole(bytes32 role, address account) public view returns (bool) {\n        return _roles[role][account];\n    }\n\n    /// @notice Check if the given address is the owner or has the given role.\n    /// @param role The role to check for.\n    modifier checkPermission(bytes32 role) {\n        require(_msgSender() == owner() || hasRole(role, _msgSender()), 'unauthorized');\n        _;\n    }\n\n    uint256[48] private __gap;\n}\n"
    },
    "contracts/ArtistV6.sol": {
      "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity ^0.8.14;\n\n/*\n               ^###############################################&5               \n               ?@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&               \n   !PPPPPPPPPPP&@@@@@@@@@@@@?!!!!!!!!!!7&@@@@@@@@@@@@@@@@@@@@@@@@BPPPPPPPPPPJ   \n   B@@@@@@@@@@@@@@@@@@@@@@@&            #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@.  \n   B@@@@@@@@@@@@@@@@@@@@@@@&            ~55555555555&@@@@@@@@@@@@@@@@@@@@@@@@.  \n   B@@@@@@@@@@@@@@@@@@@@@@@&                        J@@@@@@@@@@@@@@@@@@@@@@@@.  \n   B@@@@@@@@@@@@@@@@@@@@@@@&~::::::::::::::::::::::.~B######################P   \n   B@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@7                           \n   5@&&&&&&&&&&&&&&&&&&&&&&@@@@@@@@@@@@@@@@@@@@@@@@@5                           \n    .......................!@@@@@@@@@@@@@@@@@@@@@@@@@&&&&&&&&&&&&&&&&&&&&&&&B   \n                           .@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&   \n   7BBBBBBBBBBBBBBBBBBBBBBBY:^^^^^^^^^^^^^^^^^^^^^^^B@@@@@@@@@@@@@@@@@@@@@@@&   \n   B@@@@@@@@@@@@@@@@@@@@@@@&                        Y@@@@@@@@@@@@@@@@@@@@@@@&   \n   B@@@@@@@@@@@@@@@@@@@@@@@@PJYYYYYYYYY?            5@@@@@@@@@@@@@@@@@@@@@@@&   \n   B@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@:           Y@@@@@@@@@@@@@@@@@@@@@@@&   \n   !GGGGGGGGGGG&@@@@@@@@@@@@@@@@@@@@@@@@5~~~~~~~~~~~#@@@@@@@@@@@@BGGGGGGGGGGJ   \n               J@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@G               \n               ~&&&&#&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&?                 \n\n*/\n\nimport '@openzeppelin/contracts-upgradeable/interfaces/IERC2981Upgradeable.sol';\nimport '@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol';\nimport '@openzeppelin/contracts-upgradeable/utils/CountersUpgradeable.sol';\nimport '@openzeppelin/contracts/utils/cryptography/ECDSA.sol';\nimport '@openzeppelin/contracts/utils/Strings.sol';\nimport './auxillary/AccessManager.sol';\n\n/// @title Artist\n/// @author SoundXYZ - @gigamesh & @vigneshka\n/// @notice This contract is used to create & sell song NFTs for the artist who owns the contract.\n/// @dev Started as a fork of Mirror's Editions.sol https://github.com/mirror-xyz/editions-v1/blob/main/contracts/Editions.sol\ncontract ArtistV6 is ERC721Upgradeable, IERC2981Upgradeable, AccessManager {\n    // ================================\n    // TYPES\n    // ================================\n\n    struct Edition {\n        // The account that will receive sales revenue.\n        address payable fundingRecipient;\n        // The price at which each token will be sold, in ETH.\n        uint256 price;\n        // The number of tokens sold so far.\n        uint32 numSold;\n        // The maximum number of tokens that can be sold.\n        uint32 quantity;\n        // Royalty amount in bps\n        uint32 royaltyBPS;\n        // start timestamp of auction (in seconds since unix epoch)\n        uint32 startTime;\n        // end timestamp of auction (in seconds since unix epoch)\n        uint32 endTime;\n        // quantity of permissioned tokens\n        uint32 permissionedQuantity;\n        // whitelist signer address\n        address signerAddress;\n        // base uri for the edition\n        string baseURI;\n    }\n\n    using CountersUpgradeable for CountersUpgradeable.Counter;\n    using ECDSA for bytes32;\n\n    enum TimeType {\n        START,\n        END\n    }\n\n    // ================================\n    // STORAGE\n    // ================================\n\n    // The permissioned typehash (used for checking signature validity)\n    bytes32 public constant PERMISSIONED_SALE_TYPEHASH =\n        keccak256('EditionInfo(address contractAddress,address buyerAddress,uint256 editionId,uint256 ticketNumber)');\n    // Domain separator - used to prevent replay attacks using signatures from different networks\n    bytes32 public immutable DOMAIN_SEPARATOR;\n    // The default baseURI for the contract\n    string internal baseURI;\n\n    CountersUpgradeable.Counter public atTokenId; // DEPRECATED IN V3\n    CountersUpgradeable.Counter public atEditionId;\n\n    // Mapping of edition id to descriptive data.\n    mapping(uint256 => Edition) public editions;\n    // <DEPRECATED IN V3> Mapping of token id to edition id.\n    mapping(uint256 => uint256) public _tokenToEdition;\n    // The amount of funds that have been deposited for a given edition.\n    mapping(uint256 => uint256) public depositedForEdition;\n    // The amount of funds that have already been withdrawn for a given edition.\n    mapping(uint256 => uint256) public withdrawnForEdition;\n    // Used to track which tokens have been claimed. editionId -> index -> bit array\n    mapping(uint256 => mapping(uint256 => uint256)) ticketNumbers;\n\n    // ================================\n    // EVENTS\n    // ================================\n\n    event EditionCreated(\n        uint256 indexed editionId,\n        address fundingRecipient,\n        uint256 price,\n        uint32 quantity,\n        uint32 royaltyBPS,\n        uint32 startTime,\n        uint32 endTime,\n        uint32 permissionedQuantity,\n        address signerAddress\n    );\n\n    event EditionPurchased(\n        uint256 indexed editionId,\n        uint256 indexed tokenId,\n        // `numSold` at time of purchase represents the \"serial number\" of the NFT.\n        uint32 numSold,\n        // The account that paid for and received the NFT.\n        address indexed buyer,\n        uint256 ticketNumber\n    );\n\n    event AuctionTimeSet(TimeType timeType, uint256 editionId, uint32 indexed newTime);\n\n    event SignerAddressSet(uint256 editionId, address indexed signerAddress);\n\n    event PermissionedQuantitySet(uint256 editionId, uint32 permissionedQuantity);\n\n    event BaseURISet(uint256 editionId, string baseURI);\n\n    // ================================\n    // PUBLIC & EXTERNAL WRITABLE FUNCTIONS\n    // ================================\n\n    /// @notice Contract constructor\n    constructor() {\n        DOMAIN_SEPARATOR = keccak256(abi.encode(keccak256('EIP712Domain(uint256 chainId)'), block.chainid));\n    }\n\n    /// @notice Initializes the contract\n    /// @param _owner Owner of edition\n    /// @param _name Name of artist\n    /// @param _symbol Symbol for the artist\n    /// @param _baseURI Default base URI for all editions\n    function initialize(\n        address _owner,\n        string memory _name,\n        string memory _symbol,\n        string memory _baseURI\n    ) public initializer {\n        __ERC721_init(_name, _symbol);\n        __AccessManager_init();\n\n        // Set ownership to original sender of contract call\n        transferOwnership(_owner);\n\n        // baseURI override only for testnets\n        if (block.chainid != 1) {\n            baseURI = _baseURI;\n        }\n\n        // Set edition id start to be 1 not 0\n        atEditionId.increment();\n    }\n\n    /// @notice Creates a new edition.\n    /// @param _fundingRecipient The account that will receive sales revenue.\n    /// @param _price The price at which each token will be sold, in ETH.\n    /// @param _quantity The maximum number of tokens that can be sold.\n    /// @param _royaltyBPS The royalty amount in bps.\n    /// @param _startTime The start time of the auction, in seconds since unix epoch.\n    /// @param _endTime The end time of the auction, in seconds since unix epoch.\n    /// @param _permissionedQuantity The quantity of tokens that require a signature to buy.\n    /// @param _signerAddress signer address.\n    /// @param _editionId The expected edition ID\n    /// @param _baseURI The base URI for the edition\n    function createEdition(\n        address payable _fundingRecipient,\n        uint256 _price,\n        uint32 _quantity,\n        uint32 _royaltyBPS,\n        uint32 _startTime,\n        uint32 _endTime,\n        uint32 _permissionedQuantity,\n        address _signerAddress,\n        uint256 _editionId,\n        string memory _baseURI\n    ) external checkPermission(ADMIN_ROLE) {\n        require(_quantity > 0, 'Must set quantity');\n        require(_fundingRecipient != address(0), 'Must set fundingRecipient');\n        require(_endTime > _startTime, 'End time must be greater than start time');\n        require(_editionId == atEditionId.current(), 'Wrong edition ID');\n\n        if (_permissionedQuantity > 0) {\n            require(_signerAddress != address(0), 'Signer address cannot be 0');\n        }\n\n        editions[atEditionId.current()] = Edition({\n            fundingRecipient: _fundingRecipient,\n            price: _price,\n            numSold: 0,\n            quantity: _quantity,\n            royaltyBPS: _royaltyBPS,\n            startTime: _startTime,\n            endTime: _endTime,\n            permissionedQuantity: _permissionedQuantity,\n            signerAddress: _signerAddress,\n            baseURI: _baseURI\n        });\n\n        emit EditionCreated(\n            atEditionId.current(),\n            _fundingRecipient,\n            _price,\n            _quantity,\n            _royaltyBPS,\n            _startTime,\n            _endTime,\n            _permissionedQuantity,\n            _signerAddress\n        );\n\n        atEditionId.increment();\n    }\n\n    /// @notice Creates a new token for the given edition, and assigns it to the buyer\n    /// @param _editionId The id of the edition to purchase\n    /// @param _signature A signed message for authorizing permissioned purchases\n    /// @param _ticketNumber Ticket number required for validating this buyer hasn't already bought.\n    function buyEdition(\n        uint256 _editionId,\n        bytes calldata _signature,\n        uint256 _ticketNumber\n    ) external payable {\n        // Caching variables locally to reduce reads\n        uint256 price = editions[_editionId].price;\n        uint32 quantity = editions[_editionId].quantity;\n        uint32 numSold = editions[_editionId].numSold;\n        uint32 newNumSold = numSold + 1;\n        uint32 startTime = editions[_editionId].startTime;\n        uint32 endTime = editions[_editionId].endTime;\n        uint32 permissionedQuantity = editions[_editionId].permissionedQuantity;\n\n        // Check that the edition exists. Note: this is redundant\n        // with the next check, but it is useful for clearer error messaging.\n        require(quantity > 0, 'Edition does not exist');\n        // Check that the sender is paying the correct amount.\n        require(msg.value >= price, 'Must send enough to purchase the edition.');\n        // Don't allow purchases after the end time\n        require(endTime > block.timestamp, 'Auction has ended');\n\n        // If the public auction hasn't started...\n        if (startTime > block.timestamp) {\n            // Check that permissioned tokens are still available\n            require(numSold < permissionedQuantity, 'No permissioned tokens available & open auction not started');\n\n            // Check that the signature is valid.\n            require(\n                getSigner(_signature, _editionId, _ticketNumber) == editions[_editionId].signerAddress,\n                'Invalid signer'\n            );\n        } else {\n            // Check that there are still tokens available to purchase.\n            // Only need to check this for the public sale (after the start time)\n            // so we can accomodate open editions\n            require(numSold < quantity, 'This edition is already sold out.');\n        }\n\n        // Create the token id by packing editionId in the top bits\n        uint256 tokenId;\n        unchecked {\n            tokenId = (_editionId << 128) | newNumSold;\n            // Increment the number of tokens sold for this edition.\n            editions[_editionId].numSold = newNumSold;\n        }\n\n        // If fundingRecipient is the owner (artist's wallet), update the edition's balance & don't send the funds\n        if (editions[_editionId].fundingRecipient == owner()) {\n            // Update the deposited total for the edition\n            depositedForEdition[_editionId] += msg.value;\n        } else {\n            // Send funds to the funding recipient.\n            _sendFunds(editions[_editionId].fundingRecipient, msg.value);\n        }\n\n        // Mint a new token for the sender, using the `tokenId`.\n        _mint(msg.sender, tokenId);\n\n        emit EditionPurchased(_editionId, tokenId, newNumSold, msg.sender, _ticketNumber);\n    }\n\n    /// @notice Withdraws from the Artist to the fundingRecipient for an edition\n    /// @param _editionId The id of the edition to withdraw from\n    function withdrawFunds(uint256 _editionId) external {\n        // Compute the amount available for withdrawing from this edition.\n        uint256 remainingForEdition = depositedForEdition[_editionId] - withdrawnForEdition[_editionId];\n\n        // Set the amount withdrawn to the amount deposited.\n        withdrawnForEdition[_editionId] = depositedForEdition[_editionId];\n\n        // Send the amount that was remaining for the edition, to the funding recipient.\n        _sendFunds(editions[_editionId].fundingRecipient, remainingForEdition);\n    }\n\n    /// @notice Sets the start time for an edition\n    /// @param _editionId The id of the edition to set the start time for\n    /// @param _startTime The start time to set (in seconds since unix epoch)\n    function setStartTime(uint256 _editionId, uint32 _startTime) external checkPermission(ADMIN_ROLE) {\n        editions[_editionId].startTime = _startTime;\n        emit AuctionTimeSet(TimeType.START, _editionId, _startTime);\n    }\n\n    /// @notice Sets the end time for an edition\n    /// @param _editionId The id of the edition to set the end time for\n    /// @param _endTime The end time to set (in seconds since unix epoch)\n    function setEndTime(uint256 _editionId, uint32 _endTime) external checkPermission(ADMIN_ROLE) {\n        editions[_editionId].endTime = _endTime;\n        emit AuctionTimeSet(TimeType.END, _editionId, _endTime);\n    }\n\n    /// @notice Sets the signature address of an edition\n    /// @param _editionId The edition id to set the signature address for\n    /// @param _newSignerAddress The address that will be used to sign purchases\n    function setSignerAddress(uint256 _editionId, address _newSignerAddress) external checkPermission(ADMIN_ROLE) {\n        require(_newSignerAddress != address(0), 'Signer address cannot be 0');\n\n        editions[_editionId].signerAddress = _newSignerAddress;\n        emit SignerAddressSet(_editionId, _newSignerAddress);\n    }\n\n    /// @notice Sets the permissioned quantity for an edition\n    /// @param _editionId The edition id to set the permissioned quantity for\n    /// @param _permissionedQuantity The new permissiond quantity\n    function setPermissionedQuantity(uint256 _editionId, uint32 _permissionedQuantity)\n        external\n        checkPermission(ADMIN_ROLE)\n    {\n        // Prevent setting to permissioned quantity when there is no signer address\n        require(editions[_editionId].signerAddress != address(0), 'Edition must have a signer');\n\n        editions[_editionId].permissionedQuantity = _permissionedQuantity;\n        emit PermissionedQuantitySet(_editionId, _permissionedQuantity);\n    }\n\n    /// @notice Sets a new owner, only callable by current owner or the soundRecoveryAddress (ie: gnosis safe)\n    /// @param _newOwner The new owner of the contract\n    function setOwnerOverride(address _newOwner) external {\n        require(_msgSender() == soundRecoveryAddress() || _msgSender() == owner(), 'unauthorized');\n\n        super._transferOwnership(_newOwner);\n    }\n\n    /// @notice Sets the base URI for an edition\n    /// @param _editionId The target edition's id\n    /// @param _baseURI The new base URI\n    function setEditionBaseURI(uint256 _editionId, string calldata _baseURI) external checkPermission(ADMIN_ROLE) {\n        require(\n            editions[_editionId].quantity > 0 || editions[_editionId].permissionedQuantity > 0,\n            'Nonexistent edition'\n        );\n\n        editions[_editionId].baseURI = _baseURI;\n\n        emit BaseURISet(_editionId, _baseURI);\n    }\n\n    // ================================\n    // VIEW FUNCTIONS\n    // ================================\n\n    /// @notice Returns token URI (metadata URL). e.g. https://sound.xyz/api/metadata/[contractAddress]/[tokenId]/metadata.json\n    /// @dev Concatenate the baseURI and tokenId, to create URI.\n    function tokenURI(uint256 _tokenId) public view override returns (string memory) {\n        require(_exists(_tokenId), 'ERC721Metadata: URI query for nonexistent token');\n\n        uint256 editionId = tokenToEdition(_tokenId);\n\n        string memory editionBaseURI = editions[editionId].baseURI;\n\n        // If the edition has a baseURI, it means this edition is on permastorage\n        // Using 3 as the length in case it gets accidentally set to empty space\n        if (bytes(editionBaseURI).length > 3) {\n            return string.concat(editionBaseURI, Strings.toString(_tokenId), '/metadata.json');\n        }\n\n        return string.concat(_contractBaseURI(), Strings.toString(_tokenId));\n    }\n\n    /// @notice Returns contract URI used by Opensea. e.g. https://sound.xyz/api/metadata/[contractAddress]/storefront\n    function contractURI() public view returns (string memory) {\n        return string.concat(_contractBaseURI(), 'storefront');\n    }\n\n    /// @notice Get royalty information for token\n    /// @param _tokenId token id\n    /// @param _salePrice Sale price for the token\n    function royaltyInfo(uint256 _tokenId, uint256 _salePrice)\n        external\n        view\n        override\n        returns (address fundingRecipient, uint256 royaltyAmount)\n    {\n        uint256 editionId = tokenToEdition(_tokenId);\n        Edition memory edition = editions[editionId];\n\n        if (edition.fundingRecipient == address(0x0)) {\n            return (edition.fundingRecipient, 0);\n        }\n\n        uint256 royaltyBPS = uint256(edition.royaltyBPS);\n\n        return (edition.fundingRecipient, (_salePrice * royaltyBPS) / 10_000);\n    }\n\n    /// @notice The total number of tokens created by this contract\n    function totalSupply() external view returns (uint256) {\n        uint256 total = 0;\n        for (uint256 id = 1; id < atEditionId.current(); id++) {\n            total += editions[id].numSold;\n        }\n        return total;\n    }\n\n    /// @notice Informs other contracts which interfaces this contract supports\n    /// @param _interfaceId The interface id to check\n    /// @dev https://eips.ethereum.org/EIPS/eip-165\n    function supportsInterface(bytes4 _interfaceId)\n        public\n        view\n        override(ERC721Upgradeable, IERC165Upgradeable)\n        returns (bool)\n    {\n        return\n            type(IERC2981Upgradeable).interfaceId == _interfaceId || ERC721Upgradeable.supportsInterface(_interfaceId);\n    }\n\n    /// @notice returns the number of editions for this artist\n    function editionCount() external view returns (uint256) {\n        return atEditionId.current() - 1; // because atEditionId is incremented after each edition is created\n    }\n\n    /// @notice Returns the edition id for a given token id\n    /// @param _tokenId token id\n    function tokenToEdition(uint256 _tokenId) public view returns (uint256) {\n        // Check the top bits to see if the edition id is there\n        uint256 editionId = _tokenId >> 128;\n\n        // If edition ID is 0, then this edition was created before the V3 upgrade\n        if (editionId == 0) {\n            // get edition ID from storage\n            return _tokenToEdition[_tokenId];\n        }\n\n        return editionId;\n    }\n\n    /// @notice Returns a list of owner addresses for a given list of token ids\n    /// @param _tokenIds List of token ids\n    function ownersOfTokenIds(uint256[] calldata _tokenIds) external view returns (address[] memory) {\n        address[] memory owners = new address[](_tokenIds.length);\n        for (uint256 i = 0; i < _tokenIds.length; i++) {\n            owners[i] = ownerOf(_tokenIds[i]);\n        }\n        return owners;\n    }\n\n    /// @notice Returns the claimed ticket numbers for a given edition and list of ticket numbers (indexes)\n    /// @param _editionId Edition id\n    /// @param _ticketNumbers List of ticket numbers (indexes)\n    function checkTicketNumbers(uint256 _editionId, uint256[] calldata _ticketNumbers)\n        external\n        view\n        returns (bool[] memory)\n    {\n        bool[] memory claimed = new bool[](_ticketNumbers.length);\n\n        for (uint256 i = 0; i < _ticketNumbers.length; i++) {\n            (uint256 storedBit, , , ) = _getBitForTicketNumber(_editionId, _ticketNumbers[i]);\n            claimed[i] = storedBit == 1;\n        }\n\n        return claimed;\n    }\n\n    /// @notice Returns the address (ie: gnosis safe) authorized to change ownership of the contract\n    function soundRecoveryAddress() public view virtual returns (address) {\n        if (block.chainid == 1) {\n            return 0x858a92511485715Cfb754f397a7894b7724c7Abd;\n        } else if (block.chainid == 4) {\n            return 0xee35E946Dd73EF78d352454c3F915e2cA0a09d87;\n        } else {\n            revert('unsupported chain');\n        }\n    }\n\n    // ================================\n    // PRIVATE FUNCTIONS\n    // ================================\n\n    /// @notice Sends funds to an address\n    /// @param _recipient The address to send funds to\n    /// @param _amount The amount of funds to send\n    function _sendFunds(address payable _recipient, uint256 _amount) private {\n        require(address(this).balance >= _amount, 'Insufficient balance for send');\n\n        (bool success, ) = _recipient.call{value: _amount}('');\n        require(success, 'Unable to send value: recipient may have reverted');\n    }\n\n    /// @notice Gets signer address to validate permissioned purchase\n    /// @param _signature signed message\n    /// @param _editionId edition id\n    /// @param _ticketNumber ticket number to check\n    /// @return address of signer\n    /// @dev https://eips.ethereum.org/EIPS/eip-712\n    function getSigner(\n        bytes calldata _signature,\n        uint256 _editionId,\n        uint256 _ticketNumber\n    ) private returns (address) {\n        // Check that the ticket number is within the reserved range for the edition\n        // permissionedQuantity is uint32, so ticketNumber can't exceed max uint32\n        require(_ticketNumber < 2**32, 'Ticket number exceeds max');\n\n        // gets the stored bit\n        (\n            uint256 storedBit,\n            uint256 localGroup,\n            uint256 localGroupOffset,\n            uint256 ticketNumbersIdx\n        ) = _getBitForTicketNumber(_editionId, _ticketNumber);\n\n        require(storedBit == 0, 'Invalid ticket number or NFT already claimed');\n\n        // Flip the bit to 1 to indicate that the ticket has been claimed\n        ticketNumbers[_editionId][ticketNumbersIdx] = localGroup | (uint256(1) << localGroupOffset);\n\n        bytes32 digest = keccak256(\n            abi.encodePacked(\n                '\\x19\\x01',\n                DOMAIN_SEPARATOR,\n                keccak256(abi.encode(PERMISSIONED_SALE_TYPEHASH, address(this), msg.sender, _editionId, _ticketNumber))\n            )\n        );\n        return digest.recover(_signature);\n    }\n\n    /// @notice Gets the bit variables associated with a ticket number\n    /// @param _editionId edition id\n    /// @param _ticketNumber ticket number\n    function _getBitForTicketNumber(uint256 _editionId, uint256 _ticketNumber)\n        private\n        view\n        returns (\n            uint256,\n            uint256,\n            uint256,\n            uint256\n        )\n    {\n        uint256 localGroup; // the bit array for this ticket number\n        uint256 ticketNumbersIdx; // the index of the the local group\n        uint256 localGroupOffset; // the offset/index for the ticket number in the local group\n        uint256 storedBit; // the stored bit at this ticket number's index within the local group\n        unchecked {\n            ticketNumbersIdx = _ticketNumber / 256;\n            localGroupOffset = _ticketNumber % 256;\n        }\n\n        // cache the local group for efficiency\n        localGroup = ticketNumbers[_editionId][ticketNumbersIdx];\n\n        // gets the stored bit\n        storedBit = (localGroup >> localGroupOffset) & uint256(1);\n\n        return (storedBit, localGroup, localGroupOffset, ticketNumbersIdx);\n    }\n\n    function _contractBaseURI() private view returns (string memory) {\n        string memory contractAddress = Strings.toHexString(uint256(uint160(address(this))), 20);\n        if (block.chainid == 1) {\n            return string.concat('https://metadata.sound.xyz/v1/', contractAddress, '/');\n        } else {\n            return string.concat(baseURI, contractAddress, '/');\n        }\n    }\n}\n"
    },
    "contracts/ArtistV5.sol": {
      "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity ^0.8.14;\n\n/*\n               ^###############################################&5               \n               ?@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&               \n   !PPPPPPPPPPP&@@@@@@@@@@@@?!!!!!!!!!!7&@@@@@@@@@@@@@@@@@@@@@@@@BPPPPPPPPPPJ   \n   B@@@@@@@@@@@@@@@@@@@@@@@&            #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@.  \n   B@@@@@@@@@@@@@@@@@@@@@@@&            ~55555555555&@@@@@@@@@@@@@@@@@@@@@@@@.  \n   B@@@@@@@@@@@@@@@@@@@@@@@&                        J@@@@@@@@@@@@@@@@@@@@@@@@.  \n   B@@@@@@@@@@@@@@@@@@@@@@@&~::::::::::::::::::::::.~B######################P   \n   B@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@7                           \n   5@&&&&&&&&&&&&&&&&&&&&&&@@@@@@@@@@@@@@@@@@@@@@@@@5                           \n    .......................!@@@@@@@@@@@@@@@@@@@@@@@@@&&&&&&&&&&&&&&&&&&&&&&&B   \n                           .@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&   \n   7BBBBBBBBBBBBBBBBBBBBBBBY:^^^^^^^^^^^^^^^^^^^^^^^B@@@@@@@@@@@@@@@@@@@@@@@&   \n   B@@@@@@@@@@@@@@@@@@@@@@@&                        Y@@@@@@@@@@@@@@@@@@@@@@@&   \n   B@@@@@@@@@@@@@@@@@@@@@@@@PJYYYYYYYYY?            5@@@@@@@@@@@@@@@@@@@@@@@&   \n   B@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@:           Y@@@@@@@@@@@@@@@@@@@@@@@&   \n   !GGGGGGGGGGG&@@@@@@@@@@@@@@@@@@@@@@@@5~~~~~~~~~~~#@@@@@@@@@@@@BGGGGGGGGGGJ   \n               J@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@G               \n               ~&&&&#&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&?                 \n\n*/\n\nimport '@openzeppelin/contracts-upgradeable/interfaces/IERC2981Upgradeable.sol';\nimport '@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol';\nimport '@openzeppelin/contracts-upgradeable/utils/CountersUpgradeable.sol';\nimport '@openzeppelin/contracts/utils/cryptography/ECDSA.sol';\nimport '@openzeppelin/contracts/utils/Strings.sol';\nimport './auxillary/AccessManager.sol';\n\n/// @title Artist\n/// @author SoundXYZ - @gigamesh & @vigneshka\n/// @notice This contract is used to create & sell song NFTs for the artist who owns the contract.\n/// @dev Started as a fork of Mirror's Editions.sol https://github.com/mirror-xyz/editions-v1/blob/main/contracts/Editions.sol\ncontract ArtistV5 is ERC721Upgradeable, IERC2981Upgradeable, AccessManager {\n    // ================================\n    // STORAGE\n    // ================================\n\n    // The permissioned typehash (used for checking signature validity)\n    bytes32 public constant PERMISSIONED_SALE_TYPEHASH =\n        keccak256('EditionInfo(address contractAddress,address buyerAddress,uint256 editionId,uint256 ticketNumber)');\n    // Domain separator - used to prevent replay attacks using signatures from different networks\n    bytes32 public immutable DOMAIN_SEPARATOR;\n    // The default baseURI for the contract\n    string internal baseURI;\n\n    CountersUpgradeable.Counter public atTokenId; // DEPRECATED IN V3\n    CountersUpgradeable.Counter public atEditionId;\n\n    // Mapping of edition id to descriptive data.\n    mapping(uint256 => Edition) public editions;\n    // <DEPRECATED IN V3> Mapping of token id to edition id.\n    mapping(uint256 => uint256) public _tokenToEdition;\n    // The amount of funds that have been deposited for a given edition.\n    mapping(uint256 => uint256) public depositedForEdition;\n    // The amount of funds that have already been withdrawn for a given edition.\n    mapping(uint256 => uint256) public withdrawnForEdition;\n    // Used to track which tokens have been claimed. editionId -> index -> bit array\n    mapping(uint256 => mapping(uint256 => uint256)) ticketNumbers;\n\n    // ================================\n    // TYPES\n    // ================================\n\n    struct Edition {\n        // The account that will receive sales revenue.\n        address payable fundingRecipient;\n        // The price at which each token will be sold, in ETH.\n        uint256 price;\n        // The number of tokens sold so far.\n        uint32 numSold;\n        // The maximum number of tokens that can be sold.\n        uint32 quantity;\n        // Royalty amount in bps\n        uint32 royaltyBPS;\n        // start timestamp of auction (in seconds since unix epoch)\n        uint32 startTime;\n        // end timestamp of auction (in seconds since unix epoch)\n        uint32 endTime;\n        // quantity of permissioned tokens\n        uint32 permissionedQuantity;\n        // whitelist signer address\n        address signerAddress;\n        // base uri for the edition\n        string baseURI;\n    }\n\n    using CountersUpgradeable for CountersUpgradeable.Counter;\n    using ECDSA for bytes32;\n\n    enum TimeType {\n        START,\n        END\n    }\n\n    // ================================\n    // EVENTS\n    // ================================\n\n    event EditionCreated(\n        uint256 indexed editionId,\n        address fundingRecipient,\n        uint256 price,\n        uint32 quantity,\n        uint32 royaltyBPS,\n        uint32 startTime,\n        uint32 endTime,\n        uint32 permissionedQuantity,\n        address signerAddress\n    );\n\n    event EditionPurchased(\n        uint256 indexed editionId,\n        uint256 indexed tokenId,\n        // `numSold` at time of purchase represents the \"serial number\" of the NFT.\n        uint32 numSold,\n        // The account that paid for and received the NFT.\n        address indexed buyer,\n        uint256 ticketNumber\n    );\n\n    event AuctionTimeSet(TimeType timeType, uint256 editionId, uint32 indexed newTime);\n\n    event SignerAddressSet(uint256 editionId, address indexed signerAddress);\n\n    event PermissionedQuantitySet(uint256 editionId, uint32 permissionedQuantity);\n\n    event BaseURISet(uint256 editionId, string baseURI);\n\n    // ================================\n    // PUBLIC & EXTERNAL WRITABLE FUNCTIONS\n    // ================================\n\n    /// @notice Contract constructor\n    constructor() {\n        DOMAIN_SEPARATOR = keccak256(abi.encode(keccak256('EIP712Domain(uint256 chainId)'), block.chainid));\n    }\n\n    /// @notice Initializes the contract\n    /// @param _owner Owner of edition\n    /// @param _name Name of artist\n    /// @param _symbol Symbol for the artist\n    /// @param _baseURI Default base URI for all editions\n    function initialize(\n        address _owner,\n        string memory _name,\n        string memory _symbol,\n        string memory _baseURI\n    ) public initializer {\n        __ERC721_init(_name, _symbol);\n        __AccessManager_init();\n\n        // Set ownership to original sender of contract call\n        transferOwnership(_owner);\n\n        // baseURI override only for testnets\n        if (block.chainid != 1) {\n            baseURI = _baseURI;\n        }\n\n        // Set edition id start to be 1 not 0\n        atEditionId.increment();\n    }\n\n    /// @notice Creates a new edition.\n    /// @param _fundingRecipient The account that will receive sales revenue.\n    /// @param _price The price at which each token will be sold, in ETH.\n    /// @param _quantity The maximum number of tokens that can be sold.\n    /// @param _royaltyBPS The royalty amount in bps.\n    /// @param _startTime The start time of the auction, in seconds since unix epoch.\n    /// @param _endTime The end time of the auction, in seconds since unix epoch.\n    /// @param _permissionedQuantity The quantity of tokens that require a signature to buy.\n    /// @param _signerAddress signer address.\n    /// @param _editionId The expected edition ID\n    /// @param _baseURI The base URI for the edition\n    function createEdition(\n        address payable _fundingRecipient,\n        uint256 _price,\n        uint32 _quantity,\n        uint32 _royaltyBPS,\n        uint32 _startTime,\n        uint32 _endTime,\n        uint32 _permissionedQuantity,\n        address _signerAddress,\n        uint256 _editionId,\n        string memory _baseURI\n    ) external checkPermission(ADMIN_ROLE) {\n        require(_quantity > 0, 'Must set quantity');\n        require(_fundingRecipient != address(0), 'Must set fundingRecipient');\n        require(_endTime > _startTime, 'End time must be greater than start time');\n        require(_editionId == atEditionId.current(), 'Wrong edition ID');\n\n        if (_permissionedQuantity > 0) {\n            require(_signerAddress != address(0), 'Signer address cannot be 0');\n        }\n\n        editions[atEditionId.current()] = Edition({\n            fundingRecipient: _fundingRecipient,\n            price: _price,\n            numSold: 0,\n            quantity: _quantity,\n            royaltyBPS: _royaltyBPS,\n            startTime: _startTime,\n            endTime: _endTime,\n            permissionedQuantity: _permissionedQuantity,\n            signerAddress: _signerAddress,\n            baseURI: _baseURI\n        });\n\n        emit EditionCreated(\n            atEditionId.current(),\n            _fundingRecipient,\n            _price,\n            _quantity,\n            _royaltyBPS,\n            _startTime,\n            _endTime,\n            _permissionedQuantity,\n            _signerAddress\n        );\n\n        atEditionId.increment();\n    }\n\n    /// @notice Creates a new token for the given edition, and assigns it to the buyer\n    /// @param _editionId The id of the edition to purchase\n    /// @param _signature A signed message for authorizing permissioned purchases\n    /// @param _ticketNumber Ticket number required for validating this buyer hasn't already bought.\n    function buyEdition(\n        uint256 _editionId,\n        bytes calldata _signature,\n        uint256 _ticketNumber\n    ) external payable {\n        // Caching variables locally to reduce reads\n        uint256 price = editions[_editionId].price;\n        uint32 quantity = editions[_editionId].quantity;\n        uint32 numSold = editions[_editionId].numSold;\n        uint32 newNumSold = numSold + 1;\n        uint32 startTime = editions[_editionId].startTime;\n        uint32 endTime = editions[_editionId].endTime;\n        uint32 permissionedQuantity = editions[_editionId].permissionedQuantity;\n\n        // Check that the edition exists. Note: this is redundant\n        // with the next check, but it is useful for clearer error messaging.\n        require(quantity > 0, 'Edition does not exist');\n        // Check that the sender is paying the correct amount.\n        require(msg.value >= price, 'Must send enough to purchase the edition.');\n        // Don't allow purchases after the end time\n        require(endTime > block.timestamp, 'Auction has ended');\n\n        // If the public auction hasn't started...\n        if (startTime > block.timestamp) {\n            // Check that permissioned tokens are still available\n            require(numSold < permissionedQuantity, 'No permissioned tokens available & open auction not started');\n\n            // Check that the signature is valid.\n            require(\n                getSigner(_signature, _editionId, _ticketNumber) == editions[_editionId].signerAddress,\n                'Invalid signer'\n            );\n        } else {\n            // Check that there are still tokens available to purchase.\n            // Only need to check this for the public sale (after the start time)\n            // so we can accomodate open editions\n            require(numSold < quantity, 'This edition is already sold out.');\n        }\n\n        // Create the token id by packing editionId in the top bits\n        uint256 tokenId;\n        unchecked {\n            tokenId = (_editionId << 128) | newNumSold;\n            // Increment the number of tokens sold for this edition.\n            editions[_editionId].numSold = newNumSold;\n        }\n\n        // If fundingRecipient is the owner (artist's wallet), update the edition's balance & don't send the funds\n        if (editions[_editionId].fundingRecipient == owner()) {\n            // Update the deposited total for the edition\n            depositedForEdition[_editionId] += msg.value;\n        } else {\n            // Send funds to the funding recipient.\n            _sendFunds(editions[_editionId].fundingRecipient, msg.value);\n        }\n\n        // Mint a new token for the sender, using the `tokenId`.\n        _mint(msg.sender, tokenId);\n\n        emit EditionPurchased(_editionId, tokenId, newNumSold, msg.sender, _ticketNumber);\n    }\n\n    /// @notice Withdraws from the Artist to the fundingRecipient for an edition\n    /// @param _editionId The id of the edition to withdraw from\n    function withdrawFunds(uint256 _editionId) external {\n        // Compute the amount available for withdrawing from this edition.\n        uint256 remainingForEdition = depositedForEdition[_editionId] - withdrawnForEdition[_editionId];\n\n        // Set the amount withdrawn to the amount deposited.\n        withdrawnForEdition[_editionId] = depositedForEdition[_editionId];\n\n        // Send the amount that was remaining for the edition, to the funding recipient.\n        _sendFunds(editions[_editionId].fundingRecipient, remainingForEdition);\n    }\n\n    /// @notice Sets the start time for an edition\n    /// @param _editionId The id of the edition to set the start time for\n    /// @param _startTime The start time to set (in seconds since unix epoch)\n    function setStartTime(uint256 _editionId, uint32 _startTime) external checkPermission(ADMIN_ROLE) {\n        editions[_editionId].startTime = _startTime;\n        emit AuctionTimeSet(TimeType.START, _editionId, _startTime);\n    }\n\n    /// @notice Sets the end time for an edition\n    /// @param _editionId The id of the edition to set the end time for\n    /// @param _endTime The end time to set (in seconds since unix epoch)\n    function setEndTime(uint256 _editionId, uint32 _endTime) external checkPermission(ADMIN_ROLE) {\n        editions[_editionId].endTime = _endTime;\n        emit AuctionTimeSet(TimeType.END, _editionId, _endTime);\n    }\n\n    /// @notice Sets the signature address of an edition\n    /// @param _editionId The edition id to set the signature address for\n    /// @param _newSignerAddress The address that will be used to sign purchases\n    function setSignerAddress(uint256 _editionId, address _newSignerAddress) external checkPermission(ADMIN_ROLE) {\n        require(_newSignerAddress != address(0), 'Signer address cannot be 0');\n\n        editions[_editionId].signerAddress = _newSignerAddress;\n        emit SignerAddressSet(_editionId, _newSignerAddress);\n    }\n\n    /// @notice Sets the permissioned quantity for an edition\n    /// @param _editionId The edition id to set the permissioned quantity for\n    /// @param _permissionedQuantity The new permissiond quantity\n    function setPermissionedQuantity(uint256 _editionId, uint32 _permissionedQuantity)\n        external\n        checkPermission(ADMIN_ROLE)\n    {\n        // Prevent setting to permissioned quantity when there is no signer address\n        require(editions[_editionId].signerAddress != address(0), 'Edition must have a signer');\n\n        editions[_editionId].permissionedQuantity = _permissionedQuantity;\n        emit PermissionedQuantitySet(_editionId, _permissionedQuantity);\n    }\n\n    /// @notice Sets a new owner, only callable by current owner or the soundRecoveryAddress (ie: gnosis safe)\n    /// @param _newOwner The new owner of the contract\n    function setOwnerOverride(address _newOwner) external {\n        require(_msgSender() == soundRecoveryAddress() || _msgSender() == owner(), 'unauthorized');\n\n        super._transferOwnership(_newOwner);\n    }\n\n    /// @notice Sets the base URI for an edition\n    /// @param _editionId The target edition's id\n    /// @param _baseURI The new base URI\n    function setEditionBaseURI(uint256 _editionId, string calldata _baseURI) external checkPermission(ADMIN_ROLE) {\n        require(\n            editions[_editionId].quantity > 0 || editions[_editionId].permissionedQuantity > 0,\n            'Nonexistent edition'\n        );\n\n        editions[_editionId].baseURI = _baseURI;\n\n        emit BaseURISet(_editionId, _baseURI);\n    }\n\n    // ================================\n    // VIEW FUNCTIONS\n    // ================================\n\n    /// @notice Returns token URI (metadata URL). e.g. https://sound.xyz/api/metadata/[contractAddress]/[tokenId]/metadata.json\n    /// @dev Concatenate the baseURI and tokenId, to create URI.\n    function tokenURI(uint256 _tokenId) public view override returns (string memory) {\n        require(_exists(_tokenId), 'ERC721Metadata: URI query for nonexistent token');\n\n        uint256 editionId = tokenToEdition(_tokenId);\n\n        string memory editionBaseURI = editions[editionId].baseURI;\n\n        // If the edition has a baseURI, it means this edition is on permastorage\n        // Using 3 as the length in case it gets accidentally set to empty space\n        if (bytes(editionBaseURI).length > 3) {\n            return string.concat(editionBaseURI, Strings.toString(_tokenId), '/metadata.json');\n        }\n\n        return string.concat(_contractBaseURI(), Strings.toString(_tokenId));\n    }\n\n    /// @notice Returns contract URI used by Opensea. e.g. https://sound.xyz/api/metadata/[contractAddress]/storefront\n    function contractURI() public view returns (string memory) {\n        return string.concat(_contractBaseURI(), 'storefront');\n    }\n\n    /// @notice Get royalty information for token\n    /// @param _tokenId token id\n    /// @param _salePrice Sale price for the token\n    function royaltyInfo(uint256 _tokenId, uint256 _salePrice)\n        external\n        view\n        override\n        returns (address fundingRecipient, uint256 royaltyAmount)\n    {\n        uint256 editionId = tokenToEdition(_tokenId);\n        Edition memory edition = editions[editionId];\n\n        if (edition.fundingRecipient == address(0x0)) {\n            return (edition.fundingRecipient, 0);\n        }\n\n        uint256 royaltyBPS = uint256(edition.royaltyBPS);\n\n        return (edition.fundingRecipient, (_salePrice * royaltyBPS) / 10_000);\n    }\n\n    /// @notice The total number of tokens created by this contract\n    function totalSupply() external view returns (uint256) {\n        uint256 total = 0;\n        for (uint256 id = 1; id < atEditionId.current(); id++) {\n            total += editions[id].numSold;\n        }\n        return total;\n    }\n\n    /// @notice Informs other contracts which interfaces this contract supports\n    /// @param _interfaceId The interface id to check\n    /// @dev https://eips.ethereum.org/EIPS/eip-165\n    function supportsInterface(bytes4 _interfaceId)\n        public\n        view\n        override(ERC721Upgradeable, IERC165Upgradeable)\n        returns (bool)\n    {\n        return\n            type(IERC2981Upgradeable).interfaceId == _interfaceId || ERC721Upgradeable.supportsInterface(_interfaceId);\n    }\n\n    /// @notice returns the number of editions for this artist\n    function editionCount() external view returns (uint256) {\n        return atEditionId.current() - 1; // because atEditionId is incremented after each edition is created\n    }\n\n    /// @notice Returns the edition id for a given token id\n    /// @param _tokenId token id\n    function tokenToEdition(uint256 _tokenId) public view returns (uint256) {\n        // Check the top bits to see if the edition id is there\n        uint256 editionId = _tokenId >> 128;\n\n        // If edition ID is 0, then this edition was created before the V3 upgrade\n        if (editionId == 0) {\n            // get edition ID from storage\n            return _tokenToEdition[_tokenId];\n        }\n\n        return editionId;\n    }\n\n    /// @notice Returns a list of owner addresses for a given list of token ids\n    /// @param _tokenIds List of token ids\n    function ownersOfTokenIds(uint256[] calldata _tokenIds) external view returns (address[] memory) {\n        address[] memory owners = new address[](_tokenIds.length);\n        for (uint256 i = 0; i < _tokenIds.length; i++) {\n            owners[i] = ownerOf(_tokenIds[i]);\n        }\n        return owners;\n    }\n\n    /// @notice Returns the claimed ticket numbers for a given edition and list of ticket numbers (indexes)\n    /// @param _editionId Edition id\n    /// @param _ticketNumbers List of ticket numbers (indexes)\n    function checkTicketNumbers(uint256 _editionId, uint256[] calldata _ticketNumbers)\n        external\n        view\n        returns (bool[] memory)\n    {\n        bool[] memory claimed = new bool[](_ticketNumbers.length);\n\n        for (uint256 i = 0; i < _ticketNumbers.length; i++) {\n            (uint256 storedBit, , , ) = _getBitForTicketNumber(_editionId, _ticketNumbers[i]);\n            claimed[i] = storedBit == 1;\n        }\n\n        return claimed;\n    }\n\n    /// @notice Returns the address (ie: gnosis safe) authorized to change ownership of the contract\n    function soundRecoveryAddress() public view virtual returns (address) {\n        if (block.chainid == 1) {\n            return 0x858a92511485715Cfb754f397a7894b7724c7Abd;\n        } else if (block.chainid == 4) {\n            return 0xee35E946Dd73EF78d352454c3F915e2cA0a09d87;\n        } else {\n            revert('unsupported chain');\n        }\n    }\n\n    // ================================\n    // PRIVATE FUNCTIONS\n    // ================================\n\n    /// @notice Sends funds to an address\n    /// @param _recipient The address to send funds to\n    /// @param _amount The amount of funds to send\n    function _sendFunds(address payable _recipient, uint256 _amount) private {\n        require(address(this).balance >= _amount, 'Insufficient balance for send');\n\n        (bool success, ) = _recipient.call{value: _amount}('');\n        require(success, 'Unable to send value: recipient may have reverted');\n    }\n\n    /// @notice Gets signer address to validate permissioned purchase\n    /// @param _signature signed message\n    /// @param _editionId edition id\n    /// @param _ticketNumber ticket number to check\n    /// @return address of signer\n    /// @dev https://eips.ethereum.org/EIPS/eip-712\n    function getSigner(\n        bytes calldata _signature,\n        uint256 _editionId,\n        uint256 _ticketNumber\n    ) private returns (address) {\n        // Check that the ticket number is within the reserved range for the edition\n        // permissionedQuantity is uint32, so ticketNumber can't exceed max uint32\n        require(_ticketNumber < 2**32, 'Ticket number exceeds max');\n\n        // gets the stored bit\n        (\n            uint256 storedBit,\n            uint256 localGroup,\n            uint256 localGroupOffset,\n            uint256 ticketNumbersIdx\n        ) = _getBitForTicketNumber(_editionId, _ticketNumber);\n\n        require(storedBit == 0, 'Invalid ticket number or NFT already claimed');\n\n        // Flip the bit to 1 to indicate that the ticket has been claimed\n        ticketNumbers[_editionId][ticketNumbersIdx] = localGroup | (uint256(1) << localGroupOffset);\n\n        bytes32 digest = keccak256(\n            abi.encodePacked(\n                '\\x19\\x01',\n                DOMAIN_SEPARATOR,\n                keccak256(abi.encode(PERMISSIONED_SALE_TYPEHASH, address(this), msg.sender, _editionId, _ticketNumber))\n            )\n        );\n        return digest.recover(_signature);\n    }\n\n    /// @notice Gets the bit variables associated with a ticket number\n    /// @param _editionId edition id\n    /// @param _ticketNumber ticket number\n    function _getBitForTicketNumber(uint256 _editionId, uint256 _ticketNumber)\n        private\n        view\n        returns (\n            uint256,\n            uint256,\n            uint256,\n            uint256\n        )\n    {\n        uint256 localGroup; // the bit array for this ticket number\n        uint256 ticketNumbersIdx; // the index of the the local group\n        uint256 localGroupOffset; // the offset/index for the ticket number in the local group\n        uint256 storedBit; // the stored bit at this ticket number's index within the local group\n        unchecked {\n            ticketNumbersIdx = _ticketNumber / 256;\n            localGroupOffset = _ticketNumber % 256;\n        }\n\n        // cache the local group for efficiency\n        localGroup = ticketNumbers[_editionId][ticketNumbersIdx];\n\n        // gets the stored bit\n        storedBit = (localGroup >> localGroupOffset) & uint256(1);\n\n        return (storedBit, localGroup, localGroupOffset, ticketNumbersIdx);\n    }\n\n    function _contractBaseURI() private view returns (string memory) {\n        string memory contractAddress = Strings.toHexString(uint256(uint160(address(this))), 20);\n        if (block.chainid == 1) {\n            return string.concat('https://metadata.sound.xyz/v1/', contractAddress, '/');\n        } else {\n            return string.concat(baseURI, contractAddress, '/');\n        }\n    }\n}\n"
    },
    "contracts/ArtistV4.sol": {
      "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity ^0.8.7;\n\n/*\n               ^###############################################&5               \n               ?@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&               \n   !PPPPPPPPPPP&@@@@@@@@@@@@?!!!!!!!!!!7&@@@@@@@@@@@@@@@@@@@@@@@@BPPPPPPPPPPJ   \n   B@@@@@@@@@@@@@@@@@@@@@@@&            #@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@.  \n   B@@@@@@@@@@@@@@@@@@@@@@@&            ~55555555555&@@@@@@@@@@@@@@@@@@@@@@@@.  \n   B@@@@@@@@@@@@@@@@@@@@@@@&                        J@@@@@@@@@@@@@@@@@@@@@@@@.  \n   B@@@@@@@@@@@@@@@@@@@@@@@&~::::::::::::::::::::::.~B######################P   \n   B@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@7                           \n   5@&&&&&&&&&&&&&&&&&&&&&&@@@@@@@@@@@@@@@@@@@@@@@@@5                           \n    .......................!@@@@@@@@@@@@@@@@@@@@@@@@@&&&&&&&&&&&&&&&&&&&&&&&B   \n                           .@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@&   \n   7BBBBBBBBBBBBBBBBBBBBBBBY:^^^^^^^^^^^^^^^^^^^^^^^B@@@@@@@@@@@@@@@@@@@@@@@&   \n   B@@@@@@@@@@@@@@@@@@@@@@@&                        Y@@@@@@@@@@@@@@@@@@@@@@@&   \n   B@@@@@@@@@@@@@@@@@@@@@@@@PJYYYYYYYYY?            5@@@@@@@@@@@@@@@@@@@@@@@&   \n   B@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@:           Y@@@@@@@@@@@@@@@@@@@@@@@&   \n   !GGGGGGGGGGG&@@@@@@@@@@@@@@@@@@@@@@@@5~~~~~~~~~~~#@@@@@@@@@@@@BGGGGGGGGGGJ   \n               J@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@G               \n               ~&&&&#&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&?                 \n\n*/\n\nimport {IERC2981Upgradeable, IERC165Upgradeable} from '@openzeppelin/contracts-upgradeable/interfaces/IERC2981Upgradeable.sol';\nimport {ERC721Upgradeable} from '@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol';\nimport {OwnableUpgradeable} from '@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol';\nimport {LibUintToString} from './utils/LibUintToString.sol';\nimport {CountersUpgradeable} from '@openzeppelin/contracts-upgradeable/utils/CountersUpgradeable.sol';\nimport {ECDSA} from '@openzeppelin/contracts/utils/cryptography/ECDSA.sol';\n\n/// @title Artist\n/// @author SoundXYZ - @gigamesh & @vigneshka\n/// @notice This contract is used to create & sell song NFTs for the artist who owns the contract.\n/// @dev Started as a fork of Mirror's Editions.sol https://github.com/mirror-xyz/editions-v1/blob/main/contracts/Editions.sol\ncontract ArtistV4 is ERC721Upgradeable, IERC2981Upgradeable, OwnableUpgradeable {\n    // ================================\n    // TYPES\n    // ================================\n\n    using LibUintToString for uint256;\n    using CountersUpgradeable for CountersUpgradeable.Counter;\n    using ECDSA for bytes32;\n\n    enum TimeType {\n        START,\n        END\n    }\n\n    // ============ Structs ============\n\n    struct Edition {\n        // The account that will receive sales revenue.\n        address payable fundingRecipient;\n        // The price at which each token will be sold, in ETH.\n        uint256 price;\n        // The number of tokens sold so far.\n        uint32 numSold;\n        // The maximum number of tokens that can be sold.\n        uint32 quantity;\n        // Royalty amount in bps\n        uint32 royaltyBPS;\n        // start timestamp of auction (in seconds since unix epoch)\n        uint32 startTime;\n        // end timestamp of auction (in seconds since unix epoch)\n        uint32 endTime;\n        // quantity of permissioned tokens\n        uint32 permissionedQuantity;\n        // whitelist signer address\n        address signerAddress;\n    }\n\n    // ================================\n    // STORAGE\n    // ================================\n\n    string internal baseURI;\n\n    CountersUpgradeable.Counter private atTokenId; // DEPRECATED IN V3\n    CountersUpgradeable.Counter private atEditionId;\n\n    // Mapping of edition id to descriptive data.\n    mapping(uint256 => Edition) public editions;\n    // <DEPRECATED IN V3> Mapping of token id to edition id.\n    mapping(uint256 => uint256) private _tokenToEdition;\n    // The amount of funds that have been deposited for a given edition.\n    mapping(uint256 => uint256) public depositedForEdition;\n    // The amount of funds that have already been withdrawn for a given edition.\n    mapping(uint256 => uint256) public withdrawnForEdition;\n    // The permissioned typehash (used for checking signature validity)\n    bytes32 private constant PERMISSIONED_SALE_TYPEHASH =\n        keccak256('EditionInfo(address contractAddress,address buyerAddress,uint256 editionId,uint256 ticketNumber)');\n    // Domain separator - used to prevent replay attacks using signatures from different networks\n    bytes32 private immutable DOMAIN_SEPARATOR;\n    // Used to track which tokens have been claimed. editionId -> index -> bit array\n    mapping(uint256 => mapping(uint256 => uint256)) ticketNumbers;\n\n    // ================================\n    // EVENTS\n    // ================================\n\n    event EditionCreated(\n        uint256 indexed editionId,\n        address fundingRecipient,\n        uint256 price,\n        uint32 quantity,\n        uint32 royaltyBPS,\n        uint32 startTime,\n        uint32 endTime,\n        uint32 permissionedQuantity,\n        address signerAddress\n    );\n\n    event EditionPurchased(\n        uint256 indexed editionId,\n        uint256 indexed tokenId,\n        // `numSold` at time of purchase represents the \"serial number\" of the NFT.\n        uint32 numSold,\n        // The account that paid for and received the NFT.\n        address indexed buyer,\n        uint256 ticketNumber\n    );\n\n    event AuctionTimeSet(TimeType timeType, uint256 editionId, uint32 indexed newTime);\n\n    event SignerAddressSet(uint256 editionId, address indexed signerAddress);\n\n    event PermissionedQuantitySet(uint256 editionId, uint32 permissionedQuantity);\n\n    // ================================\n    // PUBLIC & EXTERNAL WRITABLE FUNCTIONS\n    // ================================\n\n    /// @notice Contract constructor\n    constructor() {\n        DOMAIN_SEPARATOR = keccak256(abi.encode(keccak256('EIP712Domain(uint256 chainId)'), block.chainid));\n    }\n\n    /// @notice Initializes the contract\n    /// @param _owner Owner of edition\n    /// @param _name Name of artist\n    function initialize(\n        address _owner,\n        uint256 _artistId,\n        string memory _name,\n        string memory _symbol,\n        string memory _baseURI\n    ) public initializer {\n        __ERC721_init(_name, _symbol);\n        __Ownable_init();\n\n        // Set ownership to original sender of contract call\n        transferOwnership(_owner);\n\n        // E.g. https://sound.xyz/api/metadata/[artistId]/\n        baseURI = string(abi.encodePacked(_baseURI, _artistId.toString(), '/'));\n\n        // Set edition id start to be 1 not 0\n        atEditionId.increment();\n    }\n\n    /// @notice Creates a new edition.\n    /// @param _fundingRecipient The account that will receive sales revenue.\n    /// @param _price The price at which each token will be sold, in ETH.\n    /// @param _quantity The maximum number of tokens that can be sold.\n    /// @param _royaltyBPS The royalty amount in bps.\n    /// @param _startTime The start time of the auction, in seconds since unix epoch.\n    /// @param _endTime The end time of the auction, in seconds since unix epoch.\n    /// @param _permissionedQuantity The quantity of tokens that require a signature to buy.\n    /// @param _signerAddress signer address.\n    function createEdition(\n        address payable _fundingRecipient,\n        uint256 _price,\n        uint32 _quantity,\n        uint32 _royaltyBPS,\n        uint32 _startTime,\n        uint32 _endTime,\n        uint32 _permissionedQuantity,\n        address _signerAddress\n    ) external onlyOwner {\n        require(_quantity > 0, 'Must set quantity');\n        require(_fundingRecipient != address(0), 'Must set fundingRecipient');\n        require(_endTime > _startTime, 'End time must be greater than start time');\n\n        if (_permissionedQuantity > 0) {\n            require(_signerAddress != address(0), 'Signer address cannot be 0');\n        }\n\n        editions[atEditionId.current()] = Edition({\n            fundingRecipient: _fundingRecipient,\n            price: _price,\n            numSold: 0,\n            quantity: _quantity,\n            royaltyBPS: _royaltyBPS,\n            startTime: _startTime,\n            endTime: _endTime,\n            permissionedQuantity: _permissionedQuantity,\n            signerAddress: _signerAddress\n        });\n\n        emit EditionCreated(\n            atEditionId.current(),\n            _fundingRecipient,\n            _price,\n            _quantity,\n            _royaltyBPS,\n            _startTime,\n            _endTime,\n            _permissionedQuantity,\n            _signerAddress\n        );\n\n        atEditionId.increment();\n    }\n\n    /// @notice Creates a new token for the given edition, and assigns it to the buyer\n    /// @param _editionId The id of the edition to purchase\n    /// @param _signature A signed message for authorizing permissioned purchases\n    /// @param _ticketNumber Ticket number required for validating this buyer hasn't already bought.\n    function buyEdition(\n        uint256 _editionId,\n        bytes calldata _signature,\n        uint256 _ticketNumber\n    ) external payable {\n        // Caching variables locally to reduce reads\n        uint256 price = editions[_editionId].price;\n        uint32 quantity = editions[_editionId].quantity;\n        uint32 numSold = editions[_editionId].numSold;\n        uint32 newNumSold = numSold + 1;\n        uint32 startTime = editions[_editionId].startTime;\n        uint32 endTime = editions[_editionId].endTime;\n        uint32 permissionedQuantity = editions[_editionId].permissionedQuantity;\n\n        // Check that the edition exists. Note: this is redundant\n        // with the next check, but it is useful for clearer error messaging.\n        require(quantity > 0, 'Edition does not exist');\n        // Check that the sender is paying the correct amount.\n        require(msg.value >= price, 'Must send enough to purchase the edition.');\n\n        // If the public auction hasn't started...\n        if (startTime > block.timestamp) {\n            // Check that permissioned tokens are still available\n            require(numSold < permissionedQuantity, 'No permissioned tokens available & open auction not started');\n\n            // Check that the signature is valid.\n            require(\n                getSigner(_signature, _editionId, _ticketNumber) == editions[_editionId].signerAddress,\n                'Invalid signer'\n            );\n        } else {\n            // Check that there are still tokens available to purchase.\n            // Only need to check this for the public sale (after the start time)\n            // so we can accomodate open editions\n            require(numSold < quantity, 'This edition is already sold out.');\n        }\n\n        // Don't allow purchases after the end time\n        require(endTime > block.timestamp, 'Auction has ended');\n\n        // Create the token id by packing editionId in the top bits\n        uint256 tokenId;\n        unchecked {\n            tokenId = (_editionId << 128) | newNumSold;\n            // Increment the number of tokens sold for this edition.\n            editions[_editionId].numSold = newNumSold;\n        }\n\n        // If fundingRecipient is the owner (artist's wallet), update the edition's balance & don't send the funds\n        if (editions[_editionId].fundingRecipient == owner()) {\n            // Update the deposited total for the edition\n            depositedForEdition[_editionId] += msg.value;\n        } else {\n            // Send funds to the funding recipient.\n            _sendFunds(editions[_editionId].fundingRecipient, msg.value);\n        }\n\n        // Mint a new token for the sender, using the `tokenId`.\n        _mint(msg.sender, tokenId);\n\n        emit EditionPurchased(_editionId, tokenId, newNumSold, msg.sender, _ticketNumber);\n    }\n\n    function withdrawFunds(uint256 _editionId) external {\n        // Compute the amount available for withdrawing from this edition.\n        uint256 remainingForEdition = depositedForEdition[_editionId] - withdrawnForEdition[_editionId];\n\n        // Set the amount withdrawn to the amount deposited.\n        withdrawnForEdition[_editionId] = depositedForEdition[_editionId];\n\n        // Send the amount that was remaining for the edition, to the funding recipient.\n        _sendFunds(editions[_editionId].fundingRecipient, remainingForEdition);\n    }\n\n    /// @notice Sets the start time for an edition\n    function setStartTime(uint256 _editionId, uint32 _startTime) external onlyOwner {\n        editions[_editionId].startTime = _startTime;\n        emit AuctionTimeSet(TimeType.START, _editionId, _startTime);\n    }\n\n    /// @notice Sets the end time for an edition\n    function setEndTime(uint256 _editionId, uint32 _endTime) external onlyOwner {\n        editions[_editionId].endTime = _endTime;\n        emit AuctionTimeSet(TimeType.END, _editionId, _endTime);\n    }\n\n    /// @notice Sets the signature address of an edition\n    function setSignerAddress(uint256 _editionId, address _newSignerAddress) external onlyOwner {\n        require(_newSignerAddress != address(0), 'Signer address cannot be 0');\n\n        editions[_editionId].signerAddress = _newSignerAddress;\n        emit SignerAddressSet(_editionId, _newSignerAddress);\n    }\n\n    /// @notice Sets the permissioned quantity for an edition\n    function setPermissionedQuantity(uint256 _editionId, uint32 _permissionedQuantity) external onlyOwner {\n        // Prevent setting to permissioned quantity when there is no signer address\n        require(editions[_editionId].signerAddress != address(0), 'Edition must have a signer');\n\n        editions[_editionId].permissionedQuantity = _permissionedQuantity;\n        emit PermissionedQuantitySet(_editionId, _permissionedQuantity);\n    }\n\n    // ================================\n    // VIEW FUNCTIONS\n    // ================================\n\n    /// @notice Returns token URI (metadata URL). e.g. https://sound.xyz/api/metadata/[artistId]/[editionId]/[tokenId]\n    /// @dev Concatenate the baseURI, editionId and tokenId, to create URI.\n    function tokenURI(uint256 _tokenId) public view override returns (string memory) {\n        require(_exists(_tokenId), 'ERC721Metadata: URI query for nonexistent token');\n\n        uint256 editionId = tokenToEdition(_tokenId);\n\n        return string(abi.encodePacked(baseURI, editionId.toString(), '/', _tokenId.toString()));\n    }\n\n    /// @notice Returns contract URI used by Opensea. e.g. https://sound.xyz/api/metadata/[artistId]/storefront\n    function contractURI() public view returns (string memory) {\n        return string(abi.encodePacked(baseURI, 'storefront'));\n    }\n\n    /// @notice Get royalty information for token\n    /// @param _tokenId token id\n    /// @param _salePrice Sale price for the token\n    function royaltyInfo(uint256 _tokenId, uint256 _salePrice)\n        external\n        view\n        override\n        returns (address fundingRecipient, uint256 royaltyAmount)\n    {\n        uint256 editionId = tokenToEdition(_tokenId);\n        Edition memory edition = editions[editionId];\n\n        if (edition.fundingRecipient == address(0x0)) {\n            return (edition.fundingRecipient, 0);\n        }\n\n        uint256 royaltyBPS = uint256(edition.royaltyBPS);\n\n        return (edition.fundingRecipient, (_salePrice * royaltyBPS) / 10_000);\n    }\n\n    /// @notice The total number of tokens created by this contract\n    function totalSupply() external view returns (uint256) {\n        uint256 total = 0;\n        for (uint256 id = 1; id < atEditionId.current(); id++) {\n            total += editions[id].numSold;\n        }\n        return total;\n    }\n\n    /// @notice Informs other contracts which interfaces this contract supports\n    /// @dev https://eips.ethereum.org/EIPS/eip-165\n    function supportsInterface(bytes4 _interfaceId)\n        public\n        view\n        override(ERC721Upgradeable, IERC165Upgradeable)\n        returns (bool)\n    {\n        return\n            type(IERC2981Upgradeable).interfaceId == _interfaceId || ERC721Upgradeable.supportsInterface(_interfaceId);\n    }\n\n    /// @notice returns the number of editions for this artist\n    function editionCount() external view returns (uint256) {\n        return atEditionId.current() - 1; // because atEditionId is incremented after each edition is created\n    }\n\n    /// @notice Returns the edition id for a given token id\n    /// @param _tokenId token id\n    function tokenToEdition(uint256 _tokenId) public view returns (uint256) {\n        // Check the top bits to see if the edition id is there\n        uint256 editionId = _tokenId >> 128;\n\n        // If edition ID is 0, then this edition was created before the V3 upgrade\n        if (editionId == 0) {\n            // get edition ID from storage\n            return _tokenToEdition[_tokenId];\n        }\n\n        return editionId;\n    }\n\n    /// @notice Returns a list of owner addresses for a given list of token ids\n    /// @param _tokenIds List of token ids\n    function ownersOfTokenIds(uint256[] calldata _tokenIds) external view returns (address[] memory) {\n        address[] memory owners = new address[](_tokenIds.length);\n        for (uint256 i = 0; i < _tokenIds.length; i++) {\n            owners[i] = ownerOf(_tokenIds[i]);\n        }\n        return owners;\n    }\n\n    function checkTicketNumbers(uint256 _editionId, uint256[] calldata _ticketNumbers)\n        external\n        view\n        returns (bool[] memory)\n    {\n        bool[] memory claimed = new bool[](_ticketNumbers.length);\n\n        for (uint256 i = 0; i < _ticketNumbers.length; i++) {\n            (uint256 storedBit, , , ) = _getBitForTicketNumber(_editionId, _ticketNumbers[i]);\n            claimed[i] = storedBit == 1;\n        }\n\n        return claimed;\n    }\n\n    // ================================\n    // PRIVATE FUNCTIONS\n    // ================================\n\n    /// @notice Sends funds to an address\n    /// @param _recipient The address to send funds to\n    /// @param _amount The amount of funds to send\n    function _sendFunds(address payable _recipient, uint256 _amount) private {\n        require(address(this).balance >= _amount, 'Insufficient balance for send');\n\n        (bool success, ) = _recipient.call{value: _amount}('');\n        require(success, 'Unable to send value: recipient may have reverted');\n    }\n\n    /// @notice Gets signer address to validate permissioned purchase\n    /// @param _signature signed message\n    /// @param _editionId edition id\n    /// @return address of signer\n    /// @dev https://eips.ethereum.org/EIPS/eip-712\n    function getSigner(\n        bytes calldata _signature,\n        uint256 _editionId,\n        uint256 _ticketNumber\n    ) private returns (address) {\n        // Check that the ticket number is within the reserved range for the edition\n        // permissionedQuantity is uint32, so ticketNumber can't exceed max uint32\n        require(_ticketNumber < 2**32, 'Ticket number exceeds max');\n\n        // gets the stored bit\n        (\n            uint256 storedBit,\n            uint256 localGroup,\n            uint256 localGroupOffset,\n            uint256 ticketNumbersIdx\n        ) = _getBitForTicketNumber(_editionId, _ticketNumber);\n\n        require(storedBit == 0, 'Invalid ticket number or NFT already claimed');\n\n        // Flip the bit to 1 to indicate that the ticket has been claimed\n        ticketNumbers[_editionId][ticketNumbersIdx] = localGroup | (uint256(1) << localGroupOffset);\n\n        bytes32 digest = keccak256(\n            abi.encodePacked(\n                '\\x19\\x01',\n                DOMAIN_SEPARATOR,\n                keccak256(abi.encode(PERMISSIONED_SALE_TYPEHASH, address(this), msg.sender, _editionId, _ticketNumber))\n            )\n        );\n        return digest.recover(_signature);\n    }\n\n    /// @notice Gets the bit variables associated with a ticket number\n    /// @param _editionId edition id\n    /// @param _ticketNumber ticket number\n    function _getBitForTicketNumber(uint256 _editionId, uint256 _ticketNumber)\n        private\n        view\n        returns (\n            uint256,\n            uint256,\n            uint256,\n            uint256\n        )\n    {\n        uint256 localGroup; // the bit array for this ticket number\n        uint256 ticketNumbersIdx; // the index of the the local group\n        uint256 localGroupOffset; // the offset/index for the ticket number in the local group\n        uint256 storedBit; // the stored bit at this ticket number's index within the local group\n        unchecked {\n            ticketNumbersIdx = _ticketNumber / 256;\n            localGroupOffset = _ticketNumber % 256;\n        }\n\n        // cache the local group for efficiency\n        localGroup = ticketNumbers[_editionId][ticketNumbersIdx];\n\n        // gets the stored bit\n        storedBit = (localGroup >> localGroupOffset) & uint256(1);\n\n        return (storedBit, localGroup, localGroupOffset, ticketNumbersIdx);\n    }\n}\n"
    },
    "contracts/utils/LibUintToString.sol": {
      "content": "//SPDX-License-Identifier: Unlicense\npragma solidity ^0.8.0;\n\nlibrary LibUintToString {\n    uint256 private constant MAX_UINT256_STRING_LENGTH = 78;\n    uint8 private constant ASCII_DIGIT_OFFSET = 48;\n\n    /// @dev Converts a `uint256` value to a string.\n    /// @param n The integer to convert.\n    /// @return nstr `n` as a decimal string.\n    function toString(uint256 n) internal pure returns (string memory nstr) {\n        if (n == 0) {\n            return '0';\n        }\n        // Overallocate memory\n        nstr = new string(MAX_UINT256_STRING_LENGTH);\n        uint256 k = MAX_UINT256_STRING_LENGTH;\n        // Populate string from right to left (lsb to msb).\n        while (n != 0) {\n            assembly {\n                let char := add(ASCII_DIGIT_OFFSET, mod(n, 10))\n                mstore(add(nstr, k), char)\n                k := sub(k, 1)\n                n := div(n, 10)\n            }\n        }\n        assembly {\n            // Shift pointer over to actual start of string.\n            nstr := add(nstr, k)\n            // Store actual string length.\n            mstore(nstr, sub(MAX_UINT256_STRING_LENGTH, k))\n        }\n        return nstr;\n    }\n}\n"
    },
    "contracts/ArtistV3.sol": {
      "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity ^0.8.7;\n\n/*\n ██████  ██████  ██    ██ ███    ██ ██████  \n██      ██    ██ ██    ██ ████   ██ ██   ██ \n███████ ██    ██ ██    ██ ██ ██  ██ ██   ██ \n     ██ ██    ██ ██    ██ ██  ██ ██ ██   ██ \n███████  ██████   ██████  ██   ████ ██████ \n*/\n\nimport {IERC2981Upgradeable, IERC165Upgradeable} from '@openzeppelin/contracts-upgradeable/interfaces/IERC2981Upgradeable.sol';\nimport {ERC721Upgradeable} from '@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol';\nimport {OwnableUpgradeable} from '@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol';\nimport {LibUintToString} from './utils/LibUintToString.sol';\nimport {CountersUpgradeable} from '@openzeppelin/contracts-upgradeable/utils/CountersUpgradeable.sol';\nimport {ArtistCreator} from './ArtistCreator.sol';\nimport {ECDSA} from '@openzeppelin/contracts/utils/cryptography/ECDSA.sol';\n\n/// @title Artist\n/// @author SoundXYZ - @gigamesh & @vigneshka\n/// @notice This contract is used to create & sell song NFTs for the artist who owns the contract.\n/// @dev Started as a fork of Mirror's Editions.sol https://github.com/mirror-xyz/editions-v1/blob/main/contracts/Editions.sol\ncontract ArtistV3 is ERC721Upgradeable, IERC2981Upgradeable, OwnableUpgradeable {\n    // ================================\n    // TYPES\n    // ================================\n\n    using LibUintToString for uint256;\n    using CountersUpgradeable for CountersUpgradeable.Counter;\n    using ECDSA for bytes32;\n\n    enum TimeType {\n        START,\n        END\n    }\n\n    // ============ Structs ============\n\n    struct Edition {\n        // The account that will receive sales revenue.\n        address payable fundingRecipient;\n        // The price at which each token will be sold, in ETH.\n        uint256 price;\n        // The number of tokens sold so far.\n        uint32 numSold;\n        // The maximum number of tokens that can be sold.\n        uint32 quantity;\n        // Royalty amount in bps\n        uint32 royaltyBPS;\n        // start timestamp of auction (in seconds since unix epoch)\n        uint32 startTime;\n        // end timestamp of auction (in seconds since unix epoch)\n        uint32 endTime;\n        // quantity of permissioned tokens\n        uint32 permissionedQuantity;\n        // whitelist signer address\n        address signerAddress;\n    }\n\n    // ================================\n    // STORAGE\n    // ================================\n\n    string internal baseURI;\n\n    CountersUpgradeable.Counter private atTokenId; // DEPRECATED IN V3\n    CountersUpgradeable.Counter private atEditionId;\n\n    // Mapping of edition id to descriptive data.\n    mapping(uint256 => Edition) public editions;\n    // <DEPRECATED IN V3> Mapping of token id to edition id.\n    mapping(uint256 => uint256) private _tokenToEdition;\n    // The amount of funds that have been deposited for a given edition.\n    mapping(uint256 => uint256) public depositedForEdition;\n    // The amount of funds that have already been withdrawn for a given edition.\n    mapping(uint256 => uint256) public withdrawnForEdition;\n    // The permissioned typehash (used for checking signature validity)\n    bytes32 private constant PERMISSIONED_SALE_TYPEHASH =\n        keccak256('EditionInfo(address contractAddress,address buyerAddress,uint256 editionId)');\n    bytes32 private immutable DOMAIN_SEPARATOR;\n\n    // ================================\n    // EVENTS\n    // ================================\n\n    event EditionCreated(\n        uint256 indexed editionId,\n        address fundingRecipient,\n        uint256 price,\n        uint32 quantity,\n        uint32 royaltyBPS,\n        uint32 startTime,\n        uint32 endTime,\n        uint32 permissionedQuantity,\n        address signerAddress\n    );\n\n    event EditionPurchased(\n        uint256 indexed editionId,\n        uint256 indexed tokenId,\n        // `numSold` at time of purchase represents the \"serial number\" of the NFT.\n        uint32 numSold,\n        // The account that paid for and received the NFT.\n        address indexed buyer\n    );\n\n    event AuctionTimeSet(TimeType timeType, uint256 editionId, uint32 indexed newTime);\n\n    event SignerAddressSet(uint256 editionId, address indexed signerAddress);\n\n    event PermissionedQuantitySet(uint256 editionId, uint32 permissionedQuantity);\n\n    // ================================\n    // PUBLIC & EXTERNAL WRITABLE FUNCTIONS\n    // ================================\n\n    /// @notice Contract constructor\n    constructor() {\n        DOMAIN_SEPARATOR = keccak256(abi.encode(keccak256('EIP712Domain(uint256 chainId)'), block.chainid));\n    }\n\n    /// @notice Initializes the contract\n    /// @param _owner Owner of edition\n    /// @param _name Name of artist\n    function initialize(\n        address _owner,\n        uint256 _artistId,\n        string memory _name,\n        string memory _symbol,\n        string memory _baseURI\n    ) public initializer {\n        __ERC721_init(_name, _symbol);\n        __Ownable_init();\n\n        // Set ownership to original sender of contract call\n        transferOwnership(_owner);\n\n        // E.g. https://sound.xyz/api/metadata/[artistId]/\n        baseURI = string(abi.encodePacked(_baseURI, _artistId.toString(), '/'));\n\n        // Set edition id start to be 1 not 0\n        atEditionId.increment();\n    }\n\n    /// @notice Creates a new edition.\n    /// @param _fundingRecipient The account that will receive sales revenue.\n    /// @param _price The price at which each token will be sold, in ETH.\n    /// @param _quantity The maximum number of tokens that can be sold.\n    /// @param _royaltyBPS The royalty amount in bps.\n    /// @param _startTime The start time of the auction, in seconds since unix epoch.\n    /// @param _endTime The end time of the auction, in seconds since unix epoch.\n    /// @param _permissionedQuantity The quantity of tokens that require a signature to buy.\n    /// @param _signerAddress signer address.\n    function createEdition(\n        address payable _fundingRecipient,\n        uint256 _price,\n        uint32 _quantity,\n        uint32 _royaltyBPS,\n        uint32 _startTime,\n        uint32 _endTime,\n        uint32 _permissionedQuantity,\n        address _signerAddress\n    ) external onlyOwner {\n        require(_permissionedQuantity < _quantity + 1, 'Permissioned quantity too big');\n        require(_quantity > 0, 'Must set quantity');\n        require(_fundingRecipient != address(0), 'Must set fundingRecipient');\n        require(_endTime > _startTime, 'End time must be greater than start time');\n\n        if (_permissionedQuantity > 0) {\n            require(_signerAddress != address(0), 'Signer address cannot be 0');\n        }\n\n        editions[atEditionId.current()] = Edition({\n            fundingRecipient: _fundingRecipient,\n            price: _price,\n            numSold: 0,\n            quantity: _quantity,\n            royaltyBPS: _royaltyBPS,\n            startTime: _startTime,\n            endTime: _endTime,\n            permissionedQuantity: _permissionedQuantity,\n            signerAddress: _signerAddress\n        });\n\n        emit EditionCreated(\n            atEditionId.current(),\n            _fundingRecipient,\n            _price,\n            _quantity,\n            _royaltyBPS,\n            _startTime,\n            _endTime,\n            _permissionedQuantity,\n            _signerAddress\n        );\n\n        atEditionId.increment();\n    }\n\n    /// @notice Creates a new token for the given edition, and assigns it to the buyer\n    /// @param _editionId The id of the edition to purchase\n    /// @param _signature A signed message for authorizing permissioned purchases\n    function buyEdition(uint256 _editionId, bytes calldata _signature) external payable {\n        // Caching variables locally to reduce reads\n        uint256 price = editions[_editionId].price;\n        uint32 quantity = editions[_editionId].quantity;\n        uint32 numSold = editions[_editionId].numSold;\n        uint32 startTime = editions[_editionId].startTime;\n        uint32 endTime = editions[_editionId].endTime;\n        uint32 permissionedQuantity = editions[_editionId].permissionedQuantity;\n\n        // Check that the edition exists. Note: this is redundant\n        // with the next check, but it is useful for clearer error messaging.\n        require(quantity > 0, 'Edition does not exist');\n        // Check that there are still tokens available to purchase.\n        require(numSold < quantity, 'This edition is already sold out.');\n        // Check that the sender is paying the correct amount.\n        require(msg.value >= price, 'Must send enough to purchase the edition.');\n\n        // If the open auction hasn't started...\n        if (startTime > block.timestamp) {\n            // Check that permissioned tokens are still available\n            require(\n                permissionedQuantity > 0 && numSold < permissionedQuantity,\n                'No permissioned tokens available & open auction not started'\n            );\n\n            // Check that the signature is valid.\n            require(getSigner(_signature, _editionId) == editions[_editionId].signerAddress, 'Invalid signer');\n        }\n\n        // Don't allow purchases after the end time\n        require(endTime > block.timestamp, 'Auction has ended');\n\n        // Create the token id by packing editionId in the top bits\n        uint256 tokenId;\n        unchecked {\n            tokenId = (_editionId << 128) | (numSold + 1);\n            // Increment the number of tokens sold for this edition.\n            editions[_editionId].numSold = numSold + 1;\n        }\n\n        // If fundingRecipient is the owner (artist's wallet), update the edition's balance & don't send the funds\n        if (editions[_editionId].fundingRecipient == owner()) {\n            // Update the deposited total for the edition\n            depositedForEdition[_editionId] += msg.value;\n        } else {\n            // Send funds to the funding recipient.\n            _sendFunds(editions[_editionId].fundingRecipient, msg.value);\n        }\n\n        // Mint a new token for the sender, using the `tokenId`.\n        _mint(msg.sender, tokenId);\n\n        emit EditionPurchased(_editionId, tokenId, editions[_editionId].numSold, msg.sender);\n    }\n\n    function withdrawFunds(uint256 _editionId) external {\n        // Compute the amount available for withdrawing from this edition.\n        uint256 remainingForEdition = depositedForEdition[_editionId] - withdrawnForEdition[_editionId];\n\n        // Set the amount withdrawn to the amount deposited.\n        withdrawnForEdition[_editionId] = depositedForEdition[_editionId];\n\n        // Send the amount that was remaining for the edition, to the funding recipient.\n        _sendFunds(editions[_editionId].fundingRecipient, remainingForEdition);\n    }\n\n    /// @notice Sets the start time for an edition\n    function setStartTime(uint256 _editionId, uint32 _startTime) external onlyOwner {\n        editions[_editionId].startTime = _startTime;\n        emit AuctionTimeSet(TimeType.START, _editionId, _startTime);\n    }\n\n    /// @notice Sets the end time for an edition\n    function setEndTime(uint256 _editionId, uint32 _endTime) external onlyOwner {\n        editions[_editionId].endTime = _endTime;\n        emit AuctionTimeSet(TimeType.END, _editionId, _endTime);\n    }\n\n    /// @notice Sets the signature address of an edition\n    function setSignerAddress(uint256 _editionId, address _newSignerAddress) external onlyOwner {\n        require(_newSignerAddress != address(0), 'Signer address cannot be 0');\n\n        editions[_editionId].signerAddress = _newSignerAddress;\n        emit SignerAddressSet(_editionId, _newSignerAddress);\n    }\n\n    /// @notice Sets the permissioned quantity for an edition\n    function setPermissionedQuantity(uint256 _editionId, uint32 _permissionedQuantity) external onlyOwner {\n        // Check that the permissioned quantity is less than the total quantity\n        require(_permissionedQuantity < editions[_editionId].quantity + 1, 'Must not exceed quantity');\n        // Prevent setting to permissioned quantity when there is no signer address\n        require(editions[_editionId].signerAddress != address(0), 'Edition must have a signer');\n\n        editions[_editionId].permissionedQuantity = _permissionedQuantity;\n        emit PermissionedQuantitySet(_editionId, _permissionedQuantity);\n    }\n\n    // ================================\n    // VIEW FUNCTIONS\n    // ================================\n\n    /// @notice Returns token URI (metadata URL). e.g. https://sound.xyz/api/metadata/[artistId]/[editionId]/[tokenId]\n    /// @dev Concatenate the baseURI, editionId and tokenId, to create URI.\n    function tokenURI(uint256 _tokenId) public view override returns (string memory) {\n        require(_exists(_tokenId), 'ERC721Metadata: URI query for nonexistent token');\n\n        uint256 editionId = tokenToEdition(_tokenId);\n\n        return string(abi.encodePacked(baseURI, editionId.toString(), '/', _tokenId.toString()));\n    }\n\n    /// @notice Returns contract URI used by Opensea. e.g. https://sound.xyz/api/metadata/[artistId]/storefront\n    function contractURI() public view returns (string memory) {\n        return string(abi.encodePacked(baseURI, 'storefront'));\n    }\n\n    /// @notice Get royalty information for token\n    /// @param _tokenId token id\n    /// @param _salePrice Sale price for the token\n    function royaltyInfo(uint256 _tokenId, uint256 _salePrice)\n        external\n        view\n        override\n        returns (address fundingRecipient, uint256 royaltyAmount)\n    {\n        uint256 editionId = tokenToEdition(_tokenId);\n        Edition memory edition = editions[editionId];\n\n        if (edition.fundingRecipient == address(0x0)) {\n            return (edition.fundingRecipient, 0);\n        }\n\n        uint256 royaltyBPS = uint256(edition.royaltyBPS);\n\n        return (edition.fundingRecipient, (_salePrice * royaltyBPS) / 10_000);\n    }\n\n    /// @notice The total number of tokens created by this contract\n    function totalSupply() external view returns (uint256) {\n        uint256 total = 0;\n        for (uint256 id = 1; id < atEditionId.current(); id++) {\n            total += editions[id].numSold;\n        }\n        return total;\n    }\n\n    /// @notice Informs other contracts which interfaces this contract supports\n    /// @dev https://eips.ethereum.org/EIPS/eip-165\n    function supportsInterface(bytes4 _interfaceId)\n        public\n        view\n        override(ERC721Upgradeable, IERC165Upgradeable)\n        returns (bool)\n    {\n        return\n            type(IERC2981Upgradeable).interfaceId == _interfaceId || ERC721Upgradeable.supportsInterface(_interfaceId);\n    }\n\n    /// @notice returns the number of editions for this artist\n    function editionCount() external view returns (uint256) {\n        return atEditionId.current() - 1; // because atEditionId is incremented after each edition is created\n    }\n\n    function tokenToEdition(uint256 _tokenId) public view returns (uint256) {\n        // Check the top bits to see if the edition id is there\n        uint256 editionId = _tokenId >> 128;\n\n        // If edition ID is 0, then this edition was created before the V3 upgrade\n        if (editionId == 0) {\n            // get edition ID from storage\n            return _tokenToEdition[_tokenId];\n        }\n\n        return editionId;\n    }\n\n    function ownersOfTokenIds(uint256[] calldata _tokenIds) external view returns (address[] memory) {\n        address[] memory owners = new address[](_tokenIds.length);\n        for (uint256 i = 0; i < _tokenIds.length; i++) {\n            owners[i] = ownerOf(_tokenIds[i]);\n        }\n        return owners;\n    }\n\n    // ================================\n    // FUNCTIONS - PRIVATE\n    // ================================\n\n    /// @notice Sends funds to an address\n    /// @param _recipient The address to send funds to\n    /// @param _amount The amount of funds to send\n    function _sendFunds(address payable _recipient, uint256 _amount) private {\n        require(address(this).balance >= _amount, 'Insufficient balance for send');\n\n        (bool success, ) = _recipient.call{value: _amount}('');\n        require(success, 'Unable to send value: recipient may have reverted');\n    }\n\n    /// @notice Gets signer address to validate permissioned purchase\n    /// @param _signature signed message\n    /// @param _editionId edition id\n    /// @return address of signer\n    /// @dev https://eips.ethereum.org/EIPS/eip-712\n    function getSigner(bytes calldata _signature, uint256 _editionId) private view returns (address) {\n        bytes32 digest = keccak256(\n            abi.encodePacked(\n                '\\x19\\x01',\n                DOMAIN_SEPARATOR,\n                keccak256(abi.encode(PERMISSIONED_SALE_TYPEHASH, address(this), msg.sender, _editionId))\n            )\n        );\n        address recoveredAddress = digest.recover(_signature);\n        return recoveredAddress;\n    }\n}\n"
    },
    "contracts/ArtistCreator.sol": {
      "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity ^0.8.7;\n\n/*\n ██████  ██████  ██    ██ ███    ██ ██████  \n██      ██    ██ ██    ██ ████   ██ ██   ██ \n███████ ██    ██ ██    ██ ██ ██  ██ ██   ██ \n     ██ ██    ██ ██    ██ ██  ██ ██ ██   ██ \n███████  ██████   ██████  ██   ████ ██████ \n*/\n\nimport '@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol';\nimport '@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol';\nimport '@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol';\nimport '@openzeppelin/contracts-upgradeable/utils/CountersUpgradeable.sol';\nimport '@openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol';\nimport '@openzeppelin/contracts/proxy/beacon/BeaconProxy.sol';\nimport '@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol';\nimport './Artist.sol';\n\ncontract ArtistCreator is Initializable, UUPSUpgradeable, OwnableUpgradeable {\n    using CountersUpgradeable for CountersUpgradeable.Counter;\n    using ECDSAUpgradeable for bytes32;\n\n    // ============ Storage ============\n\n    bytes32 public constant MINTER_TYPEHASH = keccak256('Deployer(address artistWallet)');\n    CountersUpgradeable.Counter private atArtistId;\n    // address used for signature verification, changeable by owner\n    address public admin;\n    bytes32 public DOMAIN_SEPARATOR;\n    address public beaconAddress;\n    // registry of created contracts\n    address[] public artistContracts;\n\n    // ============ Events ============\n\n    /// Emitted when an Artist is created\n    event CreatedArtist(uint256 artistId, string name, string symbol, address indexed artistAddress);\n\n    // ============ Functions ============\n\n    /// Initializes factory\n    function initialize() public initializer {\n        __Ownable_init_unchained();\n\n        // set admin for artist deployment authorization\n        admin = msg.sender;\n        DOMAIN_SEPARATOR = keccak256(abi.encode(keccak256('EIP712Domain(uint256 chainId)'), block.chainid));\n\n        // set up beacon with msg.sender as the owner\n        UpgradeableBeacon _beacon = new UpgradeableBeacon(address(new Artist()));\n        _beacon.transferOwnership(msg.sender);\n        beaconAddress = address(_beacon);\n\n        // Set artist id start to be 1 not 0\n        atArtistId.increment();\n    }\n\n    /// Creates a new artist contract as a factory with a deterministic address\n    /// Important: None of these fields (except the Url fields with the same hash) can be changed after calling\n    /// @param _name Name of the artist\n    function createArtist(\n        bytes calldata signature,\n        string memory _name,\n        string memory _symbol,\n        string memory _baseURI\n    ) public returns (address) {\n        require((getSigner(signature) == admin), 'invalid authorization signature');\n\n        BeaconProxy proxy = new BeaconProxy(\n            beaconAddress,\n            abi.encodeWithSelector(\n                Artist(address(0)).initialize.selector,\n                msg.sender,\n                atArtistId.current(),\n                _name,\n                _symbol,\n                _baseURI\n            )\n        );\n\n        // add to registry\n        artistContracts.push(address(proxy));\n\n        emit CreatedArtist(atArtistId.current(), _name, _symbol, address(proxy));\n\n        atArtistId.increment();\n\n        return address(proxy);\n    }\n\n    /// Get signer address of signature\n    function getSigner(bytes calldata signature) public view returns (address) {\n        require(admin != address(0), 'whitelist not enabled');\n        // Verify EIP-712 signature by recreating the data structure\n        // that we signed on the client side, and then using that to recover\n        // the address that signed the signature for this data.\n        bytes32 digest = keccak256(\n            abi.encodePacked('\\x19\\x01', DOMAIN_SEPARATOR, keccak256(abi.encode(MINTER_TYPEHASH, msg.sender)))\n        );\n        // Use the recover method to see what address was used to create\n        // the signature on this data.\n        // Note that if the digest doesn't exactly match what was signed we'll\n        // get a random recovered address.\n        address recoveredAddress = digest.recover(signature);\n        return recoveredAddress;\n    }\n\n    /// Sets the admin for authorizing artist deployment\n    /// @param _newAdmin address of new admin\n    function setAdmin(address _newAdmin) external {\n        require(owner() == _msgSender() || admin == _msgSender(), 'invalid authorization');\n        admin = _newAdmin;\n    }\n\n    function _authorizeUpgrade(address) internal override onlyOwner {}\n}\n"
    },
    "contracts/ArtistV2.sol": {
      "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity ^0.8.7;\n\n/*\n ██████  ██████  ██    ██ ███    ██ ██████  \n██      ██    ██ ██    ██ ████   ██ ██   ██ \n███████ ██    ██ ██    ██ ██ ██  ██ ██   ██ \n     ██ ██    ██ ██    ██ ██  ██ ██ ██   ██ \n███████  ██████   ██████  ██   ████ ██████ \n*/\n\nimport {IERC2981Upgradeable, IERC165Upgradeable} from '@openzeppelin/contracts-upgradeable/interfaces/IERC2981Upgradeable.sol';\nimport {ERC721Upgradeable} from '@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol';\nimport {OwnableUpgradeable} from '@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol';\nimport {Strings} from '@openzeppelin/contracts/utils/Strings.sol';\nimport {CountersUpgradeable} from '@openzeppelin/contracts-upgradeable/utils/CountersUpgradeable.sol';\nimport {ArtistCreator} from './ArtistCreator.sol';\nimport {ECDSA} from '@openzeppelin/contracts/utils/cryptography/ECDSA.sol';\n\n/// @title Artist\n/// @author SoundXYZ - @gigamesh & @vigneshka\n/// @notice This contract is used to create & sell song NFTs for the artist who owns the contract.\n/// @dev Started as a fork of Mirror's Editions.sol https://github.com/mirror-xyz/editions-v1/blob/main/contracts/Editions.sol\ncontract ArtistV2 is ERC721Upgradeable, IERC2981Upgradeable, OwnableUpgradeable {\n    // ================================\n    // TYPES\n    // ================================\n\n    using Strings for uint256;\n    using CountersUpgradeable for CountersUpgradeable.Counter;\n    using ECDSA for bytes32;\n\n    enum TimeType {\n        START,\n        END\n    }\n\n    // ============ Structs ============\n\n    struct Edition {\n        // The account that will receive sales revenue.\n        address payable fundingRecipient;\n        // The price at which each token will be sold, in ETH.\n        uint256 price;\n        // The number of tokens sold so far.\n        uint32 numSold;\n        // The maximum number of tokens that can be sold.\n        uint32 quantity;\n        // Royalty amount in bps\n        uint32 royaltyBPS;\n        // start timestamp of auction (in seconds since unix epoch)\n        uint32 startTime;\n        // end timestamp of auction (in seconds since unix epoch)\n        uint32 endTime;\n        // quantity of presale tokens\n        uint32 presaleQuantity;\n        // whitelist signer address\n        address signerAddress;\n    }\n\n    // ================================\n    // STORAGE\n    // ================================\n\n    string internal baseURI;\n\n    CountersUpgradeable.Counter private atTokenId;\n    CountersUpgradeable.Counter private atEditionId;\n\n    // Mapping of edition id to descriptive data.\n    mapping(uint256 => Edition) public editions;\n    // Mapping of token id to edition id.\n    mapping(uint256 => uint256) public tokenToEdition;\n    // The amount of funds that have been deposited for a given edition.\n    mapping(uint256 => uint256) public depositedForEdition;\n    // The amount of funds that have already been withdrawn for a given edition.\n    mapping(uint256 => uint256) public withdrawnForEdition;\n    // The presale typehash (used for checking signature validity)\n    bytes32 public constant PRESALE_TYPEHASH =\n        keccak256('EditionInfo(address contractAddress,address buyerAddress,uint256 editionId)');\n\n    // ================================\n    // EVENTS\n    // ================================\n\n    event EditionCreated(\n        uint256 indexed editionId,\n        address fundingRecipient,\n        uint256 price,\n        uint32 quantity,\n        uint32 royaltyBPS,\n        uint32 startTime,\n        uint32 endTime,\n        uint32 presaleQuantity,\n        address signerAddress\n    );\n\n    event EditionPurchased(\n        uint256 indexed editionId,\n        uint256 indexed tokenId,\n        // `numSold` at time of purchase represents the \"serial number\" of the NFT.\n        uint32 numSold,\n        // The account that paid for and received the NFT.\n        address indexed buyer\n    );\n\n    event AuctionTimeSet(TimeType timeType, uint256 editionId, uint32 indexed newTime);\n\n    // ================================\n    // FUNCTIONS - PUBLIC & EXTERNAL\n    // ================================\n\n    /// @notice Initializes the contract\n    /// @param _owner Owner of edition\n    /// @param _name Name of artist\n    function initialize(\n        address _owner,\n        uint256 _artistId,\n        string memory _name,\n        string memory _symbol,\n        string memory _baseURI\n    ) public initializer {\n        __ERC721_init(_name, _symbol);\n        __Ownable_init();\n\n        // Set ownership to original sender of contract call\n        transferOwnership(_owner);\n\n        // E.g. https://sound.xyz/api/metadata/[artistId]/\n        baseURI = string(abi.encodePacked(_baseURI, _artistId.toString(), '/'));\n\n        // Set token id start to be 1 not 0\n        atTokenId.increment();\n\n        // Set edition id start to be 1 not 0\n        atEditionId.increment();\n    }\n\n    /// @notice Creates a new edition.\n    /// @param _fundingRecipient The account that will receive sales revenue.\n    /// @param _price The price at which each token will be sold, in ETH.\n    /// @param _quantity The maximum number of tokens that can be sold.\n    /// @param _royaltyBPS The royalty amount in bps.\n    /// @param _startTime The start time of the auction, in seconds since unix epoch.\n    /// @param _endTime The end time of the auction, in seconds since unix epoch.\n    /// @param _presaleQuantity The quantity of presale tokens.\n    /// @param _signerAddress signer address.\n    function createEdition(\n        address payable _fundingRecipient,\n        uint256 _price,\n        uint32 _quantity,\n        uint32 _royaltyBPS,\n        uint32 _startTime,\n        uint32 _endTime,\n        uint32 _presaleQuantity,\n        address _signerAddress\n    ) external onlyOwner {\n        require(_presaleQuantity < _quantity + 1, 'Presale quantity too big');\n\n        if (_presaleQuantity > 0) {\n            require(_signerAddress != address(0), 'Signer address cannot be 0');\n        }\n\n        editions[atEditionId.current()] = Edition({\n            fundingRecipient: _fundingRecipient,\n            price: _price,\n            numSold: 0,\n            quantity: _quantity,\n            royaltyBPS: _royaltyBPS,\n            startTime: _startTime,\n            endTime: _endTime,\n            presaleQuantity: _presaleQuantity,\n            signerAddress: _signerAddress\n        });\n\n        emit EditionCreated(\n            atEditionId.current(),\n            _fundingRecipient,\n            _price,\n            _quantity,\n            _royaltyBPS,\n            _startTime,\n            _endTime,\n            _presaleQuantity,\n            _signerAddress\n        );\n\n        atEditionId.increment();\n    }\n\n    /// @notice Creates a new token for the given edition, and assigns it to the buyer\n    /// @param _editionId The id of the edition to purchase\n    /// @param _signature A signed message for authorizing presale purchases\n    function buyEdition(uint256 _editionId, bytes calldata _signature) external payable {\n        // Caching variables locally to reduce reads\n        uint256 price = editions[_editionId].price;\n        uint32 quantity = editions[_editionId].quantity;\n        uint32 numSold = editions[_editionId].numSold;\n        uint32 startTime = editions[_editionId].startTime;\n        uint32 endTime = editions[_editionId].endTime;\n        uint32 presaleQuantity = editions[_editionId].presaleQuantity;\n\n        // Check that the edition exists. Note: this is redundant\n        // with the next check, but it is useful for clearer error messaging.\n        require(quantity > 0, 'Edition does not exist');\n        // Check that there are still tokens available to purchase.\n        require(numSold < quantity, 'This edition is already sold out.');\n        // Check that the sender is paying the correct amount.\n        require(msg.value >= price, 'Must send enough to purchase the edition.');\n\n        // If the open auction hasn't started...\n        if (startTime > block.timestamp) {\n            // Check that presale tokens are still available\n            require(\n                presaleQuantity > 0 && numSold < presaleQuantity,\n                'No presale available & open auction not started'\n            );\n\n            // Check that the signature is valid.\n            require(getSigner(_signature, _editionId) == editions[_editionId].signerAddress, 'Invalid signer');\n        }\n\n        // Don't allow purchases after the end time\n        require(endTime > block.timestamp, 'Auction has ended');\n\n        // Update the deposited total for the edition\n        depositedForEdition[_editionId] += msg.value;\n\n        // Increment the number of tokens sold for this edition.\n        editions[_editionId].numSold++;\n\n        // Mint a new token for the sender, using the `tokenId`.\n        _mint(msg.sender, atTokenId.current());\n\n        // Store the mapping of token id to the edition being purchased.\n        tokenToEdition[atTokenId.current()] = _editionId;\n\n        emit EditionPurchased(_editionId, atTokenId.current(), editions[_editionId].numSold, msg.sender);\n\n        atTokenId.increment();\n    }\n\n    function withdrawFunds(uint256 _editionId) external {\n        // Compute the amount available for withdrawing from this edition.\n        uint256 remainingForEdition = depositedForEdition[_editionId] - withdrawnForEdition[_editionId];\n\n        // Set the amount withdrawn to the amount deposited.\n        withdrawnForEdition[_editionId] = depositedForEdition[_editionId];\n\n        // Send the amount that was remaining for the edition, to the funding recipient.\n        _sendFunds(editions[_editionId].fundingRecipient, remainingForEdition);\n    }\n\n    /// @notice Sets the start time for an edition\n    function setStartTime(uint256 _editionId, uint32 _startTime) external onlyOwner {\n        editions[_editionId].startTime = _startTime;\n        emit AuctionTimeSet(TimeType.START, _editionId, _startTime);\n    }\n\n    /// @notice Sets the end time for an edition\n    function setEndTime(uint256 _editionId, uint32 _endTime) external onlyOwner {\n        editions[_editionId].endTime = _endTime;\n        emit AuctionTimeSet(TimeType.END, _editionId, _endTime);\n    }\n\n    /// @notice Returns token URI (metadata URL). e.g. https://sound.xyz/api/metadata/[artistId]/[editionId]/[tokenId]\n    function tokenURI(uint256 _tokenId) public view override returns (string memory) {\n        require(_exists(_tokenId), 'ERC721Metadata: URI query for nonexistent token');\n\n        // Concatenate the components, baseURI, editionId and tokenId, to create URI.\n        return string(abi.encodePacked(baseURI, tokenToEdition[_tokenId].toString(), '/', _tokenId.toString()));\n    }\n\n    /// @notice Returns contract URI used by Opensea. e.g. https://sound.xyz/api/metadata/[artistId]/storefront\n    function contractURI() public view returns (string memory) {\n        // Concatenate the components, baseURI, editionId and tokenId, to create URI.\n        return string(abi.encodePacked(baseURI, 'storefront'));\n    }\n\n    /// @notice Get token ids for a given edition id\n    /// @param _editionId edition id\n    function getTokenIdsOfEdition(uint256 _editionId) public view returns (uint256[] memory) {\n        uint256[] memory tokenIdsOfEdition = new uint256[](editions[_editionId].numSold);\n        uint256 index = 0;\n\n        for (uint256 id = 1; id < atTokenId.current(); id++) {\n            if (tokenToEdition[id] == _editionId) {\n                tokenIdsOfEdition[index] = id;\n                index++;\n            }\n        }\n        return tokenIdsOfEdition;\n    }\n\n    /// @notice Get owners of a given edition id\n    /// @param _editionId edition id\n    function getOwnersOfEdition(uint256 _editionId) public view returns (address[] memory) {\n        address[] memory ownersOfEdition = new address[](editions[_editionId].numSold);\n        uint256 index = 0;\n\n        for (uint256 id = 1; id < atTokenId.current(); id++) {\n            if (tokenToEdition[id] == _editionId) {\n                ownersOfEdition[index] = ERC721Upgradeable.ownerOf(id);\n                index++;\n            }\n        }\n        return ownersOfEdition;\n    }\n\n    /// @notice Get royalty information for token\n    /// @param _tokenId token id\n    /// @param _salePrice Sale price for the token\n    function royaltyInfo(uint256 _tokenId, uint256 _salePrice)\n        external\n        view\n        override\n        returns (address fundingRecipient, uint256 royaltyAmount)\n    {\n        uint256 editionId = tokenToEdition[_tokenId];\n        Edition memory edition = editions[editionId];\n\n        if (edition.fundingRecipient == address(0x0)) {\n            return (edition.fundingRecipient, 0);\n        }\n\n        uint256 royaltyBPS = uint256(edition.royaltyBPS);\n\n        return (edition.fundingRecipient, (_salePrice * royaltyBPS) / 10_000);\n    }\n\n    /// @notice The total number of tokens created by this contract\n    function totalSupply() external view returns (uint256) {\n        return atTokenId.current() - 1; // because atTokenId is 1-indexed\n    }\n\n    /// @notice Informs other contracts which interfaces this contract supports\n    /// @dev https://eips.ethereum.org/EIPS/eip-165\n    function supportsInterface(bytes4 _interfaceId)\n        public\n        view\n        override(ERC721Upgradeable, IERC165Upgradeable)\n        returns (bool)\n    {\n        return\n            type(IERC2981Upgradeable).interfaceId == _interfaceId || ERC721Upgradeable.supportsInterface(_interfaceId);\n    }\n\n    // ================================\n    // FUNCTIONS - PRIVATE\n    // ================================\n\n    /// @notice Sends funds to an address\n    /// @param _recipient The address to send funds to\n    /// @param _amount The amount of funds to send\n    function _sendFunds(address payable _recipient, uint256 _amount) private {\n        require(address(this).balance >= _amount, 'Insufficient balance for send');\n\n        (bool success, ) = _recipient.call{value: _amount}('');\n        require(success, 'Unable to send value: recipient may have reverted');\n    }\n\n    /// @notice Gets signer address to validate presale purchase\n    /// @param _signature signed message\n    /// @param _editionId edition id\n    /// @return address of signer\n    /// @dev https://eips.ethereum.org/EIPS/eip-712\n    function getSigner(bytes calldata _signature, uint256 _editionId) private view returns (address) {\n        bytes32 digest = keccak256(\n            abi.encodePacked(\n                '\\x19\\x01',\n                keccak256(abi.encode(keccak256('EIP712Domain(uint256 chainId)'), block.chainid)),\n                keccak256(abi.encode(PRESALE_TYPEHASH, address(this), msg.sender, _editionId))\n            )\n        );\n        address recoveredAddress = digest.recover(_signature);\n        return recoveredAddress;\n    }\n}\n"
    },
    "contracts/ArtistCreatorProxy.sol": {
      "content": "// SPDX-License-Identifier: GPL-3.0-or-later\npragma solidity ^0.8.7;\n\nimport '@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol';\n\n// This contract doesn't change the bytecode of ERC1967Proxy. It exists solely to make it compatible with hardhat-deploy plugin.\n// https://github.com/wighawag/hardhat-deploy/issues/146#issuecomment-907755963\n\n// Kept for backwards compatibility with older versions of Hardhat and Truffle plugins.\ncontract ArtistCreatorProxy is ERC1967Proxy {\n    constructor(\n        address _logic,\n        address,\n        bytes memory _data\n    ) payable ERC1967Proxy(_logic, _data) {}\n}\n"
    }
  },
  "settings": {
    "optimizer": {
      "enabled": true,
      "runs": 200
    },
    "outputSelection": {
      "*": {
        "*": [
          "abi",
          "evm.bytecode",
          "evm.deployedBytecode",
          "evm.methodIdentifiers",
          "metadata",
          "storageLayout",
          "devdoc",
          "userdoc",
          "evm.gasEstimates"
        ],
        "": ["ast"]
      }
    },
    "metadata": {
      "useLiteralContent": true
    }
  }
}
