Skip to content

Commit

Permalink
Merge pull request #10 from FastLane-Labs/helper-func
Browse files Browse the repository at this point in the history
feat: get atlas version from its address
  • Loading branch information
jj1980a authored Dec 14, 2024
2 parents ce9b1fb + 1ffac35 commit 7b55030
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions config/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,28 @@ func GetVersion(version *string) string {
return *version
}

func GetVersionFromAtlasAddress(chainId uint64, atlasAddr common.Address) (string, error) {
if err := initChainConfig(); err != nil {
return "", err
}

mu.RLock()
defer mu.RUnlock()

for _, version := range allVersions {
chainConf, ok := chainConfig[chainId][version]
if !ok {
continue
}

if chainConf.Contract.Atlas == atlasAddr {
return version, nil
}
}

return "", fmt.Errorf("atlas address not found for chain id %d", chainId)
}

func GetChainConfig(chainId uint64, version *string) (*ChainConfig, error) {
if err := initChainConfig(); err != nil {
return nil, err
Expand Down

0 comments on commit 7b55030

Please sign in to comment.