chore: fix linting issues exposed by fixing golangci-lint (#12895)

Co-authored-by: Marko <marbar3778@yahoo.com>
Co-authored-by: Julien Robert <julien@rbrt.fr>
This commit is contained in:
Jacob Gadikian 2022-08-12 03:00:24 +07:00 committed by GitHub
parent 15b04c2a87
commit 0943a70215
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
148 changed files with 570 additions and 468 deletions

View File

@ -42,7 +42,7 @@ type (
) )
// BaseApp reflects the ABCI application implementation. // BaseApp reflects the ABCI application implementation.
type BaseApp struct { // nolint: maligned type BaseApp struct { //nolint: maligned
// initialized on creation // initialized on creation
logger log.Logger logger log.Logger
name string // application name from abci.Info name string // application name from abci.Info

View File

@ -97,6 +97,7 @@ input
- bip39 passphrase - bip39 passphrase
- bip44 path - bip44 path
- local encryption password - local encryption password
output output
- armor encrypted private key (saved to file) - armor encrypted private key (saved to file)
*/ */

View File

@ -96,6 +96,7 @@ func (ac *AminoCodec) MarshalInterface(i proto.Message) ([]byte, error) {
// NOTE: to unmarshal a concrete type, you should use Unmarshal instead // NOTE: to unmarshal a concrete type, you should use Unmarshal instead
// //
// Example: // Example:
//
// var x MyInterface // var x MyInterface
// err := cdc.UnmarshalInterface(bz, &x) // err := cdc.UnmarshalInterface(bz, &x)
func (ac *AminoCodec) UnmarshalInterface(bz []byte, ptr interface{}) error { func (ac *AminoCodec) UnmarshalInterface(bz []byte, ptr interface{}) error {
@ -117,6 +118,7 @@ func (ac *AminoCodec) MarshalInterfaceJSON(i proto.Message) ([]byte, error) {
// NOTE: to unmarshal a concrete type, you should use UnmarshalJSON instead // NOTE: to unmarshal a concrete type, you should use UnmarshalJSON instead
// //
// Example: // Example:
//
// var x MyInterface // var x MyInterface
// err := cdc.UnmarshalInterfaceJSON(bz, &x) // err := cdc.UnmarshalInterfaceJSON(bz, &x)
func (ac *AminoCodec) UnmarshalInterfaceJSON(bz []byte, ptr interface{}) error { func (ac *AminoCodec) UnmarshalInterfaceJSON(bz []byte, ptr interface{}) error {

View File

@ -204,6 +204,7 @@ func (pc *ProtoCodec) MarshalInterface(i gogoproto.Message) ([]byte, error) {
// NOTE: to unmarshal a concrete type, you should use Unmarshal instead // NOTE: to unmarshal a concrete type, you should use Unmarshal instead
// //
// Example: // Example:
//
// var x MyInterface // var x MyInterface
// err := cdc.UnmarshalInterface(bz, &x) // err := cdc.UnmarshalInterface(bz, &x)
func (pc *ProtoCodec) UnmarshalInterface(bz []byte, ptr interface{}) error { func (pc *ProtoCodec) UnmarshalInterface(bz []byte, ptr interface{}) error {
@ -233,6 +234,7 @@ func (pc *ProtoCodec) MarshalInterfaceJSON(x gogoproto.Message) ([]byte, error)
// NOTE: to unmarshal a concrete type, you should use UnmarshalJSON instead // NOTE: to unmarshal a concrete type, you should use UnmarshalJSON instead
// //
// Example: // Example:
//
// var x MyInterface // must implement proto.Message // var x MyInterface // must implement proto.Message
// err := cdc.UnmarshalInterfaceJSON(&x, bz) // err := cdc.UnmarshalInterfaceJSON(&x, bz)
func (pc *ProtoCodec) UnmarshalInterfaceJSON(bz []byte, iface interface{}) error { func (pc *ProtoCodec) UnmarshalInterfaceJSON(bz []byte, iface interface{}) error {

View File

@ -81,6 +81,7 @@ func (c *cosmovisorEnv) Set(envVar, envVal string) {
// clearEnv clears environment variables and what they were. // clearEnv clears environment variables and what they were.
// Designed to be used like this: // Designed to be used like this:
//
// initialEnv := clearEnv() // initialEnv := clearEnv()
// defer setEnv(nil, initialEnv) // defer setEnv(nil, initialEnv)
func (s *argsTestSuite) clearEnv() *cosmovisorEnv { func (s *argsTestSuite) clearEnv() *cosmovisorEnv {

View File

@ -47,6 +47,7 @@ func (c *cosmovisorHelpEnv) Set(envVar, envVal string) {
// clearEnv clears environment variables and returns what they were. // clearEnv clears environment variables and returns what they were.
// Designed to be used like this: // Designed to be used like this:
//
// initialEnv := clearEnv() // initialEnv := clearEnv()
// defer setEnv(nil, initialEnv) // defer setEnv(nil, initialEnv)
func (s *HelpTestSuite) clearEnv() *cosmovisorHelpEnv { func (s *HelpTestSuite) clearEnv() *cosmovisorHelpEnv {

View File

@ -53,6 +53,7 @@ func (c *cosmovisorInitEnv) Set(envVar, envVal string) {
// clearEnv clears environment variables and returns what they were. // clearEnv clears environment variables and returns what they were.
// Designed to be used like this: // Designed to be used like this:
//
// initialEnv := clearEnv() // initialEnv := clearEnv()
// defer setEnv(nil, initialEnv) // defer setEnv(nil, initialEnv)
func (s *InitTestSuite) clearEnv() *cosmovisorInitEnv { func (s *InitTestSuite) clearEnv() *cosmovisorInitEnv {
@ -137,6 +138,7 @@ func NewBufferedPipe(name string, replicateTo ...io.Writer) (BufferedPipe, error
// StartNewBufferedPipe creates a new BufferedPipe and starts it. // StartNewBufferedPipe creates a new BufferedPipe and starts it.
// //
// This is functionally equivalent to: // This is functionally equivalent to:
//
// p, _ := NewBufferedPipe(name, replicateTo...) // p, _ := NewBufferedPipe(name, replicateTo...)
// p.Start() // p.Start()
func StartNewBufferedPipe(name string, replicateTo ...io.Writer) (BufferedPipe, error) { func StartNewBufferedPipe(name string, replicateTo ...io.Writer) (BufferedPipe, error) {

View File

@ -4,11 +4,11 @@ import (
"bytes" "bytes"
"encoding/hex" "encoding/hex"
"fmt" "fmt"
"io/ioutil" "io"
"github.com/tendermint/crypto/bcrypt" "github.com/tendermint/crypto/bcrypt"
"github.com/tendermint/tendermint/crypto" "github.com/tendermint/tendermint/crypto"
"golang.org/x/crypto/openpgp/armor" // nolint: staticcheck "golang.org/x/crypto/openpgp/armor" //nolint: staticcheck
"github.com/cosmos/cosmos-sdk/codec/legacy" "github.com/cosmos/cosmos-sdk/codec/legacy"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
@ -235,7 +235,7 @@ func DecodeArmor(armorStr string) (blockType string, headers map[string]string,
if err != nil { if err != nil {
return "", nil, nil, err return "", nil, nil, err
} }
data, err = ioutil.ReadAll(block.Body) data, err = io.ReadAll(block.Body)
if err != nil { if err != nil {
return "", nil, nil, err return "", nil, nil, err
} }

View File

@ -1,6 +1,7 @@
// Package hd provides support for hierarchical deterministic wallets generation and derivation. // Package hd provides support for hierarchical deterministic wallets generation and derivation.
// //
// The user must understand the overall concept of the BIP 32 and the BIP 44 specs: // The user must understand the overall concept of the BIP 32 and the BIP 44 specs:
//
// https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki // https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki
// https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki // https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki
// //

View File

@ -1,19 +1,18 @@
// Package keys provides common key management API. // Package keys provides common key management API.
// //
// // # The Keyring interface
// The Keyring interface
// //
// The Keyring interface defines the methods that a type needs to implement to be used // The Keyring interface defines the methods that a type needs to implement to be used
// as key storage backend. This package provides few implementations out-of-the-box. // as key storage backend. This package provides few implementations out-of-the-box.
// //
// NewInMemory // # NewInMemory
// //
// The NewInMemory constructor returns an implementation backed by an in-memory, goroutine-safe // The NewInMemory constructor returns an implementation backed by an in-memory, goroutine-safe
// map that has historically been used for testing purposes or on-the-fly key generation as the // map that has historically been used for testing purposes or on-the-fly key generation as the
// generated keys are discarded when the process terminates or the type instance is garbage // generated keys are discarded when the process terminates or the type instance is garbage
// collected. // collected.
// //
// New // # New
// //
// The New constructor returns an implementation backed by a keyring library // The New constructor returns an implementation backed by a keyring library
// (https://github.com/99designs/keyring), whose aim is to provide a common abstraction and uniform // (https://github.com/99designs/keyring), whose aim is to provide a common abstraction and uniform
@ -21,6 +20,7 @@
// as well as operating system-agnostic encrypted file-based backends. // as well as operating system-agnostic encrypted file-based backends.
// //
// The backends: // The backends:
//
// os The instance returned by this constructor uses the operating system's default // os The instance returned by this constructor uses the operating system's default
// credentials store to handle keys storage operations securely. It should be noted // credentials store to handle keys storage operations securely. It should be noted
// that the keyring keyring may be kept unlocked for the whole duration of the user // that the keyring keyring may be kept unlocked for the whole duration of the user

View File

@ -21,7 +21,7 @@ type KeyOutput struct {
} }
// NewKeyOutput creates a default KeyOutput instance without Mnemonic, Threshold and PubKeys // NewKeyOutput creates a default KeyOutput instance without Mnemonic, Threshold and PubKeys
func NewKeyOutput(name string, keyType KeyType, a sdk.Address, pk cryptotypes.PubKey) (KeyOutput, error) { // nolint:interfacer func NewKeyOutput(name string, keyType KeyType, a sdk.Address, pk cryptotypes.PubKey) (KeyOutput, error) { //nolint:interfacer
apk, err := codectypes.NewAnyWithValue(pk) apk, err := codectypes.NewAnyWithValue(pk)
if err != nil { if err != nil {
return KeyOutput{}, err return KeyOutput{}, err

View File

@ -15,8 +15,7 @@ const (
PubKeyAminoRoute = "tendermint/PubKeyMultisigThreshold" PubKeyAminoRoute = "tendermint/PubKeyMultisigThreshold"
) )
//nolint // AminoCdc is being deprecated in the SDK. But even if you need to
// Deprecated: Amino is being deprecated in the SDK. But even if you need to
// use Amino for some reason, please use `codec/legacy.Cdc` instead. // use Amino for some reason, please use `codec/legacy.Cdc` instead.
var AminoCdc = codec.NewLegacyAmino() var AminoCdc = codec.NewLegacyAmino()

View File

@ -10,7 +10,7 @@ import (
secp256k1 "github.com/btcsuite/btcd/btcec" secp256k1 "github.com/btcsuite/btcd/btcec"
"github.com/tendermint/tendermint/crypto" "github.com/tendermint/tendermint/crypto"
"golang.org/x/crypto/ripemd160" // nolint: staticcheck // necessary for Bitcoin address format "golang.org/x/crypto/ripemd160" //nolint: staticcheck // necessary for Bitcoin address format
"github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/codec"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"

View File

@ -92,6 +92,7 @@ func invoke(ctr *container, key *moduleKey, invokers []interface{}) error {
// instance when an interface of type Duck is requested as an input. // instance when an interface of type Duck is requested as an input.
// //
// BindInterface( // BindInterface(
//
// "cosmossdk.io/depinject_test/depinject_test.Duck", // "cosmossdk.io/depinject_test/depinject_test.Duck",
// "cosmossdk.io/depinject_test/depinject_test.Canvasback") // "cosmossdk.io/depinject_test/depinject_test.Canvasback")
func BindInterface(inTypeName string, outTypeName string) Config { func BindInterface(inTypeName string, outTypeName string) Config {
@ -106,6 +107,7 @@ func BindInterface(inTypeName string, outTypeName string) Config {
// "moduleFoo". // "moduleFoo".
// //
// BindInterfaceInModule( // BindInterfaceInModule(
//
// "moduleFoo", // "moduleFoo",
// "cosmossdk.io/depinject_test/depinject_test.Duck", // "cosmossdk.io/depinject_test/depinject_test.Duck",
// "cosmossdk.io/depinject_test/depinject_test.Canvasback") // "cosmossdk.io/depinject_test/depinject_test.Canvasback")

View File

@ -449,7 +449,6 @@ func (c *container) build(loc Location, outputs ...interface{}) error {
if !values[i].CanInterface() { if !values[i].CanInterface() {
return []reflect.Value{}, fmt.Errorf("depinject.Out struct %s on package can't have unexported field", values[i].String()) return []reflect.Value{}, fmt.Errorf("depinject.Out struct %s on package can't have unexported field", values[i].String())
} }
val.Elem().Set(values[i]) val.Elem().Set(values[i])
} }

View File

@ -7,6 +7,7 @@ package depinject
// can be provided by the container. // can be provided by the container.
// //
// Ex: // Ex:
//
// var x int // var x int
// Inject(Provide(func() int { return 1 }), &x) // Inject(Provide(func() int { return 1 }), &x)
// //

View File

@ -9,6 +9,7 @@ import (
// ProviderDescriptor defines a special provider type that is defined by // ProviderDescriptor defines a special provider type that is defined by
// reflection. It should be passed as a value to the Provide function. // reflection. It should be passed as a value to the Provide function.
// Ex: // Ex:
//
// option.Provide(ProviderDescriptor{ ... }) // option.Provide(ProviderDescriptor{ ... })
type ProviderDescriptor struct { type ProviderDescriptor struct {
// Inputs defines the in parameter types to Fn. // Inputs defines the in parameter types to Fn.

View File

@ -13,6 +13,7 @@ import (
// positional parameters. // positional parameters.
// //
// Fields of the struct may support the following tags: // Fields of the struct may support the following tags:
//
// optional if set to true, the dependency is optional and will // optional if set to true, the dependency is optional and will
// be set to its default value if not found, rather than causing // be set to its default value if not found, rather than causing
// an error // an error
@ -176,7 +177,6 @@ func buildIn(typ reflect.Type, values []reflect.Value) (reflect.Value, int, erro
} }
if !values[j].CanInterface() { if !values[j].CanInterface() {
return reflect.Value{}, 0, fmt.Errorf("depinject.Out struct %s on package %s can't have unexported field", res.Elem().String(), f.PkgPath) return reflect.Value{}, 0, fmt.Errorf("depinject.Out struct %s on package %s can't have unexported field", res.Elem().String(), f.PkgPath)
} }
res.Elem().Field(i).Set(values[j]) res.Elem().Field(i).Set(values[j])

View File

@ -29,6 +29,5 @@ Stacktrace information can be printed using %+v and %v formats.
%s is just the error message %s is just the error message
%+v is the full stack trace %+v is the full stack trace
%v appends a compressed [filename:line] where the error was created %v appends a compressed [filename:line] where the error was created
*/ */
package errors package errors

View File

@ -80,6 +80,7 @@ func writeSimpleFrame(s io.Writer, f errors.Frame) {
// %s is just the error message // %s is just the error message
// %+v is the full stack trace // %+v is the full stack trace
// %v appends a compressed [filename:line] where the error // %v appends a compressed [filename:line] where the error
//
// was created // was created
// //
// Inspired by https://github.com/pkg/errors/blob/v0.8.1/errors.go#L162-L176 // Inspired by https://github.com/pkg/errors/blob/v0.8.1/errors.go#L162-L176

View File

@ -128,8 +128,11 @@ func LegacyNewDecFromIntWithPrec(i Int, prec int64) LegacyDec {
// create a decimal from an input decimal string. // create a decimal from an input decimal string.
// valid must come in the form: // valid must come in the form:
//
// (-) whole integers (.) decimal integers // (-) whole integers (.) decimal integers
//
// examples of acceptable input include: // examples of acceptable input include:
//
// -123.456 // -123.456
// 456.7890 // 456.7890
// 345 // 345

View File

@ -4,6 +4,7 @@ package testpb
import ( import (
context "context" context "context"
ormlist "github.com/cosmos/cosmos-sdk/orm/model/ormlist" ormlist "github.com/cosmos/cosmos-sdk/orm/model/ormlist"
ormtable "github.com/cosmos/cosmos-sdk/orm/model/ormtable" ormtable "github.com/cosmos/cosmos-sdk/orm/model/ormtable"
ormerrors "github.com/cosmos/cosmos-sdk/orm/types/ormerrors" ormerrors "github.com/cosmos/cosmos-sdk/orm/types/ormerrors"

View File

@ -4,6 +4,7 @@ package testpb
import ( import (
context "context" context "context"
ormlist "github.com/cosmos/cosmos-sdk/orm/model/ormlist" ormlist "github.com/cosmos/cosmos-sdk/orm/model/ormlist"
ormtable "github.com/cosmos/cosmos-sdk/orm/model/ormtable" ormtable "github.com/cosmos/cosmos-sdk/orm/model/ormtable"
ormerrors "github.com/cosmos/cosmos-sdk/orm/types/ormerrors" ormerrors "github.com/cosmos/cosmos-sdk/orm/types/ormerrors"

View File

@ -10,6 +10,7 @@ import (
// testing purposes independent of any storage layer. // testing purposes independent of any storage layer.
// //
// Example: // Example:
//
// backend := ormtest.NewMemoryBackend() // backend := ormtest.NewMemoryBackend()
// ctx := ormtable.WrapContextDefault() // ctx := ormtable.WrapContextDefault()
// ... // ...

View File

@ -33,7 +33,7 @@ import (
// done declaratively with an app config and the rest of it is done the old way. // done declaratively with an app config and the rest of it is done the old way.
// See simapp/app.go for an example of this setup. // See simapp/app.go for an example of this setup.
// //
// nolint:unused //nolint:unused
type App struct { type App struct {
*baseapp.BaseApp *baseapp.BaseApp

View File

@ -3,7 +3,6 @@ package config
import ( import (
"bytes" "bytes"
"fmt" "fmt"
"io/ioutil"
"os" "os"
"text/template" "text/template"
@ -280,7 +279,7 @@ func WriteConfigFile(configFilePath string, config interface{}) {
} }
func mustWriteFile(filePath string, contents []byte, mode os.FileMode) { func mustWriteFile(filePath string, contents []byte, mode os.FileMode) {
if err := ioutil.WriteFile(filePath, contents, mode); err != nil { if err := os.WriteFile(filePath, contents, mode); err != nil {
fmt.Printf(fmt.Sprintf("failed to write file: %v", err) + "\n") fmt.Printf(fmt.Sprintf("failed to write file: %v", err) + "\n")
os.Exit(1) os.Exit(1)
} }

View File

@ -9,7 +9,7 @@ import (
_ "github.com/gogo/protobuf/gogoproto" // required so it does register the gogoproto file descriptor _ "github.com/gogo/protobuf/gogoproto" // required so it does register the gogoproto file descriptor
gogoproto "github.com/gogo/protobuf/proto" gogoproto "github.com/gogo/protobuf/proto"
// nolint: staticcheck //nolint: staticcheck
"github.com/golang/protobuf/proto" "github.com/golang/protobuf/proto"
dpb "github.com/golang/protobuf/protoc-gen-go/descriptor" dpb "github.com/golang/protobuf/protoc-gen-go/descriptor"
_ "github.com/regen-network/cosmos-proto" // look above _ "github.com/regen-network/cosmos-proto" // look above
@ -60,7 +60,8 @@ func init() {
} }
// compress compresses the given file descriptor // compress compresses the given file descriptor
// nolint: interfacer //
//nolint:interfacer
func compress(fd *dpb.FileDescriptorProto) ([]byte, error) { func compress(fd *dpb.FileDescriptorProto) ([]byte, error) {
fdBytes, err := proto.Marshal(fd) fdBytes, err := proto.Marshal(fd)
if err != nil { if err != nil {
@ -86,7 +87,7 @@ func getFileDescriptor(filePath string) []byte {
if len(fd) != 0 { if len(fd) != 0 {
return fd return fd
} }
// nolint: staticcheck //nolint: staticcheck
return proto.FileDescriptor(filePath) return proto.FileDescriptor(filePath)
} }
@ -95,7 +96,7 @@ func getMessageType(name string) reflect.Type {
if typ != nil { if typ != nil {
return typ return typ
} }
// nolint: staticcheck //nolint: staticcheck
return proto.MessageType(name) return proto.MessageType(name)
} }
@ -107,7 +108,7 @@ func getExtension(extID int32, m proto.Message) *gogoproto.ExtensionDesc {
} }
} }
// check into proto registry // check into proto registry
// nolint: staticcheck //nolint: staticcheck
for id, desc := range proto.RegisteredExtensions(m) { for id, desc := range proto.RegisteredExtensions(m) {
if id == extID { if id == extID {
return &gogoproto.ExtensionDesc{ return &gogoproto.ExtensionDesc{
@ -133,7 +134,7 @@ func getExtensionsNumbers(m proto.Message) []int32 {
if len(out) != 0 { if len(out) != 0 {
return out return out
} }
// nolint: staticcheck //nolint: staticcheck
protoExts := proto.RegisteredExtensions(m) protoExts := proto.RegisteredExtensions(m)
out = make([]int32, 0, len(protoExts)) out = make([]int32, 0, len(protoExts))
for id := range protoExts { for id := range protoExts {

View File

@ -23,6 +23,7 @@ The service implemented is defined in:
https://github.com/grpc/grpc/blob/master/src/proto/grpc/reflection/v1alpha/reflection.proto. https://github.com/grpc/grpc/blob/master/src/proto/grpc/reflection/v1alpha/reflection.proto.
To register server reflection on a gRPC server: To register server reflection on a gRPC server:
import "google.golang.org/grpc/reflection" import "google.golang.org/grpc/reflection"
s := grpc.NewServer() s := grpc.NewServer()
@ -32,7 +33,6 @@ To register server reflection on a gRPC server:
reflection.Register(s) reflection.Register(s)
s.Serve(lis) s.Serve(lis)
*/ */
package gogoreflection // import "google.golang.org/grpc/reflection" package gogoreflection // import "google.golang.org/grpc/reflection"
@ -46,7 +46,7 @@ import (
"sort" "sort"
"sync" "sync"
// nolint: staticcheck //nolint: staticcheck
"github.com/golang/protobuf/proto" "github.com/golang/protobuf/proto"
dpb "github.com/golang/protobuf/protoc-gen-go/descriptor" dpb "github.com/golang/protobuf/protoc-gen-go/descriptor"
"google.golang.org/grpc" "google.golang.org/grpc"

View File

@ -2,7 +2,6 @@ package mock
import ( import (
"fmt" "fmt"
"io/ioutil"
"os" "os"
"github.com/rs/zerolog" "github.com/rs/zerolog"
@ -23,7 +22,7 @@ func SetupApp() (abci.Application, func(), error) {
} }
logger = logger.With("module", "mock") logger = logger.With("module", "mock")
rootDir, err := ioutil.TempDir("", "mock-sdk") rootDir, err := os.MkdirTemp("", "mock-sdk")
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
} }

View File

@ -1,4 +1,3 @@
//nolint
package mock package mock
import ( import (
@ -70,7 +69,7 @@ func decodeTx(txBytes []byte) (sdk.Tx, error) {
var tx sdk.Tx var tx sdk.Tx
split := bytes.Split(txBytes, []byte("=")) split := bytes.Split(txBytes, []byte("="))
if len(split) == 1 { if len(split) == 1 { //nolint:gocritic
k := split[0] k := split[0]
tx = kvstoreTx{k, k, txBytes} tx = kvstoreTx{k, k, txBytes}
} else if len(split) == 2 { } else if len(split) == 2 {

View File

@ -256,6 +256,7 @@ func (c *Client) TxOperationsAndSignersAccountIdentifiers(signed bool, txBytes [
} }
// GetTx returns a transaction given its hash. For Rosetta we make a synthetic transaction for BeginBlock // GetTx returns a transaction given its hash. For Rosetta we make a synthetic transaction for BeginBlock
//
// and EndBlock to adhere to balance tracking rules. // and EndBlock to adhere to balance tracking rules.
func (c *Client) GetTx(ctx context.Context, hash string) (*rosettatypes.Transaction, error) { func (c *Client) GetTx(ctx context.Context, hash string) (*rosettatypes.Transaction, error) {
hashBytes, err := hex.DecodeString(hash) hashBytes, err := hex.DecodeString(hash)

View File

@ -47,6 +47,7 @@ func (app *SimApp) ExportAppStateAndValidators(
// prepare for fresh start at zero height // prepare for fresh start at zero height
// NOTE zero height genesis is a temporary feature which will be deprecated // NOTE zero height genesis is a temporary feature which will be deprecated
//
// in favour of export at a block height // in favour of export at a block height
func (app *SimApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []string) { func (app *SimApp) prepForZeroHeightGenesis(ctx sdk.Context, jailAllowedAddrs []string) {
applyAllowedAddrs := false applyAllowedAddrs := false

View File

@ -6,7 +6,6 @@ import (
"bufio" "bufio"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil"
"net" "net"
"os" "os"
"path/filepath" "path/filepath"
@ -476,7 +475,7 @@ func writeFile(name string, dir string, contents []byte) error {
return err return err
} }
err = ioutil.WriteFile(file, contents, 0o644) // nolint: gosec err = os.WriteFile(file, contents, 0o644) //nolint: gosec
if err != nil { if err != nil {
return err return err
} }

View File

@ -23,11 +23,11 @@ import (
// Although the ABCI interface (and this manager) passes chunks as byte slices, the internal // Although the ABCI interface (and this manager) passes chunks as byte slices, the internal
// snapshot/restore APIs use IO streams (i.e. chan io.ReadCloser), for two reasons: // snapshot/restore APIs use IO streams (i.e. chan io.ReadCloser), for two reasons:
// //
// 1) In the future, ABCI should support streaming. Consider e.g. InitChain during chain // 1. In the future, ABCI should support streaming. Consider e.g. InitChain during chain
// upgrades, which currently passes the entire chain state as an in-memory byte slice. // upgrades, which currently passes the entire chain state as an in-memory byte slice.
// https://github.com/tendermint/tendermint/issues/5184 // https://github.com/tendermint/tendermint/issues/5184
// //
// 2) io.ReadCloser streams automatically propagate IO errors, and can pass arbitrary // 2. io.ReadCloser streams automatically propagate IO errors, and can pass arbitrary
// errors via io.Pipe.CloseWithError(). // errors via io.Pipe.CloseWithError().
type Manager struct { type Manager struct {
extensions map[string]types.ExtensionSnapshotter extensions map[string]types.ExtensionSnapshotter

View File

@ -259,7 +259,7 @@ func (s *Store) Save(
snapshotHasher := sha256.New() snapshotHasher := sha256.New()
chunkHasher := sha256.New() chunkHasher := sha256.New()
for chunkBody := range chunks { for chunkBody := range chunks {
defer chunkBody.Close() // nolint: staticcheck defer chunkBody.Close() //nolint: staticcheck
dir := s.pathSnapshot(height, format) dir := s.pathSnapshot(height, format)
err = os.MkdirAll(dir, 0o755) err = os.MkdirAll(dir, 0o755)
if err != nil { if err != nil {
@ -270,7 +270,7 @@ func (s *Store) Save(
if err != nil { if err != nil {
return nil, sdkerrors.Wrapf(err, "failed to create snapshot chunk file %q", path) return nil, sdkerrors.Wrapf(err, "failed to create snapshot chunk file %q", path)
} }
defer file.Close() // nolint: staticcheck defer file.Close() //nolint: staticcheck
chunkHasher.Reset() chunkHasher.Reset()
_, err = io.Copy(io.MultiWriter(file, chunkHasher, snapshotHasher), chunkBody) _, err = io.Copy(io.MultiWriter(file, chunkHasher, snapshotHasher), chunkBody)

View File

@ -417,6 +417,7 @@ var _ types.Iterator = (*iavlIterator)(nil)
// newIAVLIterator will create a new iavlIterator. // newIAVLIterator will create a new iavlIterator.
// CONTRACT: Caller must release the iavlIterator, as each one creates a new // CONTRACT: Caller must release the iavlIterator, as each one creates a new
// goroutine. // goroutine.
//
//nolint:deadcode,unused //nolint:deadcode,unused
func newIAVLIterator(tree *iavl.ImmutableTree, start, end []byte, ascending bool) *iavlIterator { func newIAVLIterator(tree *iavl.ImmutableTree, start, end []byte, ascending bool) *iavlIterator {
iterator, err := tree.Iterator(start, end, ascending) iterator, err := tree.Iterator(start, end, ascending)

View File

@ -28,7 +28,7 @@ func NewStore() *Store {
return NewStoreWithDB(dbm.NewMemDB()) return NewStoreWithDB(dbm.NewMemDB())
} }
func NewStoreWithDB(db *dbm.MemDB) *Store { // nolint: interfacer func NewStoreWithDB(db *dbm.MemDB) *Store { //nolint: interfacer
return &Store{Store: dbadapter.Store{DB: db}} return &Store{Store: dbadapter.Store{DB: db}}
} }

View File

@ -3,7 +3,6 @@ package file
import ( import (
"errors" "errors"
"fmt" "fmt"
"io/ioutil"
"os" "os"
"path" "path"
"path/filepath" "path/filepath"
@ -284,7 +283,7 @@ func (fss *StreamingService) Close() error {
// to dir. It returns nil if dir is writable. // to dir. It returns nil if dir is writable.
func isDirWriteable(dir string) error { func isDirWriteable(dir string) error {
f := path.Join(dir, ".touch") f := path.Join(dir, ".touch")
if err := ioutil.WriteFile(f, []byte(""), 0o600); err != nil { if err := os.WriteFile(f, []byte(""), 0o600); err != nil {
return err return err
} }
return os.Remove(f) return os.Remove(f)

View File

@ -3,7 +3,6 @@ package file
import ( import (
"encoding/binary" "encoding/binary"
"fmt" "fmt"
"io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
"sync" "sync"
@ -369,7 +368,7 @@ func testListenEndBlock(t *testing.T) {
func readInFile(name string) ([]byte, error) { func readInFile(name string) ([]byte, error) {
path := filepath.Join(testDir, name) path := filepath.Join(testDir, name)
return ioutil.ReadFile(path) return os.ReadFile(path)
} }
// segmentBytes returns all of the protobuf messages contained in the byte array as an array of byte arrays // segmentBytes returns all of the protobuf messages contained in the byte array as an array of byte arrays

View File

@ -1,4 +1,4 @@
// nolint:unused //nolint:unused
package multi package multi
import ( import (
@ -43,7 +43,7 @@ func (dbSaveVersionFails) SaveVersion(uint64) error { return errors.New("dbSaveV
func (db dbRevertFails) Revert() error { func (db dbRevertFails) Revert() error {
fail := false fail := false
if len(db.failOn) > 0 { if len(db.failOn) > 0 {
fail, db.failOn = db.failOn[0], db.failOn[1:] // nolint:staticcheck fail, db.failOn = db.failOn[0], db.failOn[1:] //nolint:staticcheck
} }
if fail { if fail {
return errors.New("dbRevertFails") return errors.New("dbRevertFails")

View File

@ -2,7 +2,7 @@ package client
import ( import (
"fmt" "fmt"
"io/ioutil" "io"
"os" "os"
"github.com/gogo/protobuf/proto" "github.com/gogo/protobuf/proto"
@ -419,7 +419,7 @@ func (s *EndToEndTestSuite) TestNewSendTxCmdDryRun() {
s.Require().NoError(err) s.Require().NoError(err)
w.Close() w.Close()
out, _ := ioutil.ReadAll(r) out, _ := io.ReadAll(r)
os.Stderr = oldSterr os.Stderr = oldSterr
s.Require().Regexp("gas estimate: [0-9]+", string(out)) s.Require().Regexp("gas estimate: [0-9]+", string(out))

View File

@ -31,7 +31,6 @@ type IntegrationTestSuite struct {
} }
func TestIntegrationTestSuite(t *testing.T) { func TestIntegrationTestSuite(t *testing.T) {
suite.Run(t, new(IntegrationTestSuite)) suite.Run(t, new(IntegrationTestSuite))
} }

View File

@ -122,7 +122,6 @@ func (suite *IntegrationTestSuite) initKeepersWithmAccPerms(blockedAddrs map[str
} }
func (suite *IntegrationTestSuite) SetupTest() { func (suite *IntegrationTestSuite) SetupTest() {
var interfaceRegistry codectypes.InterfaceRegistry var interfaceRegistry codectypes.InterfaceRegistry
app, err := sims.Setup( app, err := sims.Setup(
@ -139,7 +138,7 @@ func (suite *IntegrationTestSuite) SetupTest() {
suite.ctx = app.BaseApp.NewContext(false, tmproto.Header{Time: time.Now()}) suite.ctx = app.BaseApp.NewContext(false, tmproto.Header{Time: time.Now()})
suite.fetchStoreKey = app.UnsafeFindStoreKey suite.fetchStoreKey = app.UnsafeFindStoreKey
//suite.Require().NoError(suite.accountKeeper.SetParams(suite.ctx, authtypes.DefaultParams())) // suite.Require().NoError(suite.accountKeeper.SetParams(suite.ctx, authtypes.DefaultParams()))
suite.Require().NoError(suite.bankKeeper.SetParams(suite.ctx, types.DefaultParams())) suite.Require().NoError(suite.bankKeeper.SetParams(suite.ctx, types.DefaultParams()))
queryHelper := baseapp.NewQueryServerTestHelper(suite.ctx, interfaceRegistry) queryHelper := baseapp.NewQueryServerTestHelper(suite.ctx, interfaceRegistry)

View File

@ -62,8 +62,10 @@ var lock = new(sync.Mutex)
// AppConstructor defines a function which accepts a network configuration and // AppConstructor defines a function which accepts a network configuration and
// creates an ABCI Application to provide to Tendermint. // creates an ABCI Application to provide to Tendermint.
type AppConstructor = func(val moduletestutil.Validator) servertypes.Application type (
type TestFixtureFactory = func() TestFixture AppConstructor = func(val moduletestutil.Validator) servertypes.Application
TestFixtureFactory = func() TestFixture
)
type TestFixture struct { type TestFixture struct {
AppConstructor AppConstructor AppConstructor AppConstructor

View File

@ -3,7 +3,7 @@ package network
import ( import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil" "os"
"path/filepath" "path/filepath"
"time" "time"
@ -200,7 +200,7 @@ func writeFile(name string, dir string, contents []byte) error {
return err return err
} }
err = ioutil.WriteFile(file, contents, 0o644) // nolint: gosec err = os.WriteFile(file, contents, 0o644) //nolint: gosec
if err != nil { if err != nil {
return err return err
} }

View File

@ -12,7 +12,7 @@ import (
// GetRequest defines a wrapper around an HTTP GET request with a provided URL. // 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. // An error is returned if the request or reading the body fails.
func GetRequest(url string) ([]byte, error) { func GetRequest(url string) ([]byte, error) {
res, err := http.Get(url) // nolint:gosec res, err := http.Get(url) //nolint:gosec
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -31,7 +31,7 @@ func GetRequest(url string) ([]byte, error) {
// PostRequest defines a wrapper around an HTTP POST request with a provided URL and data. // 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. // An error is returned if the request or reading the body fails.
func PostRequest(url string, contentType string, data []byte) ([]byte, error) { func PostRequest(url string, 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
if err != nil { if err != nil {
return nil, fmt.Errorf("error while sending post request: %w", err) return nil, fmt.Errorf("error while sending post request: %w", err)
} }

View File

@ -9,8 +9,7 @@ import (
) )
// bytesValueRenderer implements ValueRenderer for bytes // bytesValueRenderer implements ValueRenderer for bytes
type bytesValueRenderer struct { type bytesValueRenderer struct{}
}
var _ ValueRenderer = bytesValueRenderer{} var _ ValueRenderer = bytesValueRenderer{}

View File

@ -4,7 +4,7 @@ import (
"context" "context"
"encoding/hex" "encoding/hex"
"encoding/json" "encoding/json"
"io/ioutil" "os"
"strings" "strings"
"testing" "testing"
@ -14,7 +14,7 @@ import (
func TestFormatBytes(t *testing.T) { func TestFormatBytes(t *testing.T) {
var testcases []bytesTest var testcases []bytesTest
raw, err := ioutil.ReadFile("../internal/testdata/bytes.json") raw, err := os.ReadFile("../internal/testdata/bytes.json")
require.NoError(t, err) require.NoError(t, err)
err = json.Unmarshal(raw, &testcases) err = json.Unmarshal(raw, &testcases)

View File

@ -4,7 +4,7 @@ import (
"context" "context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil" "os"
"strconv" "strconv"
"strings" "strings"
"testing" "testing"
@ -20,7 +20,7 @@ import (
func TestFormatInteger(t *testing.T) { func TestFormatInteger(t *testing.T) {
type integerTest []string type integerTest []string
var testcases []integerTest var testcases []integerTest
raw, err := ioutil.ReadFile("../internal/testdata/integers.json") raw, err := os.ReadFile("../internal/testdata/integers.json")
require.NoError(t, err) require.NoError(t, err)
err = json.Unmarshal(raw, &testcases) err = json.Unmarshal(raw, &testcases)
require.NoError(t, err) require.NoError(t, err)
@ -67,7 +67,7 @@ func TestFormatInteger(t *testing.T) {
func TestFormatDecimal(t *testing.T) { func TestFormatDecimal(t *testing.T) {
type decimalTest []string type decimalTest []string
var testcases []decimalTest var testcases []decimalTest
raw, err := ioutil.ReadFile("../internal/testdata/decimals.json") raw, err := os.ReadFile("../internal/testdata/decimals.json")
require.NoError(t, err) require.NoError(t, err)
err = json.Unmarshal(raw, &testcases) err = json.Unmarshal(raw, &testcases)
require.NoError(t, err) require.NoError(t, err)

View File

@ -489,6 +489,7 @@ func (coins Coins) SafeQuoInt(x Int) (Coins, bool) {
// of AmountOf(D) of the inputs. Note that the result might be not // of AmountOf(D) of the inputs. Note that the result might be not
// be equal to either input. For any valid Coins a, b, and c, the // be equal to either input. For any valid Coins a, b, and c, the
// following are always true: // following are always true:
//
// a.IsAllLTE(a.Max(b)) // a.IsAllLTE(a.Max(b))
// b.IsAllLTE(a.Max(b)) // b.IsAllLTE(a.Max(b))
// a.IsAllLTE(c) && b.IsAllLTE(c) == a.Max(b).IsAllLTE(c) // a.IsAllLTE(c) && b.IsAllLTE(c) == a.Max(b).IsAllLTE(c)
@ -534,6 +535,7 @@ func (coins Coins) Max(coinsB Coins) Coins {
// of AmountOf(D) of the inputs. Note that the result might be not // of AmountOf(D) of the inputs. Note that the result might be not
// be equal to either input. For any valid Coins a, b, and c, the // be equal to either input. For any valid Coins a, b, and c, the
// following are always true: // following are always true:
//
// a.Min(b).IsAllLTE(a) // a.Min(b).IsAllLTE(a)
// a.Min(b).IsAllLTE(b) // a.Min(b).IsAllLTE(b)
// c.IsAllLTE(a) && c.IsAllLTE(b) == c.IsAllLTE(a.Min(b)) // c.IsAllLTE(a) && c.IsAllLTE(b) == c.IsAllLTE(a.Min(b))

View File

@ -91,6 +91,7 @@ func (config *Config) SetBech32PrefixForAccount(addressPrefix, pubKeyPrefix stri
} }
// SetBech32PrefixForValidator builds the Config with Bech32 addressPrefix and publKeyPrefix for validators // SetBech32PrefixForValidator builds the Config with Bech32 addressPrefix and publKeyPrefix for validators
//
// and returns the config instance // and returns the config instance
func (config *Config) SetBech32PrefixForValidator(addressPrefix, pubKeyPrefix string) { func (config *Config) SetBech32PrefixForValidator(addressPrefix, pubKeyPrefix string) {
config.assertNotSealed() config.assertNotSealed()

View File

@ -7,7 +7,9 @@ import (
// Type Aliases to errors module // Type Aliases to errors module
// //
// Deprecated: functionality of this package has been moved to it's own module: // Deprecated: functionality of this package has been moved to it's own module:
//
// cosmossdk.io/errors // cosmossdk.io/errors
//
// Please use the above module instead of this package. // Please use the above module instead of this package.
var ( var (
SuccessABCICode = errorsmod.SuccessABCICode SuccessABCICode = errorsmod.SuccessABCICode

View File

@ -43,6 +43,7 @@ func ChainAnteDecorators(chain ...AnteDecorator) AnteHandler {
// Terminator AnteDecorator will get added to the chain to simplify decorator code // Terminator AnteDecorator will get added to the chain to simplify decorator code
// Don't need to check if next == nil further up the chain // Don't need to check if next == nil further up the chain
//
// ______ // ______
// <((((((\\\ // <((((((\\\
// / . }\ // / . }\

View File

@ -364,6 +364,7 @@ type VersionMap map[string]uint64
// returning RunMigrations should be enough: // returning RunMigrations should be enough:
// //
// Example: // Example:
//
// cfg := module.NewConfigurator(...) // cfg := module.NewConfigurator(...)
// app.UpgradeKeeper.SetUpgradeHandler("my-plan", func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { // app.UpgradeKeeper.SetUpgradeHandler("my-plan", func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
// return app.mm.RunMigrations(ctx, cfg, fromVM) // return app.mm.RunMigrations(ctx, cfg, fromVM)
@ -377,6 +378,7 @@ type VersionMap map[string]uint64
// - if the module does not exist in the `fromVM` (which means that it's a new module, // - if the module does not exist in the `fromVM` (which means that it's a new module,
// because it was not in the previous x/upgrade's store), then run // because it was not in the previous x/upgrade's store), then run
// `InitGenesis` on that module. // `InitGenesis` on that module.
//
// - return the `updatedVM` to be persisted in the x/upgrade's store. // - return the `updatedVM` to be persisted in the x/upgrade's store.
// //
// Migrations are run in an order defined by `Manager.OrderMigrations` or (if not set) defined by // Migrations are run in an order defined by `Manager.OrderMigrations` or (if not set) defined by
@ -389,6 +391,7 @@ type VersionMap map[string]uint64
// running anything for foo. // running anything for foo.
// //
// Example: // Example:
//
// cfg := module.NewConfigurator(...) // cfg := module.NewConfigurator(...)
// app.UpgradeKeeper.SetUpgradeHandler("my-plan", func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { // app.UpgradeKeeper.SetUpgradeHandler("my-plan", func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) {
// // Assume "foo" is a new module. // // Assume "foo" is a new module.

View File

@ -4,7 +4,7 @@ import (
"bytes" "bytes"
"compress/gzip" "compress/gzip"
"fmt" "fmt"
"io/ioutil" "io"
"reflect" "reflect"
"github.com/gogo/protobuf/proto" "github.com/gogo/protobuf/proto"
@ -64,7 +64,7 @@ func unzip(b []byte) []byte {
panic(err) panic(err)
} }
unzipped, err := ioutil.ReadAll(r) unzipped, err := io.ReadAll(r)
if err != nil { if err != nil {
panic(err) panic(err)
} }

View File

@ -13,8 +13,10 @@ import (
const MaxGasWanted = uint64((1 << 63) - 1) const MaxGasWanted = uint64((1 << 63) - 1)
// Interface implementation checks. // Interface implementation checks.
var _, _, _, _ codectypes.UnpackInterfacesMessage = &Tx{}, &TxBody{}, &AuthInfo{}, &SignerInfo{} var (
var _ sdk.Tx = &Tx{} _, _, _, _ codectypes.UnpackInterfacesMessage = &Tx{}, &TxBody{}, &AuthInfo{}, &SignerInfo{}
_ sdk.Tx = &Tx{}
)
// GetMsgs implements the GetMsgs method on sdk.Tx. // GetMsgs implements the GetMsgs method on sdk.Tx.
func (t *Tx) GetMsgs() []sdk.Msg { func (t *Tx) GetMsgs() []sdk.Msg {

View File

@ -3,7 +3,7 @@
// produces apps versioning information based on flags // produces apps versioning information based on flags
// passed at compile time. // passed at compile time.
// //
// Configure the version command // # Configure the version command
// //
// The version command can be just added to your cobra root command. // The version command can be just added to your cobra root command.
// At build time, the variables Name, Version, Commit, and BuildTags // At build time, the variables Name, Version, Commit, and BuildTags

View File

@ -69,7 +69,8 @@ func TestSimulateGasCost(t *testing.T) {
testdata.NewTestMsg(accs[1].acc.GetAddress(), accs[2].acc.GetAddress()), testdata.NewTestMsg(accs[1].acc.GetAddress(), accs[2].acc.GetAddress()),
} }
return TestCaseArgs{accNums: []uint64{0, 1, 2}, return TestCaseArgs{
accNums: []uint64{0, 1, 2},
accSeqs: []uint64{0, 0, 0}, accSeqs: []uint64{0, 0, 0},
feeAmount: feeAmount, feeAmount: feeAmount,
gasLimit: simulatedGas, gasLimit: simulatedGas,
@ -867,7 +868,8 @@ func TestAnteHandlerMultiSigner(t *testing.T) {
privs, accNums, accSeqs = []cryptotypes.PrivKey{accs[0].priv, accs[1].priv, accs[2].priv}, []uint64{0, 1, 2}, []uint64{1, 1, 1} privs, accNums, accSeqs = []cryptotypes.PrivKey{accs[0].priv, accs[1].priv, accs[2].priv}, []uint64{0, 1, 2}, []uint64{1, 1, 1}
return TestCaseArgs{accNums: accNums, return TestCaseArgs{
accNums: accNums,
accSeqs: accSeqs, accSeqs: accSeqs,
msgs: msgs, msgs: msgs,
privs: privs, privs: privs,
@ -950,7 +952,7 @@ func TestAnteHandlerBadSignBytes(t *testing.T) {
return TestCaseArgs{ return TestCaseArgs{
chainID: suite.ctx.ChainID(), chainID: suite.ctx.ChainID(),
accNums: []uint64{0}, accNums: []uint64{0},
accSeqs: []uint64{2}, //wrong accSeq accSeqs: []uint64{2}, // wrong accSeq
feeAmount: feeAmount, feeAmount: feeAmount,
gasLimit: gasLimit, gasLimit: gasLimit,
msgs: []sdk.Msg{msg0}, msgs: []sdk.Msg{msg0},
@ -1018,7 +1020,6 @@ func TestAnteHandlerBadSignBytes(t *testing.T) {
msgs: []sdk.Msg{msg0}, msgs: []sdk.Msg{msg0},
privs: []cryptotypes.PrivKey{accs[1].priv}, privs: []cryptotypes.PrivKey{accs[1].priv},
} }
}, },
false, false,
false, false,

View File

@ -31,7 +31,8 @@ func TestDeductFeesNoDelegation(t *testing.T) {
valid bool valid bool
err error err error
malleate func(*AnteTestSuite) (signer TestAccount, feeAcc sdk.AccAddress) malleate func(*AnteTestSuite) (signer TestAccount, feeAcc sdk.AccAddress)
}{"paying with low funds": { }{
"paying with low funds": {
fee: 50, fee: 50,
valid: false, valid: false,
err: sdkerrors.ErrInsufficientFunds, err: sdkerrors.ErrInsufficientFunds,

View File

@ -52,7 +52,7 @@ func SetupTestSuite(t *testing.T, isCheckTx bool) *AnteTestSuite {
key := sdk.NewKVStoreKey(types.StoreKey) key := sdk.NewKVStoreKey(types.StoreKey)
testCtx := testutil.DefaultContextWithDB(t, key, sdk.NewTransientStoreKey("transient_test")) testCtx := testutil.DefaultContextWithDB(t, key, sdk.NewTransientStoreKey("transient_test"))
suite.ctx = testCtx.Ctx.WithIsCheckTx(isCheckTx).WithBlockHeight(1) //app.BaseApp.NewContext(isCheckTx, tmproto.Header{}).WithBlockHeight(1) suite.ctx = testCtx.Ctx.WithIsCheckTx(isCheckTx).WithBlockHeight(1) // app.BaseApp.NewContext(isCheckTx, tmproto.Header{}).WithBlockHeight(1)
suite.encCfg = moduletestutil.MakeTestEncodingConfig(auth.AppModuleBasic{}) suite.encCfg = moduletestutil.MakeTestEncodingConfig(auth.AppModuleBasic{})
maccPerms := map[string][]string{ maccPerms := map[string][]string{

View File

@ -238,7 +238,7 @@ func (ak AccountKeeper) decodeAccount(bz []byte) types.AccountI {
} }
// MarshalAccount protobuf serializes an Account interface // MarshalAccount protobuf serializes an Account interface
func (ak AccountKeeper) MarshalAccount(accountI types.AccountI) ([]byte, error) { // nolint:interfacer func (ak AccountKeeper) MarshalAccount(accountI types.AccountI) ([]byte, error) { //nolint:interfacer
return ak.cdc.MarshalInterface(accountI) return ak.cdc.MarshalInterface(accountI)
} }

View File

@ -107,6 +107,7 @@ func (tx StdTx) GetMsgs() []sdk.Msg { return tx.Msgs }
// ValidateBasic does a simple and lightweight validation check that doesn't // ValidateBasic does a simple and lightweight validation check that doesn't
// require access to any other information. // require access to any other information.
//
//nolint:revive // we need to change the receiver name here, because otherwise we conflict with tx.MaxGasWanted. //nolint:revive // we need to change the receiver name here, because otherwise we conflict with tx.MaxGasWanted.
func (stdTx StdTx) ValidateBasic() error { func (stdTx StdTx) ValidateBasic() error {
stdSigs := stdTx.GetSignatures() stdSigs := stdTx.GetSignatures()

View File

@ -7,7 +7,7 @@ import (
"strings" "strings"
gogogrpc "github.com/gogo/protobuf/grpc" gogogrpc "github.com/gogo/protobuf/grpc"
"github.com/golang/protobuf/proto" // nolint: staticcheck "github.com/golang/protobuf/proto" //nolint: staticcheck
"github.com/grpc-ecosystem/grpc-gateway/runtime" "github.com/grpc-ecosystem/grpc-gateway/runtime"
"google.golang.org/grpc/codes" "google.golang.org/grpc/codes"
"google.golang.org/grpc/status" "google.golang.org/grpc/status"

View File

@ -26,6 +26,7 @@ var (
) )
// NewBaseAccount creates a new BaseAccount object // NewBaseAccount creates a new BaseAccount object
//
//nolint:interfacer //nolint:interfacer
func NewBaseAccount(address sdk.AccAddress, pubKey cryptotypes.PubKey, accountNumber, sequence uint64) *BaseAccount { func NewBaseAccount(address sdk.AccAddress, pubKey cryptotypes.PubKey, accountNumber, sequence uint64) *BaseAccount {
acc := &BaseAccount{ acc := &BaseAccount{

View File

@ -41,8 +41,10 @@ func DefaultParams() Params {
// SigVerifyCostSecp256r1 returns gas fee of secp256r1 signature verification. // SigVerifyCostSecp256r1 returns gas fee of secp256r1 signature verification.
// Set by benchmarking current implementation: // Set by benchmarking current implementation:
//
// BenchmarkSig/secp256k1 4334 277167 ns/op 4128 B/op 79 allocs/op // BenchmarkSig/secp256k1 4334 277167 ns/op 4128 B/op 79 allocs/op
// BenchmarkSig/secp256r1 10000 108769 ns/op 1672 B/op 33 allocs/op // BenchmarkSig/secp256r1 10000 108769 ns/op 1672 B/op 33 allocs/op
//
// Based on the results above secp256k1 is 2.7x is slwer. However we propose to discount it // Based on the results above secp256k1 is 2.7x is slwer. However we propose to discount it
// because we are we don't compare the cgo implementation of secp256k1, which is faster. // because we are we don't compare the cgo implementation of secp256k1, which is faster.
func (p Params) SigVerifyCostSecp256r1() uint64 { func (p Params) SigVerifyCostSecp256r1() uint64 {

View File

@ -23,6 +23,7 @@ var _ sdk.Msg = &MsgCreatePermanentLockedAccount{}
var _ sdk.Msg = &MsgCreatePeriodicVestingAccount{} var _ sdk.Msg = &MsgCreatePeriodicVestingAccount{}
// NewMsgCreateVestingAccount returns a reference to a new MsgCreateVestingAccount. // NewMsgCreateVestingAccount returns a reference to a new MsgCreateVestingAccount.
//
//nolint:interfacer //nolint:interfacer
func NewMsgCreateVestingAccount(fromAddr, toAddr sdk.AccAddress, amount sdk.Coins, endTime int64, delayed bool) *MsgCreateVestingAccount { func NewMsgCreateVestingAccount(fromAddr, toAddr sdk.AccAddress, amount sdk.Coins, endTime int64, delayed bool) *MsgCreateVestingAccount {
return &MsgCreateVestingAccount{ return &MsgCreateVestingAccount{
@ -77,6 +78,7 @@ func (msg MsgCreateVestingAccount) GetSigners() []sdk.AccAddress {
} }
// NewMsgCreatePermanentLockedAccount returns a reference to a new MsgCreatePermanentLockedAccount. // NewMsgCreatePermanentLockedAccount returns a reference to a new MsgCreatePermanentLockedAccount.
//
//nolint:interfacer //nolint:interfacer
func NewMsgCreatePermanentLockedAccount(fromAddr, toAddr sdk.AccAddress, amount sdk.Coins) *MsgCreatePermanentLockedAccount { func NewMsgCreatePermanentLockedAccount(fromAddr, toAddr sdk.AccAddress, amount sdk.Coins) *MsgCreatePermanentLockedAccount {
return &MsgCreatePermanentLockedAccount{ return &MsgCreatePermanentLockedAccount{
@ -125,6 +127,7 @@ func (msg MsgCreatePermanentLockedAccount) GetSigners() []sdk.AccAddress {
} }
// NewMsgCreatePeriodicVestingAccount returns a reference to a new MsgCreatePeriodicVestingAccount. // NewMsgCreatePeriodicVestingAccount returns a reference to a new MsgCreatePeriodicVestingAccount.
//
//nolint:interfacer //nolint:interfacer
func NewMsgCreatePeriodicVestingAccount(fromAddr, toAddr sdk.AccAddress, startTime int64, periods []Period) *MsgCreatePeriodicVestingAccount { func NewMsgCreatePeriodicVestingAccount(fromAddr, toAddr sdk.AccAddress, startTime int64, periods []Period) *MsgCreatePeriodicVestingAccount {
return &MsgCreatePeriodicVestingAccount{ return &MsgCreatePeriodicVestingAccount{

View File

@ -6,13 +6,12 @@ can be (de)serialized properly.
Amino types should be ideally registered inside this codec within the init function of each module's Amino types should be ideally registered inside this codec within the init function of each module's
codec.go file as follows: codec.go file as follows:
func init() { func init() {
// ... // ...
RegisterLegacyAminoCodec(authzcodec.Amino) RegisterLegacyAminoCodec(authzcodec.Amino)
} }
The codec instance is put inside this package and not the x/authz package in order to avoid any dependency cycle. The codec instance is put inside this package and not the x/authz package in order to avoid any dependency cycle.
*/ */
package codec package codec

View File

@ -15,7 +15,6 @@ import (
// //
// - 0x01<grant_Bytes>: Grant // - 0x01<grant_Bytes>: Grant
// - 0x02<grant_expiration_Bytes>: GrantQueueItem // - 0x02<grant_expiration_Bytes>: GrantQueueItem
//
var ( var (
GrantKey = []byte{0x01} // prefix for each key GrantKey = []byte{0x01} // prefix for each key
GrantQueuePrefix = []byte{0x02} GrantQueuePrefix = []byte{0x02}
@ -78,6 +77,7 @@ func parseGrantQueueKey(key []byte) (time.Time, sdk.AccAddress, sdk.AccAddress,
// GrantQueueKey - return grant queue store key. If a given grant doesn't have a defined // GrantQueueKey - return grant queue store key. If a given grant doesn't have a defined
// expiration, then it should not be used in the pruning queue. // expiration, then it should not be used in the pruning queue.
// Key format is: // Key format is:
//
// 0x02<grant_expiration_Bytes>: GrantQueueItem // 0x02<grant_expiration_Bytes>: GrantQueueItem
func GrantQueueKey(expiration time.Time, granter sdk.AccAddress, grantee sdk.AccAddress) []byte { func GrantQueueKey(expiration time.Time, granter sdk.AccAddress, grantee sdk.AccAddress) []byte {
exp := sdk.FormatTimeBytes(expiration) exp := sdk.FormatTimeBytes(expiration)

View File

@ -14,7 +14,6 @@ import (
// //
// - 0x01<grant_Bytes>: Grant // - 0x01<grant_Bytes>: Grant
// - 0x02<grant_expiration_Bytes>: GrantQueueItem // - 0x02<grant_expiration_Bytes>: GrantQueueItem
//
var ( var (
GrantPrefix = []byte{0x01} GrantPrefix = []byte{0x01}
GrantQueuePrefix = []byte{0x02} GrantQueuePrefix = []byte{0x02}

View File

@ -23,7 +23,6 @@ import (
) )
func TestExpiredGrantsQueue(t *testing.T) { func TestExpiredGrantsQueue(t *testing.T) {
key := sdk.NewKVStoreKey(keeper.StoreKey) key := sdk.NewKVStoreKey(keeper.StoreKey)
testCtx := testutil.DefaultContextWithDB(t, key, sdk.NewTransientStoreKey("transient_test")) testCtx := testutil.DefaultContextWithDB(t, key, sdk.NewTransientStoreKey("transient_test"))
encCfg := moduletestutil.MakeTestEncodingConfig(authzmodule.AppModuleBasic{}) encCfg := moduletestutil.MakeTestEncodingConfig(authzmodule.AppModuleBasic{})

View File

@ -28,6 +28,7 @@ var (
) )
// NewMsgGrant creates a new MsgGrant // NewMsgGrant creates a new MsgGrant
//
//nolint:interfacer //nolint:interfacer
func NewMsgGrant(granter sdk.AccAddress, grantee sdk.AccAddress, a Authorization, expiration *time.Time) (*MsgGrant, error) { func NewMsgGrant(granter sdk.AccAddress, grantee sdk.AccAddress, a Authorization, expiration *time.Time) (*MsgGrant, error) {
m := &MsgGrant{ m := &MsgGrant{
@ -118,6 +119,7 @@ func (msg MsgGrant) UnpackInterfaces(unpacker cdctypes.AnyUnpacker) error {
} }
// NewMsgRevoke creates a new MsgRevoke // NewMsgRevoke creates a new MsgRevoke
//
//nolint:interfacer //nolint:interfacer
func NewMsgRevoke(granter sdk.AccAddress, grantee sdk.AccAddress, msgTypeURL string) MsgRevoke { func NewMsgRevoke(granter sdk.AccAddress, grantee sdk.AccAddress, msgTypeURL string) MsgRevoke {
return MsgRevoke{ return MsgRevoke{
@ -171,6 +173,7 @@ func (msg MsgRevoke) GetSignBytes() []byte {
} }
// NewMsgExec creates a new MsgExecAuthorized // NewMsgExec creates a new MsgExecAuthorized
//
//nolint:interfacer //nolint:interfacer
func NewMsgExec(grantee sdk.AccAddress, msgs []sdk.Msg) MsgExec { func NewMsgExec(grantee sdk.AccAddress, msgs []sdk.Msg) MsgExec {
msgsAny := make([]*cdctypes.Any, len(msgs)) msgsAny := make([]*cdctypes.Any, len(msgs))

View File

@ -26,6 +26,7 @@ var (
) )
// Simulation operation weights constants // Simulation operation weights constants
//
//nolint:gosec // these are not hardcoded credentials. //nolint:gosec // these are not hardcoded credentials.
const ( const (
OpWeightMsgGrant = "op_weight_msg_grant" OpWeightMsgGrant = "op_weight_msg_grant"

View File

@ -115,6 +115,7 @@ func NewBaseKeeper(
// WithMintCoinsRestriction restricts the bank Keeper used within a specific module to // WithMintCoinsRestriction restricts the bank Keeper used within a specific module to
// have restricted permissions on minting via function passed in parameter. // have restricted permissions on minting via function passed in parameter.
// Previous restriction functions can be nested as such: // Previous restriction functions can be nested as such:
//
// bankKeeper.WithMintCoinsRestriction(restriction1).WithMintCoinsRestriction(restriction2) // bankKeeper.WithMintCoinsRestriction(restriction1).WithMintCoinsRestriction(restriction2)
func (k BaseKeeper) WithMintCoinsRestriction(check MintingRestrictionFn) BaseKeeper { func (k BaseKeeper) WithMintCoinsRestriction(check MintingRestrictionFn) BaseKeeper {
oldRestrictionFn := k.mintCoinsRestrictionFn oldRestrictionFn := k.mintCoinsRestrictionFn

View File

@ -681,7 +681,8 @@ func (suite *KeeperTestSuite) TestMsgMultiSendEvents() {
newCoins := sdk.NewCoins(sdk.NewInt64Coin(fooDenom, 50)) newCoins := sdk.NewCoins(sdk.NewInt64Coin(fooDenom, 50))
newCoins2 := sdk.NewCoins(sdk.NewInt64Coin(barDenom, 100)) newCoins2 := sdk.NewCoins(sdk.NewInt64Coin(barDenom, 100))
inputs := []banktypes.Input{ inputs := []banktypes.Input{
{Address: accAddrs[0].String(), {
Address: accAddrs[0].String(),
Coins: coins, Coins: coins,
}, },
} }

View File

@ -99,6 +99,7 @@ func (k BaseSendKeeper) GetParams(ctx sdk.Context) (params types.Params) {
} }
// SetParams sets the total set of bank parameters. // SetParams sets the total set of bank parameters.
//
//nolint:staticcheck // params.SendEnabled is deprecated but it should be here regardless. //nolint:staticcheck // params.SendEnabled is deprecated but it should be here regardless.
func (k BaseSendKeeper) SetParams(ctx sdk.Context, params types.Params) error { func (k BaseSendKeeper) SetParams(ctx sdk.Context, params types.Params) error {
// normally SendEnabled is deprecated but we still support it for backwards compatibility // normally SendEnabled is deprecated but we still support it for backwards compatibility
@ -466,6 +467,7 @@ func (k BaseSendKeeper) GetAllSendEnabledEntries(ctx sdk.Context) []types.SendEn
// getSendEnabled returns whether send is enabled and whether that flag was set for a denom. // getSendEnabled returns whether send is enabled and whether that flag was set for a denom.
// //
// Example usage: // Example usage:
//
// store := ctx.KVStore(k.storeKey) // store := ctx.KVStore(k.storeKey)
// sendEnabled, found := getSendEnabled(store, "atom") // sendEnabled, found := getSendEnabled(store, "atom")
// if !found { // if !found {

View File

@ -17,6 +17,7 @@ import (
) )
// Simulation operation weights constants // Simulation operation weights constants
//
//nolint:gosec // these are not hardcoded credentials. //nolint:gosec // these are not hardcoded credentials.
const ( const (
OpWeightMsgSend = "op_weight_msg_send" OpWeightMsgSend = "op_weight_msg_send"

View File

@ -26,7 +26,6 @@ const (
) )
// NewCoinSpentEvent constructs a new coin spent sdk.Event // NewCoinSpentEvent constructs a new coin spent sdk.Event
// nolint: interfacer
func NewCoinSpentEvent(spender sdk.AccAddress, amount sdk.Coins) sdk.Event { func NewCoinSpentEvent(spender sdk.AccAddress, amount sdk.Coins) sdk.Event {
return sdk.NewEvent( return sdk.NewEvent(
EventTypeCoinSpent, EventTypeCoinSpent,
@ -36,7 +35,6 @@ func NewCoinSpentEvent(spender sdk.AccAddress, amount sdk.Coins) sdk.Event {
} }
// NewCoinReceivedEvent constructs a new coin received sdk.Event // NewCoinReceivedEvent constructs a new coin received sdk.Event
// nolint: interfacer
func NewCoinReceivedEvent(receiver sdk.AccAddress, amount sdk.Coins) sdk.Event { func NewCoinReceivedEvent(receiver sdk.AccAddress, amount sdk.Coins) sdk.Event {
return sdk.NewEvent( return sdk.NewEvent(
EventTypeCoinReceived, EventTypeCoinReceived,
@ -46,7 +44,6 @@ func NewCoinReceivedEvent(receiver sdk.AccAddress, amount sdk.Coins) sdk.Event {
} }
// NewCoinMintEvent construct a new coin minted sdk.Event // NewCoinMintEvent construct a new coin minted sdk.Event
// nolint: interfacer
func NewCoinMintEvent(minter sdk.AccAddress, amount sdk.Coins) sdk.Event { func NewCoinMintEvent(minter sdk.AccAddress, amount sdk.Coins) sdk.Event {
return sdk.NewEvent( return sdk.NewEvent(
EventTypeCoinMint, EventTypeCoinMint,
@ -56,7 +53,6 @@ func NewCoinMintEvent(minter sdk.AccAddress, amount sdk.Coins) sdk.Event {
} }
// NewCoinBurnEvent constructs a new coin burned sdk.Event // NewCoinBurnEvent constructs a new coin burned sdk.Event
// nolint: interfacer
func NewCoinBurnEvent(burner sdk.AccAddress, amount sdk.Coins) sdk.Event { func NewCoinBurnEvent(burner sdk.AccAddress, amount sdk.Coins) sdk.Event {
return sdk.NewEvent( return sdk.NewEvent(
EventTypeCoinBurn, EventTypeCoinBurn,

View File

@ -20,6 +20,7 @@ var (
) )
// NewMsgSend - construct a msg to send coins from one account to another. // NewMsgSend - construct a msg to send coins from one account to another.
//
//nolint:interfacer //nolint:interfacer
func NewMsgSend(fromAddr, toAddr sdk.AccAddress, amount sdk.Coins) *MsgSend { func NewMsgSend(fromAddr, toAddr sdk.AccAddress, amount sdk.Coins) *MsgSend {
return &MsgSend{FromAddress: fromAddr.String(), ToAddress: toAddr.String(), Amount: amount} return &MsgSend{FromAddress: fromAddr.String(), ToAddress: toAddr.String(), Amount: amount}
@ -128,6 +129,7 @@ func (in Input) ValidateBasic() error {
} }
// NewInput - create a transaction input, used with MsgMultiSend // NewInput - create a transaction input, used with MsgMultiSend
//
//nolint:interfacer //nolint:interfacer
func NewInput(addr sdk.AccAddress, coins sdk.Coins) Input { func NewInput(addr sdk.AccAddress, coins sdk.Coins) Input {
return Input{ return Input{
@ -154,6 +156,7 @@ func (out Output) ValidateBasic() error {
} }
// NewOutput - create a transaction output, used with MsgMultiSend // NewOutput - create a transaction output, used with MsgMultiSend
//
//nolint:interfacer //nolint:interfacer
func NewOutput(addr sdk.AccAddress, coins sdk.Coins) Output { func NewOutput(addr sdk.AccAddress, coins sdk.Coins) Output {
return Output{ return Output{

View File

@ -52,6 +52,7 @@ func (se SendEnabled) Validate() error {
} }
// validateSendEnabledParams is used by the x/params module to validate the params for the bank module. // validateSendEnabledParams is used by the x/params module to validate the params for the bank module.
//
//nolint:deadcode,unused //nolint:deadcode,unused
func validateSendEnabledParams(i interface{}) error { func validateSendEnabledParams(i interface{}) error {
params, ok := i.([]*SendEnabled) params, ok := i.([]*SendEnabled)
@ -87,6 +88,7 @@ func (se SendEnabled) String() string {
} }
// validateSendEnabled is used by the x/params module to validate a single SendEnabled entry. // validateSendEnabled is used by the x/params module to validate a single SendEnabled entry.
//
//nolint:unused //nolint:unused
func validateSendEnabled(i interface{}) error { func validateSendEnabled(i interface{}) error {
param, ok := i.(SendEnabled) param, ok := i.(SendEnabled)

View File

@ -14,12 +14,14 @@ const (
) )
// NewQueryBalanceRequest creates a new instance of QueryBalanceRequest. // NewQueryBalanceRequest creates a new instance of QueryBalanceRequest.
//
//nolint:interfacer //nolint:interfacer
func NewQueryBalanceRequest(addr sdk.AccAddress, denom string) *QueryBalanceRequest { func NewQueryBalanceRequest(addr sdk.AccAddress, denom string) *QueryBalanceRequest {
return &QueryBalanceRequest{Address: addr.String(), Denom: denom} return &QueryBalanceRequest{Address: addr.String(), Denom: denom}
} }
// NewQueryAllBalancesRequest creates a new instance of QueryAllBalancesRequest. // NewQueryAllBalancesRequest creates a new instance of QueryAllBalancesRequest.
//
//nolint:interfacer //nolint:interfacer
func NewQueryAllBalancesRequest(addr sdk.AccAddress, req *query.PageRequest) *QueryAllBalancesRequest { func NewQueryAllBalancesRequest(addr sdk.AccAddress, req *query.PageRequest) *QueryAllBalancesRequest {
return &QueryAllBalancesRequest{Address: addr.String(), Pagination: req} return &QueryAllBalancesRequest{Address: addr.String(), Pagination: req}
@ -27,7 +29,8 @@ func NewQueryAllBalancesRequest(addr sdk.AccAddress, req *query.PageRequest) *Qu
// NewQuerySpendableBalancesRequest creates a new instance of a // NewQuerySpendableBalancesRequest creates a new instance of a
// QuerySpendableBalancesRequest. // QuerySpendableBalancesRequest.
// nolint:interfacer //
//nolint:interfacer
func NewQuerySpendableBalancesRequest(addr sdk.AccAddress, req *query.PageRequest) *QuerySpendableBalancesRequest { func NewQuerySpendableBalancesRequest(addr sdk.AccAddress, req *query.PageRequest) *QuerySpendableBalancesRequest {
return &QuerySpendableBalancesRequest{Address: addr.String(), Pagination: req} return &QuerySpendableBalancesRequest{Address: addr.String(), Pagination: req}
} }

View File

@ -4,7 +4,6 @@ import (
"context" "context"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"testing" "testing"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
@ -97,7 +96,7 @@ func TestNewMsgVerifyInvariantTxCmd(t *testing.T) {
ctx := svrcmd.CreateExecuteContext(context.Background()) ctx := svrcmd.CreateExecuteContext(context.Background())
cmd := cli.NewMsgVerifyInvariantTxCmd() cmd := cli.NewMsgVerifyInvariantTxCmd()
cmd.SetOut(ioutil.Discard) cmd.SetOut(io.Discard)
assert.NotNil(t, cmd) assert.NotNil(t, cmd)
cmd.SetContext(ctx) cmd.SetContext(ctx)

View File

@ -14,6 +14,7 @@ const (
var _, _ sdk.Msg = &MsgVerifyInvariant{}, &MsgUpdateParams{} var _, _ sdk.Msg = &MsgVerifyInvariant{}, &MsgUpdateParams{}
// NewMsgVerifyInvariant creates a new MsgVerifyInvariant object // NewMsgVerifyInvariant creates a new MsgVerifyInvariant object
//
//nolint:interfacer //nolint:interfacer
func NewMsgVerifyInvariant(sender sdk.AccAddress, invModeName, invRoute string) *MsgVerifyInvariant { func NewMsgVerifyInvariant(sender sdk.AccAddress, invModeName, invRoute string) *MsgVerifyInvariant {
return &MsgVerifyInvariant{ return &MsgVerifyInvariant{

View File

@ -19,6 +19,7 @@ import (
) )
// Simulation operation weights constants // Simulation operation weights constants
//
//nolint:gosec // these are not hardcoded credentials. //nolint:gosec // these are not hardcoded credentials.
const ( const (
OpWeightMsgSetWithdrawAddress = "op_weight_msg_set_withdraw_address" OpWeightMsgSetWithdrawAddress = "op_weight_msg_set_withdraw_address"

View File

@ -21,6 +21,7 @@ func init() {
} }
// NewCommunityPoolSpendProposal creates a new community pool spend proposal. // NewCommunityPoolSpendProposal creates a new community pool spend proposal.
//
//nolint:interfacer //nolint:interfacer
func NewCommunityPoolSpendProposal(title, description string, recipient sdk.AccAddress, amount sdk.Coins) *CommunityPoolSpendProposal { func NewCommunityPoolSpendProposal(title, description string, recipient sdk.AccAddress, amount sdk.Coins) *CommunityPoolSpendProposal {
return &CommunityPoolSpendProposal{title, description, recipient.String(), amount} return &CommunityPoolSpendProposal{title, description, recipient.String(), amount}

View File

@ -32,6 +32,7 @@ func (res QueryDelegatorTotalRewardsResponse) String() string {
} }
// NewDelegationDelegatorReward constructs a DelegationDelegatorReward. // NewDelegationDelegatorReward constructs a DelegationDelegatorReward.
//
//nolint:interfacer //nolint:interfacer
func NewDelegationDelegatorReward(valAddr sdk.ValAddress, reward sdk.DecCoins) DelegationDelegatorReward { func NewDelegationDelegatorReward(valAddr sdk.ValAddress, reward sdk.DecCoins) DelegationDelegatorReward {
return DelegationDelegatorReward{ValidatorAddress: valAddr.String(), Reward: reward} return DelegationDelegatorReward{ValidatorAddress: valAddr.String(), Reward: reward}

View File

@ -1,6 +1,8 @@
package keeper_test package keeper_test
import ( import (
"time"
codectypes "github.com/cosmos/cosmos-sdk/codec/types" codectypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/runtime" "github.com/cosmos/cosmos-sdk/runtime"
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
@ -18,7 +20,6 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite" "github.com/stretchr/testify/suite"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types" tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
"time"
) )
type InfractionTestSuite struct { type InfractionTestSuite struct {
@ -38,9 +39,7 @@ type InfractionTestSuite struct {
} }
func (suite *InfractionTestSuite) SetupTest() { func (suite *InfractionTestSuite) SetupTest() {
var ( var evidenceKeeper keeper.Keeper
evidenceKeeper keeper.Keeper
)
app, err := simtestutil.Setup(testutil.AppConfig, app, err := simtestutil.Setup(testutil.AppConfig,
&evidenceKeeper, &evidenceKeeper,

View File

@ -3,13 +3,14 @@ package keeper_test
import ( import (
"encoding/hex" "encoding/hex"
"fmt" "fmt"
"time"
"github.com/cosmos/cosmos-sdk/testutil" "github.com/cosmos/cosmos-sdk/testutil"
moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil"
"github.com/cosmos/cosmos-sdk/x/evidence" "github.com/cosmos/cosmos-sdk/x/evidence"
evidencetestutil "github.com/cosmos/cosmos-sdk/x/evidence/testutil" evidencetestutil "github.com/cosmos/cosmos-sdk/x/evidence/testutil"
"github.com/golang/mock/gomock" "github.com/golang/mock/gomock"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types" tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
"time"
"github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"

View File

@ -1,9 +1,10 @@
package types package types
import ( import (
"github.com/cosmos/cosmos-sdk/x/auth/types"
"time" "time"
"github.com/cosmos/cosmos-sdk/x/auth/types"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"

View File

@ -23,6 +23,7 @@ var (
) )
// NewMsgSubmitEvidence returns a new MsgSubmitEvidence with a signer/submitter. // NewMsgSubmitEvidence returns a new MsgSubmitEvidence with a signer/submitter.
//
//nolint:interfacer //nolint:interfacer
func NewMsgSubmitEvidence(s sdk.AccAddress, evi exported.Evidence) (*MsgSubmitEvidence, error) { func NewMsgSubmitEvidence(s sdk.AccAddress, evi exported.Evidence) (*MsgSubmitEvidence, error) {
msg, ok := evi.(proto.Message) msg, ok := evi.(proto.Message)

View File

@ -11,6 +11,7 @@ import (
var _ types.UnpackInterfacesMessage = &Grant{} var _ types.UnpackInterfacesMessage = &Grant{}
// NewGrant creates a new FeeAllowanceGrant. // NewGrant creates a new FeeAllowanceGrant.
//
//nolint:interfacer //nolint:interfacer
func NewGrant(granter, grantee sdk.AccAddress, feeAllowance FeeAllowanceI) (Grant, error) { func NewGrant(granter, grantee sdk.AccAddress, feeAllowance FeeAllowanceI) (Grant, error) {
msg, ok := feeAllowance.(proto.Message) msg, ok := feeAllowance.(proto.Message)

View File

@ -17,6 +17,7 @@ var (
) )
// NewMsgGrantAllowance creates a new MsgGrantAllowance. // NewMsgGrantAllowance creates a new MsgGrantAllowance.
//
//nolint:interfacer //nolint:interfacer
func NewMsgGrantAllowance(feeAllowance FeeAllowanceI, granter, grantee sdk.AccAddress) (*MsgGrantAllowance, error) { func NewMsgGrantAllowance(feeAllowance FeeAllowanceI, granter, grantee sdk.AccAddress) (*MsgGrantAllowance, error) {
msg, ok := feeAllowance.(proto.Message) msg, ok := feeAllowance.(proto.Message)
@ -93,6 +94,7 @@ func (msg MsgGrantAllowance) UnpackInterfaces(unpacker types.AnyUnpacker) error
// NewMsgRevokeAllowance returns a message to revoke a fee allowance for a given // NewMsgRevokeAllowance returns a message to revoke a fee allowance for a given
// granter and grantee // granter and grantee
//
//nolint:interfacer //nolint:interfacer
func NewMsgRevokeAllowance(granter sdk.AccAddress, grantee sdk.AccAddress) MsgRevokeAllowance { func NewMsgRevokeAllowance(granter sdk.AccAddress, grantee sdk.AccAddress) MsgRevokeAllowance {
return MsgRevokeAllowance{Granter: granter.String(), Grantee: grantee.String()} return MsgRevokeAllowance{Granter: granter.String(), Grantee: grantee.String()}

View File

@ -15,6 +15,7 @@ import (
) )
// Simulation operation weights constants // Simulation operation weights constants
//
//nolint:gosec // These aren't harcoded credentials. //nolint:gosec // These aren't harcoded credentials.
const ( const (
OpWeightMsgGrantAllowance = "op_weight_msg_grant_fee_allowance" OpWeightMsgGrantAllowance = "op_weight_msg_grant_fee_allowance"

View File

@ -509,6 +509,8 @@ $ %s query gov tally 1
} }
// GetCmdQueryParams implements the query params command. // GetCmdQueryParams implements the query params command.
//
//nolint:staticcheck // this function contains deprecated commands that we need.
func GetCmdQueryParams() *cobra.Command { func GetCmdQueryParams() *cobra.Command {
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "params", Use: "params",
@ -589,6 +591,7 @@ $ %s query gov param deposit
} }
var out fmt.Stringer var out fmt.Stringer
//nolint:staticcheck // this switch statement contains deprecated commands that we need.
switch args[0] { switch args[0] {
case "voting": case "voting":
out = res.GetVotingParams() out = res.GetVotingParams()

View File

@ -357,9 +357,9 @@ func (s *IntegrationTestSuite) TestGetParamsGRPC() {
val := s.network.Validators[0] val := s.network.Validators[0]
params := v1.DefaultParams() params := v1.DefaultParams()
dp := v1.NewDepositParams(params.MinDeposit, params.MaxDepositPeriod) dp := v1.NewDepositParams(params.MinDeposit, params.MaxDepositPeriod) //nolint:staticcheck // we use deprecated gov commands here, but we don't want to remove them
vp := v1.NewVotingParams(params.VotingPeriod) vp := v1.NewVotingParams(params.VotingPeriod) //nolint:staticcheck // we use deprecated gov commands here, but we don't want to remove them
tp := v1.NewTallyParams(params.Quorum, params.Threshold, params.VetoThreshold) tp := v1.NewTallyParams(params.Quorum, params.Threshold, params.VetoThreshold) //nolint:staticcheck // we use deprecated gov commands here, but we don't want to remove them
testCases := []struct { testCases := []struct {
name string name string

View File

@ -18,6 +18,7 @@ var commonArgs = []string{
} }
// MsgSubmitLegacyProposal creates a tx for submit legacy proposal // MsgSubmitLegacyProposal creates a tx for submit legacy proposal
//
//nolint:staticcheck // we are intentionally using a deprecated flag here. //nolint:staticcheck // we are intentionally using a deprecated flag here.
func MsgSubmitLegacyProposal(clientCtx client.Context, from, title, description, proposalType string, extraArgs ...string) (testutil.BufferWriter, error) { func MsgSubmitLegacyProposal(clientCtx client.Context, from, title, description, proposalType string, extraArgs ...string) (testutil.BufferWriter, error) {
args := append([]string{ args := append([]string{

View File

@ -53,6 +53,8 @@ func InitGenesis(ctx sdk.Context, ak types.AccountKeeper, bk types.BankKeeper, k
} }
// ExportGenesis - output genesis parameters // ExportGenesis - output genesis parameters
//
//nolint:staticcheck
func ExportGenesis(ctx sdk.Context, k *keeper.Keeper) *v1.GenesisState { func ExportGenesis(ctx sdk.Context, k *keeper.Keeper) *v1.GenesisState {
startingProposalID, _ := k.GetProposalID(ctx) startingProposalID, _ := k.GetProposalID(ctx)
proposals := k.GetProposals(ctx) proposals := k.GetProposals(ctx)

View File

@ -162,6 +162,7 @@ func (q Keeper) Params(c context.Context, req *v1.QueryParamsRequest) (*v1.Query
response := &v1.QueryParamsResponse{} response := &v1.QueryParamsResponse{}
//nolint:staticcheck
switch req.ParamsType { switch req.ParamsType {
case v1.ParamDeposit: case v1.ParamDeposit:
depositParams := v1.NewDepositParams(params.MinDeposit, params.MaxDepositPeriod) depositParams := v1.NewDepositParams(params.MinDeposit, params.MaxDepositPeriod)
@ -371,11 +372,11 @@ func (q legacyQueryServer) Votes(c context.Context, req *v1beta1.QueryVotesReque
}, nil }, nil
} }
//nolint:staticcheck
func (q legacyQueryServer) Params(c context.Context, req *v1beta1.QueryParamsRequest) (*v1beta1.QueryParamsResponse, error) { func (q legacyQueryServer) Params(c context.Context, req *v1beta1.QueryParamsRequest) (*v1beta1.QueryParamsResponse, error) {
resp, err := q.keeper.Params(c, &v1.QueryParamsRequest{ resp, err := q.keeper.Params(c, &v1.QueryParamsRequest{
ParamsType: req.ParamsType, ParamsType: req.ParamsType,
}) })
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -19,7 +19,7 @@ import (
// Keeper defines the governance module Keeper // Keeper defines the governance module Keeper
type Keeper struct { type Keeper struct {
// The reference to the Paramstore to get and set gov specific params // The reference to the Paramstore to get and set gov specific params
paramSpace types.ParamSubspace paramSpace types.ParamSubspace //nolint:unused
authKeeper types.AccountKeeper authKeeper types.AccountKeeper
bankKeeper types.BankKeeper bankKeeper types.BankKeeper

View File

@ -5,14 +5,12 @@ import (
"fmt" "fmt"
"strconv" "strconv"
"cosmossdk.io/errors"
"github.com/armon/go-metrics" "github.com/armon/go-metrics"
storetypes "github.com/cosmos/cosmos-sdk/store/types" storetypes "github.com/cosmos/cosmos-sdk/store/types"
"github.com/cosmos/cosmos-sdk/telemetry" "github.com/cosmos/cosmos-sdk/telemetry"
sdk "github.com/cosmos/cosmos-sdk/types" sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/errors"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/x/gov/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
v1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" v1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
"github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1" "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
@ -59,7 +57,7 @@ func (k msgServer) SubmitProposal(goCtx context.Context, msg *v1.MsgSubmitPropos
"submit proposal", "submit proposal",
) )
defer telemetry.IncrCounter(1, types.ModuleName, "proposal") defer telemetry.IncrCounter(1, govtypes.ModuleName, "proposal")
proposer, _ := sdk.AccAddressFromBech32(msg.GetProposer()) proposer, _ := sdk.AccAddressFromBech32(msg.GetProposer())
votingStarted, err := k.Keeper.AddDeposit(ctx, proposal.Id, proposer, msg.GetInitialDeposit()) votingStarted, err := k.Keeper.AddDeposit(ctx, proposal.Id, proposer, msg.GetInitialDeposit())
@ -70,14 +68,14 @@ func (k msgServer) SubmitProposal(goCtx context.Context, msg *v1.MsgSubmitPropos
ctx.EventManager().EmitEvent( ctx.EventManager().EmitEvent(
sdk.NewEvent( sdk.NewEvent(
sdk.EventTypeMessage, sdk.EventTypeMessage,
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), sdk.NewAttribute(sdk.AttributeKeyModule, govtypes.AttributeValueCategory),
sdk.NewAttribute(sdk.AttributeKeySender, msg.GetProposer()), sdk.NewAttribute(sdk.AttributeKeySender, msg.GetProposer()),
), ),
) )
if votingStarted { if votingStarted {
submitEvent := sdk.NewEvent(types.EventTypeSubmitProposal, submitEvent := sdk.NewEvent(govtypes.EventTypeSubmitProposal,
sdk.NewAttribute(types.AttributeKeyVotingPeriodStart, fmt.Sprintf("%d", proposal.Id)), sdk.NewAttribute(govtypes.AttributeKeyVotingPeriodStart, fmt.Sprintf("%d", proposal.Id)),
) )
ctx.EventManager().EmitEvent(submitEvent) ctx.EventManager().EmitEvent(submitEvent)
@ -93,22 +91,22 @@ func (k msgServer) ExecLegacyContent(goCtx context.Context, msg *v1.MsgExecLegac
govAcct := k.GetGovernanceAccount(ctx).GetAddress().String() govAcct := k.GetGovernanceAccount(ctx).GetAddress().String()
if govAcct != msg.Authority { if govAcct != msg.Authority {
return nil, sdkerrors.Wrapf(types.ErrInvalidSigner, "expected %s got %s", govAcct, msg.Authority) return nil, errors.Wrapf(govtypes.ErrInvalidSigner, "expected %s got %s", govAcct, msg.Authority)
} }
content, err := v1.LegacyContentFromMessage(msg) content, err := v1.LegacyContentFromMessage(msg)
if err != nil { if err != nil {
return nil, sdkerrors.Wrapf(types.ErrInvalidProposalContent, "%+v", err) return nil, errors.Wrapf(govtypes.ErrInvalidProposalContent, "%+v", err)
} }
// Ensure that the content has a respective handler // Ensure that the content has a respective handler
if !k.Keeper.legacyRouter.HasRoute(content.ProposalRoute()) { if !k.Keeper.legacyRouter.HasRoute(content.ProposalRoute()) {
return nil, sdkerrors.Wrap(types.ErrNoProposalHandlerExists, content.ProposalRoute()) return nil, errors.Wrap(govtypes.ErrNoProposalHandlerExists, content.ProposalRoute())
} }
handler := k.Keeper.legacyRouter.GetRoute(content.ProposalRoute()) handler := k.Keeper.legacyRouter.GetRoute(content.ProposalRoute())
if err := handler(ctx, content); err != nil { if err := handler(ctx, content); err != nil {
return nil, sdkerrors.Wrapf(types.ErrInvalidProposalContent, "failed to run legacy handler %s, %+v", content.ProposalRoute(), err) return nil, errors.Wrapf(govtypes.ErrInvalidProposalContent, "failed to run legacy handler %s, %+v", content.ProposalRoute(), err)
} }
return &v1.MsgExecLegacyContentResponse{}, nil return &v1.MsgExecLegacyContentResponse{}, nil
@ -126,7 +124,7 @@ func (k msgServer) Vote(goCtx context.Context, msg *v1.MsgVote) (*v1.MsgVoteResp
} }
defer telemetry.IncrCounterWithLabels( defer telemetry.IncrCounterWithLabels(
[]string{types.ModuleName, "vote"}, []string{govtypes.ModuleName, "vote"},
1, 1,
[]metrics.Label{ []metrics.Label{
telemetry.NewLabel("proposal_id", strconv.Itoa(int(msg.ProposalId))), telemetry.NewLabel("proposal_id", strconv.Itoa(int(msg.ProposalId))),
@ -136,7 +134,7 @@ func (k msgServer) Vote(goCtx context.Context, msg *v1.MsgVote) (*v1.MsgVoteResp
ctx.EventManager().EmitEvent( ctx.EventManager().EmitEvent(
sdk.NewEvent( sdk.NewEvent(
sdk.EventTypeMessage, sdk.EventTypeMessage,
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), sdk.NewAttribute(sdk.AttributeKeyModule, govtypes.AttributeValueCategory),
sdk.NewAttribute(sdk.AttributeKeySender, msg.Voter), sdk.NewAttribute(sdk.AttributeKeySender, msg.Voter),
), ),
) )
@ -156,7 +154,7 @@ func (k msgServer) VoteWeighted(goCtx context.Context, msg *v1.MsgVoteWeighted)
} }
defer telemetry.IncrCounterWithLabels( defer telemetry.IncrCounterWithLabels(
[]string{types.ModuleName, "vote"}, []string{govtypes.ModuleName, "vote"},
1, 1,
[]metrics.Label{ []metrics.Label{
telemetry.NewLabel("proposal_id", strconv.Itoa(int(msg.ProposalId))), telemetry.NewLabel("proposal_id", strconv.Itoa(int(msg.ProposalId))),
@ -166,7 +164,7 @@ func (k msgServer) VoteWeighted(goCtx context.Context, msg *v1.MsgVoteWeighted)
ctx.EventManager().EmitEvent( ctx.EventManager().EmitEvent(
sdk.NewEvent( sdk.NewEvent(
sdk.EventTypeMessage, sdk.EventTypeMessage,
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), sdk.NewAttribute(sdk.AttributeKeyModule, govtypes.AttributeValueCategory),
sdk.NewAttribute(sdk.AttributeKeySender, msg.Voter), sdk.NewAttribute(sdk.AttributeKeySender, msg.Voter),
), ),
) )
@ -186,7 +184,7 @@ func (k msgServer) Deposit(goCtx context.Context, msg *v1.MsgDeposit) (*v1.MsgDe
} }
defer telemetry.IncrCounterWithLabels( defer telemetry.IncrCounterWithLabels(
[]string{types.ModuleName, "deposit"}, []string{govtypes.ModuleName, "deposit"},
1, 1,
[]metrics.Label{ []metrics.Label{
telemetry.NewLabel("proposal_id", strconv.Itoa(int(msg.ProposalId))), telemetry.NewLabel("proposal_id", strconv.Itoa(int(msg.ProposalId))),
@ -196,7 +194,7 @@ func (k msgServer) Deposit(goCtx context.Context, msg *v1.MsgDeposit) (*v1.MsgDe
ctx.EventManager().EmitEvent( ctx.EventManager().EmitEvent(
sdk.NewEvent( sdk.NewEvent(
sdk.EventTypeMessage, sdk.EventTypeMessage,
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory), sdk.NewAttribute(sdk.AttributeKeyModule, govtypes.AttributeValueCategory),
sdk.NewAttribute(sdk.AttributeKeySender, msg.Depositor), sdk.NewAttribute(sdk.AttributeKeySender, msg.Depositor),
), ),
) )
@ -204,8 +202,8 @@ func (k msgServer) Deposit(goCtx context.Context, msg *v1.MsgDeposit) (*v1.MsgDe
if votingStarted { if votingStarted {
ctx.EventManager().EmitEvent( ctx.EventManager().EmitEvent(
sdk.NewEvent( sdk.NewEvent(
types.EventTypeProposalDeposit, govtypes.EventTypeProposalDeposit,
sdk.NewAttribute(types.AttributeKeyVotingPeriodStart, fmt.Sprintf("%d", msg.ProposalId)), sdk.NewAttribute(govtypes.AttributeKeyVotingPeriodStart, fmt.Sprintf("%d", msg.ProposalId)),
), ),
) )
} }

View File

@ -740,7 +740,6 @@ func (suite *KeeperTestSuite) TestLegacyMsgDeposit() {
} }
func (suite *KeeperTestSuite) TestMsgUpdateParams() { func (suite *KeeperTestSuite) TestMsgUpdateParams() {
authority := suite.app.GovKeeper.GetAuthority() authority := suite.app.GovKeeper.GetAuthority()
params := v1.DefaultParams() params := v1.DefaultParams()
testCases := []struct { testCases := []struct {
@ -1015,7 +1014,7 @@ func (suite *KeeperTestSuite) TestMsgUpdateParams() {
func (suite *KeeperTestSuite) TestSubmitProposal_InitialDeposit() { func (suite *KeeperTestSuite) TestSubmitProposal_InitialDeposit() {
const meetsDepositValue = baseDepositTestAmount * baseDepositTestPercent / 100 const meetsDepositValue = baseDepositTestAmount * baseDepositTestPercent / 100
var baseDepositRatioDec = sdk.NewDec(baseDepositTestPercent).Quo(sdk.NewDec(100)) baseDepositRatioDec := sdk.NewDec(baseDepositTestPercent).Quo(sdk.NewDec(100))
testcases := map[string]struct { testcases := map[string]struct {
minDeposit sdk.Coins minDeposit sdk.Coins

Some files were not shown because too many files have changed in this diff Show More