Skip to content

Commit

Permalink
feat(app): wire authz and feegrant modules to app (#270)
Browse files Browse the repository at this point in the history
  • Loading branch information
zale144 authored Jun 23, 2024
1 parent 43d647f commit dad400c
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 4 deletions.
1 change: 1 addition & 0 deletions app/ante/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ func NewHandler(options HandlerOptions) (sdk.AnteHandler, error) {
}
anteHandler = cosmosHandler(
options,
// nolint:staticcheck
cosmosante.NewLegacyEip712SigVerificationDecorator(options.AccountKeeper, options.SignModeHandler), // Use old signature verification: uses EIP instead of the cosmos signature validator
)
case "/ethermint.types.v1.ExtensionOptionDynamicFeeTx": // TODO: can delete?
Expand Down
37 changes: 33 additions & 4 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ import (

"github.com/dymensionxyz/rollapp-evm/app/ante"

"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"
"github.com/spf13/cast"
Expand All @@ -28,7 +31,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"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
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"
"github.com/cosmos/cosmos-sdk/x/gov"
Expand Down Expand Up @@ -95,13 +101,14 @@ import (
ibckeeper "github.com/cosmos/ibc-go/v6/modules/core/keeper"
ibctestingtypes "github.com/cosmos/ibc-go/v6/testing/types"

rollappparams "github.com/dymensionxyz/rollapp-evm/app/params"
srvflags "github.com/evmos/evmos/v12/server/flags"

rollappparams "github.com/dymensionxyz/rollapp-evm/app/params"

// 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 Down Expand Up @@ -147,7 +154,8 @@ const (
var (
AccountAddressPrefix string
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 @@ -190,6 +198,7 @@ var (
// and genesis verification.
ModuleBasics = module.NewBasicManager(
auth.AppModuleBasic{},
authzmodule.AppModuleBasic{},
genutil.AppModuleBasic{},
bank.AppModuleBasic{},
capability.AppModuleBasic{},
Expand All @@ -200,6 +209,7 @@ var (
distr.AppModuleBasic{},
gov.NewAppModuleBasic(getGovProposalHandlers()),
params.AppModuleBasic{},
feegrantmodule.AppModuleBasic{},
upgrade.AppModuleBasic{},
ibc.AppModuleBasic{},
vesting.AppModuleBasic{},
Expand All @@ -218,6 +228,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 @@ -276,6 +287,7 @@ type App struct {

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

// make scoped keepers public for test purposes
ScopedIBCKeeper capabilitykeeper.ScopedKeeper
Expand Down Expand Up @@ -399,6 +412,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 @@ -435,6 +455,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 @@ -580,9 +601,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 @@ -624,11 +647,13 @@ func NewRollapp(
ibchost.ModuleName,
ibctransfertypes.ModuleName,
authtypes.ModuleName,
authz.ModuleName,
banktypes.ModuleName,
govtypes.ModuleName,
erc20types.ModuleName,
claimstypes.ModuleName,
genutiltypes.ModuleName,
feegrant.ModuleName,
epochstypes.ModuleName,
paramstypes.ModuleName,
hubgentypes.ModuleName,
Expand All @@ -644,13 +669,15 @@ func NewRollapp(
feemarkettypes.ModuleName,
capabilitytypes.ModuleName,
authtypes.ModuleName,
authz.ModuleName,
banktypes.ModuleName,
distrtypes.ModuleName,
vestingtypes.ModuleName,
minttypes.ModuleName,
erc20types.ModuleName,
claimstypes.ModuleName,
genutiltypes.ModuleName,
feegrant.ModuleName,
epochstypes.ModuleName,
paramstypes.ModuleName,
upgradetypes.ModuleName,
Expand All @@ -670,6 +697,7 @@ func NewRollapp(
initGenesisList := []string{
capabilitytypes.ModuleName,
authtypes.ModuleName,
authz.ModuleName,
banktypes.ModuleName,
evmtypes.ModuleName,
feemarkettypes.ModuleName,
Expand All @@ -688,6 +716,7 @@ func NewRollapp(
paramstypes.ModuleName,
upgradetypes.ModuleName,
ibctransfertypes.ModuleName,
feegrant.ModuleName,
hubgentypes.ModuleName,
denommetadatamoduletypes.ModuleName,
}
Expand Down

0 comments on commit dad400c

Please sign in to comment.