Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions lib/networks/networks.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,17 @@ func (n Networks) EthProvidersConfig() ethproviders.Config {

return res
}

func (n Networks) GetByChainID(chainID uint64) *Network {
for _, network := range n {
if network.ChainID == chainID {
return network
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't Networks a map? I think we can look up items directly

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

item, ok := n[chainID]
return item, ok

}
return nil
}

func (n Networks) GetByName(name string) *Network {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please return boolean too

network, _ := n[name]
return network
}
Loading