Cosmos module implementation
Projects that want to integrate the meshsecurityprovider module onto their Cosmos SDK chain must enable the following modules:
-
Add the mesh security package to the go.mod and install it.
require ( ... github.com/osmosis-labs/mesh-security ... ) -
Add the following modules to
app.goimport ( ... meshsecprov "github.com/osmosis-labs/mesh-security-sdk/x/meshsecurityprovider" meshsecprovkeeper "github.com/osmosis-labs/mesh-security-sdk/x/meshsecurityprovider/keeper" meshsecprovtypes "github.com/osmosis-labs/mesh-security-sdk/x/meshsecurityprovider/types" ... ) -
In
app.go: Register the AppModule for the mesh security provider module.ModuleBasics = module.NewBasicManager( ... meshsecprov.AppModuleBasic{}, ... ) -
In
app.go: Add mesh security provider keeper.type App struct { ... MeshSecProvKeeper *meshsecprovkeeper.Keeper ... } -
In
app.go: Add mesh security provider store key.keys := sdk.NewKVStoreKeys( ... meshsecprovtypes.StoreKey, ... ) -
In
app.go: Instantiate mesh security provider keeperapp.MeshSecProvKeeper = meshsecprovkeeper.NewKeeper( appCodec, keys[meshsecprovtypes.StoreKey], authtypes.NewModuleAddress(govtypes.ModuleName).String(), app.BankKeeper, &app.WasmKeeper, app.StakingKeeper, ) -
In
app.go: Add the mesh security provider module to the app manager instantiation.app.mm = module.NewManager( ... meshsecprov.NewAppModule(app.MeshSecProvKeeper) ... ) -
In
app.go: Add the module as the final element to the following:
- SetOrderBeginBlockers
- SetOrderEndBlockers
- SetOrderInitGenesis
// Add mesh security to begin blocker logic app.moduleManager.SetOrderBeginBlockers( ... meshsecprovtypes.ModuleName, ... ) // Add mesh security to end blocker logic app.moduleManager.SetOrderEndBlockers( ... meshsecprovtypes.ModuleName, ... ) // Add mesh security to init genesis logic app.moduleManager.SetOrderInitGenesis( ... meshsecprovtypes.ModuleName, ... )
- In
app.go: Add the mesh security wasm message handler decorator to the wasm module.meshMessageHandler := wasmkeeper.WithMessageHandlerDecorator(func(nested wasmkeeper.Messenger) wasmkeeper.Messenger { return wasmkeeper.NewMessageHandlerChain( meshsecprovkeeper.CustomMessageDecorator(app.MeshSecProvKeeper), nested, ) }) wasmOpts = append(wasmOpts, meshMessageHandler)