penumbra_sdk_ibc/
params.rs

1use penumbra_sdk_proto::core::component::ibc::v1 as pb;
2use penumbra_sdk_proto::DomainType;
3use serde::{Deserialize, Serialize};
4
5#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
6#[serde(try_from = "pb::IbcParameters", into = "pb::IbcParameters")]
7pub struct IBCParameters {
8    /// Whether IBC (forming connections, processing IBC packets) is enabled.
9    pub ibc_enabled: bool,
10    /// Whether inbound ICS-20 transfers are enabled
11    pub inbound_ics20_transfers_enabled: bool,
12    /// Whether outbound ICS-20 transfers are enabled
13    pub outbound_ics20_transfers_enabled: bool,
14}
15
16impl DomainType for IBCParameters {
17    type Proto = pb::IbcParameters;
18}
19
20impl TryFrom<pb::IbcParameters> for IBCParameters {
21    type Error = anyhow::Error;
22
23    fn try_from(msg: pb::IbcParameters) -> anyhow::Result<Self> {
24        Ok(IBCParameters {
25            ibc_enabled: msg.ibc_enabled,
26            inbound_ics20_transfers_enabled: msg.inbound_ics20_transfers_enabled,
27            outbound_ics20_transfers_enabled: msg.outbound_ics20_transfers_enabled,
28        })
29    }
30}
31
32impl From<IBCParameters> for pb::IbcParameters {
33    fn from(params: IBCParameters) -> Self {
34        pb::IbcParameters {
35            ibc_enabled: params.ibc_enabled,
36            inbound_ics20_transfers_enabled: params.inbound_ics20_transfers_enabled,
37            outbound_ics20_transfers_enabled: params.outbound_ics20_transfers_enabled,
38        }
39    }
40}
41
42impl Default for IBCParameters {
43    fn default() -> Self {
44        Self {
45            ibc_enabled: true,
46            inbound_ics20_transfers_enabled: true,
47            outbound_ics20_transfers_enabled: true,
48        }
49    }
50}