Skip to content

Commit

Permalink
add check bondweight
Browse files Browse the repository at this point in the history
  • Loading branch information
GNaD13 committed Feb 28, 2024
1 parent 436524e commit e43677d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
14 changes: 12 additions & 2 deletions x/multi-staking/keeper/proposal.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ func (k Keeper) AddMultiStakingCoinProposal(
return fmt.Errorf("Error MultiStakingCoin %s already exist", p.Denom) //nolint:stylecheck
}

k.SetBondWeight(ctx, p.Denom, *p.BondWeight)
bondWeight := *p.BondWeight
if bondWeight.LTE(sdk.ZeroDec()) {
return fmt.Errorf("Error MultiStakingCoin BondWeight %s invalid", bondWeight) //nolint:stylecheck
}

k.SetBondWeight(ctx, p.Denom, bondWeight)

ctx.EventManager().EmitEvent(
sdk.NewEvent(
Expand All @@ -39,7 +44,12 @@ func (k Keeper) BondWeightProposal(
return fmt.Errorf("Error MultiStakingCoin %s not found", p.Denom) //nolint:stylecheck
}

k.SetBondWeight(ctx, p.Denom, *p.UpdatedBondWeight)
bondWeight := *p.UpdatedBondWeight
if bondWeight.LTE(sdk.ZeroDec()) {
return fmt.Errorf("Error MultiStakingCoin BondWeight %s invalid", bondWeight) //nolint:stylecheck
}

k.SetBondWeight(ctx, p.Denom, bondWeight)

ctx.EventManager().EmitEvent(
sdk.NewEvent(
Expand Down
2 changes: 1 addition & 1 deletion x/multi-staking/keeper/proposal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
govv1types "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
)

func (suite *KeeperTestSuite) TestAddHostZoneProposal() {
func (suite *KeeperTestSuite) TestAddMultiStakingCoinProposal() {
bondWeight := sdk.NewDec(1)

for _, tc := range []struct {
Expand Down

0 comments on commit e43677d

Please sign in to comment.