penumbra_sdk_fee/
params.rs1use penumbra_sdk_proto::penumbra::core::component::fee::v1 as pb;
2
3use penumbra_sdk_proto::DomainType;
4use serde::{Deserialize, Serialize};
5
6use crate::GasPrices;
7
8#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq, Default)]
9#[serde(try_from = "pb::FeeParameters", into = "pb::FeeParameters")]
10pub struct FeeParameters {
11 pub fixed_gas_prices: GasPrices,
12 pub fixed_alt_gas_prices: Vec<GasPrices>,
13}
14
15impl DomainType for FeeParameters {
16 type Proto = pb::FeeParameters;
17}
18
19impl TryFrom<pb::FeeParameters> for FeeParameters {
20 type Error = anyhow::Error;
21
22 fn try_from(msg: pb::FeeParameters) -> anyhow::Result<Self> {
23 Ok(FeeParameters {
24 fixed_gas_prices: msg.fixed_gas_prices.unwrap_or_default().try_into()?,
25 fixed_alt_gas_prices: msg
26 .fixed_alt_gas_prices
27 .into_iter()
28 .map(|p| p.try_into())
29 .collect::<Result<_, _>>()?,
30 })
31 }
32}
33
34impl From<FeeParameters> for pb::FeeParameters {
35 fn from(params: FeeParameters) -> Self {
36 pb::FeeParameters {
37 fixed_gas_prices: Some(params.fixed_gas_prices.into()),
38 fixed_alt_gas_prices: params
39 .fixed_alt_gas_prices
40 .into_iter()
41 .map(Into::into)
42 .collect(),
43 }
44 }
45}