From 3a9f71f6ad0cce228e16341d7487062721b99efa Mon Sep 17 00:00:00 2001 From: Giuseppe Natale <12249307+giunatale@users.noreply.github.com> Date: Tue, 24 Sep 2024 18:27:06 +0200 Subject: [PATCH] fmt pass --- x/gov/keeper/governor.go | 6 ++++-- x/gov/keeper/invariants.go | 2 +- x/gov/keeper/msg_server.go | 6 +++--- x/gov/simulation/genesis.go | 6 +++--- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/x/gov/keeper/governor.go b/x/gov/keeper/governor.go index 50a2eade..5b646181 100644 --- a/x/gov/keeper/governor.go +++ b/x/gov/keeper/governor.go @@ -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" @@ -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) { @@ -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()) diff --git a/x/gov/keeper/invariants.go b/x/gov/keeper/invariants.go index 45891f2e..2955ed82 100644 --- a/x/gov/keeper/invariants.go +++ b/x/gov/keeper/invariants.go @@ -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 ) diff --git a/x/gov/keeper/msg_server.go b/x/gov/keeper/msg_server.go index 55a43ac2..087d1031 100644 --- a/x/gov/keeper/msg_server.go +++ b/x/gov/keeper/msg_server.go @@ -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" @@ -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()) diff --git a/x/gov/simulation/genesis.go b/x/gov/simulation/genesis.go index 4306acda..10aa98c3 100644 --- a/x/gov/simulation/genesis.go +++ b/x/gov/simulation/genesis.go @@ -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 @@ -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) },