refactor(server/v2): remove unneeded generic type parameters (#20966)

This commit is contained in:
Julien Robert 2024-07-16 11:09:01 +02:00 committed by GitHub
parent 7a387cb175
commit a567229106
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
13 changed files with 82 additions and 87 deletions

View File

@ -14,7 +14,7 @@ import (
"cosmossdk.io/server/v2/api/grpc/gogoreflection"
)
type GRPCServer[AppT serverv2.AppI[T], T transaction.Tx] struct {
type GRPCServer[T transaction.Tx] struct {
logger log.Logger
config *Config
cfgOptions []CfgOption
@ -23,15 +23,15 @@ type GRPCServer[AppT serverv2.AppI[T], T transaction.Tx] struct {
}
// New creates a new grpc server.
func New[AppT serverv2.AppI[T], T transaction.Tx](cfgOptions ...CfgOption) *GRPCServer[AppT, T] {
return &GRPCServer[AppT, T]{
func New[T transaction.Tx](cfgOptions ...CfgOption) *GRPCServer[T] {
return &GRPCServer[T]{
cfgOptions: cfgOptions,
}
}
// Init returns a correctly configured and initialized gRPC server.
// Note, the caller is responsible for starting the server.
func (s *GRPCServer[AppT, T]) Init(appI AppT, v *viper.Viper, logger log.Logger) error {
func (s *GRPCServer[T]) Init(appI serverv2.AppI[T], v *viper.Viper, logger log.Logger) error {
cfg := s.Config().(*Config)
if v != nil {
if err := v.Sub(s.Name()).Unmarshal(&cfg); err != nil {
@ -57,11 +57,11 @@ func (s *GRPCServer[AppT, T]) Init(appI AppT, v *viper.Viper, logger log.Logger)
return nil
}
func (s *GRPCServer[AppT, T]) Name() string {
func (s *GRPCServer[T]) Name() string {
return "grpc"
}
func (s *GRPCServer[AppT, T]) Config() any {
func (s *GRPCServer[T]) Config() any {
if s.config == nil || s.config == (&Config{}) {
cfg := DefaultConfig()
// overwrite the default config with the provided options
@ -75,7 +75,7 @@ func (s *GRPCServer[AppT, T]) Config() any {
return s.config
}
func (s *GRPCServer[AppT, T]) Start(ctx context.Context) error {
func (s *GRPCServer[T]) Start(ctx context.Context) error {
if !s.config.Enable {
return nil
}
@ -102,7 +102,7 @@ func (s *GRPCServer[AppT, T]) Start(ctx context.Context) error {
return err
}
func (s *GRPCServer[AppT, T]) Stop(ctx context.Context) error {
func (s *GRPCServer[T]) Stop(ctx context.Context) error {
if !s.config.Enable {
return nil
}

View File

@ -18,16 +18,14 @@ import (
serverv2 "cosmossdk.io/server/v2"
)
var _ serverv2.ServerComponent[
serverv2.AppI[transaction.Tx], transaction.Tx,
] = (*GRPCGatewayServer[serverv2.AppI[transaction.Tx], transaction.Tx])(nil)
var _ serverv2.ServerComponent[transaction.Tx] = (*GRPCGatewayServer[transaction.Tx])(nil)
const (
// GRPCBlockHeightHeader is the gRPC header for block height.
GRPCBlockHeightHeader = "x-cosmos-block-height"
)
type GRPCGatewayServer[AppT serverv2.AppI[T], T transaction.Tx] struct {
type GRPCGatewayServer[T transaction.Tx] struct {
logger log.Logger
config *Config
cfgOptions []CfgOption
@ -37,7 +35,7 @@ type GRPCGatewayServer[AppT serverv2.AppI[T], T transaction.Tx] struct {
}
// New creates a new gRPC-gateway server.
func New[AppT serverv2.AppI[T], T transaction.Tx](grpcSrv *grpc.Server, ir jsonpb.AnyResolver, cfgOptions ...CfgOption) *GRPCGatewayServer[AppT, T] {
func New[T transaction.Tx](grpcSrv *grpc.Server, ir jsonpb.AnyResolver, cfgOptions ...CfgOption) *GRPCGatewayServer[T] {
// The default JSON marshaller used by the gRPC-Gateway is unable to marshal non-nullable non-scalar fields.
// Using the gogo/gateway package with the gRPC-Gateway WithMarshaler option fixes the scalar field marshaling issue.
marshalerOption := &gateway.JSONPb{
@ -47,7 +45,7 @@ func New[AppT serverv2.AppI[T], T transaction.Tx](grpcSrv *grpc.Server, ir jsonp
AnyResolver: ir,
}
return &GRPCGatewayServer[AppT, T]{
return &GRPCGatewayServer[T]{
GRPCSrv: grpcSrv,
GRPCGatewayRouter: runtime.NewServeMux(
// Custom marshaler option is required for gogo proto
@ -65,11 +63,11 @@ func New[AppT serverv2.AppI[T], T transaction.Tx](grpcSrv *grpc.Server, ir jsonp
}
}
func (g *GRPCGatewayServer[AppT, T]) Name() string {
func (g *GRPCGatewayServer[T]) Name() string {
return "grpc-gateway"
}
func (s *GRPCGatewayServer[AppT, T]) Config() any {
func (s *GRPCGatewayServer[T]) Config() any {
if s.config == nil || s.config == (&Config{}) {
cfg := DefaultConfig()
// overwrite the default config with the provided options
@ -83,7 +81,7 @@ func (s *GRPCGatewayServer[AppT, T]) Config() any {
return s.config
}
func (s *GRPCGatewayServer[AppT, T]) Init(appI AppT, v *viper.Viper, logger log.Logger) error {
func (s *GRPCGatewayServer[T]) Init(appI serverv2.AppI[transaction.Tx], v *viper.Viper, logger log.Logger) error {
cfg := s.Config().(*Config)
if v != nil {
if err := v.Sub(s.Name()).Unmarshal(&cfg); err != nil {
@ -100,7 +98,7 @@ func (s *GRPCGatewayServer[AppT, T]) Init(appI AppT, v *viper.Viper, logger log.
return nil
}
func (s *GRPCGatewayServer[AppT, T]) Start(ctx context.Context) error {
func (s *GRPCGatewayServer[T]) Start(ctx context.Context) error {
if !s.config.Enable {
return nil
}
@ -110,7 +108,7 @@ func (s *GRPCGatewayServer[AppT, T]) Start(ctx context.Context) error {
return nil
}
func (s *GRPCGatewayServer[AppT, T]) Stop(ctx context.Context) error {
func (s *GRPCGatewayServer[T]) Stop(ctx context.Context) error {
if !s.config.Enable {
return nil
}
@ -119,7 +117,7 @@ func (s *GRPCGatewayServer[AppT, T]) Stop(ctx context.Context) error {
}
// Register implements registers a grpc-gateway server
func (s *GRPCGatewayServer[AppT, T]) Register(r mux.Router) error {
func (s *GRPCGatewayServer[T]) Register(r mux.Router) error {
// configure grpc-gatway server
r.PathPrefix("/").Handler(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
// Fall back to grpc gateway server.

View File

@ -28,7 +28,7 @@ import (
"github.com/cosmos/cosmos-sdk/version"
)
func (s *CometBFTServer[AppT, T]) rpcClient(cmd *cobra.Command) (rpc.CometRPC, error) {
func (s *CometBFTServer[T]) rpcClient(cmd *cobra.Command) (rpc.CometRPC, error) {
if s.config.Standalone {
client, err := rpchttp.New(client.GetConfigFromCmd(cmd).RPC.ListenAddress)
if err != nil {
@ -51,7 +51,7 @@ func (s *CometBFTServer[AppT, T]) rpcClient(cmd *cobra.Command) (rpc.CometRPC, e
}
// StatusCommand returns the command to return the status of the network.
func (s *CometBFTServer[AppT, T]) StatusCommand() *cobra.Command {
func (s *CometBFTServer[T]) StatusCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "status",
Short: "Query remote node for status",
@ -82,7 +82,7 @@ func (s *CometBFTServer[AppT, T]) StatusCommand() *cobra.Command {
}
// ShowNodeIDCmd - ported from CometBFT, dump node ID to stdout
func (s *CometBFTServer[AppT, T]) ShowNodeIDCmd() *cobra.Command {
func (s *CometBFTServer[T]) ShowNodeIDCmd() *cobra.Command {
return &cobra.Command{
Use: "show-node-id",
Short: "Show this node's ID",
@ -100,7 +100,7 @@ func (s *CometBFTServer[AppT, T]) ShowNodeIDCmd() *cobra.Command {
}
// ShowValidatorCmd - ported from CometBFT, show this node's validator info
func (s *CometBFTServer[AppT, T]) ShowValidatorCmd() *cobra.Command {
func (s *CometBFTServer[T]) ShowValidatorCmd() *cobra.Command {
cmd := cobra.Command{
Use: "show-validator",
Short: "Show this node's CometBFT validator info",
@ -134,7 +134,7 @@ func (s *CometBFTServer[AppT, T]) ShowValidatorCmd() *cobra.Command {
}
// ShowAddressCmd - show this node's validator address
func (s *CometBFTServer[AppT, T]) ShowAddressCmd() *cobra.Command {
func (s *CometBFTServer[T]) ShowAddressCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "show-address",
Short: "Shows this node's CometBFT validator consensus address",
@ -153,7 +153,7 @@ func (s *CometBFTServer[AppT, T]) ShowAddressCmd() *cobra.Command {
}
// VersionCmd prints CometBFT and ABCI version numbers.
func (s *CometBFTServer[AppT, T]) VersionCmd() *cobra.Command {
func (s *CometBFTServer[T]) VersionCmd() *cobra.Command {
return &cobra.Command{
Use: "version",
Short: "Print CometBFT libraries' version",
@ -181,7 +181,7 @@ func (s *CometBFTServer[AppT, T]) VersionCmd() *cobra.Command {
}
// QueryBlocksCmd returns a command to search through blocks by events.
func (s *CometBFTServer[AppT, T]) QueryBlocksCmd() *cobra.Command {
func (s *CometBFTServer[T]) QueryBlocksCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "blocks",
Short: "Query for paginated blocks that match a set of events",
@ -231,7 +231,7 @@ for. Each module documents its respective events under 'xx_events.md'.
}
// QueryBlockCmd implements the default command for a Block query.
func (s *CometBFTServer[AppT, T]) QueryBlockCmd() *cobra.Command {
func (s *CometBFTServer[T]) QueryBlockCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "block --type=[height|hash] [height|hash]",
Short: "Query for a committed block by height, hash, or event(s)",
@ -318,7 +318,7 @@ $ %s query block --%s=%s <hash>
}
// QueryBlockResultsCmd implements the default command for a BlockResults query.
func (s *CometBFTServer[AppT, T]) QueryBlockResultsCmd() *cobra.Command {
func (s *CometBFTServer[T]) QueryBlockResultsCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "block-results [height]",
Short: "Query for a committed block's results by height",
@ -383,7 +383,7 @@ func parseOptionalHeight(heightStr string) (*int64, error) {
return &tmp, nil
}
func (s *CometBFTServer[AppT, T]) BootstrapStateCmd() *cobra.Command {
func (s *CometBFTServer[T]) BootstrapStateCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "bootstrap-state",
Short: "Bootstrap CometBFT state at an arbitrary block height using a light client",

View File

@ -30,14 +30,12 @@ import (
)
var (
_ serverv2.ServerComponent[
serverv2.AppI[transaction.Tx], transaction.Tx,
] = (*CometBFTServer[serverv2.AppI[transaction.Tx], transaction.Tx])(nil)
_ serverv2.HasCLICommands = (*CometBFTServer[serverv2.AppI[transaction.Tx], transaction.Tx])(nil)
_ serverv2.HasStartFlags = (*CometBFTServer[serverv2.AppI[transaction.Tx], transaction.Tx])(nil)
_ serverv2.ServerComponent[transaction.Tx] = (*CometBFTServer[transaction.Tx])(nil)
_ serverv2.HasCLICommands = (*CometBFTServer[transaction.Tx])(nil)
_ serverv2.HasStartFlags = (*CometBFTServer[transaction.Tx])(nil)
)
type CometBFTServer[AppT serverv2.AppI[T], T transaction.Tx] struct {
type CometBFTServer[T transaction.Tx] struct {
Node *node.Node
Consensus *Consensus[T]
@ -48,15 +46,15 @@ type CometBFTServer[AppT serverv2.AppI[T], T transaction.Tx] struct {
cmtConfigOptions []CmtCfgOption
}
func New[AppT serverv2.AppI[T], T transaction.Tx](txCodec transaction.Codec[T], options ServerOptions[T], cfgOptions ...CmtCfgOption) *CometBFTServer[AppT, T] {
return &CometBFTServer[AppT, T]{
func New[T transaction.Tx](txCodec transaction.Codec[T], options ServerOptions[T], cfgOptions ...CmtCfgOption) *CometBFTServer[T] {
return &CometBFTServer[T]{
initTxCodec: txCodec,
options: options,
cmtConfigOptions: cfgOptions,
}
}
func (s *CometBFTServer[AppT, T]) Init(appI AppT, v *viper.Viper, logger log.Logger) error {
func (s *CometBFTServer[T]) Init(appI serverv2.AppI[T], v *viper.Viper, logger log.Logger) error {
s.config = Config{CmtConfig: GetConfigFromViper(v), ConsensusAuthority: appI.GetConsensusAuthority()}
s.logger = logger.With(log.ModuleKey, s.Name())
@ -85,11 +83,11 @@ func (s *CometBFTServer[AppT, T]) Init(appI AppT, v *viper.Viper, logger log.Log
return nil
}
func (s *CometBFTServer[AppT, T]) Name() string {
func (s *CometBFTServer[T]) Name() string {
return "comet"
}
func (s *CometBFTServer[AppT, T]) Start(ctx context.Context) error {
func (s *CometBFTServer[T]) Start(ctx context.Context) error {
viper := ctx.Value(corectx.ViperContextKey).(*viper.Viper)
cometConfig := GetConfigFromViper(viper)
@ -128,7 +126,7 @@ func (s *CometBFTServer[AppT, T]) Start(ctx context.Context) error {
return s.Node.Start()
}
func (s *CometBFTServer[AppT, T]) Stop(context.Context) error {
func (s *CometBFTServer[T]) Stop(context.Context) error {
if s.Node != nil && s.Node.IsRunning() {
return s.Node.Stop()
}
@ -174,7 +172,7 @@ func getGenDocProvider(cfg *cmtcfg.Config) func() (node.ChecksummedGenesisDoc, e
}
}
func (s *CometBFTServer[AppT, T]) StartCmdFlags() *pflag.FlagSet {
func (s *CometBFTServer[T]) StartCmdFlags() *pflag.FlagSet {
flags := pflag.NewFlagSet("cometbft", pflag.ExitOnError)
flags.Bool(FlagWithComet, true, "Run abci app embedded in-process with CometBFT")
flags.String(FlagAddress, "tcp://127.0.0.1:26658", "Listen address")
@ -189,7 +187,7 @@ func (s *CometBFTServer[AppT, T]) StartCmdFlags() *pflag.FlagSet {
return flags
}
func (s *CometBFTServer[AppT, T]) CLICommands() serverv2.CLIConfig {
func (s *CometBFTServer[T]) CLICommands() serverv2.CLIConfig {
return serverv2.CLIConfig{
Commands: []*cobra.Command{
s.StatusCommand(),
@ -208,7 +206,7 @@ func (s *CometBFTServer[AppT, T]) CLICommands() serverv2.CLIConfig {
}
}
func (s *CometBFTServer[AppT, T]) WriteDefaultConfigAt(configPath string) error {
func (s *CometBFTServer[T]) WriteDefaultConfigAt(configPath string) error {
cometConfig := cmtcfg.DefaultConfig()
for _, opt := range s.cmtConfigOptions {
opt(cometConfig)

View File

@ -35,11 +35,11 @@ func Execute(rootCmd *cobra.Command, envPrefix, defaultHome string) error {
// AddCommands add the server commands to the root command
// It configure the config handling and the logger handling
func AddCommands[AppT AppI[T], T transaction.Tx](
func AddCommands[T transaction.Tx](
rootCmd *cobra.Command,
newApp AppCreator[AppT, T],
newApp AppCreator[T],
logger log.Logger,
components ...ServerComponent[AppT, T],
components ...ServerComponent[T],
) error {
if len(components) == 0 {
return errors.New("no components provided")
@ -96,9 +96,9 @@ func AddCommands[AppT AppI[T], T transaction.Tx](
}
// createStartCommand creates the start command for the application.
func createStartCommand[AppT AppI[T], T transaction.Tx](
server *Server[AppT, T],
newApp AppCreator[AppT, T],
func createStartCommand[T transaction.Tx](
server *Server[T],
newApp AppCreator[T],
) *cobra.Command {
flags := server.StartFlags()
@ -146,7 +146,7 @@ func createStartCommand[AppT AppI[T], T transaction.Tx](
}
// configHandle writes the default config to the home directory if it does not exist and sets the server context
func configHandle[AppT AppI[T], T transaction.Tx](s *Server[AppT, T], cmd *cobra.Command) error {
func configHandle[T transaction.Tx](s *Server[T], cmd *cobra.Command) error {
home, err := cmd.Flags().GetString(FlagHome)
if err != nil {
return err

View File

@ -18,12 +18,12 @@ import (
)
// ServerComponent is a server module that can be started and stopped.
type ServerComponent[AppT AppI[T], T transaction.Tx] interface {
type ServerComponent[T transaction.Tx] interface {
Name() string
Start(context.Context) error
Stop(context.Context) error
Init(AppT, *viper.Viper, log.Logger) error
Init(AppI[T], *viper.Viper, log.Logger) error
}
// HasCLICommands is a server module that has CLI commands.
@ -41,7 +41,7 @@ type HasStartFlags interface {
StartCmdFlags() *pflag.FlagSet
}
var _ ServerComponent[AppI[transaction.Tx], transaction.Tx] = (*Server[AppI[transaction.Tx], transaction.Tx])(nil)
var _ ServerComponent[transaction.Tx] = (*Server[transaction.Tx])(nil)
// ReadConfig returns a viper instance of the config file
func ReadConfig(configPath string) (*viper.Viper, error) {
@ -63,26 +63,27 @@ func ReadConfig(configPath string) (*viper.Viper, error) {
return v, nil
}
type Server[AppT AppI[T], T transaction.Tx] struct {
type Server[T transaction.Tx] struct {
logger log.Logger
components []ServerComponent[AppT, T]
components []ServerComponent[T]
}
func NewServer[AppT AppI[T], T transaction.Tx](
logger log.Logger, components ...ServerComponent[AppT, T],
) *Server[AppT, T] {
return &Server[AppT, T]{
func NewServer[T transaction.Tx](
logger log.Logger,
components ...ServerComponent[T],
) *Server[T] {
return &Server[T]{
logger: logger,
components: components,
}
}
func (s *Server[AppT, T]) Name() string {
func (s *Server[T]) Name() string {
return "server"
}
// Start starts all components concurrently.
func (s *Server[AppT, T]) Start(ctx context.Context) error {
func (s *Server[T]) Start(ctx context.Context) error {
s.logger.Info("starting servers...")
g, ctx := errgroup.WithContext(ctx)
@ -103,7 +104,7 @@ func (s *Server[AppT, T]) Start(ctx context.Context) error {
}
// Stop stops all components concurrently.
func (s *Server[AppT, T]) Stop(ctx context.Context) error {
func (s *Server[T]) Stop(ctx context.Context) error {
s.logger.Info("stopping servers...")
g, ctx := errgroup.WithContext(ctx)
@ -118,7 +119,7 @@ func (s *Server[AppT, T]) Stop(ctx context.Context) error {
}
// CLICommands returns all CLI commands of all components.
func (s *Server[AppT, T]) CLICommands() CLIConfig {
func (s *Server[T]) CLICommands() CLIConfig {
compart := func(name string, cmds ...*cobra.Command) *cobra.Command {
if len(cmds) == 1 && strings.HasPrefix(cmds[0].Use, name) {
return cmds[0]
@ -156,7 +157,7 @@ func (s *Server[AppT, T]) CLICommands() CLIConfig {
}
// Configs returns all configs of all server components.
func (s *Server[AppT, T]) Configs() map[string]any {
func (s *Server[T]) Configs() map[string]any {
cfgs := make(map[string]any)
for _, mod := range s.components {
if configmod, ok := mod.(HasConfig); ok {
@ -170,8 +171,8 @@ func (s *Server[AppT, T]) Configs() map[string]any {
// Init initializes all server components with the provided application, configuration, and logger.
// It returns an error if any component fails to initialize.
func (s *Server[AppT, T]) Init(appI AppT, v *viper.Viper, logger log.Logger) error {
var components []ServerComponent[AppT, T]
func (s *Server[T]) Init(appI AppI[T], v *viper.Viper, logger log.Logger) error {
var components []ServerComponent[T]
for _, mod := range s.components {
mod := mod
if err := mod.Init(appI, v, logger); err != nil {
@ -187,7 +188,7 @@ func (s *Server[AppT, T]) Init(appI AppT, v *viper.Viper, logger log.Logger) err
// WriteConfig writes the config to the given path.
// Note: it does not use viper.WriteConfigAs because we do not want to store flag values in the config.
func (s *Server[AppT, T]) WriteConfig(configPath string) error {
func (s *Server[T]) WriteConfig(configPath string) error {
cfgs := s.Configs()
b, err := toml.Marshal(cfgs)
if err != nil {
@ -219,7 +220,7 @@ func (s *Server[AppT, T]) WriteConfig(configPath string) error {
}
// StartFlags returns all flags of all server components.
func (s *Server[AppT, T]) StartFlags() []*pflag.FlagSet {
func (s *Server[T]) StartFlags() []*pflag.FlagSet {
flags := []*pflag.FlagSet{}
for _, mod := range s.components {
if startmod, ok := mod.(HasStartFlags); ok {

View File

@ -58,7 +58,7 @@ func TestServer(t *testing.T) {
}
logger := log.NewLogger(os.Stdout)
grpcServer := grpc.New[serverv2.AppI[transaction.Tx], transaction.Tx]()
grpcServer := grpc.New[transaction.Tx]()
if err := grpcServer.Init(&mockApp[transaction.Tx]{}, v, logger); err != nil {
t.Log(err)
t.Fail()

View File

@ -9,7 +9,7 @@ import (
"cosmossdk.io/server/v2/appmanager"
)
type AppCreator[AppT AppI[T], T transaction.Tx] func(log.Logger, *viper.Viper) AppT
type AppCreator[T transaction.Tx] func(log.Logger, *viper.Viper) AppI[T]
type AppI[T transaction.Tx] interface {
GetAppManager() *appmanager.AppManager[T]

View File

@ -72,13 +72,13 @@ func (t *temporaryTxDecoder[T]) DecodeJSON(bz []byte) (T, error) {
return out, nil
}
func newApp[AppT serverv2.AppI[T], T transaction.Tx](
func newApp[T transaction.Tx](
logger log.Logger, viper *viper.Viper,
) AppT {
return serverv2.AppI[T](simapp.NewSimApp[T](logger, viper)).(AppT)
) serverv2.AppI[T] {
return serverv2.AppI[T](simapp.NewSimApp[T](logger, viper))
}
func initRootCmd[AppT serverv2.AppI[T], T transaction.Tx](
func initRootCmd[T transaction.Tx](
rootCmd *cobra.Command,
txConfig client.TxConfig,
moduleManager *runtimev2.MM[T],
@ -114,8 +114,8 @@ func initRootCmd[AppT serverv2.AppI[T], T transaction.Tx](
rootCmd,
newApp,
logger,
cometbft.New[AppT, T](&temporaryTxDecoder[T]{txConfig}, cometbft.DefaultServerOptions[T]()),
grpc.New[AppT, T](),
cometbft.New[T](&temporaryTxDecoder[T]{txConfig}, cometbft.DefaultServerOptions[T]()),
grpc.New[T](),
); err != nil {
panic(err)
}

View File

@ -12,7 +12,6 @@ import (
"cosmossdk.io/depinject"
"cosmossdk.io/log"
"cosmossdk.io/runtime/v2"
serverv2 "cosmossdk.io/server/v2"
"cosmossdk.io/simapp/v2"
"cosmossdk.io/x/auth/tx"
authtxconfig "cosmossdk.io/x/auth/tx/config"
@ -26,7 +25,7 @@ import (
)
// NewRootCmd creates a new root command for simd. It is called once in the main function.
func NewRootCmd[AppT serverv2.AppI[T], T transaction.Tx]() *cobra.Command {
func NewRootCmd[T transaction.Tx]() *cobra.Command {
var (
autoCliOpts autocli.AppOptions
moduleManager *runtime.MM[T]
@ -81,7 +80,7 @@ func NewRootCmd[AppT serverv2.AppI[T], T transaction.Tx]() *cobra.Command {
},
}
initRootCmd[AppT, T](rootCmd, clientCtx.TxConfig, moduleManager)
initRootCmd[T](rootCmd, clientCtx.TxConfig, moduleManager)
if err := autoCliOpts.EnhanceRootCommand(rootCmd); err != nil {
panic(err)
}

View File

@ -7,7 +7,6 @@ import (
"github.com/stretchr/testify/require"
"cosmossdk.io/core/transaction"
serverv2 "cosmossdk.io/server/v2"
"cosmossdk.io/simapp/v2"
"cosmossdk.io/simapp/v2/simdv2/cmd"
@ -17,7 +16,7 @@ import (
)
func TestInitCmd(t *testing.T) {
rootCmd := cmd.NewRootCmd[serverv2.AppI[transaction.Tx], transaction.Tx]()
rootCmd := cmd.NewRootCmd[transaction.Tx]()
rootCmd.SetArgs([]string{
"init", // Test the init cmd
"simapp-test", // Moniker
@ -30,7 +29,7 @@ func TestInitCmd(t *testing.T) {
func TestHomeFlagRegistration(t *testing.T) {
homeDir := "/tmp/foo"
rootCmd := cmd.NewRootCmd[serverv2.AppI[transaction.Tx], transaction.Tx]()
rootCmd := cmd.NewRootCmd[transaction.Tx]()
rootCmd.SetArgs([]string{
"query",
fmt.Sprintf("--%s", flags.FlagHome),

View File

@ -336,8 +336,8 @@ func initTestnetFiles[T transaction.Tx](
}
// Write server config
cometServer := cometbft.New[serverv2.AppI[T], T](&temporaryTxDecoder[T]{clientCtx.TxConfig}, cometbft.ServerOptions[T]{}, cometbft.OverwriteDefaultCometConfig(nodeConfig))
grpcServer := grpc.New[serverv2.AppI[T], T](grpc.OverwriteDefaultConfig(grpcConfig))
cometServer := cometbft.New[T](&temporaryTxDecoder[T]{clientCtx.TxConfig}, cometbft.ServerOptions[T]{}, cometbft.OverwriteDefaultCometConfig(nodeConfig))
grpcServer := grpc.New[T](grpc.OverwriteDefaultConfig(grpcConfig))
server := serverv2.NewServer(log.NewNopLogger(), cometServer, grpcServer)
err = server.WriteConfig(filepath.Join(nodeDir, "config"))
if err != nil {

View File

@ -11,7 +11,7 @@ import (
)
func main() {
rootCmd := cmd.NewRootCmd[serverv2.AppI[transaction.Tx], transaction.Tx]()
rootCmd := cmd.NewRootCmd[transaction.Tx]()
if err := serverv2.Execute(rootCmd, "", simapp.DefaultNodeHome); err != nil {
fmt.Fprintln(rootCmd.OutOrStderr(), err)
os.Exit(1)