Skip to content

Commit

Permalink
Merge pull request #95 from xch-dev/cleanup-offers
Browse files Browse the repository at this point in the history
Cleanup offers
  • Loading branch information
Rigidity authored Nov 14, 2024
2 parents c95af02 + c2fef86 commit 63b6045
Show file tree
Hide file tree
Showing 9 changed files with 421 additions and 467 deletions.
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.

1 change: 1 addition & 0 deletions crates/sage-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ specta = { workspace = true, features = ["derive", "bigdecimal"] }
bigdecimal = { workspace = true, features = ["serde"] }
once_cell = { workspace = true }
num-traits = { workspace = true }
indexmap = { workspace = true }
38 changes: 27 additions & 11 deletions crates/sage-api/src/records/offer_summary.rs
Original file line number Diff line number Diff line change
@@ -1,26 +1,42 @@
use indexmap::IndexMap;
use serde::{Deserialize, Serialize};
use specta::Type;

use crate::{Amount, AssetKind};
use crate::Amount;

#[derive(Debug, Clone, Serialize, Deserialize, Type)]
pub struct OfferSummary {
pub fee: Amount,
pub offered: Vec<OfferedCoin>,
pub requested: Vec<RequestedAsset>,
pub maker: OfferAssets,
pub taker: OfferAssets,
}

#[derive(Debug, Clone, Serialize, Deserialize, Type)]
pub struct OfferedCoin {
pub coin_id: String,
pub offered_amount: Amount,
#[serde(flatten)]
pub kind: AssetKind,
pub struct OfferAssets {
pub xch: OfferXch,
pub cats: IndexMap<String, OfferCat>,
pub nfts: IndexMap<String, OfferNft>,
}

#[derive(Debug, Clone, Serialize, Deserialize, Type)]
pub struct RequestedAsset {
pub struct OfferXch {
pub amount: Amount,
#[serde(flatten)]
pub kind: AssetKind,
pub royalty: Amount,
}

#[derive(Debug, Clone, Serialize, Deserialize, Type)]
pub struct OfferCat {
pub amount: Amount,
pub royalty: Amount,
pub name: Option<String>,
pub ticker: Option<String>,
pub icon_url: Option<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize, Type)]
pub struct OfferNft {
pub image_data: Option<String>,
pub image_mime_type: Option<String>,
pub name: Option<String>,
pub royalty_percent: String,
}
1 change: 0 additions & 1 deletion crates/sage-wallet/src/wallet/offer/take_offer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ impl Wallet {

let mut builder = offer.take();
let requested_payments = parse_offer_payments(&mut ctx, &mut builder)?;

let taker_amounts = requested_payments.amounts();

let taker_royalties = calculate_royalties(
Expand Down
2 changes: 2 additions & 0 deletions src-tauri/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ use crate::{app_state::AppState, error::Result};
mod actions;
mod data;
mod keys;
mod offers;
mod settings;
mod transactions;

pub use actions::*;
pub use data::*;
pub use keys::*;
pub use offers::*;
pub use settings::*;
pub use transactions::*;

Expand Down
Loading

0 comments on commit 63b6045

Please sign in to comment.