penumbra_sdk_fee/
genesis.rs

1use anyhow::Context;
2use penumbra_sdk_proto::{penumbra::core::component::fee::v1 as pb, DomainType};
3use serde::{Deserialize, Serialize};
4
5use crate::params::FeeParameters;
6
7#[derive(Deserialize, Serialize, Debug, Clone)]
8#[serde(try_from = "pb::GenesisContent", into = "pb::GenesisContent")]
9pub struct Content {
10    /// The initial configuration parameters for the fee component.
11    pub fee_params: FeeParameters,
12}
13
14impl From<Content> for pb::GenesisContent {
15    fn from(value: Content) -> Self {
16        pb::GenesisContent {
17            fee_params: Some(value.fee_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            fee_params: msg
28                .fee_params
29                .context("fee params not present in protobuf message")?
30                .try_into()?,
31        })
32    }
33}
34
35impl DomainType for Content {
36    type Proto = pb::GenesisContent;
37}
38
39impl Default for Content {
40    fn default() -> Self {
41        Self {
42            fee_params: FeeParameters::default(),
43        }
44    }
45}