|
|
@ -10,6 +10,7 @@ defmodule BlockScoutWeb.AddressTransactionController do |
|
|
|
|
|
|
|
|
|
|
|
alias BlockScoutWeb.TransactionView |
|
|
|
alias BlockScoutWeb.TransactionView |
|
|
|
alias Explorer.{Chain, Market} |
|
|
|
alias Explorer.{Chain, Market} |
|
|
|
|
|
|
|
alias Explorer.Chain.AddressTokenTransferCsvExporter |
|
|
|
alias Explorer.ExchangeRates.Token |
|
|
|
alias Explorer.ExchangeRates.Token |
|
|
|
alias Indexer.Fetcher.CoinBalanceOnDemand |
|
|
|
alias Indexer.Fetcher.CoinBalanceOnDemand |
|
|
|
alias Phoenix.View |
|
|
|
alias Phoenix.View |
|
|
@ -106,4 +107,24 @@ defmodule BlockScoutWeb.AddressTransactionController do |
|
|
|
not_found(conn) |
|
|
|
not_found(conn) |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def token_transfers_csv(conn, %{"address_id" => address_hash_string}) do |
|
|
|
|
|
|
|
with {:ok, address_hash} <- Chain.string_to_address_hash(address_hash_string), |
|
|
|
|
|
|
|
{:ok, address} <- Chain.hash_to_address(address_hash) do |
|
|
|
|
|
|
|
address |
|
|
|
|
|
|
|
|> AddressTokenTransferCsvExporter.export() |
|
|
|
|
|
|
|
|> Enum.into( |
|
|
|
|
|
|
|
conn |
|
|
|
|
|
|
|
|> put_resp_content_type("application/csv") |
|
|
|
|
|
|
|
|> put_resp_header("content-disposition", "attachment; filename=transactions.csv") |
|
|
|
|
|
|
|
|> send_chunked(200) |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
:error -> |
|
|
|
|
|
|
|
unprocessable_entity(conn) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{:error, :not_found} -> |
|
|
|
|
|
|
|
not_found(conn) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|