Skip to content

Commit

Permalink
feat: add forking config [APE-817] (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
NotPeopling2day committed Apr 11, 2023
1 parent e4df22d commit 5326464
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Expand Up @@ -10,13 +10,13 @@ repos:
- id: isort

- repo: https://github.com/psf/black
rev: 22.12.0
rev: 23.3.0
hooks:
- id: black
name: black

- repo: https://github.com/pycqa/flake8
rev: 5.0.4
rev: 6.0.0
hooks:
- id: flake8

Expand Down
2 changes: 1 addition & 1 deletion ape_avalanche/__init__.py
Expand Up @@ -21,10 +21,10 @@ def ecosystems():
def networks():
for network_name, network_params in NETWORKS.items():
yield "avalanche", network_name, create_network_type(*network_params)
yield "avalanche", f"{network_name}-fork", NetworkAPI

# NOTE: This works for development providers, as they get chain_id from themselves
yield "avalanche", LOCAL_NETWORK_NAME, NetworkAPI
yield "avalanche", "mainnet-fork", NetworkAPI


@plugins.register(plugins.ProviderPlugin)
Expand Down
24 changes: 21 additions & 3 deletions ape_avalanche/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
Expand All @@ -9,10 +11,26 @@
}


def _create_network_config(
required_confirmations: int = 1, block_time: int = 2, **kwargs
) -> NetworkConfig:
return NetworkConfig(
required_confirmations=required_confirmations, block_time=block_time, **kwargs
)


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 AvalancheConfig(PluginConfig):
mainnet: NetworkConfig = NetworkConfig(required_confirmations=1, block_time=2) # type: ignore
fuji: 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()
fuji: NetworkConfig = _create_network_config()
fuji_fork: NetworkConfig = _create_local_config()
local: NetworkConfig = NetworkConfig(default_provider="test")
default_network: str = LOCAL_NETWORK_NAME


Expand Down
8 changes: 4 additions & 4 deletions setup.py
Expand Up @@ -10,10 +10,10 @@
"hypothesis>=6.2.0,<7.0", # Strategy-based fuzzer
],
"lint": [
"black>=22.12.0", # auto-formatter and linter
"mypy>=0.991", # Static type analyzer
"black>=23.3.0,<24", # Auto-formatter and linter
"mypy>=0.991,<1", # Static type analyzer
"types-setuptools", # Needed for mypy type shed
"flake8>=5.0.4", # Style linter
"flake8>=6.0.0,<7", # Style linter
"isort>=5.10.1", # Import sorting linter
"mdformat>=0.7.16", # Auto-formatter for markdown
"mdformat-gfm>=0.3.5", # Needed for formatting GitHub-flavored markdown
Expand Down Expand Up @@ -57,7 +57,7 @@
url="https://github.com/ApeWorX/ape-avalanche",
include_package_data=True,
install_requires=[
"eth-ape>=0.6.5,<0.7.0",
"eth-ape>=0.6.7,<0.7.0",
],
python_requires=">=3.8,<4",
extras_require=extras_require,
Expand Down

0 comments on commit 5326464

Please sign in to comment.