|
|
|
@ -103,7 +103,8 @@ defmodule Explorer.ChainSpec.Parity.Importer do |
|
|
|
|
!is_nil(map["balance"]) |
|
|
|
|
end) |
|
|
|
|
|> Stream.map(fn {address, %{"balance" => value}} -> |
|
|
|
|
{:ok, address_hash} = AddressHash.cast(address) |
|
|
|
|
formatted_address = if String.starts_with?(address, "0x"), do: address, else: "0x" <> address |
|
|
|
|
{:ok, address_hash} = AddressHash.cast(formatted_address) |
|
|
|
|
balance = parse_number(value) |
|
|
|
|
|
|
|
|
|
%{address_hash: address_hash, value: balance} |
|
|
|
@ -135,7 +136,7 @@ defmodule Explorer.ChainSpec.Parity.Importer do |
|
|
|
|
} |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
defp parse_hex_numbers(rewards) do |
|
|
|
|
defp parse_hex_numbers(rewards) when is_map(rewards) do |
|
|
|
|
Enum.map(rewards, fn {hex_block_number, hex_reward} -> |
|
|
|
|
block_number = parse_number(hex_block_number) |
|
|
|
|
{:ok, reward} = hex_reward |> parse_number() |> Wei.cast() |
|
|
|
@ -144,6 +145,12 @@ defmodule Explorer.ChainSpec.Parity.Importer do |
|
|
|
|
end) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
defp parse_hex_numbers(reward) do |
|
|
|
|
{:ok, reward} = reward |> parse_number() |> Wei.cast() |
|
|
|
|
|
|
|
|
|
[{0, reward}] |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
defp parse_number("0x" <> hex_number) do |
|
|
|
|
{number, ""} = Integer.parse(hex_number, 16) |
|
|
|
|
|
|
|
|
|