diff --git a/lib/explorer/forms/transaction_form.ex b/lib/explorer/forms/transaction_form.ex
index 2d5836b6c0..9ebbbc9070 100644
--- a/lib/explorer/forms/transaction_form.ex
+++ b/lib/explorer/forms/transaction_form.ex
@@ -24,6 +24,8 @@ defmodule Explorer.TransactionForm do
from_address: transaction |> from_address,
confirmations: block |> confirmations,
status: transaction |> status,
+ first_seen: transaction |> first_seen,
+ last_seen: transaction |> last_seen,
})
end
@@ -85,4 +87,12 @@ defmodule Explorer.TransactionForm do
gettext("Pending")
end
end
+
+ def first_seen(transaction) do
+ transaction.inserted_at |> Timex.from_now
+ end
+
+ def last_seen(transaction) do
+ transaction.updated_at |> Timex.from_now
+ end
end
diff --git a/lib/explorer_web/templates/transaction/show.html.eex b/lib/explorer_web/templates/transaction/show.html.eex
index 5bf37d6e9f..d5afd493bf 100644
--- a/lib/explorer_web/templates/transaction/show.html.eex
+++ b/lib/explorer_web/templates/transaction/show.html.eex
@@ -69,6 +69,14 @@
<%= gettext "Input" %>
<%= @transaction.input %>
+
+
<%= gettext "First Seen" %>
+ <%= @transaction.first_seen %>
+
+
+
<%= gettext "Last Seen" %>
+ <%= @transaction.last_seen %>
+
diff --git a/test/explorer/forms/transaction_form_test.exs b/test/explorer/forms/transaction_form_test.exs
index 75b61a7d94..6994394aa5 100644
--- a/test/explorer/forms/transaction_form_test.exs
+++ b/test/explorer/forms/transaction_form_test.exs
@@ -13,7 +13,9 @@ defmodule Explorer.TransactionFormTest do
timestamp: time,
})
transaction =
- insert(:transaction)
+ insert(:transaction,
+ inserted_at: Timex.parse!("1970-01-01T00:00:18-00:00", "{ISO:Extended}"),
+ updated_at: Timex.parse!("1980-01-01T00:00:18-00:00", "{ISO:Extended}"))
|> with_block(block)
|> with_addresses(%{to: "0xsleepypuppy", from: "0xilovefrogs"})
|> Repo.preload(:block)
@@ -30,11 +32,17 @@ defmodule Explorer.TransactionFormTest do
from_address: "0xilovefrogs",
confirmations: 23,
status: "Success",
+ first_seen: "48 years ago",
+ last_seen: "38 years ago",
}))
end
test "works when there is no block" do
- transaction = insert(:transaction) |> with_addresses(%{to: "0xchadmuska", from: "0xtonyhawk"}) |> Repo.preload(:block)
+ transaction = insert(
+ :transaction,
+ inserted_at: Timex.parse!("1970-01-01T00:00:18-00:00", "{ISO:Extended}"),
+ updated_at: Timex.parse!("1980-01-01T00:00:18-00:00", "{ISO:Extended}"))
+ |> with_addresses(%{to: "0xchadmuska", from: "0xtonyhawk"}) |> Repo.preload(:block)
form = TransactionForm.build(transaction)
assert(form == Map.merge(transaction, %{
@@ -47,6 +55,8 @@ defmodule Explorer.TransactionFormTest do
from_address: "0xtonyhawk",
confirmations: 0,
status: "Pending",
+ first_seen: "48 years ago",
+ last_seen: "38 years ago",
}))
end
end
diff --git a/test/explorer_web/features/contributor_browsing_test.exs b/test/explorer_web/features/contributor_browsing_test.exs
index a00a2a2fbd..09eed2f17d 100644
--- a/test/explorer_web/features/contributor_browsing_test.exs
+++ b/test/explorer_web/features/contributor_browsing_test.exs
@@ -65,6 +65,8 @@ defmodule ExplorerWeb.UserListTest do
gas_price: 7890000000898912300045,
input: "0x00012",
nonce: 99045,
+ inserted_at: Timex.parse!("1970-01-01T00:00:18-00:00", "{ISO:Extended}"),
+ updated_at: Timex.parse!("1980-01-01T00:00:18-00:00", "{ISO:Extended}"),
})
|> with_block(block)
|> with_addresses(%{to: "0xabelincoln", from: "0xhowardtaft"})
@@ -94,6 +96,8 @@ defmodule ExplorerWeb.UserListTest do
|> assert_has(css(".transaction__item", text: "0xabelincoln"))
|> assert_has(css(".transaction__item", text: "0xhowardtaft"))
|> assert_has(css(".transaction__item", text: "block confirmations"))
+ |> assert_has(css(".transaction__item", text: "48 years ago"))
+ |> assert_has(css(".transaction__item", text: "38 years ago"))
session
|> click(link("0xabelincoln"))