Skip to content

Commit 9234bd9

Browse files
committed
fix: genesis state validation
1 parent d983310 commit 9234bd9

File tree

5 files changed

+30
-1
lines changed

5 files changed

+30
-1
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ Contains all the PRs that improved the code without changing the behaviors.
3333
- fixed old expirations are not removed
3434
- fixed not delegate being used in msg open contract
3535
- fixed the recipient’s IsTransferable field is overwritten to false in MsgClaimThorchain
36+
- fixed genesis state validation
3637

3738
# v1.0.5-Prerelease
3839
### Added

x/arkeo/types/errors.go

+2
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,6 @@ var (
4141
ErrInvariantMaxSupply = errors.Register(ModuleName, 32, "max supply invariant")
4242
ErrInvalidAuthorization = errors.Register(ModuleName, 33, "invalid authorization")
4343
ErrInvalidVersion = errors.Register(ModuleName, 34, "version cannot be zero or lower")
44+
ErrInvalidBlocksPerYear = errors.Register(ModuleName, 37, "blocks per year cannot be zero or lower")
45+
ErrInvalidEmissionCurve = errors.Register(ModuleName, 38, "emissionCurve set is invalid")
4446
)

x/arkeo/types/genesis_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ func TestGenesisState_Validate(t *testing.T) {
2020
valid: true,
2121
},
2222
{
23-
desc: "valid genesis state",
23+
desc: "valid genesis state",
2424
genState: &types.GenesisState{
25+
Params: types.DefaultParams(),
2526

2627
// this line is used by starport scaffolding # types/genesis/validField
2728
},

x/arkeo/types/params.go

+9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package types
22

33
import (
4+
"cosmossdk.io/errors"
45
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
56
"gopkg.in/yaml.v2"
67
)
@@ -32,6 +33,14 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs {
3233

3334
// Validate validates the set of params
3435
func (p Params) Validate() error {
36+
if p.BlockPerYear <= 0 {
37+
return errors.Wrap(ErrInvalidBlocksPerYear, "BlockPerYear must be greater than zero")
38+
}
39+
40+
if p.EmissionCurve <= 0 {
41+
return errors.Wrap(ErrInvalidEmissionCurve, "EmissionCurve must be greater than ")
42+
}
43+
3544
return nil
3645
}
3746

x/claim/types/params.go

+16
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,22 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs {
6666

6767
// Validate validates the set of params
6868
func (p Params) Validate() error {
69+
if err := validateClaimDenom(p.ClaimDenom); err != nil {
70+
return err
71+
}
72+
73+
if err := validateAirdropStartTime(p.AirdropStartTime); err != nil {
74+
return err
75+
}
76+
77+
if err := validateDurationUntilDecay(p.DurationUntilDecay); err != nil {
78+
return err
79+
}
80+
81+
if err := validateDurationOfDecay(p.DurationOfDecay); err != nil {
82+
return err
83+
}
84+
6985
return nil
7086
}
7187

0 commit comments

Comments
 (0)