forked from hyperledger-labs/yui-relayer
/
chain.go
127 lines (92 loc) · 5.37 KB
/
chain.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
package core
import (
"time"
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
transfertypes "github.com/cosmos/ibc-go/modules/apps/transfer/types"
clienttypes "github.com/cosmos/ibc-go/modules/core/02-client/types"
conntypes "github.com/cosmos/ibc-go/modules/core/03-connection/types"
chantypes "github.com/cosmos/ibc-go/modules/core/04-channel/types"
ibcexported "github.com/cosmos/ibc-go/modules/core/exported"
)
// ProvableChain represents a chain that is supported by the relayer
type ProvableChain struct {
ChainI
ProverI
}
// NewProvableChain returns a new ProvableChain instance
func NewProvableChain(chain ChainI, prover ProverI) *ProvableChain {
return &ProvableChain{ChainI: chain, ProverI: prover}
}
// ChainI represents a chain that supports sending transactions and querying the state
type ChainI interface {
// ChainID returns ID of the chain
ChainID() string
// GetLatestHeight gets the chain for the latest height and returns it
GetLatestHeight() (int64, error)
// GetAddress returns the address of relayer
GetAddress() (sdk.AccAddress, error)
// Codec returns the codec
Codec() codec.ProtoCodecMarshaler
// SetPath sets a given path to the chain
SetPath(p *PathEnd) error
// Path returns the path
Path() *PathEnd
// SendMsgs sends msgs to the chain
SendMsgs(msgs []sdk.Msg) ([]byte, error)
// Send sends msgs to the chain and logging a result of it
// It returns a boolean value whether the result is success
Send(msgs []sdk.Msg) bool
// StartEventListener ...
StartEventListener(dst ChainI, strategy StrategyI)
// Init ...
Init(homePath string, timeout time.Duration, codec codec.ProtoCodecMarshaler, debug bool) error
IBCQuerierI
}
// IBCQuerierI is an interface to the state of IBC
type IBCQuerierI interface {
// QueryClientConsensusState retrevies the latest consensus state for a client in state at a given height
QueryClientConsensusState(height int64, dstClientConsHeight ibcexported.Height) (*clienttypes.QueryConsensusStateResponse, error)
// QueryClientState returns the client state of dst chain
// height represents the height of dst chain
QueryClientState(height int64) (*clienttypes.QueryClientStateResponse, error)
// QueryConnection returns the remote end of a given connection
QueryConnection(height int64) (*conntypes.QueryConnectionResponse, error)
// QueryChannel returns the channel associated with a channelID
QueryChannel(height int64) (chanRes *chantypes.QueryChannelResponse, err error)
// QueryPacketCommitment returns the packet commitment corresponding to a given sequence
QueryPacketCommitment(height int64, seq uint64) (comRes *chantypes.QueryPacketCommitmentResponse, err error)
// QueryPacketAcknowledgementCommitment returns the acknowledgement corresponding to a given sequence
QueryPacketAcknowledgementCommitment(height int64, seq uint64) (ackRes *chantypes.QueryPacketAcknowledgementResponse, err error)
// QueryPacketCommitments returns an array of packet commitments
QueryPacketCommitments(offset, limit uint64, height int64) (comRes *chantypes.QueryPacketCommitmentsResponse, err error)
// QueryUnrecievedPackets returns a list of unrelayed packet commitments
QueryUnrecievedPackets(height int64, seqs []uint64) ([]uint64, error)
// QueryPacketAcknowledgementCommitments returns an array of packet acks
QueryPacketAcknowledgementCommitments(offset, limit uint64, height int64) (comRes *chantypes.QueryPacketAcknowledgementsResponse, err error)
// QueryUnrecievedAcknowledgements returns a list of unrelayed packet acks
QueryUnrecievedAcknowledgements(height int64, seqs []uint64) ([]uint64, error)
// QueryPacket returns the packet corresponding to a sequence
QueryPacket(height int64, sequence uint64) (*chantypes.Packet, error)
// QueryPacketAcknowledgement returns the acknowledgement corresponding to a sequence
QueryPacketAcknowledgement(height int64, sequence uint64) ([]byte, error)
// QueryBalance returns the amount of coins in the relayer account
QueryBalance(address sdk.AccAddress) (sdk.Coins, error)
// QueryDenomTraces returns all the denom traces from a given chain
QueryDenomTraces(offset, limit uint64, height int64) (*transfertypes.QueryDenomTracesResponse, error)
}
// IBCProvableQuerierI is an interface to the state of IBC and its proof.
type IBCProvableQuerierI interface {
// QueryClientConsensusState returns the ClientConsensusState and its proof
QueryClientConsensusStateWithProof(height int64, dstClientConsHeight ibcexported.Height) (*clienttypes.QueryConsensusStateResponse, error)
// QueryClientStateWithProof returns the ClientState and its proof
QueryClientStateWithProof(height int64) (*clienttypes.QueryClientStateResponse, error)
// QueryConnectionWithProof returns the Connection and its proof
QueryConnectionWithProof(height int64) (*conntypes.QueryConnectionResponse, error)
// QueryChannelWithProof returns the Channel and its proof
QueryChannelWithProof(height int64) (chanRes *chantypes.QueryChannelResponse, err error)
// QueryPacketCommitmentWithProof returns the packet commitment and its proof
QueryPacketCommitmentWithProof(height int64, seq uint64) (comRes *chantypes.QueryPacketCommitmentResponse, err error)
// QueryPacketAcknowledgementCommitmentWithProof returns the packet acknowledgement commitment and its proof
QueryPacketAcknowledgementCommitmentWithProof(height int64, seq uint64) (ackRes *chantypes.QueryPacketAcknowledgementResponse, err error)
}