Skip to content

Commit

Permalink
feat: add consumer info to provider info query
Browse files Browse the repository at this point in the history
  • Loading branch information
Yaru Wang committed Aug 3, 2023
1 parent 9c235c6 commit bcd1ac6
Show file tree
Hide file tree
Showing 3 changed files with 295 additions and 54 deletions.
5 changes: 5 additions & 0 deletions proto/interchain_security/ccv/consumer/v1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ message QueryParamsResponse {
message QueryProviderInfoRequest {}

message QueryProviderInfoResponse {
ChainInfo consumer = 1 [ (gogoproto.nullable) = false ];
ChainInfo provider = 2 [ (gogoproto.nullable) = false ];
}

message ChainInfo {
string ChainID = 1;
string ClientID = 2;
string ConnectionID = 3;
Expand Down
19 changes: 14 additions & 5 deletions x/ccv/consumer/keeper/provider_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func (k Keeper) GetProviderChainInfo(ctx sdk.Context) (*types.QueryProviderInfoR
}

// from channel get connection
_, consumerConnection, err := k.channelKeeper.GetChannelConnection(ctx, ccvtypes.ConsumerPortID, consumerChannelID)
consumerConnectionID, consumerConnection, err := k.channelKeeper.GetChannelConnection(ctx, ccvtypes.ConsumerPortID, consumerChannelID)
if err != nil {
return nil, err
}
Expand All @@ -35,10 +35,19 @@ func (k Keeper) GetProviderChainInfo(ctx sdk.Context) (*types.QueryProviderInfoR
providerChainID := consumerClientState.(*ibctm.ClientState).ChainId

resp := types.QueryProviderInfoResponse{
ChainID: providerChainID,
ClientID: providerConnection.GetClientID(),
ConnectionID: providerConnection.GetConnectionID(),
ChannelID: providerChannelID,
Consumer: types.ChainInfo{
ChainID: "",
ClientID: consumerConnection.GetClientID(),
ConnectionID: consumerConnectionID,
ChannelID: consumerChannelID,
},

Provider: types.ChainInfo{
ChainID: providerChainID,
ClientID: providerConnection.GetClientID(),
ConnectionID: providerConnection.GetConnectionID(),
ChannelID: providerChannelID,
},
}

return &resp, nil
Expand Down
Loading

0 comments on commit bcd1ac6

Please sign in to comment.