diff --git a/CHANGELOG.md b/CHANGELOG.md index a098d09363..716314bba6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -797,6 +797,7 @@ replace github.com/confio/ics23/go => github.com/cosmos/cosmos-sdk/ics23/go v0.8 * [#11334](https://github.com/cosmos/cosmos-sdk/pull/11334) Move `x/gov/types/v1beta2` to `x/gov/types/v1`. * (x/auth/middleware) [#11413](https://github.com/cosmos/cosmos-sdk/pull/11413) Refactor tx middleware to be extensible on tx fee logic. Merged `MempoolFeeMiddleware` and `TxPriorityMiddleware` functionalities into `DeductFeeMiddleware`, make the logic extensible using the `TxFeeChecker` option, the current fee logic is preserved by the default `checkTxFeeWithValidatorMinGasPrices` implementation. Change `RejectExtensionOptionsMiddleware` to `NewExtensionOptionsMiddleware` which is extensible with the `ExtensionOptionChecker` option. Unpack the tx extension options `Any`s to interface `TxExtensionOptionI`. * (migrations) [#11556](https://github.com/cosmos/cosmos-sdk/pull/11556#issuecomment-1091385011) Remove migration code from 0.42 and below. To use previous migrations, checkout previous versions of the cosmos-sdk. +* (x/authz,consensus,crisis,slashing) [#15675](https://github.com/cosmos/cosmos-sdk/pull/15675) Remove ModuleCdc as `NewAminoCodec` is depreacted. ### Client Breaking Changes diff --git a/client/tx/tx_test.go b/client/tx/tx_test.go index 788b96c2f2..6c0d3a7eb2 100644 --- a/client/tx/tx_test.go +++ b/client/tx/tx_test.go @@ -1,7 +1,7 @@ package tx_test import ( - gocontext "context" + "context" "fmt" "strings" "testing" @@ -40,7 +40,7 @@ type mockContext struct { wantErr bool } -func (m mockContext) Invoke(grpcCtx gocontext.Context, method string, req, reply interface{}, opts ...grpc.CallOption) (err error) { +func (m mockContext) Invoke(grpcCtx context.Context, method string, req, reply interface{}, opts ...grpc.CallOption) (err error) { if m.wantErr { return fmt.Errorf("mock err") } @@ -53,7 +53,7 @@ func (m mockContext) Invoke(grpcCtx gocontext.Context, method string, req, reply return nil } -func (mockContext) NewStream(gocontext.Context, *grpc.StreamDesc, string, ...grpc.CallOption) (grpc.ClientStream, error) { +func (mockContext) NewStream(context.Context, *grpc.StreamDesc, string, ...grpc.CallOption) (grpc.ClientStream, error) { panic("not implemented") } @@ -347,7 +347,7 @@ func TestSign(t *testing.T) { var prevSigs []signingtypes.SignatureV2 for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) { - err = tx.Sign(nil, tc.txf, tc.from, tc.txb, tc.overwrite) //nolint:staticcheck + err = tx.Sign(context.TODO(), tc.txf, tc.from, tc.txb, tc.overwrite) if len(tc.expectedPKs) == 0 { requireT.Error(err) } else { @@ -418,7 +418,7 @@ func TestPreprocessHook(t *testing.T) { txb, err := txfDirect.BuildUnsignedTx(msg1, msg2) requireT.NoError(err) - err = tx.Sign(nil, txfDirect, from, txb, false) //nolint:staticcheck + err = tx.Sign(context.TODO(), txfDirect, from, txb, false) requireT.NoError(err) // Run preprocessing diff --git a/codec/proto_codec.go b/codec/proto_codec.go index 212faf1d83..f6cf06189d 100644 --- a/codec/proto_codec.go +++ b/codec/proto_codec.go @@ -300,13 +300,12 @@ func (pc *ProtoCodec) GetMsgV1Signers(msg gogoproto.Message) ([]string, proto.Me if msgV2, ok := msg.(proto.Message); ok { signers, err := pc.getSignersCtx.GetSigners(msgV2) return signers, msgV2, err - } else { - a, err := types.NewAnyWithValue(msg) - if err != nil { - return nil, nil, err - } - return pc.GetMsgAnySigners(a) } + a, err := types.NewAnyWithValue(msg) + if err != nil { + return nil, nil, err + } + return pc.GetMsgAnySigners(a) } // GRPCCodec returns the gRPC Codec for this specific ProtoCodec diff --git a/crypto/armor.go b/crypto/armor.go index 6b1c2503f7..78e723f002 100644 --- a/crypto/armor.go +++ b/crypto/armor.go @@ -7,7 +7,7 @@ import ( "io" "github.com/cometbft/cometbft/crypto" - "golang.org/x/crypto/openpgp/armor" //nolint:staticcheck + "golang.org/x/crypto/openpgp/armor" //nolint:staticcheck // TODO: remove this dependency errorsmod "cosmossdk.io/errors" diff --git a/crypto/ledger/encode_test.go b/crypto/ledger/encode_test.go index f9ce2418fd..099c8e91a3 100644 --- a/crypto/ledger/encode_test.go +++ b/crypto/ledger/encode_test.go @@ -24,7 +24,7 @@ func checkAminoJSON(t *testing.T, src, dst interface{}, isNil bool) { require.Nil(t, err, "%+v", err) } -func ExamplePrintRegisteredTypes() { //nolint:govet +func ExamplePrintRegisteredTypes() { _ = cdc.PrintTypes(os.Stdout) // | Type | Name | Prefix | Length | Notes | // | ---- | ---- | ------ | ----- | ------ | diff --git a/testutil/rest.go b/testutil/rest.go index 93608482d1..6b8066aafb 100644 --- a/testutil/rest.go +++ b/testutil/rest.go @@ -42,7 +42,7 @@ func GetRequestWithHeaders(url string, headers map[string]string) ([]byte, error // GetRequest defines a wrapper around an HTTP GET request with a provided URL. // An error is returned if the request or reading the body fails. func GetRequest(url string) ([]byte, error) { - res, err := http.Get(url) //nolint:gosec + res, err := http.Get(url) //nolint:gosec // only used for testing if err != nil { return nil, err } @@ -61,7 +61,7 @@ func GetRequest(url string) ([]byte, error) { // PostRequest defines a wrapper around an HTTP POST request with a provided URL and data. // An error is returned if the request or reading the body fails. func PostRequest(url, contentType string, data []byte) ([]byte, error) { - res, err := http.Post(url, contentType, bytes.NewBuffer(data)) //nolint:gosec + res, err := http.Post(url, contentType, bytes.NewBuffer(data)) //nolint:gosec // only used for testing if err != nil { return nil, fmt.Errorf("error while sending post request: %w", err) } diff --git a/testutil/sims/simulation_helpers.go b/testutil/sims/simulation_helpers.go index 152703bf11..1fdf87eb1c 100644 --- a/testutil/sims/simulation_helpers.go +++ b/testutil/sims/simulation_helpers.go @@ -68,7 +68,7 @@ func SimulationOperations(app runtime.AppI, cdc codec.JSONCodec, config simtypes } } - simState.LegacyProposalContents = app.SimulationManager().GetProposalContents(simState) //nolint:staticcheck + simState.LegacyProposalContents = app.SimulationManager().GetProposalContents(simState) //nolint:staticcheck // used for legacy testing simState.ProposalMsgs = app.SimulationManager().GetProposalMsgs(simState) return app.SimulationManager().WeightedOperations(simState) } diff --git a/types/context_test.go b/types/context_test.go index e4d7e818e9..3a605d0a09 100644 --- a/types/context_test.go +++ b/types/context_test.go @@ -238,7 +238,7 @@ func (s *contextTestSuite) TestUnwrapSDKContext() { s.Require().Panics(func() { types.UnwrapSDKContext(ctx) }) // test unwrapping when we've used context.WithValue - ctx = context.WithValue(sdkCtx, "foo", "bar") //nolint:golint,staticcheck,revive + ctx = context.WithValue(sdkCtx, struct{}{}, "bar") sdkCtx2 = types.UnwrapSDKContext(ctx) s.Require().Equal(sdkCtx, sdkCtx2) } diff --git a/x/auth/vesting/module.go b/x/auth/vesting/module.go index 18f3ac2011..62a56ebbdf 100644 --- a/x/auth/vesting/module.go +++ b/x/auth/vesting/module.go @@ -131,23 +131,21 @@ func init() { ) } -//nolint:revive -type VestingInputs struct { +type ModuleInputs struct { depinject.In AccountKeeper keeper.AccountKeeper BankKeeper types.BankKeeper } -//nolint:revive -type VestingOutputs struct { +type ModuleOutputs struct { depinject.Out Module appmodule.AppModule } -func ProvideModule(in VestingInputs) VestingOutputs { +func ProvideModule(in ModuleInputs) ModuleOutputs { m := NewAppModule(in.AccountKeeper, in.BankKeeper) - return VestingOutputs{Module: m} + return ModuleOutputs{Module: m} } diff --git a/x/authz/codec/cdc.go b/x/authz/codec/cdc.go index 520e435afd..a329ad1170 100644 --- a/x/authz/codec/cdc.go +++ b/x/authz/codec/cdc.go @@ -6,10 +6,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -var ( - Amino = codec.NewLegacyAmino() - ModuleCdc = codec.NewAminoCodec(Amino) -) +var Amino = codec.NewLegacyAmino() func init() { cryptocodec.RegisterCrypto(Amino) diff --git a/x/authz/module/module.go b/x/authz/module/module.go index fe883878df..9bf6cd1705 100644 --- a/x/authz/module/module.go +++ b/x/authz/module/module.go @@ -86,7 +86,7 @@ func (AppModuleBasic) ValidateGenesis(cdc codec.JSONCodec, config sdkclient.TxEn } // RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the authz module. -func (a AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx sdkclient.Context, mux *gwruntime.ServeMux) { +func (AppModuleBasic) RegisterGRPCGatewayRoutes(clientCtx sdkclient.Context, mux *gwruntime.ServeMux) { if err := authz.RegisterQueryHandlerClient(context.Background(), mux, authz.NewQueryClient(clientCtx)); err != nil { panic(err) } @@ -170,8 +170,7 @@ func init() { ) } -//nolint:revive -type AuthzInputs struct { +type ModuleInputs struct { depinject.In Key *store.KVStoreKey @@ -182,18 +181,17 @@ type AuthzInputs struct { MsgServiceRouter baseapp.MessageRouter } -//nolint:revive -type AuthzOutputs struct { +type ModuleOutputs struct { depinject.Out AuthzKeeper keeper.Keeper Module appmodule.AppModule } -func ProvideModule(in AuthzInputs) AuthzOutputs { +func ProvideModule(in ModuleInputs) ModuleOutputs { k := keeper.NewKeeper(in.Key, in.Cdc, in.MsgServiceRouter, in.AccountKeeper) m := NewAppModule(in.Cdc, k, in.AccountKeeper, in.BankKeeper, in.Registry) - return AuthzOutputs{AuthzKeeper: k, Module: m} + return ModuleOutputs{AuthzKeeper: k, Module: m} } // ____________________________________________________________________________ diff --git a/x/authz/msgs.go b/x/authz/msgs.go index b67aa174e3..587e42275e 100644 --- a/x/authz/msgs.go +++ b/x/authz/msgs.go @@ -66,7 +66,7 @@ func (msg MsgGrant) ValidateBasic() error { // GetSignBytes implements the LegacyMsg.GetSignBytes method. func (msg MsgGrant) GetSignBytes() []byte { - return sdk.MustSortJSON(authzcodec.ModuleCdc.MustMarshalJSON(&msg)) + return sdk.MustSortJSON(authzcodec.Amino.MustMarshalJSON(&msg)) } // GetAuthorization returns the cache value from the MsgGrant.Authorization if present. @@ -145,7 +145,7 @@ func (msg MsgRevoke) ValidateBasic() error { // GetSignBytes implements the LegacyMsg.GetSignBytes method. func (msg MsgRevoke) GetSignBytes() []byte { - return sdk.MustSortJSON(authzcodec.ModuleCdc.MustMarshalJSON(&msg)) + return sdk.MustSortJSON(authzcodec.Amino.MustMarshalJSON(&msg)) } // NewMsgExec creates a new MsgExecAuthorized @@ -211,5 +211,5 @@ func (msg MsgExec) ValidateBasic() error { // GetSignBytes implements the LegacyMsg.GetSignBytes method. func (msg MsgExec) GetSignBytes() []byte { - return sdk.MustSortJSON(authzcodec.ModuleCdc.MustMarshalJSON(&msg)) + return sdk.MustSortJSON(authzcodec.Amino.MustMarshalJSON(&msg)) } diff --git a/x/consensus/module.go b/x/consensus/module.go index 776fe30b45..1834077305 100644 --- a/x/consensus/module.go +++ b/x/consensus/module.go @@ -141,8 +141,7 @@ func init() { ) } -//nolint:revive -type ConsensusInputs struct { +type ModuleInputs struct { depinject.In Config *modulev1.Module @@ -151,8 +150,7 @@ type ConsensusInputs struct { EventManager event.Service } -//nolint:revive -type ConsensusOutputs struct { +type ModuleOutputs struct { depinject.Out Keeper keeper.Keeper @@ -160,7 +158,7 @@ type ConsensusOutputs struct { BaseAppOption runtime.BaseAppOption } -func ProvideModule(in ConsensusInputs) ConsensusOutputs { +func ProvideModule(in ModuleInputs) ModuleOutputs { // default to governance authority if not provided authority := authtypes.NewModuleAddress(govtypes.ModuleName) if in.Config.Authority != "" { @@ -173,7 +171,7 @@ func ProvideModule(in ConsensusInputs) ConsensusOutputs { app.SetParamStore(k.ParamsStore) } - return ConsensusOutputs{ + return ModuleOutputs{ Keeper: k, Module: m, BaseAppOption: baseappOpt, diff --git a/x/consensus/types/codec.go b/x/consensus/types/codec.go index 205596743f..32f009ccdb 100644 --- a/x/consensus/types/codec.go +++ b/x/consensus/types/codec.go @@ -27,10 +27,7 @@ func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { legacy.RegisterAminoMsg(cdc, &MsgUpdateParams{}, "cosmos-sdk/x/consensus/MsgUpdateParams") } -var ( - amino = codec.NewLegacyAmino() - ModuleCdc = codec.NewAminoCodec(amino) -) +var amino = codec.NewLegacyAmino() func init() { RegisterLegacyAminoCodec(amino) diff --git a/x/consensus/types/msgs.go b/x/consensus/types/msgs.go index 7b0ac5c94d..8ac148dfbc 100644 --- a/x/consensus/types/msgs.go +++ b/x/consensus/types/msgs.go @@ -23,7 +23,7 @@ func (msg MsgUpdateParams) GetSigners() []sdk.AccAddress { // GetSignBytes returns the raw bytes for a MsgUpdateParams message that // the expected signer needs to sign. func (msg MsgUpdateParams) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) + return sdk.MustSortJSON(amino.MustMarshalJSON(&msg)) } // ValidateBasic performs basic MsgUpdateParams message validation. diff --git a/x/crisis/module.go b/x/crisis/module.go index 0bf4f155e8..1fec0487e9 100644 --- a/x/crisis/module.go +++ b/x/crisis/module.go @@ -191,8 +191,7 @@ func init() { ) } -//nolint:revive -type CrisisInputs struct { +type ModuleInputs struct { depinject.In Config *modulev1.Module @@ -206,15 +205,14 @@ type CrisisInputs struct { LegacySubspace exported.Subspace } -//nolint:revive -type CrisisOutputs struct { +type ModuleOutputs struct { depinject.Out Module appmodule.AppModule CrisisKeeper *keeper.Keeper } -func ProvideModule(in CrisisInputs) CrisisOutputs { +func ProvideModule(in ModuleInputs) ModuleOutputs { var invalidCheckPeriod uint if in.AppOpts != nil { invalidCheckPeriod = cast.ToUint(in.AppOpts.Get(server.FlagInvCheckPeriod)) @@ -247,5 +245,5 @@ func ProvideModule(in CrisisInputs) CrisisOutputs { m := NewAppModule(k, skipGenesisInvariants, in.LegacySubspace) - return CrisisOutputs{CrisisKeeper: k, Module: m} + return ModuleOutputs{CrisisKeeper: k, Module: m} } diff --git a/x/crisis/types/codec.go b/x/crisis/types/codec.go index 9e2ed19261..b469f00514 100644 --- a/x/crisis/types/codec.go +++ b/x/crisis/types/codec.go @@ -29,15 +29,12 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) { msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) } -var ( - amino = codec.NewLegacyAmino() - ModuleCdc = codec.NewAminoCodec(amino) -) +var aminoCdc = codec.NewLegacyAmino() func init() { - RegisterLegacyAminoCodec(amino) - cryptocodec.RegisterCrypto(amino) - sdk.RegisterLegacyAminoCodec(amino) + RegisterLegacyAminoCodec(aminoCdc) + cryptocodec.RegisterCrypto(aminoCdc) + sdk.RegisterLegacyAminoCodec(aminoCdc) // Register all Amino interfaces and concrete types on the authz and gov Amino codec so that this can later be // used to properly serialize MsgGrant, MsgExec and MsgSubmitProposal instances diff --git a/x/crisis/types/msgs.go b/x/crisis/types/msgs.go index e5a434bf20..853b40f6da 100644 --- a/x/crisis/types/msgs.go +++ b/x/crisis/types/msgs.go @@ -31,7 +31,7 @@ func (msg MsgVerifyInvariant) GetSigners() []sdk.AccAddress { // GetSignBytes gets the sign bytes for the msg MsgVerifyInvariant func (msg MsgVerifyInvariant) GetSignBytes() []byte { - bz := ModuleCdc.MustMarshalJSON(&msg) + bz := aminoCdc.MustMarshalJSON(&msg) return sdk.MustSortJSON(bz) } @@ -58,7 +58,7 @@ func (msg MsgUpdateParams) GetSigners() []sdk.AccAddress { // GetSignBytes returns the raw bytes for a MsgUpdateParams message that // the expected signer needs to sign. func (msg MsgUpdateParams) GetSignBytes() []byte { - bz := ModuleCdc.MustMarshalJSON(&msg) + bz := aminoCdc.MustMarshalJSON(&msg) return sdk.MustSortJSON(bz) } diff --git a/x/gov/module.go b/x/gov/module.go index 00acf507cd..ab09328b6e 100644 --- a/x/gov/module.go +++ b/x/gov/module.go @@ -163,8 +163,7 @@ func init() { appmodule.Invoke(InvokeAddRoutes, InvokeSetHooks)) } -//nolint:revive -type GovInputs struct { +type ModuleInputs struct { depinject.In Config *modulev1.Module @@ -182,8 +181,7 @@ type GovInputs struct { LegacySubspace govtypes.ParamSubspace } -//nolint:revive -type GovOutputs struct { +type ModuleOutputs struct { depinject.Out Module appmodule.AppModule @@ -191,7 +189,7 @@ type GovOutputs struct { HandlerRoute v1beta1.HandlerRoute } -func ProvideModule(in GovInputs) GovOutputs { +func ProvideModule(in ModuleInputs) ModuleOutputs { defaultConfig := govtypes.DefaultConfig() if in.Config.MaxMetadataLen != 0 { defaultConfig.MaxMetadataLen = in.Config.MaxMetadataLen @@ -217,7 +215,7 @@ func ProvideModule(in GovInputs) GovOutputs { m := NewAppModule(in.Cdc, k, in.AccountKeeper, in.BankKeeper, in.LegacySubspace) hr := v1beta1.HandlerRoute{Handler: v1beta1.ProposalHandler, RouteKey: govtypes.RouterKey} - return GovOutputs{Module: m, Keeper: k, HandlerRoute: hr} + return ModuleOutputs{Module: m, Keeper: k, HandlerRoute: hr} } func ProvideKeyTable() paramtypes.KeyTable { @@ -340,7 +338,7 @@ func (AppModule) GenerateGenesisState(simState *module.SimulationState) { // ProposalContents returns all the gov content functions used to // simulate governance proposals. -func (AppModule) ProposalContents(simState module.SimulationState) []simtypes.WeightedProposalContent { //nolint:staticcheck +func (AppModule) ProposalContents(simState module.SimulationState) []simtypes.WeightedProposalContent { //nolint:staticcheck // used for legacy testing return simulation.ProposalContents() } diff --git a/x/gov/simulation/operations.go b/x/gov/simulation/operations.go index ba8edee40f..3787514562 100644 --- a/x/gov/simulation/operations.go +++ b/x/gov/simulation/operations.go @@ -45,7 +45,7 @@ const ( ) // WeightedOperations returns all the operations from the module with their respective weights -func WeightedOperations(appParams simtypes.AppParams, cdc codec.JSONCodec, ak types.AccountKeeper, bk types.BankKeeper, k *keeper.Keeper, wMsgs []simtypes.WeightedProposalMsg, wContents []simtypes.WeightedProposalContent) simulation.WeightedOperations { //nolint:staticcheck +func WeightedOperations(appParams simtypes.AppParams, cdc codec.JSONCodec, ak types.AccountKeeper, bk types.BankKeeper, k *keeper.Keeper, wMsgs []simtypes.WeightedProposalMsg, wContents []simtypes.WeightedProposalContent) simulation.WeightedOperations { //nolint:staticcheck // used for legacy testing var ( weightMsgDeposit int weightMsgVote int @@ -154,7 +154,7 @@ func SimulateMsgSubmitProposal(ak types.AccountKeeper, bk types.BankKeeper, k *k // SimulateMsgSubmitLegacyProposal simulates creating a msg Submit Proposal // voting on the proposal, and subsequently slashing the proposal. It is implemented using // future operations. -func SimulateMsgSubmitLegacyProposal(ak types.AccountKeeper, bk types.BankKeeper, k *keeper.Keeper, contentSim simtypes.ContentSimulatorFn) simtypes.Operation { //nolint:staticcheck +func SimulateMsgSubmitLegacyProposal(ak types.AccountKeeper, bk types.BankKeeper, k *keeper.Keeper, contentSim simtypes.ContentSimulatorFn) simtypes.Operation { //nolint:staticcheck // used for legacy testing return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { // 1) submit proposal now diff --git a/x/gov/simulation/proposals.go b/x/gov/simulation/proposals.go index 4afda5b0e4..06c6a1d785 100644 --- a/x/gov/simulation/proposals.go +++ b/x/gov/simulation/proposals.go @@ -31,7 +31,7 @@ func SimulateTextProposal(r *rand.Rand, _ sdk.Context, _ []simtypes.Account) sdk // ProposalContents defines the module weighted proposals' contents // -//nolint:staticcheck +//nolint:staticcheck // used for legacy testing func ProposalContents() []simtypes.WeightedProposalContent { return []simtypes.WeightedProposalContent{ simulation.NewWeightedProposalContent( @@ -44,7 +44,7 @@ func ProposalContents() []simtypes.WeightedProposalContent { // SimulateTextProposalContent returns a random text proposal content. // -//nolint:staticcheck +//nolint:staticcheck // used for legacy testing func SimulateLegacyTextProposalContent(r *rand.Rand, _ sdk.Context, _ []simtypes.Account) simtypes.Content { return v1beta1.NewTextProposal( simtypes.RandStringOfLength(r, 140), diff --git a/x/gov/types/v1/msgs.go b/x/gov/types/v1/msgs.go index 6324fc000e..b1d9c75930 100644 --- a/x/gov/types/v1/msgs.go +++ b/x/gov/types/v1/msgs.go @@ -109,7 +109,7 @@ func (m MsgSubmitProposal) ValidateBasic() error { // GetSignBytes returns the message bytes to sign over. func (m MsgSubmitProposal) GetSignBytes() []byte { - bz := codec.ModuleCdc.MustMarshalJSON(&m) + bz := codec.Amino.MustMarshalJSON(&m) return sdk.MustSortJSON(bz) } @@ -147,7 +147,7 @@ func (msg MsgDeposit) ValidateBasic() error { // GetSignBytes returns the message bytes to sign over. func (msg MsgDeposit) GetSignBytes() []byte { - bz := codec.ModuleCdc.MustMarshalJSON(&msg) + bz := codec.Amino.MustMarshalJSON(&msg) return sdk.MustSortJSON(bz) } @@ -176,7 +176,7 @@ func (msg MsgVote) ValidateBasic() error { // GetSignBytes returns the message bytes to sign over. func (msg MsgVote) GetSignBytes() []byte { - bz := codec.ModuleCdc.MustMarshalJSON(&msg) + bz := codec.Amino.MustMarshalJSON(&msg) return sdk.MustSortJSON(bz) } @@ -230,7 +230,7 @@ func (msg MsgVoteWeighted) ValidateBasic() error { // GetSignBytes returns the message bytes to sign over. func (msg MsgVoteWeighted) GetSignBytes() []byte { - bz := codec.ModuleCdc.MustMarshalJSON(&msg) + bz := codec.Amino.MustMarshalJSON(&msg) return sdk.MustSortJSON(bz) } @@ -250,7 +250,7 @@ func NewMsgExecLegacyContent(content *codectypes.Any, authority string) *MsgExec // GetSignBytes returns the message bytes to sign over. func (c MsgExecLegacyContent) GetSignBytes() []byte { - bz := codec.ModuleCdc.MustMarshalJSON(&c) + bz := codec.Amino.MustMarshalJSON(&c) return sdk.MustSortJSON(bz) } @@ -287,7 +287,7 @@ func (msg MsgUpdateParams) ValidateBasic() error { // GetSignBytes returns the message bytes to sign over. func (msg MsgUpdateParams) GetSignBytes() []byte { - bz := codec.ModuleCdc.MustMarshalJSON(&msg) + bz := codec.Amino.MustMarshalJSON(&msg) return sdk.MustSortJSON(bz) } @@ -316,7 +316,7 @@ func (msg MsgCancelProposal) ValidateBasic() error { // GetSignBytes implements Msg func (msg MsgCancelProposal) GetSignBytes() []byte { - bz := codec.ModuleCdc.MustMarshalJSON(&msg) + bz := codec.Amino.MustMarshalJSON(&msg) return sdk.MustSortJSON(bz) } diff --git a/x/gov/types/v1beta1/msgs.go b/x/gov/types/v1beta1/msgs.go index ce4b68c114..50fc1ca40a 100644 --- a/x/gov/types/v1beta1/msgs.go +++ b/x/gov/types/v1beta1/msgs.go @@ -114,7 +114,7 @@ func (m MsgSubmitProposal) ValidateBasic() error { // GetSignBytes returns the message bytes to sign over. func (m MsgSubmitProposal) GetSignBytes() []byte { - bz := codec.ModuleCdc.MustMarshalJSON(&m) + bz := codec.Amino.MustMarshalJSON(&m) return sdk.MustSortJSON(bz) } @@ -154,7 +154,7 @@ func (msg MsgDeposit) ValidateBasic() error { // GetSignBytes returns the message bytes to sign over. func (msg MsgDeposit) GetSignBytes() []byte { - bz := codec.ModuleCdc.MustMarshalJSON(&msg) + bz := codec.Amino.MustMarshalJSON(&msg) return sdk.MustSortJSON(bz) } @@ -183,7 +183,7 @@ func (msg MsgVote) ValidateBasic() error { // GetSignBytes returns the message bytes to sign over. func (msg MsgVote) GetSignBytes() []byte { - bz := codec.ModuleCdc.MustMarshalJSON(&msg) + bz := codec.Amino.MustMarshalJSON(&msg) return sdk.MustSortJSON(bz) } @@ -233,7 +233,7 @@ func (msg MsgVoteWeighted) ValidateBasic() error { // GetSignBytes returns the message bytes to sign over. func (msg MsgVoteWeighted) GetSignBytes() []byte { - bz := codec.ModuleCdc.MustMarshalJSON(&msg) + bz := codec.Amino.MustMarshalJSON(&msg) return sdk.MustSortJSON(bz) } diff --git a/x/mint/module.go b/x/mint/module.go index 614367acff..ae5bda3dd2 100644 --- a/x/mint/module.go +++ b/x/mint/module.go @@ -216,8 +216,7 @@ func init() { ) } -//nolint:revive -type MintInputs struct { +type ModuleInputs struct { depinject.In ModuleKey depinject.OwnModuleKey @@ -234,15 +233,14 @@ type MintInputs struct { StakingKeeper types.StakingKeeper } -//nolint:revive -type MintOutputs struct { +type ModuleOutputs struct { depinject.Out MintKeeper keeper.Keeper Module appmodule.AppModule } -func ProvideModule(in MintInputs) MintOutputs { +func ProvideModule(in ModuleInputs) ModuleOutputs { feeCollectorName := in.Config.FeeCollectorName if feeCollectorName == "" { feeCollectorName = authtypes.FeeCollectorName @@ -267,5 +265,5 @@ func ProvideModule(in MintInputs) MintOutputs { // when no inflation calculation function is provided it will use the default types.DefaultInflationCalculationFn m := NewAppModule(in.Cdc, k, in.AccountKeeper, in.InflationCalculationFn, in.LegacySubspace) - return MintOutputs{MintKeeper: k, Module: m} + return ModuleOutputs{MintKeeper: k, Module: m} } diff --git a/x/params/simulation/operations.go b/x/params/simulation/operations.go index ae83d32c34..2d9a862dc4 100644 --- a/x/params/simulation/operations.go +++ b/x/params/simulation/operations.go @@ -19,7 +19,7 @@ func min(a, b int) int { // SimulateParamChangeProposalContent returns random parameter change content. // It will generate a ParameterChangeProposal object with anywhere between 1 and // the total amount of defined parameters changes, all of which have random valid values. -func SimulateParamChangeProposalContent(paramChangePool []simulation.LegacyParamChange) simulation.ContentSimulatorFn { //nolint:staticcheck +func SimulateParamChangeProposalContent(paramChangePool []simulation.LegacyParamChange) simulation.ContentSimulatorFn { //nolint:staticcheck // used for legacy testing numProposals := 0 // Bound the maximum number of simultaneous parameter changes maxSimultaneousParamChanges := min(len(paramChangePool), 1000) @@ -27,7 +27,7 @@ func SimulateParamChangeProposalContent(paramChangePool []simulation.LegacyParam panic("param changes array is empty") } - return func(r *rand.Rand, _ sdk.Context, _ []simulation.Account) simulation.Content { //nolint:staticcheck + return func(r *rand.Rand, _ sdk.Context, _ []simulation.Account) simulation.Content { //nolint:staticcheck // used for legacy testing numChanges := simulation.RandIntBetween(r, 1, maxSimultaneousParamChanges) paramChanges := make([]proposal.ParamChange, numChanges) diff --git a/x/params/simulation/proposals.go b/x/params/simulation/proposals.go index 30b8f84347..8dc636fa05 100644 --- a/x/params/simulation/proposals.go +++ b/x/params/simulation/proposals.go @@ -13,7 +13,7 @@ const ( // ProposalContents defines the module weighted proposals' contents // -//nolint:staticcheck +//nolint:staticcheck // used for legacy testing func ProposalContents(paramChanges []simtypes.LegacyParamChange) []simtypes.WeightedProposalContent { return []simtypes.WeightedProposalContent{ simulation.NewWeightedProposalContent( diff --git a/x/params/types/subspace_test.go b/x/params/types/subspace_test.go index ac2b4951f4..bb8c84477c 100644 --- a/x/params/types/subspace_test.go +++ b/x/params/types/subspace_test.go @@ -154,7 +154,7 @@ func (suite *SubspaceTestSuite) TestModified() { func (suite *SubspaceTestSuite) TestUpdate() { suite.Require().Panics(func() { - suite.ss.Update(suite.ctx, []byte("invalid_key"), nil) //nolint:errcheck + suite.ss.Update(suite.ctx, []byte("invalid_key"), nil) }) t := time.Hour * 48 diff --git a/x/simulation/mock_cometbft.go b/x/simulation/mock_cometbft.go index 166cf40a87..7e72a1ae8d 100644 --- a/x/simulation/mock_cometbft.go +++ b/x/simulation/mock_cometbft.go @@ -69,7 +69,7 @@ func (vals mockValidators) randomProposer(r *rand.Rand) []byte { proposer := vals[key].val pk, err := cryptoenc.PubKeyFromProto(proposer.PubKey) - if err != nil { //nolint:wsl + if err != nil { panic(err) } diff --git a/x/simulation/params.go b/x/simulation/params.go index 4ac7fac950..73b520a0fd 100644 --- a/x/simulation/params.go +++ b/x/simulation/params.go @@ -150,14 +150,14 @@ func (w WeightedProposalMsg) MsgSimulatorFn() simulation.MsgSimulatorFn { // WeightedProposalContent defines a common struct for proposal content defined by external modules (i.e outside gov) // -//nolint:staticcheck +//nolint:staticcheck // used for legacy testing type WeightedProposalContent struct { appParamsKey string // key used to retrieve the value of the weight from the simulation application params defaultWeight int // default weight contentSimulatorFn simulation.ContentSimulatorFn // content simulator function } -func NewWeightedProposalContent(appParamsKey string, defaultWeight int, contentSimulatorFn simulation.ContentSimulatorFn) simulation.WeightedProposalContent { //nolint:staticcheck +func NewWeightedProposalContent(appParamsKey string, defaultWeight int, contentSimulatorFn simulation.ContentSimulatorFn) simulation.WeightedProposalContent { //nolint:staticcheck // used for legacy testing return &WeightedProposalContent{appParamsKey: appParamsKey, defaultWeight: defaultWeight, contentSimulatorFn: contentSimulatorFn} } @@ -169,7 +169,7 @@ func (w WeightedProposalContent) DefaultWeight() int { return w.defaultWeight } -func (w WeightedProposalContent) ContentSimulatorFn() simulation.ContentSimulatorFn { //nolint:staticcheck +func (w WeightedProposalContent) ContentSimulatorFn() simulation.ContentSimulatorFn { //nolint:staticcheck // used for legacy testing return w.contentSimulatorFn } diff --git a/x/simulation/params_test.go b/x/simulation/params_test.go index 496454142c..c3ea94896f 100644 --- a/x/simulation/params_test.go +++ b/x/simulation/params_test.go @@ -30,7 +30,7 @@ func TestNewWeightedProposalContent(t *testing.T) { key := "theKey" weight := 1 content := &testContent{} - f := func(r *rand.Rand, ctx sdk.Context, accs []simtypes.Account) simtypes.Content { //nolint:staticcheck + f := func(r *rand.Rand, ctx sdk.Context, accs []simtypes.Account) simtypes.Content { //nolint:staticcheck // used for legacy testing return content } diff --git a/x/slashing/module.go b/x/slashing/module.go index 7374e27ab0..b9cff5aec9 100644 --- a/x/slashing/module.go +++ b/x/slashing/module.go @@ -212,8 +212,7 @@ func init() { ) } -//nolint:revive -type SlashingInputs struct { +type ModuleInputs struct { depinject.In Config *modulev1.Module @@ -229,8 +228,7 @@ type SlashingInputs struct { LegacySubspace exported.Subspace } -//nolint:revive -type SlashingOutputs struct { +type ModuleOutputs struct { depinject.Out Keeper keeper.Keeper @@ -238,7 +236,7 @@ type SlashingOutputs struct { Hooks staking.StakingHooksWrapper } -func ProvideModule(in SlashingInputs) SlashingOutputs { +func ProvideModule(in ModuleInputs) ModuleOutputs { // default to governance authority if not provided authority := authtypes.NewModuleAddress(govtypes.ModuleName) if in.Config.Authority != "" { @@ -247,7 +245,7 @@ func ProvideModule(in SlashingInputs) SlashingOutputs { k := keeper.NewKeeper(in.Cdc, in.LegacyAmino, in.Key, in.StakingKeeper, authority.String()) m := NewAppModule(in.Cdc, k, in.AccountKeeper, in.BankKeeper, in.StakingKeeper, in.LegacySubspace) - return SlashingOutputs{ + return ModuleOutputs{ Keeper: k, Module: m, Hooks: staking.StakingHooksWrapper{StakingHooks: k.Hooks()}, diff --git a/x/slashing/simulation/operations_test.go b/x/slashing/simulation/operations_test.go index de71e3153e..50dced5068 100644 --- a/x/slashing/simulation/operations_test.go +++ b/x/slashing/simulation/operations_test.go @@ -180,7 +180,7 @@ func (suite *SimTestSuite) TestSimulateMsgUnjail() { suite.Require().NoError(err) var msg types.MsgUnjail - types.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg) + types.Amino.UnmarshalJSON(operationMsg.Msg, &msg) suite.Require().True(operationMsg.OK) suite.Require().Equal("cosmosvaloper1p8wcgrjr4pjju90xg6u9cgq55dxwq8j7epjs3u", msg.ValidatorAddr) diff --git a/x/slashing/types/codec.go b/x/slashing/types/codec.go index ce9fb7e489..7a171ac481 100644 --- a/x/slashing/types/codec.go +++ b/x/slashing/types/codec.go @@ -29,15 +29,12 @@ func RegisterInterfaces(registry types.InterfaceRegistry) { msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) } -var ( - amino = codec.NewLegacyAmino() - ModuleCdc = codec.NewAminoCodec(amino) -) +var Amino = codec.NewLegacyAmino() func init() { - RegisterLegacyAminoCodec(amino) - cryptocodec.RegisterCrypto(amino) - sdk.RegisterLegacyAminoCodec(amino) + RegisterLegacyAminoCodec(Amino) + cryptocodec.RegisterCrypto(Amino) + sdk.RegisterLegacyAminoCodec(Amino) // Register all Amino interfaces and concrete types on the authz and gov Amino codec so that this can later be // used to properly serialize MsgGrant, MsgExec and MsgSubmitProposal instances diff --git a/x/slashing/types/msg.go b/x/slashing/types/msg.go index db8dc4c489..fe58c224a6 100644 --- a/x/slashing/types/msg.go +++ b/x/slashing/types/msg.go @@ -32,7 +32,7 @@ func (msg MsgUnjail) GetSigners() []sdk.AccAddress { // GetSignBytes gets the bytes for the message signer to sign on func (msg MsgUnjail) GetSignBytes() []byte { - bz := ModuleCdc.MustMarshalJSON(&msg) + bz := Amino.MustMarshalJSON(&msg) return sdk.MustSortJSON(bz) } @@ -46,7 +46,7 @@ func (msg MsgUnjail) ValidateBasic() error { // GetSignBytes implements the LegacyMsg interface. func (msg MsgUpdateParams) GetSignBytes() []byte { - return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg)) + return sdk.MustSortJSON(Amino.MustMarshalJSON(&msg)) } // GetSigners returns the expected signers for a MsgUpdateParams message. diff --git a/x/staking/module.go b/x/staking/module.go index 533f690956..e58654f0df 100644 --- a/x/staking/module.go +++ b/x/staking/module.go @@ -206,8 +206,7 @@ func init() { ) } -//nolint:revive -type StakingInputs struct { +type ModuleInputs struct { depinject.In Config *modulev1.Module @@ -221,16 +220,14 @@ type StakingInputs struct { } // Dependency Injection Outputs -// -//nolint:revive -type StakingOutputs struct { +type ModuleOutputs struct { depinject.Out StakingKeeper *keeper.Keeper Module appmodule.AppModule } -func ProvideModule(in StakingInputs) StakingOutputs { +func ProvideModule(in ModuleInputs) ModuleOutputs { // default to governance authority if not provided authority := authtypes.NewModuleAddress(govtypes.ModuleName) if in.Config.Authority != "" { @@ -245,7 +242,7 @@ func ProvideModule(in StakingInputs) StakingOutputs { authority.String(), ) m := NewAppModule(in.Cdc, k, in.AccountKeeper, in.BankKeeper, in.LegacySubspace) - return StakingOutputs{StakingKeeper: k, Module: m} + return ModuleOutputs{StakingKeeper: k, Module: m} } func InvokeSetStakingHooks(