Products

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

/**
 * @title IProducts
 * @dev Interface for managing product listings across the marketplace.
 */
interface IProducts {
    enum PaymentType { ETH, USDC, DAI, GHO }

    /**
     * @dev Struct representing a product listing.
     * @param isActive Whether or not the product is active / not deleted.
     * @param productId Unique identifier for the product.
     * @param seller Wallet address of the seller.
     * @param validator Wallet address of the validator.
     * @param category The category for the product.
     * @param title The title of the product.
     * @param description Hash of the product description stored off-chain.
     * @param imageLocations IPFS hashes of the product's images.
     * @param quantity Product quantity.
     * @param price Product price.
     * @param inEscrow Whether or not the product is in escrow due to a pending purchase.
     * @param paymentType Payment type accepted for the product.
     */
    struct Product {
        bool isActive;
        uint256 productId;
        address seller;
        address validator;
        string category;
        string title;
        string description;
        string[] imageLocations;
        uint256 quantity;
        uint256 price;
        bool inEscrow;
        PaymentType paymentType;
    }

    /**
     * @dev Struct representing the input parameters for listing a product.
     * @param sellerAddress Wallet address of the seller.
     * @param validatorAddress Wallet address of the validator.
     * @param category The category for the product.
     * @param title The title of the product.
     * @param description Hash of the product description stored off-chain.
     * @param imageLocations IPFS hashes of the product's images.
     * @param quantity Product quantity.
     * @param price Product price.
     * @param paymentType Payment type accepted for the product.
     */
    struct ListProductInput {
        address sellerAddress;
        address validatorAddress;
        string category;
        string title;
        string description;
        string[] imageLocations;
        uint256 quantity;
        uint256 price;
        PaymentType paymentType;
    }
    
    /**
     * @dev Emitted when a new product is listed.
     * @param productId The unique identifier for the listed product.
     * @param seller The address of the seller who listed the product.
     * @param validator The address of the validator who validates the product.
     */
    event ProductListed(uint256 indexed productId, address indexed seller, address indexed validator);

    /**
     * @dev Emitted when a product is updated.
     * @param productId The unique identifier for the updated product.
     */
    event ProductUpdated(uint256 indexed productId);

    /**
     * @dev Emitted when a product is deleted.
     * @param productId The unique identifier for the deleted product.
     */
    event ProductDeleted(uint256 indexed productId);

    /**
     * @dev Emitted when the purchase escrow address is updated.
     * @param newAddress The new purchase escrow address.
     */
    event PurchaseEscrowAddressUpdated(address indexed newAddress);

    /**
     * @dev Emitted when the USDC purchase escrow address is updated.
     * @param newAddress The new USDC purchase escrow address.
     */
    event PurchaseEscrowAddressUSDCUpdated(address indexed newAddress);

    /**
     * @dev Emitted when the DAI purchase escrow address is updated.
     * @param newAddress The new DAI purchase escrow address.
     */
    event PurchaseEscrowAddressDAIUpdated(address indexed newAddress);

    /**
     * @dev Emitted when the rewards address is updated.
     * @param newAddress The new rewards address.
     */
    event RewardsAddressUpdated(address indexed newAddress);

    /**
     * @notice List a new product for sale.
     * @dev Emits a ProductListed event upon success.
     * @dev Only the owner can call this function as sellers must go through KYC to mitigate illegal products listed on the platform.
     * @param input The struct containing all input parameters.
     * @return newProductId The unique identifier for the listed product.
     */
    function listProduct(ListProductInput calldata input) external returns (uint256);
    
    /**
     * @notice Updates an existing product listing.
     * @dev Modifies the details of an existing product listing identified by `productId`.
     * @param productId The unique identifier of the product to update.
     * @param quantity The new quantity of the product.
     * @param price The new price of the product in wei.
     * @param inEscrow Whether or not the product is in escrow due to a pending purchase.
     */
    function updateProduct(uint256 productId, uint256 quantity, uint256 price, bool inEscrow) external;
    
    /**
     * @notice Deletes an existing product listing.
     * @dev Removes a product listing identified by `productId` from the marketplace.
     * @param productId The unique identifier of the product to delete.
     */
    function deleteProduct(uint256 productId) external;
    
    /**
     * @notice Retrieves the details of a product listing.
     * @dev Returns the details of a product listing identified by `productId`.
     * @param productId The unique identifier of the product to retrieve.
     * @return product The details of the product.
     */
    function getProduct(uint256 productId) external view returns (Product memory);

    /**
     * @notice Updates the purchase escrow address.
     * @param newAddress The new purchase escrow address.
     */
    function updatePurchaseEscrowAddress(address newAddress) external;

    /**
     * @notice Updates the USDC purchase escrow address.
     * @param newAddress The USDC new purchase escrow address.
     */
    function updatePurchaseEscrowUSDCAddress(address newAddress) external;

    /**
     * @notice Updates the DAI purchase escrow address.
     * @param newAddress The new DAI purchase escrow address.
     */
    function updatePurchaseEscrowDAIAddress(address newAddress) external;        
    
    /**
     * @notice Updates the GHO purchase escrow address.
     * @param newAddress The new GHO purchase escrow address.
     */
    function updatePurchaseEscrowGHOAddress(address newAddress) external;        


    /**
     * @notice Updates the rewards address.
     * @param newAddress The new rewards address.
     */
    function updateRewardsAddress(address newAddress) external;
}

Last updated