1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//! Definitions of domain types used in the ICS-08 Wasm light client implementation.
#![forbid(unsafe_code)]
#![cfg_attr(not(feature = "std"), no_std)]
#![cfg_attr(not(test), deny(clippy::unwrap_used))]
#![cfg_attr(not(test), deny(clippy::disallowed_methods, clippy::disallowed_types))]
#![deny(
    warnings,
    trivial_casts,
    trivial_numeric_casts,
    unused_import_braces,
    unused_qualifications,
    rust_2018_idioms
)]

pub mod client_message;
pub mod client_state;
pub mod consensus_state;
pub mod error;
pub mod msgs;

#[cfg(feature = "cosmwasm")]
pub mod serializer;

use core::str::FromStr;

use ibc_core_host_types::identifiers::ClientType;
#[cfg(not(feature = "std"))]
use ibc_primitives::prelude::Vec;

pub type Bytes = Vec<u8>;

/// Re-exports ICS-08 Wasm light client proto types from `ibc-proto` crate.
pub mod proto {
    pub use ibc_proto::ibc::lightclients::wasm::*;
}

pub static SUBJECT_PREFIX: &[u8] = b"subject/";
pub static SUBSTITUTE_PREFIX: &[u8] = b"substitute/";

pub const WASM_CLIENT_TYPE: &str = "08-wasm";

/// Returns the wasm `ClientType`
pub fn client_type() -> ClientType {
    ClientType::from_str(WASM_CLIENT_TYPE).expect("Never fails because it's valid")
}

#[cfg(test)]
mod tests {
    use super::*;

    // Ensures that the validation in `ClientType::from_str` doesn't fail for the wasm client type
    #[test]
    pub fn test_wasm_client_type() {
        let _ = ClientType::from_str(WASM_CLIENT_TYPE).unwrap();
    }
}