Skip to content

Commit

Permalink
feat: add support for mumbai-fork (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey authored Oct 12, 2022
1 parent fb71717 commit 6f723f5
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 11 deletions.
2 changes: 1 addition & 1 deletion ape_polygon/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
25 changes: 22 additions & 3 deletions ape_polygon/ecosystem.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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


Expand Down
14 changes: 7 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 6f723f5

Please sign in to comment.