From 43b88a6971c9c98e185263d4800b5f11f3deb406 Mon Sep 17 00:00:00 2001 From: Ranadeep Biswas Date: Wed, 5 Jun 2024 15:44:06 +0200 Subject: [PATCH] use constant for wasm client-id prefix --- ibc-core/ics24-host/types/src/identifiers/client_id.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ibc-core/ics24-host/types/src/identifiers/client_id.rs b/ibc-core/ics24-host/types/src/identifiers/client_id.rs index f2e90acbd..d0128336b 100644 --- a/ibc-core/ics24-host/types/src/identifiers/client_id.rs +++ b/ibc-core/ics24-host/types/src/identifiers/client_id.rs @@ -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) } }