Skip to content

Commit

Permalink
feat: refactor query providerInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
Yaru Wang committed Jul 28, 2023
1 parent ee5c6f6 commit 8ddb410
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 15 deletions.
16 changes: 1 addition & 15 deletions x/ccv/consumer/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"google.golang.org/grpc/status"

sdk "github.com/cosmos/cosmos-sdk/types"

Check failure on line 9 in x/ccv/consumer/keeper/grpc_query.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gci`-ed with --skip-generated -s standard,default,blank,dot,prefix(cosmossdk.io),prefix(github.com/cosmos/cosmos-sdk),prefix(github.com/cometbft/cometbft),prefix(github.com/cosmos/interchain-security) (gci)
ibctm "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint"
"github.com/cosmos/interchain-security/v3/x/ccv/consumer/types"
)

Expand Down Expand Up @@ -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)
}
24 changes: 24 additions & 0 deletions x/ccv/consumer/keeper/provider_info.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package keeper

import (
sdk "github.com/cosmos/cosmos-sdk/types"

Check failure on line 4 in x/ccv/consumer/keeper/provider_info.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gci`-ed with --skip-generated -s standard,default,blank,dot,prefix(cosmossdk.io),prefix(github.com/cosmos/cosmos-sdk),prefix(github.com/cometbft/cometbft),prefix(github.com/cosmos/interchain-security) (gci)
ibctm "github.com/cosmos/ibc-go/v7/modules/light-clients/07-tendermint"

Check failure on line 5 in x/ccv/consumer/keeper/provider_info.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gci`-ed with --skip-generated -s standard,default,blank,dot,prefix(cosmossdk.io),prefix(github.com/cosmos/cosmos-sdk),prefix(github.com/cometbft/cometbft),prefix(github.com/cosmos/interchain-security) (gci)
"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
}

0 comments on commit 8ddb410

Please sign in to comment.