penumbra_sdk_fee/
event.rs1use crate::Fee;
2use anyhow::{anyhow, Context};
3use penumbra_sdk_proto::{core::component::fee::v1 as pb, DomainType, Name as _};
4
5#[derive(Clone, Debug)]
6pub struct EventBlockFees {
7 pub swapped_fee_total: Fee,
8 pub swapped_base_fee_total: Fee,
9 pub swapped_tip_total: Fee,
10}
11
12impl TryFrom<pb::EventBlockFees> for EventBlockFees {
13 type Error = anyhow::Error;
14
15 fn try_from(value: pb::EventBlockFees) -> Result<Self, Self::Error> {
16 fn inner(value: pb::EventBlockFees) -> anyhow::Result<EventBlockFees> {
17 Ok(EventBlockFees {
18 swapped_fee_total: value
19 .swapped_fee_total
20 .ok_or(anyhow!("missing `swapped_fee_total`"))?
21 .try_into()?,
22 swapped_base_fee_total: value
23 .swapped_base_fee_total
24 .ok_or(anyhow!("missing `swapped_base_fee_total`"))?
25 .try_into()?,
26 swapped_tip_total: value
27 .swapped_tip_total
28 .ok_or(anyhow!("missing `swapped_tip_total`"))?
29 .try_into()?,
30 })
31 }
32 inner(value).context(format!("parsing {}", pb::EventBlockFees::NAME))
33 }
34}
35
36impl From<EventBlockFees> for pb::EventBlockFees {
37 fn from(value: EventBlockFees) -> Self {
38 Self {
39 swapped_fee_total: Some(value.swapped_fee_total.into()),
40 swapped_base_fee_total: Some(value.swapped_base_fee_total.into()),
41 swapped_tip_total: Some(value.swapped_tip_total.into()),
42 }
43 }
44}
45
46impl DomainType for EventBlockFees {
47 type Proto = pb::EventBlockFees;
48}