-
Notifications
You must be signed in to change notification settings - Fork 320
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
app: create event for when app parameters change
- Loading branch information
1 parent
4d683f5
commit 033b3af
Showing
6 changed files
with
158 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
use anyhow::{anyhow, Context}; | ||
use penumbra_proto::{penumbra::core::app::v1 as pb, DomainType}; | ||
use prost::Name as _; | ||
|
||
use crate::params::AppParameters; | ||
|
||
#[derive(Clone, Debug)] | ||
struct EventAppParametersChange { | ||
new_parameters: AppParameters, | ||
} | ||
|
||
impl TryFrom<pb::EventAppParametersChange> for EventAppParametersChange { | ||
type Error = anyhow::Error; | ||
|
||
fn try_from(value: pb::EventAppParametersChange) -> Result<Self, Self::Error> { | ||
fn inner(value: pb::EventAppParametersChange) -> anyhow::Result<EventAppParametersChange> { | ||
Ok(EventAppParametersChange { | ||
new_parameters: value | ||
.new_parameters | ||
.ok_or(anyhow!("missing `new_parameters`"))? | ||
.try_into()?, | ||
}) | ||
} | ||
inner(value).context(format!("parsing {}", pb::EventAppParametersChange::NAME)) | ||
} | ||
} | ||
|
||
impl From<EventAppParametersChange> for pb::EventAppParametersChange { | ||
fn from(value: EventAppParametersChange) -> Self { | ||
Self { | ||
new_parameters: Some(value.new_parameters.into()), | ||
} | ||
} | ||
} | ||
|
||
impl DomainType for EventAppParametersChange { | ||
type Proto = pb::EventAppParametersChange; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters