Skip to content

Commit

Permalink
perf: plugin load
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey committed Nov 8, 2024
1 parent e00c0fd commit d9eeddd
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
30 changes: 25 additions & 5 deletions ape_bsc/__init__.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,31 @@
from ape import plugins
from ape.api.networks import LOCAL_NETWORK_NAME, ForkedNetworkAPI, NetworkAPI, create_network_type
from ape_node import Node
from ape_test import LocalProvider

from .ecosystem import BSC, NETWORKS, BSCConfig


@plugins.register(plugins.Config)
def config_class():
from .ecosystem import BSCConfig

return BSCConfig


@plugins.register(plugins.EcosystemPlugin)
def ecosystems():
from .ecosystem import BSC

yield BSC


@plugins.register(plugins.NetworkPlugin)
def networks():
from ape.api.networks import (
LOCAL_NETWORK_NAME,
ForkedNetworkAPI,
NetworkAPI,
create_network_type,
)

from .ecosystem import NETWORKS

for network_name, network_params in NETWORKS.items():
yield "bsc", network_name, create_network_type(*network_params)
yield "bsc", f"{network_name}-fork", ForkedNetworkAPI
Expand All @@ -28,7 +36,19 @@ def networks():

@plugins.register(plugins.ProviderPlugin)
def providers():
from ape.api.networks import LOCAL_NETWORK_NAME
from ape_node import Node
from ape_test import LocalProvider

from .ecosystem import NETWORKS

for network_name in NETWORKS:
yield "bsc", network_name, Node

yield "bsc", LOCAL_NETWORK_NAME, LocalProvider


def __getattr__(name: str):
import ape_bsc.ecosystem as module

return getattr(module, name)
3 changes: 2 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
[flake8]
max-line-length = 100
ignore = E704,W503,PYD002
ignore = E704,W503,PYD002,TC003,TC006
exclude =
venv*
.eggs
docs
build
type-checking-pydantic-enabled = True

0 comments on commit d9eeddd

Please sign in to comment.