From 59acfa5232e1b28b0aa818c6dfc1f12722e9afaa Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Tue, 14 Nov 2023 13:56:40 +0100 Subject: [PATCH] feedback --- client/v2/internal/prompt/validation.go | 32 -------------------- client/v2/internal/prompt/validation_test.go | 9 ------ x/auth/autocli.go | 2 +- x/bank/autocli.go | 2 +- x/consensus/autocli.go | 2 +- x/crisis/autocli.go | 2 +- x/distribution/autocli.go | 8 ++--- x/gov/autocli.go | 2 +- x/mint/autocli.go | 2 +- x/slashing/autocli.go | 2 +- x/staking/autocli.go | 2 +- 11 files changed, 12 insertions(+), 53 deletions(-) diff --git a/client/v2/internal/prompt/validation.go b/client/v2/internal/prompt/validation.go index 0d79347173db..05e73a4f0105 100644 --- a/client/v2/internal/prompt/validation.go +++ b/client/v2/internal/prompt/validation.go @@ -3,7 +3,6 @@ package prompt import ( "fmt" "net/url" - "unicode" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -27,26 +26,6 @@ func ValidatePromptURL(input string) error { return nil } -// ValidatePromptAddress validates that the input is a valid Bech32 address. -func ValidatePromptAddress(input string) error { // TODO(@julienrbrt) remove and add prompts in AutoCLI - _, err := sdk.AccAddressFromBech32(input) - if err == nil { - return nil - } - - _, err = sdk.ValAddressFromBech32(input) - if err == nil { - return nil - } - - _, err = sdk.ConsAddressFromBech32(input) - if err == nil { - return nil - } - - return fmt.Errorf("invalid address: %w", err) -} - // ValidatePromptYesNo validates that the input is valid sdk.COins func ValidatePromptCoins(input string) error { if _, err := sdk.ParseCoinsNormalized(input); err != nil { @@ -55,14 +34,3 @@ func ValidatePromptCoins(input string) error { return nil } - -// CamelCaseToString converts a camel case string to a string with spaces. -func CamelCaseToString(str string) string { - w := []rune(str) - for i := len(w) - 1; i > 1; i-- { - if unicode.IsUpper(w[i]) { - w = append(w[:i], append([]rune{' '}, w[i:]...)...) - } - } - return string(w) -} diff --git a/client/v2/internal/prompt/validation_test.go b/client/v2/internal/prompt/validation_test.go index dad507c05429..86e4ba4ab475 100644 --- a/client/v2/internal/prompt/validation_test.go +++ b/client/v2/internal/prompt/validation_test.go @@ -22,15 +22,6 @@ func TestValidatePromptURL(t *testing.T) { require.ErrorContains(prompt.ValidatePromptURL("foo"), "invalid URL") } -func TestValidatePromptAddress(t *testing.T) { - require := require.New(t) - - require.NoError(prompt.ValidatePromptAddress("cosmos1huydeevpz37sd9snkgul6070mstupukw00xkw9")) - require.NoError(prompt.ValidatePromptAddress("cosmosvaloper1sjllsnramtg3ewxqwwrwjxfgc4n4ef9u2lcnj0")) - require.NoError(prompt.ValidatePromptAddress("cosmosvalcons1ntk8eualewuprz0gamh8hnvcem2nrcdsgz563h")) - require.ErrorContains(prompt.ValidatePromptAddress("foo"), "invalid address") -} - func TestValidatePromptCoins(t *testing.T) { require := require.New(t) diff --git a/x/auth/autocli.go b/x/auth/autocli.go index 298e9c45c274..c75512b159bc 100644 --- a/x/auth/autocli.go +++ b/x/auth/autocli.go @@ -82,7 +82,7 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { { RpcMethod: "UpdateParams", Use: "update-params-proposal [params]", - Short: "Submit a proposal to update auth module params", + Short: "Submit a proposal to update auth module params. Note: params are JSON encoded", Example: fmt.Sprintf(`%s tx auth update-params-proposal '{ params }'`, version.AppName), PositionalArgs: []*autocliv1.PositionalArgDescriptor{{ProtoField: "params"}}, GovProposal: true, diff --git a/x/bank/autocli.go b/x/bank/autocli.go index 03b87ec8bb3a..7f614c85a015 100644 --- a/x/bank/autocli.go +++ b/x/bank/autocli.go @@ -112,7 +112,7 @@ Note: multiple coins can be send by space separated.`, { RpcMethod: "UpdateParams", Use: "update-params-proposal [params]", - Short: "Submit a proposal to update bank module params", + Short: "Submit a proposal to update bank module params. Note: params are JSON encoded", Example: fmt.Sprintf(`%s tx bank update-params-proposal '{ params }'`, version.AppName), PositionalArgs: []*autocliv1.PositionalArgDescriptor{{ProtoField: "params"}}, GovProposal: true, diff --git a/x/consensus/autocli.go b/x/consensus/autocli.go index 7b3df82dfd82..3eeac7ac51af 100644 --- a/x/consensus/autocli.go +++ b/x/consensus/autocli.go @@ -32,7 +32,7 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { { RpcMethod: "UpdateParams", Use: "update-params-proposal [params]", - Short: "Submit a proposal to update consensus module params", + Short: "Submit a proposal to update consensus module params. Note: params are JSON encoded", Example: fmt.Sprintf(`%s tx consensus update-params-proposal '{ params }'`, version.AppName), PositionalArgs: []*autocliv1.PositionalArgDescriptor{ {ProtoField: "block"}, diff --git a/x/crisis/autocli.go b/x/crisis/autocli.go index cf241c730d07..763275c5be83 100644 --- a/x/crisis/autocli.go +++ b/x/crisis/autocli.go @@ -26,7 +26,7 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { { RpcMethod: "UpdateParams", Use: "update-params-proposal [params]", - Short: "Submit a proposal to update crisis module params", + Short: "Submit a proposal to update crisis module params. Note: params are JSON encoded", Example: fmt.Sprintf(`%s tx crisis update-params-proposal '{ params }'`, version.AppName), PositionalArgs: []*autocliv1.PositionalArgDescriptor{{ProtoField: "params"}}, GovProposal: true, diff --git a/x/distribution/autocli.go b/x/distribution/autocli.go index caa2948c4053..6824812f42d3 100644 --- a/x/distribution/autocli.go +++ b/x/distribution/autocli.go @@ -4,7 +4,7 @@ import ( "fmt" autocliv1 "cosmossdk.io/api/cosmos/autocli/v1" - distirbuitonv1beta1 "cosmossdk.io/api/cosmos/distribution/v1beta1" + distributionv1beta1 "cosmossdk.io/api/cosmos/distribution/v1beta1" "github.com/cosmos/cosmos-sdk/version" ) @@ -13,7 +13,7 @@ import ( func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { return &autocliv1.ModuleOptions{ Query: &autocliv1.ServiceCommandDescriptor{ - Service: distirbuitonv1beta1.Query_ServiceDesc.ServiceName, + Service: distributionv1beta1.Query_ServiceDesc.ServiceName, RpcCommandOptions: []*autocliv1.RpcCommandOptions{ { RpcMethod: "Params", @@ -79,7 +79,7 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { }, }, Tx: &autocliv1.ServiceCommandDescriptor{ - Service: distirbuitonv1beta1.Msg_ServiceDesc.ServiceName, + Service: distributionv1beta1.Msg_ServiceDesc.ServiceName, RpcCommandOptions: []*autocliv1.RpcCommandOptions{ { RpcMethod: "SetWithdrawAddress", @@ -129,7 +129,7 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { { RpcMethod: "UpdateParams", Use: "update-params-proposal [params]", - Short: "Submit a proposal to update distribution module params", + Short: "Submit a proposal to update distribution module params. Note: params are JSON encoded", Example: fmt.Sprintf(`%s tx distribution update-params-proposal '{ params }'`, version.AppName), PositionalArgs: []*autocliv1.PositionalArgDescriptor{{ProtoField: "params"}}, GovProposal: true, diff --git a/x/gov/autocli.go b/x/gov/autocli.go index d843452abb09..6507db762573 100644 --- a/x/gov/autocli.go +++ b/x/gov/autocli.go @@ -133,7 +133,7 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { { RpcMethod: "UpdateParams", Use: "update-params-proposal [params]", - Short: "Submit a proposal to update gov module params", + Short: "Submit a proposal to update gov module params. Note: params are JSON encoded", Example: fmt.Sprintf(`%s tx gov update-params-proposal '{ params }'`, version.AppName), PositionalArgs: []*autocliv1.PositionalArgDescriptor{{ProtoField: "params"}}, GovProposal: true, diff --git a/x/mint/autocli.go b/x/mint/autocli.go index 627562ee2bed..497f7db82a48 100644 --- a/x/mint/autocli.go +++ b/x/mint/autocli.go @@ -36,7 +36,7 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { { RpcMethod: "UpdateParams", Use: "update-params-proposal [params]", - Short: "Submit a proposal to update mint module params", + Short: "Submit a proposal to update mint module params. Note: params are JSON encoded", Example: fmt.Sprintf(`%s tx mint update-params-proposal '{ params }'`, version.AppName), PositionalArgs: []*autocliv1.PositionalArgDescriptor{{ProtoField: "params"}}, GovProposal: true, diff --git a/x/slashing/autocli.go b/x/slashing/autocli.go index 62e3d53bae2d..7b4a4dfb68fe 100644 --- a/x/slashing/autocli.go +++ b/x/slashing/autocli.go @@ -48,7 +48,7 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { { RpcMethod: "UpdateParams", Use: "update-params-proposal [params]", - Short: "Submit a proposal to update slashing module params", + Short: "Submit a proposal to update slashing module params. Note: params are JSON encoded", Example: fmt.Sprintf(`%s tx slashing update-params-proposal '{ params }'`, version.AppName), PositionalArgs: []*autocliv1.PositionalArgDescriptor{{ProtoField: "params"}}, GovProposal: true, diff --git a/x/staking/autocli.go b/x/staking/autocli.go index 9d6f60f1e281..ace9ba154b4c 100644 --- a/x/staking/autocli.go +++ b/x/staking/autocli.go @@ -176,7 +176,7 @@ func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions { { RpcMethod: "UpdateParams", Use: "update-params-proposal [params]", - Short: "Submit a proposal to update staking module params", + Short: "Submit a proposal to update staking module params. Note: params are JSON encoded", Example: fmt.Sprintf(`%s tx staking update-params-proposal '{ params }'`, version.AppName), PositionalArgs: []*autocliv1.PositionalArgDescriptor{{ProtoField: "params"}}, GovProposal: true,