From 0ced31a5098cfaffb405bb472e7fe35f6d57a9b9 Mon Sep 17 00:00:00 2001 From: Matt Witkowski Date: Thu, 18 Apr 2024 20:00:02 -0400 Subject: [PATCH] Apply linter and fix basic linting issues on codebase (#1941) * Fix shadowing linting setting. * Fix linting for imports. * Changelog entry. * Fix imports order. * Lint majority of app package. * Additional linting to apps package. * Add linting to cmd package. * Add linting to genaccounts_test.go * Lint attribute module. * Lint metadata module. * Lint marker module. * Lint msgfees. * Lint name. * Additional internal linting * Basic linting on the rest of our modules. --- app/app.go | 26 +++++++++++++-------- app/app_test.go | 2 +- app/export.go | 9 +++++-- app/group.go | 3 +-- app/upgrades.go | 19 +++++---------- app/upgrades_test.go | 3 +-- cmd/provenanced/cmd/config.go | 6 ++--- cmd/provenanced/cmd/genaccounts.go | 20 +--------------- cmd/provenanced/cmd/genaccounts_test.go | 17 ++++---------- cmd/provenanced/cmd/pre_upgrade.go | 4 ++-- cmd/provenanced/cmd/root.go | 5 ++-- internal/handlers/msg_service_router.go | 2 +- internal/provwasm/simulation.go | 16 ++++++------- internal/provwasm/stargate_whitelist.go | 2 +- x/attribute/client/cli/query.go | 2 +- x/attribute/keeper/keeper.go | 7 +++--- x/attribute/keeper/query_server.go | 8 +++---- x/attribute/types/codec.go | 4 +--- x/attribute/wasm/query.go | 2 +- x/exchange/codec.go | 4 +--- x/exchange/keeper/commitments.go | 2 +- x/exchange/keeper/grpc_query.go | 2 +- x/exchange/keeper/market.go | 4 ++-- x/exchange/orders.go | 6 ++--- x/hold/client/cli/query.go | 2 +- x/ibchooks/client/cli/query.go | 2 +- x/ibchooks/wasm_hook.go | 2 +- x/ibcratelimit/client/cli/query.go | 2 +- x/ibcratelimit/codec.go | 4 +--- x/marker/client/cli/query.go | 2 +- x/marker/client/cli/tx.go | 5 +--- x/marker/keeper/query_server.go | 2 +- x/marker/simulation/operations.go | 2 +- x/marker/simulation/proposals.go | 6 ++--- x/marker/types/codec.go | 4 +--- x/marker/wasm/query.go | 2 +- x/metadata/client/cli/tx.go | 14 ++++------- x/metadata/keeper/msg_server.go | 6 ++--- x/metadata/keeper/query_server.go | 6 ++--- x/metadata/keeper/specification.go | 4 ++-- x/metadata/wasm/query.go | 2 +- x/msgfees/client/cli/query.go | 7 ++---- x/msgfees/client/cli/tx.go | 10 -------- x/msgfees/keeper/proposal_handler.go | 31 +++---------------------- x/msgfees/keeper/query_server.go | 2 +- x/msgfees/simulation/proposals.go | 4 ++-- x/msgfees/types/codec.go | 4 +--- x/name/client/cli/query.go | 2 +- x/name/keeper/params.go | 1 + x/name/keeper/query_server.go | 2 +- x/name/simulation/proposals.go | 2 +- x/name/wasm/query.go | 2 +- x/oracle/client/cli/query.go | 2 +- x/quarantine/client/cli/util.go | 4 ++-- x/quarantine/keys.go | 8 +++---- x/sanction/client/cli/query.go | 4 ++-- x/sanction/simulation/operations.go | 2 +- x/trigger/keeper/event_detector.go | 2 +- x/trigger/keeper/query_server.go | 2 +- x/trigger/simulation/genesis.go | 6 ++--- x/trigger/types/trigger.go | 4 ++-- 61 files changed, 133 insertions(+), 210 deletions(-) diff --git a/app/app.go b/app/app.go index f12bd45e01..7568b5f159 100644 --- a/app/app.go +++ b/app/app.go @@ -55,7 +55,6 @@ import ( authcodec "github.com/cosmos/cosmos-sdk/x/auth/codec" authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper" authsims "github.com/cosmos/cosmos-sdk/x/auth/simulation" - "github.com/cosmos/cosmos-sdk/x/auth/tx" authtx "github.com/cosmos/cosmos-sdk/x/auth/tx" txmodule "github.com/cosmos/cosmos-sdk/x/auth/tx/config" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" @@ -340,7 +339,7 @@ func New( }) appCodec := codec.NewProtoCodec(interfaceRegistry) legacyAmino := codec.NewLegacyAmino() - txConfig := tx.NewTxConfig(appCodec, tx.DefaultSignModes) + txConfig := authtx.NewTxConfig(appCodec, authtx.DefaultSignModes) std.RegisterLegacyAminoCodec(legacyAmino) std.RegisterInterfaces(interfaceRegistry) @@ -448,13 +447,14 @@ func New( ) // optional: enable sign mode textual by overwriting the default tx config (after setting the bank keeper) - enabledSignModes := append(tx.DefaultSignModes, sigtypes.SignMode_SIGN_MODE_TEXTUAL) - txConfigOpts := tx.ConfigOptions{ + enabledSignModes := authtx.DefaultSignModes + enabledSignModes = append(enabledSignModes, sigtypes.SignMode_SIGN_MODE_TEXTUAL) + txConfigOpts := authtx.ConfigOptions{ EnabledSignModes: enabledSignModes, TextualCoinMetadataQueryFn: txmodule.NewBankKeeperCoinMetadataQueryFn(app.BankKeeper), } var err error - txConfig, err = tx.NewTxConfigWithOptions(appCodec, txConfigOpts) + txConfig, err = authtx.NewTxConfigWithOptions(appCodec, txConfigOpts) if err != nil { panic(err) } @@ -551,7 +551,7 @@ func New( app.NameKeeper = namekeeper.NewKeeper(appCodec, keys[nametypes.StoreKey]) app.AttributeKeeper = attributekeeper.NewKeeper( - appCodec, keys[attributetypes.StoreKey], app.GetSubspace(attributetypes.ModuleName), app.AccountKeeper, &app.NameKeeper, + appCodec, keys[attributetypes.StoreKey], app.AccountKeeper, &app.NameKeeper, ) markerReqAttrBypassAddrs := []sdk.AccAddress{ @@ -986,7 +986,9 @@ func New( app.mm.RegisterInvariants(app.CrisisKeeper) app.configurator = module.NewConfigurator(app.appCodec, app.BaseApp.MsgServiceRouter(), app.GRPCQueryRouter()) - app.mm.RegisterServices(app.configurator) + if err := app.mm.RegisterServices(app.configurator); err != nil { + panic(err) + } app.sm = module.NewSimulationManager( auth.NewAppModule(appCodec, app.AccountKeeper, authsims.RandomGenesisAccounts, app.GetSubspace(authtypes.ModuleName)), @@ -1178,7 +1180,7 @@ func filterBeginBlockerEvents(responseBeginBlock sdk.BeginBlock) []abci.Event { func shouldFilterEvent(e abci.Event) bool { if e.Type == distrtypes.EventTypeCommission || e.Type == distrtypes.EventTypeRewards || e.Type == distrtypes.EventTypeProposerReward || e.Type == banktypes.EventTypeTransfer || e.Type == banktypes.EventTypeCoinSpent || e.Type == banktypes.EventTypeCoinReceived { for _, a := range e.Attributes { - if string(a.Key) == sdk.AttributeKeyAmount && len(a.Value) == 0 { + if a.Key == sdk.AttributeKeyAmount && len(a.Value) == 0 { return true } } @@ -1197,7 +1199,9 @@ func (app *App) InitChainer(ctx sdk.Context, req *abci.RequestInitChain) (*abci. if err := json.Unmarshal(req.AppStateBytes, &genesisState); err != nil { panic(err) } - app.UpgradeKeeper.SetModuleVersionMap(ctx, app.mm.GetVersionMap()) + if err := app.UpgradeKeeper.SetModuleVersionMap(ctx, app.mm.GetVersionMap()); err != nil { + panic(err) + } return app.mm.InitGenesis(ctx, app.appCodec, genesisState) } @@ -1415,7 +1419,9 @@ func (app *App) injectUpgrade(name string) { //nolint:unused // This is designed // But the upgrade keeper often its own migration stuff that change some store key stuff. // ScheduleUpgrade tries to read some of that changed store stuff and fails if the migration hasn't // been applied yet. So we're doing things the hard way here. - app.UpgradeKeeper.ClearUpgradePlan(ctx) + if err := app.UpgradeKeeper.ClearUpgradePlan(ctx); err != nil { + panic(err) + } store := ctx.KVStore(app.GetKey(upgradetypes.StoreKey)) bz := app.appCodec.MustMarshal(&plan) store.Set(upgradetypes.PlanKey(), bz) diff --git a/app/app_test.go b/app/app_test.go index 62abf5c52f..83efbca2cd 100644 --- a/app/app_test.go +++ b/app/app_test.go @@ -287,7 +287,7 @@ func logAddrs(t *testing.T, addrs []sdk.AccAddress, name string) { } } -func assertNoDupeAccountNumbers(t *testing.T, ctx sdk.Context, app *App, accts []sdk.AccountI, name string) bool { +func assertNoDupeAccountNumbers(t *testing.T, _ sdk.Context, _ *App, accts []sdk.AccountI, name string) bool { t.Helper() byAcctNum := map[uint64][]sdk.AccountI{} acctNums := []uint64{} diff --git a/app/export.go b/app/export.go index 0eea77d93e..39005d2d44 100644 --- a/app/export.go +++ b/app/export.go @@ -251,12 +251,17 @@ func (app *App) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []str /* Handle slashing state. */ // reset start height on signing infos - app.SlashingKeeper.IterateValidatorSigningInfos( + err = app.SlashingKeeper.IterateValidatorSigningInfos( ctx, func(addr sdk.ConsAddress, info slashingtypes.ValidatorSigningInfo) (stop bool) { info.StartHeight = 0 - app.SlashingKeeper.SetValidatorSigningInfo(ctx, addr, info) + if err := app.SlashingKeeper.SetValidatorSigningInfo(ctx, addr, info); err != nil { + panic(fmt.Errorf("could not set validator signing for %s: %w", addr, err)) + } return false }, ) + if err != nil { + panic(fmt.Errorf("could not iterate validator signing infos: %w", err)) + } } diff --git a/app/group.go b/app/group.go index 42e9e46299..39e2d5d45f 100644 --- a/app/group.go +++ b/app/group.go @@ -27,8 +27,7 @@ func (t GroupCheckerFunc) IsGroupAddress(ctx sdk.Context, account sdk.AccAddress func NewGroupCheckerFunc(querier GroupPolicyQuerier) GroupCheckerFunc { return GroupCheckerFunc(func(ctx sdk.Context, account sdk.AccAddress) bool { msg := &group.QueryGroupPolicyInfoRequest{Address: account.String()} - goCtx := sdk.WrapSDKContext(ctx) - _, err := querier.GroupPolicyInfo(goCtx, msg) + _, err := querier.GroupPolicyInfo(ctx, msg) return err == nil }) } diff --git a/app/upgrades.go b/app/upgrades.go index a0c60f491c..de7b0ecd5d 100644 --- a/app/upgrades.go +++ b/app/upgrades.go @@ -79,10 +79,7 @@ var upgrades = map[string]appUpgrade{ return nil, err } - err = updateIBCClients(ctx, app) - if err != nil { - return nil, err - } + updateIBCClients(ctx, app) removeInactiveValidatorDelegations(ctx, app) @@ -120,10 +117,7 @@ var upgrades = map[string]appUpgrade{ return nil, err } - err = updateIBCClients(ctx, app) - if err != nil { - return nil, err - } + updateIBCClients(ctx, app) removeInactiveValidatorDelegations(ctx, app) @@ -290,13 +284,12 @@ func pruneIBCExpiredConsensusStates(ctx sdk.Context, app *App) error { // updateIBCClients updates the allowed clients for IBC. // TODO: Remove with the umber handlers. -func updateIBCClients(ctx sdk.Context, app *App) error { +func updateIBCClients(ctx sdk.Context, app *App) { ctx.Logger().Info("Updating IBC AllowedClients.") params := app.IBCKeeper.ClientKeeper.GetParams(ctx) params.AllowedClients = append(params.AllowedClients, exported.Localhost) app.IBCKeeper.ClientKeeper.SetParams(ctx, params) ctx.Logger().Info("Done updating IBC AllowedClients.") - return nil } // migrateBaseappParams migrates to new ConsensusParamsKeeper @@ -344,7 +337,7 @@ func migrateAttributeParams(ctx sdk.Context, app *App) { if attributeParamSpace.Has(ctx, attributetypes.ParamStoreKeyMaxValueLength) { attributeParamSpace.Get(ctx, attributetypes.ParamStoreKeyMaxValueLength, &maxValueLength) } - app.AttributeKeeper.SetParams(ctx, attributetypes.Params{MaxValueLength: uint32(maxValueLength)}) + app.AttributeKeeper.SetParams(ctx, attributetypes.Params{MaxValueLength: maxValueLength}) ctx.Logger().Info("Done migrating attribute params.") } @@ -360,7 +353,7 @@ func migrateMarkerParams(ctx sdk.Context, app *App) { if markerParamSpace.Has(ctx, markertypes.ParamStoreKeyMaxTotalSupply) { var maxTotalSupply uint64 markerParamSpace.Get(ctx, markertypes.ParamStoreKeyMaxTotalSupply, &maxTotalSupply) - params.MaxTotalSupply = maxTotalSupply + params.MaxTotalSupply = maxTotalSupply //nolint:staticcheck } // TODO: remove markertypes.ParamStoreKeyEnableGovernance with the umber handlers. @@ -399,7 +392,7 @@ func migrateMetadataOSLocatorParams(ctx sdk.Context, app *App) { if metadataParamSpace.Has(ctx, metadatatypes.ParamStoreKeyMaxValueLength) { metadataParamSpace.Get(ctx, metadatatypes.ParamStoreKeyMaxValueLength, &maxValueLength) } - app.MetadataKeeper.SetOSLocatorParams(ctx, metadatatypes.OSLocatorParams{MaxUriLength: uint32(maxValueLength)}) + app.MetadataKeeper.SetOSLocatorParams(ctx, metadatatypes.OSLocatorParams{MaxUriLength: maxValueLength}) ctx.Logger().Info("Done migrating metadata os locator params.") } diff --git a/app/upgrades_test.go b/app/upgrades_test.go index 33ad99ec60..cab68e2a95 100644 --- a/app/upgrades_test.go +++ b/app/upgrades_test.go @@ -19,7 +19,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/module" "github.com/cosmos/cosmos-sdk/x/bank/testutil" - "github.com/cosmos/cosmos-sdk/x/staking/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" "github.com/provenance-io/provenance/internal/helpers" @@ -261,7 +260,7 @@ func (s *UpgradeTestSuite) CreateValidator(unbondedTime time.Time, status stakin func (s *UpgradeTestSuite) DelegateToValidator(valAddress sdk.ValAddress, delegatorAddress sdk.AccAddress, coin sdk.Coin) { validator, err := s.app.StakingKeeper.GetValidator(s.ctx, valAddress) s.Require().NoError(err, "GetValidator(%q)", valAddress.String()) - _, err = s.app.StakingKeeper.Delegate(s.ctx, delegatorAddress, coin.Amount, types.Unbonded, validator, true) + _, err = s.app.StakingKeeper.Delegate(s.ctx, delegatorAddress, coin.Amount, stakingtypes.Unbonded, validator, true) s.Require().NoError(err, "Delegate(%q, %q, unbonded, %q, true) error", delegatorAddress.String(), coin.String(), valAddress.String()) } diff --git a/cmd/provenanced/cmd/config.go b/cmd/provenanced/cmd/config.go index 07b91acdcd..4db0794e41 100644 --- a/cmd/provenanced/cmd/config.go +++ b/cmd/provenanced/cmd/config.go @@ -186,7 +186,7 @@ The directory that houses the configuration and data for the blockchain. This di `, Example: fmt.Sprintf(`$ %[1]s home`, configCmdStart), Args: cobra.ExactArgs(0), - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { return runConfigHomeCmd(cmd) }, } @@ -207,7 +207,7 @@ Settings that are their default value will not be included. `, provconfig.PackedConfFilename, provconfig.AppConfFilename, provconfig.TmConfFilename, provconfig.ClientConfFilename), Example: fmt.Sprintf(`$ %[1]s pack`, configCmdStart), Args: cobra.ExactArgs(0), - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { return runConfigPackCmd(cmd) }, } @@ -231,7 +231,7 @@ This can also be used to update the config files using the current template so t `, provconfig.PackedConfFilename, provconfig.AppConfFilename, provconfig.TmConfFilename, provconfig.ClientConfFilename), Example: fmt.Sprintf(`$ %[1]s unpack`, configCmdStart), Args: cobra.ExactArgs(0), - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { return runConfigUnpackCmd(cmd) }, } diff --git a/cmd/provenanced/cmd/genaccounts.go b/cmd/provenanced/cmd/genaccounts.go index 512a22af60..06ca984a34 100644 --- a/cmd/provenanced/cmd/genaccounts.go +++ b/cmd/provenanced/cmd/genaccounts.go @@ -11,7 +11,6 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/cosmos/cosmos-sdk/codec/types" "github.com/cosmos/cosmos-sdk/crypto/keyring" "github.com/cosmos/cosmos-sdk/server" sdk "github.com/cosmos/cosmos-sdk/types" @@ -606,7 +605,7 @@ Currently, the denom and price defaults to 1905nhash } // AddGenesisMsgFeeCmd returns add-genesis-msg-fee cobra command. -func AddGenesisMsgFeeCmd(defaultNodeHome string, interfaceRegistry types.InterfaceRegistry) *cobra.Command { +func AddGenesisMsgFeeCmd(defaultNodeHome string) *cobra.Command { cmd := &cobra.Command{ Use: "add-genesis-msg-fee [msg-url] [additional-fee]", Short: "Add a msg fee to genesis.json", @@ -630,10 +629,6 @@ func AddGenesisMsgFeeCmd(defaultNodeHome string, interfaceRegistry types.Interfa msgType = "/" + msgType } - if err := checkMsgTypeValid(interfaceRegistry, msgType); err != nil { - return err - } - additionalFee, err := sdk.ParseCoinNormalized(args[1]) if err != nil { return fmt.Errorf("failed to parse coin: %w", err) @@ -681,19 +676,6 @@ func AddGenesisMsgFeeCmd(defaultNodeHome string, interfaceRegistry types.Interfa return cmd } -func checkMsgTypeValid(registry types.InterfaceRegistry, msgTypeURL string) error { - msg, err := registry.Resolve(msgTypeURL) - if err != nil { - return err - } - - _, ok := msg.(sdk.Msg) - if !ok { - return fmt.Errorf("message type is not a sdk message: %v", msgTypeURL) - } - return err -} - // AddGenesisDefaultMarketCmd returns add-genesis-default-market cobra command. func AddGenesisDefaultMarketCmd(defaultNodeHome string) *cobra.Command { cmd := &cobra.Command{ diff --git a/cmd/provenanced/cmd/genaccounts_test.go b/cmd/provenanced/cmd/genaccounts_test.go index fd0b4de920..473e87b0e7 100644 --- a/cmd/provenanced/cmd/genaccounts_test.go +++ b/cmd/provenanced/cmd/genaccounts_test.go @@ -27,7 +27,6 @@ import ( genutiltest "github.com/cosmos/cosmos-sdk/x/genutil/client/testutil" genutiltypes "github.com/cosmos/cosmos-sdk/x/genutil/types" - "github.com/provenance-io/provenance/app" provenancecmd "github.com/provenance-io/provenance/cmd/provenanced/cmd" "github.com/provenance-io/provenance/testutil/assertions" "github.com/provenance-io/provenance/testutil/mocks" @@ -99,8 +98,6 @@ func TestAddGenesisAccountCmd(t *testing.T) { } func TestAddGenesisMsgFeeCmd(t *testing.T) { - encCfg := app.MakeTestEncodingConfig(t) - tests := []struct { name string msgType string @@ -158,7 +155,7 @@ func TestAddGenesisMsgFeeCmd(t *testing.T) { ctx = context.WithValue(ctx, server.ServerContextKey, serverCtx) cmd := provenancecmd.AddGenesisCustomFloorPriceDenomCmd(home) - cmdFee := provenancecmd.AddGenesisMsgFeeCmd(home, encCfg.InterfaceRegistry) + cmdFee := provenancecmd.AddGenesisMsgFeeCmd(home) cmd.SetArgs([]string{ tc.msgFeeFloorCoin, fmt.Sprintf("--%s=home", flags.FlagHome)}) @@ -384,9 +381,7 @@ func TestAddGenesisDefaultMarketCmd(t *testing.T) { appState[exchange.ModuleName], err = cdc.MarshalJSON(tc.iniExGenState) require.NoError(t, err, "setup: MarshalJSON exchange genesis state") } else { - if _, found := appState[exchange.ModuleName]; found { - delete(appState, exchange.ModuleName) - } + delete(appState, exchange.ModuleName) } var authState authtypes.GenesisState @@ -442,7 +437,7 @@ func TestAddGenesisDefaultMarketCmd(t *testing.T) { return } - appState, genDoc, err = genutiltypes.GenesisStateFromGenFile(genFile) + appState, _, err = genutiltypes.GenesisStateFromGenFile(genFile) require.NoError(t, err, "GenesisStateFromGenFile(%q)", genFile) var actExGenState exchange.GenesisState err = cdc.UnmarshalJSON(appState[exchange.ModuleName], &actExGenState) @@ -716,9 +711,7 @@ func TestAddGenesisCustomMarketCmd(t *testing.T) { appState[exchange.ModuleName], err = cdc.MarshalJSON(tc.iniExGenState) require.NoError(t, err, "setup: MarshalJSON exchange genesis state") } else { - if _, found := appState[exchange.ModuleName]; found { - delete(appState, exchange.ModuleName) - } + delete(appState, exchange.ModuleName) } genDoc.AppState, err = json.Marshal(appState) @@ -746,7 +739,7 @@ func TestAddGenesisCustomMarketCmd(t *testing.T) { return } - appState, genDoc, err = genutiltypes.GenesisStateFromGenFile(genFile) + appState, _, err = genutiltypes.GenesisStateFromGenFile(genFile) require.NoError(t, err, "GenesisStateFromGenFile(%q)", genFile) var actExGenState exchange.GenesisState err = cdc.UnmarshalJSON(appState[exchange.ModuleName], &actExGenState) diff --git a/cmd/provenanced/cmd/pre_upgrade.go b/cmd/provenanced/cmd/pre_upgrade.go index 31050ca887..3743cd43b8 100644 --- a/cmd/provenanced/cmd/pre_upgrade.go +++ b/cmd/provenanced/cmd/pre_upgrade.go @@ -40,13 +40,13 @@ Exit code meanings: SilenceUsage: true, // No need to print usage if the command fails. // Cosmovisor doesn't provide any args, and none are expected. But we want an // exit code of 30 here (instead of 1), so we're not using cobra.NoArgs. - Args: func(cmd *cobra.Command, args []string) error { + Args: func(_ *cobra.Command, args []string) error { if len(args) != 0 { return errors.Join(fmt.Errorf("expected 0 args, received %d", len(args)), ErrFail) } return nil }, - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { err := UpdateConfig(cmd) if err != nil { return errors.Join(fmt.Errorf("could not update config file(s): %w", err), ErrFail) diff --git a/cmd/provenanced/cmd/root.go b/cmd/provenanced/cmd/root.go index 7200d181ab..0c8a78b9c3 100644 --- a/cmd/provenanced/cmd/root.go +++ b/cmd/provenanced/cmd/root.go @@ -119,7 +119,8 @@ func NewRootCmd(sealConfig bool) (*cobra.Command, params.EncodingConfig) { // sets the RPC client needed for SIGN_MODE_TEXTUAL. This sign mode // is only available if the client is online. if !initClientCtx.Offline { - enabledSignModes := append(tx.DefaultSignModes, signing.SignMode_SIGN_MODE_TEXTUAL) + enabledSignModes := tx.DefaultSignModes + enabledSignModes = append(enabledSignModes, signing.SignMode_SIGN_MODE_TEXTUAL) txConfigOpts := tx.ConfigOptions{ EnabledSignModes: enabledSignModes, TextualCoinMetadataQueryFn: txmodule.NewGRPCCoinMetadataQueryFn(initClientCtx), @@ -201,7 +202,7 @@ func initRootCmd(rootCmd *cobra.Command, encodingConfig params.EncodingConfig, b AddGenesisAccountCmd(app.DefaultNodeHome), AddRootDomainAccountCmd(app.DefaultNodeHome), AddGenesisMarkerCmd(app.DefaultNodeHome), - AddGenesisMsgFeeCmd(app.DefaultNodeHome, encodingConfig.InterfaceRegistry), + AddGenesisMsgFeeCmd(app.DefaultNodeHome), AddGenesisCustomFloorPriceDenomCmd(app.DefaultNodeHome), AddGenesisDefaultMarketCmd(app.DefaultNodeHome), AddGenesisCustomMarketCmd(app.DefaultNodeHome), diff --git a/internal/handlers/msg_service_router.go b/internal/handlers/msg_service_router.go index 74705ed28a..e3024947dd 100644 --- a/internal/handlers/msg_service_router.go +++ b/internal/handlers/msg_service_router.go @@ -189,7 +189,7 @@ func (msr *PioMsgServiceRouter) registerMsgServiceHandler(sd *grpc.ServiceDesc, // Call the method handler from the service description with the handler object. // We don't do any decoding here because the decoding was already done. - res, err := methodHandler(handler, sdk.WrapSDKContext(ctx), noopDecoder, interceptor) + res, err := methodHandler(handler, ctx, noopDecoder, interceptor) if err != nil { return nil, err } diff --git a/internal/provwasm/simulation.go b/internal/provwasm/simulation.go index 2327976150..71b6835444 100644 --- a/internal/provwasm/simulation.go +++ b/internal/provwasm/simulation.go @@ -160,7 +160,7 @@ func SimulateMsgBindName(simState module.SimulationState, ak authkeeper.AccountK func SimulateMsgAddMarker(simState module.SimulationState, ak authkeeper.AccountKeeperI, bk bankkeeper.Keeper, nk namekeeper.Keeper, node, feebucket, merchant, consumer simtypes.Account, name string) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, _ []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { msg := markertypes.NewMsgAddMarkerRequest( denom, @@ -198,7 +198,7 @@ func SimulateMsgAddMarker(simState module.SimulationState, ak authkeeper.Account func SimulateMsgAddAccess(simState module.SimulationState, ak authkeeper.AccountKeeperI, bk bankkeeper.Keeper, nk namekeeper.Keeper, node, feebucket, merchant, consumer simtypes.Account, name string) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, _ []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { accessTypes := []markertypes.Access{markertypes.AccessByName("withdraw")} grant := *markertypes.NewAccessGrant(node.Address, accessTypes) @@ -213,7 +213,7 @@ func SimulateMsgAddAccess(simState module.SimulationState, ak authkeeper.Account func SimulateFinalizeMarker(simState module.SimulationState, ak authkeeper.AccountKeeperI, bk bankkeeper.Keeper, nk namekeeper.Keeper, node, feebucket, merchant, consumer simtypes.Account, name string) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, _ []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { msg := markertypes.NewMsgFinalizeRequest(denom, node.Address) @@ -227,7 +227,7 @@ func SimulateFinalizeMarker(simState module.SimulationState, ak authkeeper.Accou func SimulateActivateMarker(simState module.SimulationState, ak authkeeper.AccountKeeperI, bk bankkeeper.Keeper, nk namekeeper.Keeper, node, feebucket, merchant, consumer simtypes.Account, name string) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, _ []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { msg := markertypes.NewMsgActivateRequest(denom, node.Address) @@ -241,7 +241,7 @@ func SimulateActivateMarker(simState module.SimulationState, ak authkeeper.Accou func SimulateMsgWithdrawRequest(simState module.SimulationState, ak authkeeper.AccountKeeperI, bk bankkeeper.Keeper, nk namekeeper.Keeper, node, feebucket, merchant, consumer simtypes.Account, name string) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, _ []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { coins := []sdk.Coin{{ Denom: denom, @@ -258,7 +258,7 @@ func SimulateMsgWithdrawRequest(simState module.SimulationState, ak authkeeper.A func SimulateMsgStoreContract(simState module.SimulationState, ak authkeeper.AccountKeeperI, bk bankkeeper.ViewKeeper, nk namekeeper.Keeper, node, feebucket, merchant, consumer simtypes.Account, name string) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, _ []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { code, err := os.ReadFile("./sim_contracts/tutorial.wasm") @@ -281,7 +281,7 @@ func SimulateMsgStoreContract(simState module.SimulationState, ak authkeeper.Acc func SimulateMsgInstantiateContract(simState module.SimulationState, ak authkeeper.AccountKeeperI, bk bankkeeper.ViewKeeper, nk namekeeper.Keeper, node, feebucket, merchant, consumer simtypes.Account, name string) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, _ []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { record, err := nk.GetRecordByName(ctx, name) @@ -347,7 +347,7 @@ func SimulateMsgInstantiateContract(simState module.SimulationState, ak authkeep func SimulateMsgExecuteContract(simState module.SimulationState, ak authkeeper.AccountKeeperI, bk bankkeeper.ViewKeeper, _, consumer simtypes.Account, contractAddr string) simtypes.Operation { return func( - r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, _ []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { amount, _ := sdk.ParseCoinsNormalized(fmt.Sprintf("100%s", denom)) coins := bk.SpendableCoins(ctx, consumer.Address) diff --git a/internal/provwasm/stargate_whitelist.go b/internal/provwasm/stargate_whitelist.go index f03b4859e9..a6ba4cd870 100644 --- a/internal/provwasm/stargate_whitelist.go +++ b/internal/provwasm/stargate_whitelist.go @@ -159,7 +159,7 @@ func setWhitelistedQuery(queryPath string, protoType codec.ProtoMarshaler) { func GetStargateWhitelistedPaths() (keys []string) { // Iterate over the map and collect the keys - stargateWhitelist.Range(func(key, value interface{}) bool { + stargateWhitelist.Range(func(key, _ interface{}) bool { keyStr, ok := key.(string) if !ok { panic("key is not a string") diff --git a/x/attribute/client/cli/query.go b/x/attribute/client/cli/query.go index 236a156fcb..7f29b53147 100644 --- a/x/attribute/client/cli/query.go +++ b/x/attribute/client/cli/query.go @@ -43,7 +43,7 @@ func GetAttributeParamsCmd() *cobra.Command { Short: "Query the current name parameters", Args: cobra.NoArgs, Example: fmt.Sprintf(`$ %s query attribute params`, version.AppName), - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { clientCtx, err := client.GetClientQueryContext(cmd) if err != nil { return err diff --git a/x/attribute/keeper/keeper.go b/x/attribute/keeper/keeper.go index 59cccdc55b..3858763a54 100644 --- a/x/attribute/keeper/keeper.go +++ b/x/attribute/keeper/keeper.go @@ -14,7 +14,6 @@ import ( "github.com/cosmos/cosmos-sdk/telemetry" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" "github.com/provenance-io/provenance/x/attribute/types" ) @@ -45,7 +44,7 @@ type Keeper struct { // // CONTRACT: the parameter Subspace must have the param key table already initialized func NewKeeper( - cdc codec.BinaryCodec, key storetypes.StoreKey, paramSpace paramtypes.Subspace, + cdc codec.BinaryCodec, key storetypes.StoreKey, authKeeper types.AccountKeeper, nameKeeper types.NameKeeper, ) Keeper { keeper := Keeper{ @@ -68,7 +67,7 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger { func (k Keeper) GetAllAttributes(ctx sdk.Context, addr string) ([]types.Attribute, error) { defer telemetry.MeasureSince(time.Now(), types.ModuleName, "keeper_method", "get_all") - pred := func(s string) bool { return true } + pred := func(string) bool { return true } return k.prefixScan(ctx, types.AddrStrAttributesKeyPrefix(addr), pred) } @@ -76,7 +75,7 @@ func (k Keeper) GetAllAttributes(ctx sdk.Context, addr string) ([]types.Attribut func (k Keeper) GetAllAttributesAddr(ctx sdk.Context, addr []byte) ([]types.Attribute, error) { defer telemetry.MeasureSince(time.Now(), types.ModuleName, "keeper_method", "get_all") - pred := func(s string) bool { return true } + pred := func(string) bool { return true } return k.prefixScan(ctx, types.AddrAttributesKeyPrefix(addr), pred) } diff --git a/x/attribute/keeper/query_server.go b/x/attribute/keeper/query_server.go index 9998571462..1ae3a267eb 100644 --- a/x/attribute/keeper/query_server.go +++ b/x/attribute/keeper/query_server.go @@ -39,7 +39,7 @@ func (k Keeper) Attribute(c context.Context, req *types.QueryAttributeRequest) ( attributes := make([]types.Attribute, 0) store := ctx.KVStore(k.storeKey) attributeStore := prefix.NewStore(store, types.AddrStrAttributesNameKeyPrefix(req.Account, req.Name)) - pageRes, err := query.FilteredPaginate(attributeStore, req.Pagination, func(key []byte, value []byte, accumulate bool) (bool, error) { + pageRes, err := query.FilteredPaginate(attributeStore, req.Pagination, func(_ []byte, value []byte, accumulate bool) (bool, error) { var result types.Attribute err := k.cdc.Unmarshal(value, &result) if err != nil { @@ -74,7 +74,7 @@ func (k Keeper) Attributes(c context.Context, req *types.QueryAttributesRequest) store := ctx.KVStore(k.storeKey) attributeStore := prefix.NewStore(store, types.AddrStrAttributesKeyPrefix(req.Account)) - pageRes, err := query.FilteredPaginate(attributeStore, req.Pagination, func(key []byte, value []byte, accumulate bool) (bool, error) { + pageRes, err := query.FilteredPaginate(attributeStore, req.Pagination, func(_ []byte, value []byte, accumulate bool) (bool, error) { var result types.Attribute err := k.cdc.Unmarshal(value, &result) if err != nil { @@ -114,7 +114,7 @@ func (k Keeper) Scan(c context.Context, req *types.QueryScanRequest) (*types.Que store := ctx.KVStore(k.storeKey) attributeStore := prefix.NewStore(store, types.AddrStrAttributesKeyPrefix(req.Account)) - pageRes, err := query.FilteredPaginate(attributeStore, req.Pagination, func(key []byte, value []byte, accumulate bool) (bool, error) { + pageRes, err := query.FilteredPaginate(attributeStore, req.Pagination, func(_ []byte, value []byte, accumulate bool) (bool, error) { var result types.Attribute err := k.cdc.Unmarshal(value, &result) if err != nil { @@ -147,7 +147,7 @@ func (k Keeper) AttributeAccounts(c context.Context, req *types.QueryAttributeAc keyPrefix := types.AttributeNameKeyPrefix(req.AttributeName) attributeStore := prefix.NewStore(store, keyPrefix) - pageRes, err := query.FilteredPaginate(attributeStore, req.Pagination, func(key []byte, value []byte, accumulate bool) (bool, error) { + pageRes, err := query.FilteredPaginate(attributeStore, req.Pagination, func(key []byte, _ []byte, accumulate bool) (bool, error) { addressLength := int32(key[0]) address := sdk.AccAddress(key[1 : addressLength+1]) for _, account := range accounts { diff --git a/x/attribute/types/codec.go b/x/attribute/types/codec.go index 14f307cc93..fe7056cada 100644 --- a/x/attribute/types/codec.go +++ b/x/attribute/types/codec.go @@ -10,9 +10,7 @@ import ( func RegisterInterfaces(registry types.InterfaceRegistry) { messages := make([]proto.Message, len(allRequestMsgs)) - for i, msg := range allRequestMsgs { - messages[i] = msg - } + copy(messages, allRequestMsgs) registry.RegisterImplementations((*sdk.Msg)(nil), messages...) msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) } diff --git a/x/attribute/wasm/query.go b/x/attribute/wasm/query.go index 5e9c5e576d..cdd6e02aa4 100644 --- a/x/attribute/wasm/query.go +++ b/x/attribute/wasm/query.go @@ -37,7 +37,7 @@ type GetAllAttributesParams struct { // Querier returns a smart contract querier for the attribute module. func Querier(keeper keeper.Keeper) provwasm.Querier { - return func(ctx sdk.Context, query json.RawMessage, version string) ([]byte, error) { + return func(ctx sdk.Context, query json.RawMessage, _ string) ([]byte, error) { wrapper := struct { Params *AttributeQueryParams `json:"attribute"` }{} diff --git a/x/exchange/codec.go b/x/exchange/codec.go index ab42039948..384467dd8b 100644 --- a/x/exchange/codec.go +++ b/x/exchange/codec.go @@ -11,9 +11,7 @@ import ( // RegisterInterfaces registers implementations for the tx messages func RegisterInterfaces(registry types.InterfaceRegistry) { messages := make([]proto.Message, len(allRequestMsgs)) - for i, msg := range allRequestMsgs { - messages[i] = msg - } + copy(messages, allRequestMsgs) registry.RegisterImplementations((*sdk.Msg)(nil), messages...) registry.RegisterInterface( diff --git a/x/exchange/keeper/commitments.go b/x/exchange/keeper/commitments.go index ac27d3641e..82cf038dcf 100644 --- a/x/exchange/keeper/commitments.go +++ b/x/exchange/keeper/commitments.go @@ -210,7 +210,7 @@ func (k Keeper) ReleaseCommitments(ctx sdk.Context, marketID uint32, toRelease [ func (k Keeper) ReleaseAllCommitmentsForMarket(ctx sdk.Context, marketID uint32) { var keySuffixes [][]byte keyPrefix := GetKeyPrefixCommitmentsToMarket(marketID) - k.iterate(ctx, keyPrefix, func(keySuffix, value []byte) bool { + k.iterate(ctx, keyPrefix, func(keySuffix, _ []byte) bool { keySuffixes = append(keySuffixes, keySuffix) return false }) diff --git a/x/exchange/keeper/grpc_query.go b/x/exchange/keeper/grpc_query.go index d5b526f952..ea5ecae7bd 100644 --- a/x/exchange/keeper/grpc_query.go +++ b/x/exchange/keeper/grpc_query.go @@ -350,7 +350,7 @@ func (k QueryServer) GetAllMarkets(goCtx context.Context, req *exchange.QueryGet resp := &exchange.QueryGetAllMarketsResponse{} var pageErr error - resp.Pagination, pageErr = query.FilteredPaginate(store, pagination, func(key []byte, value []byte, accumulate bool) (bool, error) { + resp.Pagination, pageErr = query.FilteredPaginate(store, pagination, func(key []byte, _ []byte, accumulate bool) (bool, error) { // If we can't get the market id from the key, just pretend like it doesn't exist. marketID, ok := ParseKeySuffixKnownMarketID(key) if !ok { diff --git a/x/exchange/keeper/market.go b/x/exchange/keeper/market.go index 57d46ccbf8..fe3df8a69b 100644 --- a/x/exchange/keeper/market.go +++ b/x/exchange/keeper/market.go @@ -112,7 +112,7 @@ var ( // hasFlatFee returns true if this market has any flat fee for a given type. func hasFlatFee(store storetypes.KVStore, marketID uint32, maker flatFeeKeyMakers) bool { rv := false - iterate(store, maker.prefix(marketID), func(key, value []byte) bool { + iterate(store, maker.prefix(marketID), func(_, _ []byte) bool { rv = true return true }) @@ -311,7 +311,7 @@ var ( // hasFeeRatio returns true if this market has any fee ratios for a given type. func hasFeeRatio(store storetypes.KVStore, marketID uint32, maker ratioKeyMakers) bool { rv := false - iterate(store, maker.prefix(marketID), func(key, value []byte) bool { + iterate(store, maker.prefix(marketID), func(_, _ []byte) bool { rv = true return true }) diff --git a/x/exchange/orders.go b/x/exchange/orders.go index a9f83e1523..fdad06803b 100644 --- a/x/exchange/orders.go +++ b/x/exchange/orders.go @@ -56,8 +56,8 @@ type OrderI interface { var _ OrderI = (*Order)(nil) -// findDuplicateIds returns all order ids that appear two or more times in the provided slice. -func findDuplicateIds(orderIDs []uint64) []uint64 { +// findDuplicateIDs returns all order ids that appear two or more times in the provided slice. +func findDuplicateIDs(orderIDs []uint64) []uint64 { var rv []uint64 seen := make(map[uint64]bool, len(orderIDs)) dups := make(map[uint64]bool) @@ -91,7 +91,7 @@ func ValidateOrderIDs(field string, orderIDs []uint64) error { if ContainsUint64(orderIDs, 0) { return fmt.Errorf("invalid %s order ids: cannot contain order id zero", field) } - dupOrderIDs := findDuplicateIds(orderIDs) + dupOrderIDs := findDuplicateIDs(orderIDs) if len(dupOrderIDs) > 0 { return fmt.Errorf("duplicate %s order ids provided: %v", field, dupOrderIDs) } diff --git a/x/hold/client/cli/query.go b/x/hold/client/cli/query.go index ee83b97c28..e68cefb4d7 100644 --- a/x/hold/client/cli/query.go +++ b/x/hold/client/cli/query.go @@ -80,7 +80,7 @@ func QueryCmdGetAllHolds() *cobra.Command { Short: "Get all funds on hold for all accounts", Example: fmt.Sprintf("$ %s all", exampleQueryCmdBase), Args: cobra.ExactArgs(0), - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { clientCtx, err := client.GetClientQueryContext(cmd) if err != nil { return err diff --git a/x/ibchooks/client/cli/query.go b/x/ibchooks/client/cli/query.go index 78137ed743..03958ba788 100644 --- a/x/ibchooks/client/cli/query.go +++ b/x/ibchooks/client/cli/query.go @@ -57,7 +57,7 @@ $ %s query ibchooks wasm-hooks-sender channel-7 pb12smx2wdlyttvyzvzg54y2vnqwq2qj ), ), Args: cobra.ExactArgs(2), - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(_ *cobra.Command, args []string) error { channelID := args[0] originalSender := args[1] // ToDo: Make this flexible as an arg diff --git a/x/ibchooks/wasm_hook.go b/x/ibchooks/wasm_hook.go index a3aaaef5f1..1fd084a2c2 100644 --- a/x/ibchooks/wasm_hook.go +++ b/x/ibchooks/wasm_hook.go @@ -141,7 +141,7 @@ func (h WasmHooks) execWasmMsg(ctx sdktypes.Context, execMsg *wasmtypes.MsgExecu return nil, fmt.Errorf(types.ErrBadExecutionMsg, err.Error()) } wasmMsgServer := wasmkeeper.NewMsgServerImpl(h.ContractKeeper) - return wasmMsgServer.ExecuteContract(sdktypes.WrapSDKContext(ctx), execMsg) + return wasmMsgServer.ExecuteContract(ctx, execMsg) } func isIcs20Packet(data []byte) (isIcs20 bool, ics20data transfertypes.FungibleTokenPacketData) { diff --git a/x/ibcratelimit/client/cli/query.go b/x/ibcratelimit/client/cli/query.go index accb4b2494..4c6867d7bf 100644 --- a/x/ibcratelimit/client/cli/query.go +++ b/x/ibcratelimit/client/cli/query.go @@ -37,7 +37,7 @@ func GetParamsCmd() *cobra.Command { Short: "Query the current ibcratelimit params", Args: cobra.NoArgs, Example: fmt.Sprintf(`$ %s query ibcratelimit params`, version.AppName), - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { clientCtx, err := client.GetClientQueryContext(cmd) if err != nil { return err diff --git a/x/ibcratelimit/codec.go b/x/ibcratelimit/codec.go index 109edeb766..1e71377e40 100644 --- a/x/ibcratelimit/codec.go +++ b/x/ibcratelimit/codec.go @@ -10,9 +10,7 @@ import ( // RegisterInterfaces registers implementations for the tx messages func RegisterInterfaces(registry types.InterfaceRegistry) { messages := make([]proto.Message, len(AllRequestMsgs)) - for i, msg := range AllRequestMsgs { - messages[i] = msg - } + copy(messages, AllRequestMsgs) registry.RegisterImplementations((*sdk.Msg)(nil), messages...) msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) diff --git a/x/marker/client/cli/query.go b/x/marker/client/cli/query.go index 6baa36df59..a5b7e6cba0 100644 --- a/x/marker/client/cli/query.go +++ b/x/marker/client/cli/query.go @@ -45,7 +45,7 @@ func QueryParamsCmd() *cobra.Command { Args: cobra.NoArgs, Example: strings.TrimSpace( fmt.Sprintf(`$ %s query marker params`, version.AppName)), - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { clientCtx, err := client.GetClientQueryContext(cmd) if err != nil { return err diff --git a/x/marker/client/cli/tx.go b/x/marker/client/cli/tx.go index 3b0ce7e4e7..fa65e90c82 100644 --- a/x/marker/client/cli/tx.go +++ b/x/marker/client/cli/tx.go @@ -101,7 +101,7 @@ func GetCmdMarkerProposal() *cobra.Command { Please use 'gov proposal submit-proposal instead. `, ), - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(_ *cobra.Command, _ []string) error { return fmt.Errorf("this command has been deprecated, and is no longer functional. Please use 'gov proposal submit-proposal' instead") }, } @@ -676,9 +676,6 @@ func GetCmdRevokeAuthorization() *cobra.Command { } msg := authz.NewMsgRevoke(clientCtx.GetFromAddress(), grantee, action) - if err != nil { - return err - } return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), &msg) }, diff --git a/x/marker/keeper/query_server.go b/x/marker/keeper/query_server.go index 4232b663ee..c8c3cf9b11 100644 --- a/x/marker/keeper/query_server.go +++ b/x/marker/keeper/query_server.go @@ -33,7 +33,7 @@ func (k Keeper) AllMarkers(c context.Context, req *types.QueryAllMarkersRequest) markers := make([]*codectypes.Any, 0) store := ctx.KVStore(k.storeKey) markerStore := prefix.NewStore(store, types.MarkerStoreKeyPrefix) - pageRes, err := query.Paginate(markerStore, req.Pagination, func(key []byte, value []byte) error { + pageRes, err := query.Paginate(markerStore, req.Pagination, func(_ []byte, value []byte) error { result, err := k.GetMarker(ctx, sdk.AccAddress(value)) if err == nil { anyMsg, anyErr := codectypes.NewAnyWithValue(result) diff --git a/x/marker/simulation/operations.go b/x/marker/simulation/operations.go index c507087e35..cfab08c66d 100644 --- a/x/marker/simulation/operations.go +++ b/x/marker/simulation/operations.go @@ -614,7 +614,7 @@ func SendGovMsg(args *SendGovMsgArgs) (bool, simtypes.OperationMsg, error) { func OperationMsgVote(args *WeightedOpsArgs, voter simtypes.Account, govPropID uint64, vote govtypes.VoteOption, comment string) simtypes.Operation { return func( r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, - accs []simtypes.Account, chainID string, + _ []simtypes.Account, _ string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { msg := govtypes.NewMsgVote(voter.Address, govPropID, vote, "") diff --git a/x/marker/simulation/proposals.go b/x/marker/simulation/proposals.go index ebd7987e70..5f4e32bfb2 100644 --- a/x/marker/simulation/proposals.go +++ b/x/marker/simulation/proposals.go @@ -101,7 +101,7 @@ func SimulateCreateSupplyIncreaseProposalContent(k keeper.Keeper) simtypes.Conte // SimulateCreateSupplyDecreaseProposalContent generates random create-root-name proposal content func SimulateCreateSupplyDecreaseProposalContent(k keeper.Keeper) simtypes.ContentSimulatorFn { - return func(r *rand.Rand, ctx sdk.Context, accs []simtypes.Account) simtypes.Content { + return func(r *rand.Rand, ctx sdk.Context, _ []simtypes.Account) simtypes.Content { m := randomGovMarkerWithMaxStatus(r, ctx, k, types.StatusActive) if m == nil { return nil @@ -154,7 +154,7 @@ func SimulateCreateRemoveAdministratorProposalContent(k keeper.Keeper) simtypes. // SimulateCreateChangeStatusProposalContent generates random create-root-name proposal content func SimulateCreateChangeStatusProposalContent(k keeper.Keeper) simtypes.ContentSimulatorFn { - return func(r *rand.Rand, ctx sdk.Context, accs []simtypes.Account) simtypes.Content { + return func(r *rand.Rand, ctx sdk.Context, _ []simtypes.Account) simtypes.Content { m := randomGovMarkerWithMaxStatus(r, ctx, k, types.StatusCancelled) if m == nil { return nil @@ -170,7 +170,7 @@ func SimulateCreateChangeStatusProposalContent(k keeper.Keeper) simtypes.Content // SimulateSetDenomMetadataProposalContent generates random set denom metadata proposal content func SimulateSetDenomMetadataProposalContent(k keeper.Keeper) simtypes.ContentSimulatorFn { - return func(r *rand.Rand, ctx sdk.Context, accs []simtypes.Account) simtypes.Content { + return func(r *rand.Rand, ctx sdk.Context, _ []simtypes.Account) simtypes.Content { m := randomGovMarkerWithMaxStatus(r, ctx, k, types.StatusDestroyed) if m == nil { return nil diff --git a/x/marker/types/codec.go b/x/marker/types/codec.go index dc343ea640..0915460940 100644 --- a/x/marker/types/codec.go +++ b/x/marker/types/codec.go @@ -14,9 +14,7 @@ import ( // RegisterInterfaces registers implementations for the tx messages func RegisterInterfaces(registry types.InterfaceRegistry) { messages := make([]proto.Message, len(allRequestMsgs)) - for i, msg := range allRequestMsgs { - messages[i] = msg - } + copy(messages, allRequestMsgs) registry.RegisterImplementations((*sdk.Msg)(nil), messages...) registry.RegisterImplementations( diff --git a/x/marker/wasm/query.go b/x/marker/wasm/query.go index 5ad02c52f1..87f3b5c20a 100644 --- a/x/marker/wasm/query.go +++ b/x/marker/wasm/query.go @@ -35,7 +35,7 @@ type GetMarkerByDenom struct { // Querier returns a smart contract querier for the name module. func Querier(keeper keeper.Keeper) provwasm.Querier { - return func(ctx sdk.Context, query json.RawMessage, version string) ([]byte, error) { + return func(ctx sdk.Context, query json.RawMessage, _ string) ([]byte, error) { wrapper := struct { Params *MarkerQueryParams `json:"marker"` }{} diff --git a/x/metadata/client/cli/tx.go b/x/metadata/client/cli/tx.go index d8fe65df72..207ab5c53a 100644 --- a/x/metadata/client/cli/tx.go +++ b/x/metadata/client/cli/tx.go @@ -468,10 +468,6 @@ func ModifyOsLocatorCmd() *cobra.Command { fmt.Printf("failed to add locator for a given owner address, invalid address: %s\n", args[0]) return fmt.Errorf("invalid address: %w", errAddr) } - if err != nil { - fmt.Printf("Invalid uuid for scope id: %s", args[0]) - return err - } objectStoreLocator := types.ObjectStoreLocator{ LocatorUri: args[1], Owner: args[0], @@ -505,10 +501,10 @@ func WriteScopeSpecificationCmd() *cobra.Command { return err } - cSpecIds := strings.Split(args[3], ",") - contractSpecIds := make([]types.MetadataAddress, len(cSpecIds)) - for i, cid := range cSpecIds { - contractSpecIds[i], err = types.MetadataAddressFromBech32(cid) + cSpecIDs := strings.Split(args[3], ",") + contractSpecIDs := make([]types.MetadataAddress, len(cSpecIDs)) + for i, cid := range cSpecIDs { + contractSpecIDs[i], err = types.MetadataAddressFromBech32(cid) if err != nil { return err } @@ -529,7 +525,7 @@ func WriteScopeSpecificationCmd() *cobra.Command { OwnerAddresses: strings.Split(args[1], ","), Description: parseDescription(args[4:]), PartiesInvolved: partyTypes, - ContractSpecIds: contractSpecIds, + ContractSpecIds: contractSpecIDs, } msg := types.NewMsgWriteScopeSpecificationRequest(scopeSpec, signers) diff --git a/x/metadata/keeper/msg_server.go b/x/metadata/keeper/msg_server.go index d908bee7fc..8daf0200f6 100644 --- a/x/metadata/keeper/msg_server.go +++ b/x/metadata/keeper/msg_server.go @@ -516,11 +516,11 @@ func (k msgServer) DeleteContractSpecFromScopeSpec( return nil, sdkerrors.ErrInvalidRequest.Wrap(err.Error()) } - updateContractSpecIds := []types.MetadataAddress{} + updateContractSpecIDs := []types.MetadataAddress{} found = false for _, cSpecID := range scopeSpec.ContractSpecIds { if !cSpecID.Equals(msg.ContractSpecificationId) { - updateContractSpecIds = append(updateContractSpecIds, cSpecID) + updateContractSpecIDs = append(updateContractSpecIDs, cSpecID) } else { found = true } @@ -529,7 +529,7 @@ func (k msgServer) DeleteContractSpecFromScopeSpec( return nil, sdkerrors.ErrNotFound.Wrapf("contract specification %s not found in scope specification %s", msg.ContractSpecificationId, msg.ScopeSpecificationId) } - scopeSpec.ContractSpecIds = updateContractSpecIds + scopeSpec.ContractSpecIds = updateContractSpecIDs k.SetScopeSpecification(ctx, scopeSpec) k.EmitEvent(ctx, types.NewEventTxCompleted(types.TxEndpoint_DeleteContractSpecFromScopeSpec, msg.GetSignerStrs())) diff --git a/x/metadata/keeper/query_server.go b/x/metadata/keeper/query_server.go index 7ceee81ee1..6697b8d83c 100644 --- a/x/metadata/keeper/query_server.go +++ b/x/metadata/keeper/query_server.go @@ -24,7 +24,7 @@ const defaultLimit = 100 var _ types.QueryServer = Keeper{} // Params queries params of metadata module. -func (k Keeper) Params(c context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { +func (k Keeper) Params(_ context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { defer telemetry.MeasureSince(time.Now(), types.ModuleName, "query", "Params") resp := &types.QueryParamsResponse{Params: types.Params{}} if req != nil && req.IncludeRequest { @@ -1101,7 +1101,7 @@ func (k Keeper) OSLocatorsByURI(ctx context.Context, request *types.OSLocatorsBy uriStr := uri.String() osLocatorStore := prefix.NewStore(sdk.UnwrapSDKContext(ctx).KVStore(k.storeKey), types.OSLocatorAddressKeyPrefix) - retval.Pagination, err = query.FilteredPaginate(osLocatorStore, request.Pagination, func(key []byte, value []byte, accumulate bool) (bool, error) { + retval.Pagination, err = query.FilteredPaginate(osLocatorStore, request.Pagination, func(_ []byte, value []byte, accumulate bool) (bool, error) { record := types.ObjectStoreLocator{} if rerr := k.cdc.Unmarshal(value, &record); rerr != nil { return false, rerr @@ -1160,7 +1160,7 @@ func (k Keeper) OSAllLocators(ctx context.Context, request *types.OSAllLocatorsR osLocatorStore := prefix.NewStore(sdk.UnwrapSDKContext(ctx).KVStore(k.storeKey), types.OSLocatorAddressKeyPrefix) var err error - retval.Pagination, err = query.Paginate(osLocatorStore, request.Pagination, func(key []byte, value []byte) error { + retval.Pagination, err = query.Paginate(osLocatorStore, request.Pagination, func(_ []byte, value []byte) error { record := types.ObjectStoreLocator{} if rerr := k.cdc.Unmarshal(value, &record); rerr != nil { return rerr diff --git a/x/metadata/keeper/specification.go b/x/metadata/keeper/specification.go index 537d970958..315e4e54e4 100644 --- a/x/metadata/keeper/specification.go +++ b/x/metadata/keeper/specification.go @@ -335,7 +335,7 @@ func (k Keeper) indexContractSpecification(ctx sdk.Context, newSpec, oldSpec *ty // isContractSpecUsed checks to see if a contract spec is referenced by anything else (e.g. scope spec or session) func (k Keeper) isContractSpecUsed(ctx sdk.Context, contractSpecID types.MetadataAddress) bool { contractSpecReferenceFound := false - itScopeSpecErr := k.IterateScopeSpecsForContractSpec(ctx, contractSpecID, func(scopeID types.MetadataAddress) (stop bool) { + itScopeSpecErr := k.IterateScopeSpecsForContractSpec(ctx, contractSpecID, func(types.MetadataAddress) (stop bool) { contractSpecReferenceFound = true return true }) @@ -586,7 +586,7 @@ func (k Keeper) indexScopeSpecification(ctx sdk.Context, newSpec, oldSpec *types // isScopeSpecUsed checks to see if a scope exists that is defined by this scope spec. func (k Keeper) isScopeSpecUsed(ctx sdk.Context, scopeSpecID types.MetadataAddress) bool { scopeSpecReferenceFound := false - err := k.IterateScopesForScopeSpec(ctx, scopeSpecID, func(scopeID types.MetadataAddress) (stop bool) { + err := k.IterateScopesForScopeSpec(ctx, scopeSpecID, func(types.MetadataAddress) (stop bool) { scopeSpecReferenceFound = true return true }) diff --git a/x/metadata/wasm/query.go b/x/metadata/wasm/query.go index 7bbfd6e138..ea38f3c846 100644 --- a/x/metadata/wasm/query.go +++ b/x/metadata/wasm/query.go @@ -46,7 +46,7 @@ type GetRecordsParams struct { // Querier returns a smart contract querier for the metadata module. func Querier(keeper keeper.Keeper) provwasm.Querier { - return func(ctx sdk.Context, query json.RawMessage, version string) ([]byte, error) { + return func(ctx sdk.Context, query json.RawMessage, _ string) ([]byte, error) { wrapper := struct { Params *MetadataQueryParams `json:"metadata"` }{} diff --git a/x/msgfees/client/cli/query.go b/x/msgfees/client/cli/query.go index 7a4f2c7486..9d5a9d2eaf 100644 --- a/x/msgfees/client/cli/query.go +++ b/x/msgfees/client/cli/query.go @@ -35,7 +35,7 @@ func AllMsgFeesCmd() *cobra.Command { Aliases: []string{"ls", "l"}, Short: "List all the msg fees on the Provenance Blockchain", Args: cobra.NoArgs, - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { clientCtx, err := client.GetClientQueryContext(cmd) if err != nil { return err @@ -71,15 +71,12 @@ func ListParamsCmd() *cobra.Command { Aliases: []string{"p"}, Short: "List the msg fees params on the Provenance Blockchain", Args: cobra.NoArgs, - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { clientCtx, err := client.GetClientQueryContext(cmd) if err != nil { return err } queryClient := types.NewQueryClient(clientCtx) - if err != nil { - return err - } var response *types.QueryParamsResponse if response, err = queryClient.Params( diff --git a/x/msgfees/client/cli/tx.go b/x/msgfees/client/cli/tx.go index 48593ef8c7..9144ef85ba 100644 --- a/x/msgfees/client/cli/tx.go +++ b/x/msgfees/client/cli/tx.go @@ -80,16 +80,6 @@ $ %[1]s tx msgfees remove "removing" "removing MsgWriterRecordRequest fee" 10nha return err } - msgFee, err := clientCtx.InterfaceRegistry.Resolve(msgType) - if err != nil { - return err - } - - _, ok := msgFee.(sdk.Msg) - if !ok { - return fmt.Errorf("message type is not a sdk message: %q", msgType) - } - var addFee sdk.Coin if proposalType != "remove" { additionalFee, errMinFee := cmd.Flags().GetString(FlagMinFee) diff --git a/x/msgfees/keeper/proposal_handler.go b/x/msgfees/keeper/proposal_handler.go index 2220fab3b8..fed81e6582 100644 --- a/x/msgfees/keeper/proposal_handler.go +++ b/x/msgfees/keeper/proposal_handler.go @@ -13,16 +13,11 @@ import ( // TODO[1760]: marker: Migrate the legacy gov proposals. // HandleAddMsgFeeProposal handles an Add msg fees governance proposal request -func HandleAddMsgFeeProposal(ctx sdk.Context, k Keeper, proposal *types.AddMsgFeeProposal, registry codectypes.InterfaceRegistry) error { +func HandleAddMsgFeeProposal(ctx sdk.Context, k Keeper, proposal *types.AddMsgFeeProposal, _ codectypes.InterfaceRegistry) error { if err := proposal.ValidateBasic(); err != nil { return err } - err := checkMsgTypeValid(registry, proposal.MsgTypeUrl) - if err != nil { - return err - } - existing, err := k.GetMsgFee(ctx, proposal.MsgTypeUrl) if err != nil { return err @@ -63,28 +58,11 @@ func DetermineBips(recipient string, recipientBasisPoints string) (uint32, error return bips, nil } -func checkMsgTypeValid(registry codectypes.InterfaceRegistry, msgTypeURL string) error { - msgFee, err := registry.Resolve(msgTypeURL) - if err != nil { - return err - } - - _, ok := msgFee.(sdk.Msg) - if !ok { - return fmt.Errorf("message type is not a sdk message: %v", msgTypeURL) - } - return err -} - // HandleUpdateMsgFeeProposal handles an Update of an existing msg fees governance proposal request -func HandleUpdateMsgFeeProposal(ctx sdk.Context, k Keeper, proposal *types.UpdateMsgFeeProposal, registry codectypes.InterfaceRegistry) error { +func HandleUpdateMsgFeeProposal(ctx sdk.Context, k Keeper, proposal *types.UpdateMsgFeeProposal, _ codectypes.InterfaceRegistry) error { if err := proposal.ValidateBasic(); err != nil { return err } - err := checkMsgTypeValid(registry, proposal.MsgTypeUrl) - if err != nil { - return err - } existing, err := k.GetMsgFee(ctx, proposal.MsgTypeUrl) if err != nil { return err @@ -108,13 +86,10 @@ func HandleUpdateMsgFeeProposal(ctx sdk.Context, k Keeper, proposal *types.Updat } // HandleRemoveMsgFeeProposal handles a Remove of an existing msg fees governance proposal request -func HandleRemoveMsgFeeProposal(ctx sdk.Context, k Keeper, proposal *types.RemoveMsgFeeProposal, registry codectypes.InterfaceRegistry) error { +func HandleRemoveMsgFeeProposal(ctx sdk.Context, k Keeper, proposal *types.RemoveMsgFeeProposal, _ codectypes.InterfaceRegistry) error { if err := proposal.ValidateBasic(); err != nil { return err } - if err := checkMsgTypeValid(registry, proposal.MsgTypeUrl); err != nil { - return err - } existing, err := k.GetMsgFee(ctx, proposal.MsgTypeUrl) if err != nil { return err diff --git a/x/msgfees/keeper/query_server.go b/x/msgfees/keeper/query_server.go index d4f9f3a302..716ceabf5e 100644 --- a/x/msgfees/keeper/query_server.go +++ b/x/msgfees/keeper/query_server.go @@ -32,7 +32,7 @@ func (k Keeper) QueryAllMsgFees(c context.Context, req *types.QueryAllMsgFeesReq var msgFees []*types.MsgFee store := ctx.KVStore(k.storeKey) msgFeeStore := prefix.NewStore(store, types.MsgFeeKeyPrefix) - pageRes, err := query.Paginate(msgFeeStore, req.Pagination, func(key []byte, value []byte) error { + pageRes, err := query.Paginate(msgFeeStore, req.Pagination, func(_ []byte, value []byte) error { var msgFee types.MsgFee if err := k.cdc.Unmarshal(value, &msgFee); err != nil { diff --git a/x/msgfees/simulation/proposals.go b/x/msgfees/simulation/proposals.go index 9bc91c4a2c..3897cc05b3 100644 --- a/x/msgfees/simulation/proposals.go +++ b/x/msgfees/simulation/proposals.go @@ -38,7 +38,7 @@ func ProposalContents(k keeper.Keeper) []simtypes.WeightedProposalContent { // SimulateCreateAddMsgFeesProposal generates random additional fee with AddMsgFeesProposal func SimulateCreateAddMsgFeesProposal(k keeper.Keeper) simtypes.ContentSimulatorFn { - return func(r *rand.Rand, ctx sdk.Context, accs []simtypes.Account) simtypes.Content { + return func(r *rand.Rand, ctx sdk.Context, _ []simtypes.Account) simtypes.Content { msgFeeExists, err := k.GetMsgFee(ctx, sdk.MsgTypeURL(&attributetypes.MsgAddAttributeRequest{})) check(err) if msgFeeExists == nil { @@ -64,7 +64,7 @@ func SimulateCreateAddMsgFeesProposal(k keeper.Keeper) simtypes.ContentSimulator // SimulateCreateRemoveMsgFeesProposal generates random removal of additional fee with RemoveMsgFeesProposal func SimulateCreateRemoveMsgFeesProposal(k keeper.Keeper) simtypes.ContentSimulatorFn { - return func(r *rand.Rand, ctx sdk.Context, accs []simtypes.Account) simtypes.Content { + return func(r *rand.Rand, ctx sdk.Context, _ []simtypes.Account) simtypes.Content { msgFeeExists, err := k.GetMsgFee(ctx, sdk.MsgTypeURL(&attributetypes.MsgAddAttributeRequest{})) check(err) if msgFeeExists != nil { diff --git a/x/msgfees/types/codec.go b/x/msgfees/types/codec.go index 89bc32f0ed..803adc5077 100644 --- a/x/msgfees/types/codec.go +++ b/x/msgfees/types/codec.go @@ -12,9 +12,7 @@ import ( // double check func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { messages := make([]proto.Message, len(allRequestMsgs)) - for i, msg := range allRequestMsgs { - messages[i] = msg - } + copy(messages, allRequestMsgs) registry.RegisterImplementations((*sdk.Msg)(nil), messages...) registry.RegisterImplementations( diff --git a/x/name/client/cli/query.go b/x/name/client/cli/query.go index c4a6a537ba..20c1626c3b 100644 --- a/x/name/client/cli/query.go +++ b/x/name/client/cli/query.go @@ -41,7 +41,7 @@ func QueryParamsCmd() *cobra.Command { Short: "Query the current name parameters", Args: cobra.NoArgs, Example: fmt.Sprintf(`$ %s query name params`, version.AppName), - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { clientCtx, err := client.GetClientQueryContext(cmd) if err != nil { return err diff --git a/x/name/keeper/params.go b/x/name/keeper/params.go index 920da35ec8..28b7e63801 100644 --- a/x/name/keeper/params.go +++ b/x/name/keeper/params.go @@ -2,6 +2,7 @@ package keeper import ( sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/provenance-io/provenance/x/name/types" ) diff --git a/x/name/keeper/query_server.go b/x/name/keeper/query_server.go index ad681b39aa..5fd89c351e 100644 --- a/x/name/keeper/query_server.go +++ b/x/name/keeper/query_server.go @@ -50,7 +50,7 @@ func (k Keeper) ReverseLookup(c context.Context, request *types.QueryReverseLook return nil, types.ErrInvalidAddress } nameStore := prefix.NewStore(store, key) - pageRes, err := query.FilteredPaginate(nameStore, request.Pagination, func(key []byte, value []byte, accumulate bool) (bool, error) { + pageRes, err := query.FilteredPaginate(nameStore, request.Pagination, func(_ []byte, value []byte, accumulate bool) (bool, error) { var record types.NameRecord err = k.cdc.Unmarshal(value, &record) if err != nil { diff --git a/x/name/simulation/proposals.go b/x/name/simulation/proposals.go index 881c2e5c7c..8d1f0562e8 100644 --- a/x/name/simulation/proposals.go +++ b/x/name/simulation/proposals.go @@ -28,7 +28,7 @@ func ProposalContents(k keeper.Keeper) []simtypes.WeightedProposalContent { // SimulateCreateRootNameProposalContent generates random create-root-name proposal content func SimulateCreateRootNameProposalContent(_ keeper.Keeper) simtypes.ContentSimulatorFn { - return func(r *rand.Rand, ctx sdk.Context, accs []simtypes.Account) simtypes.Content { + return func(r *rand.Rand, _ sdk.Context, accs []simtypes.Account) simtypes.Content { simAccount, _ := simtypes.RandomAcc(r, accs) restricted := r.Intn(2) == 0 diff --git a/x/name/wasm/query.go b/x/name/wasm/query.go index f3383ce800..beee620dc9 100644 --- a/x/name/wasm/query.go +++ b/x/name/wasm/query.go @@ -35,7 +35,7 @@ type LookupQueryParams struct { // Querier returns a smart contract querier for the name module. func Querier(keeper keeper.Keeper) provwasm.Querier { - return func(ctx sdk.Context, query json.RawMessage, version string) ([]byte, error) { + return func(ctx sdk.Context, query json.RawMessage, _ string) ([]byte, error) { wrapper := struct { Params *NameQueryParams `json:"name"` }{} diff --git a/x/oracle/client/cli/query.go b/x/oracle/client/cli/query.go index 29ea90e673..c073a8808c 100644 --- a/x/oracle/client/cli/query.go +++ b/x/oracle/client/cli/query.go @@ -36,7 +36,7 @@ func GetQueryOracleAddressCmd() *cobra.Command { Args: cobra.ExactArgs(0), Aliases: []string{"a"}, Example: fmt.Sprintf(`%[1]s q oracle address`, version.AppName), - RunE: func(cmd *cobra.Command, args []string) (err error) { + RunE: func(cmd *cobra.Command, _ []string) (err error) { clientCtx, err := client.GetClientQueryContext(cmd) if err != nil { return err diff --git a/x/quarantine/client/cli/util.go b/x/quarantine/client/cli/util.go index 69a74bc9ce..f4678540a5 100644 --- a/x/quarantine/client/cli/util.go +++ b/x/quarantine/client/cli/util.go @@ -69,12 +69,12 @@ func ParseAutoResponseUpdatesFromArgs(args []string, startIndex int) ([]*quarant // Slightly different message on purpose. Makes it easier to track down the source of an error. return nil, fmt.Errorf("invalid arg %d: last arg cannot be an auto-response, got: %q", i+startIndex+1, arg) } - arArgCount += 1 + arArgCount++ ar = newAr lastArArg = arg arAddrCount = 0 } else { - arAddrCount += 1 + arAddrCount++ fromAddr, err := validateAddress(arg, "from_address") if err != nil { return nil, fmt.Errorf("unknown arg %d %q: auto-response %d %q: from_address %d: %w", i+startIndex+1, arg, arArgCount, lastArArg, arAddrCount, err) diff --git a/x/quarantine/keys.go b/x/quarantine/keys.go index c22418cf39..2f7cfff293 100644 --- a/x/quarantine/keys.go +++ b/x/quarantine/keys.go @@ -99,8 +99,8 @@ func CreateRecordKey(toAddr sdk.AccAddress, fromAddrs ...sdk.AccAddress) []byte // This is designed such that a known record suffix can be provided // as a single "from address" to create the key with that suffix. toAddrPreBz := CreateRecordToAddrPrefix(toAddr) - recordId := address.MustLengthPrefix(createRecordSuffix(fromAddrs)) - return MakeKey(toAddrPreBz, recordId) + recordID := address.MustLengthPrefix(createRecordSuffix(fromAddrs)) + return MakeKey(toAddrPreBz, recordID) } // createRecordSuffix creates a single "address" to use for the provided from addresses. @@ -162,8 +162,8 @@ func CreateRecordIndexToAddrPrefix(toAddr sdk.AccAddress) []byte { // CreateRecordIndexKey creates the key for the quarantine record suffix index. func CreateRecordIndexKey(toAddr, fromAddr sdk.AccAddress) []byte { toAddrPreBz := CreateRecordIndexToAddrPrefix(toAddr) - recordId := address.MustLengthPrefix(fromAddr) - return MakeKey(toAddrPreBz, recordId) + recordID := address.MustLengthPrefix(fromAddr) + return MakeKey(toAddrPreBz, recordID) } // ParseRecordIndexKey extracts the to address and from address from the provided quarantine record index key. diff --git a/x/sanction/client/cli/query.go b/x/sanction/client/cli/query.go index f20e755394..0a29b0990f 100644 --- a/x/sanction/client/cli/query.go +++ b/x/sanction/client/cli/query.go @@ -100,7 +100,7 @@ Examples: `, exampleQueryCmdBase), Args: cobra.ExactArgs(0), - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { clientCtx, err := client.GetClientQueryContext(cmd) if err != nil { return err @@ -200,7 +200,7 @@ Example: `, exampleQueryCmdBase), Args: cobra.ExactArgs(0), - RunE: func(cmd *cobra.Command, args []string) error { + RunE: func(cmd *cobra.Command, _ []string) error { clientCtx, err := client.GetClientQueryContext(cmd) if err != nil { return err diff --git a/x/sanction/simulation/operations.go b/x/sanction/simulation/operations.go index fac142c5da..f76d11d8e1 100644 --- a/x/sanction/simulation/operations.go +++ b/x/sanction/simulation/operations.go @@ -153,7 +153,7 @@ func SendGovMsg(args *SendGovMsgArgs) (bool, simtypes.OperationMsg, error) { func OperationMsgVote(args *WeightedOpsArgs, voter simtypes.Account, govPropID uint64, vote govv1.VoteOption, comment string) simtypes.Operation { return func( r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, - accs []simtypes.Account, chainID string, + _ []simtypes.Account, _ string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { msg := govv1.NewMsgVote(voter.Address, govPropID, vote, "") diff --git a/x/trigger/keeper/event_detector.go b/x/trigger/keeper/event_detector.go index 9b548436f3..c2ca46be9a 100644 --- a/x/trigger/keeper/event_detector.go +++ b/x/trigger/keeper/event_detector.go @@ -25,7 +25,7 @@ func (k Keeper) DetectBlockEvents(ctx sdk.Context) { // detectTransactionEvents Detects triggers that have been activated by transaction events. func (k Keeper) detectTransactionEvents(ctx sdk.Context) (triggers []types.Trigger) { detectedTriggers := map[uint64]bool{} - terminator := func(trigger types.Trigger, triggerEvent types.TriggerEventI) bool { + terminator := func(_ types.Trigger, _ types.TriggerEventI) bool { return false } diff --git a/x/trigger/keeper/query_server.go b/x/trigger/keeper/query_server.go index 2dd8e18cd4..afa28b0ffb 100644 --- a/x/trigger/keeper/query_server.go +++ b/x/trigger/keeper/query_server.go @@ -42,7 +42,7 @@ func (k Keeper) Triggers(ctx context.Context, req *types.QueryTriggersRequest) ( response := types.QueryTriggersResponse{} kvStore := sdkCtx.KVStore(k.storeKey) prefixStore := prefix.NewStore(kvStore, types.TriggerKeyPrefix) - pageResponse, err := query.FilteredPaginate(prefixStore, pagination, func(key []byte, value []byte, accumulate bool) (bool, error) { + pageResponse, err := query.FilteredPaginate(prefixStore, pagination, func(_ []byte, value []byte, accumulate bool) (bool, error) { var trigger types.Trigger vErr := trigger.Unmarshal(value) diff --git a/x/trigger/simulation/genesis.go b/x/trigger/simulation/genesis.go index de3ac9d5a9..ebd3468c4f 100644 --- a/x/trigger/simulation/genesis.go +++ b/x/trigger/simulation/genesis.go @@ -100,9 +100,9 @@ func NewRandomQueuedTrigger(r *rand.Rand, simState *module.SimulationState, accs } // RandomNewQueuedTriggers generates a random queued trigger for each provided id. -func RandomNewQueuedTriggers(r *rand.Rand, simState *module.SimulationState, accs []simtypes.Account, queuedTriggerIds []uint64) []types.QueuedTrigger { - rv := make([]types.QueuedTrigger, len(queuedTriggerIds)) - for i, id := range queuedTriggerIds { +func RandomNewQueuedTriggers(r *rand.Rand, simState *module.SimulationState, accs []simtypes.Account, queuedTriggerIDs []uint64) []types.QueuedTrigger { + rv := make([]types.QueuedTrigger, len(queuedTriggerIDs)) + for i, id := range queuedTriggerIDs { rv[i] = NewRandomQueuedTrigger(r, simState, accs, id) } return rv diff --git a/x/trigger/types/trigger.go b/x/trigger/types/trigger.go index 50e0d922d9..0d32f33874 100644 --- a/x/trigger/types/trigger.go +++ b/x/trigger/types/trigger.go @@ -60,11 +60,11 @@ func (e TransactionEvent) Matches(other abci.Event) bool { // Matches checks if two Attributes have the same name and an equal value if one is specified. func (a Attribute) Matches(other abci.EventAttribute) bool { - if a.GetName() != string(other.GetKey()) { + if a.GetName() != other.GetKey() { return false } - if a.GetValue() != "" && a.GetValue() != string(other.GetValue()) { + if a.GetValue() != "" && a.GetValue() != other.GetValue() { return false }