Skip to content

Commit

Permalink
governance: validate client ID check earlier than component/view.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
redshiftzero committed Sep 16, 2024
1 parent 90b0a55 commit b8571a4
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions crates/core/component/governance/src/proposal.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use anyhow::Context;
use bytes::Bytes;
use ibc_types::core::client::ClientId;
use serde::{Deserialize, Serialize};
use std::str::FromStr;

Expand Down Expand Up @@ -144,6 +145,9 @@ impl TryFrom<pb::Proposal> for Proposal {
if freeze_ibc_client.client_id.len() > 128 {
anyhow::bail!("client ID must be less than 128 bytes");
}
// Validation: Check the client ID is valid using the validation inside `ClientId::from_str`.
ClientId::from_str(&freeze_ibc_client.client_id)
.map_err(|e| anyhow::anyhow!("invalid client id: {e}"))?;
ProposalPayload::FreezeIbcClient {
client_id: freeze_ibc_client.client_id,
}
Expand All @@ -153,6 +157,9 @@ impl TryFrom<pb::Proposal> for Proposal {
if unfreeze_ibc_client.client_id.len() > 128 {
anyhow::bail!("client ID must be less than 128 bytes");
}
// Validation: Check the client ID is valid using the validation inside `ClientId::from_str`.
ClientId::from_str(&unfreeze_ibc_client.client_id)
.map_err(|e| anyhow::anyhow!("invalid client id: {e}"))?;
ProposalPayload::UnfreezeIbcClient {
client_id: unfreeze_ibc_client.client_id,
}
Expand Down

0 comments on commit b8571a4

Please sign in to comment.