-
Notifications
You must be signed in to change notification settings - Fork 47
/
params.go
51 lines (41 loc) · 1023 Bytes
/
params.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package types
import (
"fmt"
sdkmath "cosmossdk.io/math"
)
var (
DefaultTransferOutRelayerFeeParam = sdkmath.NewInt(250000000000000) // 0.00025
DefaultTransferOutAckRelayerFeeParam = sdkmath.NewInt(0)
)
// DefaultParams returns a default set of parameters
func DefaultParams() Params {
return Params{
TransferOutRelayerFee: DefaultTransferOutRelayerFeeParam,
TransferOutAckRelayerFee: DefaultTransferOutAckRelayerFeeParam,
}
}
// Validate validates the set of params
func (p Params) Validate() error {
err := validateRelayerFee(p.TransferOutRelayerFee)
if err != nil {
return err
}
err = validateRelayerFee(p.TransferOutAckRelayerFee)
if err != nil {
return err
}
return nil
}
func validateRelayerFee(i interface{}) error {
fee, ok := i.(sdkmath.Int)
if !ok {
return fmt.Errorf("invalid parameter type: %T", i)
}
if fee.IsNil() {
return fmt.Errorf("relay fee should not be nil")
}
if fee.IsNegative() {
return fmt.Errorf("relay fee should not less than 0")
}
return nil
}