hyperspace-rs 0.2.0

A Rust library to interact with [Hyperspace](https://avax.hyperspace.xyz/) NFT marketplace on Avalanche
Documentation
use crate::types::PaginationInfo;

use super::{Bid, CollectionStats, Deserialize, Serialize, H160};

#[derive(Debug, Serialize)]
pub(crate) struct GetStatsRequest {
    pub(crate) condition: GetStatsCondition,
    pub(crate) order_by: Option<String>,
    pub(crate) pagination_info: Option<String>,
}

#[derive(Debug, Serialize)]
pub(crate) struct GetStatsCondition {
    pub(crate) project_ids: Vec<String>,
}

impl GetStatsRequest {
    pub(crate) fn new(project_id: String) -> Self {
        Self {
            condition: GetStatsCondition {
                project_ids: vec![project_id],
            },
            order_by: None,
            pagination_info: None,
        }
    }
}

#[derive(Debug, Deserialize)]
pub(crate) struct GetStatsResponse {
    pub(crate) project_stats: Vec<CollectionStats>,
    pub(crate) pagination_info: PaginationInfo,
}

#[derive(Debug, Serialize)]
pub(crate) struct GetBidsRequest {
    pub(crate) condition: CollectionAddress,
}

#[derive(Debug, Serialize)]
pub(crate) struct CollectionAddress {
    pub(crate) contract_address: H160,
}

impl Into<CollectionAddress> for H160 {
    fn into(self) -> CollectionAddress {
        CollectionAddress {
            contract_address: self,
        }
    }
}

impl GetBidsRequest {
    pub(crate) fn new(collection_address: H160) -> Self {
        Self {
            condition: collection_address.into(),
        }
    }
}

#[derive(Debug, Deserialize)]
pub(crate) struct GetBidsResponse {
    pub(crate) bids: Vec<Bid>,
    pub(crate) pagination_info: PaginationInfo,
}