Skip to content

Commit

Permalink
Merge pull request #35 from VeerChaurasia/Implement/config/networks.g…
Browse files Browse the repository at this point in the history
…o-#13

Resolved ChainID function
  • Loading branch information
star-gazer111 authored Sep 19, 2024
2 parents fb59b2e + 545ebb5 commit 39ea4bc
Showing 1 changed file with 23 additions and 10 deletions.
33 changes: 23 additions & 10 deletions config/networks.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,29 @@ func (n Network) baseConfig(s string) (BaseConfig, error) {
return BaseConfig{}, errors.New("network not recognized")
}
}
func (n Network) chainID(s string) (uint64, error) {
switch strings.ToUpper(s) {
case "MAINNET":
return 1, nil
case "GOERLI":
return 5, nil
case "SEPOLIA":
return 11155111, nil
func (n Network) chainID (id uint64) (BaseConfig, error) {
switch id {
case 1:
config, err := Mainnet()
if err != nil {
return BaseConfig{}, err
}
return config, nil
case 5:
config, err := Goerli()
if err != nil {
return BaseConfig{}, err
}
return config, nil
case 11155111:

config, err := Sepolia()
if err != nil {
return BaseConfig{}, err
}
return config, nil
default:
return 0, errors.New("network not recognized")
return BaseConfig{}, errors.New("ChainID not recognized")
}
}
func dataDir(network Network) (string, error) {
Expand Down Expand Up @@ -186,4 +199,4 @@ func Sepolia() (BaseConfig, error) {
MaxCheckpointAge: 1_209_600, // 14 days
DataDir: &dataDir,
}, nil
}
}

0 comments on commit 39ea4bc

Please sign in to comment.