-
Notifications
You must be signed in to change notification settings - Fork 352
/
msgs.rs
51 lines (45 loc) · 2.18 KB
/
msgs.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//! Message definitions for the connection handshake datagrams.
//!
//! We define each of the four messages in the connection handshake protocol as a `struct`.
//! Each such message comprises the same fields as the datagrams defined in ICS3 English spec:
//! https://github.com/cosmos/ics/tree/master/spec/ics-003-connection-semantics.
//!
//! One departure from ICS3 is that we abstract the three counterparty fields (connection id,
//! prefix, and client id) into a single field of type `Counterparty`; this applies to messages
//! `MsgConnectionOpenInit` and `MsgConnectionOpenTry`. One other difference with regards to
//! abstraction is that all proof-related attributes in a message are encapsulated in `Proofs` type.
//!
//! Another difference to ICS3 specs is that each message comprises an additional field called
//! `signer` which is specific to Cosmos-SDK.
use crate::ics03_connection::msgs::conn_open_ack::MsgConnectionOpenAck;
use crate::ics03_connection::msgs::conn_open_confirm::MsgConnectionOpenConfirm;
use crate::ics03_connection::msgs::conn_open_init::MsgConnectionOpenInit;
use crate::ics03_connection::msgs::conn_open_try::MsgConnectionOpenTry;
pub mod conn_open_ack;
pub mod conn_open_confirm;
pub mod conn_open_init;
pub mod conn_open_try;
/// Message type for the `MsgConnectionOpenConfirm` message.
pub const TYPE_MSG_CONNECTION_OPEN_CONFIRM: &str = "connection_open_confirm";
/// Enumeration of all possible messages that the ICS3 protocol processes.
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum ConnectionMsg {
ConnectionOpenInit(MsgConnectionOpenInit),
ConnectionOpenTry(Box<MsgConnectionOpenTry>),
ConnectionOpenAck(Box<MsgConnectionOpenAck>),
ConnectionOpenConfirm(MsgConnectionOpenConfirm),
}
#[cfg(test)]
pub mod test_util {
use ibc_proto::ibc::core::commitment::v1::MerklePrefix;
use ibc_proto::ibc::core::connection::v1::Counterparty as RawCounterparty;
pub fn get_dummy_counterparty() -> RawCounterparty {
RawCounterparty {
client_id: "destclient".to_string(),
connection_id: "destconnection".to_string(),
prefix: Some(MerklePrefix {
key_prefix: b"ibc".to_vec(),
}),
}
}
}