Fix eth_getLogs API endpoint

pull/8060/head
Viktor Baranov 1 year ago
parent d7a23c3f75
commit a438b5a6e7
  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
- [#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

@ -296,17 +296,14 @@ defmodule Explorer.EthRPC do
defp paging_options(%{
"paging_options" => %{
"logIndex" => log_index,
"transactionIndex" => transaction_index,
"blockNumber" => block_number
}
})
when is_integer(transaction_index) do
}) do
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,
%{
log_index: parsed_log_index,
transaction_index: transaction_index,
block_number: parsed_block_number
}}
end

@ -248,16 +248,14 @@ defmodule Explorer.Etherscan.Logs do
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
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(
data in query,
where:
data.index > ^log_index and data.block_number >= ^block_number and
data.transaction_index >= ^transaction_index
where: data.index > ^log_index and data.block_number >= ^block_number
)
end

Loading…
Cancel
Save