Skip to content

Commit

Permalink
feat: add eth_getLogs rpc endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
zachdaniel committed Jun 20, 2019
1 parent bd7ded7 commit a28b4b6
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,11 @@ defmodule BlockScoutWeb.API.RPC.EthController do
end

defp render_log(log) do
topics = Enum.reject([log.first_topic, log.second_topic, log.third_topic, log.fourth_topic], &is_nil/1)
topics =
Enum.reject(
[log.first_topic, log.second_topic, log.third_topic, log.fourth_topic],
&is_nil/1
)

%{
"address" => to_string(log.address_hash),
Expand Down Expand Up @@ -166,7 +170,8 @@ defmodule BlockScoutWeb.API.RPC.EthController do
|> Enum.reduce({:ok, %{}}, fn {topic, index}, {:ok, acc} ->
case cast_topics(topic) do
{:ok, data} ->
with_filter = Map.put(acc, String.to_existing_atom("#{@index_to_word[index]}_topic"), data)
with_filter =
Map.put(acc, String.to_existing_atom("#{@index_to_word[index]}_topic"), data)

{:ok, add_operator(with_filter, index)}

Expand Down Expand Up @@ -245,7 +250,8 @@ defmodule BlockScoutWeb.API.RPC.EthController do
defp to_block_numbers(from_block, to_block, max_block_number, pending_block_number) do
actual_pending_block_number = pending_block_number || max_block_number

with {:ok, from} <- to_block_number(from_block, max_block_number, actual_pending_block_number),
with {:ok, from} <-
to_block_number(from_block, max_block_number, actual_pending_block_number),
{:ok, to} <- to_block_number(to_block, max_block_number, actual_pending_block_number) do
{:ok, from, to}
end
Expand Down

0 comments on commit a28b4b6

Please sign in to comment.