ibc_client_wasm_types/
lib.rs

1//! Definitions of domain types used in the ICS-08 Wasm light client implementation.
2#![forbid(unsafe_code)]
3#![cfg_attr(not(feature = "std"), no_std)]
4#![cfg_attr(not(test), deny(clippy::unwrap_used))]
5#![cfg_attr(not(test), deny(clippy::disallowed_methods, clippy::disallowed_types))]
6#![deny(
7    warnings,
8    trivial_casts,
9    trivial_numeric_casts,
10    unused_import_braces,
11    unused_qualifications,
12    rust_2018_idioms
13)]
14
15pub mod client_message;
16pub mod client_state;
17pub mod consensus_state;
18pub mod msgs;
19
20#[cfg(feature = "serde")]
21pub mod serializer;
22
23use core::str::FromStr;
24
25use ibc_core_host_types::identifiers::ClientType;
26#[cfg(not(feature = "std"))]
27use ibc_primitives::prelude::Vec;
28
29pub type Bytes = Vec<u8>;
30
31/// Re-exports ICS-08 Wasm light client proto types from `ibc-proto` crate.
32pub mod proto {
33    pub use ibc_proto::ibc::lightclients::wasm::*;
34}
35
36pub static SUBJECT_PREFIX: &[u8] = b"subject/";
37pub static SUBSTITUTE_PREFIX: &[u8] = b"substitute/";
38
39pub const WASM_CLIENT_TYPE: &str = "08-wasm";
40
41/// Returns the wasm `ClientType`
42pub fn client_type() -> ClientType {
43    ClientType::from_str(WASM_CLIENT_TYPE).expect("Never fails because it's valid")
44}
45
46#[cfg(test)]
47mod tests {
48    use super::*;
49
50    // Ensures that the validation in `ClientType::from_str` doesn't fail for the wasm client type
51    #[test]
52    pub fn test_wasm_client_type() {
53        let _ = ClientType::from_str(WASM_CLIENT_TYPE).unwrap();
54    }
55}