Skip to content

Commit

Permalink
fix: empty params shouldn't represent as null
Browse files Browse the repository at this point in the history
  • Loading branch information
yangby-cryptape committed Mar 20, 2024
1 parent 0af5a1d commit add107b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/components/bitcoin_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,19 @@ impl Clone for BitcoinClient {
}
}

#[derive(Serialize, Clone, Copy)]
struct ZeroElemTuple();

// ### Warning
//
// If parameters contain only one parameter:
// - `serde_json::to_value(($($arg,)+))`
// - `serde_json::to_value(($($arg),+))`
// are different.
//
// Ref: https://github.com/serde-rs/serde/issues/1309
macro_rules! serialize_parameters {
() => ( serde_json::Value::Null );
() => ( serde_json::to_value(ZeroElemTuple())?);
($($arg:ident),+) => ( serde_json::to_value(($($arg,)+))?)
}

Expand Down

0 comments on commit add107b

Please sign in to comment.