Skip to content

Commit

Permalink
feat(app): Add modules authz and feegrant (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
zale144 authored Apr 25, 2024
1 parent 5a00d0e commit a4451ea
Showing 1 changed file with 34 additions and 5 deletions.
39 changes: 34 additions & 5 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import (
"path/filepath"
"strings"

"github.com/cosmos/cosmos-sdk/x/authz"
authzkeeper "github.com/cosmos/cosmos-sdk/x/authz/keeper"
authzmodule "github.com/cosmos/cosmos-sdk/x/authz/module"
"github.com/gorilla/mux"
"github.com/rakyll/statik/fs"
abci "github.com/tendermint/tendermint/abci/types"
Expand All @@ -26,7 +29,7 @@ import (
"github.com/cosmos/cosmos-sdk/server/api"
"github.com/cosmos/cosmos-sdk/server/config"
servertypes "github.com/cosmos/cosmos-sdk/server/types"
simapp "github.com/cosmos/cosmos-sdk/simapp"
"github.com/cosmos/cosmos-sdk/simapp"
"github.com/cosmos/cosmos-sdk/store/streaming"

storetypes "github.com/cosmos/cosmos-sdk/store/types"
Expand All @@ -51,6 +54,9 @@ import (
capabilitytypes "github.com/cosmos/cosmos-sdk/x/capability/types"
distrclient "github.com/cosmos/cosmos-sdk/x/distribution/client"
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
"github.com/cosmos/cosmos-sdk/x/feegrant"
feegrantkeeper "github.com/cosmos/cosmos-sdk/x/feegrant/keeper"
feegrantmodule "github.com/cosmos/cosmos-sdk/x/feegrant/module"
"github.com/cosmos/cosmos-sdk/x/genutil"
genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types"

Expand Down Expand Up @@ -97,7 +103,7 @@ import (
ibckeeper "github.com/cosmos/ibc-go/v6/modules/core/keeper"
ibctestingtypes "github.com/cosmos/ibc-go/v6/testing/types"

wasm "github.com/CosmWasm/wasmd/x/wasm"
"github.com/CosmWasm/wasmd/x/wasm"
wasmclient "github.com/CosmWasm/wasmd/x/wasm/client"
wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
Expand All @@ -107,7 +113,7 @@ import (
// unnamed import of statik for swagger UI support
_ "github.com/cosmos/cosmos-sdk/client/docs/statik"

staking "github.com/dymensionxyz/dymension-rdk/x/staking"
"github.com/dymensionxyz/dymension-rdk/x/staking"
stakingkeeper "github.com/dymensionxyz/dymension-rdk/x/staking/keeper"

"github.com/dymensionxyz/dymension-rdk/x/sequencers"
Expand All @@ -124,7 +130,8 @@ const (

var (
kvstorekeys = []string{
authtypes.StoreKey, banktypes.StoreKey,
authtypes.StoreKey, authzkeeper.StoreKey,
feegrant.StoreKey, banktypes.StoreKey,
stakingtypes.StoreKey, seqtypes.StoreKey,
minttypes.StoreKey, distrtypes.StoreKey,
govtypes.StoreKey, paramstypes.StoreKey,
Expand Down Expand Up @@ -158,6 +165,7 @@ var (
// and genesis verification.
ModuleBasics = module.NewBasicManager(
auth.AppModuleBasic{},
authzmodule.AppModuleBasic{},
genutil.AppModuleBasic{},
bank.AppModuleBasic{},
capability.AppModuleBasic{},
Expand All @@ -168,6 +176,7 @@ var (
distr.AppModuleBasic{},
gov.NewAppModuleBasic(getGovProposalHandlers()),
params.AppModuleBasic{},
feegrantmodule.AppModuleBasic{},
upgrade.AppModuleBasic{},
ibc.AppModuleBasic{},
ibctransfer.AppModuleBasic{},
Expand All @@ -179,6 +188,7 @@ var (
// module account permissions
maccPerms = map[string][]string{
authtypes.FeeCollectorName: nil,
authz.ModuleName: nil,
distrtypes.ModuleName: nil,
minttypes.ModuleName: {authtypes.Minter},
stakingtypes.BondedPoolName: {authtypes.Burner, authtypes.Staking},
Expand Down Expand Up @@ -223,6 +233,7 @@ type App struct {

// keepers
AccountKeeper authkeeper.AccountKeeper
AuthzKeeper authzkeeper.Keeper
BankKeeper bankkeeper.Keeper
CapabilityKeeper *capabilitykeeper.Keeper
StakingKeeper stakingkeeper.Keeper
Expand All @@ -237,6 +248,7 @@ type App struct {
IBCKeeper *ibckeeper.Keeper // IBC Keeper must be a pointer in the app, so we can SetRouter on it correctly
TransferKeeper ibctransferkeeper.Keeper
WasmKeeper wasmkeeper.Keeper
FeeGrantKeeper feegrantkeeper.Keeper

// make scoped keepers public for test purposes
ScopedIBCKeeper capabilitykeeper.ScopedKeeper
Expand Down Expand Up @@ -336,6 +348,13 @@ func NewRollapp(
sdk.GetConfig().GetBech32AccountAddrPrefix(),
)

app.AuthzKeeper = authzkeeper.NewKeeper(
keys[authzkeeper.StoreKey],
appCodec,
app.MsgServiceRouter(),
app.AccountKeeper,
)

app.BankKeeper = bankkeeper.NewBaseKeeper(
appCodec,
keys[banktypes.StoreKey],
Expand Down Expand Up @@ -372,6 +391,7 @@ func NewRollapp(
&stakingKeeper, &app.SequencersKeeper, authtypes.FeeCollectorName, app.ModuleAccountAddrs(),
)

app.FeeGrantKeeper = feegrantkeeper.NewKeeper(appCodec, keys[feegrant.StoreKey], app.AccountKeeper)
app.UpgradeKeeper = upgradekeeper.NewKeeper(skipUpgradeHeights, keys[upgradetypes.StoreKey], appCodec, homePath, app.BaseApp, authtypes.NewModuleAddress(govtypes.ModuleName).String())

// register the staking hooks
Expand Down Expand Up @@ -497,9 +517,11 @@ func NewRollapp(
encodingConfig.TxConfig,
),
auth.NewAppModule(appCodec, app.AccountKeeper, nil),
authzmodule.NewAppModule(appCodec, app.AuthzKeeper, app.AccountKeeper, app.BankKeeper, app.interfaceRegistry),
vesting.NewAppModule(app.AccountKeeper, app.BankKeeper),
bank.NewAppModule(appCodec, app.BankKeeper, app.AccountKeeper),
capability.NewAppModule(appCodec, *app.CapabilityKeeper),
feegrantmodule.NewAppModule(appCodec, app.AccountKeeper, app.BankKeeper, app.FeeGrantKeeper, app.interfaceRegistry),
gov.NewAppModule(appCodec, app.GovKeeper, app.AccountKeeper, app.BankKeeper),
mint.NewAppModule(appCodec, app.MintKeeper, app.AccountKeeper, app.BankKeeper),
distr.NewAppModule(appCodec, app.DistrKeeper, app.AccountKeeper, app.BankKeeper, app.StakingKeeper),
Expand Down Expand Up @@ -532,9 +554,11 @@ func NewRollapp(
ibchost.ModuleName,
ibctransfertypes.ModuleName,
authtypes.ModuleName,
authz.ModuleName,
banktypes.ModuleName,
govtypes.ModuleName,
genutiltypes.ModuleName,
feegrant.ModuleName,
epochstypes.ModuleName,
paramstypes.ModuleName,
hubgentypes.ModuleName,
Expand All @@ -548,11 +572,13 @@ func NewRollapp(
seqtypes.ModuleName,
capabilitytypes.ModuleName,
authtypes.ModuleName,
authz.ModuleName,
banktypes.ModuleName,
distrtypes.ModuleName,
vestingtypes.ModuleName,
minttypes.ModuleName,
genutiltypes.ModuleName,
feegrant.ModuleName,
epochstypes.ModuleName,
paramstypes.ModuleName,
upgradetypes.ModuleName,
Expand All @@ -572,6 +598,7 @@ func NewRollapp(
initGenesisList := []string{
capabilitytypes.ModuleName,
authtypes.ModuleName,
authz.ModuleName,
banktypes.ModuleName,
distrtypes.ModuleName,
stakingtypes.ModuleName,
Expand All @@ -585,6 +612,7 @@ func NewRollapp(
paramstypes.ModuleName,
upgradetypes.ModuleName,
ibctransfertypes.ModuleName,
feegrant.ModuleName,
hubgentypes.ModuleName,
wasm.ModuleName,
}
Expand Down Expand Up @@ -671,6 +699,7 @@ func (app *App) setAnteHandler(txConfig client.TxConfig, wasmConfig wasmtypes.Wa
HandlerOptions: ante.HandlerOptions{
AccountKeeper: app.AccountKeeper,
BankKeeper: app.BankKeeper,
FeegrantKeeper: app.FeeGrantKeeper,
SignModeHandler: txConfig.SignModeHandler(),
SigGasConsumer: ante.DefaultSigVerificationGasConsumer,
},
Expand Down Expand Up @@ -717,7 +746,7 @@ func (app *App) InitChainer(ctx sdk.Context, req abci.RequestInitChain) abci.Res
panic(err)
}

//Passing the dymint sequencers to the sequencer module from RequestInitChain
// Passing the dymint sequencers to the sequencer module from RequestInitChain
if len(req.Validators) == 0 {
panic(fmt.Sprint("Dymint have no sequencers defined on InitChain, req:", req))
}
Expand Down

0 comments on commit a4451ea

Please sign in to comment.