-
Notifications
You must be signed in to change notification settings - Fork 0
/
query.go
249 lines (235 loc) · 11.4 KB
/
query.go
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
package types
import (
codectypes "github.com/ci123chain/ci123chain/pkg/abci/codec/types"
clienttypes "github.com/ci123chain/ci123chain/pkg/ibc/core/clients/types"
"github.com/ci123chain/ci123chain/pkg/ibc/core/exported"
)
//// QueryPacketCommitmentRequest is the request type for the
//// Query/PacketCommitment RPC method
//type QueryPacketCommitmentRequest struct {
// // port unique identifier
// PortId string `protobuf:"bytes,1,opt,name=port_id,json=portId,proto3" json:"port_id,omitempty"`
// // channel unique identifier
// ChannelId string `protobuf:"bytes,2,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"`
// // packet sequence
// Sequence uint64 `protobuf:"varint,3,opt,name=sequence,proto3" json:"sequence,omitempty"`
//}
//
//
//// QueryPacketCommitmentResponse defines the client query response for a packet
//// which also includes a proof and the height from which the proof was
//// retrieved
//type QueryPacketCommitmentResponse struct {
// // packet associated with the request fields
// Commitment []byte `protobuf:"bytes,1,opt,name=commitment,proto3" json:"commitment,omitempty"`
// // merkle proof of existence
// Proof []byte `protobuf:"bytes,2,opt,name=proof,proto3" json:"proof,omitempty"`
// // height at which the proof was retrieved
// ProofHeight clienttypes.Height `protobuf:"bytes,3,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height"`
//}
//
//
//// QueryPacketCommitmentsRequest is the request type for the
//// Query/QueryPacketCommitments RPC method
//type QueryPacketCommitmentsRequest struct {
// // port unique identifier
// PortId string `protobuf:"bytes,1,opt,name=port_id,json=portId,proto3" json:"port_id,omitempty"`
// // channel unique identifier
// ChannelId string `protobuf:"bytes,2,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"`
// // pagination request
// Pagination *pagination.PageRequest `protobuf:"bytes,3,opt,name=pagination,proto3" json:"pagination,omitempty"`
//}
//
//// QueryPacketCommitmentsResponse is the request type for the
//// Query/QueryPacketCommitments RPC method
//type QueryPacketCommitmentsResponse struct {
// Commitments []*PacketState `protobuf:"bytes,1,rep,name=commitments,proto3" json:"commitments,omitempty"`
// // pagination response
// Pagination *pagination.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"`
// // query block height
// Height clienttypes.Height `protobuf:"bytes,3,opt,name=height,proto3" json:"height"`
//}
//
//
//// PacketState defines the generic type necessary to retrieve and store
//// packet commitments, acknowledgements, and receipts.
//// Caller is responsible for knowing the context necessary to interpret this
//// state as a commitment, acknowledgement, or a receipt.
//type PacketState struct {
// // channel port identifier.
// PortId string `protobuf:"bytes,1,opt,name=port_id,json=portId,proto3" json:"port_id,omitempty" yaml:"port_id"`
// // channel unique identifier.
// ChannelId string `protobuf:"bytes,2,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty" yaml:"channel_id"`
// // packet sequence.
// Sequence uint64 `protobuf:"varint,3,opt,name=sequence,proto3" json:"sequence,omitempty"`
// // embedded data that represents packet state.
// Data []byte `protobuf:"bytes,4,opt,name=data,proto3" json:"data,omitempty"`
//}
//
//// QueryUnreceivedPacketsRequest is the request type for the
//// Query/UnreceivedPackets RPC method
//type QueryUnreceivedPacketsRequest struct {
// // port unique identifier
// PortId string `protobuf:"bytes,1,opt,name=port_id,json=portId,proto3" json:"port_id,omitempty"`
// // channel unique identifier
// ChannelId string `protobuf:"bytes,2,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"`
// // list of packet sequences
// PacketCommitmentSequences []uint64 `protobuf:"varint,3,rep,packed,name=packet_commitment_sequences,json=packetCommitmentSequences,proto3" json:"packet_commitment_sequences,omitempty"`
//}
//
//// QueryUnreceivedPacketsResponse is the response type for the
//// Query/UnreceivedPacketCommitments RPC method
//type QueryUnreceivedPacketsResponse struct {
// // list of unreceived packet sequences
// Sequences []uint64 `protobuf:"varint,1,rep,packed,name=sequences,proto3" json:"sequences,omitempty"`
// // query block height
// Height clienttypes.Height `protobuf:"bytes,2,opt,name=height,proto3" json:"height"`
//}
//
//
//
//// QueryChannelResponse is the response type for the Query/Channel RPC method.
//// Besides the Channel end, it includes a proof and the height from which the
//// proof was retrieved.
//type QueryChannelResponse struct {
// // channel associated with the request identifiers
// Channel *Channel `protobuf:"bytes,1,opt,name=channel,proto3" json:"channel,omitempty"`
// // merkle proof of existence
// Proof []byte `protobuf:"bytes,2,opt,name=proof,proto3" json:"proof,omitempty"`
// // height at which the proof was retrieved
// ProofHeight clienttypes.Height `protobuf:"bytes,3,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height"`
//}
// NewQueryChannelResponse creates a new QueryChannelResponse instance
func NewQueryChannelResponse(channel Channel, proof []byte, height clienttypes.Height) *QueryChannelResponse {
return &QueryChannelResponse{
Channel: &channel,
Proof: proof,
ProofHeight: height,
}
}
//// QueryChannelsRequest is the request type for the Query/Channels RPC method
//type QueryChannelsRequest struct {
// // pagination request
// Pagination *pagination.PageRequest `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination,omitempty"`
//}
//// QueryChannelsResponse is the response type for the Query/Channels RPC method.
//type QueryChannelsResponse struct {
// // list of stored channels of the chain.
// Channels []*IdentifiedChannel `protobuf:"bytes,1,rep,name=channels,proto3" json:"channels,omitempty"`
// // pagination response
// Pagination *pagination.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"`
// // query block height
// Height clienttypes.Height `protobuf:"bytes,3,opt,name=height,proto3" json:"height"`
//}
//
//
//// QueryPacketAcknowledgementRequest is the request type for the
//// Query/PacketAcknowledgement RPC method
//type QueryPacketAcknowledgementRequest struct {
// // port unique identifier
// PortId string `protobuf:"bytes,1,opt,name=port_id,json=portId,proto3" json:"port_id,omitempty"`
// // channel unique identifier
// ChannelId string `protobuf:"bytes,2,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"`
// // packet sequence
// Sequence uint64 `protobuf:"varint,3,opt,name=sequence,proto3" json:"sequence,omitempty"`
//}
//
//// QueryPacketAcknowledgementResponse defines the client query response for a
//// packet which also includes a proof and the height from which the
//// proof was retrieved
//type QueryPacketAcknowledgementResponse struct {
// // packet associated with the request fields
// Acknowledgement []byte `protobuf:"bytes,1,opt,name=acknowledgement,proto3" json:"acknowledgement,omitempty"`
// // merkle proof of existence
// Proof []byte `protobuf:"bytes,2,opt,name=proof,proto3" json:"proof,omitempty"`
// // height at which the proof was retrieved
// ProofHeight clienttypes.Height `protobuf:"bytes,3,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height"`
//}
//
//// QueryPacketAcknowledgementsRequest is the request type for the
//// Query/QueryPacketCommitments RPC method
//type QueryPacketAcknowledgementsRequest struct {
// // port unique identifier
// PortId string `protobuf:"bytes,1,opt,name=port_id,json=portId,proto3" json:"port_id,omitempty"`
// // channel unique identifier
// ChannelId string `protobuf:"bytes,2,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"`
// // pagination request
// Pagination *pagination.PageRequest `protobuf:"bytes,3,opt,name=pagination,proto3" json:"pagination,omitempty"`
//}
//// QueryPacketAcknowledgemetsResponse is the request type for the
//// Query/QueryPacketAcknowledgements RPC method
//type QueryPacketAcknowledgementsResponse struct {
// Acknowledgements []*PacketState `protobuf:"bytes,1,rep,name=acknowledgements,proto3" json:"acknowledgements,omitempty"`
// // pagination response
// Pagination *pagination.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"`
// // query block height
// Height clienttypes.Height `protobuf:"bytes,3,opt,name=height,proto3" json:"height"`
//}
// NewQueryPacketAcknowledgementResponse creates a new QueryPacketAcknowledgementResponse instance
func NewQueryPacketAcknowledgementResponse(
acknowledgement []byte, proof []byte, height clienttypes.Height,
) *QueryPacketAcknowledgementResponse {
return &QueryPacketAcknowledgementResponse{
Acknowledgement: acknowledgement,
Proof: proof,
ProofHeight: height,
}
}
//// QueryPacketReceiptRequest is the request type for the
//// Query/PacketReceipt RPC method
//type QueryPacketReceiptRequest struct {
// // port unique identifier
// PortId string `protobuf:"bytes,1,opt,name=port_id,json=portId,proto3" json:"port_id,omitempty"`
// // channel unique identifier
// ChannelId string `protobuf:"bytes,2,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"`
// // packet sequence
// Sequence uint64 `protobuf:"varint,3,opt,name=sequence,proto3" json:"sequence,omitempty"`
//}
//// QueryPacketReceiptResponse defines the client query response for a packet receipt
//// which also includes a proof, and the height from which the proof was
//// retrieved
//type QueryPacketReceiptResponse struct {
// // success flag for if receipt exists
// Received bool `protobuf:"varint,2,opt,name=received,proto3" json:"received,omitempty"`
// // merkle proof of existence
// Proof []byte `protobuf:"bytes,3,opt,name=proof,proto3" json:"proof,omitempty"`
// // height at which the proof was retrieved
// ProofHeight clienttypes.Height `protobuf:"bytes,4,opt,name=proof_height,json=proofHeight,proto3" json:"proof_height"`
//}
// NewQueryPacketReceiptResponse creates a new QueryPacketReceiptResponse instance
func NewQueryPacketReceiptResponse(
recvd bool, proof []byte, height clienttypes.Height,
) *QueryPacketReceiptResponse {
return &QueryPacketReceiptResponse{
Received: recvd,
Proof: proof,
ProofHeight: height,
}
}
// NewQueryChannelClientStateResponse creates a newQueryChannelClientStateResponse instance
func NewQueryChannelClientStateResponse(identifiedClientState clienttypes.IdentifiedClientState, proof []byte, height clienttypes.Height) *QueryChannelClientStateResponse {
return &QueryChannelClientStateResponse{
IdentifiedClientState: &identifiedClientState,
Proof: proof,
ProofHeight: height,
}
}
// NewQueryChannelConsensusStateResponse creates a newQueryChannelConsensusStateResponse instance
func NewQueryChannelConsensusStateResponse(clientID string, anyConsensusState *codectypes.Any, consensusStateHeight exported.Height, proof []byte, height clienttypes.Height) *QueryChannelConsensusStateResponse {
return &QueryChannelConsensusStateResponse{
ConsensusState: anyConsensusState,
ClientId: clientID,
Proof: proof,
ProofHeight: height,
}
}
// NewQueryNextSequenceReceiveResponse creates a new QueryNextSequenceReceiveResponse instance
func NewQueryNextSequenceReceiveResponse(
sequence uint64, proof []byte, height clienttypes.Height,
) *QueryNextSequenceReceiveResponse {
return &QueryNextSequenceReceiveResponse{
NextSequenceReceive: sequence,
Proof: proof,
ProofHeight: height,
}
}