chore: Db linting (#12141)

* mainly sdk.int to cosmossdk.io/math

* staking keys

* fumpt

* var-naming linter errors and a fumpt

* Update CHANGELOG.md

* Update .golangci.yml

* Update CHANGELOG.md

* Update test_helpers.go

* Update test_helpers.go

* fumpt and lint

* this lints the db module, and makes it easier to use.  It adds breaking name changes

* DBConnection -> Connection

* previous commit contained a merge error

* Update test_helpers.go

* Update test_helpers.go

* db renamings

* merge master

* changelog

* DBWriter -> Writer

* consistent multistore reciever

* standard recievers for multistore v2alpha1

* general cleanup of linting issues

* more linter fixes

* remove prealloc linter

* nolint the secp256k1 import

* nolint the secp256k1 package

* completenolint resulting in a diff that has only nolints
This commit is contained in:
Jacob Gadikian
2022-06-08 19:02:01 +02:00
committed by GitHub
parent 9e6607172b
commit b0e82f9640
75 changed files with 440 additions and 477 deletions
+15 -12
View File
@@ -17,10 +17,13 @@ import (
"github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/version"
legacybech32 "github.com/cosmos/cosmos-sdk/types/bech32/legacybech32"
legacybech32 "github.com/cosmos/cosmos-sdk/types/bech32/legacybech32" //nolint:staticcheck // we do old keys, they're keys after all.
)
var flagPubkeyType = "type"
var (
flagPubkeyType = "type"
ed = "ed25519"
)
// Cmd creates a main CLI command
func Cmd() *cobra.Command {
@@ -69,7 +72,7 @@ $ %s debug pubkey '{"@type":"/cosmos.crypto.secp256k1.PubKey","key":"AurroA7jvfP
}
func bytesToPubkey(bz []byte, keytype string) (cryptotypes.PubKey, bool) {
if keytype == "ed25519" {
if keytype == ed {
if len(bz) == ed25519.PubKeySize {
return &ed25519.PubKey{Key: bz}, true
}
@@ -102,17 +105,17 @@ func getPubKeyFromRawString(pkstr string, keytype string) (cryptotypes.PubKey, e
}
}
pk, err := legacybech32.UnmarshalPubKey(legacybech32.AccPK, pkstr)
pk, err := legacybech32.UnmarshalPubKey(legacybech32.AccPK, pkstr) //nolint:staticcheck // we do old keys, they're keys after all.
if err == nil {
return pk, nil
}
pk, err = legacybech32.UnmarshalPubKey(legacybech32.ValPK, pkstr)
pk, err = legacybech32.UnmarshalPubKey(legacybech32.ValPK, pkstr) //nolint:staticcheck // we do old keys, they're keys after all.
if err == nil {
return pk, nil
}
pk, err = legacybech32.UnmarshalPubKey(legacybech32.ConsPK, pkstr)
pk, err = legacybech32.UnmarshalPubKey(legacybech32.ConsPK, pkstr) //nolint:staticcheck // we do old keys, they're keys after all.
if err == nil {
return pk, nil
}
@@ -138,7 +141,7 @@ $ %s debug pubkey-raw cosmos1e0jnq2sun3dzjh8p2xq95kk0expwmd7shwjpfg
return err
}
pubkeyType = strings.ToLower(pubkeyType)
if pubkeyType != "secp256k1" && pubkeyType != "ed25519" {
if pubkeyType != "secp256k1" && pubkeyType != ed {
return errors.Wrapf(errors.ErrInvalidType, "invalid pubkey type, expected oneof ed25519 or secp256k1")
}
@@ -149,8 +152,8 @@ $ %s debug pubkey-raw cosmos1e0jnq2sun3dzjh8p2xq95kk0expwmd7shwjpfg
var consensusPub string
edPK, ok := pk.(*ed25519.PubKey)
if ok && pubkeyType == "ed25519" {
consensusPub, err = legacybech32.MarshalPubKey(legacybech32.ConsPK, edPK)
if ok && pubkeyType == ed {
consensusPub, err = legacybech32.MarshalPubKey(legacybech32.ConsPK, edPK) //nolint:staticcheck // we do old keys, they're keys after all.
if err != nil {
return err
}
@@ -163,11 +166,11 @@ $ %s debug pubkey-raw cosmos1e0jnq2sun3dzjh8p2xq95kk0expwmd7shwjpfg
if err != nil {
return err
}
accPub, err := legacybech32.MarshalPubKey(legacybech32.AccPK, pk)
accPub, err := legacybech32.MarshalPubKey(legacybech32.AccPK, pk) //nolint:staticcheck // we do old keys, they're keys after all.
if err != nil {
return err
}
valPub, err := legacybech32.MarshalPubKey(legacybech32.ValPK, pk)
valPub, err := legacybech32.MarshalPubKey(legacybech32.ValPK, pk) //nolint:staticcheck // we do old keys, they're keys after all.
if err != nil {
return err
}
@@ -182,7 +185,7 @@ $ %s debug pubkey-raw cosmos1e0jnq2sun3dzjh8p2xq95kk0expwmd7shwjpfg
return nil
},
}
cmd.Flags().StringP(flagPubkeyType, "t", "ed25519", "Pubkey type to decode (oneof secp256k1, ed25519)")
cmd.Flags().StringP(flagPubkeyType, "t", ed, "Pubkey type to decode (oneof secp256k1, ed25519)")
return cmd
}