Skip to content

Commit

Permalink
feat: search by name case insensitive
Browse files Browse the repository at this point in the history
  • Loading branch information
marktoda committed Jan 1, 2025
1 parent 4cd24ad commit 8be2d14
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,17 +165,11 @@ impl Config {
pub fn get_chain(&self, name_or_id: &str) -> Result<ChainDefinition> {
// Try to parse as chain ID first
if let Ok(chain_id) = name_or_id.parse::<u64>() {
if let Some(chain) = self.chains.iter().find(|c| c.chain_id == chain_id) {
return Ok(chain.clone());
}
return self.get_chain_config_by_id(chain_id);
}

// Try as name
if let Some(chain) = self.chains.iter().find(|c| c.name == name_or_id) {
return Ok(chain.clone());
}

Err(anyhow!("Chain '{}' not found", name_or_id))
self.get_chain_config_by_name(name_or_id)
}

pub fn get_chain_config_by_name(&self, name: &str) -> Result<ChainDefinition> {
Expand Down

0 comments on commit 8be2d14

Please sign in to comment.