-
Notifications
You must be signed in to change notification settings - Fork 580
/
query.go
66 lines (57 loc) · 2.15 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
package types
import (
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/ibc-go/v3/modules/core/exported"
)
var (
_ codectypes.UnpackInterfacesMessage = QueryClientStateResponse{}
_ codectypes.UnpackInterfacesMessage = QueryClientStatesResponse{}
_ codectypes.UnpackInterfacesMessage = QueryConsensusStateResponse{}
_ codectypes.UnpackInterfacesMessage = QueryConsensusStatesResponse{}
)
// UnpackInterfaces implements UnpackInterfacesMesssage.UnpackInterfaces
func (qcsr QueryClientStatesResponse) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error {
for _, cs := range qcsr.ClientStates {
if err := cs.UnpackInterfaces(unpacker); err != nil {
return err
}
}
return nil
}
// NewQueryClientStateResponse creates a new QueryClientStateResponse instance.
func NewQueryClientStateResponse(
clientStateAny *codectypes.Any, proof []byte, height Height,
) *QueryClientStateResponse {
return &QueryClientStateResponse{
ClientState: clientStateAny,
Proof: proof,
ProofHeight: height,
}
}
// UnpackInterfaces implements UnpackInterfacesMesssage.UnpackInterfaces
func (qcsr QueryClientStateResponse) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error {
return unpacker.UnpackAny(qcsr.ClientState, new(exported.ClientState))
}
// UnpackInterfaces implements UnpackInterfacesMesssage.UnpackInterfaces
func (qcsr QueryConsensusStatesResponse) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error {
for _, cs := range qcsr.ConsensusStates {
if err := cs.UnpackInterfaces(unpacker); err != nil {
return err
}
}
return nil
}
// NewQueryConsensusStateResponse creates a new QueryConsensusStateResponse instance.
func NewQueryConsensusStateResponse(
consensusStateAny *codectypes.Any, proof []byte, height Height,
) *QueryConsensusStateResponse {
return &QueryConsensusStateResponse{
ConsensusState: consensusStateAny,
Proof: proof,
ProofHeight: height,
}
}
// UnpackInterfaces implements UnpackInterfacesMesssage.UnpackInterfaces
func (qcsr QueryConsensusStateResponse) UnpackInterfaces(unpacker codectypes.AnyUnpacker) error {
return unpacker.UnpackAny(qcsr.ConsensusState, new(exported.ConsensusState))
}