gofumpt - apply format changes for readability and consistency (#1248)

This commit is contained in:
Jacob Gadikian 2022-05-10 01:37:36 +07:00 committed by GitHub
parent f472d119cc
commit 09ddb3e367
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
160 changed files with 300 additions and 335 deletions

View File

@ -168,10 +168,12 @@ func TestAppImportExport(t *testing.T) {
storeKeysPrefixes := []StoreKeysPrefixes{
{app.keys[baseapp.MainStoreKey], newApp.keys[baseapp.MainStoreKey], [][]byte{}},
{app.keys[auth.StoreKey], newApp.keys[auth.StoreKey], [][]byte{}},
{app.keys[staking.StoreKey], newApp.keys[staking.StoreKey],
{
app.keys[staking.StoreKey], newApp.keys[staking.StoreKey],
[][]byte{
staking.UnbondingQueueKey, staking.RedelegationQueueKey, staking.ValidatorQueueKey,
}}, // ordering may change but it doesn't matter
},
}, // ordering may change but it doesn't matter
{app.keys[slashing.StoreKey], newApp.keys[slashing.StoreKey], [][]byte{}},
{app.keys[mint.StoreKey], newApp.keys[mint.StoreKey], [][]byte{}},
{app.keys[distr.StoreKey], newApp.keys[distr.StoreKey], [][]byte{}},
@ -320,7 +322,6 @@ func TestAppStateDeterminism(t *testing.T) {
func AppStateFn(cdc *codec.Codec, simManager *module.SimulationManager) simulation.AppStateFn {
return func(r *rand.Rand, accs []simulation.Account, config simulation.Config,
) (appState json.RawMessage, simAccs []simulation.Account, chainID string, genesisTimestamp time.Time) {
if simapp.FlagGenesisTimeValue == 0 {
genesisTimestamp = time.Unix(r.Int63n(190288396800), 0) // 1st Jan year 8000
} else {

View File

@ -12,9 +12,7 @@ import (
"github.com/kava-labs/kava/app/ante"
)
var (
_ sdk.AnteHandler = (&MockAnteHandler{}).AnteHandle
)
var _ sdk.AnteHandler = (&MockAnteHandler{}).AnteHandle
type MockAnteHandler struct {
WasCalled bool

View File

@ -211,7 +211,6 @@ func TestAuthzLimiterDecorator(t *testing.T) {
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
tx, err := helpers.GenTx(
txConfig,
tc.msgs,

View File

@ -323,7 +323,6 @@ func NewApp(
options Options,
baseAppOptions ...func(*baseapp.BaseApp),
) *App {
appCodec := encodingConfig.Marshaler
legacyAmino := encodingConfig.Amino
interfaceRegistry := encodingConfig.InterfaceRegistry
@ -348,7 +347,7 @@ func NewApp(
tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey, evmtypes.TransientKey)
memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey)
var app = &App{
app := &App{
BaseApp: bApp,
legacyAmino: legacyAmino,
appCodec: appCodec,

View File

@ -84,7 +84,6 @@ func (builder *AuthBankGenesisBuilder) WithSimpleModuleAccount(moduleName string
// WithSimplePeriodicVestingAccount adds a periodic vesting account to the genesis state.
func (builder *AuthBankGenesisBuilder) WithSimplePeriodicVestingAccount(address sdk.AccAddress, balance sdk.Coins, periods vestingtypes.Periods, firstPeriodStartTimestamp int64) *AuthBankGenesisBuilder {
vestingAccount := newPeriodicVestingAccount(address, periods, firstPeriodStartTimestamp)
return builder.

View File

@ -1,3 +1,4 @@
//go:build cli_test
// +build cli_test
package clitest
@ -1137,7 +1138,8 @@ func TestKvCLIMultisignSortSignatures(t *testing.T) {
// Multisign, keys in different order
success, stdout, _ = f.TxMultisign(unsignedTxFile.Name(), keyFooBarBaz, []string{
bazSignatureFile.Name(), fooSignatureFile.Name()})
bazSignatureFile.Name(), fooSignatureFile.Name(),
})
require.True(t, success)
// Write the output to disk
@ -1205,13 +1207,15 @@ func TestKvCLIMultisign(t *testing.T) {
// Does not work in offline mode
success, stdout, _ = f.TxMultisign(unsignedTxFile.Name(), keyFooBarBaz, []string{
fooSignatureFile.Name(), barSignatureFile.Name()}, "--offline")
fooSignatureFile.Name(), barSignatureFile.Name(),
}, "--offline")
require.Contains(t, "couldn't verify signature", stdout)
require.False(t, success)
// Success multisign
success, stdout, _ = f.TxMultisign(unsignedTxFile.Name(), keyFooBarBaz, []string{
fooSignatureFile.Name(), barSignatureFile.Name()})
fooSignatureFile.Name(), barSignatureFile.Name(),
})
require.True(t, success)
// Write the output to disk

View File

@ -367,8 +367,8 @@ func (f *Fixtures) TxEncode(fileName string, flags ...string) (bool, string, str
// TxMultisign is kvcli tx multisign
func (f *Fixtures) TxMultisign(fileName, name string, signaturesFiles []string,
flags ...string) (bool, string, string) {
flags ...string,
) (bool, string, string) {
cmd := fmt.Sprintf("%s tx multisign --keyring-backend=test %v %s %s %s", f.KvcliBinary, f.Flags(),
fileName, name, strings.Join(signaturesFiles, " "),
)
@ -425,7 +425,6 @@ func (f *Fixtures) TxGovVote(proposalID int, option gov.VoteOption, from string,
func (f *Fixtures) TxGovSubmitParamChangeProposal(
from, proposalPath string, deposit sdk.Coin, flags ...string,
) (bool, string, string) {
cmd := fmt.Sprintf(
"%s tx gov submit-proposal param-change %s --keyring-backend=test --from=%s %v",
f.KvcliBinary, proposalPath, from, f.Flags(),
@ -439,7 +438,6 @@ func (f *Fixtures) TxGovSubmitParamChangeProposal(
func (f *Fixtures) TxGovSubmitCommunityPoolSpendProposal(
from, proposalPath string, deposit sdk.Coin, flags ...string,
) (bool, string, string) {
cmd := fmt.Sprintf(
"%s tx gov submit-proposal community-pool-spend %s --keyring-backend=test --from=%s %v",
f.KvcliBinary, proposalPath, from, f.Flags(),

View File

@ -16,9 +16,7 @@ import (
"github.com/tharsis/ethermint/crypto/hd"
)
var (
ethFlag = "eth"
)
var ethFlag = "eth"
// KeyCommands registers a sub-tree of commands to interact with
// local private key storage.

View File

@ -43,7 +43,6 @@ func (ac appCreator) newApp(
traceStore io.Writer,
appOpts servertypes.AppOptions,
) servertypes.Application {
var cache sdk.MultiStorePersistentCache
if cast.ToBool(appOpts.Get(server.FlagInterBlockCache)) {
cache = store.NewCommitKVStoreCacheManager()
@ -114,7 +113,6 @@ func (ac appCreator) appExport(
jailAllowedAddrs []string,
appOpts servertypes.AppOptions,
) (servertypes.ExportedApp, error) {
homePath, ok := appOpts.Get(flags.FlagHome).(string)
if !ok || homePath == "" {
return servertypes.ExportedApp{}, errors.New("application home not set")

View File

@ -83,7 +83,7 @@ func TestResetPeriodVestingAccount_SingleVestingPeriod_Vesting(t *testing.T) {
expectedEndtime := newVestingStartTime.Add(15 * 24 * time.Hour).Unix()
// new period length changed, amount unchanged
expectedPeriods := []vestingtypes.Period{
vestingtypes.Period{
{
Length: 15 * 24 * 60 * 60, // 15 days
Amount: balance,
},
@ -156,11 +156,11 @@ func TestResetPeriodVestingAccount_MultiplePeriods(t *testing.T) {
expectedEndtime := newVestingStartTime.Add(30 * 24 * time.Hour).Unix()
// new period length changed, amount unchanged
expectedPeriods := []vestingtypes.Period{
vestingtypes.Period{
{
Length: 15 * 24 * 60 * 60, // 15 days
Amount: sdk.NewCoins(sdk.NewCoin("ukava", sdk.NewInt(1e6))),
},
vestingtypes.Period{
{
Length: 15 * 24 * 60 * 60, // 15 days
Amount: sdk.NewCoins(sdk.NewCoin("ukava", sdk.NewInt(1e6))),
},

View File

@ -14,7 +14,7 @@ import (
// v40 cosmos auth module genesis state, returning a copy of the original state where all
// periodic vesting accounts have been zeroed out.
func MigrateAuthV040(authGenState v040auth.GenesisState, genesisTime time.Time, ctx client.Context) *v040auth.GenesisState {
var anyAccounts = make([]*codectypes.Any, len(authGenState.Accounts))
anyAccounts := make([]*codectypes.Any, len(authGenState.Accounts))
for i, anyAcc := range authGenState.Accounts {
// Only need to make modifications to vesting accounts
if anyAcc.TypeUrl != "/cosmos.vesting.v1beta1.PeriodicVestingAccount" {

View File

@ -8,7 +8,6 @@ import (
)
func migrateCommitteePermissions(genState committeetypes.GenesisState) committeetypes.GenesisState {
var newCommittees committeetypes.Committees
for _, committee := range genState.GetCommittees() {
switch committee.GetDescription() {

View File

@ -33,7 +33,6 @@ func GetTxCmd() *cobra.Command {
txCmd.AddCommand(cmds...)
return txCmd
}
// GetCmdPlaceBid cli command for placing bids on auctions

View File

@ -3,7 +3,6 @@ package rest
import (
"fmt"
"net/http"
"strings"
"github.com/cosmos/cosmos-sdk/client"

View File

@ -16,9 +16,10 @@ import (
"github.com/kava-labs/kava/x/auction/types"
)
var _, testAddrs = app.GeneratePrivKeyAddressPairs(2)
var testTime = time.Date(1998, 1, 1, 0, 0, 0, 0, time.UTC)
var testAuction = types.NewCollateralAuction(
var (
_, testAddrs = app.GeneratePrivKeyAddressPairs(2)
testTime = time.Date(1998, 1, 1, 0, 0, 0, 0, time.UTC)
testAuction = types.NewCollateralAuction(
"seller",
c("lotdenom", 10),
testTime,
@ -26,6 +27,7 @@ var testAuction = types.NewCollateralAuction(
types.WeightedAddresses{Addresses: testAddrs, Weights: []sdk.Int{sdk.OneInt(), sdk.OneInt()}},
c("debt", 1000),
).WithID(3).(types.GenesisAuction)
)
func TestInitGenesis(t *testing.T) {
t.Run("valid", func(t *testing.T) {

View File

@ -46,7 +46,6 @@ func (k Keeper) StartSurplusAuction(ctx sdk.Context, seller string, lot sdk.Coin
// StartDebtAuction starts a new debt (reverse) auction.
func (k Keeper) StartDebtAuction(ctx sdk.Context, buyer string, bid sdk.Coin, initialLot sdk.Coin, debt sdk.Coin) (uint64, error) {
auction := types.NewDebtAuction(
buyer,
bid,
@ -132,7 +131,6 @@ func (k Keeper) StartCollateralAuction(
// PlaceBid places a bid on any auction.
func (k Keeper) PlaceBid(ctx sdk.Context, auctionID uint64, bidder sdk.AccAddress, newAmount sdk.Coin) error {
auction, found := k.GetAuction(ctx, auctionID)
if !found {
return sdkerrors.Wrapf(types.ErrAuctionNotFound, "%d", auctionID)

View File

@ -25,11 +25,10 @@ const (
)
func TestAuctionBidding(t *testing.T) {
config := sdk.GetConfig()
app.SetBech32AddressPrefixes(config)
someTime := time.Date(0001, time.January, 1, 0, 0, 0, 0, time.UTC)
someTime := time.Date(0o001, time.January, 1, 0, 0, 0, 0, time.UTC)
_, addrs := app.GeneratePrivKeyAddressPairs(5)
buyer := addrs[0]

View File

@ -117,7 +117,6 @@ func TestGrpcAuctionsFilter(t *testing.T) {
for _, tc := range tests {
t.Run(tc.giveName, func(t *testing.T) {
res, err := qs.Auctions(sdk.WrapSDKContext(ctx), &tc.giveRequest)
require.NoError(t, err)

View File

@ -12,7 +12,6 @@ import (
// RegisterInvariants registers all staking invariants
func RegisterInvariants(ir sdk.InvariantRegistry, k Keeper) {
ir.RegisterRoute(types.ModuleName, "module-account",
ModuleAccountInvariants(k))
ir.RegisterRoute(types.ModuleName, "valid-auctions",
@ -24,7 +23,6 @@ func RegisterInvariants(ir sdk.InvariantRegistry, k Keeper) {
// ModuleAccountInvariants checks that the module account's coins matches those stored in auctions
func ModuleAccountInvariants(k Keeper) sdk.Invariant {
return func(ctx sdk.Context) (string, bool) {
totalAuctionCoins := sdk.NewCoins()
k.IterateAuctions(ctx, func(auction types.Auction) bool {
a, ok := auction.(types.GenesisAuction)

View File

@ -24,7 +24,8 @@ type Keeper struct {
// NewKeeper returns a new auction keeper.
func NewKeeper(cdc codec.Codec, storeKey sdk.StoreKey, paramstore paramtypes.Subspace,
bankKeeper types.BankKeeper, accountKeeper types.AccountKeeper) Keeper {
bankKeeper types.BankKeeper, accountKeeper types.AccountKeeper,
) Keeper {
if !paramstore.HasKeyTable() {
paramstore = paramstore.WithKeyTable(types.ParamKeyTable())
}
@ -81,7 +82,6 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger {
func (k Keeper) SetNextAuctionID(ctx sdk.Context, id uint64) {
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.NextAuctionIDKey)
store.Set(types.NextAuctionIDKey, types.Uint64ToBytes(id))
}
// GetNextAuctionID reads the next available global ID from store

View File

@ -124,7 +124,6 @@ func TestIterateAuctionsByTime(t *testing.T) {
if v.endTime.Before(cutoffTime) || v.endTime.Equal(cutoffTime) { // endTime ≤ cutoffTime
expectedIndex = append(expectedIndex, v.auctionID)
}
}
var readIndex []uint64
keeper.IterateAuctionsByTime(ctx, cutoffTime, func(id uint64) bool {

View File

@ -36,6 +36,7 @@ func GenBidDuration(r *rand.Rand) time.Duration {
}
return d
}
func GenMaxAuctionDuration(r *rand.Rand) time.Duration {
d, err := RandomPositiveDuration(r, MaxBidDuration, AverageBlockTime*200)
if err != nil {
@ -48,12 +49,13 @@ func GenIncrementCollateral(r *rand.Rand) sdk.Dec {
return simulation.RandomDecAmount(r, sdk.MustNewDecFromStr("1"))
}
var GenIncrementDebt = GenIncrementCollateral
var GenIncrementSurplus = GenIncrementCollateral
var (
GenIncrementDebt = GenIncrementCollateral
GenIncrementSurplus = GenIncrementCollateral
)
// RandomizedGenState generates a random GenesisState for auction
func RandomizedGenState(simState *module.SimulationState) {
p := types.NewParams(
GenMaxAuctionDuration(simState.Rand),
GenBidDuration(simState.Rand),
@ -80,7 +82,7 @@ func RandomizedGenState(simState *module.SimulationState) {
sdk.NewInt64Coin("debt", 100), // same as usdx
),
}
var startingID = auctionGenesis.NextAuctionID
startingID := auctionGenesis.NextAuctionID
var ok bool
var totalAuctionCoins sdk.Coins
for i, a := range auctions {

View File

@ -122,7 +122,8 @@ func SimulateMsgPlaceBid(ak auth.AccountKeeper, keeper keeper.Keeper) simulation
func generateBidAmount(
r *rand.Rand, params types.Params, auc types.Auction,
bidder authexported.Account, blockTime time.Time) (sdk.Coin, error) {
bidder authexported.Account, blockTime time.Time,
) (sdk.Coin, error) {
bidderBalance := bidder.SpendableCoins(blockTime)
switch a := auc.(type) {

View File

@ -20,7 +20,6 @@ func newTestModuleCodec() codec.Codec {
}
func TestGenesisState_Validate(t *testing.T) {
arbitraryTime := time.Date(1998, 1, 1, 0, 0, 0, 0, time.UTC)
validAuction := &CollateralAuction{
BaseAuction: BaseAuction{
@ -82,7 +81,6 @@ func TestGenesisState_Validate(t *testing.T) {
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
err := tc.genesis.Validate()
if tc.expectPass {
require.NoError(t, err)
@ -91,11 +89,9 @@ func TestGenesisState_Validate(t *testing.T) {
}
})
}
}
func TestGenesisState_UnmarshalAnys(t *testing.T) {
cdc := newTestModuleCodec()
arbitraryTime := time.Date(1998, 1, 1, 0, 0, 0, 0, time.UTC)

View File

@ -14,8 +14,10 @@ import (
"github.com/kava-labs/kava/x/bep3/types"
)
const restSwapID = "swap-id"
const restDenom = "denom"
const (
restSwapID = "swap-id"
restDenom = "denom"
)
func registerQueryRoutes(cliCtx client.Context, r *mux.Router) {
r.HandleFunc(fmt.Sprintf("/%s/swap/{%s}", types.ModuleName, restSwapID), queryAtomicSwapHandlerFn(cliCtx)).Methods("GET")
@ -23,7 +25,6 @@ func registerQueryRoutes(cliCtx client.Context, r *mux.Router) {
r.HandleFunc(fmt.Sprintf("/%s/supply/{%s}", types.ModuleName, restDenom), queryAssetSupplyHandlerFn(cliCtx)).Methods("GET")
r.HandleFunc(fmt.Sprintf("/%s/supplies", types.ModuleName), queryAssetSuppliesHandlerFn(cliCtx)).Methods("GET")
r.HandleFunc(fmt.Sprintf("/%s/parameters", types.ModuleName), queryParamsHandlerFn(cliCtx)).Methods("GET")
}
func queryAtomicSwapHandlerFn(cliCtx client.Context) http.HandlerFunc {

View File

@ -340,7 +340,6 @@ func (suite *GenesisTestSuite) TestGenesisState() {
}, tc.name)
}
})
}
}

View File

@ -98,7 +98,6 @@ func (suite *AssetTestSuite) TestIncrementCurrentAssetSupply() {
for _, tc := range testCases {
suite.SetupTest()
suite.Run(tc.name, func() {
preSupply, found := suite.keeper.GetAssetSupply(suite.ctx, tc.args.coin.Denom)
err := suite.keeper.IncrementCurrentAssetSupply(suite.ctx, tc.args.coin)
postSupply, _ := suite.keeper.GetAssetSupply(suite.ctx, tc.args.coin.Denom)
@ -138,7 +137,8 @@ func (suite *AssetTestSuite) TestIncrementTimeLimitedCurrentAssetSupply() {
OutgoingSupply: c("inc", 5),
CurrentSupply: c("inc", 10),
TimeLimitedCurrentSupply: c("inc", 5),
TimeElapsed: time.Duration(0)},
TimeElapsed: time.Duration(0),
},
},
errArgs{
expectPass: true,
@ -215,7 +215,6 @@ func (suite *AssetTestSuite) TestDecrementCurrentAssetSupply() {
for _, tc := range testCases {
suite.SetupTest()
suite.Run(tc.name, func() {
preSupply, found := suite.keeper.GetAssetSupply(suite.ctx, tc.args.coin.Denom)
err := suite.keeper.DecrementCurrentAssetSupply(suite.ctx, tc.args.coin)
postSupply, _ := suite.keeper.GetAssetSupply(suite.ctx, tc.args.coin.Denom)
@ -313,7 +312,8 @@ func (suite *AssetTestSuite) TestIncrementTimeLimitedIncomingAssetSupply() {
OutgoingSupply: c("inc", 5),
CurrentSupply: c("inc", 5),
TimeLimitedCurrentSupply: c("inc", 0),
TimeElapsed: time.Duration(0)},
TimeElapsed: time.Duration(0),
},
},
errArgs{
expectPass: true,
@ -390,7 +390,6 @@ func (suite *AssetTestSuite) TestDecrementIncomingAssetSupply() {
for _, tc := range testCases {
suite.SetupTest()
suite.Run(tc.name, func() {
preSupply, found := suite.keeper.GetAssetSupply(suite.ctx, tc.args.coin.Denom)
err := suite.keeper.DecrementIncomingAssetSupply(suite.ctx, tc.args.coin)
postSupply, _ := suite.keeper.GetAssetSupply(suite.ctx, tc.args.coin.Denom)
@ -449,7 +448,6 @@ func (suite *AssetTestSuite) TestIncrementOutgoingAssetSupply() {
for _, tc := range testCases {
suite.SetupTest()
suite.Run(tc.name, func() {
preSupply, found := suite.keeper.GetAssetSupply(suite.ctx, tc.args.coin.Denom)
err := suite.keeper.IncrementOutgoingAssetSupply(suite.ctx, tc.args.coin)
postSupply, _ := suite.keeper.GetAssetSupply(suite.ctx, tc.args.coin.Denom)

View File

@ -25,7 +25,8 @@ type Keeper struct {
// NewKeeper creates a bep3 keeper
func NewKeeper(cdc codec.Codec, key sdk.StoreKey, sk types.BankKeeper, ak types.AccountKeeper,
paramstore paramtypes.Subspace, maccs map[string]bool) Keeper {
paramstore paramtypes.Subspace, maccs map[string]bool,
) Keeper {
if !paramstore.HasKeyTable() {
paramstore = paramstore.WithKeyTable(types.ParamKeyTable())
}
@ -160,7 +161,8 @@ func (k Keeper) RemoveFromLongtermStorage(ctx sdk.Context, atomicSwap types.Atom
// IterateAtomicSwapsLongtermStorage provides an iterator over AtomicSwaps ordered by deletion height.
// For each AtomicSwap cb will be called. If cb returns true the iterator will close and stop.
func (k Keeper) IterateAtomicSwapsLongtermStorage(ctx sdk.Context, inclusiveCutoffTime uint64,
cb func(swapID []byte) (stop bool)) {
cb func(swapID []byte) (stop bool),
) {
store := prefix.NewStore(ctx.KVStore(k.key), types.AtomicSwapLongtermStoragePrefix)
iterator := store.Iterator(
nil, // start at the very start of the prefix store

View File

@ -78,6 +78,7 @@ func (suite *KeeperTestSuite) TestRemoveAtomicSwap() {
_, found = suite.keeper.GetAtomicSwap(suite.ctx, atomicSwap.GetSwapID())
suite.False(found)
}
func (suite *KeeperTestSuite) TestIterateAtomicSwaps() {
suite.ResetChain()
@ -324,7 +325,6 @@ func (suite *KeeperTestSuite) TestGetSetAssetSupply() {
}
func (suite *KeeperTestSuite) TestGetAllAssetSupplies() {
// Put asset supply in store
assetSupply := types.NewAssetSupply(c("bnb", 0), c("bnb", 0), c("bnb", 50000), c("bnb", 0), time.Duration(0))
suite.keeper.SetAssetSupply(suite.ctx, assetSupply, "bnb")

View File

@ -63,7 +63,6 @@ func (suite *ParamsTestSuite) TestGetSetDeputyAddress() {
addr, err := suite.keeper.GetDeputyAddress(suite.ctx, "bnb")
suite.Require().NoError(err)
suite.Equal(suite.addrs[1], addr)
}
func (suite *ParamsTestSuite) TestGetDeputyFixedFee() {

View File

@ -15,7 +15,8 @@ import (
// CreateAtomicSwap creates a new atomic swap.
func (k Keeper) CreateAtomicSwap(ctx sdk.Context, randomNumberHash []byte, timestamp int64, heightSpan uint64,
sender, recipient sdk.AccAddress, senderOtherChain, recipientOtherChain string,
amount sdk.Coins, crossChain bool) error {
amount sdk.Coins, crossChain bool,
) error {
// Confirm that this is not a duplicate swap
swapID := types.CalculateSwapID(randomNumberHash, sender, senderOtherChain)
_, found := k.GetAtomicSwap(ctx, swapID)

View File

@ -197,7 +197,6 @@ func (suite *AtomicSwapTestSuite) TestCreateAtomicSwap() {
true,
},
{
"outgoing swap amount not greater than fixed fee",
currentTmTime,
args{
@ -453,8 +452,7 @@ func (suite *AtomicSwapTestSuite) TestCreateAtomicSwap() {
suite.NotNil(actualSwap)
// Confirm swap contents
expectedSwap :=
types.AtomicSwap{
expectedSwap := types.AtomicSwap{
Amount: tc.args.coins,
RandomNumberHash: tc.args.randomNumberHash,
ExpireHeight: uint64(suite.ctx.BlockHeight()) + tc.args.heightSpan,

View File

@ -78,7 +78,6 @@ func GenMaxBlockLock(r *rand.Rand, minBlockLock uint64) uint64 {
// GenSupportedAssets gets randomized SupportedAssets
func GenSupportedAssets(r *rand.Rand) types.AssetParams {
numAssets := (r.Intn(10) + 1)
assets := make(types.AssetParams, numAssets+1)
for i := 0; i < numAssets; i++ {
@ -113,7 +112,8 @@ func genSupportedAsset(r *rand.Rand, denom string) types.AssetParam {
Limit: limit,
TimeLimited: timeLimited,
TimePeriod: time.Hour * 24,
TimeBasedLimit: timeBasedLimit},
TimeBasedLimit: timeBasedLimit,
},
Active: true,
DeputyAddress: GenRandBnbDeputy(r).Address,
FixedFee: GenRandFixedFee(r),
@ -146,7 +146,6 @@ func RandomizedGenState(simState *module.SimulationState) {
}
func loadRandomBep3GenState(simState *module.SimulationState) types.GenesisState {
supportedAssets := GenSupportedAssets(simState.Rand)
supplies := types.AssetSupplies{}
for _, asset := range supportedAssets {

View File

@ -133,7 +133,6 @@ func SimulateMsgCreateAtomicSwap(ak types.AccountKeeper, k keeper.Keeper) simula
}
// The maximum amount for outgoing swaps is limited by the asset's current supply
if recipient.Address.Equals(asset.DeputyAddress) {
if maximumAmount.GT(assetSupply.CurrentSupply.Amount.Sub(assetSupply.OutgoingSupply.Amount)) {
maximumAmount = assetSupply.CurrentSupply.Amount.Sub(assetSupply.OutgoingSupply.Amount)
}
@ -330,7 +329,8 @@ func operationRefundAtomicSwap(ak types.AccountKeeper, k keeper.Keeper, swapID [
// findValidAccountAssetSupplyPair finds an account for which the callback func returns true
func findValidAccountAssetPair(accounts []simulation.Account, assets types.AssetParams,
cb func(simulation.Account, types.AssetParam) bool) (simulation.Account, types.AssetParam, bool) {
cb func(simulation.Account, types.AssetParam) bool,
) (simulation.Account, types.AssetParam, bool) {
for _, asset := range assets {
for _, acc := range accounts {
if isValid := cb(acc, asset); isValid {

View File

@ -113,7 +113,6 @@ func (suite *GenesisTestSuite) TestValidate() {
} else {
suite.Require().Error(err, tc.name)
}
})
}
}

View File

@ -38,7 +38,8 @@ var (
// NewMsgCreateAtomicSwap initializes a new MsgCreateAtomicSwap
func NewMsgCreateAtomicSwap(from, to string, recipientOtherChain,
senderOtherChain string, randomNumberHash tmbytes.HexBytes, timestamp int64,
amount sdk.Coins, heightSpan uint64) MsgCreateAtomicSwap {
amount sdk.Coins, heightSpan uint64,
) MsgCreateAtomicSwap {
return MsgCreateAtomicSwap{
From: from,
To: to,

View File

@ -39,7 +39,6 @@ func (suite *ParamsTestSuite) SetupTest() {
}
func (suite *ParamsTestSuite) TestParamValidation() {
type args struct {
assetParams types.AssetParams
}
@ -83,7 +82,8 @@ func (suite *ParamsTestSuite) TestParamValidation() {
{
name: "valid multi asset",
args: args{
assetParams: types.AssetParams{types.NewAssetParam(
assetParams: types.AssetParams{
types.NewAssetParam(
"bnb", 714, suite.supply[0], true,
suite.addr, sdk.NewInt(1000), sdk.NewInt(100000000), sdk.NewInt(100000000000),
types.DefaultMinBlockLock, types.DefaultMaxBlockLock),
@ -213,7 +213,8 @@ func (suite *ParamsTestSuite) TestParamValidation() {
{
name: "duplicate denom",
args: args{
assetParams: types.AssetParams{types.NewAssetParam(
assetParams: types.AssetParams{
types.NewAssetParam(
"bnb", 714, suite.supply[0], true,
suite.addr, sdk.NewInt(1000), sdk.NewInt(100000000), sdk.NewInt(100000000000),
types.DefaultMinBlockLock, types.DefaultMaxBlockLock),

View File

@ -70,7 +70,8 @@ type QueryAtomicSwaps struct {
// NewQueryAtomicSwaps creates a new instance of QueryAtomicSwaps
func NewQueryAtomicSwaps(page, limit int, involve sdk.AccAddress, expiration uint64,
status SwapStatus, direction SwapDirection) QueryAtomicSwaps {
status SwapStatus, direction SwapDirection,
) QueryAtomicSwaps {
return QueryAtomicSwaps{
Page: page,
Limit: limit,

View File

@ -15,7 +15,8 @@ import (
// NewAtomicSwap returns a new AtomicSwap
func NewAtomicSwap(amount sdk.Coins, randomNumberHash tmbytes.HexBytes, expireHeight uint64, timestamp int64,
sender, recipient sdk.AccAddress, senderOtherChain, recipientOtherChain string, closedBlock int64,
status SwapStatus, crossChain bool, direction SwapDirection) AtomicSwap {
status SwapStatus, crossChain bool, direction SwapDirection,
) AtomicSwap {
return AtomicSwap{
Amount: amount,
RandomNumberHash: randomNumberHash,

View File

@ -120,6 +120,7 @@ func (suite *ModuleTestSuite) setPrice(price sdk.Dec, market string) {
suite.NoError(err)
suite.Equal(price, pp.Price)
}
func (suite *ModuleTestSuite) TestBeginBlock() {
suite.createCdps()
ak := suite.app.GetAccountKeeper()
@ -147,7 +148,6 @@ func (suite *ModuleTestSuite) TestBeginBlock() {
acc = ak.GetModuleAccount(suite.ctx, auctiontypes.ModuleName)
suite.Equal(int64(71955653865), bk.GetBalance(suite.ctx, acc.GetAddress(), "debt").Amount.Int64())
}
func (suite *ModuleTestSuite) TestSeizeSingleCdpWithFees() {

View File

@ -11,7 +11,6 @@ import (
// InitGenesis sets initial genesis state for cdp module
func InitGenesis(ctx sdk.Context, k keeper.Keeper, pk types.PricefeedKeeper, ak types.AccountKeeper, gs types.GenesisState) {
if err := gs.Validate(); err != nil {
panic(fmt.Sprintf("failed to validate %s genesis state: %s", types.ModuleName, err))
}
@ -85,7 +84,6 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, pk types.PricefeedKeeper, ak
for _, d := range gs.Deposits {
k.SetDeposit(ctx, d)
}
}
// ExportGenesis export genesis state for cdp module

View File

@ -168,7 +168,6 @@ func (suite *GenesisTestSuite) TestValidGenState() {
}
func (suite *GenesisTestSuite) Test_InitExportGenesis() {
cdps := types.CDPs{
{
ID: 2,

View File

@ -108,6 +108,7 @@ func NewPricefeedGenStateMulti(cdc codec.JSONCodec) app.GenesisState {
}
return app.GenesisState{pricefeedtypes.ModuleName: cdc.MustMarshalJSON(&pfGenesis)}
}
func NewCDPGenStateMulti(cdc codec.JSONCodec) app.GenesisState {
cdpGenesis := types.GenesisState{
Params: types.Params{

View File

@ -27,8 +27,8 @@ func (k Keeper) AuctionCollateral(ctx sdk.Context, deposits types.Deposits, coll
// CreateAuctionsFromDeposit creates auctions from the input deposit
func (k Keeper) CreateAuctionsFromDeposit(
ctx sdk.Context, collateral sdk.Coin, collateralType string, returnAddr sdk.AccAddress, debt, auctionSize sdk.Int,
principalDenom string) error {
principalDenom string,
) error {
// number of auctions of auctionSize
numberOfAuctions := collateral.Amount.Quo(auctionSize)
debtPerAuction := debt.Mul(auctionSize).Quo(collateral.Amount)
@ -73,7 +73,6 @@ func (k Keeper) CreateAuctionsFromDeposit(
sdk.NewCoin(principalDenom, debtAmount.Add(penalty)), []sdk.AccAddress{returnAddr},
[]sdk.Int{auctionSize}, sdk.NewCoin(debtDenom, debtAmount),
)
if err != nil {
return err
}

View File

@ -173,7 +173,6 @@ func (k Keeper) BurnDebtCoins(ctx sdk.Context, moduleAccount string, denom strin
// GetCdpID returns the id of the cdp corresponding to a specific owner and collateral denom
func (k Keeper) GetCdpID(ctx sdk.Context, owner sdk.AccAddress, collateralType string) (uint64, bool) {
cdpIDs, found := k.GetCdpIdsByOwner(ctx, owner)
if !found {
return 0, false
@ -185,7 +184,6 @@ func (k Keeper) GetCdpID(ctx sdk.Context, owner sdk.AccAddress, collateralType s
}
}
return 0, false
}
// GetCdpIdsByOwner returns all the ids of cdps corresponding to a particular owner
@ -256,7 +254,6 @@ func (k Keeper) DeleteCDP(ctx sdk.Context, cdp types.CDP) error {
}
store.Delete(types.CdpKey(cdp.Type, cdp.ID))
return nil
}
// GetAllCdps returns all cdps from the store

View File

@ -124,7 +124,6 @@ func (k Keeper) GetDeposit(ctx sdk.Context, cdpID uint64, depositor sdk.AccAddre
}
k.cdc.MustUnmarshal(bz, &deposit)
return deposit, true
}
// SetDeposit sets the deposit in the store
@ -133,7 +132,6 @@ func (k Keeper) SetDeposit(ctx sdk.Context, deposit types.Deposit) {
bz := k.cdc.MustMarshal(&deposit)
store.Set(types.DepositKey(deposit.CdpID, deposit.Depositor), bz)
}
// DeleteDeposit deletes a deposit from the store

View File

@ -35,7 +35,8 @@ func (suite *DepositTestSuite) SetupTest() {
cdc,
[]sdk.Coins{
cs(c("xrp", 500000000), c("btc", 500000000)),
cs(c("xrp", 200000000))},
cs(c("xrp", 200000000)),
},
addrs[0:2],
)
tApp.InitializeFromGenesisStates(

View File

@ -53,7 +53,6 @@ func (suite *DrawTestSuite) SetupTest() {
}
func (suite *DrawTestSuite) TestAddRepayPrincipal() {
err := suite.keeper.AddPrincipal(suite.ctx, suite.addrs[0], "xrp-a", c("usdx", 10000000))
suite.NoError(err)
@ -125,7 +124,6 @@ func (suite *DrawTestSuite) TestAddRepayPrincipal() {
bk = suite.app.GetBankKeeper()
acc = ak.GetModuleAccount(suite.ctx, types.ModuleName)
suite.Equal(sdk.Coins{}, bk.GetAllBalances(suite.ctx, acc.GetAddress()))
}
func (suite *DrawTestSuite) TestRepayPrincipalOverpay() {

View File

@ -97,8 +97,7 @@ func (s QueryServer) TotalCollateral(c context.Context, req *types.QueryTotalCol
// collect collateral types for each denom
for _, collateralParam := range params.CollateralParams {
denomCollateralTypes[collateralParam.Denom] =
append(denomCollateralTypes[collateralParam.Denom], collateralParam.Type)
denomCollateralTypes[collateralParam.Denom] = append(denomCollateralTypes[collateralParam.Denom], collateralParam.Type)
}
// sort collateral types alphabetically

View File

@ -217,6 +217,7 @@ func (suite *grpcQueryTestSuite) TestGrpcQueryCdp() {
})
}
}
func (suite *grpcQueryTestSuite) TestGrpcQueryDeposits() {
suite.addCdp()

View File

@ -9,9 +9,7 @@ import (
"github.com/kava-labs/kava/x/cdp/types"
)
var (
scalingFactor = 1e18
)
var scalingFactor = 1e18
// AccumulateInterest calculates the new interest that has accrued for the input collateral type based on the total amount of principal
// that has been created with that collateral type and the amount of time that has passed since interest was last accumulated

View File

@ -146,7 +146,6 @@ func (suite *InterestTestSuite) TestCalculateInterestFactor() {
}
func (suite *InterestTestSuite) TestAccumulateInterest() {
type args struct {
ctype string
initialTime time.Time
@ -385,7 +384,6 @@ func (suite *InterestTestSuite) TestSynchronizeInterest() {
suite.Require().Equal(tc.args.expectedFees, cdp.AccumulatedFees)
suite.Require().Equal(tc.args.expectedFeesUpdatedTime, cdp.FeesUpdated)
})
}
}
@ -532,7 +530,6 @@ func (suite *InterestTestSuite) TestMultipleCDPInterest() {
}
suite.Require().Equal(tc.args.expectedSumOfCDPPrincipal, sumOfCDPPrincipal)
})
}
}
@ -640,7 +637,6 @@ func (suite *InterestTestSuite) TestCalculateCDPInterest() {
newInterest := suite.keeper.CalculateNewInterest(suite.ctx, cdp)
suite.Require().Equal(tc.args.expectedFees, newInterest)
})
}
}
@ -665,7 +661,6 @@ func (suite *InterestTestSuite) TestSyncInterestForRiskyCDPs() {
oneYearInSeconds := 31536000
testCases := []test{
{
"1 year",
args{

View File

@ -27,7 +27,8 @@ type Keeper struct {
// NewKeeper creates a new keeper
func NewKeeper(cdc codec.Codec, key sdk.StoreKey, paramstore paramtypes.Subspace, pfk types.PricefeedKeeper,
ak types.AuctionKeeper, bk types.BankKeeper, ack types.AccountKeeper, maccs map[string][]string) Keeper {
ak types.AuctionKeeper, bk types.BankKeeper, ack types.AccountKeeper, maccs map[string][]string,
) Keeper {
if !paramstore.HasKeyTable() {
paramstore = paramstore.WithKeyTable(types.ParamKeyTable())
}

View File

@ -117,7 +117,6 @@ func BenchmarkCdpIteration(b *testing.B) {
}
})
}
}
var errResult error

View File

@ -68,7 +68,6 @@ func queryGetCdp(ctx sdk.Context, req abci.RequestQuery, keeper Keeper, legacyQu
return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error())
}
return bz, nil
}
// query deposits on a particular cdp
@ -96,7 +95,6 @@ func queryGetDeposits(ctx sdk.Context, req abci.RequestQuery, keeper Keeper, leg
return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error())
}
return bz, nil
}
// query cdps with matching denom and ratio LESS THAN the input ratio
@ -264,8 +262,7 @@ func queryGetTotalCollateral(ctx sdk.Context, req abci.RequestQuery, keeper Keep
// collect collateral types for each denom
for _, collateralParam := range params.CollateralParams {
denomCollateralTypes[collateralParam.Denom] =
append(denomCollateralTypes[collateralParam.Denom], collateralParam.Type)
denomCollateralTypes[collateralParam.Denom] = append(denomCollateralTypes[collateralParam.Denom], collateralParam.Type)
}
// sort collateral types alphabetically

View File

@ -152,7 +152,6 @@ func (suite *QuerierTestSuite) TestQueryCdp() {
}
_, err = suite.querier(ctx, []string{types.QueryGetCdp}, query)
suite.Error(err)
}
func (suite *QuerierTestSuite) TestQueryCdpsByCollateralType() {
@ -282,7 +281,6 @@ func (suite *QuerierTestSuite) TestQueryDeposits() {
var d types.Deposits
suite.Nil(suite.legacyAmino.UnmarshalJSON(bz, &d))
suite.Equal(deposits, d)
}
func (suite *QuerierTestSuite) TestQueryAccounts() {

View File

@ -11,7 +11,8 @@ import (
// NewGenesisState returns a new genesis state
func NewGenesisState(params Params, cdps CDPs, deposits Deposits, startingCdpID uint64,
debtDenom, govDenom string, prevAccumTimes GenesisAccumulationTimes,
totalPrincipals GenesisTotalPrincipals) GenesisState {
totalPrincipals GenesisTotalPrincipals,
) GenesisState {
return GenesisState{
Params: params,
CDPs: cdps,
@ -41,7 +42,6 @@ func DefaultGenesisState() GenesisState {
// Validate performs basic validation of genesis data returning an
// error for any failed validation criteria.
func (gs GenesisState) Validate() error {
if err := gs.Params.Validate(); err != nil {
return err
}

View File

@ -137,7 +137,6 @@ func CollateralRatioKey(collateralType string, cdpID uint64, ratio sdk.Dec) []by
// SplitCollateralRatioKey split the collateral ratio key and return the denom, cdp id, and collateral:debt ratio
func SplitCollateralRatioKey(key []byte) (string, uint64, sdk.Dec) {
cdpID := GetCdpIDFromBytes(key[len(key)-8:])
split := bytes.Split(key[:len(key)-8], sep)
collateralType := string(split[0])

View File

@ -68,7 +68,8 @@ func DefaultParams() Params {
// NewCollateralParam returns a new CollateralParam
func NewCollateralParam(
denom, ctype string, liqRatio sdk.Dec, debtLimit sdk.Coin, stabilityFee sdk.Dec, auctionSize sdk.Int,
liqPenalty sdk.Dec, spotMarketID, liquidationMarketID string, keeperReward sdk.Dec, checkIndexCount sdk.Int, conversionFactor sdk.Int) CollateralParam {
liqPenalty sdk.Dec, spotMarketID, liquidationMarketID string, keeperReward sdk.Dec, checkIndexCount sdk.Int, conversionFactor sdk.Int,
) CollateralParam {
return CollateralParam{
Denom: denom,
Type: ctype,

View File

@ -31,7 +31,6 @@ type PostProposalReq struct {
func postProposalHandlerFn(cliCtx client.Context) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
// Parse and validate url params
vars := mux.Vars(r)
if len(vars[RestCommitteeID]) == 0 {
@ -78,7 +77,6 @@ type PostVoteReq struct {
func postVoteHandlerFn(cliCtx client.Context) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
// Parse and validate url params
vars := mux.Vars(r)
if len(vars[RestProposalID]) == 0 {
@ -148,7 +146,6 @@ func ProposalRESTHandler(cliCtx client.Context) govrest.ProposalRESTHandler {
func postGovProposalHandlerFn(cliCtx client.Context) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
// Parse and validate http request body
var req PostGovProposalReq
if !rest.ReadRESTReq(w, r, cliCtx.LegacyAmino, &req) {

View File

@ -33,7 +33,6 @@ func (suite *GenesisTestSuite) SetupTest() {
}
func (suite *GenesisTestSuite) TestInitGenesis() {
memberCom := types.MustNewMemberCommittee(
1,
"This member committee is for testing.",

View File

@ -260,8 +260,8 @@ func (suite *PermissionTestSuite) TestSubParamChangePermission_Allows() {
)
})
}
}
func TestPermissionTestSuite(t *testing.T) {
suite.Run(t, new(PermissionTestSuite))
}

View File

@ -16,7 +16,6 @@ import (
// getProposalVoteMap collects up votes into a map indexed by proposalID
func getProposalVoteMap(k keeper.Keeper, ctx sdk.Context) map[uint64]([]types.Vote) {
proposalVoteMap := map[uint64]([]types.Vote){}
k.IterateProposals(ctx, func(p types.Proposal) bool {

View File

@ -25,7 +25,8 @@ type Keeper struct {
}
func NewKeeper(cdc codec.Codec, storeKey sdk.StoreKey, router govtypes.Router,
paramKeeper types.ParamKeeper, ak types.AccountKeeper, sk types.BankKeeper) Keeper {
paramKeeper types.ParamKeeper, ak types.AccountKeeper, sk types.BankKeeper,
) Keeper {
// Logic in the keeper methods assume the set of gov handlers is fixed.
// So the gov router must be sealed so no handlers can be added or removed after the keeper is created.
router.Seal()

View File

@ -118,7 +118,6 @@ func (suite *MsgServerTestSuite) TestSubmitProposalMsg_Invalid() {
suite.keeper.GetProposalsByCommittee(suite.ctx, committeeID),
"proposal found when none should exist",
)
}
func (suite *MsgServerTestSuite) TestSubmitProposalMsg_ValidUpgrade() {

View File

@ -57,7 +57,6 @@ func (k Keeper) AddVote(ctx sdk.Context, proposalID uint64, voter sdk.AccAddress
}
if pr.HasExpiredBy(ctx.BlockTime()) {
return sdkerrors.Wrapf(types.ErrProposalExpired, "%s ≥ %s", ctx.BlockTime(), pr.Deadline)
}
com, found := k.GetCommittee(ctx, pr.CommitteeID)
if !found {
@ -189,7 +188,8 @@ func (k Keeper) GetTokenCommitteeProposalResult(ctx sdk.Context, proposalID uint
// total current votes, total possible votes (equal to token supply), vote threshold (yes vote ratio
// required for proposal to pass), and quorum (votes tallied at this percentage).
func (k Keeper) TallyTokenCommitteeVotes(ctx sdk.Context, proposalID uint64,
tallyDenom string) (yesVotes, noVotes, totalVotes, possibleVotes sdk.Dec) {
tallyDenom string,
) (yesVotes, noVotes, totalVotes, possibleVotes sdk.Dec) {
votes := k.GetVotesByProposal(ctx, proposalID)
yesVotes = sdk.ZeroDec()

View File

@ -43,7 +43,6 @@ func NewQuerier(k Keeper, legacyQuerierCdc *codec.LegacyAmino) sdk.Querier {
// ------------------------------------------
func queryCommittees(ctx sdk.Context, req abci.RequestQuery, keeper Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) {
committees := keeper.GetCommittees(ctx)
bz, err := codec.MarshalJSONIndent(legacyQuerierCdc, committees)
@ -128,7 +127,6 @@ func queryNextProposalID(ctx sdk.Context, req abci.RequestQuery, k Keeper, legac
func queryVotes(ctx sdk.Context, req abci.RequestQuery, keeper Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) {
var params types.QueryProposalParams
err := legacyQuerierCdc.UnmarshalJSON(req.Data, &params)
if err != nil {
return nil, sdkerrors.Wrap(sdkerrors.ErrJSONUnmarshal, err.Error())
}

View File

@ -192,7 +192,6 @@ func (suite *QuerierTestSuite) TestQueryVote() {
}
func (suite *QuerierTestSuite) TestQueryTally() {
ctx := suite.ctx.WithIsCheckTx(false)
// Expected result
@ -236,6 +235,7 @@ func (p *TestParams) ParamSetPairs() paramstypes.ParamSetPairs {
paramstypes.NewParamSetPair([]byte(paramKey), &p.TestKey, func(interface{}) error { return nil }),
}
}
func (suite *QuerierTestSuite) TestQueryRawParams() {
ctx := suite.ctx.WithIsCheckTx(false)

View File

@ -239,7 +239,8 @@ type MemberCommittee struct {
// NewMemberCommittee instantiates a new instance of MemberCommittee
func NewMemberCommittee(id uint64, description string, members []sdk.AccAddress, permissions []Permission,
threshold sdk.Dec, duration time.Duration, tallyOption TallyOption) MemberCommittee {
threshold sdk.Dec, duration time.Duration, tallyOption TallyOption,
) MemberCommittee {
return MemberCommittee{
BaseCommittee: BaseCommittee{
ID: id,
@ -276,7 +277,8 @@ type TokenCommittee struct {
// NewTokenCommittee instantiates a new instance of TokenCommittee
func NewTokenCommittee(id uint64, description string, members []sdk.AccAddress, permissions []Permission,
threshold sdk.Dec, duration time.Duration, tallyOption TallyOption, quorum sdk.Dec, tallyDenom string) TokenCommittee {
threshold sdk.Dec, duration time.Duration, tallyOption TallyOption, quorum sdk.Dec, tallyDenom string,
) TokenCommittee {
return TokenCommittee{
BaseCommittee: BaseCommittee{
ID: id,

View File

@ -112,7 +112,8 @@ type AllowedCollateralParam struct {
func NewAllowedCollateralParam(
ctype string, denom, liqRatio, debtLimit,
stabilityFee, auctionSize, liquidationPenalty,
prefix, spotMarket, liquidationMarket, conversionFactor, keeperReward, ltvIndexCount bool) AllowedCollateralParam {
prefix, spotMarket, liquidationMarket, conversionFactor, keeperReward, ltvIndexCount bool,
) AllowedCollateralParam {
return AllowedCollateralParam{
Type: ctype,
Denom: denom,

View File

@ -105,7 +105,7 @@ func (s *migrateTestSuite) TestMigrate_PricefeedPermissions() {
genstate := Migrate(s.v15genstate, s.v15pricefeedgenstate)
var uniqueMarkets = make(map[string]bool)
uniqueMarkets := make(map[string]bool)
for _, permission := range genstate.GetCommittees()[0].GetPermissions() {
paramChangePermission, ok := permission.(v016committee.ParamsChangePermission)

View File

@ -16,9 +16,7 @@ import (
"github.com/kava-labs/kava/x/committee/types"
)
var (
proposalPassPercentage = 0.9
)
var proposalPassPercentage = 0.9
type AccountKeeper interface {
GetAccount(sdk.Context, sdk.AccAddress) authexported.Account
@ -27,8 +25,8 @@ type AccountKeeper interface {
// WeightedOperations creates an operation (with weight) for each type of proposal generator.
// Custom proposal generators can be added for more control over types of proposal submitted, eg to increase likelyhood of particular cdp param changes.
func WeightedOperations(appParams simulation.AppParams, cdc *codec.Codec, ak AccountKeeper,
k keeper.Keeper, wContents []simulation.WeightedProposalContent) simulation.WeightedOperations {
k keeper.Keeper, wContents []simulation.WeightedProposalContent,
) simulation.WeightedOperations {
var wops simulation.WeightedOperations
for _, wContent := range wContents {
@ -59,7 +57,6 @@ func WeightedOperations(appParams simulation.AppParams, cdc *codec.Codec, ak Acc
// For each submit proposal msg, future ops for the vote messages are generated. Sometimes it doesn't run enough votes to allow the proposal to timeout - the likelihood of this happening is controlled by a parameter.
func SimulateMsgSubmitProposal(cdc *codec.Codec, ak AccountKeeper, k keeper.Keeper, contentSim simulation.ContentSimulatorFn) simulation.Operation {
return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simulation.Account, chainID string) (simulation.OperationMsg, []simulation.FutureOperation, error) {
// 1) Send a submit proposal msg
committees := k.GetCommittees(ctx)
@ -176,8 +173,8 @@ func SimulateMsgSubmitProposal(cdc *codec.Codec, ak AccountKeeper, k keeper.Keep
func SimulateMsgVote(k keeper.Keeper, ak AccountKeeper, voter sdk.AccAddress, proposalID uint64, voteType types.VoteType) simulation.Operation {
return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simulation.Account, chainID string) (
opMsg simulation.OperationMsg, fOps []simulation.FutureOperation, err error) {
opMsg simulation.OperationMsg, fOps []simulation.FutureOperation, err error,
) {
msg := types.NewMsgVote(voter, proposalID, voteType)
account := ak.GetAccount(ctx, voter)

View File

@ -242,7 +242,8 @@ func (c BaseCommittee) Validate() error {
// NewMemberCommittee instantiates a new instance of MemberCommittee
func NewMemberCommittee(id uint64, description string, members []sdk.AccAddress, permissions []Permission,
threshold sdk.Dec, duration time.Duration, tallyOption TallyOption) (*MemberCommittee, error) {
threshold sdk.Dec, duration time.Duration, tallyOption TallyOption,
) (*MemberCommittee, error) {
permissionsAny, err := PackPermissions(permissions)
if err != nil {
return nil, err
@ -262,7 +263,8 @@ func NewMemberCommittee(id uint64, description string, members []sdk.AccAddress,
// MustNewMemberCommittee instantiates a new instance of MemberCommittee and panics on error
func MustNewMemberCommittee(id uint64, description string, members []sdk.AccAddress, permissions []Permission,
threshold sdk.Dec, duration time.Duration, tallyOption TallyOption) *MemberCommittee {
threshold sdk.Dec, duration time.Duration, tallyOption TallyOption,
) *MemberCommittee {
committee, err := NewMemberCommittee(id, description, members, permissions, threshold, duration, tallyOption)
if err != nil {
panic(err)
@ -275,7 +277,8 @@ func (c MemberCommittee) GetType() string { return MemberCommitteeType }
// NewTokenCommittee instantiates a new instance of TokenCommittee
func NewTokenCommittee(id uint64, description string, members []sdk.AccAddress, permissions []Permission,
threshold sdk.Dec, duration time.Duration, tallyOption TallyOption, quorum sdk.Dec, tallyDenom string) (*TokenCommittee, error) {
threshold sdk.Dec, duration time.Duration, tallyOption TallyOption, quorum sdk.Dec, tallyDenom string,
) (*TokenCommittee, error) {
permissionsAny, err := PackPermissions(permissions)
if err != nil {
return nil, err
@ -297,7 +300,8 @@ func NewTokenCommittee(id uint64, description string, members []sdk.AccAddress,
// MustNewTokenCommittee instantiates a new instance of TokenCommittee and panics on error
func MustNewTokenCommittee(id uint64, description string, members []sdk.AccAddress, permissions []Permission,
threshold sdk.Dec, duration time.Duration, tallyOption TallyOption, quorum sdk.Dec, tallyDenom string) *TokenCommittee {
threshold sdk.Dec, duration time.Duration, tallyOption TallyOption, quorum sdk.Dec, tallyDenom string,
) *TokenCommittee {
committee, err := NewTokenCommittee(id, description, members, permissions, threshold, duration, tallyOption, quorum, tallyDenom)
if err != nil {
panic(err)

View File

@ -57,7 +57,8 @@ func TestGenesisState_Validate(t *testing.T) {
"hard",
),
},
types.Proposals{types.MustNewProposal(
types.Proposals{
types.MustNewProposal(
govtypes.NewTextProposal("A Title", "A description of this proposal."), 1, 1, testTime.Add(7*24*time.Hour)),
},
[]types.Vote{

View File

@ -45,7 +45,6 @@ func TestMsgSubmitProposal_ValidateBasic(t *testing.T) {
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
err := tc.msg.ValidateBasic()
if tc.expectPass {
@ -98,7 +97,6 @@ func TestMsgVote_ValidateBasic(t *testing.T) {
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
err := tc.msg.ValidateBasic()
if tc.expectPass {

View File

@ -794,7 +794,8 @@ func (s *ParamsChangeTestSuite) TestParamsChangePermission_NoSubparamRequirement
{
name: "fail if one change is not allowed",
expected: false,
changes: []paramsproposal.ParamChange{{
changes: []paramsproposal.ParamChange{
{
Subspace: cdptypes.ModuleName,
Key: string(cdptypes.KeySurplusThreshold),
Value: sdk.NewInt(120).String(),
@ -803,7 +804,8 @@ func (s *ParamsChangeTestSuite) TestParamsChangePermission_NoSubparamRequirement
Subspace: cdptypes.ModuleName,
Key: string(cdptypes.KeySurplusLot),
Value: sdk.NewInt(120).String(),
}},
},
},
},
}
@ -834,7 +836,6 @@ func TestParamsChangeTestSuite(t *testing.T) {
}
func TestAllowedParamsChanges_Get(t *testing.T) {
exampleAPCs := types.AllowedParamsChanges{
{
Subspace: "subspaceA",
@ -907,7 +908,6 @@ func TestAllowedParamsChanges_Get(t *testing.T) {
}
func TestAllowedParamsChanges_Set(t *testing.T) {
exampleAPCs := types.AllowedParamsChanges{
{
Subspace: "subspaceA",
@ -1029,7 +1029,6 @@ func TestAllowedParamsChanges_Set(t *testing.T) {
}
func TestAllowedParamsChanges_Delete(t *testing.T) {
exampleAPCs := types.AllowedParamsChanges{
{
Subspace: "subspaceA",

View File

@ -150,7 +150,7 @@ func (suite *evmBankKeeperTestSuite) TestSendCoinsFromModuleToAccount() {
sdk.NewCoins(sdk.NewInt64Coin("akava", 98_000_000_000_000)),
sdk.Coins{},
sdk.NewCoins(
sdk.NewInt64Coin("akava", 00),
sdk.NewInt64Coin("akava", 0o0),
sdk.NewInt64Coin("ukava", 98),
),
false,

View File

@ -33,7 +33,6 @@ func FullyBackedInvariant(bankK types.BankKeeper, k Keeper) sdk.Invariant {
message := sdk.FormatInvariant(types.ModuleName, "fully backed broken", "sum of minor balances greater than module account")
return func(ctx sdk.Context) (string, bool) {
totalMinorBalances := sdk.ZeroInt()
k.IterateAllAccounts(ctx, func(acc types.Account) bool {
totalMinorBalances = totalMinorBalances.Add(acc.Balance)
@ -55,7 +54,6 @@ func SmallBalancesInvariant(_ types.BankKeeper, k Keeper) sdk.Invariant {
message := sdk.FormatInvariant(types.ModuleName, "small balances broken", "minor balances not all less than overflow")
return func(ctx sdk.Context) (string, bool) {
k.IterateAllAccounts(ctx, func(account types.Account) bool {
if account.Balance.GTE(ConversionMultiplier) {
broken = true

View File

@ -78,7 +78,6 @@ func (suite *invariantTestSuite) runInvariant(route string, invariant func(bankK
}
func (suite *invariantTestSuite) TestFullyBackedInvariant() {
// default state is valid
_, broken := suite.runInvariant("fully-backed", keeper.FullyBackedInvariant)
suite.Equal(false, broken)

View File

@ -12,9 +12,7 @@ const (
StoreKey = "utilevm" // cannot be emvutil due to collision with x/evm
)
var (
AccountStoreKeyPrefix = []byte{0x00} // prefix for keys that store accounts
)
var AccountStoreKeyPrefix = []byte{0x00} // prefix for keys that store accounts
// AccountStoreKey turns an address to a key used to get the account from the store
func AccountStoreKey(addr sdk.AccAddress) []byte {

View File

@ -39,7 +39,6 @@ func (suite *GenesisTestSuite) SetupTest() {
}
func (suite *GenesisTestSuite) Test_InitExportGenesis() {
loanToValue, _ := sdk.NewDecFromStr("0.6")
params := types.NewParams(
types.MoneyMarkets{

View File

@ -427,7 +427,6 @@ func (suite *KeeperTestSuite) TestBorrow() {
}
func (suite *KeeperTestSuite) TestValidateBorrow() {
blockDuration := time.Second * 3600 * 24 // long blocks to accumulate larger interest
_, addrs := app.GeneratePrivKeyAddressPairs(5)

View File

@ -55,7 +55,6 @@ func (suite *grpcQueryTestSuite) SetupTest() {
addrs,
),
)
}
func (suite *grpcQueryTestSuite) TestGrpcQueryParams() {

View File

@ -60,7 +60,6 @@ func (k Keeper) ApplyInterestRateUpdates(ctx sdk.Context) {
// AccrueInterest applies accrued interest to total borrows and reserves by calculating
// interest from the last checkpoint time and writing the updated values to the store.
func (k Keeper) AccrueInterest(ctx sdk.Context, denom string) error {
previousAccrualTime, found := k.GetPreviousAccrualTime(ctx, denom)
if !found {
k.SetPreviousAccrualTime(ctx, denom, ctx.BlockTime())

View File

@ -26,7 +26,8 @@ type Keeper struct {
// NewKeeper creates a new keeper
func NewKeeper(cdc codec.Codec, key sdk.StoreKey, paramstore paramtypes.Subspace,
ak types.AccountKeeper, bk types.BankKeeper,
pfk types.PricefeedKeeper, auk types.AuctionKeeper) Keeper {
pfk types.PricefeedKeeper, auk types.AuctionKeeper,
) Keeper {
if !paramstore.HasKeyTable() {
paramstore = paramstore.WithKeyTable(types.ParamKeyTable())
}

View File

@ -62,7 +62,6 @@ func (suite *KeeperTestSuite) TestGetSetDeleteDeposit() {
_, f = suite.keeper.GetDeposit(suite.ctx, sdk.AccAddress("test"))
suite.Require().False(f)
}
func (suite *KeeperTestSuite) TestIterateDeposits() {

View File

@ -73,7 +73,8 @@ func (k Keeper) AttemptKeeperLiquidation(ctx sdk.Context, keeper sdk.AccAddress,
// SeizeDeposits seizes a list of deposits and sends them to auction
func (k Keeper) SeizeDeposits(ctx sdk.Context, keeper sdk.AccAddress, deposit types.Deposit,
borrow types.Borrow, dDenoms, bDenoms []string) error {
borrow types.Borrow, dDenoms, bDenoms []string,
) error {
liqMap, err := k.LoadLiquidationData(ctx, deposit, borrow)
if err != nil {
return err
@ -146,7 +147,8 @@ func (k Keeper) SeizeDeposits(ctx sdk.Context, keeper sdk.AccAddress, deposit ty
// StartAuctions attempts to start auctions for seized assets
func (k Keeper) StartAuctions(ctx sdk.Context, borrower sdk.AccAddress, borrows, deposits sdk.Coins,
depositCoinValues, borrowCoinValues types.ValuationMap, ltv sdk.Dec, liqMap map[string]LiqData) (sdk.Coins, error) {
depositCoinValues, borrowCoinValues types.ValuationMap, ltv sdk.Dec, liqMap map[string]LiqData,
) (sdk.Coins, error) {
// Sort keys to ensure deterministic behavior
bKeys := borrowCoinValues.GetSortedKeys()
dKeys := depositCoinValues.GetSortedKeys()
@ -387,7 +389,6 @@ func (k Keeper) LoadLiquidationData(ctx sdk.Context, deposit types.Deposit, borr
mm, found := k.GetMoneyMarket(ctx, denom)
if !found {
return liqMap, sdkerrors.Wrapf(types.ErrMarketNotFound, "no market found for denom %s", denom)
}
priceData, err := k.pricefeedKeeper.GetCurrentPrice(ctx, mm.SpotMarketID)

View File

@ -82,7 +82,6 @@ func queryGetModAccounts(ctx sdk.Context, req abci.RequestQuery, k Keeper, legac
}
bz, err := codec.MarshalJSONIndent(legacyQuerierCdc, response)
if err != nil {
return nil, sdkerrors.Wrap(sdkerrors.ErrJSONMarshal, err.Error())
}
@ -91,7 +90,6 @@ func queryGetModAccounts(ctx sdk.Context, req abci.RequestQuery, k Keeper, legac
}
func queryGetDeposits(ctx sdk.Context, req abci.RequestQuery, k Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) {
var params types.QueryDepositsParams
err := legacyQuerierCdc.UnmarshalJSON(req.Data, &params)
if err != nil {
@ -163,7 +161,6 @@ func queryGetDeposits(ctx sdk.Context, req abci.RequestQuery, k Keeper, legacyQu
}
func queryGetUnsyncedDeposits(ctx sdk.Context, req abci.RequestQuery, k Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) {
var params types.QueryUnsyncedDepositsParams
err := legacyQuerierCdc.UnmarshalJSON(req.Data, &params)
if err != nil {
@ -219,7 +216,6 @@ func queryGetUnsyncedDeposits(ctx sdk.Context, req abci.RequestQuery, k Keeper,
}
func queryGetBorrows(ctx sdk.Context, req abci.RequestQuery, k Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) {
var params types.QueryBorrowsParams
err := legacyQuerierCdc.UnmarshalJSON(req.Data, &params)
if err != nil {
@ -291,7 +287,6 @@ func queryGetBorrows(ctx sdk.Context, req abci.RequestQuery, k Keeper, legacyQue
}
func queryGetUnsyncedBorrows(ctx sdk.Context, req abci.RequestQuery, k Keeper, legacyQuerierCdc *codec.LegacyAmino) ([]byte, error) {
var params types.QueryUnsyncedBorrowsParams
err := legacyQuerierCdc.UnmarshalJSON(req.Data, &params)
if err != nil {

View File

@ -207,7 +207,6 @@ func (suite *KeeperTestSuite) TestWithdraw() {
suite.Require().True(strings.Contains(err.Error(), tc.errArgs.contains))
}
})
}
}

View File

@ -122,7 +122,6 @@ func (bif BorrowInterestFactor) Validate() error {
}
if bif.Value.IsNegative() {
return fmt.Errorf("borrow interest factor value cannot be negative: %s", bif)
}
return nil
}

View File

@ -113,5 +113,4 @@ func TestBorrow_NormalizedBorrow(t *testing.T) {
}
})
}
}

View File

@ -122,7 +122,6 @@ func (sif SupplyInterestFactor) Validate() error {
}
if sif.Value.IsNegative() {
return fmt.Errorf("supply interest factor value cannot be negative: %s", sif)
}
return nil
}

View File

@ -113,5 +113,4 @@ func TestDeposit_NormalizedDeposit(t *testing.T) {
}
})
}
}

View File

@ -10,7 +10,8 @@ import (
// NewGenesisState returns a new genesis state
func NewGenesisState(
params Params, prevAccumulationTimes GenesisAccumulationTimes, deposits Deposits,
borrows Borrows, totalSupplied, totalBorrowed, totalReserves sdk.Coins) GenesisState {
borrows Borrows, totalSupplied, totalBorrowed, totalReserves sdk.Coins,
) GenesisState {
return GenesisState{
Params: params,
PreviousAccumulationTimes: prevAccumulationTimes,
@ -38,7 +39,6 @@ func DefaultGenesisState() GenesisState {
// Validate performs basic validation of genesis data returning an
// error for any failed validation criteria.
func (gs GenesisState) Validate() error {
if err := gs.Params.Validate(); err != nil {
return err
}

View File

@ -61,7 +61,8 @@ func (bl BorrowLimit) Equal(blCompareTo BorrowLimit) bool {
// NewMoneyMarket returns a new MoneyMarket
func NewMoneyMarket(denom string, borrowLimit BorrowLimit, spotMarketID string, conversionFactor sdk.Int,
interestRateModel InterestRateModel, reserveFactor, keeperRewardPercentage sdk.Dec) MoneyMarket {
interestRateModel InterestRateModel, reserveFactor, keeperRewardPercentage sdk.Dec,
) MoneyMarket {
return MoneyMarket{
Denom: denom,
BorrowLimit: borrowLimit,

View File

@ -14,8 +14,10 @@ import (
"github.com/kava-labs/kava/x/incentive/types"
)
const multiplierFlag = "multiplier"
const multiplierFlagShort = "m"
const (
multiplierFlag = "multiplier"
multiplierFlagShort = "m"
)
// GetTxCmd returns the transaction cli commands for the incentive module
func GetTxCmd() *cobra.Command {
@ -42,7 +44,6 @@ func GetTxCmd() *cobra.Command {
}
func getCmdClaimCdp() *cobra.Command {
cmd := &cobra.Command{
Use: "claim-cdp [multiplier]",
Short: "claim USDX minting rewards using a given multiplier",

View File

@ -183,7 +183,6 @@ func executeSwapRewardsQuery(w http.ResponseWriter, cliCtx client.Context, param
}
func executeAllRewardQueries(w http.ResponseWriter, cliCtx client.Context, params types.QueryRewardsParams) {
paramsBz, err := cliCtx.LegacyAmino.MarshalJSON(params)
if err != nil {
rest.WriteErrorResponse(w, http.StatusBadRequest, fmt.Sprintf("failed to marshal query params: %s", err))

View File

@ -29,14 +29,17 @@ func usdxMintingGenerator(req PostClaimReq) (sdk.Msg, error) {
msg := types.NewMsgClaimUSDXMintingReward(req.Sender.String(), req.DenomsToClaim[0].MultiplierName)
return &msg, nil
}
func hardGenerator(req PostClaimReq) (sdk.Msg, error) {
msg := types.NewMsgClaimHardReward(req.Sender.String(), req.DenomsToClaim)
return &msg, nil
}
func delegatorGenerator(req PostClaimReq) (sdk.Msg, error) {
msg := types.NewMsgClaimDelegatorReward(req.Sender.String(), req.DenomsToClaim)
return &msg, nil
}
func swapGenerator(req PostClaimReq) (sdk.Msg, error) {
msg := types.NewMsgClaimSwapReward(req.Sender.String(), req.DenomsToClaim)
return &msg, nil

View File

@ -15,11 +15,13 @@ type Hooks struct {
k Keeper
}
var _ cdptypes.CDPHooks = Hooks{}
var _ hardtypes.HARDHooks = Hooks{}
var _ stakingtypes.StakingHooks = Hooks{}
var _ swaptypes.SwapHooks = Hooks{}
var _ savingstypes.SavingsHooks = Hooks{}
var (
_ cdptypes.CDPHooks = Hooks{}
_ hardtypes.HARDHooks = Hooks{}
_ stakingtypes.StakingHooks = Hooks{}
_ swaptypes.SwapHooks = Hooks{}
_ savingstypes.SavingsHooks = Hooks{}
)
// Hooks create new incentive hooks
func (k Keeper) Hooks() Hooks { return Hooks{k} }

View File

@ -30,7 +30,6 @@ func NewKeeper(
cdpk types.CdpKeeper, hk types.HardKeeper, ak types.AccountKeeper, stk types.StakingKeeper,
swpk types.SwapKeeper, svk types.SavingsKeeper,
) Keeper {
if !paramstore.HasKeyTable() {
paramstore = paramstore.WithKeyTable(types.ParamKeyTable())
}
@ -66,7 +65,6 @@ func (k Keeper) SetUSDXMintingClaim(ctx sdk.Context, c types.USDXMintingClaim) {
store := prefix.NewStore(ctx.KVStore(k.key), types.USDXMintingClaimKeyPrefix)
bz := k.cdc.MustMarshal(&c)
store.Set(c.Owner, bz)
}
// DeleteUSDXMintingClaim deletes the claim in the store corresponding to the input address, collateral type, and id

Some files were not shown because too many files have changed in this diff Show More