laconicd/x/bond/params.go
Isha Venikar f23f691646 Add lint config and fix lint errors (#7)
* Add config file for linter

* Fix lint errors

* Fix gofumpt errors

* Fix pre-allocate slices lint error

* Remove unused lint rule

* Disable style check ID error

* Add gomodguard section in yml file

* Remove trailing white spaces

* Remove unnecessary comments

---------

Co-authored-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
2024-07-16 09:25:39 +05:30

44 lines
937 B
Go

package bond
import (
"errors"
fmt "fmt"
sdkmath "cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"
)
// DefaultMaxBondAmountTokens are the default parameter values.
var DefaultMaxBondAmountTokens = sdkmath.NewInt(100000000000)
func NewParams(maxBondAmount sdk.Coin) Params {
return Params{MaxBondAmount: maxBondAmount}
}
// DefaultParams returns default module parameters
func DefaultParams() Params {
return NewParams(sdk.NewCoin(sdk.DefaultBondDenom, DefaultMaxBondAmountTokens))
}
// Validate checks that the parameters have valid values
func (p Params) Validate() error {
if err := validateMaxBondAmount(p.MaxBondAmount); err != nil {
return err
}
return nil
}
func validateMaxBondAmount(i interface{}) error {
v, ok := i.(sdk.Coin)
if !ok {
return fmt.Errorf("invalid parameter type: %T", i)
}
if v.Amount.IsNegative() {
return errors.New("max bond amount must be positive")
}
return nil
}