Skip to content

Commit 616cff4

Browse files
authored
Merge pull request #2392 from CosmWasm/rm-deprecated
Remove from_slice, from_binary, to_vec, to_binary
2 parents 961bdd8 + 85f74a5 commit 616cff4

File tree

5 files changed

+12
-39
lines changed

5 files changed

+12
-39
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ and this project adheres to
3434
- cosmwasm-vm: Charge gas for `write_region` ([#2378])
3535
- cosmwasm-vm: Remove the `cranelift` feature. This was doing nothing since
3636
2.2.0 already. ([#2262])
37+
- cosmwasm-std: Remove previously deprecated `from_slice`, `from_binary`,
38+
`to_vec` and `to_binary`. ([#2156])
3739

3840
## Fixed
3941

@@ -42,6 +44,7 @@ and this project adheres to
4244
- cosmwasm-vm: Fix CWA-2025-002.
4345

4446
[#2155]: https://github.com/CosmWasm/cosmwasm/issues/2155
47+
[#2156]: https://github.com/CosmWasm/cosmwasm/issues/2156
4548
[#2262]: https://github.com/CosmWasm/cosmwasm/issues/2262
4649
[#2268]: https://github.com/CosmWasm/cosmwasm/issues/2268
4750
[#2269]: https://github.com/CosmWasm/cosmwasm/issues/2269

packages/std/src/lib.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,7 @@ pub use crate::results::{
111111
pub use crate::results::{DistributionMsg, StakingMsg};
112112
#[cfg(feature = "stargate")]
113113
pub use crate::results::{GovMsg, VoteOption};
114-
#[allow(deprecated)]
115-
pub use crate::serde::{
116-
from_binary, from_json, from_slice, to_binary, to_json_binary, to_json_string, to_json_vec,
117-
to_vec,
118-
};
114+
pub use crate::serde::{from_json, to_json_binary, to_json_string, to_json_vec};
119115
pub use crate::stdack::StdAck;
120116
pub use crate::storage::MemoryStorage;
121117
pub use crate::timestamp::Timestamp;

packages/std/src/results/contract_result.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,19 @@ use crate::prelude::*;
1717
/// Success:
1818
///
1919
/// ```
20-
/// # use cosmwasm_std::{to_vec, ContractResult, Response};
20+
/// # use cosmwasm_std::{to_json_string, ContractResult, Response};
2121
/// let response: Response = Response::default();
2222
/// let result: ContractResult<Response> = ContractResult::Ok(response);
23-
/// assert_eq!(to_vec(&result).unwrap(), br#"{"ok":{"messages":[],"attributes":[],"events":[],"data":null}}"#);
23+
/// assert_eq!(to_json_string(&result).unwrap(), r#"{"ok":{"messages":[],"attributes":[],"events":[],"data":null}}"#);
2424
/// ```
2525
///
2626
/// Failure:
2727
///
2828
/// ```
29-
/// # use cosmwasm_std::{to_vec, ContractResult, Response};
29+
/// # use cosmwasm_std::{to_json_string, ContractResult, Response};
3030
/// let error_msg = String::from("Something went wrong");
3131
/// let result: ContractResult<Response> = ContractResult::Err(error_msg);
32-
/// assert_eq!(to_vec(&result).unwrap(), br#"{"error":"Something went wrong"}"#);
32+
/// assert_eq!(to_json_string(&result).unwrap(), r#"{"error":"Something went wrong"}"#);
3333
/// ```
3434
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
3535
#[serde(rename_all = "snake_case")]

packages/std/src/results/system_result.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,19 @@ use crate::SystemError;
1616
/// Success:
1717
///
1818
/// ```
19-
/// # use cosmwasm_std::{to_vec, Binary, ContractResult, SystemResult};
19+
/// # use cosmwasm_std::{to_json_string, Binary, ContractResult, SystemResult};
2020
/// let data = Binary::from(b"hello, world");
2121
/// let result = SystemResult::Ok(ContractResult::Ok(data));
22-
/// assert_eq!(to_vec(&result).unwrap(), br#"{"ok":{"ok":"aGVsbG8sIHdvcmxk"}}"#);
22+
/// assert_eq!(to_json_string(&result).unwrap(), r#"{"ok":{"ok":"aGVsbG8sIHdvcmxk"}}"#);
2323
/// ```
2424
///
2525
/// Failure:
2626
///
2727
/// ```
28-
/// # use cosmwasm_std::{to_vec, Binary, ContractResult, SystemResult, SystemError};
28+
/// # use cosmwasm_std::{to_json_string, Binary, ContractResult, SystemResult, SystemError};
2929
/// let error = SystemError::Unknown {};
3030
/// let result: SystemResult<Binary> = SystemResult::Err(error);
31-
/// assert_eq!(to_vec(&result).unwrap(), br#"{"error":{"unknown":{}}}"#);
31+
/// assert_eq!(to_json_string(&result).unwrap(), r#"{"error":{"unknown":{}}}"#);
3232
/// ```
3333
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
3434
#[serde(rename_all = "snake_case")]

packages/std/src/serde.rs

-26
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,6 @@ use serde::{de::DeserializeOwned, Serialize};
99
use crate::Binary;
1010
use crate::{StdError, StdResult};
1111

12-
#[deprecated = "use from_json instead"]
13-
pub fn from_slice<T: DeserializeOwned>(value: &[u8]) -> StdResult<T> {
14-
from_json(value)
15-
}
16-
17-
#[deprecated = "use from_json instead"]
18-
pub fn from_binary<T: DeserializeOwned>(value: &Binary) -> StdResult<T> {
19-
from_json(value)
20-
}
21-
2212
/// Deserializes the given JSON bytes to a data structure.
2313
///
2414
/// Errors if the input is not valid JSON or cannot be deserialized to the given type.
@@ -27,22 +17,6 @@ pub fn from_json<T: DeserializeOwned>(value: impl AsRef<[u8]>) -> StdResult<T> {
2717
.map_err(|e| StdError::parse_err(type_name::<T>(), e))
2818
}
2919

30-
#[deprecated = "use to_json_vec instead"]
31-
pub fn to_vec<T>(data: &T) -> StdResult<Vec<u8>>
32-
where
33-
T: Serialize + ?Sized,
34-
{
35-
to_json_vec(data)
36-
}
37-
38-
#[deprecated = "use to_json_binary instead"]
39-
pub fn to_binary<T>(data: &T) -> StdResult<Binary>
40-
where
41-
T: Serialize + ?Sized,
42-
{
43-
to_json_binary(data)
44-
}
45-
4620
/// Serializes the given data structure as a JSON byte vector.
4721
pub fn to_json_vec<T>(data: &T) -> StdResult<Vec<u8>>
4822
where

0 commit comments

Comments
 (0)