|
|
|
@ -100,6 +100,7 @@ defmodule BlockScoutWeb.API.RPC.AddressController do |
|
|
|
|
|
|
|
|
|
with {:address_param, {:ok, address_param}} <- fetch_address(params), |
|
|
|
|
{:format, {:ok, address_hash}} <- to_address_hash(address_param), |
|
|
|
|
{:address, :ok} <- {:address, Chain.check_address_exists(address_hash)}, |
|
|
|
|
{:ok, transactions} <- list_transactions(address_hash, options) do |
|
|
|
|
render(conn, :txlist, %{transactions: transactions}) |
|
|
|
|
else |
|
|
|
@ -113,7 +114,7 @@ defmodule BlockScoutWeb.API.RPC.AddressController do |
|
|
|
|
|> put_status(200) |
|
|
|
|
|> render(:error, error: "Invalid address format") |
|
|
|
|
|
|
|
|
|
{:error, :not_found} -> |
|
|
|
|
{_, :not_found} -> |
|
|
|
|
render(conn, :error, error: "No transactions found", data: []) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
@ -148,13 +149,14 @@ defmodule BlockScoutWeb.API.RPC.AddressController do |
|
|
|
|
options = optional_params(params) |
|
|
|
|
|
|
|
|
|
with {:format, {:ok, address_hash}} <- to_address_hash(address_param), |
|
|
|
|
{:address, :ok} <- {:address, Chain.check_address_exists(address_hash)}, |
|
|
|
|
{:ok, internal_transactions} <- list_internal_transactions(address_hash, options) do |
|
|
|
|
render(conn, :txlistinternal, %{internal_transactions: internal_transactions}) |
|
|
|
|
else |
|
|
|
|
{:format, :error} -> |
|
|
|
|
render(conn, :error, error: "Invalid address format") |
|
|
|
|
|
|
|
|
|
{:error, :not_found} -> |
|
|
|
|
{_, :not_found} -> |
|
|
|
|
render(conn, :error, error: "No internal transactions found", data: []) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
@ -165,6 +167,7 @@ defmodule BlockScoutWeb.API.RPC.AddressController do |
|
|
|
|
with {:address_param, {:ok, address_param}} <- fetch_address(params), |
|
|
|
|
{:format, {:ok, address_hash}} <- to_address_hash(address_param), |
|
|
|
|
{:contract_address, {:ok, contract_address_hash}} <- to_contract_address_hash(params["contractaddress"]), |
|
|
|
|
{:address, :ok} <- {:address, Chain.check_address_exists(address_hash)}, |
|
|
|
|
{:ok, token_transfers} <- list_token_transfers(address_hash, contract_address_hash, options) do |
|
|
|
|
render(conn, :tokentx, %{token_transfers: token_transfers}) |
|
|
|
|
else |
|
|
|
@ -177,7 +180,7 @@ defmodule BlockScoutWeb.API.RPC.AddressController do |
|
|
|
|
{:contract_address, :error} -> |
|
|
|
|
render(conn, :error, error: "Invalid contract address format") |
|
|
|
|
|
|
|
|
|
{:error, :not_found} -> |
|
|
|
|
{_, :not_found} -> |
|
|
|
|
render(conn, :error, error: "No token transfers found", data: []) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
@ -202,6 +205,7 @@ defmodule BlockScoutWeb.API.RPC.AddressController do |
|
|
|
|
def tokenlist(conn, params) do |
|
|
|
|
with {:address_param, {:ok, address_param}} <- fetch_address(params), |
|
|
|
|
{:format, {:ok, address_hash}} <- to_address_hash(address_param), |
|
|
|
|
{:address, :ok} <- {:address, Chain.check_address_exists(address_hash)}, |
|
|
|
|
{:ok, token_list} <- list_tokens(address_hash) do |
|
|
|
|
render(conn, :token_list, %{token_list: token_list}) |
|
|
|
|
else |
|
|
|
@ -211,7 +215,7 @@ defmodule BlockScoutWeb.API.RPC.AddressController do |
|
|
|
|
{:format, :error} -> |
|
|
|
|
render(conn, :error, error: "Invalid address format") |
|
|
|
|
|
|
|
|
|
{:error, :not_found} -> |
|
|
|
|
{_, :not_found} -> |
|
|
|
|
render(conn, :error, error: "No tokens found", data: []) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
@ -221,6 +225,7 @@ defmodule BlockScoutWeb.API.RPC.AddressController do |
|
|
|
|
|
|
|
|
|
with {:address_param, {:ok, address_param}} <- fetch_address(params), |
|
|
|
|
{:format, {:ok, address_hash}} <- to_address_hash(address_param), |
|
|
|
|
{:address, :ok} <- {:address, Chain.check_address_exists(address_hash)}, |
|
|
|
|
{:ok, blocks} <- list_blocks(address_hash, options) do |
|
|
|
|
render(conn, :getminedblocks, %{blocks: blocks}) |
|
|
|
|
else |
|
|
|
@ -230,7 +235,7 @@ defmodule BlockScoutWeb.API.RPC.AddressController do |
|
|
|
|
{:format, :error} -> |
|
|
|
|
render(conn, :error, error: "Invalid address format") |
|
|
|
|
|
|
|
|
|
{:error, :not_found} -> |
|
|
|
|
{_, :not_found} -> |
|
|
|
|
render(conn, :error, error: "No blocks found", data: []) |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
@ -495,8 +500,8 @@ defmodule BlockScoutWeb.API.RPC.AddressController do |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
defp list_internal_transactions(transaction_hash, options) do |
|
|
|
|
case Etherscan.list_internal_transactions(transaction_hash, options) do |
|
|
|
|
defp list_internal_transactions(address_hash, options) do |
|
|
|
|
case Etherscan.list_internal_transactions(address_hash, options) do |
|
|
|
|
[] -> {:error, :not_found} |
|
|
|
|
internal_transactions -> {:ok, internal_transactions} |
|
|
|
|
end |
|
|
|
|