Skip to content

Commit

Permalink
chore: adding HasGenesis compiler assertions to ibc modules (cosmos#4647
Browse files Browse the repository at this point in the history
)
  • Loading branch information
damiannolan authored Sep 13, 2023
1 parent baa4f40 commit f8d4190
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 18 deletions.
7 changes: 2 additions & 5 deletions modules/apps/27-interchain-accounts/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ import (
"github.com/cosmos/cosmos-sdk/types/module"
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"

abci "github.com/cometbft/cometbft/abci/types"

"github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/client/cli"
controllerkeeper "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller/keeper"
controllertypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller/types"
Expand All @@ -36,6 +34,7 @@ var (
_ module.AppModule = (*AppModule)(nil)
_ module.AppModuleBasic = (*AppModuleBasic)(nil)
_ module.AppModuleSimulation = (*AppModule)(nil)
_ module.HasGenesis = (*AppModule)(nil)
_ module.HasProposalMsgs = (*AppModule)(nil)
_ appmodule.AppModule = (*AppModule)(nil)

Expand Down Expand Up @@ -174,7 +173,7 @@ func (am AppModule) RegisterServices(cfg module.Configurator) {

// InitGenesis performs genesis initialization for the interchain accounts module.
// It returns no validator updates.
func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate {
func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) {
var genesisState genesistypes.GenesisState
cdc.MustUnmarshalJSON(data, &genesisState)

Expand All @@ -185,8 +184,6 @@ func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.
if am.hostKeeper != nil {
hostkeeper.InitGenesis(ctx, *am.hostKeeper, genesisState.HostGenesisState)
}

return []abci.ValidatorUpdate{}
}

// ExportGenesis returns the exported genesis state as raw bytes for the interchain accounts module
Expand Down
6 changes: 2 additions & 4 deletions modules/apps/29-fee/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ import (
"github.com/cosmos/cosmos-sdk/types/module"
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"

abci "github.com/cometbft/cometbft/abci/types"

"github.com/cosmos/ibc-go/v8/modules/apps/29-fee/client/cli"
"github.com/cosmos/ibc-go/v8/modules/apps/29-fee/keeper"
"github.com/cosmos/ibc-go/v8/modules/apps/29-fee/types"
Expand All @@ -27,6 +25,7 @@ import (
var (
_ module.AppModule = (*AppModule)(nil)
_ module.AppModuleBasic = (*AppModuleBasic)(nil)
_ module.HasGenesis = (*AppModule)(nil)
_ appmodule.AppModule = (*AppModule)(nil)
)

Expand Down Expand Up @@ -111,11 +110,10 @@ func (am AppModule) RegisterServices(cfg module.Configurator) {

// InitGenesis performs genesis initialization for the ibc-29-fee module. It returns
// no validator updates.
func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate {
func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) {
var genesisState types.GenesisState
cdc.MustUnmarshalJSON(data, &genesisState)
am.keeper.InitGenesis(ctx, genesisState)
return []abci.ValidatorUpdate{}
}

// ExportGenesis returns the exported genesis state as raw bytes for the ibc-29-fee
Expand Down
6 changes: 2 additions & 4 deletions modules/apps/transfer/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ import (
"github.com/cosmos/cosmos-sdk/types/module"
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"

abci "github.com/cometbft/cometbft/abci/types"

"github.com/cosmos/ibc-go/v8/modules/apps/transfer/client/cli"
"github.com/cosmos/ibc-go/v8/modules/apps/transfer/keeper"
"github.com/cosmos/ibc-go/v8/modules/apps/transfer/simulation"
Expand All @@ -29,6 +27,7 @@ import (
var (
_ module.AppModule = (*AppModule)(nil)
_ module.AppModuleBasic = (*AppModuleBasic)(nil)
_ module.HasGenesis = (*AppModule)(nil)
_ module.HasProposalMsgs = (*AppModule)(nil)
_ appmodule.AppModule = (*AppModule)(nil)
_ porttypes.IBCModule = (*IBCModule)(nil)
Expand Down Expand Up @@ -135,11 +134,10 @@ func (am AppModule) RegisterServices(cfg module.Configurator) {

// InitGenesis performs genesis initialization for the ibc-transfer module. It returns
// no validator updates.
func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) []abci.ValidatorUpdate {
func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage) {
var genesisState types.GenesisState
cdc.MustUnmarshalJSON(data, &genesisState)
am.keeper.InitGenesis(ctx, genesisState)
return []abci.ValidatorUpdate{}
}

// ExportGenesis returns the exported genesis state as raw bytes for the ibc-transfer
Expand Down
8 changes: 3 additions & 5 deletions modules/core/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ import (
"github.com/cosmos/cosmos-sdk/types/module"
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"

abci "github.com/cometbft/cometbft/abci/types"

ibcclient "github.com/cosmos/ibc-go/v8/modules/core/02-client"
clientkeeper "github.com/cosmos/ibc-go/v8/modules/core/02-client/keeper"
clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types"
Expand All @@ -36,9 +34,10 @@ var (
_ module.AppModule = (*AppModule)(nil)
_ module.AppModuleBasic = (*AppModuleBasic)(nil)
_ module.AppModuleSimulation = (*AppModule)(nil)
_ module.HasGenesis = (*AppModule)(nil)
_ module.HasProposalMsgs = (*AppModule)(nil)
_ appmodule.HasBeginBlocker = (*AppModule)(nil)
_ appmodule.AppModule = (*AppModule)(nil)
_ appmodule.HasBeginBlocker = (*AppModule)(nil)
)

// AppModuleBasic defines the basic application module used by the ibc module.
Expand Down Expand Up @@ -164,14 +163,13 @@ func (am AppModule) RegisterServices(cfg module.Configurator) {

// InitGenesis performs genesis initialization for the ibc module. It returns
// no validator updates.
func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, bz json.RawMessage) []abci.ValidatorUpdate {
func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, bz json.RawMessage) {
var gs types.GenesisState
err := cdc.UnmarshalJSON(bz, &gs)
if err != nil {
panic(fmt.Sprintf("failed to unmarshal %s genesis state: %s", exported.ModuleName, err))
}
InitGenesis(ctx, *am.keeper, &gs)
return []abci.ValidatorUpdate{}
}

// ExportGenesis returns the exported genesis state as raw bytes for the ibc
Expand Down

0 comments on commit f8d4190

Please sign in to comment.