penumbra_sdk_app/
penumbra_host_chain.rs

1use async_trait::async_trait;
2use penumbra_sdk_ibc::component::HostInterface;
3use penumbra_sdk_sct::component::clock::EpochRead;
4
5use crate::app::StateReadExt;
6
7/// The implementation of [`penumbra_sdk_ibc::component::HostInterface`] for Penumbra.
8/// It encapsulates all of the chain-specific data that the ibc implementation needs.
9#[derive(Clone)]
10pub struct PenumbraHost {}
11
12#[async_trait]
13impl HostInterface for PenumbraHost {
14    async fn get_chain_id<S: cnidarium::StateRead>(state: S) -> anyhow::Result<String> {
15        state.get_chain_id().await
16    }
17
18    async fn get_revision_number<S: cnidarium::StateRead>(state: S) -> anyhow::Result<u64> {
19        state.get_revision_number().await
20    }
21
22    async fn get_block_height<S: cnidarium::StateRead>(state: S) -> anyhow::Result<u64> {
23        state.get_block_height().await
24    }
25
26    async fn get_block_timestamp<S: cnidarium::StateRead>(
27        state: S,
28    ) -> anyhow::Result<tendermint::Time> {
29        state.get_current_block_timestamp().await
30    }
31}