|
|
|
@ -11,8 +11,8 @@ defmodule BlockScoutWeb.BlockTransactionController do |
|
|
|
|
alias Phoenix.View |
|
|
|
|
|
|
|
|
|
def index(conn, %{"block_hash_or_number" => formatted_block_hash_or_number, "type" => "JSON"} = params) do |
|
|
|
|
with {:ok, block} <- |
|
|
|
|
param_block_hash_or_number_to_block(formatted_block_hash_or_number, []) do |
|
|
|
|
case param_block_hash_or_number_to_block(formatted_block_hash_or_number, []) do |
|
|
|
|
{:ok, block} -> |
|
|
|
|
full_options = |
|
|
|
|
Keyword.merge( |
|
|
|
|
[ |
|
|
|
@ -61,7 +61,7 @@ defmodule BlockScoutWeb.BlockTransactionController do |
|
|
|
|
next_page_path: next_page_path |
|
|
|
|
} |
|
|
|
|
) |
|
|
|
|
else |
|
|
|
|
|
|
|
|
|
{:error, {:invalid, :hash}} -> |
|
|
|
|
not_found(conn) |
|
|
|
|
|
|
|
|
@ -80,8 +80,7 @@ defmodule BlockScoutWeb.BlockTransactionController do |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def index(conn, %{"block_hash_or_number" => formatted_block_hash_or_number}) do |
|
|
|
|
with {:ok, block} <- |
|
|
|
|
param_block_hash_or_number_to_block(formatted_block_hash_or_number, |
|
|
|
|
case param_block_hash_or_number_to_block(formatted_block_hash_or_number, |
|
|
|
|
necessity_by_association: %{ |
|
|
|
|
[miner: :names] => :required, |
|
|
|
|
:uncles => :optional, |
|
|
|
@ -89,6 +88,7 @@ defmodule BlockScoutWeb.BlockTransactionController do |
|
|
|
|
:rewards => :optional |
|
|
|
|
} |
|
|
|
|
) do |
|
|
|
|
{:ok, block} -> |
|
|
|
|
block_transaction_count = Chain.block_to_transaction_count(block.hash) |
|
|
|
|
|
|
|
|
|
render( |
|
|
|
@ -98,7 +98,7 @@ defmodule BlockScoutWeb.BlockTransactionController do |
|
|
|
|
block_transaction_count: block_transaction_count, |
|
|
|
|
current_path: current_path(conn) |
|
|
|
|
) |
|
|
|
|
else |
|
|
|
|
|
|
|
|
|
{:error, {:invalid, :hash}} -> |
|
|
|
|
not_found(conn) |
|
|
|
|
|
|
|
|
@ -117,19 +117,23 @@ defmodule BlockScoutWeb.BlockTransactionController do |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
defp param_block_hash_or_number_to_block("0x" <> _ = param, options) do |
|
|
|
|
with {:ok, hash} <- string_to_block_hash(param) do |
|
|
|
|
case string_to_block_hash(param) do |
|
|
|
|
{:ok, hash} -> |
|
|
|
|
hash_to_block(hash, options) |
|
|
|
|
else |
|
|
|
|
:error -> {:error, {:invalid, :hash}} |
|
|
|
|
|
|
|
|
|
:error -> |
|
|
|
|
{:error, {:invalid, :hash}} |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
defp param_block_hash_or_number_to_block(number_string, options) |
|
|
|
|
when is_binary(number_string) do |
|
|
|
|
with {:ok, number} <- BlockScoutWeb.Chain.param_to_block_number(number_string) do |
|
|
|
|
case BlockScoutWeb.Chain.param_to_block_number(number_string) do |
|
|
|
|
{:ok, number} -> |
|
|
|
|
number_to_block(number, options) |
|
|
|
|
else |
|
|
|
|
{:error, :invalid} -> {:error, {:invalid, :number}} |
|
|
|
|
|
|
|
|
|
{:error, :invalid} -> |
|
|
|
|
{:error, {:invalid, :number}} |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|