2019-06-05 16:26:17 -07:00
|
|
|
package types
|
|
|
|
|
|
|
|
import (
|
2019-12-10 08:48:57 -08:00
|
|
|
"fmt"
|
|
|
|
|
2019-06-05 16:26:17 -07:00
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
2020-02-19 03:52:20 -08:00
|
|
|
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
|
2019-06-05 16:26:17 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
// Default parameter namespace
|
|
|
|
const (
|
|
|
|
DefaultParamspace = ModuleName
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
// key for constant fee parameter
|
|
|
|
ParamStoreKeyConstantFee = []byte("ConstantFee")
|
|
|
|
)
|
|
|
|
|
|
|
|
// type declaration for parameters
|
2020-02-19 03:52:20 -08:00
|
|
|
func ParamKeyTable() paramtypes.KeyTable {
|
|
|
|
return paramtypes.NewKeyTable(
|
|
|
|
paramtypes.NewParamSetPair(ParamStoreKeyConstantFee, sdk.Coin{}, validateConstantFee),
|
2019-06-05 16:26:17 -07:00
|
|
|
)
|
|
|
|
}
|
2019-12-10 08:48:57 -08:00
|
|
|
|
|
|
|
func validateConstantFee(i interface{}) error {
|
|
|
|
v, ok := i.(sdk.Coin)
|
|
|
|
if !ok {
|
|
|
|
return fmt.Errorf("invalid parameter type: %T", i)
|
|
|
|
}
|
|
|
|
|
|
|
|
if !v.IsValid() {
|
|
|
|
return fmt.Errorf("invalid constant fee: %s", v)
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|