From 49ac599d7e939b8ec83fce47c3702d2f7fd0d8b9 Mon Sep 17 00:00:00 2001 From: Danilo Pantani Date: Thu, 25 Jul 2024 23:21:37 +0200 Subject: [PATCH 1/3] feat: add flags to the extension hooks commands (#4270) * add flags to the hook commands * add flags to executed hook cmd * create hook.ImportFlags method * add changelog * Update changelog.md (cherry picked from commit 54e7f526a00999c3f2b1a3729199d664268f4d32) # Conflicts: # ignite/services/plugin/grpc/v1/interface.pb.go --- changelog.md | 17 +++++ ignite/cmd/plugin.go | 19 +++++- .../services/plugin/grpc/v1/client_api.pb.go | 6 +- .../services/plugin/grpc/v1/interface.pb.go | 68 ++++++++++++------- .../plugin/grpc/v1/interface_command.go | 6 +- .../services/plugin/grpc/v1/interface_flag.go | 2 +- .../services/plugin/grpc/v1/interface_hook.go | 7 ++ ignite/services/plugin/grpc/v1/service.pb.go | 28 ++++---- .../plugin/grpc/v1/service_grpc.pb.go | 32 ++++++--- .../services/plugin/grpc/v1/interface.proto | 3 + 10 files changed, 133 insertions(+), 55 deletions(-) diff --git a/changelog.md b/changelog.md index d2dc17d5ed..27de8533f6 100644 --- a/changelog.md +++ b/changelog.md @@ -3,6 +3,23 @@ ## Unreleased ## [`v28.5.1`](https://github.com/ignite/cli/releases/tag/v28.5.1) +### Features + +- [#3707](https://github.com/ignite/cli/pull/3707) and [#4094](https://github.com/ignite/cli/pull/4094) Add collections support. +- [#3977](https://github.com/ignite/cli/pull/3977) Add `chain lint` command to lint the chain's codebase using `golangci-lint` +- [#3770](https://github.com/ignite/cli/pull/3770) Add `scaffold configs` and `scaffold params` commands +- [#4001](https://github.com/ignite/cli/pull/4001) Improve `xgenny` dry run +- [#3967](https://github.com/ignite/cli/issues/3967) Add HD wallet parameters `address index` and `account number` to the chain account config +- [#4004](https://github.com/ignite/cli/pull/4004) Remove all import placeholders using the `xast` pkg +- [#4071](https://github.com/ignite/cli/pull/4071) Support custom proto path +- [#3718](https://github.com/ignite/cli/pull/3718) Add `gen-mig-diffs` tool app to compare scaffold output of two versions of ignite +- [#4100](https://github.com/ignite/cli/pull/4100) Set the `proto-dir` flag only for the `scaffold chain` command and use the proto path from the config +- [#4111](https://github.com/ignite/cli/pull/4111) Remove vuex generation +- [#4113](https://github.com/ignite/cli/pull/4113) Generate chain config documentation automatically +- [#4131](https://github.com/ignite/cli/pull/4131) Support `bytes` as data type in the `scaffold` commands +- [#4270](https://github.com/ignite/cli/pull/4270) Add flags to the extension hooks commands +- [#4269](https://github.com/ignite/cli/pull/4269) Add custom flag parser for extensions +- [#4276](https://github.com/ignite/cli/pull/4276) Add `cosmosclient.CreateTxWithOptions` method to facilite more custom tx creation ### Changes diff --git a/ignite/cmd/plugin.go b/ignite/cmd/plugin.go index dd25b2535b..80132aec1f 100644 --- a/ignite/cmd/plugin.go +++ b/ignite/cmd/plugin.go @@ -180,6 +180,7 @@ func linkPluginHook(rootCmd *cobra.Command, p *plugin.Plugin, hook *plugin.Hook) } newExecutedHook := func(hook *plugin.Hook, cmd *cobra.Command, args []string) *plugin.ExecutedHook { + hook.ImportFlags(cmd) execHook := &plugin.ExecutedHook{ Hook: hook, ExecutedCommand: &plugin.ExecutedCommand{ @@ -188,12 +189,27 @@ func linkPluginHook(rootCmd *cobra.Command, p *plugin.Plugin, hook *plugin.Hook) Args: args, OsArgs: os.Args, With: p.With, + Flags: hook.Flags, }, } execHook.ExecutedCommand.ImportFlags(cmd) return execHook } + for _, f := range hook.Flags { + var fs *flag.FlagSet + if f.Persistent { + fs = cmd.PersistentFlags() + } else { + fs = cmd.Flags() + } + + if err := f.ExportToFlagSet(fs); err != nil { + p.Error = errors.Errorf("can't attach hook flags %q to command %q", hook.Flags, hook.PlaceHookOn) + return + } + } + preRun := cmd.PreRunE cmd.PreRunE = func(cmd *cobra.Command, args []string) error { if preRun != nil { @@ -218,11 +234,10 @@ func linkPluginHook(rootCmd *cobra.Command, p *plugin.Plugin, hook *plugin.Hook) } runCmd := cmd.RunE - cmd.RunE = func(cmd *cobra.Command, args []string) error { if runCmd != nil { err := runCmd(cmd, args) - // if the command has failed the `PostRun` will not execute. here we execute the cleanup step before returnning. + // if the command has failed the `PostRun` will not execute. here we execute the cleanup step before returning. if err != nil { api, err := newAppClientAPI(cmd) if err != nil { diff --git a/ignite/services/plugin/grpc/v1/client_api.pb.go b/ignite/services/plugin/grpc/v1/client_api.pb.go index eb5942fd13..59786f9563 100644 --- a/ignite/services/plugin/grpc/v1/client_api.pb.go +++ b/ignite/services/plugin/grpc/v1/client_api.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 +// protoc-gen-go v1.34.2 // protoc (unknown) // source: ignite/services/plugin/grpc/v1/client_api.proto @@ -137,7 +137,7 @@ func file_ignite_services_plugin_grpc_v1_client_api_proto_rawDescGZIP() []byte { } var file_ignite_services_plugin_grpc_v1_client_api_proto_msgTypes = make([]protoimpl.MessageInfo, 1) -var file_ignite_services_plugin_grpc_v1_client_api_proto_goTypes = []interface{}{ +var file_ignite_services_plugin_grpc_v1_client_api_proto_goTypes = []any{ (*ChainInfo)(nil), // 0: ignite.services.plugin.grpc.v1.ChainInfo } var file_ignite_services_plugin_grpc_v1_client_api_proto_depIdxs = []int32{ @@ -154,7 +154,7 @@ func file_ignite_services_plugin_grpc_v1_client_api_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_ignite_services_plugin_grpc_v1_client_api_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_ignite_services_plugin_grpc_v1_client_api_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*ChainInfo); i { case 0: return &v.state diff --git a/ignite/services/plugin/grpc/v1/interface.pb.go b/ignite/services/plugin/grpc/v1/interface.pb.go index 3c42937d95..90f6658bcc 100644 --- a/ignite/services/plugin/grpc/v1/interface.pb.go +++ b/ignite/services/plugin/grpc/v1/interface.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 +// protoc-gen-go v1.34.2 // protoc (unknown) // source: ignite/services/plugin/grpc/v1/interface.proto @@ -563,6 +563,8 @@ type Hook struct { Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` // Indicates the command where to register the hooks. PlaceHookOn string `protobuf:"bytes,2,opt,name=place_hook_on,json=placeHookOn,proto3" json:"place_hook_on,omitempty"` + // Flags holds the list of command flags. + Flags []*Flag `protobuf:"bytes,3,rep,name=flags,proto3" json:"flags,omitempty"` } func (x *Hook) Reset() { @@ -611,6 +613,13 @@ func (x *Hook) GetPlaceHookOn() string { return "" } +func (x *Hook) GetFlags() []*Flag { + if x != nil { + return x.Flags + } + return nil +} + var File_ignite_services_plugin_grpc_v1_interface_proto protoreflect.FileDescriptor var file_ignite_services_plugin_grpc_v1_interface_proto_rawDesc = []byte{ @@ -704,15 +713,27 @@ var file_ignite_services_plugin_grpc_v1_interface_proto_rawDesc = []byte{ 0x55, 0x49, 0x4e, 0x54, 0x36, 0x34, 0x10, 0x04, 0x12, 0x12, 0x0a, 0x0e, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x46, 0x4c, 0x41, 0x47, 0x5f, 0x42, 0x4f, 0x4f, 0x4c, 0x10, 0x05, 0x12, 0x1a, 0x0a, 0x16, 0x54, 0x59, 0x50, 0x45, 0x5f, 0x46, 0x4c, 0x41, 0x47, 0x5f, 0x53, 0x54, 0x52, 0x49, 0x4e, 0x47, - 0x5f, 0x53, 0x4c, 0x49, 0x43, 0x45, 0x10, 0x06, 0x22, 0x3e, 0x0a, 0x04, 0x48, 0x6f, 0x6f, 0x6b, + 0x5f, 0x53, 0x4c, 0x49, 0x43, 0x45, 0x10, 0x06, 0x22, 0x7a, 0x0a, 0x04, 0x48, 0x6f, 0x6f, 0x6b, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x22, 0x0a, 0x0d, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x5f, 0x68, 0x6f, 0x6f, 0x6b, 0x5f, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x70, 0x6c, 0x61, +<<<<<<< HEAD 0x63, 0x65, 0x48, 0x6f, 0x6f, 0x6b, 0x4f, 0x6e, 0x42, 0x3a, 0x5a, 0x38, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x69, 0x67, 0x6e, 0x69, 0x74, 0x65, 0x2f, 0x63, 0x6c, 0x69, 0x2f, 0x76, 0x32, 0x38, 0x2f, 0x69, 0x67, 0x6e, 0x69, 0x74, 0x65, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2f, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +======= + 0x63, 0x65, 0x48, 0x6f, 0x6f, 0x6b, 0x4f, 0x6e, 0x12, 0x3a, 0x0a, 0x05, 0x66, 0x6c, 0x61, 0x67, + 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x69, 0x67, 0x6e, 0x69, 0x74, 0x65, + 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, + 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x76, 0x31, 0x2e, 0x46, 0x6c, 0x61, 0x67, 0x52, 0x05, 0x66, + 0x6c, 0x61, 0x67, 0x73, 0x42, 0x3a, 0x5a, 0x38, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, + 0x6f, 0x6d, 0x2f, 0x69, 0x67, 0x6e, 0x69, 0x74, 0x65, 0x2f, 0x63, 0x6c, 0x69, 0x2f, 0x76, 0x32, + 0x39, 0x2f, 0x69, 0x67, 0x6e, 0x69, 0x74, 0x65, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, + 0x73, 0x2f, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x76, 0x31, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +>>>>>>> 54e7f526 (feat: add flags to the extension hooks commands (#4270)) } var ( @@ -729,7 +750,7 @@ func file_ignite_services_plugin_grpc_v1_interface_proto_rawDescGZIP() []byte { var file_ignite_services_plugin_grpc_v1_interface_proto_enumTypes = make([]protoimpl.EnumInfo, 1) var file_ignite_services_plugin_grpc_v1_interface_proto_msgTypes = make([]protoimpl.MessageInfo, 7) -var file_ignite_services_plugin_grpc_v1_interface_proto_goTypes = []interface{}{ +var file_ignite_services_plugin_grpc_v1_interface_proto_goTypes = []any{ (Flag_Type)(0), // 0: ignite.services.plugin.grpc.v1.Flag.Type (*ExecutedCommand)(nil), // 1: ignite.services.plugin.grpc.v1.ExecutedCommand (*ExecutedHook)(nil), // 2: ignite.services.plugin.grpc.v1.ExecutedHook @@ -740,20 +761,21 @@ var file_ignite_services_plugin_grpc_v1_interface_proto_goTypes = []interface{}{ nil, // 7: ignite.services.plugin.grpc.v1.ExecutedCommand.WithEntry } var file_ignite_services_plugin_grpc_v1_interface_proto_depIdxs = []int32{ - 7, // 0: ignite.services.plugin.grpc.v1.ExecutedCommand.with:type_name -> ignite.services.plugin.grpc.v1.ExecutedCommand.WithEntry - 5, // 1: ignite.services.plugin.grpc.v1.ExecutedCommand.flags:type_name -> ignite.services.plugin.grpc.v1.Flag - 6, // 2: ignite.services.plugin.grpc.v1.ExecutedHook.hook:type_name -> ignite.services.plugin.grpc.v1.Hook - 1, // 3: ignite.services.plugin.grpc.v1.ExecutedHook.executed_command:type_name -> ignite.services.plugin.grpc.v1.ExecutedCommand - 4, // 4: ignite.services.plugin.grpc.v1.Manifest.commands:type_name -> ignite.services.plugin.grpc.v1.Command - 6, // 5: ignite.services.plugin.grpc.v1.Manifest.hooks:type_name -> ignite.services.plugin.grpc.v1.Hook - 5, // 6: ignite.services.plugin.grpc.v1.Command.flags:type_name -> ignite.services.plugin.grpc.v1.Flag - 4, // 7: ignite.services.plugin.grpc.v1.Command.commands:type_name -> ignite.services.plugin.grpc.v1.Command - 0, // 8: ignite.services.plugin.grpc.v1.Flag.type:type_name -> ignite.services.plugin.grpc.v1.Flag.Type - 9, // [9:9] is the sub-list for method output_type - 9, // [9:9] is the sub-list for method input_type - 9, // [9:9] is the sub-list for extension type_name - 9, // [9:9] is the sub-list for extension extendee - 0, // [0:9] is the sub-list for field type_name + 7, // 0: ignite.services.plugin.grpc.v1.ExecutedCommand.with:type_name -> ignite.services.plugin.grpc.v1.ExecutedCommand.WithEntry + 5, // 1: ignite.services.plugin.grpc.v1.ExecutedCommand.flags:type_name -> ignite.services.plugin.grpc.v1.Flag + 6, // 2: ignite.services.plugin.grpc.v1.ExecutedHook.hook:type_name -> ignite.services.plugin.grpc.v1.Hook + 1, // 3: ignite.services.plugin.grpc.v1.ExecutedHook.executed_command:type_name -> ignite.services.plugin.grpc.v1.ExecutedCommand + 4, // 4: ignite.services.plugin.grpc.v1.Manifest.commands:type_name -> ignite.services.plugin.grpc.v1.Command + 6, // 5: ignite.services.plugin.grpc.v1.Manifest.hooks:type_name -> ignite.services.plugin.grpc.v1.Hook + 5, // 6: ignite.services.plugin.grpc.v1.Command.flags:type_name -> ignite.services.plugin.grpc.v1.Flag + 4, // 7: ignite.services.plugin.grpc.v1.Command.commands:type_name -> ignite.services.plugin.grpc.v1.Command + 0, // 8: ignite.services.plugin.grpc.v1.Flag.type:type_name -> ignite.services.plugin.grpc.v1.Flag.Type + 5, // 9: ignite.services.plugin.grpc.v1.Hook.flags:type_name -> ignite.services.plugin.grpc.v1.Flag + 10, // [10:10] is the sub-list for method output_type + 10, // [10:10] is the sub-list for method input_type + 10, // [10:10] is the sub-list for extension type_name + 10, // [10:10] is the sub-list for extension extendee + 0, // [0:10] is the sub-list for field type_name } func init() { file_ignite_services_plugin_grpc_v1_interface_proto_init() } @@ -762,7 +784,7 @@ func file_ignite_services_plugin_grpc_v1_interface_proto_init() { return } if !protoimpl.UnsafeEnabled { - file_ignite_services_plugin_grpc_v1_interface_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_ignite_services_plugin_grpc_v1_interface_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*ExecutedCommand); i { case 0: return &v.state @@ -774,7 +796,7 @@ func file_ignite_services_plugin_grpc_v1_interface_proto_init() { return nil } } - file_ignite_services_plugin_grpc_v1_interface_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_ignite_services_plugin_grpc_v1_interface_proto_msgTypes[1].Exporter = func(v any, i int) any { switch v := v.(*ExecutedHook); i { case 0: return &v.state @@ -786,7 +808,7 @@ func file_ignite_services_plugin_grpc_v1_interface_proto_init() { return nil } } - file_ignite_services_plugin_grpc_v1_interface_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + file_ignite_services_plugin_grpc_v1_interface_proto_msgTypes[2].Exporter = func(v any, i int) any { switch v := v.(*Manifest); i { case 0: return &v.state @@ -798,7 +820,7 @@ func file_ignite_services_plugin_grpc_v1_interface_proto_init() { return nil } } - file_ignite_services_plugin_grpc_v1_interface_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + file_ignite_services_plugin_grpc_v1_interface_proto_msgTypes[3].Exporter = func(v any, i int) any { switch v := v.(*Command); i { case 0: return &v.state @@ -810,7 +832,7 @@ func file_ignite_services_plugin_grpc_v1_interface_proto_init() { return nil } } - file_ignite_services_plugin_grpc_v1_interface_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + file_ignite_services_plugin_grpc_v1_interface_proto_msgTypes[4].Exporter = func(v any, i int) any { switch v := v.(*Flag); i { case 0: return &v.state @@ -822,7 +844,7 @@ func file_ignite_services_plugin_grpc_v1_interface_proto_init() { return nil } } - file_ignite_services_plugin_grpc_v1_interface_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + file_ignite_services_plugin_grpc_v1_interface_proto_msgTypes[5].Exporter = func(v any, i int) any { switch v := v.(*Hook); i { case 0: return &v.state diff --git a/ignite/services/plugin/grpc/v1/interface_command.go b/ignite/services/plugin/grpc/v1/interface_command.go index c396c75146..01721f966c 100644 --- a/ignite/services/plugin/grpc/v1/interface_command.go +++ b/ignite/services/plugin/grpc/v1/interface_command.go @@ -32,7 +32,7 @@ func (c *Command) ToCobraCommand() (*cobra.Command, error) { fs = cmd.Flags() } - if err := f.exportToFlagSet(fs); err != nil { + if err := f.ExportToFlagSet(fs); err != nil { return nil, err } } @@ -54,7 +54,7 @@ func (c *ExecutedCommand) NewFlags() (*pflag.FlagSet, error) { continue } - if err := f.exportToFlagSet(fs); err != nil { + if err := f.ExportToFlagSet(fs); err != nil { return nil, err } } @@ -71,7 +71,7 @@ func (c *ExecutedCommand) NewPersistentFlags() (*pflag.FlagSet, error) { continue } - if err := f.exportToFlagSet(fs); err != nil { + if err := f.ExportToFlagSet(fs); err != nil { return nil, err } } diff --git a/ignite/services/plugin/grpc/v1/interface_flag.go b/ignite/services/plugin/grpc/v1/interface_flag.go index 142cf8ebf3..8ca199bf84 100644 --- a/ignite/services/plugin/grpc/v1/interface_flag.go +++ b/ignite/services/plugin/grpc/v1/interface_flag.go @@ -33,7 +33,7 @@ func newDefaultFlagValueError(typeName, value string) error { return errors.Errorf("invalid default value for plugin command %s flag: %s", typeName, value) } -func (f *Flag) exportToFlagSet(fs *pflag.FlagSet) error { +func (f *Flag) ExportToFlagSet(fs *pflag.FlagSet) error { switch f.Type { //nolint:exhaustive case Flag_TYPE_FLAG_BOOL, Flag_TYPE_FLAG_INT, diff --git a/ignite/services/plugin/grpc/v1/interface_hook.go b/ignite/services/plugin/grpc/v1/interface_hook.go index db5d02484a..bb39ef945e 100644 --- a/ignite/services/plugin/grpc/v1/interface_hook.go +++ b/ignite/services/plugin/grpc/v1/interface_hook.go @@ -1,6 +1,13 @@ package v1 +import "github.com/spf13/cobra" + // CommandPath returns the absolute command path including the binary name as prefix. func (h *Hook) CommandPath() string { return ensureFullCommandPath(h.PlaceHookOn) } + +// ImportFlags imports flags from a Cobra command. +func (h *Hook) ImportFlags(cmd *cobra.Command) { + h.Flags = extractCobraFlags(cmd) +} diff --git a/ignite/services/plugin/grpc/v1/service.pb.go b/ignite/services/plugin/grpc/v1/service.pb.go index a80f1ca676..7f305f0b3d 100644 --- a/ignite/services/plugin/grpc/v1/service.pb.go +++ b/ignite/services/plugin/grpc/v1/service.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: -// protoc-gen-go v1.32.0 +// protoc-gen-go v1.34.2 // protoc (unknown) // source: ignite/services/plugin/grpc/v1/service.proto @@ -697,7 +697,7 @@ func file_ignite_services_plugin_grpc_v1_service_proto_rawDescGZIP() []byte { } var file_ignite_services_plugin_grpc_v1_service_proto_msgTypes = make([]protoimpl.MessageInfo, 12) -var file_ignite_services_plugin_grpc_v1_service_proto_goTypes = []interface{}{ +var file_ignite_services_plugin_grpc_v1_service_proto_goTypes = []any{ (*ManifestRequest)(nil), // 0: ignite.services.plugin.grpc.v1.ManifestRequest (*ManifestResponse)(nil), // 1: ignite.services.plugin.grpc.v1.ManifestResponse (*ExecuteRequest)(nil), // 2: ignite.services.plugin.grpc.v1.ExecuteRequest @@ -749,7 +749,7 @@ func file_ignite_services_plugin_grpc_v1_service_proto_init() { file_ignite_services_plugin_grpc_v1_client_api_proto_init() file_ignite_services_plugin_grpc_v1_interface_proto_init() if !protoimpl.UnsafeEnabled { - file_ignite_services_plugin_grpc_v1_service_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + file_ignite_services_plugin_grpc_v1_service_proto_msgTypes[0].Exporter = func(v any, i int) any { switch v := v.(*ManifestRequest); i { case 0: return &v.state @@ -761,7 +761,7 @@ func file_ignite_services_plugin_grpc_v1_service_proto_init() { return nil } } - file_ignite_services_plugin_grpc_v1_service_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + file_ignite_services_plugin_grpc_v1_service_proto_msgTypes[1].Exporter = func(v any, i int) any { switch v := v.(*ManifestResponse); i { case 0: return &v.state @@ -773,7 +773,7 @@ func file_ignite_services_plugin_grpc_v1_service_proto_init() { return nil } } - file_ignite_services_plugin_grpc_v1_service_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + file_ignite_services_plugin_grpc_v1_service_proto_msgTypes[2].Exporter = func(v any, i int) any { switch v := v.(*ExecuteRequest); i { case 0: return &v.state @@ -785,7 +785,7 @@ func file_ignite_services_plugin_grpc_v1_service_proto_init() { return nil } } - file_ignite_services_plugin_grpc_v1_service_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + file_ignite_services_plugin_grpc_v1_service_proto_msgTypes[3].Exporter = func(v any, i int) any { switch v := v.(*ExecuteResponse); i { case 0: return &v.state @@ -797,7 +797,7 @@ func file_ignite_services_plugin_grpc_v1_service_proto_init() { return nil } } - file_ignite_services_plugin_grpc_v1_service_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + file_ignite_services_plugin_grpc_v1_service_proto_msgTypes[4].Exporter = func(v any, i int) any { switch v := v.(*ExecuteHookPreRequest); i { case 0: return &v.state @@ -809,7 +809,7 @@ func file_ignite_services_plugin_grpc_v1_service_proto_init() { return nil } } - file_ignite_services_plugin_grpc_v1_service_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + file_ignite_services_plugin_grpc_v1_service_proto_msgTypes[5].Exporter = func(v any, i int) any { switch v := v.(*ExecuteHookPreResponse); i { case 0: return &v.state @@ -821,7 +821,7 @@ func file_ignite_services_plugin_grpc_v1_service_proto_init() { return nil } } - file_ignite_services_plugin_grpc_v1_service_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + file_ignite_services_plugin_grpc_v1_service_proto_msgTypes[6].Exporter = func(v any, i int) any { switch v := v.(*ExecuteHookPostRequest); i { case 0: return &v.state @@ -833,7 +833,7 @@ func file_ignite_services_plugin_grpc_v1_service_proto_init() { return nil } } - file_ignite_services_plugin_grpc_v1_service_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + file_ignite_services_plugin_grpc_v1_service_proto_msgTypes[7].Exporter = func(v any, i int) any { switch v := v.(*ExecuteHookPostResponse); i { case 0: return &v.state @@ -845,7 +845,7 @@ func file_ignite_services_plugin_grpc_v1_service_proto_init() { return nil } } - file_ignite_services_plugin_grpc_v1_service_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + file_ignite_services_plugin_grpc_v1_service_proto_msgTypes[8].Exporter = func(v any, i int) any { switch v := v.(*ExecuteHookCleanUpRequest); i { case 0: return &v.state @@ -857,7 +857,7 @@ func file_ignite_services_plugin_grpc_v1_service_proto_init() { return nil } } - file_ignite_services_plugin_grpc_v1_service_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + file_ignite_services_plugin_grpc_v1_service_proto_msgTypes[9].Exporter = func(v any, i int) any { switch v := v.(*ExecuteHookCleanUpResponse); i { case 0: return &v.state @@ -869,7 +869,7 @@ func file_ignite_services_plugin_grpc_v1_service_proto_init() { return nil } } - file_ignite_services_plugin_grpc_v1_service_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + file_ignite_services_plugin_grpc_v1_service_proto_msgTypes[10].Exporter = func(v any, i int) any { switch v := v.(*GetChainInfoRequest); i { case 0: return &v.state @@ -881,7 +881,7 @@ func file_ignite_services_plugin_grpc_v1_service_proto_init() { return nil } } - file_ignite_services_plugin_grpc_v1_service_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { + file_ignite_services_plugin_grpc_v1_service_proto_msgTypes[11].Exporter = func(v any, i int) any { switch v := v.(*GetChainInfoResponse); i { case 0: return &v.state diff --git a/ignite/services/plugin/grpc/v1/service_grpc.pb.go b/ignite/services/plugin/grpc/v1/service_grpc.pb.go index 759410d156..f40fafe16d 100644 --- a/ignite/services/plugin/grpc/v1/service_grpc.pb.go +++ b/ignite/services/plugin/grpc/v1/service_grpc.pb.go @@ -1,6 +1,6 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: -// - protoc-gen-go-grpc v1.3.0 +// - protoc-gen-go-grpc v1.4.0 // - protoc (unknown) // source: ignite/services/plugin/grpc/v1/service.proto @@ -16,8 +16,8 @@ import ( // This is a compile-time assertion to ensure that this generated file // is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.32.0 or later. -const _ = grpc.SupportPackageIsVersion7 +// Requires gRPC-Go v1.62.0 or later. +const _ = grpc.SupportPackageIsVersion8 const ( InterfaceService_Manifest_FullMethodName = "/ignite.services.plugin.grpc.v1.InterfaceService/Manifest" @@ -30,6 +30,8 @@ const ( // InterfaceServiceClient is the client API for InterfaceService service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +// +// InterfaceService defines the interface that must be implemented by all plugins. type InterfaceServiceClient interface { // Manifest declares the plugin's Command(s) and Hook(s). Manifest(ctx context.Context, in *ManifestRequest, opts ...grpc.CallOption) (*ManifestResponse, error) @@ -64,8 +66,9 @@ func NewInterfaceServiceClient(cc grpc.ClientConnInterface) InterfaceServiceClie } func (c *interfaceServiceClient) Manifest(ctx context.Context, in *ManifestRequest, opts ...grpc.CallOption) (*ManifestResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(ManifestResponse) - err := c.cc.Invoke(ctx, InterfaceService_Manifest_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, InterfaceService_Manifest_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -73,8 +76,9 @@ func (c *interfaceServiceClient) Manifest(ctx context.Context, in *ManifestReque } func (c *interfaceServiceClient) Execute(ctx context.Context, in *ExecuteRequest, opts ...grpc.CallOption) (*ExecuteResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(ExecuteResponse) - err := c.cc.Invoke(ctx, InterfaceService_Execute_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, InterfaceService_Execute_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -82,8 +86,9 @@ func (c *interfaceServiceClient) Execute(ctx context.Context, in *ExecuteRequest } func (c *interfaceServiceClient) ExecuteHookPre(ctx context.Context, in *ExecuteHookPreRequest, opts ...grpc.CallOption) (*ExecuteHookPreResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(ExecuteHookPreResponse) - err := c.cc.Invoke(ctx, InterfaceService_ExecuteHookPre_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, InterfaceService_ExecuteHookPre_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -91,8 +96,9 @@ func (c *interfaceServiceClient) ExecuteHookPre(ctx context.Context, in *Execute } func (c *interfaceServiceClient) ExecuteHookPost(ctx context.Context, in *ExecuteHookPostRequest, opts ...grpc.CallOption) (*ExecuteHookPostResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(ExecuteHookPostResponse) - err := c.cc.Invoke(ctx, InterfaceService_ExecuteHookPost_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, InterfaceService_ExecuteHookPost_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -100,8 +106,9 @@ func (c *interfaceServiceClient) ExecuteHookPost(ctx context.Context, in *Execut } func (c *interfaceServiceClient) ExecuteHookCleanUp(ctx context.Context, in *ExecuteHookCleanUpRequest, opts ...grpc.CallOption) (*ExecuteHookCleanUpResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(ExecuteHookCleanUpResponse) - err := c.cc.Invoke(ctx, InterfaceService_ExecuteHookCleanUp_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, InterfaceService_ExecuteHookCleanUp_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -111,6 +118,8 @@ func (c *interfaceServiceClient) ExecuteHookCleanUp(ctx context.Context, in *Exe // InterfaceServiceServer is the server API for InterfaceService service. // All implementations must embed UnimplementedInterfaceServiceServer // for forward compatibility +// +// InterfaceService defines the interface that must be implemented by all plugins. type InterfaceServiceServer interface { // Manifest declares the plugin's Command(s) and Hook(s). Manifest(context.Context, *ManifestRequest) (*ManifestResponse, error) @@ -298,6 +307,8 @@ const ( // ClientAPIServiceClient is the client API for ClientAPIService service. // // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +// +// ClientAPIService defines the interface that allows plugins to get chain app analysis info. type ClientAPIServiceClient interface { // GetChainInfo returns basic chain info for the configured app GetChainInfo(ctx context.Context, in *GetChainInfoRequest, opts ...grpc.CallOption) (*GetChainInfoResponse, error) @@ -312,8 +323,9 @@ func NewClientAPIServiceClient(cc grpc.ClientConnInterface) ClientAPIServiceClie } func (c *clientAPIServiceClient) GetChainInfo(ctx context.Context, in *GetChainInfoRequest, opts ...grpc.CallOption) (*GetChainInfoResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(GetChainInfoResponse) - err := c.cc.Invoke(ctx, ClientAPIService_GetChainInfo_FullMethodName, in, out, opts...) + err := c.cc.Invoke(ctx, ClientAPIService_GetChainInfo_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } @@ -323,6 +335,8 @@ func (c *clientAPIServiceClient) GetChainInfo(ctx context.Context, in *GetChainI // ClientAPIServiceServer is the server API for ClientAPIService service. // All implementations must embed UnimplementedClientAPIServiceServer // for forward compatibility +// +// ClientAPIService defines the interface that allows plugins to get chain app analysis info. type ClientAPIServiceServer interface { // GetChainInfo returns basic chain info for the configured app GetChainInfo(context.Context, *GetChainInfoRequest) (*GetChainInfoResponse, error) diff --git a/proto/ignite/services/plugin/grpc/v1/interface.proto b/proto/ignite/services/plugin/grpc/v1/interface.proto index ed1b9bae71..1ee10e6fa4 100644 --- a/proto/ignite/services/plugin/grpc/v1/interface.proto +++ b/proto/ignite/services/plugin/grpc/v1/interface.proto @@ -144,4 +144,7 @@ message Hook { // Indicates the command where to register the hooks. string place_hook_on = 2; + + // Flags holds the list of command flags. + repeated Flag flags = 3; } From 9e34c840b001352188b4a01ace939971d966c782 Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Fri, 26 Jul 2024 15:56:03 +0200 Subject: [PATCH 2/3] `make proto-gen` --- ignite/services/plugin/grpc/v1/client_api.pb.go | 5 ++--- ignite/services/plugin/grpc/v1/interface.pb.go | 15 +++------------ ignite/services/plugin/grpc/v1/service.pb.go | 5 ++--- ignite/services/plugin/grpc/v1/service_grpc.pb.go | 1 - 4 files changed, 7 insertions(+), 19 deletions(-) diff --git a/ignite/services/plugin/grpc/v1/client_api.pb.go b/ignite/services/plugin/grpc/v1/client_api.pb.go index 59786f9563..cf40d105f9 100644 --- a/ignite/services/plugin/grpc/v1/client_api.pb.go +++ b/ignite/services/plugin/grpc/v1/client_api.pb.go @@ -7,11 +7,10 @@ package v1 import ( - reflect "reflect" - sync "sync" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" ) const ( diff --git a/ignite/services/plugin/grpc/v1/interface.pb.go b/ignite/services/plugin/grpc/v1/interface.pb.go index 90f6658bcc..159d27ce27 100644 --- a/ignite/services/plugin/grpc/v1/interface.pb.go +++ b/ignite/services/plugin/grpc/v1/interface.pb.go @@ -7,11 +7,10 @@ package v1 import ( - reflect "reflect" - sync "sync" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" ) const ( @@ -717,23 +716,15 @@ var file_ignite_services_plugin_grpc_v1_interface_proto_rawDesc = []byte{ 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x22, 0x0a, 0x0d, 0x70, 0x6c, 0x61, 0x63, 0x65, 0x5f, 0x68, 0x6f, 0x6f, 0x6b, 0x5f, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x70, 0x6c, 0x61, -<<<<<<< HEAD - 0x63, 0x65, 0x48, 0x6f, 0x6f, 0x6b, 0x4f, 0x6e, 0x42, 0x3a, 0x5a, 0x38, 0x67, 0x69, 0x74, 0x68, - 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x69, 0x67, 0x6e, 0x69, 0x74, 0x65, 0x2f, 0x63, 0x6c, - 0x69, 0x2f, 0x76, 0x32, 0x38, 0x2f, 0x69, 0x67, 0x6e, 0x69, 0x74, 0x65, 0x2f, 0x73, 0x65, 0x72, - 0x76, 0x69, 0x63, 0x65, 0x73, 0x2f, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2f, 0x67, 0x72, 0x70, - 0x63, 0x2f, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -======= 0x63, 0x65, 0x48, 0x6f, 0x6f, 0x6b, 0x4f, 0x6e, 0x12, 0x3a, 0x0a, 0x05, 0x66, 0x6c, 0x61, 0x67, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x69, 0x67, 0x6e, 0x69, 0x74, 0x65, 0x2e, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2e, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x76, 0x31, 0x2e, 0x46, 0x6c, 0x61, 0x67, 0x52, 0x05, 0x66, 0x6c, 0x61, 0x67, 0x73, 0x42, 0x3a, 0x5a, 0x38, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x69, 0x67, 0x6e, 0x69, 0x74, 0x65, 0x2f, 0x63, 0x6c, 0x69, 0x2f, 0x76, 0x32, - 0x39, 0x2f, 0x69, 0x67, 0x6e, 0x69, 0x74, 0x65, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, + 0x38, 0x2f, 0x69, 0x67, 0x6e, 0x69, 0x74, 0x65, 0x2f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73, 0x2f, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, ->>>>>>> 54e7f526 (feat: add flags to the extension hooks commands (#4270)) } var ( diff --git a/ignite/services/plugin/grpc/v1/service.pb.go b/ignite/services/plugin/grpc/v1/service.pb.go index 7f305f0b3d..e4acca07b7 100644 --- a/ignite/services/plugin/grpc/v1/service.pb.go +++ b/ignite/services/plugin/grpc/v1/service.pb.go @@ -7,11 +7,10 @@ package v1 import ( - reflect "reflect" - sync "sync" - protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" ) const ( diff --git a/ignite/services/plugin/grpc/v1/service_grpc.pb.go b/ignite/services/plugin/grpc/v1/service_grpc.pb.go index f40fafe16d..2d8a0637d0 100644 --- a/ignite/services/plugin/grpc/v1/service_grpc.pb.go +++ b/ignite/services/plugin/grpc/v1/service_grpc.pb.go @@ -8,7 +8,6 @@ package v1 import ( context "context" - grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" From a8e011731772f925334444361139c95fe9c0f481 Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Fri, 26 Jul 2024 15:57:03 +0200 Subject: [PATCH 3/3] updates --- changelog.md | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/changelog.md b/changelog.md index 27de8533f6..98b822786d 100644 --- a/changelog.md +++ b/changelog.md @@ -3,28 +3,12 @@ ## Unreleased ## [`v28.5.1`](https://github.com/ignite/cli/releases/tag/v28.5.1) -### Features - -- [#3707](https://github.com/ignite/cli/pull/3707) and [#4094](https://github.com/ignite/cli/pull/4094) Add collections support. -- [#3977](https://github.com/ignite/cli/pull/3977) Add `chain lint` command to lint the chain's codebase using `golangci-lint` -- [#3770](https://github.com/ignite/cli/pull/3770) Add `scaffold configs` and `scaffold params` commands -- [#4001](https://github.com/ignite/cli/pull/4001) Improve `xgenny` dry run -- [#3967](https://github.com/ignite/cli/issues/3967) Add HD wallet parameters `address index` and `account number` to the chain account config -- [#4004](https://github.com/ignite/cli/pull/4004) Remove all import placeholders using the `xast` pkg -- [#4071](https://github.com/ignite/cli/pull/4071) Support custom proto path -- [#3718](https://github.com/ignite/cli/pull/3718) Add `gen-mig-diffs` tool app to compare scaffold output of two versions of ignite -- [#4100](https://github.com/ignite/cli/pull/4100) Set the `proto-dir` flag only for the `scaffold chain` command and use the proto path from the config -- [#4111](https://github.com/ignite/cli/pull/4111) Remove vuex generation -- [#4113](https://github.com/ignite/cli/pull/4113) Generate chain config documentation automatically -- [#4131](https://github.com/ignite/cli/pull/4131) Support `bytes` as data type in the `scaffold` commands -- [#4270](https://github.com/ignite/cli/pull/4270) Add flags to the extension hooks commands -- [#4269](https://github.com/ignite/cli/pull/4269) Add custom flag parser for extensions -- [#4276](https://github.com/ignite/cli/pull/4276) Add `cosmosclient.CreateTxWithOptions` method to facilite more custom tx creation ### Changes - [#4262](https://github.com/ignite/cli/pull/4262) Bring back relayer command - [#4269](https://github.com/ignite/cli/pull/4269) Add custom flag parser for extensions +- [#4270](https://github.com/ignite/cli/pull/4270) Add flags to the extension hooks commands ## [`v28.5.0`](https://github.com/ignite/cli/releases/tag/v28.5.0)