From 9ffdc37c3d473e3c640e8fd85872f3a2f178c857 Mon Sep 17 00:00:00 2001 From: Nicolas Lara Date: Wed, 10 Aug 2022 14:45:56 +0200 Subject: [PATCH] make format --- app/app.go | 7 ++--- x/epochs/module.go | 3 +-- x/gamm/twap/hook_listener.go | 6 +++-- x/gamm/twap/keeper_test.go | 6 +++-- x/gamm/twap/module.go | 3 +-- x/gamm/twap/store_test.go | 36 +++++++++++++++++--------- x/ibc-rate-limit/ibc_middleware.go | 6 +++-- x/ibc-rate-limit/rate_limit.go | 3 ++- x/ibc-rate-limit/testutil/chain.go | 6 ++--- x/ibc-rate-limit/testutil/wasm.go | 3 ++- x/ibc-rate-limit/types/params.go | 2 +- x/incentives/keeper/msg_server_test.go | 1 - x/incentives/module.go | 3 +-- x/lockup/module.go | 3 +-- x/mint/keeper/export_test.go | 4 +-- x/mint/keeper/keeper_test.go | 4 +-- x/pool-incentives/module.go | 3 +-- x/superfluid/keeper/stake_test.go | 1 - x/superfluid/module.go | 3 +-- x/tokenfactory/module.go | 3 +-- x/txfees/module.go | 3 +-- 21 files changed, 58 insertions(+), 51 deletions(-) diff --git a/app/app.go b/app/app.go index 9e43cc96028..2299c0e198e 100644 --- a/app/app.go +++ b/app/app.go @@ -2,15 +2,16 @@ package app import ( "fmt" - capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper" - stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" - ibckeeper "github.com/cosmos/ibc-go/v3/modules/core/keeper" "io" "net/http" "os" "path/filepath" "strings" + capabilitykeeper "github.com/cosmos/cosmos-sdk/x/capability/keeper" + stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper" + ibckeeper "github.com/cosmos/ibc-go/v3/modules/core/keeper" + "github.com/CosmWasm/wasmd/x/wasm" "github.com/gorilla/mux" "github.com/rakyll/statik/fs" diff --git a/x/epochs/module.go b/x/epochs/module.go index 3af73db3c68..289ca580926 100644 --- a/x/epochs/module.go +++ b/x/epochs/module.go @@ -44,8 +44,7 @@ var ( // ---------------------------------------------------------------------------- // AppModuleBasic implements the AppModuleBasic interface for the capability module. -type AppModuleBasic struct { -} +type AppModuleBasic struct{} func NewAppModuleBasic() AppModuleBasic { return AppModuleBasic{} diff --git a/x/gamm/twap/hook_listener.go b/x/gamm/twap/hook_listener.go index cad053ab64a..1b3c550ddd3 100644 --- a/x/gamm/twap/hook_listener.go +++ b/x/gamm/twap/hook_listener.go @@ -9,8 +9,10 @@ import ( "github.com/osmosis-labs/osmosis/v10/x/gamm/types" ) -var _ types.GammHooks = &gammhook{} -var _ epochtypes.EpochHooks = &epochhook{} +var ( + _ types.GammHooks = &gammhook{} + _ epochtypes.EpochHooks = &epochhook{} +) type epochhook struct { k Keeper diff --git a/x/gamm/twap/keeper_test.go b/x/gamm/twap/keeper_test.go index 4ff8a68e015..97414ffcc8b 100644 --- a/x/gamm/twap/keeper_test.go +++ b/x/gamm/twap/keeper_test.go @@ -12,8 +12,10 @@ import ( "github.com/osmosis-labs/osmosis/v10/x/gamm/twap/types" ) -var defaultUniV2Coins = sdk.NewCoins(sdk.NewInt64Coin("token/B", 1_000_000_000), sdk.NewInt64Coin("token/A", 1_000_000_000)) -var baseTime = time.Unix(1257894000, 0).UTC() +var ( + defaultUniV2Coins = sdk.NewCoins(sdk.NewInt64Coin("token/B", 1_000_000_000), sdk.NewInt64Coin("token/A", 1_000_000_000)) + baseTime = time.Unix(1257894000, 0).UTC() +) type TestSuite struct { apptesting.KeeperTestHelper diff --git a/x/gamm/twap/module.go b/x/gamm/twap/module.go index 178c65219f5..8a2cecb4921 100644 --- a/x/gamm/twap/module.go +++ b/x/gamm/twap/module.go @@ -23,8 +23,7 @@ var ( _ module.AppModuleBasic = AppModuleBasic{} ) -type AppModuleBasic struct { -} +type AppModuleBasic struct{} func (AppModuleBasic) Name() string { return types.ModuleName } diff --git a/x/gamm/twap/store_test.go b/x/gamm/twap/store_test.go index 50712277af5..74e15b496d8 100644 --- a/x/gamm/twap/store_test.go +++ b/x/gamm/twap/store_test.go @@ -84,12 +84,14 @@ func (s *TestSuite) TestGetAllMostRecentRecordsForPool() { recordsToSet: []types.TwapRecord{ newEmptyPriceRecord(1, baseTime, "tokenB", "tokenA"), newEmptyPriceRecord(1, baseTime, "tokenC", "tokenB"), - newEmptyPriceRecord(1, baseTime, "tokenC", "tokenA")}, + newEmptyPriceRecord(1, baseTime, "tokenC", "tokenA"), + }, poolId: 1, expectedRecords: []types.TwapRecord{ newEmptyPriceRecord(1, baseTime, "tokenB", "tokenA"), newEmptyPriceRecord(1, baseTime, "tokenC", "tokenA"), - newEmptyPriceRecord(1, baseTime, "tokenC", "tokenB")}, + newEmptyPriceRecord(1, baseTime, "tokenC", "tokenB"), + }, }, } @@ -136,40 +138,50 @@ func (s *TestSuite) TestGetRecordAtOrBeforeTime() { "rev at latest (exact)": {[]types.TwapRecord{baseRecord}, defaultRevInputAt(baseTime), baseRecord, true}, "get latest (exact) w/ past entries": { - []types.TwapRecord{tMin1Record, baseRecord}, defaultInputAt(baseTime), baseRecord, false}, + []types.TwapRecord{tMin1Record, baseRecord}, defaultInputAt(baseTime), baseRecord, false, + }, "get entry (exact) w/ a subsequent entry": { - []types.TwapRecord{tMin1Record, baseRecord}, defaultInputAt(tMin1), tMin1Record, false}, + []types.TwapRecord{tMin1Record, baseRecord}, defaultInputAt(tMin1), tMin1Record, false, + }, "get sandwitched entry (exact)": { - []types.TwapRecord{tMin1Record, baseRecord, tPlus1Record}, defaultInputAt(baseTime), baseRecord, false}, + []types.TwapRecord{tMin1Record, baseRecord, tPlus1Record}, defaultInputAt(baseTime), baseRecord, false, + }, "rev sandwitched entry (exact)": { - []types.TwapRecord{tMin1Record, baseRecord, tPlus1Record}, defaultRevInputAt(baseTime), baseRecord, true}, + []types.TwapRecord{tMin1Record, baseRecord, tPlus1Record}, defaultRevInputAt(baseTime), baseRecord, true, + }, "get future": {[]types.TwapRecord{baseRecord}, defaultInputAt(tPlus1), baseRecord, false}, "get future w/ past entries": {[]types.TwapRecord{tMin1Record, baseRecord}, defaultInputAt(tPlus1), baseRecord, false}, "get in between entries (2 entry)": { []types.TwapRecord{tMin1Record, baseRecord}, - defaultInputAt(baseTime.Add(-time.Millisecond)), tMin1Record, false}, + defaultInputAt(baseTime.Add(-time.Millisecond)), tMin1Record, false, + }, "get in between entries (3 entry)": { []types.TwapRecord{tMin1Record, baseRecord, tPlus1Record}, - defaultInputAt(baseTime.Add(-time.Millisecond)), tMin1Record, false}, + defaultInputAt(baseTime.Add(-time.Millisecond)), tMin1Record, false, + }, "get in between entries (3 entry) #2": { []types.TwapRecord{tMin1Record, baseRecord, tPlus1Record}, - defaultInputAt(baseTime.Add(time.Millisecond)), baseRecord, false}, + defaultInputAt(baseTime.Add(time.Millisecond)), baseRecord, false, + }, "query too old": { []types.TwapRecord{tMin1Record, baseRecord, tPlus1Record}, defaultInputAt(baseTime.Add(-time.Second * 2)), - baseRecord, true}, + baseRecord, true, + }, "non-existent pool ID": { []types.TwapRecord{tMin1Record, baseRecord, tPlus1Record}, - wrongPoolIdInputAt(baseTime), baseRecord, true}, + wrongPoolIdInputAt(baseTime), baseRecord, true, + }, "pool2 record get": { recordsToSet: []types.TwapRecord{newEmptyPriceRecord(2, baseTime, "tokenB", "tokenA")}, input: wrongPoolIdInputAt(baseTime), expectedRecord: newEmptyPriceRecord(2, baseTime, "tokenB", "tokenA"), - expErr: false}, + expErr: false, + }, } for name, test := range tests { s.Run(name, func() { diff --git a/x/ibc-rate-limit/ibc_middleware.go b/x/ibc-rate-limit/ibc_middleware.go index fc360e0a6ea..b2375804004 100644 --- a/x/ibc-rate-limit/ibc_middleware.go +++ b/x/ibc-rate-limit/ibc_middleware.go @@ -16,8 +16,10 @@ import ( lockupkeeper "github.com/osmosis-labs/osmosis/v10/x/lockup/keeper" ) -var _ porttypes.Middleware = &IBCModule{} -var _ porttypes.ICS4Wrapper = &ICS4Middleware{} +var ( + _ porttypes.Middleware = &IBCModule{} + _ porttypes.ICS4Wrapper = &ICS4Middleware{} +) type ICS4Middleware struct { channel porttypes.ICS4Wrapper diff --git a/x/ibc-rate-limit/rate_limit.go b/x/ibc-rate-limit/rate_limit.go index e0fed44596b..82a307ddfa5 100644 --- a/x/ibc-rate-limit/rate_limit.go +++ b/x/ibc-rate-limit/rate_limit.go @@ -3,13 +3,14 @@ package ibc_rate_limit import ( "encoding/json" "fmt" + "strings" + wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" transfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types" "github.com/cosmos/ibc-go/v3/modules/core/exported" "github.com/osmosis-labs/osmosis/v10/x/ibc-rate-limit/types" - "strings" ) func CheckRateLimits(ctx sdk.Context, wasmKeeper *wasmkeeper.Keeper, msgType, contractParam, channelValue, sourceChannel string, sender sdk.AccAddress, amount string) error { diff --git a/x/ibc-rate-limit/testutil/chain.go b/x/ibc-rate-limit/testutil/chain.go index ca0fc4ffd68..de5fcaeeb57 100644 --- a/x/ibc-rate-limit/testutil/chain.go +++ b/x/ibc-rate-limit/testutil/chain.go @@ -1,16 +1,17 @@ package osmosisibctesting import ( + "time" + "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/ibc-go/v3/testing" + ibctesting "github.com/cosmos/ibc-go/v3/testing" "github.com/cosmos/ibc-go/v3/testing/simapp/helpers" "github.com/osmosis-labs/osmosis/v10/app" abci "github.com/tendermint/tendermint/abci/types" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - "time" ) type TestChain struct { @@ -56,7 +57,6 @@ func SignAndDeliver( txCfg client.TxConfig, app *baseapp.BaseApp, header tmproto.Header, msgs []sdk.Msg, chainID string, accNums, accSeqs []uint64, priv ...cryptotypes.PrivKey, ) (sdk.GasInfo, *sdk.Result, error) { - tx, _ := helpers.GenTx( txCfg, msgs, diff --git a/x/ibc-rate-limit/testutil/wasm.go b/x/ibc-rate-limit/testutil/wasm.go index 39c4c879f3f..1aafb15512c 100644 --- a/x/ibc-rate-limit/testutil/wasm.go +++ b/x/ibc-rate-limit/testutil/wasm.go @@ -2,6 +2,8 @@ package osmosisibctesting import ( "fmt" + "io/ioutil" + wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -9,7 +11,6 @@ import ( transfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types" "github.com/osmosis-labs/osmosis/v10/x/ibc-rate-limit/types" "github.com/stretchr/testify/suite" - "io/ioutil" ) func (chain *TestChain) StoreContractCode(suite *suite.Suite) { diff --git a/x/ibc-rate-limit/types/params.go b/x/ibc-rate-limit/types/params.go index 316f946e206..2651c6ba42d 100644 --- a/x/ibc-rate-limit/types/params.go +++ b/x/ibc-rate-limit/types/params.go @@ -2,6 +2,7 @@ package types import ( "fmt" + sdk "github.com/cosmos/cosmos-sdk/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" @@ -54,7 +55,6 @@ func validateContractAddress(i interface{}) error { bech32, err := sdk.AccAddressFromBech32(v) if err != nil { return err - } err = sdk.VerifyAddressFormat(bech32) diff --git a/x/incentives/keeper/msg_server_test.go b/x/incentives/keeper/msg_server_test.go index f6c8518a957..72b0f04dd21 100644 --- a/x/incentives/keeper/msg_server_test.go +++ b/x/incentives/keeper/msg_server_test.go @@ -134,7 +134,6 @@ func (suite *KeeperTestSuite) TestCreateGauge_Fee() { } func (suite *KeeperTestSuite) TestAddToGauge_Fee() { - tests := []struct { name string accountBalanceToFund sdk.Coins diff --git a/x/incentives/module.go b/x/incentives/module.go index 18f3dfcb9d7..d6bba6ce7a7 100644 --- a/x/incentives/module.go +++ b/x/incentives/module.go @@ -44,8 +44,7 @@ var ( // ---------------------------------------------------------------------------- // Implements the AppModuleBasic interface for the module. -type AppModuleBasic struct { -} +type AppModuleBasic struct{} // NewAppModuleBasic creates a new AppModuleBasic struct. func NewAppModuleBasic() AppModuleBasic { diff --git a/x/lockup/module.go b/x/lockup/module.go index 74522afdca2..9882046099d 100644 --- a/x/lockup/module.go +++ b/x/lockup/module.go @@ -47,8 +47,7 @@ var ( // ---------------------------------------------------------------------------- // AppModuleBasic implements the AppModuleBasic interface for the capability module. -type AppModuleBasic struct { -} +type AppModuleBasic struct{} func NewAppModuleBasic() AppModuleBasic { return AppModuleBasic{} diff --git a/x/mint/keeper/export_test.go b/x/mint/keeper/export_test.go index 90cfc2453e8..d7db176e64c 100644 --- a/x/mint/keeper/export_test.go +++ b/x/mint/keeper/export_test.go @@ -16,9 +16,7 @@ const ( DeveloperVestingAmount = developerVestingAmount ) -var ( - GetProportions = getProportions -) +var GetProportions = getProportions func (k Keeper) DistributeToModule(ctx sdk.Context, recipientModule string, mintedCoin sdk.Coin, proportion sdk.Dec) (sdk.Int, error) { return k.distributeToModule(ctx, recipientModule, mintedCoin, proportion) diff --git a/x/mint/keeper/keeper_test.go b/x/mint/keeper/keeper_test.go index d05d0711ecf..acb2da1a059 100644 --- a/x/mint/keeper/keeper_test.go +++ b/x/mint/keeper/keeper_test.go @@ -158,9 +158,7 @@ func (suite *KeeperTestSuite) TestDistributeMintedCoin() { mintAmount = 10000 ) - var ( - params = types.DefaultParams() - ) + params := types.DefaultParams() tests := []struct { name string diff --git a/x/pool-incentives/module.go b/x/pool-incentives/module.go index 5f963bde10d..fddd674fa32 100644 --- a/x/pool-incentives/module.go +++ b/x/pool-incentives/module.go @@ -40,8 +40,7 @@ var ( _ module.AppModuleSimulation = AppModule{} ) -type AppModuleBasic struct { -} +type AppModuleBasic struct{} // Name returns the pool-incentives module's name. func (AppModuleBasic) Name() string { return types.ModuleName } diff --git a/x/superfluid/keeper/stake_test.go b/x/superfluid/keeper/stake_test.go index ad1b52b6fac..5f16df89e18 100644 --- a/x/superfluid/keeper/stake_test.go +++ b/x/superfluid/keeper/stake_test.go @@ -514,7 +514,6 @@ func (suite *KeeperTestSuite) TestRefreshIntermediaryDelegationAmounts() { refreshed := suite.App.BankKeeper.GetBalance(suite.Ctx, intermediaryAcc.GetAccAddress(), sdk.DefaultBondDenom) suite.Require().True(refreshed.IsZero()) } - }) } } diff --git a/x/superfluid/module.go b/x/superfluid/module.go index c53127ca2ff..386b20695ae 100644 --- a/x/superfluid/module.go +++ b/x/superfluid/module.go @@ -43,8 +43,7 @@ var ( // ---------------------------------------------------------------------------- // AppModuleBasic implements the AppModuleBasic interface for the capability module. -type AppModuleBasic struct { -} +type AppModuleBasic struct{} func NewAppModuleBasic() AppModuleBasic { return AppModuleBasic{} diff --git a/x/tokenfactory/module.go b/x/tokenfactory/module.go index 5a694320045..a368632a01e 100644 --- a/x/tokenfactory/module.go +++ b/x/tokenfactory/module.go @@ -41,8 +41,7 @@ var ( // ---------------------------------------------------------------------------- // AppModuleBasic implements the AppModuleBasic interface for the capability module. -type AppModuleBasic struct { -} +type AppModuleBasic struct{} func NewAppModuleBasic() AppModuleBasic { return AppModuleBasic{} diff --git a/x/txfees/module.go b/x/txfees/module.go index 943486f5151..b11927dcf3e 100644 --- a/x/txfees/module.go +++ b/x/txfees/module.go @@ -42,8 +42,7 @@ const ModuleName = types.ModuleName // ---------------------------------------------------------------------------- // AppModuleBasic implements the AppModuleBasic interface for the txfees module. -type AppModuleBasic struct { -} +type AppModuleBasic struct{} func NewAppModuleBasic() AppModuleBasic { return AppModuleBasic{}