Blockchain explorer for Ethereum based network and a tool for inspecting and analyzing EVM based blockchains.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
blockscout/lib/explorer_web/controllers/transaction_controller.ex

35 lines
1.1 KiB

defmodule ExplorerWeb.TransactionController do
use ExplorerWeb, :controller
import Ecto.Query
alias Explorer.Repo.NewRelic, as: Repo
alias Explorer.Transaction
alias Explorer.TransactionForm
def index(conn, params) do
query = from transaction in Transaction,
left_join: block_transaction in assoc(transaction, :block_transaction),
left_join: block in assoc(block_transaction, :block),
preload: [block_transaction: block_transaction, block: block],
order_by: [asc: block.inserted_at]
transactions = Repo.paginate(query, params)
render(conn, "index.html", transactions: transactions)
end
def show(conn, params) do
query = from transaction in Transaction,
left_join: block_transaction in assoc(transaction, :block_transaction),
left_join: block in assoc(block_transaction, :block),
preload: [block_transaction: block_transaction, block: block],
where: transaction.hash == ^params["id"],
limit: 1
transaction = query |> Repo.one |> TransactionForm.build
render(conn, "show.html", transaction: transaction)
end
end