Skip to content

Commit

Permalink
feat: pep-625 compliance and type checking performance refactors (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
bitwise-constructs authored Dec 9, 2024
1 parent 6bab4a1 commit 2703603
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 41 deletions.
76 changes: 37 additions & 39 deletions ape_tenderly/__init__.py
Original file line number Diff line number Diff line change
@@ -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",
]
38 changes: 38 additions & 0 deletions ape_tenderly/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
],
}
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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/"
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
],
Expand Down

0 comments on commit 2703603

Please sign in to comment.