Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

51 changes: 49 additions & 2 deletions crates/sage-api/src/requests/offers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,55 @@ pub struct ImportOfferResponse {
description = "List all offers created by or available to this wallet."
)
)]
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[cfg_attr(feature = "tauri", derive(specta::Type))]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
pub struct GetOffers {}
pub struct GetOffers {
/// Starting offset for pagination
#[serde(default)]
pub offset: Option<u32>,
/// Maximum number of offers to return (all when omitted)
#[serde(default)]
pub limit: Option<u32>,
/// Only return offers with this status
#[serde(default)]
pub status: Option<OfferRecordStatus>,
/// Search by asset name, ticker, asset/offer id, or NFT/DID/option address
#[serde(default)]
pub find_value: Option<String>,
/// Which side of the offer the search applies to (defaults to any)
#[serde(default)]
pub find_side: Option<OfferFindSide>,
/// Sort column (defaults to creation time)
#[serde(default)]
pub sort_mode: Option<OfferSortMode>,
/// Sort ascending (defaults to false, newest first)
#[serde(default)]
pub ascending: bool,
}

/// Which side of an offer a search matches
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Serialize, Deserialize)]
#[cfg_attr(feature = "tauri", derive(specta::Type))]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
#[serde(rename_all = "snake_case")]
pub enum OfferFindSide {
#[default]
Any,
Offered,
Requested,
}

/// Offer list sort column
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Serialize, Deserialize)]
#[cfg_attr(feature = "tauri", derive(specta::Type))]
#[cfg_attr(feature = "openapi", derive(utoipa::ToSchema))]
#[serde(rename_all = "snake_case")]
pub enum OfferSortMode {
#[default]
Created,
Expiration,
}

/// Response with list of offers
#[cfg_attr(feature = "openapi", crate::openapi_attr(tag = "Offers"))]
Expand All @@ -209,6 +254,8 @@ pub struct GetOffers {}
pub struct GetOffersResponse {
/// List of offers
pub offers: Vec<OfferRecord>,
/// Total number of offers matching the filters, before paging
pub total: u32,
}

/// Get offers for a specific asset
Expand Down
4 changes: 4 additions & 0 deletions crates/sage-database/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,7 @@ sqlx = { workspace = true, features = ["sqlite"] }
thiserror = { workspace = true }
tracing = { workspace = true }
hex = { workspace = true }

[dev-dependencies]
sqlx = { workspace = true, features = ["sqlite", "runtime-tokio", "migrate"] }
tokio = { workspace = true, features = ["macros", "rt"] }
Loading
Loading