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
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
//! proto/mod.rs: Protobuf types defined in NibiruChain/nibiru/proto.

mod traits;
mod type_url_cosmos;
mod type_url_nibiru;

pub use traits::*;
pub use type_url_cosmos::*;
pub use type_url_nibiru::*;

pub mod cosmos {
    /// Authentication of accounts and transactions.
    pub mod auth {
        pub mod v1beta1 {
            include!("buf/cosmos.auth.v1beta1.rs");
        }
    }

    pub mod authz {
        pub mod v1beta1 {
            include!("buf/cosmos.authz.v1beta1.rs");
        }
    }

    pub mod bank {
        pub mod v1beta1 {
            include!("buf/cosmos.bank.v1beta1.rs");
        }
    }

    /// Base functionality.
    pub mod base {
        /// Application BlockChain Interface (ABCI).
        ///
        /// Interface that defines the boundary between the replication engine
        /// (the blockchain), and the state machine (the application).
        pub mod abci {
            pub mod v1beta1 {
                include!("buf/cosmos.base.abci.v1beta1.rs");
            }
        }

        /// Key-value pairs.
        pub mod kv {
            pub mod v1beta1 {
                include!("buf/cosmos.base.kv.v1beta1.rs");
            }
        }

        /// Query support.
        pub mod query {
            pub mod v1beta1 {
                include!("buf/cosmos.base.query.v1beta1.rs");
            }
        }

        /// Reflection support.
        pub mod reflection {
            pub mod v1beta1 {
                include!("buf/cosmos.base.reflection.v1beta1.rs");
            }

            pub mod v2alpha1 {
                include!("buf/cosmos.base.reflection.v2alpha1.rs");
            }
        }

        /// Snapshots containing Tendermint state sync info.
        pub mod snapshots {
            pub mod v1beta1 {
                include!("buf/cosmos.base.snapshots.v1beta1.rs");
            }
        }

        /// Data structure that holds the state of the application.
        pub mod store {
            pub mod v1beta1 {
                include!("buf/cosmos.base.store.v1beta1.rs");
            }
        }

        /// Defines base data structures like Coin, DecCoin, IntProto, and
        /// DecProto. These types implement custo method signatures required by
        /// gogoproto.
        pub mod v1beta1 {
            include!("buf/cosmos.base.v1beta1.rs");
        }

        /// For consensus types related to blocks, block headers, and merkle
        /// proofs.
        pub mod tendermint {
            pub mod v1beta1 {
                include!("buf/cosmos.base.tendermint.v1beta1.rs");
            }
        }
    }

    pub mod crisis {
        pub mod v1beta1 {
            include!("buf/cosmos.crisis.v1beta1.rs");
        }
    }

    pub mod crypto {
        pub mod v1beta1 {
            include!("buf/cosmos.crisis.v1beta1.rs");
        }

        pub mod ed25519 {
            include!("buf/cosmos.crypto.ed25519.rs");
        }

        pub mod hd {
            pub mod v1 {
                include!("buf/cosmos.crypto.hd.v1.rs");
            }
        }

        pub mod keyring {
            pub mod v1 {
                include!("buf/cosmos.crypto.keyring.v1.rs");
            }
        }

        pub mod multisig {
            pub mod v1beta1 {
                include!("buf/cosmos.crypto.multisig.v1beta1.rs");
            }
        }
        pub mod secp256r1 {
            include!("buf/cosmos.crypto.secp256r1.rs");
        }
    }

    pub mod genutil {
        pub mod v1beta1 {
            include!("buf/cosmos.genutil.v1beta1.rs");
        }
    }

    /// Types related to decentralized governance of the network.
    pub mod gov {
        pub mod v1 {
            include!("buf/cosmos.gov.v1.rs");
        }
    }

    pub mod group {
        pub mod v1 {
            include!("buf/cosmos.group.v1.rs");
        }
    }

    pub mod mint {
        pub mod v1beta1 {
            include!("buf/cosmos.mint.v1beta1.rs");
        }
    }

    pub mod nft {
        pub mod v1beta1 {
            include!("buf/cosmos.nft.v1beta1.rs");
        }
    }

    pub mod params {
        pub mod v1beta1 {
            include!("buf/cosmos.params.v1beta1.rs");
        }
    }
    pub mod reflection {
        pub mod v1 {
            include!("buf/cosmos.reflection.v1.rs");
        }
    }
    pub mod slashing {
        pub mod v1beta1 {
            include!("buf/cosmos.slashing.v1beta1.rs");
        }
    }
    pub mod staking {
        pub mod v1beta1 {
            include!("buf/cosmos.staking.v1beta1.rs");
        }
    }
    pub mod tx {
        pub mod config {
            pub mod v1 {
                include!("buf/cosmos.tx.config.v1.rs");
            }
        }
        pub mod signing {
            pub mod v1beta1 {
                include!("buf/cosmos.tx.signing.v1beta1.rs");
            }
        }
        pub mod v1beta1 {
            include!("buf/cosmos.tx.v1beta1.rs");
        }
    }

    pub mod upgrade {
        pub mod v1beta1 {
            include!("buf/cosmos.upgrade.v1beta1.rs");
        }
    }

    pub mod vesting {
        pub mod v1beta1 {
            include!("buf/cosmos.vesting.v1beta1.rs");
        }
    }

    // TODO: protobuf mod for cosmos capability
    // TODO: protobuf mod for cosmos consensus
    // TODO: protobuf mod for cosmos crisis
    // TODO: protobuf mod for cosmos crypto
    // TODO: protobuf mod for cosmos distribution
    // TODO: protobuf mod for cosmos evidence
    // TODO: protobuf mod for cosmos feegrant
}

pub mod nibiru {
    pub mod devgas {
        include!("buf/nibiru.devgas.v1.rs");
    }
    pub mod epochs {
        include!("buf/nibiru.epochs.v1.rs");
    }
    pub mod genmsg {
        include!("buf/nibiru.genmsg.v1.rs");
    }
    pub mod inflation {
        include!("buf/nibiru.inflation.v1.rs");
    }
    pub mod oracle {
        include!("buf/nibiru.oracle.v1.rs");
    }
    pub mod perp {
        include!("buf/nibiru.perp.v2.rs");
    }
    pub mod spot {
        include!("buf/nibiru.spot.v1.rs");
    }
    pub mod sudo {
        include!("buf/nibiru.sudo.v1.rs");
    }
    pub mod tokenfactory {
        include!("buf/nibiru.tokenfactory.v1.rs");
    }
}

pub mod tendermint {
    pub mod abci {
        include!("buf/tendermint.abci.rs");
    }
    pub mod crypto {
        include!("buf/tendermint.crypto.rs");
    }
    pub mod p2p {
        include!("buf/tendermint.p2p.rs");
    }
    pub mod types {
        include!("buf/tendermint.types.rs");
    }
    pub mod version {
        include!("buf/tendermint.version.rs");
    }
}

#[cfg(test)]
mod tests {

    use super::{
        cosmos::{self, base::v1beta1::Coin},
        nibiru::perp,
    };

    #[test]
    fn nibiru_common_imports() {
        let _ = perp::MsgMarketOrder {
            sender: "sender".to_string(),
            pair: "nibi:usd".to_string(),
            side: perp::Direction::Long.into(),
            quote_asset_amount: "123".into(),
            leverage: "123".into(),
            base_asset_amount_limit: "0".into(),
        };
    }

    #[test]
    fn cosmos_imports() {
        let _ = cosmos::bank::v1beta1::MsgSend {
            from_address: "from".to_string(),
            to_address: "to".to_string(),
            amount: vec![Coin {
                denom: "unibi".to_string(),
                amount: "123".to_string(),
            }],
        };
    }
}