Skip to content

Commit

Permalink
feat(app)!: add group module (#1340)
Browse files Browse the repository at this point in the history
* feat: register group module

* chore: update upgrade handler

* Update CHANGELOG.md

Co-authored-by: Ryan Christoffersen <12519942+ryanchristo@users.noreply.github.com>

* chore: remove migration test

Co-authored-by: Ryan Christoffersen <12519942+ryanchristo@users.noreply.github.com>
  • Loading branch information
aleem1314 and ryanchristo authored Aug 11, 2022
1 parent 4790f83 commit 073b1e4
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### x/group

#### Added

- [#1340](https://github.com/regen-network/regen-ledger/pull/1340) Add group module

#### Removed

- [#1258](https://github.com/regen-network/regen-ledger/pull/1258) Remove group module
Expand Down
15 changes: 14 additions & 1 deletion app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ import (
upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"

"github.com/cosmos/cosmos-sdk/x/group"
groupkeeper "github.com/cosmos/cosmos-sdk/x/group/keeper"
groupmodule "github.com/cosmos/cosmos-sdk/x/group/module"

"github.com/cosmos/ibc-go/v5/modules/apps/transfer"
ibctransferkeeper "github.com/cosmos/ibc-go/v5/modules/apps/transfer/keeper"
ibctransfertypes "github.com/cosmos/ibc-go/v5/modules/apps/transfer/types"
Expand Down Expand Up @@ -137,6 +141,7 @@ var (
vesting.AppModuleBasic{},
feegrantmodule.AppModuleBasic{},
authzmodule.AppModuleBasic{},
groupmodule.AppModuleBasic{},
ecocreditmodule.Module{},
data.Module{},
}, setCustomModuleBasics()...)...,
Expand Down Expand Up @@ -199,6 +204,7 @@ type RegenApp struct {
TransferKeeper ibctransferkeeper.Keeper
FeeGrantKeeper feegrantkeeper.Keeper
AuthzKeeper authzkeeper.Keeper
GroupKeeper groupkeeper.Keeper

// make scoped keepers public for test purposes
ScopedIBCKeeper capabilitykeeper.ScopedKeeper
Expand Down Expand Up @@ -245,7 +251,7 @@ func NewRegenApp(logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest
govtypes.StoreKey, paramstypes.StoreKey, upgradetypes.StoreKey,
evidencetypes.StoreKey, capabilitytypes.StoreKey, feegrant.StoreKey,
authzkeeper.StoreKey,
ibchost.StoreKey, ibctransfertypes.StoreKey,
ibchost.StoreKey, ibctransfertypes.StoreKey, group.StoreKey,
}, setCustomKVStoreKeys()...)...,
)

Expand Down Expand Up @@ -360,6 +366,9 @@ func NewRegenApp(logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest
)
app.AuthzKeeper = authzKeeper

groupConfig := group.DefaultConfig()
app.GroupKeeper = groupkeeper.NewKeeper(keys[group.StoreKey], appCodec, app.MsgServiceRouter(), app.AccountKeeper, groupConfig)

// register custom modules here
app.smm = setCustomModules(app, interfaceRegistry)
ecocreditModule := ecocreditmodule.NewModule(
Expand Down Expand Up @@ -415,6 +424,7 @@ func NewRegenApp(logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest
ibc.NewAppModule(app.IBCKeeper),
params.NewAppModule(app.ParamsKeeper),
transferModule,
groupmodule.NewAppModule(appCodec, app.GroupKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry),
}, app.setCustomModuleManager()...)...,
)

Expand All @@ -441,6 +451,7 @@ func NewRegenApp(logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest
feegrant.ModuleName,
paramstypes.ModuleName,
vestingtypes.ModuleName,
group.ModuleName,

// ibc modules
ibchost.ModuleName,
Expand All @@ -465,6 +476,7 @@ func NewRegenApp(logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest
paramstypes.ModuleName,
upgradetypes.ModuleName,
vestingtypes.ModuleName,
group.ModuleName,

// ibc modules
ibchost.ModuleName,
Expand Down Expand Up @@ -494,6 +506,7 @@ func NewRegenApp(logger log.Logger, db dbm.DB, traceStore io.Writer, loadLatest
vestingtypes.ModuleName,
paramstypes.ModuleName,
upgradetypes.ModuleName,
group.ModuleName,

// ibc modules
ibctransfertypes.ModuleName,
Expand Down
17 changes: 17 additions & 0 deletions app/stable_appconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/cosmos/cosmos-sdk/x/gov"
govclient "github.com/cosmos/cosmos-sdk/x/gov/client"
govv1beta1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
"github.com/cosmos/cosmos-sdk/x/group"
paramsclient "github.com/cosmos/cosmos-sdk/x/params/client"
paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper"
upgradeclient "github.com/cosmos/cosmos-sdk/x/upgrade/client"
Expand Down Expand Up @@ -63,6 +64,22 @@ func (app *RegenApp) registerUpgradeHandlers() {
// transfer module consensus version has been bumped to 2
return app.mm.RunMigrations(ctx, app.configurator, fromVM)
})

upgradeInfo, err := app.UpgradeKeeper.ReadUpgradeInfoFromDisk()
if err != nil {
panic(err)
}

if upgradeInfo.Name == upgradeName && !app.UpgradeKeeper.IsSkipHeight(upgradeInfo.Height) {
storeUpgrades := storetypes.StoreUpgrades{
Added: []string{
group.ModuleName,
},
}

// configure store loader that checks if version == upgradeHeight and applies store upgrades
app.SetStoreLoader(upgradetypes.UpgradeStoreLoader(upgradeInfo.Height, &storeUpgrades))
}
}

func (app *RegenApp) setCustomAnteHandler(cfg client.TxConfig) (sdk.AnteHandler, error) {
Expand Down

0 comments on commit 073b1e4

Please sign in to comment.