Skip to content

Commit

Permalink
fix: genesis state validation
Browse files Browse the repository at this point in the history
  • Loading branch information
shreyasbhat0 committed Feb 18, 2025
1 parent d983310 commit 9234bd9
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Contains all the PRs that improved the code without changing the behaviors.
- fixed old expirations are not removed
- fixed not delegate being used in msg open contract
- fixed the recipient’s IsTransferable field is overwritten to false in MsgClaimThorchain
- fixed genesis state validation

# v1.0.5-Prerelease
### Added
Expand Down
2 changes: 2 additions & 0 deletions x/arkeo/types/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,6 @@ var (
ErrInvariantMaxSupply = errors.Register(ModuleName, 32, "max supply invariant")
ErrInvalidAuthorization = errors.Register(ModuleName, 33, "invalid authorization")
ErrInvalidVersion = errors.Register(ModuleName, 34, "version cannot be zero or lower")
ErrInvalidBlocksPerYear = errors.Register(ModuleName, 37, "blocks per year cannot be zero or lower")
ErrInvalidEmissionCurve = errors.Register(ModuleName, 38, "emissionCurve set is invalid")
)
3 changes: 2 additions & 1 deletion x/arkeo/types/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ func TestGenesisState_Validate(t *testing.T) {
valid: true,
},
{
desc: "valid genesis state",
desc: "valid genesis state",
genState: &types.GenesisState{
Params: types.DefaultParams(),

// this line is used by starport scaffolding # types/genesis/validField
},
Expand Down
9 changes: 9 additions & 0 deletions x/arkeo/types/params.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package types

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

// Validate validates the set of params
func (p Params) Validate() error {
if p.BlockPerYear <= 0 {
return errors.Wrap(ErrInvalidBlocksPerYear, "BlockPerYear must be greater than zero")
}

if p.EmissionCurve <= 0 {
return errors.Wrap(ErrInvalidEmissionCurve, "EmissionCurve must be greater than ")
}

return nil
}

Expand Down
16 changes: 16 additions & 0 deletions x/claim/types/params.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,22 @@ func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs {

// Validate validates the set of params
func (p Params) Validate() error {
if err := validateClaimDenom(p.ClaimDenom); err != nil {
return err
}

if err := validateAirdropStartTime(p.AirdropStartTime); err != nil {
return err
}

if err := validateDurationUntilDecay(p.DurationUntilDecay); err != nil {
return err
}

if err := validateDurationOfDecay(p.DurationOfDecay); err != nil {
return err
}

return nil
}

Expand Down

0 comments on commit 9234bd9

Please sign in to comment.