use crate::candid::{self, Decode, Error, Limits, Nat, Reader, Schema};
use candidate_types::Principal;
use serde::{Deserialize, Serialize};
projection! {
#[derive(Copy)]
enum NodeType {
#[serde(rename = "type4")]
449_540_154 => Type4,
#[serde(rename = "type4_1")]
4_172_531_116 => Type4_1,
#[serde(rename = "type4_2")]
4_172_531_117 => Type4_2,
#[serde(rename = "type4_3")]
4_172_531_118 => Type4_3,
#[serde(rename = "type4_4")]
4_172_531_119 => Type4_4,
#[serde(rename = "type4_5")]
4_172_531_120 => Type4_5,
}
}
projection! {
Price {
2_625_678_760 => gross_cycles: Nat [required],
3_039_038_447 => net_cycles: Nat [required],
}
}
projection! {
PriceEntry {
22_399 => dc: Option<String> [strict_optional],
272_465_847 => updated_at: i64 [required],
287_472_983 => node_type: NodeType [required],
590_999_857 => provider: Option<Principal> [strict_optional],
3_364_572_809 => price: Price [required],
}
}
projection! {
MarketplaceEntry {
5_343_647 => key: String [required],
1_887_860_850 => entry: PriceEntry [required],
}
}
pub fn decode_list_marketplace_prices_response(
bytes: &[u8],
limits: Limits,
) -> Result<Vec<MarketplaceEntry>, Error> {
candid::decode(bytes, limits)
}