Skip to content

Commit

Permalink
use constant for wasm client-id prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
rnbguy committed Jun 5, 2024
1 parent ebd2327 commit 43b88a6
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions ibc-core/ics24-host/types/src/identifiers/client_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,14 @@ impl ClientId {

/// Check if the client identifier is for 08-wasm light client.
pub fn is_wasm_client_id(&self) -> bool {
const WASM_CLIENT_PREFIX: &str = "08-wasm-";

// prefixed with wasm client type identifier.
self.0.starts_with("08-wasm-")
self.0.starts_with(WASM_CLIENT_PREFIX)
// followed by non-empty string.
&& self.0.len() > "08-wasm-".len()
&& self.0.len() > WASM_CLIENT_PREFIX.len()
// and the rest of the string is numeric.
&& self.0.chars().skip("08-wasm-".len()).all(char::is_numeric)
&& self.0.chars().skip(WASM_CLIENT_PREFIX.len()).all(char::is_numeric)
}
}

Expand Down

0 comments on commit 43b88a6

Please sign in to comment.