Skip to content

Commit

Permalink
fix: use new forked APIs [APE-1505] (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey authored Nov 3, 2023
1 parent 207be68 commit 010b3d9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
5 changes: 2 additions & 3 deletions ape_arbitrum/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from ape import plugins
from ape.api import NetworkAPI, create_network_type
from ape.api.networks import LOCAL_NETWORK_NAME
from ape.api.networks import LOCAL_NETWORK_NAME, ForkedNetworkAPI, NetworkAPI, create_network_type
from ape_geth import GethProvider
from ape_test import LocalProvider

Expand All @@ -21,7 +20,7 @@ def ecosystems():
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 "arbitrum", f"{network_name}-fork", ForkedNetworkAPI

# NOTE: This works for development providers, as they get chain_id from themselves
yield "arbitrum", LOCAL_NETWORK_NAME, NetworkAPI
Expand Down
28 changes: 16 additions & 12 deletions ape_arbitrum/ecosystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from ape.logging import logger
from ape.types import TransactionSignature
from ape.utils import DEFAULT_LOCAL_TRANSACTION_ACCEPTANCE_TIMEOUT
from ape_ethereum.ecosystem import Ethereum, NetworkConfig
from ape_ethereum.ecosystem import Ethereum, ForkedNetworkConfig, NetworkConfig
from ape_ethereum.transactions import (
DynamicFeeTransaction,
Receipt,
Expand Down Expand Up @@ -92,35 +92,39 @@ def await_confirmations(self) -> "ReceiptAPI":
return self


def _create_network_config(
required_confirmations: int = 1, block_time: int = 1, **kwargs
def _create_config(
required_confirmations: int = 1,
block_time: int = 1,
cls: Type = NetworkConfig,
**kwargs,
) -> NetworkConfig:
return NetworkConfig(
return cls(
required_confirmations=required_confirmations,
block_time=block_time,
default_transaction_type=EthTransactionType.STATIC,
**kwargs,
)


def _create_local_config(default_provider: Optional[str] = None, **kwargs) -> NetworkConfig:
return _create_network_config(
def _create_local_config(default_provider: Optional[str] = None, use_fork: bool = False, **kwargs):
return _create_config(
block_time=0,
default_provider=default_provider,
gas_limit=LOCAL_GAS_LIMIT,
required_confirmations=0,
transaction_acceptance_timeout=DEFAULT_LOCAL_TRANSACTION_ACCEPTANCE_TIMEOUT,
cls=ForkedNetworkConfig if use_fork else NetworkConfig,
**kwargs,
)


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()
sepolia: NetworkConfig = _create_network_config()
sepolia_fork: NetworkConfig = _create_local_config()
mainnet: NetworkConfig = _create_config()
mainnet_fork: ForkedNetworkConfig = _create_local_config(use_fork=True)
goerli: NetworkConfig = _create_config()
goerli_fork: ForkedNetworkConfig = _create_local_config(use_fork=True)
sepolia: NetworkConfig = _create_config()
sepolia_fork: ForkedNetworkConfig = _create_local_config(use_fork=True)
local: NetworkConfig = _create_local_config(default_provider="test")
default_network: str = LOCAL_NETWORK_NAME

Expand Down

0 comments on commit 010b3d9

Please sign in to comment.