laconicd/x/bond/params.go
Prathamesh Musale 8e12b9dcf5
Some checks failed
Integration Tests / test-integration (pull_request) Failing after 3m12s
Build / build (pull_request) Successful in 3m18s
E2E Tests / test-e2e (pull_request) Failing after 3m27s
Unit Tests / test-unit (pull_request) Successful in 2m24s
SDK Tests / sdk_tests_nameservice_expiry (pull_request) Failing after 8m21s
SDK Tests / sdk_tests (pull_request) Failing after 6m57s
SDK Tests / sdk_tests_auctions (pull_request) Failing after 13m22s
Setup alnt and lnt coin denoms
2024-07-30 11:02:54 +05:30

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
}