Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

code hygiene: rename validateEnabled to validateEnabledType #2469

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func DefaultParams() Params {

// Validate validates all controller submodule parameters
func (p Params) Validate() error {
if err := validateEnabled(p.ControllerEnabled); err != nil {
if err := validateEnabledType(p.ControllerEnabled); err != nil {
return err
}

Expand All @@ -43,11 +43,11 @@ func (p Params) Validate() error {
// ParamSetPairs implements params.ParamSet
func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs {
return paramtypes.ParamSetPairs{
paramtypes.NewParamSetPair(KeyControllerEnabled, p.ControllerEnabled, validateEnabled),
paramtypes.NewParamSetPair(KeyControllerEnabled, p.ControllerEnabled, validateEnabledType),
}
}

func validateEnabled(i interface{}) error {
func validateEnabledType(i interface{}) error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fwiw, we can remove these functions when we self manage params

_, ok := i.(bool)
if !ok {
return fmt.Errorf("invalid parameter type: %T", i)
Expand Down
6 changes: 3 additions & 3 deletions modules/apps/27-interchain-accounts/host/types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func DefaultParams() Params {

// Validate validates all host submodule parameters
func (p Params) Validate() error {
if err := validateEnabled(p.HostEnabled); err != nil {
if err := validateEnabledType(p.HostEnabled); err != nil {
return err
}

Expand All @@ -53,12 +53,12 @@ func (p Params) Validate() error {
// ParamSetPairs implements params.ParamSet
func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs {
return paramtypes.ParamSetPairs{
paramtypes.NewParamSetPair(KeyHostEnabled, p.HostEnabled, validateEnabled),
paramtypes.NewParamSetPair(KeyHostEnabled, p.HostEnabled, validateEnabledType),
paramtypes.NewParamSetPair(KeyAllowMessages, p.AllowMessages, validateAllowlist),
}
}

func validateEnabled(i interface{}) error {
func validateEnabledType(i interface{}) error {
_, ok := i.(bool)
if !ok {
return fmt.Errorf("invalid parameter type: %T", i)
Expand Down
10 changes: 5 additions & 5 deletions modules/apps/transfer/types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,22 @@ func DefaultParams() Params {

// Validate all ibc-transfer module parameters
func (p Params) Validate() error {
if err := validateEnabled(p.SendEnabled); err != nil {
if err := validateEnabledType(p.SendEnabled); err != nil {
return err
}

return validateEnabled(p.ReceiveEnabled)
return validateEnabledType(p.ReceiveEnabled)
}

// ParamSetPairs implements params.ParamSet
func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs {
return paramtypes.ParamSetPairs{
paramtypes.NewParamSetPair(KeySendEnabled, p.SendEnabled, validateEnabled),
paramtypes.NewParamSetPair(KeyReceiveEnabled, p.ReceiveEnabled, validateEnabled),
paramtypes.NewParamSetPair(KeySendEnabled, p.SendEnabled, validateEnabledType),
paramtypes.NewParamSetPair(KeyReceiveEnabled, p.ReceiveEnabled, validateEnabledType),
}
}

func validateEnabled(i interface{}) error {
func validateEnabledType(i interface{}) error {
_, ok := i.(bool)
if !ok {
return fmt.Errorf("invalid parameter type: %T", i)
Expand Down