penumbra_sdk_fee/component/
rpc.rs

1use async_trait::async_trait;
2use cnidarium::Storage;
3use penumbra_sdk_proto::core::component::fee::v1::{
4    self as pb, query_service_server::QueryService,
5};
6
7use super::StateReadExt;
8
9// TODO: Hide this and only expose a Router?
10pub struct Server {
11    storage: Storage,
12}
13
14impl Server {
15    pub fn new(storage: Storage) -> Self {
16        Self { storage }
17    }
18}
19
20#[async_trait]
21impl QueryService for Server {
22    async fn current_gas_prices(
23        &self,
24        _request: tonic::Request<pb::CurrentGasPricesRequest>,
25    ) -> Result<tonic::Response<pb::CurrentGasPricesResponse>, tonic::Status> {
26        let state = self.storage.latest_snapshot();
27
28        let gas_prices = state
29            .get_gas_prices()
30            .await
31            .map_err(|e| tonic::Status::internal(e.to_string()))?;
32
33        Ok(tonic::Response::new(pb::CurrentGasPricesResponse {
34            gas_prices: Some(gas_prices.into()),
35            alt_gas_prices: Vec::new(),
36        }))
37    }
38}