|
|
@ -64,19 +64,26 @@ defmodule Indexer.Transform.AddressCoinBalancesDaily do |
|
|
|
|
|
|
|
|
|
|
|
block_timestamp_map = |
|
|
|
block_timestamp_map = |
|
|
|
Enum.reduce(block_numbers, %{}, fn block_number, map -> |
|
|
|
Enum.reduce(block_numbers, %{}, fn block_number, map -> |
|
|
|
{:ok, %Blocks{blocks_params: [%{timestamp: timestamp}]}} = |
|
|
|
case EthereumJSONRPC.fetch_blocks_by_range(block_number..block_number, json_rpc_named_arguments) do |
|
|
|
EthereumJSONRPC.fetch_blocks_by_range(block_number..block_number, json_rpc_named_arguments) |
|
|
|
{:ok, %Blocks{blocks_params: [%{timestamp: timestamp}]}} -> |
|
|
|
|
|
|
|
day = DateTime.to_date(timestamp) |
|
|
|
day = DateTime.to_date(timestamp) |
|
|
|
Map.put(map, "#{block_number}", day) |
|
|
|
Map.put(map, "#{block_number}", day) |
|
|
|
|
|
|
|
|
|
|
|
_ -> |
|
|
|
|
|
|
|
map |
|
|
|
|
|
|
|
end |
|
|
|
end) |
|
|
|
end) |
|
|
|
|
|
|
|
|
|
|
|
logs_params |
|
|
|
logs_params |
|
|
|
|> Enum.into(acc, fn |
|
|
|
|> Enum.into(acc, fn |
|
|
|
%{address_hash: address_hash, block_number: block_number} |
|
|
|
%{address_hash: address_hash, block_number: block_number} |
|
|
|
when is_binary(address_hash) and is_integer(block_number) -> |
|
|
|
when is_binary(address_hash) and is_integer(block_number) -> |
|
|
|
day = Map.get(block_timestamp_map, "#{block_number}") |
|
|
|
if Map.has_key?(block_timestamp_map, "#{block_number}") do |
|
|
|
%{address_hash: address_hash, day: day} |
|
|
|
day = Map.get(block_timestamp_map, "#{block_number}") |
|
|
|
|
|
|
|
%{address_hash: address_hash, day: day} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
nil |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
%{type: "pending"} -> |
|
|
|
%{type: "pending"} -> |
|
|
|
nil |
|
|
|
nil |
|
|
@ -137,19 +144,22 @@ defmodule Indexer.Transform.AddressCoinBalancesDaily do |
|
|
|
# a transaction MUST have a `from_address_hash` |
|
|
|
# a transaction MUST have a `from_address_hash` |
|
|
|
json_rpc_named_arguments = Application.get_env(:explorer, :json_rpc_named_arguments) |
|
|
|
json_rpc_named_arguments = Application.get_env(:explorer, :json_rpc_named_arguments) |
|
|
|
|
|
|
|
|
|
|
|
{:ok, %Blocks{blocks_params: [%{timestamp: block_timestamp}]}} = |
|
|
|
case EthereumJSONRPC.fetch_blocks_by_range(block_number..block_number, json_rpc_named_arguments) do |
|
|
|
EthereumJSONRPC.fetch_blocks_by_range(block_number..block_number, json_rpc_named_arguments) |
|
|
|
{:ok, %Blocks{blocks_params: [%{timestamp: block_timestamp}]}} -> |
|
|
|
|
|
|
|
day = DateTime.to_date(block_timestamp) |
|
|
|
|
|
|
|
acc = MapSet.put(initial, %{address_hash: from_address_hash, day: day}) |
|
|
|
|
|
|
|
|
|
|
|
day = DateTime.to_date(block_timestamp) |
|
|
|
# `to_address_hash` is optional |
|
|
|
acc = MapSet.put(initial, %{address_hash: from_address_hash, day: day}) |
|
|
|
case transaction_params do |
|
|
|
|
|
|
|
%{to_address_hash: to_address_hash} when is_binary(to_address_hash) -> |
|
|
|
|
|
|
|
MapSet.put(acc, %{address_hash: to_address_hash, day: day}) |
|
|
|
|
|
|
|
|
|
|
|
# `to_address_hash` is optional |
|
|
|
_ -> |
|
|
|
case transaction_params do |
|
|
|
acc |
|
|
|
%{to_address_hash: to_address_hash} when is_binary(to_address_hash) -> |
|
|
|
end |
|
|
|
MapSet.put(acc, %{address_hash: to_address_hash, day: day}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_ -> |
|
|
|
_ -> |
|
|
|
acc |
|
|
|
initial |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|