Merge pull request #8060 from blockscout/vb-fix-eth-get-logs-api-endpoint

Fix eth_getLogs API endpoint
pull/8053/head
Victor Baranov 1 year ago committed by GitHub
commit f1b38d88e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      CHANGELOG.md
  2. 5
      apps/explorer/lib/explorer/eth_rpc.ex
  3. 8
      apps/explorer/lib/explorer/etherscan/logs.ex

@ -7,6 +7,7 @@
### Fixes ### Fixes
- [#8040](https://github.com/blockscout/blockscout/pull/8040) - Resolve issue with Docker image for Mac M1/M2 - [#8040](https://github.com/blockscout/blockscout/pull/8040) - Resolve issue with Docker image for Mac M1/M2
- [#8060](https://github.com/blockscout/blockscout/pull/8060) - Fix eth_getLogs API endpoint
### Chore ### Chore

@ -296,17 +296,14 @@ defmodule Explorer.EthRPC do
defp paging_options(%{ defp paging_options(%{
"paging_options" => %{ "paging_options" => %{
"logIndex" => log_index, "logIndex" => log_index,
"transactionIndex" => transaction_index,
"blockNumber" => block_number "blockNumber" => block_number
} }
}) }) do
when is_integer(transaction_index) do
with {:ok, parsed_block_number} <- to_number(block_number, "invalid block number"), with {:ok, parsed_block_number} <- to_number(block_number, "invalid block number"),
{:ok, parsed_log_index} <- to_number(log_index, "invalid log index") do {:ok, parsed_log_index} <- to_number(log_index, "invalid log index") do
{:ok, {:ok,
%{ %{
log_index: parsed_log_index, log_index: parsed_log_index,
transaction_index: transaction_index,
block_number: parsed_block_number block_number: parsed_block_number
}} }}
end end

@ -248,16 +248,14 @@ defmodule Explorer.Etherscan.Logs do
defp where_multiple_topics_match(query, _, _, _), do: query defp where_multiple_topics_match(query, _, _, _), do: query
defp page_logs(query, %{block_number: nil, transaction_index: nil, log_index: nil}) do defp page_logs(query, %{block_number: nil, log_index: nil}) do
query query
end end
defp page_logs(query, %{block_number: block_number, transaction_index: transaction_index, log_index: log_index}) do defp page_logs(query, %{block_number: block_number, log_index: log_index}) do
from( from(
data in query, data in query,
where: where: data.index > ^log_index and data.block_number >= ^block_number
data.index > ^log_index and data.block_number >= ^block_number and
data.transaction_index >= ^transaction_index
) )
end end

Loading…
Cancel
Save