Skip to content

Commit

Permalink
chore: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
rach-id committed Jul 8, 2024
1 parent 375cfbd commit 7902a0d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 13 deletions.
5 changes: 1 addition & 4 deletions cmd/blobstream-ops/common/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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, "--"), "-", "_")),
".",
"_",
)
Expand Down
12 changes: 3 additions & 9 deletions cmd/blobstream-ops/replay/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 7902a0d

Please sign in to comment.