Address changes in web3 block fetching

pull/3/head
Doc Ritezel 7 years ago
parent 57f86e554e
commit ede8d0579e
  1. 15
      lib/explorer/importers/block_importer.ex

@ -38,7 +38,9 @@ defmodule Explorer.BlockImporter do
@dialyzer {:nowarn_function, download_block: 1}
def download_block(block_number) do
{:ok, block} = eth_get_block_by_number(block_number, true)
{:ok, block} = block_number
|> encode_number()
|> eth_get_block_by_number(true)
block
end
@ -58,6 +60,17 @@ defmodule Explorer.BlockImporter do
}
end
defp encode_number("latest"), do: "latest"
defp encode_number("earliest"), do: "earliest"
defp encode_number("pending"), do: "pending"
defp encode_number(number) when is_binary(number) do
number
|> String.to_integer()
|> encode_number()
end
defp encode_number(number), do: "0x" <> Integer.to_string(number, 16)
def decode_integer_field(hex) do
{"0x", base_16} = String.split_at(hex, 2)
String.to_integer(base_16, 16)

Loading…
Cancel
Save