somm_gravity_proto/
lib.rs

1//! This crate provides Gravity proto definitions in Rust and also re-exports cosmos_sdk_proto for use by downstream
2//! crates. By default around a dozen proto files are generated and places into the prost folder. We could then proceed
3//! to fix up all these files and use them as the required dependencies to the Gravity file, but we chose instead to replace
4//! those paths with references ot upstream cosmos-sdk-proto and delete the other files. This reduces cruft in this repo even
5//! if it does make for a somewhat more confusing proto generation process.
6
7pub use cosmos_sdk_proto;
8pub mod gravity {
9    include!("prost/gravity.v1.rs");
10}
11
12use bytes::BytesMut;
13use prost::Message;
14use prost_types::Any;
15
16pub trait ToAny {
17    fn to_any(&self) -> Option<prost_types::Any>
18    where
19        Self: prost::Message;
20}
21
22impl ToAny for gravity::BatchExecutedEvent {
23    fn to_any(&self) -> Option<prost_types::Any> {
24        let mut buf = BytesMut::with_capacity(self.encoded_len());
25        self.encode(&mut buf).expect("encoding failed");
26        Some(Any {
27            type_url: "/gravity.v1.BatchExecutedEvent".into(),
28            value: buf.to_vec(),
29        })
30    }
31}
32
33impl ToAny for gravity::BatchTxConfirmation {
34    fn to_any(&self) -> Option<prost_types::Any> {
35        let mut buf = BytesMut::with_capacity(self.encoded_len());
36        self.encode(&mut buf).expect("encoding failed");
37        Some(Any {
38            type_url: "/gravity.v1.BatchTxConfirmation".into(),
39            value: buf.to_vec(),
40        })
41    }
42}
43
44impl ToAny for gravity::ContractCallExecutedEvent {
45    fn to_any(&self) -> Option<prost_types::Any> {
46        let mut buf = BytesMut::with_capacity(self.encoded_len());
47        self.encode(&mut buf).expect("encoding failed");
48        Some(Any {
49            type_url: "/gravity.v1.ContractCallExecutedEvent".into(),
50            value: buf.to_vec(),
51        })
52    }
53}
54
55impl ToAny for gravity::ContractCallTxConfirmation {
56    fn to_any(&self) -> Option<prost_types::Any> {
57        let mut buf = BytesMut::with_capacity(self.encoded_len());
58        self.encode(&mut buf).expect("encoding failed");
59        Some(Any {
60            type_url: "/gravity.v1.ContractCallTxConfirmation".into(),
61            value: buf.to_vec(),
62        })
63    }
64}
65
66impl ToAny for gravity::Erc20DeployedEvent {
67    fn to_any(&self) -> Option<prost_types::Any> {
68        let mut buf = BytesMut::with_capacity(self.encoded_len());
69        self.encode(&mut buf).expect("encoding failed");
70        Some(Any {
71            type_url: "/gravity.v1.ERC20DeployedEvent".into(),
72            value: buf.to_vec(),
73        })
74    }
75}
76
77impl ToAny for gravity::SendToCosmosEvent {
78    fn to_any(&self) -> Option<prost_types::Any> {
79        let mut buf = BytesMut::with_capacity(self.encoded_len());
80        self.encode(&mut buf).expect("encoding failed");
81        Some(Any {
82            type_url: "/gravity.v1.SendToCosmosEvent".into(),
83            value: buf.to_vec(),
84        })
85    }
86}
87
88impl ToAny for gravity::SignerSetTxExecutedEvent {
89    fn to_any(&self) -> Option<prost_types::Any> {
90        let mut buf = BytesMut::with_capacity(self.encoded_len());
91        self.encode(&mut buf).expect("encoding failed");
92        Some(Any {
93            type_url: "/gravity.v1.SignerSetTxExecutedEvent".into(),
94            value: buf.to_vec(),
95        })
96    }
97}
98
99impl ToAny for gravity::SignerSetTxConfirmation {
100    fn to_any(&self) -> Option<prost_types::Any> {
101        let mut buf = BytesMut::with_capacity(self.encoded_len());
102        self.encode(&mut buf).expect("encoding failed");
103        Some(Any {
104            type_url: "/gravity.v1.SignerSetTxConfirmation".into(),
105            value: buf.to_vec(),
106        })
107    }
108}