Skip to content

Commit

Permalink
Convert plugin for Scroll
Browse files Browse the repository at this point in the history
  • Loading branch information
theref committed May 10, 2023
1 parent 8baabc4 commit ccee718
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 22 deletions.
16 changes: 8 additions & 8 deletions ape_scroll/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,32 @@
from ape_geth import GethProvider
from ape_test import LocalProvider

from .ecosystem import NETWORKS, Arbitrum, ArbitrumConfig
from .ecosystem import NETWORKS, Scroll, ScrollConfig


@plugins.register(plugins.Config)
def config_class():
return ArbitrumConfig
return ScrollConfig


@plugins.register(plugins.EcosystemPlugin)
def ecosystems():
yield Arbitrum
yield Scroll


@plugins.register(plugins.NetworkPlugin)
def networks():
for network_name, network_params in NETWORKS.items():
yield "arbitrum", network_name, create_network_type(*network_params)
yield "arbitrum", f"{network_name}-fork", NetworkAPI
yield "scroll", network_name, create_network_type(*network_params)
yield "scroll", f"{network_name}-fork", NetworkAPI

# NOTE: This works for development providers, as they get chain_id from themselves
yield "arbitrum", LOCAL_NETWORK_NAME, NetworkAPI
yield "scroll", LOCAL_NETWORK_NAME, NetworkAPI


@plugins.register(plugins.ProviderPlugin)
def providers():
for network_name in NETWORKS:
yield "arbitrum", network_name, GethProvider
yield "scroll", network_name, GethProvider

yield "arbitrum", LOCAL_NETWORK_NAME, LocalProvider
yield "scroll", LOCAL_NETWORK_NAME, LocalProvider
24 changes: 10 additions & 14 deletions ape_scroll/ecosystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,13 @@

NETWORKS = {
# chain_id, network_id
"mainnet": (42161, 42161),
"goerli": (421613, 421613),
"testnet": (534353, 534353),
}


class ApeArbitrumError(ApeException):
class ApeScrollError(ApeException):
"""
Raised in the ape-arbitrum plugin.
Raised in the ape-scroll plugin.
"""


Expand All @@ -37,19 +36,16 @@ def _create_local_config(default_provider: Optional[str] = None) -> NetworkConfi
)


class ArbitrumConfig(PluginConfig):
mainnet: NetworkConfig = _create_network_config()
mainnet_fork: NetworkConfig = _create_local_config()
goerli: NetworkConfig = _create_network_config()
goerli_fork: NetworkConfig = _create_local_config()
local: NetworkConfig = _create_local_config(default_provider="test")
class ScrollConfig(PluginConfig):
testnet: NetworkConfig = _create_network_config()
testnet_fork: NetworkConfig = _create_local_config()
default_network: str = LOCAL_NETWORK_NAME


class Arbitrum(Ethereum):
class Scroll(Ethereum):
@property
def config(self) -> ArbitrumConfig: # type: ignore
return cast(ArbitrumConfig, self.config_manager.get_config("arbitrum"))
def config(self) -> ScrollConfig: # type: ignore
return cast(ScrollConfig, self.config_manager.get_config("scroll"))

def create_transaction(self, **kwargs) -> TransactionAPI:
"""
Expand Down Expand Up @@ -115,6 +111,6 @@ def _get_transaction_cls(transaction_type: TransactionType) -> Type[TransactionA
TransactionType.DYNAMIC: DynamicFeeTransaction,
}
if transaction_type not in transaction_types:
raise ApeArbitrumError(f"Transaction type '{transaction_type}' not supported.")
raise ApeScrollError(f"Transaction type '{transaction_type}' not supported.")

return transaction_types[transaction_type]

0 comments on commit ccee718

Please sign in to comment.