chore: set circuitbreaker in app.go as example (#16288)
This commit is contained in:
parent
8e74f6be65
commit
b6613f9163
@ -491,6 +491,9 @@ func (app *BaseApp) GetFinalizeBlockStateCtx() sdk.Context {
|
||||
// SetCircuitBreaker sets the circuit breaker for the BaseApp.
|
||||
// The circuit breaker is checked on every message execution to verify if a transaction should be executed or not.
|
||||
func (app *BaseApp) SetCircuitBreaker(cb CircuitBreaker) {
|
||||
if app.msgServiceRouter == nil {
|
||||
panic("cannot set circuit breaker with no msg service router set")
|
||||
}
|
||||
app.msgServiceRouter.SetCircuit(cb)
|
||||
}
|
||||
|
||||
|
||||
@ -302,6 +302,7 @@ func NewSimApp(
|
||||
)
|
||||
|
||||
app.CircuitKeeper = circuitkeeper.NewKeeper(keys[circuittypes.StoreKey], authtypes.NewModuleAddress(govtypes.ModuleName).String(), app.AccountKeeper.AddressCodec())
|
||||
app.BaseApp.SetCircuitBreaker(&app.CircuitKeeper)
|
||||
|
||||
app.AuthzKeeper = authzkeeper.NewKeeper(runtime.NewKVStoreService(keys[authzkeeper.StoreKey]), appCodec, app.MsgServiceRouter(), app.AccountKeeper)
|
||||
|
||||
|
||||
@ -13,9 +13,11 @@ import (
|
||||
store "cosmossdk.io/store/types"
|
||||
"cosmossdk.io/x/circuit/client/cli"
|
||||
abci "github.com/cometbft/cometbft/abci/types"
|
||||
"github.com/cosmos/cosmos-sdk/baseapp"
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
"github.com/cosmos/cosmos-sdk/runtime"
|
||||
"github.com/cosmos/cosmos-sdk/telemetry"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/module"
|
||||
@ -149,7 +151,7 @@ func init() {
|
||||
)
|
||||
}
|
||||
|
||||
type Inputs struct {
|
||||
type ModuleInputs struct {
|
||||
depinject.In
|
||||
|
||||
Config *modulev1.Module
|
||||
@ -159,14 +161,15 @@ type Inputs struct {
|
||||
AddressCodec address.Codec
|
||||
}
|
||||
|
||||
type Outputs struct {
|
||||
type ModuleOutputs struct {
|
||||
depinject.Out
|
||||
|
||||
CircuitKeeper keeper.Keeper
|
||||
Module appmodule.AppModule
|
||||
CircuitKeeper keeper.Keeper
|
||||
Module appmodule.AppModule
|
||||
BaseappOptions runtime.BaseAppOption
|
||||
}
|
||||
|
||||
func ProvideModule(in Inputs) Outputs {
|
||||
func ProvideModule(in ModuleInputs) ModuleOutputs {
|
||||
// default to governance authority if not provided
|
||||
authority := authtypes.NewModuleAddress("gov")
|
||||
if in.Config.Authority != "" {
|
||||
@ -180,5 +183,9 @@ func ProvideModule(in Inputs) Outputs {
|
||||
)
|
||||
m := NewAppModule(in.Cdc, circuitkeeper)
|
||||
|
||||
return Outputs{CircuitKeeper: circuitkeeper, Module: m}
|
||||
baseappOpt := func(app *baseapp.BaseApp) {
|
||||
app.SetCircuitBreaker(&circuitkeeper)
|
||||
}
|
||||
|
||||
return ModuleOutputs{CircuitKeeper: circuitkeeper, Module: m, BaseappOptions: baseappOpt}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user