penumbra_sdk_funding/component/
view.rsuse async_trait::async_trait;
use crate::{component::state_key, params::FundingParameters};
use anyhow::Result;
use cnidarium::{StateRead, StateWrite};
use penumbra_sdk_proto::{StateReadProto, StateWriteProto};
#[async_trait]
pub trait StateReadExt: StateRead {
async fn get_funding_params(&self) -> Result<FundingParameters> {
self.get(state_key::funding_parameters())
.await?
.ok_or_else(|| anyhow::anyhow!("Missing FundingParameters"))
}
}
impl<T: StateRead + ?Sized> StateReadExt for T {}
#[async_trait]
pub trait StateWriteExt: StateWrite + StateReadExt {
fn put_funding_params(&mut self, params: FundingParameters) {
self.put(state_key::funding_parameters().into(), params)
}
}
impl<T: StateWrite + ?Sized> StateWriteExt for T {}