Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[main] Deprecate compact serialization of Binary, HexBinary, Checksum #2125

Merged
merged 4 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ and this project adheres to
- cosmwasm-schema: `#[cw_serde]` now doesn't add `#[serde(deny_unknown_fields)]`
to the expanded code anymore ([#2080])
- cosmwasm-std: Improve performance of `Uint{64,128,256,512}::isqrt` ([#2108])
- cosmwasm-std: Deprecate "compact" serialization of `Binary`, `HexBinary`,
`Checksum` ([#2125])

[#2044]: https://github.com/CosmWasm/cosmwasm/pull/2044
[#2051]: https://github.com/CosmWasm/cosmwasm/pull/2051
Expand All @@ -60,6 +62,7 @@ and this project adheres to
[#2070]: https://github.com/CosmWasm/cosmwasm/pull/2070
[#2080]: https://github.com/CosmWasm/cosmwasm/pull/2080
[#2108]: https://github.com/CosmWasm/cosmwasm/pull/2108
[#2125]: https://github.com/CosmWasm/cosmwasm/pull/2125

## [2.0.1] - 2024-04-03

Expand Down
12 changes: 10 additions & 2 deletions packages/core/src/binary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,11 @@ impl Serialize for Binary {
where
S: ser::Serializer,
{
serializer.serialize_str(&self.to_base64())
if serializer.is_human_readable() {
serializer.serialize_str(&self.to_base64())
} else {
panic!("Binary is only intended to be used with JSON serialization for now. If you are hitting this panic please open an issue at https://github.com/CosmWasm/cosmwasm describing your use case.")
}
}
}

Expand All @@ -219,7 +223,11 @@ impl<'de> Deserialize<'de> for Binary {
where
D: Deserializer<'de>,
{
deserializer.deserialize_str(Base64Visitor)
if deserializer.is_human_readable() {
deserializer.deserialize_str(Base64Visitor)
} else {
panic!("Binary is only intended to be used with JSON serialization for now. If you are hitting this panic please open an issue at https://github.com/CosmWasm/cosmwasm describing your use case.")
}
}
}

Expand Down
12 changes: 10 additions & 2 deletions packages/core/src/hex_binary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,11 @@ impl Serialize for HexBinary {
where
S: ser::Serializer,
{
serializer.serialize_str(&self.to_hex())
if serializer.is_human_readable() {
serializer.serialize_str(&self.to_hex())
} else {
panic!("HexBinary is only intended to be used with JSON serialization for now. If you are hitting this panic please open an issue at https://github.com/CosmWasm/cosmwasm describing your use case.")
}
}
}

Expand All @@ -222,7 +226,11 @@ impl<'de> Deserialize<'de> for HexBinary {
where
D: Deserializer<'de>,
{
deserializer.deserialize_str(HexVisitor)
if deserializer.is_human_readable() {
deserializer.deserialize_str(HexVisitor)
} else {
panic!("HexBinary is only intended to be used with JSON serialization for now. If you are hitting this panic please open an issue at https://github.com/CosmWasm/cosmwasm describing your use case.")
}
}
}

Expand Down
12 changes: 10 additions & 2 deletions packages/std/src/checksum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,11 @@ impl Serialize for Checksum {
where
S: ser::Serializer,
{
serializer.serialize_str(&self.to_hex())
if serializer.is_human_readable() {
serializer.serialize_str(&self.to_hex())
} else {
panic!("Checksum is only intended to be used with JSON serialization for now. If you are hitting this panic please open an issue at https://github.com/CosmWasm/cosmwasm describing your use case.")
}
}
}

Expand All @@ -81,7 +85,11 @@ impl<'de> Deserialize<'de> for Checksum {
where
D: Deserializer<'de>,
{
deserializer.deserialize_str(ChecksumVisitor)
if deserializer.is_human_readable() {
deserializer.deserialize_str(ChecksumVisitor)
} else {
panic!("Checksum is only intended to be used with JSON serialization for now. If you are hitting this panic please open an issue at https://github.com/CosmWasm/cosmwasm describing your use case.")
}
}
}

Expand Down