Skip to content

Commit

Permalink
refactor: use len check instead of nil check in multisignature (cosmo…
Browse files Browse the repository at this point in the history
  • Loading branch information
julienrbrt authored Jan 17, 2023
1 parent 067f759 commit 2c1853b
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions crypto/types/multisig/multisignature.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package multisig

import (
"errors"
"fmt"
"strings"

Expand Down Expand Up @@ -63,13 +64,19 @@ func AddSignatureFromPubKey(mSig *signing.MultiSignatureData, sig signing.Signat
if mSig == nil {
return fmt.Errorf("value of mSig is nil %v", mSig)
}

if sig == nil {
return fmt.Errorf("value of sig is nil %v", sig)
}

if pubkey == nil || keys == nil {
return fmt.Errorf("pubkey or keys can't be nil %v %v", pubkey, keys)
if pubkey == nil {
return fmt.Errorf("pubkey can't be nil %v", pubkey)
}

if len(keys) == 0 {
return errors.New("keys can't be empty")
}

index := getIndex(pubkey, keys)
if index == -1 {
keysStr := make([]string, len(keys))
Expand Down

0 comments on commit 2c1853b

Please sign in to comment.