Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(voyager): ensure_ibc_interface supports multiple interfaces #3578

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
refactor: cleanup ensure_ibc_interface
kayandra committed Jan 30, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit b50f591fc814af8c4e801dc92f5da653e9fa2aea
14 changes: 7 additions & 7 deletions lib/voyager-message/src/module.rs
Original file line number Diff line number Diff line change
@@ -176,19 +176,19 @@ impl ClientModuleInfo {

pub fn ensure_ibc_interface(
&self,
expected_interfaces: impl IntoIterator<Item = impl AsRef<str>>,
expected_interfaces: impl IntoIterator<Item = &'static str>,
) -> Result<(), UnexpectedIbcInterfaceError> {
let expected_interfaces: Vec<String> = expected_interfaces
let expected_interfaces: Vec<IbcInterface> = expected_interfaces
.into_iter()
.map(|s| s.as_ref().to_string())
.map(IbcInterface::new)
.collect();

if !expected_interfaces
.iter()
.any(|expected| expected == self.ibc_interface.as_str())
.any(|e| e.as_str() == self.ibc_interface.as_str())
{
Err(UnexpectedIbcInterfaceError {
expected: expected_interfaces.join(","),
expected: expected_interfaces,
found: self.ibc_interface.to_string(),
})
} else {
@@ -277,9 +277,9 @@ pub struct UnexpectedClientTypeError {
}

#[derive(Debug, Clone, thiserror::Error)]
#[error("invalid IBC interface: this module provides functionality for IBC interfaces `{expected}`, but the config specifies `{found}`")]
#[error("invalid IBC interface: this module provides functionality for IBC interfaces `{expected}`, but the config specifies `{found}`", expected = expected.into_iter().map(|x| x.as_str()).collect::<Vec<_>>().join(","))]
pub struct UnexpectedIbcInterfaceError {
pub expected: String,
pub expected: Vec<IbcInterface>,
pub found: String,
}