Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(app)!: add group module #1340

Merged
merged 9 commits into from
Aug 11, 2022
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
aleem1314 marked this conversation as resolved.
Show resolved Hide resolved

#### 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()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

group module default-config.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Defaults look good to me.

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