Skip to content

Commit 05740d0

Browse files
committed
fix: use empty string for None in v2 api
1 parent e88dedb commit 05740d0

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "tycho-toncenter"
33
description = "A partial TON Center API V2 and V3 implementation for Tycho-based networks"
4-
version = "0.2.6"
4+
version = "0.2.7"
55
edition = "2024"
66
authors = ["Broxus Team"]
77
rust-version = "1.89.0"

src/api/toncenter_v2/models.rs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ pub struct JettonMasterData {
485485
#[serde(with = "serde_helpers::string")]
486486
pub total_supply: num_bigint::BigInt,
487487
pub mintable: bool,
488-
#[serde(with = "serde_helpers::option_tonlib_address")]
488+
#[serde(with = "tonlib_address_or_empty")]
489489
pub admin_address: Option<StdAddr>,
490490
#[serde(serialize_with = "JettonMasterData::serialize_jetton_conent")]
491491
pub jetton_content: TokenDataAttributes,
@@ -908,9 +908,9 @@ pub struct TonlibMessage {
908908
pub ty: &'static str,
909909
#[serde(with = "serde_helpers::tonlib_hash")]
910910
pub hash: HashBytes,
911-
#[serde(with = "serde_helpers::option_tonlib_address")]
911+
#[serde(with = "tonlib_address_or_empty")]
912912
pub source: Option<StdAddr>,
913-
#[serde(with = "serde_helpers::option_tonlib_address")]
913+
#[serde(with = "tonlib_address_or_empty")]
914914
pub destination: Option<StdAddr>,
915915
#[serde(with = "serde_helpers::string")]
916916
pub value: Tokens,
@@ -1818,6 +1818,20 @@ mod code_hash {
18181818
]);
18191819
}
18201820

1821+
mod tonlib_address_or_empty {
1822+
use super::*;
1823+
1824+
pub fn serialize<S>(value: &Option<StdAddr>, serializer: S) -> Result<S::Ok, S::Error>
1825+
where
1826+
S: serde::Serializer,
1827+
{
1828+
match value {
1829+
Some(value) => serde_helpers::tonlib_address::serialize(value, serializer),
1830+
None => serializer.serialize_str(""),
1831+
}
1832+
}
1833+
}
1834+
18211835
#[cfg(test)]
18221836
mod tests {
18231837
use super::*;

0 commit comments

Comments
 (0)