Skip to content

Commit

Permalink
Use to_json_string instead of to_json_vec for easier equality check
Browse files Browse the repository at this point in the history
  • Loading branch information
webmaster128 committed Feb 21, 2025
1 parent 3d42638 commit 85f74a5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions packages/std/src/results/contract_result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@ use crate::prelude::*;
/// Success:
///
/// ```
/// # use cosmwasm_std::{to_json_vec, ContractResult, Response};
/// # use cosmwasm_std::{to_json_string, ContractResult, Response};
/// let response: Response = Response::default();
/// let result: ContractResult<Response> = ContractResult::Ok(response);
/// assert_eq!(to_json_vec(&result).unwrap(), br#"{"ok":{"messages":[],"attributes":[],"events":[],"data":null}}"#);
/// assert_eq!(to_json_string(&result).unwrap(), r#"{"ok":{"messages":[],"attributes":[],"events":[],"data":null}}"#);
/// ```
///
/// Failure:
///
/// ```
/// # use cosmwasm_std::{to_json_vec, ContractResult, Response};
/// # use cosmwasm_std::{to_json_string, ContractResult, Response};
/// let error_msg = String::from("Something went wrong");
/// let result: ContractResult<Response> = ContractResult::Err(error_msg);
/// assert_eq!(to_json_vec(&result).unwrap(), br#"{"error":"Something went wrong"}"#);
/// assert_eq!(to_json_string(&result).unwrap(), r#"{"error":"Something went wrong"}"#);
/// ```
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
#[serde(rename_all = "snake_case")]
Expand Down
8 changes: 4 additions & 4 deletions packages/std/src/results/system_result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@ use crate::SystemError;
/// Success:
///
/// ```
/// # use cosmwasm_std::{to_json_vec, Binary, ContractResult, SystemResult};
/// # use cosmwasm_std::{to_json_string, Binary, ContractResult, SystemResult};
/// let data = Binary::from(b"hello, world");
/// let result = SystemResult::Ok(ContractResult::Ok(data));
/// assert_eq!(to_json_vec(&result).unwrap(), br#"{"ok":{"ok":"aGVsbG8sIHdvcmxk"}}"#);
/// assert_eq!(to_json_string(&result).unwrap(), r#"{"ok":{"ok":"aGVsbG8sIHdvcmxk"}}"#);
/// ```
///
/// Failure:
///
/// ```
/// # use cosmwasm_std::{to_json_vec, Binary, ContractResult, SystemResult, SystemError};
/// # use cosmwasm_std::{to_json_string, Binary, ContractResult, SystemResult, SystemError};
/// let error = SystemError::Unknown {};
/// let result: SystemResult<Binary> = SystemResult::Err(error);
/// assert_eq!(to_json_vec(&result).unwrap(), br#"{"error":{"unknown":{}}}"#);
/// assert_eq!(to_json_string(&result).unwrap(), r#"{"error":{"unknown":{}}}"#);
/// ```
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
#[serde(rename_all = "snake_case")]
Expand Down

0 comments on commit 85f74a5

Please sign in to comment.