1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
//! Protobuf definitions for Penumbra.
//!
//! This crate only contains the `.proto` files and the Rust types generated
//! from them.  These types only handle parsing the wire format; validation
//! should be performed by converting them into an appropriate domain type, as
//! in the following diagram:
//!
//! ```ascii
//! ┌───────┐          ┌──────────────┐               ┌──────────────┐
//! │encoded│ protobuf │penumbra_proto│ TryFrom/Into  │ domain types │
//! │ bytes │<──wire ─>│    types     │<─validation ─>│(other crates)│
//! └───────┘  format  └──────────────┘   boundary    └──────────────┘
//! ```
//!
//! The [`DomainType`] marker trait can be implemented on a domain type to ensure
//! these conversions exist.

// The autogen code is not clippy-clean, so we disable some clippy warnings for this crate.
#![allow(clippy::derive_partial_eq_without_eq)]
#![allow(clippy::large_enum_variant)]
#![allow(clippy::needless_borrow)]
#![allow(clippy::unwrap_used)]
#![allow(non_snake_case)]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]

pub use prost::{Message, Name};

/// Helper methods used for shaping the JSON (and other Serde) formats derived from the protos.
pub mod serializers;

#[cfg(feature = "box-grpc")]
pub mod box_grpc_svc;

/// Helper trait for using Protobuf messages as ABCI events.
pub mod event;
mod protobuf;
pub use protobuf::DomainType;

#[cfg(feature = "cnidarium")]
pub mod state;
#[cfg(feature = "cnidarium")]
pub use state::StateReadProto;
#[cfg(feature = "cnidarium")]
pub use state::StateWriteProto;

pub use penumbra::*;

pub mod penumbra {
    /// Core protocol structures.
    pub mod core {
        /// Top-level structures for the Penumbra application.
        pub mod app {
            pub mod v1 {
                include!("gen/penumbra.core.app.v1.rs");
                include!("gen/penumbra.core.app.v1.serde.rs");
            }
        }

        pub mod asset {
            pub mod v1 {
                include!("gen/penumbra.core.asset.v1.rs");
                include!("gen/penumbra.core.asset.v1.serde.rs");
            }
        }

        pub mod txhash {
            pub mod v1 {
                include!("gen/penumbra.core.txhash.v1.rs");
                include!("gen/penumbra.core.txhash.v1.serde.rs");
            }
        }

        /// Components of the Penumbra application.
        pub mod component {
            pub mod auction {
                pub mod v1alpha1 {
                    include!("gen/penumbra.core.component.auction.v1alpha1.rs");
                    include!("gen/penumbra.core.component.auction.v1alpha1.serde.rs");
                }
            }
            pub mod compact_block {
                pub mod v1 {
                    include!("gen/penumbra.core.component.compact_block.v1.rs");
                    include!("gen/penumbra.core.component.compact_block.v1.serde.rs");
                }
            }

            pub mod community_pool {
                pub mod v1 {
                    include!("gen/penumbra.core.component.community_pool.v1.rs");
                    include!("gen/penumbra.core.component.community_pool.v1.serde.rs");
                }
            }

            pub mod dex {
                pub mod v1 {
                    include!("gen/penumbra.core.component.dex.v1.rs");
                    include!("gen/penumbra.core.component.dex.v1.serde.rs");
                }
            }

            pub mod distributions {
                pub mod v1 {
                    include!("gen/penumbra.core.component.distributions.v1.rs");
                    include!("gen/penumbra.core.component.distributions.v1.serde.rs");
                }
            }

            pub mod fee {
                pub mod v1 {
                    include!("gen/penumbra.core.component.fee.v1.rs");
                    include!("gen/penumbra.core.component.fee.v1.serde.rs");
                }
            }

            pub mod funding {
                pub mod v1 {
                    include!("gen/penumbra.core.component.funding.v1.rs");
                    include!("gen/penumbra.core.component.funding.v1.serde.rs");
                }
            }

            pub mod governance {
                pub mod v1 {
                    include!("gen/penumbra.core.component.governance.v1.rs");
                    include!("gen/penumbra.core.component.governance.v1.serde.rs");
                }
            }

            pub mod ibc {
                pub mod v1 {
                    include!("gen/penumbra.core.component.ibc.v1.rs");
                    include!("gen/penumbra.core.component.ibc.v1.serde.rs");
                }
            }

            pub mod sct {
                pub mod v1 {
                    include!("gen/penumbra.core.component.sct.v1.rs");
                    include!("gen/penumbra.core.component.sct.v1.serde.rs");
                }
            }

            pub mod shielded_pool {
                pub mod v1 {
                    include!("gen/penumbra.core.component.shielded_pool.v1.rs");
                    include!("gen/penumbra.core.component.shielded_pool.v1.serde.rs");
                }
            }

            pub mod stake {
                pub mod v1 {
                    include!("gen/penumbra.core.component.stake.v1.rs");
                    include!("gen/penumbra.core.component.stake.v1.serde.rs");
                }
            }
        }

        pub mod keys {
            pub mod v1 {
                include!("gen/penumbra.core.keys.v1.rs");
                include!("gen/penumbra.core.keys.v1.serde.rs");
            }
        }

        pub mod num {
            pub mod v1 {
                include!("gen/penumbra.core.num.v1.rs");
                include!("gen/penumbra.core.num.v1.serde.rs");
            }
        }

        /// Transaction structures.
        pub mod transaction {
            pub mod v1 {
                include!("gen/penumbra.core.transaction.v1.rs");
                include!("gen/penumbra.core.transaction.v1.serde.rs");
            }
        }
    }

    /// Cryptography primitives used by Penumbra.
    pub mod crypto {
        pub mod decaf377_fmd {
            pub mod v1 {
                include!("gen/penumbra.crypto.decaf377_fmd.v1.rs");
                include!("gen/penumbra.crypto.decaf377_fmd.v1.serde.rs");
            }
        }

        pub mod decaf377_frost {
            pub mod v1 {
                include!("gen/penumbra.crypto.decaf377_frost.v1.rs");
                include!("gen/penumbra.crypto.decaf377_frost.v1.serde.rs");
            }
        }

        pub mod decaf377_rdsa {
            pub mod v1 {
                include!("gen/penumbra.crypto.decaf377_rdsa.v1.rs");
                include!("gen/penumbra.crypto.decaf377_rdsa.v1.serde.rs");
            }
        }

        pub mod tct {
            pub mod v1 {
                include!("gen/penumbra.crypto.tct.v1.rs");
                include!("gen/penumbra.crypto.tct.v1.serde.rs");
            }
        }
    }

    /// Custody protocol structures.
    pub mod custody {
        pub mod threshold {
            pub mod v1 {
                include!("gen/penumbra.custody.threshold.v1.rs");
                include!("gen/penumbra.custody.threshold.v1.serde.rs");
            }
        }

        pub mod v1 {
            include!("gen/penumbra.custody.v1.rs");
            include!("gen/penumbra.custody.v1.serde.rs");
        }
    }

    pub mod cnidarium {
        pub mod v1 {
            include!("gen/penumbra.cnidarium.v1.rs");
            include!("gen/penumbra.cnidarium.v1.serde.rs");
        }
    }

    pub mod util {
        pub mod tendermint_proxy {
            pub mod v1 {
                include!("gen/penumbra.util.tendermint_proxy.v1.rs");
                include!("gen/penumbra.util.tendermint_proxy.v1.serde.rs");
            }
        }
    }

    pub mod tools {
        pub mod summoning {
            pub mod v1 {
                include!("gen/penumbra.tools.summoning.v1.rs");
                include!("gen/penumbra.tools.summoning.v1.serde.rs");
            }
        }
    }

    /// View protocol structures.
    pub mod view {
        pub mod v1 {
            include!("gen/penumbra.view.v1.rs");
            include!("gen/penumbra.view.v1.serde.rs");
        }
    }
}

pub mod tendermint {
    pub mod crypto {
        include!("gen/tendermint.crypto.rs");
    }

    #[allow(clippy::large_enum_variant)]
    pub mod types {
        include!("gen/tendermint.types.rs");
    }

    pub mod version {
        include!("gen/tendermint.version.rs");
    }

    pub mod p2p {
        include!("gen/tendermint.p2p.rs");
    }
}

#[cfg(feature = "rpc")]
// https://github.com/penumbra-zone/penumbra/issues/3038#issuecomment-1722534133
pub const FILE_DESCRIPTOR_SET: &[u8] = include_bytes!("gen/proto_descriptor.bin.no_lfs");