diff --git a/curvesim/constants.py b/curvesim/constants.py index f645eb766..a7471ab95 100644 --- a/curvesim/constants.py +++ b/curvesim/constants.py @@ -1,7 +1,33 @@ +""" +Constants and Enum types used in Curvesim. +""" from enum import Enum -class Chain(str, Enum): +class StrEnum(str, Enum): + """ + Custom string enum type since the builtin `StrEnum` is not available + until Python 3.11. + """ + + def __str__(self): + """ + Regular Enum's __str__ is the name, rather than the value, + e.g. + + >>> str(Chain.MAINNET) + 'Chain.MAINNET' + + so we need to explicit use the value. + + This behaves like the builtin `StrEnum` (available in 3.11). + """ + return str.__str__(self) + + +class Chain(StrEnum): + """Identifiers for chains & layer 2s.""" + MAINNET = "mainnet" ARBITRUM = "arbitrum" OPTIMISM = "optimism" @@ -11,6 +37,8 @@ class Chain(str, Enum): XDAI = "xdai" -class Env(str, Enum): +class Env(StrEnum): + """Names for different API environments.""" + PROD = "prod" STAGING = "staging"