penumbra_sdk_ibc/
genesis.rs

1use anyhow::Context;
2use penumbra_sdk_proto::{penumbra::core::component::ibc::v1 as pb, DomainType};
3use serde::{Deserialize, Serialize};
4
5use crate::params::IBCParameters;
6
7#[derive(Deserialize, Serialize, Debug, Clone, Default)]
8#[serde(try_from = "pb::GenesisContent", into = "pb::GenesisContent")]
9pub struct Content {
10    /// The initial configuration parameters for the IBC component.
11    pub ibc_params: IBCParameters,
12}
13
14impl From<Content> for pb::GenesisContent {
15    fn from(value: Content) -> Self {
16        pb::GenesisContent {
17            ibc_params: Some(value.ibc_params.into()),
18        }
19    }
20}
21
22impl TryFrom<pb::GenesisContent> for Content {
23    type Error = anyhow::Error;
24
25    fn try_from(msg: pb::GenesisContent) -> Result<Self, Self::Error> {
26        Ok(Content {
27            ibc_params: msg
28                .ibc_params
29                .context("ibc params not present in protobuf message")?
30                .try_into()?,
31        })
32    }
33}
34
35impl DomainType for Content {
36    type Proto = pb::GenesisContent;
37}