From 86178412967d8220238ba79ede821128a06e814e Mon Sep 17 00:00:00 2001 From: rigel rozanski Date: Wed, 19 Jul 2017 01:23:13 -0400 Subject: [PATCH] errors cleanup --- Makefile | 2 +- errors/common.go | 76 ++++------------------------------ errors/common_test.go | 8 ---- modules/auth/errors.go | 30 ++++++++++++++ modules/auth/errors_test.go | 29 +++++++++++++ modules/auth/tx.go | 6 +-- modules/base/chain.go | 7 ++-- modules/base/errors.go | 40 ++++++++++++++++++ modules/base/errors_test.go | 45 ++++++++++++++++++++ modules/base/tx.go | 4 +- modules/coin/commands/query.go | 6 +-- modules/coin/commands/tx.go | 6 +-- modules/coin/errors.go | 24 +++++++---- modules/coin/handler.go | 2 +- modules/fee/errors.go | 8 ++-- modules/nonce/errors.go | 19 ++++++--- modules/nonce/tx.go | 5 +-- modules/roles/error.go | 16 +++---- 18 files changed, 214 insertions(+), 119 deletions(-) create mode 100644 modules/auth/errors.go create mode 100644 modules/auth/errors_test.go create mode 100644 modules/base/errors.go create mode 100644 modules/base/errors_test.go diff --git a/Makefile b/Makefile index aaee262c3c..66e51f817d 100644 --- a/Makefile +++ b/Makefile @@ -29,7 +29,7 @@ test_unit: test_cli: tests/cli/shunit2 # sudo apt-get install jq ./tests/cli/keys.sh - #./tests/cli/rpc.sh + ./tests/cli/rpc.sh ./tests/cli/init.sh ./tests/cli/basictx.sh ./tests/cli/counter.sh diff --git a/errors/common.go b/errors/common.go index 1ef42177f9..f4fd66debf 100644 --- a/errors/common.go +++ b/errors/common.go @@ -5,27 +5,17 @@ import ( "fmt" "reflect" - "github.com/pkg/errors" - abci "github.com/tendermint/abci/types" ) var ( - errDecoding = fmt.Errorf("Error decoding input") - errUnauthorized = fmt.Errorf("Unauthorized") - errInvalidSignature = fmt.Errorf("Invalid Signature") - errTooLarge = fmt.Errorf("Input size too large") - errNoSigners = fmt.Errorf("There are no signers") - errMissingSignature = fmt.Errorf("Signature missing") - errTooManySignatures = fmt.Errorf("Too many signatures") - errNoChain = fmt.Errorf("No chain id provided") - errTxEmpty = fmt.Errorf("The provided Tx is empty") - errWrongChain = fmt.Errorf("Wrong chain for tx") - errUnknownTxType = fmt.Errorf("Tx type unknown") - errInvalidFormat = fmt.Errorf("Invalid format") - errUnknownModule = fmt.Errorf("Unknown module") - errExpired = fmt.Errorf("Tx expired") - errUnknownKey = fmt.Errorf("Unknown key") + errDecoding = fmt.Errorf("Error decoding input") + errUnauthorized = fmt.Errorf("Unauthorized") + errTooLarge = fmt.Errorf("Input size too large") + errMissingSignature = fmt.Errorf("Signature missing") + errUnknownTxType = fmt.Errorf("Tx type unknown") + errInvalidFormat = fmt.Errorf("Invalid format") + errUnknownModule = fmt.Errorf("Unknown module") internalErr = abci.CodeType_InternalError encodingErr = abci.CodeType_EncodingError @@ -70,14 +60,6 @@ func IsUnknownModuleErr(err error) bool { return IsSameError(errUnknownModule, err) } -func ErrUnknownKey(mod string) TMError { - w := errors.Wrap(errUnknownKey, mod) - return WithCode(w, abci.CodeType_UnknownRequest) -} -func IsUnknownKeyErr(err error) bool { - return IsSameError(errUnknownKey, err) -} - func ErrInternal(msg string) TMError { return New(msg, internalErr) } @@ -104,10 +86,6 @@ func IsUnauthorizedErr(err error) bool { return HasErrorCode(err, unauthorized) } -func ErrNoSigners() TMError { - return WithCode(errNoSigners, unauthorized) -} - func ErrMissingSignature() TMError { return WithCode(errMissingSignature, unauthorized) } @@ -115,49 +93,9 @@ func IsMissingSignatureErr(err error) bool { return IsSameError(errMissingSignature, err) } -func ErrTooManySignatures() TMError { - return WithCode(errTooManySignatures, unauthorized) -} -func IsTooManySignaturesErr(err error) bool { - return IsSameError(errTooManySignatures, err) -} - -func ErrInvalidSignature() TMError { - return WithCode(errInvalidSignature, unauthorized) -} -func IsInvalidSignatureErr(err error) bool { - return IsSameError(errInvalidSignature, err) -} - -func ErrNoChain() TMError { - return WithCode(errNoChain, unauthorized) -} -func IsNoChainErr(err error) bool { - return IsSameError(errNoChain, err) -} - -func ErrTxEmpty() TMError { - return WithCode(errTxEmpty, unauthorized) -} - -func ErrWrongChain(chain string) TMError { - msg := errors.Wrap(errWrongChain, chain) - return WithCode(msg, unauthorized) -} -func IsWrongChainErr(err error) bool { - return IsSameError(errWrongChain, err) -} - func ErrTooLarge() TMError { return WithCode(errTooLarge, encodingErr) } func IsTooLargeErr(err error) bool { return IsSameError(errTooLarge, err) } - -func ErrExpired() TMError { - return WithCode(errExpired, unauthorized) -} -func IsExpiredErr(err error) bool { - return IsSameError(errExpired, err) -} diff --git a/errors/common_test.go b/errors/common_test.go index 59d5fc6268..f16933df4d 100644 --- a/errors/common_test.go +++ b/errors/common_test.go @@ -42,7 +42,6 @@ func TestErrorMatches(t *testing.T) { {errUnauthorized, ErrUnauthorized(), true}, {errMissingSignature, ErrUnauthorized(), false}, {errMissingSignature, ErrMissingSignature(), true}, - {errWrongChain, ErrWrongChain("hakz"), true}, {errUnknownTxType, ErrUnknownTxType(holder{}), true}, {errUnknownTxType, ErrUnknownTxType("some text here..."), true}, {errUnknownTxType, ErrUnknownTxType(demoTx{5}.Wrap()), true}, @@ -66,13 +65,6 @@ func TestChecks(t *testing.T) { {ErrDecoding(), IsDecodingErr, true}, {ErrUnauthorized(), IsDecodingErr, false}, {ErrUnauthorized(), IsUnauthorizedErr, true}, - {ErrInvalidSignature(), IsInvalidSignatureErr, true}, - // unauthorized includes InvalidSignature, but not visa versa - {ErrInvalidSignature(), IsUnauthorizedErr, true}, - {ErrUnauthorized(), IsInvalidSignatureErr, false}, - // make sure WrongChain works properly - {ErrWrongChain("fooz"), IsUnauthorizedErr, true}, - {ErrWrongChain("barz"), IsWrongChainErr, true}, // make sure lots of things match InternalErr, but not everything {ErrInternal("bad db connection"), IsInternalErr, true}, {Wrap(errors.New("wrapped")), IsInternalErr, true}, diff --git a/modules/auth/errors.go b/modules/auth/errors.go new file mode 100644 index 0000000000..8de87b20f2 --- /dev/null +++ b/modules/auth/errors.go @@ -0,0 +1,30 @@ +//nolint +package auth + +import ( + "fmt" + + abci "github.com/tendermint/abci/types" + "github.com/tendermint/basecoin/errors" +) + +var ( + errInvalidSignature = fmt.Errorf("Invalid Signature") //move auth + errTooManySignatures = fmt.Errorf("Too many signatures") //move auth + + unauthorized = abci.CodeType_Unauthorized +) + +func ErrTooManySignatures() errors.TMError { + return errors.WithCode(errTooManySignatures, unauthorized) +} +func IsTooManySignaturesErr(err error) bool { + return errors.IsSameError(errTooManySignatures, err) +} + +func ErrInvalidSignature() errors.TMError { + return errors.WithCode(errInvalidSignature, unauthorized) +} +func IsInvalidSignatureErr(err error) bool { + return errors.IsSameError(errInvalidSignature, err) +} diff --git a/modules/auth/errors_test.go b/modules/auth/errors_test.go new file mode 100644 index 0000000000..887eae1e5c --- /dev/null +++ b/modules/auth/errors_test.go @@ -0,0 +1,29 @@ +package auth + +import ( + "testing" + + "github.com/stretchr/testify/assert" + + "github.com/tendermint/basecoin/errors" +) + +func TestChecks(t *testing.T) { + // TODO: make sure the Is and Err methods match + assert := assert.New(t) + + cases := []struct { + err error + check func(error) bool + match bool + }{ + // unauthorized includes InvalidSignature, but not visa versa + {ErrInvalidSignature(), IsInvalidSignatureErr, true}, + {ErrInvalidSignature(), errors.IsUnauthorizedErr, true}, + } + + for i, tc := range cases { + match := tc.check(tc.err) + assert.Equal(tc.match, match, "%d", i) + } +} diff --git a/modules/auth/tx.go b/modules/auth/tx.go index 26e2b94b68..970f321dc5 100644 --- a/modules/auth/tx.go +++ b/modules/auth/tx.go @@ -106,7 +106,7 @@ func (s *OneSig) Sign(pubkey crypto.PubKey, sig crypto.Signature) error { return errors.ErrMissingSignature() } if !s.Empty() { - return errors.ErrTooManySignatures() + return ErrTooManySignatures() } // set the value once we are happy s.Signed = signed @@ -121,7 +121,7 @@ func (s *OneSig) Signers() ([]crypto.PubKey, error) { return nil, errors.ErrMissingSignature() } if !s.Pubkey.VerifyBytes(s.SignBytes(), s.Sig) { - return nil, errors.ErrInvalidSignature() + return nil, ErrInvalidSignature() } return []crypto.PubKey{s.Pubkey}, nil } @@ -194,7 +194,7 @@ func (s *MultiSig) Signers() ([]crypto.PubKey, error) { for i := range s.Sigs { ms := s.Sigs[i] if !ms.Pubkey.VerifyBytes(data, ms.Sig) { - return nil, errors.ErrInvalidSignature() + return nil, ErrInvalidSignature() } keys[i] = ms.Pubkey } diff --git a/modules/base/chain.go b/modules/base/chain.go index 65513679de..9dc704c362 100644 --- a/modules/base/chain.go +++ b/modules/base/chain.go @@ -2,7 +2,6 @@ package base import ( "github.com/tendermint/basecoin" - "github.com/tendermint/basecoin/errors" "github.com/tendermint/basecoin/stack" "github.com/tendermint/basecoin/state" ) @@ -48,7 +47,7 @@ func (c Chain) checkChainTx(chainID string, height uint64, tx basecoin.Tx) (base // make sure it is a chaintx ctx, ok := tx.Unwrap().(ChainTx) if !ok { - return tx, errors.ErrNoChain() + return tx, ErrNoChain() } // basic validation @@ -59,10 +58,10 @@ func (c Chain) checkChainTx(chainID string, height uint64, tx basecoin.Tx) (base // compare against state if ctx.ChainID != chainID { - return tx, errors.ErrWrongChain(ctx.ChainID) + return tx, ErrWrongChain(ctx.ChainID) } if ctx.ExpiresAt != 0 && ctx.ExpiresAt <= height { - return tx, errors.ErrExpired() + return tx, ErrExpired() } return ctx.Tx, nil } diff --git a/modules/base/errors.go b/modules/base/errors.go new file mode 100644 index 0000000000..bd55b1ffea --- /dev/null +++ b/modules/base/errors.go @@ -0,0 +1,40 @@ +//nolint +package base + +import ( + "fmt" + + pkgerrors "github.com/pkg/errors" + + abci "github.com/tendermint/abci/types" + "github.com/tendermint/basecoin/errors" +) + +var ( + errNoChain = fmt.Errorf("No chain id provided") //move base + errWrongChain = fmt.Errorf("Wrong chain for tx") //move base + errExpired = fmt.Errorf("Tx expired") //move base + + unauthorized = abci.CodeType_Unauthorized +) + +func ErrNoChain() errors.TMError { + return errors.WithCode(errNoChain, unauthorized) +} +func IsNoChainErr(err error) bool { + return errors.IsSameError(errNoChain, err) +} +func ErrWrongChain(chain string) errors.TMError { + msg := pkgerrors.Wrap(errWrongChain, chain) + return errors.WithCode(msg, unauthorized) +} +func IsWrongChainErr(err error) bool { + return errors.IsSameError(errWrongChain, err) +} + +func ErrExpired() errors.TMError { + return errors.WithCode(errExpired, unauthorized) +} +func IsExpiredErr(err error) bool { + return errors.IsSameError(errExpired, err) +} diff --git a/modules/base/errors_test.go b/modules/base/errors_test.go new file mode 100644 index 0000000000..64fda60f84 --- /dev/null +++ b/modules/base/errors_test.go @@ -0,0 +1,45 @@ +package base + +import ( + "testing" + + "github.com/stretchr/testify/assert" + + "github.com/tendermint/basecoin/errors" +) + +func TestErrorMatches(t *testing.T) { + assert := assert.New(t) + + cases := []struct { + pattern, err error + match bool + }{ + {errWrongChain, ErrWrongChain("hakz"), true}, + } + + for i, tc := range cases { + same := errors.IsSameError(tc.pattern, tc.err) + assert.Equal(tc.match, same, "%d: %#v / %#v", i, tc.pattern, tc.err) + } +} + +func TestChecks(t *testing.T) { + // TODO: make sure the Is and Err methods match + assert := assert.New(t) + + cases := []struct { + err error + check func(error) bool + match bool + }{ + // make sure WrongChain works properly + {ErrWrongChain("fooz"), errors.IsUnauthorizedErr, true}, + {ErrWrongChain("barz"), IsWrongChainErr, true}, + } + + for i, tc := range cases { + match := tc.check(tc.err) + assert.Equal(tc.match, match, "%d", i) + } +} diff --git a/modules/base/tx.go b/modules/base/tx.go index fd66fad884..d365c1b7b8 100644 --- a/modules/base/tx.go +++ b/modules/base/tx.go @@ -86,10 +86,10 @@ func (c ChainTx) Wrap() basecoin.Tx { } func (c ChainTx) ValidateBasic() error { if c.ChainID == "" { - return errors.ErrNoChain() + return ErrNoChain() } if !chainPattern.MatchString(c.ChainID) { - return errors.ErrWrongChain(c.ChainID) + return ErrWrongChain(c.ChainID) } if c.Tx.Empty() { return errors.ErrUnknownTxType(c.Tx) diff --git a/modules/coin/commands/query.go b/modules/coin/commands/query.go index 8f5ef70409..55e7a060ff 100644 --- a/modules/coin/commands/query.go +++ b/modules/coin/commands/query.go @@ -4,9 +4,9 @@ import ( "github.com/pkg/errors" "github.com/spf13/cobra" - lc "github.com/tendermint/light-client" lcmd "github.com/tendermint/basecoin/client/commands" proofcmd "github.com/tendermint/basecoin/client/commands/proofs" + lc "github.com/tendermint/light-client" "github.com/tendermint/basecoin/modules/auth" "github.com/tendermint/basecoin/modules/coin" @@ -17,10 +17,10 @@ import ( var AccountQueryCmd = &cobra.Command{ Use: "account [address]", Short: "Get details of an account, with proof", - RunE: lcmd.RequireInit(doAccountQuery), + RunE: lcmd.RequireInit(accountQueryCmd), } -func doAccountQuery(cmd *cobra.Command, args []string) error { +func accountQueryCmd(cmd *cobra.Command, args []string) error { addr, err := proofcmd.ParseHexKey(args, "address") if err != nil { return err diff --git a/modules/coin/commands/tx.go b/modules/coin/commands/tx.go index 9a338582c3..c817c57b69 100644 --- a/modules/coin/commands/tx.go +++ b/modules/coin/commands/tx.go @@ -14,7 +14,7 @@ import ( var SendTxCmd = &cobra.Command{ Use: "send", Short: "send tokens from one account to another", - RunE: commands.RequireInit(doSendTx), + RunE: commands.RequireInit(sendTxCmd), } //nolint @@ -31,8 +31,8 @@ func init() { flags.String(FlagFrom, "", "Address sending coins, if not first signer") } -// doSendTx is an example of how to make a tx -func doSendTx(cmd *cobra.Command, args []string) error { +// sendTxCmd is an example of how to make a tx +func sendTxCmd(cmd *cobra.Command, args []string) error { // load data from json or flags // var tx basecoin.Tx // found, err := txcmd.LoadJSON(&tx) diff --git a/modules/coin/errors.go b/modules/coin/errors.go index 0bf3bde9e7..1f045adbbb 100644 --- a/modules/coin/errors.go +++ b/modules/coin/errors.go @@ -4,23 +4,25 @@ package coin import ( "fmt" + pkgerrors "github.com/pkg/errors" + abci "github.com/tendermint/abci/types" "github.com/tendermint/basecoin/errors" ) var ( errNoAccount = fmt.Errorf("No such account") - errInsufficientFunds = fmt.Errorf("Insufficient Funds") - errNoInputs = fmt.Errorf("No Input Coins") - errNoOutputs = fmt.Errorf("No Output Coins") - errInvalidAddress = fmt.Errorf("Invalid Address") - errInvalidCoins = fmt.Errorf("Invalid Coins") -) + errInsufficientFunds = fmt.Errorf("Insufficient funds") + errNoInputs = fmt.Errorf("No input coins") + errNoOutputs = fmt.Errorf("No output coins") + errInvalidAddress = fmt.Errorf("Invalid address") + errInvalidCoins = fmt.Errorf("Invalid coins") + errUnknownKey = fmt.Errorf("Unknown key") -var ( invalidInput = abci.CodeType_BaseInvalidInput invalidOutput = abci.CodeType_BaseInvalidOutput unknownAddress = abci.CodeType_BaseUnknownAddress + unknownRequest = abci.CodeType_UnknownRequest ) // here are some generic handlers to grab classes of errors based on code @@ -79,3 +81,11 @@ func ErrNoOutputs() errors.TMError { func IsNoOutputsErr(err error) bool { return errors.IsSameError(errNoOutputs, err) } + +func ErrUnknownKey(mod string) errors.TMError { + w := pkgerrors.Wrap(errUnknownKey, mod) + return errors.WithCode(w, unknownRequest) +} +func IsUnknownKeyErr(err error) bool { + return errors.IsSameError(errUnknownKey, err) +} diff --git a/modules/coin/handler.go b/modules/coin/handler.go index 0e3378db70..ef3f3ae0f6 100644 --- a/modules/coin/handler.go +++ b/modules/coin/handler.go @@ -99,7 +99,7 @@ func (h Handler) SetOption(l log.Logger, store state.KVStore, module, key, value return "Success", nil } - return "", errors.ErrUnknownKey(key) + return "", ErrUnknownKey(key) } func checkTx(ctx basecoin.Context, tx basecoin.Tx) (send SendTx, err error) { diff --git a/modules/fee/errors.go b/modules/fee/errors.go index 06cdd10c5c..5edc847864 100644 --- a/modules/fee/errors.go +++ b/modules/fee/errors.go @@ -10,19 +10,21 @@ import ( ) var ( - errInsufficientFees = fmt.Errorf("Insufficient Fees") + errInsufficientFees = fmt.Errorf("Insufficient fees") errWrongFeeDenom = fmt.Errorf("Required fee denomination") + + invalidInput = abci.CodeType_BaseInvalidInput ) func ErrInsufficientFees() errors.TMError { - return errors.WithCode(errInsufficientFees, abci.CodeType_BaseInvalidInput) + return errors.WithCode(errInsufficientFees, invalidInput) } func IsInsufficientFeesErr(err error) bool { return errors.IsSameError(errInsufficientFees, err) } func ErrWrongFeeDenom(denom string) errors.TMError { - return errors.WithMessage(denom, errWrongFeeDenom, abci.CodeType_BaseInvalidInput) + return errors.WithMessage(denom, errWrongFeeDenom, invalidInput) } func IsWrongFeeDenomErr(err error) bool { return errors.IsSameError(errWrongFeeDenom, err) diff --git a/modules/nonce/errors.go b/modules/nonce/errors.go index f88629b457..832ea8ce2e 100644 --- a/modules/nonce/errors.go +++ b/modules/nonce/errors.go @@ -11,22 +11,31 @@ import ( var ( errNoNonce = fmt.Errorf("Tx doesn't contain nonce") - errNotMember = fmt.Errorf("nonce contains non-permissioned member") + errNotMember = fmt.Errorf("Nonce contains non-permissioned member") errZeroSequence = fmt.Errorf("Sequence number cannot be zero") + errNoSigners = fmt.Errorf("There are no signers") + errTxEmpty = fmt.Errorf("The provided Tx is empty") unauthorized = abci.CodeType_Unauthorized + badNonce = abci.CodeType_BadNonce + invalidInput = abci.CodeType_BaseInvalidInput ) func ErrBadNonce(got, expected uint32) errors.TMError { - return errors.WithCode(fmt.Errorf("Bad nonce sequence, got %d, expected %d", got, expected), unauthorized) + return errors.WithCode(fmt.Errorf("Bad nonce sequence, got %d, expected %d", got, expected), badNonce) } - func ErrNoNonce() errors.TMError { - return errors.WithCode(errNoNonce, unauthorized) + return errors.WithCode(errNoNonce, badNonce) } func ErrNotMember() errors.TMError { return errors.WithCode(errNotMember, unauthorized) } func ErrZeroSequence() errors.TMError { - return errors.WithCode(errZeroSequence, unauthorized) + return errors.WithCode(errZeroSequence, invalidInput) +} +func ErrNoSigners() errors.TMError { + return errors.WithCode(errNoSigners, invalidInput) +} +func ErrTxEmpty() errors.TMError { + return errors.WithCode(errTxEmpty, invalidInput) } diff --git a/modules/nonce/tx.go b/modules/nonce/tx.go index 7a70878b2d..6fb5ce7fd2 100644 --- a/modules/nonce/tx.go +++ b/modules/nonce/tx.go @@ -11,7 +11,6 @@ import ( "sort" "github.com/tendermint/basecoin" - "github.com/tendermint/basecoin/errors" "github.com/tendermint/basecoin/state" ) @@ -50,11 +49,11 @@ func (n Tx) Wrap() basecoin.Tx { func (n Tx) ValidateBasic() error { switch { case n.Tx.Empty(): - return errors.ErrTxEmpty() + return ErrTxEmpty() case n.Sequence == 0: return ErrZeroSequence() case len(n.Signers) == 0: - return errors.ErrNoSigners() + return ErrNoSigners() } return n.Tx.ValidateBasic() } diff --git a/modules/roles/error.go b/modules/roles/error.go index 1fb8333a27..02b9e0637a 100644 --- a/modules/roles/error.go +++ b/modules/roles/error.go @@ -16,54 +16,56 @@ var ( errNoMembers = fmt.Errorf("No members specified") errTooManyMembers = fmt.Errorf("Too many members specified") errNotEnoughMembers = fmt.Errorf("Not enough members specified") + + unauthorized = abci.CodeType_Unauthorized ) // TODO: codegen? // ex: err-gen NoRole,"No such role",CodeType_Unauthorized func ErrNoRole() errors.TMError { - return errors.WithCode(errNoRole, abci.CodeType_Unauthorized) + return errors.WithCode(errNoRole, unauthorized) } func IsNoRoleErr(err error) bool { return errors.IsSameError(errNoRole, err) } func ErrRoleExists() errors.TMError { - return errors.WithCode(errRoleExists, abci.CodeType_Unauthorized) + return errors.WithCode(errRoleExists, unauthorized) } func IsRoleExistsErr(err error) bool { return errors.IsSameError(errRoleExists, err) } func ErrNotMember() errors.TMError { - return errors.WithCode(errNotMember, abci.CodeType_Unauthorized) + return errors.WithCode(errNotMember, unauthorized) } func IsNotMemberErr(err error) bool { return errors.IsSameError(errNotMember, err) } func ErrInsufficientSigs() errors.TMError { - return errors.WithCode(errInsufficientSigs, abci.CodeType_Unauthorized) + return errors.WithCode(errInsufficientSigs, unauthorized) } func IsInsufficientSigsErr(err error) bool { return errors.IsSameError(errInsufficientSigs, err) } func ErrNoMembers() errors.TMError { - return errors.WithCode(errNoMembers, abci.CodeType_Unauthorized) + return errors.WithCode(errNoMembers, unauthorized) } func IsNoMembersErr(err error) bool { return errors.IsSameError(errNoMembers, err) } func ErrTooManyMembers() errors.TMError { - return errors.WithCode(errTooManyMembers, abci.CodeType_Unauthorized) + return errors.WithCode(errTooManyMembers, unauthorized) } func IsTooManyMembersErr(err error) bool { return errors.IsSameError(errTooManyMembers, err) } func ErrNotEnoughMembers() errors.TMError { - return errors.WithCode(errNotEnoughMembers, abci.CodeType_Unauthorized) + return errors.WithCode(errNotEnoughMembers, unauthorized) } func IsNotEnoughMembersErr(err error) bool { return errors.IsSameError(errNotEnoughMembers, err)