Skip to content

Commit

Permalink
Merge pull request cosmos#404 from agoric-labs/jimlarson-lint
Browse files Browse the repository at this point in the history
chore: silence some lint warnings
  • Loading branch information
JimLarson authored Mar 5, 2024
2 parents 9c20eac + e96708b commit a0154d6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
7 changes: 4 additions & 3 deletions x/auth/vesting/cmd/vestcalc/vestcalc.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"strings"
"time"

sdkmath "cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth/vesting/client/cli"
)
Expand All @@ -18,15 +19,15 @@ import (

// divide returns the division of total as evenly as possible.
// Divisor must be 1 or greater and total must be nonnegative.
func divide(total sdk.Int, divisor int) ([]sdk.Int, error) {
func divide(total sdkmath.Int, divisor int) ([]sdkmath.Int, error) {
if divisor < 1 {
return nil, fmt.Errorf("divisions must be 1 or greater")
}
div64 := int64(divisor)
if total.IsNegative() {
return nil, fmt.Errorf("total must be nonnegative")
}
divisions := make([]sdk.Int, divisor)
divisions := make([]sdkmath.Int, divisor)

// Ideally we could compute total of the first i divisions as
// cumulative(i) = floor((total * i) / divisor)
Expand Down Expand Up @@ -68,7 +69,7 @@ func divideCoins(coins sdk.Coins, divisor int) ([]sdk.Coins, error) {
return nil, fmt.Errorf("divisor must be 1 or greater")
}
divisions := make([]sdk.Coins, divisor)
divisionsByDenom := make(map[string][]sdk.Int)
divisionsByDenom := make(map[string][]sdkmath.Int)
for _, coin := range coins {
dividedCoin, err := divide(coin.Amount, divisor)
if err != nil {
Expand Down
3 changes: 3 additions & 0 deletions x/auth/vesting/types/vesting_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -1087,6 +1087,9 @@ func (va *BaseVestingAccount) forceTransfer(ctx sdk.Context, amt sdk.Coins, dest
gotCoins = gotCoins.Sub(decrVesting...)
ak.SetAccount(ctx, va)
// gotCoins should be zero at this point, unless DF+DV was not accurate
if !gotCoins.IsZero() {
ctx.Logger().Error("more staked than tracked in vesting delegation - %s undercounted by %s", va.Address, gotCoins)
}

// If we've transferred everything and still haven't transferred the desired clawback amount,
// then the account must have lost some unvested tokens from slashing.
Expand Down
2 changes: 1 addition & 1 deletion x/staking/keeper/delegation.go
Original file line number Diff line number Diff line change
Expand Up @@ -976,7 +976,7 @@ func (k Keeper) Undelegate(
// TransferUnbonding changes the ownership of UnbondingDelegation entries
// until the desired number of tokens have changed hands. Returns the actual
// number of tokens transferred.
func (k Keeper) TransferUnbonding(ctx sdk.Context, fromAddr, toAddr sdk.AccAddress, valAddr sdk.ValAddress, wantAmt sdk.Int) sdk.Int {
func (k Keeper) TransferUnbonding(ctx sdk.Context, fromAddr, toAddr sdk.AccAddress, valAddr sdk.ValAddress, wantAmt math.Int) math.Int {
transferred := sdk.ZeroInt()
ubdFrom, found := k.GetUnbondingDelegation(ctx, fromAddr, valAddr)
if !found {
Expand Down

0 comments on commit a0154d6

Please sign in to comment.