style: various linting fixes (#15675)
## Description fix various linting issues --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... * [ ] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title * [ ] added `!` to the type prefix if API or client breaking change * [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#pr-targeting)) * [ ] provided a link to the relevant issue or specification * [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/main/docs/docs/building-modules) * [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/main/CONTRIBUTING.md#testing) * [ ] added a changelog entry to `CHANGELOG.md` * [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) * [ ] updated the relevant documentation or specification * [ ] reviewed "Files changed" and left comments if necessary * [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... * [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title * [ ] confirmed `!` in the type prefix if API or client breaking change * [ ] confirmed all author checklist items have been addressed * [ ] reviewed state machine logic * [ ] reviewed API design and naming * [ ] reviewed documentation is accurate * [ ] reviewed tests and test coverage * [ ] manually tested (if applicable)
This commit is contained in:
parent
448ffbc722
commit
38c7c948f5
@ -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
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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"
|
||||
|
||||
|
||||
@ -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 |
|
||||
// | ---- | ---- | ------ | ----- | ------ |
|
||||
|
||||
@ -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)
|
||||
}
|
||||
|
||||
@ -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)
|
||||
}
|
||||
|
||||
@ -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)
|
||||
}
|
||||
|
||||
@ -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}
|
||||
}
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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}
|
||||
}
|
||||
|
||||
// ____________________________________________________________________________
|
||||
|
||||
@ -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))
|
||||
}
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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.
|
||||
|
||||
@ -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}
|
||||
}
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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)
|
||||
}
|
||||
|
||||
|
||||
@ -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()
|
||||
}
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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),
|
||||
|
||||
@ -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)
|
||||
}
|
||||
|
||||
|
||||
@ -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)
|
||||
}
|
||||
|
||||
|
||||
@ -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}
|
||||
}
|
||||
|
||||
@ -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)
|
||||
|
||||
|
||||
@ -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(
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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)
|
||||
}
|
||||
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
|
||||
@ -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
|
||||
}
|
||||
|
||||
|
||||
@ -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()},
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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.
|
||||
|
||||
@ -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(
|
||||
|
||||
Loading…
Reference in New Issue
Block a user