diff --git a/docs/MESSAGE_TYPES.md b/docs/MESSAGE_TYPES.md index e69b8c3d6f..e9258c8f32 100644 --- a/docs/MESSAGE_TYPES.md +++ b/docs/MESSAGE_TYPES.md @@ -31,6 +31,7 @@ Rust types as well as `cosmwasm_std` types and how they are encoded in JSON. | [Binary] | string containing base64 data | `"MTIzCg=="` | | | [HexBinary] | string containing hex data | `"b5d7d24e428c"` | | | [Timestamp] | string containing nanoseconds since epoch | `"1677687687000000000"` | | +| [Order] | string containing order variant | `"ascending"` or `"descending"` | | [uint64]: https://docs.rs/cosmwasm-std/1.3.3/cosmwasm_std/struct.Uint64.html [uint128]: https://docs.rs/cosmwasm-std/1.3.3/cosmwasm_std/struct.Uint128.html @@ -48,6 +49,7 @@ Rust types as well as `cosmwasm_std` types and how they are encoded in JSON. https://docs.rs/cosmwasm-std/1.3.3/cosmwasm_std/struct.HexBinary.html [timestamp]: https://docs.rs/cosmwasm-std/1.3.3/cosmwasm_std/struct.Timestamp.html +[order]: https://docs.rs/cosmwasm-std/1.3.3/cosmwasm_std/enum.Order.html [dev-note-4]: https://medium.com/cosmwasm/dev-note-4-u128-i128-serialization-in-cosmwasm-90cb76784d44 diff --git a/packages/std/src/iterator.rs b/packages/std/src/iterator.rs index 4f39c2bcfc..41f043a093 100644 --- a/packages/std/src/iterator.rs +++ b/packages/std/src/iterator.rs @@ -33,3 +33,29 @@ impl From for i32 { original as _ } } + +#[cfg(test)] +mod tests { + use crate::{from_json, to_json_vec}; + + use super::*; + + #[test] + fn order_serde() { + let ascending_bytes = br#""ascending""#; + let descending_bytes = br#""descending""#; + + assert_eq!(to_json_vec(&Order::Ascending).unwrap(), ascending_bytes); + assert_eq!(to_json_vec(&Order::Descending).unwrap(), descending_bytes); + + assert_eq!( + from_json::(ascending_bytes).unwrap(), + Order::Ascending + ); + + assert_eq!( + from_json::(descending_bytes).unwrap(), + Order::Descending + ); + } +}