Skip to content

Commit

Permalink
fmt pass
Browse files Browse the repository at this point in the history
  • Loading branch information
giunatale committed Sep 24, 2024
1 parent 86031e6 commit 3a9f71f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
6 changes: 4 additions & 2 deletions x/gov/keeper/governor.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package keeper

import (
"cosmossdk.io/math"

sdk "github.com/cosmos/cosmos-sdk/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"

Expand Down Expand Up @@ -117,7 +119,7 @@ func (k Keeper) IterateMaxGovernorsByGovernancePower(ctx sdk.Context, cb func(in
}
}

func (k Keeper) getGovernorBondedTokens(ctx sdk.Context, govAddr types.GovernorAddress) (bondedTokens sdk.Int) {
func (k Keeper) getGovernorBondedTokens(ctx sdk.Context, govAddr types.GovernorAddress) (bondedTokens math.Int) {
bondedTokens = sdk.ZeroInt()
addr := sdk.AccAddress(govAddr)
k.sk.IterateDelegations(ctx, addr, func(_ int64, delegation stakingtypes.DelegationI) (stop bool) {
Expand All @@ -134,7 +136,7 @@ func (k Keeper) getGovernorBondedTokens(ctx sdk.Context, govAddr types.GovernorA
}

func (k Keeper) ValidateGovernorMinSelfDelegation(ctx sdk.Context, governor v1.Governor) bool {
minGovernorSelfDelegation, _ := sdk.NewIntFromString(k.GetParams(ctx).MinGovernorSelfDelegation)
minGovernorSelfDelegation, _ := math.NewIntFromString(k.GetParams(ctx).MinGovernorSelfDelegation)
bondedTokens := k.getGovernorBondedTokens(ctx, governor.GetAddress())
delAddr := sdk.AccAddress(governor.GetAddress())

Expand Down
2 changes: 1 addition & 1 deletion x/gov/keeper/invariants.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func GovernorsVotingPowerInvariant(keeper *Keeper, sk types.StakingKeeper) sdk.I
func GovernorsDelegationsInvariant(keeper *Keeper, sk types.StakingKeeper) sdk.Invariant {
return func(ctx sdk.Context) (string, bool) {
var (
broken bool = false
broken = false
invariantStr string
)

Expand Down
6 changes: 3 additions & 3 deletions x/gov/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import (
"fmt"

"cosmossdk.io/errors"
"cosmossdk.io/math"

sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors1 "github.com/cosmos/cosmos-sdk/types/errors"

"github.com/atomone-hub/atomone/x/gov/types"
govtypes "github.com/atomone-hub/atomone/x/gov/types"
v1 "github.com/atomone-hub/atomone/x/gov/types/v1"
"github.com/atomone-hub/atomone/x/gov/types/v1beta1"
Expand Down Expand Up @@ -223,10 +223,10 @@ func (k msgServer) CreateGovernor(goCtx context.Context, msg *v1.MsgCreateGovern
return nil, err
}

minSelfDelegation, _ := sdk.NewIntFromString(k.GetParams(ctx).MinGovernorSelfDelegation)
minSelfDelegation, _ := math.NewIntFromString(k.GetParams(ctx).MinGovernorSelfDelegation)
bondedTokens := k.getGovernorBondedTokens(ctx, govAddr)
if bondedTokens.LT(minSelfDelegation) {
types.ErrInsufficientGovernorDelegation.Wrapf("minimum self-delegation required: %s, total bonded tokens: %s", minSelfDelegation, bondedTokens)
return nil, govtypes.ErrInsufficientGovernorDelegation.Wrapf("minimum self-delegation required: %s, total bonded tokens: %s", minSelfDelegation, bondedTokens)
}

governor, err := v1.NewGovernor(govAddr.String(), msg.Description, ctx.BlockTime())
Expand Down
6 changes: 3 additions & 3 deletions x/gov/simulation/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ func GenQuorumCheckCount(r *rand.Rand) uint64 {
}

// GenMinGovernorSelfDelegation returns a randomized MinGovernorSelfDelegation
func GenMinGovernorSelfDelegation(r *rand.Rand) sdk.Int {
return sdk.NewInt(int64(simulation.RandIntBetween(r, 1000, 10000000)))
func GenMinGovernorSelfDelegation(r *rand.Rand) math.Int {
return math.NewInt(int64(simulation.RandIntBetween(r, 1000, 10000000)))
}

// RandomizedGenState generates a random GenesisState for gov
Expand Down Expand Up @@ -194,7 +194,7 @@ func RandomizedGenState(simState *module.SimulationState) {
func(r *rand.Rand) { governorStatusChangePeriod = GenDepositParamsDepositPeriod(r) },
)

var minGovernorSelfDelegation sdk.Int
var minGovernorSelfDelegation math.Int
simState.AppParams.GetOrGenerate(
simState.Cdc, MinGovernorSelfDelegation, &minGovernorSelfDelegation, simState.Rand,
func(r *rand.Rand) { minGovernorSelfDelegation = GenMinGovernorSelfDelegation(r) },
Expand Down

0 comments on commit 3a9f71f

Please sign in to comment.