Prathamesh Musale
c162396298
All checks were successful
Integration Tests / test-integration (push) Successful in 2m43s
Unit Tests / test-unit (push) Successful in 3m27s
E2E Tests / test-e2e (push) Successful in 2m48s
SDK Tests / sdk_tests_nameservice_expiry (push) Successful in 7m57s
SDK Tests / sdk_tests (push) Successful in 8m59s
SDK Tests / sdk_tests_auctions (push) Successful in 13m4s
Part of [laconicd testnet validator enrollment](https://www.notion.so/laconicd-testnet-validator-enrollment-6fc1d3cafcc64fef8c5ed3affa27c675) Co-authored-by: zramsay <zach@bluecollarcoding.ca> Reviewed-on: #46 Co-authored-by: Prathamesh Musale <prathamesh.musale0@gmail.com> Co-committed-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
44 lines
952 B
Go
44 lines
952 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(1000000000000) // 10^12 alnt
|
|
|
|
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
|
|
}
|