Skip to content

Commit

Permalink
feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
julienrbrt committed Nov 14, 2023
1 parent e5cb363 commit 59acfa5
Show file tree
Hide file tree
Showing 11 changed files with 12 additions and 53 deletions.
32 changes: 0 additions & 32 deletions client/v2/internal/prompt/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package prompt
import (
"fmt"
"net/url"
"unicode"

sdk "github.com/cosmos/cosmos-sdk/types"
)
Expand All @@ -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 {
Expand All @@ -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)
}
9 changes: 0 additions & 9 deletions client/v2/internal/prompt/validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion x/auth/autocli.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion x/bank/autocli.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion x/consensus/autocli.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand Down
2 changes: 1 addition & 1 deletion x/crisis/autocli.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions x/distribution/autocli.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion x/gov/autocli.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion x/mint/autocli.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion x/slashing/autocli.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion x/staking/autocli.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 59acfa5

Please sign in to comment.