remove alias.go from 02-client (#6542)

This commit is contained in:
colin axner 2020-06-30 12:37:05 +02:00 committed by GitHub
parent c0e48e1c43
commit 43b4f2f120
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 49 additions and 112 deletions

View File

@ -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"
@ -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

View File

@ -1,70 +0,0 @@
package client
// autogenerated code using github.com/rigelrozanski/multitool
// aliases generated for the following subdirectories:
// ALIASGEN: github.com/cosmos/cosmos-sdk/x/ibc/02-client/types
// ALIASGEN: github.com/cosmos/cosmos-sdk/x/ibc/02-client/keeper
import (
"github.com/cosmos/cosmos-sdk/x/ibc/02-client/keeper"
"github.com/cosmos/cosmos-sdk/x/ibc/02-client/types"
)
const (
AttributeKeyClientID = types.AttributeKeyClientID
AttributeKeyClientType = types.AttributeKeyClientType
SubModuleName = types.SubModuleName
RouterKey = types.RouterKey
QuerierRoute = types.QuerierRoute
QueryAllClients = types.QueryAllClients
QueryClientState = types.QueryClientState
QueryConsensusState = types.QueryConsensusState
)
var (
// functions aliases
RegisterCodec = types.RegisterCodec
NewClientConsensusStates = types.NewClientConsensusStates
NewGenesisState = types.NewGenesisState
DefaultGenesisState = types.DefaultGenesisState
NewQueryAllClientsParams = types.NewQueryAllClientsParams
NewClientStateResponse = types.NewClientStateResponse
NewConsensusStateResponse = types.NewConsensusStateResponse
NewKeeper = keeper.NewKeeper
QuerierClients = keeper.QuerierClients
// variable aliases
SubModuleCdc = types.SubModuleCdc
ErrClientExists = types.ErrClientExists
ErrClientNotFound = types.ErrClientNotFound
ErrClientFrozen = types.ErrClientFrozen
ErrConsensusStateNotFound = types.ErrConsensusStateNotFound
ErrInvalidConsensus = types.ErrInvalidConsensus
ErrClientTypeNotFound = types.ErrClientTypeNotFound
ErrInvalidClientType = types.ErrInvalidClientType
ErrRootNotFound = types.ErrRootNotFound
ErrInvalidHeader = types.ErrInvalidHeader
ErrInvalidEvidence = types.ErrInvalidEvidence
ErrFailedClientConsensusStateVerification = types.ErrFailedClientConsensusStateVerification
ErrFailedConnectionStateVerification = types.ErrFailedConnectionStateVerification
ErrFailedChannelStateVerification = types.ErrFailedChannelStateVerification
ErrFailedPacketCommitmentVerification = types.ErrFailedPacketCommitmentVerification
ErrFailedPacketAckVerification = types.ErrFailedPacketAckVerification
ErrFailedPacketAckAbsenceVerification = types.ErrFailedPacketAckAbsenceVerification
ErrFailedNextSeqRecvVerification = types.ErrFailedNextSeqRecvVerification
ErrSelfConsensusStateNotFound = types.ErrSelfConsensusStateNotFound
EventTypeCreateClient = types.EventTypeCreateClient
EventTypeUpdateClient = types.EventTypeUpdateClient
EventTypeSubmitMisbehaviour = types.EventTypeSubmitMisbehaviour
AttributeValueCategory = types.AttributeValueCategory
)
type (
StakingKeeper = types.StakingKeeper
ConsensusStates = types.ClientConsensusStates
GenesisState = types.GenesisState
QueryAllClientsParams = types.QueryAllClientsParams
StateResponse = types.StateResponse
ConsensusStateResponse = types.ConsensusStateResponse
Keeper = keeper.Keeper
)

View File

@ -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())
@ -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,

View File

@ -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 (
@ -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
@ -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(
@ -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),
),
})
@ -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
@ -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 {

View File

@ -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

View File

@ -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"
@ -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

View File

@ -2,8 +2,8 @@ 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"
)
@ -11,12 +11,12 @@ import (
// 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,

View File

@ -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"
@ -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(
@ -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),
@ -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"}),
@ -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{

View File

@ -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"
@ -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
@ -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)

View File

@ -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"
@ -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] {

View File

@ -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"
@ -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)

View File

@ -1,22 +1,22 @@
package types
import (
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"
)
// GenesisState defines the ibc module's genesis state.
type GenesisState struct {
ClientGenesis client.GenesisState `json:"client_genesis" yaml:"client_genesis"`
ConnectionGenesis connection.GenesisState `json:"connection_genesis" yaml:"connection_genesis"`
ChannelGenesis channel.GenesisState `json:"channel_genesis" yaml:"channel_genesis"`
ClientGenesis clienttypes.GenesisState `json:"client_genesis" yaml:"client_genesis"`
ConnectionGenesis connection.GenesisState `json:"connection_genesis" yaml:"connection_genesis"`
ChannelGenesis channel.GenesisState `json:"channel_genesis" yaml:"channel_genesis"`
}
// DefaultGenesisState returns the ibc module's default genesis state.
func DefaultGenesisState() GenesisState {
return GenesisState{
ClientGenesis: client.DefaultGenesisState(),
ClientGenesis: clienttypes.DefaultGenesisState(),
ConnectionGenesis: connection.DefaultGenesisState(),
ChannelGenesis: channel.DefaultGenesisState(),
}