forked from cosmos/cosmos-sdk
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: CLI tooling to generate proposal JSONs (backport cosmos#13304) (c…
…osmos#13328) * feat: CLI tooling to generate proposal JSONs (cosmos#13304) (cherry picked from commit 7252f4a) # Conflicts: # CHANGELOG.md # api/cosmos/nft/v1beta1/tx.pulsar.go # go.mod # go.sum # simapp/go.mod # simapp/go.sum # tests/go.mod # tests/go.sum # x/gov/README.md # x/group/spec/05_client.md * fix changelog * remove unnecessary addition * updates * fix docs * updates Co-authored-by: Julien Robert <julien@rbrt.fr>
- Loading branch information
1 parent
c524571
commit ef0f19c
Showing
11 changed files
with
402 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package client | ||
|
||
import ( | ||
"fmt" | ||
"net/url" | ||
"unicode" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
) | ||
|
||
// ValidatePromptNotEmpty validates that the input is not empty. | ||
func ValidatePromptNotEmpty(input string) error { | ||
if input == "" { | ||
return fmt.Errorf("input cannot be empty") | ||
} | ||
|
||
return nil | ||
} | ||
|
||
// ValidatePromptURL validates that the input is a valid URL. | ||
func ValidatePromptURL(input string) error { | ||
_, err := url.ParseRequestURI(input) | ||
if err != nil { | ||
return fmt.Errorf("invalid URL: %w", err) | ||
} | ||
|
||
return nil | ||
} | ||
|
||
// ValidatePromptAddress validates that the input is a valid Bech32 address. | ||
func ValidatePromptAddress(input string) error { | ||
if _, err := sdk.AccAddressFromBech32(input); err != nil { | ||
return fmt.Errorf("invalid address: %w", err) | ||
} | ||
|
||
return nil | ||
} | ||
|
||
// ValidatePromptYesNo validates that the input is valid sdk.COins | ||
func ValidatePromptCoins(input string) error { | ||
if _, err := sdk.ParseCoinsNormalized(input); err != nil { | ||
return fmt.Errorf("invalid coins: %w", err) | ||
} | ||
|
||
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) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.