Skip to content

Commit

Permalink
fix: new cfg
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey committed Jan 23, 2024
1 parent b8bc9b0 commit 2e4a968
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 30 deletions.
30 changes: 6 additions & 24 deletions ape_arbitrum/ecosystem.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import time
from typing import Dict, Optional, Tuple, Type, cast
from typing import ClassVar, Dict, Tuple, Type, cast

from ape.api.config import PluginConfig
from ape.api.networks import LOCAL_NETWORK_NAME
from ape.api.transactions import ConfirmationsProgressBar, ReceiptAPI, TransactionAPI
from ape.exceptions import ApeException, TransactionError
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, ForkedNetworkConfig, NetworkConfig
from ape.types import GasLimit, TransactionSignature
from ape_ethereum.ecosystem import BaseEthereumConfig, Ethereum, NetworkConfig
from ape_ethereum.transactions import (
AccessListTransaction,
DynamicFeeTransaction,
Expand Down Expand Up @@ -107,27 +104,12 @@ def _create_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):
class ArbitrumConfig(BaseEthereumConfig):
DEFAULT_TRANSACTION_TYPE: ClassVar[int] = EthTransactionType.STATIC.value
DEFAULT_LOCAL_GAS_LIMIT: ClassVar[GasLimit] = LOCAL_GAS_LIMIT
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


class Arbitrum(Ethereum):
Expand Down
30 changes: 30 additions & 0 deletions tests/test_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
from ape_ethereum.transactions import TransactionType

from ape_arbitrum.ecosystem import LOCAL_GAS_LIMIT, ArbitrumConfig


def test_gas_limit(arbitrum):
# NOTE: The reason we have a hard-coded gas limit is because
# the block gas limit in Arbitrum is extremely high.
assert arbitrum.config.local.gas_limit == LOCAL_GAS_LIMIT


def test_default_transaction_type(arbitrum):
assert arbitrum.config.mainnet.default_transaction_type == TransactionType.STATIC


def test_mainnet_fork_not_configured():
obj = ArbitrumConfig.model_validate({})
assert obj.mainnet_fork.required_confirmations == 0


def test_mainnet_fork_configured():
data = {"mainnet_fork": {"required_confirmations": 555}}
obj = ArbitrumConfig.model_validate(data)
assert obj.mainnet_fork.required_confirmations == 555


def test_custom_network():
data = {"apenet": {"required_confirmations": 333}}
obj = ArbitrumConfig.model_validate(data)
assert obj.apenet.required_confirmations == 333
6 changes: 0 additions & 6 deletions tests/test_ecosystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@
from ape_arbitrum.ecosystem import INTERNAL_TRANSACTION_TYPE, LOCAL_GAS_LIMIT, ArbitrumReceipt


def test_gas_limit(arbitrum):
# NOTE: The reason we have a hard-coded gas limit is because
# the block gas limit in Arbitrum is extremely high.
assert arbitrum.config.local.gas_limit == LOCAL_GAS_LIMIT


@pytest.mark.parametrize(
"tx_kwargs",
[
Expand Down

0 comments on commit 2e4a968

Please sign in to comment.