// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/// @author: manifold.xyz

/**
 * Lazy Claim interface
 */
interface IERC1155LazyPayableClaim {
    enum StorageProtocol { INVALID, NONE, ARWEAVE, IPFS }

    struct ClaimParameters {
        uint32 totalMax;
        uint32 walletMax;
        uint48 startDate;
        uint48 endDate;
        StorageProtocol storageProtocol;
        bytes32 merkleRoot;
        string location;
        uint cost;
        address paymentReceiver;
    }

    struct Claim {
        uint32 total;
        uint32 totalMax;
        uint32 walletMax;
        uint48 startDate;
        uint48 endDate;
        StorageProtocol storageProtocol;
        bytes32 merkleRoot;
        string location;
        uint tokenId;
        uint cost;
        address paymentReceiver;
    }

    event ClaimInitialized(address indexed creatorContract, uint224 indexed claimIndex, address initializer);
    event ClaimMint(address indexed creatorContract, uint256 indexed claimIndex);
    event ClaimMintBatch(address indexed creatorContract, uint256 indexed claimIndex, uint16 mintCount);

    /**
     * @notice initialize a new claim, emit initialize event, and return the newly created index
     * @param creatorContractAddress    the creator contract the claim will mint tokens for
     * @param claimParameters           the parameters which will affect the minting behavior of the claim
     * @return                          the index of the newly created claim
     */
    function initializeClaim(address creatorContractAddress, ClaimParameters calldata claimParameters) external returns(uint256);

    /**
     * @notice update an existing claim at claimIndex
     * @param creatorContractAddress    the creator contract corresponding to the claim
     * @param claimIndex                the index of the claim in the list of creatorContractAddress' _claims
     * @param claimParameters           the parameters which will affect the minting behavior of the claim
     */
    function updateClaim(address creatorContractAddress, uint256 claimIndex, ClaimParameters calldata claimParameters) external;

/**
     * @notice get the number of _claims initialized for a given creator contract
     * @param creatorContractAddress    the address of the creator contract
     * @return                          the number of _claims initialized for this creator contract
     */
    function getClaimCount(address creatorContractAddress) external view returns(uint256);

    /**
     * @notice get a claim corresponding to a creator contract and index
     * @param creatorContractAddress    the address of the creator contract
     * @param claimIndex                the index of the claim
     * @return                          the claim object
     */
    function getClaim(address creatorContractAddress, uint256 claimIndex) external view returns(Claim memory);

    /**
     * @notice check if a mint index has been consumed or not (only for merkle claims)
     *
     * @param creatorContractAddress    the address of the creator contract for the claim
     * @param claimIndex                the index of the claim
     * @param mintIndex                 the mint index of the claim
     * @return                          whether or not the mint index was consumed
     */
    function checkMintIndex(address creatorContractAddress, uint256 claimIndex, uint32 mintIndex) external view returns(bool);

    /**
     * @notice check if multiple mint indices has been consumed or not (only for merkle claims)
     *
     * @param creatorContractAddress    the address of the creator contract for the claim
     * @param claimIndex                the index of the claim
     * @param mintIndices               the mint index of the claim
     * @return                          whether or not the mint index was consumed
     */
    function checkMintIndices(address creatorContractAddress, uint256 claimIndex, uint32[] calldata mintIndices) external view returns(bool[] memory);

    /**
     * @notice get mints made for a wallet (only for non-merkle claims with walletMax)
     *
     * @param minter                    the address of the minting address
     * @param creatorContractAddress    the address of the creator contract for the claim
     * @param claimIndex                the index of the claim
     * @return                          how many mints the minter has made
     */
    function getTotalMints(address minter, address creatorContractAddress, uint256 claimIndex) external view returns(uint32);

    /**
     * @notice allow a wallet to lazily claim a token according to parameters
     * @param creatorContractAddress    the creator contract address
     * @param claimIndex                the index of the claim for which we will mint
     * @param mintIndex                 the mint index (only needed for merkle claims)
     * @param merkleProof               if the claim has a merkleRoot, verifying merkleProof ensures that address + minterValue was used to construct it  (only needed for merkle claims)
     */
    function mint(address creatorContractAddress, uint256 claimIndex, uint32 mintIndex, bytes32[] calldata merkleProof) external payable;

    /**
     * @notice allow a wallet to lazily claim a token according to parameters
     * @param creatorContractAddress    the creator contract address
     * @param claimIndex                the index of the claim for which we will mint
     * @param mintCount                 the number of claims to mint
     * @param mintIndices               the mint index (only needed for merkle claims)
     * @param merkleProofs              if the claim has a merkleRoot, verifying merkleProof ensures that address + minterValue was used to construct it  (only needed for merkle claims)
     */
    function mintBatch(address creatorContractAddress, uint256 claimIndex, uint16 mintCount, uint32[] calldata mintIndices, bytes32[][] calldata merkleProofs) external payable;
}
[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"creatorContract","type":"address"},{"indexed":true,"internalType":"uint224","name":"claimIndex","type":"uint224"},{"indexed":false,"internalType":"address","name":"initializer","type":"address"}],"name":"ClaimInitialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"creatorContract","type":"address"},{"indexed":true,"internalType":"uint256","name":"claimIndex","type":"uint256"}],"name":"ClaimMint","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"creatorContract","type":"address"},{"indexed":true,"internalType":"uint256","name":"claimIndex","type":"uint256"},{"indexed":false,"internalType":"uint16","name":"mintCount","type":"uint16"}],"name":"ClaimMintBatch","type":"event"},{"inputs":[{"internalType":"address","name":"creatorContractAddress","type":"address"},{"internalType":"uint256","name":"claimIndex","type":"uint256"},{"internalType":"uint32","name":"mintIndex","type":"uint32"}],"name":"checkMintIndex","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"creatorContractAddress","type":"address"},{"internalType":"uint256","name":"claimIndex","type":"uint256"},{"internalType":"uint32[]","name":"mintIndices","type":"uint32[]"}],"name":"checkMintIndices","outputs":[{"internalType":"bool[]","name":"minted","type":"bool[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"creatorContractAddress","type":"address"},{"internalType":"uint256","name":"claimIndex","type":"uint256"}],"name":"getClaim","outputs":[{"components":[{"internalType":"uint32","name":"total","type":"uint32"},{"internalType":"uint32","name":"totalMax","type":"uint32"},{"internalType":"uint32","name":"walletMax","type":"uint32"},{"internalType":"uint48","name":"startDate","type":"uint48"},{"internalType":"uint48","name":"endDate","type":"uint48"},{"internalType":"enum IERC1155LazyPayableClaim.StorageProtocol","name":"storageProtocol","type":"uint8"},{"internalType":"bytes32","name":"merkleRoot","type":"bytes32"},{"internalType":"string","name":"location","type":"string"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"cost","type":"uint256"},{"internalType":"address","name":"paymentReceiver","type":"address"}],"internalType":"struct IERC1155LazyPayableClaim.Claim","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"creatorContractAddress","type":"address"}],"name":"getClaimCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"minter","type":"address"},{"internalType":"address","name":"creatorContractAddress","type":"address"},{"internalType":"uint256","name":"claimIndex","type":"uint256"}],"name":"getTotalMints","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"creatorContractAddress","type":"address"},{"components":[{"internalType":"uint32","name":"totalMax","type":"uint32"},{"internalType":"uint32","name":"walletMax","type":"uint32"},{"internalType":"uint48","name":"startDate","type":"uint48"},{"internalType":"uint48","name":"endDate","type":"uint48"},{"internalType":"enum IERC1155LazyPayableClaim.StorageProtocol","name":"storageProtocol","type":"uint8"},{"internalType":"bytes32","name":"merkleRoot","type":"bytes32"},{"internalType":"string","name":"location","type":"string"},{"internalType":"uint256","name":"cost","type":"uint256"},{"internalType":"address","name":"paymentReceiver","type":"address"}],"internalType":"struct IERC1155LazyPayableClaim.ClaimParameters","name":"claimParameters","type":"tuple"}],"name":"initializeClaim","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"creatorContractAddress","type":"address"},{"internalType":"uint256","name":"claimIndex","type":"uint256"},{"internalType":"uint32","name":"mintIndex","type":"uint32"},{"internalType":"bytes32[]","name":"merkleProof","type":"bytes32[]"}],"name":"mint","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"creatorContractAddress","type":"address"},{"internalType":"uint256","name":"claimIndex","type":"uint256"},{"internalType":"uint16","name":"mintCount","type":"uint16"},{"internalType":"uint32[]","name":"mintIndices","type":"uint32[]"},{"internalType":"bytes32[][]","name":"merkleProofs","type":"bytes32[][]"}],"name":"mintBatch","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"creatorContractAddress","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"uri","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"creatorContractAddress","type":"address"},{"internalType":"uint256","name":"claimIndex","type":"uint256"},{"components":[{"internalType":"uint32","name":"totalMax","type":"uint32"},{"internalType":"uint32","name":"walletMax","type":"uint32"},{"internalType":"uint48","name":"startDate","type":"uint48"},{"internalType":"uint48","name":"endDate","type":"uint48"},{"internalType":"enum IERC1155LazyPayableClaim.StorageProtocol","name":"storageProtocol","type":"uint8"},{"internalType":"bytes32","name":"merkleRoot","type":"bytes32"},{"internalType":"string","name":"location","type":"string"},{"internalType":"uint256","name":"cost","type":"uint256"},{"internalType":"address","name":"paymentReceiver","type":"address"}],"internalType":"struct IERC1155LazyPayableClaim.ClaimParameters","name":"claimParameters","type":"tuple"}],"name":"updateClaim","outputs":[],"stateMutability":"nonpayable","type":"function"}]