Skip to content

Commit

Permalink
more lints
Browse files Browse the repository at this point in the history
  • Loading branch information
czarcas7ic committed Jan 31, 2024
1 parent f1306c6 commit fc23c2e
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 20 deletions.
3 changes: 1 addition & 2 deletions x/auth/vesting/client/cli/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package cli
import (
"encoding/json"
"fmt"
"io/ioutil"
"os"
"strconv"
"time"
Expand Down Expand Up @@ -221,7 +220,7 @@ func NewMsgCreatePeriodicVestingAccountCmd() *cobra.Command {
// readScheduleFile reads the file at path and unmarshals it to get the schedule.
// Returns start time, periods, and error.
func readScheduleFile(path string) (int64, []types.Period, error) {
contents, err := ioutil.ReadFile(path)
contents, err := os.ReadFile(path)

Check failure

Code scanning / gosec

Potential file inclusion via variable Error

Potential file inclusion via variable
if err != nil {
return 0, nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion x/auth/vesting/types/period.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ func ConjunctPeriods(startP, startQ int64, periodsP, periodsQ []Period) (startTi
}

endTime = time
return
return startTime, endTime, merged
}

// AlignSchedules rewrites the first period length to align the two arguments to the same start time,
Expand Down
13 changes: 6 additions & 7 deletions x/auth/vesting/types/vesting_account.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/cosmos/cosmos-sdk/x/auth/vesting/exported"
vestexported "github.com/cosmos/cosmos-sdk/x/auth/vesting/exported"
)

Expand Down Expand Up @@ -755,7 +754,7 @@ func NewClawbackGrantAction(
grantStartTime int64,
grantLockupPeriods, grantVestingPeriods []Period,
grantCoins sdk.Coins,
) exported.AddGrantAction {
) vestexported.AddGrantAction {
return clawbackGrantAction{
funderAddress: funderAddress,
grantStartTime: grantStartTime,
Expand All @@ -765,7 +764,7 @@ func NewClawbackGrantAction(
}
}

func (cga clawbackGrantAction) AddToAccount(ctx sdk.Context, rawAccount exported.VestingAccount) error {
func (cga clawbackGrantAction) AddToAccount(ctx sdk.Context, rawAccount vestexported.VestingAccount) error {
cva, ok := rawAccount.(*ClawbackVestingAccount)
if !ok {
return fmt.Errorf("expected *ClawbackVestingAccount, got %T", rawAccount)
Expand All @@ -781,7 +780,7 @@ func (cga clawbackGrantAction) AddToAccount(ctx sdk.Context, rawAccount exported
return nil
}

func (va *ClawbackVestingAccount) AddGrant(ctx sdk.Context, action exported.AddGrantAction) error {
func (va *ClawbackVestingAccount) AddGrant(ctx sdk.Context, action vestexported.AddGrantAction) error {
return action.AddToAccount(ctx, va)
}

Expand Down Expand Up @@ -865,7 +864,7 @@ type clawbackAction struct {
bk BankKeeper
}

func NewClawbackAction(requestor, dest sdk.AccAddress, ak AccountKeeper, bk BankKeeper) exported.ClawbackAction {
func NewClawbackAction(requestor, dest sdk.AccAddress, ak AccountKeeper, bk BankKeeper) vestexported.ClawbackAction {
return clawbackAction{
requestor: requestor,
dest: dest,
Expand All @@ -874,7 +873,7 @@ func NewClawbackAction(requestor, dest sdk.AccAddress, ak AccountKeeper, bk Bank
}
}

func (ca clawbackAction) TakeFromAccount(ctx sdk.Context, rawAccount exported.VestingAccount) error {
func (ca clawbackAction) TakeFromAccount(ctx sdk.Context, rawAccount vestexported.VestingAccount) error {
cva, ok := rawAccount.(*ClawbackVestingAccount)
if !ok {
return fmt.Errorf("clawback expects *ClawbackVestingAccount, got %T", rawAccount)
Expand All @@ -885,7 +884,7 @@ func (ca clawbackAction) TakeFromAccount(ctx sdk.Context, rawAccount exported.Ve
return cva.clawback(ctx, ca.dest, ca.ak, ca.bk)
}

func (va *ClawbackVestingAccount) Clawback(ctx sdk.Context, action exported.ClawbackAction) error {
func (va *ClawbackVestingAccount) Clawback(ctx sdk.Context, action vestexported.ClawbackAction) error {
return action.TakeFromAccount(ctx, va)
}

Expand Down
4 changes: 2 additions & 2 deletions x/bank/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ type Keeper interface {
HasSupply(ctx sdk.Context, denom string) bool
GetPaginatedTotalSupply(ctx sdk.Context, pagination *query.PageRequest) (sdk.Coins, *query.PageResponse, error)
IterateTotalSupply(ctx sdk.Context, cb func(sdk.Coin) bool)
GetSupplyOffset(ctx sdk.Context, denom string) sdk.Int
AddSupplyOffset(ctx sdk.Context, denom string, offsetAmount sdk.Int)
GetSupplyOffset(ctx sdk.Context, denom string) math.Int
AddSupplyOffset(ctx sdk.Context, denom string, offsetAmount math.Int)
GetSupplyWithOffset(ctx sdk.Context, denom string) sdk.Coin
GetPaginatedTotalSupplyWithOffsets(ctx sdk.Context, pagination *query.PageRequest) (sdk.Coins, *query.PageResponse, error)
IterateTotalSupplyWithOffsets(ctx sdk.Context, cb func(sdk.Coin) bool)
Expand Down
4 changes: 2 additions & 2 deletions x/bank/keeper/send.go
Original file line number Diff line number Diff line change
Expand Up @@ -440,8 +440,8 @@ func (k BaseSendKeeper) initBalances(ctx sdk.Context, addr sdk.AccAddress, balan
return nil
}

// 2 blocks after osmosis first epoch
var osmosisFirstEpochHeight = int64(12834361)
// // 2 blocks after osmosis first epoch
// var osmosisFirstEpochHeight = int64(12834361)

// setBalance sets the coin balance for an account by address.
func (k BaseSendKeeper) setBalance(ctx sdk.Context, addr sdk.AccAddress, balance sdk.Coin) error {
Expand Down
13 changes: 7 additions & 6 deletions x/bank/keeper/supply_offset.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ package keeper
import (
"fmt"

"cosmossdk.io/math"
"github.com/cosmos/cosmos-sdk/store/prefix"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/query"
"github.com/cosmos/cosmos-sdk/x/bank/types"
)

// GetSupplyOffset retrieves the SupplyOffset from store for a specific denom
func (k BaseViewKeeper) GetSupplyOffset(ctx sdk.Context, denom string) sdk.Int {
func (k BaseViewKeeper) GetSupplyOffset(ctx sdk.Context, denom string) math.Int {
store := ctx.KVStore(k.storeKey)
supplyOffsetStore := prefix.NewStore(store, types.SupplyOffsetKey)

Expand All @@ -19,7 +20,7 @@ func (k BaseViewKeeper) GetSupplyOffset(ctx sdk.Context, denom string) sdk.Int {
return sdk.NewInt(0)
}

var amount sdk.Int
var amount math.Int
err := amount.Unmarshal(bz)
if err != nil {
panic(fmt.Errorf("unable to unmarshal supply offset value %v", err))
Expand All @@ -29,7 +30,7 @@ func (k BaseViewKeeper) GetSupplyOffset(ctx sdk.Context, denom string) sdk.Int {
}

// setSupplyOffset sets the supply offset for the given denom
func (k BaseKeeper) setSupplyOffset(ctx sdk.Context, denom string, offsetAmount sdk.Int) {
func (k BaseKeeper) setSupplyOffset(ctx sdk.Context, denom string, offsetAmount math.Int) {
intBytes, err := offsetAmount.Marshal()
if err != nil {
panic(fmt.Errorf("unable to marshal amount value %v", err))
Expand All @@ -47,7 +48,7 @@ func (k BaseKeeper) setSupplyOffset(ctx sdk.Context, denom string, offsetAmount
}

// AddSupplyOffset adjusts the current supply offset of a denom by the inputted offsetAmount
func (k BaseKeeper) AddSupplyOffset(ctx sdk.Context, denom string, offsetAmount sdk.Int) {
func (k BaseKeeper) AddSupplyOffset(ctx sdk.Context, denom string, offsetAmount math.Int) {
k.setSupplyOffset(ctx, denom, k.GetSupplyOffset(ctx, denom).Add(offsetAmount))
}

Expand Down Expand Up @@ -75,7 +76,7 @@ func (k BaseKeeper) GetPaginatedTotalSupplyWithOffsets(ctx sdk.Context, paginati
pageRes, err := query.Paginate(supplyStore, pagination, func(key, value []byte) error {
denom := string(key)

var amount sdk.Int
var amount math.Int
err := amount.Unmarshal(value)
if err != nil {
return fmt.Errorf("unable to convert amount string to Int %v", err)
Expand Down Expand Up @@ -105,7 +106,7 @@ func (k BaseViewKeeper) IterateTotalSupplyWithOffsets(ctx sdk.Context, cb func(s
defer iterator.Close()

for ; iterator.Valid(); iterator.Next() {
var amount sdk.Int
var amount math.Int
err := amount.Unmarshal(iterator.Value())
if err != nil {
panic(fmt.Errorf("unable to unmarshal supply value %v", err))
Expand Down

0 comments on commit fc23c2e

Please sign in to comment.