chore: run modernize (#24356)

This commit is contained in:
Alex | Interchain Labs
2025-04-03 10:42:20 -04:00
committed by GitHub
parent df07789843
commit 3c6deab626
185 changed files with 667 additions and 590 deletions
+2 -2
View File
@@ -163,9 +163,9 @@ func TestGlobalLabelsEventsMarshalling(t *testing.T) {
func TestGlobalLabelsWriteRead(t *testing.T) {
expected := [][]string{{"labelname3", "labelvalue3"}, {"labelname4", "labelvalue4"}}
expectedRaw := make([]interface{}, len(expected))
expectedRaw := make([]any, len(expected))
for i, exp := range expected {
pair := make([]interface{}, len(exp))
pair := make([]any, len(exp))
for j, s := range exp {
pair[j] = s
}
+1 -1
View File
@@ -283,7 +283,7 @@ func SetConfigTemplate(customTemplate string) {
// WriteConfigFile renders config using the template and writes it to
// configFilePath.
func WriteConfigFile(configFilePath string, config interface{}) {
func WriteConfigFile(configFilePath string, config any) {
var buffer bytes.Buffer
if err := configTemplate.Execute(&buffer, config); err != nil {
@@ -309,7 +309,7 @@ func (s *serverReflectionServer) fileDescEncodingByFilename(name string, sentFil
// For SupportPackageIsVersion4, m is the name of the proto file, we
// call proto.FileDescriptor to get the byte slice.
// For SupportPackageIsVersion3, m is a byte slice itself.
func parseMetadata(meta interface{}) ([]byte, bool) {
func parseMetadata(meta any) ([]byte, bool) {
// Check if meta is the file name.
if fileNameForMeta, ok := meta.(string); ok {
return getFileDescriptor(fileNameForMeta), true
+1 -1
View File
@@ -17,7 +17,7 @@ type CometLoggerWrapper struct {
// With returns a new wrapped logger with additional context provided by a set
// of key/value tuples. The number of tuples must be even and the key of the
// tuple must be a string.
func (cmt CometLoggerWrapper) With(keyVals ...interface{}) cmtlog.Logger {
func (cmt CometLoggerWrapper) With(keyVals ...any) cmtlog.Logger {
logger := cmt.Logger.With(keyVals...)
return CometLoggerWrapper{logger}
}
+2 -2
View File
@@ -153,7 +153,7 @@ type MsgServerImpl struct {
capKeyMainStore *storetypes.KVStoreKey
}
func MsgTestHandler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
func MsgTestHandler(srv any, ctx context.Context, dec func(any) error, interceptor grpc.UnaryServerInterceptor) (any, error) {
in := new(KVStoreTx)
if err := dec(in); err != nil {
return nil, err
@@ -165,7 +165,7 @@ func MsgTestHandler(srv interface{}, ctx context.Context, dec func(interface{})
Server: srv,
FullMethod: "/KVStoreTx",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
handler := func(ctx context.Context, req any) (any, error) {
return srv.(MsgServer).Test(ctx, req.(*KVStoreTx))
}
return interceptor(ctx, in, info, handler)
+4 -4
View File
@@ -829,7 +829,7 @@ func testnetify(ctx *Context, testnetAppCreator types.AppCreator, db dbm.DB, tra
state.AppHash = appHash
} else {
// Node was likely stopped via SIGTERM, delete the next block's seen commit
err := blockStoreDB.Delete([]byte(fmt.Sprintf("SC:%v", blockStore.Height()+1)))
err := blockStoreDB.Delete(fmt.Appendf(nil, "SC:%v", blockStore.Height()+1))
if err != nil {
return nil, err
}
@@ -928,19 +928,19 @@ func testnetify(ctx *Context, testnetAppCreator types.AppCreator, db dbm.DB, tra
}
// Modfiy Validators stateDB entry.
err = stateDB.Set([]byte(fmt.Sprintf("validatorsKey:%v", blockStore.Height())), buf)
err = stateDB.Set(fmt.Appendf(nil, "validatorsKey:%v", blockStore.Height()), buf)
if err != nil {
return nil, err
}
// Modify LastValidators stateDB entry.
err = stateDB.Set([]byte(fmt.Sprintf("validatorsKey:%v", blockStore.Height()-1)), buf)
err = stateDB.Set(fmt.Appendf(nil, "validatorsKey:%v", blockStore.Height()-1), buf)
if err != nil {
return nil, err
}
// Modify NextValidators stateDB entry.
err = stateDB.Set([]byte(fmt.Sprintf("validatorsKey:%v", blockStore.Height()+1)), buf)
err = stateDB.Set(fmt.Appendf(nil, "validatorsKey:%v", blockStore.Height()+1), buf)
if err != nil {
return nil, err
}
+1 -1
View File
@@ -28,7 +28,7 @@ type (
// the expected types and could result in type assertion errors. It is recommend
// to either use the cast package or perform manual conversion for safety.
AppOptions interface {
Get(string) interface{}
Get(string) any
}
// Application defines an application interface that wraps abci.Application.
+3 -3
View File
@@ -99,7 +99,7 @@ func bindFlags(basename string, cmd *cobra.Command, v *viper.Viper) (err error)
// InterceptConfigsPreRunHandler is identical to InterceptConfigsAndCreateContext
// except it also sets the server context on the command and the server logger.
func InterceptConfigsPreRunHandler(cmd *cobra.Command, customAppConfigTemplate string, customAppConfig interface{}, cmtConfig *cmtcfg.Config) error {
func InterceptConfigsPreRunHandler(cmd *cobra.Command, customAppConfigTemplate string, customAppConfig any, cmtConfig *cmtcfg.Config) error {
serverCtx, err := InterceptConfigsAndCreateContext(cmd, customAppConfigTemplate, customAppConfig, cmtConfig)
if err != nil {
return err
@@ -126,7 +126,7 @@ func InterceptConfigsPreRunHandler(cmd *cobra.Command, customAppConfigTemplate s
// is used to read and parse the application configuration. Command handlers can
// fetch the server Context to get the CometBFT configuration or to get access
// to Viper.
func InterceptConfigsAndCreateContext(cmd *cobra.Command, customAppConfigTemplate string, customAppConfig interface{}, cmtConfig *cmtcfg.Config) (*Context, error) {
func InterceptConfigsAndCreateContext(cmd *cobra.Command, customAppConfigTemplate string, customAppConfig any, cmtConfig *cmtcfg.Config) (*Context, error) {
serverCtx := NewDefaultContext()
// Get the executable name and configure the viper instance so that environmental
@@ -231,7 +231,7 @@ func SetCmdServerContext(cmd *cobra.Command, serverCtx *Context) error {
// configuration file. The CometBFT configuration file is parsed given a root
// Viper object, whereas the application is parsed with the private package-aware
// viperCfg object.
func interceptConfigs(rootViper *viper.Viper, customAppTemplate string, customConfig interface{}, cmtConfig *cmtcfg.Config) (*cmtcfg.Config, error) {
func interceptConfigs(rootViper *viper.Viper, customAppTemplate string, customConfig any, cmtConfig *cmtcfg.Config) (*cmtcfg.Config, error) {
rootDir := rootViper.GetString(flags.FlagHome)
configPath := filepath.Join(rootDir, "config")
cmtCfgFile := filepath.Join(configPath, "config.toml")
+2 -2
View File
@@ -460,9 +460,9 @@ func TestEmptyMinGasPrices(t *testing.T) {
require.Errorf(t, err, sdkerrors.ErrAppConfig.Error())
}
type mapGetter map[string]interface{}
type mapGetter map[string]any
func (m mapGetter) Get(key string) interface{} {
func (m mapGetter) Get(key string) any {
return m[key]
}