From fc522ef16b5f6116df79c31f4b748ce91c4216d7 Mon Sep 17 00:00:00 2001 From: slush Date: Fri, 6 Dec 2024 21:00:38 -0600 Subject: [PATCH] feat: pep-625 compliance and type checking performance refactors --- ape_tenderly/__init__.py | 76 +++++++++++++++++++--------------------- ape_tenderly/provider.py | 38 ++++++++++++++++++++ pyproject.toml | 2 +- setup.py | 2 +- 4 files changed, 77 insertions(+), 41 deletions(-) diff --git a/ape_tenderly/__init__.py b/ape_tenderly/__init__.py index 60fd154..d739804 100644 --- a/ape_tenderly/__init__.py +++ b/ape_tenderly/__init__.py @@ -1,52 +1,50 @@ from ape import plugins -from .provider import TenderlyConfig, TenderlyForkProvider, TenderlyGatewayProvider - -NETWORKS = { - "ethereum": [ - ("mainnet", TenderlyGatewayProvider), - ("mainnet-fork", TenderlyForkProvider), - ("sepolia", TenderlyGatewayProvider), - ("sepolia-fork", TenderlyForkProvider), - ], - "polygon": [ - ("mainnet", TenderlyGatewayProvider), - ("mainnet-fork", TenderlyForkProvider), - ("amoy", TenderlyGatewayProvider), - ("amoy-fork", TenderlyForkProvider), - ], - "arbitrum": [ - ("mainnet-fork", TenderlyForkProvider), - ("sepolia-fork", TenderlyForkProvider), - ], - "optimism": [ - ("mainnet", TenderlyGatewayProvider), - ("mainnet-fork", TenderlyForkProvider), - ("sepolia", TenderlyGatewayProvider), - ("sepolia-fork", TenderlyForkProvider), - ], - "base": [ - ("mainnet", TenderlyGatewayProvider), - ("mainnet-fork", TenderlyForkProvider), - ("sepolia", TenderlyGatewayProvider), - ("sepolia-fork", TenderlyForkProvider), - ], - "avalanche": [ - ("mainnet-fork", TenderlyForkProvider), - ], - "fantom": [ - ("opera-fork", TenderlyForkProvider), - ], -} - @plugins.register(plugins.Config) def config_class(): + from ape_tenderly.provider import TenderlyConfig + return TenderlyConfig @plugins.register(plugins.ProviderPlugin) def providers(): + from ape_tenderly.provider import NETWORKS + for ecosystem_name in NETWORKS: for network_name, provider in NETWORKS[ecosystem_name]: yield ecosystem_name, network_name, provider + + +def __getattr__(name: str): + if name == "NETWORKS": + from ape_tenderly.provider import NETWORKS + + return NETWORKS + + elif name == "TenderlyConfig": + from ape_tenderly.provider import TenderlyConfig + + return TenderlyConfig + + elif name == "TenderlyForkProvider": + from ape_tenderly.provider import TenderlyForkProvider + + return TenderlyForkProvider + + elif name == "TenderlyGatewayProvider": + from ape_tenderly.provider import TenderlyGatewayProvider + + return TenderlyGatewayProvider + + else: + raise AttributeError(name) + + +__all__ = [ + "NETWORKS", + "TenderlyConfig", + "TenderlyForkProvider", + "TenderlyGatewayProvider", +] diff --git a/ape_tenderly/provider.py b/ape_tenderly/provider.py index 4ec996d..f40632b 100644 --- a/ape_tenderly/provider.py +++ b/ape_tenderly/provider.py @@ -105,3 +105,41 @@ def connect(self): def disconnect(self): self._web3 = None + + +NETWORKS = { + "ethereum": [ + ("mainnet", TenderlyGatewayProvider), + ("mainnet-fork", TenderlyForkProvider), + ("sepolia", TenderlyGatewayProvider), + ("sepolia-fork", TenderlyForkProvider), + ], + "polygon": [ + ("mainnet", TenderlyGatewayProvider), + ("mainnet-fork", TenderlyForkProvider), + ("amoy", TenderlyGatewayProvider), + ("amoy-fork", TenderlyForkProvider), + ], + "arbitrum": [ + ("mainnet-fork", TenderlyForkProvider), + ("sepolia-fork", TenderlyForkProvider), + ], + "optimism": [ + ("mainnet", TenderlyGatewayProvider), + ("mainnet-fork", TenderlyForkProvider), + ("sepolia", TenderlyGatewayProvider), + ("sepolia-fork", TenderlyForkProvider), + ], + "base": [ + ("mainnet", TenderlyGatewayProvider), + ("mainnet-fork", TenderlyForkProvider), + ("sepolia", TenderlyGatewayProvider), + ("sepolia-fork", TenderlyForkProvider), + ], + "avalanche": [ + ("mainnet-fork", TenderlyForkProvider), + ], + "fantom": [ + ("opera-fork", TenderlyForkProvider), + ], +} diff --git a/pyproject.toml b/pyproject.toml index 11b5011..04a3545 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [build-system] -requires = ["setuptools>=51.1.1", "wheel", "setuptools_scm[toml]>=5.0"] +requires = ["setuptools>=75.6.0", "wheel", "setuptools_scm[toml]>=5.0"] [tool.mypy] exclude = "build/" diff --git a/setup.py b/setup.py index fc93aba..1dfe88a 100644 --- a/setup.py +++ b/setup.py @@ -26,7 +26,7 @@ "mdformat-pyproject>=0.0.2", # Allows configuring in pyproject.toml ], "release": [ # `release` GitHub Action job uses this - "setuptools", # Installation tool + "setuptools>=75.6.0", # Installation tool "wheel", # Packaging tool "twine", # Package upload tool ],