cosmos-sdk/runtime/services.go
mergify[bot] e135030273
fix(runtime): remove appv1alpha1.Config from runtime (backport #21042) (#21080)
Co-authored-by: Julien Robert <julien@rbrt.fr>
Co-authored-by: marbar3778 <marbar3778@yahoo.com>
2024-07-26 09:08:39 +00:00

49 lines
1.4 KiB
Go

package runtime
import (
"context"
appv1alpha1 "cosmossdk.io/api/cosmos/app/v1alpha1"
autocliv1 "cosmossdk.io/api/cosmos/autocli/v1"
reflectionv1 "cosmossdk.io/api/cosmos/reflection/v1"
"cosmossdk.io/core/comet"
"cosmossdk.io/core/header"
"github.com/cosmos/cosmos-sdk/runtime/services"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/module"
)
func (a *App) registerRuntimeServices(cfg module.Configurator) error {
// no app config service if user is using app.yaml / app.json
// it is as in v0.52, this whole query service does not exist at all.
if a.appConfig != nil {
appv1alpha1.RegisterQueryServer(cfg.QueryServer(), services.NewAppQueryService(a.appConfig))
}
autocliv1.RegisterQueryServer(cfg.QueryServer(), services.NewAutoCLIQueryService(a.ModuleManager.Modules))
reflectionSvc, err := services.NewReflectionService()
if err != nil {
return err
}
reflectionv1.RegisterReflectionServiceServer(cfg.QueryServer(), reflectionSvc)
return nil
}
var _ comet.BlockInfoService = cometInfoService{}
type cometInfoService struct{}
func (cometInfoService) GetCometBlockInfo(ctx context.Context) comet.BlockInfo {
return sdk.UnwrapSDKContext(ctx).CometInfo()
}
var _ header.Service = headerInfoService{}
type headerInfoService struct{}
func (headerInfoService) GetHeaderInfo(ctx context.Context) header.Info {
return sdk.UnwrapSDKContext(ctx).HeaderInfo()
}