msgs_handshake.gno
5.86 Kb · 164 lines
1package types
2
3// Handshake datagrams: client lifecycle (create / update / force-update),
4// connection handshake (4-way), and channel handshake (4-way + close).
5// Mirroring the packet datagrams in msgs.gno, proof heights are plain block
6// numbers (u64) and constructors are pure (no realm boundary).
7
8// --- client lifecycle ---
9
10type MsgCreateClient struct {
11 ClientType ClientType
12 ClientStateBytes []byte
13 ConsensusStateBytes []byte
14 Relayer string
15}
16
17func NewMsgCreateClient(clientType ClientType, clientStateBytes, consensusStateBytes []byte) MsgCreateClient {
18 return MsgCreateClient{ClientType: clientType, ClientStateBytes: clientStateBytes, ConsensusStateBytes: consensusStateBytes}
19}
20
21type MsgUpdateClient struct {
22 ClientId ClientId
23 ClientMessage []byte
24 Relayer string
25}
26
27func NewMsgUpdateClient(clientId ClientId, clientMessage []byte) MsgUpdateClient {
28 return MsgUpdateClient{ClientId: clientId, ClientMessage: clientMessage}
29}
30
31type MsgForceUpdateClient struct {
32 ClientId ClientId
33 ClientStateBytes []byte
34 ConsensusStateBytes []byte
35}
36
37func NewMsgForceUpdateClient(clientId ClientId, clientStateBytes, consensusStateBytes []byte) MsgForceUpdateClient {
38 return MsgForceUpdateClient{ClientId: clientId, ClientStateBytes: clientStateBytes, ConsensusStateBytes: consensusStateBytes}
39}
40
41type MsgMisbehaviour struct {
42 ClientId ClientId
43 ClientMessage []byte
44 Relayer string
45}
46
47func NewMsgMisbehaviour(clientId ClientId, clientMessage []byte, relayer string) MsgMisbehaviour {
48 return MsgMisbehaviour{ClientId: clientId, ClientMessage: clientMessage, Relayer: relayer}
49}
50
51// --- connection handshake ---
52
53type MsgConnectionOpenInit struct {
54 ClientId ClientId
55 CounterpartyClientId ClientId
56}
57
58func NewMsgConnectionOpenInit(clientId, counterpartyClientId ClientId) MsgConnectionOpenInit {
59 return MsgConnectionOpenInit{ClientId: clientId, CounterpartyClientId: counterpartyClientId}
60}
61
62type MsgConnectionOpenTry struct {
63 ClientId ClientId
64 CounterpartyClientId ClientId
65 CounterpartyConnectionId ConnectionId
66 ProofInit []byte
67 ProofHeight uint64
68}
69
70func NewMsgConnectionOpenTry(clientId, counterpartyClientId ClientId, counterpartyConnectionId ConnectionId, proofInit []byte, proofHeight uint64) MsgConnectionOpenTry {
71 return MsgConnectionOpenTry{ClientId: clientId, CounterpartyClientId: counterpartyClientId, CounterpartyConnectionId: counterpartyConnectionId, ProofInit: proofInit, ProofHeight: proofHeight}
72}
73
74type MsgConnectionOpenAck struct {
75 ConnectionId ConnectionId
76 CounterpartyConnectionId ConnectionId
77 ProofTry []byte
78 ProofHeight uint64
79}
80
81func NewMsgConnectionOpenAck(connectionId, counterpartyConnectionId ConnectionId, proofTry []byte, proofHeight uint64) MsgConnectionOpenAck {
82 return MsgConnectionOpenAck{ConnectionId: connectionId, CounterpartyConnectionId: counterpartyConnectionId, ProofTry: proofTry, ProofHeight: proofHeight}
83}
84
85type MsgConnectionOpenConfirm struct {
86 ConnectionId ConnectionId
87 ProofAck []byte
88 ProofHeight uint64
89}
90
91func NewMsgConnectionOpenConfirm(connectionId ConnectionId, proofAck []byte, proofHeight uint64) MsgConnectionOpenConfirm {
92 return MsgConnectionOpenConfirm{ConnectionId: connectionId, ProofAck: proofAck, ProofHeight: proofHeight}
93}
94
95// --- channel handshake ---
96
97type MsgChannelOpenInit struct {
98 PortId []byte
99 CounterpartyPortId []byte
100 ConnectionId ConnectionId
101 Version string
102 Relayer string
103}
104
105func NewMsgChannelOpenInit(portId, counterpartyPortId []byte, connectionId ConnectionId, version string, relayer string) MsgChannelOpenInit {
106 return MsgChannelOpenInit{PortId: portId, CounterpartyPortId: counterpartyPortId, ConnectionId: connectionId, Version: version, Relayer: relayer}
107}
108
109type MsgChannelOpenTry struct {
110 PortId []byte
111 Channel Channel
112 CounterpartyVersion string
113 ProofInit []byte
114 ProofHeight uint64
115 Relayer string
116}
117
118func NewMsgChannelOpenTry(portId []byte, channel Channel, counterpartyVersion string, proofInit []byte, proofHeight uint64, relayer string) MsgChannelOpenTry {
119 return MsgChannelOpenTry{PortId: portId, Channel: channel, CounterpartyVersion: counterpartyVersion, ProofInit: proofInit, ProofHeight: proofHeight, Relayer: relayer}
120}
121
122type MsgChannelOpenAck struct {
123 ChannelId ChannelId
124 CounterpartyVersion string
125 CounterpartyChannelId ChannelId
126 ProofTry []byte
127 ProofHeight uint64
128 Relayer string
129}
130
131func NewMsgChannelOpenAck(channelId ChannelId, counterpartyVersion string, counterpartyChannelId ChannelId, proofTry []byte, proofHeight uint64, relayer string) MsgChannelOpenAck {
132 return MsgChannelOpenAck{ChannelId: channelId, CounterpartyVersion: counterpartyVersion, CounterpartyChannelId: counterpartyChannelId, ProofTry: proofTry, ProofHeight: proofHeight, Relayer: relayer}
133}
134
135type MsgChannelOpenConfirm struct {
136 ChannelId ChannelId
137 ProofAck []byte
138 ProofHeight uint64
139 Relayer string
140}
141
142func NewMsgChannelOpenConfirm(channelId ChannelId, proofAck []byte, proofHeight uint64, relayer string) MsgChannelOpenConfirm {
143 return MsgChannelOpenConfirm{ChannelId: channelId, ProofAck: proofAck, ProofHeight: proofHeight, Relayer: relayer}
144}
145
146type MsgChannelCloseInit struct {
147 ChannelId ChannelId
148 Relayer string
149}
150
151func NewMsgChannelCloseInit(channelId ChannelId, relayer string) MsgChannelCloseInit {
152 return MsgChannelCloseInit{ChannelId: channelId, Relayer: relayer}
153}
154
155type MsgChannelCloseConfirm struct {
156 ChannelId ChannelId
157 ProofInit []byte
158 ProofHeight uint64
159 Relayer string
160}
161
162func NewMsgChannelCloseConfirm(channelId ChannelId, proofInit []byte, proofHeight uint64, relayer string) MsgChannelCloseConfirm {
163 return MsgChannelCloseConfirm{ChannelId: channelId, ProofInit: proofInit, ProofHeight: proofHeight, Relayer: relayer}
164}