x/ibc: gRPC query service (#6466)
* x/ibc: gRPC query service * fixes * connection updates * register channel query service * update clients * change proofs to bytes * implement additional channel grpc queries * unrelayed packets query * query.proto files * move next sequence recv query to channel client * update REST * wip test * add missing cli queries * install the right tools * fixes * build * lint * use gRPC when query proof is not requested * connection gRPC tests * IBC query server interface * more gRPC channel tests * pagination tests * connection use query server * connection pagination tests * channel pagination tests * typo * remove buf * Update x/ibc/03-connection/keeper/grpc_query_test.go Co-authored-by: colin axner <25233464+colin-axner@users.noreply.github.com> * address comments from review * fix tests * unrelayed packet sequences flag * remove ClientsConnections query * fix Co-authored-by: colin axner <25233464+colin-axner@users.noreply.github.com>
This commit is contained in:
parent
2f44fbf2ab
commit
f35e3b2c02
|
@ -17,32 +17,32 @@ message MsgChannelOpenInit {
|
|||
// MsgChannelOpenInit defines a msg sent by a Relayer to try to open a channel
|
||||
// on Chain B.
|
||||
message MsgChannelOpenTry {
|
||||
string port_id = 1 [(gogoproto.customname) = "PortID", (gogoproto.moretags) = "yaml:\"port_id\""];
|
||||
string channel_id = 2 [(gogoproto.customname) = "ChannelID", (gogoproto.moretags) = "yaml:\"channel_id\""];
|
||||
Channel channel = 3 [(gogoproto.nullable) = false];
|
||||
string counterparty_version = 4 [(gogoproto.moretags) = "yaml:\"counterparty_version\""];
|
||||
bytes proof_init = 5 [(gogoproto.moretags) = "yaml:\"proof_init\""];
|
||||
uint64 proof_height = 6 [(gogoproto.moretags) = "yaml:\"proof_height\""];
|
||||
bytes signer = 7 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"];
|
||||
string port_id = 1 [(gogoproto.customname) = "PortID", (gogoproto.moretags) = "yaml:\"port_id\""];
|
||||
string channel_id = 2 [(gogoproto.customname) = "ChannelID", (gogoproto.moretags) = "yaml:\"channel_id\""];
|
||||
Channel channel = 3 [(gogoproto.nullable) = false];
|
||||
string counterparty_version = 4 [(gogoproto.moretags) = "yaml:\"counterparty_version\""];
|
||||
bytes proof_init = 5 [(gogoproto.moretags) = "yaml:\"proof_init\""];
|
||||
uint64 proof_height = 6 [(gogoproto.moretags) = "yaml:\"proof_height\""];
|
||||
bytes signer = 7 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"];
|
||||
}
|
||||
|
||||
// MsgChannelOpenAck defines a msg sent by a Relayer to Chain A to acknowledge
|
||||
// the change of channel state to TRYOPEN on Chain B.
|
||||
message MsgChannelOpenAck {
|
||||
string port_id = 1 [(gogoproto.customname) = "PortID", (gogoproto.moretags) = "yaml:\"port_id\""];
|
||||
string channel_id = 2 [(gogoproto.customname) = "ChannelID", (gogoproto.moretags) = "yaml:\"channel_id\""];
|
||||
string counterparty_version = 3 [(gogoproto.moretags) = "yaml:\"counterparty_version\""];
|
||||
bytes proof_try = 4 [(gogoproto.moretags) = "yaml:\"proof_try\""];
|
||||
uint64 proof_height = 5 [(gogoproto.moretags) = "yaml:\"proof_height\""];
|
||||
bytes signer = 6 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"];
|
||||
string port_id = 1 [(gogoproto.customname) = "PortID", (gogoproto.moretags) = "yaml:\"port_id\""];
|
||||
string channel_id = 2 [(gogoproto.customname) = "ChannelID", (gogoproto.moretags) = "yaml:\"channel_id\""];
|
||||
string counterparty_version = 3 [(gogoproto.moretags) = "yaml:\"counterparty_version\""];
|
||||
bytes proof_try = 4 [(gogoproto.moretags) = "yaml:\"proof_try\""];
|
||||
uint64 proof_height = 5 [(gogoproto.moretags) = "yaml:\"proof_height\""];
|
||||
bytes signer = 6 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"];
|
||||
}
|
||||
|
||||
// MsgChannelOpenConfirm defines a msg sent by a Relayer to Chain B to acknowledge
|
||||
// the change of channel state to OPEN on Chain A.
|
||||
message MsgChannelOpenConfirm {
|
||||
string port_id = 1 [(gogoproto.customname) = "PortID", (gogoproto.moretags) = "yaml:\"port_id\""];
|
||||
string channel_id = 2 [(gogoproto.customname) = "ChannelID", (gogoproto.moretags) = "yaml:\"channel_id\""];
|
||||
bytes proof_ack = 3 [(gogoproto.moretags) = "yaml:\"proof_ack\""];
|
||||
string port_id = 1 [(gogoproto.customname) = "PortID", (gogoproto.moretags) = "yaml:\"port_id\""];
|
||||
string channel_id = 2 [(gogoproto.customname) = "ChannelID", (gogoproto.moretags) = "yaml:\"channel_id\""];
|
||||
bytes proof_ack = 3 [(gogoproto.moretags) = "yaml:\"proof_ack\""];
|
||||
uint64 proof_height = 4 [(gogoproto.moretags) = "yaml:\"proof_height\""];
|
||||
bytes signer = 5 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"];
|
||||
}
|
||||
|
@ -58,37 +58,37 @@ message MsgChannelCloseInit {
|
|||
// MsgChannelCloseConfirm defines a msg sent by a Relayer to Chain B
|
||||
// to acknowledge the change of channel state to CLOSED on Chain A.
|
||||
message MsgChannelCloseConfirm {
|
||||
string port_id = 1 [(gogoproto.customname) = "PortID", (gogoproto.moretags) = "yaml:\"port_id\""];
|
||||
string channel_id = 2 [(gogoproto.customname) = "ChannelID", (gogoproto.moretags) = "yaml:\"channel_id\""];
|
||||
bytes proof_init = 3 [(gogoproto.moretags) = "yaml:\"proof_init\""];
|
||||
string port_id = 1 [(gogoproto.customname) = "PortID", (gogoproto.moretags) = "yaml:\"port_id\""];
|
||||
string channel_id = 2 [(gogoproto.customname) = "ChannelID", (gogoproto.moretags) = "yaml:\"channel_id\""];
|
||||
bytes proof_init = 3 [(gogoproto.moretags) = "yaml:\"proof_init\""];
|
||||
uint64 proof_height = 4 [(gogoproto.moretags) = "yaml:\"proof_height\""];
|
||||
bytes signer = 5 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"];
|
||||
}
|
||||
|
||||
// MsgPacket receives incoming IBC packet
|
||||
message MsgPacket {
|
||||
Packet packet = 1 [(gogoproto.nullable) = false];
|
||||
bytes proof = 2;
|
||||
uint64 proof_height = 3 [(gogoproto.moretags) = "yaml:\"proof_height\""];
|
||||
bytes signer = 4 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"];
|
||||
Packet packet = 1 [(gogoproto.nullable) = false];
|
||||
bytes proof = 2;
|
||||
uint64 proof_height = 3 [(gogoproto.moretags) = "yaml:\"proof_height\""];
|
||||
bytes signer = 4 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"];
|
||||
}
|
||||
|
||||
// MsgTimeout receives timed-out packet
|
||||
message MsgTimeout {
|
||||
Packet packet = 1 [(gogoproto.nullable) = false];
|
||||
bytes proof = 2;
|
||||
uint64 proof_height = 3 [(gogoproto.moretags) = "yaml:\"proof_height\""];
|
||||
uint64 next_sequence_recv = 4 [(gogoproto.moretags) = "yaml:\"next_sequence_recv\""];
|
||||
bytes signer = 5 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"];
|
||||
Packet packet = 1 [(gogoproto.nullable) = false];
|
||||
bytes proof = 2;
|
||||
uint64 proof_height = 3 [(gogoproto.moretags) = "yaml:\"proof_height\""];
|
||||
uint64 next_sequence_recv = 4 [(gogoproto.moretags) = "yaml:\"next_sequence_recv\""];
|
||||
bytes signer = 5 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"];
|
||||
}
|
||||
|
||||
// MsgAcknowledgement receives incoming IBC acknowledgement
|
||||
message MsgAcknowledgement {
|
||||
Packet packet = 1 [(gogoproto.nullable) = false];
|
||||
bytes acknowledgement = 2;
|
||||
bytes proof = 3;
|
||||
uint64 proof_height = 4 [(gogoproto.moretags) = "yaml:\"proof_height\""];
|
||||
bytes signer = 5 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"];
|
||||
Packet packet = 1 [(gogoproto.nullable) = false];
|
||||
bytes acknowledgement = 2;
|
||||
bytes proof = 3;
|
||||
uint64 proof_height = 4 [(gogoproto.moretags) = "yaml:\"proof_height\""];
|
||||
bytes signer = 5 [(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.AccAddress"];
|
||||
}
|
||||
|
||||
// Channel defines pipeline for exactly-once packet delivery between specific
|
||||
|
@ -110,6 +110,28 @@ message Channel {
|
|||
string version = 5;
|
||||
}
|
||||
|
||||
// IdentifiedChannel defines a channel with additional port and channel identifier
|
||||
// fields.
|
||||
message IdentifiedChannel {
|
||||
option (gogoproto.goproto_getters) = false;
|
||||
|
||||
// current state of the channel end
|
||||
State state = 1;
|
||||
// whether the channel is ordered or unordered
|
||||
Order ordering = 2;
|
||||
// counterparty channel end
|
||||
Counterparty counterparty = 3 [(gogoproto.nullable) = false];
|
||||
// list of connection identifiers, in order, along which packets sent on this
|
||||
// channel will travel
|
||||
repeated string connection_hops = 4 [(gogoproto.moretags) = "yaml:\"connection_hops\""];
|
||||
// opaque channel version, which is agreed upon during the handshake
|
||||
string version = 5;
|
||||
// port identifier
|
||||
string port_id = 6 [(gogoproto.customname) = "PortID"];
|
||||
// channel identifier
|
||||
string channel_id = 7 [(gogoproto.customname) = "ChannelID"];
|
||||
}
|
||||
|
||||
// State defines if a channel is in one of the following states:
|
||||
// CLOSED, INIT, TRYOPEN, OPEN or UNINITIALIZED.
|
||||
enum State {
|
||||
|
@ -173,3 +195,18 @@ message Packet {
|
|||
// block timestamp (in nanoseconds) after which the packet times out
|
||||
uint64 timeout_timestamp = 8 [(gogoproto.moretags) = "yaml:\"timeout_timestamp\""];
|
||||
}
|
||||
|
||||
// PacketAckCommitment defines the genesis type necessary to retrieve and store
|
||||
// acknowlegements.
|
||||
message PacketAckCommitment {
|
||||
option (gogoproto.goproto_getters) = false;
|
||||
|
||||
// channel port identifier.
|
||||
string port_id = 1 [(gogoproto.customname) = "PortID", (gogoproto.moretags) = "yaml:\"port_id\""];
|
||||
// channel unique identifier.
|
||||
string channel_id = 2 [(gogoproto.customname) = "ChannelID", (gogoproto.moretags) = "yaml:\"channel_id\""];
|
||||
// packet sequence.
|
||||
uint64 sequence = 3;
|
||||
// packet commitment hash.
|
||||
bytes hash = 4;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,183 @@
|
|||
syntax = "proto3";
|
||||
package ibc.channel;
|
||||
|
||||
import "gogoproto/gogo.proto";
|
||||
import "cosmos/query/pagination.proto";
|
||||
import "ibc/channel/channel.proto";
|
||||
|
||||
option go_package = "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types";
|
||||
|
||||
// Query provides defines the gRPC querier service
|
||||
service Query {
|
||||
// Channel queries an IBC Channel.
|
||||
rpc Channel(QueryChannelRequest) returns (QueryChannelResponse) {}
|
||||
|
||||
// Channels queries all the IBC channels of a chain.
|
||||
rpc Channels(QueryChannelsRequest) returns (QueryChannelsResponse) {}
|
||||
|
||||
// ConnectionChannels queries all the channels associated with a connection end.
|
||||
rpc ConnectionChannels(QueryConnectionChannelsRequest) returns (QueryConnectionChannelsResponse) {}
|
||||
|
||||
// PacketCommitment queries a stored packet commitment hash.
|
||||
rpc PacketCommitment(QueryPacketCommitmentRequest) returns (QueryPacketCommitmentResponse) {}
|
||||
|
||||
// PacketCommitments returns the all the packet commitments hashes associated with a channel.
|
||||
rpc PacketCommitments(QueryPacketCommitmentsRequest) returns (QueryPacketCommitmentsResponse) {}
|
||||
|
||||
// UnrelayedPackets returns all the unrelayed IBC packets associated with a channel and sequences.
|
||||
rpc UnrelayedPackets(QueryUnrelayedPacketsRequest) returns (QueryUnrelayedPacketsResponse) {}
|
||||
|
||||
// NextSequenceReceive returns the next receive sequence for a given channel
|
||||
rpc NextSequenceReceive(QueryNextSequenceReceiveRequest) returns (QueryNextSequenceReceiveResponse) {}
|
||||
|
||||
// TODO: blocked by client proto migration
|
||||
// rpc ChannelClientState(QueryChannelClientStateRequest) returns (QueryChannelClientStateRequest) {}
|
||||
}
|
||||
|
||||
// QueryChannelRequest is the request type for the Query/Channel RPC method
|
||||
message QueryChannelRequest {
|
||||
// port unique identifier
|
||||
string port_id = 1 [(gogoproto.customname) = "PortID"];
|
||||
// channel unique identifier
|
||||
string channel_id = 2 [(gogoproto.customname) = "ChannelID"];
|
||||
}
|
||||
|
||||
// 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.
|
||||
message QueryChannelResponse {
|
||||
// channel associated with the request identifiers
|
||||
ibc.channel.Channel channel = 1;
|
||||
// merkle proof of existence
|
||||
bytes proof = 2;
|
||||
// merkle proof path
|
||||
string proof_path = 3;
|
||||
// height at which the proof was retrieved
|
||||
uint64 proof_height = 4;
|
||||
}
|
||||
|
||||
// QueryChannelsRequest is the request type for the Query/Channels RPC method
|
||||
message QueryChannelsRequest {
|
||||
// pagination request
|
||||
cosmos.query.PageRequest req = 1;
|
||||
}
|
||||
|
||||
// QueryChannelsResponse is the response type for the Query/Channels RPC method.
|
||||
message QueryChannelsResponse {
|
||||
// list of stored channels of the chain.
|
||||
repeated ibc.channel.IdentifiedChannel channels = 1;
|
||||
// pagination response
|
||||
cosmos.query.PageResponse res = 2;
|
||||
// query block height
|
||||
int64 height = 3;
|
||||
}
|
||||
|
||||
// QueryConnectionChannelsRequest is the request type for the Query/QueryConnectionChannels RPC method
|
||||
message QueryConnectionChannelsRequest {
|
||||
// connection unique identifier
|
||||
string connection = 1;
|
||||
// pagination request
|
||||
cosmos.query.PageRequest req = 2;
|
||||
}
|
||||
|
||||
// QueryConnectionChannelsResponse is the Response type for the Query/QueryConnectionChannels RPC method
|
||||
message QueryConnectionChannelsResponse {
|
||||
// list of channels associated with a connection.
|
||||
repeated ibc.channel.IdentifiedChannel channels = 1;
|
||||
// pagination response
|
||||
cosmos.query.PageResponse res = 2;
|
||||
// query block height
|
||||
int64 height = 3;
|
||||
}
|
||||
|
||||
// QueryPacketCommitmentRequest is the request type for the Query/PacketCommitment RPC method
|
||||
message QueryPacketCommitmentRequest {
|
||||
// port unique identifier
|
||||
string port_id = 1 [(gogoproto.customname) = "PortID"];
|
||||
// channel unique identifier
|
||||
string channel_id = 2 [(gogoproto.customname) = "ChannelID"];
|
||||
// packet sequence
|
||||
uint64 sequence = 3;
|
||||
}
|
||||
|
||||
// QueryPacketCommitmentResponse defines the client query response for a packet which also
|
||||
// includes a proof, its path and the height form which the proof was retrieved
|
||||
message QueryPacketCommitmentResponse {
|
||||
// packet associated with the request fields
|
||||
bytes commitment = 1;
|
||||
// merkle proof of existence
|
||||
bytes proof = 2;
|
||||
// merkle proof path
|
||||
string proof_path = 3;
|
||||
// height at which the proof was retrieved
|
||||
uint64 proof_height = 4;
|
||||
}
|
||||
|
||||
// QueryPacketCommitmentsRequest is the request type for the Query/QueryPacketCommitments RPC method
|
||||
message QueryPacketCommitmentsRequest {
|
||||
// port unique identifier
|
||||
string port_id = 1 [(gogoproto.customname) = "PortID"];
|
||||
// channel unique identifier
|
||||
string channel_id = 2 [(gogoproto.customname) = "ChannelID"];
|
||||
// pagination request
|
||||
cosmos.query.PageRequest req = 3;
|
||||
}
|
||||
|
||||
// QueryPacketCommitmentsResponse is the request type for the Query/QueryPacketCommitments RPC method
|
||||
message QueryPacketCommitmentsResponse {
|
||||
repeated ibc.channel.PacketAckCommitment commitments = 1;
|
||||
// pagination response
|
||||
cosmos.query.PageResponse res = 2;
|
||||
// query block height
|
||||
int64 height = 3;
|
||||
}
|
||||
|
||||
// QueryUnrelayedPacketsRequest is the request type for the Query/QueryConnectionChannels RPC method
|
||||
message QueryUnrelayedPacketsRequest {
|
||||
// port unique identifier
|
||||
string port_id = 1 [(gogoproto.customname) = "PortID"];
|
||||
// channel unique identifier
|
||||
string channel_id = 2 [(gogoproto.customname) = "ChannelID"];
|
||||
// list of packet sequences
|
||||
repeated uint64 sequences = 3;
|
||||
// pagination request
|
||||
cosmos.query.PageRequest req = 4;
|
||||
}
|
||||
|
||||
// QueryUnrelayedPacketsResponse is the request type for the Query/QueryConnectionChannels RPC method
|
||||
message QueryUnrelayedPacketsResponse {
|
||||
// list of unrelayed packets sequences
|
||||
repeated uint64 packets = 1;
|
||||
// pagination response
|
||||
cosmos.query.PageResponse res = 2;
|
||||
// query block height
|
||||
int64 height = 3;
|
||||
}
|
||||
|
||||
// QueryNextSequenceReceiveRequest is the request type for the Query/QueryNextSequenceReceiveRequest RPC method
|
||||
message QueryNextSequenceReceiveRequest {
|
||||
// port unique identifier
|
||||
string port_id = 1 [(gogoproto.customname) = "PortID"];
|
||||
// channel unique identifier
|
||||
string channel_id = 2 [(gogoproto.customname) = "ChannelID"];
|
||||
}
|
||||
|
||||
// QuerySequenceResponse is the request type for the Query/QueryNextSequenceReceiveResponse RPC method
|
||||
message QueryNextSequenceReceiveResponse {
|
||||
// next sequence receive number
|
||||
uint64 next_sequence_receive = 1;
|
||||
// merkle proof of existence
|
||||
bytes proof = 2;
|
||||
// merkle proof path
|
||||
string proof_path = 3;
|
||||
// height at which the proof was retrieved
|
||||
uint64 proof_height = 4;
|
||||
}
|
||||
|
||||
// QueryChannelClientStateRequest is the request type for the Query/ClientState RPC method
|
||||
message QueryChannelClientStateRequest {
|
||||
// port unique identifier
|
||||
string port_id = 1 [(gogoproto.customname) = "PortID"];
|
||||
// channel unique identifier
|
||||
string channel_id = 2 [(gogoproto.customname) = "ChannelID"];
|
||||
}
|
|
@ -23,7 +23,7 @@ message MsgConnectionOpenTry {
|
|||
Counterparty counterparty = 3 [(gogoproto.nullable) = false];
|
||||
repeated string counterparty_versions = 4 [(gogoproto.moretags) = "yaml:\"counterparty_versions\""];
|
||||
// proof of the initialization the connection on Chain A: `UNITIALIZED -> INIT`
|
||||
bytes proof_init = 5 [(gogoproto.moretags) = "yaml:\"proof_init\""];
|
||||
bytes proof_init = 5 [(gogoproto.moretags) = "yaml:\"proof_init\""];
|
||||
uint64 proof_height = 6;
|
||||
// proof of client consensus state
|
||||
bytes proof_consensus = 7
|
||||
|
@ -110,5 +110,14 @@ message Counterparty {
|
|||
|
||||
// ClientPaths define all the connection paths for a client state.
|
||||
message ClientPaths {
|
||||
// list of connection paths
|
||||
repeated string paths = 1;
|
||||
}
|
||||
|
||||
// ConnectionPaths define all the connection paths for a given client state.
|
||||
message ConnectionPaths {
|
||||
// client state unique identifier
|
||||
string client_id = 1 [(gogoproto.customname) = "ClientID", (gogoproto.moretags) = "yaml:\"client_id\""];
|
||||
// list of connection paths
|
||||
repeated string paths = 2;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,75 @@
|
|||
syntax = "proto3";
|
||||
package ibc.connection;
|
||||
|
||||
import "gogoproto/gogo.proto";
|
||||
import "cosmos/query/pagination.proto";
|
||||
import "ibc/connection/connection.proto";
|
||||
|
||||
option go_package = "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/types";
|
||||
|
||||
// Query provides defines the gRPC querier service
|
||||
service Query {
|
||||
// Connection queries an IBC connection end.
|
||||
rpc Connection(QueryConnectionRequest) returns (QueryConnectionResponse) {}
|
||||
|
||||
// Connections queries all the IBC connections of a chain.
|
||||
rpc Connections(QueryConnectionsRequest) returns (QueryConnectionsResponse) {}
|
||||
|
||||
// ClientConnections queries the connection paths associated with a client state.
|
||||
rpc ClientConnections(QueryClientConnectionsRequest) returns (QueryClientConnectionsResponse) {}
|
||||
}
|
||||
|
||||
// QueryConnectionRequest is the request type for the Query/Connection RPC method
|
||||
message QueryConnectionRequest {
|
||||
// connection unique identifier
|
||||
string connection_id = 1 [(gogoproto.customname) = "ConnectionID"];
|
||||
}
|
||||
|
||||
// QueryConnectionResponse is the response type for the Query/Connection RPC method.
|
||||
// Besides the connection end, it includes a proof and the height from which the
|
||||
// proof was retrieved.
|
||||
message QueryConnectionResponse {
|
||||
// connection associated with the request identifier
|
||||
ibc.connection.ConnectionEnd connection = 1;
|
||||
// merkle proof of existence
|
||||
bytes proof = 2;
|
||||
// merkle proof path
|
||||
string proof_path = 3;
|
||||
// height at which the proof was retrieved
|
||||
uint64 proof_height = 4;
|
||||
}
|
||||
|
||||
// QueryConnectionsRequest is the request type for the Query/Connections RPC method
|
||||
message QueryConnectionsRequest {
|
||||
cosmos.query.PageRequest req = 1;
|
||||
}
|
||||
|
||||
// QueryConnectionsResponse is the response type for the Query/Connections RPC method.
|
||||
message QueryConnectionsResponse {
|
||||
// list of stored connections of the chain.
|
||||
repeated ibc.connection.ConnectionEnd connections = 1;
|
||||
// pagination response
|
||||
cosmos.query.PageResponse res = 2;
|
||||
// query block height
|
||||
int64 height = 3;
|
||||
}
|
||||
|
||||
// QueryClientConnectionsRequest is the request type for the Query/ClientConnections
|
||||
// RPC method
|
||||
message QueryClientConnectionsRequest {
|
||||
// client identifier associated with a connection
|
||||
string client_id = 1 [(gogoproto.customname) = "ClientID"];
|
||||
}
|
||||
|
||||
// QueryClientConnectionsResponse is the response type for the Query/ClientConnections
|
||||
// RPC method
|
||||
message QueryClientConnectionsResponse {
|
||||
// slice of all the connection paths associated with a client.
|
||||
repeated string connection_paths = 1;
|
||||
// merkle proof of existence
|
||||
bytes proof = 2;
|
||||
// merkle proof path
|
||||
string proof_path = 3;
|
||||
// height at which the proof was generated
|
||||
uint64 proof_height = 4;
|
||||
}
|
|
@ -80,7 +80,6 @@ Example:
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return clientCtx.PrintOutput(res.Balances)
|
||||
}
|
||||
|
||||
|
|
|
@ -7,9 +7,8 @@ import (
|
|||
"google.golang.org/grpc/status"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/store/prefix"
|
||||
"github.com/cosmos/cosmos-sdk/types/query"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/query"
|
||||
"github.com/cosmos/cosmos-sdk/x/bank/types"
|
||||
)
|
||||
|
||||
|
|
|
@ -7,23 +7,6 @@ import (
|
|||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
)
|
||||
|
||||
// GetQueryCmd returns the query commands for IBC fungible token transfer
|
||||
func GetQueryCmd(clientCtx client.Context) *cobra.Command {
|
||||
ics20TransferQueryCmd := &cobra.Command{
|
||||
Use: "ibc-transfer",
|
||||
Short: "IBC fungible token transfer query subcommands",
|
||||
DisableFlagParsing: true,
|
||||
SuggestionsMinimumDistance: 2,
|
||||
RunE: client.ValidateCmd,
|
||||
}
|
||||
|
||||
ics20TransferQueryCmd.AddCommand(flags.GetCommands(
|
||||
GetCmdQueryNextSequence(clientCtx),
|
||||
)...)
|
||||
|
||||
return ics20TransferQueryCmd
|
||||
}
|
||||
|
||||
// NewTxCmd returns the transaction commands for IBC fungible token transfer
|
||||
func NewTxCmd(clientCtx client.Context) *cobra.Command {
|
||||
ics20TransferTxCmd := &cobra.Command{
|
||||
|
|
|
@ -1,49 +0,0 @@
|
|||
package cli
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/cosmos/cosmos-sdk/version"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc-transfer/client/utils"
|
||||
)
|
||||
|
||||
// GetCmdQueryNextSequence defines the command to query a next receive sequence
|
||||
// TODO: move to channel
|
||||
func GetCmdQueryNextSequence(clientCtx client.Context) *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "next-recv [port-id] [channel-id]",
|
||||
Short: "Query a next receive sequence",
|
||||
Long: strings.TrimSpace(fmt.Sprintf(`Query an IBC channel end
|
||||
|
||||
Example:
|
||||
$ %s query ibc-transfer next-recv [port-id] [channel-id]
|
||||
`, version.ClientName),
|
||||
),
|
||||
Example: fmt.Sprintf("%s query ibc-transfer next-recv [port-id] [channel-id]", version.ClientName),
|
||||
Args: cobra.ExactArgs(2),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx = clientCtx.Init()
|
||||
|
||||
portID := args[0]
|
||||
channelID := args[1]
|
||||
prove, _ := cmd.Flags().GetBool(flags.FlagProve)
|
||||
|
||||
sequenceRes, err := utils.QueryNextSequenceRecv(clientCtx, portID, channelID, prove)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
clientCtx = clientCtx.WithHeight(int64(sequenceRes.ProofHeight))
|
||||
return clientCtx.PrintOutput(sequenceRes)
|
||||
},
|
||||
}
|
||||
|
||||
cmd.Flags().Bool(flags.FlagProve, true, "show proofs for the query results")
|
||||
|
||||
return cmd
|
||||
}
|
|
@ -1,51 +0,0 @@
|
|||
package rest
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/cosmos/cosmos-sdk/types/rest"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc-transfer/client/utils"
|
||||
)
|
||||
|
||||
func registerQueryRoutes(clientCtx client.Context, r *mux.Router) {
|
||||
r.HandleFunc(fmt.Sprintf("/ibc/ports/{%s}/channels/{%s}/next-sequence-recv", RestPortID, RestChannelID), queryNextSequenceRecvHandlerFn(clientCtx)).Methods("GET")
|
||||
}
|
||||
|
||||
// queryNextSequenceRecvHandlerFn implements a next sequence receive querying route
|
||||
//
|
||||
// @Summary Query next sequence receive
|
||||
// @Tags IBC
|
||||
// @Produce json
|
||||
// @Param port-id path string true "Port ID"
|
||||
// @Param channel-id path string true "Channel ID"
|
||||
// @Success 200 {object} QueryNextSequenceRecv "OK"
|
||||
// @Failure 400 {object} rest.ErrorResponse "Invalid port id or channel id"
|
||||
// @Failure 500 {object} rest.ErrorResponse "Internal Server Error"
|
||||
// @Router /ibc/ports/{port-id}/channels/{channel-id}/next-sequence-recv [get]
|
||||
func queryNextSequenceRecvHandlerFn(clientCtx client.Context) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
vars := mux.Vars(r)
|
||||
portID := vars[RestPortID]
|
||||
channelID := vars[RestChannelID]
|
||||
prove := rest.ParseQueryParamBool(r, flags.FlagProve)
|
||||
|
||||
clientCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, clientCtx, r)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
sequenceRes, err := utils.QueryNextSequenceRecv(clientCtx, portID, channelID, prove)
|
||||
if err != nil {
|
||||
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
clientCtx = clientCtx.WithHeight(int64(sequenceRes.ProofHeight))
|
||||
rest.PostProcessResponse(w, clientCtx, sequenceRes)
|
||||
}
|
||||
}
|
|
@ -9,13 +9,12 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
RestChannelID = "channel-id"
|
||||
RestPortID = "port-id"
|
||||
restChannelID = "channel-id"
|
||||
restPortID = "port-id"
|
||||
)
|
||||
|
||||
// RegisterRoutes - Central function to define routes that get registered by the main application
|
||||
func RegisterRoutes(clientCtx client.Context, r *mux.Router) {
|
||||
registerQueryRoutes(clientCtx, r)
|
||||
registerTxRoutes(clientCtx, r)
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ import (
|
|||
)
|
||||
|
||||
func registerTxRoutes(clientCtx client.Context, r *mux.Router) {
|
||||
r.HandleFunc(fmt.Sprintf("/ibc/ports/{%s}/channels/{%s}/transfer", RestPortID, RestChannelID), transferHandlerFn(clientCtx)).Methods("POST")
|
||||
r.HandleFunc(fmt.Sprintf("/ibc/ports/{%s}/channels/{%s}/transfer", restPortID, restChannelID), transferHandlerFn(clientCtx)).Methods("POST")
|
||||
}
|
||||
|
||||
// transferHandlerFn implements a transfer handler
|
||||
|
@ -33,8 +33,8 @@ func registerTxRoutes(clientCtx client.Context, r *mux.Router) {
|
|||
func transferHandlerFn(clientCtx client.Context) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
vars := mux.Vars(r)
|
||||
portID := vars[RestPortID]
|
||||
channelID := vars[RestChannelID]
|
||||
portID := vars[restPortID]
|
||||
channelID := vars[restChannelID]
|
||||
|
||||
var req TransferTxReq
|
||||
if !rest.ReadRESTReq(w, r, clientCtx.Codec, &req) {
|
||||
|
|
|
@ -1,33 +0,0 @@
|
|||
package utils
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
channeltypes "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types"
|
||||
host "github.com/cosmos/cosmos-sdk/x/ibc/24-host"
|
||||
)
|
||||
|
||||
// QueryNextSequenceRecv queries the store to get the next receive sequence and
|
||||
// a merkle proof.
|
||||
func QueryNextSequenceRecv(
|
||||
clientCtx client.Context, portID, channelID string, prove bool,
|
||||
) (channeltypes.RecvResponse, error) {
|
||||
req := abci.RequestQuery{
|
||||
Path: "store/ibc/key",
|
||||
Data: host.KeyNextSequenceRecv(portID, channelID),
|
||||
Prove: prove,
|
||||
}
|
||||
|
||||
res, err := clientCtx.QueryABCI(req)
|
||||
if err != nil {
|
||||
return channeltypes.RecvResponse{}, err
|
||||
}
|
||||
|
||||
sequence := binary.BigEndian.Uint64(res.Value)
|
||||
sequenceRes := channeltypes.NewRecvResponse(portID, channelID, sequence, res.Proof, res.Height)
|
||||
|
||||
return sequenceRes, nil
|
||||
}
|
|
@ -77,7 +77,7 @@ func (AppModuleBasic) GetTxCmd(clientCtx client.Context) *cobra.Command {
|
|||
|
||||
// GetQueryCmd implements AppModuleBasic interface
|
||||
func (AppModuleBasic) GetQueryCmd(clientCtx client.Context) *cobra.Command {
|
||||
return cli.GetQueryCmd(clientCtx)
|
||||
return nil
|
||||
}
|
||||
|
||||
// RegisterInterfaceTypes registers module concrete types into protobuf Any.
|
||||
|
|
|
@ -20,6 +20,7 @@ func GetQueryCmd(clientCtx client.Context) *cobra.Command {
|
|||
ics03ConnectionQueryCmd.AddCommand(flags.GetCommands(
|
||||
GetCmdQueryConnections(clientCtx),
|
||||
GetCmdQueryConnection(clientCtx),
|
||||
GetCmdQueryClientConnections(clientCtx),
|
||||
)...)
|
||||
|
||||
return ics03ConnectionQueryCmd
|
||||
|
|
|
@ -1,48 +1,51 @@
|
|||
package cli
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/cosmos/cosmos-sdk/types/query"
|
||||
"github.com/cosmos/cosmos-sdk/version"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/03-connection/client/utils"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/03-connection/types"
|
||||
host "github.com/cosmos/cosmos-sdk/x/ibc/24-host"
|
||||
)
|
||||
|
||||
// GetCmdQueryConnections defines the command to query all the connection ends
|
||||
// that this chain mantains.
|
||||
func GetCmdQueryConnections(clientCtx client.Context) *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "connections",
|
||||
Short: "Query all available light clients",
|
||||
Long: strings.TrimSpace(
|
||||
fmt.Sprintf(`Query all available connections
|
||||
|
||||
Example:
|
||||
$ %s query ibc connection connections
|
||||
`, version.ClientName),
|
||||
),
|
||||
Example: fmt.Sprintf("%s query ibc connection connections", version.ClientName),
|
||||
Use: "connections",
|
||||
Short: "Query all connections",
|
||||
Long: "Query all connections ends from a chain",
|
||||
Example: fmt.Sprintf("%s query %s %s connections", version.ClientName, host.ModuleName, types.SubModuleName),
|
||||
Args: cobra.NoArgs,
|
||||
RunE: func(cmd *cobra.Command, _ []string) error {
|
||||
clientCtx = clientCtx.Init()
|
||||
queryClient := types.NewQueryClient(clientCtx)
|
||||
|
||||
page, _ := cmd.Flags().GetInt(flags.FlagPage)
|
||||
offset, _ := cmd.Flags().GetInt(flags.FlagPage)
|
||||
limit, _ := cmd.Flags().GetInt(flags.FlagLimit)
|
||||
|
||||
connections, height, err := utils.QueryAllConnections(clientCtx, page, limit)
|
||||
req := &types.QueryConnectionsRequest{
|
||||
Req: &query.PageRequest{
|
||||
Offset: uint64(offset),
|
||||
Limit: uint64(limit),
|
||||
},
|
||||
}
|
||||
|
||||
res, err := queryClient.Connections(context.Background(), req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
clientCtx = clientCtx.WithHeight(height)
|
||||
return clientCtx.PrintOutput(connections)
|
||||
return clientCtx.PrintOutput(res)
|
||||
},
|
||||
}
|
||||
|
||||
cmd.Flags().Int(flags.FlagPage, 1, "pagination page of light clients to to query for")
|
||||
cmd.Flags().Int(flags.FlagLimit, 100, "pagination limit of light clients to query for")
|
||||
|
||||
|
@ -52,21 +55,19 @@ $ %s query ibc connection connections
|
|||
// GetCmdQueryConnection defines the command to query a connection end
|
||||
func GetCmdQueryConnection(clientCtx client.Context) *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "end [connection-id]",
|
||||
Short: "Query stored connection end",
|
||||
Long: strings.TrimSpace(fmt.Sprintf(`Query stored connection end
|
||||
|
||||
Example:
|
||||
$ %s query ibc connection end [connection-id]
|
||||
`, version.ClientName),
|
||||
),
|
||||
Example: fmt.Sprintf("%s query ibc connection end [connection-id]", version.ClientName),
|
||||
Use: "end [connection-id]",
|
||||
Short: "Query stored connection end",
|
||||
Long: "Query stored connection end",
|
||||
Example: fmt.Sprintf("%s query %s %s end [connection-id]", version.ClientName, host.ModuleName, types.SubModuleName),
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx = clientCtx.Init()
|
||||
|
||||
connectionID := args[0]
|
||||
prove, _ := cmd.Flags().GetBool(flags.FlagProve)
|
||||
prove, err := cmd.Flags().GetBool(flags.FlagProve)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
connRes, err := utils.QueryConnection(clientCtx, connectionID, prove)
|
||||
if err != nil {
|
||||
|
@ -83,59 +84,22 @@ $ %s query ibc connection end [connection-id]
|
|||
return cmd
|
||||
}
|
||||
|
||||
// GetCmdQueryAllClientConnections defines the command to query a all the client connection paths.
|
||||
func GetCmdQueryAllClientConnections(clientCtx client.Context) *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "paths",
|
||||
Short: "Query all stored client connection paths",
|
||||
Long: strings.TrimSpace(fmt.Sprintf(`Query all stored client connection paths
|
||||
|
||||
Example:
|
||||
$ %s query ibc connection paths
|
||||
`, version.ClientName),
|
||||
),
|
||||
Example: fmt.Sprintf("%s query ibc connection paths", version.ClientName),
|
||||
Args: cobra.NoArgs,
|
||||
RunE: func(cmd *cobra.Command, _ []string) error {
|
||||
clientCtx = clientCtx.Init()
|
||||
|
||||
page, _ := cmd.Flags().GetInt(flags.FlagPage)
|
||||
limit, _ := cmd.Flags().GetInt(flags.FlagLimit)
|
||||
|
||||
connectionPaths, height, err := utils.QueryAllClientConnectionPaths(clientCtx, page, limit)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
clientCtx = clientCtx.WithHeight(height)
|
||||
return clientCtx.PrintOutput(connectionPaths)
|
||||
},
|
||||
}
|
||||
|
||||
cmd.Flags().Int(flags.FlagPage, 1, "pagination page of light clients to to query for")
|
||||
cmd.Flags().Int(flags.FlagLimit, 100, "pagination limit of light clients to query for")
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
// GetCmdQueryClientConnections defines the command to query a client connections
|
||||
func GetCmdQueryClientConnections(clientCtx client.Context) *cobra.Command {
|
||||
return &cobra.Command{
|
||||
Use: "path [client-id]",
|
||||
Short: "Query stored client connection paths",
|
||||
Long: strings.TrimSpace(fmt.Sprintf(`Query stored client connection paths
|
||||
|
||||
Example:
|
||||
$ %s query ibc connection path [client-id]
|
||||
`, version.ClientName),
|
||||
),
|
||||
Example: fmt.Sprintf("%s query ibc connection path [client-id]", version.ClientName),
|
||||
Use: "path [client-id]",
|
||||
Short: "Query stored client connection paths",
|
||||
Long: "Query stored client connection paths",
|
||||
Example: fmt.Sprintf("%s query %s %s path [client-id]", version.ClientName, host.ModuleName, types.SubModuleName),
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx = clientCtx.Init()
|
||||
|
||||
clientID := args[0]
|
||||
prove, _ := cmd.Flags().GetBool(flags.FlagProve)
|
||||
prove, err := cmd.Flags().GetBool(flags.FlagProve)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
connPathsRes, err := utils.QueryClientConnections(clientCtx, clientID, prove)
|
||||
if err != nil {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package rest
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
|
@ -8,62 +9,42 @@ import (
|
|||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/cosmos/cosmos-sdk/types/query"
|
||||
"github.com/cosmos/cosmos-sdk/types/rest"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/03-connection/client/utils"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/03-connection/types"
|
||||
)
|
||||
|
||||
func registerQueryRoutes(clientCtx client.Context, r *mux.Router) {
|
||||
r.HandleFunc("/ibc/connections", queryConnectionsHandlerFn(clientCtx)).Methods("GET")
|
||||
r.HandleFunc(fmt.Sprintf("/ibc/connections/{%s}", RestConnectionID), queryConnectionHandlerFn(clientCtx)).Methods("GET")
|
||||
r.HandleFunc("/ibc/clients/connections", queryClientsConnectionsHandlerFn(clientCtx)).Methods("GET")
|
||||
r.HandleFunc(fmt.Sprintf("/ibc/clients/{%s}/connections", RestClientID), queryClientConnectionsHandlerFn(clientCtx)).Methods("GET")
|
||||
}
|
||||
|
||||
// queryConnectionsHandlerFn implements connections querying route
|
||||
//
|
||||
// @Summary Query a client connection paths
|
||||
// @Tags IBC
|
||||
// @Produce json
|
||||
// @Param page query int false "The page number to query" default(1)
|
||||
// @Param limit query int false "The number of results per page" default(100)
|
||||
// @Success 200 {object} QueryConnection "OK"
|
||||
// @Failure 400 {object} rest.ErrorResponse "Bad Request"
|
||||
// @Failure 500 {object} rest.ErrorResponse "Internal Server Error"
|
||||
// @Router /ibc/connections [get]
|
||||
func queryClientsConnectionsHandlerFn(clientCtx client.Context) http.HandlerFunc {
|
||||
func queryConnectionsHandlerFn(clientCtx client.Context) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
_, page, limit, err := rest.ParseHTTPArgsWithLimit(r, 0)
|
||||
if rest.CheckBadRequestError(w, err) {
|
||||
return
|
||||
}
|
||||
|
||||
clientCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, clientCtx, r)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
connections, height, err := utils.QueryAllConnections(clientCtx, page, limit)
|
||||
queryClient := types.NewQueryClient(clientCtx)
|
||||
|
||||
req := &types.QueryConnectionsRequest{
|
||||
Req: &query.PageRequest{},
|
||||
}
|
||||
|
||||
res, err := queryClient.Connections(context.Background(), req)
|
||||
if err != nil {
|
||||
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
clientCtx = clientCtx.WithHeight(height)
|
||||
rest.PostProcessResponse(w, clientCtx, connections)
|
||||
clientCtx = clientCtx.WithHeight(res.Height)
|
||||
rest.PostProcessResponse(w, clientCtx, res)
|
||||
}
|
||||
}
|
||||
|
||||
// queryConnectionHandlerFn implements a connection querying route
|
||||
//
|
||||
// @Summary Query connection
|
||||
// @Tags IBC
|
||||
// @Produce json
|
||||
// @Param connection-id path string true "Client ID"
|
||||
// @Param prove query boolean false "Proof of result"
|
||||
// @Success 200 {object} QueryConnection "OK"
|
||||
// @Failure 400 {object} rest.ErrorResponse "Invalid connection id"
|
||||
// @Failure 500 {object} rest.ErrorResponse "Internal Server Error"
|
||||
// @Router /ibc/connections/{connection-id} [get]
|
||||
func queryConnectionHandlerFn(clientCtx client.Context) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
vars := mux.Vars(r)
|
||||
|
@ -86,51 +67,6 @@ func queryConnectionHandlerFn(clientCtx client.Context) http.HandlerFunc {
|
|||
}
|
||||
}
|
||||
|
||||
// queryConnectionsHandlerFn implements a client connections paths querying route
|
||||
//
|
||||
// @Summary Query all client connection paths
|
||||
// @Tags IBC
|
||||
// @Produce json
|
||||
// @Param page query int false "The page number to query" default(1)
|
||||
// @Param limit query int false "The number of results per page" default(100)
|
||||
// @Success 200 {object} QueryClientsConnections "OK"
|
||||
// @Failure 400 {object} rest.ErrorResponse "Bad Request"
|
||||
// @Failure 500 {object} rest.ErrorResponse "Internal Server Error"
|
||||
// @Router /ibc/clients/connections [get]
|
||||
func queryConnectionsHandlerFn(clientCtx client.Context) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
_, page, limit, err := rest.ParseHTTPArgsWithLimit(r, 0)
|
||||
if rest.CheckBadRequestError(w, err) {
|
||||
return
|
||||
}
|
||||
|
||||
clientCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, clientCtx, r)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
connectionsPaths, height, err := utils.QueryAllClientConnectionPaths(clientCtx, page, limit)
|
||||
if err != nil {
|
||||
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
clientCtx = clientCtx.WithHeight(height)
|
||||
rest.PostProcessResponse(w, clientCtx, connectionsPaths)
|
||||
}
|
||||
}
|
||||
|
||||
// queryClientConnectionsHandlerFn implements a client connections querying route
|
||||
//
|
||||
// @Summary Query connections of a client
|
||||
// @Tags IBC
|
||||
// @Produce json
|
||||
// @Param client-id path string true "Client ID"
|
||||
// @Param prove query boolean false "Proof of result"
|
||||
// @Success 200 {object} QueryClientConnections "OK"
|
||||
// @Failure 400 {object} rest.ErrorResponse "Invalid client id"
|
||||
// @Failure 500 {object} rest.ErrorResponse "Internal Server Error"
|
||||
// @Router /ibc/clients/{client-id}/connections [get]
|
||||
func queryClientConnectionsHandlerFn(clientCtx client.Context) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
vars := mux.Vars(r)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package utils
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
|
||||
|
@ -15,101 +16,90 @@ import (
|
|||
host "github.com/cosmos/cosmos-sdk/x/ibc/24-host"
|
||||
)
|
||||
|
||||
// QueryAllConnections returns all the connections. It _does not_ return
|
||||
// any merkle proof.
|
||||
func QueryAllConnections(clientCtx client.Context, page, limit int) ([]types.ConnectionEnd, int64, error) {
|
||||
params := types.NewQueryAllConnectionsParams(page, limit)
|
||||
bz, err := clientCtx.JSONMarshaler.MarshalJSON(params)
|
||||
if err != nil {
|
||||
return nil, 0, fmt.Errorf("failed to marshal query params: %w", err)
|
||||
}
|
||||
|
||||
route := fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryAllConnections)
|
||||
res, height, err := clientCtx.QueryWithData(route, bz)
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
|
||||
var connections []types.ConnectionEnd
|
||||
err = clientCtx.JSONMarshaler.UnmarshalJSON(res, &connections)
|
||||
if err != nil {
|
||||
return nil, 0, fmt.Errorf("failed to unmarshal connections: %w", err)
|
||||
}
|
||||
return connections, height, nil
|
||||
}
|
||||
|
||||
// QueryConnection queries the store to get a connection end and a merkle
|
||||
// proof.
|
||||
// QueryConnection returns a connection end.
|
||||
// If prove is true, it performs an ABCI store query in order to retrieve the merkle proof. Otherwise,
|
||||
// it uses the gRPC query client.
|
||||
func QueryConnection(
|
||||
clientCtx client.Context, connectionID string, prove bool,
|
||||
) (types.ConnectionResponse, error) {
|
||||
) (*types.QueryConnectionResponse, error) {
|
||||
if prove {
|
||||
return queryConnectionABCI(clientCtx, connectionID)
|
||||
}
|
||||
|
||||
queryClient := types.NewQueryClient(clientCtx)
|
||||
req := &types.QueryConnectionRequest{
|
||||
ConnectionID: connectionID,
|
||||
}
|
||||
|
||||
return queryClient.Connection(context.Background(), req)
|
||||
}
|
||||
|
||||
func queryConnectionABCI(clientCtx client.Context, connectionID string) (*types.QueryConnectionResponse, error) {
|
||||
req := abci.RequestQuery{
|
||||
Path: "store/ibc/key",
|
||||
Data: host.KeyConnection(connectionID),
|
||||
Prove: prove,
|
||||
Prove: true,
|
||||
}
|
||||
|
||||
res, err := clientCtx.QueryABCI(req)
|
||||
if err != nil {
|
||||
return types.ConnectionResponse{}, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var connection types.ConnectionEnd
|
||||
if err := clientCtx.Codec.UnmarshalBinaryBare(res.Value, &connection); err != nil {
|
||||
return types.ConnectionResponse{}, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
connRes := types.NewConnectionResponse(connectionID, connection, res.Proof, res.Height)
|
||||
proofBz, err := clientCtx.Codec.MarshalBinaryBare(res.Proof)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return connRes, nil
|
||||
return types.NewQueryConnectionResponse(connection, proofBz, res.Height), nil
|
||||
}
|
||||
|
||||
// QueryAllClientConnectionPaths returns all the client connections paths. It
|
||||
// _does not_ return any merkle proof.
|
||||
func QueryAllClientConnectionPaths(clientCtx client.Context, page, limit int) ([]types.ConnectionPaths, int64, error) {
|
||||
params := types.NewQueryAllConnectionsParams(page, limit)
|
||||
bz, err := clientCtx.JSONMarshaler.MarshalJSON(params)
|
||||
if err != nil {
|
||||
return nil, 0, fmt.Errorf("failed to marshal query params: %w", err)
|
||||
}
|
||||
|
||||
route := fmt.Sprintf("custom/%s/%s", types.QuerierRoute, types.QueryAllClientConnections)
|
||||
res, height, err := clientCtx.QueryWithData(route, bz)
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
}
|
||||
|
||||
var connectionPaths []types.ConnectionPaths
|
||||
err = clientCtx.JSONMarshaler.UnmarshalJSON(res, &connectionPaths)
|
||||
if err != nil {
|
||||
return nil, 0, fmt.Errorf("failed to unmarshal client connection paths: %w", err)
|
||||
}
|
||||
return connectionPaths, height, nil
|
||||
}
|
||||
|
||||
// QueryClientConnections queries the store to get the registered connection paths
|
||||
// registered for a particular client and a merkle proof.
|
||||
// QueryClientConnections queries the connection paths registered for a particular client.
|
||||
// If prove is true, it performs an ABCI store query in order to retrieve the merkle proof. Otherwise,
|
||||
// it uses the gRPC query client.
|
||||
func QueryClientConnections(
|
||||
clientCtx client.Context, clientID string, prove bool,
|
||||
) (types.ClientConnectionsResponse, error) {
|
||||
) (*types.QueryClientConnectionsResponse, error) {
|
||||
if prove {
|
||||
return queryClientConnectionsABCI(clientCtx, clientID)
|
||||
}
|
||||
|
||||
queryClient := types.NewQueryClient(clientCtx)
|
||||
req := &types.QueryClientConnectionsRequest{
|
||||
ClientID: clientID,
|
||||
}
|
||||
|
||||
return queryClient.ClientConnections(context.Background(), req)
|
||||
}
|
||||
|
||||
func queryClientConnectionsABCI(clientCtx client.Context, clientID string) (*types.QueryClientConnectionsResponse, error) {
|
||||
req := abci.RequestQuery{
|
||||
Path: "store/ibc/key",
|
||||
Data: host.KeyClientConnections(clientID),
|
||||
Prove: prove,
|
||||
Prove: true,
|
||||
}
|
||||
|
||||
res, err := clientCtx.QueryABCI(req)
|
||||
if err != nil {
|
||||
return types.ClientConnectionsResponse{}, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var paths []string
|
||||
if err := clientCtx.Codec.UnmarshalBinaryBare(res.Value, &paths); err != nil {
|
||||
return types.ClientConnectionsResponse{}, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
connPathsRes := types.NewClientConnectionsResponse(clientID, paths, res.Proof, res.Height)
|
||||
return connPathsRes, nil
|
||||
proofBz, err := clientCtx.Codec.MarshalBinaryBare(res.Proof)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return types.NewQueryClientConnectionsResponse(clientID, paths, proofBz, res.Height), nil
|
||||
}
|
||||
|
||||
// ParsePrefix unmarshals an cmd input argument from a JSON string to a commitment
|
||||
|
|
|
@ -0,0 +1,99 @@
|
|||
package keeper
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/store/prefix"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
"github.com/cosmos/cosmos-sdk/types/query"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/03-connection/types"
|
||||
host "github.com/cosmos/cosmos-sdk/x/ibc/24-host"
|
||||
)
|
||||
|
||||
var _ types.QueryServer = Keeper{}
|
||||
|
||||
// Connection implements the Query/Connection gRPC method
|
||||
func (q Keeper) Connection(c context.Context, req *types.QueryConnectionRequest) (*types.QueryConnectionResponse, error) {
|
||||
if req == nil {
|
||||
return nil, status.Error(codes.InvalidArgument, "empty request")
|
||||
}
|
||||
|
||||
if err := host.ConnectionIdentifierValidator(req.ConnectionID); err != nil {
|
||||
return nil, status.Error(codes.InvalidArgument, err.Error())
|
||||
}
|
||||
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
connection, found := q.GetConnection(ctx, req.ConnectionID)
|
||||
if !found {
|
||||
return nil, status.Error(
|
||||
codes.NotFound,
|
||||
sdkerrors.Wrap(types.ErrConnectionNotFound, req.ConnectionID).Error(),
|
||||
)
|
||||
}
|
||||
|
||||
return &types.QueryConnectionResponse{
|
||||
Connection: &connection,
|
||||
ProofHeight: uint64(ctx.BlockHeight()),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Connections implements the Query/Connections gRPC method
|
||||
func (q Keeper) Connections(c context.Context, req *types.QueryConnectionsRequest) (*types.QueryConnectionsResponse, error) {
|
||||
if req == nil {
|
||||
return nil, status.Error(codes.InvalidArgument, "empty request")
|
||||
}
|
||||
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
|
||||
connections := []*types.ConnectionEnd{}
|
||||
store := prefix.NewStore(ctx.KVStore(q.storeKey), host.KeyConnectionPrefix)
|
||||
|
||||
res, err := query.Paginate(store, req.Req, func(_, value []byte) error {
|
||||
var result types.ConnectionEnd
|
||||
if err := q.cdc.UnmarshalBinaryBare(value, &result); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
connections = append(connections, &result)
|
||||
return nil
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &types.QueryConnectionsResponse{
|
||||
Connections: connections,
|
||||
Res: res,
|
||||
Height: ctx.BlockHeight(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// ClientConnections implements the Query/ClientConnections gRPC method
|
||||
func (q Keeper) ClientConnections(c context.Context, req *types.QueryClientConnectionsRequest) (*types.QueryClientConnectionsResponse, error) {
|
||||
if req == nil {
|
||||
return nil, status.Error(codes.InvalidArgument, "empty request")
|
||||
}
|
||||
|
||||
if err := host.ClientIdentifierValidator(req.ClientID); err != nil {
|
||||
return nil, status.Error(codes.InvalidArgument, err.Error())
|
||||
}
|
||||
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
clientConnectionPaths, found := q.GetClientConnectionPaths(ctx, req.ClientID)
|
||||
if !found {
|
||||
return nil, status.Error(
|
||||
codes.NotFound,
|
||||
sdkerrors.Wrap(types.ErrClientConnectionPathsNotFound, req.ClientID).Error(),
|
||||
)
|
||||
}
|
||||
|
||||
return &types.QueryClientConnectionsResponse{
|
||||
ConnectionPaths: clientConnectionPaths,
|
||||
ProofHeight: uint64(ctx.BlockHeight()),
|
||||
}, nil
|
||||
}
|
|
@ -0,0 +1,216 @@
|
|||
package keeper_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/query"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/03-connection/types"
|
||||
commitmenttypes "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/types"
|
||||
)
|
||||
|
||||
func (suite *KeeperTestSuite) TestQueryConnection() {
|
||||
var (
|
||||
req *types.QueryConnectionRequest
|
||||
expConnection types.ConnectionEnd
|
||||
)
|
||||
|
||||
testCases := []struct {
|
||||
msg string
|
||||
malleate func()
|
||||
expPass bool
|
||||
}{
|
||||
{
|
||||
"empty request",
|
||||
func() {
|
||||
req = nil
|
||||
},
|
||||
false,
|
||||
},
|
||||
{"invalid connectionID",
|
||||
func() {
|
||||
req = &types.QueryConnectionRequest{}
|
||||
},
|
||||
false,
|
||||
},
|
||||
{"connection not found",
|
||||
func() {
|
||||
req = &types.QueryConnectionRequest{
|
||||
ConnectionID: testConnectionIDB,
|
||||
}
|
||||
},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"success",
|
||||
func() {
|
||||
counterparty := types.NewCounterparty(testClientIDA, testConnectionIDA, commitmenttypes.NewMerklePrefix(suite.chainA.App.IBCKeeper.ConnectionKeeper.GetCommitmentPrefix().Bytes()))
|
||||
expConnection = types.NewConnectionEnd(types.INIT, testConnectionIDB, testClientIDB, counterparty, types.GetCompatibleVersions())
|
||||
suite.chainA.App.IBCKeeper.ConnectionKeeper.SetConnection(suite.chainA.GetContext(), testConnectionIDB, expConnection)
|
||||
|
||||
req = &types.QueryConnectionRequest{
|
||||
ConnectionID: testConnectionIDB,
|
||||
}
|
||||
},
|
||||
true,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
suite.Run(fmt.Sprintf("Case %s", tc.msg), func() {
|
||||
suite.SetupTest() // reset
|
||||
|
||||
tc.malleate()
|
||||
ctx := sdk.WrapSDKContext(suite.chainA.GetContext())
|
||||
|
||||
res, err := suite.chainA.QueryServer.Connection(ctx, req)
|
||||
|
||||
if tc.expPass {
|
||||
suite.Require().NoError(err)
|
||||
suite.Require().NotNil(res)
|
||||
suite.Require().Equal(&expConnection, res.Connection)
|
||||
} else {
|
||||
suite.Require().Error(err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (suite *KeeperTestSuite) TestQueryConnections() {
|
||||
var (
|
||||
req *types.QueryConnectionsRequest
|
||||
expConnections = []*types.ConnectionEnd{}
|
||||
)
|
||||
|
||||
testCases := []struct {
|
||||
msg string
|
||||
malleate func()
|
||||
expPass bool
|
||||
}{
|
||||
{
|
||||
"empty request",
|
||||
func() {
|
||||
req = nil
|
||||
},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"empty pagination",
|
||||
func() {
|
||||
req = &types.QueryConnectionsRequest{}
|
||||
},
|
||||
true,
|
||||
},
|
||||
{
|
||||
"success",
|
||||
func() {
|
||||
counterparty1 := types.NewCounterparty(testClientIDA, testConnectionIDA, commitmenttypes.NewMerklePrefix(suite.oldchainA.App.IBCKeeper.ConnectionKeeper.GetCommitmentPrefix().Bytes()))
|
||||
counterparty2 := types.NewCounterparty(testClientIDB, testConnectionIDB, commitmenttypes.NewMerklePrefix(suite.oldchainA.App.IBCKeeper.ConnectionKeeper.GetCommitmentPrefix().Bytes()))
|
||||
counterparty3 := types.NewCounterparty(testClientID3, testConnectionID3, commitmenttypes.NewMerklePrefix(suite.oldchainA.App.IBCKeeper.ConnectionKeeper.GetCommitmentPrefix().Bytes()))
|
||||
|
||||
conn1 := types.NewConnectionEnd(types.INIT, testConnectionIDA, testClientIDA, counterparty3, types.GetCompatibleVersions())
|
||||
conn2 := types.NewConnectionEnd(types.INIT, testConnectionIDB, testClientIDB, counterparty1, types.GetCompatibleVersions())
|
||||
conn3 := types.NewConnectionEnd(types.UNINITIALIZED, testConnectionID3, testClientID3, counterparty2, types.GetCompatibleVersions())
|
||||
|
||||
expConnections = []*types.ConnectionEnd{&conn1, &conn2, &conn3}
|
||||
|
||||
for i := range expConnections {
|
||||
suite.chainA.App.IBCKeeper.ConnectionKeeper.SetConnection(suite.chainA.GetContext(), expConnections[i].ID, *expConnections[i])
|
||||
}
|
||||
|
||||
req = &types.QueryConnectionsRequest{
|
||||
Req: &query.PageRequest{
|
||||
Limit: 3,
|
||||
CountTotal: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
true,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
suite.Run(fmt.Sprintf("Case %s", tc.msg), func() {
|
||||
suite.SetupTest() // reset
|
||||
|
||||
tc.malleate()
|
||||
ctx := sdk.WrapSDKContext(suite.chainA.GetContext())
|
||||
|
||||
res, err := suite.chainA.QueryServer.Connections(ctx, req)
|
||||
|
||||
if tc.expPass {
|
||||
suite.Require().NoError(err)
|
||||
suite.Require().NotNil(res)
|
||||
suite.Require().Equal(expConnections, res.Connections)
|
||||
} else {
|
||||
suite.Require().Error(err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (suite *KeeperTestSuite) TestQueryClientConnections() {
|
||||
var (
|
||||
req *types.QueryClientConnectionsRequest
|
||||
expPaths []string
|
||||
)
|
||||
|
||||
testCases := []struct {
|
||||
msg string
|
||||
malleate func()
|
||||
expPass bool
|
||||
}{
|
||||
{
|
||||
"empty request",
|
||||
func() {
|
||||
req = nil
|
||||
},
|
||||
false,
|
||||
},
|
||||
{"invalid connectionID",
|
||||
func() {
|
||||
req = &types.QueryClientConnectionsRequest{}
|
||||
},
|
||||
false,
|
||||
},
|
||||
{"connection not found",
|
||||
func() {
|
||||
req = &types.QueryClientConnectionsRequest{
|
||||
ClientID: testClientIDA,
|
||||
}
|
||||
},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"success",
|
||||
func() {
|
||||
expPaths = []string{testConnectionIDA, testConnectionIDB}
|
||||
suite.chainA.App.IBCKeeper.ConnectionKeeper.SetClientConnectionPaths(suite.chainA.GetContext(), testClientIDA, expPaths)
|
||||
|
||||
req = &types.QueryClientConnectionsRequest{
|
||||
ClientID: testClientIDA,
|
||||
}
|
||||
},
|
||||
true,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
suite.Run(fmt.Sprintf("Case %s", tc.msg), func() {
|
||||
suite.SetupTest() // reset
|
||||
|
||||
tc.malleate()
|
||||
ctx := sdk.WrapSDKContext(suite.chainA.GetContext())
|
||||
|
||||
res, err := suite.chainA.QueryServer.ClientConnections(ctx, req)
|
||||
|
||||
if tc.expPass {
|
||||
suite.Require().NoError(err)
|
||||
suite.Require().NotNil(res)
|
||||
suite.Require().Equal(expPaths, res.ConnectionPaths)
|
||||
} else {
|
||||
suite.Require().Error(err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
|
@ -18,6 +18,9 @@ import (
|
|||
|
||||
// Keeper defines the IBC connection keeper
|
||||
type Keeper struct {
|
||||
// implements gRPC QueryServer interface
|
||||
types.QueryServer
|
||||
|
||||
storeKey sdk.StoreKey
|
||||
aminoCdc *codec.Codec // amino codec. TODO: remove after clients have been migrated to proto
|
||||
cdc codec.Marshaler // hybrid codec
|
||||
|
|
|
@ -1,82 +0,0 @@
|
|||
package keeper
|
||||
|
||||
import (
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/03-connection/types"
|
||||
)
|
||||
|
||||
// QuerierConnections defines the sdk.Querier to query all the connections.
|
||||
func QuerierConnections(ctx sdk.Context, req abci.RequestQuery, k Keeper) ([]byte, error) {
|
||||
var params types.QueryAllConnectionsParams
|
||||
|
||||
if err := k.cdc.UnmarshalJSON(req.Data, ¶ms); err != nil {
|
||||
return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error())
|
||||
}
|
||||
|
||||
connections := k.GetAllConnections(ctx)
|
||||
|
||||
start, end := client.Paginate(len(connections), params.Page, params.Limit, 100)
|
||||
if start < 0 || end < 0 {
|
||||
connections = []types.ConnectionEnd{}
|
||||
} else {
|
||||
connections = connections[start:end]
|
||||
}
|
||||
|
||||
res, err := codec.MarshalJSONIndent(k.cdc, connections)
|
||||
if err != nil {
|
||||
return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error())
|
||||
}
|
||||
|
||||
return res, nil
|
||||
}
|
||||
|
||||
// QuerierClientConnections defines the sdk.Querier to query the client connections
|
||||
func QuerierClientConnections(ctx sdk.Context, req abci.RequestQuery, k Keeper) ([]byte, error) {
|
||||
var params types.QueryClientConnectionsParams
|
||||
|
||||
if err := k.cdc.UnmarshalJSON(req.Data, ¶ms); err != nil {
|
||||
return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error())
|
||||
}
|
||||
|
||||
clientConnectionPaths, found := k.GetClientConnectionPaths(ctx, params.ClientID)
|
||||
if !found {
|
||||
return nil, sdkerrors.Wrap(types.ErrClientConnectionPathsNotFound, params.ClientID)
|
||||
}
|
||||
|
||||
bz, err := types.SubModuleCdc.MarshalJSON(clientConnectionPaths)
|
||||
if err != nil {
|
||||
return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error())
|
||||
}
|
||||
|
||||
return bz, nil
|
||||
}
|
||||
|
||||
// QuerierAllClientConnections defines the sdk.Querier to query the connections paths for clients.
|
||||
func QuerierAllClientConnections(ctx sdk.Context, req abci.RequestQuery, k Keeper) ([]byte, error) {
|
||||
var params types.QueryAllConnectionsParams
|
||||
|
||||
if err := k.cdc.UnmarshalJSON(req.Data, ¶ms); err != nil {
|
||||
return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error())
|
||||
}
|
||||
|
||||
clientsConnectionPaths := k.GetAllClientConnectionPaths(ctx)
|
||||
|
||||
start, end := client.Paginate(len(clientsConnectionPaths), params.Page, params.Limit, 100)
|
||||
if start < 0 || end < 0 {
|
||||
clientsConnectionPaths = []types.ConnectionPaths{}
|
||||
} else {
|
||||
clientsConnectionPaths = clientsConnectionPaths[start:end]
|
||||
}
|
||||
|
||||
res, err := codec.MarshalJSONIndent(k.cdc, clientsConnectionPaths)
|
||||
if err != nil {
|
||||
return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error())
|
||||
}
|
||||
|
||||
return res, nil
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
package connection
|
||||
|
||||
import (
|
||||
"github.com/gogo/protobuf/grpc"
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
|
@ -10,7 +11,7 @@ import (
|
|||
"github.com/cosmos/cosmos-sdk/x/ibc/03-connection/types"
|
||||
)
|
||||
|
||||
// Name returns the IBC connection ICS name
|
||||
// Name returns the IBC connection ICS name.
|
||||
func Name() string {
|
||||
return types.SubModuleName
|
||||
}
|
||||
|
@ -20,7 +21,7 @@ func GetTxCmd(clientCtx client.Context) *cobra.Command {
|
|||
return cli.NewTxCmd(clientCtx)
|
||||
}
|
||||
|
||||
// GetQueryCmd returns no root query command for the IBC connections.
|
||||
// GetQueryCmd returns the root query command for the IBC connections.
|
||||
func GetQueryCmd(clientCtx client.Context) *cobra.Command {
|
||||
return cli.GetQueryCmd(clientCtx)
|
||||
}
|
||||
|
@ -29,3 +30,8 @@ func GetQueryCmd(clientCtx client.Context) *cobra.Command {
|
|||
func RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router) {
|
||||
rest.RegisterRoutes(clientCtx, rtr)
|
||||
}
|
||||
|
||||
// RegisterQueryService registers the gRPC query service for IBC connections.
|
||||
func RegisterQueryService(server grpc.Server, queryServer types.QueryServer) {
|
||||
types.RegisterQueryServer(server, queryServer)
|
||||
}
|
||||
|
|
|
@ -507,6 +507,7 @@ var xxx_messageInfo_Counterparty proto.InternalMessageInfo
|
|||
|
||||
// ClientPaths define all the connection paths for a client state.
|
||||
type ClientPaths struct {
|
||||
// list of connection paths
|
||||
Paths []string `protobuf:"bytes,1,rep,name=paths,proto3" json:"paths,omitempty"`
|
||||
}
|
||||
|
||||
|
@ -550,6 +551,61 @@ func (m *ClientPaths) GetPaths() []string {
|
|||
return nil
|
||||
}
|
||||
|
||||
// ConnectionPaths define all the connection paths for a given client state.
|
||||
type ConnectionPaths struct {
|
||||
// client state unique identifier
|
||||
ClientID string `protobuf:"bytes,1,opt,name=client_id,json=clientId,proto3" json:"client_id,omitempty" yaml:"client_id"`
|
||||
// list of connection paths
|
||||
Paths []string `protobuf:"bytes,2,rep,name=paths,proto3" json:"paths,omitempty"`
|
||||
}
|
||||
|
||||
func (m *ConnectionPaths) Reset() { *m = ConnectionPaths{} }
|
||||
func (m *ConnectionPaths) String() string { return proto.CompactTextString(m) }
|
||||
func (*ConnectionPaths) ProtoMessage() {}
|
||||
func (*ConnectionPaths) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_3bf62bacf5a27ee9, []int{7}
|
||||
}
|
||||
func (m *ConnectionPaths) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *ConnectionPaths) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_ConnectionPaths.Marshal(b, m, deterministic)
|
||||
} else {
|
||||
b = b[:cap(b)]
|
||||
n, err := m.MarshalToSizedBuffer(b)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return b[:n], nil
|
||||
}
|
||||
}
|
||||
func (m *ConnectionPaths) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_ConnectionPaths.Merge(m, src)
|
||||
}
|
||||
func (m *ConnectionPaths) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *ConnectionPaths) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_ConnectionPaths.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_ConnectionPaths proto.InternalMessageInfo
|
||||
|
||||
func (m *ConnectionPaths) GetClientID() string {
|
||||
if m != nil {
|
||||
return m.ClientID
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *ConnectionPaths) GetPaths() []string {
|
||||
if m != nil {
|
||||
return m.Paths
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterEnum("ibc.connection.State", State_name, State_value)
|
||||
proto.RegisterType((*MsgConnectionOpenInit)(nil), "ibc.connection.MsgConnectionOpenInit")
|
||||
|
@ -559,66 +615,68 @@ func init() {
|
|||
proto.RegisterType((*ConnectionEnd)(nil), "ibc.connection.ConnectionEnd")
|
||||
proto.RegisterType((*Counterparty)(nil), "ibc.connection.Counterparty")
|
||||
proto.RegisterType((*ClientPaths)(nil), "ibc.connection.ClientPaths")
|
||||
proto.RegisterType((*ConnectionPaths)(nil), "ibc.connection.ConnectionPaths")
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("ibc/connection/connection.proto", fileDescriptor_3bf62bacf5a27ee9) }
|
||||
|
||||
var fileDescriptor_3bf62bacf5a27ee9 = []byte{
|
||||
// 864 bytes of a gzipped FileDescriptorProto
|
||||
// 879 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xdc, 0x56, 0x4f, 0x6f, 0xe2, 0x46,
|
||||
0x14, 0xc7, 0xc6, 0xfc, 0x1b, 0x20, 0xcb, 0x7a, 0xa1, 0x6b, 0xb9, 0x2b, 0xdb, 0xf5, 0x5e, 0x50,
|
||||
0xab, 0x40, 0x77, 0xb7, 0xda, 0x03, 0x52, 0x0f, 0x40, 0x88, 0x6a, 0xa9, 0x21, 0xc8, 0x21, 0x95,
|
||||
0x9a, 0x0b, 0x02, 0xdb, 0x81, 0x11, 0xc1, 0x46, 0xf6, 0xa4, 0x0a, 0xdf, 0x20, 0xe2, 0xd4, 0x6b,
|
||||
0x0f, 0x91, 0x2a, 0xe5, 0x4b, 0xf4, 0x13, 0x54, 0x39, 0xe6, 0xd8, 0x93, 0x55, 0x91, 0x6f, 0x80,
|
||||
0x7a, 0xea, 0xa9, 0xf2, 0x8c, 0xb1, 0x0d, 0x44, 0xad, 0x52, 0x72, 0xa8, 0x7a, 0xe2, 0xfd, 0xf9,
|
||||
0xbd, 0x37, 0xf3, 0xde, 0xef, 0xf1, 0x3c, 0x40, 0x84, 0x03, 0xad, 0xaa, 0x59, 0xa6, 0x69, 0x68,
|
||||
0x08, 0x5a, 0x66, 0x44, 0xac, 0x4c, 0x6d, 0x0b, 0x59, 0xec, 0x1e, 0x1c, 0x68, 0x95, 0xd0, 0xca,
|
||||
0x17, 0x87, 0xd6, 0xd0, 0xc2, 0xae, 0xaa, 0x27, 0x11, 0x14, 0xef, 0xa7, 0x99, 0x4c, 0x20, 0x9a,
|
||||
0x18, 0x26, 0x8a, 0x88, 0x04, 0x20, 0xff, 0x42, 0x83, 0xd2, 0x91, 0x33, 0x6c, 0x06, 0x89, 0x8e,
|
||||
0xa7, 0x86, 0xa9, 0x98, 0x10, 0xb1, 0x5f, 0x83, 0x8c, 0x76, 0x01, 0x0d, 0x13, 0xf5, 0xa0, 0xce,
|
||||
0x51, 0x12, 0x55, 0xce, 0x34, 0xa4, 0x85, 0x2b, 0xa6, 0x9b, 0xd8, 0xa8, 0x1c, 0x2c, 0x5d, 0xb1,
|
||||
0x30, 0xeb, 0x4f, 0x2e, 0x6a, 0x72, 0x00, 0x93, 0xd5, 0x34, 0x91, 0x15, 0x9d, 0x3d, 0x02, 0xf9,
|
||||
0xf0, 0x76, 0x5e, 0x0a, 0x1a, 0xa7, 0x28, 0x2f, 0x5c, 0x31, 0x17, 0x9e, 0x86, 0xd3, 0x14, 0xfd,
|
||||
0x34, 0x51, 0xb8, 0xac, 0xe6, 0x42, 0x5d, 0xd1, 0xd9, 0x43, 0x90, 0xd3, 0xac, 0x4b, 0x13, 0x19,
|
||||
0xf6, 0xb4, 0x6f, 0xa3, 0x19, 0x17, 0x97, 0xa8, 0x72, 0xf6, 0xfd, 0x9b, 0xca, 0x7a, 0x17, 0x2a,
|
||||
0xcd, 0x08, 0xa6, 0xc1, 0xdc, 0xb9, 0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0xa5, 0xb9, 0x32, 0xb0, 0x87, 0xa0, 0x10, 0x78, 0x57, 0x67, 0xa5,
|
||||
0xbd, 0xb3, 0x1a, 0x9f, 0x2e, 0x5d, 0xf1, 0x75, 0xd0, 0xfe, 0x35, 0x84, 0xac, 0xbe, 0x08, 0x4c,
|
||||
0xfe, 0x65, 0xc2, 0xb1, 0xcb, 0xec, 0x3a, 0x76, 0xbf, 0xc6, 0x1f, 0x19, 0xbb, 0xba, 0x36, 0xde,
|
||||
0x9e, 0x1b, 0x6a, 0xa7, 0xb9, 0xe1, 0x40, 0xca, 0xe7, 0x8e, 0x0c, 0xa0, 0xba, 0x52, 0xd9, 0x77,
|
||||
0x80, 0x30, 0xd1, 0x43, 0x36, 0x19, 0xa7, 0x5c, 0xa3, 0x18, 0xce, 0x74, 0xe0, 0x92, 0xd5, 0x34,
|
||||
0x96, 0xbd, 0xbf, 0x44, 0x6d, 0x83, 0x2f, 0x06, 0xf7, 0xf0, 0xf5, 0xd2, 0x15, 0x5f, 0x45, 0xa3,
|
||||
0x56, 0xfd, 0xfb, 0x27, 0x22, 0x13, 0xcf, 0x42, 0x64, 0x72, 0x27, 0x22, 0x53, 0xbb, 0x12, 0x79,
|
||||
0x4b, 0x03, 0x6e, 0x8b, 0xc8, 0xa6, 0x65, 0x9e, 0x43, 0x7b, 0xf2, 0xdc, 0x64, 0x06, 0x94, 0xf5,
|
||||
0xb5, 0x31, 0xa6, 0xf3, 0x11, 0xca, 0xfa, 0xda, 0x78, 0x45, 0x99, 0x37, 0x4e, 0x9b, 0x94, 0xc5,
|
||||
0x9f, 0x40, 0xd9, 0x33, 0x6e, 0xd9, 0x39, 0x0d, 0xf2, 0x61, 0xc1, 0x2d, 0x53, 0x67, 0xdf, 0x02,
|
||||
0x3a, 0xe8, 0xc7, 0xab, 0x85, 0x2b, 0xd2, 0xb8, 0x0b, 0x19, 0x72, 0x29, 0xaf, 0x74, 0x1a, 0xea,
|
||||
0xeb, 0x3b, 0x98, 0x7e, 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||
0x10, 0xb4, 0xcc, 0x88, 0x58, 0x99, 0xd9, 0x16, 0xb2, 0xd8, 0x03, 0x38, 0xd0, 0x2a, 0xa1, 0x95,
|
||||
0x2f, 0x8e, 0xac, 0x91, 0x85, 0x5d, 0x55, 0x4f, 0x22, 0x28, 0xde, 0x0f, 0x33, 0x9d, 0x42, 0x34,
|
||||
0x35, 0x4c, 0x14, 0x11, 0x09, 0x40, 0xfe, 0x85, 0x06, 0xa5, 0x53, 0x67, 0xd4, 0x0c, 0x02, 0xbd,
|
||||
0x9f, 0x19, 0xa6, 0x62, 0x42, 0xc4, 0x7e, 0x0d, 0x32, 0xda, 0x05, 0x34, 0x4c, 0xd4, 0x83, 0x3a,
|
||||
0x47, 0x49, 0x54, 0x39, 0xd3, 0x90, 0x96, 0xae, 0x98, 0x6e, 0x62, 0xa3, 0x72, 0xbc, 0x72, 0xc5,
|
||||
0xc2, 0xbc, 0x3f, 0xbd, 0xa8, 0xc9, 0x01, 0x4c, 0x56, 0xd3, 0x44, 0x56, 0x74, 0xf6, 0x14, 0xe4,
|
||||
0xc3, 0xec, 0xbc, 0x10, 0x34, 0x0e, 0x51, 0x5e, 0xba, 0x62, 0x2e, 0xbc, 0x0d, 0x87, 0x29, 0xfa,
|
||||
0x61, 0xa2, 0x70, 0x59, 0xcd, 0x85, 0xba, 0xa2, 0xb3, 0x27, 0x20, 0xa7, 0x59, 0x97, 0x26, 0x32,
|
||||
0xec, 0x59, 0xdf, 0x46, 0x73, 0x2e, 0x2e, 0x51, 0xe5, 0xec, 0x9b, 0x97, 0x95, 0xcd, 0x2e, 0x54,
|
||||
0x9a, 0x11, 0x4c, 0x83, 0xb9, 0x75, 0xc5, 0x98, 0xba, 0x71, 0x8e, 0x55, 0x40, 0xd2, 0x81, 0x23,
|
||||
0xd3, 0xb0, 0x39, 0x46, 0xa2, 0xca, 0xb9, 0xc6, 0xeb, 0x3f, 0x5d, 0xf1, 0x68, 0x04, 0xd1, 0xf8,
|
||||
0x72, 0x50, 0xd1, 0xac, 0x69, 0x55, 0xb3, 0x9c, 0xa9, 0xe5, 0xf8, 0x3f, 0x47, 0x8e, 0x3e, 0xa9,
|
||||
0xa2, 0xf9, 0xcc, 0x70, 0x2a, 0x75, 0x4d, 0xab, 0xeb, 0xba, 0x6d, 0x38, 0x8e, 0xea, 0x07, 0x90,
|
||||
0xff, 0x60, 0x40, 0x71, 0xa7, 0x75, 0x5d, 0x7b, 0xfe, 0x3f, 0xed, 0xdc, 0x39, 0x28, 0x45, 0xf5,
|
||||
0xde, 0x0f, 0x86, 0xed, 0x40, 0xcb, 0x74, 0x38, 0x46, 0x8a, 0x7b, 0x15, 0xae, 0x5c, 0xf1, 0xe5,
|
||||
0x3a, 0x9d, 0x07, 0x60, 0xb2, 0x5a, 0x8c, 0xda, 0xbf, 0xf3, 0xcd, 0xec, 0x57, 0x00, 0xcc, 0x6c,
|
||||
0xcb, 0x1a, 0xf6, 0xa0, 0x09, 0x11, 0x97, 0xc0, 0xa4, 0x94, 0x56, 0xae, 0xf8, 0x8c, 0xc4, 0x0a,
|
||||
0x7d, 0xb2, 0x9a, 0xc1, 0x0a, 0x1e, 0xce, 0xcf, 0x40, 0x8e, 0x78, 0xc6, 0x06, 0x1c, 0x8d, 0x11,
|
||||
0x97, 0x94, 0xa8, 0x32, 0xa3, 0x66, 0xb1, 0xed, 0x1b, 0x6c, 0x62, 0x9b, 0xe0, 0x90, 0x40, 0x34,
|
||||
0xcb, 0x74, 0x0c, 0xd3, 0xb9, 0x74, 0xb8, 0x14, 0x8e, 0xce, 0xaf, 0x5c, 0xf1, 0x93, 0x68, 0xf4,
|
||||
0x00, 0x20, 0xab, 0x07, 0xd8, 0xd2, 0x5c, 0x1b, 0xd8, 0x13, 0x50, 0x08, 0xbc, 0xeb, 0xbb, 0xd2,
|
||||
0xde, 0x5d, 0x8d, 0x4f, 0x57, 0xae, 0xf8, 0x22, 0x68, 0xff, 0x06, 0x42, 0x56, 0x0f, 0x03, 0x93,
|
||||
0x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 0xd5, 0x8d,
|
||||
0x10, 0x6b, 0x74, 0x6e, 0x97, 0x02, 0x75, 0xb7, 0x14, 0xa8, 0xdf, 0x97, 0x02, 0xf5, 0xe3, 0xbd,
|
||||
0x10, 0xbb, 0xbb, 0x17, 0x62, 0xbf, 0xdd, 0x0b, 0xb1, 0x0f, 0xef, 0xfe, 0xf6, 0x3b, 0xfb, 0x58,
|
||||
0xf5, 0x5e, 0x84, 0x5f, 0xbe, 0x3d, 0x8a, 0xbc, 0x2d, 0xf1, 0xb7, 0x37, 0x48, 0xe2, 0x07, 0xe1,
|
||||
0xdb, 0xbf, 0x02, 0x00, 0x00, 0xff, 0xff, 0x37, 0x42, 0xa5, 0xea, 0x7a, 0x0a, 0x00, 0x00,
|
||||
}
|
||||
|
||||
func (m *MsgConnectionOpenInit) Marshal() (dAtA []byte, err error) {
|
||||
|
@ -1019,6 +1077,45 @@ func (m *ClientPaths) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
|||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func (m *ConnectionPaths) Marshal() (dAtA []byte, err error) {
|
||||
size := m.Size()
|
||||
dAtA = make([]byte, size)
|
||||
n, err := m.MarshalToSizedBuffer(dAtA[:size])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return dAtA[:n], nil
|
||||
}
|
||||
|
||||
func (m *ConnectionPaths) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *ConnectionPaths) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
if len(m.Paths) > 0 {
|
||||
for iNdEx := len(m.Paths) - 1; iNdEx >= 0; iNdEx-- {
|
||||
i -= len(m.Paths[iNdEx])
|
||||
copy(dAtA[i:], m.Paths[iNdEx])
|
||||
i = encodeVarintConnection(dAtA, i, uint64(len(m.Paths[iNdEx])))
|
||||
i--
|
||||
dAtA[i] = 0x12
|
||||
}
|
||||
}
|
||||
if len(m.ClientID) > 0 {
|
||||
i -= len(m.ClientID)
|
||||
copy(dAtA[i:], m.ClientID)
|
||||
i = encodeVarintConnection(dAtA, i, uint64(len(m.ClientID)))
|
||||
i--
|
||||
dAtA[i] = 0xa
|
||||
}
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func encodeVarintConnection(dAtA []byte, offset int, v uint64) int {
|
||||
offset -= sovConnection(v)
|
||||
base := offset
|
||||
|
@ -1217,6 +1314,25 @@ func (m *ClientPaths) Size() (n int) {
|
|||
return n
|
||||
}
|
||||
|
||||
func (m *ConnectionPaths) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
var l int
|
||||
_ = l
|
||||
l = len(m.ClientID)
|
||||
if l > 0 {
|
||||
n += 1 + l + sovConnection(uint64(l))
|
||||
}
|
||||
if len(m.Paths) > 0 {
|
||||
for _, s := range m.Paths {
|
||||
l = len(s)
|
||||
n += 1 + l + sovConnection(uint64(l))
|
||||
}
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func sovConnection(x uint64) (n int) {
|
||||
return (math_bits.Len64(x|1) + 6) / 7
|
||||
}
|
||||
|
@ -2594,6 +2710,123 @@ func (m *ClientPaths) Unmarshal(dAtA []byte) error {
|
|||
}
|
||||
return nil
|
||||
}
|
||||
func (m *ConnectionPaths) Unmarshal(dAtA []byte) error {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
for iNdEx < l {
|
||||
preIndex := iNdEx
|
||||
var wire uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowConnection
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
wire |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
fieldNum := int32(wire >> 3)
|
||||
wireType := int(wire & 0x7)
|
||||
if wireType == 4 {
|
||||
return fmt.Errorf("proto: ConnectionPaths: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: ConnectionPaths: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
case 1:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field ClientID", wireType)
|
||||
}
|
||||
var stringLen uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowConnection
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
stringLen |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
intStringLen := int(stringLen)
|
||||
if intStringLen < 0 {
|
||||
return ErrInvalidLengthConnection
|
||||
}
|
||||
postIndex := iNdEx + intStringLen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthConnection
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.ClientID = string(dAtA[iNdEx:postIndex])
|
||||
iNdEx = postIndex
|
||||
case 2:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Paths", wireType)
|
||||
}
|
||||
var stringLen uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowConnection
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
stringLen |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
intStringLen := int(stringLen)
|
||||
if intStringLen < 0 {
|
||||
return ErrInvalidLengthConnection
|
||||
}
|
||||
postIndex := iNdEx + intStringLen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthConnection
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.Paths = append(m.Paths, string(dAtA[iNdEx:postIndex]))
|
||||
iNdEx = postIndex
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipConnection(dAtA[iNdEx:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if skippy < 0 {
|
||||
return ErrInvalidLengthConnection
|
||||
}
|
||||
if (iNdEx + skippy) < 0 {
|
||||
return ErrInvalidLengthConnection
|
||||
}
|
||||
if (iNdEx + skippy) > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
iNdEx += skippy
|
||||
}
|
||||
}
|
||||
|
||||
if iNdEx > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func skipConnection(dAtA []byte) (n int, err error) {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
|
|
|
@ -6,12 +6,6 @@ import (
|
|||
host "github.com/cosmos/cosmos-sdk/x/ibc/24-host"
|
||||
)
|
||||
|
||||
// ConnectionPaths define all the connection paths for a given client state.
|
||||
type ConnectionPaths struct {
|
||||
ClientID string `json:"client_id" yaml:"client_id"`
|
||||
Paths []string `json:"paths" yaml:"paths"`
|
||||
}
|
||||
|
||||
// NewConnectionPaths creates a ConnectionPaths instance.
|
||||
func NewConnectionPaths(id string, paths []string) ConnectionPaths {
|
||||
return ConnectionPaths{
|
||||
|
|
|
@ -3,8 +3,6 @@ package types
|
|||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/tendermint/tendermint/crypto/merkle"
|
||||
|
||||
commitmenttypes "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/types"
|
||||
host "github.com/cosmos/cosmos-sdk/x/ibc/24-host"
|
||||
)
|
||||
|
@ -16,73 +14,35 @@ const (
|
|||
QueryAllClientConnections = "all_client_connections"
|
||||
)
|
||||
|
||||
// ConnectionResponse defines the client query response for a connection which
|
||||
// also includes a proof and the height from which the proof was retrieved.
|
||||
type ConnectionResponse struct {
|
||||
Connection ConnectionEnd `json:"connection" yaml:"connection"`
|
||||
Proof commitmenttypes.MerkleProof `json:"proof,omitempty" yaml:"proof,omitempty"`
|
||||
ProofPath commitmenttypes.MerklePath `json:"proof_path,omitempty" yaml:"proof_path,omitempty"`
|
||||
ProofHeight uint64 `json:"proof_height,omitempty" yaml:"proof_height,omitempty"`
|
||||
}
|
||||
|
||||
// NewConnectionResponse creates a new ConnectionResponse instance
|
||||
func NewConnectionResponse(
|
||||
connectionID string, connection ConnectionEnd, proof *merkle.Proof, height int64,
|
||||
) ConnectionResponse {
|
||||
return ConnectionResponse{
|
||||
Connection: connection,
|
||||
Proof: commitmenttypes.MerkleProof{Proof: proof},
|
||||
ProofPath: commitmenttypes.NewMerklePath(strings.Split(host.ConnectionPath(connectionID), "/")),
|
||||
// NewQueryConnectionResponse creates a new QueryConnectionResponse instance
|
||||
func NewQueryConnectionResponse(
|
||||
connection ConnectionEnd, proof []byte, height int64,
|
||||
) *QueryConnectionResponse {
|
||||
path := commitmenttypes.NewMerklePath(strings.Split(host.ConnectionPath(connection.ID), "/"))
|
||||
return &QueryConnectionResponse{
|
||||
Connection: &connection,
|
||||
Proof: proof,
|
||||
ProofPath: path.Pretty(),
|
||||
ProofHeight: uint64(height),
|
||||
}
|
||||
}
|
||||
|
||||
// QueryAllConnectionsParams defines the parameters necessary for querying for all
|
||||
// connections.
|
||||
type QueryAllConnectionsParams struct {
|
||||
Page int `json:"page" yaml:"page"`
|
||||
Limit int `json:"limit" yaml:"limit"`
|
||||
}
|
||||
|
||||
// NewQueryAllConnectionsParams creates a new QueryAllConnectionsParams instance.
|
||||
func NewQueryAllConnectionsParams(page, limit int) QueryAllConnectionsParams {
|
||||
return QueryAllConnectionsParams{
|
||||
Page: page,
|
||||
Limit: limit,
|
||||
}
|
||||
}
|
||||
|
||||
// ClientConnectionsResponse defines the client query response for a client
|
||||
// connection paths which also includes a proof and the height from which the
|
||||
// proof was retrieved.
|
||||
type ClientConnectionsResponse struct {
|
||||
ConnectionPaths []string `json:"connection_paths" yaml:"connection_paths"`
|
||||
Proof commitmenttypes.MerkleProof `json:"proof,omitempty" yaml:"proof,omitempty"`
|
||||
ProofPath commitmenttypes.MerklePath `json:"proof_path,omitempty" yaml:"proof_path,omitempty"`
|
||||
ProofHeight uint64 `json:"proof_height,omitempty" yaml:"proof_height,omitempty"`
|
||||
}
|
||||
|
||||
// NewClientConnectionsResponse creates a new ConnectionPaths instance
|
||||
func NewClientConnectionsResponse(
|
||||
clientID string, connectionPaths []string, proof *merkle.Proof, height int64,
|
||||
) ClientConnectionsResponse {
|
||||
return ClientConnectionsResponse{
|
||||
// NewQueryClientConnectionsResponse creates a new ConnectionPaths instance
|
||||
func NewQueryClientConnectionsResponse(
|
||||
clientID string, connectionPaths []string, proof []byte, height int64,
|
||||
) *QueryClientConnectionsResponse {
|
||||
path := commitmenttypes.NewMerklePath(strings.Split(host.ClientConnectionsPath(clientID), "/"))
|
||||
return &QueryClientConnectionsResponse{
|
||||
ConnectionPaths: connectionPaths,
|
||||
Proof: commitmenttypes.MerkleProof{Proof: proof},
|
||||
ProofPath: commitmenttypes.NewMerklePath(strings.Split(host.ClientConnectionsPath(clientID), "/")),
|
||||
Proof: proof,
|
||||
ProofPath: path.Pretty(),
|
||||
ProofHeight: uint64(height),
|
||||
}
|
||||
}
|
||||
|
||||
// QueryClientConnectionsParams defines the params for the following queries:
|
||||
// - 'custom/ibc/client/<clientID>/connections'
|
||||
type QueryClientConnectionsParams struct {
|
||||
ClientID string
|
||||
}
|
||||
|
||||
// NewQueryClientConnectionsParams creates a new QueryClientConnectionsParams instance
|
||||
func NewQueryClientConnectionsParams(clientID string) QueryClientConnectionsParams {
|
||||
return QueryClientConnectionsParams{
|
||||
// NewQueryClientConnectionsRequest creates a new QueryClientConnectionsRequest instance
|
||||
func NewQueryClientConnectionsRequest(clientID string) *QueryClientConnectionsRequest {
|
||||
return &QueryClientConnectionsRequest{
|
||||
ClientID: clientID,
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -19,13 +19,15 @@ func GetQueryCmd(clientCtx client.Context) *cobra.Command {
|
|||
}
|
||||
|
||||
ics04ChannelQueryCmd.AddCommand(flags.GetCommands(
|
||||
// TODO: Query all channels
|
||||
GetCmdQueryChannels(clientCtx),
|
||||
GetCmdQueryChannel(clientCtx),
|
||||
// TODO: Query channels from a connection
|
||||
GetCmdQueryConnectionChannels(clientCtx),
|
||||
GetCmdQueryChannelClientState(clientCtx),
|
||||
// TODO: Query all packet commitments
|
||||
// TODO: Query unrelayed packet ACKS
|
||||
// TODO: Query unrelayed packet sends
|
||||
GetCmdQueryPacketCommitment(clientCtx),
|
||||
GetCmdQueryPacketCommitments(clientCtx),
|
||||
GetCmdQueryUnrelayedPackets(clientCtx),
|
||||
GetCmdQueryNextSequenceReceive(clientCtx),
|
||||
// TODO: next sequence Send ?
|
||||
)...)
|
||||
|
||||
return ics04ChannelQueryCmd
|
||||
|
|
|
@ -1,18 +1,61 @@
|
|||
package cli
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/cosmos/cosmos-sdk/types/query"
|
||||
"github.com/cosmos/cosmos-sdk/version"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/04-channel/client/utils"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types"
|
||||
host "github.com/cosmos/cosmos-sdk/x/ibc/24-host"
|
||||
)
|
||||
|
||||
const flagSequences = "sequences"
|
||||
|
||||
// GetCmdQueryChannels defines the command to query all the channels ends
|
||||
// that this chain mantains.
|
||||
func GetCmdQueryChannels(clientCtx client.Context) *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "channels",
|
||||
Short: "Query all channels",
|
||||
Long: "Query all channels from a chain",
|
||||
Example: fmt.Sprintf("%s query %s %s channels", version.ClientName, host.ModuleName, types.SubModuleName),
|
||||
Args: cobra.NoArgs,
|
||||
RunE: func(cmd *cobra.Command, _ []string) error {
|
||||
clientCtx = clientCtx.Init()
|
||||
queryClient := types.NewQueryClient(clientCtx)
|
||||
|
||||
offset, _ := cmd.Flags().GetInt(flags.FlagPage)
|
||||
limit, _ := cmd.Flags().GetInt(flags.FlagLimit)
|
||||
|
||||
req := &types.QueryChannelsRequest{
|
||||
Req: &query.PageRequest{
|
||||
Offset: uint64(offset),
|
||||
Limit: uint64(limit),
|
||||
},
|
||||
}
|
||||
|
||||
res, err := queryClient.Channels(context.Background(), req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
clientCtx = clientCtx.WithHeight(res.Height)
|
||||
return clientCtx.PrintOutput(res)
|
||||
},
|
||||
}
|
||||
cmd.Flags().Int(flags.FlagPage, 1, "pagination page of light clients to to query for")
|
||||
cmd.Flags().Int(flags.FlagLimit, 100, "pagination limit of light clients to query for")
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
// GetCmdQueryChannel defines the command to query a channel end
|
||||
func GetCmdQueryChannel(clientCtx client.Context) *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
|
@ -28,7 +71,10 @@ func GetCmdQueryChannel(clientCtx client.Context) *cobra.Command {
|
|||
|
||||
portID := args[0]
|
||||
channelID := args[1]
|
||||
prove, _ := cmd.Flags().GetBool(flags.FlagProve)
|
||||
prove, err := cmd.Flags().GetBool(flags.FlagProve)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
channelRes, err := utils.QueryChannel(clientCtx, portID, channelID, prove)
|
||||
if err != nil {
|
||||
|
@ -40,6 +86,44 @@ func GetCmdQueryChannel(clientCtx client.Context) *cobra.Command {
|
|||
},
|
||||
}
|
||||
cmd.Flags().Bool(flags.FlagProve, true, "show proofs for the query results")
|
||||
return cmd
|
||||
}
|
||||
|
||||
// GetCmdQueryConnectionChannels defines the command to query all the channels associated with a
|
||||
// connection
|
||||
func GetCmdQueryConnectionChannels(clientCtx client.Context) *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "connections [connection-id]",
|
||||
Short: "Query all channels associated with a connection",
|
||||
Long: "Query all channels associated with a connection",
|
||||
Example: fmt.Sprintf("%s query %s %s connections [connection-id]", version.ClientName, host.ModuleName, types.SubModuleName),
|
||||
Args: cobra.ExactArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx = clientCtx.Init()
|
||||
queryClient := types.NewQueryClient(clientCtx)
|
||||
|
||||
offset, _ := cmd.Flags().GetInt(flags.FlagPage)
|
||||
limit, _ := cmd.Flags().GetInt(flags.FlagLimit)
|
||||
|
||||
req := &types.QueryConnectionChannelsRequest{
|
||||
Connection: args[0],
|
||||
Req: &query.PageRequest{
|
||||
Offset: uint64(offset),
|
||||
Limit: uint64(limit),
|
||||
},
|
||||
}
|
||||
|
||||
res, err := queryClient.ConnectionChannels(context.Background(), req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
clientCtx = clientCtx.WithHeight(res.Height)
|
||||
return clientCtx.PrintOutput(res)
|
||||
},
|
||||
}
|
||||
cmd.Flags().Int(flags.FlagPage, 1, "pagination page of light clients to to query for")
|
||||
cmd.Flags().Int(flags.FlagLimit, 100, "pagination limit of light clients to query for")
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
@ -52,7 +136,7 @@ func GetCmdQueryChannelClientState(clientCtx client.Context) *cobra.Command {
|
|||
Long: "Query the client state associated with a channel, by providing its port and channel identifiers.",
|
||||
Example: fmt.Sprintf("%s query ibc channel client-state [port-id] [channel-id]", version.ClientName),
|
||||
Args: cobra.ExactArgs(2),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
RunE: func(_ *cobra.Command, args []string) error {
|
||||
clientCtx = clientCtx.Init()
|
||||
|
||||
portID := args[0]
|
||||
|
@ -69,3 +153,169 @@ func GetCmdQueryChannelClientState(clientCtx client.Context) *cobra.Command {
|
|||
}
|
||||
return cmd
|
||||
}
|
||||
|
||||
// GetCmdQueryPacketCommitments defines the command to query all packet commitments associated with
|
||||
// a channel
|
||||
func GetCmdQueryPacketCommitments(clientCtx client.Context) *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "packet-commitments [port-id] [channel-id]",
|
||||
Short: "Query all packet commitments associated with a channel",
|
||||
Long: "Query all packet commitments associated with a channel",
|
||||
Example: fmt.Sprintf("%s query %s %s packet-commitments [port-id] [channel-id]", version.ClientName, host.ModuleName, types.SubModuleName),
|
||||
Args: cobra.ExactArgs(2),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx = clientCtx.Init()
|
||||
queryClient := types.NewQueryClient(clientCtx)
|
||||
|
||||
offset, _ := cmd.Flags().GetInt(flags.FlagPage)
|
||||
limit, _ := cmd.Flags().GetInt(flags.FlagLimit)
|
||||
|
||||
req := &types.QueryPacketCommitmentsRequest{
|
||||
PortID: args[0],
|
||||
ChannelID: args[1],
|
||||
Req: &query.PageRequest{
|
||||
Offset: uint64(offset),
|
||||
Limit: uint64(limit),
|
||||
},
|
||||
}
|
||||
|
||||
res, err := queryClient.PacketCommitments(context.Background(), req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
clientCtx = clientCtx.WithHeight(res.Height)
|
||||
return clientCtx.PrintOutput(res)
|
||||
},
|
||||
}
|
||||
cmd.Flags().Int(flags.FlagPage, 1, "pagination page of light clients to to query for")
|
||||
cmd.Flags().Int(flags.FlagLimit, 100, "pagination limit of light clients to query for")
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
// GetCmdQueryPacketCommitment defines the command to query a channel end
|
||||
func GetCmdQueryPacketCommitment(clientCtx client.Context) *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "packet-commitment [port-id] [channel-id] [sequence]",
|
||||
Short: "Query a packet commitment",
|
||||
Long: "Query a packet commitment",
|
||||
Example: fmt.Sprintf(
|
||||
"%s query %s %s end [port-id] [channel-id]", version.ClientName, host.ModuleName, types.SubModuleName,
|
||||
),
|
||||
Args: cobra.ExactArgs(3),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx = clientCtx.Init()
|
||||
|
||||
portID := args[0]
|
||||
channelID := args[1]
|
||||
prove, err := cmd.Flags().GetBool(flags.FlagProve)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
seq, err := strconv.ParseUint(args[2], 10, 64)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
res, err := utils.QueryPacketCommitment(clientCtx, portID, channelID, seq, prove)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
clientCtx = clientCtx.WithHeight(int64(res.ProofHeight))
|
||||
return clientCtx.PrintOutput(res)
|
||||
},
|
||||
}
|
||||
cmd.Flags().Bool(flags.FlagProve, true, "show proofs for the query results")
|
||||
return cmd
|
||||
}
|
||||
|
||||
// GetCmdQueryUnrelayedPackets defines the command to query all the unrelayed packets.
|
||||
func GetCmdQueryUnrelayedPackets(clientCtx client.Context) *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "unrelayed-packets [port-id] [channel-id]",
|
||||
Short: "Query all the unrelayed packets associated with a channel",
|
||||
Long: `It indicates if a packet, given a list of packet commitment sequences, is unrelayed.
|
||||
An unrelayed packet corresponds to:
|
||||
|
||||
- Unrelayed packet commitments: when no acknowledgement exists for the given sequence.
|
||||
- Unrelayed packet acknowledgements: when an acknowledgement exists and a packet commitment also exists.`,
|
||||
Example: fmt.Sprintf("%s query %s %s unrelayed-packets [port-id] [channel-id] --sequences=1,2,3", version.ClientName, host.ModuleName, types.SubModuleName),
|
||||
Args: cobra.ExactArgs(2),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx = clientCtx.Init()
|
||||
queryClient := types.NewQueryClient(clientCtx)
|
||||
|
||||
seqSlice, err := cmd.Flags().GetInt64Slice(flagSequences)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
seqs := make([]uint64, len(seqSlice))
|
||||
for i := range seqSlice {
|
||||
seqs[i] = uint64(seqSlice[i])
|
||||
}
|
||||
|
||||
offset, _ := cmd.Flags().GetInt(flags.FlagPage)
|
||||
limit, _ := cmd.Flags().GetInt(flags.FlagLimit)
|
||||
|
||||
req := &types.QueryUnrelayedPacketsRequest{
|
||||
PortID: args[0],
|
||||
ChannelID: args[1],
|
||||
Sequences: seqs,
|
||||
Req: &query.PageRequest{
|
||||
Offset: uint64(offset),
|
||||
Limit: uint64(limit),
|
||||
},
|
||||
}
|
||||
|
||||
res, err := queryClient.UnrelayedPackets(context.Background(), req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
clientCtx = clientCtx.WithHeight(res.Height)
|
||||
return clientCtx.PrintOutput(res)
|
||||
},
|
||||
}
|
||||
cmd.Flags().Int64Slice(flagSequences, []int64{}, "comma separated list of packet sequence numbers")
|
||||
cmd.Flags().Int(flags.FlagPage, 1, "pagination page of light clients to to query for")
|
||||
cmd.Flags().Int(flags.FlagLimit, 100, "pagination limit of light clients to query for")
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
// GetCmdQueryNextSequenceReceive defines the command to query a next receive sequence for a given channel
|
||||
func GetCmdQueryNextSequenceReceive(clientCtx client.Context) *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "next-sequence-receive [port-id] [channel-id]",
|
||||
Short: "Query a next receive sequence",
|
||||
Long: "Query the next receive sequence for a given channel",
|
||||
Example: fmt.Sprintf(
|
||||
"%s query %s %s next-sequence-receive [port-id] [channel-id]", version.ClientName, host.ModuleName, types.SubModuleName,
|
||||
),
|
||||
Args: cobra.ExactArgs(2),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx = clientCtx.Init()
|
||||
|
||||
portID := args[0]
|
||||
channelID := args[1]
|
||||
prove, err := cmd.Flags().GetBool(flags.FlagProve)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
sequenceRes, err := utils.QueryNextSequenceReceive(clientCtx, portID, channelID, prove)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
clientCtx = clientCtx.WithHeight(int64(sequenceRes.ProofHeight))
|
||||
return clientCtx.PrintOutput(sequenceRes)
|
||||
},
|
||||
}
|
||||
cmd.Flags().Bool(flags.FlagProve, true, "show proofs for the query results")
|
||||
return cmd
|
||||
}
|
||||
|
|
|
@ -15,20 +15,9 @@ import (
|
|||
func registerQueryRoutes(clientCtx client.Context, r *mux.Router) {
|
||||
r.HandleFunc(fmt.Sprintf("/ibc/ports/{%s}/channels/{%s}", RestPortID, RestChannelID), queryChannelHandlerFn(clientCtx)).Methods("GET")
|
||||
r.HandleFunc(fmt.Sprintf("/ibc/ports/{%s}/channels/{%s}/client_state", RestPortID, RestChannelID), queryChannelClientStateHandlerFn(clientCtx)).Methods("GET")
|
||||
r.HandleFunc(fmt.Sprintf("/ibc/ports/{%s}/channels/{%s}/next_sequence_receive", RestPortID, RestChannelID), queryNextSequenceRecvHandlerFn(clientCtx)).Methods("GET")
|
||||
}
|
||||
|
||||
// queryChannelHandlerFn implements a channel querying route
|
||||
//
|
||||
// @Summary Query channel
|
||||
// @Tags IBC
|
||||
// @Produce json
|
||||
// @Param port-id path string true "Port ID"
|
||||
// @Param channel-id path string true "Channel ID"
|
||||
// @Param prove query boolean false "Proof of result"
|
||||
// @Success 200 {object} QueryChannel "OK"
|
||||
// @Failure 400 {object} rest.ErrorResponse "Invalid port id or channel id"
|
||||
// @Failure 500 {object} rest.ErrorResponse "Internal Server Error"
|
||||
// @Router /ibc/ports/{port-id}/channels/{channel-id} [get]
|
||||
func queryChannelHandlerFn(clientCtx client.Context) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
vars := mux.Vars(r)
|
||||
|
@ -73,3 +62,26 @@ func queryChannelClientStateHandlerFn(clientCtx client.Context) http.HandlerFunc
|
|||
rest.PostProcessResponse(w, clientCtx, clientState)
|
||||
}
|
||||
}
|
||||
|
||||
func queryNextSequenceRecvHandlerFn(clientCtx client.Context) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
vars := mux.Vars(r)
|
||||
portID := vars[RestPortID]
|
||||
channelID := vars[RestChannelID]
|
||||
prove := rest.ParseQueryParamBool(r, flags.FlagProve)
|
||||
|
||||
clientCtx, ok := rest.ParseQueryHeightOrReturnBadRequest(w, clientCtx, r)
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
sequenceRes, err := utils.QueryNextSequenceReceive(clientCtx, portID, channelID, prove)
|
||||
if err != nil {
|
||||
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
clientCtx = clientCtx.WithHeight(int64(sequenceRes.ProofHeight))
|
||||
rest.PostProcessResponse(w, clientCtx, sequenceRes)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package utils
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
|
@ -11,71 +13,98 @@ import (
|
|||
host "github.com/cosmos/cosmos-sdk/x/ibc/24-host"
|
||||
)
|
||||
|
||||
// QueryPacket returns a packet from the store
|
||||
func QueryPacket(
|
||||
ctx client.Context, portID, channelID string,
|
||||
sequence, timeoutHeight, timeoutTimestamp uint64, prove bool,
|
||||
) (types.PacketResponse, error) {
|
||||
// QueryPacketCommitment returns a packet commitment.
|
||||
// If prove is true, it performs an ABCI store query in order to retrieve the merkle proof. Otherwise,
|
||||
// it uses the gRPC query client.
|
||||
func QueryPacketCommitment(
|
||||
clientCtx client.Context, portID, channelID string,
|
||||
sequence uint64, prove bool,
|
||||
) (*types.QueryPacketCommitmentResponse, error) {
|
||||
if prove {
|
||||
return queryPacketCommitmentABCI(clientCtx, portID, channelID, sequence)
|
||||
}
|
||||
|
||||
queryClient := types.NewQueryClient(clientCtx)
|
||||
req := &types.QueryPacketCommitmentRequest{
|
||||
PortID: portID,
|
||||
ChannelID: channelID,
|
||||
Sequence: sequence,
|
||||
}
|
||||
|
||||
return queryClient.PacketCommitment(context.Background(), req)
|
||||
}
|
||||
|
||||
func queryPacketCommitmentABCI(
|
||||
clientCtx client.Context, portID, channelID string, sequence uint64,
|
||||
) (*types.QueryPacketCommitmentResponse, error) {
|
||||
req := abci.RequestQuery{
|
||||
Path: "store/ibc/key",
|
||||
Data: host.KeyPacketCommitment(portID, channelID, sequence),
|
||||
Prove: prove,
|
||||
Prove: true,
|
||||
}
|
||||
|
||||
res, err := ctx.QueryABCI(req)
|
||||
res, err := clientCtx.QueryABCI(req)
|
||||
if err != nil {
|
||||
return types.PacketResponse{}, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
channelRes, err := QueryChannel(ctx, portID, channelID, prove)
|
||||
proofBz, err := clientCtx.Codec.MarshalBinaryBare(res.Proof)
|
||||
if err != nil {
|
||||
return types.PacketResponse{}, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
destPortID := channelRes.Channel.Counterparty.PortID
|
||||
destChannelID := channelRes.Channel.Counterparty.ChannelID
|
||||
|
||||
packet := types.NewPacket(
|
||||
res.Value,
|
||||
sequence,
|
||||
portID,
|
||||
channelID,
|
||||
destPortID,
|
||||
destChannelID,
|
||||
timeoutHeight,
|
||||
timeoutTimestamp,
|
||||
)
|
||||
|
||||
// FIXME: res.Height+1 is hack, fix later
|
||||
return types.NewPacketResponse(portID, channelID, sequence, packet, res.Proof, res.Height+1), nil
|
||||
return types.NewQueryPacketCommitmentResponse(portID, channelID, sequence, res.Value, proofBz, res.Height+1), nil
|
||||
}
|
||||
|
||||
// QueryChannel queries the store to get a channel and a merkle proof.
|
||||
// QueryChannel returns a channel end.
|
||||
// If prove is true, it performs an ABCI store query in order to retrieve the merkle proof. Otherwise,
|
||||
// it uses the gRPC query client.
|
||||
func QueryChannel(
|
||||
ctx client.Context, portID, channelID string, prove bool,
|
||||
) (types.ChannelResponse, error) {
|
||||
clientCtx client.Context, portID, channelID string, prove bool,
|
||||
) (*types.QueryChannelResponse, error) {
|
||||
if prove {
|
||||
return queryChannelABCI(clientCtx, portID, channelID)
|
||||
}
|
||||
|
||||
queryClient := types.NewQueryClient(clientCtx)
|
||||
req := &types.QueryChannelRequest{
|
||||
PortID: portID,
|
||||
ChannelID: channelID,
|
||||
}
|
||||
|
||||
return queryClient.Channel(context.Background(), req)
|
||||
}
|
||||
|
||||
func queryChannelABCI(clientCtx client.Context, portID, channelID string) (*types.QueryChannelResponse, error) {
|
||||
req := abci.RequestQuery{
|
||||
Path: "store/ibc/key",
|
||||
Data: host.KeyChannel(portID, channelID),
|
||||
Prove: prove,
|
||||
Prove: true,
|
||||
}
|
||||
|
||||
res, err := ctx.QueryABCI(req)
|
||||
if res.Value == nil || err != nil {
|
||||
return types.ChannelResponse{}, err
|
||||
res, err := clientCtx.QueryABCI(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var channel types.Channel
|
||||
if err := ctx.Codec.UnmarshalBinaryBare(res.Value, &channel); err != nil {
|
||||
return types.ChannelResponse{}, err
|
||||
if err := clientCtx.Codec.UnmarshalBinaryBare(res.Value, &channel); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return types.NewChannelResponse(portID, channelID, channel, res.Proof, res.Height), nil
|
||||
|
||||
proofBz, err := clientCtx.Codec.MarshalBinaryBare(res.Proof)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return types.NewQueryChannelResponse(portID, channelID, channel, proofBz, res.Height), nil
|
||||
}
|
||||
|
||||
// QueryChannelClientState uses the channel Querier to return the ClientState of
|
||||
// a Channel.
|
||||
func QueryChannelClientState(clientCtx client.Context, portID, channelID string) (clientexported.ClientState, int64, error) {
|
||||
params := types.NewQueryChannelClientStateParams(portID, channelID)
|
||||
params := types.NewQueryChannelClientStateRequest(portID, channelID)
|
||||
bz, err := clientCtx.JSONMarshaler.MarshalJSON(params)
|
||||
if err != nil {
|
||||
return nil, 0, fmt.Errorf("failed to marshal query params: %w", err)
|
||||
|
@ -94,3 +123,43 @@ func QueryChannelClientState(clientCtx client.Context, portID, channelID string)
|
|||
}
|
||||
return clientState, height, nil
|
||||
}
|
||||
|
||||
// QueryNextSequenceReceive returns the next sequence receive.
|
||||
// If prove is true, it performs an ABCI store query in order to retrieve the merkle proof. Otherwise,
|
||||
// it uses the gRPC query client.
|
||||
func QueryNextSequenceReceive(
|
||||
clientCtx client.Context, portID, channelID string, prove bool,
|
||||
) (*types.QueryNextSequenceReceiveResponse, error) {
|
||||
if prove {
|
||||
return queryNextSequenceRecvABCI(clientCtx, portID, channelID)
|
||||
}
|
||||
|
||||
queryClient := types.NewQueryClient(clientCtx)
|
||||
req := &types.QueryNextSequenceReceiveRequest{
|
||||
PortID: portID,
|
||||
ChannelID: channelID,
|
||||
}
|
||||
|
||||
return queryClient.NextSequenceReceive(context.Background(), req)
|
||||
}
|
||||
|
||||
func queryNextSequenceRecvABCI(clientCtx client.Context, portID, channelID string) (*types.QueryNextSequenceReceiveResponse, error) {
|
||||
req := abci.RequestQuery{
|
||||
Path: "store/ibc/key",
|
||||
Data: host.KeyNextSequenceRecv(portID, channelID),
|
||||
Prove: true,
|
||||
}
|
||||
|
||||
res, err := clientCtx.QueryABCI(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
proofBz, err := clientCtx.Codec.MarshalBinaryBare(res.Proof)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
sequence := binary.BigEndian.Uint64(res.Value)
|
||||
return types.NewQueryNextSequenceReceiveResponse(portID, channelID, sequence, proofBz, res.Height), nil
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
func InitGenesis(ctx sdk.Context, k keeper.Keeper, gs types.GenesisState) {
|
||||
for _, channel := range gs.Channels {
|
||||
ch := types.NewChannel(channel.State, channel.Ordering, channel.Counterparty, channel.ConnectionHops, channel.Version)
|
||||
k.SetChannel(ctx, channel.PortID, channel.ID, ch)
|
||||
k.SetChannel(ctx, channel.PortID, channel.ChannelID, ch)
|
||||
}
|
||||
for _, ack := range gs.Acknowledgements {
|
||||
k.SetPacketAcknowledgement(ctx, ack.PortID, ack.ChannelID, ack.Sequence, ack.Hash)
|
||||
|
|
|
@ -0,0 +1,267 @@
|
|||
package keeper
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/store/prefix"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
"github.com/cosmos/cosmos-sdk/types/query"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types"
|
||||
host "github.com/cosmos/cosmos-sdk/x/ibc/24-host"
|
||||
)
|
||||
|
||||
var _ types.QueryServer = (*Keeper)(nil)
|
||||
|
||||
// Channel implements the Query/Channel gRPC method
|
||||
func (q Keeper) Channel(c context.Context, req *types.QueryChannelRequest) (*types.QueryChannelResponse, error) {
|
||||
if req == nil {
|
||||
return nil, status.Error(codes.InvalidArgument, "empty request")
|
||||
}
|
||||
|
||||
if err := validategRPCRequest(req.PortID, req.ChannelID); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
channel, found := q.GetChannel(ctx, req.PortID, req.ChannelID)
|
||||
if !found {
|
||||
return nil, status.Error(
|
||||
codes.NotFound,
|
||||
sdkerrors.Wrapf(types.ErrChannelNotFound, "port-id: %s, channel-id %s", req.PortID, req.ChannelID).Error(),
|
||||
)
|
||||
}
|
||||
|
||||
return types.NewQueryChannelResponse(req.PortID, req.ChannelID, channel, nil, ctx.BlockHeight()), nil
|
||||
}
|
||||
|
||||
// Channels implements the Query/Channels gRPC method
|
||||
func (q Keeper) Channels(c context.Context, req *types.QueryChannelsRequest) (*types.QueryChannelsResponse, error) {
|
||||
if req == nil {
|
||||
return nil, status.Error(codes.InvalidArgument, "empty request")
|
||||
}
|
||||
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
|
||||
channels := []*types.IdentifiedChannel{}
|
||||
store := prefix.NewStore(ctx.KVStore(q.storeKey), []byte(host.KeyChannelPrefix))
|
||||
|
||||
res, err := query.Paginate(store, req.Req, func(key, value []byte) error {
|
||||
var result types.Channel
|
||||
if err := q.cdc.UnmarshalBinaryBare(value, &result); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
portID, channelID, err := host.ParseChannelPath(string(key))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
identifiedChannel := types.NewIdentifiedChannel(portID, channelID, result)
|
||||
channels = append(channels, &identifiedChannel)
|
||||
return nil
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &types.QueryChannelsResponse{
|
||||
Channels: channels,
|
||||
Res: res,
|
||||
Height: ctx.BlockHeight(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// ConnectionChannels implements the Query/ConnectionChannels gRPC method
|
||||
func (q Keeper) ConnectionChannels(c context.Context, req *types.QueryConnectionChannelsRequest) (*types.QueryConnectionChannelsResponse, error) {
|
||||
if req == nil {
|
||||
return nil, status.Error(codes.InvalidArgument, "empty request")
|
||||
}
|
||||
|
||||
if err := host.ConnectionIdentifierValidator(req.Connection); err != nil {
|
||||
return nil, status.Error(codes.InvalidArgument, err.Error())
|
||||
}
|
||||
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
|
||||
channels := []*types.IdentifiedChannel{}
|
||||
store := prefix.NewStore(ctx.KVStore(q.storeKey), []byte(host.KeyChannelPrefix))
|
||||
|
||||
res, err := query.Paginate(store, req.Req, func(key, value []byte) error {
|
||||
var result types.Channel
|
||||
if err := q.cdc.UnmarshalBinaryBare(value, &result); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// ignore channel and continue to the next item if the connection is
|
||||
// different than the requested one
|
||||
if result.ConnectionHops[0] != req.Connection {
|
||||
return nil
|
||||
}
|
||||
|
||||
portID, channelID, err := host.ParseChannelPath(string(key))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
identifiedChannel := types.NewIdentifiedChannel(portID, channelID, result)
|
||||
channels = append(channels, &identifiedChannel)
|
||||
return nil
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &types.QueryConnectionChannelsResponse{
|
||||
Channels: channels,
|
||||
Res: res,
|
||||
Height: ctx.BlockHeight(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// PacketCommitment implements the Query/PacketCommitment gRPC method
|
||||
func (q Keeper) PacketCommitment(c context.Context, req *types.QueryPacketCommitmentRequest) (*types.QueryPacketCommitmentResponse, error) {
|
||||
if req == nil {
|
||||
return nil, status.Error(codes.InvalidArgument, "empty request")
|
||||
}
|
||||
|
||||
if err := validategRPCRequest(req.PortID, req.ChannelID); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if req.Sequence == 0 {
|
||||
return nil, status.Error(codes.InvalidArgument, "packet sequence cannot be 0")
|
||||
}
|
||||
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
|
||||
commitmentBz := q.GetPacketCommitment(ctx, req.PortID, req.ChannelID, req.Sequence)
|
||||
if len(commitmentBz) == 0 {
|
||||
return nil, status.Error(codes.NotFound, "packet commitment hash not found")
|
||||
}
|
||||
|
||||
return types.NewQueryPacketCommitmentResponse(req.PortID, req.ChannelID, req.Sequence, commitmentBz, nil, ctx.BlockHeight()), nil
|
||||
}
|
||||
|
||||
// PacketCommitments implements the Query/PacketCommitments gRPC method
|
||||
func (q Keeper) PacketCommitments(c context.Context, req *types.QueryPacketCommitmentsRequest) (*types.QueryPacketCommitmentsResponse, error) {
|
||||
if req == nil {
|
||||
return nil, status.Error(codes.InvalidArgument, "empty request")
|
||||
}
|
||||
|
||||
if err := validategRPCRequest(req.PortID, req.ChannelID); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
|
||||
commitments := []*types.PacketAckCommitment{}
|
||||
store := prefix.NewStore(ctx.KVStore(q.storeKey), []byte(host.PacketCommitmentPrefixPath(req.PortID, req.ChannelID)))
|
||||
|
||||
res, err := query.Paginate(store, req.Req, func(key, value []byte) error {
|
||||
keySplit := strings.Split(string(key), "/")
|
||||
|
||||
sequence, err := strconv.ParseUint(keySplit[len(keySplit)-1], 10, 64)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
commitment := types.NewPacketAckCommitment(req.PortID, req.ChannelID, sequence, value)
|
||||
commitments = append(commitments, &commitment)
|
||||
return nil
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &types.QueryPacketCommitmentsResponse{
|
||||
Commitments: commitments,
|
||||
Res: res,
|
||||
Height: ctx.BlockHeight(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// UnrelayedPackets implements the Query/UnrelayedPackets gRPC method
|
||||
func (q Keeper) UnrelayedPackets(c context.Context, req *types.QueryUnrelayedPacketsRequest) (*types.QueryUnrelayedPacketsResponse, error) {
|
||||
if req == nil {
|
||||
return nil, status.Error(codes.InvalidArgument, "empty request")
|
||||
}
|
||||
|
||||
if err := validategRPCRequest(req.PortID, req.ChannelID); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
|
||||
var (
|
||||
unrelayedPackets = []uint64{}
|
||||
store sdk.KVStore
|
||||
res *query.PageResponse
|
||||
err error
|
||||
)
|
||||
|
||||
for i, seq := range req.Sequences {
|
||||
if seq == 0 {
|
||||
return nil, status.Errorf(codes.InvalidArgument, "packet sequence %d cannot be 0", i)
|
||||
}
|
||||
|
||||
store = prefix.NewStore(ctx.KVStore(q.storeKey), host.KeyPacketAcknowledgement(req.PortID, req.ChannelID, seq))
|
||||
res, err = query.Paginate(store, req.Req, func(_, _ []byte) error {
|
||||
return nil
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
// ignore error and continue to the next sequence item
|
||||
continue
|
||||
}
|
||||
|
||||
unrelayedPackets = append(unrelayedPackets, seq)
|
||||
}
|
||||
return &types.QueryUnrelayedPacketsResponse{
|
||||
Packets: unrelayedPackets,
|
||||
Res: res,
|
||||
Height: ctx.BlockHeight(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// NextSequenceReceive implements the Query/NextSequenceReceive gRPC method
|
||||
func (q Keeper) NextSequenceReceive(c context.Context, req *types.QueryNextSequenceReceiveRequest) (*types.QueryNextSequenceReceiveResponse, error) {
|
||||
if req == nil {
|
||||
return nil, status.Error(codes.InvalidArgument, "empty request")
|
||||
}
|
||||
|
||||
if err := validategRPCRequest(req.PortID, req.ChannelID); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
sequence, found := q.GetNextSequenceRecv(ctx, req.PortID, req.ChannelID)
|
||||
if !found {
|
||||
return nil, status.Error(
|
||||
codes.NotFound,
|
||||
sdkerrors.Wrapf(types.ErrSequenceReceiveNotFound, "port-id: %s, channel-id %s", req.PortID, req.ChannelID).Error(),
|
||||
)
|
||||
}
|
||||
|
||||
return types.NewQueryNextSequenceReceiveResponse(req.PortID, req.ChannelID, sequence, nil, ctx.BlockHeight()), nil
|
||||
}
|
||||
|
||||
func validategRPCRequest(portID, channelID string) error {
|
||||
if err := host.PortIdentifierValidator(portID); err != nil {
|
||||
return status.Error(codes.InvalidArgument, err.Error())
|
||||
}
|
||||
|
||||
if err := host.ChannelIdentifierValidator(channelID); err != nil {
|
||||
return status.Error(codes.InvalidArgument, err.Error())
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
|
@ -0,0 +1,657 @@
|
|||
package keeper_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/query"
|
||||
clientexported "github.com/cosmos/cosmos-sdk/x/ibc/02-client/exported"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types"
|
||||
ibctesting "github.com/cosmos/cosmos-sdk/x/ibc/testing"
|
||||
)
|
||||
|
||||
func (suite *KeeperTestSuite) TestQueryChannel() {
|
||||
var (
|
||||
req *types.QueryChannelRequest
|
||||
expChannel types.Channel
|
||||
)
|
||||
|
||||
testCases := []struct {
|
||||
msg string
|
||||
malleate func()
|
||||
expPass bool
|
||||
}{
|
||||
{
|
||||
"empty request",
|
||||
func() {
|
||||
req = nil
|
||||
},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"invalid port ID",
|
||||
func() {
|
||||
req = &types.QueryChannelRequest{
|
||||
PortID: "",
|
||||
ChannelID: "test-channel-id",
|
||||
}
|
||||
},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"invalid channel ID",
|
||||
func() {
|
||||
req = &types.QueryChannelRequest{
|
||||
PortID: "test-port-id",
|
||||
ChannelID: "",
|
||||
}
|
||||
},
|
||||
false,
|
||||
},
|
||||
{"channel not found",
|
||||
func() {
|
||||
req = &types.QueryChannelRequest{
|
||||
PortID: "test-port-id",
|
||||
ChannelID: "test-channel-id",
|
||||
}
|
||||
},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"success",
|
||||
func() {
|
||||
_, _, connA, connB := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, clientexported.Tendermint)
|
||||
// init channel
|
||||
channelA, _, err := suite.coordinator.ChanOpenInit(suite.chainA, suite.chainB, connA, connB, types.ORDERED)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
expChannel = suite.chainA.GetChannel(channelA)
|
||||
|
||||
req = &types.QueryChannelRequest{
|
||||
PortID: channelA.PortID,
|
||||
ChannelID: channelA.ID,
|
||||
}
|
||||
},
|
||||
true,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
suite.Run(fmt.Sprintf("Case %s", tc.msg), func() {
|
||||
suite.SetupTest() // reset
|
||||
|
||||
tc.malleate()
|
||||
ctx := sdk.WrapSDKContext(suite.chainA.GetContext())
|
||||
|
||||
res, err := suite.chainA.QueryServer.Channel(ctx, req)
|
||||
|
||||
if tc.expPass {
|
||||
suite.Require().NoError(err)
|
||||
suite.Require().NotNil(res)
|
||||
suite.Require().Equal(&expChannel, res.Channel)
|
||||
} else {
|
||||
suite.Require().Error(err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (suite *KeeperTestSuite) TestQueryChannels() {
|
||||
var (
|
||||
req *types.QueryChannelsRequest
|
||||
expChannels = []*types.IdentifiedChannel{}
|
||||
)
|
||||
|
||||
testCases := []struct {
|
||||
msg string
|
||||
malleate func()
|
||||
expPass bool
|
||||
}{
|
||||
{
|
||||
"empty request",
|
||||
func() {
|
||||
req = nil
|
||||
},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"empty pagination",
|
||||
func() {
|
||||
req = &types.QueryChannelsRequest{}
|
||||
},
|
||||
true,
|
||||
},
|
||||
{
|
||||
"success",
|
||||
func() {
|
||||
_, _, connA0, connB0, testchannel0, _ := suite.coordinator.Setup(suite.chainA, suite.chainB)
|
||||
// channel0 on first connection on chainA
|
||||
counterparty0 := types.Counterparty{
|
||||
PortID: connB0.Channels[0].PortID,
|
||||
ChannelID: connB0.Channels[0].ID,
|
||||
}
|
||||
|
||||
// channel1 is second channel on first connection on chainA
|
||||
testchannel1, _ := suite.coordinator.CreateChannel(suite.chainA, suite.chainB, connA0, connB0, types.ORDERED)
|
||||
counterparty1 := types.Counterparty{
|
||||
PortID: connB0.Channels[1].PortID,
|
||||
ChannelID: connB0.Channels[1].ID,
|
||||
}
|
||||
|
||||
channel0 := types.NewChannel(
|
||||
types.OPEN, types.UNORDERED,
|
||||
counterparty0, []string{connA0.ID}, ibctesting.ChannelVersion,
|
||||
)
|
||||
channel1 := types.NewChannel(
|
||||
types.OPEN, types.ORDERED,
|
||||
counterparty1, []string{connA0.ID}, ibctesting.ChannelVersion,
|
||||
)
|
||||
|
||||
idCh0 := types.NewIdentifiedChannel(testchannel0.PortID, testchannel0.ID, channel0)
|
||||
idCh1 := types.NewIdentifiedChannel(testchannel1.PortID, testchannel1.ID, channel1)
|
||||
|
||||
expChannels = []*types.IdentifiedChannel{&idCh0, &idCh1}
|
||||
|
||||
req = &types.QueryChannelsRequest{
|
||||
Req: &query.PageRequest{
|
||||
Key: nil,
|
||||
Limit: 2,
|
||||
CountTotal: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
true,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
suite.Run(fmt.Sprintf("Case %s", tc.msg), func() {
|
||||
suite.SetupTest() // reset
|
||||
|
||||
tc.malleate()
|
||||
ctx := sdk.WrapSDKContext(suite.chainA.GetContext())
|
||||
|
||||
res, err := suite.chainA.QueryServer.Channels(ctx, req)
|
||||
|
||||
if tc.expPass {
|
||||
suite.Require().NoError(err)
|
||||
suite.Require().NotNil(res)
|
||||
suite.Require().Equal(expChannels, res.Channels)
|
||||
suite.Require().Equal(len(expChannels), int(res.Res.Total))
|
||||
} else {
|
||||
suite.Require().Error(err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (suite *KeeperTestSuite) TestQueryConnectionChannels() {
|
||||
var (
|
||||
req *types.QueryConnectionChannelsRequest
|
||||
expChannels = []*types.IdentifiedChannel{}
|
||||
)
|
||||
|
||||
testCases := []struct {
|
||||
msg string
|
||||
malleate func()
|
||||
expPass bool
|
||||
}{
|
||||
{
|
||||
"empty request",
|
||||
func() {
|
||||
req = nil
|
||||
},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"invalid connection ID",
|
||||
func() {
|
||||
req = &types.QueryConnectionChannelsRequest{
|
||||
Connection: "",
|
||||
}
|
||||
},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"success",
|
||||
func() {
|
||||
_, _, connA0, connB0, testchannel0, _ := suite.coordinator.Setup(suite.chainA, suite.chainB)
|
||||
// channel0 on first connection on chainA
|
||||
counterparty0 := types.Counterparty{
|
||||
PortID: connB0.Channels[0].PortID,
|
||||
ChannelID: connB0.Channels[0].ID,
|
||||
}
|
||||
|
||||
// channel1 is second channel on first connection on chainA
|
||||
testchannel1, _ := suite.coordinator.CreateChannel(suite.chainA, suite.chainB, connA0, connB0, types.ORDERED)
|
||||
counterparty1 := types.Counterparty{
|
||||
PortID: connB0.Channels[1].PortID,
|
||||
ChannelID: connB0.Channels[1].ID,
|
||||
}
|
||||
|
||||
channel0 := types.NewChannel(
|
||||
types.OPEN, types.UNORDERED,
|
||||
counterparty0, []string{connA0.ID}, ibctesting.ChannelVersion,
|
||||
)
|
||||
channel1 := types.NewChannel(
|
||||
types.OPEN, types.ORDERED,
|
||||
counterparty1, []string{connA0.ID}, ibctesting.ChannelVersion,
|
||||
)
|
||||
|
||||
idCh0 := types.NewIdentifiedChannel(testchannel0.PortID, testchannel0.ID, channel0)
|
||||
idCh1 := types.NewIdentifiedChannel(testchannel1.PortID, testchannel1.ID, channel1)
|
||||
|
||||
expChannels = []*types.IdentifiedChannel{&idCh0, &idCh1}
|
||||
|
||||
req = &types.QueryConnectionChannelsRequest{
|
||||
Connection: connB0.ID,
|
||||
Req: &query.PageRequest{
|
||||
Key: nil,
|
||||
Limit: 2,
|
||||
CountTotal: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
true,
|
||||
},
|
||||
{
|
||||
"success, empty response",
|
||||
func() {
|
||||
suite.coordinator.Setup(suite.chainA, suite.chainB)
|
||||
expChannels = []*types.IdentifiedChannel{}
|
||||
req = &types.QueryConnectionChannelsRequest{
|
||||
Connection: "externalConnID",
|
||||
Req: &query.PageRequest{
|
||||
Key: nil,
|
||||
Limit: 2,
|
||||
CountTotal: false,
|
||||
},
|
||||
}
|
||||
},
|
||||
true,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
suite.Run(fmt.Sprintf("Case %s", tc.msg), func() {
|
||||
suite.SetupTest() // reset
|
||||
|
||||
tc.malleate()
|
||||
ctx := sdk.WrapSDKContext(suite.chainA.GetContext())
|
||||
|
||||
res, err := suite.chainA.QueryServer.ConnectionChannels(ctx, req)
|
||||
|
||||
if tc.expPass {
|
||||
suite.Require().NoError(err)
|
||||
suite.Require().NotNil(res)
|
||||
suite.Require().Equal(expChannels, res.Channels)
|
||||
} else {
|
||||
suite.Require().Error(err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (suite *KeeperTestSuite) TestQueryPacketCommitment() {
|
||||
var (
|
||||
req *types.QueryPacketCommitmentRequest
|
||||
expCommitment []byte
|
||||
)
|
||||
|
||||
testCases := []struct {
|
||||
msg string
|
||||
malleate func()
|
||||
expPass bool
|
||||
}{
|
||||
{
|
||||
"empty request",
|
||||
func() {
|
||||
req = nil
|
||||
},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"invalid port ID",
|
||||
func() {
|
||||
req = &types.QueryPacketCommitmentRequest{
|
||||
PortID: "",
|
||||
ChannelID: "test-channel-id",
|
||||
Sequence: 0,
|
||||
}
|
||||
},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"invalid channel ID",
|
||||
func() {
|
||||
req = &types.QueryPacketCommitmentRequest{
|
||||
PortID: "test-port-id",
|
||||
ChannelID: "",
|
||||
Sequence: 0,
|
||||
}
|
||||
},
|
||||
false,
|
||||
},
|
||||
{"invalid sequence",
|
||||
func() {
|
||||
req = &types.QueryPacketCommitmentRequest{
|
||||
PortID: "test-port-id",
|
||||
ChannelID: "test-channel-id",
|
||||
Sequence: 0,
|
||||
}
|
||||
},
|
||||
false,
|
||||
},
|
||||
{"channel not found",
|
||||
func() {
|
||||
req = &types.QueryPacketCommitmentRequest{
|
||||
PortID: "test-port-id",
|
||||
ChannelID: "test-channel-id",
|
||||
Sequence: 1,
|
||||
}
|
||||
},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"success",
|
||||
func() {
|
||||
_, _, _, _, channelA, _ := suite.coordinator.Setup(suite.chainA, suite.chainB)
|
||||
expCommitment = []byte("hash")
|
||||
suite.chainA.App.IBCKeeper.ChannelKeeper.SetPacketCommitment(suite.chainA.GetContext(), channelA.PortID, channelA.ID, 1, expCommitment)
|
||||
|
||||
req = &types.QueryPacketCommitmentRequest{
|
||||
PortID: channelA.PortID,
|
||||
ChannelID: channelA.ID,
|
||||
Sequence: 1,
|
||||
}
|
||||
},
|
||||
true,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
suite.Run(fmt.Sprintf("Case %s", tc.msg), func() {
|
||||
suite.SetupTest() // reset
|
||||
|
||||
tc.malleate()
|
||||
ctx := sdk.WrapSDKContext(suite.chainA.GetContext())
|
||||
|
||||
res, err := suite.chainA.QueryServer.PacketCommitment(ctx, req)
|
||||
|
||||
if tc.expPass {
|
||||
suite.Require().NoError(err)
|
||||
suite.Require().NotNil(res)
|
||||
suite.Require().Equal(expCommitment, res.Commitment)
|
||||
} else {
|
||||
suite.Require().Error(err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (suite *KeeperTestSuite) TestQueryPacketCommitments() {
|
||||
var (
|
||||
req *types.QueryPacketCommitmentsRequest
|
||||
expCommitments = []*types.PacketAckCommitment{}
|
||||
)
|
||||
|
||||
testCases := []struct {
|
||||
msg string
|
||||
malleate func()
|
||||
expPass bool
|
||||
}{
|
||||
{
|
||||
"empty request",
|
||||
func() {
|
||||
req = nil
|
||||
},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"invalid ID",
|
||||
func() {
|
||||
req = &types.QueryPacketCommitmentsRequest{
|
||||
PortID: "",
|
||||
ChannelID: "test-channel-id",
|
||||
}
|
||||
},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"success, empty res",
|
||||
func() {
|
||||
expCommitments = []*types.PacketAckCommitment{}
|
||||
|
||||
req = &types.QueryPacketCommitmentsRequest{
|
||||
PortID: "test-port-id",
|
||||
ChannelID: "test-channel-id",
|
||||
Req: &query.PageRequest{
|
||||
Key: nil,
|
||||
Limit: 2,
|
||||
CountTotal: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
true,
|
||||
},
|
||||
{
|
||||
"success",
|
||||
func() {
|
||||
_, _, _, _, channelA, _ := suite.coordinator.Setup(suite.chainA, suite.chainB)
|
||||
|
||||
expCommitments = make([]*types.PacketAckCommitment, 9)
|
||||
|
||||
for i := uint64(0); i < 9; i++ {
|
||||
commitment := types.NewPacketAckCommitment(channelA.PortID, channelA.ID, i, []byte(fmt.Sprintf("hash_%d", i)))
|
||||
suite.chainA.App.IBCKeeper.ChannelKeeper.SetPacketCommitment(suite.chainA.GetContext(), commitment.PortID, commitment.ChannelID, commitment.Sequence, commitment.Hash)
|
||||
expCommitments[i] = &commitment
|
||||
}
|
||||
|
||||
req = &types.QueryPacketCommitmentsRequest{
|
||||
PortID: channelA.PortID,
|
||||
ChannelID: channelA.ID,
|
||||
Req: &query.PageRequest{
|
||||
Key: nil,
|
||||
Limit: 11,
|
||||
CountTotal: true,
|
||||
},
|
||||
}
|
||||
},
|
||||
true,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
suite.Run(fmt.Sprintf("Case %s", tc.msg), func() {
|
||||
suite.SetupTest() // reset
|
||||
|
||||
tc.malleate()
|
||||
ctx := sdk.WrapSDKContext(suite.chainA.GetContext())
|
||||
|
||||
res, err := suite.chainA.QueryServer.PacketCommitments(ctx, req)
|
||||
|
||||
if tc.expPass {
|
||||
suite.Require().NoError(err)
|
||||
suite.Require().NotNil(res)
|
||||
suite.Require().Equal(expCommitments, res.Commitments)
|
||||
} else {
|
||||
suite.Require().Error(err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (suite *KeeperTestSuite) TestQueryUnrelayedPackets() {
|
||||
var (
|
||||
req *types.QueryUnrelayedPacketsRequest
|
||||
expSeq = []uint64{}
|
||||
)
|
||||
|
||||
testCases := []struct {
|
||||
msg string
|
||||
malleate func()
|
||||
expPass bool
|
||||
}{
|
||||
{
|
||||
"empty request",
|
||||
func() {
|
||||
req = nil
|
||||
},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"invalid port ID",
|
||||
func() {
|
||||
req = &types.QueryUnrelayedPacketsRequest{
|
||||
PortID: "",
|
||||
ChannelID: "test-channel-id",
|
||||
}
|
||||
},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"invalid channel ID",
|
||||
func() {
|
||||
req = &types.QueryUnrelayedPacketsRequest{
|
||||
PortID: "test-port-id",
|
||||
ChannelID: "",
|
||||
}
|
||||
},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"invalid seq",
|
||||
func() {
|
||||
req = &types.QueryUnrelayedPacketsRequest{
|
||||
PortID: "test-port-id",
|
||||
ChannelID: "test-channel-id",
|
||||
Sequences: []uint64{0},
|
||||
}
|
||||
},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"success",
|
||||
func() {
|
||||
_, _, _, _, channelA, _ := suite.coordinator.Setup(suite.chainA, suite.chainB)
|
||||
ack := types.NewPacketAckCommitment(channelA.PortID, channelA.ID, 1, []byte("hash"))
|
||||
suite.chainA.App.IBCKeeper.ChannelKeeper.SetPacketAcknowledgement(suite.chainA.GetContext(), channelA.PortID, channelA.ID, 1, ack.Hash)
|
||||
|
||||
expSeq = []uint64{1}
|
||||
req = &types.QueryUnrelayedPacketsRequest{
|
||||
PortID: channelA.PortID,
|
||||
ChannelID: channelA.ID,
|
||||
Sequences: []uint64{1},
|
||||
Req: &query.PageRequest{
|
||||
Key: nil,
|
||||
Limit: 1,
|
||||
CountTotal: false,
|
||||
},
|
||||
}
|
||||
},
|
||||
true,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
suite.Run(fmt.Sprintf("Case %s", tc.msg), func() {
|
||||
suite.SetupTest() // reset
|
||||
|
||||
tc.malleate()
|
||||
ctx := sdk.WrapSDKContext(suite.chainA.GetContext())
|
||||
|
||||
res, err := suite.chainA.QueryServer.UnrelayedPackets(ctx, req)
|
||||
|
||||
if tc.expPass {
|
||||
suite.Require().NoError(err)
|
||||
suite.Require().NotNil(res)
|
||||
suite.Require().Equal(expSeq, res.Packets)
|
||||
} else {
|
||||
suite.Require().Error(err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func (suite *KeeperTestSuite) TestQueryNextSequenceReceive() {
|
||||
var (
|
||||
req *types.QueryNextSequenceReceiveRequest
|
||||
expSeq uint64
|
||||
)
|
||||
|
||||
testCases := []struct {
|
||||
msg string
|
||||
malleate func()
|
||||
expPass bool
|
||||
}{
|
||||
{
|
||||
"empty request",
|
||||
func() {
|
||||
req = nil
|
||||
},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"invalid port ID",
|
||||
func() {
|
||||
req = &types.QueryNextSequenceReceiveRequest{
|
||||
PortID: "",
|
||||
ChannelID: "test-channel-id",
|
||||
}
|
||||
},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"invalid channel ID",
|
||||
func() {
|
||||
req = &types.QueryNextSequenceReceiveRequest{
|
||||
PortID: "test-port-id",
|
||||
ChannelID: "",
|
||||
}
|
||||
},
|
||||
false,
|
||||
},
|
||||
{"channel not found",
|
||||
func() {
|
||||
req = &types.QueryNextSequenceReceiveRequest{
|
||||
PortID: "test-port-id",
|
||||
ChannelID: "test-channel-id",
|
||||
}
|
||||
},
|
||||
false,
|
||||
},
|
||||
{
|
||||
"success",
|
||||
func() {
|
||||
_, _, _, _, channelA, _ := suite.coordinator.Setup(suite.chainA, suite.chainB)
|
||||
expSeq = 1
|
||||
suite.chainA.App.IBCKeeper.ChannelKeeper.SetNextSequenceRecv(suite.chainA.GetContext(), channelA.PortID, channelA.ID, expSeq)
|
||||
|
||||
req = &types.QueryNextSequenceReceiveRequest{
|
||||
PortID: channelA.PortID,
|
||||
ChannelID: channelA.ID,
|
||||
}
|
||||
},
|
||||
true,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
suite.Run(fmt.Sprintf("Case %s", tc.msg), func() {
|
||||
suite.SetupTest() // reset
|
||||
|
||||
tc.malleate()
|
||||
ctx := sdk.WrapSDKContext(suite.chainA.GetContext())
|
||||
|
||||
res, err := suite.chainA.QueryServer.NextSequenceReceive(ctx, req)
|
||||
|
||||
if tc.expPass {
|
||||
suite.Require().NoError(err)
|
||||
suite.Require().NotNil(res)
|
||||
suite.Require().Equal(expSeq, res.NextSequenceReceive)
|
||||
} else {
|
||||
suite.Require().Error(err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
|
@ -19,6 +19,9 @@ import (
|
|||
|
||||
// Keeper defines the IBC channel keeper
|
||||
type Keeper struct {
|
||||
// implements gRPC QueryServer interface
|
||||
types.QueryServer
|
||||
|
||||
storeKey sdk.StoreKey
|
||||
cdc codec.Marshaler
|
||||
clientKeeper types.ClientKeeper
|
||||
|
@ -131,7 +134,8 @@ func (k Keeper) GetPacketCommitment(ctx sdk.Context, portID, channelID string, s
|
|||
|
||||
// HasPacketCommitment returns true if the packet commitment exists
|
||||
func (k Keeper) HasPacketCommitment(ctx sdk.Context, portID, channelID string, sequence uint64) bool {
|
||||
return len(k.GetPacketCommitment(ctx, portID, channelID, sequence)) > 0
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
return store.Has(host.KeyPacketCommitment(portID, channelID, sequence))
|
||||
}
|
||||
|
||||
// SetPacketCommitment sets the packet commitment hash to the store
|
||||
|
|
|
@ -3,7 +3,6 @@ package keeper
|
|||
import (
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
|
@ -12,75 +11,18 @@ import (
|
|||
"github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types"
|
||||
)
|
||||
|
||||
// QuerierChannels defines the sdk.Querier to query all the channels.
|
||||
func QuerierChannels(ctx sdk.Context, req abci.RequestQuery, k Keeper) ([]byte, error) {
|
||||
var params types.QueryAllChannelsParams
|
||||
|
||||
if err := k.cdc.UnmarshalJSON(req.Data, ¶ms); err != nil {
|
||||
return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error())
|
||||
}
|
||||
|
||||
channels := k.GetAllChannels(ctx)
|
||||
|
||||
start, end := client.Paginate(len(channels), params.Page, params.Limit, 100)
|
||||
if start < 0 || end < 0 {
|
||||
channels = []types.IdentifiedChannel{}
|
||||
} else {
|
||||
channels = channels[start:end]
|
||||
}
|
||||
|
||||
res, err := codec.MarshalJSONIndent(k.cdc, channels)
|
||||
if err != nil {
|
||||
return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error())
|
||||
}
|
||||
|
||||
return res, nil
|
||||
}
|
||||
|
||||
// QuerierConnectionChannels defines the sdk.Querier to query all the channels for a connection.
|
||||
func QuerierConnectionChannels(ctx sdk.Context, req abci.RequestQuery, k Keeper) ([]byte, error) {
|
||||
var params types.QueryConnectionChannelsParams
|
||||
|
||||
if err := k.cdc.UnmarshalJSON(req.Data, ¶ms); err != nil {
|
||||
return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error())
|
||||
}
|
||||
|
||||
channels := k.GetAllChannels(ctx)
|
||||
|
||||
connectionChannels := []types.IdentifiedChannel{}
|
||||
for _, channel := range channels {
|
||||
if channel.ConnectionHops[0] == params.Connection {
|
||||
connectionChannels = append(connectionChannels, channel)
|
||||
}
|
||||
}
|
||||
|
||||
start, end := client.Paginate(len(connectionChannels), params.Page, params.Limit, 100)
|
||||
if start < 0 || end < 0 {
|
||||
connectionChannels = []types.IdentifiedChannel{}
|
||||
} else {
|
||||
connectionChannels = channels[start:end]
|
||||
}
|
||||
|
||||
res, err := codec.MarshalJSONIndent(k.cdc, connectionChannels)
|
||||
if err != nil {
|
||||
return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error())
|
||||
}
|
||||
|
||||
return res, nil
|
||||
}
|
||||
|
||||
// QuerierChannelClientState defines the sdk.Querier to query all the ClientState
|
||||
// associated with a given Channel.
|
||||
func QuerierChannelClientState(ctx sdk.Context, req abci.RequestQuery, k Keeper) ([]byte, error) {
|
||||
var params types.QueryChannelClientStateParams
|
||||
func QuerierChannelClientState(ctx sdk.Context, abciReq abci.RequestQuery, k Keeper) ([]byte, error) {
|
||||
var req types.QueryChannelClientStateRequest
|
||||
|
||||
if err := k.cdc.UnmarshalJSON(req.Data, ¶ms); err != nil {
|
||||
if err := k.cdc.UnmarshalJSON(abciReq.Data, &req); err != nil {
|
||||
return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error())
|
||||
}
|
||||
|
||||
channel, found := k.GetChannel(ctx, params.PortID, params.ChannelID)
|
||||
channel, found := k.GetChannel(ctx, req.PortID, req.ChannelID)
|
||||
if !found {
|
||||
return nil, sdkerrors.Wrapf(types.ErrChannelNotFound, params.PortID, params.ChannelID)
|
||||
return nil, sdkerrors.Wrapf(types.ErrChannelNotFound, req.PortID, req.ChannelID)
|
||||
}
|
||||
|
||||
connection, found := k.connectionKeeper.GetConnection(ctx, channel.ConnectionHops[0])
|
||||
|
@ -100,79 +42,3 @@ func QuerierChannelClientState(ctx sdk.Context, req abci.RequestQuery, k Keeper)
|
|||
|
||||
return res, nil
|
||||
}
|
||||
|
||||
// QuerierPacketCommitments defines the sdk.Querier to query all packet commitments on a
|
||||
// specified channel.
|
||||
func QuerierPacketCommitments(ctx sdk.Context, req abci.RequestQuery, k Keeper) ([]byte, error) {
|
||||
var params types.QueryPacketCommitmentsParams
|
||||
|
||||
if err := k.cdc.UnmarshalJSON(req.Data, ¶ms); err != nil {
|
||||
return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error())
|
||||
}
|
||||
|
||||
packetCommitments := k.GetAllPacketCommitmentsAtChannel(ctx, params.PortID, params.ChannelID)
|
||||
sequences := make([]uint64, 0, len(packetCommitments))
|
||||
|
||||
for _, pc := range packetCommitments {
|
||||
sequences = append(sequences, pc.Sequence)
|
||||
}
|
||||
|
||||
start, end := client.Paginate(len(sequences), params.Page, params.Limit, 100)
|
||||
if start < 0 || end < 0 {
|
||||
sequences = []uint64{}
|
||||
} else {
|
||||
sequences = sequences[start:end]
|
||||
}
|
||||
|
||||
res, err := codec.MarshalJSONIndent(k.cdc, sequences)
|
||||
if err != nil {
|
||||
return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error())
|
||||
}
|
||||
|
||||
return res, nil
|
||||
}
|
||||
|
||||
// QuerierUnrelayedAcknowledgements defines the sdk.Querier to query all unrelayed
|
||||
// acknowledgements for a specified channel end.
|
||||
func QuerierUnrelayedAcknowledgements(ctx sdk.Context, req abci.RequestQuery, k Keeper) ([]byte, error) {
|
||||
return queryUnrelayedPackets(ctx, req, k, true)
|
||||
}
|
||||
|
||||
// QuerierUnrelayedPacketSends defines the sdk.Querier to query all unrelayed packets for a
|
||||
// specified channel end.
|
||||
func QuerierUnrelayedPacketSends(ctx sdk.Context, req abci.RequestQuery, k Keeper) ([]byte, error) {
|
||||
return queryUnrelayedPackets(ctx, req, k, false)
|
||||
}
|
||||
|
||||
// helper function to query for unrelayed packets as specified by the isForAcks boolean. If
|
||||
// set to true it will return unrelayed acknowledgements otherwise it will return unrelayed
|
||||
// packet sends.
|
||||
func queryUnrelayedPackets(ctx sdk.Context, req abci.RequestQuery, k Keeper, isForAcks bool) ([]byte, error) {
|
||||
var params types.QueryUnrelayedPacketsParams
|
||||
|
||||
if err := k.cdc.UnmarshalJSON(req.Data, ¶ms); err != nil {
|
||||
return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error())
|
||||
}
|
||||
|
||||
var unrelayedPackets []uint64
|
||||
for _, seq := range params.Sequences {
|
||||
if _, found := k.GetPacketAcknowledgement(ctx, params.PortID, params.ChannelID, seq); found == isForAcks {
|
||||
unrelayedPackets = append(unrelayedPackets, seq)
|
||||
}
|
||||
}
|
||||
|
||||
start, end := client.Paginate(len(unrelayedPackets), params.Page, params.Limit, 100)
|
||||
if start < 0 || end < 0 {
|
||||
unrelayedPackets = []uint64{}
|
||||
} else {
|
||||
unrelayedPackets = unrelayedPackets[start:end]
|
||||
}
|
||||
|
||||
res, err := codec.MarshalJSONIndent(k.cdc, unrelayedPackets)
|
||||
if err != nil {
|
||||
return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error())
|
||||
}
|
||||
|
||||
return res, nil
|
||||
|
||||
}
|
||||
|
|
|
@ -9,222 +9,6 @@ import (
|
|||
"github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types"
|
||||
)
|
||||
|
||||
// TestQueryChannels tests singular, multiple, and no connection for
|
||||
// correct retrieval of all channels.
|
||||
func (suite *KeeperTestSuite) TestQueryChannels() {
|
||||
path := []string{types.SubModuleName, types.QueryAllChannels}
|
||||
var (
|
||||
expRes []byte
|
||||
err error
|
||||
)
|
||||
|
||||
params := types.NewQueryAllChannelsParams(1, 100)
|
||||
data, err := suite.chainA.App.AppCodec().MarshalJSON(params)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
query := abci.RequestQuery{
|
||||
Path: "",
|
||||
Data: data,
|
||||
}
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
setup func()
|
||||
}{
|
||||
{
|
||||
"success with different connection channels",
|
||||
func() {
|
||||
channels := make([]types.IdentifiedChannel, 0, 2)
|
||||
|
||||
// create first connection/channel
|
||||
clientA, clientB, _, _, channelA0, _ := suite.coordinator.Setup(suite.chainA, suite.chainB)
|
||||
|
||||
channels = append(channels,
|
||||
types.NewIdentifiedChannel(
|
||||
channelA0.PortID,
|
||||
channelA0.ID,
|
||||
suite.chainA.GetChannel(channelA0),
|
||||
),
|
||||
)
|
||||
|
||||
// create second connection
|
||||
connA1, connB1 := suite.coordinator.CreateConnection(suite.chainA, suite.chainB, clientA, clientB)
|
||||
|
||||
// create second channel on second connection
|
||||
channelA1, _ := suite.coordinator.CreateChannel(suite.chainA, suite.chainB, connA1, connB1, types.ORDERED)
|
||||
|
||||
channels = append(channels,
|
||||
types.NewIdentifiedChannel(
|
||||
channelA1.PortID,
|
||||
channelA1.ID,
|
||||
suite.chainA.GetChannel(channelA1),
|
||||
),
|
||||
)
|
||||
|
||||
// set expected result
|
||||
expRes, err = codec.MarshalJSONIndent(suite.chainA.App.AppCodec(), channels)
|
||||
suite.Require().NoError(err)
|
||||
},
|
||||
},
|
||||
{
|
||||
"success with singular connection channels",
|
||||
func() {
|
||||
channels := make([]types.IdentifiedChannel, 0, 2)
|
||||
|
||||
// create first connection/channel
|
||||
_, _, connA, connB, channelA0, _ := suite.coordinator.Setup(suite.chainA, suite.chainB)
|
||||
|
||||
channels = append(channels,
|
||||
types.NewIdentifiedChannel(
|
||||
channelA0.PortID,
|
||||
channelA0.ID,
|
||||
suite.chainA.GetChannel(channelA0),
|
||||
),
|
||||
)
|
||||
|
||||
// create second channel on the same connection
|
||||
channelA1, _ := suite.coordinator.CreateChannel(suite.chainA, suite.chainB, connA, connB, types.UNORDERED)
|
||||
channels = append(channels,
|
||||
types.NewIdentifiedChannel(
|
||||
channelA1.PortID,
|
||||
channelA1.ID,
|
||||
suite.chainA.GetChannel(channelA1),
|
||||
),
|
||||
)
|
||||
|
||||
// set expected result
|
||||
expRes, err = codec.MarshalJSONIndent(suite.chainA.App.AppCodec(), channels)
|
||||
suite.Require().NoError(err)
|
||||
},
|
||||
},
|
||||
{
|
||||
"success no channels",
|
||||
func() {
|
||||
expRes, err = codec.MarshalJSONIndent(suite.chainA.App.AppCodec(), []types.IdentifiedChannel{})
|
||||
suite.Require().NoError(err)
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for i, tc := range testCases {
|
||||
suite.SetupTest() // reset
|
||||
tc.setup()
|
||||
|
||||
bz, err := suite.chainA.Querier(suite.chainA.GetContext(), path, query)
|
||||
|
||||
suite.Require().NoError(err, "test case %d failed: %s", i, tc.name)
|
||||
suite.Require().Equal(expRes, bz, "test case %d failed: %s", i, tc.name)
|
||||
}
|
||||
}
|
||||
|
||||
// TestQueryConnectionChannel tests querying existing channels on a singular connection.
|
||||
func (suite *KeeperTestSuite) TestQueryConnectionChannels() {
|
||||
path := []string{types.SubModuleName, types.QueryConnectionChannels}
|
||||
|
||||
var (
|
||||
expRes []byte
|
||||
params types.QueryConnectionChannelsParams
|
||||
err error
|
||||
)
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
setup func()
|
||||
}{
|
||||
{
|
||||
"success with singular connection channels",
|
||||
func() {
|
||||
channels := make([]types.IdentifiedChannel, 0, 2)
|
||||
|
||||
// create first connection/channel
|
||||
_, _, connA, connB, channelA0, _ := suite.coordinator.Setup(suite.chainA, suite.chainB)
|
||||
|
||||
channels = append(channels,
|
||||
types.NewIdentifiedChannel(
|
||||
channelA0.PortID,
|
||||
channelA0.ID,
|
||||
suite.chainA.GetChannel(channelA0),
|
||||
),
|
||||
)
|
||||
|
||||
// create second channel on the same connection
|
||||
channelA1, _ := suite.coordinator.CreateChannel(suite.chainA, suite.chainB, connA, connB, types.ORDERED)
|
||||
channels = append(channels,
|
||||
types.NewIdentifiedChannel(
|
||||
channelA1.PortID,
|
||||
channelA1.ID,
|
||||
suite.chainA.GetChannel(channelA1),
|
||||
),
|
||||
)
|
||||
|
||||
params = types.NewQueryConnectionChannelsParams(connA.ID, 1, 100)
|
||||
|
||||
// set expected result
|
||||
expRes, err = codec.MarshalJSONIndent(suite.chainA.App.AppCodec(), channels)
|
||||
suite.Require().NoError(err)
|
||||
},
|
||||
},
|
||||
{
|
||||
"success multiple connection channels",
|
||||
func() {
|
||||
channels := make([]types.IdentifiedChannel, 0, 1)
|
||||
|
||||
// create first connection/channel
|
||||
clientA, clientB, connA, _, channelA0, _ := suite.coordinator.Setup(suite.chainA, suite.chainB)
|
||||
|
||||
channels = append(channels,
|
||||
types.NewIdentifiedChannel(
|
||||
channelA0.PortID,
|
||||
channelA0.ID,
|
||||
suite.chainA.GetChannel(channelA0),
|
||||
),
|
||||
)
|
||||
|
||||
// create second connection
|
||||
connA1, connB1 := suite.coordinator.CreateConnection(suite.chainA, suite.chainB, clientA, clientB)
|
||||
|
||||
// create second channel on second connection
|
||||
suite.coordinator.CreateChannel(suite.chainA, suite.chainB, connA1, connB1, types.ORDERED)
|
||||
|
||||
params = types.NewQueryConnectionChannelsParams(connA.ID, 1, 100)
|
||||
|
||||
// set expected result
|
||||
expRes, err = codec.MarshalJSONIndent(suite.chainA.App.AppCodec(), channels)
|
||||
suite.Require().NoError(err)
|
||||
},
|
||||
},
|
||||
{
|
||||
"success no channels",
|
||||
func() {
|
||||
// create connection but no channels
|
||||
_, _, connA, _ := suite.coordinator.SetupClientConnections(suite.chainA, suite.chainB, clientexported.Tendermint)
|
||||
params = types.NewQueryConnectionChannelsParams(connA.ID, 1, 100)
|
||||
|
||||
expRes, err = codec.MarshalJSONIndent(suite.chainA.App.AppCodec(), []types.IdentifiedChannel{})
|
||||
suite.Require().NoError(err)
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for i, tc := range testCases {
|
||||
suite.SetupTest() // reset
|
||||
tc.setup()
|
||||
|
||||
data, err := suite.chainA.App.AppCodec().MarshalJSON(params)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
query := abci.RequestQuery{
|
||||
Path: "",
|
||||
Data: data,
|
||||
}
|
||||
|
||||
bz, err := suite.chainA.Querier(suite.chainA.GetContext(), path, query)
|
||||
|
||||
suite.Require().NoError(err, "test case %d failed: %s", i, tc.name)
|
||||
suite.Require().Equal(expRes, bz, "test case %d failed: %s", i, tc.name)
|
||||
}
|
||||
}
|
||||
|
||||
// TestQuerierChannelClientState verifies correct querying of client state associated
|
||||
// with a channel end.
|
||||
func (suite *KeeperTestSuite) TestQuerierChannelClientState() {
|
||||
|
@ -232,7 +16,7 @@ func (suite *KeeperTestSuite) TestQuerierChannelClientState() {
|
|||
|
||||
var (
|
||||
clientID string
|
||||
params types.QueryChannelClientStateParams
|
||||
req *types.QueryChannelClientStateRequest
|
||||
)
|
||||
|
||||
testCases := []struct {
|
||||
|
@ -247,7 +31,7 @@ func (suite *KeeperTestSuite) TestQuerierChannelClientState() {
|
|||
suite.Require().NoError(err)
|
||||
|
||||
clientID = clientA
|
||||
params = types.NewQueryChannelClientStateParams("doesnotexist", "doesnotexist")
|
||||
req = types.NewQueryChannelClientStateRequest("doesnotexist", "doesnotexist")
|
||||
},
|
||||
false,
|
||||
},
|
||||
|
@ -264,7 +48,7 @@ func (suite *KeeperTestSuite) TestQuerierChannelClientState() {
|
|||
suite.chainA.App.IBCKeeper.ChannelKeeper.SetChannel(suite.chainA.GetContext(), channelA.PortID, channelA.ID, channel)
|
||||
|
||||
clientID = clientA
|
||||
params = types.NewQueryChannelClientStateParams(channelA.PortID, channelA.ID)
|
||||
req = types.NewQueryChannelClientStateRequest(channelA.PortID, channelA.ID)
|
||||
|
||||
},
|
||||
false,
|
||||
|
@ -278,7 +62,7 @@ func (suite *KeeperTestSuite) TestQuerierChannelClientState() {
|
|||
suite.chainA.App.IBCKeeper.ConnectionKeeper.SetConnection(suite.chainA.GetContext(), connA.ID, connectiontypes.ConnectionEnd{})
|
||||
|
||||
clientID = clientA
|
||||
params = types.NewQueryChannelClientStateParams(channelA.PortID, channelA.ID)
|
||||
req = types.NewQueryChannelClientStateRequest(channelA.PortID, channelA.ID)
|
||||
},
|
||||
false,
|
||||
},
|
||||
|
@ -288,7 +72,7 @@ func (suite *KeeperTestSuite) TestQuerierChannelClientState() {
|
|||
clientA, _, _, _, channelA, _ := suite.coordinator.Setup(suite.chainA, suite.chainB)
|
||||
|
||||
clientID = clientA
|
||||
params = types.NewQueryChannelClientStateParams(channelA.PortID, channelA.ID)
|
||||
req = types.NewQueryChannelClientStateRequest(channelA.PortID, channelA.ID)
|
||||
},
|
||||
true,
|
||||
},
|
||||
|
@ -298,7 +82,7 @@ func (suite *KeeperTestSuite) TestQuerierChannelClientState() {
|
|||
suite.SetupTest() // reset
|
||||
tc.setup()
|
||||
|
||||
data, err := suite.chainA.App.AppCodec().MarshalJSON(params)
|
||||
data, err := suite.chainA.App.AppCodec().MarshalJSON(req)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
query := abci.RequestQuery{
|
||||
|
@ -322,229 +106,3 @@ func (suite *KeeperTestSuite) TestQuerierChannelClientState() {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TestQueryPacketCommitments tests querying packet commitments on a specified channel end.
|
||||
func (suite *KeeperTestSuite) TestQueryPacketCommitments() {
|
||||
path := []string{types.SubModuleName, types.QueryPacketCommitments}
|
||||
|
||||
var (
|
||||
expRes []byte
|
||||
params types.QueryPacketCommitmentsParams
|
||||
err error
|
||||
)
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
setup func()
|
||||
}{
|
||||
{
|
||||
"success",
|
||||
func() {
|
||||
_, _, _, _, channelA, _ := suite.coordinator.Setup(suite.chainA, suite.chainB)
|
||||
|
||||
seq := uint64(1)
|
||||
commitments := []uint64{}
|
||||
|
||||
// create several commitments on the same channel and port
|
||||
for i := seq; i < 10; i++ {
|
||||
suite.chainA.App.IBCKeeper.ChannelKeeper.SetPacketCommitment(suite.chainA.GetContext(), channelA.PortID, channelA.ID, i, []byte("ack"))
|
||||
commitments = append(commitments, i)
|
||||
}
|
||||
|
||||
params = types.NewQueryPacketCommitmentsParams(channelA.PortID, channelA.ID, 1, 100)
|
||||
|
||||
expRes, err = codec.MarshalJSONIndent(suite.chainA.App.AppCodec(), commitments)
|
||||
suite.Require().NoError(err)
|
||||
},
|
||||
},
|
||||
{
|
||||
"success with multiple channels",
|
||||
func() {
|
||||
_, _, connA, connB, channelA0, _ := suite.coordinator.Setup(suite.chainA, suite.chainB)
|
||||
|
||||
seq := uint64(1)
|
||||
commitments := []uint64{}
|
||||
|
||||
// create several commitments on the same channel and port
|
||||
for i := seq; i < 10; i++ {
|
||||
suite.chainA.App.IBCKeeper.ChannelKeeper.SetPacketCommitment(suite.chainA.GetContext(), channelA0.PortID, channelA0.ID, i, []byte("ack"))
|
||||
commitments = append(commitments, i)
|
||||
}
|
||||
|
||||
// create second channel
|
||||
channelA1, _ := suite.coordinator.CreateChannel(suite.chainA, suite.chainB, connA, connB, types.ORDERED)
|
||||
|
||||
// create several commitments on a different channel and port
|
||||
for i := seq; i < 10; i++ {
|
||||
suite.chainA.App.IBCKeeper.ChannelKeeper.SetPacketCommitment(suite.chainA.GetContext(), channelA1.PortID, channelA1.ID, i, []byte("ack"))
|
||||
}
|
||||
|
||||
params = types.NewQueryPacketCommitmentsParams(channelA0.PortID, channelA1.ID, 1, 100)
|
||||
|
||||
expRes, err = codec.MarshalJSONIndent(suite.chainA.App.AppCodec(), commitments)
|
||||
suite.Require().NoError(err)
|
||||
},
|
||||
},
|
||||
{
|
||||
"success no packet commitments",
|
||||
func() {
|
||||
_, _, _, _, channelA, _ := suite.coordinator.Setup(suite.chainA, suite.chainB)
|
||||
|
||||
params = types.NewQueryPacketCommitmentsParams(channelA.PortID, channelA.ID, 1, 100)
|
||||
|
||||
expRes, err = codec.MarshalJSONIndent(suite.chainA.App.AppCodec(), []uint64{})
|
||||
suite.Require().NoError(err)
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for i, tc := range testCases {
|
||||
suite.SetupTest() // reset
|
||||
tc.setup()
|
||||
|
||||
data, err := suite.chainA.App.AppCodec().MarshalJSON(params)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
query := abci.RequestQuery{
|
||||
Path: "",
|
||||
Data: data,
|
||||
}
|
||||
|
||||
bz, err := suite.chainA.Querier(suite.chainA.GetContext(), path, query)
|
||||
|
||||
suite.Require().NoError(err, "test case %d failed: %s", i, tc.name)
|
||||
suite.Require().Equal(expRes, bz, "test case %d failed: %s", i, tc.name)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// TestQueryUnrelayedPackets tests querying unrelayed acknowledgements and unrelayed packets sends
|
||||
// on a specified channel end.
|
||||
func (suite *KeeperTestSuite) TestQueryUnrelayedAcks() {
|
||||
pathAck := []string{types.SubModuleName, types.QueryUnrelayedAcknowledgements}
|
||||
pathSend := []string{types.SubModuleName, types.QueryUnrelayedPacketSends}
|
||||
sequences := []uint64{1, 2, 3, 4, 5}
|
||||
|
||||
var (
|
||||
expResAck []byte
|
||||
expResSend []byte
|
||||
params types.QueryUnrelayedPacketsParams
|
||||
err error
|
||||
)
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
setup func()
|
||||
}{
|
||||
{
|
||||
"success",
|
||||
func() {
|
||||
_, _, _, _, channelA, _ := suite.coordinator.Setup(suite.chainA, suite.chainB)
|
||||
|
||||
unrelayedAcks := []uint64{}
|
||||
unrelayedSends := []uint64{}
|
||||
|
||||
// create acknowledgements for first 3 sequences
|
||||
for _, seq := range sequences {
|
||||
if seq < 4 {
|
||||
suite.chainA.App.IBCKeeper.ChannelKeeper.SetPacketAcknowledgement(suite.chainA.GetContext(), channelA.PortID, channelA.ID, seq, []byte("ack"))
|
||||
unrelayedAcks = append(unrelayedAcks, seq)
|
||||
} else {
|
||||
unrelayedSends = append(unrelayedSends, seq)
|
||||
}
|
||||
}
|
||||
|
||||
params = types.NewQueryUnrelayedPacketsParams(channelA.PortID, channelA.ID, sequences, 1, 100)
|
||||
|
||||
expResAck, err = codec.MarshalJSONIndent(suite.chainA.App.AppCodec(), unrelayedAcks)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
expResSend, err = codec.MarshalJSONIndent(suite.chainA.App.AppCodec(), unrelayedSends)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
},
|
||||
},
|
||||
{
|
||||
"success with multiple channels",
|
||||
func() {
|
||||
_, _, connA, connB, channelA0, _ := suite.coordinator.Setup(suite.chainA, suite.chainB)
|
||||
ctxA := suite.chainA.GetContext()
|
||||
|
||||
unrelayedAcks := []uint64{}
|
||||
unrelayedSends := []uint64{}
|
||||
|
||||
// create acknowledgements for first 3 sequences
|
||||
for _, seq := range sequences {
|
||||
if seq < 4 {
|
||||
suite.chainA.App.IBCKeeper.ChannelKeeper.SetPacketAcknowledgement(ctxA, channelA0.PortID, channelA0.ID, seq, []byte("ack"))
|
||||
unrelayedAcks = append(unrelayedAcks, seq)
|
||||
} else {
|
||||
unrelayedSends = append(unrelayedSends, seq)
|
||||
}
|
||||
}
|
||||
|
||||
// create second channel
|
||||
channelA1, _ := suite.coordinator.CreateChannel(suite.chainA, suite.chainB, connA, connB, types.UNORDERED)
|
||||
|
||||
// create acknowledgements for other sequences on different channel/port
|
||||
for _, seq := range sequences {
|
||||
if seq >= 4 {
|
||||
suite.chainA.App.IBCKeeper.ChannelKeeper.SetPacketAcknowledgement(ctxA, channelA1.PortID, channelA1.ID, seq, []byte("ack"))
|
||||
}
|
||||
}
|
||||
|
||||
params = types.NewQueryUnrelayedPacketsParams(channelA0.PortID, channelA0.ID, sequences, 1, 100)
|
||||
|
||||
expResAck, err = codec.MarshalJSONIndent(suite.chainA.App.AppCodec(), unrelayedAcks)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
expResSend, err = codec.MarshalJSONIndent(suite.chainA.App.AppCodec(), unrelayedSends)
|
||||
suite.Require().NoError(err)
|
||||
},
|
||||
},
|
||||
{
|
||||
"success no unrelayed acks",
|
||||
func() {
|
||||
_, _, _, _, channelA, _ := suite.coordinator.Setup(suite.chainA, suite.chainB)
|
||||
|
||||
// create acknowledgements for all sequences
|
||||
for _, seq := range sequences {
|
||||
suite.chainA.App.IBCKeeper.ChannelKeeper.SetPacketAcknowledgement(suite.chainA.GetContext(), channelA.PortID, channelA.ID, seq, []byte("ack"))
|
||||
}
|
||||
|
||||
params = types.NewQueryUnrelayedPacketsParams(channelA.PortID, channelA.ID, sequences, 1, 100)
|
||||
|
||||
expResSend, err = codec.MarshalJSONIndent(suite.chainA.App.AppCodec(), []uint64{})
|
||||
suite.Require().NoError(err)
|
||||
|
||||
expResAck, err = codec.MarshalJSONIndent(suite.chainA.App.AppCodec(), sequences)
|
||||
suite.Require().NoError(err)
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for i, tc := range testCases {
|
||||
suite.SetupTest() // reset
|
||||
tc.setup()
|
||||
|
||||
data, err := suite.chainA.App.AppCodec().MarshalJSON(params)
|
||||
suite.Require().NoError(err)
|
||||
|
||||
query := abci.RequestQuery{
|
||||
Path: "",
|
||||
Data: data,
|
||||
}
|
||||
|
||||
bz, err := suite.chainA.Querier(suite.chainA.GetContext(), pathAck, query)
|
||||
|
||||
suite.Require().NoError(err, "test case %d failed: %s", i, tc.name)
|
||||
suite.Require().Equal(expResAck, bz, "test case %d failed: %s", i, tc.name)
|
||||
|
||||
bz, err = suite.chainA.Querier(suite.chainA.GetContext(), pathSend, query)
|
||||
|
||||
suite.Require().NoError(err, "test case %d failed: %s", i, tc.name)
|
||||
suite.Require().Equal(expResSend, bz, "test case %d failed: %s", i, tc.name)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package channel
|
||||
|
||||
import (
|
||||
"github.com/gogo/protobuf/grpc"
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
|
@ -10,22 +11,27 @@ import (
|
|||
"github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types"
|
||||
)
|
||||
|
||||
// Name returns the IBC connection ICS name
|
||||
// Name returns the IBC channel ICS name.
|
||||
func Name() string {
|
||||
return types.SubModuleName
|
||||
}
|
||||
|
||||
// GetTxCmd returns the root tx command for the IBC connections.
|
||||
// GetTxCmd returns the root tx command for IBC channels.
|
||||
func GetTxCmd(clientCtx client.Context) *cobra.Command {
|
||||
return cli.NewTxCmd(clientCtx)
|
||||
}
|
||||
|
||||
// GetQueryCmd returns no root query command for the IBC connections.
|
||||
// GetQueryCmd returns the root query command for IBC channels.
|
||||
func GetQueryCmd(clientCtx client.Context) *cobra.Command {
|
||||
return cli.GetQueryCmd(clientCtx)
|
||||
}
|
||||
|
||||
// RegisterRESTRoutes registers the REST routes for the IBC channel
|
||||
// RegisterRESTRoutes registers the REST routes for IBC channels.
|
||||
func RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router) {
|
||||
rest.RegisterRoutes(clientCtx, rtr)
|
||||
}
|
||||
|
||||
// RegisterQueryService registers the gRPC query service for IBC channels.
|
||||
func RegisterQueryService(server grpc.Server, queryServer types.QueryServer) {
|
||||
types.RegisterQueryServer(server, queryServer)
|
||||
}
|
||||
|
|
|
@ -116,34 +116,22 @@ func (c Counterparty) ValidateBasic() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// IdentifiedChannel defines a channel with additional port and channel identifier
|
||||
// fields.
|
||||
type IdentifiedChannel struct {
|
||||
ID string `json:"id" yaml:"id"`
|
||||
PortID string `json:"port_id" yaml:"port_id"`
|
||||
State State `json:"state" yaml:"state"`
|
||||
Ordering Order `json:"ordering" yaml:"ordering"`
|
||||
Counterparty Counterparty `json:"counterparty" yaml:"counterparty"`
|
||||
ConnectionHops []string `json:"connection_hops" yaml:"connection_hops"`
|
||||
Version string `json:"version" yaml:"version "`
|
||||
}
|
||||
|
||||
// NewIdentifiedChannel creates a new IdentifiedChannel instance
|
||||
func NewIdentifiedChannel(portID, channelID string, ch Channel) IdentifiedChannel {
|
||||
return IdentifiedChannel{
|
||||
ID: channelID,
|
||||
PortID: portID,
|
||||
State: ch.State,
|
||||
Ordering: ch.Ordering,
|
||||
Counterparty: ch.Counterparty,
|
||||
ConnectionHops: ch.ConnectionHops,
|
||||
Version: ch.Version,
|
||||
PortID: portID,
|
||||
ChannelID: channelID,
|
||||
}
|
||||
}
|
||||
|
||||
// ValidateBasic performs a basic validation of the identifiers and channel fields.
|
||||
func (ic IdentifiedChannel) ValidateBasic() error {
|
||||
if err := host.ChannelIdentifierValidator(ic.ID); err != nil {
|
||||
if err := host.ChannelIdentifierValidator(ic.ChannelID); err != nil {
|
||||
return sdkerrors.Wrap(ErrInvalidChannel, err.Error())
|
||||
}
|
||||
if err := host.PortIdentifierValidator(ic.PortID); err != nil {
|
||||
|
|
|
@ -839,6 +839,59 @@ func (m *Channel) XXX_DiscardUnknown() {
|
|||
|
||||
var xxx_messageInfo_Channel proto.InternalMessageInfo
|
||||
|
||||
// IdentifiedChannel defines a channel with additional port and channel identifier
|
||||
// fields.
|
||||
type IdentifiedChannel struct {
|
||||
// current state of the channel end
|
||||
State State `protobuf:"varint,1,opt,name=state,proto3,enum=ibc.channel.State" json:"state,omitempty"`
|
||||
// whether the channel is ordered or unordered
|
||||
Ordering Order `protobuf:"varint,2,opt,name=ordering,proto3,enum=ibc.channel.Order" json:"ordering,omitempty"`
|
||||
// counterparty channel end
|
||||
Counterparty Counterparty `protobuf:"bytes,3,opt,name=counterparty,proto3" json:"counterparty"`
|
||||
// list of connection identifiers, in order, along which packets sent on this
|
||||
// channel will travel
|
||||
ConnectionHops []string `protobuf:"bytes,4,rep,name=connection_hops,json=connectionHops,proto3" json:"connection_hops,omitempty" yaml:"connection_hops"`
|
||||
// opaque channel version, which is agreed upon during the handshake
|
||||
Version string `protobuf:"bytes,5,opt,name=version,proto3" json:"version,omitempty"`
|
||||
// port identifier
|
||||
PortID string `protobuf:"bytes,6,opt,name=port_id,json=portId,proto3" json:"port_id,omitempty"`
|
||||
// channel identifier
|
||||
ChannelID string `protobuf:"bytes,7,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"`
|
||||
}
|
||||
|
||||
func (m *IdentifiedChannel) Reset() { *m = IdentifiedChannel{} }
|
||||
func (m *IdentifiedChannel) String() string { return proto.CompactTextString(m) }
|
||||
func (*IdentifiedChannel) ProtoMessage() {}
|
||||
func (*IdentifiedChannel) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_9277922ccfb7f043, []int{10}
|
||||
}
|
||||
func (m *IdentifiedChannel) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *IdentifiedChannel) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_IdentifiedChannel.Marshal(b, m, deterministic)
|
||||
} else {
|
||||
b = b[:cap(b)]
|
||||
n, err := m.MarshalToSizedBuffer(b)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return b[:n], nil
|
||||
}
|
||||
}
|
||||
func (m *IdentifiedChannel) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_IdentifiedChannel.Merge(m, src)
|
||||
}
|
||||
func (m *IdentifiedChannel) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *IdentifiedChannel) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_IdentifiedChannel.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_IdentifiedChannel proto.InternalMessageInfo
|
||||
|
||||
// Counterparty defines a channel end counterparty
|
||||
type Counterparty struct {
|
||||
// port on the counterparty chain which owns the other end of the channel.
|
||||
|
@ -851,7 +904,7 @@ func (m *Counterparty) Reset() { *m = Counterparty{} }
|
|||
func (m *Counterparty) String() string { return proto.CompactTextString(m) }
|
||||
func (*Counterparty) ProtoMessage() {}
|
||||
func (*Counterparty) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_9277922ccfb7f043, []int{10}
|
||||
return fileDescriptor_9277922ccfb7f043, []int{11}
|
||||
}
|
||||
func (m *Counterparty) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
|
@ -906,7 +959,7 @@ func (m *Packet) Reset() { *m = Packet{} }
|
|||
func (m *Packet) String() string { return proto.CompactTextString(m) }
|
||||
func (*Packet) ProtoMessage() {}
|
||||
func (*Packet) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_9277922ccfb7f043, []int{11}
|
||||
return fileDescriptor_9277922ccfb7f043, []int{12}
|
||||
}
|
||||
func (m *Packet) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
|
@ -935,6 +988,52 @@ func (m *Packet) XXX_DiscardUnknown() {
|
|||
|
||||
var xxx_messageInfo_Packet proto.InternalMessageInfo
|
||||
|
||||
// PacketAckCommitment defines the genesis type necessary to retrieve and store
|
||||
// acknowlegements.
|
||||
type PacketAckCommitment 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"`
|
||||
// packet commitment hash.
|
||||
Hash []byte `protobuf:"bytes,4,opt,name=hash,proto3" json:"hash,omitempty"`
|
||||
}
|
||||
|
||||
func (m *PacketAckCommitment) Reset() { *m = PacketAckCommitment{} }
|
||||
func (m *PacketAckCommitment) String() string { return proto.CompactTextString(m) }
|
||||
func (*PacketAckCommitment) ProtoMessage() {}
|
||||
func (*PacketAckCommitment) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_9277922ccfb7f043, []int{13}
|
||||
}
|
||||
func (m *PacketAckCommitment) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *PacketAckCommitment) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_PacketAckCommitment.Marshal(b, m, deterministic)
|
||||
} else {
|
||||
b = b[:cap(b)]
|
||||
n, err := m.MarshalToSizedBuffer(b)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return b[:n], nil
|
||||
}
|
||||
}
|
||||
func (m *PacketAckCommitment) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_PacketAckCommitment.Merge(m, src)
|
||||
}
|
||||
func (m *PacketAckCommitment) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *PacketAckCommitment) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_PacketAckCommitment.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_PacketAckCommitment proto.InternalMessageInfo
|
||||
|
||||
func init() {
|
||||
proto.RegisterEnum("ibc.channel.State", State_name, State_value)
|
||||
proto.RegisterEnum("ibc.channel.Order", Order_name, Order_value)
|
||||
|
@ -948,89 +1047,97 @@ func init() {
|
|||
proto.RegisterType((*MsgTimeout)(nil), "ibc.channel.MsgTimeout")
|
||||
proto.RegisterType((*MsgAcknowledgement)(nil), "ibc.channel.MsgAcknowledgement")
|
||||
proto.RegisterType((*Channel)(nil), "ibc.channel.Channel")
|
||||
proto.RegisterType((*IdentifiedChannel)(nil), "ibc.channel.IdentifiedChannel")
|
||||
proto.RegisterType((*Counterparty)(nil), "ibc.channel.Counterparty")
|
||||
proto.RegisterType((*Packet)(nil), "ibc.channel.Packet")
|
||||
proto.RegisterType((*PacketAckCommitment)(nil), "ibc.channel.PacketAckCommitment")
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("ibc/channel/channel.proto", fileDescriptor_9277922ccfb7f043) }
|
||||
|
||||
var fileDescriptor_9277922ccfb7f043 = []byte{
|
||||
// 1196 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x58, 0xcd, 0x6e, 0xdb, 0x46,
|
||||
0x10, 0x16, 0xf5, 0x6b, 0x8d, 0x64, 0x5b, 0x5e, 0xff, 0x44, 0x56, 0x5c, 0x51, 0x20, 0x7a, 0x10,
|
||||
0x02, 0x58, 0xaa, 0x1d, 0xb7, 0x05, 0x7c, 0xaa, 0xfe, 0x82, 0x08, 0x8d, 0x25, 0x63, 0x2d, 0x17,
|
||||
0x68, 0x2e, 0x02, 0x4d, 0x6d, 0x64, 0x42, 0x16, 0xa9, 0x92, 0xb4, 0x13, 0xbd, 0x41, 0x60, 0xa0,
|
||||
0x69, 0xef, 0x85, 0x81, 0x02, 0x3d, 0xf5, 0x09, 0xfa, 0x0a, 0x01, 0x7a, 0x68, 0x0e, 0x3d, 0x14,
|
||||
0x2d, 0xc0, 0x16, 0xf6, 0x1b, 0xe8, 0xd8, 0x53, 0xc1, 0xdd, 0xa5, 0x44, 0xca, 0x69, 0x0e, 0x56,
|
||||
0x01, 0x35, 0x27, 0xee, 0xcc, 0x7c, 0x33, 0x3b, 0xf3, 0xcd, 0xfe, 0x81, 0xb0, 0xa9, 0x9e, 0x28,
|
||||
0x45, 0xe5, 0x54, 0xd6, 0x34, 0x72, 0xe6, 0x7e, 0x0b, 0x03, 0x43, 0xb7, 0x74, 0x94, 0x50, 0x4f,
|
||||
0x94, 0x02, 0x57, 0x65, 0xd6, 0xba, 0x7a, 0x57, 0xa7, 0xfa, 0xa2, 0x33, 0x62, 0x10, 0xe9, 0x9b,
|
||||
0x20, 0xa0, 0x03, 0xb3, 0x5b, 0x61, 0xa0, 0xe6, 0x80, 0x68, 0x75, 0x4d, 0xb5, 0xd0, 0xc7, 0x10,
|
||||
0x1b, 0xe8, 0x86, 0xd5, 0x56, 0x3b, 0x69, 0x21, 0x27, 0xe4, 0xe3, 0xe5, 0xad, 0x6b, 0x5b, 0x8c,
|
||||
0x1e, 0xea, 0x86, 0x55, 0xaf, 0x8e, 0x6c, 0x71, 0x69, 0x28, 0xf7, 0xcf, 0xf6, 0x25, 0x0e, 0x91,
|
||||
0x70, 0xd4, 0x19, 0xd5, 0x3b, 0xa8, 0x04, 0xc0, 0xa7, 0x73, 0x3c, 0x83, 0xd4, 0x53, 0xba, 0xb6,
|
||||
0xc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c3, 0x40, 0xfc,
|
||||
0xb6, 0xe1, 0x40, 0xb4, 0x06, 0x11, 0x9a, 0x1a, 0xe5, 0x2e, 0x89, 0x99, 0x70, 0xab, 0xba, 0xd0,
|
||||
0x9d, 0xaa, 0x9b, 0xf9, 0x3e, 0xff, 0x31, 0x08, 0x70, 0x60, 0x76, 0x5b, 0x6a, 0x9f, 0xe8, 0xe7,
|
||||
0xff, 0x93, 0xf2, 0x3e, 0x07, 0xa4, 0x91, 0x17, 0x56, 0xdb, 0x24, 0x5f, 0x9d, 0x13, 0x4d, 0x21,
|
||||
0x6d, 0x83, 0x28, 0x17, 0xbc, 0xfd, 0x1f, 0x8c, 0x6c, 0x71, 0x93, 0x45, 0xb8, 0x8d, 0x91, 0x70,
|
||||
0xca, 0x51, 0x1e, 0x71, 0x1d, 0x26, 0xca, 0xc5, 0x7f, 0xb9, 0x12, 0x5e, 0xb1, 0xd7, 0x60, 0x49,
|
||||
0xe9, 0x69, 0xfa, 0xf3, 0x33, 0xd2, 0xe9, 0x92, 0x3e, 0xd1, 0xee, 0xc4, 0x59, 0x1e, 0x96, 0x65,
|
||||
0x7f, 0x14, 0xce, 0xde, 0xb4, 0x7a, 0xc2, 0x6e, 0xe8, 0x5d, 0xec, 0xce, 0x69, 0x6b, 0x7c, 0x1d,
|
||||
0x84, 0x18, 0x3f, 0x05, 0x50, 0x1e, 0x22, 0xa6, 0x25, 0x5b, 0x84, 0x92, 0xb0, 0xb4, 0x8b, 0x7c,
|
||||
0x24, 0x1c, 0x39, 0x16, 0xcc, 0x00, 0xa8, 0x00, 0x0b, 0xba, 0xd1, 0x21, 0x86, 0xaa, 0x75, 0x69,
|
||||
0xd5, 0xd3, 0xe0, 0xa6, 0x63, 0xc4, 0x63, 0x0c, 0xaa, 0x40, 0xd2, 0x7b, 0x9d, 0xf3, 0x77, 0xde,
|
||||
0xa6, 0xff, 0x9d, 0xe7, 0x01, 0x70, 0xae, 0x7d, 0x4e, 0xa8, 0x02, 0xcb, 0x8a, 0xae, 0x69, 0x44,
|
||||
0xb1, 0x54, 0x5d, 0x6b, 0x9f, 0xea, 0x03, 0x33, 0x1d, 0xce, 0x85, 0xf2, 0xf1, 0x72, 0x66, 0x64,
|
||||
0x8b, 0x1b, 0xee, 0x5b, 0xc2, 0x07, 0x90, 0xf0, 0xd2, 0x44, 0xf3, 0x58, 0x1f, 0x98, 0x28, 0x0d,
|
||||
0x31, 0xf7, 0x21, 0xe2, 0x70, 0x17, 0xc7, 0xae, 0xb8, 0x1f, 0x7e, 0xf9, 0xbd, 0x18, 0x90, 0x5e,
|
||||
0x09, 0x90, 0xf4, 0x66, 0x32, 0xbf, 0x23, 0x97, 0x27, 0xf4, 0x67, 0x08, 0xa2, 0xfc, 0xe0, 0xca,
|
||||
0xc0, 0x82, 0xbb, 0x57, 0x68, 0x2e, 0x61, 0x3c, 0x96, 0xd1, 0xa7, 0x90, 0x30, 0xf5, 0x73, 0x43,
|
||||
0x21, 0x6d, 0x27, 0x01, 0x3e, 0xe1, 0xc6, 0xc8, 0x16, 0x11, 0x9b, 0xc3, 0x63, 0x94, 0x30, 0x30,
|
||||
0xc9, 0x29, 0x02, 0x7d, 0x06, 0x4b, 0xdc, 0xe6, 0x7d, 0x84, 0xc7, 0xcb, 0x9b, 0x23, 0x5b, 0x5c,
|
||||
0xf7, 0xf9, 0x72, 0xbb, 0x84, 0x17, 0x99, 0xc2, 0x5d, 0x36, 0x8f, 0x20, 0xd5, 0x21, 0xa6, 0xa5,
|
||||
0x6a, 0x32, 0xe5, 0x9d, 0xce, 0xcf, 0x5e, 0xe1, 0xf7, 0x47, 0xb6, 0x78, 0x8f, 0xc5, 0x98, 0x46,
|
||||
0x48, 0x78, 0xd9, 0xa3, 0xa2, 0x99, 0x34, 0x61, 0xd5, 0x8b, 0x72, 0xd3, 0xa1, 0x6d, 0x2a, 0x67,
|
||||
0x47, 0xb6, 0x98, 0xb9, 0x1d, 0x6a, 0x9c, 0x13, 0xf2, 0x68, 0xdd, 0xc4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x73, 0x88, 0xd0, 0x9d, 0x8e, 0x3e, 0x84,
|
||||
0x8d, 0x26, 0xae, 0xd6, 0x70, 0xbb, 0xd1, 0x6c, 0xd4, 0xa6, 0xf2, 0xa5, 0x21, 0x1d, 0x3d, 0x92,
|
||||
0x60, 0x99, 0xa1, 0x8e, 0x1b, 0xf4, 0x5b, 0xab, 0xa6, 0x84, 0xcc, 0xe2, 0xe5, 0x55, 0x2e, 0x3e,
|
||||
0x56, 0x38, 0x09, 0x33, 0x8c, 0x8b, 0xe0, 0x09, 0x73, 0x91, 0x4d, 0x5c, 0x3e, 0x78, 0x7d, 0x9d,
|
||||
0x15, 0xde, 0x5c, 0x67, 0x85, 0xbf, 0xae, 0xb3, 0xc2, 0xb7, 0x37, 0xd9, 0xc0, 0x9b, 0x9b, 0x6c,
|
||||
0xe0, 0xb7, 0x9b, 0x6c, 0xe0, 0xe9, 0xc3, 0x77, 0x1e, 0x83, 0x2f, 0x8a, 0xea, 0x89, 0x52, 0xfc,
|
||||
0x68, 0x6f, 0xdb, 0xfd, 0x9d, 0x40, 0xcf, 0xc5, 0x93, 0x28, 0xfd, 0x55, 0xf0, 0xf0, 0x9f, 0x00,
|
||||
0x00, 0x00, 0xff, 0xff, 0x39, 0x21, 0x50, 0x48, 0x6a, 0x10, 0x00, 0x00,
|
||||
// 1281 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xec, 0x58, 0x4f, 0x6f, 0x1b, 0x45,
|
||||
0x14, 0xf7, 0xfa, 0x6f, 0xfc, 0xf2, 0xcf, 0x99, 0xa4, 0xa9, 0xe3, 0x16, 0xaf, 0xb5, 0x70, 0xb0,
|
||||
0x2a, 0xea, 0xd0, 0x3f, 0x80, 0xd4, 0x13, 0xb6, 0xe3, 0xaa, 0x2b, 0x1a, 0x3b, 0x9a, 0xb8, 0x48,
|
||||
0xf4, 0x62, 0x6d, 0x76, 0xa7, 0xf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x25, 0xca,
|
||||
0xd9, 0x5a, 0x61, 0xe4, 0xc9, 0x9b, 0xc1, 0x5b, 0x22, 0x02, 0x50, 0xf0, 0xca, 0x44, 0x73, 0x8f,
|
||||
0x0e, 0x1d, 0x94, 0x87, 0x4c, 0xf0, 0x10, 0xf1, 0xb9, 0xcb, 0xe2, 0x40, 0xbc, 0x93, 0x7c, 0xf6,
|
||||
0xb5, 0x1c, 0x53, 0xfe, 0x88, 0xc3, 0x9a, 0x6a, 0x10, 0xcb, 0x35, 0x1f, 0x99, 0xc4, 0xf8, 0x9f,
|
||||
0x19, 0xff, 0xd5, 0xf5, 0xf6, 0x64, 0xea, 0xa4, 0xd9, 0xec, 0x80, 0xc9, 0xd4, 0x19, 0xcf, 0x98,
|
||||
0x77, 0x23, 0x33, 0x26, 0xc3, 0x70, 0xcb, 0x91, 0x19, 0x13, 0x1a, 0x27, 0x82, 0xec, 0xe7, 0x12,
|
||||
0x2c, 0x85, 0x93, 0x9b, 0xdf, 0x7c, 0x13, 0x01, 0xfd, 0x96, 0x80, 0xb4, 0x98, 0x12, 0x05, 0x58,
|
||||
0x08, 0x1a, 0x13, 0x8b, 0x25, 0x89, 0xc7, 0x32, 0xfa, 0x10, 0x16, 0x1d, 0x7a, 0x64, 0xeb, 0xa4,
|
||||
0xe3, 0x07, 0x20, 0x0e, 0xdc, 0x1c, 0x79, 0x32, 0xe2, 0x67, 0x84, 0x8c, 0x0a, 0x06, 0x2e, 0xf9,
|
||||
0x49, 0xa0, 0x8f, 0x60, 0x45, 0xd8, 0xc2, 0xff, 0xf1, 0x64, 0x6b, 0x5b, 0x23, 0x4f, 0xbe, 0x14,
|
||||
0xd9, 0x2b, 0xec, 0x0a, 0x5e, 0xe6, 0x8a, 0xe0, 0x26, 0xde, 0x85, 0x9c, 0x41, 0x1c, 0xd7, 0xb4,
|
||||
0x34, 0x56, 0x4a, 0x76, 0x3e, 0xff, 0x97, 0xe7, 0xca, 0xc8, 0x93, 0x2f, 0x73, 0x1f, 0xd3, 0x08,
|
||||
0x05, 0xaf, 0x86, 0x54, 0x2c, 0x92, 0x16, 0xac, 0x87, 0x51, 0x41, 0x38, 0xac, 0xf2, 0xb5, 0xe2,
|
||||
0xc8, 0x93, 0x0b, 0xe7, 0x5d, 0x8d, 0x63, 0x42, 0x21, 0x6d, 0x10, 0x18, 0x82, 0xa4, 0xa1, 0xb9,
|
||||
0x1a, 0x7f, 0x29, 0x63, 0xb6, 0xf6, 0xd3, 0x75, 0xf9, 0x54, 0x0a, 0xba, 0x5c, 0x86, 0x75, 0xb9,
|
||||
0x50, 0xba, 0x51, 0xbb, 0x82, 0x97, 0x85, 0x62, 0xdc, 0xe9, 0xd6, 0x02, 0x84, 0xff, 0x75, 0x5c,
|
||||
0x6d, 0x30, 0xcc, 0x2f, 0x30, 0x27, 0x57, 0x47, 0x9e, 0x9c, 0x8f, 0x3a, 0x19, 0x43, 0x14, 0x9c,
|
||||
0x13, 0xba, 0x76, 0xa0, 0x12, 0x15, 0xfe, 0x5e, 0x82, 0x75, 0x5e, 0xe1, 0xaa, 0xde, 0xaf, 0xd3,
|
||||
0xc1, 0xc0, 0x74, 0x59, 0x93, 0x9e, 0xdf, 0xcb, 0x2a, 0x7c, 0xd1, 0x12, 0x53, 0x17, 0x0d, 0x41,
|
||||
0xb2, 0xa7, 0x39, 0x3d, 0xfe, 0x46, 0xc0, 0x6c, 0xcd, 0xf3, 0xb8, 0xf6, 0x9d, 0x04, 0x29, 0xd6,
|
||||
0x78, 0xd0, 0x07, 0x20, 0xef, 0xb7, 0xab, 0xed, 0x46, 0xe7, 0x41, 0x53, 0x6d, 0xaa, 0x6d, 0xb5,
|
||||
0x7a, 0x5f, 0x7d, 0xd8, 0xd8, 0xe9, 0x3c, 0x68, 0xee, 0xef, 0x35, 0xea, 0xea, 0x5d, 0xb5, 0xb1,
|
||||
0x93, 0x8b, 0x15, 0xd6, 0x4e, 0x4e, 0x4b, 0xcb, 0x11, 0x00, 0xca, 0x03, 0xf0, 0x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0x95, 0x61, 0xbf, 0x9f, 0x12, 0x00,
|
||||
0x00,
|
||||
}
|
||||
|
||||
func (m *MsgChannelOpenInit) Marshal() (dAtA []byte, err error) {
|
||||
|
@ -1606,6 +1713,79 @@ func (m *Channel) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
|||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func (m *IdentifiedChannel) Marshal() (dAtA []byte, err error) {
|
||||
size := m.Size()
|
||||
dAtA = make([]byte, size)
|
||||
n, err := m.MarshalToSizedBuffer(dAtA[:size])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return dAtA[:n], nil
|
||||
}
|
||||
|
||||
func (m *IdentifiedChannel) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *IdentifiedChannel) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
if len(m.ChannelID) > 0 {
|
||||
i -= len(m.ChannelID)
|
||||
copy(dAtA[i:], m.ChannelID)
|
||||
i = encodeVarintChannel(dAtA, i, uint64(len(m.ChannelID)))
|
||||
i--
|
||||
dAtA[i] = 0x3a
|
||||
}
|
||||
if len(m.PortID) > 0 {
|
||||
i -= len(m.PortID)
|
||||
copy(dAtA[i:], m.PortID)
|
||||
i = encodeVarintChannel(dAtA, i, uint64(len(m.PortID)))
|
||||
i--
|
||||
dAtA[i] = 0x32
|
||||
}
|
||||
if len(m.Version) > 0 {
|
||||
i -= len(m.Version)
|
||||
copy(dAtA[i:], m.Version)
|
||||
i = encodeVarintChannel(dAtA, i, uint64(len(m.Version)))
|
||||
i--
|
||||
dAtA[i] = 0x2a
|
||||
}
|
||||
if len(m.ConnectionHops) > 0 {
|
||||
for iNdEx := len(m.ConnectionHops) - 1; iNdEx >= 0; iNdEx-- {
|
||||
i -= len(m.ConnectionHops[iNdEx])
|
||||
copy(dAtA[i:], m.ConnectionHops[iNdEx])
|
||||
i = encodeVarintChannel(dAtA, i, uint64(len(m.ConnectionHops[iNdEx])))
|
||||
i--
|
||||
dAtA[i] = 0x22
|
||||
}
|
||||
}
|
||||
{
|
||||
size, err := m.Counterparty.MarshalToSizedBuffer(dAtA[:i])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
i -= size
|
||||
i = encodeVarintChannel(dAtA, i, uint64(size))
|
||||
}
|
||||
i--
|
||||
dAtA[i] = 0x1a
|
||||
if m.Ordering != 0 {
|
||||
i = encodeVarintChannel(dAtA, i, uint64(m.Ordering))
|
||||
i--
|
||||
dAtA[i] = 0x10
|
||||
}
|
||||
if m.State != 0 {
|
||||
i = encodeVarintChannel(dAtA, i, uint64(m.State))
|
||||
i--
|
||||
dAtA[i] = 0x8
|
||||
}
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func (m *Counterparty) Marshal() (dAtA []byte, err error) {
|
||||
size := m.Size()
|
||||
dAtA = make([]byte, size)
|
||||
|
@ -1716,6 +1896,55 @@ func (m *Packet) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
|||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func (m *PacketAckCommitment) Marshal() (dAtA []byte, err error) {
|
||||
size := m.Size()
|
||||
dAtA = make([]byte, size)
|
||||
n, err := m.MarshalToSizedBuffer(dAtA[:size])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return dAtA[:n], nil
|
||||
}
|
||||
|
||||
func (m *PacketAckCommitment) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *PacketAckCommitment) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
if len(m.Hash) > 0 {
|
||||
i -= len(m.Hash)
|
||||
copy(dAtA[i:], m.Hash)
|
||||
i = encodeVarintChannel(dAtA, i, uint64(len(m.Hash)))
|
||||
i--
|
||||
dAtA[i] = 0x22
|
||||
}
|
||||
if m.Sequence != 0 {
|
||||
i = encodeVarintChannel(dAtA, i, uint64(m.Sequence))
|
||||
i--
|
||||
dAtA[i] = 0x18
|
||||
}
|
||||
if len(m.ChannelID) > 0 {
|
||||
i -= len(m.ChannelID)
|
||||
copy(dAtA[i:], m.ChannelID)
|
||||
i = encodeVarintChannel(dAtA, i, uint64(len(m.ChannelID)))
|
||||
i--
|
||||
dAtA[i] = 0x12
|
||||
}
|
||||
if len(m.PortID) > 0 {
|
||||
i -= len(m.PortID)
|
||||
copy(dAtA[i:], m.PortID)
|
||||
i = encodeVarintChannel(dAtA, i, uint64(len(m.PortID)))
|
||||
i--
|
||||
dAtA[i] = 0xa
|
||||
}
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func encodeVarintChannel(dAtA []byte, offset int, v uint64) int {
|
||||
offset -= sovChannel(v)
|
||||
base := offset
|
||||
|
@ -1993,6 +2222,41 @@ func (m *Channel) Size() (n int) {
|
|||
return n
|
||||
}
|
||||
|
||||
func (m *IdentifiedChannel) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
var l int
|
||||
_ = l
|
||||
if m.State != 0 {
|
||||
n += 1 + sovChannel(uint64(m.State))
|
||||
}
|
||||
if m.Ordering != 0 {
|
||||
n += 1 + sovChannel(uint64(m.Ordering))
|
||||
}
|
||||
l = m.Counterparty.Size()
|
||||
n += 1 + l + sovChannel(uint64(l))
|
||||
if len(m.ConnectionHops) > 0 {
|
||||
for _, s := range m.ConnectionHops {
|
||||
l = len(s)
|
||||
n += 1 + l + sovChannel(uint64(l))
|
||||
}
|
||||
}
|
||||
l = len(m.Version)
|
||||
if l > 0 {
|
||||
n += 1 + l + sovChannel(uint64(l))
|
||||
}
|
||||
l = len(m.PortID)
|
||||
if l > 0 {
|
||||
n += 1 + l + sovChannel(uint64(l))
|
||||
}
|
||||
l = len(m.ChannelID)
|
||||
if l > 0 {
|
||||
n += 1 + l + sovChannel(uint64(l))
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (m *Counterparty) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
|
@ -2048,6 +2312,30 @@ func (m *Packet) Size() (n int) {
|
|||
return n
|
||||
}
|
||||
|
||||
func (m *PacketAckCommitment) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
var l int
|
||||
_ = l
|
||||
l = len(m.PortID)
|
||||
if l > 0 {
|
||||
n += 1 + l + sovChannel(uint64(l))
|
||||
}
|
||||
l = len(m.ChannelID)
|
||||
if l > 0 {
|
||||
n += 1 + l + sovChannel(uint64(l))
|
||||
}
|
||||
if m.Sequence != 0 {
|
||||
n += 1 + sovChannel(uint64(m.Sequence))
|
||||
}
|
||||
l = len(m.Hash)
|
||||
if l > 0 {
|
||||
n += 1 + l + sovChannel(uint64(l))
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func sovChannel(x uint64) (n int) {
|
||||
return (math_bits.Len64(x|1) + 6) / 7
|
||||
}
|
||||
|
@ -4062,6 +4350,258 @@ func (m *Channel) Unmarshal(dAtA []byte) error {
|
|||
}
|
||||
return nil
|
||||
}
|
||||
func (m *IdentifiedChannel) Unmarshal(dAtA []byte) error {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
for iNdEx < l {
|
||||
preIndex := iNdEx
|
||||
var wire uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowChannel
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
wire |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
fieldNum := int32(wire >> 3)
|
||||
wireType := int(wire & 0x7)
|
||||
if wireType == 4 {
|
||||
return fmt.Errorf("proto: IdentifiedChannel: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: IdentifiedChannel: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
case 1:
|
||||
if wireType != 0 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field State", wireType)
|
||||
}
|
||||
m.State = 0
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowChannel
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
m.State |= State(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
case 2:
|
||||
if wireType != 0 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Ordering", wireType)
|
||||
}
|
||||
m.Ordering = 0
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowChannel
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
m.Ordering |= Order(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
case 3:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Counterparty", wireType)
|
||||
}
|
||||
var msglen int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowChannel
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
msglen |= int(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if msglen < 0 {
|
||||
return ErrInvalidLengthChannel
|
||||
}
|
||||
postIndex := iNdEx + msglen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthChannel
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
if err := m.Counterparty.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||
return err
|
||||
}
|
||||
iNdEx = postIndex
|
||||
case 4:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field ConnectionHops", wireType)
|
||||
}
|
||||
var stringLen uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowChannel
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
stringLen |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
intStringLen := int(stringLen)
|
||||
if intStringLen < 0 {
|
||||
return ErrInvalidLengthChannel
|
||||
}
|
||||
postIndex := iNdEx + intStringLen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthChannel
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.ConnectionHops = append(m.ConnectionHops, string(dAtA[iNdEx:postIndex]))
|
||||
iNdEx = postIndex
|
||||
case 5:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Version", wireType)
|
||||
}
|
||||
var stringLen uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowChannel
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
stringLen |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
intStringLen := int(stringLen)
|
||||
if intStringLen < 0 {
|
||||
return ErrInvalidLengthChannel
|
||||
}
|
||||
postIndex := iNdEx + intStringLen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthChannel
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.Version = string(dAtA[iNdEx:postIndex])
|
||||
iNdEx = postIndex
|
||||
case 6:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field PortID", wireType)
|
||||
}
|
||||
var stringLen uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowChannel
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
stringLen |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
intStringLen := int(stringLen)
|
||||
if intStringLen < 0 {
|
||||
return ErrInvalidLengthChannel
|
||||
}
|
||||
postIndex := iNdEx + intStringLen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthChannel
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.PortID = string(dAtA[iNdEx:postIndex])
|
||||
iNdEx = postIndex
|
||||
case 7:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field ChannelID", wireType)
|
||||
}
|
||||
var stringLen uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowChannel
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
stringLen |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
intStringLen := int(stringLen)
|
||||
if intStringLen < 0 {
|
||||
return ErrInvalidLengthChannel
|
||||
}
|
||||
postIndex := iNdEx + intStringLen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthChannel
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.ChannelID = string(dAtA[iNdEx:postIndex])
|
||||
iNdEx = postIndex
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipChannel(dAtA[iNdEx:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if skippy < 0 {
|
||||
return ErrInvalidLengthChannel
|
||||
}
|
||||
if (iNdEx + skippy) < 0 {
|
||||
return ErrInvalidLengthChannel
|
||||
}
|
||||
if (iNdEx + skippy) > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
iNdEx += skippy
|
||||
}
|
||||
}
|
||||
|
||||
if iNdEx > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (m *Counterparty) Unmarshal(dAtA []byte) error {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
|
@ -4451,6 +4991,176 @@ func (m *Packet) Unmarshal(dAtA []byte) error {
|
|||
}
|
||||
return nil
|
||||
}
|
||||
func (m *PacketAckCommitment) Unmarshal(dAtA []byte) error {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
for iNdEx < l {
|
||||
preIndex := iNdEx
|
||||
var wire uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowChannel
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
wire |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
fieldNum := int32(wire >> 3)
|
||||
wireType := int(wire & 0x7)
|
||||
if wireType == 4 {
|
||||
return fmt.Errorf("proto: PacketAckCommitment: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: PacketAckCommitment: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
case 1:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field PortID", wireType)
|
||||
}
|
||||
var stringLen uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowChannel
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
stringLen |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
intStringLen := int(stringLen)
|
||||
if intStringLen < 0 {
|
||||
return ErrInvalidLengthChannel
|
||||
}
|
||||
postIndex := iNdEx + intStringLen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthChannel
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.PortID = string(dAtA[iNdEx:postIndex])
|
||||
iNdEx = postIndex
|
||||
case 2:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field ChannelID", wireType)
|
||||
}
|
||||
var stringLen uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowChannel
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
stringLen |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
intStringLen := int(stringLen)
|
||||
if intStringLen < 0 {
|
||||
return ErrInvalidLengthChannel
|
||||
}
|
||||
postIndex := iNdEx + intStringLen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthChannel
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.ChannelID = string(dAtA[iNdEx:postIndex])
|
||||
iNdEx = postIndex
|
||||
case 3:
|
||||
if wireType != 0 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Sequence", wireType)
|
||||
}
|
||||
m.Sequence = 0
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowChannel
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
m.Sequence |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
case 4:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Hash", wireType)
|
||||
}
|
||||
var byteLen int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowChannel
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
byteLen |= int(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if byteLen < 0 {
|
||||
return ErrInvalidLengthChannel
|
||||
}
|
||||
postIndex := iNdEx + byteLen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthChannel
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.Hash = append(m.Hash[:0], dAtA[iNdEx:postIndex]...)
|
||||
if m.Hash == nil {
|
||||
m.Hash = []byte{}
|
||||
}
|
||||
iNdEx = postIndex
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipChannel(dAtA[iNdEx:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if skippy < 0 {
|
||||
return ErrInvalidLengthChannel
|
||||
}
|
||||
if (iNdEx + skippy) < 0 {
|
||||
return ErrInvalidLengthChannel
|
||||
}
|
||||
if (iNdEx + skippy) > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
iNdEx += skippy
|
||||
}
|
||||
}
|
||||
|
||||
if iNdEx > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func skipChannel(dAtA []byte) (n int, err error) {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
|
|
|
@ -7,15 +7,6 @@ import (
|
|||
host "github.com/cosmos/cosmos-sdk/x/ibc/24-host"
|
||||
)
|
||||
|
||||
// PacketAckCommitment defines the genesis type necessary to retrieve and store
|
||||
// acknowlegements.
|
||||
type PacketAckCommitment struct {
|
||||
PortID string `json:"port_id" yaml:"port_id"`
|
||||
ChannelID string `json:"channel_id" yaml:"channel_id"`
|
||||
Sequence uint64 `json:"sequence" yaml:"sequence"`
|
||||
Hash []byte `json:"hash" yaml:"hash"`
|
||||
}
|
||||
|
||||
// NewPacketAckCommitment creates a new PacketAckCommitment instance.
|
||||
func NewPacketAckCommitment(portID, channelID string, seq uint64, hash []byte) PacketAckCommitment {
|
||||
return PacketAckCommitment{
|
||||
|
|
|
@ -3,8 +3,6 @@ package types
|
|||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/tendermint/tendermint/crypto/merkle"
|
||||
|
||||
commitmenttypes "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/types"
|
||||
host "github.com/cosmos/cosmos-sdk/x/ibc/24-host"
|
||||
)
|
||||
|
@ -20,153 +18,46 @@ const (
|
|||
QueryUnrelayedPacketSends = "unrelayed-packet-sends"
|
||||
)
|
||||
|
||||
// ChannelResponse defines the client query response for a channel which also
|
||||
// includes a proof,its path and the height from which the proof was retrieved.
|
||||
type ChannelResponse struct {
|
||||
Channel IdentifiedChannel `json:"channel" yaml:"channel"`
|
||||
Proof commitmenttypes.MerkleProof `json:"proof,omitempty" yaml:"proof,omitempty"`
|
||||
ProofPath commitmenttypes.MerklePath `json:"proof_path,omitempty" yaml:"proof_path,omitempty"`
|
||||
ProofHeight uint64 `json:"proof_height,omitempty" yaml:"proof_height,omitempty"`
|
||||
}
|
||||
|
||||
// NewChannelResponse creates a new ChannelResponse instance
|
||||
func NewChannelResponse(
|
||||
portID, channelID string, channel Channel, proof *merkle.Proof, height int64,
|
||||
) ChannelResponse {
|
||||
return ChannelResponse{
|
||||
|
||||
Channel: NewIdentifiedChannel(portID, channelID, channel),
|
||||
Proof: commitmenttypes.MerkleProof{Proof: proof},
|
||||
ProofPath: commitmenttypes.NewMerklePath(strings.Split(host.ChannelPath(portID, channelID), "/")),
|
||||
// NewQueryChannelResponse creates a new QueryChannelResponse instance
|
||||
func NewQueryChannelResponse(portID, channelID string, channel Channel, proof []byte, height int64) *QueryChannelResponse {
|
||||
path := commitmenttypes.NewMerklePath(strings.Split(host.ChannelPath(portID, channelID), "/"))
|
||||
return &QueryChannelResponse{
|
||||
Channel: &channel,
|
||||
Proof: proof,
|
||||
ProofPath: path.Pretty(),
|
||||
ProofHeight: uint64(height),
|
||||
}
|
||||
}
|
||||
|
||||
// QueryAllChannelsParams defines the parameters necessary for querying for all
|
||||
// channels.
|
||||
type QueryAllChannelsParams struct {
|
||||
Page int `json:"page" yaml:"page"`
|
||||
Limit int `json:"limit" yaml:"limit"`
|
||||
}
|
||||
|
||||
// NewQueryAllChannelsParams creates a new QueryAllChannelsParams instance.
|
||||
func NewQueryAllChannelsParams(page, limit int) QueryAllChannelsParams {
|
||||
return QueryAllChannelsParams{
|
||||
Page: page,
|
||||
Limit: limit,
|
||||
}
|
||||
}
|
||||
|
||||
// QueryConnectionChannelsParams defines the parameters necessary for querying
|
||||
// for all channels associated with a given connection.
|
||||
type QueryConnectionChannelsParams struct {
|
||||
Connection string `json:"connection" yaml:"connection"`
|
||||
Page int `json:"page" yaml:"page"`
|
||||
Limit int `json:"limit" yaml:"limit"`
|
||||
}
|
||||
|
||||
// NewQueryConnectionChannelsParams creates a new QueryConnectionChannelsParams instance.
|
||||
func NewQueryConnectionChannelsParams(connection string, page, limit int) QueryConnectionChannelsParams {
|
||||
return QueryConnectionChannelsParams{
|
||||
Connection: connection,
|
||||
Page: page,
|
||||
Limit: limit,
|
||||
}
|
||||
}
|
||||
|
||||
// QueryPacketCommitmentsParams defines the parameters necessary for querying
|
||||
// all packet commitments at an associated port ID and channel ID.
|
||||
type QueryPacketCommitmentsParams struct {
|
||||
PortID string `json:"port_id" yaml:"port_id"`
|
||||
ChannelID string `json:"channel_id" yaml:"channel_id"`
|
||||
Page int `json:"page" yaml:"page"`
|
||||
Limit int `json:"limit" yaml:"limit"`
|
||||
}
|
||||
|
||||
// NewQueryPacketCommitmentsParams creates a new QueryPacketCommitmentsParams instance.
|
||||
func NewQueryPacketCommitmentsParams(portID, channelID string, page, limit int) QueryPacketCommitmentsParams {
|
||||
return QueryPacketCommitmentsParams{
|
||||
PortID: portID,
|
||||
ChannelID: channelID,
|
||||
Page: page,
|
||||
Limit: limit,
|
||||
}
|
||||
}
|
||||
|
||||
// QueryUnrelayedPacketsParams defines the parameters necessary for querying
|
||||
// unrelayed packets at an associated port ID and channel ID.
|
||||
type QueryUnrelayedPacketsParams struct {
|
||||
PortID string `json:"port_id" yaml:"port_id"`
|
||||
ChannelID string `json:"channel_id" yaml:"channel_id"`
|
||||
Sequences []uint64 `json:"sequences" yaml:"sequences"`
|
||||
Page int `json:"page" yaml:"page"`
|
||||
Limit int `json:"limit" yaml:"limit"`
|
||||
}
|
||||
|
||||
// NewQueryUnrealyedPacketsParams creates a new QueryUnrelayedPacketsParams instance.
|
||||
func NewQueryUnrelayedPacketsParams(portID, channelID string, sequences []uint64, page, limit int) QueryUnrelayedPacketsParams {
|
||||
return QueryUnrelayedPacketsParams{
|
||||
PortID: portID,
|
||||
ChannelID: channelID,
|
||||
Sequences: sequences,
|
||||
Page: page,
|
||||
Limit: limit,
|
||||
}
|
||||
}
|
||||
|
||||
// PacketResponse defines the client query response for a packet which also
|
||||
// includes a proof, its path and the height form which the proof was retrieved
|
||||
type PacketResponse struct {
|
||||
Packet Packet `json:"packet" yaml:"packet"`
|
||||
Proof commitmenttypes.MerkleProof `json:"proof,omitempty" yaml:"proof,omitempty"`
|
||||
ProofPath commitmenttypes.MerklePath `json:"proof_path,omitempty" yaml:"proof_path,omitempty"`
|
||||
ProofHeight uint64 `json:"proof_height,omitempty" yaml:"proof_height,omitempty"`
|
||||
}
|
||||
|
||||
// NewPacketResponse creates a new PacketResponswe instance
|
||||
func NewPacketResponse(
|
||||
portID, channelID string, sequence uint64, packet Packet, proof *merkle.Proof, height int64,
|
||||
) PacketResponse {
|
||||
return PacketResponse{
|
||||
Packet: packet,
|
||||
Proof: commitmenttypes.MerkleProof{Proof: proof},
|
||||
ProofPath: commitmenttypes.NewMerklePath(strings.Split(host.PacketCommitmentPath(portID, channelID, sequence), "/")),
|
||||
// NewQueryPacketCommitmentResponse creates a new QueryPacketCommitmentResponse instance
|
||||
func NewQueryPacketCommitmentResponse(
|
||||
portID, channelID string, sequence uint64, commitment []byte, proof []byte, height int64,
|
||||
) *QueryPacketCommitmentResponse {
|
||||
path := commitmenttypes.NewMerklePath(strings.Split(host.PacketCommitmentPath(portID, channelID, sequence), "/"))
|
||||
return &QueryPacketCommitmentResponse{
|
||||
Commitment: commitment,
|
||||
Proof: proof,
|
||||
ProofPath: path.Pretty(),
|
||||
ProofHeight: uint64(height),
|
||||
}
|
||||
}
|
||||
|
||||
// RecvResponse defines the client query response for the next receive sequence
|
||||
// number which also includes a proof, its path and the height form which the
|
||||
// proof was retrieved
|
||||
type RecvResponse struct {
|
||||
NextSequenceRecv uint64 `json:"next_sequence_recv" yaml:"next_sequence_recv"`
|
||||
Proof commitmenttypes.MerkleProof `json:"proof,omitempty" yaml:"proof,omitempty"`
|
||||
ProofPath commitmenttypes.MerklePath `json:"proof_path,omitempty" yaml:"proof_path,omitempty"`
|
||||
ProofHeight uint64 `json:"proof_height,omitempty" yaml:"proof_height,omitempty"`
|
||||
}
|
||||
|
||||
// NewRecvResponse creates a new RecvResponse instance
|
||||
func NewRecvResponse(
|
||||
portID, channelID string, sequenceRecv uint64, proof *merkle.Proof, height int64,
|
||||
) RecvResponse {
|
||||
return RecvResponse{
|
||||
NextSequenceRecv: sequenceRecv,
|
||||
Proof: commitmenttypes.MerkleProof{Proof: proof},
|
||||
ProofPath: commitmenttypes.NewMerklePath(strings.Split(host.NextSequenceRecvPath(portID, channelID), "/")),
|
||||
ProofHeight: uint64(height),
|
||||
// NewQueryNextSequenceReceiveResponse creates a new QueryNextSequenceReceiveResponse instance
|
||||
func NewQueryNextSequenceReceiveResponse(
|
||||
portID, channelID string, sequence uint64, proof []byte, height int64,
|
||||
) *QueryNextSequenceReceiveResponse {
|
||||
path := commitmenttypes.NewMerklePath(strings.Split(host.NextSequenceRecvPath(portID, channelID), "/"))
|
||||
return &QueryNextSequenceReceiveResponse{
|
||||
NextSequenceReceive: sequence,
|
||||
Proof: proof,
|
||||
ProofPath: path.Pretty(),
|
||||
ProofHeight: uint64(height),
|
||||
}
|
||||
}
|
||||
|
||||
// QueryChannelClientStateParams defines the parameters necessary for querying
|
||||
// ClientState at an associated port ID and channel ID.
|
||||
type QueryChannelClientStateParams struct {
|
||||
PortID string `json:"port_id" yaml:"port_id"`
|
||||
ChannelID string `json:"channel_id" yaml:"channel_id"`
|
||||
}
|
||||
|
||||
// NewQueryChannelClientStateParams creates a new QueryChannelClientStateParams instance.
|
||||
func NewQueryChannelClientStateParams(portID, channelID string) QueryChannelClientStateParams {
|
||||
return QueryChannelClientStateParams{
|
||||
// NewQueryChannelClientStateRequest creates a new QueryChannelClientStateRequest instance.
|
||||
func NewQueryChannelClientStateRequest(portID, channelID string) *QueryChannelClientStateRequest {
|
||||
return &QueryChannelClientStateRequest{
|
||||
PortID: portID,
|
||||
ChannelID: channelID,
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,58 @@
|
|||
package keeper
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
connectiontypes "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/types"
|
||||
channeltypes "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types"
|
||||
)
|
||||
|
||||
// Connection implements the IBC QueryServer interface
|
||||
func (q Keeper) Connection(c context.Context, req *connectiontypes.QueryConnectionRequest) (*connectiontypes.QueryConnectionResponse, error) {
|
||||
return q.ConnectionKeeper.Connection(c, req)
|
||||
}
|
||||
|
||||
// Connections implements the IBC QueryServer interface
|
||||
func (q Keeper) Connections(c context.Context, req *connectiontypes.QueryConnectionsRequest) (*connectiontypes.QueryConnectionsResponse, error) {
|
||||
return q.ConnectionKeeper.Connections(c, req)
|
||||
}
|
||||
|
||||
// ClientConnections implements the IBC QueryServer interface
|
||||
func (q Keeper) ClientConnections(c context.Context, req *connectiontypes.QueryClientConnectionsRequest) (*connectiontypes.QueryClientConnectionsResponse, error) {
|
||||
return q.ConnectionKeeper.ClientConnections(c, req)
|
||||
}
|
||||
|
||||
// Channel implements the IBC QueryServer interface
|
||||
func (q Keeper) Channel(c context.Context, req *channeltypes.QueryChannelRequest) (*channeltypes.QueryChannelResponse, error) {
|
||||
return q.ChannelKeeper.Channel(c, req)
|
||||
}
|
||||
|
||||
// Channels implements the IBC QueryServer interface
|
||||
func (q Keeper) Channels(c context.Context, req *channeltypes.QueryChannelsRequest) (*channeltypes.QueryChannelsResponse, error) {
|
||||
return q.ChannelKeeper.Channels(c, req)
|
||||
}
|
||||
|
||||
// ConnectionChannels implements the IBC QueryServer interface
|
||||
func (q Keeper) ConnectionChannels(c context.Context, req *channeltypes.QueryConnectionChannelsRequest) (*channeltypes.QueryConnectionChannelsResponse, error) {
|
||||
return q.ChannelKeeper.ConnectionChannels(c, req)
|
||||
}
|
||||
|
||||
// PacketCommitment implements the IBC QueryServer interface
|
||||
func (q Keeper) PacketCommitment(c context.Context, req *channeltypes.QueryPacketCommitmentRequest) (*channeltypes.QueryPacketCommitmentResponse, error) {
|
||||
return q.ChannelKeeper.PacketCommitment(c, req)
|
||||
}
|
||||
|
||||
// PacketCommitments implements the IBC QueryServer interface
|
||||
func (q Keeper) PacketCommitments(c context.Context, req *channeltypes.QueryPacketCommitmentsRequest) (*channeltypes.QueryPacketCommitmentsResponse, error) {
|
||||
return q.ChannelKeeper.PacketCommitments(c, req)
|
||||
}
|
||||
|
||||
// UnrelayedPackets implements the IBC QueryServer interface
|
||||
func (q Keeper) UnrelayedPackets(c context.Context, req *channeltypes.QueryUnrelayedPacketsRequest) (*channeltypes.QueryUnrelayedPacketsResponse, error) {
|
||||
return q.ChannelKeeper.UnrelayedPackets(c, req)
|
||||
}
|
||||
|
||||
// NextSequenceReceive implements the IBC QueryServer interface
|
||||
func (q Keeper) NextSequenceReceive(c context.Context, req *channeltypes.QueryNextSequenceReceiveRequest) (*channeltypes.QueryNextSequenceReceiveResponse, error) {
|
||||
return q.ChannelKeeper.NextSequenceReceive(c, req)
|
||||
}
|
|
@ -10,10 +10,16 @@ import (
|
|||
channelkeeper "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/keeper"
|
||||
portkeeper "github.com/cosmos/cosmos-sdk/x/ibc/05-port/keeper"
|
||||
porttypes "github.com/cosmos/cosmos-sdk/x/ibc/05-port/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/types"
|
||||
)
|
||||
|
||||
var _ types.QueryServer = (*Keeper)(nil)
|
||||
|
||||
// Keeper defines each ICS keeper for IBC
|
||||
type Keeper struct {
|
||||
// implements gRPC QueryServer interface
|
||||
types.QueryServer
|
||||
|
||||
aminoCdc *codec.Codec
|
||||
cdc codec.Marshaler
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@ import (
|
|||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
clientkeeper "github.com/cosmos/cosmos-sdk/x/ibc/02-client/keeper"
|
||||
clienttypes "github.com/cosmos/cosmos-sdk/x/ibc/02-client/types"
|
||||
connectionkeeper "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/keeper"
|
||||
connectiontypes "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/types"
|
||||
channelkeeper "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/keeper"
|
||||
channeltypes "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types"
|
||||
|
@ -30,30 +29,11 @@ func NewQuerier(k Keeper) sdk.Querier {
|
|||
err = sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unknown IBC %s query endpoint", clienttypes.SubModuleName)
|
||||
}
|
||||
case connectiontypes.SubModuleName:
|
||||
switch path[1] {
|
||||
case connectiontypes.QueryAllConnections:
|
||||
res, err = connectionkeeper.QuerierConnections(ctx, req, k.ConnectionKeeper)
|
||||
case connectiontypes.QueryAllClientConnections:
|
||||
res, err = connectionkeeper.QuerierAllClientConnections(ctx, req, k.ConnectionKeeper)
|
||||
case connectiontypes.QueryClientConnections:
|
||||
res, err = connectionkeeper.QuerierClientConnections(ctx, req, k.ConnectionKeeper)
|
||||
default:
|
||||
err = sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unknown IBC %s query endpoint", connectiontypes.SubModuleName)
|
||||
}
|
||||
err = sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unknown IBC %s query endpoint", connectiontypes.SubModuleName)
|
||||
case channeltypes.SubModuleName:
|
||||
switch path[1] {
|
||||
case channeltypes.QueryAllChannels:
|
||||
res, err = channelkeeper.QuerierChannels(ctx, req, k.ChannelKeeper)
|
||||
case channeltypes.QueryConnectionChannels:
|
||||
res, err = channelkeeper.QuerierConnectionChannels(ctx, req, k.ChannelKeeper)
|
||||
case channeltypes.QueryChannelClientState:
|
||||
res, err = channelkeeper.QuerierChannelClientState(ctx, req, k.ChannelKeeper)
|
||||
case channeltypes.QueryPacketCommitments:
|
||||
res, err = channelkeeper.QuerierPacketCommitments(ctx, req, k.ChannelKeeper)
|
||||
case channeltypes.QueryUnrelayedAcknowledgements:
|
||||
res, err = channelkeeper.QuerierUnrelayedAcknowledgements(ctx, req, k.ChannelKeeper)
|
||||
case channeltypes.QueryUnrelayedPacketSends:
|
||||
res, err = channelkeeper.QuerierUnrelayedPacketSends(ctx, req, k.ChannelKeeper)
|
||||
default:
|
||||
err = sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unknown IBC %s query endpoint", channeltypes.SubModuleName)
|
||||
}
|
||||
|
|
|
@ -26,94 +26,29 @@ func (suite *KeeperTestSuite) TestNewQuerier() {
|
|||
expectsDefaultErr bool
|
||||
errMsg string
|
||||
}{
|
||||
{"client - QuerierClientState",
|
||||
[]string{clienttypes.SubModuleName, clienttypes.QueryClientState},
|
||||
false,
|
||||
"",
|
||||
},
|
||||
{"client - QuerierClients",
|
||||
[]string{clienttypes.SubModuleName, clienttypes.QueryAllClients},
|
||||
false,
|
||||
"",
|
||||
},
|
||||
{
|
||||
"client - QuerierConsensusState",
|
||||
[]string{clienttypes.SubModuleName, clienttypes.QueryConsensusState},
|
||||
false,
|
||||
"",
|
||||
},
|
||||
{
|
||||
"client - invalid query",
|
||||
[]string{clienttypes.SubModuleName, "foo"},
|
||||
true,
|
||||
fmt.Sprintf("unknown IBC %s query endpoint", clienttypes.SubModuleName),
|
||||
},
|
||||
{
|
||||
"connection - QuerierConnections",
|
||||
[]string{connectiontypes.SubModuleName, connectiontypes.QueryAllConnections},
|
||||
false,
|
||||
"",
|
||||
},
|
||||
{
|
||||
"connection - QuerierAllClientConnections",
|
||||
[]string{connectiontypes.SubModuleName, connectiontypes.QueryAllClientConnections},
|
||||
false,
|
||||
"",
|
||||
},
|
||||
{
|
||||
"connection - QuerierClientConnections",
|
||||
[]string{connectiontypes.SubModuleName, connectiontypes.QueryClientConnections},
|
||||
false,
|
||||
"",
|
||||
},
|
||||
{
|
||||
"connection - invalid query",
|
||||
[]string{connectiontypes.SubModuleName, "foo"},
|
||||
true,
|
||||
fmt.Sprintf("unknown IBC %s query endpoint", connectiontypes.SubModuleName),
|
||||
},
|
||||
{
|
||||
"channel - QuerierChannel",
|
||||
[]string{channeltypes.SubModuleName, channeltypes.QueryChannel},
|
||||
false,
|
||||
"",
|
||||
},
|
||||
{
|
||||
"channel - QuerierChannels",
|
||||
[]string{channeltypes.SubModuleName, channeltypes.QueryAllChannels},
|
||||
false,
|
||||
"",
|
||||
},
|
||||
{
|
||||
"channel - QuerierConnectionChannels",
|
||||
[]string{channeltypes.SubModuleName, channeltypes.QueryConnectionChannels},
|
||||
false,
|
||||
"",
|
||||
},
|
||||
{
|
||||
"channel - QuerierChannelClientState",
|
||||
[]string{channeltypes.SubModuleName, channeltypes.QueryChannelClientState},
|
||||
false,
|
||||
"",
|
||||
},
|
||||
{
|
||||
"channel - QuerierPacketCommitments",
|
||||
[]string{channeltypes.SubModuleName, channeltypes.QueryPacketCommitments},
|
||||
false,
|
||||
"",
|
||||
},
|
||||
{
|
||||
"channel - QuerierUnrelayedAcknowledgements",
|
||||
[]string{channeltypes.SubModuleName, channeltypes.QueryUnrelayedAcknowledgements},
|
||||
false,
|
||||
"",
|
||||
},
|
||||
{
|
||||
"channel - QuerierUnrelayedPacketSends",
|
||||
[]string{channeltypes.SubModuleName, channeltypes.QueryUnrelayedPacketSends},
|
||||
false,
|
||||
"",
|
||||
},
|
||||
{
|
||||
"channel - invalid query",
|
||||
[]string{channeltypes.SubModuleName, "foo"},
|
||||
|
|
|
@ -17,7 +17,7 @@ import (
|
|||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/module"
|
||||
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
|
||||
client2 "github.com/cosmos/cosmos-sdk/x/ibc/02-client"
|
||||
ibcclient "github.com/cosmos/cosmos-sdk/x/ibc/02-client"
|
||||
host "github.com/cosmos/cosmos-sdk/x/ibc/24-host"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/client/cli"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/client/rest"
|
||||
|
@ -124,7 +124,10 @@ func (am AppModule) NewQuerierHandler() sdk.Querier {
|
|||
return keeper.NewQuerier(*am.keeper)
|
||||
}
|
||||
|
||||
func (am AppModule) RegisterQueryService(grpc.Server) {}
|
||||
// RegisterQueryService registers the gRPC query service for the ibc module.
|
||||
func (am AppModule) RegisterQueryService(server grpc.Server) {
|
||||
types.RegisterQueryService(server, am.keeper)
|
||||
}
|
||||
|
||||
// InitGenesis performs genesis initialization for the ibc module. It returns
|
||||
// no validator updates.
|
||||
|
@ -146,7 +149,7 @@ func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONMarshaler) json
|
|||
|
||||
// BeginBlock returns the begin blocker for the ibc module.
|
||||
func (am AppModule) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock) {
|
||||
client2.BeginBlocker(ctx, am.keeper.ClientKeeper)
|
||||
ibcclient.BeginBlocker(ctx, am.keeper.ClientKeeper)
|
||||
}
|
||||
|
||||
// EndBlock returns the end blocker for the ibc module. It returns no validator
|
||||
|
|
|
@ -29,6 +29,7 @@ import (
|
|||
commitmenttypes "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/types"
|
||||
host "github.com/cosmos/cosmos-sdk/x/ibc/24-host"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/keeper"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/types"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -64,7 +65,8 @@ type TestChain struct {
|
|||
ChainID string
|
||||
LastHeader ibctmtypes.Header // header for last block height committed
|
||||
CurrentHeader abci.Header // header for current block height
|
||||
Querier sdk.Querier
|
||||
Querier sdk.Querier // TODO: deprecate once clients are migrated to gRPC
|
||||
QueryServer types.QueryServer
|
||||
|
||||
Vals *tmtypes.ValidatorSet
|
||||
Signers []tmtypes.PrivValidator
|
||||
|
@ -119,6 +121,7 @@ func NewTestChain(t *testing.T, chainID string) *TestChain {
|
|||
App: app,
|
||||
CurrentHeader: header,
|
||||
Querier: keeper.NewQuerier(*app.IBCKeeper),
|
||||
QueryServer: app.IBCKeeper,
|
||||
Vals: valSet,
|
||||
Signers: signers,
|
||||
senderPrivKey: senderPrivKey,
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
package types
|
||||
|
||||
import (
|
||||
connection "github.com/cosmos/cosmos-sdk/x/ibc/03-connection"
|
||||
connectiontypes "github.com/cosmos/cosmos-sdk/x/ibc/03-connection/types"
|
||||
channel "github.com/cosmos/cosmos-sdk/x/ibc/04-channel"
|
||||
channeltypes "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types"
|
||||
"github.com/gogo/protobuf/grpc"
|
||||
)
|
||||
|
||||
// QueryServer defines the IBC interfaces that the gRPC query server must implement
|
||||
type QueryServer interface {
|
||||
connectiontypes.QueryServer
|
||||
channeltypes.QueryServer
|
||||
}
|
||||
|
||||
// RegisterQueryService registers each individual IBC submodule query service
|
||||
func RegisterQueryService(server grpc.Server, queryService QueryServer) {
|
||||
connection.RegisterQueryService(server, queryService)
|
||||
channel.RegisterQueryService(server, queryService)
|
||||
}
|
Loading…
Reference in New Issue