style: linting (#15704)
## Description closing in on completion of linting --- ### 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
f8e2c41a48
commit
90e2a2ae89
@ -45,6 +45,9 @@ issues:
|
||||
text: "SA1019:"
|
||||
linters:
|
||||
- staticcheck
|
||||
- text: "SA1019: codec.NewAminoCodec is deprecated" # TODO remove once migration path is set out
|
||||
linters:
|
||||
- staticcheck
|
||||
- text: "leading space"
|
||||
linters:
|
||||
- nolintlint
|
||||
|
||||
@ -801,7 +801,6 @@ 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
|
||||
|
||||
|
||||
@ -48,7 +48,7 @@ const (
|
||||
var _ abci.Application = (*BaseApp)(nil)
|
||||
|
||||
// BaseApp reflects the ABCI application implementation.
|
||||
type BaseApp struct { //nolint: maligned
|
||||
type BaseApp struct {
|
||||
// initialized on creation
|
||||
logger log.Logger
|
||||
name string // application name from abci.Info
|
||||
|
||||
@ -2,7 +2,6 @@ package client
|
||||
|
||||
import (
|
||||
gocontext "context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"reflect"
|
||||
"strconv"
|
||||
@ -142,7 +141,3 @@ func (ctx Context) gRPCCodec() encoding.Codec {
|
||||
|
||||
return pc.GRPCCodec()
|
||||
}
|
||||
|
||||
// errCodecNotSet is return by failingInterfaceRegistry in case there are attempt to decode
|
||||
// or encode a type which contains an interface field.
|
||||
var errCodecNotSet = errors.New("client: cannot encode or decode type which requires the application specific codec")
|
||||
|
||||
@ -151,9 +151,7 @@ func (pc *ProtoCodec) MustUnmarshalLengthPrefixed(bz []byte, ptr gogoproto.Messa
|
||||
// it marshals to JSON using proto codec.
|
||||
// NOTE: this function must be used with a concrete type which
|
||||
// implements proto.Message. For interface please use the codec.MarshalInterfaceJSON
|
||||
//
|
||||
//nolint:stdmethods
|
||||
func (pc *ProtoCodec) MarshalJSON(o gogoproto.Message) ([]byte, error) {
|
||||
func (pc *ProtoCodec) MarshalJSON(o gogoproto.Message) ([]byte, error) { //nolint:stdmethods // we don't want to implement Marshaler interface
|
||||
if o == nil {
|
||||
return nil, fmt.Errorf("cannot protobuf JSON encode nil")
|
||||
}
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
// nolint
|
||||
package types
|
||||
|
||||
import (
|
||||
@ -11,6 +10,7 @@ import (
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
)
|
||||
|
||||
// nolint:revive // XXX is reqired for proto compatibility
|
||||
type Any struct {
|
||||
// A URL/resource name that uniquely identifies the type of the serialized
|
||||
// protocol buffer message. This string must contain at least
|
||||
|
||||
@ -17,7 +17,7 @@ func (d Dog) Greet() string { return d.Name }
|
||||
func (d *Dog) Reset() { d.Name = "" }
|
||||
func (d *Dog) String() string { return d.Name }
|
||||
func (d *Dog) ProtoMessage() {}
|
||||
func (d *Dog) XXX_MessageName() string { return "tests/dog" } //nolint:revive
|
||||
func (d *Dog) XXX_MessageName() string { return "tests/dog" } //nolint:revive // XXX_ prefix is required
|
||||
|
||||
type Animal interface {
|
||||
Greet() string
|
||||
|
||||
@ -19,7 +19,7 @@ var _ proto.Message = (*errOnMarshal)(nil)
|
||||
|
||||
var errAlways = fmt.Errorf("always erroring")
|
||||
|
||||
func (eom *errOnMarshal) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { //nolint:revive
|
||||
func (eom *errOnMarshal) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { //nolint:revive // XXX_ prefix is intentional
|
||||
return nil, errAlways
|
||||
}
|
||||
|
||||
|
||||
@ -44,7 +44,7 @@ var (
|
||||
func (dog FakeDog) Reset() {}
|
||||
func (dog FakeDog) String() string { return "fakedog" }
|
||||
func (dog FakeDog) ProtoMessage() {}
|
||||
func (dog FakeDog) XXX_MessageName() string { return proto.MessageName(&testdata.Dog{}) } //nolint:revive
|
||||
func (dog FakeDog) XXX_MessageName() string { return proto.MessageName(&testdata.Dog{}) } //nolint:revive // XXX_ prefix is intentional
|
||||
func (dog FakeDog) Greet() string { return "fakedog" }
|
||||
|
||||
func TestRegister(t *testing.T) {
|
||||
|
||||
@ -185,7 +185,7 @@ func TestDeriveHDPathRange(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func ExampleStringifyPathParams() { //nolint:govet
|
||||
func ExampleStringifyPathParams() { //nolint:govet // ignore naming convention
|
||||
path := hd.NewParams(44, 0, 0, false, 0)
|
||||
fmt.Println(path.String())
|
||||
path = hd.NewParams(44, 33, 7, true, 9)
|
||||
@ -195,7 +195,7 @@ func ExampleStringifyPathParams() { //nolint:govet
|
||||
// m/44'/33'/7'/1/9
|
||||
}
|
||||
|
||||
func ExampleSomeBIP32TestVecs() { //nolint:govet
|
||||
func ExampleSomeBIP32TestVecs() { //nolint:govet // ignore naming convention
|
||||
seed := mnemonicToSeed("barrel original fuel morning among eternal " +
|
||||
"filter ball stove pluck matrix mechanic")
|
||||
master, ch := hd.ComputeMastersFromSeed(seed)
|
||||
|
||||
@ -66,7 +66,7 @@ func tmToProto(tmPk tmMultisig) (*LegacyAminoPubKey, error) {
|
||||
}
|
||||
|
||||
// MarshalAminoJSON overrides amino JSON unmarshaling.
|
||||
func (m LegacyAminoPubKey) MarshalAminoJSON() (tmMultisig, error) { //nolint:golint,revive
|
||||
func (m LegacyAminoPubKey) MarshalAminoJSON() (tmMultisig, error) { //nolint:golint,revive // we need to override the default amino JSON marshaling
|
||||
return protoToTm(&m)
|
||||
}
|
||||
|
||||
|
||||
@ -11,7 +11,7 @@ import (
|
||||
errorsmod "cosmossdk.io/errors"
|
||||
"github.com/cometbft/cometbft/crypto"
|
||||
secp256k1 "github.com/decred/dcrd/dcrec/secp256k1/v4"
|
||||
"golang.org/x/crypto/ripemd160" //nolint: staticcheck
|
||||
"golang.org/x/crypto/ripemd160" //nolint: staticcheck // keep around for backwards compatibility
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
|
||||
|
||||
@ -24,7 +24,7 @@ func checkAminoJSON(t *testing.T, src, dst interface{}, isNil bool) {
|
||||
require.Nil(t, err, "%+v", err)
|
||||
}
|
||||
|
||||
func ExamplePrintRegisteredTypes() {
|
||||
func ExamplePrintRegisteredTypes() { //nolint:govet // ignore for examples
|
||||
_ = cdc.PrintTypes(os.Stdout)
|
||||
// | Type | Name | Prefix | Length | Notes |
|
||||
// | ---- | ---- | ------ | ----- | ------ |
|
||||
|
||||
@ -7,7 +7,7 @@ import (
|
||||
gogoproto "github.com/cosmos/gogoproto/proto"
|
||||
|
||||
_ "github.com/cosmos/cosmos-proto" // look above
|
||||
"github.com/golang/protobuf/proto" //nolint:staticcheck
|
||||
"github.com/golang/protobuf/proto" //nolint:staticcheck // migrate in a future pr
|
||||
)
|
||||
|
||||
func getFileDescriptor(filePath string) []byte {
|
||||
@ -18,7 +18,7 @@ func getFileDescriptor(filePath string) []byte {
|
||||
return fd
|
||||
}
|
||||
|
||||
return proto.FileDescriptor(filePath) //nolint:staticcheck
|
||||
return proto.FileDescriptor(filePath) //nolint:staticcheck // keep for backward compatibility
|
||||
}
|
||||
|
||||
func getMessageType(name string) reflect.Type {
|
||||
@ -27,7 +27,7 @@ func getMessageType(name string) reflect.Type {
|
||||
return typ
|
||||
}
|
||||
|
||||
return proto.MessageType(name) //nolint:staticcheck
|
||||
return proto.MessageType(name) //nolint:staticcheck // keep for backward compatibility
|
||||
}
|
||||
|
||||
func getExtension(extID int32, m proto.Message) *gogoproto.ExtensionDesc {
|
||||
@ -39,8 +39,7 @@ func getExtension(extID int32, m proto.Message) *gogoproto.ExtensionDesc {
|
||||
}
|
||||
|
||||
// check into proto registry
|
||||
//nolint:staticcheck
|
||||
for id, desc := range proto.RegisteredExtensions(m) {
|
||||
for id, desc := range proto.RegisteredExtensions(m) { //nolint:staticcheck // kept for backwards compatibility
|
||||
if id == extID {
|
||||
return &gogoproto.ExtensionDesc{
|
||||
ExtendedType: desc.ExtendedType,
|
||||
@ -67,7 +66,7 @@ func getExtensionsNumbers(m proto.Message) []int32 {
|
||||
return out
|
||||
}
|
||||
|
||||
protoExts := proto.RegisteredExtensions(m) //nolint:staticcheck
|
||||
protoExts := proto.RegisteredExtensions(m) //nolint:staticcheck // kept for backwards compatibility
|
||||
out = make([]int32, 0, len(protoExts))
|
||||
for id := range protoExts {
|
||||
out = append(out, id)
|
||||
|
||||
@ -46,7 +46,7 @@ import (
|
||||
"sort"
|
||||
"sync"
|
||||
|
||||
//nolint: staticcheck
|
||||
//nolint: staticcheck // keep this import for backward compatibility
|
||||
"github.com/golang/protobuf/proto"
|
||||
dpb "github.com/golang/protobuf/protoc-gen-go/descriptor"
|
||||
"google.golang.org/grpc"
|
||||
|
||||
@ -47,7 +47,7 @@ func NewApp(rootDir string, logger log.Logger) (abci.Application, error) {
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "Test",
|
||||
Handler: _Msg_Test_Handler,
|
||||
Handler: MsgTestHandler,
|
||||
},
|
||||
},
|
||||
}
|
||||
@ -147,7 +147,7 @@ type MsgServerImpl struct {
|
||||
capKeyMainStore *storetypes.KVStoreKey
|
||||
}
|
||||
|
||||
func _Msg_Test_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { //nolint:revive
|
||||
func MsgTestHandler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { // nolint: revive // refactor this in a followup pr
|
||||
in := new(KVStoreTx)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
|
||||
@ -121,13 +121,14 @@ func decodeTx(txBytes []byte) (sdk.Tx, error) {
|
||||
var tx sdk.Tx
|
||||
|
||||
split := bytes.Split(txBytes, []byte("="))
|
||||
if len(split) == 1 { //nolint:gocritic
|
||||
switch len(split) {
|
||||
case 1:
|
||||
k := split[0]
|
||||
tx = &KVStoreTx{k, k, txBytes, nil}
|
||||
} else if len(split) == 2 {
|
||||
case 2:
|
||||
k, v := split[0], split[1]
|
||||
tx = &KVStoreTx{k, v, txBytes, nil}
|
||||
} else {
|
||||
default:
|
||||
return nil, errorsmod.Wrap(sdkerrors.ErrTxDecode, "too many '='")
|
||||
}
|
||||
|
||||
|
||||
@ -783,8 +783,8 @@ func TestDecimalMutation(t *testing.T) {
|
||||
|
||||
// prior to the merge of https://github.com/cosmos/cosmos-sdk/pull/15506
|
||||
// gogoproto.Marshal would mutate Decimal fields changing JSON output as shown in the assertions below
|
||||
//require.NotEqual(t, `{"rate":"0","max_rate":"0","max_change_rate":"0"}`, string(rateBz))
|
||||
//require.Equal(t,
|
||||
// require.NotEqual(t, `{"rate":"0","max_rate":"0","max_change_rate":"0"}`, string(rateBz))
|
||||
// require.Equal(t,
|
||||
// `{"rate":"0.000000000000000000","max_rate":"0.000000000000000000","max_change_rate":"0.000000000000000000"}`,
|
||||
// string(rateBz))
|
||||
|
||||
|
||||
@ -1293,21 +1293,19 @@ func (s *coinTestSuite) TestCoinValidate() {
|
||||
t := s.T()
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
err := tc.coin.Validate()
|
||||
if tc.wantErr == "" {
|
||||
switch {
|
||||
case tc.wantErr == "":
|
||||
if err != nil {
|
||||
t.Errorf("Unexpected error: %v", err)
|
||||
}
|
||||
return
|
||||
} else {
|
||||
if err == nil {
|
||||
t.Error("Expected an error")
|
||||
} else if !strings.Contains(err.Error(), tc.wantErr) {
|
||||
t.Errorf("Error mismatch\n\tGot: %q\nWant: %q", err, tc.wantErr)
|
||||
}
|
||||
case err == nil:
|
||||
t.Error("Expected an error")
|
||||
case !strings.Contains(err.Error(), tc.wantErr):
|
||||
t.Errorf("Error mismatch\n\tGot: %q\nWant: %q", err, tc.wantErr)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (s *coinTestSuite) TestCoinAminoEncoding() {
|
||||
|
||||
@ -139,7 +139,7 @@ func (s *contextTestSuite) TestContextWithCustom() {
|
||||
s.Require().Equal(cp, ctx.WithConsensusParams(cp).ConsensusParams())
|
||||
|
||||
// test inner context
|
||||
newContext := context.WithValue(ctx.Context(), "key", "value") //nolint:golint,staticcheck,revive
|
||||
newContext := context.WithValue(ctx.Context(), struct{}{}, "value")
|
||||
s.Require().NotEqual(ctx.Context(), ctx.WithContext(newContext).Context())
|
||||
}
|
||||
|
||||
|
||||
@ -33,7 +33,7 @@ type HasProposalMsgs interface {
|
||||
// HasProposalContents defines the contents that can be used to simulate legacy governance (v1beta1) proposals
|
||||
type HasProposalContents interface {
|
||||
// content functions used to simulate governance proposals
|
||||
ProposalContents(simState SimulationState) []simulation.WeightedProposalContent //nolint:staticcheck
|
||||
ProposalContents(simState SimulationState) []simulation.WeightedProposalContent //nolint:staticcheck // legacy v1beta1 governance
|
||||
}
|
||||
|
||||
// SimulationManager defines a simulation manager that provides the high level utility
|
||||
@ -151,7 +151,7 @@ type SimulationState struct {
|
||||
GenTimestamp time.Time // genesis timestamp
|
||||
UnbondTime time.Duration // staking unbond time stored to use it as the slashing maximum evidence duration
|
||||
LegacyParamChange []simulation.LegacyParamChange // simulated parameter changes from modules
|
||||
//nolint:staticcheck
|
||||
//nolint:staticcheck // legacy used for testing
|
||||
LegacyProposalContents []simulation.WeightedProposalContent // proposal content generator functions with their default weight and app sim key
|
||||
ProposalMsgs []simulation.WeightedProposalMsg // proposal msg generator functions with their default weight and app sim key
|
||||
}
|
||||
|
||||
@ -75,13 +75,13 @@ func ParseTimeBytes(bz []byte) (time.Time, error) {
|
||||
}
|
||||
|
||||
// Parses an encoded type using FormatTimeKey back into a time.Time
|
||||
func ParseTime(T any) (time.Time, error) { //nolint:gocritic
|
||||
func ParseTime(t any) (time.Time, error) {
|
||||
var (
|
||||
result time.Time
|
||||
err error
|
||||
)
|
||||
|
||||
switch t := T.(type) {
|
||||
switch t := t.(type) {
|
||||
case time.Time:
|
||||
result, err = t, nil
|
||||
case []byte:
|
||||
|
||||
@ -63,7 +63,7 @@ func (m Migrator) Migrate3to4(ctx sdk.Context) error {
|
||||
// set the account without map to accAddr to accNumber.
|
||||
//
|
||||
// NOTE: This is used for testing purposes only.
|
||||
func (m Migrator) V45_SetAccount(ctx sdk.Context, acc sdk.AccountI) error { //nolint:revive
|
||||
func (m Migrator) V45SetAccount(ctx sdk.Context, acc sdk.AccountI) error {
|
||||
addr := acc.GetAddress()
|
||||
store := m.keeper.storeService.OpenKVStore(ctx)
|
||||
|
||||
|
||||
@ -68,7 +68,7 @@ func TestMigrateMapAccAddressToAccNumberKey(t *testing.T) {
|
||||
// migrator
|
||||
m := keeper.NewMigrator(accountKeeper, app.GRPCQueryRouter(), legacySubspace)
|
||||
// set the account to store with map acc addr to acc number
|
||||
require.NoError(t, m.V45_SetAccount(ctx, acc))
|
||||
require.NoError(t, m.V45SetAccount(ctx, acc))
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
|
||||
@ -49,7 +49,7 @@ func VerifySignature(ctx context.Context, pubKey cryptotypes.PubKey, signerData
|
||||
// checks if the sign mode handler supports SignModeHandlerWithContext, in
|
||||
// which case it passes the context.Context argument. Otherwise, it fallbacks
|
||||
// to GetSignBytes.
|
||||
func GetSignBytesWithContext(h SignModeHandler, ctx context.Context, mode signing.SignMode, data SignerData, tx sdk.Tx) ([]byte, error) { //nolint:revive
|
||||
func GetSignBytesWithContext(h SignModeHandler, ctx context.Context, mode signing.SignMode, data SignerData, tx sdk.Tx) ([]byte, error) { //nolint:revive // refactor this in a future pr
|
||||
hWithCtx, ok := h.(SignModeHandlerWithContext)
|
||||
if ok {
|
||||
return hWithCtx.GetSignBytesWithContext(ctx, mode, data, tx)
|
||||
|
||||
@ -24,7 +24,7 @@ func TestTxBuilder(t *testing.T) {
|
||||
marshaler := codec.NewProtoCodec(codectypes.NewInterfaceRegistry())
|
||||
txBuilder := newBuilder(nil)
|
||||
|
||||
memo := "sometestmemo" //nolint:goconst
|
||||
memo := "testmemo"
|
||||
msgs := []sdk.Msg{testdata.NewTestMsg(addr)}
|
||||
accSeq := uint64(2) // Arbitrary account sequence
|
||||
any, err := codectypes.NewAnyWithValue(pubkey)
|
||||
|
||||
@ -6,7 +6,7 @@ import (
|
||||
"strings"
|
||||
|
||||
gogogrpc "github.com/cosmos/gogoproto/grpc"
|
||||
"github.com/golang/protobuf/proto" //nolint:staticcheck
|
||||
"github.com/golang/protobuf/proto" //nolint:staticcheck // keep legacy for now
|
||||
"github.com/grpc-ecosystem/grpc-gateway/runtime"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/status"
|
||||
|
||||
@ -6,7 +6,10 @@ import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
||||
var Amino = codec.NewLegacyAmino()
|
||||
var (
|
||||
Amino = codec.NewLegacyAmino()
|
||||
ModuleCdc = codec.NewAminoCodec(Amino)
|
||||
)
|
||||
|
||||
func init() {
|
||||
cryptocodec.RegisterCrypto(Amino)
|
||||
|
||||
@ -41,7 +41,7 @@ func RegisterInterfaces(registry types.InterfaceRegistry) {
|
||||
|
||||
var (
|
||||
amino = codec.NewLegacyAmino()
|
||||
ModuleCdc = codec.NewAminoCodec(amino) //nolint:staticcheck // TODO: remove once amino is removed
|
||||
ModuleCdc = codec.NewAminoCodec(amino)
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
||||
@ -27,7 +27,10 @@ func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
|
||||
legacy.RegisterAminoMsg(cdc, &MsgUpdateParams{}, "cosmos-sdk/x/consensus/MsgUpdateParams")
|
||||
}
|
||||
|
||||
var amino = codec.NewLegacyAmino()
|
||||
var (
|
||||
amino = codec.NewLegacyAmino()
|
||||
ModuleCdc = codec.NewAminoCodec(amino)
|
||||
)
|
||||
|
||||
func init() {
|
||||
RegisterLegacyAminoCodec(amino)
|
||||
|
||||
@ -29,7 +29,10 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) {
|
||||
msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc)
|
||||
}
|
||||
|
||||
var aminoCdc = codec.NewLegacyAmino()
|
||||
var (
|
||||
aminoCdc = codec.NewLegacyAmino()
|
||||
ModuleCdc = codec.NewAminoCodec(aminoCdc)
|
||||
)
|
||||
|
||||
func init() {
|
||||
RegisterLegacyAminoCodec(aminoCdc)
|
||||
|
||||
@ -122,8 +122,8 @@ func (k msgServer) UpdateParams(goCtx context.Context, req *types.MsgUpdateParam
|
||||
return nil, errorsmod.Wrapf(govtypes.ErrInvalidSigner, "invalid authority; expected %s, got %s", k.authority, req.Authority)
|
||||
}
|
||||
|
||||
if (!req.Params.BaseProposerReward.IsNil() && !req.Params.BaseProposerReward.IsZero()) || //nolint:staticcheck
|
||||
(!req.Params.BonusProposerReward.IsNil() && !req.Params.BonusProposerReward.IsZero()) { //nolint:staticcheck
|
||||
if (!req.Params.BaseProposerReward.IsNil() && !req.Params.BaseProposerReward.IsZero()) || //nolint:staticcheck // deprecated but kept for backwards compatibility
|
||||
(!req.Params.BonusProposerReward.IsNil() && !req.Params.BonusProposerReward.IsZero()) { //nolint:staticcheck // deprecated but kept for backwards compatibility
|
||||
return nil, errorsmod.Wrapf(errors.ErrInvalidRequest, "cannot update base or bonus proposer reward because these are deprecated fields")
|
||||
}
|
||||
|
||||
|
||||
@ -132,10 +132,8 @@ func init() {
|
||||
)
|
||||
}
|
||||
|
||||
// GenutilInputs defines the inputs needed for the genutil module.
|
||||
//
|
||||
//nolint:revive
|
||||
type GenutilInputs struct {
|
||||
// ModuleInputs defines the inputs needed for the genutil module.
|
||||
type ModuleInputs struct {
|
||||
depinject.In
|
||||
|
||||
AccountKeeper types.AccountKeeper
|
||||
@ -144,7 +142,7 @@ type GenutilInputs struct {
|
||||
Config client.TxConfig
|
||||
}
|
||||
|
||||
func ProvideModule(in GenutilInputs) appmodule.AppModule {
|
||||
func ProvideModule(in ModuleInputs) appmodule.AppModule {
|
||||
m := NewAppModule(in.AccountKeeper, in.StakingKeeper, in.DeliverTx, in.Config)
|
||||
return m
|
||||
}
|
||||
|
||||
@ -14,6 +14,11 @@ import (
|
||||
"github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
|
||||
)
|
||||
|
||||
const (
|
||||
abc = "abc"
|
||||
o1 = "-0.1"
|
||||
)
|
||||
|
||||
var (
|
||||
longAddress = "cosmos1v9skzctpv9skzctpv9skzctpv9skzctpv9skzctpv9skzctpv9skzctpv9skzctpv9skzctpv9skzctpv9skzctpv9skzctpv9skzctpv9skzctpv9skzctpv9skzctpv9skzctpv9skzctpv9skzctpv9skzctpv9skzctpv9skzctpv9skzctpv9skzctpv9skzctpv9skzctpv9skzctpv9skzctpv9skzctpv9skzctpv9skzctpv9skzctpv9skzctpv9skzctpv9skzctpv9skzctpv9skzctpv9skzctpv9skzctpv9skzctpv9skzctpv9skzctpv9skzctpv9skzctpv9skzctpv9skzctpv9skzctpv9skzctpv9skzctpv9skzctpv9skzctpv9skzctpv9skzctpv9skzctpv9skzctpv9skzctpv9skzctpv9skzctpv9skzctpv9skzctpg0s5ed"
|
||||
longAddressError = "address max length is 255"
|
||||
@ -977,7 +982,7 @@ func (suite *KeeperTestSuite) TestMsgUpdateParams() {
|
||||
name: "invalid quorum",
|
||||
input: func() *v1.MsgUpdateParams {
|
||||
params1 := params
|
||||
params1.Quorum = "abc" //nolint:goconst
|
||||
params1.Quorum = abc
|
||||
|
||||
return &v1.MsgUpdateParams{
|
||||
Authority: authority,
|
||||
@ -991,7 +996,7 @@ func (suite *KeeperTestSuite) TestMsgUpdateParams() {
|
||||
name: "negative quorum",
|
||||
input: func() *v1.MsgUpdateParams {
|
||||
params1 := params
|
||||
params1.Quorum = "-0.1"
|
||||
params1.Quorum = o1
|
||||
|
||||
return &v1.MsgUpdateParams{
|
||||
Authority: authority,
|
||||
@ -1019,7 +1024,7 @@ func (suite *KeeperTestSuite) TestMsgUpdateParams() {
|
||||
name: "invalid threshold",
|
||||
input: func() *v1.MsgUpdateParams {
|
||||
params1 := params
|
||||
params1.Threshold = "abc"
|
||||
params1.Threshold = abc
|
||||
|
||||
return &v1.MsgUpdateParams{
|
||||
Authority: authority,
|
||||
@ -1033,7 +1038,7 @@ func (suite *KeeperTestSuite) TestMsgUpdateParams() {
|
||||
name: "negative threshold",
|
||||
input: func() *v1.MsgUpdateParams {
|
||||
params1 := params
|
||||
params1.Threshold = "-0.1"
|
||||
params1.Threshold = o1
|
||||
|
||||
return &v1.MsgUpdateParams{
|
||||
Authority: authority,
|
||||
@ -1061,7 +1066,7 @@ func (suite *KeeperTestSuite) TestMsgUpdateParams() {
|
||||
name: "invalid veto threshold",
|
||||
input: func() *v1.MsgUpdateParams {
|
||||
params1 := params
|
||||
params1.VetoThreshold = "abc"
|
||||
params1.VetoThreshold = abc
|
||||
|
||||
return &v1.MsgUpdateParams{
|
||||
Authority: authority,
|
||||
@ -1075,7 +1080,7 @@ func (suite *KeeperTestSuite) TestMsgUpdateParams() {
|
||||
name: "negative veto threshold",
|
||||
input: func() *v1.MsgUpdateParams {
|
||||
params1 := params
|
||||
params1.VetoThreshold = "-0.1"
|
||||
params1.VetoThreshold = o1
|
||||
|
||||
return &v1.MsgUpdateParams{
|
||||
Authority: authority,
|
||||
|
||||
@ -21,6 +21,8 @@ var (
|
||||
sdk.AccAddress("test1"),
|
||||
sdk.AccAddress("test2"),
|
||||
}
|
||||
|
||||
metadata = "metadata"
|
||||
)
|
||||
|
||||
func init() {
|
||||
@ -62,7 +64,6 @@ func TestMsgDeposit(t *testing.T) {
|
||||
|
||||
// test ValidateBasic for MsgVote
|
||||
func TestMsgVote(t *testing.T) {
|
||||
metadata := "metadata" //nolint:goconst
|
||||
tests := []struct {
|
||||
proposalID uint64
|
||||
voterAddr sdk.AccAddress
|
||||
@ -90,7 +91,6 @@ func TestMsgVote(t *testing.T) {
|
||||
|
||||
// test ValidateBasic for MsgVoteWeighted
|
||||
func TestMsgVoteWeighted(t *testing.T) {
|
||||
metadata := "metadata"
|
||||
tests := []struct {
|
||||
proposalID uint64
|
||||
voterAddr sdk.AccAddress
|
||||
@ -135,7 +135,6 @@ func TestMsgVoteWeighted(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestMsgSubmitProposal_ValidateBasic(t *testing.T) {
|
||||
metadata := "metadata"
|
||||
// Valid msg
|
||||
msg1, err := v1.NewLegacyContent(v1beta1.NewTextProposal("Title", "description"), addrs[0].String())
|
||||
require.NoError(t, err)
|
||||
|
||||
@ -2,8 +2,6 @@ package math
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
@ -257,41 +255,3 @@ func testIsNegative(t *rapid.T) {
|
||||
|
||||
require.Equal(t, f < 0, dec.IsNegative())
|
||||
}
|
||||
|
||||
func floatDecimalPlaces(t *rapid.T, f float64) uint32 { //nolint:unused
|
||||
reScientific := regexp.MustCompile(`^\-?(?:[[:digit:]]+(?:\.([[:digit:]]+))?|\.([[:digit:]]+))(?:e?(?:\+?([[:digit:]]+)|(-[[:digit:]]+)))?$`)
|
||||
fStr := fmt.Sprintf("%g", f)
|
||||
matches := reScientific.FindAllStringSubmatch(fStr, 1)
|
||||
if len(matches) != 1 {
|
||||
t.Fatalf("Didn't match float: %g", f)
|
||||
}
|
||||
|
||||
// basePlaces is the number of decimal places in the decimal part of the
|
||||
// string
|
||||
basePlaces := 0
|
||||
if matches[0][1] != "" {
|
||||
basePlaces = len(matches[0][1])
|
||||
} else if matches[0][2] != "" {
|
||||
basePlaces = len(matches[0][2])
|
||||
}
|
||||
t.Logf("Base places: %d", basePlaces)
|
||||
|
||||
// exp is the exponent
|
||||
exp := 0
|
||||
if matches[0][3] != "" {
|
||||
var err error
|
||||
exp, err = strconv.Atoi(matches[0][3])
|
||||
require.NoError(t, err)
|
||||
} else if matches[0][4] != "" {
|
||||
var err error
|
||||
exp, err = strconv.Atoi(matches[0][4])
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
// Subtract exponent from base and check if negative
|
||||
if res := basePlaces - exp; res <= 0 {
|
||||
return 0
|
||||
} else { //nolint:revive
|
||||
return uint32(res)
|
||||
}
|
||||
}
|
||||
|
||||
@ -180,7 +180,7 @@ func (suite *SimTestSuite) TestSimulateMsgUnjail() {
|
||||
suite.Require().NoError(err)
|
||||
|
||||
var msg types.MsgUnjail
|
||||
types.Amino.UnmarshalJSON(operationMsg.Msg, &msg)
|
||||
types.ModuleCdc.UnmarshalJSON(operationMsg.Msg, &msg)
|
||||
|
||||
suite.Require().True(operationMsg.OK)
|
||||
suite.Require().Equal("cosmosvaloper1p8wcgrjr4pjju90xg6u9cgq55dxwq8j7epjs3u", msg.ValidatorAddr)
|
||||
|
||||
@ -29,12 +29,15 @@ func RegisterInterfaces(registry types.InterfaceRegistry) {
|
||||
msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc)
|
||||
}
|
||||
|
||||
var Amino = codec.NewLegacyAmino()
|
||||
var (
|
||||
amino = codec.NewLegacyAmino()
|
||||
ModuleCdc = codec.NewAminoCodec(amino)
|
||||
)
|
||||
|
||||
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 := Amino.MustMarshalJSON(&msg)
|
||||
bz := ModuleCdc.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(Amino.MustMarshalJSON(&msg))
|
||||
return sdk.MustSortJSON(ModuleCdc.MustMarshalJSON(&msg))
|
||||
}
|
||||
|
||||
// GetSigners returns the expected signers for a MsgUpdateParams message.
|
||||
|
||||
@ -62,7 +62,7 @@ func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
|
||||
}
|
||||
|
||||
// RegisterInterfaces registers the module's interface types
|
||||
func (b AppModuleBasic) RegisterInterfaces(registry cdctypes.InterfaceRegistry) {
|
||||
func (AppModuleBasic) RegisterInterfaces(registry cdctypes.InterfaceRegistry) {
|
||||
types.RegisterInterfaces(registry)
|
||||
}
|
||||
|
||||
|
||||
@ -101,7 +101,6 @@ func TestAminoJsonSignMode(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestNewSignModeHandler(t *testing.T) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user