docs: demonstrate how to wire custom ante handlers in 0.50 app_di (#21767)
This commit is contained in:
parent
b21441cf59
commit
3feb2c08b5
@ -202,8 +202,10 @@ var (
|
||||
Config: appconfig.WrapAny(¶msmodulev1.Module{}),
|
||||
},
|
||||
{
|
||||
Name: "tx",
|
||||
Config: appconfig.WrapAny(&txconfigv1.Config{}),
|
||||
Name: "tx",
|
||||
Config: appconfig.WrapAny(&txconfigv1.Config{
|
||||
SkipAnteHandler: true, // Enable this to skip the default antehandlers and set custom ante handlers.
|
||||
}),
|
||||
},
|
||||
{
|
||||
Name: genutiltypes.ModuleName,
|
||||
|
||||
@ -29,6 +29,7 @@ import (
|
||||
testdata_pulsar "github.com/cosmos/cosmos-sdk/testutil/testdata/testpb"
|
||||
"github.com/cosmos/cosmos-sdk/types/module"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth/ante"
|
||||
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
|
||||
authsims "github.com/cosmos/cosmos-sdk/x/auth/simulation"
|
||||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
@ -81,7 +82,7 @@ type SimApp struct {
|
||||
GroupKeeper groupkeeper.Keeper
|
||||
NFTKeeper nftkeeper.Keeper
|
||||
ConsensusParamsKeeper consensuskeeper.Keeper
|
||||
CircuitBreakerKeeper circuitkeeper.Keeper
|
||||
CircuitKeeper circuitkeeper.Keeper
|
||||
|
||||
// simulation manager
|
||||
sm *module.SimulationManager
|
||||
@ -182,7 +183,7 @@ func NewSimApp(
|
||||
&app.GroupKeeper,
|
||||
&app.NFTKeeper,
|
||||
&app.ConsensusParamsKeeper,
|
||||
&app.CircuitBreakerKeeper,
|
||||
&app.CircuitKeeper,
|
||||
); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@ -248,6 +249,9 @@ func NewSimApp(
|
||||
|
||||
app.sm.RegisterStoreDecoders()
|
||||
|
||||
// set custom ante handler
|
||||
app.setAnteHandler(app.txConfig)
|
||||
|
||||
// A custom InitChainer can be set if extra pre-init-genesis logic is required.
|
||||
// By default, when using app wiring enabled module, this is not required.
|
||||
// For instance, the upgrade module will set automatically the module version map in its init genesis thanks to app wiring.
|
||||
@ -266,6 +270,29 @@ func NewSimApp(
|
||||
return app
|
||||
}
|
||||
|
||||
// setAnteHandler sets custom ante handlers.
|
||||
// "x/auth/tx" pre-defined ante handler have been disabled in app_config.
|
||||
func (app *SimApp) setAnteHandler(txConfig client.TxConfig) {
|
||||
anteHandler, err := NewAnteHandler(
|
||||
HandlerOptions{
|
||||
ante.HandlerOptions{
|
||||
AccountKeeper: app.AccountKeeper,
|
||||
BankKeeper: app.BankKeeper,
|
||||
SignModeHandler: txConfig.SignModeHandler(),
|
||||
FeegrantKeeper: app.FeeGrantKeeper,
|
||||
SigGasConsumer: ante.DefaultSigVerificationGasConsumer,
|
||||
},
|
||||
&app.CircuitKeeper,
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// Set the AnteHandler for the app
|
||||
app.SetAnteHandler(anteHandler)
|
||||
}
|
||||
|
||||
// LegacyAmino returns SimApp's amino codec.
|
||||
//
|
||||
// NOTE: This is solely to be used for testing purposes as it may be desirable
|
||||
Loading…
Reference in New Issue
Block a user