-
Notifications
You must be signed in to change notification settings - Fork 97
/
Copy pathtx_msg.rs
33 lines (25 loc) · 895 Bytes
/
tx_msg.rs
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
use prost_types::Any;
use tendermint::account::Id as AccountId;
pub trait Msg: Clone {
type ValidationError: std::error::Error;
// TODO -- clarify what is this function supposed to do & its connection to ICS26 routing mod.
fn route(&self) -> String;
fn get_type(&self) -> String;
fn validate_basic(&self) -> Result<(), Self::ValidationError>;
fn get_sign_bytes<M: From<Self> + prost::Message>(&self) -> Vec<u8> {
let mut buf = Vec::new();
let raw_msg: M = self.clone().into();
prost::Message::encode(&raw_msg, &mut buf).unwrap();
buf
}
fn type_url(&self) -> String {
unimplemented!()
}
fn to_any<M: From<Self> + prost::Message>(&self) -> Any {
Any {
type_url: self.type_url(),
value: self.get_sign_bytes::<M>(),
}
}
fn get_signers(&self) -> Vec<AccountId>;
}