Documentation ¶
Overview ¶
Package appmodule defines the functionality for registering Cosmos SDK app modules that are assembled using the cosmossdk.io/depinject dependency injection system and the declarative app configuration format handled by the appconfig package.
Index ¶
- Variables
- func RegisterEventListener[E protoiface.MessageV1](registrar *EventListenerRegistrar, listener func(context.Context, E) error)
- type AppModule
- type EventListenerRegistrar
- type GenesisSource
- type GenesisTarget
- type HasBeginBlocker
- type HasEndBlocker
- type HasEventListeners
- type HasGenesis
- type HasPreBlocker
- type HasPrecommit
- type HasPrepareCheckState
- type HasServices
- type Option
- type ResponsePreBlock
- type UpgradeModule
Constants ¶
This section is empty.
Variables ¶
var Invoke = depinjectappconfig.Invoke
Invoke registers invokers to run with depinject. Each invoker will be called at the end of dependency graph configuration in the order in which it was defined. Invokers may not define output parameters, although they may return an error, and all of their input parameters will be marked as optional so that invokers impose no additional constraints on the dependency graph. Invoker functions should nil-check all inputs.
var Provide = depinjectappconfig.Provide
Provide registers providers with the dependency injection system that will be run within the module scope. See cosmossdk.io/depinject for documentation on the dependency injection system.
var Register = depinjectappconfig.RegisterModule
Register registers a module with the global module registry. The provided protobuf message is used only to uniquely identify the protobuf module config type. The instance of the protobuf message used in the actual configuration will be injected into the container and can be requested by a provider function. All module initialization should be handled by the provided options.
Protobuf message types used for module configuration should define the cosmos.app.v1alpha.module option and must explicitly specify go_package to make debugging easier for users.
Functions ¶
func RegisterEventListener ¶ added in v0.5.1
func RegisterEventListener[E protoiface.MessageV1](registrar *EventListenerRegistrar, listener func(context.Context, E) error)
RegisterEventListener registers an event listener for event type E. If a non-nil error is returned by the listener, it will cause the process which emitted the event to fail.
Types ¶
type AppModule ¶ added in v0.3.1
type AppModule interface { depinject.OnePerModuleType // IsAppModule is a dummy method to tag a struct as implementing an AppModule. IsAppModule() }
AppModule is a tag interface for app module implementations to use as a basis for extension interfaces. It provides no functionality itself, but is the type that all valid app modules should provide so that they can be identified by other modules (usually via depinject) as app modules.
type EventListenerRegistrar ¶ added in v0.5.1
type EventListenerRegistrar struct {
// contains filtered or unexported fields
}
EventListenerRegistrar allows registering event listeners.
func (*EventListenerRegistrar) GetListeners ¶ added in v0.5.1
func (e *EventListenerRegistrar) GetListeners() []any
GetListeners gets the event listeners that have been registered
type GenesisSource ¶ added in v0.3.4
type GenesisSource = func(field string) (io.ReadCloser, error)
GenesisSource is a source for genesis data in JSON format. It may abstract over a single JSON object or separate files for each field in a JSON object that can be streamed over. Modules should open a separate io.ReadCloser for each field that is required. When fields represent arrays they can efficiently be streamed over. If there is no data for a field, this function should return nil, nil. It is important that the caller closes the reader when done with it.
type GenesisTarget ¶ added in v0.3.4
type GenesisTarget = func(field string) (io.WriteCloser, error)
GenesisTarget is a target for writing genesis data in JSON format. It may abstract over a single JSON object or JSON in separate files that can be streamed over. Modules should open a separate io.WriteCloser for each field and should prefer writing fields as arrays when possible to support efficient iteration. It is important the caller closers the writer AND checks the error when done with it. It is expected that a stream of JSON data is written to the writer.
type HasBeginBlocker ¶ added in v0.5.0
type HasBeginBlocker interface { AppModule // BeginBlock is a method that will be run before transactions are processed in // a block. BeginBlock(context.Context) error }
HasBeginBlocker is the extension interface that modules should implement to run custom logic before transaction processing in a block.
type HasEndBlocker ¶ added in v0.5.0
type HasEndBlocker interface { AppModule // EndBlock is a method that will be run after transactions are processed in // a block. EndBlock(context.Context) error }
HasEndBlocker is the extension interface that modules should implement to run custom logic after transaction processing in a block.
type HasEventListeners ¶ added in v0.5.1
type HasEventListeners interface { AppModule // RegisterEventListeners registers the module's events listeners. RegisterEventListeners(registrar *EventListenerRegistrar) }
HasEventListeners is the extension interface that modules should implement to register event listeners.
type HasGenesis ¶ added in v0.3.4
type HasGenesis interface { AppModule // DefaultGenesis writes the default genesis for this module to the target. DefaultGenesis(GenesisTarget) error // ValidateGenesis validates the genesis data read from the source. ValidateGenesis(GenesisSource) error // InitGenesis initializes module state from the genesis source. InitGenesis(context.Context, GenesisSource) error // ExportGenesis exports module state to the genesis target. ExportGenesis(context.Context, GenesisTarget) error }
HasGenesis is the extension interface that modules should implement to handle genesis data and state initialization. WARNING: This interface is experimental and may change at any time.
type HasPreBlocker ¶ added in v0.11.0
type HasPreBlocker interface { AppModule // PreBlock is method that will be run before BeginBlock. PreBlock(context.Context) (ResponsePreBlock, error) }
HasPreBlocker is the extension interface that modules should implement to run custom logic before BeginBlock.
type HasPrecommit ¶ added in v0.7.0
HasPrecommit is an extension interface that contains information about the AppModule and Precommit.
type HasPrepareCheckState ¶ added in v0.7.0
HasPrepareCheckState is an extension interface that contains information about the AppModule and PrepareCheckState.
type HasServices ¶ added in v0.5.0
type HasServices interface { AppModule // RegisterServices registers the module's services with the app's service // registrar. // // Two types of services are currently supported: // - read-only gRPC query services, which are the default. // - transaction message services, which must have the protobuf service // option "cosmos.msg.v1.service" (defined in "cosmos/msg/v1/service.proto") // set to true. // // The service registrar will figure out which type of service you are // implementing based on the presence (or absence) of protobuf options. You // do not need to specify this in golang code. RegisterServices(grpc.ServiceRegistrar) error }
HasServices is the extension interface that modules should implement to register implementations of services defined in .proto files.
type Option ¶
type Option = depinjectappconfig.Option
Option is a functional option for implementing modules.
type ResponsePreBlock ¶ added in v0.11.0
type ResponsePreBlock interface {
IsConsensusParamsChanged() bool
}
ResponsePreBlock represents the response from the PreBlock method. It can modify consensus parameters in storage and signal the caller through the return value. When it returns ConsensusParamsChanged=true, the caller must refresh the consensus parameter in the finalize context. The new context (ctx) must be passed to all the other lifecycle methods.
type UpgradeModule ¶ added in v0.10.0
type UpgradeModule interface {
IsUpgradeModule()
}
UpgradeModule is the extension interface that upgrade module should implement to differentiate it from other modules, migration handler need ensure the upgrade module's migration is executed before the rest of the modules.