Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove alias.go from 02-client #6542

Merged
merged 1 commit into from
Jun 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import (
ibctransferkeeper "github.com/cosmos/cosmos-sdk/x/ibc-transfer/keeper"
ibctransfertypes "github.com/cosmos/cosmos-sdk/x/ibc-transfer/types"
ibcclient "github.com/cosmos/cosmos-sdk/x/ibc/02-client"
ibcclienttypes "github.com/cosmos/cosmos-sdk/x/ibc/02-client/types"
port "github.com/cosmos/cosmos-sdk/x/ibc/05-port"
ibchost "github.com/cosmos/cosmos-sdk/x/ibc/24-host"
ibckeeper "github.com/cosmos/cosmos-sdk/x/ibc/keeper"
Expand Down Expand Up @@ -288,7 +289,7 @@ func NewSimApp(
appCodec, keys[evidencetypes.StoreKey], &app.StakingKeeper, app.SlashingKeeper,
)
evidenceRouter := evidencetypes.NewRouter().
AddRoute(ibcclient.RouterKey, ibcclient.HandlerClientMisbehaviour(app.IBCKeeper.ClientKeeper))
AddRoute(ibcclienttypes.RouterKey, ibcclient.HandlerClientMisbehaviour(app.IBCKeeper.ClientKeeper))

evidenceKeeper.SetRouter(evidenceRouter)
app.EvidenceKeeper = *evidenceKeeper
Expand Down
70 changes: 0 additions & 70 deletions x/ibc/02-client/alias.go

This file was deleted.

8 changes: 5 additions & 3 deletions x/ibc/02-client/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ package client
import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/ibc/02-client/exported"
"github.com/cosmos/cosmos-sdk/x/ibc/02-client/keeper"
"github.com/cosmos/cosmos-sdk/x/ibc/02-client/types"
localhosttypes "github.com/cosmos/cosmos-sdk/x/ibc/09-localhost/types"
)

// InitGenesis initializes the ibc client submodule's state from a provided genesis
// state.
func InitGenesis(ctx sdk.Context, k Keeper, gs GenesisState) {
func InitGenesis(ctx sdk.Context, k keeper.Keeper, gs types.GenesisState) {
for _, client := range gs.Clients {
k.SetClientState(ctx, client)
k.SetClientType(ctx, client.GetID(), client.ClientType())
Expand Down Expand Up @@ -39,8 +41,8 @@ func InitGenesis(ctx sdk.Context, k Keeper, gs GenesisState) {
}

// ExportGenesis returns the ibc client submodule's exported genesis.
func ExportGenesis(ctx sdk.Context, k Keeper) GenesisState {
return GenesisState{
func ExportGenesis(ctx sdk.Context, k keeper.Keeper) types.GenesisState {
return types.GenesisState{
Clients: k.GetAllClients(ctx),
ClientsConsensus: k.GetAllConsensusStates(ctx),
CreateLocalhost: true,
Expand Down
19 changes: 10 additions & 9 deletions x/ibc/02-client/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ import (
evidenceexported "github.com/cosmos/cosmos-sdk/x/evidence/exported"
evidencetypes "github.com/cosmos/cosmos-sdk/x/evidence/types"
"github.com/cosmos/cosmos-sdk/x/ibc/02-client/exported"
"github.com/cosmos/cosmos-sdk/x/ibc/02-client/keeper"
"github.com/cosmos/cosmos-sdk/x/ibc/02-client/types"
ibctmtypes "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types"
localhosttypes "github.com/cosmos/cosmos-sdk/x/ibc/09-localhost/types"
)

// HandleMsgCreateClient defines the sdk.Handler for MsgCreateClient
func HandleMsgCreateClient(ctx sdk.Context, k Keeper, msg exported.MsgCreateClient) (*sdk.Result, error) {
func HandleMsgCreateClient(ctx sdk.Context, k keeper.Keeper, msg exported.MsgCreateClient) (*sdk.Result, error) {
clientType := exported.ClientTypeFromString(msg.GetClientType())

var (
Expand All @@ -26,7 +27,7 @@ func HandleMsgCreateClient(ctx sdk.Context, k Keeper, msg exported.MsgCreateClie
case exported.Tendermint:
tmMsg, ok := msg.(ibctmtypes.MsgCreateClient)
if !ok {
return nil, sdkerrors.Wrap(ErrInvalidClientType, "Msg is not a Tendermint CreateClient msg")
return nil, sdkerrors.Wrap(types.ErrInvalidClientType, "Msg is not a Tendermint CreateClient msg")
}
var err error

Expand All @@ -40,7 +41,7 @@ func HandleMsgCreateClient(ctx sdk.Context, k Keeper, msg exported.MsgCreateClie
clientState = localhosttypes.NewClientState(ctx.ChainID(), ctx.BlockHeight())
consensusHeight = uint64(ctx.BlockHeight())
default:
return nil, sdkerrors.Wrap(ErrInvalidClientType, msg.GetClientType())
return nil, sdkerrors.Wrap(types.ErrInvalidClientType, msg.GetClientType())
}

_, err := k.CreateClient(
Expand All @@ -52,14 +53,14 @@ func HandleMsgCreateClient(ctx sdk.Context, k Keeper, msg exported.MsgCreateClie

ctx.EventManager().EmitEvents(sdk.Events{
sdk.NewEvent(
EventTypeCreateClient,
sdk.NewAttribute(AttributeKeyClientID, msg.GetClientID()),
sdk.NewAttribute(AttributeKeyClientType, msg.GetClientType()),
types.EventTypeCreateClient,
sdk.NewAttribute(types.AttributeKeyClientID, msg.GetClientID()),
sdk.NewAttribute(types.AttributeKeyClientType, msg.GetClientType()),
sdk.NewAttribute(types.AttributeKeyConsensusHeight, fmt.Sprintf("%d", consensusHeight)),
),
sdk.NewEvent(
sdk.EventTypeMessage,
sdk.NewAttribute(sdk.AttributeKeyModule, AttributeValueCategory),
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
),
})

Expand All @@ -69,7 +70,7 @@ func HandleMsgCreateClient(ctx sdk.Context, k Keeper, msg exported.MsgCreateClie
}

// HandleMsgUpdateClient defines the sdk.Handler for MsgUpdateClient
func HandleMsgUpdateClient(ctx sdk.Context, k Keeper, msg exported.MsgUpdateClient) (*sdk.Result, error) {
func HandleMsgUpdateClient(ctx sdk.Context, k keeper.Keeper, msg exported.MsgUpdateClient) (*sdk.Result, error) {
_, err := k.UpdateClient(ctx, msg.GetClientID(), msg.GetHeader())
if err != nil {
return nil, err
Expand All @@ -82,7 +83,7 @@ func HandleMsgUpdateClient(ctx sdk.Context, k Keeper, msg exported.MsgUpdateClie

// HandlerClientMisbehaviour defines the Evidence module handler for submitting a
// light client misbehaviour.
func HandlerClientMisbehaviour(k Keeper) evidencetypes.Handler {
func HandlerClientMisbehaviour(k keeper.Keeper) evidencetypes.Handler {
return func(ctx sdk.Context, evidence evidenceexported.Evidence) error {
misbehaviour, ok := evidence.(exported.Misbehaviour)
if !ok {
Expand Down
3 changes: 2 additions & 1 deletion x/ibc/02-client/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ import (
"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/x/ibc/02-client/client/cli"
"github.com/cosmos/cosmos-sdk/x/ibc/02-client/client/rest"
"github.com/cosmos/cosmos-sdk/x/ibc/02-client/types"
)

// Name returns the IBC client name
func Name() string {
return SubModuleName
return types.SubModuleName
}

// RegisterRESTRoutes registers the REST routes for the IBC client
Expand Down
4 changes: 2 additions & 2 deletions x/ibc/04-channel/keeper/packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types"
client "github.com/cosmos/cosmos-sdk/x/ibc/02-client"
clienttypes "github.com/cosmos/cosmos-sdk/x/ibc/02-client/types"
connection "github.com/cosmos/cosmos-sdk/x/ibc/03-connection"
"github.com/cosmos/cosmos-sdk/x/ibc/04-channel/exported"
"github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types"
Expand Down Expand Up @@ -72,7 +72,7 @@ func (k Keeper) SendPacket(

clientState, found := k.clientKeeper.GetClientState(ctx, connectionEnd.GetClientID())
if !found {
return client.ErrConsensusStateNotFound
return clienttypes.ErrConsensusStateNotFound
}

// check if packet timeouted on the receiving chain
Expand Down
6 changes: 3 additions & 3 deletions x/ibc/ante/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@ package ante

import (
sdk "github.com/cosmos/cosmos-sdk/types"
client "github.com/cosmos/cosmos-sdk/x/ibc/02-client"
clientexported "github.com/cosmos/cosmos-sdk/x/ibc/02-client/exported"
clientkeeper "github.com/cosmos/cosmos-sdk/x/ibc/02-client/keeper"
channel "github.com/cosmos/cosmos-sdk/x/ibc/04-channel"
)

// ProofVerificationDecorator handles messages that contains application specific packet types,
// including MsgPacket, MsgAcknowledgement, MsgTimeout.
// MsgUpdateClients are also handled here to perform atomic multimsg transaction
type ProofVerificationDecorator struct {
clientKeeper client.Keeper
clientKeeper clientkeeper.Keeper
channelKeeper channel.Keeper
}

// NewProofVerificationDecorator constructs new ProofverificationDecorator
func NewProofVerificationDecorator(clientKeeper client.Keeper, channelKeeper channel.Keeper) ProofVerificationDecorator {
func NewProofVerificationDecorator(clientKeeper clientkeeper.Keeper, channelKeeper channel.Keeper) ProofVerificationDecorator {
return ProofVerificationDecorator{
clientKeeper: clientKeeper,
channelKeeper: channelKeeper,
Expand Down
14 changes: 7 additions & 7 deletions x/ibc/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package ibc_test
import (
lite "github.com/tendermint/tendermint/lite2"

client "github.com/cosmos/cosmos-sdk/x/ibc/02-client"
"github.com/cosmos/cosmos-sdk/x/ibc/02-client/exported"
clienttypes "github.com/cosmos/cosmos-sdk/x/ibc/02-client/types"
connection "github.com/cosmos/cosmos-sdk/x/ibc/03-connection"
channel "github.com/cosmos/cosmos-sdk/x/ibc/04-channel"
ibctmtypes "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types"
Expand All @@ -28,13 +28,13 @@ func (suite *IBCTestSuite) TestValidateGenesis() {
{
name: "valid genesis",
genState: types.GenesisState{
ClientGenesis: client.NewGenesisState(
ClientGenesis: clienttypes.NewGenesisState(
[]exported.ClientState{
ibctmtypes.NewClientState(clientID, lite.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, suite.header, commitmenttypes.GetSDKSpecs()),
localhosttypes.NewClientState("chaindID", 10),
},
[]client.ConsensusStates{
client.NewClientConsensusStates(
[]clienttypes.ClientConsensusStates{
clienttypes.NewClientConsensusStates(
clientID,
[]exported.ConsensusState{
ibctmtypes.NewConsensusState(
Expand Down Expand Up @@ -84,7 +84,7 @@ func (suite *IBCTestSuite) TestValidateGenesis() {
{
name: "invalid client genesis",
genState: types.GenesisState{
ClientGenesis: client.NewGenesisState(
ClientGenesis: clienttypes.NewGenesisState(
[]exported.ClientState{
ibctmtypes.NewClientState(clientID, lite.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, suite.header, commitmenttypes.GetSDKSpecs()),
localhosttypes.NewClientState("(chaindID)", 0),
Expand All @@ -99,7 +99,7 @@ func (suite *IBCTestSuite) TestValidateGenesis() {
{
name: "invalid connection genesis",
genState: types.GenesisState{
ClientGenesis: client.DefaultGenesisState(),
ClientGenesis: clienttypes.DefaultGenesisState(),
ConnectionGenesis: connection.NewGenesisState(
[]connection.End{
connection.NewConnectionEnd(connection.INIT, connectionID, "(CLIENTIDONE)", connection.NewCounterparty(clientID, connectionID2, commitmenttypes.NewMerklePrefix([]byte("prefix"))), []string{"1.0.0"}),
Expand All @@ -114,7 +114,7 @@ func (suite *IBCTestSuite) TestValidateGenesis() {
{
name: "invalid channel genesis",
genState: types.GenesisState{
ClientGenesis: client.DefaultGenesisState(),
ClientGenesis: clienttypes.DefaultGenesisState(),
ConnectionGenesis: connection.DefaultGenesisState(),
ChannelGenesis: channel.GenesisState{
Acknowledgements: []channel.PacketAckCommitment{
Expand Down
9 changes: 5 additions & 4 deletions x/ibc/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import (
"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper"
client "github.com/cosmos/cosmos-sdk/x/ibc/02-client"
clientkeeper "github.com/cosmos/cosmos-sdk/x/ibc/02-client/keeper"
clienttypes "github.com/cosmos/cosmos-sdk/x/ibc/02-client/types"
connection "github.com/cosmos/cosmos-sdk/x/ibc/03-connection"
channel "github.com/cosmos/cosmos-sdk/x/ibc/04-channel"
port "github.com/cosmos/cosmos-sdk/x/ibc/05-port"
Expand All @@ -15,7 +16,7 @@ type Keeper struct {
aminoCdc *codec.Codec
cdc codec.Marshaler

ClientKeeper client.Keeper
ClientKeeper clientkeeper.Keeper
ConnectionKeeper connection.Keeper
ChannelKeeper channel.Keeper
PortKeeper port.Keeper
Expand All @@ -24,9 +25,9 @@ type Keeper struct {

// NewKeeper creates a new ibc Keeper
func NewKeeper(
aminoCdc *codec.Codec, cdc codec.Marshaler, key sdk.StoreKey, stakingKeeper client.StakingKeeper, scopedKeeper capabilitykeeper.ScopedKeeper,
aminoCdc *codec.Codec, cdc codec.Marshaler, key sdk.StoreKey, stakingKeeper clienttypes.StakingKeeper, scopedKeeper capabilitykeeper.ScopedKeeper,
) *Keeper {
clientKeeper := client.NewKeeper(aminoCdc, key, stakingKeeper)
clientKeeper := clientkeeper.NewKeeper(aminoCdc, key, stakingKeeper)
connectionKeeper := connection.NewKeeper(aminoCdc, cdc, key, clientKeeper)
portKeeper := port.NewKeeper(scopedKeeper)
channelKeeper := channel.NewKeeper(cdc, key, clientKeeper, connectionKeeper, portKeeper, scopedKeeper)
Expand Down
11 changes: 6 additions & 5 deletions x/ibc/keeper/querier.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import (

sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
client "github.com/cosmos/cosmos-sdk/x/ibc/02-client"
clientkeeper "github.com/cosmos/cosmos-sdk/x/ibc/02-client/keeper"
clienttypes "github.com/cosmos/cosmos-sdk/x/ibc/02-client/types"
connection "github.com/cosmos/cosmos-sdk/x/ibc/03-connection"
channelkeeper "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/keeper"
channeltypes "github.com/cosmos/cosmos-sdk/x/ibc/04-channel/types"
Expand All @@ -20,12 +21,12 @@ func NewQuerier(k Keeper) sdk.Querier {
)

switch path[0] {
case client.SubModuleName:
case clienttypes.SubModuleName:
switch path[1] {
case client.QueryAllClients:
res, err = client.QuerierClients(ctx, req, k.ClientKeeper)
case clienttypes.QueryAllClients:
res, err = clientkeeper.QuerierClients(ctx, req, k.ClientKeeper)
default:
err = sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unknown IBC %s query endpoint", client.SubModuleName)
err = sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unknown IBC %s query endpoint", clienttypes.SubModuleName)
}
case connection.SubModuleName:
switch path[1] {
Expand Down
4 changes: 2 additions & 2 deletions x/ibc/types/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package types
import (
"github.com/cosmos/cosmos-sdk/codec"
cdctypes "github.com/cosmos/cosmos-sdk/codec/types"
client "github.com/cosmos/cosmos-sdk/x/ibc/02-client"
clienttypes "github.com/cosmos/cosmos-sdk/x/ibc/02-client/types"
connection "github.com/cosmos/cosmos-sdk/x/ibc/03-connection"
channel "github.com/cosmos/cosmos-sdk/x/ibc/04-channel"
ibctmtypes "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types"
Expand All @@ -14,7 +14,7 @@ import (
// RegisterCodec registers the necessary x/ibc interfaces and concrete types
// on the provided Amino codec. These types are used for Amino JSON serialization.
func RegisterCodec(cdc *codec.Codec) {
client.RegisterCodec(cdc)
clienttypes.RegisterCodec(cdc)
connection.RegisterCodec(cdc)
channel.RegisterCodec(cdc)
ibctmtypes.RegisterCodec(cdc)
Expand Down
Loading