Skip to content
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

eth_getFilterChanges, getFilterLogs, and getLogs use Method #1752

Merged
merged 4 commits into from
Oct 16, 2020
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
1 change: 1 addition & 0 deletions newsfragments/1752.misc.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Move eth_getFilterChanges, eth_getFilterLogs, and eth_getLogs to use ``Method``
35 changes: 0 additions & 35 deletions tests/core/middleware/test_request_param_normalizer.py

This file was deleted.

6 changes: 5 additions & 1 deletion web3/_utils/method_formatters.py
Original file line number Diff line number Diff line change
Expand Up @@ -499,8 +499,12 @@ def get_request_formatters(
method_name: Union[RPCEndpoint, Callable[..., RPCEndpoint]]
) -> Dict[str, Callable[..., Any]]:
request_formatter_maps = (
METHOD_NORMALIZERS,
ABI_REQUEST_FORMATTERS,
# METHOD_NORMALIZERS needs to be after ABI_REQUEST_FORMATTERS
# so that eth_getLogs's apply_formatter_at_index formatter
# is applied to the whole address
# rather than on the first byte of the address
METHOD_NORMALIZERS,
Copy link
Member

Choose a reason for hiding this comment

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

channeling an old review: if this order is important, might be worth documenting with a comment explanation.

PYTHONIC_REQUEST_FORMATTERS,
)
formatters = combine_formatters(request_formatter_maps, method_name)
Expand Down
28 changes: 14 additions & 14 deletions web3/eth.py
Original file line number Diff line number Diff line change
Expand Up @@ -500,20 +500,20 @@ def filter(
"a valid filter object, or a filter_id as a string "
"or hex.")

def getFilterChanges(self, filter_id: HexStr) -> List[LogReceipt]:
return self.web3.manager.request_blocking(
RPC.eth_getFilterChanges, [filter_id],
)

def getFilterLogs(self, filter_id: HexStr) -> List[LogReceipt]:
return self.web3.manager.request_blocking(
RPC.eth_getFilterLogs, [filter_id],
)

def getLogs(self, filter_params: FilterParams) -> List[LogReceipt]:
return self.web3.manager.request_blocking(
RPC.eth_getLogs, [filter_params],
)
getFilterChanges: Method[Callable[[HexStr], List[LogReceipt]]] = Method(
RPC.eth_getFilterChanges,
mungers=[default_root_munger]
)

getFilterLogs: Method[Callable[[HexStr], List[LogReceipt]]] = Method(
RPC.eth_getFilterLogs,
mungers=[default_root_munger]
)

getLogs: Method[Callable[[FilterParams], List[LogReceipt]]] = Method(
RPC.eth_getLogs,
mungers=[default_root_munger]
)

submitHashrate: Method[Callable[[int, _Hash32], bool]] = Method(
RPC.eth_submitHashrate,
Expand Down