diff --git a/clientcontroller/babylon.go b/clientcontroller/babylon.go index 2b7efaa..57be717 100644 --- a/clientcontroller/babylon.go +++ b/clientcontroller/babylon.go @@ -2,6 +2,7 @@ package clientcontroller import ( "context" + "errors" "fmt" "math" "time" @@ -108,7 +109,7 @@ func (bc *BabylonController) QueryStakingParamsByVersion(version uint32) (*types for _, pk := range stakingParamRes.Params.CovenantPks { covPk, err := pk.ToBTCPK() if err != nil { - return nil, fmt.Errorf("invalid covenant public key") + return nil, errors.New("invalid covenant public key") } covenantPks = append(covenantPks, covPk) } @@ -242,11 +243,11 @@ func DelegationRespToDelegation(del *btcstakingtypes.BTCDelegationResponse) (*ty ) if del.StakingTxHex == "" { - return nil, fmt.Errorf("staking tx should not be empty in delegation") + return nil, errors.New("staking tx should not be empty in delegation") } if del.SlashingTxHex == "" { - return nil, fmt.Errorf("slashing tx should not be empty in delegation") + return nil, errors.New("slashing tx should not be empty in delegation") } for _, s := range del.CovenantSigs { @@ -270,7 +271,7 @@ func DelegationRespToDelegation(del *btcstakingtypes.BTCDelegationResponse) (*ty } if del.UnbondingTime > uint32(math.MaxUint16) { - return nil, fmt.Errorf("unbonding time should be smaller than max uint16") + return nil, errors.New("unbonding time should be smaller than max uint16") } if del.TotalSat > uint64(math.MaxInt64) { @@ -301,11 +302,11 @@ func UndelegationRespToUndelegation(undel *btcstakingtypes.BTCUndelegationRespon ) if undel.UnbondingTxHex == "" { - return nil, fmt.Errorf("staking tx should not be empty in undelegation") + return nil, errors.New("staking tx should not be empty in undelegation") } if undel.SlashingTxHex == "" { - return nil, fmt.Errorf("slashing tx should not be empty in undelegation") + return nil, errors.New("slashing tx should not be empty in undelegation") } for _, unbondingSig := range undel.CovenantUnbondingSigList { diff --git a/config/config.go b/config/config.go index dc57336..5d46d37 100644 --- a/config/config.go +++ b/config/config.go @@ -1,6 +1,7 @@ package config import ( + "errors" "fmt" "path/filepath" "time" @@ -90,11 +91,11 @@ func LoadConfig(homePath string) (*Config, error) { // normalized. The cleaned up config is returned on success. func (cfg *Config) Validate() error { if cfg.Metrics == nil { - return fmt.Errorf("empty metrics config") + return errors.New("empty metrics config") } if err := cfg.Metrics.Validate(); err != nil { - return fmt.Errorf("invalid metrics config") + return errors.New("invalid metrics config") } switch cfg.BitcoinNetwork { diff --git a/covenant-signer/cmd/signerCmd.go b/covenant-signer/cmd/signerCmd.go index db8922d..acbc2b5 100644 --- a/covenant-signer/cmd/signerCmd.go +++ b/covenant-signer/cmd/signerCmd.go @@ -43,7 +43,7 @@ var runSignerCmd = &cobra.Command{ } prk = kr } else { - return fmt.Errorf("unknown key store type") + return errors.New("unknown key store type") } app := signerapp.NewSignerApp( diff --git a/covenant-signer/config/keystore.go b/covenant-signer/config/keystore.go index 12c8d65..86d97fb 100644 --- a/covenant-signer/config/keystore.go +++ b/covenant-signer/config/keystore.go @@ -1,6 +1,8 @@ package config -import "fmt" +import ( + "errors" +) type KeyStoreType int @@ -13,7 +15,7 @@ func KeyStoreToString(c KeyStoreType) (string, error) { case CosmosKeyStore: return "cosmos", nil default: - return "", fmt.Errorf("unknown key store type") + return "", errors.New("unknown key store type") } } @@ -22,7 +24,7 @@ func KeyStoreFromString(s string) (KeyStoreType, error) { case "cosmos": return CosmosKeyStore, nil default: - return -1, fmt.Errorf("unknown key store type") + return -1, errors.New("unknown key store type") } } diff --git a/covenant-signer/keystore/cosmos/cosmoskeyretriever.go b/covenant-signer/keystore/cosmos/cosmoskeyretriever.go index cb2f3e7..efef11f 100644 --- a/covenant-signer/keystore/cosmos/cosmoskeyretriever.go +++ b/covenant-signer/keystore/cosmos/cosmoskeyretriever.go @@ -2,6 +2,7 @@ package cosmos import ( "context" + "errors" "fmt" "strings" "sync" @@ -41,7 +42,7 @@ func (k *CosmosKeyringRetriever) PrivKey(ctx context.Context) (*btcec.PrivateKey defer k.mu.Unlock() if k.btcecPrivKey == nil { - return nil, fmt.Errorf("private key is not unlocked. Please call Unlock() first") + return nil, errors.New("private key is not unlocked. Please call Unlock() first") } return k.btcecPrivKey, nil