From 70605a28e8d2c2cc1c43cd39d439306e9a288959 Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Wed, 11 May 2022 11:20:57 +0200 Subject: [PATCH] fix nits --- crypto/ledger/ledger_secp256k1.go | 4 +- server/config/config_test.go | 1 - server/mock/app.go | 8 +--- simapp/simd/cmd/root.go | 3 +- snapshots/chunk.go | 1 - x/authz/keeper/grpc_query.go | 8 +--- x/authz/keeper/keeper.go | 4 +- x/distribution/types/query.go | 8 +--- x/gov/keeper/querier_test.go | 4 +- x/group/keeper/keeper_test.go | 5 +-- x/group/module/abci_test.go | 5 +-- x/staking/client/testutil/test_helpers.go | 4 +- x/staking/keeper/delegation.go | 45 ++++++----------------- x/staking/types/authz.go | 4 +- 14 files changed, 25 insertions(+), 79 deletions(-) diff --git a/crypto/ledger/ledger_secp256k1.go b/crypto/ledger/ledger_secp256k1.go index 91051a037518..dffded571ab5 100644 --- a/crypto/ledger/ledger_secp256k1.go +++ b/crypto/ledger/ledger_secp256k1.go @@ -100,9 +100,7 @@ func (pkl PrivKeyLedgerSecp256k1) Sign(message []byte) ([]byte, error) { } // ShowAddress triggers a ledger device to show the corresponding address. -func ShowAddress(path hd.BIP44Params, expectedPubKey types.PubKey, - accountAddressPrefix string, -) error { +func ShowAddress(path hd.BIP44Params, expectedPubKey types.PubKey, accountAddressPrefix string) error { device, err := getDevice() if err != nil { return err diff --git a/server/config/config_test.go b/server/config/config_test.go index b38afb303162..442e56026ec4 100644 --- a/server/config/config_test.go +++ b/server/config/config_test.go @@ -7,7 +7,6 @@ import ( "github.com/spf13/viper" "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/server/mock/app.go b/server/mock/app.go index ae41a2919c8c..83e562223558 100644 --- a/server/mock/app.go +++ b/server/mock/app.go @@ -136,9 +136,7 @@ func InitChainer(key storetypes.StoreKey) func(sdk.Context, abci.RequestInitChai // AppGenState can be passed into InitCmd, returns a static string of a few // key-values that can be parsed by InitChainer -func AppGenState(_ *codec.LegacyAmino, _ types.GenesisDoc, _ []json.RawMessage) (appState json. - RawMessage, err error, -) { +func AppGenState(_ *codec.LegacyAmino, _ types.GenesisDoc, _ []json.RawMessage) (appState json.RawMessage, err error) { appState = json.RawMessage(`{ "values": [ { @@ -155,9 +153,7 @@ func AppGenState(_ *codec.LegacyAmino, _ types.GenesisDoc, _ []json.RawMessage) } // AppGenStateEmpty returns an empty transaction state for mocking. -func AppGenStateEmpty(_ *codec.LegacyAmino, _ types.GenesisDoc, _ []json.RawMessage) ( - appState json.RawMessage, err error, -) { +func AppGenStateEmpty(_ *codec.LegacyAmino, _ types.GenesisDoc, _ []json.RawMessage) (appState json.RawMessage, err error) { appState = json.RawMessage(``) return } diff --git a/simapp/simd/cmd/root.go b/simapp/simd/cmd/root.go index 8bdf8df3dee2..cb0d3f6e0c34 100644 --- a/simapp/simd/cmd/root.go +++ b/simapp/simd/cmd/root.go @@ -297,8 +297,7 @@ func (a appCreator) newApp(logger log.Logger, db dbm.DB, traceStore io.Writer, a // appExport creates a new simapp (optionally at a given height) // and exports state. func (a appCreator) appExport( - logger log.Logger, db dbm.DB, traceStore io.Writer, height int64, forZeroHeight bool, jailAllowedAddrs []string, - appOpts servertypes.AppOptions, + logger log.Logger, db dbm.DB, traceStore io.Writer, height int64, forZeroHeight bool, jailAllowedAddrs []string, appOpts servertypes.AppOptions, ) (servertypes.ExportedApp, error) { var simApp *simapp.SimApp homePath, ok := appOpts.Get(flags.FlagHome).(string) diff --git a/snapshots/chunk.go b/snapshots/chunk.go index aa244d9a0335..74503f058027 100644 --- a/snapshots/chunk.go +++ b/snapshots/chunk.go @@ -5,7 +5,6 @@ import ( "math" snapshottypes "github.com/cosmos/cosmos-sdk/snapshots/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) diff --git a/x/authz/keeper/grpc_query.go b/x/authz/keeper/grpc_query.go index 488b948d252f..1156ac23521d 100644 --- a/x/authz/keeper/grpc_query.go +++ b/x/authz/keeper/grpc_query.go @@ -119,9 +119,7 @@ func (k Keeper) GranterGrants(c context.Context, req *authz.QueryGranterGrantsRe authzStore := prefix.NewStore(store, grantStoreKey(nil, granter, "")) var grants []*authz.GrantAuthorization - pageRes, err := query.FilteredPaginate(authzStore, req.Pagination, func(key []byte, value []byte, - accumulate bool, - ) (bool, error) { + pageRes, err := query.FilteredPaginate(authzStore, req.Pagination, func(key []byte, value []byte, accumulate bool) (bool, error) { auth, err := unmarshalAuthorization(k.cdc, value) if err != nil { return false, err @@ -173,9 +171,7 @@ func (k Keeper) GranteeGrants(c context.Context, req *authz.QueryGranteeGrantsRe store := prefix.NewStore(ctx.KVStore(k.storeKey), GrantKey) var authorizations []*authz.GrantAuthorization - pageRes, err := query.FilteredPaginate(store, req.Pagination, func(key []byte, value []byte, - accumulate bool, - ) (bool, error) { + pageRes, err := query.FilteredPaginate(store, req.Pagination, func(key []byte, value []byte, accumulate bool) (bool, error) { auth, err := unmarshalAuthorization(k.cdc, value) if err != nil { return false, err diff --git a/x/authz/keeper/keeper.go b/x/authz/keeper/keeper.go index 21d49651bd0a..a1fd37d57deb 100644 --- a/x/authz/keeper/keeper.go +++ b/x/authz/keeper/keeper.go @@ -288,9 +288,7 @@ func (k Keeper) setGrantQueueItem(ctx sdk.Context, expiration time.Time, } // insertIntoGrantQueue inserts a grant key into the grant queue -func (keeper Keeper) insertIntoGrantQueue(ctx sdk.Context, granter, grantee sdk.AccAddress, msgType string, - expiration time.Time, -) error { +func (keeper Keeper) insertIntoGrantQueue(ctx sdk.Context, granter, grantee sdk.AccAddress, msgType string, expiration time.Time) error { queueItems, err := keeper.getGrantQueueItem(ctx, expiration, granter, grantee) if err != nil { return err diff --git a/x/distribution/types/query.go b/x/distribution/types/query.go index 13423038b245..ef3d34ceae5a 100644 --- a/x/distribution/types/query.go +++ b/x/distribution/types/query.go @@ -15,9 +15,7 @@ type QueryDelegatorTotalRewardsResponse struct { } // NewQueryDelegatorTotalRewardsResponse constructs a QueryDelegatorTotalRewardsResponse -func NewQueryDelegatorTotalRewardsResponse(rewards []DelegationDelegatorReward, - total sdk.DecCoins, -) QueryDelegatorTotalRewardsResponse { +func NewQueryDelegatorTotalRewardsResponse(rewards []DelegationDelegatorReward, total sdk.DecCoins) QueryDelegatorTotalRewardsResponse { return QueryDelegatorTotalRewardsResponse{Rewards: rewards, Total: total} } @@ -35,8 +33,6 @@ func (res QueryDelegatorTotalRewardsResponse) String() string { // NewDelegationDelegatorReward constructs a DelegationDelegatorReward. //nolint:interfacer -func NewDelegationDelegatorReward(valAddr sdk.ValAddress, - reward sdk.DecCoins, -) DelegationDelegatorReward { +func NewDelegationDelegatorReward(valAddr sdk.ValAddress, reward sdk.DecCoins) DelegationDelegatorReward { return DelegationDelegatorReward{ValidatorAddress: valAddr.String(), Reward: reward} } diff --git a/x/gov/keeper/querier_test.go b/x/gov/keeper/querier_test.go index f4494e11f338..d47d87f2a256 100644 --- a/x/gov/keeper/querier_test.go +++ b/x/gov/keeper/querier_test.go @@ -127,9 +127,7 @@ func getQueriedVote(t *testing.T, ctx sdk.Context, cdc *codec.LegacyAmino, queri return vote } -func getQueriedVotes(t *testing.T, ctx sdk.Context, cdc *codec.LegacyAmino, querier sdk.Querier, - proposalID uint64, page, limit int, -) []v1.Vote { +func getQueriedVotes(t *testing.T, ctx sdk.Context, cdc *codec.LegacyAmino, querier sdk.Querier, proposalID uint64, page, limit int) []v1.Vote { query := abci.RequestQuery{ Path: strings.Join([]string{custom, types.QuerierRoute, v1.QueryVote}, "/"), Data: cdc.MustMarshalJSON(v1.NewQueryProposalVotesParams(proposalID, page, limit)), diff --git a/x/group/keeper/keeper_test.go b/x/group/keeper/keeper_test.go index dcad1aa23907..ab1287e8f59f 100644 --- a/x/group/keeper/keeper_test.go +++ b/x/group/keeper/keeper_test.go @@ -2829,10 +2829,7 @@ func (s *TestSuite) TestLeaveGroup() { } } -func submitProposal( - ctx context.Context, s *TestSuite, msgs []sdk.Msg, - proposers []string, -) uint64 { +func submitProposal(ctx context.Context, s *TestSuite, msgs []sdk.Msg, proposers []string) uint64 { proposalReq := &group.MsgSubmitProposal{ GroupPolicyAddress: s.groupPolicyAddr.String(), Proposers: proposers, diff --git a/x/group/module/abci_test.go b/x/group/module/abci_test.go index 0a37441ccbb2..fd298c14b54d 100644 --- a/x/group/module/abci_test.go +++ b/x/group/module/abci_test.go @@ -504,10 +504,7 @@ func TestEndBlockerTallying(t *testing.T) { } } -func submitProposal( - app *simapp.SimApp, ctx context.Context, msgs []sdk.Msg, - proposers []string, groupPolicyAddr sdk.AccAddress, -) (uint64, error) { +func submitProposal(app *simapp.SimApp, ctx context.Context, msgs []sdk.Msg, proposers []string, groupPolicyAddr sdk.AccAddress) (uint64, error) { proposalReq := &group.MsgSubmitProposal{ GroupPolicyAddress: groupPolicyAddr.String(), Proposers: proposers, diff --git a/x/staking/client/testutil/test_helpers.go b/x/staking/client/testutil/test_helpers.go index e54dc82bf39d..0fa752e05720 100644 --- a/x/staking/client/testutil/test_helpers.go +++ b/x/staking/client/testutil/test_helpers.go @@ -18,9 +18,7 @@ var commonArgs = []string{ } // MsgRedelegateExec creates a redelegate message. -func MsgRedelegateExec(clientCtx client.Context, from, src, dst, amount fmt.Stringer, - extraArgs ...string, -) (testutil.BufferWriter, error) { +func MsgRedelegateExec(clientCtx client.Context, from, src, dst, amount fmt.Stringer, extraArgs ...string) (testutil.BufferWriter, error) { args := []string{ src.String(), dst.String(), diff --git a/x/staking/keeper/delegation.go b/x/staking/keeper/delegation.go index 105f3fa9dae6..4c99e4adaedb 100644 --- a/x/staking/keeper/delegation.go +++ b/x/staking/keeper/delegation.go @@ -11,9 +11,7 @@ import ( ) // GetDelegation returns a specific delegation. -func (k Keeper) GetDelegation(ctx sdk.Context, - delAddr sdk.AccAddress, valAddr sdk.ValAddress, -) (delegation types.Delegation, found bool) { +func (k Keeper) GetDelegation(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) (delegation types.Delegation, found bool) { store := ctx.KVStore(k.storeKey) key := types.GetDelegationKey(delAddr, valAddr) @@ -72,9 +70,7 @@ func (k Keeper) GetValidatorDelegations(ctx sdk.Context, valAddr sdk.ValAddress) // GetDelegatorDelegations returns a given amount of all the delegations from a // delegator. -func (k Keeper) GetDelegatorDelegations(ctx sdk.Context, delegator sdk.AccAddress, - maxRetrieve uint16, -) (delegations []types.Delegation) { +func (k Keeper) GetDelegatorDelegations(ctx sdk.Context, delegator sdk.AccAddress, maxRetrieve uint16) (delegations []types.Delegation) { delegations = make([]types.Delegation, maxRetrieve) store := ctx.KVStore(k.storeKey) delegatorPrefixKey := types.GetDelegationsKey(delegator) @@ -121,9 +117,7 @@ func (k Keeper) RemoveDelegation(ctx sdk.Context, delegation types.Delegation) e } // GetUnbondingDelegations returns a given amount of all the delegator unbonding-delegations. -func (k Keeper) GetUnbondingDelegations(ctx sdk.Context, delegator sdk.AccAddress, - maxRetrieve uint16, -) (unbondingDelegations []types.UnbondingDelegation) { +func (k Keeper) GetUnbondingDelegations(ctx sdk.Context, delegator sdk.AccAddress, maxRetrieve uint16) (unbondingDelegations []types.UnbondingDelegation) { unbondingDelegations = make([]types.UnbondingDelegation, maxRetrieve) store := ctx.KVStore(k.storeKey) @@ -143,9 +137,7 @@ func (k Keeper) GetUnbondingDelegations(ctx sdk.Context, delegator sdk.AccAddres } // GetUnbondingDelegation returns a unbonding delegation. -func (k Keeper) GetUnbondingDelegation( - ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress, -) (ubd types.UnbondingDelegation, found bool) { +func (k Keeper) GetUnbondingDelegation(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) (ubd types.UnbondingDelegation, found bool) { store := ctx.KVStore(k.storeKey) key := types.GetUBDKey(delAddr, valAddr) value := store.Get(key) @@ -272,9 +264,7 @@ func (k Keeper) IterateDelegatorRedelegations(ctx sdk.Context, delegator sdk.Acc } // HasMaxUnbondingDelegationEntries - check if unbonding delegation has maximum number of entries. -func (k Keeper) HasMaxUnbondingDelegationEntries(ctx sdk.Context, - delegatorAddr sdk.AccAddress, validatorAddr sdk.ValAddress, -) bool { +func (k Keeper) HasMaxUnbondingDelegationEntries(ctx sdk.Context, delegatorAddr sdk.AccAddress, validatorAddr sdk.ValAddress) bool { ubd, found := k.GetUnbondingDelegation(ctx, delegatorAddr, validatorAddr) if !found { return false @@ -363,9 +353,7 @@ func (k Keeper) SetUBDQueueTimeSlice(ctx sdk.Context, timestamp time.Time, keys // InsertUBDQueue inserts an unbonding delegation to the appropriate timeslice // in the unbonding queue. -func (k Keeper) InsertUBDQueue(ctx sdk.Context, ubd types.UnbondingDelegation, - completionTime time.Time, -) { +func (k Keeper) InsertUBDQueue(ctx sdk.Context, ubd types.UnbondingDelegation, completionTime time.Time) { dvPair := types.DVPair{DelegatorAddress: ubd.DelegatorAddress, ValidatorAddress: ubd.ValidatorAddress} timeSlice := k.GetUBDQueueTimeSlice(ctx, completionTime) @@ -407,9 +395,7 @@ func (k Keeper) DequeueAllMatureUBDQueue(ctx sdk.Context, currTime time.Time) (m } // GetRedelegations returns a given amount of all the delegator redelegations. -func (k Keeper) GetRedelegations(ctx sdk.Context, delegator sdk.AccAddress, - maxRetrieve uint16, -) (redelegations []types.Redelegation) { +func (k Keeper) GetRedelegations(ctx sdk.Context, delegator sdk.AccAddress, maxRetrieve uint16) (redelegations []types.Redelegation) { redelegations = make([]types.Redelegation, maxRetrieve) store := ctx.KVStore(k.storeKey) @@ -429,9 +415,7 @@ func (k Keeper) GetRedelegations(ctx sdk.Context, delegator sdk.AccAddress, } // GetRedelegation returns a redelegation. -func (k Keeper) GetRedelegation(ctx sdk.Context, - delAddr sdk.AccAddress, valSrcAddr, valDstAddr sdk.ValAddress, -) (red types.Redelegation, found bool) { +func (k Keeper) GetRedelegation(ctx sdk.Context, delAddr sdk.AccAddress, valSrcAddr, valDstAddr sdk.ValAddress) (red types.Redelegation, found bool) { store := ctx.KVStore(k.storeKey) key := types.GetREDKey(delAddr, valSrcAddr, valDstAddr) @@ -464,9 +448,7 @@ func (k Keeper) GetRedelegationsFromSrcValidator(ctx sdk.Context, valAddr sdk.Va } // HasReceivingRedelegation checks if validator is receiving a redelegation. -func (k Keeper) HasReceivingRedelegation(ctx sdk.Context, - delAddr sdk.AccAddress, valDstAddr sdk.ValAddress, -) bool { +func (k Keeper) HasReceivingRedelegation(ctx sdk.Context, delAddr sdk.AccAddress, valDstAddr sdk.ValAddress) bool { store := ctx.KVStore(k.storeKey) prefix := types.GetREDsByDelToValDstIndexKey(delAddr, valDstAddr) @@ -477,10 +459,7 @@ func (k Keeper) HasReceivingRedelegation(ctx sdk.Context, } // HasMaxRedelegationEntries checks if redelegation has maximum number of entries. -func (k Keeper) HasMaxRedelegationEntries(ctx sdk.Context, - delegatorAddr sdk.AccAddress, validatorSrcAddr, - validatorDstAddr sdk.ValAddress, -) bool { +func (k Keeper) HasMaxRedelegationEntries(ctx sdk.Context, delegatorAddr sdk.AccAddress, validatorSrcAddr, validatorDstAddr sdk.ValAddress) bool { red, found := k.GetRedelegation(ctx, delegatorAddr, validatorSrcAddr, validatorDstAddr) if !found { return false @@ -598,9 +577,7 @@ func (k Keeper) SetRedelegationQueueTimeSlice(ctx sdk.Context, timestamp time.Ti // InsertRedelegationQueue insert an redelegation delegation to the appropriate // timeslice in the redelegation queue. -func (k Keeper) InsertRedelegationQueue(ctx sdk.Context, red types.Redelegation, - completionTime time.Time, -) { +func (k Keeper) InsertRedelegationQueue(ctx sdk.Context, red types.Redelegation, completionTime time.Time) { timeSlice := k.GetRedelegationQueueTimeSlice(ctx, completionTime) dvvTriplet := types.DVVTriplet{ DelegatorAddress: red.DelegatorAddress, diff --git a/x/staking/types/authz.go b/x/staking/types/authz.go index 9f2efe851dd8..1f9016cdbb6e 100644 --- a/x/staking/types/authz.go +++ b/x/staking/types/authz.go @@ -10,9 +10,7 @@ import ( // Tracking issues https://github.com/cosmos/cosmos-sdk/issues/9054, https://github.com/cosmos/cosmos-sdk/discussions/9072 const gasCostPerIteration = uint64(10) -var ( - _ authz.Authorization = &StakeAuthorization{} -) +var _ authz.Authorization = &StakeAuthorization{} // NewStakeAuthorization creates a new StakeAuthorization object. func NewStakeAuthorization(allowed []sdk.ValAddress, denied []sdk.ValAddress, authzType AuthorizationType, amount *sdk.Coin) (*StakeAuthorization, error) {