-
Notifications
You must be signed in to change notification settings - Fork 832
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
base: main
Are you sure you want to change the base?
refactor(voyager): ensure_ibc_interface supports multiple interfaces #3578
Conversation
@kayandra is attempting to deploy a commit to the unionbuild Team on Vercel. A member of the Team first needs to authorize it. |
@@ -176,12 +176,18 @@ impl ClientModuleInfo { | |||
|
|||
pub fn ensure_ibc_interface( | |||
&self, | |||
ibc_interface: impl AsRef<str>, | |||
expected_interfaces: Vec<impl AsRef<str>>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of Vec, you can take impl IntoIterator<Item = impl AsRef<str>>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gotcha
@@ -47,7 +47,7 @@ impl ClientModule for Module { | |||
async fn new(config: Self::Config, info: ClientModuleInfo) -> Result<Self, BoxDynError> { | |||
info.ensure_client_type(ClientType::ETHEREUM)?; | |||
info.ensure_consensus_type(ConsensusType::ETHEREUM)?; | |||
info.ensure_ibc_interface(IbcInterface::IBC_COSMWASM)?; | |||
info.ensure_ibc_interface(vec![IbcInterface::IBC_COSMWASM])?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you change this to accept impl IntoIterator<Item = impl AsRef<str>>
, you can simply pass [IbcInterface::IBC_COSMWASM]
here
@@ -46,7 +46,7 @@ impl ClientModule for Module { | |||
async fn new(Config {}: Self::Config, info: ClientModuleInfo) -> Result<Self, BoxDynError> { | |||
info.ensure_client_type(ClientType::MOVEMENT)?; | |||
info.ensure_consensus_type(ConsensusType::MOVEMENT)?; | |||
info.ensure_ibc_interface(IbcInterface::IBC_COSMWASM)?; | |||
info.ensure_ibc_interface(vec![IbcInterface::IBC_COSMWASM])?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ibid
@@ -46,7 +46,7 @@ impl ClientModule for Module { | |||
async fn new(_: Self::Config, info: ClientModuleInfo) -> Result<Self, BoxDynError> { | |||
info.ensure_client_type(ClientType::STATE_LENS_ICS23_ICS23)?; | |||
info.ensure_consensus_type(ConsensusType::TENDERMINT)?; | |||
info.ensure_ibc_interface(IbcInterface::IBC_SOLIDITY)?; | |||
info.ensure_ibc_interface(vec![IbcInterface::IBC_COSMWASM])?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ibid
@@ -81,8 +81,7 @@ impl ClientModule for Module { | |||
async fn new(_: Self::Config, info: ClientModuleInfo) -> Result<Self, BoxDynError> { | |||
info.ensure_client_type(ClientType::STATE_LENS_ICS23_MPT)?; | |||
info.ensure_consensus_type(ConsensusType::ETHEREUM)?; | |||
info.ensure_ibc_interface(IbcInterface::IBC_SOLIDITY) | |||
.or(info.ensure_ibc_interface(IbcInterface::IBC_COSMWASM))?; | |||
info.ensure_ibc_interface(vec![IbcInterface::IBC_SOLIDITY, IbcInterface::IBC_COSMWASM])?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ibid
#[cfg(not(feature = "library"))] | ||
use cosmwasm_std::entry_point; | ||
use cosmwasm_std::{ | ||
attr, entry_point, DepsMut, Env, IbcBasicResponse, IbcChannel, IbcChannelCloseMsg, | ||
IbcChannelConnectMsg, IbcChannelOpenMsg, IbcOrder, IbcPacket, IbcPacketAckMsg, | ||
IbcPacketReceiveMsg, IbcPacketTimeoutMsg, IbcReceiveResponse, Reply, Response, StdError, | ||
attr, DepsMut, Env, IbcBasicResponse, IbcChannel, IbcChannelCloseMsg, IbcChannelConnectMsg, | ||
IbcChannelOpenMsg, IbcOrder, IbcPacket, IbcPacketAckMsg, IbcPacketReceiveMsg, | ||
IbcPacketTimeoutMsg, IbcReceiveResponse, Reply, Response, StdError, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are these changes related to this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
got a warning in my editor, so i cleaned it. should have made it a separate commit.
if !expected_interfaces | ||
.iter() | ||
.any(|expected| expected.as_ref() == self.ibc_interface.as_str()) | ||
{ | ||
Err(UnexpectedIbcInterfaceError { | ||
expected: self.ibc_interface.clone(), | ||
found: ibc_interface.as_ref().to_owned(), | ||
found: expected_interfaces | ||
.iter() | ||
.map(|s| s.as_ref().to_string()) | ||
.collect(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think we actually have all of these backwards now that i look at it - all of the Unexpected*Error
found
/expected
semantics should be switched such that the found
contains what was in the config (i.e. self.ibc_interface
in this context) and expected contains the list of supported values.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gotcha, will fix.
Allow checking an interface against multiple expected values by taking a Vec of interfaces.
Updates error type to show all valid interfaces in error message.
Ref #3438