forked from cerc-io/laconicd
Part of https://www.notion.so/Multiple-tokens-support-and-disable-transfers-for-LSTAKE-1f2a6b22d47280269f87df3fe03e8d64 - Add base token with denoms `alps` and `lps` (`1 lps = 10^18 alps`) - Keep `alnt` as the staking token and for laconic module ops - Accept tx fees only in `alnt` Reviewed-on: cerc-io/laconicd#68 Co-authored-by: Prathamesh Musale <prathamesh.musale0@gmail.com> Co-committed-by: Prathamesh Musale <prathamesh.musale0@gmail.com>
45 lines
984 B
Go
45 lines
984 B
Go
package bond
|
|
|
|
import (
|
|
"errors"
|
|
fmt "fmt"
|
|
|
|
sdkmath "cosmossdk.io/math"
|
|
"git.vdb.to/cerc-io/laconicd/app/params"
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
)
|
|
|
|
// DefaultMaxBondAmountTokens are the default parameter values.
|
|
var DefaultMaxBondAmountTokens = sdkmath.NewInt(1000000000000) // 10^12
|
|
|
|
func NewParams(maxBondAmount sdk.Coin) Params {
|
|
return Params{MaxBondAmount: maxBondAmount}
|
|
}
|
|
|
|
// DefaultParams returns default module parameters
|
|
func DefaultParams() Params {
|
|
return NewParams(sdk.NewCoin(params.CoinUnit, 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
|
|
}
|