From 6f723f5785576a418a7390df667dfd312dd73804 Mon Sep 17 00:00:00 2001 From: Juliya Smith Date: Wed, 12 Oct 2022 15:05:34 -0500 Subject: [PATCH] feat: add support for mumbai-fork (#8) --- ape_polygon/__init__.py | 2 +- ape_polygon/ecosystem.py | 25 ++++++++++++++++++++++--- setup.py | 14 +++++++------- 3 files changed, 30 insertions(+), 11 deletions(-) diff --git a/ape_polygon/__init__.py b/ape_polygon/__init__.py index 4945a6c..f381155 100644 --- a/ape_polygon/__init__.py +++ b/ape_polygon/__init__.py @@ -21,10 +21,10 @@ def ecosystems(): def networks(): for network_name, network_params in NETWORKS.items(): yield "polygon", network_name, create_network_type(*network_params) + yield "polygon", f"{network_name}-fork", NetworkAPI # NOTE: This works for development providers, as they get chain_id from themselves yield "polygon", LOCAL_NETWORK_NAME, NetworkAPI - yield "polygon", "mainnet-fork", NetworkAPI @plugins.register(plugins.ProviderPlugin) diff --git a/ape_polygon/ecosystem.py b/ape_polygon/ecosystem.py index 51ad8f2..9bde0d9 100644 --- a/ape_polygon/ecosystem.py +++ b/ape_polygon/ecosystem.py @@ -1,3 +1,5 @@ +from typing import Optional + from ape.api.config import PluginConfig from ape.api.networks import LOCAL_NETWORK_NAME from ape_ethereum.ecosystem import Ethereum, NetworkConfig @@ -9,10 +11,27 @@ } +def _create_network_config( + required_confirmations: int = 1, block_time: int = 2, **kwargs +) -> NetworkConfig: + # Helper method to isolate `type: ignore` comments. + return NetworkConfig( + required_confirmations=required_confirmations, block_time=block_time, **kwargs + ) # type: ignore + + +def _create_local_config(default_provider: Optional[str] = None) -> NetworkConfig: + return _create_network_config( + required_confirmations=0, block_time=0, default_provider=default_provider + ) + + class PolygonConfig(PluginConfig): - mainnet: NetworkConfig = NetworkConfig(required_confirmations=1, block_time=2) # type: ignore - mumbai: NetworkConfig = NetworkConfig(required_confirmations=1, block_time=2) # type: ignore - local: NetworkConfig = NetworkConfig(default_provider="test") # type: ignore + mainnet: NetworkConfig = _create_network_config() + mainnet_fork: NetworkConfig = _create_local_config() + mumbai: NetworkConfig = _create_network_config() + mumbai_fork: NetworkConfig = _create_local_config() + local: NetworkConfig = NetworkConfig(default_provider="test") default_network: str = LOCAL_NETWORK_NAME diff --git a/setup.py b/setup.py index a9b8990..84b0c7c 100644 --- a/setup.py +++ b/setup.py @@ -7,13 +7,13 @@ "pytest>=6.0", # Core testing package "pytest-xdist", # multi-process runner "pytest-cov", # Coverage analyzer plugin - "hypothesis>=6.2.0,<7.0", # Strategy-based fuzzer + "hypothesis>=6.2.0,<7", # Strategy-based fuzzer ], "lint": [ - "black>=22.6.0,<23.0", # auto-formatter and linter - "mypy>=0.971,<1.0", # Static type analyzer - "flake8>=4.0.1,<5.0", # Style linter - "isort>=5.10.1,<6.0", # Import sorting linter + "black>=22.6.0,<23", # auto-formatter and linter + "mypy>=0.971,<1", # Static type analyzer + "flake8>=4.0.1,<5", # Style linter + "isort>=5.10.1,<6", # Import sorting linter ], "release": [ # `release` GitHub Action job uses this "setuptools", # Installation tool @@ -53,9 +53,9 @@ url="https://github.com/ApeWorX/ape-polygon", include_package_data=True, install_requires=[ - "eth-ape>=0.5.0,<0.6.0", + "eth-ape>=0.5.2,<0.6", ], - python_requires=">=3.8,<4", + python_requires=">=3.8,<3.11", extras_require=extras_require, py_modules=["ape_polygon"], license="Apache-2.0",