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

[1.5] Deprecate compact serialization of Binary, HexBinary #2126

Merged
merged 4 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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 @@ -22,9 +22,12 @@ and this project adheres to

- cosmwasm-std: Let `Timestamp::plus_nanos`/`::minus_nanos` use
`Uint64::strict_add`/`::strict_sub` and document overflows. ([#2098], [#2107])
- cosmwasm-std: Deprecate "compact" serialization of `Binary`, `HexBinary`,
`Checksum` ([#2126])
uint marked this conversation as resolved.
Show resolved Hide resolved

[#2098]: https://github.com/CosmWasm/cosmwasm/pull/2098
[#2107]: https://github.com/CosmWasm/cosmwasm/pull/2107
[#2126]: https://github.com/CosmWasm/cosmwasm/pull/2126

### Fixed

Expand Down
12 changes: 10 additions & 2 deletions packages/std/src/binary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,11 @@
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.")

Check warning on line 220 in packages/std/src/binary.rs

View check run for this annotation

Codecov / codecov/patch

packages/std/src/binary.rs#L220

Added line #L220 was not covered by tests
}
}
}

Expand All @@ -224,7 +228,11 @@
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.")

Check warning on line 234 in packages/std/src/binary.rs

View check run for this annotation

Codecov / codecov/patch

packages/std/src/binary.rs#L234

Added line #L234 was not covered by tests
}
}
}

Expand Down
12 changes: 10 additions & 2 deletions packages/std/src/hex_binary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,11 @@
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.")

Check warning on line 215 in packages/std/src/hex_binary.rs

View check run for this annotation

Codecov / codecov/patch

packages/std/src/hex_binary.rs#L215

Added line #L215 was not covered by tests
}
}
}

Expand All @@ -219,7 +223,11 @@
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.")

Check warning on line 229 in packages/std/src/hex_binary.rs

View check run for this annotation

Codecov / codecov/patch

packages/std/src/hex_binary.rs#L229

Added line #L229 was not covered by tests
}
}
}

Expand Down
Loading