diff --git a/CHANGELOG.md b/CHANGELOG.md index 2269e3786694..5bb730013bb3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Features +* (types) [#15958](https://github.com/cosmos/cosmos-sdk/pull/15958) Add `module.NewBasicManagerFromManager` for creating a basic module manager from a module manager. * (runtime) [#15818](https://github.com/cosmos/cosmos-sdk/pull/15818) Provide logger through `depinject` instead of appBuilder. * (client) [#15597](https://github.com/cosmos/cosmos-sdk/pull/15597) Add status endpoint for clients. * (testutil/integration) [#15556](https://github.com/cosmos/cosmos-sdk/pull/15556) Introduce `testutil/integration` package for module integration testing. @@ -68,6 +69,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Improvements +* (simapp) [#15958](https://github.com/cosmos/cosmos-sdk/pull/15958) Refactor SimApp for removing the global basic manager. * (gov) [#15979](https://github.com/cosmos/cosmos-sdk/pull/15979) Improve gov error message when failing to convert v1 proposal to v1beta1. * (crypto) [#3129](https://github.com/cosmos/cosmos-sdk/pull/3129) New armor and keyring key derivation uses aead and encryption uses chacha20poly * (x/slashing) [#15580](https://github.com/cosmos/cosmos-sdk/pull/15580) Refactor the validator's missed block signing window to be a chunked bitmap instead of a "logical" bitmap, significantly reducing the storage footprint. @@ -201,8 +203,9 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Bug Fixes +* (types) [#16010](https://github.com/cosmos/cosmos-sdk/pull/16010) Let `module.CoreAppModuleBasicAdaptor` fallback to legacy genesis handling. * (x/group) [#16017](https://github.com/cosmos/cosmos-sdk/pull/16017) Correctly apply account number in group v2 migration. -* (types) [#15691](https://github.com/cosmos/cosmos-sdk/pull/15691) Make Coin.Validate() check that .Amount is not nil +* (types) [#15691](https://github.com/cosmos/cosmos-sdk/pull/15691) Make `Coin.Validate()` check that `.Amount` is not nil. * (x/auth) [#15059](https://github.com/cosmos/cosmos-sdk/pull/15059) `ante.CountSubKeys` returns 0 when passing a nil `Pubkey`. * (x/capability) [#15030](https://github.com/cosmos/cosmos-sdk/pull/15030) Prevent `x/capability` from consuming `GasMeter` gas during `InitMemStore` * (types/coin) [#14739](https://github.com/cosmos/cosmos-sdk/pull/14739) Deprecate the method `Coin.IsEqual` in favour of `Coin.Equal`. The difference between the two methods is that the first one results in a panic when denoms are not equal. This panic lead to unexpected behavior diff --git a/errors/CHANGELOG.md b/errors/CHANGELOG.md index f92b5148378a..74f343055879 100644 --- a/errors/CHANGELOG.md +++ b/errors/CHANGELOG.md @@ -34,11 +34,6 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Features * [#15989](https://github.com/cosmos/cosmos-sdk/pull/15989) Add `ErrStopIterating` for modules to use for breaking out of iteration. - -## v1.0.0 - -### Features - * [#10779](https://github.com/cosmos/cosmos-sdk/pull/10779) Import code from the `github.com/cosmos/cosmos-sdk/types/errors` package. * [#11274](https://github.com/cosmos/cosmos-sdk/pull/11274) Add `RegisterWithGRPCCode` function to associate a gRPC error code with errors. diff --git a/orm/model/ormdb/module.go b/orm/model/ormdb/module.go index 72324cab02c7..a8ab9f89aa97 100644 --- a/orm/model/ormdb/module.go +++ b/orm/model/ormdb/module.go @@ -29,13 +29,17 @@ type ModuleDB interface { // GenesisHandler returns an implementation of appmodule.HasGenesis // to be embedded in or called from app module implementations. // Ex: - // type Keeper struct { + // type AppModule struct { // appmodule.HasGenesis // } // // func NewKeeper(db ModuleDB) *Keeper { - // return &Keeper{HasGenesis: db.GenesisHandler()} + // return &Keeper{genesisHandler: db.GenesisHandler()} // } + // + // func NewAppModule(keeper keeper.Keeper) AppModule { + // return AppModule{HasGenesis: keeper.GenesisHandler()} + // } GenesisHandler() appmodule.HasGenesis private() diff --git a/runtime/module.go b/runtime/module.go index 055eef22ebc0..c4ca32e8009f 100644 --- a/runtime/module.go +++ b/runtime/module.go @@ -164,11 +164,10 @@ func SetupAppBuilder(inputs AppInputs) { continue } - if basicMod, ok := mod.(module.AppModuleBasic); ok { - app.basicManager[name] = basicMod - basicMod.RegisterInterfaces(inputs.InterfaceRegistry) - basicMod.RegisterLegacyAminoCodec(inputs.LegacyAmino) - } + coreAppModuleBasic := module.CoreAppModuleBasicAdaptor(name, mod) + app.basicManager[name] = coreAppModuleBasic + coreAppModuleBasic.RegisterInterfaces(inputs.InterfaceRegistry) + coreAppModuleBasic.RegisterLegacyAminoCodec(inputs.LegacyAmino) } } diff --git a/types/module/core_module.go b/types/module/core_module.go index d12c18338637..d4330ecb5e45 100644 --- a/types/module/core_module.go +++ b/types/module/core_module.go @@ -38,7 +38,7 @@ type coreAppModuleBasicAdapator struct { } // DefaultGenesis implements HasGenesis -func (c coreAppModuleBasicAdapator) DefaultGenesis(codec.JSONCodec) json.RawMessage { +func (c coreAppModuleBasicAdapator) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { if mod, ok := c.module.(appmodule.HasGenesis); ok { target := genesis.RawJSONTarget{} err := mod.DefaultGenesis(target.Target()) @@ -53,6 +53,11 @@ func (c coreAppModuleBasicAdapator) DefaultGenesis(codec.JSONCodec) json.RawMess return res } + + if mod, ok := c.module.(HasGenesisBasics); ok { + return mod.DefaultGenesis(cdc) + } + return nil } @@ -69,6 +74,10 @@ func (c coreAppModuleBasicAdapator) ValidateGenesis(cdc codec.JSONCodec, txConfi } } + if mod, ok := c.module.(HasGenesisBasics); ok { + return mod.ValidateGenesis(cdc, txConfig, bz) + } + return nil } @@ -89,11 +98,16 @@ func (c coreAppModuleBasicAdapator) ExportGenesis(ctx sdk.Context, cdc codec.JSO return rawJSON } + + if mod, ok := c.module.(HasGenesis); ok { + return mod.ExportGenesis(ctx, cdc) + } + return nil } // InitGenesis implements HasGenesis -func (c coreAppModuleBasicAdapator) InitGenesis(ctx sdk.Context, _ codec.JSONCodec, bz json.RawMessage) []abci.ValidatorUpdate { +func (c coreAppModuleBasicAdapator) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, bz json.RawMessage) []abci.ValidatorUpdate { if module, ok := c.module.(appmodule.HasGenesis); ok { // core API genesis source, err := genesis.SourceFromRawJSON(bz) @@ -106,6 +120,11 @@ func (c coreAppModuleBasicAdapator) InitGenesis(ctx sdk.Context, _ codec.JSONCod panic(err) } } + + if mod, ok := c.module.(HasGenesis); ok { + return mod.InitGenesis(ctx, cdc, bz) + } + return nil } diff --git a/types/module/module.go b/types/module/module.go index 364724c95d5e..673e4965a550 100644 --- a/types/module/module.go +++ b/types/module/module.go @@ -101,6 +101,11 @@ func NewBasicManagerFromManager(manager *Manager, customModuleBasics map[string] continue } + if appModule, ok := module.(appmodule.AppModule); ok { + moduleMap[name] = CoreAppModuleBasicAdaptor(name, appModule) + continue + } + if basicMod, ok := module.(AppModuleBasic); ok { moduleMap[name] = basicMod }