x:ibc: remove alias.go usage (#6429)
* x:ibc: remove alias.go usage * Replace ibc24host with ibchost
This commit is contained in:
parent
1783f5ef1e
commit
560398cfdc
|
@ -33,6 +33,8 @@ import (
|
|||
transfer "github.com/cosmos/cosmos-sdk/x/ibc-transfer"
|
||||
ibcclient "github.com/cosmos/cosmos-sdk/x/ibc/02-client"
|
||||
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"
|
||||
"github.com/cosmos/cosmos-sdk/x/mint"
|
||||
mintkeeper "github.com/cosmos/cosmos-sdk/x/mint/keeper"
|
||||
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
|
||||
|
@ -134,7 +136,7 @@ type SimApp struct {
|
|||
CrisisKeeper crisis.Keeper
|
||||
UpgradeKeeper upgradekeeper.Keeper
|
||||
ParamsKeeper paramskeeper.Keeper
|
||||
IBCKeeper *ibc.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly
|
||||
IBCKeeper *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly
|
||||
EvidenceKeeper evidence.Keeper
|
||||
TransferKeeper transfer.Keeper
|
||||
|
||||
|
@ -165,7 +167,7 @@ func NewSimApp(
|
|||
keys := sdk.NewKVStoreKeys(
|
||||
auth.StoreKey, bank.StoreKey, stakingtypes.StoreKey,
|
||||
minttypes.StoreKey, distr.StoreKey, slashingtypes.StoreKey,
|
||||
govtypes.StoreKey, paramstypes.StoreKey, ibc.StoreKey, upgradetypes.StoreKey,
|
||||
govtypes.StoreKey, paramstypes.StoreKey, ibchost.StoreKey, upgradetypes.StoreKey,
|
||||
evidence.StoreKey, transfer.StoreKey, capability.StoreKey,
|
||||
)
|
||||
tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey)
|
||||
|
@ -198,7 +200,7 @@ func NewSimApp(
|
|||
|
||||
// add capability keeper and ScopeToModule for ibc module
|
||||
app.CapabilityKeeper = capability.NewKeeper(appCodec, keys[capability.StoreKey], memKeys[capability.MemStoreKey])
|
||||
scopedIBCKeeper := app.CapabilityKeeper.ScopeToModule(ibc.ModuleName)
|
||||
scopedIBCKeeper := app.CapabilityKeeper.ScopeToModule(ibchost.ModuleName)
|
||||
scopedTransferKeeper := app.CapabilityKeeper.ScopeToModule(transfer.ModuleName)
|
||||
|
||||
// add keepers
|
||||
|
@ -247,8 +249,8 @@ func NewSimApp(
|
|||
// Create IBC Keeper
|
||||
// TODO: remove amino codec dependency once Tendermint version is upgraded with
|
||||
// protobuf changes
|
||||
app.IBCKeeper = ibc.NewKeeper(
|
||||
app.cdc, appCodec, keys[ibc.StoreKey], app.StakingKeeper, scopedIBCKeeper,
|
||||
app.IBCKeeper = ibckeeper.NewKeeper(
|
||||
app.cdc, appCodec, keys[ibchost.StoreKey], app.StakingKeeper, scopedIBCKeeper,
|
||||
)
|
||||
|
||||
// Create Transfer Keepers
|
||||
|
@ -300,7 +302,7 @@ func NewSimApp(
|
|||
// NOTE: staking module is required if HistoricalEntries param > 0
|
||||
app.mm.SetOrderBeginBlockers(
|
||||
upgradetypes.ModuleName, minttypes.ModuleName, distr.ModuleName, slashingtypes.ModuleName,
|
||||
evidence.ModuleName, stakingtypes.ModuleName, ibc.ModuleName,
|
||||
evidence.ModuleName, stakingtypes.ModuleName, ibchost.ModuleName,
|
||||
)
|
||||
app.mm.SetOrderEndBlockers(crisis.ModuleName, govtypes.ModuleName, stakingtypes.ModuleName)
|
||||
|
||||
|
@ -312,7 +314,7 @@ func NewSimApp(
|
|||
app.mm.SetOrderInitGenesis(
|
||||
capability.ModuleName, auth.ModuleName, distr.ModuleName, stakingtypes.ModuleName, bank.ModuleName,
|
||||
slashingtypes.ModuleName, govtypes.ModuleName, minttypes.ModuleName, crisis.ModuleName,
|
||||
ibc.ModuleName, genutiltypes.ModuleName, evidence.ModuleName, transfer.ModuleName,
|
||||
ibchost.ModuleName, genutiltypes.ModuleName, evidence.ModuleName, transfer.ModuleName,
|
||||
)
|
||||
|
||||
app.mm.RegisterInvariants(&app.CrisisKeeper)
|
||||
|
|
|
@ -23,8 +23,8 @@ import (
|
|||
distr "github.com/cosmos/cosmos-sdk/x/distribution"
|
||||
"github.com/cosmos/cosmos-sdk/x/evidence"
|
||||
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc"
|
||||
transfer "github.com/cosmos/cosmos-sdk/x/ibc-transfer"
|
||||
ibchost "github.com/cosmos/cosmos-sdk/x/ibc/24-host"
|
||||
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
|
||||
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/simulation"
|
||||
|
@ -162,7 +162,7 @@ func TestAppImportExport(t *testing.T) {
|
|||
{app.keys[govtypes.StoreKey], newApp.keys[govtypes.StoreKey], [][]byte{}},
|
||||
{app.keys[evidence.StoreKey], newApp.keys[evidence.StoreKey], [][]byte{}},
|
||||
{app.keys[capability.StoreKey], newApp.keys[capability.StoreKey], [][]byte{}},
|
||||
{app.keys[ibc.StoreKey], newApp.keys[ibc.StoreKey], [][]byte{}},
|
||||
{app.keys[ibchost.StoreKey], newApp.keys[ibchost.StoreKey], [][]byte{}},
|
||||
{app.keys[transfer.StoreKey], newApp.keys[transfer.StoreKey], [][]byte{}},
|
||||
}
|
||||
|
||||
|
|
|
@ -1,33 +0,0 @@
|
|||
package ibc
|
||||
|
||||
// autogenerated code using github.com/rigelrozanski/multitool
|
||||
// aliases generated for the following subdirectories:
|
||||
// ALIASGEN: github.com/cosmos/cosmos-sdk/x/ibc/keeper
|
||||
// ALIASGEN: github.com/cosmos/cosmos-sdk/x/ibc/types
|
||||
|
||||
import (
|
||||
host "github.com/cosmos/cosmos-sdk/x/ibc/24-host"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/keeper"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/types"
|
||||
)
|
||||
|
||||
const (
|
||||
ModuleName = host.ModuleName
|
||||
StoreKey = host.StoreKey
|
||||
QuerierRoute = host.QuerierRoute
|
||||
RouterKey = host.RouterKey
|
||||
)
|
||||
|
||||
var (
|
||||
// functions aliases
|
||||
NewKeeper = keeper.NewKeeper
|
||||
NewQuerier = keeper.NewQuerier
|
||||
RegisterCodec = types.RegisterCodec
|
||||
RegisterInterfaces = types.RegisterInterfaces
|
||||
DefaultGenesisState = types.DefaultGenesisState
|
||||
)
|
||||
|
||||
type (
|
||||
Keeper = keeper.Keeper
|
||||
GenesisState = types.GenesisState
|
||||
)
|
|
@ -5,19 +5,21 @@ import (
|
|||
client "github.com/cosmos/cosmos-sdk/x/ibc/02-client"
|
||||
connection "github.com/cosmos/cosmos-sdk/x/ibc/03-connection"
|
||||
channel "github.com/cosmos/cosmos-sdk/x/ibc/04-channel"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/keeper"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/types"
|
||||
)
|
||||
|
||||
// InitGenesis initializes the ibc state from a provided genesis
|
||||
// state.
|
||||
func InitGenesis(ctx sdk.Context, k Keeper, createLocalhost bool, gs GenesisState) {
|
||||
func InitGenesis(ctx sdk.Context, k keeper.Keeper, createLocalhost bool, gs types.GenesisState) {
|
||||
client.InitGenesis(ctx, k.ClientKeeper, gs.ClientGenesis)
|
||||
connection.InitGenesis(ctx, k.ConnectionKeeper, gs.ConnectionGenesis)
|
||||
channel.InitGenesis(ctx, k.ChannelKeeper, gs.ChannelGenesis)
|
||||
}
|
||||
|
||||
// ExportGenesis returns the ibc 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{
|
||||
ClientGenesis: client.ExportGenesis(ctx, k.ClientKeeper),
|
||||
ConnectionGenesis: connection.ExportGenesis(ctx, k.ConnectionKeeper),
|
||||
ChannelGenesis: channel.ExportGenesis(ctx, k.ChannelKeeper),
|
||||
|
|
|
@ -3,7 +3,6 @@ package ibc_test
|
|||
import (
|
||||
lite "github.com/tendermint/tendermint/lite2"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc"
|
||||
client "github.com/cosmos/cosmos-sdk/x/ibc/02-client"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/02-client/exported"
|
||||
connection "github.com/cosmos/cosmos-sdk/x/ibc/03-connection"
|
||||
|
@ -12,22 +11,23 @@ import (
|
|||
localhosttypes "github.com/cosmos/cosmos-sdk/x/ibc/09-localhost/types"
|
||||
commitmenttypes "github.com/cosmos/cosmos-sdk/x/ibc/23-commitment/types"
|
||||
host "github.com/cosmos/cosmos-sdk/x/ibc/24-host"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/types"
|
||||
)
|
||||
|
||||
func (suite *IBCTestSuite) TestValidateGenesis() {
|
||||
testCases := []struct {
|
||||
name string
|
||||
genState ibc.GenesisState
|
||||
genState types.GenesisState
|
||||
expPass bool
|
||||
}{
|
||||
{
|
||||
name: "default",
|
||||
genState: ibc.DefaultGenesisState(),
|
||||
genState: types.DefaultGenesisState(),
|
||||
expPass: true,
|
||||
},
|
||||
{
|
||||
name: "valid genesis",
|
||||
genState: ibc.GenesisState{
|
||||
genState: types.GenesisState{
|
||||
ClientGenesis: client.NewGenesisState(
|
||||
[]exported.ClientState{
|
||||
ibctmtypes.NewClientState(clientID, lite.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, suite.header, commitmenttypes.GetSDKSpecs()),
|
||||
|
@ -83,7 +83,7 @@ func (suite *IBCTestSuite) TestValidateGenesis() {
|
|||
},
|
||||
{
|
||||
name: "invalid client genesis",
|
||||
genState: ibc.GenesisState{
|
||||
genState: types.GenesisState{
|
||||
ClientGenesis: client.NewGenesisState(
|
||||
[]exported.ClientState{
|
||||
ibctmtypes.NewClientState(clientID, lite.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, suite.header, commitmenttypes.GetSDKSpecs()),
|
||||
|
@ -98,7 +98,7 @@ func (suite *IBCTestSuite) TestValidateGenesis() {
|
|||
},
|
||||
{
|
||||
name: "invalid connection genesis",
|
||||
genState: ibc.GenesisState{
|
||||
genState: types.GenesisState{
|
||||
ClientGenesis: client.DefaultGenesisState(),
|
||||
ConnectionGenesis: connection.NewGenesisState(
|
||||
[]connection.End{
|
||||
|
@ -113,7 +113,7 @@ func (suite *IBCTestSuite) TestValidateGenesis() {
|
|||
},
|
||||
{
|
||||
name: "invalid channel genesis",
|
||||
genState: ibc.GenesisState{
|
||||
genState: types.GenesisState{
|
||||
ClientGenesis: client.DefaultGenesisState(),
|
||||
ConnectionGenesis: connection.DefaultGenesisState(),
|
||||
ChannelGenesis: channel.GenesisState{
|
||||
|
|
|
@ -8,10 +8,11 @@ import (
|
|||
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"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/keeper"
|
||||
)
|
||||
|
||||
// NewHandler defines the IBC handler
|
||||
func NewHandler(k Keeper) sdk.Handler {
|
||||
func NewHandler(k keeper.Keeper) sdk.Handler {
|
||||
return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) {
|
||||
ctx = ctx.WithEventManager(sdk.NewEventManager())
|
||||
|
||||
|
|
|
@ -21,7 +21,9 @@ import (
|
|||
host "github.com/cosmos/cosmos-sdk/x/ibc/24-host"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/client/cli"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/client/rest"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/keeper"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/simulation"
|
||||
"github.com/cosmos/cosmos-sdk/x/ibc/types"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -42,20 +44,20 @@ func (AppModuleBasic) Name() string {
|
|||
|
||||
// RegisterCodec registers the ibc module's types for the given codec.
|
||||
func (AppModuleBasic) RegisterCodec(cdc *codec.Codec) {
|
||||
RegisterCodec(cdc)
|
||||
types.RegisterCodec(cdc)
|
||||
}
|
||||
|
||||
// DefaultGenesis returns default genesis state as raw bytes for the ibc
|
||||
// module.
|
||||
func (AppModuleBasic) DefaultGenesis(cdc codec.JSONMarshaler) json.RawMessage {
|
||||
return cdc.MustMarshalJSON(DefaultGenesisState())
|
||||
return cdc.MustMarshalJSON(types.DefaultGenesisState())
|
||||
}
|
||||
|
||||
// ValidateGenesis performs genesis state validation for the ibc module.
|
||||
func (AppModuleBasic) ValidateGenesis(cdc codec.JSONMarshaler, bz json.RawMessage) error {
|
||||
var gs GenesisState
|
||||
var gs types.GenesisState
|
||||
if err := cdc.UnmarshalJSON(bz, &gs); err != nil {
|
||||
return fmt.Errorf("failed to unmarshal %s genesis state: %w", ModuleName, err)
|
||||
return fmt.Errorf("failed to unmarshal %s genesis state: %w", host.ModuleName, err)
|
||||
}
|
||||
|
||||
return gs.Validate()
|
||||
|
@ -63,35 +65,35 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONMarshaler, bz json.RawMessag
|
|||
|
||||
// RegisterRESTRoutes registers the REST routes for the ibc module.
|
||||
func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router) {
|
||||
rest.RegisterRoutes(clientCtx, rtr, StoreKey)
|
||||
rest.RegisterRoutes(clientCtx, rtr, host.StoreKey)
|
||||
}
|
||||
|
||||
// GetTxCmd returns the root tx command for the ibc module.
|
||||
func (AppModuleBasic) GetTxCmd(clientCtx client.Context) *cobra.Command {
|
||||
return cli.GetTxCmd(StoreKey, clientCtx.Codec)
|
||||
return cli.GetTxCmd(host.StoreKey, clientCtx.Codec)
|
||||
}
|
||||
|
||||
// GetQueryCmd returns no root query command for the ibc module.
|
||||
func (AppModuleBasic) GetQueryCmd(clientCtx client.Context) *cobra.Command {
|
||||
return cli.GetQueryCmd(QuerierRoute, clientCtx.Codec)
|
||||
return cli.GetQueryCmd(host.QuerierRoute, clientCtx.Codec)
|
||||
}
|
||||
|
||||
// RegisterInterfaceTypes registers module concrete types into protobuf Any.
|
||||
func (AppModuleBasic) RegisterInterfaceTypes(registry cdctypes.InterfaceRegistry) {
|
||||
RegisterInterfaces(registry)
|
||||
types.RegisterInterfaces(registry)
|
||||
}
|
||||
|
||||
// AppModule implements an application module for the ibc module.
|
||||
type AppModule struct {
|
||||
AppModuleBasic
|
||||
keeper *Keeper
|
||||
keeper *keeper.Keeper
|
||||
|
||||
// create localhost by default
|
||||
createLocalhost bool
|
||||
}
|
||||
|
||||
// NewAppModule creates a new AppModule object
|
||||
func NewAppModule(k *Keeper) AppModule {
|
||||
func NewAppModule(k *keeper.Keeper) AppModule {
|
||||
return AppModule{
|
||||
keeper: k,
|
||||
}
|
||||
|
@ -99,7 +101,7 @@ func NewAppModule(k *Keeper) AppModule {
|
|||
|
||||
// Name returns the ibc module's name.
|
||||
func (AppModule) Name() string {
|
||||
return ModuleName
|
||||
return host.ModuleName
|
||||
}
|
||||
|
||||
// RegisterInvariants registers the ibc module invariants.
|
||||
|
@ -109,17 +111,17 @@ func (am AppModule) RegisterInvariants(ir sdk.InvariantRegistry) {
|
|||
|
||||
// Route returns the message routing key for the ibc module.
|
||||
func (am AppModule) Route() sdk.Route {
|
||||
return sdk.NewRoute(RouterKey, NewHandler(*am.keeper))
|
||||
return sdk.NewRoute(host.RouterKey, NewHandler(*am.keeper))
|
||||
}
|
||||
|
||||
// QuerierRoute returns the ibc module's querier route name.
|
||||
func (AppModule) QuerierRoute() string {
|
||||
return QuerierRoute
|
||||
return host.QuerierRoute
|
||||
}
|
||||
|
||||
// NewQuerierHandler returns the ibc module sdk.Querier.
|
||||
func (am AppModule) NewQuerierHandler() sdk.Querier {
|
||||
return NewQuerier(*am.keeper)
|
||||
return keeper.NewQuerier(*am.keeper)
|
||||
}
|
||||
|
||||
func (am AppModule) RegisterQueryService(grpc.Server) {}
|
||||
|
@ -127,10 +129,10 @@ func (am AppModule) RegisterQueryService(grpc.Server) {}
|
|||
// InitGenesis performs genesis initialization for the ibc module. It returns
|
||||
// no validator updates.
|
||||
func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONMarshaler, bz json.RawMessage) []abci.ValidatorUpdate {
|
||||
var gs GenesisState
|
||||
var gs types.GenesisState
|
||||
err := cdc.UnmarshalJSON(bz, &gs)
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("failed to unmarshal %s genesis state: %s", ModuleName, err))
|
||||
panic(fmt.Sprintf("failed to unmarshal %s genesis state: %s", host.ModuleName, err))
|
||||
}
|
||||
InitGenesis(ctx, *am.keeper, am.createLocalhost, gs)
|
||||
return []abci.ValidatorUpdate{}
|
||||
|
@ -174,7 +176,7 @@ func (AppModule) RandomizedParams(_ *rand.Rand) []simtypes.ParamChange {
|
|||
|
||||
// RegisterStoreDecoder registers a decoder for ibc module's types
|
||||
func (am AppModule) RegisterStoreDecoder(sdr sdk.StoreDecoderRegistry) {
|
||||
sdr[StoreKey] = simulation.NewDecodeStore(am.keeper.Codecs())
|
||||
sdr[host.StoreKey] = simulation.NewDecodeStore(am.keeper.Codecs())
|
||||
}
|
||||
|
||||
// WeightedOperations returns the all the ibc module operations with their respective weights.
|
||||
|
|
Loading…
Reference in New Issue