penumbra_sdk_proto/gen/
penumbra.core.component.fee.v1.rs

1// This file is @generated by prost-build.
2/// Specifies fees paid by a transaction.
3#[derive(Clone, PartialEq, ::prost::Message)]
4pub struct Fee {
5    /// The amount of the token used to pay fees.
6    #[prost(message, optional, tag = "1")]
7    pub amount: ::core::option::Option<super::super::super::num::v1::Amount>,
8    /// If present, the asset ID of the token used to pay fees.
9    /// If absent, specifies the staking token implicitly.
10    #[prost(message, optional, tag = "2")]
11    pub asset_id: ::core::option::Option<super::super::super::asset::v1::AssetId>,
12}
13impl ::prost::Name for Fee {
14    const NAME: &'static str = "Fee";
15    const PACKAGE: &'static str = "penumbra.core.component.fee.v1";
16    fn full_name() -> ::prost::alloc::string::String {
17        "penumbra.core.component.fee.v1.Fee".into()
18    }
19    fn type_url() -> ::prost::alloc::string::String {
20        "/penumbra.core.component.fee.v1.Fee".into()
21    }
22}
23/// Gas usage for a transaction.
24///
25/// Gas used is multiplied by `GasPrices` to determine a `Fee`.
26#[derive(Clone, Copy, PartialEq, ::prost::Message)]
27pub struct Gas {
28    /// The amount of block space used.
29    #[prost(uint64, tag = "1")]
30    pub block_space: u64,
31    /// The amount of compact block space used.
32    #[prost(uint64, tag = "2")]
33    pub compact_block_space: u64,
34    /// The amount of verification cost used.
35    #[prost(uint64, tag = "3")]
36    pub verification: u64,
37    /// The amount of execution cost used.
38    #[prost(uint64, tag = "4")]
39    pub execution: u64,
40}
41impl ::prost::Name for Gas {
42    const NAME: &'static str = "Gas";
43    const PACKAGE: &'static str = "penumbra.core.component.fee.v1";
44    fn full_name() -> ::prost::alloc::string::String {
45        "penumbra.core.component.fee.v1.Gas".into()
46    }
47    fn type_url() -> ::prost::alloc::string::String {
48        "/penumbra.core.component.fee.v1.Gas".into()
49    }
50}
51#[derive(Clone, PartialEq, ::prost::Message)]
52pub struct GasPrices {
53    /// The asset ID of the fee token these prices are for.
54    ///
55    /// If absent, specifies the staking token implicitly.
56    #[prost(message, optional, tag = "15")]
57    pub asset_id: ::core::option::Option<super::super::super::asset::v1::AssetId>,
58    /// The price per unit block space in terms of the staking token, with an implicit 1,000 denominator.
59    #[prost(uint64, tag = "1")]
60    pub block_space_price: u64,
61    /// The price per unit compact block space in terms of the staking token, with an implicit 1,000 denominator.
62    #[prost(uint64, tag = "2")]
63    pub compact_block_space_price: u64,
64    /// The price per unit verification cost in terms of the staking token, with an implicit 1,000 denominator.
65    #[prost(uint64, tag = "3")]
66    pub verification_price: u64,
67    /// The price per unit execution cost in terms of the staking token, with an implicit 1,000 denominator.
68    #[prost(uint64, tag = "4")]
69    pub execution_price: u64,
70}
71impl ::prost::Name for GasPrices {
72    const NAME: &'static str = "GasPrices";
73    const PACKAGE: &'static str = "penumbra.core.component.fee.v1";
74    fn full_name() -> ::prost::alloc::string::String {
75        "penumbra.core.component.fee.v1.GasPrices".into()
76    }
77    fn type_url() -> ::prost::alloc::string::String {
78        "/penumbra.core.component.fee.v1.GasPrices".into()
79    }
80}
81#[derive(Clone, Copy, PartialEq, ::prost::Message)]
82pub struct FeeTier {
83    /// The selected fee tier.
84    #[prost(enumeration = "fee_tier::Tier", tag = "1")]
85    pub fee_tier: i32,
86}
87/// Nested message and enum types in `FeeTier`.
88pub mod fee_tier {
89    /// The tier for the fee.
90    #[derive(
91        Clone,
92        Copy,
93        Debug,
94        PartialEq,
95        Eq,
96        Hash,
97        PartialOrd,
98        Ord,
99        ::prost::Enumeration
100    )]
101    #[repr(i32)]
102    pub enum Tier {
103        Unspecified = 0,
104        Low = 1,
105        Medium = 2,
106        High = 3,
107    }
108    impl Tier {
109        /// String value of the enum field names used in the ProtoBuf definition.
110        ///
111        /// The values are not transformed in any way and thus are considered stable
112        /// (if the ProtoBuf definition does not change) and safe for programmatic use.
113        pub fn as_str_name(&self) -> &'static str {
114            match self {
115                Self::Unspecified => "TIER_UNSPECIFIED",
116                Self::Low => "TIER_LOW",
117                Self::Medium => "TIER_MEDIUM",
118                Self::High => "TIER_HIGH",
119            }
120        }
121        /// Creates an enum from field names used in the ProtoBuf definition.
122        pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
123            match value {
124                "TIER_UNSPECIFIED" => Some(Self::Unspecified),
125                "TIER_LOW" => Some(Self::Low),
126                "TIER_MEDIUM" => Some(Self::Medium),
127                "TIER_HIGH" => Some(Self::High),
128                _ => None,
129            }
130        }
131    }
132}
133impl ::prost::Name for FeeTier {
134    const NAME: &'static str = "FeeTier";
135    const PACKAGE: &'static str = "penumbra.core.component.fee.v1";
136    fn full_name() -> ::prost::alloc::string::String {
137        "penumbra.core.component.fee.v1.FeeTier".into()
138    }
139    fn type_url() -> ::prost::alloc::string::String {
140        "/penumbra.core.component.fee.v1.FeeTier".into()
141    }
142}
143/// Fee component configuration data.
144#[derive(Clone, PartialEq, ::prost::Message)]
145pub struct FeeParameters {
146    /// Fixed gas prices in the native token used to compute transactions' base
147    /// fees.
148    ///
149    /// In the future, this should be removed and replaced with parameters for
150    /// dynamic gas pricing.
151    #[prost(message, optional, tag = "1")]
152    pub fixed_gas_prices: ::core::option::Option<GasPrices>,
153    /// Fixed gas prices in other tokens used to compute transactions' base fees.
154    ///
155    /// In the future, this should be removed and replaced with fixed multiples of
156    /// the native token's price (so that there is one set of dynamically
157    /// determined gas prices in the native token, and derived gas prices in other
158    /// alternative tokens).
159    ///
160    /// If this is empty, no other tokens are accepted for gas.
161    #[prost(message, repeated, tag = "2")]
162    pub fixed_alt_gas_prices: ::prost::alloc::vec::Vec<GasPrices>,
163}
164impl ::prost::Name for FeeParameters {
165    const NAME: &'static str = "FeeParameters";
166    const PACKAGE: &'static str = "penumbra.core.component.fee.v1";
167    fn full_name() -> ::prost::alloc::string::String {
168        "penumbra.core.component.fee.v1.FeeParameters".into()
169    }
170    fn type_url() -> ::prost::alloc::string::String {
171        "/penumbra.core.component.fee.v1.FeeParameters".into()
172    }
173}
174/// Fee-specific genesis content.
175#[derive(Clone, PartialEq, ::prost::Message)]
176pub struct GenesisContent {
177    /// The FeeParameters present at genesis.
178    #[prost(message, optional, tag = "1")]
179    pub fee_params: ::core::option::Option<FeeParameters>,
180}
181impl ::prost::Name for GenesisContent {
182    const NAME: &'static str = "GenesisContent";
183    const PACKAGE: &'static str = "penumbra.core.component.fee.v1";
184    fn full_name() -> ::prost::alloc::string::String {
185        "penumbra.core.component.fee.v1.GenesisContent".into()
186    }
187    fn type_url() -> ::prost::alloc::string::String {
188        "/penumbra.core.component.fee.v1.GenesisContent".into()
189    }
190}
191#[derive(Clone, Copy, PartialEq, ::prost::Message)]
192pub struct CurrentGasPricesRequest {}
193impl ::prost::Name for CurrentGasPricesRequest {
194    const NAME: &'static str = "CurrentGasPricesRequest";
195    const PACKAGE: &'static str = "penumbra.core.component.fee.v1";
196    fn full_name() -> ::prost::alloc::string::String {
197        "penumbra.core.component.fee.v1.CurrentGasPricesRequest".into()
198    }
199    fn type_url() -> ::prost::alloc::string::String {
200        "/penumbra.core.component.fee.v1.CurrentGasPricesRequest".into()
201    }
202}
203#[derive(Clone, PartialEq, ::prost::Message)]
204pub struct CurrentGasPricesResponse {
205    /// The current gas prices, in the preferred (native) token.
206    #[prost(message, optional, tag = "1")]
207    pub gas_prices: ::core::option::Option<GasPrices>,
208    /// Other gas prices for other accepted tokens.
209    #[prost(message, repeated, tag = "2")]
210    pub alt_gas_prices: ::prost::alloc::vec::Vec<GasPrices>,
211}
212impl ::prost::Name for CurrentGasPricesResponse {
213    const NAME: &'static str = "CurrentGasPricesResponse";
214    const PACKAGE: &'static str = "penumbra.core.component.fee.v1";
215    fn full_name() -> ::prost::alloc::string::String {
216        "penumbra.core.component.fee.v1.CurrentGasPricesResponse".into()
217    }
218    fn type_url() -> ::prost::alloc::string::String {
219        "/penumbra.core.component.fee.v1.CurrentGasPricesResponse".into()
220    }
221}
222/// Emitted during fee payment.
223#[derive(Clone, PartialEq, ::prost::Message)]
224pub struct EventPaidFee {
225    /// The fee paid.
226    #[prost(message, optional, tag = "1")]
227    pub fee: ::core::option::Option<Fee>,
228    /// The base fee that was required.
229    #[prost(message, optional, tag = "2")]
230    pub base_fee: ::core::option::Option<Fee>,
231    /// The tip that was paid to the proposer.
232    #[prost(message, optional, tag = "3")]
233    pub tip: ::core::option::Option<Fee>,
234    /// The gas used to compute the base fee.
235    #[prost(message, optional, tag = "4")]
236    pub gas_used: ::core::option::Option<Gas>,
237}
238impl ::prost::Name for EventPaidFee {
239    const NAME: &'static str = "EventPaidFee";
240    const PACKAGE: &'static str = "penumbra.core.component.fee.v1";
241    fn full_name() -> ::prost::alloc::string::String {
242        "penumbra.core.component.fee.v1.EventPaidFee".into()
243    }
244    fn type_url() -> ::prost::alloc::string::String {
245        "/penumbra.core.component.fee.v1.EventPaidFee".into()
246    }
247}
248/// Emitted as a summary of fees in the block.
249#[derive(Clone, PartialEq, ::prost::Message)]
250pub struct EventBlockFees {
251    /// The total fees, after swapping to the native token.
252    #[prost(message, optional, tag = "1")]
253    pub swapped_fee_total: ::core::option::Option<Fee>,
254    /// The total base fees, after swapping to the native token.
255    #[prost(message, optional, tag = "2")]
256    pub swapped_base_fee_total: ::core::option::Option<Fee>,
257    /// The total tips, after swapping to the native token.
258    #[prost(message, optional, tag = "3")]
259    pub swapped_tip_total: ::core::option::Option<Fee>,
260}
261impl ::prost::Name for EventBlockFees {
262    const NAME: &'static str = "EventBlockFees";
263    const PACKAGE: &'static str = "penumbra.core.component.fee.v1";
264    fn full_name() -> ::prost::alloc::string::String {
265        "penumbra.core.component.fee.v1.EventBlockFees".into()
266    }
267    fn type_url() -> ::prost::alloc::string::String {
268        "/penumbra.core.component.fee.v1.EventBlockFees".into()
269    }
270}
271/// Generated client implementations.
272#[cfg(feature = "rpc")]
273pub mod query_service_client {
274    #![allow(
275        unused_variables,
276        dead_code,
277        missing_docs,
278        clippy::wildcard_imports,
279        clippy::let_unit_value,
280    )]
281    use tonic::codegen::*;
282    use tonic::codegen::http::Uri;
283    /// Query operations for the fee component.
284    #[derive(Debug, Clone)]
285    pub struct QueryServiceClient<T> {
286        inner: tonic::client::Grpc<T>,
287    }
288    impl QueryServiceClient<tonic::transport::Channel> {
289        /// Attempt to create a new client by connecting to a given endpoint.
290        pub async fn connect<D>(dst: D) -> Result<Self, tonic::transport::Error>
291        where
292            D: TryInto<tonic::transport::Endpoint>,
293            D::Error: Into<StdError>,
294        {
295            let conn = tonic::transport::Endpoint::new(dst)?.connect().await?;
296            Ok(Self::new(conn))
297        }
298    }
299    impl<T> QueryServiceClient<T>
300    where
301        T: tonic::client::GrpcService<tonic::body::BoxBody>,
302        T::Error: Into<StdError>,
303        T::ResponseBody: Body<Data = Bytes> + std::marker::Send + 'static,
304        <T::ResponseBody as Body>::Error: Into<StdError> + std::marker::Send,
305    {
306        pub fn new(inner: T) -> Self {
307            let inner = tonic::client::Grpc::new(inner);
308            Self { inner }
309        }
310        pub fn with_origin(inner: T, origin: Uri) -> Self {
311            let inner = tonic::client::Grpc::with_origin(inner, origin);
312            Self { inner }
313        }
314        pub fn with_interceptor<F>(
315            inner: T,
316            interceptor: F,
317        ) -> QueryServiceClient<InterceptedService<T, F>>
318        where
319            F: tonic::service::Interceptor,
320            T::ResponseBody: Default,
321            T: tonic::codegen::Service<
322                http::Request<tonic::body::BoxBody>,
323                Response = http::Response<
324                    <T as tonic::client::GrpcService<tonic::body::BoxBody>>::ResponseBody,
325                >,
326            >,
327            <T as tonic::codegen::Service<
328                http::Request<tonic::body::BoxBody>,
329            >>::Error: Into<StdError> + std::marker::Send + std::marker::Sync,
330        {
331            QueryServiceClient::new(InterceptedService::new(inner, interceptor))
332        }
333        /// Compress requests with the given encoding.
334        ///
335        /// This requires the server to support it otherwise it might respond with an
336        /// error.
337        #[must_use]
338        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
339            self.inner = self.inner.send_compressed(encoding);
340            self
341        }
342        /// Enable decompressing responses.
343        #[must_use]
344        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
345            self.inner = self.inner.accept_compressed(encoding);
346            self
347        }
348        /// Limits the maximum size of a decoded message.
349        ///
350        /// Default: `4MB`
351        #[must_use]
352        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
353            self.inner = self.inner.max_decoding_message_size(limit);
354            self
355        }
356        /// Limits the maximum size of an encoded message.
357        ///
358        /// Default: `usize::MAX`
359        #[must_use]
360        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
361            self.inner = self.inner.max_encoding_message_size(limit);
362            self
363        }
364        /// Get the current gas prices.
365        pub async fn current_gas_prices(
366            &mut self,
367            request: impl tonic::IntoRequest<super::CurrentGasPricesRequest>,
368        ) -> std::result::Result<
369            tonic::Response<super::CurrentGasPricesResponse>,
370            tonic::Status,
371        > {
372            self.inner
373                .ready()
374                .await
375                .map_err(|e| {
376                    tonic::Status::unknown(
377                        format!("Service was not ready: {}", e.into()),
378                    )
379                })?;
380            let codec = tonic::codec::ProstCodec::default();
381            let path = http::uri::PathAndQuery::from_static(
382                "/penumbra.core.component.fee.v1.QueryService/CurrentGasPrices",
383            );
384            let mut req = request.into_request();
385            req.extensions_mut()
386                .insert(
387                    GrpcMethod::new(
388                        "penumbra.core.component.fee.v1.QueryService",
389                        "CurrentGasPrices",
390                    ),
391                );
392            self.inner.unary(req, path, codec).await
393        }
394    }
395}
396/// Generated server implementations.
397#[cfg(feature = "rpc")]
398pub mod query_service_server {
399    #![allow(
400        unused_variables,
401        dead_code,
402        missing_docs,
403        clippy::wildcard_imports,
404        clippy::let_unit_value,
405    )]
406    use tonic::codegen::*;
407    /// Generated trait containing gRPC methods that should be implemented for use with QueryServiceServer.
408    #[async_trait]
409    pub trait QueryService: std::marker::Send + std::marker::Sync + 'static {
410        /// Get the current gas prices.
411        async fn current_gas_prices(
412            &self,
413            request: tonic::Request<super::CurrentGasPricesRequest>,
414        ) -> std::result::Result<
415            tonic::Response<super::CurrentGasPricesResponse>,
416            tonic::Status,
417        >;
418    }
419    /// Query operations for the fee component.
420    #[derive(Debug)]
421    pub struct QueryServiceServer<T> {
422        inner: Arc<T>,
423        accept_compression_encodings: EnabledCompressionEncodings,
424        send_compression_encodings: EnabledCompressionEncodings,
425        max_decoding_message_size: Option<usize>,
426        max_encoding_message_size: Option<usize>,
427    }
428    impl<T> QueryServiceServer<T> {
429        pub fn new(inner: T) -> Self {
430            Self::from_arc(Arc::new(inner))
431        }
432        pub fn from_arc(inner: Arc<T>) -> Self {
433            Self {
434                inner,
435                accept_compression_encodings: Default::default(),
436                send_compression_encodings: Default::default(),
437                max_decoding_message_size: None,
438                max_encoding_message_size: None,
439            }
440        }
441        pub fn with_interceptor<F>(
442            inner: T,
443            interceptor: F,
444        ) -> InterceptedService<Self, F>
445        where
446            F: tonic::service::Interceptor,
447        {
448            InterceptedService::new(Self::new(inner), interceptor)
449        }
450        /// Enable decompressing requests with the given encoding.
451        #[must_use]
452        pub fn accept_compressed(mut self, encoding: CompressionEncoding) -> Self {
453            self.accept_compression_encodings.enable(encoding);
454            self
455        }
456        /// Compress responses with the given encoding, if the client supports it.
457        #[must_use]
458        pub fn send_compressed(mut self, encoding: CompressionEncoding) -> Self {
459            self.send_compression_encodings.enable(encoding);
460            self
461        }
462        /// Limits the maximum size of a decoded message.
463        ///
464        /// Default: `4MB`
465        #[must_use]
466        pub fn max_decoding_message_size(mut self, limit: usize) -> Self {
467            self.max_decoding_message_size = Some(limit);
468            self
469        }
470        /// Limits the maximum size of an encoded message.
471        ///
472        /// Default: `usize::MAX`
473        #[must_use]
474        pub fn max_encoding_message_size(mut self, limit: usize) -> Self {
475            self.max_encoding_message_size = Some(limit);
476            self
477        }
478    }
479    impl<T, B> tonic::codegen::Service<http::Request<B>> for QueryServiceServer<T>
480    where
481        T: QueryService,
482        B: Body + std::marker::Send + 'static,
483        B::Error: Into<StdError> + std::marker::Send + 'static,
484    {
485        type Response = http::Response<tonic::body::BoxBody>;
486        type Error = std::convert::Infallible;
487        type Future = BoxFuture<Self::Response, Self::Error>;
488        fn poll_ready(
489            &mut self,
490            _cx: &mut Context<'_>,
491        ) -> Poll<std::result::Result<(), Self::Error>> {
492            Poll::Ready(Ok(()))
493        }
494        fn call(&mut self, req: http::Request<B>) -> Self::Future {
495            match req.uri().path() {
496                "/penumbra.core.component.fee.v1.QueryService/CurrentGasPrices" => {
497                    #[allow(non_camel_case_types)]
498                    struct CurrentGasPricesSvc<T: QueryService>(pub Arc<T>);
499                    impl<
500                        T: QueryService,
501                    > tonic::server::UnaryService<super::CurrentGasPricesRequest>
502                    for CurrentGasPricesSvc<T> {
503                        type Response = super::CurrentGasPricesResponse;
504                        type Future = BoxFuture<
505                            tonic::Response<Self::Response>,
506                            tonic::Status,
507                        >;
508                        fn call(
509                            &mut self,
510                            request: tonic::Request<super::CurrentGasPricesRequest>,
511                        ) -> Self::Future {
512                            let inner = Arc::clone(&self.0);
513                            let fut = async move {
514                                <T as QueryService>::current_gas_prices(&inner, request)
515                                    .await
516                            };
517                            Box::pin(fut)
518                        }
519                    }
520                    let accept_compression_encodings = self.accept_compression_encodings;
521                    let send_compression_encodings = self.send_compression_encodings;
522                    let max_decoding_message_size = self.max_decoding_message_size;
523                    let max_encoding_message_size = self.max_encoding_message_size;
524                    let inner = self.inner.clone();
525                    let fut = async move {
526                        let method = CurrentGasPricesSvc(inner);
527                        let codec = tonic::codec::ProstCodec::default();
528                        let mut grpc = tonic::server::Grpc::new(codec)
529                            .apply_compression_config(
530                                accept_compression_encodings,
531                                send_compression_encodings,
532                            )
533                            .apply_max_message_size_config(
534                                max_decoding_message_size,
535                                max_encoding_message_size,
536                            );
537                        let res = grpc.unary(method, req).await;
538                        Ok(res)
539                    };
540                    Box::pin(fut)
541                }
542                _ => {
543                    Box::pin(async move {
544                        let mut response = http::Response::new(empty_body());
545                        let headers = response.headers_mut();
546                        headers
547                            .insert(
548                                tonic::Status::GRPC_STATUS,
549                                (tonic::Code::Unimplemented as i32).into(),
550                            );
551                        headers
552                            .insert(
553                                http::header::CONTENT_TYPE,
554                                tonic::metadata::GRPC_CONTENT_TYPE,
555                            );
556                        Ok(response)
557                    })
558                }
559            }
560        }
561    }
562    impl<T> Clone for QueryServiceServer<T> {
563        fn clone(&self) -> Self {
564            let inner = self.inner.clone();
565            Self {
566                inner,
567                accept_compression_encodings: self.accept_compression_encodings,
568                send_compression_encodings: self.send_compression_encodings,
569                max_decoding_message_size: self.max_decoding_message_size,
570                max_encoding_message_size: self.max_encoding_message_size,
571            }
572        }
573    }
574    /// Generated gRPC service name
575    pub const SERVICE_NAME: &str = "penumbra.core.component.fee.v1.QueryService";
576    impl<T> tonic::server::NamedService for QueryServiceServer<T> {
577        const NAME: &'static str = SERVICE_NAME;
578    }
579}