Skip to content

Merge cosmos sdk state modules #3526

Open
@benluelo

Description

@benluelo

Currently we have two separate modules for reading state from cosmos sdk based chains:

https://github.com/unionlabs/union/tree/5f9b75ea6e035937a082097a33370783d7447ada/voyager/modules/state/cosmos-sdk
https://github.com/unionlabs/union/tree/5f9b75ea6e035937a082097a33370783d7447ada/voyager/modules/state/cosmos-sdk-union

These should be merged into one, switching the querying logic based on

pub ibc_spec_id: IbcSpecId,

The implementation should use a pattern similar to this:

#[derive(Debug, Clone, PartialEq, Copy, serde::Serialize, serde::Deserialize)]
#[serde(try_from = "String", into = "String")]
pub enum SupportedIbcInterface {
IbcSolidity,
IbcCosmwasm,
}
impl TryFrom<String> for SupportedIbcInterface {
// TODO: Better error type here
type Error = String;
fn try_from(value: String) -> Result<Self, Self::Error> {
match &*value {
IbcInterface::IBC_SOLIDITY => Ok(SupportedIbcInterface::IbcSolidity),
IbcInterface::IBC_COSMWASM => Ok(SupportedIbcInterface::IbcCosmwasm),
_ => Err(format!("unsupported IBC interface: `{value}`")),
}
}
}
impl SupportedIbcInterface {
fn as_str(&self) -> &'static str {
match self {
SupportedIbcInterface::IbcSolidity => IbcInterface::IBC_SOLIDITY,
SupportedIbcInterface::IbcCosmwasm => IbcInterface::IBC_COSMWASM,
}
}
}
impl From<SupportedIbcInterface> for String {
fn from(value: SupportedIbcInterface) -> Self {
value.as_str().to_owned()
}
}

using an enum like this:

pub enum SupportedIbcSpec {
    IbcUnion,
    IbcClassic,
}

and then match on this value in every method.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-voyagerArea: voyager (relayer)C-enhancementCategory: An issue proposing an enhancement or a PR with one.E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions