Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
robert-zaremba committed Apr 16, 2024
1 parent cd5cbf2 commit 0ece567
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 16 deletions.
7 changes: 0 additions & 7 deletions x/auction/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package keeper

import (
"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/store"
prefixstore "github.com/cosmos/cosmos-sdk/store/prefix"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"

Expand Down Expand Up @@ -53,14 +51,9 @@ type Keeper struct {
bank auction.BankKeeper
ugov ugov.WithEmergencyGroup

// TODO: ctx should be removed when we migrate leverage and oracle
ctx *sdk.Context
}

func (k Keeper) prefixStore(prefix []byte) store.KVStore {
return prefixstore.NewStore(k.store, prefix)
}

func (k Keeper) sendCoins(from, to sdk.AccAddress, amount sdk.Coins) error {
return k.bank.SendCoins(*k.ctx, from, to, amount)

Check warning on line 58 in x/auction/keeper/keeper.go

View check run for this annotation

Codecov / codecov/patch

x/auction/keeper/keeper.go#L57-L58

Added lines #L57 - L58 were not covered by tests
}
22 changes: 13 additions & 9 deletions x/oracle/keeper/historic_price.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ import (
"github.com/umee-network/umee/v6/x/oracle/types"
)

func wrapDenomError(err error, denom string) error {
return errors.Wrap(err, "denom: "+denom)

Check warning on line 13 in x/oracle/keeper/historic_price.go

View check run for this annotation

Codecov / codecov/patch

x/oracle/keeper/historic_price.go#L12-L13

Added lines #L12 - L13 were not covered by tests
}

// HistoricMedians returns a list of a given denom's last numStamps medians.
func (k Keeper) HistoricMedians(
ctx sdk.Context,
Expand Down Expand Up @@ -45,7 +49,7 @@ func (k Keeper) CalcAndSetHistoricMedian(

median, err := decmath.Median(historicPrices)
if err != nil {
return errors.Wrap(err, "denom: "+denom)
return wrapDenomError(err, denom)

Check warning on line 52 in x/oracle/keeper/historic_price.go

View check run for this annotation

Codecov / codecov/patch

x/oracle/keeper/historic_price.go#L52

Added line #L52 was not covered by tests
}

block := uint64(ctx.BlockHeight())
Expand Down Expand Up @@ -75,7 +79,7 @@ func (k Keeper) HistoricMedianDeviation(
blockNum := uint64(ctx.BlockHeight()) - blockDiff
bz := store.Get(types.KeyMedianDeviation(denom, blockNum))
if bz == nil {
return types.Price{}, types.ErrNoMedianDeviation.Wrap("denom: " + denom)
return types.Price{}, wrapDenomError(types.ErrNoMedianDeviation, denom)

Check warning on line 82 in x/oracle/keeper/historic_price.go

View check run for this annotation

Codecov / codecov/patch

x/oracle/keeper/historic_price.go#L82

Added line #L82 was not covered by tests
}

decProto := sdk.DecProto{}
Expand All @@ -93,14 +97,14 @@ func (k Keeper) WithinHistoricMedianDeviation(
// get latest median
medians := k.HistoricMedians(ctx, denom, 1)
if len(medians) == 0 {
return false, types.ErrNoMedian.Wrap("denom: " + denom)
return false, wrapDenomError(types.ErrNoMedian, denom)

Check warning on line 100 in x/oracle/keeper/historic_price.go

View check run for this annotation

Codecov / codecov/patch

x/oracle/keeper/historic_price.go#L100

Added line #L100 was not covered by tests
}
median := medians[0].ExchangeRateTuple.ExchangeRate

// get latest historic price
prices := k.historicPrices(ctx, denom, 1)
if len(prices) == 0 {
return false, types.ErrNoHistoricPrice.Wrap("denom: " + denom)
return false, wrapDenomError(types.ErrNoHistoricPrice, denom)

Check warning on line 107 in x/oracle/keeper/historic_price.go

View check run for this annotation

Codecov / codecov/patch

x/oracle/keeper/historic_price.go#L107

Added line #L107 was not covered by tests
}
price := prices[0]

Expand All @@ -122,7 +126,7 @@ func (k Keeper) calcAndSetHistoricMedianDeviation(
) error {
medianDeviation, err := decmath.MedianDeviation(median, prices)
if err != nil {
return errors.Wrap(err, "denom: "+denom)
return wrapDenomError(err, denom)

Check warning on line 129 in x/oracle/keeper/historic_price.go

View check run for this annotation

Codecov / codecov/patch

x/oracle/keeper/historic_price.go#L129

Added line #L129 was not covered by tests
}

block := uint64(ctx.BlockHeight())
Expand Down Expand Up @@ -155,7 +159,7 @@ func (k Keeper) MedianOfHistoricMedians(
}
median, err := decmath.Median(medians.Decs())
if err != nil {
return sdk.ZeroDec(), 0, errors.Wrap(err, "denom: "+denom)
return sdk.ZeroDec(), 0, wrapDenomError(err, denom)

Check warning on line 162 in x/oracle/keeper/historic_price.go

View check run for this annotation

Codecov / codecov/patch

x/oracle/keeper/historic_price.go#L162

Added line #L162 was not covered by tests
}

return median, uint32(len(medians)), nil
Expand All @@ -175,7 +179,7 @@ func (k Keeper) AverageOfHistoricMedians(
}
average, err := decmath.Average(medians.Decs())
if err != nil {
return sdk.ZeroDec(), 0, errors.Wrap(err, "denom: "+denom)
return sdk.ZeroDec(), 0, wrapDenomError(err, denom)

Check warning on line 182 in x/oracle/keeper/historic_price.go

View check run for this annotation

Codecov / codecov/patch

x/oracle/keeper/historic_price.go#L182

Added line #L182 was not covered by tests
}

return average, uint32(len(medians)), nil
Expand All @@ -195,7 +199,7 @@ func (k Keeper) MaxOfHistoricMedians(
}
max, err := decmath.Max(medians.Decs())
if err != nil {
return sdk.ZeroDec(), 0, errors.Wrap(err, "denom: "+denom)
return sdk.ZeroDec(), 0, wrapDenomError(err, denom)

Check warning on line 202 in x/oracle/keeper/historic_price.go

View check run for this annotation

Codecov / codecov/patch

x/oracle/keeper/historic_price.go#L202

Added line #L202 was not covered by tests
}

return max, uint32(len(medians)), nil
Expand All @@ -215,7 +219,7 @@ func (k Keeper) MinOfHistoricMedians(
}
min, err := decmath.Min(medians.Decs())
if err != nil {
return sdk.ZeroDec(), 0, errors.Wrap(err, "denom: "+denom)
return sdk.ZeroDec(), 0, wrapDenomError(err, denom)

Check warning on line 222 in x/oracle/keeper/historic_price.go

View check run for this annotation

Codecov / codecov/patch

x/oracle/keeper/historic_price.go#L222

Added line #L222 was not covered by tests
}

return min, uint32(len(medians)), nil
Expand Down

0 comments on commit 0ece567

Please sign in to comment.