Skip to content

Organize eth module as separate files #2753

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ethpm/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def __init__(
validate_w3_instance(w3)

self.w3 = w3
self.w3.eth.defaultContractFactory = cast(Type[Contract], LinkableContract)
self.w3.eth._default_contract_factory = cast(Type[Contract], LinkableContract)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this ever meant to be a public property? 🤔

I don't mind putting this back, but this made a bit more sense. We don't have documentation on this afaik.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see any docs either, so I think this is good.

self.manifest = manifest
self._uri = uri

Expand Down
1 change: 1 addition & 0 deletions newsfragments/2753.internal.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Organize the ``eth`` module into separate files for better readability.
2 changes: 1 addition & 1 deletion tests/core/pm-module/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def setup_w3():
t = EthereumTester(backend=pyevm_backend)
w3 = Web3(Web3.EthereumTesterProvider(ethereum_tester=t))
w3.eth.default_account = w3.eth.accounts[0]
w3.eth.defaultContractFactory = LinkableContract
w3.eth._default_contract_factory = LinkableContract
w3.enable_unstable_package_management_api()
return w3

Expand Down
2 changes: 1 addition & 1 deletion tests/core/pm-module/test_registry_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
def fresh_w3():
w3 = Web3(Web3.EthereumTesterProvider())
w3.eth.default_account = w3.eth.accounts[0]
w3.eth.defaultContractFactory = LinkableContract
w3.eth._default_contract_factory = LinkableContract
w3.enable_unstable_package_management_api()
return w3

Expand Down
3 changes: 2 additions & 1 deletion web3/_utils/blocks.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from typing import (
Any,
Optional,
)

from eth_utils import (
Expand Down Expand Up @@ -57,7 +58,7 @@ def is_hex_encoded_block_number(value: Any) -> bool:
@curry
def select_method_for_block_identifier(
value: Any, if_hash: RPCEndpoint, if_number: RPCEndpoint, if_predefined: RPCEndpoint
) -> RPCEndpoint:
) -> Optional[RPCEndpoint]:
if is_predefined_block_number(value):
return if_predefined
elif isinstance(value, bytes):
Expand Down
2 changes: 1 addition & 1 deletion web3/_utils/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ def select_filter_method(
if_new_block_filter: RPCEndpoint,
if_new_pending_transaction_filter: RPCEndpoint,
if_new_filter: RPCEndpoint,
) -> RPCEndpoint:
) -> Optional[RPCEndpoint]:

if is_string(value):
if value == "latest":
Expand Down
9 changes: 5 additions & 4 deletions web3/_utils/module_testing/eth_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
construct_error_generator_middleware,
)
from web3.types import ( # noqa: F401
ENS,
BlockData,
FilterParams,
LogReceipt,
Expand Down Expand Up @@ -1374,7 +1375,7 @@ async def test_async_eth_get_storage_at_ens_name(
) -> None:
with ens_addresses(async_w3, {"emitter.eth": emitter_contract_address}):
storage = await async_w3.eth.get_storage_at( # type: ignore
"emitter.eth", 0
ENS("emitter.eth"), 0
)
assert isinstance(storage, HexBytes)

Expand Down Expand Up @@ -1679,7 +1680,7 @@ def test_eth_get_storage_at_ens_name(
self, w3: "Web3", emitter_contract_address: ChecksumAddress
) -> None:
with ens_addresses(w3, {"emitter.eth": emitter_contract_address}):
storage = w3.eth.get_storage_at("emitter.eth", 0)
storage = w3.eth.get_storage_at(ENS("emitter.eth"), 0)
assert isinstance(storage, HexBytes)

def test_eth_get_storage_at_invalid_address(self, w3: "Web3") -> None:
Expand All @@ -1703,7 +1704,7 @@ def test_eth_get_transaction_count_ens_name(
w3, {"unlocked-acct-dual-type.eth": unlocked_account_dual_type}
):
transaction_count = w3.eth.get_transaction_count(
"unlocked-acct-dual-type.eth"
ENS("unlocked-acct-dual-type.eth")
)
assert is_integer(transaction_count)
assert transaction_count >= 0
Expand Down Expand Up @@ -1774,7 +1775,7 @@ def test_eth_get_code_ens_address(
self, w3: "Web3", math_contract_address: ChecksumAddress
) -> None:
with ens_addresses(w3, {"mathcontract.eth": math_contract_address}):
code = w3.eth.get_code("mathcontract.eth")
code = w3.eth.get_code(ENS("mathcontract.eth"))
assert isinstance(code, HexBytes)
assert len(code) > 0

Expand Down
Loading