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 modules authz and feegrant #60

Merged
merged 1 commit into from
Apr 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -125,7 +131,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 @@ -159,6 +166,7 @@ var (
// and genesis verification.
ModuleBasics = module.NewBasicManager(
auth.AppModuleBasic{},
authzmodule.AppModuleBasic{},
genutil.AppModuleBasic{},
bank.AppModuleBasic{},
capability.AppModuleBasic{},
Expand All @@ -169,6 +177,7 @@ var (
distr.AppModuleBasic{},
gov.NewAppModuleBasic(getGovProposalHandlers()),
params.AppModuleBasic{},
feegrantmodule.AppModuleBasic{},
upgrade.AppModuleBasic{},
ibc.AppModuleBasic{},
ibctransfer.AppModuleBasic{},
Expand All @@ -180,6 +189,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 @@ -224,6 +234,7 @@ type App struct {

// keepers
AccountKeeper authkeeper.AccountKeeper
AuthzKeeper authzkeeper.Keeper
BankKeeper bankkeeper.Keeper
CapabilityKeeper *capabilitykeeper.Keeper
StakingKeeper stakingkeeper.Keeper
Expand All @@ -238,6 +249,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 @@ -337,6 +349,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 @@ -373,6 +392,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 @@ -498,9 +518,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 @@ -533,9 +555,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 @@ -549,11 +573,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 @@ -573,6 +599,7 @@ func NewRollapp(
initGenesisList := []string{
capabilitytypes.ModuleName,
authtypes.ModuleName,
authz.ModuleName,
banktypes.ModuleName,
distrtypes.ModuleName,
stakingtypes.ModuleName,
Expand All @@ -586,6 +613,7 @@ func NewRollapp(
paramstypes.ModuleName,
upgradetypes.ModuleName,
ibctransfertypes.ModuleName,
feegrant.ModuleName,
hubgentypes.ModuleName,
wasm.ModuleName,
}
Expand Down Expand Up @@ -672,6 +700,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 @@ -718,7 +747,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
Loading