From f3a712fac6f4bb7a50788e87dd8cecb8dd3996e2 Mon Sep 17 00:00:00 2001 From: Pantani Date: Thu, 4 Apr 2024 22:42:07 +0200 Subject: [PATCH 01/23] support custom proto path --- ignite/cmd/chain.go | 21 ++--- ignite/cmd/cmd.go | 29 +++++++ ignite/cmd/scaffold.go | 7 +- ignite/cmd/scaffold_configs.go | 7 +- ignite/cmd/scaffold_message.go | 7 +- ignite/cmd/scaffold_module.go | 7 +- ignite/cmd/scaffold_packet.go | 7 +- ignite/cmd/scaffold_params.go | 7 +- ignite/cmd/scaffold_query.go | 7 +- ignite/config/chain/base/config.go | 27 +------ ignite/config/chain/defaults/default.go | 27 +++++++ ignite/config/chain/parse.go | 21 +++++ ignite/config/chain/v1/config.go | 25 +++--- ignite/config/chain/v1/config_test.go | 41 +++++----- ignite/config/chain/v1/validator_servers.go | 14 ++-- ignite/pkg/cosmosbuf/buf.go | 2 +- ignite/pkg/cosmosbuf/config.go | 58 ++++++++++++++ .../xembed/testdata/subtestdata/subfile.txt | 0 .../subtestdata/subtestdata/subfile2.txt | 0 ignite/pkg/xembed/testdata/test.txt | 0 ignite/pkg/xembed/xembed.go | 39 ++++++++++ ignite/pkg/xembed/xembed_test.go | 78 +++++++++++++++++++ ignite/services/chain/chain.go | 18 +++-- ignite/services/chain/proto.go | 27 +++---- ignite/services/chain/serve.go | 13 +++- ignite/services/scaffolder/component.go | 8 +- ignite/services/scaffolder/configs.go | 7 +- ignite/services/scaffolder/init.go | 4 +- ignite/services/scaffolder/message.go | 36 +++++++-- ignite/services/scaffolder/module.go | 9 ++- ignite/services/scaffolder/packet.go | 23 ++++-- ignite/services/scaffolder/params.go | 7 +- ignite/services/scaffolder/patch.go | 6 +- ignite/services/scaffolder/query.go | 7 +- ignite/services/scaffolder/scaffolder.go | 20 +++-- ignite/services/scaffolder/type.go | 14 ++-- ignite/templates/app/proto.go | 5 ++ ignite/templates/app/proto_test.go | 24 ++++++ ignite/templates/ibc/packet.go | 5 +- ignite/templates/message/message.go | 4 +- ignite/templates/message/options.go | 1 + ignite/templates/module/create/configs.go | 2 +- ignite/templates/module/create/ibc.go | 2 +- ignite/templates/module/create/options.go | 4 + ignite/templates/module/create/params.go | 2 +- ignite/templates/query/options.go | 1 + ignite/templates/query/query.go | 2 +- ignite/templates/typed/list/genesis.go | 2 +- ignite/templates/typed/list/list.go | 4 +- ignite/templates/typed/map/map.go | 6 +- ignite/templates/typed/options.go | 7 +- ignite/templates/typed/singleton/singleton.go | 6 +- integration/ibc/cmd_relayer_test.go | 12 --- 53 files changed, 537 insertions(+), 182 deletions(-) create mode 100644 ignite/config/chain/defaults/default.go create mode 100644 ignite/pkg/cosmosbuf/config.go create mode 100644 ignite/pkg/xembed/testdata/subtestdata/subfile.txt create mode 100644 ignite/pkg/xembed/testdata/subtestdata/subtestdata/subfile2.txt create mode 100644 ignite/pkg/xembed/testdata/test.txt create mode 100644 ignite/pkg/xembed/xembed.go create mode 100644 ignite/pkg/xembed/xembed_test.go create mode 100644 ignite/templates/app/proto_test.go diff --git a/ignite/cmd/chain.go b/ignite/cmd/chain.go index 0ca7bb989a..afbbeee559 100644 --- a/ignite/cmd/chain.go +++ b/ignite/cmd/chain.go @@ -191,7 +191,15 @@ func toolsMigrationPreRunHandler(cmd *cobra.Command, session *cliui.Session, app } func bufMigrationPreRunHandler(cmd *cobra.Command, session *cliui.Session, appPath string) error { - hasFiles := chain.CheckBufFiles(appPath) + protoPath, err := getProtoPathFromConfig(cmd) + if err != nil { + return err + } + + hasFiles, err := chain.CheckBufFiles(appPath, protoPath) + if err != nil { + return err + } if hasFiles { return nil } @@ -214,15 +222,8 @@ func bufMigrationPreRunHandler(cmd *cobra.Command, session *cliui.Session, appPa return nil } -func configMigrationPreRunHandler(cmd *cobra.Command, session *cliui.Session, appPath string) (err error) { - configPath := getConfig(cmd) - if configPath == "" { - if configPath, err = chainconfig.LocateDefault(appPath); err != nil { - return err - } - } - - rawCfg, err := os.ReadFile(configPath) +func configMigrationPreRunHandler(cmd *cobra.Command, session *cliui.Session, appPath string) error { + rawCfg, configPath, err := getRawConfig(cmd) if err != nil { return err } diff --git a/ignite/cmd/cmd.go b/ignite/cmd/cmd.go index 16e678c916..b5e5da41ee 100644 --- a/ignite/cmd/cmd.go +++ b/ignite/cmd/cmd.go @@ -1,6 +1,7 @@ package ignitecmd import ( + "bytes" "context" "fmt" "os" @@ -12,6 +13,7 @@ import ( flag "github.com/spf13/pflag" "github.com/ignite/cli/v29/ignite/config" + chainconfig "github.com/ignite/cli/v29/ignite/config/chain" "github.com/ignite/cli/v29/ignite/pkg/cache" "github.com/ignite/cli/v29/ignite/pkg/cliui" uilog "github.com/ignite/cli/v29/ignite/pkg/cliui/log" @@ -139,6 +141,33 @@ func getConfig(cmd *cobra.Command) (config string) { return } +func getRawConfig(cmd *cobra.Command) ([]byte, string, error) { + configPath := getConfig(cmd) + + path := flagGetPath(cmd) + path, err := filepath.Abs(path) + if err != nil { + return nil, "", err + } + + if configPath == "" { + if configPath, err = chainconfig.LocateDefault(path); err != nil { + return nil, "", err + } + } + + rawConfig, err := os.ReadFile(configPath) + return rawConfig, configPath, err +} + +func getProtoPathFromConfig(cmd *cobra.Command) (string, error) { + rawCfg, _, err := getRawConfig(cmd) + if err != nil { + return "", err + } + return chainconfig.ReadProtoPath(bytes.NewReader(rawCfg)) +} + func flagSetYes() *flag.FlagSet { fs := flag.NewFlagSet("", flag.ContinueOnError) fs.BoolP(flagYes, "y", false, "answers interactive yes/no questions with yes") diff --git a/ignite/cmd/scaffold.go b/ignite/cmd/scaffold.go index 053f58c469..207f7929cf 100644 --- a/ignite/cmd/scaffold.go +++ b/ignite/cmd/scaffold.go @@ -203,10 +203,15 @@ func scaffoldType( } } + protoPath, err := getProtoPathFromConfig(cmd) + if err != nil { + return err + } + session := cliui.New(cliui.StartSpinnerWithText(statusScaffolding)) defer session.End() - sc, err := scaffolder.New(cmd.Context(), appPath) + sc, err := scaffolder.New(cmd.Context(), appPath, protoPath) if err != nil { return err } diff --git a/ignite/cmd/scaffold_configs.go b/ignite/cmd/scaffold_configs.go index 2700d51de4..73c93f947c 100644 --- a/ignite/cmd/scaffold_configs.go +++ b/ignite/cmd/scaffold_configs.go @@ -48,6 +48,11 @@ func scaffoldConfigsHandler(cmd *cobra.Command, args []string) error { moduleName = flagGetModule(cmd) ) + protoPath, err := getProtoPathFromConfig(cmd) + if err != nil { + return err + } + session := cliui.New(cliui.StartSpinnerWithText(statusScaffolding)) defer session.End() @@ -56,7 +61,7 @@ func scaffoldConfigsHandler(cmd *cobra.Command, args []string) error { return err } - sc, err := scaffolder.New(cmd.Context(), appPath) + sc, err := scaffolder.New(cmd.Context(), appPath, protoPath) if err != nil { return err } diff --git a/ignite/cmd/scaffold_message.go b/ignite/cmd/scaffold_message.go index a904988d28..23aa99d3d6 100644 --- a/ignite/cmd/scaffold_message.go +++ b/ignite/cmd/scaffold_message.go @@ -88,6 +88,11 @@ func messageHandler(cmd *cobra.Command, args []string) error { withoutSimulation = flagGetNoSimulation(cmd) ) + protoPath, err := getProtoPathFromConfig(cmd) + if err != nil { + return err + } + session := cliui.New(cliui.StartSpinnerWithText(statusScaffolding)) defer session.End() @@ -113,7 +118,7 @@ func messageHandler(cmd *cobra.Command, args []string) error { options = append(options, scaffolder.WithoutSimulation()) } - sc, err := scaffolder.New(cmd.Context(), appPath) + sc, err := scaffolder.New(cmd.Context(), appPath, protoPath) if err != nil { return err } diff --git a/ignite/cmd/scaffold_module.go b/ignite/cmd/scaffold_module.go index 6a17aa1bf4..e926228f54 100644 --- a/ignite/cmd/scaffold_module.go +++ b/ignite/cmd/scaffold_module.go @@ -131,6 +131,11 @@ func scaffoldModuleHandler(cmd *cobra.Command, args []string) error { return err } + protoPath, err := getProtoPathFromConfig(cmd) + if err != nil { + return err + } + cacheStorage, err := newCache(cmd) if err != nil { return err @@ -171,7 +176,7 @@ func scaffoldModuleHandler(cmd *cobra.Command, args []string) error { var msg bytes.Buffer fmt.Fprintf(&msg, "\nšŸŽ‰ Module created %s.\n\n", name) - sc, err := scaffolder.New(cmd.Context(), appPath) + sc, err := scaffolder.New(cmd.Context(), appPath, protoPath) if err != nil { return err } diff --git a/ignite/cmd/scaffold_packet.go b/ignite/cmd/scaffold_packet.go index 2748cade0f..ac03332525 100644 --- a/ignite/cmd/scaffold_packet.go +++ b/ignite/cmd/scaffold_packet.go @@ -54,6 +54,11 @@ func createPacketHandler(cmd *cobra.Command, args []string) error { ackFields, _ := cmd.Flags().GetStringSlice(flagAck) noMessage, _ := cmd.Flags().GetBool(flagNoMessage) + protoPath, err := getProtoPathFromConfig(cmd) + if err != nil { + return err + } + cacheStorage, err := newCache(cmd) if err != nil { return err @@ -66,7 +71,7 @@ func createPacketHandler(cmd *cobra.Command, args []string) error { options = append(options, scaffolder.PacketWithSigner(signer)) } - sc, err := scaffolder.New(cmd.Context(), appPath) + sc, err := scaffolder.New(cmd.Context(), appPath, protoPath) if err != nil { return err } diff --git a/ignite/cmd/scaffold_params.go b/ignite/cmd/scaffold_params.go index 322ed57ddd..3c20d5984f 100644 --- a/ignite/cmd/scaffold_params.go +++ b/ignite/cmd/scaffold_params.go @@ -50,6 +50,11 @@ func scaffoldParamsHandler(cmd *cobra.Command, args []string) error { moduleName = flagGetModule(cmd) ) + protoPath, err := getProtoPathFromConfig(cmd) + if err != nil { + return err + } + session := cliui.New(cliui.StartSpinnerWithText(statusScaffolding)) defer session.End() @@ -58,7 +63,7 @@ func scaffoldParamsHandler(cmd *cobra.Command, args []string) error { return err } - sc, err := scaffolder.New(cmd.Context(), appPath) + sc, err := scaffolder.New(cmd.Context(), appPath, protoPath) if err != nil { return err } diff --git a/ignite/cmd/scaffold_query.go b/ignite/cmd/scaffold_query.go index 81cf24457b..cab0e76c14 100644 --- a/ignite/cmd/scaffold_query.go +++ b/ignite/cmd/scaffold_query.go @@ -59,12 +59,17 @@ func queryHandler(cmd *cobra.Command, args []string) error { paginated, _ := cmd.Flags().GetBool(flagPaginated) + protoPath, err := getProtoPathFromConfig(cmd) + if err != nil { + return err + } + cacheStorage, err := newCache(cmd) if err != nil { return err } - sc, err := scaffolder.New(cmd.Context(), appPath) + sc, err := scaffolder.New(cmd.Context(), appPath, protoPath) if err != nil { return err } diff --git a/ignite/config/chain/base/config.go b/ignite/config/chain/base/config.go index 9d7b27cae9..1990a1753e 100644 --- a/ignite/config/chain/base/config.go +++ b/ignite/config/chain/base/config.go @@ -3,30 +3,11 @@ package base import ( "github.com/imdario/mergo" + "github.com/ignite/cli/v29/ignite/config/chain/defaults" "github.com/ignite/cli/v29/ignite/config/chain/version" "github.com/ignite/cli/v29/ignite/pkg/xyaml" ) -var ( - // DefaultGRPCAddress is the default GRPC address. - DefaultGRPCAddress = "0.0.0.0:9090" - - // DefaultGRPCWebAddress is the default GRPC-Web address. - DefaultGRPCWebAddress = "0.0.0.0:9091" - - // DefaultAPIAddress is the default API address. - DefaultAPIAddress = "0.0.0.0:1317" - - // DefaultRPCAddress is the default RPC address. - DefaultRPCAddress = "0.0.0.0:26657" - - // DefaultP2PAddress is the default P2P address. - DefaultP2PAddress = "0.0.0.0:26656" - - // DefaultPProfAddress is the default Prof address. - DefaultPProfAddress = "0.0.0.0:6060" -) - // Account holds the options related to setting up Cosmos wallets. type Account struct { Name string `yaml:"name"` @@ -76,7 +57,7 @@ type Client struct { OpenAPI OpenAPI `yaml:"openapi,omitempty"` } -// TSClient configures code generation for Typescript Client. +// Typescript configures code generation for Typescript Client. type Typescript struct { // Path configures out location for generated Typescript Client code. Path string `yaml:"path"` @@ -206,12 +187,12 @@ func DefaultConfig() Config { return Config{ Build: Build{ Proto: Proto{ - Path: "proto", + Path: defaults.ProtoPath, ThirdPartyPaths: []string{"third_party/proto", "proto_vendor"}, }, }, Faucet: Faucet{ - Host: "0.0.0.0:4500", + Host: defaults.FaucetHost, }, } } diff --git a/ignite/config/chain/defaults/default.go b/ignite/config/chain/defaults/default.go new file mode 100644 index 0000000000..0e9b5a5784 --- /dev/null +++ b/ignite/config/chain/defaults/default.go @@ -0,0 +1,27 @@ +package defaults + +const ( + // GRPCAddress is the default GRPC address. + GRPCAddress = "0.0.0.0:9090" + + // GRPCWebAddress is the default GRPC-Web address. + GRPCWebAddress = "0.0.0.0:9091" + + // APIAddress is the default API address. + APIAddress = "0.0.0.0:1317" + + // RPCAddress is the default RPC address. + RPCAddress = "0.0.0.0:26657" + + // P2PAddress is the default P2P address. + P2PAddress = "0.0.0.0:26656" + + // PProfAddress is the default Prof address. + PProfAddress = "0.0.0.0:6060" + + // ProtoPath is the default proto path. + ProtoPath = "proto" + + // FaucetHost is the default faucet host. + FaucetHost = "0.0.0.0:4500" +) diff --git a/ignite/config/chain/parse.go b/ignite/config/chain/parse.go index 4514d27422..78f3ecd745 100644 --- a/ignite/config/chain/parse.go +++ b/ignite/config/chain/parse.go @@ -8,6 +8,7 @@ import ( "github.com/cosmos/cosmos-sdk/types/bech32" "gopkg.in/yaml.v2" + "github.com/ignite/cli/v29/ignite/config/chain/defaults" "github.com/ignite/cli/v29/ignite/config/chain/version" "github.com/ignite/cli/v29/ignite/pkg/errors" ) @@ -102,6 +103,26 @@ func ReadConfigVersion(configFile io.Reader) (version.Version, error) { return c.Version, err } +// ReadProtoPath reads the build proto path from the config. +func ReadProtoPath(configFile io.Reader) (string, error) { + c := struct { + Build struct { + Proto struct { + Path string `yaml:"path"` + } `yaml:"proto"` + } `yaml:"build"` + }{} + + if err := yaml.NewDecoder(configFile).Decode(&c); err != nil { + return "", err + } + path := c.Build.Proto.Path + if path == "" { + path = defaults.ProtoPath + } + return path, nil +} + func decodeConfig(r io.Reader, version version.Version) (version.Converter, error) { c, ok := Versions[version] if !ok { diff --git a/ignite/config/chain/v1/config.go b/ignite/config/chain/v1/config.go index 3f009d9f84..4eba9daba3 100644 --- a/ignite/config/chain/v1/config.go +++ b/ignite/config/chain/v1/config.go @@ -7,6 +7,7 @@ import ( "gopkg.in/yaml.v2" "github.com/ignite/cli/v29/ignite/config/chain/base" + "github.com/ignite/cli/v29/ignite/config/chain/defaults" "github.com/ignite/cli/v29/ignite/config/chain/version" "github.com/ignite/cli/v29/ignite/pkg/xnet" ) @@ -77,43 +78,43 @@ func (c *Config) updateValidatorAddresses() (err error) { func incrementDefaultServerPortsBy(s Servers, inc uint64) (Servers, error) { var err error - if s.GRPC.Address == base.DefaultGRPCAddress { - s.GRPC.Address, err = xnet.IncreasePortBy(base.DefaultGRPCAddress, inc) + if s.GRPC.Address == defaults.GRPCAddress { + s.GRPC.Address, err = xnet.IncreasePortBy(defaults.GRPCAddress, inc) if err != nil { return Servers{}, err } } - if s.GRPCWeb.Address == base.DefaultGRPCWebAddress { - s.GRPCWeb.Address, err = xnet.IncreasePortBy(base.DefaultGRPCWebAddress, inc) + if s.GRPCWeb.Address == defaults.GRPCWebAddress { + s.GRPCWeb.Address, err = xnet.IncreasePortBy(defaults.GRPCWebAddress, inc) if err != nil { return Servers{}, err } } - if s.API.Address == base.DefaultAPIAddress { - s.API.Address, err = xnet.IncreasePortBy(base.DefaultAPIAddress, inc) + if s.API.Address == defaults.APIAddress { + s.API.Address, err = xnet.IncreasePortBy(defaults.APIAddress, inc) if err != nil { return Servers{}, err } } - if s.P2P.Address == base.DefaultP2PAddress { - s.P2P.Address, err = xnet.IncreasePortBy(base.DefaultP2PAddress, inc) + if s.P2P.Address == defaults.P2PAddress { + s.P2P.Address, err = xnet.IncreasePortBy(defaults.P2PAddress, inc) if err != nil { return Servers{}, err } } - if s.RPC.Address == base.DefaultRPCAddress { - s.RPC.Address, err = xnet.IncreasePortBy(base.DefaultRPCAddress, inc) + if s.RPC.Address == defaults.RPCAddress { + s.RPC.Address, err = xnet.IncreasePortBy(defaults.RPCAddress, inc) if err != nil { return Servers{}, err } } - if s.RPC.PProfAddress == base.DefaultPProfAddress { - s.RPC.PProfAddress, err = xnet.IncreasePortBy(base.DefaultPProfAddress, inc) + if s.RPC.PProfAddress == defaults.PProfAddress { + s.RPC.PProfAddress, err = xnet.IncreasePortBy(defaults.PProfAddress, inc) if err != nil { return Servers{}, err } diff --git a/ignite/config/chain/v1/config_test.go b/ignite/config/chain/v1/config_test.go index a7cf2854e8..cbf9b3058c 100644 --- a/ignite/config/chain/v1/config_test.go +++ b/ignite/config/chain/v1/config_test.go @@ -8,6 +8,7 @@ import ( "github.com/stretchr/testify/require" "github.com/ignite/cli/v29/ignite/config/chain/base" + "github.com/ignite/cli/v29/ignite/config/chain/defaults" v1 "github.com/ignite/cli/v29/ignite/config/chain/v1" "github.com/ignite/cli/v29/ignite/pkg/xnet" ) @@ -99,12 +100,12 @@ func TestConfigValidatorDefaultServers(t *testing.T) { require.NoError(t, err) // Assert - require.Equal(t, base.DefaultGRPCAddress, servers.GRPC.Address) - require.Equal(t, base.DefaultGRPCWebAddress, servers.GRPCWeb.Address) - require.Equal(t, base.DefaultAPIAddress, servers.API.Address) - require.Equal(t, base.DefaultRPCAddress, servers.RPC.Address) - require.Equal(t, base.DefaultP2PAddress, servers.P2P.Address) - require.Equal(t, base.DefaultPProfAddress, servers.RPC.PProfAddress) + require.Equal(t, defaults.GRPCAddress, servers.GRPC.Address) + require.Equal(t, defaults.GRPCWebAddress, servers.GRPCWeb.Address) + require.Equal(t, defaults.APIAddress, servers.API.Address) + require.Equal(t, defaults.RPCAddress, servers.RPC.Address) + require.Equal(t, defaults.P2PAddress, servers.P2P.Address) + require.Equal(t, defaults.PProfAddress, servers.RPC.PProfAddress) } func TestConfigValidatorWithExistingServers(t *testing.T) { @@ -141,10 +142,10 @@ func TestConfigValidatorWithExistingServers(t *testing.T) { // Assert require.Equal(t, rpcAddr, servers.RPC.Address) require.Equal(t, apiAddr, servers.API.Address) - require.Equal(t, base.DefaultGRPCAddress, servers.GRPC.Address) - require.Equal(t, base.DefaultGRPCWebAddress, servers.GRPCWeb.Address) - require.Equal(t, base.DefaultP2PAddress, servers.P2P.Address) - require.Equal(t, base.DefaultPProfAddress, servers.RPC.PProfAddress) + require.Equal(t, defaults.GRPCAddress, servers.GRPC.Address) + require.Equal(t, defaults.GRPCWebAddress, servers.GRPCWeb.Address) + require.Equal(t, defaults.P2PAddress, servers.P2P.Address) + require.Equal(t, defaults.PProfAddress, servers.RPC.PProfAddress) } func TestConfigValidatorsWithExistingServers(t *testing.T) { @@ -188,10 +189,10 @@ func TestConfigValidatorsWithExistingServers(t *testing.T) { require.Equal(t, apiAddr, servers.API.Address) // Assert: The second validator should have the ports incremented by 10 - require.Equal(t, xnet.MustIncreasePortBy(base.DefaultGRPCAddress, inc), servers.GRPC.Address) - require.Equal(t, xnet.MustIncreasePortBy(base.DefaultGRPCWebAddress, inc), servers.GRPCWeb.Address) - require.Equal(t, xnet.MustIncreasePortBy(base.DefaultP2PAddress, inc), servers.P2P.Address) - require.Equal(t, xnet.MustIncreasePortBy(base.DefaultPProfAddress, inc), servers.RPC.PProfAddress) + require.Equal(t, xnet.MustIncreasePortBy(defaults.GRPCAddress, inc), servers.GRPC.Address) + require.Equal(t, xnet.MustIncreasePortBy(defaults.GRPCWebAddress, inc), servers.GRPCWeb.Address) + require.Equal(t, xnet.MustIncreasePortBy(defaults.P2PAddress, inc), servers.P2P.Address) + require.Equal(t, xnet.MustIncreasePortBy(defaults.PProfAddress, inc), servers.RPC.PProfAddress) } func TestConfigValidatorsDefaultServers(t *testing.T) { @@ -221,12 +222,12 @@ func TestConfigValidatorsDefaultServers(t *testing.T) { require.NoError(t, err) // Assert: The second validator should have the ports incremented by 10 - require.Equal(t, xnet.MustIncreasePortBy(base.DefaultGRPCAddress, inc), servers.GRPC.Address) - require.Equal(t, xnet.MustIncreasePortBy(base.DefaultGRPCWebAddress, inc), servers.GRPCWeb.Address) - require.Equal(t, xnet.MustIncreasePortBy(base.DefaultAPIAddress, inc), servers.API.Address) - require.Equal(t, xnet.MustIncreasePortBy(base.DefaultRPCAddress, inc), servers.RPC.Address) - require.Equal(t, xnet.MustIncreasePortBy(base.DefaultP2PAddress, inc), servers.P2P.Address) - require.Equal(t, xnet.MustIncreasePortBy(base.DefaultPProfAddress, inc), servers.RPC.PProfAddress) + require.Equal(t, xnet.MustIncreasePortBy(defaults.GRPCAddress, inc), servers.GRPC.Address) + require.Equal(t, xnet.MustIncreasePortBy(defaults.GRPCWebAddress, inc), servers.GRPCWeb.Address) + require.Equal(t, xnet.MustIncreasePortBy(defaults.APIAddress, inc), servers.API.Address) + require.Equal(t, xnet.MustIncreasePortBy(defaults.RPCAddress, inc), servers.RPC.Address) + require.Equal(t, xnet.MustIncreasePortBy(defaults.P2PAddress, inc), servers.P2P.Address) + require.Equal(t, xnet.MustIncreasePortBy(defaults.PProfAddress, inc), servers.RPC.PProfAddress) } func TestClone(t *testing.T) { diff --git a/ignite/config/chain/v1/validator_servers.go b/ignite/config/chain/v1/validator_servers.go index ae3d8e8e1d..7cb49db339 100644 --- a/ignite/config/chain/v1/validator_servers.go +++ b/ignite/config/chain/v1/validator_servers.go @@ -3,18 +3,18 @@ package v1 import ( "github.com/mitchellh/mapstructure" - baseconfig "github.com/ignite/cli/v29/ignite/config/chain/base" + baseconfig "github.com/ignite/cli/v29/ignite/config/chain/defaults" "github.com/ignite/cli/v29/ignite/pkg/errors" ) func DefaultServers() Servers { s := Servers{} - s.GRPC.Address = baseconfig.DefaultGRPCAddress - s.GRPCWeb.Address = baseconfig.DefaultGRPCWebAddress - s.API.Address = baseconfig.DefaultAPIAddress - s.P2P.Address = baseconfig.DefaultP2PAddress - s.RPC.Address = baseconfig.DefaultRPCAddress - s.RPC.PProfAddress = baseconfig.DefaultPProfAddress + s.GRPC.Address = baseconfig.GRPCAddress + s.GRPCWeb.Address = baseconfig.GRPCWebAddress + s.API.Address = baseconfig.APIAddress + s.P2P.Address = baseconfig.P2PAddress + s.RPC.Address = baseconfig.RPCAddress + s.RPC.PProfAddress = baseconfig.PProfAddress return s } diff --git a/ignite/pkg/cosmosbuf/buf.go b/ignite/pkg/cosmosbuf/buf.go index 566bdcc7a6..94dedeb047 100644 --- a/ignite/pkg/cosmosbuf/buf.go +++ b/ignite/pkg/cosmosbuf/buf.go @@ -189,7 +189,7 @@ func (b Buf) Generate( continue } - specs, err := xos.FindFiles(protoDir, "proto") + specs, err := xos.FindFiles(protoDir, xos.ProtoFile) if err != nil { return err } diff --git a/ignite/pkg/cosmosbuf/config.go b/ignite/pkg/cosmosbuf/config.go new file mode 100644 index 0000000000..4ab3be6b9b --- /dev/null +++ b/ignite/pkg/cosmosbuf/config.go @@ -0,0 +1,58 @@ +package cosmosbuf + +import ( + "os" + + "gopkg.in/yaml.v3" + + "github.com/ignite/cli/v29/ignite/pkg/errors" +) + +// BufWork represents the buf.work.yaml file. +type BufWork struct { + Version string `yaml:"version"` + Directories []string `yaml:"directories"` +} + +// ParseBufWork parse the buf.work.yaml file. +func ParseBufWork(path string) (BufWork, error) { + f, err := os.Open(path) + if err != nil { + return BufWork{}, err + } + defer f.Close() + + var w BufWork + return w, yaml.NewDecoder(f).Decode(&w) +} + +// ChangeProtoPath change the name of a proto directory path into the buf work file. +func (w *BufWork) ChangeProtoPath(oldPath, newPath string) error { + for i, path := range w.Directories { + if path == oldPath { + w.Directories[i] = newPath + return nil + } + } + return errors.Errorf("proto path %s not found", oldPath) +} + +// HasProtoPath returns true if the proto path exist into the directories slice. +func (w *BufWork) HasProtoPath(path string) bool { + for _, dirPath := range w.Directories { + if path == dirPath { + return true + } + } + return false +} + +// Save saves the buf work file. +func (w *BufWork) Save(path string) error { + file, err := os.OpenFile(path, os.O_WRONLY|os.O_TRUNC, 0o755) + if err != nil { + return err + } + defer file.Close() + return yaml.NewEncoder(file).Encode(w) +} diff --git a/ignite/pkg/xembed/testdata/subtestdata/subfile.txt b/ignite/pkg/xembed/testdata/subtestdata/subfile.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ignite/pkg/xembed/testdata/subtestdata/subtestdata/subfile2.txt b/ignite/pkg/xembed/testdata/subtestdata/subtestdata/subfile2.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ignite/pkg/xembed/testdata/test.txt b/ignite/pkg/xembed/testdata/test.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ignite/pkg/xembed/xembed.go b/ignite/pkg/xembed/xembed.go new file mode 100644 index 0000000000..4b982c4177 --- /dev/null +++ b/ignite/pkg/xembed/xembed.go @@ -0,0 +1,39 @@ +package xembed + +import ( + "embed" + "io/fs" + "path/filepath" +) + +// FileList list all files into an embed.FS in a provider path. +func FileList(efs embed.FS, path string) ([]string, error) { + return fileList(efs, path, path) +} + +func fileList(efs embed.FS, path, currentDir string) ([]string, error) { + dir, err := fs.ReadDir(efs, currentDir) + if err != nil { + return nil, err + } + + files := make([]string, 0) + for _, f := range dir { + if !f.IsDir() { + relPath, err := filepath.Rel(path, filepath.Join(currentDir, f.Name())) + if err != nil { + return nil, err + } + files = append(files, relPath) + continue + } + + newDir := filepath.Join(currentDir, f.Name()) + dirFiles, err := fileList(efs, path, newDir) + if err != nil { + return nil, err + } + files = append(files, dirFiles...) + } + return files, nil +} diff --git a/ignite/pkg/xembed/xembed_test.go b/ignite/pkg/xembed/xembed_test.go new file mode 100644 index 0000000000..edb65a6d3e --- /dev/null +++ b/ignite/pkg/xembed/xembed_test.go @@ -0,0 +1,78 @@ +package xembed + +import ( + "embed" + "testing" + + "github.com/stretchr/testify/require" +) + +//go:embed testdata/* +var fsProtoTest embed.FS + +func TestFileList(t *testing.T) { + type args struct { + efs embed.FS + path string + } + tests := []struct { + name string + args args + want []string + err error + }{ + { + name: "root folder", + args: args{ + efs: fsProtoTest, + path: ".", + }, + want: []string{ + "testdata/subtestdata/subfile.txt", + "testdata/subtestdata/subtestdata/subfile2.txt", + "testdata/test.txt", + }, + }, + { + name: "testdata folder", + args: args{ + efs: fsProtoTest, + path: "testdata", + }, + want: []string{ + "subtestdata/subfile.txt", + "subtestdata/subtestdata/subfile2.txt", + "test.txt", + }, + }, + { + name: "sub testdata folder", + args: args{ + efs: fsProtoTest, + path: "testdata/subtestdata", + }, + want: []string{ + "subfile.txt", + "subtestdata/subfile2.txt", + }, + }, + { + name: "sub sub testdata folder", + args: args{ + efs: fsProtoTest, + path: "testdata/subtestdata/subtestdata", + }, + want: []string{"subfile2.txt"}, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + got, err := FileList(tt.args.efs, tt.args.path) + if tt.err != nil { + require.Error(t, err) + } + require.NoError(t, err) + require.EqualValues(t, tt.want, got) + }) + } +} diff --git a/ignite/services/chain/chain.go b/ignite/services/chain/chain.go index a1faa37b07..f2a3289ac4 100644 --- a/ignite/services/chain/chain.go +++ b/ignite/services/chain/chain.go @@ -29,14 +29,6 @@ const ( flagHome = "home" ) -var appBackendSourceWatchPaths = []string{ - "app", - "cmd", - "x", - "proto", - "third_party", -} - type ( // Chain provides programmatic access and tools for a Cosmos SDK blockchain. Chain struct { @@ -532,3 +524,13 @@ func (c *Chain) Commands(ctx context.Context) (chaincmdrunner.Runner, error) { return chaincmdrunner.New(ctx, cc, ccrOptions...) } + +func appBackendSourceWatchPaths(protoPath string) []string { + return []string{ + "app", + "cmd", + "x", + "third_party", + protoPath, + } +} diff --git a/ignite/services/chain/proto.go b/ignite/services/chain/proto.go index a38abb7375..9843008fd8 100644 --- a/ignite/services/chain/proto.go +++ b/ignite/services/chain/proto.go @@ -2,29 +2,30 @@ package chain import ( "path/filepath" + "strings" "github.com/ignite/cli/v29/ignite/pkg/xgenny" "github.com/ignite/cli/v29/ignite/pkg/xos" "github.com/ignite/cli/v29/ignite/templates/app" ) -var bufFiles = []string{ - "buf.work.yaml", - "proto/buf.gen.gogo.yaml", - "proto/buf.gen.pulsar.yaml", - "proto/buf.gen.swagger.yaml", - "proto/buf.gen.ts.yaml", - "proto/buf.lock", - "proto/buf.yaml", -} +const defaultProtoFolder = "proto/" -func CheckBufFiles(appPath string) bool { - for _, bufFile := range bufFiles { +func CheckBufFiles(appPath, protoPath string) (bool, error) { + files, err := app.BufFiles() + if err != nil { + return false, nil + } + for _, bufFile := range files { + bufFile, ok := strings.CutPrefix(bufFile, defaultProtoFolder) + if ok { + bufFile = filepath.Join(protoPath, bufFile) + } if !xos.FileExists(filepath.Join(appPath, bufFile)) { - return false + return false, nil } } - return true + return true, nil } func BoxBufFiles(runner *xgenny.Runner, appPath string) (xgenny.SourceModification, error) { diff --git a/ignite/services/chain/serve.go b/ignite/services/chain/serve.go index e421236d8e..6c7236b5db 100644 --- a/ignite/services/chain/serve.go +++ b/ignite/services/chain/serve.go @@ -294,7 +294,12 @@ func (c *Chain) refreshServe() { } func (c *Chain) watchAppBackend(ctx context.Context) error { - watchPaths := appBackendSourceWatchPaths + conf, err := c.Config() + if err != nil { + return err + } + + watchPaths := appBackendSourceWatchPaths(conf.Build.Proto.Path) if c.ConfigPath() != "" { watchPaths = append(watchPaths, c.ConfigPath()) } @@ -324,6 +329,8 @@ func (c *Chain) serve( return &CannotBuildAppError{err} } + sourceWatchPaths := appBackendSourceWatchPaths(conf.Build.Proto.Path) + commands, err := c.Commands(ctx) if err != nil { return err @@ -358,7 +365,7 @@ func (c *Chain) serve( // check if source has been modified since last serve // if the state must not be reset but the source has changed, we rebuild the chain and import the exported state - sourceModified, err := dirchange.HasDirChecksumChanged(dirCache, sourceChecksumKey, c.app.Path, appBackendSourceWatchPaths...) + sourceModified, err := dirchange.HasDirChecksumChanged(dirCache, sourceChecksumKey, c.app.Path, sourceWatchPaths...) if err != nil { return err } @@ -437,7 +444,7 @@ func (c *Chain) serve( } } - if err := dirchange.SaveDirChecksum(dirCache, sourceChecksumKey, c.app.Path, appBackendSourceWatchPaths...); err != nil { + if err := dirchange.SaveDirChecksum(dirCache, sourceChecksumKey, c.app.Path, sourceWatchPaths...); err != nil { return err } diff --git a/ignite/services/scaffolder/component.go b/ignite/services/scaffolder/component.go index 1c4cf3f64a..85fc63bea8 100644 --- a/ignite/services/scaffolder/component.go +++ b/ignite/services/scaffolder/component.go @@ -21,8 +21,6 @@ const ( componentMessage = "message" componentQuery = "query" componentPacket = "packet" - - protoFolder = "proto" ) // checkComponentValidity performs various checks common to all components to verify if it can be scaffolded. @@ -109,8 +107,8 @@ func checkComponentCreated(appPath, moduleName string, compName multiformatname. } // checkCustomTypes returns error if one of the types is invalid. -func checkCustomTypes(ctx context.Context, path, appName, module string, fields []string) error { - protoPath := filepath.Join(path, protoFolder, appName, module) +func checkCustomTypes(ctx context.Context, appPath, appName, protoPath, module string, fields []string) error { + path := filepath.Join(appPath, protoPath, appName, module) customFieldTypes := make([]string, 0) for _, field := range fields { ft, ok := fieldType(field) @@ -122,7 +120,7 @@ func checkCustomTypes(ctx context.Context, path, appName, module string, fields customFieldTypes = append(customFieldTypes, ft) } } - return protoanalysis.HasMessages(ctx, protoPath, customFieldTypes...) + return protoanalysis.HasMessages(ctx, path, customFieldTypes...) } // checkForbiddenComponentName returns true if the name is forbidden as a component name. diff --git a/ignite/services/scaffolder/configs.go b/ignite/services/scaffolder/configs.go index 7115187d4d..e6a7e85ddd 100644 --- a/ignite/services/scaffolder/configs.go +++ b/ignite/services/scaffolder/configs.go @@ -28,7 +28,7 @@ func (s Scaffolder) CreateConfigs( moduleName = mfName.LowerCase // Check if the module already exist - ok, err := moduleExists(s.path, moduleName) + ok, err := moduleExists(s.appPath, moduleName) if err != nil { return err } @@ -36,7 +36,7 @@ func (s Scaffolder) CreateConfigs( return errors.Errorf("the module %v not exist", moduleName) } - if err := checkConfigCreated(s.path, appName, moduleName, configs); err != nil { + if err := checkConfigCreated(s.appPath, appName, moduleName, configs); err != nil { return err } @@ -50,7 +50,8 @@ func (s Scaffolder) CreateConfigs( ModuleName: moduleName, Configs: configsFields, AppName: s.modpath.Package, - AppPath: s.path, + AppPath: s.appPath, + ProtoPath: s.protoPath, } g, err := modulecreate.NewModuleConfigs(opts) diff --git a/ignite/services/scaffolder/init.go b/ignite/services/scaffolder/init.go index f2de8e367e..2c55e80cf5 100644 --- a/ignite/services/scaffolder/init.go +++ b/ignite/services/scaffolder/init.go @@ -6,6 +6,7 @@ import ( "path/filepath" "strings" + "github.com/ignite/cli/v29/ignite/config/chain/defaults" "github.com/ignite/cli/v29/ignite/pkg/cosmosgen" "github.com/ignite/cli/v29/ignite/pkg/gomodulepath" "github.com/ignite/cli/v29/ignite/pkg/xgenny" @@ -82,7 +83,7 @@ func generate( githubPath := gomodulepath.ExtractAppPath(pathInfo.RawPath) if !strings.Contains(githubPath, "/") { - // A username must be added when the app module path has a single element + // A username must be added when the app module appPath has a single element githubPath = fmt.Sprintf("username/%s", githubPath) } @@ -122,6 +123,7 @@ func generate( ModulePath: pathInfo.RawPath, AppName: pathInfo.Package, AppPath: absRoot, + ProtoPath: defaults.ProtoPath, Params: paramsFields, Configs: configsFields, IsIBC: false, diff --git a/ignite/services/scaffolder/message.go b/ignite/services/scaffolder/message.go index 371df142bd..aa019cc98d 100644 --- a/ignite/services/scaffolder/message.go +++ b/ignite/services/scaffolder/message.go @@ -6,6 +6,7 @@ import ( "github.com/gobuffalo/genny/v2" + "github.com/ignite/cli/v29/ignite/config/chain/defaults" "github.com/ignite/cli/v29/ignite/pkg/errors" "github.com/ignite/cli/v29/ignite/pkg/multiformatname" "github.com/ignite/cli/v29/ignite/templates/field" @@ -18,6 +19,7 @@ import ( type messageOptions struct { description string signer string + protoPath string withoutSimulation bool } @@ -26,6 +28,7 @@ func newMessageOptions(messageName string) messageOptions { return messageOptions{ description: fmt.Sprintf("Broadcast message %s", messageName), signer: "creator", + protoPath: defaults.ProtoPath, } } @@ -46,6 +49,13 @@ func WithSigner(signer string) MessageOption { } } +// WithProtoPath provides a custom proto appPath. +func WithProtoPath(protoPath string) MessageOption { + return func(m *messageOptions) { + m.protoPath = protoPath + } +} + // WithoutSimulation disables generating messages simulation. func WithoutSimulation() MessageOption { return func(m *messageOptions) { @@ -83,12 +93,19 @@ func (s Scaffolder) AddMessage( return err } - if err := checkComponentValidity(s.path, moduleName, name, false); err != nil { + if err := checkComponentValidity(s.appPath, moduleName, name, false); err != nil { return err } // Check and parse provided fields - if err := checkCustomTypes(ctx, s.path, s.modpath.Package, moduleName, fields); err != nil { + if err := checkCustomTypes( + ctx, + s.appPath, + s.modpath.Package, + scaffoldingOpts.protoPath, + moduleName, + fields, + ); err != nil { return err } parsedMsgFields, err := field.ParseFields(fields, checkForbiddenMessageField, scaffoldingOpts.signer) @@ -97,7 +114,14 @@ func (s Scaffolder) AddMessage( } // Check and parse provided response fields - if err := checkCustomTypes(ctx, s.path, s.modpath.Package, moduleName, resFields); err != nil { + if err := checkCustomTypes( + ctx, + s.appPath, + s.modpath.Package, + scaffoldingOpts.protoPath, + moduleName, + resFields, + ); err != nil { return err } parsedResFields, err := field.ParseFields(resFields, checkGoReservedWord, scaffoldingOpts.signer) @@ -114,7 +138,8 @@ func (s Scaffolder) AddMessage( g *genny.Generator opts = &message.Options{ AppName: s.modpath.Package, - AppPath: s.path, + AppPath: s.appPath, + ProtoPath: s.protoPath, ModulePath: s.modpath.RawPath, ModuleName: moduleName, MsgName: name, @@ -131,12 +156,13 @@ func (s Scaffolder) AddMessage( gens, err = supportMsgServer( gens, s.Tracer(), - s.path, + s.appPath, &modulecreate.MsgServerOptions{ ModuleName: opts.ModuleName, ModulePath: opts.ModulePath, AppName: opts.AppName, AppPath: opts.AppPath, + ProtoPath: opts.ProtoPath, }, ) if err != nil { diff --git a/ignite/services/scaffolder/module.go b/ignite/services/scaffolder/module.go index 2173112ca0..826dacfaeb 100644 --- a/ignite/services/scaffolder/module.go +++ b/ignite/services/scaffolder/module.go @@ -172,12 +172,12 @@ func (s Scaffolder) CreateModule( moduleName = mfName.LowerCase // Check if the module name is valid - if err := checkModuleName(s.path, moduleName); err != nil { + if err := checkModuleName(s.appPath, moduleName); err != nil { return err } // Check if the module already exist - ok, err := moduleExists(s.path, moduleName) + ok, err := moduleExists(s.appPath, moduleName) if err != nil { return err } @@ -204,7 +204,7 @@ func (s Scaffolder) CreateModule( } // Check dependencies - if err := checkDependencies(creationOpts.dependencies, s.path); err != nil { + if err := checkDependencies(creationOpts.dependencies, s.appPath); err != nil { return err } @@ -214,7 +214,8 @@ func (s Scaffolder) CreateModule( Params: params, Configs: configs, AppName: s.modpath.Package, - AppPath: s.path, + AppPath: s.appPath, + ProtoPath: s.protoPath, IsIBC: creationOpts.ibc, IBCOrdering: creationOpts.ibcChannelOrdering, Dependencies: creationOpts.dependencies, diff --git a/ignite/services/scaffolder/packet.go b/ignite/services/scaffolder/packet.go index 5fba16094f..6fabd107b0 100644 --- a/ignite/services/scaffolder/packet.go +++ b/ignite/services/scaffolder/packet.go @@ -7,6 +7,7 @@ import ( "github.com/gobuffalo/genny/v2" + "github.com/ignite/cli/v29/ignite/config/chain/defaults" "github.com/ignite/cli/v29/ignite/pkg/errors" "github.com/ignite/cli/v29/ignite/pkg/multiformatname" "github.com/ignite/cli/v29/ignite/templates/field" @@ -22,12 +23,14 @@ const ( type packetOptions struct { withoutMessage bool signer string + protoPath string } // newPacketOptions returns a packetOptions with default options. func newPacketOptions() packetOptions { return packetOptions{ - signer: "creator", + signer: "creator", + protoPath: defaults.ProtoPath, } } @@ -48,6 +51,13 @@ func PacketWithSigner(signer string) PacketOption { } } +// PacketWithProtoPath provides a custom proto appPath. +func PacketWithProtoPath(protoPath string) PacketOption { + return func(m *packetOptions) { + m.protoPath = protoPath + } +} + // AddPacket adds a new type stype to scaffolded app by using optional type fields. func (s Scaffolder) AddPacket( ctx context.Context, @@ -74,7 +84,7 @@ func (s Scaffolder) AddPacket( return err } - if err := checkComponentValidity(s.path, moduleName, name, o.withoutMessage); err != nil { + if err := checkComponentValidity(s.appPath, moduleName, name, o.withoutMessage); err != nil { return err } @@ -84,7 +94,7 @@ func (s Scaffolder) AddPacket( } // Module must implement IBC - ok, err := isIBCModule(s.path, moduleName) + ok, err := isIBCModule(s.appPath, moduleName) if err != nil { return err } @@ -98,7 +108,7 @@ func (s Scaffolder) AddPacket( } // Check and parse packet fields - if err := checkCustomTypes(ctx, s.path, s.modpath.Package, moduleName, packetFields); err != nil { + if err := checkCustomTypes(ctx, s.appPath, s.modpath.Package, o.protoPath, moduleName, packetFields); err != nil { return err } parsedPacketFields, err := field.ParseFields(packetFields, checkForbiddenPacketField, signer) @@ -107,7 +117,7 @@ func (s Scaffolder) AddPacket( } // check and parse acknowledgment fields - if err := checkCustomTypes(ctx, s.path, s.modpath.Package, moduleName, ackFields); err != nil { + if err := checkCustomTypes(ctx, s.appPath, s.modpath.Package, o.protoPath, moduleName, ackFields); err != nil { return err } parsedAcksFields, err := field.ParseFields(ackFields, checkGoReservedWord, signer) @@ -120,7 +130,8 @@ func (s Scaffolder) AddPacket( g *genny.Generator opts = &ibc.PacketOptions{ AppName: s.modpath.Package, - AppPath: s.path, + AppPath: s.appPath, + ProtoPath: s.protoPath, ModulePath: s.modpath.RawPath, ModuleName: moduleName, PacketName: name, diff --git a/ignite/services/scaffolder/params.go b/ignite/services/scaffolder/params.go index aa3bb7a8b0..1bc2a9989d 100644 --- a/ignite/services/scaffolder/params.go +++ b/ignite/services/scaffolder/params.go @@ -27,7 +27,7 @@ func (s Scaffolder) CreateParams( moduleName = mfName.LowerCase // Check if the module already exist - ok, err := moduleExists(s.path, moduleName) + ok, err := moduleExists(s.appPath, moduleName) if err != nil { return err } @@ -35,7 +35,7 @@ func (s Scaffolder) CreateParams( return errors.Errorf("the module %v not exist", moduleName) } - if err := checkParamCreated(s.path, moduleName, params); err != nil { + if err := checkParamCreated(s.appPath, moduleName, params); err != nil { return err } @@ -49,7 +49,8 @@ func (s Scaffolder) CreateParams( ModuleName: moduleName, Params: paramsFields, AppName: s.modpath.Package, - AppPath: s.path, + AppPath: s.appPath, + ProtoPath: s.protoPath, } g, err := modulecreate.NewModuleParam(opts) diff --git a/ignite/services/scaffolder/patch.go b/ignite/services/scaffolder/patch.go index b7e964e11c..317b6d469f 100644 --- a/ignite/services/scaffolder/patch.go +++ b/ignite/services/scaffolder/patch.go @@ -20,7 +20,7 @@ func supportMsgServer( opts *modulecreate.MsgServerOptions, ) ([]*genny.Generator, error) { // Check if convention used - msgServerDefined, err := isMsgServerDefined(appPath, opts.AppName, opts.ModuleName) + msgServerDefined, err := isMsgServerDefined(appPath, opts.AppName, opts.ProtoPath, opts.ModuleName) if err != nil { return nil, err } @@ -37,8 +37,8 @@ func supportMsgServer( // isMsgServerDefined checks if the module uses the MsgServer convention for transactions // this is checked by verifying the existence of the tx.proto file. -func isMsgServerDefined(appPath, appName, moduleName string) (bool, error) { - txProto, err := filepath.Abs(filepath.Join(appPath, "proto", appName, moduleName, "tx.proto")) +func isMsgServerDefined(appPath, appName, protoPath, moduleName string) (bool, error) { + txProto, err := filepath.Abs(filepath.Join(appPath, protoPath, appName, moduleName, "tx.proto")) if err != nil { return false, err } diff --git a/ignite/services/scaffolder/query.go b/ignite/services/scaffolder/query.go index fe61736186..6c87d98ae3 100644 --- a/ignite/services/scaffolder/query.go +++ b/ignite/services/scaffolder/query.go @@ -36,7 +36,7 @@ func (s Scaffolder) AddQuery( return err } - if err := checkComponentValidity(s.path, moduleName, name, true); err != nil { + if err := checkComponentValidity(s.appPath, moduleName, name, true); err != nil { return err } @@ -50,7 +50,7 @@ func (s Scaffolder) AddQuery( } // Check and parse provided response fields - if err := checkCustomTypes(ctx, s.path, s.modpath.Package, moduleName, resFields); err != nil { + if err := checkCustomTypes(ctx, s.appPath, s.modpath.Package, s.protoPath, moduleName, resFields); err != nil { return err } parsedResFields, err := field.ParseFields(resFields, checkGoReservedWord) @@ -62,7 +62,8 @@ func (s Scaffolder) AddQuery( g *genny.Generator opts = &query.Options{ AppName: s.modpath.Package, - AppPath: s.path, + AppPath: s.appPath, + ProtoPath: s.protoPath, ModulePath: s.modpath.RawPath, ModuleName: moduleName, QueryName: name, diff --git a/ignite/services/scaffolder/scaffolder.go b/ignite/services/scaffolder/scaffolder.go index 5203236485..9624973e32 100644 --- a/ignite/services/scaffolder/scaffolder.go +++ b/ignite/services/scaffolder/scaffolder.go @@ -25,8 +25,11 @@ type Scaffolder struct { // Version of the chain Version cosmosver.Version - // path of the app. - path string + // appPath path of the app. + appPath string + + // protoPath path of the proto folder. + protoPath string // modpath represents the go module Path of the app. modpath gomodulepath.Path @@ -36,7 +39,7 @@ type Scaffolder struct { } // New creates a new scaffold app. -func New(context context.Context, appPath string) (Scaffolder, error) { +func New(context context.Context, appPath, protoPath string) (Scaffolder, error) { path, err := filepath.Abs(appPath) if err != nil { return Scaffolder{}, err @@ -62,10 +65,11 @@ func New(context context.Context, appPath string) (Scaffolder, error) { } s := Scaffolder{ - Version: ver, - path: path, - modpath: modpath, - runner: xgenny.NewRunner(context, path), + Version: ver, + appPath: path, + protoPath: protoPath, + modpath: modpath, + runner: xgenny.NewRunner(context, path), } return s, nil @@ -84,7 +88,7 @@ func (s Scaffolder) Run(gens ...*genny.Generator) error { } func (s Scaffolder) PostScaffold(ctx context.Context, cacheStorage cache.Storage, skipProto bool) error { - return PostScaffold(ctx, cacheStorage, s.path, s.modpath.RawPath, skipProto) + return PostScaffold(ctx, cacheStorage, s.appPath, s.modpath.RawPath, skipProto) } func PostScaffold(ctx context.Context, cacheStorage cache.Storage, path, gomodPath string, skipProto bool) error { diff --git a/ignite/services/scaffolder/type.go b/ignite/services/scaffolder/type.go index fd762bf8e4..f30bee0102 100644 --- a/ignite/services/scaffolder/type.go +++ b/ignite/services/scaffolder/type.go @@ -6,6 +6,7 @@ import ( "github.com/gobuffalo/genny/v2" + "github.com/ignite/cli/v29/ignite/config/chain/defaults" "github.com/ignite/cli/v29/ignite/pkg/errors" "github.com/ignite/cli/v29/ignite/pkg/multiformatname" "github.com/ignite/cli/v29/ignite/pkg/placeholder" @@ -27,6 +28,7 @@ type AddTypeKind func(*addTypeOptions) type addTypeOptions struct { moduleName string + protoPath string fields []string isList bool @@ -45,6 +47,7 @@ func newAddTypeOptions(moduleName string) addTypeOptions { return addTypeOptions{ moduleName: moduleName, signer: "creator", + protoPath: defaults.ProtoPath, } } @@ -138,12 +141,12 @@ func (s Scaffolder) AddType( return err } - if err := checkComponentValidity(s.path, moduleName, name, o.withoutMessage); err != nil { + if err := checkComponentValidity(s.appPath, moduleName, name, o.withoutMessage); err != nil { return err } // Check and parse provided fields - if err := checkCustomTypes(ctx, s.path, s.modpath.Package, moduleName, o.fields); err != nil { + if err := checkCustomTypes(ctx, s.appPath, s.modpath.Package, o.protoPath, moduleName, o.fields); err != nil { return err } tFields, err := parseTypeFields(o) @@ -156,7 +159,7 @@ func (s Scaffolder) AddType( return err } - isIBC, err := isIBCModule(s.path, moduleName) + isIBC, err := isIBCModule(s.appPath, moduleName) if err != nil { return err } @@ -165,7 +168,8 @@ func (s Scaffolder) AddType( g *genny.Generator opts = &typed.Options{ AppName: s.modpath.Package, - AppPath: s.path, + AppPath: s.appPath, + ProtoPath: s.protoPath, ModulePath: s.modpath.RawPath, ModuleName: moduleName, TypeName: name, @@ -181,7 +185,7 @@ func (s Scaffolder) AddType( gens, err = supportMsgServer( gens, s.runner.Tracer(), - s.path, + s.appPath, &modulecreate.MsgServerOptions{ ModuleName: opts.ModuleName, ModulePath: opts.ModulePath, diff --git a/ignite/templates/app/proto.go b/ignite/templates/app/proto.go index 4259257bfa..aeb60622bf 100644 --- a/ignite/templates/app/proto.go +++ b/ignite/templates/app/proto.go @@ -5,6 +5,7 @@ import ( "github.com/gobuffalo/genny/v2" + "github.com/ignite/cli/v29/ignite/pkg/xembed" "github.com/ignite/cli/v29/ignite/pkg/xgenny" ) @@ -23,3 +24,7 @@ func NewBufGenerator(appPath string) (*genny.Generator, error) { ) return g, xgenny.Box(g, template) } + +func BufFiles() ([]string, error) { + return xembed.FileList(fsProto, "files") +} diff --git a/ignite/templates/app/proto_test.go b/ignite/templates/app/proto_test.go new file mode 100644 index 0000000000..f9049dd6fb --- /dev/null +++ b/ignite/templates/app/proto_test.go @@ -0,0 +1,24 @@ +package app + +import ( + "os" + "path/filepath" + "testing" + + "github.com/stretchr/testify/require" + + "github.com/ignite/cli/v29/ignite/config/chain/defaults" +) + +func TestBufFiles(t *testing.T) { + want := []string{"buf.work.yaml"} + protoDir, err := os.ReadDir(filepath.Join("files", defaults.ProtoPath)) + require.NoError(t, err) + for _, e := range protoDir { + want = append(want, filepath.Join(defaults.ProtoPath, e.Name())) + } + + got, err := BufFiles() + require.NoError(t, err) + require.ElementsMatch(t, want, got) +} diff --git a/ignite/templates/ibc/packet.go b/ignite/templates/ibc/packet.go index 7c5180ce49..783b3e8aed 100644 --- a/ignite/templates/ibc/packet.go +++ b/ignite/templates/ibc/packet.go @@ -34,6 +34,7 @@ var ( type PacketOptions struct { AppName string AppPath string + ProtoPath string ModuleName string ModulePath string PacketName multiformatname.Name @@ -181,7 +182,7 @@ func moduleModify(replacer placeholder.Replacer, opts *PacketOptions) genny.RunF // - Existence of a Oneof field named 'packet'. func protoModify(opts *PacketOptions) genny.RunFn { return func(r *genny.Runner) error { - path := filepath.Join(opts.AppPath, "proto", opts.AppName, opts.ModuleName, "packet.proto") + path := filepath.Join(opts.AppPath, opts.ProtoPath, opts.AppName, opts.ModuleName, "packet.proto") f, err := r.Disk.Find(path) if err != nil { return err @@ -288,7 +289,7 @@ func eventModify(replacer placeholder.Replacer, opts *PacketOptions) genny.RunFn // elements in the file. func protoTxModify(opts *PacketOptions) genny.RunFn { return func(r *genny.Runner) error { - path := filepath.Join(opts.AppPath, "proto", opts.AppName, opts.ModuleName, "tx.proto") + path := filepath.Join(opts.AppPath, opts.ProtoPath, opts.AppName, opts.ModuleName, "tx.proto") f, err := r.Disk.Find(path) if err != nil { return err diff --git a/ignite/templates/message/message.go b/ignite/templates/message/message.go index be6d0bf572..cffe528fad 100644 --- a/ignite/templates/message/message.go +++ b/ignite/templates/message/message.go @@ -87,7 +87,7 @@ func NewGenerator(replacer placeholder.Replacer, opts *Options) (*genny.Generato // - A service named "Msg" to exist in the proto file, it appends the RPCs inside it. func protoTxRPCModify(opts *Options) genny.RunFn { return func(r *genny.Runner) error { - path := filepath.Join(opts.AppPath, "proto", opts.AppName, opts.ModuleName, "tx.proto") + path := filepath.Join(opts.AppPath, opts.ProtoPath, opts.AppName, opts.ModuleName, "tx.proto") f, err := r.Disk.Find(path) if err != nil { return err @@ -118,7 +118,7 @@ func protoTxRPCModify(opts *Options) genny.RunFn { func protoTxMessageModify(opts *Options) genny.RunFn { return func(r *genny.Runner) error { - path := filepath.Join(opts.AppPath, "proto", opts.AppName, opts.ModuleName, "tx.proto") + path := filepath.Join(opts.AppPath, opts.ProtoPath, opts.AppName, opts.ModuleName, "tx.proto") f, err := r.Disk.Find(path) if err != nil { return err diff --git a/ignite/templates/message/options.go b/ignite/templates/message/options.go index 8cf90ec3e4..74eee2661f 100644 --- a/ignite/templates/message/options.go +++ b/ignite/templates/message/options.go @@ -9,6 +9,7 @@ import ( type Options struct { AppName string AppPath string + ProtoPath string ModuleName string ModulePath string MsgName multiformatname.Name diff --git a/ignite/templates/module/create/configs.go b/ignite/templates/module/create/configs.go index 539993fdd0..7610179f83 100644 --- a/ignite/templates/module/create/configs.go +++ b/ignite/templates/module/create/configs.go @@ -18,7 +18,7 @@ func NewModuleConfigs(opts ConfigsOptions) (*genny.Generator, error) { func configsProtoModify(opts ConfigsOptions) genny.RunFn { return func(r *genny.Runner) error { - path := filepath.Join(opts.AppPath, "proto", opts.AppName, opts.ModuleName, "module/module.proto") + path := filepath.Join(opts.AppPath, opts.ProtoPath, opts.AppName, opts.ModuleName, "module/module.proto") f, err := r.Disk.Find(path) if err != nil { return err diff --git a/ignite/templates/module/create/ibc.go b/ignite/templates/module/create/ibc.go index 1605f800cf..cc8d541b8f 100644 --- a/ignite/templates/module/create/ibc.go +++ b/ignite/templates/module/create/ibc.go @@ -130,7 +130,7 @@ func genesisTypesModify(replacer placeholder.Replacer, opts *CreateOptions) genn // - Existence of a message named 'GenesisState' in genesis.proto. func genesisProtoModify(opts *CreateOptions) genny.RunFn { return func(r *genny.Runner) error { - path := filepath.Join(opts.AppPath, "proto", opts.AppName, opts.ModuleName, "genesis.proto") + path := filepath.Join(opts.AppPath, opts.ProtoPath, opts.AppName, opts.ModuleName, "genesis.proto") f, err := r.Disk.Find(path) if err != nil { return err diff --git a/ignite/templates/module/create/options.go b/ignite/templates/module/create/options.go index 36898d9b1a..2857e81460 100644 --- a/ignite/templates/module/create/options.go +++ b/ignite/templates/module/create/options.go @@ -14,6 +14,7 @@ type ( ModuleName string AppName string AppPath string + ProtoPath string Configs field.Fields } @@ -22,6 +23,7 @@ type ( ModuleName string AppName string AppPath string + ProtoPath string Params field.Fields } @@ -31,6 +33,7 @@ type ( ModulePath string AppName string AppPath string + ProtoPath string Params field.Fields Configs field.Fields @@ -58,6 +61,7 @@ type ( ModulePath string AppName string AppPath string + ProtoPath string } ) diff --git a/ignite/templates/module/create/params.go b/ignite/templates/module/create/params.go index 392e0ddf93..d017bacb5e 100644 --- a/ignite/templates/module/create/params.go +++ b/ignite/templates/module/create/params.go @@ -21,7 +21,7 @@ func NewModuleParam(opts ParamsOptions) (*genny.Generator, error) { func paramsProtoModify(opts ParamsOptions) genny.RunFn { return func(r *genny.Runner) error { - path := filepath.Join(opts.AppPath, "proto", opts.AppName, opts.ModuleName, "params.proto") + path := filepath.Join(opts.AppPath, opts.ProtoPath, opts.AppName, opts.ModuleName, "params.proto") f, err := r.Disk.Find(path) if err != nil { return err diff --git a/ignite/templates/query/options.go b/ignite/templates/query/options.go index d10b7e3cd2..e59be1124b 100644 --- a/ignite/templates/query/options.go +++ b/ignite/templates/query/options.go @@ -9,6 +9,7 @@ import ( type Options struct { AppName string AppPath string + ProtoPath string ModuleName string ModulePath string QueryName multiformatname.Name diff --git a/ignite/templates/query/query.go b/ignite/templates/query/query.go index 862c9846d0..394cd74b9c 100644 --- a/ignite/templates/query/query.go +++ b/ignite/templates/query/query.go @@ -67,7 +67,7 @@ func NewGenerator(replacer placeholder.Replacer, opts *Options) (*genny.Generato // - Existence of a service with name "Query" since that is where the RPCs will be added. func protoQueryModify(opts *Options) genny.RunFn { return func(r *genny.Runner) error { - path := filepath.Join(opts.AppPath, "proto", opts.AppName, opts.ModuleName, "query.proto") + path := filepath.Join(opts.AppPath, opts.ProtoPath, opts.AppName, opts.ModuleName, "query.proto") f, err := r.Disk.Find(path) if err != nil { return err diff --git a/ignite/templates/typed/list/genesis.go b/ignite/templates/typed/list/genesis.go index 779397fed6..9612ffffd7 100644 --- a/ignite/templates/typed/list/genesis.go +++ b/ignite/templates/typed/list/genesis.go @@ -28,7 +28,7 @@ func genesisModify(replacer placeholder.Replacer, opts *typed.Options, g *genny. // - Existence of a message with name "GenesisState". Adds the field there. func genesisProtoModify(opts *typed.Options) genny.RunFn { return func(r *genny.Runner) error { - path := opts.ProtoPath("genesis.proto") + path := opts.ProtoFile("genesis.proto") f, err := r.Disk.Find(path) if err != nil { return err diff --git a/ignite/templates/typed/list/list.go b/ignite/templates/typed/list/list.go index 79da02e3c7..7e049cfa99 100644 --- a/ignite/templates/typed/list/list.go +++ b/ignite/templates/typed/list/list.go @@ -89,7 +89,7 @@ func NewGenerator(replacer placeholder.Replacer, opts *typed.Options) (*genny.Ge // - A service named "Msg" to exist in the proto file, it appends the RPCs inside it. func protoTxModify(opts *typed.Options) genny.RunFn { return func(r *genny.Runner) error { - path := opts.ProtoPath("tx.proto") + path := opts.ProtoFile("tx.proto") f, err := r.Disk.Find(path) if err != nil { return err @@ -196,7 +196,7 @@ func protoTxModify(opts *typed.Options) genny.RunFn { // - Existence of a service with name "Query". Adds the rpc's there. func protoQueryModify(opts *typed.Options) genny.RunFn { return func(r *genny.Runner) error { - path := opts.ProtoPath("query.proto") + path := opts.ProtoFile("query.proto") f, err := r.Disk.Find(path) if err != nil { return err diff --git a/ignite/templates/typed/map/map.go b/ignite/templates/typed/map/map.go index 597d5efd88..76629c2ea1 100644 --- a/ignite/templates/typed/map/map.go +++ b/ignite/templates/typed/map/map.go @@ -123,7 +123,7 @@ func NewGenerator(replacer placeholder.Replacer, opts *typed.Options) (*genny.Ge // - Existence of a service with name "Query". Adds the rpc's there. func protoRPCModify(opts *typed.Options) genny.RunFn { return func(r *genny.Runner) error { - path := opts.ProtoPath("query.proto") + path := opts.ProtoFile("query.proto") f, err := r.Disk.Find(path) if err != nil { return err @@ -287,7 +287,7 @@ func clientCliQueryModify(replacer placeholder.Replacer, opts *typed.Options) ge // - Existence of a message with name "GenesisState". Adds the field there. func genesisProtoModify(opts *typed.Options) genny.RunFn { return func(r *genny.Runner) error { - path := opts.ProtoPath("genesis.proto") + path := opts.ProtoFile("genesis.proto") f, err := r.Disk.Find(path) if err != nil { return err @@ -522,7 +522,7 @@ func genesisTypesTestsModify(replacer placeholder.Replacer, opts *typed.Options) // - A service named "Msg" to exist in the proto file, it appends the RPCs inside it. func protoTxModify(opts *typed.Options) genny.RunFn { return func(r *genny.Runner) error { - path := opts.ProtoPath("tx.proto") + path := opts.ProtoFile("tx.proto") f, err := r.Disk.Find(path) if err != nil { return err diff --git a/ignite/templates/typed/options.go b/ignite/templates/typed/options.go index b9d2d4a11a..9669202d36 100644 --- a/ignite/templates/typed/options.go +++ b/ignite/templates/typed/options.go @@ -15,6 +15,7 @@ import ( type Options struct { AppName string AppPath string + ProtoPath string ModuleName string ModulePath string TypeName multiformatname.Name @@ -31,9 +32,9 @@ func (opts *Options) Validate() error { return nil } -// ProtoPath returns the path to the proto folder within the generated app. -func (opts *Options) ProtoPath(fname string) string { - return filepath.Join(opts.AppPath, "proto", opts.AppName, opts.ModuleName, fname) +// ProtoFile returns the path to the proto folder within the generated app. +func (opts *Options) ProtoFile(fname string) string { + return filepath.Join(opts.AppPath, opts.ProtoPath, opts.AppName, opts.ModuleName, fname) } // ProtoTypeImport Return the protobuf import statement for this type. diff --git a/ignite/templates/typed/singleton/singleton.go b/ignite/templates/typed/singleton/singleton.go index 9d6ba5ebc8..99773b29e9 100644 --- a/ignite/templates/typed/singleton/singleton.go +++ b/ignite/templates/typed/singleton/singleton.go @@ -143,7 +143,7 @@ func keeperModify(replacer placeholder.Replacer, opts *typed.Options) genny.RunF // - Existence of a service with name "Query". Adds the rpc's there. func protoRPCModify(opts *typed.Options) genny.RunFn { return func(r *genny.Runner) error { - path := opts.ProtoPath("query.proto") + path := opts.ProtoFile("query.proto") f, err := r.Disk.Find(path) if err != nil { return err @@ -231,7 +231,7 @@ func clientCliQueryModify(replacer placeholder.Replacer, opts *typed.Options) ge // - Existence of a message with name "GenesisState". Adds the field there. func genesisProtoModify(opts *typed.Options) genny.RunFn { return func(r *genny.Runner) error { - path := opts.ProtoPath("genesis.proto") + path := opts.ProtoFile("genesis.proto") f, err := r.Disk.Find(path) if err != nil { return err @@ -403,7 +403,7 @@ if err == nil { // - A service named "Msg" to exist in the proto file, it appends the RPCs inside it. func protoTxModify(opts *typed.Options) genny.RunFn { return func(r *genny.Runner) error { - path := opts.ProtoPath("tx.proto") + path := opts.ProtoFile("tx.proto") f, err := r.Disk.Find(path) if err != nil { return err diff --git a/integration/ibc/cmd_relayer_test.go b/integration/ibc/cmd_relayer_test.go index 368f22dd90..c7aa280a26 100644 --- a/integration/ibc/cmd_relayer_test.go +++ b/integration/ibc/cmd_relayer_test.go @@ -38,12 +38,6 @@ var ( marsConfig = v1.Config{ Config: base.Config{ Version: 1, - Build: base.Build{ - Proto: base.Proto{ - Path: "proto", - ThirdPartyPaths: []string{"third_party/proto", "proto_vendor"}, - }, - }, Accounts: []base.Account{ { Name: "alice", @@ -89,12 +83,6 @@ var ( earthConfig = v1.Config{ Config: base.Config{ Version: 1, - Build: base.Build{ - Proto: base.Proto{ - Path: "proto", - ThirdPartyPaths: []string{"third_party/proto", "proto_vendor"}, - }, - }, Accounts: []base.Account{ { Name: "alice", From 9fcff90b249180968cf235d06e2e3c4b2d5993ef Mon Sep 17 00:00:00 2001 From: Pantani Date: Thu, 4 Apr 2024 22:48:22 +0200 Subject: [PATCH 02/23] add changelog --- changelog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/changelog.md b/changelog.md index e572d36540..8bfc636aa0 100644 --- a/changelog.md +++ b/changelog.md @@ -10,6 +10,7 @@ - [#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 ### Changes From 95c96fc6a35a1a0d7fb4354ca3561f2d997eea8b Mon Sep 17 00:00:00 2001 From: Pantani Date: Thu, 4 Apr 2024 23:11:41 +0200 Subject: [PATCH 03/23] check buf work proto --- ignite/cmd/chain.go | 2 +- ignite/pkg/cosmosbuf/config.go | 33 +++++++++---------- ignite/services/chain/proto.go | 23 +++++++++++-- ignite/services/scaffolder/init.go | 1 + ignite/services/scaffolder/type.go | 7 ++++ ignite/services/scaffolder/type_test.go | 4 +++ ignite/templates/app/app.go | 1 + .../{buf.work.yaml => buf.work.yaml.plush} | 2 +- ignite/templates/app/options.go | 1 + ignite/templates/app/proto.go | 27 ++++++++++++--- 10 files changed, 76 insertions(+), 25 deletions(-) rename ignite/templates/app/files/{buf.work.yaml => buf.work.yaml.plush} (54%) diff --git a/ignite/cmd/chain.go b/ignite/cmd/chain.go index afbbeee559..c27c5908e5 100644 --- a/ignite/cmd/chain.go +++ b/ignite/cmd/chain.go @@ -211,7 +211,7 @@ func bufMigrationPreRunHandler(cmd *cobra.Command, session *cliui.Session, appPa } runner := xgenny.NewRunner(cmd.Context(), appPath) - sm, err := chain.BoxBufFiles(runner, appPath) + sm, err := chain.BoxBufFiles(runner, appPath, protoPath) if err != nil { return err } diff --git a/ignite/pkg/cosmosbuf/config.go b/ignite/pkg/cosmosbuf/config.go index 4ab3be6b9b..0fffe58d23 100644 --- a/ignite/pkg/cosmosbuf/config.go +++ b/ignite/pkg/cosmosbuf/config.go @@ -2,20 +2,24 @@ package cosmosbuf import ( "os" + "path/filepath" "gopkg.in/yaml.v3" - - "github.com/ignite/cli/v29/ignite/pkg/errors" ) +const workFilename = "buf.work.yaml" + // BufWork represents the buf.work.yaml file. type BufWork struct { + path string `yaml:"-"` Version string `yaml:"version"` Directories []string `yaml:"directories"` } -// ParseBufWork parse the buf.work.yaml file. -func ParseBufWork(path string) (BufWork, error) { +// ParseBufWork parse the buf.work.yaml file at app path. +func ParseBufWork(appPath string) (BufWork, error) { + path := filepath.Join(appPath, workFilename) + f, err := os.Open(path) if err != nil { return BufWork{}, err @@ -26,19 +30,14 @@ func ParseBufWork(path string) (BufWork, error) { return w, yaml.NewDecoder(f).Decode(&w) } -// ChangeProtoPath change the name of a proto directory path into the buf work file. -func (w *BufWork) ChangeProtoPath(oldPath, newPath string) error { - for i, path := range w.Directories { - if path == oldPath { - w.Directories[i] = newPath - return nil - } - } - return errors.Errorf("proto path %s not found", oldPath) +// AddProtoPath change the name of a proto directory path into the buf work file. +func (w BufWork) AddProtoPath(newPath string) error { + w.Directories = append(w.Directories, newPath) + return w.save() } // HasProtoPath returns true if the proto path exist into the directories slice. -func (w *BufWork) HasProtoPath(path string) bool { +func (w BufWork) HasProtoPath(path string) bool { for _, dirPath := range w.Directories { if path == dirPath { return true @@ -47,9 +46,9 @@ func (w *BufWork) HasProtoPath(path string) bool { return false } -// Save saves the buf work file. -func (w *BufWork) Save(path string) error { - file, err := os.OpenFile(path, os.O_WRONLY|os.O_TRUNC, 0o755) +// save saves the buf work file. +func (w BufWork) save() error { + file, err := os.OpenFile(w.path, os.O_WRONLY|os.O_TRUNC, 0o755) if err != nil { return err } diff --git a/ignite/services/chain/proto.go b/ignite/services/chain/proto.go index 9843008fd8..dc8fe2489a 100644 --- a/ignite/services/chain/proto.go +++ b/ignite/services/chain/proto.go @@ -4,6 +4,7 @@ import ( "path/filepath" "strings" + "github.com/ignite/cli/v29/ignite/pkg/cosmosbuf" "github.com/ignite/cli/v29/ignite/pkg/xgenny" "github.com/ignite/cli/v29/ignite/pkg/xos" "github.com/ignite/cli/v29/ignite/templates/app" @@ -11,6 +12,24 @@ import ( const defaultProtoFolder = "proto/" +func CheckBufProtoPath(appPath, protoPath string) (bool, error) { + workFile, err := cosmosbuf.ParseBufWork(appPath) + if err != nil { + return false, err + } + + return workFile.HasProtoPath(protoPath), nil +} + +func AddBufProtoPath(appPath, protoPath string) error { + workFile, err := cosmosbuf.ParseBufWork(appPath) + if err != nil { + return err + } + + return workFile.AddProtoPath(protoPath) +} + func CheckBufFiles(appPath, protoPath string) (bool, error) { files, err := app.BufFiles() if err != nil { @@ -28,8 +47,8 @@ func CheckBufFiles(appPath, protoPath string) (bool, error) { return true, nil } -func BoxBufFiles(runner *xgenny.Runner, appPath string) (xgenny.SourceModification, error) { - g, err := app.NewBufGenerator(appPath) +func BoxBufFiles(runner *xgenny.Runner, appPath, protoPath string) (xgenny.SourceModification, error) { + g, err := app.NewBufGenerator(appPath, protoPath) if err != nil { return xgenny.SourceModification{}, err } diff --git a/ignite/services/scaffolder/init.go b/ignite/services/scaffolder/init.go index 2c55e80cf5..ee23c7f2a6 100644 --- a/ignite/services/scaffolder/init.go +++ b/ignite/services/scaffolder/init.go @@ -92,6 +92,7 @@ func generate( ModulePath: pathInfo.RawPath, AppName: pathInfo.Package, AppPath: absRoot, + ProtoPath: defaults.ProtoPath, GitHubPath: githubPath, BinaryNamePrefix: pathInfo.Root, AddressPrefix: addressPrefix, diff --git a/ignite/services/scaffolder/type.go b/ignite/services/scaffolder/type.go index f30bee0102..12cb37fa42 100644 --- a/ignite/services/scaffolder/type.go +++ b/ignite/services/scaffolder/type.go @@ -114,6 +114,13 @@ func TypeWithSigner(signer string) AddTypeOption { } } +// TypeWithProtoPath provides a custom proto path. +func TypeWithProtoPath(protoPath string) AddTypeOption { + return func(o *addTypeOptions) { + o.protoPath = protoPath + } +} + // AddType adds a new type to a scaffolded app. // if none of the list, map or singleton given, a dry type without anything extra (like a storage layer, models, CLI etc.) // will be scaffolded. diff --git a/ignite/services/scaffolder/type_test.go b/ignite/services/scaffolder/type_test.go index 01a824a6f9..c3b5994926 100644 --- a/ignite/services/scaffolder/type_test.go +++ b/ignite/services/scaffolder/type_test.go @@ -34,6 +34,7 @@ func TestParseTypeFields(t *testing.T) { moduleName: testModuleName, fields: []string{"foo", "bar"}, isList: true, + protoPath: "proto", signer: testSigner, }, shouldError: false, @@ -76,6 +77,7 @@ func TestParseTypeFields(t *testing.T) { moduleName: "module", isSingleton: true, signer: testSigner, + protoPath: "proto", }, shouldError: false, expectedFields: nil, @@ -92,6 +94,7 @@ func TestParseTypeFields(t *testing.T) { isMap: true, withoutSimulation: true, signer: testSigner, + protoPath: "proto", }, shouldError: false, expectedFields: nil, @@ -109,6 +112,7 @@ func TestParseTypeFields(t *testing.T) { withoutMessage: true, fields: []string{"FieldFoo"}, signer: "signer", + protoPath: "proto", }, shouldError: false, expectedFields: field.Fields{ diff --git a/ignite/templates/app/app.go b/ignite/templates/app/app.go index 25e9cf4eb1..8f6e93f958 100644 --- a/ignite/templates/app/app.go +++ b/ignite/templates/app/app.go @@ -70,6 +70,7 @@ func NewGenerator(opts *Options) (*genny.Generator, error) { ctx := plush.NewContext() ctx.Set("ModulePath", opts.ModulePath) ctx.Set("AppName", opts.AppName) + ctx.Set("ProtoPath", opts.ProtoPath) ctx.Set("GitHubPath", opts.GitHubPath) ctx.Set("BinaryNamePrefix", opts.BinaryNamePrefix) ctx.Set("AddressPrefix", opts.AddressPrefix) diff --git a/ignite/templates/app/files/buf.work.yaml b/ignite/templates/app/files/buf.work.yaml.plush similarity index 54% rename from ignite/templates/app/files/buf.work.yaml rename to ignite/templates/app/files/buf.work.yaml.plush index 1878b341be..595c36ab37 100644 --- a/ignite/templates/app/files/buf.work.yaml +++ b/ignite/templates/app/files/buf.work.yaml.plush @@ -1,3 +1,3 @@ version: v1 directories: - - proto + - <%= ProtoPath %> diff --git a/ignite/templates/app/options.go b/ignite/templates/app/options.go index c60b966de5..4a8afe6064 100644 --- a/ignite/templates/app/options.go +++ b/ignite/templates/app/options.go @@ -4,6 +4,7 @@ package app type Options struct { AppName string AppPath string + ProtoPath string GitHubPath string BinaryNamePrefix string ModulePath string diff --git a/ignite/templates/app/proto.go b/ignite/templates/app/proto.go index aeb60622bf..a867284c25 100644 --- a/ignite/templates/app/proto.go +++ b/ignite/templates/app/proto.go @@ -2,18 +2,20 @@ package app import ( "embed" + "strings" "github.com/gobuffalo/genny/v2" + "github.com/gobuffalo/plush/v4" "github.com/ignite/cli/v29/ignite/pkg/xembed" "github.com/ignite/cli/v29/ignite/pkg/xgenny" ) -//go:embed files/proto/* files/buf.work.yaml +//go:embed files/proto/* files/buf.work.yaml.plush var fsProto embed.FS // NewBufGenerator returns the generator to buf build files. -func NewBufGenerator(appPath string) (*genny.Generator, error) { +func NewBufGenerator(appPath, protoPath string) (*genny.Generator, error) { var ( g = genny.New() template = xgenny.NewEmbedWalker( @@ -22,9 +24,26 @@ func NewBufGenerator(appPath string) (*genny.Generator, error) { appPath, ) ) - return g, xgenny.Box(g, template) + if err := xgenny.Box(g, template); err != nil { + return nil, err + } + + ctx := plush.NewContext() + ctx.Set("ProtoPath", protoPath) + g.Transformer(xgenny.Transformer(ctx)) + + return g, nil } +// BufFiles returns a list of Buf.Build files. func BufFiles() ([]string, error) { - return xembed.FileList(fsProto, "files") + files, err := xembed.FileList(fsProto, "files") + if err != nil { + return nil, err + } + // remove all .plush extensions. + for i, file := range files { + files[i] = strings.TrimSuffix(file, ".plush") + } + return files, nil } From 160b7620c6c30521de30a1dd2cd85b417e553c40 Mon Sep 17 00:00:00 2001 From: Pantani Date: Thu, 4 Apr 2024 23:24:59 +0200 Subject: [PATCH 04/23] check if the buf.work.yaml has the same proto path from the config file --- ignite/cmd/chain.go | 51 +++++++++++++++++++++++++++++++-------------- 1 file changed, 35 insertions(+), 16 deletions(-) diff --git a/ignite/cmd/chain.go b/ignite/cmd/chain.go index c27c5908e5..0664469435 100644 --- a/ignite/cmd/chain.go +++ b/ignite/cmd/chain.go @@ -25,12 +25,13 @@ import ( ) const ( - msgMigration = "Migrating blockchain config file from v%d to v%d..." - msgMigrationPrefix = "Your blockchain config version is v%d and the latest is v%d." - msgMigrationPrompt = "Would you like to upgrade your config file to v%d" - msgMigrationBuf = "Now ignite supports the `buf.build` (https://buf.build) registry to manage the protobuf dependencies. The embed protoc binary was deprecated and, your blockchain is still using it. Would you like to upgrade and add the `buf.build` config files to `proto/` folder" - msgMigrationAddTools = "Some required imports are missing in %s file: %s. Would you like to add them" - msgMigrationRemoveTools = "File %s contains deprecated imports: %s. Would you like to remove them" + msgMigration = "Migrating blockchain config file from v%d to v%d..." + msgMigrationPrefix = "Your blockchain config version is v%d and the latest is v%d." + msgMigrationPrompt = "Would you like to upgrade your config file to v%d" + msgMigrationBuf = "Now ignite supports the `buf.build` (https://buf.build) registry to manage the protobuf dependencies. The embed protoc binary was deprecated and, your blockchain is still using it. Would you like to upgrade and add the `buf.build` config files to `proto/` folder" + msgMigrationBufProtoPath = "Ignite proto directory path from the chain config doesn't match the proto directory path from your `buf.work.yaml`. Do you want to add the proto path `%[1]v` to the directories list from the buf work file?" + msgMigrationAddTools = "Some required imports are missing in %s file: %s. Would you like to add them" + msgMigrationRemoveTools = "File %s contains deprecated imports: %s. Would you like to remove them" ) var ErrProtocUnsupported = errors.New("code generation using protoc is only supported by Ignite CLI v0.26.1 or older") @@ -196,28 +197,46 @@ func bufMigrationPreRunHandler(cmd *cobra.Command, session *cliui.Session, appPa return err } + // check if the buf files exist. hasFiles, err := chain.CheckBufFiles(appPath, protoPath) if err != nil { return err } - if hasFiles { - return nil - } - if !getYes(cmd) { - if err := session.AskConfirm(msgMigrationBuf); err != nil { - return ErrProtocUnsupported + if !hasFiles { + if !getYes(cmd) { + if err := session.AskConfirm(msgMigrationBuf); err != nil { + return ErrProtocUnsupported + } + } + + runner := xgenny.NewRunner(cmd.Context(), appPath) + sm, err := chain.BoxBufFiles(runner, appPath, protoPath) + if err != nil { + return err } + + session.Print("\nšŸŽ‰ buf.build files added: \n\n") + session.Printf("%s\n\n", strings.Join(sm.CreatedFiles(), "\n")) } - runner := xgenny.NewRunner(cmd.Context(), appPath) - sm, err := chain.BoxBufFiles(runner, appPath, protoPath) + // check if the buf.work.yaml has the same proto path from the config file. + hasProtoPath, err := chain.CheckBufProtoPath(appPath, protoPath) if err != nil { return err } - session.Print("\nšŸŽ‰ buf.build files added: \n\n") - session.Printf("%s\n\n", strings.Join(sm.CreatedFiles(), "\n")) + if !hasProtoPath { + if !getYes(cmd) { + if err := session.AskConfirm(fmt.Sprintf(msgMigrationBufProtoPath, protoPath)); err != nil { + return nil + } + } + + if err := chain.AddBufProtoPath(appPath, protoPath); err != nil { + return err + } + } return nil } From 15ba5c6985b9dc2604cb0bb49bf20c1d81c3d019 Mon Sep 17 00:00:00 2001 From: Pantani Date: Thu, 4 Apr 2024 23:28:15 +0200 Subject: [PATCH 05/23] add comments --- ignite/services/chain/proto.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/ignite/services/chain/proto.go b/ignite/services/chain/proto.go index dc8fe2489a..ebc904fa6e 100644 --- a/ignite/services/chain/proto.go +++ b/ignite/services/chain/proto.go @@ -1,17 +1,18 @@ package chain import ( + "fmt" "path/filepath" "strings" + "github.com/ignite/cli/v29/ignite/config/chain/defaults" "github.com/ignite/cli/v29/ignite/pkg/cosmosbuf" "github.com/ignite/cli/v29/ignite/pkg/xgenny" "github.com/ignite/cli/v29/ignite/pkg/xos" "github.com/ignite/cli/v29/ignite/templates/app" ) -const defaultProtoFolder = "proto/" - +// CheckBufProtoPath check if the proto path exist into the directory list in the buf.work.yaml file. func CheckBufProtoPath(appPath, protoPath string) (bool, error) { workFile, err := cosmosbuf.ParseBufWork(appPath) if err != nil { @@ -21,6 +22,7 @@ func CheckBufProtoPath(appPath, protoPath string) (bool, error) { return workFile.HasProtoPath(protoPath), nil } +// AddBufProtoPath add the proto path into the directory list in the buf.work.yaml file. func AddBufProtoPath(appPath, protoPath string) error { workFile, err := cosmosbuf.ParseBufWork(appPath) if err != nil { @@ -30,13 +32,14 @@ func AddBufProtoPath(appPath, protoPath string) error { return workFile.AddProtoPath(protoPath) } +// CheckBufFiles check if the buf files exist. func CheckBufFiles(appPath, protoPath string) (bool, error) { files, err := app.BufFiles() if err != nil { return false, nil } for _, bufFile := range files { - bufFile, ok := strings.CutPrefix(bufFile, defaultProtoFolder) + bufFile, ok := strings.CutPrefix(bufFile, fmt.Sprintf("%s/", defaults.ProtoPath)) if ok { bufFile = filepath.Join(protoPath, bufFile) } @@ -47,6 +50,7 @@ func CheckBufFiles(appPath, protoPath string) (bool, error) { return true, nil } +// BoxBufFiles box all buf files. func BoxBufFiles(runner *xgenny.Runner, appPath, protoPath string) (xgenny.SourceModification, error) { g, err := app.NewBufGenerator(appPath, protoPath) if err != nil { From 3b03538c796a3ad08904058e96832151d1b638e4 Mon Sep 17 00:00:00 2001 From: Pantani Date: Fri, 5 Apr 2024 00:13:59 +0200 Subject: [PATCH 06/23] rmeove unused code --- ignite/services/chain/serve.go | 13 +++++++------ ignite/services/scaffolder/message.go | 14 ++------------ ignite/services/scaffolder/packet.go | 16 +++------------- ignite/services/scaffolder/type.go | 12 +----------- ignite/services/scaffolder/type_test.go | 4 ---- 5 files changed, 13 insertions(+), 46 deletions(-) diff --git a/ignite/services/chain/serve.go b/ignite/services/chain/serve.go index 6c7236b5db..ca953d1a78 100644 --- a/ignite/services/chain/serve.go +++ b/ignite/services/chain/serve.go @@ -15,6 +15,7 @@ import ( "github.com/ignite/cli/v29/ignite/config" chainconfig "github.com/ignite/cli/v29/ignite/config/chain" + "github.com/ignite/cli/v29/ignite/config/chain/defaults" "github.com/ignite/cli/v29/ignite/pkg/cache" chaincmdrunner "github.com/ignite/cli/v29/ignite/pkg/chaincmd/runner" "github.com/ignite/cli/v29/ignite/pkg/cliui/colors" @@ -294,14 +295,14 @@ func (c *Chain) refreshServe() { } func (c *Chain) watchAppBackend(ctx context.Context) error { - conf, err := c.Config() - if err != nil { - return err - } + watchPaths := appBackendSourceWatchPaths(defaults.ProtoPath) - watchPaths := appBackendSourceWatchPaths(conf.Build.Proto.Path) if c.ConfigPath() != "" { - watchPaths = append(watchPaths, c.ConfigPath()) + conf, err := c.Config() + if err != nil { + return err + } + watchPaths = append(appBackendSourceWatchPaths(conf.Build.Proto.Path), c.ConfigPath()) } return localfs.Watch( diff --git a/ignite/services/scaffolder/message.go b/ignite/services/scaffolder/message.go index aa019cc98d..07481622b5 100644 --- a/ignite/services/scaffolder/message.go +++ b/ignite/services/scaffolder/message.go @@ -6,7 +6,6 @@ import ( "github.com/gobuffalo/genny/v2" - "github.com/ignite/cli/v29/ignite/config/chain/defaults" "github.com/ignite/cli/v29/ignite/pkg/errors" "github.com/ignite/cli/v29/ignite/pkg/multiformatname" "github.com/ignite/cli/v29/ignite/templates/field" @@ -19,7 +18,6 @@ import ( type messageOptions struct { description string signer string - protoPath string withoutSimulation bool } @@ -28,7 +26,6 @@ func newMessageOptions(messageName string) messageOptions { return messageOptions{ description: fmt.Sprintf("Broadcast message %s", messageName), signer: "creator", - protoPath: defaults.ProtoPath, } } @@ -49,13 +46,6 @@ func WithSigner(signer string) MessageOption { } } -// WithProtoPath provides a custom proto appPath. -func WithProtoPath(protoPath string) MessageOption { - return func(m *messageOptions) { - m.protoPath = protoPath - } -} - // WithoutSimulation disables generating messages simulation. func WithoutSimulation() MessageOption { return func(m *messageOptions) { @@ -102,7 +92,7 @@ func (s Scaffolder) AddMessage( ctx, s.appPath, s.modpath.Package, - scaffoldingOpts.protoPath, + s.protoPath, moduleName, fields, ); err != nil { @@ -118,7 +108,7 @@ func (s Scaffolder) AddMessage( ctx, s.appPath, s.modpath.Package, - scaffoldingOpts.protoPath, + s.protoPath, moduleName, resFields, ); err != nil { diff --git a/ignite/services/scaffolder/packet.go b/ignite/services/scaffolder/packet.go index 6fabd107b0..c96cc34393 100644 --- a/ignite/services/scaffolder/packet.go +++ b/ignite/services/scaffolder/packet.go @@ -7,7 +7,6 @@ import ( "github.com/gobuffalo/genny/v2" - "github.com/ignite/cli/v29/ignite/config/chain/defaults" "github.com/ignite/cli/v29/ignite/pkg/errors" "github.com/ignite/cli/v29/ignite/pkg/multiformatname" "github.com/ignite/cli/v29/ignite/templates/field" @@ -23,14 +22,12 @@ const ( type packetOptions struct { withoutMessage bool signer string - protoPath string } // newPacketOptions returns a packetOptions with default options. func newPacketOptions() packetOptions { return packetOptions{ - signer: "creator", - protoPath: defaults.ProtoPath, + signer: "creator", } } @@ -51,13 +48,6 @@ func PacketWithSigner(signer string) PacketOption { } } -// PacketWithProtoPath provides a custom proto appPath. -func PacketWithProtoPath(protoPath string) PacketOption { - return func(m *packetOptions) { - m.protoPath = protoPath - } -} - // AddPacket adds a new type stype to scaffolded app by using optional type fields. func (s Scaffolder) AddPacket( ctx context.Context, @@ -108,7 +98,7 @@ func (s Scaffolder) AddPacket( } // Check and parse packet fields - if err := checkCustomTypes(ctx, s.appPath, s.modpath.Package, o.protoPath, moduleName, packetFields); err != nil { + if err := checkCustomTypes(ctx, s.appPath, s.modpath.Package, s.protoPath, moduleName, packetFields); err != nil { return err } parsedPacketFields, err := field.ParseFields(packetFields, checkForbiddenPacketField, signer) @@ -117,7 +107,7 @@ func (s Scaffolder) AddPacket( } // check and parse acknowledgment fields - if err := checkCustomTypes(ctx, s.appPath, s.modpath.Package, o.protoPath, moduleName, ackFields); err != nil { + if err := checkCustomTypes(ctx, s.appPath, s.modpath.Package, s.protoPath, moduleName, ackFields); err != nil { return err } parsedAcksFields, err := field.ParseFields(ackFields, checkGoReservedWord, signer) diff --git a/ignite/services/scaffolder/type.go b/ignite/services/scaffolder/type.go index 12cb37fa42..2d29b4f4db 100644 --- a/ignite/services/scaffolder/type.go +++ b/ignite/services/scaffolder/type.go @@ -6,7 +6,6 @@ import ( "github.com/gobuffalo/genny/v2" - "github.com/ignite/cli/v29/ignite/config/chain/defaults" "github.com/ignite/cli/v29/ignite/pkg/errors" "github.com/ignite/cli/v29/ignite/pkg/multiformatname" "github.com/ignite/cli/v29/ignite/pkg/placeholder" @@ -28,7 +27,6 @@ type AddTypeKind func(*addTypeOptions) type addTypeOptions struct { moduleName string - protoPath string fields []string isList bool @@ -47,7 +45,6 @@ func newAddTypeOptions(moduleName string) addTypeOptions { return addTypeOptions{ moduleName: moduleName, signer: "creator", - protoPath: defaults.ProtoPath, } } @@ -114,13 +111,6 @@ func TypeWithSigner(signer string) AddTypeOption { } } -// TypeWithProtoPath provides a custom proto path. -func TypeWithProtoPath(protoPath string) AddTypeOption { - return func(o *addTypeOptions) { - o.protoPath = protoPath - } -} - // AddType adds a new type to a scaffolded app. // if none of the list, map or singleton given, a dry type without anything extra (like a storage layer, models, CLI etc.) // will be scaffolded. @@ -153,7 +143,7 @@ func (s Scaffolder) AddType( } // Check and parse provided fields - if err := checkCustomTypes(ctx, s.appPath, s.modpath.Package, o.protoPath, moduleName, o.fields); err != nil { + if err := checkCustomTypes(ctx, s.appPath, s.modpath.Package, s.protoPath, moduleName, o.fields); err != nil { return err } tFields, err := parseTypeFields(o) diff --git a/ignite/services/scaffolder/type_test.go b/ignite/services/scaffolder/type_test.go index c3b5994926..01a824a6f9 100644 --- a/ignite/services/scaffolder/type_test.go +++ b/ignite/services/scaffolder/type_test.go @@ -34,7 +34,6 @@ func TestParseTypeFields(t *testing.T) { moduleName: testModuleName, fields: []string{"foo", "bar"}, isList: true, - protoPath: "proto", signer: testSigner, }, shouldError: false, @@ -77,7 +76,6 @@ func TestParseTypeFields(t *testing.T) { moduleName: "module", isSingleton: true, signer: testSigner, - protoPath: "proto", }, shouldError: false, expectedFields: nil, @@ -94,7 +92,6 @@ func TestParseTypeFields(t *testing.T) { isMap: true, withoutSimulation: true, signer: testSigner, - protoPath: "proto", }, shouldError: false, expectedFields: nil, @@ -112,7 +109,6 @@ func TestParseTypeFields(t *testing.T) { withoutMessage: true, fields: []string{"FieldFoo"}, signer: "signer", - protoPath: "proto", }, shouldError: false, expectedFields: field.Fields{ From a9474b456e27532b059e827e53567d6fe1fa11b6 Mon Sep 17 00:00:00 2001 From: Pantani Date: Fri, 5 Apr 2024 01:18:46 +0200 Subject: [PATCH 07/23] remove unused proto paths and add integrations tests --- ignite/cmd/chain.go | 29 ++++++--- ignite/pkg/cosmosbuf/config.go | 38 ++++++++++-- ignite/services/chain/proto.go | 21 ++++++- integration/app/cmd_proto_path_test.go | 82 ++++++++++++++++++++++++++ integration/ibc/cmd_relayer_test.go | 4 +- 5 files changed, 156 insertions(+), 18 deletions(-) create mode 100644 integration/app/cmd_proto_path_test.go diff --git a/ignite/cmd/chain.go b/ignite/cmd/chain.go index 0664469435..b6a7f8613f 100644 --- a/ignite/cmd/chain.go +++ b/ignite/cmd/chain.go @@ -25,13 +25,14 @@ import ( ) const ( - msgMigration = "Migrating blockchain config file from v%d to v%d..." - msgMigrationPrefix = "Your blockchain config version is v%d and the latest is v%d." - msgMigrationPrompt = "Would you like to upgrade your config file to v%d" - msgMigrationBuf = "Now ignite supports the `buf.build` (https://buf.build) registry to manage the protobuf dependencies. The embed protoc binary was deprecated and, your blockchain is still using it. Would you like to upgrade and add the `buf.build` config files to `proto/` folder" - msgMigrationBufProtoPath = "Ignite proto directory path from the chain config doesn't match the proto directory path from your `buf.work.yaml`. Do you want to add the proto path `%[1]v` to the directories list from the buf work file?" - msgMigrationAddTools = "Some required imports are missing in %s file: %s. Would you like to add them" - msgMigrationRemoveTools = "File %s contains deprecated imports: %s. Would you like to remove them" + msgMigration = "Migrating blockchain config file from v%d to v%d..." + msgMigrationPrefix = "Your blockchain config version is v%d and the latest is v%d." + msgMigrationPrompt = "Would you like to upgrade your config file to v%d" + msgMigrationBuf = "Now ignite supports the `buf.build` (https://buf.build) registry to manage the protobuf dependencies. The embed protoc binary was deprecated and, your blockchain is still using it. Would you like to upgrade and add the `buf.build` config files to `proto/` folder" + msgMigrationBufProtoPath = "Ignite proto directory path from the chain config doesn't match the proto directory path from the chain `buf.work.yaml`. Do you want to add the proto path `%[1]v` to the directories list from the buf work file" + msgMigrationBufProtoPaths = "Chain `buf.work.yaml` file contains directories that don't exist anymore (%[1]v). Do you want to delete them" + msgMigrationAddTools = "Some required imports are missing in %s file: %s. Would you like to add them" + msgMigrationRemoveTools = "File %s contains deprecated imports: %s. Would you like to remove them" ) var ErrProtocUnsupported = errors.New("code generation using protoc is only supported by Ignite CLI v0.26.1 or older") @@ -221,7 +222,7 @@ func bufMigrationPreRunHandler(cmd *cobra.Command, session *cliui.Session, appPa } // check if the buf.work.yaml has the same proto path from the config file. - hasProtoPath, err := chain.CheckBufProtoPath(appPath, protoPath) + hasProtoPath, missingPaths, err := chain.CheckBufProtoPath(appPath, protoPath) if err != nil { return err } @@ -238,6 +239,18 @@ func bufMigrationPreRunHandler(cmd *cobra.Command, session *cliui.Session, appPa } } + if len(missingPaths) > 0 { + if !getYes(cmd) { + if err := session.AskConfirm(fmt.Sprintf(msgMigrationBufProtoPaths, strings.Join(missingPaths, ", "))); err != nil { + return nil + } + } + + if err := chain.RemoveBufProtoPath(appPath, missingPaths...); err != nil { + return err + } + } + return nil } diff --git a/ignite/pkg/cosmosbuf/config.go b/ignite/pkg/cosmosbuf/config.go index 0fffe58d23..d1b94995c1 100644 --- a/ignite/pkg/cosmosbuf/config.go +++ b/ignite/pkg/cosmosbuf/config.go @@ -11,7 +11,8 @@ const workFilename = "buf.work.yaml" // BufWork represents the buf.work.yaml file. type BufWork struct { - path string `yaml:"-"` + appPath string `yaml:"-"` + filePath string `yaml:"-"` Version string `yaml:"version"` Directories []string `yaml:"directories"` } @@ -26,16 +27,43 @@ func ParseBufWork(appPath string) (BufWork, error) { } defer f.Close() - var w BufWork + w := BufWork{appPath: appPath, filePath: path} return w, yaml.NewDecoder(f).Decode(&w) } -// AddProtoPath change the name of a proto directory path into the buf work file. +// MissingDirectories check if the directories inside the buf work exist. +func (w BufWork) MissingDirectories() ([]string, error) { + missingPaths := make([]string, 0) + for _, dir := range w.Directories { + protoDir := filepath.Join(w.appPath, dir) + if _, err := os.Stat(protoDir); os.IsNotExist(err) { + missingPaths = append(missingPaths, dir) + } else if !os.IsNotExist(err) { + return nil, err + } + } + return missingPaths, nil +} + +// AddProtoPath add a proto directory path from the buf work file. func (w BufWork) AddProtoPath(newPath string) error { w.Directories = append(w.Directories, newPath) return w.save() } +// RemoveProtoPaths remove a list a proto directory paths from the buf work file. +func (w BufWork) RemoveProtoPaths(paths ...string) error { + for _, path := range paths { + for i, dir := range w.Directories { + if dir == path { + w.Directories = append(w.Directories[:i], w.Directories[i+1:]...) + break + } + } + } + return w.save() +} + // HasProtoPath returns true if the proto path exist into the directories slice. func (w BufWork) HasProtoPath(path string) bool { for _, dirPath := range w.Directories { @@ -48,10 +76,10 @@ func (w BufWork) HasProtoPath(path string) bool { // save saves the buf work file. func (w BufWork) save() error { - file, err := os.OpenFile(w.path, os.O_WRONLY|os.O_TRUNC, 0o755) + file, err := os.OpenFile(w.filePath, os.O_WRONLY|os.O_TRUNC, 0o755) if err != nil { return err } defer file.Close() - return yaml.NewEncoder(file).Encode(w) + return yaml.NewEncoder(file).Encode(&w) } diff --git a/ignite/services/chain/proto.go b/ignite/services/chain/proto.go index ebc904fa6e..8bd73b6480 100644 --- a/ignite/services/chain/proto.go +++ b/ignite/services/chain/proto.go @@ -13,13 +13,18 @@ import ( ) // CheckBufProtoPath check if the proto path exist into the directory list in the buf.work.yaml file. -func CheckBufProtoPath(appPath, protoPath string) (bool, error) { +func CheckBufProtoPath(appPath, protoPath string) (bool, []string, error) { workFile, err := cosmosbuf.ParseBufWork(appPath) if err != nil { - return false, err + return false, nil, err } - return workFile.HasProtoPath(protoPath), nil + missing, err := workFile.MissingDirectories() + if err != nil { + return false, nil, err + } + + return workFile.HasProtoPath(protoPath), missing, nil } // AddBufProtoPath add the proto path into the directory list in the buf.work.yaml file. @@ -32,6 +37,16 @@ func AddBufProtoPath(appPath, protoPath string) error { return workFile.AddProtoPath(protoPath) } +// RemoveBufProtoPath add the proto path into the directory list in the buf.work.yaml file. +func RemoveBufProtoPath(appPath string, protoPaths ...string) error { + workFile, err := cosmosbuf.ParseBufWork(appPath) + if err != nil { + return err + } + + return workFile.RemoveProtoPaths(protoPaths...) +} + // CheckBufFiles check if the buf files exist. func CheckBufFiles(appPath, protoPath string) (bool, error) { files, err := app.BufFiles() diff --git a/integration/app/cmd_proto_path_test.go b/integration/app/cmd_proto_path_test.go new file mode 100644 index 0000000000..9a817b7c58 --- /dev/null +++ b/integration/app/cmd_proto_path_test.go @@ -0,0 +1,82 @@ +//go:build !relayer + +package app_test + +import ( + "os" + "path/filepath" + "testing" + + "github.com/stretchr/testify/require" + "gopkg.in/yaml.v3" + + "github.com/ignite/cli/v29/ignite/config/chain" + "github.com/ignite/cli/v29/ignite/config/chain/base" + "github.com/ignite/cli/v29/ignite/config/chain/defaults" + v1 "github.com/ignite/cli/v29/ignite/config/chain/v1" + "github.com/ignite/cli/v29/ignite/pkg/xos" + "github.com/ignite/cli/v29/ignite/pkg/xyaml" + envtest "github.com/ignite/cli/v29/integration" +) + +const newProtoPath = "myProto" + +var ( + bobName = "bob" + cfg = v1.Config{ + Config: base.Config{ + Version: 1, + Build: base.Build{ + Proto: base.Proto{ + Path: newProtoPath, + }, + }, + Accounts: []base.Account{ + { + Name: "alice", + Coins: []string{"100000000000token", "10000000000000000000stake"}, + Mnemonic: "slide moment original seven milk crawl help text kick fluid boring awkward doll wonder sure fragile plate grid hard next casual expire okay body", + }, + { + Name: bobName, + Coins: []string{"100000000000token", "10000000000000000000stake"}, + Mnemonic: "trap possible liquid elite embody host segment fantasy swim cable digital eager tiny broom burden diary earn hen grow engine pigeon fringe claim program", + }, + }, + Faucet: base.Faucet{ + Name: &bobName, + Coins: []string{"500token", "100000000stake"}, + Host: ":4501", + }, + Genesis: xyaml.Map{"chain_id": "mars-1"}, + }, + Validators: []v1.Validator{ + { + Name: "alice", + Bonded: "100000000stake", + }, + }, + } +) + +func TestChangeProtoPath(t *testing.T) { + var ( + env = envtest.New(t) + app = env.Scaffold("github.com/test/protopath") + appPath = app.SourcePath() + cfgPath = filepath.Join(appPath, chain.ConfigFilenames[0]) + ) + + // set the custom config path. + file, err := os.Create(cfgPath) + require.NoError(t, err) + require.NoError(t, yaml.NewEncoder(file).Encode(cfg)) + require.NoError(t, file.Close()) + app.SetConfigPath(cfgPath) + + oldProtoPath := filepath.Join(appPath, defaults.ProtoPath) + protoPath := filepath.Join(appPath, newProtoPath) + require.NoError(t, xos.Rename(oldProtoPath, protoPath)) + + app.EnsureSteady() +} diff --git a/integration/ibc/cmd_relayer_test.go b/integration/ibc/cmd_relayer_test.go index c7aa280a26..caeb189f52 100644 --- a/integration/ibc/cmd_relayer_test.go +++ b/integration/ibc/cmd_relayer_test.go @@ -45,7 +45,7 @@ var ( Mnemonic: "slide moment original seven milk crawl help text kick fluid boring awkward doll wonder sure fragile plate grid hard next casual expire okay body", }, { - Name: "bob", + Name: bobName, Coins: []string{"100000000000token", "10000000000000000000stake"}, Mnemonic: "trap possible liquid elite embody host segment fantasy swim cable digital eager tiny broom burden diary earn hen grow engine pigeon fringe claim program", }, @@ -90,7 +90,7 @@ var ( Mnemonic: "slide moment original seven milk crawl help text kick fluid boring awkward doll wonder sure fragile plate grid hard next casual expire okay body", }, { - Name: "bob", + Name: bobName, Coins: []string{"100000000000token", "10000000000000000000stake"}, Mnemonic: "trap possible liquid elite embody host segment fantasy swim cable digital eager tiny broom burden diary earn hen grow engine pigeon fringe claim program", }, From 3012a9b6fff867bedb31027bf1d85de06ceccaca Mon Sep 17 00:00:00 2001 From: Pantani Date: Fri, 5 Apr 2024 01:39:51 +0200 Subject: [PATCH 08/23] fix resolve includes function --- ignite/pkg/cosmosgen/generate.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ignite/pkg/cosmosgen/generate.go b/ignite/pkg/cosmosgen/generate.go index f3efa540fd..97efa3d7bb 100644 --- a/ignite/pkg/cosmosgen/generate.go +++ b/ignite/pkg/cosmosgen/generate.go @@ -11,6 +11,7 @@ import ( "gopkg.in/yaml.v2" + "github.com/ignite/cli/v29/ignite/config/chain/defaults" "github.com/ignite/cli/v29/ignite/pkg/cache" "github.com/ignite/cli/v29/ignite/pkg/cliui/colors" "github.com/ignite/cli/v29/ignite/pkg/cliui/icons" @@ -123,7 +124,7 @@ func (g *generator) setup(ctx context.Context) (err error) { return err } - g.appIncludes, _, err = g.resolveIncludes(ctx, g.appPath) + g.appIncludes, _, err = g.resolveIncludes(ctx, g.appPath, g.protoDir) if err != nil { return err } @@ -185,7 +186,7 @@ func (g *generator) setup(ctx context.Context) (err error) { cacheable = true ) if len(modules) > 0 { - includes, cacheable, err = g.resolveIncludes(ctx, path) + includes, cacheable, err = g.resolveIncludes(ctx, path, defaults.ProtoPath) if err != nil { return err } @@ -254,7 +255,7 @@ func (g *generator) generateBufIncludeFolder(ctx context.Context, modpath string return protoPath, nil } -func (g *generator) resolveIncludes(ctx context.Context, path string) (protoIncludes, bool, error) { +func (g *generator) resolveIncludes(ctx context.Context, path, protoDir string) (protoIncludes, bool, error) { // Init paths with the global include paths for protoc paths, err := protocGlobalInclude() if err != nil { @@ -270,7 +271,7 @@ func (g *generator) resolveIncludes(ctx context.Context, path string) (protoIncl protoPath = filepath.Join(g.sdkDir, "proto") } else { // Check that the app/package proto directory exists - protoPath = filepath.Join(path, g.protoDir) + protoPath = filepath.Join(path, protoDir) fi, err := os.Stat(protoPath) if err != nil && !os.IsNotExist(err) { return protoIncludes{}, false, err From 33bd6eb6e42e808761a8a38434d902dad1aaf6bc Mon Sep 17 00:00:00 2001 From: Pantani Date: Fri, 5 Apr 2024 01:59:28 +0200 Subject: [PATCH 09/23] fix integration tests --- integration/app/cmd_proto_path_test.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/integration/app/cmd_proto_path_test.go b/integration/app/cmd_proto_path_test.go index 9a817b7c58..3dccd03dce 100644 --- a/integration/app/cmd_proto_path_test.go +++ b/integration/app/cmd_proto_path_test.go @@ -14,7 +14,6 @@ import ( "github.com/ignite/cli/v29/ignite/config/chain/base" "github.com/ignite/cli/v29/ignite/config/chain/defaults" v1 "github.com/ignite/cli/v29/ignite/config/chain/v1" - "github.com/ignite/cli/v29/ignite/pkg/xos" "github.com/ignite/cli/v29/ignite/pkg/xyaml" envtest "github.com/ignite/cli/v29/integration" ) @@ -76,7 +75,7 @@ func TestChangeProtoPath(t *testing.T) { oldProtoPath := filepath.Join(appPath, defaults.ProtoPath) protoPath := filepath.Join(appPath, newProtoPath) - require.NoError(t, xos.Rename(oldProtoPath, protoPath)) + require.NoError(t, os.Rename(oldProtoPath, protoPath)) app.EnsureSteady() } From 3e80404b78fb59eeb07b4a5911fd5f070815d695 Mon Sep 17 00:00:00 2001 From: Pantani Date: Fri, 5 Apr 2024 02:00:57 +0200 Subject: [PATCH 10/23] scaffold a list into the tests --- integration/app/cmd_proto_path_test.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/integration/app/cmd_proto_path_test.go b/integration/app/cmd_proto_path_test.go index 3dccd03dce..fb61bd1f38 100644 --- a/integration/app/cmd_proto_path_test.go +++ b/integration/app/cmd_proto_path_test.go @@ -14,6 +14,7 @@ import ( "github.com/ignite/cli/v29/ignite/config/chain/base" "github.com/ignite/cli/v29/ignite/config/chain/defaults" v1 "github.com/ignite/cli/v29/ignite/config/chain/v1" + "github.com/ignite/cli/v29/ignite/pkg/cmdrunner/step" "github.com/ignite/cli/v29/ignite/pkg/xyaml" envtest "github.com/ignite/cli/v29/integration" ) @@ -77,5 +78,12 @@ func TestChangeProtoPath(t *testing.T) { protoPath := filepath.Join(appPath, newProtoPath) require.NoError(t, os.Rename(oldProtoPath, protoPath)) + env.Must(env.Exec("create a list with a custom proto path", + step.NewSteps(step.New( + step.Exec(envtest.IgniteApp, "s", "list", "--yes", "user", "email"), + step.Workdir(app.SourcePath()), + )), + )) + app.EnsureSteady() } From 9b0808b435e5b7840c6b8ab0e3d2f3147d46218d Mon Sep 17 00:00:00 2001 From: Pantani Date: Fri, 5 Apr 2024 14:16:33 +0200 Subject: [PATCH 11/23] proto dir flag --- ignite/cmd/chain.go | 32 +++++----- ignite/cmd/cmd.go | 14 ++++- ignite/cmd/scaffold.go | 12 ++-- ignite/cmd/scaffold_configs.go | 8 +-- ignite/cmd/scaffold_message.go | 8 +-- ignite/cmd/scaffold_module.go | 12 ++-- ignite/cmd/scaffold_packet.go | 8 +-- ignite/cmd/scaffold_params.go | 8 +-- ignite/cmd/scaffold_query.go | 12 ++-- ignite/config/chain/base/config.go | 2 +- ignite/config/chain/defaults/default.go | 4 +- ignite/config/chain/parse.go | 2 +- ignite/pkg/cosmosbuf/config.go | 12 ++-- ignite/pkg/cosmosgen/generate.go | 2 +- ignite/services/chain/chain.go | 4 +- ignite/services/chain/proto.go | 28 ++++----- ignite/services/chain/serve.go | 2 +- ignite/services/scaffolder/component.go | 4 +- ignite/services/scaffolder/configs.go | 2 +- ignite/services/scaffolder/init.go | 4 +- ignite/services/scaffolder/message.go | 8 +-- ignite/services/scaffolder/module.go | 2 +- ignite/services/scaffolder/packet.go | 6 +- ignite/services/scaffolder/params.go | 2 +- ignite/services/scaffolder/patch.go | 2 +- ignite/services/scaffolder/query.go | 4 +- ignite/services/scaffolder/scaffolder.go | 16 ++--- ignite/services/scaffolder/type.go | 4 +- ignite/templates/app/app.go | 4 +- .../templates/app/files/buf.work.yaml.plush | 2 +- .../{proto => {{protoDir}}}/buf.gen.gogo.yaml | 0 .../buf.gen.pulsar.yaml | 0 .../{proto => {{protoDir}}}/buf.gen.sta.yaml | 0 .../buf.gen.swagger.yaml | 0 .../{proto => {{protoDir}}}/buf.gen.ts.yaml | 0 .../files/{proto => {{protoDir}}}/buf.lock | 0 .../files/{proto => {{protoDir}}}/buf.yaml | 0 ignite/templates/app/options.go | 2 +- ignite/templates/app/proto.go | 8 ++- ignite/templates/app/proto_test.go | 4 +- ignite/templates/ibc/packet.go | 7 ++- ignite/templates/message/message.go | 5 +- ignite/templates/message/options.go | 2 +- ignite/templates/module/create/base.go | 1 + ignite/templates/module/create/configs.go | 2 +- .../{{moduleName}}/genesis.proto.plush | 0 .../{{moduleName}}/module/module.proto.plush | 0 .../{{moduleName}}/params.proto.plush | 0 .../{{moduleName}}/query.proto.plush | 0 .../{{moduleName}}/packet.proto.plush | 0 .../{{appName}}/{{moduleName}}/tx.proto.plush | 0 ignite/templates/module/create/ibc.go | 3 +- ignite/templates/module/create/msgserver.go | 1 + ignite/templates/module/create/options.go | 8 +-- ignite/templates/module/create/params.go | 2 +- ignite/templates/query/options.go | 2 +- ignite/templates/query/query.go | 2 +- .../{{moduleName}}/{{typeName}}.proto.plush | 0 .../{{moduleName}}/{{typeName}}.proto.plush | 0 .../{{moduleName}}/{{typeName}}.proto.plush | 0 ignite/templates/typed/options.go | 4 +- .../{{moduleName}}/{{typeName}}.proto.plush | 0 ignite/templates/typed/typed.go | 1 + integration/app/cmd_app_test.go | 26 -------- integration/app/cmd_proto_path_test.go | 60 ++++++++++++++++++- 65 files changed, 201 insertions(+), 169 deletions(-) rename ignite/templates/app/files/{proto => {{protoDir}}}/buf.gen.gogo.yaml (100%) rename ignite/templates/app/files/{proto => {{protoDir}}}/buf.gen.pulsar.yaml (100%) rename ignite/templates/app/files/{proto => {{protoDir}}}/buf.gen.sta.yaml (100%) rename ignite/templates/app/files/{proto => {{protoDir}}}/buf.gen.swagger.yaml (100%) rename ignite/templates/app/files/{proto => {{protoDir}}}/buf.gen.ts.yaml (100%) rename ignite/templates/app/files/{proto => {{protoDir}}}/buf.lock (100%) rename ignite/templates/app/files/{proto => {{protoDir}}}/buf.yaml (100%) rename ignite/templates/module/create/files/base/{proto => {{protoDir}}}/{{appName}}/{{moduleName}}/genesis.proto.plush (100%) rename ignite/templates/module/create/files/base/{proto => {{protoDir}}}/{{appName}}/{{moduleName}}/module/module.proto.plush (100%) rename ignite/templates/module/create/files/base/{proto => {{protoDir}}}/{{appName}}/{{moduleName}}/params.proto.plush (100%) rename ignite/templates/module/create/files/base/{proto => {{protoDir}}}/{{appName}}/{{moduleName}}/query.proto.plush (100%) rename ignite/templates/module/create/files/ibc/{proto => {{protoDir}}}/{{appName}}/{{moduleName}}/packet.proto.plush (100%) rename ignite/templates/module/create/files/msgserver/{proto => {{protoDir}}}/{{appName}}/{{moduleName}}/tx.proto.plush (100%) rename ignite/templates/typed/dry/files/component/{proto => {{protoDir}}}/{{appName}}/{{moduleName}}/{{typeName}}.proto.plush (100%) rename ignite/templates/typed/list/files/component/{proto => {{protoDir}}}/{{appName}}/{{moduleName}}/{{typeName}}.proto.plush (100%) rename ignite/templates/typed/map/files/component/{proto => {{protoDir}}}/{{appName}}/{{moduleName}}/{{typeName}}.proto.plush (100%) rename ignite/templates/typed/singleton/files/component/{proto => {{protoDir}}}/{{appName}}/{{moduleName}}/{{typeName}}.proto.plush (100%) diff --git a/ignite/cmd/chain.go b/ignite/cmd/chain.go index b6a7f8613f..820a1e689b 100644 --- a/ignite/cmd/chain.go +++ b/ignite/cmd/chain.go @@ -25,14 +25,14 @@ import ( ) const ( - msgMigration = "Migrating blockchain config file from v%d to v%d..." - msgMigrationPrefix = "Your blockchain config version is v%d and the latest is v%d." - msgMigrationPrompt = "Would you like to upgrade your config file to v%d" - msgMigrationBuf = "Now ignite supports the `buf.build` (https://buf.build) registry to manage the protobuf dependencies. The embed protoc binary was deprecated and, your blockchain is still using it. Would you like to upgrade and add the `buf.build` config files to `proto/` folder" - msgMigrationBufProtoPath = "Ignite proto directory path from the chain config doesn't match the proto directory path from the chain `buf.work.yaml`. Do you want to add the proto path `%[1]v` to the directories list from the buf work file" - msgMigrationBufProtoPaths = "Chain `buf.work.yaml` file contains directories that don't exist anymore (%[1]v). Do you want to delete them" - msgMigrationAddTools = "Some required imports are missing in %s file: %s. Would you like to add them" - msgMigrationRemoveTools = "File %s contains deprecated imports: %s. Would you like to remove them" + msgMigration = "Migrating blockchain config file from v%d to v%d..." + msgMigrationPrefix = "Your blockchain config version is v%d and the latest is v%d." + msgMigrationPrompt = "Would you like to upgrade your config file to v%d" + msgMigrationBuf = "Now ignite supports the `buf.build` (https://buf.build) registry to manage the protobuf dependencies. The embed protoc binary was deprecated and, your blockchain is still using it. Would you like to upgrade and add the `buf.build` config files to `proto/` folder" + msgMigrationBufProtoDir = "Ignite proto directory path from the chain config doesn't match the proto directory path from the chain `buf.work.yaml`. Do you want to add the proto path `%[1]v` to the directories list from the buf work file" + msgMigrationBufProtoDirs = "Chain `buf.work.yaml` file contains directories that don't exist anymore (%[1]v). Do you want to delete them" + msgMigrationAddTools = "Some required imports are missing in %s file: %s. Would you like to add them" + msgMigrationRemoveTools = "File %s contains deprecated imports: %s. Would you like to remove them" ) var ErrProtocUnsupported = errors.New("code generation using protoc is only supported by Ignite CLI v0.26.1 or older") @@ -193,13 +193,13 @@ func toolsMigrationPreRunHandler(cmd *cobra.Command, session *cliui.Session, app } func bufMigrationPreRunHandler(cmd *cobra.Command, session *cliui.Session, appPath string) error { - protoPath, err := getProtoPathFromConfig(cmd) + protoDir, err := getProtoDirFromConfig(cmd) if err != nil { return err } // check if the buf files exist. - hasFiles, err := chain.CheckBufFiles(appPath, protoPath) + hasFiles, err := chain.CheckBufFiles(appPath, protoDir) if err != nil { return err } @@ -212,7 +212,7 @@ func bufMigrationPreRunHandler(cmd *cobra.Command, session *cliui.Session, appPa } runner := xgenny.NewRunner(cmd.Context(), appPath) - sm, err := chain.BoxBufFiles(runner, appPath, protoPath) + sm, err := chain.BoxBufFiles(runner, appPath, protoDir) if err != nil { return err } @@ -222,31 +222,31 @@ func bufMigrationPreRunHandler(cmd *cobra.Command, session *cliui.Session, appPa } // check if the buf.work.yaml has the same proto path from the config file. - hasProtoPath, missingPaths, err := chain.CheckBufProtoPath(appPath, protoPath) + hasProtoPath, missingPaths, err := chain.CheckBufProtoDir(appPath, protoDir) if err != nil { return err } if !hasProtoPath { if !getYes(cmd) { - if err := session.AskConfirm(fmt.Sprintf(msgMigrationBufProtoPath, protoPath)); err != nil { + if err := session.AskConfirm(fmt.Sprintf(msgMigrationBufProtoDir, protoDir)); err != nil { return nil } } - if err := chain.AddBufProtoPath(appPath, protoPath); err != nil { + if err := chain.AddBufProtoDir(appPath, protoDir); err != nil { return err } } if len(missingPaths) > 0 { if !getYes(cmd) { - if err := session.AskConfirm(fmt.Sprintf(msgMigrationBufProtoPaths, strings.Join(missingPaths, ", "))); err != nil { + if err := session.AskConfirm(fmt.Sprintf(msgMigrationBufProtoDirs, strings.Join(missingPaths, ", "))); err != nil { return nil } } - if err := chain.RemoveBufProtoPath(appPath, missingPaths...); err != nil { + if err := chain.RemoveBufProtoDirs(appPath, missingPaths...); err != nil { return err } } diff --git a/ignite/cmd/cmd.go b/ignite/cmd/cmd.go index 4149d41bd6..123249f0a9 100644 --- a/ignite/cmd/cmd.go +++ b/ignite/cmd/cmd.go @@ -15,6 +15,7 @@ import ( "github.com/ignite/cli/v29/ignite/config" chainconfig "github.com/ignite/cli/v29/ignite/config/chain" + "github.com/ignite/cli/v29/ignite/config/chain/defaults" "github.com/ignite/cli/v29/ignite/pkg/cache" "github.com/ignite/cli/v29/ignite/pkg/cliui" uilog "github.com/ignite/cli/v29/ignite/pkg/cliui/log" @@ -133,6 +134,17 @@ func getHome(cmd *cobra.Command) (home string) { return } +func flagSetProtoDir() *flag.FlagSet { + fs := flag.NewFlagSet("", flag.ContinueOnError) + fs.String(flagProtoDir, defaults.ProtoDir, "chain proto directory") + return fs +} + +func flagGetProtoDir(cmd *cobra.Command) (config string) { + config, _ = cmd.Flags().GetString(flagProtoDir) + return +} + func flagSetConfig() *flag.FlagSet { fs := flag.NewFlagSet("", flag.ContinueOnError) fs.StringP(flagConfig, "c", "", "path to Ignite config file (default: ./config.yml)") @@ -163,7 +175,7 @@ func getRawConfig(cmd *cobra.Command) ([]byte, string, error) { return rawConfig, configPath, err } -func getProtoPathFromConfig(cmd *cobra.Command) (string, error) { +func getProtoDirFromConfig(cmd *cobra.Command) (string, error) { rawCfg, _, err := getRawConfig(cmd) if err != nil { return "", err diff --git a/ignite/cmd/scaffold.go b/ignite/cmd/scaffold.go index 207f7929cf..551f48bb2a 100644 --- a/ignite/cmd/scaffold.go +++ b/ignite/cmd/scaffold.go @@ -23,6 +23,7 @@ const ( flagNoSimulation = "no-simulation" flagResponse = "response" flagDescription = "desc" + flagProtoDir = "proto-dir" msgCommitPrefix = "Your saved project changes have not been committed.\nTo enable reverting to your current state, commit your saved changes." msgCommitPrompt = "Do you want to proceed without committing your saved changes" @@ -131,6 +132,9 @@ with an "--ibc" flag. Note that the default module is not IBC-enabled. NewScaffoldReact(), ) + // Add flags required for the configMigrationPreRunHandler + c.PersistentFlags().AddFlagSet(flagSetProtoDir()) + return c } @@ -182,6 +186,7 @@ func scaffoldType( withoutSimulation = flagGetNoSimulation(cmd) signer = flagGetSigner(cmd) appPath = flagGetPath(cmd) + protoDir = flagGetProtoDir(cmd) ) var options []scaffolder.AddTypeOption @@ -203,15 +208,10 @@ func scaffoldType( } } - protoPath, err := getProtoPathFromConfig(cmd) - if err != nil { - return err - } - session := cliui.New(cliui.StartSpinnerWithText(statusScaffolding)) defer session.End() - sc, err := scaffolder.New(cmd.Context(), appPath, protoPath) + sc, err := scaffolder.New(cmd.Context(), appPath, protoDir) if err != nil { return err } diff --git a/ignite/cmd/scaffold_configs.go b/ignite/cmd/scaffold_configs.go index 73c93f947c..a1d97dfc71 100644 --- a/ignite/cmd/scaffold_configs.go +++ b/ignite/cmd/scaffold_configs.go @@ -46,13 +46,9 @@ func scaffoldConfigsHandler(cmd *cobra.Command, args []string) error { configs = args[0:] appPath = flagGetPath(cmd) moduleName = flagGetModule(cmd) + protoDir = flagGetProtoDir(cmd) ) - protoPath, err := getProtoPathFromConfig(cmd) - if err != nil { - return err - } - session := cliui.New(cliui.StartSpinnerWithText(statusScaffolding)) defer session.End() @@ -61,7 +57,7 @@ func scaffoldConfigsHandler(cmd *cobra.Command, args []string) error { return err } - sc, err := scaffolder.New(cmd.Context(), appPath, protoPath) + sc, err := scaffolder.New(cmd.Context(), appPath, protoDir) if err != nil { return err } diff --git a/ignite/cmd/scaffold_message.go b/ignite/cmd/scaffold_message.go index 23aa99d3d6..0db510ac47 100644 --- a/ignite/cmd/scaffold_message.go +++ b/ignite/cmd/scaffold_message.go @@ -86,13 +86,9 @@ func messageHandler(cmd *cobra.Command, args []string) error { signer = flagGetSigner(cmd) appPath = flagGetPath(cmd) withoutSimulation = flagGetNoSimulation(cmd) + protoDir = flagGetProtoDir(cmd) ) - protoPath, err := getProtoPathFromConfig(cmd) - if err != nil { - return err - } - session := cliui.New(cliui.StartSpinnerWithText(statusScaffolding)) defer session.End() @@ -118,7 +114,7 @@ func messageHandler(cmd *cobra.Command, args []string) error { options = append(options, scaffolder.WithoutSimulation()) } - sc, err := scaffolder.New(cmd.Context(), appPath, protoPath) + sc, err := scaffolder.New(cmd.Context(), appPath, protoDir) if err != nil { return err } diff --git a/ignite/cmd/scaffold_module.go b/ignite/cmd/scaffold_module.go index e926228f54..8a81d623c6 100644 --- a/ignite/cmd/scaffold_module.go +++ b/ignite/cmd/scaffold_module.go @@ -114,8 +114,9 @@ params. func scaffoldModuleHandler(cmd *cobra.Command, args []string) error { var ( - name = args[0] - appPath = flagGetPath(cmd) + name = args[0] + appPath = flagGetPath(cmd) + protoDir = flagGetProtoDir(cmd) ) session := cliui.New(cliui.StartSpinnerWithText(statusScaffolding)) @@ -131,11 +132,6 @@ func scaffoldModuleHandler(cmd *cobra.Command, args []string) error { return err } - protoPath, err := getProtoPathFromConfig(cmd) - if err != nil { - return err - } - cacheStorage, err := newCache(cmd) if err != nil { return err @@ -176,7 +172,7 @@ func scaffoldModuleHandler(cmd *cobra.Command, args []string) error { var msg bytes.Buffer fmt.Fprintf(&msg, "\nšŸŽ‰ Module created %s.\n\n", name) - sc, err := scaffolder.New(cmd.Context(), appPath, protoPath) + sc, err := scaffolder.New(cmd.Context(), appPath, protoDir) if err != nil { return err } diff --git a/ignite/cmd/scaffold_packet.go b/ignite/cmd/scaffold_packet.go index ac03332525..6923952c61 100644 --- a/ignite/cmd/scaffold_packet.go +++ b/ignite/cmd/scaffold_packet.go @@ -41,6 +41,7 @@ func createPacketHandler(cmd *cobra.Command, args []string) error { packetFields = args[1:] signer = flagGetSigner(cmd) appPath = flagGetPath(cmd) + protoDir = flagGetProtoDir(cmd) ) session := cliui.New(cliui.StartSpinnerWithText(statusScaffolding)) @@ -54,11 +55,6 @@ func createPacketHandler(cmd *cobra.Command, args []string) error { ackFields, _ := cmd.Flags().GetStringSlice(flagAck) noMessage, _ := cmd.Flags().GetBool(flagNoMessage) - protoPath, err := getProtoPathFromConfig(cmd) - if err != nil { - return err - } - cacheStorage, err := newCache(cmd) if err != nil { return err @@ -71,7 +67,7 @@ func createPacketHandler(cmd *cobra.Command, args []string) error { options = append(options, scaffolder.PacketWithSigner(signer)) } - sc, err := scaffolder.New(cmd.Context(), appPath, protoPath) + sc, err := scaffolder.New(cmd.Context(), appPath, protoDir) if err != nil { return err } diff --git a/ignite/cmd/scaffold_params.go b/ignite/cmd/scaffold_params.go index 3c20d5984f..38b7534e94 100644 --- a/ignite/cmd/scaffold_params.go +++ b/ignite/cmd/scaffold_params.go @@ -48,13 +48,9 @@ func scaffoldParamsHandler(cmd *cobra.Command, args []string) error { params = args[0:] appPath = flagGetPath(cmd) moduleName = flagGetModule(cmd) + protoDir = flagGetProtoDir(cmd) ) - protoPath, err := getProtoPathFromConfig(cmd) - if err != nil { - return err - } - session := cliui.New(cliui.StartSpinnerWithText(statusScaffolding)) defer session.End() @@ -63,7 +59,7 @@ func scaffoldParamsHandler(cmd *cobra.Command, args []string) error { return err } - sc, err := scaffolder.New(cmd.Context(), appPath, protoPath) + sc, err := scaffolder.New(cmd.Context(), appPath, protoDir) if err != nil { return err } diff --git a/ignite/cmd/scaffold_query.go b/ignite/cmd/scaffold_query.go index cab0e76c14..bd09bf44a8 100644 --- a/ignite/cmd/scaffold_query.go +++ b/ignite/cmd/scaffold_query.go @@ -39,7 +39,10 @@ For detailed type information use ignite scaffold type --help.`, } func queryHandler(cmd *cobra.Command, args []string) error { - appPath := flagGetPath(cmd) + var ( + appPath = flagGetPath(cmd) + protoDir = flagGetProtoDir(cmd) + ) session := cliui.New(cliui.StartSpinnerWithText(statusScaffolding)) defer session.End() @@ -59,17 +62,12 @@ func queryHandler(cmd *cobra.Command, args []string) error { paginated, _ := cmd.Flags().GetBool(flagPaginated) - protoPath, err := getProtoPathFromConfig(cmd) - if err != nil { - return err - } - cacheStorage, err := newCache(cmd) if err != nil { return err } - sc, err := scaffolder.New(cmd.Context(), appPath, protoPath) + sc, err := scaffolder.New(cmd.Context(), appPath, protoDir) if err != nil { return err } diff --git a/ignite/config/chain/base/config.go b/ignite/config/chain/base/config.go index 1990a1753e..bf8d4ce4cd 100644 --- a/ignite/config/chain/base/config.go +++ b/ignite/config/chain/base/config.go @@ -187,7 +187,7 @@ func DefaultConfig() Config { return Config{ Build: Build{ Proto: Proto{ - Path: defaults.ProtoPath, + Path: defaults.ProtoDir, ThirdPartyPaths: []string{"third_party/proto", "proto_vendor"}, }, }, diff --git a/ignite/config/chain/defaults/default.go b/ignite/config/chain/defaults/default.go index 0e9b5a5784..8378062e9d 100644 --- a/ignite/config/chain/defaults/default.go +++ b/ignite/config/chain/defaults/default.go @@ -19,8 +19,8 @@ const ( // PProfAddress is the default Prof address. PProfAddress = "0.0.0.0:6060" - // ProtoPath is the default proto path. - ProtoPath = "proto" + // ProtoDir is the default proto directory path. + ProtoDir = "proto" // FaucetHost is the default faucet host. FaucetHost = "0.0.0.0:4500" diff --git a/ignite/config/chain/parse.go b/ignite/config/chain/parse.go index 78f3ecd745..8683de8934 100644 --- a/ignite/config/chain/parse.go +++ b/ignite/config/chain/parse.go @@ -118,7 +118,7 @@ func ReadProtoPath(configFile io.Reader) (string, error) { } path := c.Build.Proto.Path if path == "" { - path = defaults.ProtoPath + path = defaults.ProtoDir } return path, nil } diff --git a/ignite/pkg/cosmosbuf/config.go b/ignite/pkg/cosmosbuf/config.go index d1b94995c1..a25138e2ab 100644 --- a/ignite/pkg/cosmosbuf/config.go +++ b/ignite/pkg/cosmosbuf/config.go @@ -45,14 +45,14 @@ func (w BufWork) MissingDirectories() ([]string, error) { return missingPaths, nil } -// AddProtoPath add a proto directory path from the buf work file. -func (w BufWork) AddProtoPath(newPath string) error { +// AddProtoDir add a proto directory path from the buf work file. +func (w BufWork) AddProtoDir(newPath string) error { w.Directories = append(w.Directories, newPath) return w.save() } -// RemoveProtoPaths remove a list a proto directory paths from the buf work file. -func (w BufWork) RemoveProtoPaths(paths ...string) error { +// RemoveProtoDirs remove a list a proto directory paths from the buf work file. +func (w BufWork) RemoveProtoDirs(paths ...string) error { for _, path := range paths { for i, dir := range w.Directories { if dir == path { @@ -64,8 +64,8 @@ func (w BufWork) RemoveProtoPaths(paths ...string) error { return w.save() } -// HasProtoPath returns true if the proto path exist into the directories slice. -func (w BufWork) HasProtoPath(path string) bool { +// HasProtoDir returns true if the proto path exist into the directories slice. +func (w BufWork) HasProtoDir(path string) bool { for _, dirPath := range w.Directories { if path == dirPath { return true diff --git a/ignite/pkg/cosmosgen/generate.go b/ignite/pkg/cosmosgen/generate.go index 97efa3d7bb..e9dc227a67 100644 --- a/ignite/pkg/cosmosgen/generate.go +++ b/ignite/pkg/cosmosgen/generate.go @@ -186,7 +186,7 @@ func (g *generator) setup(ctx context.Context) (err error) { cacheable = true ) if len(modules) > 0 { - includes, cacheable, err = g.resolveIncludes(ctx, path, defaults.ProtoPath) + includes, cacheable, err = g.resolveIncludes(ctx, path, defaults.ProtoDir) if err != nil { return err } diff --git a/ignite/services/chain/chain.go b/ignite/services/chain/chain.go index f2a3289ac4..a861d8db85 100644 --- a/ignite/services/chain/chain.go +++ b/ignite/services/chain/chain.go @@ -525,12 +525,12 @@ func (c *Chain) Commands(ctx context.Context) (chaincmdrunner.Runner, error) { return chaincmdrunner.New(ctx, cc, ccrOptions...) } -func appBackendSourceWatchPaths(protoPath string) []string { +func appBackendSourceWatchPaths(protoDir string) []string { return []string{ "app", "cmd", "x", "third_party", - protoPath, + protoDir, } } diff --git a/ignite/services/chain/proto.go b/ignite/services/chain/proto.go index 8bd73b6480..b03303c58a 100644 --- a/ignite/services/chain/proto.go +++ b/ignite/services/chain/proto.go @@ -12,8 +12,8 @@ import ( "github.com/ignite/cli/v29/ignite/templates/app" ) -// CheckBufProtoPath check if the proto path exist into the directory list in the buf.work.yaml file. -func CheckBufProtoPath(appPath, protoPath string) (bool, []string, error) { +// CheckBufProtoDir check if the proto path exist into the directory list in the buf.work.yaml file. +func CheckBufProtoDir(appPath, protoDir string) (bool, []string, error) { workFile, err := cosmosbuf.ParseBufWork(appPath) if err != nil { return false, nil, err @@ -24,39 +24,39 @@ func CheckBufProtoPath(appPath, protoPath string) (bool, []string, error) { return false, nil, err } - return workFile.HasProtoPath(protoPath), missing, nil + return workFile.HasProtoDir(protoDir), missing, nil } -// AddBufProtoPath add the proto path into the directory list in the buf.work.yaml file. -func AddBufProtoPath(appPath, protoPath string) error { +// AddBufProtoDir add the proto path into the directory list in the buf.work.yaml file. +func AddBufProtoDir(appPath, protoDir string) error { workFile, err := cosmosbuf.ParseBufWork(appPath) if err != nil { return err } - return workFile.AddProtoPath(protoPath) + return workFile.AddProtoDir(protoDir) } -// RemoveBufProtoPath add the proto path into the directory list in the buf.work.yaml file. -func RemoveBufProtoPath(appPath string, protoPaths ...string) error { +// RemoveBufProtoDirs add the proto path into the directory list in the buf.work.yaml file. +func RemoveBufProtoDirs(appPath string, protoDirs ...string) error { workFile, err := cosmosbuf.ParseBufWork(appPath) if err != nil { return err } - return workFile.RemoveProtoPaths(protoPaths...) + return workFile.RemoveProtoDirs(protoDirs...) } // CheckBufFiles check if the buf files exist. -func CheckBufFiles(appPath, protoPath string) (bool, error) { +func CheckBufFiles(appPath, protoDir string) (bool, error) { files, err := app.BufFiles() if err != nil { return false, nil } for _, bufFile := range files { - bufFile, ok := strings.CutPrefix(bufFile, fmt.Sprintf("%s/", defaults.ProtoPath)) + bufFile, ok := strings.CutPrefix(bufFile, fmt.Sprintf("%s/", defaults.ProtoDir)) if ok { - bufFile = filepath.Join(protoPath, bufFile) + bufFile = filepath.Join(protoDir, bufFile) } if !xos.FileExists(filepath.Join(appPath, bufFile)) { return false, nil @@ -66,8 +66,8 @@ func CheckBufFiles(appPath, protoPath string) (bool, error) { } // BoxBufFiles box all buf files. -func BoxBufFiles(runner *xgenny.Runner, appPath, protoPath string) (xgenny.SourceModification, error) { - g, err := app.NewBufGenerator(appPath, protoPath) +func BoxBufFiles(runner *xgenny.Runner, appPath, protoDir string) (xgenny.SourceModification, error) { + g, err := app.NewBufGenerator(appPath, protoDir) if err != nil { return xgenny.SourceModification{}, err } diff --git a/ignite/services/chain/serve.go b/ignite/services/chain/serve.go index ca953d1a78..9b1ebc5a09 100644 --- a/ignite/services/chain/serve.go +++ b/ignite/services/chain/serve.go @@ -295,7 +295,7 @@ func (c *Chain) refreshServe() { } func (c *Chain) watchAppBackend(ctx context.Context) error { - watchPaths := appBackendSourceWatchPaths(defaults.ProtoPath) + watchPaths := appBackendSourceWatchPaths(defaults.ProtoDir) if c.ConfigPath() != "" { conf, err := c.Config() diff --git a/ignite/services/scaffolder/component.go b/ignite/services/scaffolder/component.go index 85fc63bea8..e7c22232ad 100644 --- a/ignite/services/scaffolder/component.go +++ b/ignite/services/scaffolder/component.go @@ -107,8 +107,8 @@ func checkComponentCreated(appPath, moduleName string, compName multiformatname. } // checkCustomTypes returns error if one of the types is invalid. -func checkCustomTypes(ctx context.Context, appPath, appName, protoPath, module string, fields []string) error { - path := filepath.Join(appPath, protoPath, appName, module) +func checkCustomTypes(ctx context.Context, appPath, appName, protoDir, module string, fields []string) error { + path := filepath.Join(appPath, protoDir, appName, module) customFieldTypes := make([]string, 0) for _, field := range fields { ft, ok := fieldType(field) diff --git a/ignite/services/scaffolder/configs.go b/ignite/services/scaffolder/configs.go index e6a7e85ddd..05b3fab530 100644 --- a/ignite/services/scaffolder/configs.go +++ b/ignite/services/scaffolder/configs.go @@ -51,7 +51,7 @@ func (s Scaffolder) CreateConfigs( Configs: configsFields, AppName: s.modpath.Package, AppPath: s.appPath, - ProtoPath: s.protoPath, + ProtoDir: s.protoDir, } g, err := modulecreate.NewModuleConfigs(opts) diff --git a/ignite/services/scaffolder/init.go b/ignite/services/scaffolder/init.go index ee23c7f2a6..189ff4d002 100644 --- a/ignite/services/scaffolder/init.go +++ b/ignite/services/scaffolder/init.go @@ -92,7 +92,7 @@ func generate( ModulePath: pathInfo.RawPath, AppName: pathInfo.Package, AppPath: absRoot, - ProtoPath: defaults.ProtoPath, + ProtoDir: defaults.ProtoDir, GitHubPath: githubPath, BinaryNamePrefix: pathInfo.Root, AddressPrefix: addressPrefix, @@ -124,7 +124,7 @@ func generate( ModulePath: pathInfo.RawPath, AppName: pathInfo.Package, AppPath: absRoot, - ProtoPath: defaults.ProtoPath, + ProtoDir: defaults.ProtoDir, Params: paramsFields, Configs: configsFields, IsIBC: false, diff --git a/ignite/services/scaffolder/message.go b/ignite/services/scaffolder/message.go index 07481622b5..96583abaa6 100644 --- a/ignite/services/scaffolder/message.go +++ b/ignite/services/scaffolder/message.go @@ -92,7 +92,7 @@ func (s Scaffolder) AddMessage( ctx, s.appPath, s.modpath.Package, - s.protoPath, + s.protoDir, moduleName, fields, ); err != nil { @@ -108,7 +108,7 @@ func (s Scaffolder) AddMessage( ctx, s.appPath, s.modpath.Package, - s.protoPath, + s.protoDir, moduleName, resFields, ); err != nil { @@ -129,7 +129,7 @@ func (s Scaffolder) AddMessage( opts = &message.Options{ AppName: s.modpath.Package, AppPath: s.appPath, - ProtoPath: s.protoPath, + ProtoDir: s.protoDir, ModulePath: s.modpath.RawPath, ModuleName: moduleName, MsgName: name, @@ -152,7 +152,7 @@ func (s Scaffolder) AddMessage( ModulePath: opts.ModulePath, AppName: opts.AppName, AppPath: opts.AppPath, - ProtoPath: opts.ProtoPath, + ProtoDir: opts.ProtoDir, }, ) if err != nil { diff --git a/ignite/services/scaffolder/module.go b/ignite/services/scaffolder/module.go index 826dacfaeb..5be2263cd1 100644 --- a/ignite/services/scaffolder/module.go +++ b/ignite/services/scaffolder/module.go @@ -215,7 +215,7 @@ func (s Scaffolder) CreateModule( Configs: configs, AppName: s.modpath.Package, AppPath: s.appPath, - ProtoPath: s.protoPath, + ProtoDir: s.protoDir, IsIBC: creationOpts.ibc, IBCOrdering: creationOpts.ibcChannelOrdering, Dependencies: creationOpts.dependencies, diff --git a/ignite/services/scaffolder/packet.go b/ignite/services/scaffolder/packet.go index c96cc34393..c27fd0798a 100644 --- a/ignite/services/scaffolder/packet.go +++ b/ignite/services/scaffolder/packet.go @@ -98,7 +98,7 @@ func (s Scaffolder) AddPacket( } // Check and parse packet fields - if err := checkCustomTypes(ctx, s.appPath, s.modpath.Package, s.protoPath, moduleName, packetFields); err != nil { + if err := checkCustomTypes(ctx, s.appPath, s.modpath.Package, s.protoDir, moduleName, packetFields); err != nil { return err } parsedPacketFields, err := field.ParseFields(packetFields, checkForbiddenPacketField, signer) @@ -107,7 +107,7 @@ func (s Scaffolder) AddPacket( } // check and parse acknowledgment fields - if err := checkCustomTypes(ctx, s.appPath, s.modpath.Package, s.protoPath, moduleName, ackFields); err != nil { + if err := checkCustomTypes(ctx, s.appPath, s.modpath.Package, s.protoDir, moduleName, ackFields); err != nil { return err } parsedAcksFields, err := field.ParseFields(ackFields, checkGoReservedWord, signer) @@ -121,7 +121,7 @@ func (s Scaffolder) AddPacket( opts = &ibc.PacketOptions{ AppName: s.modpath.Package, AppPath: s.appPath, - ProtoPath: s.protoPath, + ProtoDir: s.protoDir, ModulePath: s.modpath.RawPath, ModuleName: moduleName, PacketName: name, diff --git a/ignite/services/scaffolder/params.go b/ignite/services/scaffolder/params.go index 1bc2a9989d..1a06260b21 100644 --- a/ignite/services/scaffolder/params.go +++ b/ignite/services/scaffolder/params.go @@ -50,7 +50,7 @@ func (s Scaffolder) CreateParams( Params: paramsFields, AppName: s.modpath.Package, AppPath: s.appPath, - ProtoPath: s.protoPath, + ProtoDir: s.protoDir, } g, err := modulecreate.NewModuleParam(opts) diff --git a/ignite/services/scaffolder/patch.go b/ignite/services/scaffolder/patch.go index 317b6d469f..a4da4f813d 100644 --- a/ignite/services/scaffolder/patch.go +++ b/ignite/services/scaffolder/patch.go @@ -20,7 +20,7 @@ func supportMsgServer( opts *modulecreate.MsgServerOptions, ) ([]*genny.Generator, error) { // Check if convention used - msgServerDefined, err := isMsgServerDefined(appPath, opts.AppName, opts.ProtoPath, opts.ModuleName) + msgServerDefined, err := isMsgServerDefined(appPath, opts.AppName, opts.ProtoDir, opts.ModuleName) if err != nil { return nil, err } diff --git a/ignite/services/scaffolder/query.go b/ignite/services/scaffolder/query.go index 6c87d98ae3..9584935868 100644 --- a/ignite/services/scaffolder/query.go +++ b/ignite/services/scaffolder/query.go @@ -50,7 +50,7 @@ func (s Scaffolder) AddQuery( } // Check and parse provided response fields - if err := checkCustomTypes(ctx, s.appPath, s.modpath.Package, s.protoPath, moduleName, resFields); err != nil { + if err := checkCustomTypes(ctx, s.appPath, s.modpath.Package, s.protoDir, moduleName, resFields); err != nil { return err } parsedResFields, err := field.ParseFields(resFields, checkGoReservedWord) @@ -63,7 +63,7 @@ func (s Scaffolder) AddQuery( opts = &query.Options{ AppName: s.modpath.Package, AppPath: s.appPath, - ProtoPath: s.protoPath, + ProtoDir: s.protoDir, ModulePath: s.modpath.RawPath, ModuleName: moduleName, QueryName: name, diff --git a/ignite/services/scaffolder/scaffolder.go b/ignite/services/scaffolder/scaffolder.go index 9624973e32..5c24e6ed6f 100644 --- a/ignite/services/scaffolder/scaffolder.go +++ b/ignite/services/scaffolder/scaffolder.go @@ -28,8 +28,8 @@ type Scaffolder struct { // appPath path of the app. appPath string - // protoPath path of the proto folder. - protoPath string + // protoDir path of the proto folder. + protoDir string // modpath represents the go module Path of the app. modpath gomodulepath.Path @@ -39,7 +39,7 @@ type Scaffolder struct { } // New creates a new scaffold app. -func New(context context.Context, appPath, protoPath string) (Scaffolder, error) { +func New(context context.Context, appPath, protoDir string) (Scaffolder, error) { path, err := filepath.Abs(appPath) if err != nil { return Scaffolder{}, err @@ -65,11 +65,11 @@ func New(context context.Context, appPath, protoPath string) (Scaffolder, error) } s := Scaffolder{ - Version: ver, - appPath: path, - protoPath: protoPath, - modpath: modpath, - runner: xgenny.NewRunner(context, path), + Version: ver, + appPath: path, + protoDir: protoDir, + modpath: modpath, + runner: xgenny.NewRunner(context, path), } return s, nil diff --git a/ignite/services/scaffolder/type.go b/ignite/services/scaffolder/type.go index 2d29b4f4db..406d87a885 100644 --- a/ignite/services/scaffolder/type.go +++ b/ignite/services/scaffolder/type.go @@ -143,7 +143,7 @@ func (s Scaffolder) AddType( } // Check and parse provided fields - if err := checkCustomTypes(ctx, s.appPath, s.modpath.Package, s.protoPath, moduleName, o.fields); err != nil { + if err := checkCustomTypes(ctx, s.appPath, s.modpath.Package, s.protoDir, moduleName, o.fields); err != nil { return err } tFields, err := parseTypeFields(o) @@ -166,7 +166,7 @@ func (s Scaffolder) AddType( opts = &typed.Options{ AppName: s.modpath.Package, AppPath: s.appPath, - ProtoPath: s.protoPath, + ProtoDir: s.protoDir, ModulePath: s.modpath.RawPath, ModuleName: moduleName, TypeName: name, diff --git a/ignite/templates/app/app.go b/ignite/templates/app/app.go index 8f6e93f958..241e82fd5d 100644 --- a/ignite/templates/app/app.go +++ b/ignite/templates/app/app.go @@ -70,7 +70,7 @@ func NewGenerator(opts *Options) (*genny.Generator, error) { ctx := plush.NewContext() ctx.Set("ModulePath", opts.ModulePath) ctx.Set("AppName", opts.AppName) - ctx.Set("ProtoPath", opts.ProtoPath) + ctx.Set("ProtoDir", opts.ProtoDir) ctx.Set("GitHubPath", opts.GitHubPath) ctx.Set("BinaryNamePrefix", opts.BinaryNamePrefix) ctx.Set("AddressPrefix", opts.AddressPrefix) @@ -80,6 +80,8 @@ func NewGenerator(opts *Options) (*genny.Generator, error) { plushhelpers.ExtendPlushContext(ctx) g.Transformer(xgenny.Transformer(ctx)) + g.Transformer(genny.Replace("{{protoDir}}", opts.ProtoDir)) + g.Transformer(genny.Replace("{{protoDir}}", opts.ProtoDir)) g.Transformer(genny.Replace("{{appName}}", opts.AppName)) g.Transformer(genny.Replace("{{binaryNamePrefix}}", opts.BinaryNamePrefix)) diff --git a/ignite/templates/app/files/buf.work.yaml.plush b/ignite/templates/app/files/buf.work.yaml.plush index 595c36ab37..9be86fcfff 100644 --- a/ignite/templates/app/files/buf.work.yaml.plush +++ b/ignite/templates/app/files/buf.work.yaml.plush @@ -1,3 +1,3 @@ version: v1 directories: - - <%= ProtoPath %> + - <%= ProtoDir %> diff --git a/ignite/templates/app/files/proto/buf.gen.gogo.yaml b/ignite/templates/app/files/{{protoDir}}/buf.gen.gogo.yaml similarity index 100% rename from ignite/templates/app/files/proto/buf.gen.gogo.yaml rename to ignite/templates/app/files/{{protoDir}}/buf.gen.gogo.yaml diff --git a/ignite/templates/app/files/proto/buf.gen.pulsar.yaml b/ignite/templates/app/files/{{protoDir}}/buf.gen.pulsar.yaml similarity index 100% rename from ignite/templates/app/files/proto/buf.gen.pulsar.yaml rename to ignite/templates/app/files/{{protoDir}}/buf.gen.pulsar.yaml diff --git a/ignite/templates/app/files/proto/buf.gen.sta.yaml b/ignite/templates/app/files/{{protoDir}}/buf.gen.sta.yaml similarity index 100% rename from ignite/templates/app/files/proto/buf.gen.sta.yaml rename to ignite/templates/app/files/{{protoDir}}/buf.gen.sta.yaml diff --git a/ignite/templates/app/files/proto/buf.gen.swagger.yaml b/ignite/templates/app/files/{{protoDir}}/buf.gen.swagger.yaml similarity index 100% rename from ignite/templates/app/files/proto/buf.gen.swagger.yaml rename to ignite/templates/app/files/{{protoDir}}/buf.gen.swagger.yaml diff --git a/ignite/templates/app/files/proto/buf.gen.ts.yaml b/ignite/templates/app/files/{{protoDir}}/buf.gen.ts.yaml similarity index 100% rename from ignite/templates/app/files/proto/buf.gen.ts.yaml rename to ignite/templates/app/files/{{protoDir}}/buf.gen.ts.yaml diff --git a/ignite/templates/app/files/proto/buf.lock b/ignite/templates/app/files/{{protoDir}}/buf.lock similarity index 100% rename from ignite/templates/app/files/proto/buf.lock rename to ignite/templates/app/files/{{protoDir}}/buf.lock diff --git a/ignite/templates/app/files/proto/buf.yaml b/ignite/templates/app/files/{{protoDir}}/buf.yaml similarity index 100% rename from ignite/templates/app/files/proto/buf.yaml rename to ignite/templates/app/files/{{protoDir}}/buf.yaml diff --git a/ignite/templates/app/options.go b/ignite/templates/app/options.go index 4a8afe6064..1621505f88 100644 --- a/ignite/templates/app/options.go +++ b/ignite/templates/app/options.go @@ -4,7 +4,7 @@ package app type Options struct { AppName string AppPath string - ProtoPath string + ProtoDir string GitHubPath string BinaryNamePrefix string ModulePath string diff --git a/ignite/templates/app/proto.go b/ignite/templates/app/proto.go index a867284c25..25a3cb505b 100644 --- a/ignite/templates/app/proto.go +++ b/ignite/templates/app/proto.go @@ -9,13 +9,14 @@ import ( "github.com/ignite/cli/v29/ignite/pkg/xembed" "github.com/ignite/cli/v29/ignite/pkg/xgenny" + "github.com/ignite/cli/v29/ignite/templates/field/plushhelpers" ) //go:embed files/proto/* files/buf.work.yaml.plush var fsProto embed.FS // NewBufGenerator returns the generator to buf build files. -func NewBufGenerator(appPath, protoPath string) (*genny.Generator, error) { +func NewBufGenerator(appPath, protoDir string) (*genny.Generator, error) { var ( g = genny.New() template = xgenny.NewEmbedWalker( @@ -29,8 +30,11 @@ func NewBufGenerator(appPath, protoPath string) (*genny.Generator, error) { } ctx := plush.NewContext() - ctx.Set("ProtoPath", protoPath) + ctx.Set("ProtoDir", protoDir) + + plushhelpers.ExtendPlushContext(ctx) g.Transformer(xgenny.Transformer(ctx)) + g.Transformer(genny.Replace("{{protoDir}}", protoDir)) return g, nil } diff --git a/ignite/templates/app/proto_test.go b/ignite/templates/app/proto_test.go index f9049dd6fb..356775ad4a 100644 --- a/ignite/templates/app/proto_test.go +++ b/ignite/templates/app/proto_test.go @@ -12,10 +12,10 @@ import ( func TestBufFiles(t *testing.T) { want := []string{"buf.work.yaml"} - protoDir, err := os.ReadDir(filepath.Join("files", defaults.ProtoPath)) + protoDir, err := os.ReadDir(filepath.Join("files", defaults.ProtoDir)) require.NoError(t, err) for _, e := range protoDir { - want = append(want, filepath.Join(defaults.ProtoPath, e.Name())) + want = append(want, filepath.Join(defaults.ProtoDir, e.Name())) } got, err := BufFiles() diff --git a/ignite/templates/ibc/packet.go b/ignite/templates/ibc/packet.go index 783b3e8aed..b2f99b83b7 100644 --- a/ignite/templates/ibc/packet.go +++ b/ignite/templates/ibc/packet.go @@ -34,7 +34,7 @@ var ( type PacketOptions struct { AppName string AppPath string - ProtoPath string + ProtoDir string ModuleName string ModulePath string PacketName multiformatname.Name @@ -90,6 +90,7 @@ func NewPacket(replacer placeholder.Replacer, opts *PacketOptions) (*genny.Gener plushhelpers.ExtendPlushContext(ctx) g.Transformer(xgenny.Transformer(ctx)) + g.Transformer(genny.Replace("{{protoDir}}", opts.ProtoDir)) g.Transformer(genny.Replace("{{appName}}", opts.AppName)) g.Transformer(genny.Replace("{{moduleName}}", opts.ModuleName)) g.Transformer(genny.Replace("{{packetName}}", opts.PacketName.Snake)) @@ -182,7 +183,7 @@ func moduleModify(replacer placeholder.Replacer, opts *PacketOptions) genny.RunF // - Existence of a Oneof field named 'packet'. func protoModify(opts *PacketOptions) genny.RunFn { return func(r *genny.Runner) error { - path := filepath.Join(opts.AppPath, opts.ProtoPath, opts.AppName, opts.ModuleName, "packet.proto") + path := filepath.Join(opts.AppPath, opts.ProtoDir, opts.AppName, opts.ModuleName, "packet.proto") f, err := r.Disk.Find(path) if err != nil { return err @@ -289,7 +290,7 @@ func eventModify(replacer placeholder.Replacer, opts *PacketOptions) genny.RunFn // elements in the file. func protoTxModify(opts *PacketOptions) genny.RunFn { return func(r *genny.Runner) error { - path := filepath.Join(opts.AppPath, opts.ProtoPath, opts.AppName, opts.ModuleName, "tx.proto") + path := filepath.Join(opts.AppPath, opts.ProtoDir, opts.AppName, opts.ModuleName, "tx.proto") f, err := r.Disk.Find(path) if err != nil { return err diff --git a/ignite/templates/message/message.go b/ignite/templates/message/message.go index cffe528fad..b394e02914 100644 --- a/ignite/templates/message/message.go +++ b/ignite/templates/message/message.go @@ -44,6 +44,7 @@ func Box(box packd.Walker, opts *Options, g *genny.Generator) error { plushhelpers.ExtendPlushContext(ctx) g.Transformer(xgenny.Transformer(ctx)) + g.Transformer(genny.Replace("{{protoDir}}", opts.ProtoDir)) g.Transformer(genny.Replace("{{appName}}", opts.AppName)) g.Transformer(genny.Replace("{{moduleName}}", opts.ModuleName)) g.Transformer(genny.Replace("{{msgName}}", opts.MsgName.Snake)) @@ -87,7 +88,7 @@ func NewGenerator(replacer placeholder.Replacer, opts *Options) (*genny.Generato // - A service named "Msg" to exist in the proto file, it appends the RPCs inside it. func protoTxRPCModify(opts *Options) genny.RunFn { return func(r *genny.Runner) error { - path := filepath.Join(opts.AppPath, opts.ProtoPath, opts.AppName, opts.ModuleName, "tx.proto") + path := filepath.Join(opts.AppPath, opts.ProtoDir, opts.AppName, opts.ModuleName, "tx.proto") f, err := r.Disk.Find(path) if err != nil { return err @@ -118,7 +119,7 @@ func protoTxRPCModify(opts *Options) genny.RunFn { func protoTxMessageModify(opts *Options) genny.RunFn { return func(r *genny.Runner) error { - path := filepath.Join(opts.AppPath, opts.ProtoPath, opts.AppName, opts.ModuleName, "tx.proto") + path := filepath.Join(opts.AppPath, opts.ProtoDir, opts.AppName, opts.ModuleName, "tx.proto") f, err := r.Disk.Find(path) if err != nil { return err diff --git a/ignite/templates/message/options.go b/ignite/templates/message/options.go index 74eee2661f..b8b00890bd 100644 --- a/ignite/templates/message/options.go +++ b/ignite/templates/message/options.go @@ -9,7 +9,7 @@ import ( type Options struct { AppName string AppPath string - ProtoPath string + ProtoDir string ModuleName string ModulePath string MsgName multiformatname.Name diff --git a/ignite/templates/module/create/base.go b/ignite/templates/module/create/base.go index b10f4dcc82..79265fdbea 100644 --- a/ignite/templates/module/create/base.go +++ b/ignite/templates/module/create/base.go @@ -57,6 +57,7 @@ func NewGenerator(opts *CreateOptions) (*genny.Generator, error) { plushhelpers.ExtendPlushContext(ctx) g.Transformer(xgenny.Transformer(ctx)) + g.Transformer(genny.Replace("{{protoDir}}", opts.ProtoDir)) g.Transformer(genny.Replace("{{appName}}", opts.AppName)) g.Transformer(genny.Replace("{{moduleName}}", opts.ModuleName)) diff --git a/ignite/templates/module/create/configs.go b/ignite/templates/module/create/configs.go index 7610179f83..de74dace00 100644 --- a/ignite/templates/module/create/configs.go +++ b/ignite/templates/module/create/configs.go @@ -18,7 +18,7 @@ func NewModuleConfigs(opts ConfigsOptions) (*genny.Generator, error) { func configsProtoModify(opts ConfigsOptions) genny.RunFn { return func(r *genny.Runner) error { - path := filepath.Join(opts.AppPath, opts.ProtoPath, opts.AppName, opts.ModuleName, "module/module.proto") + path := filepath.Join(opts.AppPath, opts.ProtoDir, opts.AppName, opts.ModuleName, "module/module.proto") f, err := r.Disk.Find(path) if err != nil { return err diff --git a/ignite/templates/module/create/files/base/proto/{{appName}}/{{moduleName}}/genesis.proto.plush b/ignite/templates/module/create/files/base/{{protoDir}}/{{appName}}/{{moduleName}}/genesis.proto.plush similarity index 100% rename from ignite/templates/module/create/files/base/proto/{{appName}}/{{moduleName}}/genesis.proto.plush rename to ignite/templates/module/create/files/base/{{protoDir}}/{{appName}}/{{moduleName}}/genesis.proto.plush diff --git a/ignite/templates/module/create/files/base/proto/{{appName}}/{{moduleName}}/module/module.proto.plush b/ignite/templates/module/create/files/base/{{protoDir}}/{{appName}}/{{moduleName}}/module/module.proto.plush similarity index 100% rename from ignite/templates/module/create/files/base/proto/{{appName}}/{{moduleName}}/module/module.proto.plush rename to ignite/templates/module/create/files/base/{{protoDir}}/{{appName}}/{{moduleName}}/module/module.proto.plush diff --git a/ignite/templates/module/create/files/base/proto/{{appName}}/{{moduleName}}/params.proto.plush b/ignite/templates/module/create/files/base/{{protoDir}}/{{appName}}/{{moduleName}}/params.proto.plush similarity index 100% rename from ignite/templates/module/create/files/base/proto/{{appName}}/{{moduleName}}/params.proto.plush rename to ignite/templates/module/create/files/base/{{protoDir}}/{{appName}}/{{moduleName}}/params.proto.plush diff --git a/ignite/templates/module/create/files/base/proto/{{appName}}/{{moduleName}}/query.proto.plush b/ignite/templates/module/create/files/base/{{protoDir}}/{{appName}}/{{moduleName}}/query.proto.plush similarity index 100% rename from ignite/templates/module/create/files/base/proto/{{appName}}/{{moduleName}}/query.proto.plush rename to ignite/templates/module/create/files/base/{{protoDir}}/{{appName}}/{{moduleName}}/query.proto.plush diff --git a/ignite/templates/module/create/files/ibc/proto/{{appName}}/{{moduleName}}/packet.proto.plush b/ignite/templates/module/create/files/ibc/{{protoDir}}/{{appName}}/{{moduleName}}/packet.proto.plush similarity index 100% rename from ignite/templates/module/create/files/ibc/proto/{{appName}}/{{moduleName}}/packet.proto.plush rename to ignite/templates/module/create/files/ibc/{{protoDir}}/{{appName}}/{{moduleName}}/packet.proto.plush diff --git a/ignite/templates/module/create/files/msgserver/proto/{{appName}}/{{moduleName}}/tx.proto.plush b/ignite/templates/module/create/files/msgserver/{{protoDir}}/{{appName}}/{{moduleName}}/tx.proto.plush similarity index 100% rename from ignite/templates/module/create/files/msgserver/proto/{{appName}}/{{moduleName}}/tx.proto.plush rename to ignite/templates/module/create/files/msgserver/{{protoDir}}/{{appName}}/{{moduleName}}/tx.proto.plush diff --git a/ignite/templates/module/create/ibc.go b/ignite/templates/module/create/ibc.go index cc8d541b8f..28b5639cd0 100644 --- a/ignite/templates/module/create/ibc.go +++ b/ignite/templates/module/create/ibc.go @@ -47,6 +47,7 @@ func NewIBC(replacer placeholder.Replacer, opts *CreateOptions) (*genny.Generato plushhelpers.ExtendPlushContext(ctx) g.Transformer(xgenny.Transformer(ctx)) + g.Transformer(genny.Replace("{{protoDir}}", opts.ProtoDir)) g.Transformer(genny.Replace("{{appName}}", opts.AppName)) g.Transformer(genny.Replace("{{moduleName}}", opts.ModuleName)) return g, nil @@ -130,7 +131,7 @@ func genesisTypesModify(replacer placeholder.Replacer, opts *CreateOptions) genn // - Existence of a message named 'GenesisState' in genesis.proto. func genesisProtoModify(opts *CreateOptions) genny.RunFn { return func(r *genny.Runner) error { - path := filepath.Join(opts.AppPath, opts.ProtoPath, opts.AppName, opts.ModuleName, "genesis.proto") + path := filepath.Join(opts.AppPath, opts.ProtoDir, opts.AppName, opts.ModuleName, "genesis.proto") f, err := r.Disk.Find(path) if err != nil { return err diff --git a/ignite/templates/module/create/msgserver.go b/ignite/templates/module/create/msgserver.go index 584ca423f3..b3938e440f 100644 --- a/ignite/templates/module/create/msgserver.go +++ b/ignite/templates/module/create/msgserver.go @@ -40,6 +40,7 @@ func AddMsgServerConventionToLegacyModule(replacer placeholder.Replacer, opts *M plushhelpers.ExtendPlushContext(ctx) g.Transformer(xgenny.Transformer(ctx)) + g.Transformer(genny.Replace("{{protoDir}}", opts.ProtoDir)) g.Transformer(genny.Replace("{{appName}}", opts.AppName)) g.Transformer(genny.Replace("{{moduleName}}", opts.ModuleName)) return g, nil diff --git a/ignite/templates/module/create/options.go b/ignite/templates/module/create/options.go index 2857e81460..3b93b0e876 100644 --- a/ignite/templates/module/create/options.go +++ b/ignite/templates/module/create/options.go @@ -14,7 +14,7 @@ type ( ModuleName string AppName string AppPath string - ProtoPath string + ProtoDir string Configs field.Fields } @@ -23,7 +23,7 @@ type ( ModuleName string AppName string AppPath string - ProtoPath string + ProtoDir string Params field.Fields } @@ -33,7 +33,7 @@ type ( ModulePath string AppName string AppPath string - ProtoPath string + ProtoDir string Params field.Fields Configs field.Fields @@ -61,7 +61,7 @@ type ( ModulePath string AppName string AppPath string - ProtoPath string + ProtoDir string } ) diff --git a/ignite/templates/module/create/params.go b/ignite/templates/module/create/params.go index d017bacb5e..475f5cd4e3 100644 --- a/ignite/templates/module/create/params.go +++ b/ignite/templates/module/create/params.go @@ -21,7 +21,7 @@ func NewModuleParam(opts ParamsOptions) (*genny.Generator, error) { func paramsProtoModify(opts ParamsOptions) genny.RunFn { return func(r *genny.Runner) error { - path := filepath.Join(opts.AppPath, opts.ProtoPath, opts.AppName, opts.ModuleName, "params.proto") + path := filepath.Join(opts.AppPath, opts.ProtoDir, opts.AppName, opts.ModuleName, "params.proto") f, err := r.Disk.Find(path) if err != nil { return err diff --git a/ignite/templates/query/options.go b/ignite/templates/query/options.go index e59be1124b..0ee7e1dd21 100644 --- a/ignite/templates/query/options.go +++ b/ignite/templates/query/options.go @@ -9,7 +9,7 @@ import ( type Options struct { AppName string AppPath string - ProtoPath string + ProtoDir string ModuleName string ModulePath string QueryName multiformatname.Name diff --git a/ignite/templates/query/query.go b/ignite/templates/query/query.go index 394cd74b9c..839c0a3e15 100644 --- a/ignite/templates/query/query.go +++ b/ignite/templates/query/query.go @@ -67,7 +67,7 @@ func NewGenerator(replacer placeholder.Replacer, opts *Options) (*genny.Generato // - Existence of a service with name "Query" since that is where the RPCs will be added. func protoQueryModify(opts *Options) genny.RunFn { return func(r *genny.Runner) error { - path := filepath.Join(opts.AppPath, opts.ProtoPath, opts.AppName, opts.ModuleName, "query.proto") + path := filepath.Join(opts.AppPath, opts.ProtoDir, opts.AppName, opts.ModuleName, "query.proto") f, err := r.Disk.Find(path) if err != nil { return err diff --git a/ignite/templates/typed/dry/files/component/proto/{{appName}}/{{moduleName}}/{{typeName}}.proto.plush b/ignite/templates/typed/dry/files/component/{{protoDir}}/{{appName}}/{{moduleName}}/{{typeName}}.proto.plush similarity index 100% rename from ignite/templates/typed/dry/files/component/proto/{{appName}}/{{moduleName}}/{{typeName}}.proto.plush rename to ignite/templates/typed/dry/files/component/{{protoDir}}/{{appName}}/{{moduleName}}/{{typeName}}.proto.plush diff --git a/ignite/templates/typed/list/files/component/proto/{{appName}}/{{moduleName}}/{{typeName}}.proto.plush b/ignite/templates/typed/list/files/component/{{protoDir}}/{{appName}}/{{moduleName}}/{{typeName}}.proto.plush similarity index 100% rename from ignite/templates/typed/list/files/component/proto/{{appName}}/{{moduleName}}/{{typeName}}.proto.plush rename to ignite/templates/typed/list/files/component/{{protoDir}}/{{appName}}/{{moduleName}}/{{typeName}}.proto.plush diff --git a/ignite/templates/typed/map/files/component/proto/{{appName}}/{{moduleName}}/{{typeName}}.proto.plush b/ignite/templates/typed/map/files/component/{{protoDir}}/{{appName}}/{{moduleName}}/{{typeName}}.proto.plush similarity index 100% rename from ignite/templates/typed/map/files/component/proto/{{appName}}/{{moduleName}}/{{typeName}}.proto.plush rename to ignite/templates/typed/map/files/component/{{protoDir}}/{{appName}}/{{moduleName}}/{{typeName}}.proto.plush diff --git a/ignite/templates/typed/options.go b/ignite/templates/typed/options.go index 9669202d36..8c9877dcde 100644 --- a/ignite/templates/typed/options.go +++ b/ignite/templates/typed/options.go @@ -15,7 +15,7 @@ import ( type Options struct { AppName string AppPath string - ProtoPath string + ProtoDir string ModuleName string ModulePath string TypeName multiformatname.Name @@ -34,7 +34,7 @@ func (opts *Options) Validate() error { // ProtoFile returns the path to the proto folder within the generated app. func (opts *Options) ProtoFile(fname string) string { - return filepath.Join(opts.AppPath, opts.ProtoPath, opts.AppName, opts.ModuleName, fname) + return filepath.Join(opts.AppPath, opts.ProtoDir, opts.AppName, opts.ModuleName, fname) } // ProtoTypeImport Return the protobuf import statement for this type. diff --git a/ignite/templates/typed/singleton/files/component/proto/{{appName}}/{{moduleName}}/{{typeName}}.proto.plush b/ignite/templates/typed/singleton/files/component/{{protoDir}}/{{appName}}/{{moduleName}}/{{typeName}}.proto.plush similarity index 100% rename from ignite/templates/typed/singleton/files/component/proto/{{appName}}/{{moduleName}}/{{typeName}}.proto.plush rename to ignite/templates/typed/singleton/files/component/{{protoDir}}/{{appName}}/{{moduleName}}/{{typeName}}.proto.plush diff --git a/ignite/templates/typed/typed.go b/ignite/templates/typed/typed.go index d65c364992..51022e2b30 100644 --- a/ignite/templates/typed/typed.go +++ b/ignite/templates/typed/typed.go @@ -42,6 +42,7 @@ func Box(box packd.Walker, opts *Options, g *genny.Generator) error { plushhelpers.ExtendPlushContext(ctx) g.Transformer(xgenny.Transformer(ctx)) + g.Transformer(genny.Replace("{{protoDir}}", opts.ProtoDir)) g.Transformer(genny.Replace("{{appName}}", opts.AppName)) g.Transformer(genny.Replace("{{moduleName}}", opts.ModuleName)) g.Transformer(genny.Replace("{{typeName}}", opts.TypeName.Snake)) diff --git a/integration/app/cmd_app_test.go b/integration/app/cmd_app_test.go index ca28db1195..d576f32e1e 100644 --- a/integration/app/cmd_app_test.go +++ b/integration/app/cmd_app_test.go @@ -80,32 +80,6 @@ func TestGenerateAnAppWithNoDefaultModuleAndCreateAModule(t *testing.T) { )) } -func TestGenerateAnAppWithWasm(t *testing.T) { - t.Skip() - - var ( - env = envtest.New(t) - app = env.Scaffold("github.com/test/blog") - ) - - env.Must(env.Exec("add Wasm module", - step.NewSteps(step.New( - step.Exec(envtest.IgniteApp, "s", "wasm", "--yes"), - step.Workdir(app.SourcePath()), - )), - )) - - env.Must(env.Exec("should not add Wasm module second time", - step.NewSteps(step.New( - step.Exec(envtest.IgniteApp, "s", "wasm", "--yes"), - step.Workdir(app.SourcePath()), - )), - envtest.ExecShouldError(), - )) - - app.EnsureSteady() -} - func TestGenerateAppWithEmptyModule(t *testing.T) { var ( env = envtest.New(t) diff --git a/integration/app/cmd_proto_path_test.go b/integration/app/cmd_proto_path_test.go index fb61bd1f38..edcd127641 100644 --- a/integration/app/cmd_proto_path_test.go +++ b/integration/app/cmd_proto_path_test.go @@ -74,13 +74,69 @@ func TestChangeProtoPath(t *testing.T) { require.NoError(t, file.Close()) app.SetConfigPath(cfgPath) - oldProtoPath := filepath.Join(appPath, defaults.ProtoPath) + oldProtoPath := filepath.Join(appPath, defaults.ProtoDir) protoPath := filepath.Join(appPath, newProtoPath) require.NoError(t, os.Rename(oldProtoPath, protoPath)) env.Must(env.Exec("create a list with a custom proto path", step.NewSteps(step.New( - step.Exec(envtest.IgniteApp, "s", "list", "--yes", "user", "email"), + step.Exec(envtest.IgniteApp, "s", "list", "--yes", "listUser", "email", "-p", newProtoPath), + step.Workdir(app.SourcePath()), + )), + )) + + env.Must(env.Exec("create a map with a custom proto path", + step.NewSteps(step.New( + step.Exec(envtest.IgniteApp, "s", "map", "--yes", "mapUser", "email", "-p", newProtoPath), + step.Workdir(app.SourcePath()), + )), + )) + + env.Must(env.Exec("create a single with a custom proto path", + step.NewSteps(step.New( + step.Exec(envtest.IgniteApp, "s", "single", "--yes", "singleUser", "email", "-p", newProtoPath), + step.Workdir(app.SourcePath()), + )), + )) + + env.Must(env.Exec("create a query with a custom proto path", + step.NewSteps(step.New( + step.Exec(envtest.IgniteApp, "s", "query", "--yes", "foo", "-p", newProtoPath), + step.Workdir(app.SourcePath()), + )), + )) + + env.Must(env.Exec("create a new module with parameter", + step.NewSteps(step.New( + step.Exec(envtest.IgniteApp, + "s", + "module", + "--yes", + "foo", + "--params", + "bla,baz:uint,bar:bool", + "--require-registration", + "-p", + newProtoPath, + ), + step.Workdir(app.SourcePath()), + )), + )) + + env.Must(env.Exec("create a new module parameters in the mars module", + step.NewSteps(step.New( + step.Exec(envtest.IgniteApp, + "s", + "params", + "--yes", + "foo", + "bar:uint", + "baz:bool", + "--module", + "foo", + "-p", + newProtoPath, + ), step.Workdir(app.SourcePath()), )), )) From 39338acef3f81444a3fe86df093c165abbc3d453 Mon Sep 17 00:00:00 2001 From: Pantani Date: Fri, 5 Apr 2024 14:19:05 +0200 Subject: [PATCH 12/23] avoid read config for scaffold commands --- ignite/cmd/chain.go | 14 +++++++------- ignite/cmd/scaffold.go | 10 ++++++---- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/ignite/cmd/chain.go b/ignite/cmd/chain.go index 820a1e689b..83f54baaf9 100644 --- a/ignite/cmd/chain.go +++ b/ignite/cmd/chain.go @@ -136,7 +136,12 @@ func preRunHandler(cmd *cobra.Command, _ []string) error { return err } - return bufMigrationPreRunHandler(cmd, session, appPath) + protoDir, err := getProtoDirFromConfig(cmd) + if err != nil { + return err + } + + return bufMigrationPreRunHandler(cmd, session, appPath, protoDir) } func toolsMigrationPreRunHandler(cmd *cobra.Command, session *cliui.Session, appPath string) error { @@ -192,12 +197,7 @@ func toolsMigrationPreRunHandler(cmd *cobra.Command, session *cliui.Session, app return os.WriteFile(toolsFilename, buf.Bytes(), 0o644) } -func bufMigrationPreRunHandler(cmd *cobra.Command, session *cliui.Session, appPath string) error { - protoDir, err := getProtoDirFromConfig(cmd) - if err != nil { - return err - } - +func bufMigrationPreRunHandler(cmd *cobra.Command, session *cliui.Session, appPath, protoDir string) error { // check if the buf files exist. hasFiles, err := chain.CheckBufFiles(appPath, protoDir) if err != nil { diff --git a/ignite/cmd/scaffold.go b/ignite/cmd/scaffold.go index 551f48bb2a..e3917316d9 100644 --- a/ignite/cmd/scaffold.go +++ b/ignite/cmd/scaffold.go @@ -143,10 +143,12 @@ func migrationPreRunHandler(cmd *cobra.Command, args []string) error { return err } - session := cliui.New() + var ( + path = flagGetPath(cmd) + protoDir = flagGetProtoDir(cmd) + session = cliui.New() + ) defer session.End() - - path := flagGetPath(cmd) path, err := filepath.Abs(path) if err != nil { return err @@ -170,7 +172,7 @@ func migrationPreRunHandler(cmd *cobra.Command, args []string) error { return err } - return bufMigrationPreRunHandler(cmd, session, appPath) + return bufMigrationPreRunHandler(cmd, session, appPath, protoDir) } func scaffoldType( From 2933962bb486a21f238e2c4ffeeb16c299214657 Mon Sep 17 00:00:00 2001 From: Pantani Date: Fri, 5 Apr 2024 14:20:18 +0200 Subject: [PATCH 13/23] fix wrong embed path --- ignite/templates/app/proto.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ignite/templates/app/proto.go b/ignite/templates/app/proto.go index 25a3cb505b..0d21fecccc 100644 --- a/ignite/templates/app/proto.go +++ b/ignite/templates/app/proto.go @@ -12,7 +12,7 @@ import ( "github.com/ignite/cli/v29/ignite/templates/field/plushhelpers" ) -//go:embed files/proto/* files/buf.work.yaml.plush +//go:embed files/{{protoDir}}/* files/buf.work.yaml.plush var fsProto embed.FS // NewBufGenerator returns the generator to buf build files. From 8b73bced0fa003d91782eff3f383d0f0e098fc1c Mon Sep 17 00:00:00 2001 From: Pantani Date: Fri, 5 Apr 2024 14:26:35 +0200 Subject: [PATCH 14/23] scaffold a chain with a custom proto path --- integration/app/cmd_proto_path_test.go | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/integration/app/cmd_proto_path_test.go b/integration/app/cmd_proto_path_test.go index edcd127641..51f3ad06e8 100644 --- a/integration/app/cmd_proto_path_test.go +++ b/integration/app/cmd_proto_path_test.go @@ -12,7 +12,6 @@ import ( "github.com/ignite/cli/v29/ignite/config/chain" "github.com/ignite/cli/v29/ignite/config/chain/base" - "github.com/ignite/cli/v29/ignite/config/chain/defaults" v1 "github.com/ignite/cli/v29/ignite/config/chain/v1" "github.com/ignite/cli/v29/ignite/pkg/cmdrunner/step" "github.com/ignite/cli/v29/ignite/pkg/xyaml" @@ -62,7 +61,7 @@ var ( func TestChangeProtoPath(t *testing.T) { var ( env = envtest.New(t) - app = env.Scaffold("github.com/test/protopath") + app = env.Scaffold("github.com/test/protopath", "--proto-dir", newProtoPath) appPath = app.SourcePath() cfgPath = filepath.Join(appPath, chain.ConfigFilenames[0]) ) @@ -74,10 +73,6 @@ func TestChangeProtoPath(t *testing.T) { require.NoError(t, file.Close()) app.SetConfigPath(cfgPath) - oldProtoPath := filepath.Join(appPath, defaults.ProtoDir) - protoPath := filepath.Join(appPath, newProtoPath) - require.NoError(t, os.Rename(oldProtoPath, protoPath)) - env.Must(env.Exec("create a list with a custom proto path", step.NewSteps(step.New( step.Exec(envtest.IgniteApp, "s", "list", "--yes", "listUser", "email", "-p", newProtoPath), From ecf03b1daeb39ddb0dfd65dfdc4863188da80259 Mon Sep 17 00:00:00 2001 From: Pantani Date: Fri, 5 Apr 2024 14:32:51 +0200 Subject: [PATCH 15/23] fix proto-dir flag --- integration/app/cmd_proto_path_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/integration/app/cmd_proto_path_test.go b/integration/app/cmd_proto_path_test.go index 51f3ad06e8..6f21b22ebc 100644 --- a/integration/app/cmd_proto_path_test.go +++ b/integration/app/cmd_proto_path_test.go @@ -75,28 +75,28 @@ func TestChangeProtoPath(t *testing.T) { env.Must(env.Exec("create a list with a custom proto path", step.NewSteps(step.New( - step.Exec(envtest.IgniteApp, "s", "list", "--yes", "listUser", "email", "-p", newProtoPath), + step.Exec(envtest.IgniteApp, "s", "list", "--yes", "listUser", "email", "--proto-dir", newProtoPath), step.Workdir(app.SourcePath()), )), )) env.Must(env.Exec("create a map with a custom proto path", step.NewSteps(step.New( - step.Exec(envtest.IgniteApp, "s", "map", "--yes", "mapUser", "email", "-p", newProtoPath), + step.Exec(envtest.IgniteApp, "s", "map", "--yes", "mapUser", "email", "--proto-dir", newProtoPath), step.Workdir(app.SourcePath()), )), )) env.Must(env.Exec("create a single with a custom proto path", step.NewSteps(step.New( - step.Exec(envtest.IgniteApp, "s", "single", "--yes", "singleUser", "email", "-p", newProtoPath), + step.Exec(envtest.IgniteApp, "s", "single", "--yes", "singleUser", "email", "--proto-dir", newProtoPath), step.Workdir(app.SourcePath()), )), )) env.Must(env.Exec("create a query with a custom proto path", step.NewSteps(step.New( - step.Exec(envtest.IgniteApp, "s", "query", "--yes", "foo", "-p", newProtoPath), + step.Exec(envtest.IgniteApp, "s", "query", "--yes", "foo", "--proto-dir", newProtoPath), step.Workdir(app.SourcePath()), )), )) From e93fbfa7c415e15fbca50156aee043c03f9db967 Mon Sep 17 00:00:00 2001 From: Pantani Date: Fri, 5 Apr 2024 16:37:51 +0200 Subject: [PATCH 16/23] fix protoDir var for plush files --- ignite/templates/app/app.go | 1 - ignite/templates/query/query.go | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/ignite/templates/app/app.go b/ignite/templates/app/app.go index 241e82fd5d..b73bc73799 100644 --- a/ignite/templates/app/app.go +++ b/ignite/templates/app/app.go @@ -81,7 +81,6 @@ func NewGenerator(opts *Options) (*genny.Generator, error) { plushhelpers.ExtendPlushContext(ctx) g.Transformer(xgenny.Transformer(ctx)) g.Transformer(genny.Replace("{{protoDir}}", opts.ProtoDir)) - g.Transformer(genny.Replace("{{protoDir}}", opts.ProtoDir)) g.Transformer(genny.Replace("{{appName}}", opts.AppName)) g.Transformer(genny.Replace("{{binaryNamePrefix}}", opts.BinaryNamePrefix)) diff --git a/ignite/templates/query/query.go b/ignite/templates/query/query.go index 839c0a3e15..f9a5cb7906 100644 --- a/ignite/templates/query/query.go +++ b/ignite/templates/query/query.go @@ -38,6 +38,7 @@ func Box(box packd.Walker, opts *Options, g *genny.Generator) error { plushhelpers.ExtendPlushContext(ctx) g.Transformer(xgenny.Transformer(ctx)) + g.Transformer(genny.Replace("{{protoDir}}", opts.ProtoDir)) g.Transformer(genny.Replace("{{appName}}", opts.AppName)) g.Transformer(genny.Replace("{{moduleName}}", opts.ModuleName)) g.Transformer(genny.Replace("{{queryName}}", opts.QueryName.Snake)) From dd96bb4b10463ab3fde345dfbdff031f544a11ef Mon Sep 17 00:00:00 2001 From: Pantani Date: Fri, 5 Apr 2024 17:10:51 +0200 Subject: [PATCH 17/23] fix buf pkg --- go.mod | 68 ++++---- go.sum | 152 ++++++++++-------- ignite/templates/app/files/go.mod.plush | 2 +- .../doctor/testdata/missing-tools.go.txt | 2 +- 4 files changed, 117 insertions(+), 107 deletions(-) diff --git a/go.mod b/go.mod index 42a5b2c8b8..f0aa4233f3 100644 --- a/go.mod +++ b/go.mod @@ -24,7 +24,7 @@ require ( github.com/DATA-DOG/go-sqlmock v1.5.0 github.com/blang/semver/v4 v4.0.0 github.com/briandowns/spinner v1.23.0 - github.com/bufbuild/buf v1.29.0 + github.com/bufbuild/buf v1.30.1 github.com/buger/jsonparser v1.1.1 github.com/cenkalti/backoff v2.2.1+incompatible github.com/charmbracelet/bubbles v0.7.6 @@ -76,16 +76,17 @@ require ( github.com/tbruyelle/mdgofmt v0.1.3 github.com/vektra/mockery/v2 v2.36.1 go.etcd.io/bbolt v1.3.8 - golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 - golang.org/x/mod v0.15.0 + golang.org/x/exp v0.0.0-20240325151524-a685a6edb6d8 + golang.org/x/mod v0.16.0 golang.org/x/sync v0.6.0 - golang.org/x/term v0.17.0 + golang.org/x/term v0.18.0 golang.org/x/text v0.14.0 - golang.org/x/tools v0.18.0 + golang.org/x/tools v0.19.0 golang.org/x/vuln v1.0.1 - google.golang.org/grpc v1.62.0 + google.golang.org/grpc v1.62.1 google.golang.org/protobuf v1.33.0 gopkg.in/yaml.v2 v2.4.0 + gopkg.in/yaml.v3 v3.0.1 mvdan.cc/gofumpt v0.5.0 sigs.k8s.io/yaml v1.4.0 ) @@ -93,8 +94,8 @@ require ( require ( 4d63.com/gocheckcompilerdirectives v1.2.1 // indirect 4d63.com/gochecknoglobals v0.2.1 // indirect - buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.32.0-20231115204500-e097f827e652.1 // indirect - connectrpc.com/connect v1.14.0 // indirect + buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.33.0-20240221180331-f05a6f4403ce.1 // indirect + connectrpc.com/connect v1.16.0 // indirect connectrpc.com/otelconnect v0.7.0 // indirect cosmossdk.io/api v0.7.3 // indirect cosmossdk.io/collections v0.4.0 // indirect @@ -145,9 +146,9 @@ require ( github.com/breml/errchkjson v0.3.6 // indirect github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect github.com/btcsuite/btcd/chaincfg/chainhash v1.0.2 // indirect - github.com/bufbuild/protocompile v0.8.0 // indirect - github.com/bufbuild/protovalidate-go v0.5.0 // indirect - github.com/bufbuild/protoyaml-go v0.1.7 // indirect + github.com/bufbuild/protocompile v0.9.0 // indirect + github.com/bufbuild/protovalidate-go v0.6.0 // indirect + github.com/bufbuild/protoyaml-go v0.1.8 // indirect github.com/butuzov/ireturn v0.2.2 // indirect github.com/butuzov/mirror v1.1.0 // indirect github.com/calmh/randomart v1.1.0 // indirect @@ -182,7 +183,7 @@ require ( github.com/cosmos/iavl v1.0.1 // indirect github.com/cosmos/ics23/go v0.10.0 // indirect github.com/cosmos/ledger-cosmos-go v0.13.3 // indirect - github.com/cpuguy83/go-md2man/v2 v2.0.3 // indirect + github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect github.com/curioswitch/go-reassign v0.2.0 // indirect github.com/cyphar/filepath-securejoin v0.2.4 // indirect github.com/daixiang0/gci v0.11.2 // indirect @@ -197,11 +198,11 @@ require ( github.com/dgraph-io/ristretto v0.1.1 // indirect github.com/dgrijalva/jwt-go v3.2.0+incompatible // indirect github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 // indirect - github.com/distribution/reference v0.5.0 // indirect + github.com/distribution/reference v0.6.0 // indirect github.com/dlclark/regexp2 v1.2.0 // indirect - github.com/docker/cli v24.0.7+incompatible // indirect + github.com/docker/cli v26.0.0+incompatible // indirect github.com/docker/distribution v2.8.3+incompatible // indirect - github.com/docker/docker v25.0.5+incompatible // indirect + github.com/docker/docker v26.0.0+incompatible // indirect github.com/docker/docker-credential-helpers v0.8.1 // indirect github.com/docker/go-connections v0.5.0 // indirect github.com/docker/go-units v0.5.0 // indirect @@ -214,14 +215,14 @@ require ( github.com/fatih/color v1.15.0 // indirect github.com/fatih/structs v1.1.0 // indirect github.com/fatih/structtag v1.2.0 // indirect - github.com/felixge/fgprof v0.9.3 // indirect + github.com/felixge/fgprof v0.9.4 // indirect github.com/felixge/httpsnoop v1.0.4 // indirect github.com/firefart/nonamedreturns v1.0.4 // indirect github.com/fsnotify/fsnotify v1.7.0 // indirect github.com/fzipp/gocyclo v0.6.0 // indirect github.com/getsentry/sentry-go v0.27.0 // indirect github.com/ghostiam/protogetter v0.2.3 // indirect - github.com/go-chi/chi/v5 v5.0.11 // indirect + github.com/go-chi/chi/v5 v5.0.12 // indirect github.com/go-critic/go-critic v0.9.0 // indirect github.com/go-delve/liner v1.2.3-0.20220127212407-d32d89dd2a5d // indirect github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect @@ -267,12 +268,12 @@ require ( github.com/golangci/revgrep v0.5.2 // indirect github.com/golangci/unconvert v0.0.0-20180507085042-28b1c447d1f4 // indirect github.com/google/btree v1.1.2 // indirect - github.com/google/cel-go v0.19.0 // indirect + github.com/google/cel-go v0.20.1 // indirect github.com/google/go-cmp v0.6.0 // indirect - github.com/google/go-containerregistry v0.18.0 // indirect + github.com/google/go-containerregistry v0.19.1 // indirect github.com/google/go-dap v0.9.1 // indirect github.com/google/go-querystring v1.1.0 // indirect - github.com/google/pprof v0.0.0-20240117000934-35fc243c5815 // indirect + github.com/google/pprof v0.0.0-20240327155427-868f304927ed // indirect github.com/google/uuid v1.6.0 // indirect github.com/gordonklaus/ineffassign v0.0.0-20230610083614-0e73809eb601 // indirect github.com/gorilla/css v1.0.0 // indirect @@ -347,6 +348,7 @@ require ( github.com/mikesmitty/edkey v0.0.0-20170222072505-3356ea4e686a // indirect github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/mitchellh/go-testing-interface v1.14.1 // indirect + github.com/moby/docker-image-spec v1.3.1 // indirect github.com/moby/patternmatcher v0.6.0 // indirect github.com/moby/sys/sequential v0.5.0 // indirect github.com/moby/sys/user v0.1.0 // indirect @@ -368,7 +370,7 @@ require ( github.com/oklog/run v1.1.0 // indirect github.com/olekukonko/tablewriter v0.0.5 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect - github.com/opencontainers/image-spec v1.1.0-rc5 // indirect + github.com/opencontainers/image-spec v1.1.0 // indirect github.com/pelletier/go-toml/v2 v2.1.0 // indirect github.com/petermattis/goid v0.0.0-20230904192822-1876fd5063bc // indirect github.com/pjbgf/sha1cd v0.3.0 // indirect @@ -426,7 +428,6 @@ require ( github.com/tdakkota/asciicheck v0.2.0 // indirect github.com/tendermint/go-amino v0.16.0 // indirect github.com/tetafro/godot v1.4.15 // indirect - github.com/tetratelabs/wazero v1.6.0 // indirect github.com/tidwall/btree v1.7.0 // indirect github.com/timakin/bodyclose v0.0.0-20230421092635-574207250966 // indirect github.com/timonwong/loggercheck v0.9.4 // indirect @@ -449,28 +450,27 @@ require ( github.com/zondax/ledger-go v0.14.3 // indirect gitlab.com/bosi/decorder v0.4.1 // indirect go-simpler.org/sloglint v0.1.2 // indirect - go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.47.0 // indirect - go.opentelemetry.io/otel v1.22.0 // indirect - go.opentelemetry.io/otel/metric v1.22.0 // indirect - go.opentelemetry.io/otel/sdk v1.22.0 // indirect - go.opentelemetry.io/otel/trace v1.22.0 // indirect + go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 // indirect + go.opentelemetry.io/otel v1.24.0 // indirect + go.opentelemetry.io/otel/metric v1.24.0 // indirect + go.opentelemetry.io/otel/sdk v1.24.0 // indirect + go.opentelemetry.io/otel/trace v1.24.0 // indirect go.starlark.net v0.0.0-20220816155156-cfacd8902214 // indirect go.tmz.dev/musttag v0.7.2 // indirect go.uber.org/atomic v1.11.0 // indirect go.uber.org/multierr v1.11.0 // indirect - go.uber.org/zap v1.26.0 // indirect + go.uber.org/zap v1.27.0 // indirect golang.org/x/arch v0.0.0-20190927153633-4e8777c89be4 // indirect - golang.org/x/crypto v0.19.0 // indirect + golang.org/x/crypto v0.21.0 // indirect golang.org/x/exp/typeparams v0.0.0-20230307190834-24139beb5833 // indirect - golang.org/x/net v0.21.0 // indirect - golang.org/x/sys v0.17.0 // indirect + golang.org/x/net v0.22.0 // indirect + golang.org/x/sys v0.18.0 // indirect golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect google.golang.org/genproto v0.0.0-20240213162025-012b6fc9bca9 // indirect - google.golang.org/genproto/googleapis/api v0.0.0-20240205150955-31a09d347014 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240221002015-b0ce06bbee7c // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20240325203815-454cdb8f5daa // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240325203815-454cdb8f5daa // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/warnings.v0 v0.1.2 // indirect - gopkg.in/yaml.v3 v3.0.1 // indirect gotest.tools/v3 v3.5.1 // indirect honnef.co/go/tools v0.4.6 // indirect mvdan.cc/interfacer v0.0.0-20180901003855-c20040233aed // indirect diff --git a/go.sum b/go.sum index a80cddd685..40cacbf37f 100644 --- a/go.sum +++ b/go.sum @@ -2,8 +2,8 @@ 4d63.com/gocheckcompilerdirectives v1.2.1/go.mod h1:yjDJSxmDTtIHHCqX0ufRYZDL6vQtMG7tJdKVeWwsqvs= 4d63.com/gochecknoglobals v0.2.1 h1:1eiorGsgHOFOuoOiJDy2psSrQbRdIHrlge0IJIkUgDc= 4d63.com/gochecknoglobals v0.2.1/go.mod h1:KRE8wtJB3CXCsb1xy421JfTHIIbmT3U5ruxw2Qu8fSU= -buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.32.0-20231115204500-e097f827e652.1 h1:u0olL4yf2p7Tl5jfsAK5keaFi+JFJuv1CDHrbiXkxkk= -buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.32.0-20231115204500-e097f827e652.1/go.mod h1:tiTMKD8j6Pd/D2WzREoweufjzaJKHZg35f/VGcZ2v3I= +buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.33.0-20240221180331-f05a6f4403ce.1 h1:0nWhrRcnkgw1kwJ7xibIO8bqfOA7pBzBjGCDBxIHch8= +buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.33.0-20240221180331-f05a6f4403ce.1/go.mod h1:Tgn5bgL220vkFOI0KPStlcClPeOJzAv4uT+V8JXGUnw= cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= @@ -47,8 +47,8 @@ cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RX cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= cloud.google.com/go/storage v1.35.1 h1:B59ahL//eDfx2IIKFBeT5Atm9wnNmj3+8xG/W4WB//w= cloud.google.com/go/storage v1.35.1/go.mod h1:M6M/3V/D3KpzMTJyPOR/HU6n2Si5QdaXYEsng2xgOs8= -connectrpc.com/connect v1.14.0 h1:PDS+J7uoz5Oui2VEOMcfz6Qft7opQM9hPiKvtGC01pA= -connectrpc.com/connect v1.14.0/go.mod h1:uoAq5bmhhn43TwhaKdGKN/bZcGtzPW1v+ngDTn5u+8s= +connectrpc.com/connect v1.16.0 h1:rdtfQjZ0OyFkWPTegBNcH7cwquGAN1WzyJy80oFNibg= +connectrpc.com/connect v1.16.0/go.mod h1:XpZAduBQUySsb4/KO5JffORVkDI4B6/EYPi7N8xpNZw= connectrpc.com/otelconnect v0.7.0 h1:ZH55ZZtcJOTKWWLy3qmL4Pam4RzRWBJFOqTPyAqCXkY= connectrpc.com/otelconnect v0.7.0/go.mod h1:Bt2ivBymHZHqxvo4HkJ0EwHuUzQN6k2l0oH+mp/8nwc= cosmossdk.io/api v0.7.3 h1:V815i8YOwOAQa1rLCsSMjVG5Gnzs02JLq+l7ks8s1jk= @@ -227,14 +227,14 @@ github.com/btcsuite/btcd/btcutil v1.1.3 h1:xfbtw8lwpp0G6NwSHb+UE67ryTFHJAiNuipus github.com/btcsuite/btcd/btcutil v1.1.3/go.mod h1:UR7dsSJzJUfMmFiiLlIrMq1lS9jh9EdCV7FStZSnpi0= github.com/btcsuite/btcd/chaincfg/chainhash v1.0.2 h1:KdUfX2zKommPRa+PD0sWZUyXe9w277ABlgELO7H04IM= github.com/btcsuite/btcd/chaincfg/chainhash v1.0.2/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= -github.com/bufbuild/buf v1.29.0 h1:llP6HqOcCaSGBxOfnrp/mwvcY1O/dciEOl1QaMEOB3M= -github.com/bufbuild/buf v1.29.0/go.mod h1:UTjvPXTObvKQiGqxod32wt9zRz70TJsMpaigpbIZGuc= -github.com/bufbuild/protocompile v0.8.0 h1:9Kp1q6OkS9L4nM3FYbr8vlJnEwtbpDPQlQOVXfR+78s= -github.com/bufbuild/protocompile v0.8.0/go.mod h1:+Etjg4guZoAqzVk2czwEQP12yaxLJ8DxuqCJ9qHdH94= -github.com/bufbuild/protovalidate-go v0.5.0 h1:xFery2RlLh07FQTvB7hlasKqPrDK2ug+uw6DUiuadjo= -github.com/bufbuild/protovalidate-go v0.5.0/go.mod h1:3XAwFeJ2x9sXyPLgkxufH9sts1tQRk8fdt1AW93NiUU= -github.com/bufbuild/protoyaml-go v0.1.7 h1:3uKIoNb/l5zrZ93u+Xzsg6cdAO06lveZE/K7UUbUQLw= -github.com/bufbuild/protoyaml-go v0.1.7/go.mod h1:R8vE2+l49bSiIExP4VJpxOXleHE+FDzZ6HVxr3cYunw= +github.com/bufbuild/buf v1.30.1 h1:QFtanwsXodoGFAwzXFXGXpzBkb7N2u8ZDyA3jWB4Pbs= +github.com/bufbuild/buf v1.30.1/go.mod h1:7W8DJnj76wQa55EA3z2CmDxS0/nsHh8FqtE00dyDAdA= +github.com/bufbuild/protocompile v0.9.0 h1:DI8qLG5PEO0Mu1Oj51YFPqtx6I3qYXUAhJVJ/IzAVl0= +github.com/bufbuild/protocompile v0.9.0/go.mod h1:s89m1O8CqSYpyE/YaSGtg1r1YFMF5nLTwh4vlj6O444= +github.com/bufbuild/protovalidate-go v0.6.0 h1:Jgs1kFuZ2LHvvdj8SpCLA1W/+pXS8QSM3F/E2l3InPY= +github.com/bufbuild/protovalidate-go v0.6.0/go.mod h1:1LamgoYHZ2NdIQH0XGczGTc6Z8YrTHjcJVmiBaar4t4= +github.com/bufbuild/protoyaml-go v0.1.8 h1:X9QDLfl9uEllh4gsXUGqPanZYCOKzd92uniRtW2OnAQ= +github.com/bufbuild/protoyaml-go v0.1.8/go.mod h1:R8vE2+l49bSiIExP4VJpxOXleHE+FDzZ6HVxr3cYunw= github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUs= github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0= github.com/butuzov/ireturn v0.2.2 h1:jWI36dxXwVrI+RnXDwux2IZOewpmfv930OuIRfaBUJ0= @@ -283,6 +283,9 @@ github.com/chavacava/garif v0.1.0/go.mod h1:XMyYCkEL58DF0oyW4qDjjnPWONs2HBqYKI+U github.com/chigopher/pathlib v0.15.0 h1:1pg96WL3iC1/YyWV4UJSl3E0GBf4B+h5amBtsbAAieY= github.com/chigopher/pathlib v0.15.0/go.mod h1:3+YPPV21mU9vyw8Mjp+F33CyCfE6iOzinpiqBcccv7I= github.com/chris-ramon/douceur v0.2.0/go.mod h1:wDW5xjJdeoMm1mRt4sD4c/LbF/mWdEpRXQKjTR8nIBE= +github.com/chromedp/cdproto v0.0.0-20230802225258-3cf4e6d46a89/go.mod h1:GKljq0VrfU4D5yc+2qA6OVr8pmO/MBbPEWqWQ/oqGEs= +github.com/chromedp/chromedp v0.9.2/go.mod h1:LkSXJKONWTCHAfQasKFUZI+mxqS4tZqhmtGzzhLsnLs= +github.com/chromedp/sysutil v1.0.0/go.mod h1:kgWmDdq8fTzXYcKIBqIYvRRTnYb9aNS9moAV0xufSww= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/logex v1.2.1 h1:XHDu3E6q+gdHgsdTPH6ImJMIp436vR6MPtH8gP05QzM= github.com/chzyer/logex v1.2.1/go.mod h1:JLbx6lG2kDbNRFnfkgvh4eRJRPX1QCoOIWomwysCBrQ= @@ -382,8 +385,9 @@ github.com/cosmos/ledger-cosmos-go v0.13.3/go.mod h1:HENcEP+VtahZFw38HZ3+LS3Iv5X github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= -github.com/cpuguy83/go-md2man/v2 v2.0.3 h1:qMCsGGgs+MAzDFyp9LpAe1Lqy/fY/qCovCm0qnXZOBM= github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/cpuguy83/go-md2man/v2 v2.0.4 h1:wfIWP927BUkWJb2NmU/kNDYIBTh/ziUX91+lVfRxZq4= +github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/creack/pty v1.1.17/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4= @@ -422,16 +426,16 @@ github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUn github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 h1:fAjc9m62+UWV/WAFKLNi6ZS0675eEUC9y3AlwSbQu1Y= github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= -github.com/distribution/reference v0.5.0 h1:/FUIFXtfc/x2gpa5/VGfiGLuOIdYa1t65IKK2OFGvA0= -github.com/distribution/reference v0.5.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E= +github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5QvfrDyIgxBk= +github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E= github.com/dlclark/regexp2 v1.2.0 h1:8sAhBGEM0dRWogWqWyQeIJnxjWO6oIjl8FKqREDsGfk= github.com/dlclark/regexp2 v1.2.0/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc= -github.com/docker/cli v24.0.7+incompatible h1:wa/nIwYFW7BVTGa7SWPVyyXU9lgORqUb1xfI36MSkFg= -github.com/docker/cli v24.0.7+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= +github.com/docker/cli v26.0.0+incompatible h1:90BKrx1a1HKYpSnnBFR6AgDq/FqkHxwlUyzJVPxD30I= +github.com/docker/cli v26.0.0+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= github.com/docker/distribution v2.8.3+incompatible h1:AtKxIZ36LoNK51+Z6RpzLpddBirtxJnzDrHLEKxTAYk= github.com/docker/distribution v2.8.3+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= -github.com/docker/docker v25.0.5+incompatible h1:UmQydMduGkrD5nQde1mecF/YnSbTOaPeFIeP5C4W+DE= -github.com/docker/docker v25.0.5+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= +github.com/docker/docker v26.0.0+incompatible h1:Ng2qi+gdKADUa/VM+6b6YaY2nlZhk/lVJiKR/2bMudU= +github.com/docker/docker v26.0.0+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/docker-credential-helpers v0.8.1 h1:j/eKUktUltBtMzKqmfLB0PAgqYyMHOp5vfsD1807oKo= github.com/docker/docker-credential-helpers v0.8.1/go.mod h1:P3ci7E3lwkZg6XiHdRKft1KckHiO9a2rNtyFbZ/ry9M= github.com/docker/go-connections v0.5.0 h1:USnMq7hx7gwdVZq1L49hLXaFtUdTADjXGp+uj1Br63c= @@ -481,8 +485,9 @@ github.com/fatih/structs v1.1.0 h1:Q7juDM0QtcnhCpeyLGQKyg4TOIghuNXrkL32pHAUMxo= github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M= github.com/fatih/structtag v1.2.0 h1:/OdNE99OxoI/PqaW/SuSK9uxxT3f/tcSZgon/ssNSx4= github.com/fatih/structtag v1.2.0/go.mod h1:mBJUNpUnHmRKrKlQQlmCrh5PuhftFbNv8Ys4/aAZl94= -github.com/felixge/fgprof v0.9.3 h1:VvyZxILNuCiUCSXtPtYmmtGvb65nqXh2QFWc0Wpf2/g= github.com/felixge/fgprof v0.9.3/go.mod h1:RdbpDgzqYVh/T9fPELJyV7EYJuHB55UTEULNun8eiPw= +github.com/felixge/fgprof v0.9.4 h1:ocDNwMFlnA0NU0zSB3I52xkO4sFXk80VK9lXjLClu88= +github.com/felixge/fgprof v0.9.4/go.mod h1:yKl+ERSa++RYOs32d8K6WEXCB4uXdLls4ZaZPpayhMM= github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= github.com/firefart/nonamedreturns v1.0.4 h1:abzI1p7mAEPYuR4A+VLKn4eNDOycjYo2phmY9sfv40Y= @@ -511,8 +516,8 @@ github.com/gin-gonic/gin v1.7.0 h1:jGB9xAJQ12AIGNB4HguylppmDK1Am9ppF7XnGXXJuoU= github.com/gin-gonic/gin v1.7.0/go.mod h1:jD2toBW3GZUr5UMcdrwQA10I7RuaFOl/SGeDjXkfUtY= github.com/gliderlabs/ssh v0.3.5 h1:OcaySEmAQJgyYcArR+gGGTHCyE7nvhEMTlYY+Dp8CpY= github.com/gliderlabs/ssh v0.3.5/go.mod h1:8XB4KraRrX39qHhT6yxPsHedjA08I/uBVwj4xC+/+z4= -github.com/go-chi/chi/v5 v5.0.11 h1:BnpYbFZ3T3S1WMpD79r7R5ThWX40TaFB7L31Y8xqSwA= -github.com/go-chi/chi/v5 v5.0.11/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8= +github.com/go-chi/chi/v5 v5.0.12 h1:9euLV5sTrTNTRUU9POmDUvfxyj6LAABLUcEWO+JJb4s= +github.com/go-chi/chi/v5 v5.0.12/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8= github.com/go-critic/go-critic v0.9.0 h1:Pmys9qvU3pSML/3GEQ2Xd9RZ/ip+aXHKILuxczKGV/U= github.com/go-critic/go-critic v0.9.0/go.mod h1:5P8tdXL7m/6qnyG6oRAlYLORvoXH0WDypYgAEmagT40= github.com/go-delve/delve v1.21.0 h1:npcc8TZhdVxaMSJon+zqcE3bXM/ck8SSOOWw/id13jI= @@ -707,8 +712,8 @@ github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Z github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.1.2 h1:xf4v41cLI2Z6FxbKm+8Bu+m8ifhj15JuZ9sa0jZCMUU= github.com/google/btree v1.1.2/go.mod h1:qOPhT0dTNdNzV6Z/lhRX0YXUafgPLFUh+gZMl761Gm4= -github.com/google/cel-go v0.19.0 h1:vVgaZoHPBDd1lXCYGQOh5A06L4EtuIfmqQ/qnSXSKiU= -github.com/google/cel-go v0.19.0/go.mod h1:kWcIzTsPX0zmQ+H3TirHstLLf9ep5QTsZBN9u4dOYLg= +github.com/google/cel-go v0.20.1 h1:nDx9r8S3L4pE61eDdt8igGj8rf5kjYR3ILxWIpWNi84= +github.com/google/cel-go v0.20.1/go.mod h1:kWcIzTsPX0zmQ+H3TirHstLLf9ep5QTsZBN9u4dOYLg= github.com/google/go-cmdtest v0.4.1-0.20220921163831-55ab3332a786 h1:rcv+Ippz6RAtvaGgKxc+8FQIpxHgsF+HBzPyYL2cyVU= github.com/google/go-cmdtest v0.4.1-0.20220921163831-55ab3332a786/go.mod h1:apVn/GCasLZUVpAJ6oWAuyP7Ne7CEsQbTnc0plM3m+o= github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= @@ -726,8 +731,8 @@ github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/go-containerregistry v0.18.0 h1:ShE7erKNPqRh5ue6Z9DUOlk04WsnFWPO6YGr3OxnfoQ= -github.com/google/go-containerregistry v0.18.0/go.mod h1:u0qB2l7mvtWVR5kNcbFIhFY1hLbf8eeGapA+vbFDCtQ= +github.com/google/go-containerregistry v0.19.1 h1:yMQ62Al6/V0Z7CqIrrS1iYoA5/oQCm88DeNujc7C1KY= +github.com/google/go-containerregistry v0.19.1/go.mod h1:YCMFNQeeXeLF+dnhhWkqDItx/JSkH01j1Kis4PsjzFI= github.com/google/go-dap v0.9.1 h1:d8dETjgHMR9/xs+Xza+NrZmB7jxIS5OtM2uRsyJVA/c= github.com/google/go-dap v0.9.1/go.mod h1:HAeyoSd2WIfTfg+0GRXcFrb+RnojAtGNh+k+XTIxJDE= github.com/google/go-github/v48 v48.2.0 h1:68puzySE6WqUY9KWmpOsDEQfDZsso98rT6pZcz9HqcE= @@ -751,8 +756,9 @@ github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hf github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/pprof v0.0.0-20211214055906-6f57359322fd/go.mod h1:KgnwoLYCZ8IQu3XUZ8Nc/bM9CCZFOyjUNOSygVozoDg= -github.com/google/pprof v0.0.0-20240117000934-35fc243c5815 h1:WzfWbQz/Ze8v6l++GGbGNFZnUShVpP/0xffCPLL+ax8= -github.com/google/pprof v0.0.0-20240117000934-35fc243c5815/go.mod h1:czg5+yv1E0ZGTi6S6vVK1mke0fV+FaUhNGcd6VRS9Ik= +github.com/google/pprof v0.0.0-20240227163752-401108e1b7e7/go.mod h1:czg5+yv1E0ZGTi6S6vVK1mke0fV+FaUhNGcd6VRS9Ik= +github.com/google/pprof v0.0.0-20240327155427-868f304927ed h1:n8QtJTrwsv3P7dNxPaMeNkMcxvUpqocsHLr8iDLGlQI= +github.com/google/pprof v0.0.0-20240327155427-868f304927ed/go.mod h1:kf6iHlnVGwgKolg33glAes7Yg/8iWP8ukqeldJSO7jw= github.com/google/renameio v0.1.0 h1:GOZbcHa3HfsPKPlmyPyN2KEohoMXOhdMbHrvbpl2QaA= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/s2a-go v0.1.7 h1:60BLSyTrOV4/haCDW4zb1guZItoSq8foHCXrAnjBo/o= @@ -888,6 +894,7 @@ github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSAS github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/ianlancetaylor/demangle v0.0.0-20210905161508-09a460cdf81d/go.mod h1:aYm2/VgdVmcIU8iMfdMvDMsRAQjcfZSKFby6HOFvi/w= +github.com/ianlancetaylor/demangle v0.0.0-20230524184225-eabc099b10ab/go.mod h1:gx7rwoVhcfuVKG5uya9Hs3Sxj7EIvldVofAWIUtGouw= github.com/ignite/ignite-files/nodetime v0.0.4 h1:4mA/lZTAWczsNBHZ543VSxpK+P6BAU0HsLglxUtRrMU= github.com/ignite/ignite-files/nodetime v0.0.4/go.mod h1:GKDsXdeazHyhSBPdVLp7mNIo/m9LmZ6/h8RmQ0/CoaM= github.com/ignite/ignite-files/protoc v0.0.1 h1:wXxU1dzruUgSVl1diAuAOA+xv0NQKXJFsDWht2+tAP8= @@ -909,8 +916,8 @@ github.com/jdx/go-netrc v1.0.0 h1:QbLMLyCZGj0NA8glAhxUpf1zDg6cxnWgMBbjq40W0gQ= github.com/jdx/go-netrc v1.0.0/go.mod h1:Gh9eFQJnoTNIRHXl2j5bJXA1u84hQWJWgGh569zF3v8= github.com/jgautheron/goconst v1.6.0 h1:gbMLWKRMkzAc6kYsQL6/TxaoBUg3Jm9LSF/Ih1ADWGA= github.com/jgautheron/goconst v1.6.0/go.mod h1:aAosetZ5zaeC/2EfMeRswtxUFBpe2Hr7HzkgX4fanO4= -github.com/jhump/protoreflect v1.15.4 h1:mrwJhfQGGljwvR/jPEocli8KA6G9afbQpH8NY2wORcI= -github.com/jhump/protoreflect v1.15.4/go.mod h1:2B+zwrnMY3TTIqEK01OG/d3pyUycQBfDf+bx8fE2DNg= +github.com/jhump/protoreflect v1.15.6 h1:WMYJbw2Wo+KOWwZFvgY0jMoVHM6i4XIvRs2RcBj5VmI= +github.com/jhump/protoreflect v1.15.6/go.mod h1:jCHoyYQIJnaabEYnbGwyo9hUqfyUMTbJw/tAut5t97E= github.com/jingyugao/rowserrcheck v1.1.1 h1:zibz55j/MJtLsjP1OF4bSdgXxwL1b+Vn7Tjzq7gFzUs= github.com/jingyugao/rowserrcheck v1.1.1/go.mod h1:4yvlZSDb3IyDTUZJUmpZfm2Hwok+Dtp+nu2qOq+er9c= github.com/jinzhu/copier v0.3.5 h1:GlvfUwHk62RokgqVNvYsku0TATCF7bAHVwEXoBh3iJg= @@ -923,6 +930,7 @@ github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHW github.com/jmhodges/levigo v1.0.0 h1:q5EC36kV79HWeTBWsod3mG11EgStG3qArTKcvlksN1U= github.com/jmhodges/levigo v1.0.0/go.mod h1:Q6Qx+uH3RAqyK4rFQroq9RL7mdkABMcfhEI+nNuzMJQ= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= +github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/jpillora/ansi v1.0.3 h1:nn4Jzti0EmRfDxm7JtEs5LzCbNwd5sv+0aE+LdS9/ZQ= github.com/jpillora/ansi v1.0.3/go.mod h1:D2tT+6uzJvN1nBVQILYWkIdq7zG+b5gcFN5WI/VyjMY= github.com/jpillora/backoff v1.0.0 h1:uvFg412JmmHBHw7iwprIxkPMI+sGQ4kzOWsMeHnm2EA= @@ -991,6 +999,7 @@ github.com/ldez/gomoddirectives v0.2.3 h1:y7MBaisZVDYmKvt9/l1mjNCiSA1BVn34U0ObUc github.com/ldez/gomoddirectives v0.2.3/go.mod h1:cpgBogWITnCfRq2qGoDkKMEVSaarhdBr6g8G04uz6d0= github.com/ldez/tagliatelle v0.5.0 h1:epgfuYt9v0CG3fms0pEgIMNPuFf/LpPIfjk4kyqSioo= github.com/ldez/tagliatelle v0.5.0/go.mod h1:rj1HmWiL1MiKQuOONhd09iySTEkUuE/8+5jtPYz9xa4= +github.com/ledongthuc/pdf v0.0.0-20220302134840-0c2507a12d80/go.mod h1:imJHygn/1yfhB7XSJJKlFZKl/J+dCPAknuiaGOshXAs= github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w= github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY= @@ -1016,6 +1025,7 @@ github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czP github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= +github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= github.com/manifoldco/promptui v0.9.0 h1:3V4HzJk1TtXW1MTZMP7mdlwbBpIinw3HztaIlYthEiA= github.com/manifoldco/promptui v0.9.0/go.mod h1:ka04sppxSGFAtxX0qhlYQjISsg9mR4GWtQEhdbn6Pgg= github.com/maratori/testableexamples v1.0.0 h1:dU5alXRrD8WKSjOUnmJZuzdxWOEQ57+7s93SLMxb2vI= @@ -1087,6 +1097,8 @@ github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:F github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/moby/docker-image-spec v1.3.1 h1:jMKff3w6PgbfSa69GfNg+zN/XLhfXJGnEx3Nl2EsFP0= +github.com/moby/docker-image-spec v1.3.1/go.mod h1:eKmb5VW8vQEh/BAr2yvVNvuiJuY6UIocYsFu/DxxRpo= github.com/moby/moby v24.0.9+incompatible h1:Z/hFbZJqC5Fmuf6jesMLdHU71CMAgdiSJ1ZYey+bFmg= github.com/moby/moby v24.0.9+incompatible/go.mod h1:fDXVQ6+S340veQPv35CzDahGBmHsiclFwfEygB/TWMc= github.com/moby/patternmatcher v0.6.0 h1:GmP9lR19aU5GqSSFko+5pRqHi+Ohk1O69aFiKkVGiPk= @@ -1182,8 +1194,8 @@ github.com/onsi/gomega v1.28.1/go.mod h1:9sxs+SwGrKI0+PWe4Fxa9tFQQBG5xSsSbMXOI8P github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= -github.com/opencontainers/image-spec v1.1.0-rc5 h1:Ygwkfw9bpDvs+c9E34SdgGOj41dX/cbdlwvlWt0pnFI= -github.com/opencontainers/image-spec v1.1.0-rc5/go.mod h1:X4pATf0uXsnn3g5aiGIsVnJBR4mxhKzfwmvK/B2NTm8= +github.com/opencontainers/image-spec v1.1.0 h1:8SG7/vwALn54lVB/0yZ/MMwhFrPYtpEHQb2IpWsCzug= +github.com/opencontainers/image-spec v1.1.0/go.mod h1:W4s4sFTMaBeK1BQLXbG4AdM2szdn85PY75RI83NrTrM= github.com/opentracing-contrib/go-observer v0.0.0-20170622124052-a52f23424492/go.mod h1:Ngi6UdF0k5OKD5t5wlmGhe/EDKPoUM3BXZSSfIuJbis= github.com/opentracing/basictracer-go v1.0.0/go.mod h1:QfBfYuafItcjQuMwinw9GhYKwFXS9KnPs5lxoYwgW74= github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= @@ -1192,6 +1204,7 @@ github.com/openzipkin-contrib/zipkin-go-opentracing v0.4.5/go.mod h1:/wsWhb9smxS github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJc5AZX7/PBEpw= github.com/openzipkin/zipkin-go v0.2.1/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= github.com/openzipkin/zipkin-go v0.2.2/go.mod h1:NaW6tEwdmWMaCDZzg8sh+IBNOxHMPnhQw8ySjnjRyN4= +github.com/orisano/pixelmatch v0.0.0-20220722002657-fb0b55479cde/go.mod h1:nZgzbfBr3hhjoZnS66nKrHmduYNpc34ny7RK4z5/HM0= github.com/otiai10/copy v1.2.0/go.mod h1:rrF5dJ5F0t/EWSYODDu4j9/vEeYHMkc8jt0zJChqQWw= github.com/otiai10/copy v1.14.0 h1:dCI/t1iTdYGtkvCuBG2BgR6KZa83PTclw4U5n2wAllU= github.com/otiai10/copy v1.14.0/go.mod h1:ECfuL02W+/FkTWZWgQqXPWZgW9oeKCSQ5qVfSc4qc4w= @@ -1450,8 +1463,6 @@ github.com/tenntenn/text/transform v0.0.0-20200319021203-7eef512accb3 h1:f+jULpR github.com/tenntenn/text/transform v0.0.0-20200319021203-7eef512accb3/go.mod h1:ON8b8w4BN/kE1EOhwT0o+d62W65a6aPw1nouo9LMgyY= github.com/tetafro/godot v1.4.15 h1:QzdIs+XB8q+U1WmQEWKHQbKmCw06QuQM7gLx/dky2RM= github.com/tetafro/godot v1.4.15/go.mod h1:2oVxTBSftRTh4+MVfUaUXR6bn2GDXCaMcOG4Dk3rfio= -github.com/tetratelabs/wazero v1.6.0 h1:z0H1iikCdP8t+q341xqepY4EWvHEw8Es7tlqiVzlP3g= -github.com/tetratelabs/wazero v1.6.0/go.mod h1:0U0G41+ochRKoPKCJlh0jMg1CHkyfK8kDqiirMmKY8A= github.com/tidwall/btree v1.7.0 h1:L1fkJH/AuEh5zBnnBbmTwQ5Lt+bRJ5A8EWecslvo9iI= github.com/tidwall/btree v1.7.0/go.mod h1:twD9XRA5jj9VUQGELzDO4HPQTNJsoWWfYEL+EUQ2cKY= github.com/timakin/bodyclose v0.0.0-20230421092635-574207250966 h1:quvGphlmUVU+nhpFa4gg4yJyTRJ13reZMDHrKwYw53M= @@ -1537,22 +1548,22 @@ go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0= go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= -go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.47.0 h1:sv9kVfal0MK0wBMCOGr+HeJm9v803BkJxGrk2au7j08= -go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.47.0/go.mod h1:SK2UL73Zy1quvRPonmOmRDiWk1KBV3LyIeeIxcEApWw= -go.opentelemetry.io/otel v1.22.0 h1:xS7Ku+7yTFvDfDraDIJVpw7XPyuHlB9MCiqqX5mcJ6Y= -go.opentelemetry.io/otel v1.22.0/go.mod h1:eoV4iAi3Ea8LkAEI9+GFT44O6T/D0GWAVFyZVCC6pMI= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0 h1:jq9TW8u3so/bN+JPT166wjOI6/vQPF6Xe7nMNIltagk= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.49.0/go.mod h1:p8pYQP+m5XfbZm9fxtSKAbM6oIllS7s2AfxrChvc7iw= +go.opentelemetry.io/otel v1.24.0 h1:0LAOdjNmQeSTzGBzduGe/rU4tZhMwL5rWgtp9Ku5Jfo= +go.opentelemetry.io/otel v1.24.0/go.mod h1:W7b9Ozg4nkF5tWI5zsXkaKKDjdVjpD4oAt9Qi/MArHo= go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.19.0 h1:Mne5On7VWdx7omSrSSZvM4Kw7cS7NQkOOmLcgscI51U= go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.19.0/go.mod h1:IPtUMKL4O3tH5y+iXVyAXqpAwMuzC1IrxVS81rummfE= -go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.22.0 h1:FyjCyI9jVEfqhUh2MoSkmolPjfh5fp2hnV0b0irxH4Q= -go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.22.0/go.mod h1:hYwym2nDEeZfG/motx0p7L7J1N1vyzIThemQsb4g2qY= -go.opentelemetry.io/otel/metric v1.22.0 h1:lypMQnGyJYeuYPhOM/bgjbFM6WE44W1/T45er4d8Hhg= -go.opentelemetry.io/otel/metric v1.22.0/go.mod h1:evJGjVpZv0mQ5QBRJoBF64yMuOf4xCWdXjK8pzFvliY= -go.opentelemetry.io/otel/sdk v1.22.0 h1:6coWHw9xw7EfClIC/+O31R8IY3/+EiRFHevmHafB2Gw= -go.opentelemetry.io/otel/sdk v1.22.0/go.mod h1:iu7luyVGYovrRpe2fmj3CVKouQNdTOkxtLzPvPz1DOc= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.24.0 h1:Xw8U6u2f8DK2XAkGRFV7BBLENgnTGX9i4rQRxJf+/vs= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.24.0/go.mod h1:6KW1Fm6R/s6Z3PGXwSJN2K4eT6wQB3vXX6CVnYX9NmM= +go.opentelemetry.io/otel/metric v1.24.0 h1:6EhoGWWK28x1fbpA4tYTOWBkPefTDQnb8WSGXlc88kI= +go.opentelemetry.io/otel/metric v1.24.0/go.mod h1:VYhLe1rFfxuTXLgj4CBiyz+9WYBA8pNGJgDcSFRKBco= +go.opentelemetry.io/otel/sdk v1.24.0 h1:YMPPDNymmQN3ZgczicBY3B6sf9n62Dlj9pWD3ucgoDw= +go.opentelemetry.io/otel/sdk v1.24.0/go.mod h1:KVrIYw6tEubO9E96HQpcmpTKDVn9gdv35HoYiQWGDFg= go.opentelemetry.io/otel/sdk/metric v1.19.0 h1:EJoTO5qysMsYCa+w4UghwFV/ptQgqSL/8Ni+hx+8i1k= go.opentelemetry.io/otel/sdk/metric v1.19.0/go.mod h1:XjG0jQyFJrv2PbMvwND7LwCEhsJzCzV5210euduKcKY= -go.opentelemetry.io/otel/trace v1.22.0 h1:Hg6pPujv0XG9QaVbGOBVHunyuLcCC3jN7WEhPx83XD0= -go.opentelemetry.io/otel/trace v1.22.0/go.mod h1:RbbHXVqKES9QhzZq/fE5UnOSILqRt40a21sPw2He1xo= +go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI= +go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU= go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= go.opentelemetry.io/proto/otlp v1.0.0 h1:T0TX0tmXU8a3CbNXzEKGeU5mIVOdf0oykP+u2lIVU/I= go.opentelemetry.io/proto/otlp v1.0.0/go.mod h1:Sy6pihPLfYHkr3NkUbEhGHFhINUSI/v80hjKIs5JXpM= @@ -1567,8 +1578,8 @@ go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE= go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= go.uber.org/goleak v1.1.10/go.mod h1:8a7PlsEVH3e/a/GLqe5IIrQx6GzcnRmZEufDUTk4A7A= -go.uber.org/goleak v1.2.0 h1:xqgm/S+aQvhWFTtR0XK3Jvg7z8kGV8P4X14IzwN3Eqk= -go.uber.org/goleak v1.2.0/go.mod h1:XJYK+MuIchqpmGmUSAzotztawfKvYLUIgg7guXrwVUo= +go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= +go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= @@ -1578,8 +1589,8 @@ go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9E go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= go.uber.org/zap v1.18.1/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI= -go.uber.org/zap v1.26.0 h1:sI7k6L95XOKS281NhVKOFCUNIvv9e0w4BF8N3u+tCRo= -go.uber.org/zap v1.26.0/go.mod h1:dtElttAiwGvoJ/vj4IwHBS/gXsEu/pZ50mUIRWuG0so= +go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= +go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= golang.org/x/arch v0.0.0-20190927153633-4e8777c89be4 h1:QlVATYS7JBoZMVaf+cNjb90WD/beKVHnIxFKT4QaHVI= golang.org/x/arch v0.0.0-20190927153633-4e8777c89be4/go.mod h1:flIaEI6LNU6xOCD5PaJvn9wGP0agmIOqjrtsKGRguv4= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= @@ -1600,8 +1611,8 @@ golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0 golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw= golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= -golang.org/x/crypto v0.19.0 h1:ENy+Az/9Y1vSrlrvBSyna3PITt4tiZLf7sgCjZBX7Wo= -golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= +golang.org/x/crypto v0.21.0 h1:X31++rzVUdKhX5sWmSOFZxx8UW/ldWx55cbf08iNAMA= +golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -1613,8 +1624,8 @@ golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u0 golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= golang.org/x/exp v0.0.0-20200331195152-e8c3332aa8e5/go.mod h1:4M0jN8W1tt0AVLNr8HDosyJCDCDuyL9N9+3m7wDWgKw= -golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 h1:LfspQV/FYTatPTr/3HzIcmiUFH7PGP+OQ6mgDYo3yuQ= -golang.org/x/exp v0.0.0-20240222234643-814bf88cf225/go.mod h1:CxmFvTBINI24O/j8iY7H1xHzx2i4OsyguNBmN/uPtqc= +golang.org/x/exp v0.0.0-20240325151524-a685a6edb6d8 h1:aAcj0Da7eBAtrTp03QXWvm88pSyOt+UgdZw2BFZ+lEw= +golang.org/x/exp v0.0.0-20240325151524-a685a6edb6d8/go.mod h1:CQ1k9gNrJ50XIzaKCRR2hssIjF07kZFEiieALBM/ARQ= golang.org/x/exp/typeparams v0.0.0-20220428152302-39d4317da171/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk= golang.org/x/exp/typeparams v0.0.0-20230203172020-98cc5a0785f9/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk= golang.org/x/exp/typeparams v0.0.0-20230307190834-24139beb5833 h1:jWGQJV4niP+CCmFW9ekjA9Zx8vYORzOUH2/Nl5WPuLQ= @@ -1647,8 +1658,8 @@ golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91 golang.org/x/mod v0.6.0/go.mod h1:4mET923SAdbXp2ki8ey+zGs1SLqsuM2Y0uvdZR/fUNI= golang.org/x/mod v0.7.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/mod v0.15.0 h1:SernR4v+D55NyBH2QiEQrlBAnj1ECL6AGrA5+dPaMY8= -golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/mod v0.16.0 h1:QX4fJ0Rr5cPQCF7O9lh9Se4pmwfwskqZfq5moyldzic= +golang.org/x/mod v0.16.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -1704,8 +1715,8 @@ golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= -golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4= -golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= +golang.org/x/net v0.22.0 h1:9sGLhx7iRIHEiX0oAJ3MRZMUCElJgy7Br1nO+AMN3Tc= +golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -1825,8 +1836,8 @@ golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= -golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= +golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= @@ -1837,8 +1848,8 @@ golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= golang.org/x/term v0.4.0/go.mod h1:9P2UbLfCdcvo3p/nzKvsmas4TnlujnuoV9hGgYzW1lQ= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= -golang.org/x/term v0.17.0 h1:mkTF7LCd6WGJNL3K1Ad7kwxNfYAW6a8a8QqtMblp/4U= -golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk= +golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8= +golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -1931,8 +1942,8 @@ golang.org/x/tools v0.2.0/go.mod h1:y4OqIKeOV/fWJetJ8bXPU1sEVniLMIyDAZWeHdV+NTA= golang.org/x/tools v0.3.0/go.mod h1:/rWhSS2+zyEVwoJf8YAX6L2f0ntZ7Kn/mGgAWcipA5k= golang.org/x/tools v0.5.0/go.mod h1:N+Kgy78s5I24c24dU8OfWNEotWjutIs8SnJvn5IDq+k= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= -golang.org/x/tools v0.18.0 h1:k8NLag8AGHnn+PHbl7g43CtqZAwG60vZkLqgyZgIHgQ= -golang.org/x/tools v0.18.0/go.mod h1:GL7B4CwcLLeo59yx/9UWWuNOW1n3VZ4f5axWfML7Lcg= +golang.org/x/tools v0.19.0 h1:tfGCXNR1OsFG+sVdLAitlpjAvD/I6dHDKnYrpEZUHkw= +golang.org/x/tools v0.19.0/go.mod h1:qoJWxmGSIBmAeriMx19ogtrEPrGtDbPK634QFIcLAhc= golang.org/x/vuln v1.0.1 h1:KUas02EjQK5LTuIx1OylBQdKKZ9jeugs+HiqO5HormU= golang.org/x/vuln v1.0.1/go.mod h1:bb2hMwln/tqxg32BNY4CcxHWtHXuYa3SbIBmtsyjxtM= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -2006,10 +2017,10 @@ google.golang.org/genproto v0.0.0-20210126160654-44e461bb6506/go.mod h1:FWY/as6D google.golang.org/genproto v0.0.0-20220314164441-57ef72a4c106/go.mod h1:hAL49I2IFola2sVEjAn7MEwsja0xp51I0tlGAf9hz4E= google.golang.org/genproto v0.0.0-20240213162025-012b6fc9bca9 h1:9+tzLLstTlPTRyJTh+ah5wIMsBW5c4tQwGTN3thOW9Y= google.golang.org/genproto v0.0.0-20240213162025-012b6fc9bca9/go.mod h1:mqHbVIp48Muh7Ywss/AD6I5kNVKZMmAa/QEW58Gxp2s= -google.golang.org/genproto/googleapis/api v0.0.0-20240205150955-31a09d347014 h1:x9PwdEgd11LgK+orcck69WVRo7DezSO4VUMPI4xpc8A= -google.golang.org/genproto/googleapis/api v0.0.0-20240205150955-31a09d347014/go.mod h1:rbHMSEDyoYX62nRVLOCc4Qt1HbsdytAYoVwgjiOhF3I= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240221002015-b0ce06bbee7c h1:NUsgEN92SQQqzfA+YtqYNqYmB3DMMYLlIwUZAQFVFbo= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240221002015-b0ce06bbee7c/go.mod h1:H4O17MA/PE9BsGx3w+a+W2VOLLD1Qf7oJneAoU6WktY= +google.golang.org/genproto/googleapis/api v0.0.0-20240325203815-454cdb8f5daa h1:Jt1XW5PaLXF1/ePZrznsh/aAUvI7Adfc3LY1dAKlzRs= +google.golang.org/genproto/googleapis/api v0.0.0-20240325203815-454cdb8f5daa/go.mod h1:K4kfzHtI0kqWA79gecJarFtDn/Mls+GxQcg3Zox91Ac= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240325203815-454cdb8f5daa h1:RBgMaUMP+6soRkik4VoN8ojR2nex2TqZwjSSogic+eo= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240325203815-454cdb8f5daa/go.mod h1:WtryC6hu0hhx87FDGxWCDptyssuo68sk10vYjF+T9fY= google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.0/go.mod h1:chYK+tFQF0nDUGJgXMSgLCQk3phJEuONr2DCgLDdAQM= @@ -2032,8 +2043,8 @@ google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTp google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= google.golang.org/grpc v1.45.0/go.mod h1:lN7owxKUQEqMfSyQikvvk5tf/6zMPsrK+ONuO11+0rQ= google.golang.org/grpc v1.49.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= -google.golang.org/grpc v1.62.0 h1:HQKZ/fa1bXkX1oFOvSjmZEUL8wLSaZTjCcLAlmZRtdk= -google.golang.org/grpc v1.62.0/go.mod h1:IWTG0VlJLCh1SkC58F7np9ka9mx/WNkjl4PGJaiq+QE= +google.golang.org/grpc v1.62.1 h1:B4n+nfKzOICUXMgyrNd19h/I9oH0L1pizfk1d4zSgTk= +google.golang.org/grpc v1.62.1/go.mod h1:IWTG0VlJLCh1SkC58F7np9ka9mx/WNkjl4PGJaiq+QE= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= @@ -2048,7 +2059,6 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp0 google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= diff --git a/ignite/templates/app/files/go.mod.plush b/ignite/templates/app/files/go.mod.plush index 719db2ed14..4288cda569 100644 --- a/ignite/templates/app/files/go.mod.plush +++ b/ignite/templates/app/files/go.mod.plush @@ -26,7 +26,7 @@ require ( <%= if (IsConsumerChain) { %> github.com/cosmos/interchain-security/v3 v3.2.0-consumer-rc0.0.20231123140529-1819e73f6197 <% } %> - github.com/bufbuild/buf v1.30.0 + github.com/bufbuild/buf v1.30.1 github.com/cometbft/cometbft v0.38.6 github.com/cosmos/cosmos-db v1.0.2 github.com/cosmos/cosmos-proto v1.0.0-beta.4 diff --git a/integration/doctor/testdata/missing-tools.go.txt b/integration/doctor/testdata/missing-tools.go.txt index 8817427511..2fbd1e6475 100644 --- a/integration/doctor/testdata/missing-tools.go.txt +++ b/integration/doctor/testdata/missing-tools.go.txt @@ -17,7 +17,7 @@ version: 1 module github.com/ignite/cli require ( - github.com/bufbuild/buf v1.29.0 + github.com/bufbuild/buf v1.30.1 ) go 1.20 From f201eed6ffb64d072fc011f83bc7a6037e24707a Mon Sep 17 00:00:00 2001 From: Pantani Date: Fri, 5 Apr 2024 17:20:52 +0200 Subject: [PATCH 18/23] fix unit tests for buf files --- ignite/templates/app/proto_test.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/ignite/templates/app/proto_test.go b/ignite/templates/app/proto_test.go index 356775ad4a..b330d99b40 100644 --- a/ignite/templates/app/proto_test.go +++ b/ignite/templates/app/proto_test.go @@ -6,16 +6,14 @@ import ( "testing" "github.com/stretchr/testify/require" - - "github.com/ignite/cli/v29/ignite/config/chain/defaults" ) func TestBufFiles(t *testing.T) { want := []string{"buf.work.yaml"} - protoDir, err := os.ReadDir(filepath.Join("files", defaults.ProtoDir)) + protoDir, err := os.ReadDir("files/{{protoDir}}") require.NoError(t, err) for _, e := range protoDir { - want = append(want, filepath.Join(defaults.ProtoDir, e.Name())) + want = append(want, filepath.Join("{{protoDir}}", e.Name())) } got, err := BufFiles() From 4aa2f3389b5beccb813727807b0d47858bc6ed85 Mon Sep 17 00:00:00 2001 From: Pantani Date: Sat, 6 Apr 2024 04:09:10 +0200 Subject: [PATCH 19/23] add proto dir to scaffold chain --- ignite/cmd/scaffold_chain.go | 2 ++ ignite/services/scaffolder/init.go | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ignite/cmd/scaffold_chain.go b/ignite/cmd/scaffold_chain.go index 480e343f53..874b49b9f9 100644 --- a/ignite/cmd/scaffold_chain.go +++ b/ignite/cmd/scaffold_chain.go @@ -102,6 +102,7 @@ func scaffoldChainHandler(cmd *cobra.Command, args []string) error { name = args[0] addressPrefix = getAddressPrefix(cmd) appPath = flagGetPath(cmd) + protoDir = flagGetProtoDir(cmd) noDefaultModule, _ = cmd.Flags().GetBool(flagNoDefaultModule) skipGit, _ = cmd.Flags().GetBool(flagSkipGit) minimal, _ = cmd.Flags().GetBool(flagMinimal) @@ -131,6 +132,7 @@ func scaffoldChainHandler(cmd *cobra.Command, args []string) error { appPath, name, addressPrefix, + protoDir, noDefaultModule, minimal, isConsumer, diff --git a/ignite/services/scaffolder/init.go b/ignite/services/scaffolder/init.go index 189ff4d002..0531814be4 100644 --- a/ignite/services/scaffolder/init.go +++ b/ignite/services/scaffolder/init.go @@ -20,7 +20,7 @@ import ( func Init( ctx context.Context, runner *xgenny.Runner, - root, name, addressPrefix string, + root, name, addressPrefix, protoDir string, noDefaultModule, minimal, isConsumerChain bool, params, moduleConfigs []string, ) (string, string, error) { @@ -49,6 +49,7 @@ func Init( runner, pathInfo, addressPrefix, + protoDir, path, noDefaultModule, minimal, @@ -65,6 +66,7 @@ func generate( runner *xgenny.Runner, pathInfo gomodulepath.Path, addressPrefix, + protoDir, absRoot string, noDefaultModule, minimal, isConsumerChain bool, params, moduleConfigs []string, @@ -92,7 +94,7 @@ func generate( ModulePath: pathInfo.RawPath, AppName: pathInfo.Package, AppPath: absRoot, - ProtoDir: defaults.ProtoDir, + ProtoDir: protoDir, GitHubPath: githubPath, BinaryNamePrefix: pathInfo.Root, AddressPrefix: addressPrefix, From 3c041cf3d5573fe807fc7daf9ded625dbca6ba12 Mon Sep 17 00:00:00 2001 From: Pantani Date: Sat, 6 Apr 2024 04:13:43 +0200 Subject: [PATCH 20/23] fix wrong prodir for the module --- ignite/services/scaffolder/init.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ignite/services/scaffolder/init.go b/ignite/services/scaffolder/init.go index 0531814be4..7eda0b7e1a 100644 --- a/ignite/services/scaffolder/init.go +++ b/ignite/services/scaffolder/init.go @@ -6,7 +6,6 @@ import ( "path/filepath" "strings" - "github.com/ignite/cli/v29/ignite/config/chain/defaults" "github.com/ignite/cli/v29/ignite/pkg/cosmosgen" "github.com/ignite/cli/v29/ignite/pkg/gomodulepath" "github.com/ignite/cli/v29/ignite/pkg/xgenny" @@ -126,7 +125,7 @@ func generate( ModulePath: pathInfo.RawPath, AppName: pathInfo.Package, AppPath: absRoot, - ProtoDir: defaults.ProtoDir, + ProtoDir: protoDir, Params: paramsFields, Configs: configsFields, IsIBC: false, From 53a443dde91436b0295b4067d414dcd36744dd76 Mon Sep 17 00:00:00 2001 From: Pantani Date: Sat, 6 Apr 2024 04:28:22 +0200 Subject: [PATCH 21/23] fix wrong proto dir --- ignite/cmd/scaffold_chain.go | 2 +- ignite/services/scaffolder/scaffolder.go | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ignite/cmd/scaffold_chain.go b/ignite/cmd/scaffold_chain.go index 874b49b9f9..8baf897aea 100644 --- a/ignite/cmd/scaffold_chain.go +++ b/ignite/cmd/scaffold_chain.go @@ -152,7 +152,7 @@ func scaffoldChainHandler(cmd *cobra.Command, args []string) error { return err } - if err := scaffolder.PostScaffold(cmd.Context(), cacheStorage, appDir, goModule, skipProto); err != nil { + if err := scaffolder.PostScaffold(cmd.Context(), cacheStorage, appDir, protoDir, goModule, skipProto); err != nil { return err } diff --git a/ignite/services/scaffolder/scaffolder.go b/ignite/services/scaffolder/scaffolder.go index 5c24e6ed6f..4252bea0a3 100644 --- a/ignite/services/scaffolder/scaffolder.go +++ b/ignite/services/scaffolder/scaffolder.go @@ -88,12 +88,12 @@ func (s Scaffolder) Run(gens ...*genny.Generator) error { } func (s Scaffolder) PostScaffold(ctx context.Context, cacheStorage cache.Storage, skipProto bool) error { - return PostScaffold(ctx, cacheStorage, s.appPath, s.modpath.RawPath, skipProto) + return PostScaffold(ctx, cacheStorage, s.appPath, s.protoDir, s.modpath.RawPath, skipProto) } -func PostScaffold(ctx context.Context, cacheStorage cache.Storage, path, gomodPath string, skipProto bool) error { +func PostScaffold(ctx context.Context, cacheStorage cache.Storage, path, protoDir, gomodPath string, skipProto bool) error { if !skipProto { - if err := protoc(ctx, cacheStorage, path, gomodPath); err != nil { + if err := protoc(ctx, cacheStorage, path, protoDir, gomodPath); err != nil { return err } } @@ -111,7 +111,7 @@ func PostScaffold(ctx context.Context, cacheStorage cache.Storage, path, gomodPa return nil } -func protoc(ctx context.Context, cacheStorage cache.Storage, projectPath, gomodPath string) error { +func protoc(ctx context.Context, cacheStorage cache.Storage, projectPath, protoDir, gomodPath string) error { confpath, err := chainconfig.LocateDefault(projectPath) if err != nil { return err @@ -167,5 +167,5 @@ func protoc(ctx context.Context, cacheStorage cache.Storage, projectPath, gomodP options = append(options, cosmosgen.WithOpenAPIGeneration(openAPIPath)) } - return cosmosgen.Generate(ctx, cacheStorage, projectPath, conf.Build.Proto.Path, gomodPath, options...) + return cosmosgen.Generate(ctx, cacheStorage, projectPath, protoDir, gomodPath, options...) } From 02b9687a47cfb0e936edaae45f506616077cec9e Mon Sep 17 00:00:00 2001 From: Pantani Date: Sat, 6 Apr 2024 04:57:23 +0200 Subject: [PATCH 22/23] fix text scaffold conflits --- integration/app/cmd_proto_path_test.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/integration/app/cmd_proto_path_test.go b/integration/app/cmd_proto_path_test.go index 6f21b22ebc..ce54439c70 100644 --- a/integration/app/cmd_proto_path_test.go +++ b/integration/app/cmd_proto_path_test.go @@ -109,7 +109,7 @@ func TestChangeProtoPath(t *testing.T) { "--yes", "foo", "--params", - "bla,baz:uint,bar:bool", + "bla,baz:uint", "--require-registration", "-p", newProtoPath, @@ -118,15 +118,14 @@ func TestChangeProtoPath(t *testing.T) { )), )) - env.Must(env.Exec("create a new module parameters in the mars module", + env.Must(env.Exec("create a new module parameter in the mars module", step.NewSteps(step.New( step.Exec(envtest.IgniteApp, "s", "params", "--yes", "foo", - "bar:uint", - "baz:bool", + "bar:int", "--module", "foo", "-p", From 4bc120fea2aa87e60bb3475730d177d137bd7f08 Mon Sep 17 00:00:00 2001 From: Pantani Date: Tue, 9 Apr 2024 02:04:05 +0200 Subject: [PATCH 23/23] fix wront proto path --- ignite/pkg/cosmosanalysis/app/app.go | 1 - ignite/pkg/cosmosanalysis/cosmosanalysis.go | 2 -- ignite/pkg/cosmosgen/generate_vuex.go | 2 -- ignite/pkg/goanalysis/goanalysis.go | 1 - ignite/pkg/repoversion/repoversion.go | 2 -- ignite/services/chain/proto.go | 5 +-- ignite/templates/app/proto.go | 5 +++ ignite/templates/app/proto_test.go | 35 +++++++++++++++++++++ 8 files changed, 41 insertions(+), 12 deletions(-) diff --git a/ignite/pkg/cosmosanalysis/app/app.go b/ignite/pkg/cosmosanalysis/app/app.go index eeda44dac9..cac4ba3036 100644 --- a/ignite/pkg/cosmosanalysis/app/app.go +++ b/ignite/pkg/cosmosanalysis/app/app.go @@ -237,7 +237,6 @@ func discoverRuntimeAppModules(chainRoot string) ([]string, error) { } return nil }) - if err != nil { return nil, err } diff --git a/ignite/pkg/cosmosanalysis/cosmosanalysis.go b/ignite/pkg/cosmosanalysis/cosmosanalysis.go index c316205dec..46e4f2f806 100644 --- a/ignite/pkg/cosmosanalysis/cosmosanalysis.go +++ b/ignite/pkg/cosmosanalysis/cosmosanalysis.go @@ -53,7 +53,6 @@ func DeepFindImplementation(modulePath string, interfaceList []string) (found [] found = append(found, currFound...) return nil }) - if err != nil { return nil, err } @@ -267,7 +266,6 @@ func FindAppFilePath(chainRoot string) (path string, err error) { return nil }) - if err != nil { return "", err } diff --git a/ignite/pkg/cosmosgen/generate_vuex.go b/ignite/pkg/cosmosgen/generate_vuex.go index 5add23c832..160a4c653d 100644 --- a/ignite/pkg/cosmosgen/generate_vuex.go +++ b/ignite/pkg/cosmosgen/generate_vuex.go @@ -69,7 +69,6 @@ func (g *generator) updateVueDependencies() error { tsClientName: fmt.Sprintf("file:%s", tsClientVueRelPath), }, }) - if err != nil { return errors.Errorf("failed to link ts-client dependency to the Vue app: %w", err) } @@ -136,7 +135,6 @@ func (g *generator) updateVuexDependencies() error { tsClientName: fmt.Sprintf("file:%s", tsClientVuexRelPath), }, }) - if err != nil { return errors.Errorf("failed to link ts-client dependency to the Vuex stores: %w", err) } diff --git a/ignite/pkg/goanalysis/goanalysis.go b/ignite/pkg/goanalysis/goanalysis.go index d219f1d5ed..d0e6c30c55 100644 --- a/ignite/pkg/goanalysis/goanalysis.go +++ b/ignite/pkg/goanalysis/goanalysis.go @@ -45,7 +45,6 @@ func DiscoverMain(path string) (pkgPaths []string, err error) { return nil }) - if err != nil { return nil, err } diff --git a/ignite/pkg/repoversion/repoversion.go b/ignite/pkg/repoversion/repoversion.go index 4428a5d41b..f2f3e560ec 100644 --- a/ignite/pkg/repoversion/repoversion.go +++ b/ignite/pkg/repoversion/repoversion.go @@ -50,7 +50,6 @@ func Determine(path string) (v Version, err error) { return nil }) - if err != nil { return Version{}, err } @@ -94,7 +93,6 @@ func Determine(path string) (v Version, err error) { return nil }) - if err != nil { return Version{}, err } diff --git a/ignite/services/chain/proto.go b/ignite/services/chain/proto.go index b03303c58a..0bd1331d94 100644 --- a/ignite/services/chain/proto.go +++ b/ignite/services/chain/proto.go @@ -1,11 +1,8 @@ package chain import ( - "fmt" "path/filepath" - "strings" - "github.com/ignite/cli/v29/ignite/config/chain/defaults" "github.com/ignite/cli/v29/ignite/pkg/cosmosbuf" "github.com/ignite/cli/v29/ignite/pkg/xgenny" "github.com/ignite/cli/v29/ignite/pkg/xos" @@ -54,7 +51,7 @@ func CheckBufFiles(appPath, protoDir string) (bool, error) { return false, nil } for _, bufFile := range files { - bufFile, ok := strings.CutPrefix(bufFile, fmt.Sprintf("%s/", defaults.ProtoDir)) + bufFile, ok := app.CutTemplatePrefix(bufFile) if ok { bufFile = filepath.Join(protoDir, bufFile) } diff --git a/ignite/templates/app/proto.go b/ignite/templates/app/proto.go index 0d21fecccc..f7920ff803 100644 --- a/ignite/templates/app/proto.go +++ b/ignite/templates/app/proto.go @@ -2,6 +2,7 @@ package app import ( "embed" + "fmt" "strings" "github.com/gobuffalo/genny/v2" @@ -39,6 +40,10 @@ func NewBufGenerator(appPath, protoDir string) (*genny.Generator, error) { return g, nil } +func CutTemplatePrefix(name string) (string, bool) { + return strings.CutPrefix(name, fmt.Sprintf("%s/", "{{protoDir}}")) +} + // BufFiles returns a list of Buf.Build files. func BufFiles() ([]string, error) { files, err := xembed.FileList(fsProto, "files") diff --git a/ignite/templates/app/proto_test.go b/ignite/templates/app/proto_test.go index b330d99b40..18d72ad0ba 100644 --- a/ignite/templates/app/proto_test.go +++ b/ignite/templates/app/proto_test.go @@ -20,3 +20,38 @@ func TestBufFiles(t *testing.T) { require.NoError(t, err) require.ElementsMatch(t, want, got) } + +func TestCutTemplatePrefix(t *testing.T) { + tests := []struct { + name string + arg string + want string + ok bool + }{ + { + name: "with prefix", + arg: "{{protoDir}}/myvalue", + want: "myvalue", + ok: true, + }, + { + name: "with 2 prefix", + arg: "{{protoDir}}/{{protoDir}}/myvalue", + want: "{{protoDir}}/myvalue", + ok: true, + }, + { + name: "without prefix", + arg: "myvalue", + want: "myvalue", + ok: false, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + got, ok := CutTemplatePrefix(tt.arg) + require.Equal(t, tt.ok, ok) + require.Equal(t, tt.want, got) + }) + } +}