-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(client/v2): support gov proposals (#18461)
- Loading branch information
1 parent
4ee4046
commit 9c3386f
Showing
60 changed files
with
345 additions
and
152 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
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
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
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
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,36 @@ | ||
package prompt | ||
|
||
import ( | ||
"fmt" | ||
"net/url" | ||
|
||
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 | ||
} | ||
|
||
// ValidatePromptCoins validates that the input contains valid sdk.Coins | ||
func ValidatePromptCoins(input string) error { | ||
if _, err := sdk.ParseCoinsNormalized(input); err != nil { | ||
return fmt.Errorf("invalid coins: %w", err) | ||
} | ||
|
||
return nil | ||
} |
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,30 @@ | ||
package prompt_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
|
||
"cosmossdk.io/client/v2/internal/prompt" | ||
) | ||
|
||
func TestValidatePromptNotEmpty(t *testing.T) { | ||
require := require.New(t) | ||
|
||
require.NoError(prompt.ValidatePromptNotEmpty("foo")) | ||
require.ErrorContains(prompt.ValidatePromptNotEmpty(""), "input cannot be empty") | ||
} | ||
|
||
func TestValidatePromptURL(t *testing.T) { | ||
require := require.New(t) | ||
|
||
require.NoError(prompt.ValidatePromptURL("https://example.com")) | ||
require.ErrorContains(prompt.ValidatePromptURL("foo"), "invalid URL") | ||
} | ||
|
||
func TestValidatePromptCoins(t *testing.T) { | ||
require := require.New(t) | ||
|
||
require.NoError(prompt.ValidatePromptCoins("100stake")) | ||
require.ErrorContains(prompt.ValidatePromptCoins("foo"), "invalid coins") | ||
} |
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
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.