fix(api): improve order endpoint compatibility

This commit is contained in:
floor-licker
2026-01-30 21:10:03 -05:00
parent 2570aa08a1
commit 0f577f0b2c
2 changed files with 11 additions and 6 deletions
+8 -4
View File
@@ -848,10 +848,14 @@ impl ClobClient {
let response = req.json(&body).send().await?;
if !response.status().is_success() {
return Err(PolyfillError::api(
response.status().as_u16(),
"Failed to post order",
));
let status = response.status().as_u16();
let body = response.text().await.unwrap_or_default();
let message = if body.is_empty() {
"Failed to post order".to_string()
} else {
format!("Failed to post order: {}", body)
};
return Err(PolyfillError::api(status, message));
}
Ok(response.json::<Value>().await?)
+3 -2
View File
@@ -208,9 +208,10 @@ impl Side {
}
/// Order type specifications
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, Default)]
#[allow(clippy::upper_case_acronyms)]
pub enum OrderType {
#[default]
GTC,
FOK,
GTD,
@@ -1099,7 +1100,7 @@ pub struct OpenOrder {
pub asset_id: String,
#[serde(deserialize_with = "crate::decode::deserializers::number_from_string")]
pub expiration: u64,
#[serde(rename = "type")]
#[serde(rename = "type", alias = "order_type", alias = "orderType", default)]
pub order_type: OrderType,
#[serde(deserialize_with = "crate::decode::deserializers::number_from_string")]
pub created_at: u64,