diff --git a/apps/explorer_web/lib/explorer_web/controllers/address_internal_transaction_controller.ex b/apps/explorer_web/lib/explorer_web/controllers/address_internal_transaction_controller.ex new file mode 100644 index 0000000000..2e7c5b0760 --- /dev/null +++ b/apps/explorer_web/lib/explorer_web/controllers/address_internal_transaction_controller.ex @@ -0,0 +1,45 @@ +defmodule ExplorerWeb.AddressInternalTransactionController do + @moduledoc """ + Display all the Transactions that terminate at this Address. + """ + + use ExplorerWeb, :controller + + alias Explorer.Chain + + def index(conn, %{"address_id" => address_hash}) do + case Chain.hash_to_address(address_hash) do + {:ok, address} -> + # options = [ + # necessity_by_association: %{ + # block: :required, + # from_address: :optional, + # to_address: :optional, + # receipt: :required + # }, + # pagination: params + # ] + + # page = + # Chain.address_to_transactions( + # address, + # Keyword.merge(options, current_filter(params)) + # ) + + render(conn, "index.html", address: address) + + {:error, :not_found} -> + not_found(conn) + end + end + + # defp current_filter(params) do + # params + # |> Map.get("filter") + # |> case do + # "to" -> [direction: :to] + # "from" -> [direction: :from] + # _ -> [] + # end + # end +end diff --git a/apps/explorer_web/lib/explorer_web/router.ex b/apps/explorer_web/lib/explorer_web/router.ex index c5bb8d3b3f..1b40b28285 100644 --- a/apps/explorer_web/lib/explorer_web/router.ex +++ b/apps/explorer_web/lib/explorer_web/router.ex @@ -40,7 +40,8 @@ defmodule ExplorerWeb.Router do end pipeline :jasmine do - if Mix.env() != :prod, do: plug(Jasmine, js_files: ["js/test.js"], css_files: ["css/test.css"]) + if Mix.env() != :prod, + do: plug(Jasmine, js_files: ["js/test.js"], css_files: ["css/test.css"]) end pipeline :api do @@ -76,11 +77,13 @@ defmodule ExplorerWeb.Router do end resources "/addresses", AddressController, only: [:show] do + resources("/transactions", AddressTransactionController, only: [:index], as: :transaction) + resources( - "/transactions", - AddressTransactionController, + "/internal_transactions", + AddressInternalTransactionController, only: [:index], - as: :transaction + as: :internal_transaction ) end diff --git a/apps/explorer_web/lib/explorer_web/templates/address/overview.html.eex b/apps/explorer_web/lib/explorer_web/templates/address/overview.html.eex new file mode 100644 index 0000000000..4396288209 --- /dev/null +++ b/apps/explorer_web/lib/explorer_web/templates/address/overview.html.eex @@ -0,0 +1,16 @@ +
+

<%= gettext "Address" %>

+

<%= @address.hash %>

+
+
+
+
+
+
<%= gettext "Balance" %>
+
+ <%= balance(@address) %> <%= gettext "Ether" %> +
+
+
+
+
diff --git a/apps/explorer_web/lib/explorer_web/templates/address_internal_transaction/index.html.eex b/apps/explorer_web/lib/explorer_web/templates/address_internal_transaction/index.html.eex new file mode 100644 index 0000000000..0f2774d143 --- /dev/null +++ b/apps/explorer_web/lib/explorer_web/templates/address_internal_transaction/index.html.eex @@ -0,0 +1,22 @@ +
+ <%= render ExplorerWeb.AddressView, "overview.html", assigns %> + +
+
+

+ <%= link( + gettext("Transactions"), + class: "address__link address__link", + to: address_transaction_path(@conn, :index, @conn.assigns.locale, @conn.params["address_id"]) + ) %> +

+

+ <%= link( + gettext("Internal Transactions"), + class: "address__link address__link--active", + to: address_internal_transaction_path(@conn, :index, @conn.assigns.locale, @conn.params["address_id"]) + ) %> +

+
+
+
diff --git a/apps/explorer_web/lib/explorer_web/templates/address_transaction/index.html.eex b/apps/explorer_web/lib/explorer_web/templates/address_transaction/index.html.eex index af0815d9eb..948d5b1291 100644 --- a/apps/explorer_web/lib/explorer_web/templates/address_transaction/index.html.eex +++ b/apps/explorer_web/lib/explorer_web/templates/address_transaction/index.html.eex @@ -1,20 +1,5 @@
-
-

<%= gettext "Address" %>

-

<%= @address.hash %>

-
-
-
-
-
-
<%= gettext "Balance" %>
-
- <%= balance(@address) %> <%= gettext "Ether" %> -
-
-
-
-
+ <%= render ExplorerWeb.AddressView, "overview.html", assigns %>
@@ -25,6 +10,14 @@ to: address_transaction_path(@conn, :index, @conn.assigns.locale, @conn.params["address_id"]) ) %> +

+ <%= link( + gettext("Internal Transactions"), + class: "address__link address__link", + "data-test": "internal_transactions_tab_link", + to: address_internal_transaction_path(@conn, :index, @conn.assigns.locale, @conn.params["address_id"]) + ) %> +