Skip to content

Commit

Permalink
exclude spaces or dashes when matching network names (#1004)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tofel authored Jun 20, 2024
1 parent 8a452b6 commit 1b37b28
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion utils/seth/seth.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package seth

import (
"fmt"
"regexp"
"strings"

"github.com/pkg/errors"
Expand Down Expand Up @@ -170,7 +171,7 @@ func MergeSethAndEvmNetworkConfigs(evmNetwork blockchain.EVMNetwork, sethConfig
// Merge all other simulated Geth networks
sethNetwork = mergeSimulatedNetworks(evmNetwork, *conf)
break
} else if strings.EqualFold(conf.Name, fmt.Sprint(evmNetwork.Name)) {
} else if isSameNetwork(conf, evmNetwork) {
conf.PrivateKeys = evmNetwork.PrivateKeys
if len(conf.URLs) == 0 {
conf.URLs = evmNetwork.URLs
Expand Down Expand Up @@ -286,3 +287,15 @@ func AvailableSethKeyNum(client *pkg_seth.Client) int {
}
return RootKeyNum
}

func isSameNetwork(conf *pkg_seth.Network, network blockchain.EVMNetwork) bool {
if strings.EqualFold(conf.Name, fmt.Sprint(network.Name)) {
return true
}

re := regexp.MustCompile(`[\s-]+`)
cleanSethName := re.ReplaceAllString(conf.Name, "_")
cleanNetworkName := re.ReplaceAllString(fmt.Sprint(network.Name), "_")

return strings.EqualFold(cleanSethName, cleanNetworkName)
}

0 comments on commit 1b37b28

Please sign in to comment.