pragma solidity ^0.8.0;

/**
 * @title Counters
 * @author Matt Condon (@shrugs)
 * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number
 * of elements in a mapping, issuing ERC721 ids, or counting request ids.
 *
 * Include with `using Counters for Counters.Counter;`
 */
library Counters {
    struct Counter {
        // This variable should never be directly accessed by users of the library: interactions must be restricted to
        // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add
        // this feature: see https://github.com/ethereum/solidity/issues/4637
        uint256 _value; // default: 0
    }

    function current(Counter storage counter) internal view returns (uint256) {
        return counter._value;
    }

    function increment(Counter storage counter) internal {
        unchecked {
            counter._value += 1;
        }
    }

    function decrement(Counter storage counter) internal {
        uint256 value = counter._value;
        require(value > 0, "Counter: decrement overflow");
        unchecked {
            counter._value = value - 1;
        }
    }

    function reset(Counter storage counter) internal {
        counter._value = 0;
    }
}


interface IERC20 {
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);

    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the amount of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves `amount` tokens from the caller's account to `to`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address to, uint256 amount) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 amount) external returns (bool);

    /**
     * @dev Moves `amount` tokens from `from` to `to` using the
     * allowance mechanism. `amount` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(
        address from,
        address to,
        uint256 amount
    ) external returns (bool);
}
[{"inputs":[{"internalType":"address","name":"_erc721","type":"address"},{"internalType":"address","name":"_erc1155","type":"address"},{"internalType":"address","name":"_erc20","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"listingId","type":"uint256"}],"name":"ListingDeleted1155","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"seller","type":"address"},{"indexed":true,"internalType":"uint128","name":"tokenId","type":"uint128"},{"indexed":false,"internalType":"uint128","name":"amount","type":"uint128"},{"indexed":false,"internalType":"uint128","name":"pricePerToken","type":"uint128"},{"indexed":false,"internalType":"address[]","name":"privateBuyer","type":"address[]"},{"indexed":false,"internalType":"bool","name":"privateSale","type":"bool"},{"indexed":true,"internalType":"uint256","name":"listingId","type":"uint256"}],"name":"TokenListed1155","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"seller","type":"address"},{"indexed":false,"internalType":"address","name":"buyer","type":"address"},{"indexed":false,"internalType":"uint128","name":"tokenId","type":"uint128"},{"indexed":false,"internalType":"uint128","name":"amount","type":"uint128"},{"indexed":false,"internalType":"uint128","name":"pricePerToken","type":"uint128"},{"indexed":false,"internalType":"bool","name":"privateSale","type":"bool"}],"name":"TokenSold1155","type":"event"},{"inputs":[],"name":"_listingIds1155","outputs":[{"internalType":"uint256","name":"_value","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_nft","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"address","name":"_offerer","type":"address"}],"name":"acceptOffer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"auctionNfts","outputs":[{"internalType":"address","name":"seller","type":"address"},{"internalType":"uint128","name":"price","type":"uint128"},{"internalType":"uint32","name":"duration","type":"uint32"},{"internalType":"uint128","name":"maxBid","type":"uint128"},{"internalType":"address","name":"maxBidUser","type":"address"},{"internalType":"bool","name":"isActive","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_nft","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"uint128","name":"_amount","type":"uint128"}],"name":"bid721","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_nft","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"cancelAuction721","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_nft","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"cancelMarketItem721","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"commission","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_nft","type":"address"},{"internalType":"uint128","name":"_tokenId","type":"uint128"},{"internalType":"uint128","name":"_price","type":"uint128"}],"name":"createMarketItem721","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_nft","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"createMarketSale721","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_nft","type":"address"},{"internalType":"uint128","name":"_tokenId","type":"uint128"},{"internalType":"uint128","name":"_price","type":"uint128"},{"internalType":"uint32","name":"_duration","type":"uint32"}],"name":"createTokenAuction721","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint128","name":"_listingId","type":"uint128"}],"name":"deleteListing1155","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_nft","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"executeSale721","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_nft","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"fetchMarketItem721","outputs":[{"components":[{"internalType":"address payable","name":"seller","type":"address"},{"internalType":"uint128","name":"price","type":"uint128"},{"internalType":"bool","name":"sold","type":"bool"}],"internalType":"struct BharatNFTMarketplace.MarketItem721","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_nft","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"fetchOffers","outputs":[{"components":[{"internalType":"address[]","name":"offerers","type":"address[]"},{"internalType":"uint128[]","name":"offerAmounts","type":"uint128[]"},{"internalType":"address","name":"owner","type":"address"},{"internalType":"bool","name":"isAccepted","type":"bool"}],"internalType":"struct BharatNFTMarketplace.Offer","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_nft","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"getTokenAuctionDetails721","outputs":[{"components":[{"internalType":"address","name":"seller","type":"address"},{"internalType":"uint128","name":"price","type":"uint128"},{"internalType":"uint32","name":"duration","type":"uint32"},{"internalType":"uint128","name":"maxBid","type":"uint128"},{"internalType":"address","name":"maxBidUser","type":"address"},{"internalType":"bool","name":"isActive","type":"bool"},{"internalType":"uint128[]","name":"bidAmounts","type":"uint128[]"},{"internalType":"address[]","name":"users","type":"address[]"}],"internalType":"struct BharatNFTMarketplace.tokenDetails721","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint128","name":"","type":"uint128"}],"name":"idToListing1155","outputs":[{"internalType":"address","name":"nft","type":"address"},{"internalType":"address","name":"seller","type":"address"},{"internalType":"uint128","name":"tokenId","type":"uint128"},{"internalType":"uint128","name":"amount","type":"uint128"},{"internalType":"uint128","name":"price","type":"uint128"},{"internalType":"uint128","name":"tokensAvailable","type":"uint128"},{"internalType":"bool","name":"privateListing","type":"bool"},{"internalType":"bool","name":"completed","type":"bool"},{"internalType":"uint256","name":"listingId","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"listNfts","outputs":[{"internalType":"address payable","name":"seller","type":"address"},{"internalType":"uint128","name":"price","type":"uint128"},{"internalType":"bool","name":"sold","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_nft","type":"address"},{"internalType":"uint128","name":"tokenId","type":"uint128"},{"internalType":"uint128","name":"amount","type":"uint128"},{"internalType":"uint128","name":"price","type":"uint128"},{"internalType":"address[]","name":"privateBuyer","type":"address[]"}],"name":"listToken1155","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_nft","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"},{"internalType":"uint128","name":"_offer","type":"uint128"}],"name":"makeOffer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"offerNfts","outputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"bool","name":"isAccepted","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint128","name":"listingId","type":"uint128"},{"internalType":"uint128","name":"amount","type":"uint128"}],"name":"purchaseToken1155","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_nft","type":"address"},{"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"rejectOffer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint8","name":"_newRate","type":"uint8"}],"name":"setCommission","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint128","name":"_listId","type":"uint128"}],"name":"viewListing1155","outputs":[{"components":[{"internalType":"address","name":"nft","type":"address"},{"internalType":"address","name":"seller","type":"address"},{"internalType":"address[]","name":"buyer","type":"address[]"},{"internalType":"uint128","name":"tokenId","type":"uint128"},{"internalType":"uint128","name":"amount","type":"uint128"},{"internalType":"uint128","name":"price","type":"uint128"},{"internalType":"uint128","name":"tokensAvailable","type":"uint128"},{"internalType":"bool","name":"privateListing","type":"bool"},{"internalType":"bool","name":"completed","type":"bool"},{"internalType":"uint256","name":"listingId","type":"uint256"}],"internalType":"struct BharatNFTMarketplace.Listing1155","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint128","name":"_amount","type":"uint128"}],"name":"withdraw","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint128","name":"_amount","type":"uint128"}],"name":"withdrawAnyToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]