From 7902a0df481c9397db8057c0af513a40af7efaa4 Mon Sep 17 00:00:00 2001 From: sweexordious Date: Mon, 8 Jul 2024 17:04:20 +0100 Subject: [PATCH] chore: lint --- cmd/blobstream-ops/common/utils.go | 5 +---- cmd/blobstream-ops/replay/config.go | 12 +++--------- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/cmd/blobstream-ops/common/utils.go b/cmd/blobstream-ops/common/utils.go index b98abcb..998b799 100644 --- a/cmd/blobstream-ops/common/utils.go +++ b/cmd/blobstream-ops/common/utils.go @@ -51,11 +51,8 @@ func TrapSignal(logger tmlog.Logger, cancel context.CancelFunc) { // Example: if the flag is: `--flag1.flag2-flag3`, then, the environment variable that is looked for // is `FLAG1_FLAG2_FLAG3`. func ToEnvVariableFormat(flag string) string { - if strings.HasPrefix(flag, "--") { - flag = strings.TrimPrefix(flag, "--") - } return strings.ReplaceAll( - strings.ToUpper(strings.ReplaceAll(flag, "-", "_")), + strings.ToUpper(strings.ReplaceAll(strings.TrimPrefix(flag, "--"), "-", "_")), ".", "_", ) diff --git a/cmd/blobstream-ops/replay/config.go b/cmd/blobstream-ops/replay/config.go index 1a6a2b5..e098520 100644 --- a/cmd/blobstream-ops/replay/config.go +++ b/cmd/blobstream-ops/replay/config.go @@ -200,9 +200,7 @@ func parseFlags() (Config, error) { if rawPrivateKey == "" { return Config{}, fmt.Errorf("please set the private key --%s or %s", FlagEVMPrivateKey, common.ToEnvVariableFormat(FlagEVMPrivateKey)) } - if strings.HasPrefix(rawPrivateKey, "0x") { - rawPrivateKey = strings.TrimPrefix(rawPrivateKey, "0x") - } + rawPrivateKey = strings.TrimPrefix(rawPrivateKey, "0x") privateKey, err := crypto.HexToECDSA(rawPrivateKey) if err != nil { return Config{}, fmt.Errorf("failed to hex-decode Ethereum ECDSA Private Key: %w", err) @@ -212,9 +210,7 @@ func parseFlags() (Config, error) { if strHeaderRange == "" { return Config{}, fmt.Errorf("please set the header range function ID --%s or %s", FlagHeaderRangeFunctionID, common.ToEnvVariableFormat(FlagHeaderRangeFunctionID)) } - if strings.HasPrefix(strHeaderRange, "0x") { - strHeaderRange = strings.TrimPrefix(strHeaderRange, "0x") - } + strHeaderRange = strings.TrimPrefix(strHeaderRange, "0x") decodedHeaderRange, err := hex.DecodeString(strHeaderRange) if err != nil { return Config{}, err @@ -226,9 +222,7 @@ func parseFlags() (Config, error) { if strNextHeader == "" { return Config{}, fmt.Errorf("please set the next header function ID --%s or %s", FlagNextHeaderFunctionID, common.ToEnvVariableFormat(FlagNextHeaderFunctionID)) } - if strings.HasPrefix(strNextHeader, "0x") { - strNextHeader = strings.TrimPrefix(strNextHeader, "0x") - } + strNextHeader = strings.TrimPrefix(strNextHeader, "0x") decodedNextHeader, err := hex.DecodeString(strNextHeader) if err != nil { return Config{}, err