diff --git a/x/ccv/consumer/keeper/grpc_query.go b/x/ccv/consumer/keeper/grpc_query.go index b60401d931..3396709566 100644 --- a/x/ccv/consumer/keeper/grpc_query.go +++ b/x/ccv/consumer/keeper/grpc_query.go @@ -7,7 +7,6 @@ import ( "google.golang.org/grpc/status" sdk "github.com/cosmos/cosmos-sdk/types" - ibctm "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint" "github.com/cosmos/interchain-security/v3/x/ccv/consumer/types" ) @@ -49,18 +48,5 @@ func (k Keeper) QueryProviderChainInfo(c context.Context, return nil, status.Errorf(codes.InvalidArgument, "empty request") } - providerClientID, found := k.GetProviderClientID(ctx) - if !found { - return nil, nil - } - clientState, found := k.clientKeeper.GetClientState(ctx, providerClientID) - if !found { - return nil, nil - } - providerChainID := clientState.(*ibctm.ClientState).ChainId - resp := types.QueryProviderInfoResponse{ - ChainID: providerChainID, - } - - return &resp, nil + return k.GetProviderChainInfo(ctx) } diff --git a/x/ccv/consumer/keeper/provider_info.go b/x/ccv/consumer/keeper/provider_info.go new file mode 100644 index 0000000000..23dc0c77eb --- /dev/null +++ b/x/ccv/consumer/keeper/provider_info.go @@ -0,0 +1,24 @@ +package keeper + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + ibctm "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint" + "github.com/cosmos/interchain-security/v3/x/ccv/consumer/types" +) + +func (k Keeper) GetProviderChainInfo(ctx sdk.Context) (*types.QueryProviderInfoResponse, error) { + providerClientID, found := k.GetProviderClientID(ctx) + if !found { + return nil, nil + } + clientState, found := k.clientKeeper.GetClientState(ctx, providerClientID) + if !found { + return nil, nil + } + providerChainID := clientState.(*ibctm.ClientState).ChainId + resp := types.QueryProviderInfoResponse{ + ChainID: providerChainID, + } + + return &resp, nil +}