Skip to content

Commit

Permalink
Eager validation of ETHERSCAN_API_KEY length
Browse files Browse the repository at this point in the history
  • Loading branch information
KPrasch committed Sep 21, 2023
1 parent cfa0e7e commit 4c4cd00
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions scripts/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
PROJECT_ROOT = Path(__file__).parent.parent
CONSTRUCTOR_PARAMS_DIR = PROJECT_ROOT / "deployments" / "constructor_params"
ARTIFACTS_DIR = PROJECT_ROOT / "deployments" / "artifacts"
ETHERSCAN_API_KEY_ENVVAR = "ETHERSCAN_API_KEY"


def deploy_mocks(deployer):
Expand Down Expand Up @@ -66,5 +67,8 @@ def check_etherscan_plugin() -> None:
import ape_etherscan # noqa: F401
except ImportError:
raise ImportError("Please install the ape-etherscan plugin to use this script.")
if not os.environ.get("ETHERSCAN_API_KEY"):
raise ValueError("ETHERSCAN_API_KEY is not set.")
api_key = os.environ.get(ETHERSCAN_API_KEY_ENVVAR)
if not api_key:
raise ValueError(f"{ETHERSCAN_API_KEY_ENVVAR} is not set.")
if not len(api_key) == 34:
raise ValueError(f"{ETHERSCAN_API_KEY_ENVVAR} is not valid.")

0 comments on commit 4c4cd00

Please sign in to comment.