Skip to content
Open
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
19 changes: 11 additions & 8 deletions src/clob/types/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -651,12 +651,14 @@ pub struct BuilderApiKeyResponse {
pub struct BuilderTradeResponse {
pub id: String,
pub trade_type: String,
/// Hash of the taker order.
pub taker_order_hash: B256,
/// Address of the builder.
pub builder: Address,
/// The market condition ID.
pub market: B256,
/// Hash of the taker order (optional — may be empty for pending trades).
#[serde(default)]
pub taker_order_hash: Option<B256>,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

serde(default) doesn't handle empty string B256 values

High Severity

#[serde(default)] only applies when the field is absent from the JSON — it does not handle the case where the API returns an empty string like "takerOrderHash": "". When the field is present but empty, B256 deserialization will still be attempted and fail. The same file already uses #[serde_as(as = "NoneAsEmptyString")] for identical Option<B256> patterns (e.g. condition_id, question_id) which correctly deserializes empty strings as None.

Additional Locations (2)
Fix in Cursor Fix in Web

/// Builder API key ID (UUID, not an Ethereum address).
pub builder: ApiKey,
/// The market condition ID (optional — may be empty in some API responses).
#[serde(default)]
pub market: Option<B256>,
pub asset_id: U256,
pub side: Side,
pub size: Decimal,
Expand All @@ -668,8 +670,9 @@ pub struct BuilderTradeResponse {
pub owner: ApiKey,
/// Address of the maker.
pub maker: Address,
/// On-chain transaction hash.
pub transaction_hash: B256,
/// On-chain transaction hash (optional — empty for unfilled/pending trades).
#[serde(default)]
pub transaction_hash: Option<B256>,
#[serde_as(as = "TimestampSeconds<String>")]
pub match_time: DateTime<Utc>,
pub bucket_index: u32,
Expand Down
Loading