- <%= render BlockScoutWeb.AddressView, "_link.html", address_hash: @transaction.from_address_hash, contract: BlockScoutWeb.AddressView.contract?(@transaction.from_address), locale: @locale %>
+ <%= render BlockScoutWeb.AddressView, "_link.html", address_hash: @transaction.from_address_hash, contract: BlockScoutWeb.AddressView.contract?(@transaction.from_address) %>
→
<%= if @transaction.to_address_hash do %>
- <%= render BlockScoutWeb.AddressView, "_link.html", address_hash: @transaction.to_address_hash, contract: BlockScoutWeb.AddressView.contract?(@transaction.to_address), locale: @locale %>
+ <%= render BlockScoutWeb.AddressView, "_link.html", address_hash: @transaction.to_address_hash, contract: BlockScoutWeb.AddressView.contract?(@transaction.to_address) %>
<% else %>
<%= gettext("Contract Address Pending") %>
<% end %>
@@ -34,7 +34,7 @@
<%= link(
block,
class: "transaction__link",
- to: block_path(@conn, :show, @conn.assigns.locale, block)
+ to: block_path(@conn, :show, block)
) %>
<% else %>
<%= gettext "Pending" %>
@@ -55,7 +55,9 @@
- <%= gettext "TX Fee" %>
- - <%= formatted_fee(@transaction, denomination: :ether) %> (<%= formatted_fee(@transaction, exchange_rate: @exchange_rate) %>)
+ -
+ <%= formatted_fee(@transaction, denomination: :ether) %> ( data-usd-exchange-rate=<%= @exchange_rate.usd_value %>>)
+
@@ -82,7 +84,7 @@
<%= gettext "Ether" %> <%= gettext "Value" %>
<%= value(@transaction) %>
- <%= formatted_usd_value(@transaction, @exchange_rate) %>
+ data-usd-exchange-rate=<%= @exchange_rate.usd_value %>>
diff --git a/apps/block_scout_web/lib/block_scout_web/templates/transaction_internal_transaction/_internal_transaction.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/transaction_internal_transaction/_internal_transaction.html.eex
index ef680052e5..c6c4b54113 100644
--- a/apps/block_scout_web/lib/block_scout_web/templates/transaction_internal_transaction/_internal_transaction.html.eex
+++ b/apps/block_scout_web/lib/block_scout_web/templates/transaction_internal_transaction/_internal_transaction.html.eex
@@ -4,11 +4,11 @@
<%= gettext("Internal Transaction") %>
- <%= render BlockScoutWeb.TransactionView, "_link.html", locale: @locale, transaction_hash: @internal_transaction.transaction_hash %>
+ <%= render BlockScoutWeb.TransactionView, "_link.html", transaction_hash: @internal_transaction.transaction_hash %>
- <%= render BlockScoutWeb.AddressView, "_link.html", address_hash: @internal_transaction.from_address_hash, contract: BlockScoutWeb.AddressView.contract?(@internal_transaction.from_address), locale: @locale %>
+ <%= render BlockScoutWeb.AddressView, "_link.html", address_hash: @internal_transaction.from_address_hash, contract: BlockScoutWeb.AddressView.contract?(@internal_transaction.from_address) %>
→
- <%= render BlockScoutWeb.AddressView, "_link.html", address_hash: BlockScoutWeb.InternalTransactionView.to_address_hash(@internal_transaction), contract: BlockScoutWeb.AddressView.contract?(@internal_transaction.to_address), locale: @locale %>
+ <%= render BlockScoutWeb.AddressView, "_link.html", address_hash: BlockScoutWeb.InternalTransactionView.to_address_hash(@internal_transaction), contract: BlockScoutWeb.AddressView.contract?(@internal_transaction.to_address) %>
diff --git a/apps/block_scout_web/lib/block_scout_web/templates/transaction_internal_transaction/index.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/transaction_internal_transaction/index.html.eex
index b6200c42d1..e11701176c 100644
--- a/apps/block_scout_web/lib/block_scout_web/templates/transaction_internal_transaction/index.html.eex
+++ b/apps/block_scout_web/lib/block_scout_web/templates/transaction_internal_transaction/index.html.eex
@@ -11,7 +11,7 @@
<%= link(
gettext("Token Transfers"),
class: "nav-link",
- to: transaction_token_transfer_path(@conn, :index, @conn.assigns.locale, @transaction)
+ to: transaction_token_transfer_path(@conn, :index, @transaction)
) %>
<% end %>
@@ -19,14 +19,14 @@
<%= link(
gettext("Internal Transactions"),
class: "nav-link active",
- to: transaction_internal_transaction_path(@conn, :index, @conn.assigns.locale, @transaction)
+ to: transaction_internal_transaction_path(@conn, :index, @transaction)
) %>
<%= link(
gettext("Logs"),
class: "nav-link",
- to: transaction_log_path(@conn, :index, @conn.assigns.locale, @transaction),
+ to: transaction_log_path(@conn, :index, @transaction),
"data-test": "transaction_logs_link"
) %>
@@ -41,19 +41,19 @@
<%= link(
gettext("Token Transfers"),
class: "dropdown-item",
- to: transaction_token_transfer_path(@conn, :index, @conn.assigns.locale, @transaction),
+ to: transaction_token_transfer_path(@conn, :index, @transaction),
"data-test": "transaction_token_transfer_link"
) %>
<% end %>
<%= link(
gettext("Internal Transactions"),
class: "dropdown-item",
- to: transaction_internal_transaction_path(@conn, :index, @conn.assigns.locale, @transaction)
+ to: transaction_internal_transaction_path(@conn, :index, @transaction)
) %>
<%= link(
gettext("Logs"),
class: "dropdown-item",
- to: transaction_log_path(@conn, :index, @conn.assigns.locale, @transaction),
+ to: transaction_log_path(@conn, :index, @transaction),
"data-test": "transaction_logs_link"
) %>
@@ -64,7 +64,7 @@
<%= gettext "Internal Transactions" %>
<%= if Enum.count(@internal_transactions) > 0 do %>
<%= for internal_transaction <- @internal_transactions do %>
- <%= render "_internal_transaction.html", locale: @locale, internal_transaction: internal_transaction %>
+ <%= render "_internal_transaction.html", internal_transaction: internal_transaction %>
<% end %>
<% else %>
@@ -79,7 +79,6 @@
to: transaction_internal_transaction_path(
@conn,
:index,
- @conn.assigns.locale,
@transaction,
@next_page_params
)
diff --git a/apps/block_scout_web/lib/block_scout_web/templates/transaction_log/index.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/transaction_log/index.html.eex
index e0319fbd65..4de4100181 100644
--- a/apps/block_scout_web/lib/block_scout_web/templates/transaction_log/index.html.eex
+++ b/apps/block_scout_web/lib/block_scout_web/templates/transaction_log/index.html.eex
@@ -12,7 +12,7 @@
<%= link(
gettext("Token Transfers"),
class: "nav-link",
- to: transaction_token_transfer_path(@conn, :index, @conn.assigns.locale, @transaction)
+ to: transaction_token_transfer_path(@conn, :index, @transaction)
) %>
<% end %>
@@ -20,14 +20,14 @@
<%= link(
gettext("Internal Transactions"),
class: "nav-link",
- to: transaction_internal_transaction_path(@conn, :index, @conn.assigns.locale, @transaction)
+ to: transaction_internal_transaction_path(@conn, :index, @transaction)
) %>
<%= link(
gettext("Logs"),
class: "nav-link active",
- to: transaction_log_path(@conn, :index, @conn.assigns.locale, @transaction)
+ to: transaction_log_path(@conn, :index, @transaction)
) %>
@@ -41,19 +41,19 @@
<%= link(
gettext("Token Transfers"),
class: "dropdown-item",
- to: transaction_token_transfer_path(@conn, :index, @conn.assigns.locale, @transaction),
+ to: transaction_token_transfer_path(@conn, :index, @transaction),
"data-test": "transaction_token_transfer_link"
) %>
<% end %>
<%= link(
gettext("Internal Transactions"),
class: "dropdown-item",
- to: transaction_path(@conn, :show, @conn.assigns.locale, @transaction)
+ to: transaction_path(@conn, :show, @transaction)
) %>
<%= link(
gettext("Logs"),
class: "dropdown-item",
- to: transaction_log_path(@conn, :index, @conn.assigns.locale, @transaction),
+ to: transaction_log_path(@conn, :index, @transaction),
"data-test": "transaction_logs_link"
) %>
@@ -72,7 +72,7 @@
<%= link(
log.address,
- to: address_path(@conn, :show, @conn.assigns.locale, log.address),
+ to: address_path(@conn, :show, log.address),
"data-test": "log_address_link",
"data-address-hash": log.address
) %>
@@ -124,7 +124,6 @@
to: transaction_log_path(
@conn,
:index,
- @conn.assigns.locale,
@transaction,
@next_page_params
)
diff --git a/apps/block_scout_web/lib/block_scout_web/templates/transaction_token_transfer/_token_transfer.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/transaction_token_transfer/_token_transfer.html.eex
index dda0a9eff2..e6ef09c6c1 100644
--- a/apps/block_scout_web/lib/block_scout_web/templates/transaction_token_transfer/_token_transfer.html.eex
+++ b/apps/block_scout_web/lib/block_scout_web/templates/transaction_token_transfer/_token_transfer.html.eex
@@ -5,16 +5,16 @@
- <%= render BlockScoutWeb.TransactionView, "_link.html", locale: @locale, transaction_hash: @token_transfer.transaction_hash %>
+ <%= render BlockScoutWeb.TransactionView, "_link.html", transaction_hash: @token_transfer.transaction_hash %>
- <%= render BlockScoutWeb.AddressView, "_link.html", address_hash: @token_transfer.from_address_hash, contract: BlockScoutWeb.AddressView.contract?(@token_transfer.from_address), locale: @locale %>
+ <%= render BlockScoutWeb.AddressView, "_link.html", address_hash: @token_transfer.from_address_hash, contract: BlockScoutWeb.AddressView.contract?(@token_transfer.from_address) %>
→
- <%= render BlockScoutWeb.AddressView, "_link.html", address_hash: @token_transfer.to_address_hash, contract: BlockScoutWeb.AddressView.contract?(@token_transfer.to_address), locale: @locale %>
+ <%= render BlockScoutWeb.AddressView, "_link.html", address_hash: @token_transfer.to_address_hash, contract: BlockScoutWeb.AddressView.contract?(@token_transfer.to_address) %>
<%= token_transfer_amount(@token_transfer) %>
- <%= link(token_symbol(@token_transfer.token), to: token_path(@conn, :show, @locale, @token_transfer.token.contract_address_hash)) %>
+ <%= link(token_symbol(@token_transfer.token), to: token_path(@conn, :show, @token_transfer.token.contract_address_hash)) %>
diff --git a/apps/block_scout_web/lib/block_scout_web/templates/transaction_token_transfer/index.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/transaction_token_transfer/index.html.eex
index 64fb2b7012..145a7ca439 100644
--- a/apps/block_scout_web/lib/block_scout_web/templates/transaction_token_transfer/index.html.eex
+++ b/apps/block_scout_web/lib/block_scout_web/templates/transaction_token_transfer/index.html.eex
@@ -10,21 +10,21 @@
<%= link(
gettext("Token Transfers"),
class: "nav-link active",
- to: transaction_token_transfer_path(@conn, :index, @conn.assigns.locale, @transaction)
+ to: transaction_token_transfer_path(@conn, :index, @transaction)
) %>
<%= link(
gettext("Internal Transactions"),
class: "nav-link",
- to: transaction_internal_transaction_path(@conn, :index, @conn.assigns.locale, @transaction)
+ to: transaction_internal_transaction_path(@conn, :index, @transaction)
) %>
<%= link(
gettext("Logs"),
class: "nav-link",
- to: transaction_log_path(@conn, :index, @conn.assigns.locale, @transaction)
+ to: transaction_log_path(@conn, :index, @transaction)
) %>
@@ -37,17 +37,17 @@
<%= link(
gettext("Token Transfers"),
class: "dropdown-item",
- to: transaction_token_transfer_path(@conn, :index, @conn.assigns.locale, @transaction)
+ to: transaction_token_transfer_path(@conn, :index, @transaction)
) %>
<%= link(
gettext("Internal Transactions"),
class: "dropdown-item",
- to: transaction_internal_transaction_path(@conn, :index, @conn.assigns.locale, @transaction)
+ to: transaction_internal_transaction_path(@conn, :index, @transaction)
) %>
<%= link(
gettext("Logs"),
class: "dropdown-item",
- to: transaction_log_path(@conn, :index, @conn.assigns.locale, @transaction)
+ to: transaction_log_path(@conn, :index, @transaction)
) %>
@@ -58,7 +58,7 @@
<%= gettext "Token Transfers" %>
<%= if Enum.any?(@token_transfers) do %>
<%= for token_transfer <- @token_transfers do %>
- <%= render "_token_transfer.html", locale: @locale, token_transfer: token_transfer, conn: @conn %>
+ <%= render "_token_transfer.html", token_transfer: token_transfer, conn: @conn %>
<% end %>
<% else %>
@@ -74,7 +74,6 @@
to: transaction_token_transfer_path(
@conn,
:index,
- @conn.assigns.locale,
@transaction,
@next_page_params
)
diff --git a/apps/block_scout_web/lib/block_scout_web/views/address_view.ex b/apps/block_scout_web/lib/block_scout_web/views/address_view.ex
index fe5bf39828..5cfd4ec703 100644
--- a/apps/block_scout_web/lib/block_scout_web/views/address_view.ex
+++ b/apps/block_scout_web/lib/block_scout_web/views/address_view.ex
@@ -1,10 +1,7 @@
defmodule BlockScoutWeb.AddressView do
use BlockScoutWeb, :view
- alias Explorer.Chain.{Address, Hash, SmartContract, Wei}
-
- alias Explorer.ExchangeRates.Token
- alias BlockScoutWeb.ExchangeRates.USD
+ alias Explorer.Chain.{Address, Hash, SmartContract}
@dialyzer :no_match
@@ -37,20 +34,6 @@ defmodule BlockScoutWeb.AddressView do
def contract?(nil), do: true
- def formatted_usd(%Address{fetched_coin_balance: nil}, _), do: nil
-
- def formatted_usd(%Address{fetched_coin_balance: balance}, %Token{} = exchange_rate) do
- case Wei.cast(balance) do
- {:ok, wei} ->
- wei
- |> USD.from(exchange_rate)
- |> format_usd_value()
-
- _ ->
- nil
- end
- end
-
def hash(%Address{hash: hash}) do
to_string(hash)
end
@@ -79,25 +62,23 @@ defmodule BlockScoutWeb.AddressView do
def smart_contract_with_read_only_functions?(%Address{smart_contract: nil}), do: false
- def display_address_hash(current_address, target_address, locale, truncate \\ false)
+ def display_address_hash(current_address, target_address, truncate \\ false)
- def display_address_hash(nil, target_address, locale, truncate) do
+ def display_address_hash(nil, target_address, truncate) do
render(
"_link.html",
address_hash: target_address.hash,
contract: contract?(target_address),
- locale: locale,
truncate: truncate
)
end
- def display_address_hash(current_address, target_address, locale, truncate) do
+ def display_address_hash(current_address, target_address, truncate) do
if current_address.hash == target_address.hash do
render(
"_responsive_hash.html",
address_hash: current_address.hash,
contract: contract?(current_address),
- locale: locale,
truncate: truncate
)
else
@@ -105,7 +86,6 @@ defmodule BlockScoutWeb.AddressView do
"_link.html",
address_hash: target_address.hash,
contract: contract?(target_address),
- locale: locale,
truncate: truncate
)
end
diff --git a/apps/block_scout_web/lib/block_scout_web/views/chain_view.ex b/apps/block_scout_web/lib/block_scout_web/views/chain_view.ex
index be4f383c3f..bb5814e87d 100644
--- a/apps/block_scout_web/lib/block_scout_web/views/chain_view.ex
+++ b/apps/block_scout_web/lib/block_scout_web/views/chain_view.ex
@@ -1,9 +1,6 @@
defmodule BlockScoutWeb.ChainView do
use BlockScoutWeb, :view
- alias Explorer.ExchangeRates.Token
- alias BlockScoutWeb.ExchangeRates.USD
-
def encode_market_history_data(market_history_data) do
market_history_data
|> Enum.map(fn day -> Map.take(day, [:closing_price, :date]) end)
@@ -13,16 +10,4 @@ defmodule BlockScoutWeb.ChainView do
_ -> []
end
end
-
- def format_exchange_rate(%Token{usd_value: usd_value}) do
- usd_value
- |> USD.from()
- |> format_usd_value()
- end
-
- def format_market_cap(%Token{market_cap_usd: market_cap}) do
- market_cap
- |> USD.from()
- |> format_usd_value()
- end
end
diff --git a/apps/block_scout_web/lib/block_scout_web/views/currency_helpers.ex b/apps/block_scout_web/lib/block_scout_web/views/currency_helpers.ex
index 9005997a30..9d50e68ce4 100644
--- a/apps/block_scout_web/lib/block_scout_web/views/currency_helpers.ex
+++ b/apps/block_scout_web/lib/block_scout_web/views/currency_helpers.ex
@@ -3,46 +3,8 @@ defmodule BlockScoutWeb.CurrencyHelpers do
Helper functions for interacting with `t:BlockScoutWeb.ExchangeRates.USD.t/0` values.
"""
- alias BlockScoutWeb.ExchangeRates.USD
alias BlockScoutWeb.Cldr.Number
- @doc """
- Formats a `BlockScoutWeb.ExchangeRates.USD` value into USD and applies a unit label.
-
- ## Examples
-
- iex> format_usd_value(%USD{value: Decimal.new(0.0000001)})
- "< $0.000001 USD"
-
- iex> format_usd_value(%USD{value: Decimal.new(0.123456789)})
- "$0.123457 USD"
-
- iex> format_usd_value(%USD{value: Decimal.new(0.1234)})
- "$0.123400 USD"
-
- iex> format_usd_value(%USD{value: Decimal.new(1.23456789)})
- "$1.23 USD"
-
- iex> format_usd_value(%USD{value: Decimal.new(1.2)})
- "$1.20 USD"
-
- iex> format_usd_value(%USD{value: Decimal.new(123456.789)})
- "$123,457 USD"
- """
- @spec format_usd_value(USD.t() | nil) :: binary() | nil
- def format_usd_value(nil), do: nil
-
- def format_usd_value(%USD{value: nil}), do: nil
-
- def format_usd_value(%USD{value: value}) do
- cond do
- Decimal.cmp(value, "0.000001") == :lt -> "< $0.000001 USD"
- Decimal.cmp(value, 1) == :lt -> "$#{Number.to_string!(value, format: "0.000000")} USD"
- Decimal.cmp(value, 100_000) == :lt -> "$#{Number.to_string!(value, format: "#,###.00")} USD"
- true -> "$#{Number.to_string!(value, format: "#,###")} USD"
- end
- end
-
@doc """
Formats the given integer value to a currency format.
diff --git a/apps/block_scout_web/lib/block_scout_web/views/transaction_view.ex b/apps/block_scout_web/lib/block_scout_web/views/transaction_view.ex
index 5b851a372f..4cd0c9d9a2 100644
--- a/apps/block_scout_web/lib/block_scout_web/views/transaction_view.ex
+++ b/apps/block_scout_web/lib/block_scout_web/views/transaction_view.ex
@@ -4,9 +4,7 @@ defmodule BlockScoutWeb.TransactionView do
alias Cldr.Number
alias Explorer.Chain
alias Explorer.Chain.{Address, InternalTransaction, Transaction, Wei}
- alias Explorer.ExchangeRates.Token
alias BlockScoutWeb.{AddressView, BlockView}
- alias BlockScoutWeb.ExchangeRates.USD
import BlockScoutWeb.Gettext
@@ -30,14 +28,18 @@ defmodule BlockScoutWeb.TransactionView do
def to_address_hash(%Transaction{to_address: %Address{hash: address_hash}}), do: address_hash
+ def fee(%Transaction{} = transaction) do
+ {_, value} = Chain.fee(transaction, :wei)
+ value
+ end
+
def formatted_fee(%Transaction{} = transaction, opts) do
transaction
|> Chain.fee(:wei)
- |> fee_to_currency(opts)
+ |> fee_to_denomination(opts)
|> case do
- {_, nil} -> nil
{:actual, value} -> value
- {:maximum, value} -> "<= " <> value
+ {:maximum, value} -> "#{gettext("Max of")} #{value}"
end
end
@@ -80,12 +82,6 @@ defmodule BlockScoutWeb.TransactionView do
end
end
- def formatted_usd_value(%Transaction{value: nil}, _token), do: nil
-
- def formatted_usd_value(%Transaction{value: value}, token) do
- format_usd_value(USD.from(value, token))
- end
-
defdelegate formatted_timestamp(block), to: BlockView
def gas(%type{gas: gas}) when is_transaction_type(type) do
@@ -137,23 +133,6 @@ defmodule BlockScoutWeb.TransactionView do
format_wei_value(value, :ether, include_unit_label: include_label?)
end
- defp fee_to_currency(fee, options) do
- case Keyword.fetch(options, :exchange_rate) do
- {:ok, exchange_rate} -> fee_to_usd(fee, exchange_rate)
- :error -> fee_to_denomination(fee, options)
- end
- end
-
- defp fee_to_usd({fee_type, fee}, %Token{} = exchange_rate) do
- formatted =
- fee
- |> Wei.from(:wei)
- |> USD.from(exchange_rate)
- |> format_usd_value()
-
- {fee_type, formatted}
- end
-
defp fee_to_denomination({fee_type, fee}, opts) do
denomination = Keyword.get(opts, :denomination)
include_label? = Keyword.get(opts, :include_label, true)
diff --git a/apps/block_scout_web/mix.exs b/apps/block_scout_web/mix.exs
index 14d14cbbb8..94b52b3389 100644
--- a/apps/block_scout_web/mix.exs
+++ b/apps/block_scout_web/mix.exs
@@ -52,7 +52,6 @@ defmodule BlockScoutWeb.Mixfile do
:timex,
:timex_ecto,
:crontab,
- :set_locale,
:logger,
:runtime_tools
]
@@ -89,8 +88,6 @@ defmodule BlockScoutWeb.Mixfile do
{:phoenix_live_reload, "~> 1.0", only: [:dev]},
{:phoenix_pubsub, "~> 1.0"},
{:postgrex, ">= 0.0.0"},
- # Waiting on https://github.com/smeevil/set_locale/pull/9
- {:set_locale, github: "minifast/set_locale", branch: "master"},
{:sobelow, ">= 0.7.0", only: [:dev, :test], runtime: false},
{:timex, "~> 3.1.24"},
{:timex_ecto, "~> 3.2.1"},
diff --git a/apps/block_scout_web/priv/gettext/default.pot b/apps/block_scout_web/priv/gettext/default.pot
index cdcafba536..851924fc41 100644
--- a/apps/block_scout_web/priv/gettext/default.pot
+++ b/apps/block_scout_web/priv/gettext/default.pot
@@ -6,7 +6,7 @@ msgstr ""
msgid "Block"
msgstr ""
-#: lib/block_scout_web/templates/chain/show.html.eex:58
+#: lib/block_scout_web/templates/chain/show.html.eex:56
#: lib/block_scout_web/templates/layout/_topnav.html.eex:13
msgid "Blocks"
msgstr ""
@@ -39,18 +39,18 @@ msgstr ""
#: lib/block_scout_web/templates/address_read_contract/index.html.eex:10
#: lib/block_scout_web/templates/address_transaction/index.html.eex:13
#: lib/block_scout_web/templates/address_transaction/index.html.eex:55
-#: lib/block_scout_web/templates/address_transaction/index.html.eex:131
+#: lib/block_scout_web/templates/address_transaction/index.html.eex:129
#: lib/block_scout_web/templates/block_transaction/index.html.eex:13
#: lib/block_scout_web/templates/block_transaction/index.html.eex:26
#: lib/block_scout_web/templates/block_transaction/index.html.eex:36
-#: lib/block_scout_web/templates/chain/show.html.eex:75
+#: lib/block_scout_web/templates/chain/show.html.eex:73
#: lib/block_scout_web/templates/layout/_topnav.html.eex:18
#: lib/block_scout_web/templates/pending_transaction/index.html.eex:46
#: lib/block_scout_web/templates/transaction/index.html.eex:56
msgid "Transactions"
msgstr ""
-#: lib/block_scout_web/templates/transaction/overview.html.eex:82
+#: lib/block_scout_web/templates/transaction/overview.html.eex:84
msgid "Value"
msgstr ""
@@ -110,7 +110,7 @@ msgstr ""
msgid "Cumulative Gas Used"
msgstr ""
-#: lib/block_scout_web/templates/transaction/overview.html.eex:93
+#: lib/block_scout_web/templates/transaction/overview.html.eex:95
msgid "Gas"
msgstr ""
@@ -118,7 +118,7 @@ msgstr ""
msgid "Gas Price"
msgstr ""
-#: lib/block_scout_web/templates/transaction/overview.html.eex:63
+#: lib/block_scout_web/templates/transaction/overview.html.eex:65
msgid "Input"
msgstr ""
@@ -130,12 +130,12 @@ msgstr ""
msgid "%{count} transactions in this block"
msgstr ""
-#: lib/block_scout_web/views/address_view.ex:15
+#: lib/block_scout_web/views/address_view.ex:12
msgid "Address"
msgstr ""
-#: lib/block_scout_web/templates/address_internal_transaction/index.html.eex:106
-#: lib/block_scout_web/templates/address_transaction/index.html.eex:117
+#: lib/block_scout_web/templates/address_internal_transaction/index.html.eex:105
+#: lib/block_scout_web/templates/address_transaction/index.html.eex:116
#: lib/block_scout_web/views/address_internal_transaction_view.ex:10
#: lib/block_scout_web/views/address_transaction_view.ex:10
msgid "From"
@@ -146,7 +146,7 @@ msgstr ""
msgid "Overview"
msgstr ""
-#: lib/block_scout_web/views/transaction_view.ex:79
+#: lib/block_scout_web/views/transaction_view.ex:81
msgid "Success"
msgstr ""
@@ -198,8 +198,8 @@ msgstr ""
#: lib/block_scout_web/templates/transaction/index.html.eex:16
#: lib/block_scout_web/templates/transaction/index.html.eex:35
#: lib/block_scout_web/templates/transaction/overview.html.eex:40
-#: lib/block_scout_web/views/transaction_view.ex:44
-#: lib/block_scout_web/views/transaction_view.ex:78
+#: lib/block_scout_web/views/transaction_view.ex:46
+#: lib/block_scout_web/views/transaction_view.ex:80
msgid "Pending"
msgstr ""
@@ -267,11 +267,11 @@ msgstr ""
msgid "Next Page"
msgstr ""
-#: lib/block_scout_web/views/transaction_view.ex:76
+#: lib/block_scout_web/views/transaction_view.ex:78
msgid "Failed"
msgstr ""
-#: lib/block_scout_web/views/transaction_view.ex:77
+#: lib/block_scout_web/views/transaction_view.ex:79
msgid "Out of Gas"
msgstr ""
@@ -291,7 +291,7 @@ msgstr ""
#: lib/block_scout_web/templates/address_internal_transaction/_internal_transaction.html.eex:22
#: lib/block_scout_web/templates/pending_transaction/index.html.eex:68
#: lib/block_scout_web/templates/transaction/_tile.html.eex:24
-#: lib/block_scout_web/templates/transaction/overview.html.eex:82
+#: lib/block_scout_web/templates/transaction/overview.html.eex:84
#: lib/block_scout_web/templates/transaction_internal_transaction/_internal_transaction.html.eex:16
#: lib/block_scout_web/views/wei_helpers.ex:72
msgid "Ether"
@@ -305,7 +305,7 @@ msgstr ""
#: lib/block_scout_web/templates/address_contract/index.html.eex:17
#: lib/block_scout_web/templates/address_internal_transaction/index.html.eex:20
#: lib/block_scout_web/templates/address_internal_transaction/index.html.eex:60
-#: lib/block_scout_web/templates/address_internal_transaction/index.html.eex:119
+#: lib/block_scout_web/templates/address_internal_transaction/index.html.eex:117
#: lib/block_scout_web/templates/address_read_contract/index.html.eex:17
#: lib/block_scout_web/templates/address_transaction/index.html.eex:20
#: lib/block_scout_web/templates/address_transaction/index.html.eex:60
@@ -391,11 +391,13 @@ msgstr ""
msgid "Avg Block Time"
msgstr ""
-#: lib/block_scout_web/templates/chain/show.html.eex:18
+#: lib/block_scout_web/templates/chain/show.html.eex:17
+#: lib/block_scout_web/templates/layout/app.html.eex:24
msgid "Market Cap"
msgstr ""
#: lib/block_scout_web/templates/chain/show.html.eex:10
+#: lib/block_scout_web/templates/layout/app.html.eex:25
msgid "Price"
msgstr ""
@@ -439,7 +441,7 @@ msgstr ""
msgid "Total Gas Used"
msgstr ""
-#: lib/block_scout_web/views/transaction_view.ex:124
+#: lib/block_scout_web/views/transaction_view.ex:120
msgid "Transaction"
msgstr ""
@@ -462,7 +464,7 @@ msgstr ""
msgid "Contract"
msgstr ""
-#: lib/block_scout_web/views/address_view.ex:13
+#: lib/block_scout_web/views/address_view.ex:10
msgid "Contract Address"
msgstr ""
@@ -474,8 +476,8 @@ msgstr ""
msgid "There are no Transactions"
msgstr ""
-#: lib/block_scout_web/templates/address_internal_transaction/index.html.eex:132
-#: lib/block_scout_web/templates/address_transaction/index.html.eex:145
+#: lib/block_scout_web/templates/address_internal_transaction/index.html.eex:130
+#: lib/block_scout_web/templates/address_transaction/index.html.eex:143
#: lib/block_scout_web/templates/block/index.html.eex:15
#: lib/block_scout_web/templates/block_transaction/index.html.eex:50
#: lib/block_scout_web/templates/pending_transaction/index.html.eex:78
@@ -524,7 +526,7 @@ msgid "Newer"
msgstr ""
#, elixir-format
-#: lib/block_scout_web/views/transaction_view.ex:122
+#: lib/block_scout_web/views/transaction_view.ex:118
msgid "Contract Creation"
msgstr ""
@@ -554,27 +556,27 @@ msgid "Twitter"
msgstr ""
#, elixir-format
-#: lib/block_scout_web/templates/chain/show.html.eex:57
+#: lib/block_scout_web/templates/chain/show.html.eex:55
msgid "View All Blocks →"
msgstr ""
#, elixir-format
-#: lib/block_scout_web/templates/chain/show.html.eex:74
+#: lib/block_scout_web/templates/chain/show.html.eex:72
msgid "View All Transactions →"
msgstr ""
#, elixir-format
-#: lib/block_scout_web/templates/chain/show.html.eex:28
+#: lib/block_scout_web/templates/chain/show.html.eex:26
msgid "Average block time"
msgstr ""
#, elixir-format
-#: lib/block_scout_web/templates/chain/show.html.eex:36
+#: lib/block_scout_web/templates/chain/show.html.eex:34
msgid "Total transactions"
msgstr ""
#, elixir-format
-#: lib/block_scout_web/templates/chain/show.html.eex:44
+#: lib/block_scout_web/templates/chain/show.html.eex:42
msgid "Wallet addresses"
msgstr ""
@@ -586,7 +588,7 @@ msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address/overview.html.eex:8
-#: lib/block_scout_web/templates/address_contract/index.html.eex:73
+#: lib/block_scout_web/templates/address_contract/index.html.eex:75
msgid "Copy Address"
msgstr ""
@@ -599,17 +601,17 @@ msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address/overview.html.eex:13
-#: lib/block_scout_web/templates/address/overview.html.eex:66
+#: lib/block_scout_web/templates/address/overview.html.eex:64
msgid "QR Code"
msgstr ""
#, elixir-format
-#: lib/block_scout_web/templates/address_internal_transaction/index.html.eex:126
+#: lib/block_scout_web/templates/address_internal_transaction/index.html.eex:124
msgid "There are no internal transactions for this address."
msgstr ""
#, elixir-format
-#: lib/block_scout_web/templates/address_transaction/index.html.eex:139
+#: lib/block_scout_web/templates/address_transaction/index.html.eex:137
#: lib/block_scout_web/templates/block_transaction/index.html.eex:44
msgid "There are no transactions for this address."
msgstr ""
@@ -621,7 +623,7 @@ msgid "Contract Address Pending"
msgstr ""
#, elixir-format
-#: lib/block_scout_web/views/transaction_view.ex:123
+#: lib/block_scout_web/views/transaction_view.ex:119
msgid "Contract Call"
msgstr ""
@@ -631,12 +633,12 @@ msgid "Contract created by"
msgstr ""
#, elixir-format
-#: lib/block_scout_web/templates/address/overview.html.eex:36
+#: lib/block_scout_web/templates/address/overview.html.eex:35
msgid "at"
msgstr ""
#, elixir-format
-#: lib/block_scout_web/templates/tokens/token/_token_transfer.html.eex:38
+#: lib/block_scout_web/templates/tokens/token/_token_transfer.html.eex:36
#: lib/block_scout_web/templates/transaction/_tile.html.eex:34
msgid "Block #%{number}"
msgstr ""
@@ -693,7 +695,7 @@ msgid "Block Height #%{height}"
msgstr ""
#, elixir-format
-#: lib/block_scout_web/templates/address/overview.html.eex:75
+#: lib/block_scout_web/templates/address/overview.html.eex:73
msgid "Close"
msgstr ""
@@ -708,7 +710,7 @@ msgid "Block Confirmations"
msgstr ""
#, elixir-format
-#: lib/block_scout_web/templates/transaction/overview.html.eex:105
+#: lib/block_scout_web/templates/transaction/overview.html.eex:107
msgid "Limit"
msgstr ""
@@ -724,14 +726,14 @@ msgid "There are no logs for this transaction."
msgstr ""
#, elixir-format
-#: lib/block_scout_web/templates/transaction/overview.html.eex:98
+#: lib/block_scout_web/templates/transaction/overview.html.eex:100
msgid "Used"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/tokens/token/_token_transfer.html.eex:4
#: lib/block_scout_web/templates/transaction_token_transfer/_token_transfer.html.eex:4
-#: lib/block_scout_web/views/transaction_view.ex:121
+#: lib/block_scout_web/views/transaction_view.ex:117
msgid "Token Transfer"
msgstr ""
@@ -749,7 +751,7 @@ msgstr[1] ""
#, elixir-format
#: lib/block_scout_web/templates/address_transaction/index.html.eex:84
-#: lib/block_scout_web/templates/chain/show.html.eex:71
+#: lib/block_scout_web/templates/chain/show.html.eex:69
#: lib/block_scout_web/templates/transaction/index.html.eex:48
msgid "More transactions have come in"
msgstr ""
@@ -831,22 +833,15 @@ msgstr[0] ""
msgstr[1] ""
#, elixir-format
-#: lib/block_scout_web/templates/address/_balance_card.html.eex:16
-#: lib/block_scout_web/templates/address/_token_holdings.html.eex:16
+#: lib/block_scout_web/templates/address/_balance_card.html.eex:19
msgid "Error tryng to fetch balances."
msgstr ""
#, elixir-format
-#: lib/block_scout_web/templates/address/_balance_card.html.eex:12
-#: lib/block_scout_web/templates/address/_token_holdings.html.eex:12
+#: lib/block_scout_web/templates/address/_balance_card.html.eex:15
msgid "Fetching tokens..."
msgstr ""
-#, elixir-format
-#: lib/block_scout_web/templates/address/_token_holdings.html.eex:3
-msgid "Token Holdings"
-msgstr ""
-
#, elixir-format
#: lib/block_scout_web/templates/api_docs/_action_tile.html.eex:38
#: lib/block_scout_web/templates/api_docs/_action_tile.html.eex:53
@@ -1005,3 +1000,13 @@ msgstr ""
#: lib/block_scout_web/templates/transaction/_tile.html.eex:68
msgid "View Less Transfers"
msgstr ""
+
+#, elixir-format
+#: lib/block_scout_web/templates/layout/app.html.eex:23
+msgid "Less than"
+msgstr ""
+
+#, elixir-format
+#: lib/block_scout_web/views/transaction_view.ex:42
+msgid "Max of"
+msgstr ""
diff --git a/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po b/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po
index ecd4c93d83..8031a508d0 100644
--- a/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po
+++ b/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po
@@ -18,7 +18,7 @@ msgstr "Age"
msgid "Block"
msgstr "Block"
-#: lib/block_scout_web/templates/chain/show.html.eex:58
+#: lib/block_scout_web/templates/chain/show.html.eex:56
#: lib/block_scout_web/templates/layout/_topnav.html.eex:13
msgid "Blocks"
msgstr "Blocks"
@@ -51,18 +51,18 @@ msgstr "BlockScout"
#: lib/block_scout_web/templates/address_read_contract/index.html.eex:10
#: lib/block_scout_web/templates/address_transaction/index.html.eex:13
#: lib/block_scout_web/templates/address_transaction/index.html.eex:55
-#: lib/block_scout_web/templates/address_transaction/index.html.eex:131
+#: lib/block_scout_web/templates/address_transaction/index.html.eex:129
#: lib/block_scout_web/templates/block_transaction/index.html.eex:13
#: lib/block_scout_web/templates/block_transaction/index.html.eex:26
#: lib/block_scout_web/templates/block_transaction/index.html.eex:36
-#: lib/block_scout_web/templates/chain/show.html.eex:75
+#: lib/block_scout_web/templates/chain/show.html.eex:73
#: lib/block_scout_web/templates/layout/_topnav.html.eex:18
#: lib/block_scout_web/templates/pending_transaction/index.html.eex:46
#: lib/block_scout_web/templates/transaction/index.html.eex:56
msgid "Transactions"
msgstr "Transactions"
-#: lib/block_scout_web/templates/transaction/overview.html.eex:82
+#: lib/block_scout_web/templates/transaction/overview.html.eex:84
msgid "Value"
msgstr "Value"
@@ -122,7 +122,7 @@ msgstr "Transaction Details"
msgid "Cumulative Gas Used"
msgstr "Cumulative Gas Used"
-#: lib/block_scout_web/templates/transaction/overview.html.eex:93
+#: lib/block_scout_web/templates/transaction/overview.html.eex:95
msgid "Gas"
msgstr "Gas"
@@ -130,7 +130,7 @@ msgstr "Gas"
msgid "Gas Price"
msgstr "Gas Price"
-#: lib/block_scout_web/templates/transaction/overview.html.eex:63
+#: lib/block_scout_web/templates/transaction/overview.html.eex:65
msgid "Input"
msgstr "Input"
@@ -142,12 +142,12 @@ msgstr "%{confirmations} block confirmations"
msgid "%{count} transactions in this block"
msgstr "%{count} transactions in this block"
-#: lib/block_scout_web/views/address_view.ex:15
+#: lib/block_scout_web/views/address_view.ex:12
msgid "Address"
msgstr "Address"
-#: lib/block_scout_web/templates/address_internal_transaction/index.html.eex:106
-#: lib/block_scout_web/templates/address_transaction/index.html.eex:117
+#: lib/block_scout_web/templates/address_internal_transaction/index.html.eex:105
+#: lib/block_scout_web/templates/address_transaction/index.html.eex:116
#: lib/block_scout_web/views/address_internal_transaction_view.ex:10
#: lib/block_scout_web/views/address_transaction_view.ex:10
msgid "From"
@@ -158,7 +158,7 @@ msgstr "From"
msgid "Overview"
msgstr "Overview"
-#: lib/block_scout_web/views/transaction_view.ex:79
+#: lib/block_scout_web/views/transaction_view.ex:81
msgid "Success"
msgstr "Success"
@@ -210,8 +210,8 @@ msgstr "Showing %{count} Transactions"
#: lib/block_scout_web/templates/transaction/index.html.eex:16
#: lib/block_scout_web/templates/transaction/index.html.eex:35
#: lib/block_scout_web/templates/transaction/overview.html.eex:40
-#: lib/block_scout_web/views/transaction_view.ex:44
-#: lib/block_scout_web/views/transaction_view.ex:78
+#: lib/block_scout_web/views/transaction_view.ex:46
+#: lib/block_scout_web/views/transaction_view.ex:80
msgid "Pending"
msgstr "Pending"
@@ -279,11 +279,11 @@ msgstr ""
msgid "Next Page"
msgstr ""
-#: lib/block_scout_web/views/transaction_view.ex:76
+#: lib/block_scout_web/views/transaction_view.ex:78
msgid "Failed"
msgstr ""
-#: lib/block_scout_web/views/transaction_view.ex:77
+#: lib/block_scout_web/views/transaction_view.ex:79
msgid "Out of Gas"
msgstr ""
@@ -303,7 +303,7 @@ msgstr ""
#: lib/block_scout_web/templates/address_internal_transaction/_internal_transaction.html.eex:22
#: lib/block_scout_web/templates/pending_transaction/index.html.eex:68
#: lib/block_scout_web/templates/transaction/_tile.html.eex:24
-#: lib/block_scout_web/templates/transaction/overview.html.eex:82
+#: lib/block_scout_web/templates/transaction/overview.html.eex:84
#: lib/block_scout_web/templates/transaction_internal_transaction/_internal_transaction.html.eex:16
#: lib/block_scout_web/views/wei_helpers.ex:72
msgid "Ether"
@@ -317,7 +317,7 @@ msgstr ""
#: lib/block_scout_web/templates/address_contract/index.html.eex:17
#: lib/block_scout_web/templates/address_internal_transaction/index.html.eex:20
#: lib/block_scout_web/templates/address_internal_transaction/index.html.eex:60
-#: lib/block_scout_web/templates/address_internal_transaction/index.html.eex:119
+#: lib/block_scout_web/templates/address_internal_transaction/index.html.eex:117
#: lib/block_scout_web/templates/address_read_contract/index.html.eex:17
#: lib/block_scout_web/templates/address_transaction/index.html.eex:20
#: lib/block_scout_web/templates/address_transaction/index.html.eex:60
@@ -403,11 +403,13 @@ msgstr ""
msgid "Avg Block Time"
msgstr ""
-#: lib/block_scout_web/templates/chain/show.html.eex:18
+#: lib/block_scout_web/templates/chain/show.html.eex:17
+#: lib/block_scout_web/templates/layout/app.html.eex:24
msgid "Market Cap"
msgstr ""
#: lib/block_scout_web/templates/chain/show.html.eex:10
+#: lib/block_scout_web/templates/layout/app.html.eex:25
msgid "Price"
msgstr ""
@@ -451,7 +453,7 @@ msgstr ""
msgid "Total Gas Used"
msgstr ""
-#: lib/block_scout_web/views/transaction_view.ex:124
+#: lib/block_scout_web/views/transaction_view.ex:120
msgid "Transaction"
msgstr ""
@@ -474,7 +476,7 @@ msgstr ""
msgid "Contract"
msgstr ""
-#: lib/block_scout_web/views/address_view.ex:13
+#: lib/block_scout_web/views/address_view.ex:10
msgid "Contract Address"
msgstr ""
@@ -486,8 +488,8 @@ msgstr ""
msgid "There are no Transactions"
msgstr ""
-#: lib/block_scout_web/templates/address_internal_transaction/index.html.eex:132
-#: lib/block_scout_web/templates/address_transaction/index.html.eex:145
+#: lib/block_scout_web/templates/address_internal_transaction/index.html.eex:130
+#: lib/block_scout_web/templates/address_transaction/index.html.eex:143
#: lib/block_scout_web/templates/block/index.html.eex:15
#: lib/block_scout_web/templates/block_transaction/index.html.eex:50
#: lib/block_scout_web/templates/pending_transaction/index.html.eex:78
@@ -536,7 +538,7 @@ msgid "Newer"
msgstr ""
#, elixir-format
-#: lib/block_scout_web/views/transaction_view.ex:122
+#: lib/block_scout_web/views/transaction_view.ex:118
msgid "Contract Creation"
msgstr ""
@@ -566,27 +568,27 @@ msgid "Twitter"
msgstr ""
#, elixir-format
-#: lib/block_scout_web/templates/chain/show.html.eex:57
+#: lib/block_scout_web/templates/chain/show.html.eex:55
msgid "View All Blocks →"
msgstr ""
#, elixir-format
-#: lib/block_scout_web/templates/chain/show.html.eex:74
+#: lib/block_scout_web/templates/chain/show.html.eex:72
msgid "View All Transactions →"
msgstr ""
#, elixir-format
-#: lib/block_scout_web/templates/chain/show.html.eex:28
+#: lib/block_scout_web/templates/chain/show.html.eex:26
msgid "Average block time"
msgstr ""
#, elixir-format
-#: lib/block_scout_web/templates/chain/show.html.eex:36
+#: lib/block_scout_web/templates/chain/show.html.eex:34
msgid "Total transactions"
msgstr ""
#, elixir-format
-#: lib/block_scout_web/templates/chain/show.html.eex:44
+#: lib/block_scout_web/templates/chain/show.html.eex:42
msgid "Wallet addresses"
msgstr ""
@@ -598,7 +600,7 @@ msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address/overview.html.eex:8
-#: lib/block_scout_web/templates/address_contract/index.html.eex:73
+#: lib/block_scout_web/templates/address_contract/index.html.eex:75
msgid "Copy Address"
msgstr ""
@@ -611,17 +613,17 @@ msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address/overview.html.eex:13
-#: lib/block_scout_web/templates/address/overview.html.eex:66
+#: lib/block_scout_web/templates/address/overview.html.eex:64
msgid "QR Code"
msgstr ""
#, elixir-format
-#: lib/block_scout_web/templates/address_internal_transaction/index.html.eex:126
+#: lib/block_scout_web/templates/address_internal_transaction/index.html.eex:124
msgid "There are no internal transactions for this address."
msgstr ""
#, elixir-format
-#: lib/block_scout_web/templates/address_transaction/index.html.eex:139
+#: lib/block_scout_web/templates/address_transaction/index.html.eex:137
#: lib/block_scout_web/templates/block_transaction/index.html.eex:44
msgid "There are no transactions for this address."
msgstr ""
@@ -633,7 +635,7 @@ msgid "Contract Address Pending"
msgstr ""
#, elixir-format
-#: lib/block_scout_web/views/transaction_view.ex:123
+#: lib/block_scout_web/views/transaction_view.ex:119
msgid "Contract Call"
msgstr ""
@@ -643,12 +645,12 @@ msgid "Contract created by"
msgstr ""
#, elixir-format
-#: lib/block_scout_web/templates/address/overview.html.eex:36
+#: lib/block_scout_web/templates/address/overview.html.eex:35
msgid "at"
msgstr ""
#, elixir-format
-#: lib/block_scout_web/templates/tokens/token/_token_transfer.html.eex:38
+#: lib/block_scout_web/templates/tokens/token/_token_transfer.html.eex:36
#: lib/block_scout_web/templates/transaction/_tile.html.eex:34
msgid "Block #%{number}"
msgstr ""
@@ -705,7 +707,7 @@ msgid "Block Height #%{height}"
msgstr ""
#, elixir-format
-#: lib/block_scout_web/templates/address/overview.html.eex:75
+#: lib/block_scout_web/templates/address/overview.html.eex:73
msgid "Close"
msgstr ""
@@ -720,7 +722,7 @@ msgid "Block Confirmations"
msgstr ""
#, elixir-format
-#: lib/block_scout_web/templates/transaction/overview.html.eex:105
+#: lib/block_scout_web/templates/transaction/overview.html.eex:107
msgid "Limit"
msgstr ""
@@ -736,14 +738,14 @@ msgid "There are no logs for this transaction."
msgstr ""
#, elixir-format
-#: lib/block_scout_web/templates/transaction/overview.html.eex:98
+#: lib/block_scout_web/templates/transaction/overview.html.eex:100
msgid "Used"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/tokens/token/_token_transfer.html.eex:4
#: lib/block_scout_web/templates/transaction_token_transfer/_token_transfer.html.eex:4
-#: lib/block_scout_web/views/transaction_view.ex:121
+#: lib/block_scout_web/views/transaction_view.ex:117
msgid "Token Transfer"
msgstr ""
@@ -761,7 +763,7 @@ msgstr[1] ""
#, elixir-format
#: lib/block_scout_web/templates/address_transaction/index.html.eex:84
-#: lib/block_scout_web/templates/chain/show.html.eex:71
+#: lib/block_scout_web/templates/chain/show.html.eex:69
#: lib/block_scout_web/templates/transaction/index.html.eex:48
msgid "More transactions have come in"
msgstr ""
@@ -843,22 +845,15 @@ msgstr[0] ""
msgstr[1] ""
#, elixir-format
-#: lib/block_scout_web/templates/address/_balance_card.html.eex:16
-#: lib/block_scout_web/templates/address/_token_holdings.html.eex:16
+#: lib/block_scout_web/templates/address/_balance_card.html.eex:19
msgid "Error tryng to fetch balances."
msgstr ""
#, elixir-format
-#: lib/block_scout_web/templates/address/_balance_card.html.eex:12
-#: lib/block_scout_web/templates/address/_token_holdings.html.eex:12
+#: lib/block_scout_web/templates/address/_balance_card.html.eex:15
msgid "Fetching tokens..."
msgstr ""
-#, elixir-format
-#: lib/block_scout_web/templates/address/_token_holdings.html.eex:3
-msgid "Token Holdings"
-msgstr ""
-
#, elixir-format
#: lib/block_scout_web/templates/api_docs/_action_tile.html.eex:38
#: lib/block_scout_web/templates/api_docs/_action_tile.html.eex:53
@@ -1017,3 +1012,13 @@ msgstr ""
#: lib/block_scout_web/templates/transaction/_tile.html.eex:68
msgid "View Less Transfers"
msgstr ""
+
+#, elixir-format
+#: lib/block_scout_web/templates/layout/app.html.eex:23
+msgid "Less than"
+msgstr ""
+
+#, elixir-format
+#: lib/block_scout_web/views/transaction_view.ex:42
+msgid "Max of"
+msgstr ""
diff --git a/apps/block_scout_web/test/block_scout_web/controllers/address_contract_controller_test.exs b/apps/block_scout_web/test/block_scout_web/controllers/address_contract_controller_test.exs
index ad303714f3..0cdb3ae8ad 100644
--- a/apps/block_scout_web/test/block_scout_web/controllers/address_contract_controller_test.exs
+++ b/apps/block_scout_web/test/block_scout_web/controllers/address_contract_controller_test.exs
@@ -1,7 +1,7 @@
defmodule BlockScoutWeb.AddressContractControllerTest do
use BlockScoutWeb.ConnCase
- import BlockScoutWeb.Router.Helpers, only: [address_contract_path: 4]
+ import BlockScoutWeb.Router.Helpers, only: [address_contract_path: 3]
alias Explorer.Factory
alias Explorer.Chain.Hash
@@ -11,7 +11,7 @@ defmodule BlockScoutWeb.AddressContractControllerTest do
test "returns not found for unexistent address", %{conn: conn} do
unexistent_address_hash = Hash.to_string(Factory.address_hash())
- conn = get(conn, address_contract_path(BlockScoutWeb.Endpoint, :index, :en, unexistent_address_hash))
+ conn = get(conn, address_contract_path(BlockScoutWeb.Endpoint, :index, unexistent_address_hash))
assert html_response(conn, 404)
end
@@ -19,7 +19,7 @@ defmodule BlockScoutWeb.AddressContractControllerTest do
test "returns not found given an invalid address hash ", %{conn: conn} do
invalid_hash = "invalid_hash"
- conn = get(conn, address_contract_path(BlockScoutWeb.Endpoint, :index, :en, invalid_hash))
+ conn = get(conn, address_contract_path(BlockScoutWeb.Endpoint, :index, invalid_hash))
assert html_response(conn, 404)
end
@@ -27,7 +27,7 @@ defmodule BlockScoutWeb.AddressContractControllerTest do
test "returns not found when the address isn't a contract", %{conn: conn} do
address = insert(:address)
- conn = get(conn, address_contract_path(BlockScoutWeb.Endpoint, :index, :en, address))
+ conn = get(conn, address_contract_path(BlockScoutWeb.Endpoint, :index, address))
assert html_response(conn, 404)
end
@@ -44,7 +44,7 @@ defmodule BlockScoutWeb.AddressContractControllerTest do
created_contract_address: address
)
- conn = get(conn, address_contract_path(BlockScoutWeb.Endpoint, :index, :en, address))
+ conn = get(conn, address_contract_path(BlockScoutWeb.Endpoint, :index, address))
assert html_response(conn, 200)
assert address.hash == conn.assigns.address.hash
diff --git a/apps/block_scout_web/test/block_scout_web/controllers/address_controller_test.exs b/apps/block_scout_web/test/block_scout_web/controllers/address_controller_test.exs
index e284612310..6aa40daee7 100644
--- a/apps/block_scout_web/test/block_scout_web/controllers/address_controller_test.exs
+++ b/apps/block_scout_web/test/block_scout_web/controllers/address_controller_test.exs
@@ -2,12 +2,12 @@ defmodule BlockScoutWeb.AddressControllerTest do
use BlockScoutWeb.ConnCase
describe "GET show/3" do
- test "redirects to addresses/:address_id/transactions", %{conn: conn} do
+ test "redirects to address/:address_id/transactions", %{conn: conn} do
insert(:address, hash: "0x5aAeb6053F3E94C9b9A09f33669435E7Ef1BeAed")
- conn = get(conn, "/en/addresses/0x5aAeb6053F3E94C9b9A09f33669435E7Ef1BeAed")
+ conn = get(conn, "/address/0x5aAeb6053F3E94C9b9A09f33669435E7Ef1BeAed")
- assert redirected_to(conn) =~ "/en/addresses/0x5aAeb6053F3E94C9b9A09f33669435E7Ef1BeAed/transactions"
+ assert redirected_to(conn) =~ "/en/address/0x5aAeb6053F3E94C9b9A09f33669435E7Ef1BeAed/transactions"
end
end
end
diff --git a/apps/block_scout_web/test/block_scout_web/controllers/address_internal_transaction_controller_test.exs b/apps/block_scout_web/test/block_scout_web/controllers/address_internal_transaction_controller_test.exs
index 4018601a66..4b1fa454a8 100644
--- a/apps/block_scout_web/test/block_scout_web/controllers/address_internal_transaction_controller_test.exs
+++ b/apps/block_scout_web/test/block_scout_web/controllers/address_internal_transaction_controller_test.exs
@@ -1,7 +1,7 @@
defmodule BlockScoutWeb.AddressInternalTransactionControllerTest do
use BlockScoutWeb.ConnCase
- import BlockScoutWeb.Router.Helpers, only: [address_internal_transaction_path: 4]
+ import BlockScoutWeb.Router.Helpers, only: [address_internal_transaction_path: 3]
alias Explorer.Chain.{Block, InternalTransaction, Transaction}
alias Explorer.ExchangeRates.Token
@@ -10,14 +10,13 @@ defmodule BlockScoutWeb.AddressInternalTransactionControllerTest do
test "with invalid address hash", %{conn: conn} do
conn =
conn
- |> get(address_internal_transaction_path(BlockScoutWeb.Endpoint, :index, :en, "invalid_address"))
+ |> get(address_internal_transaction_path(BlockScoutWeb.Endpoint, :index, "invalid_address"))
assert html_response(conn, 404)
end
test "with valid address hash without address", %{conn: conn} do
- conn =
- get(conn, address_internal_transaction_path(conn, :index, :en, "0x8bf38d4764929064f2d4d3a56520a76ab3df415b"))
+ conn = get(conn, address_internal_transaction_path(conn, :index, "0x8bf38d4764929064f2d4d3a56520a76ab3df415b"))
assert html_response(conn, 404)
end
@@ -35,7 +34,7 @@ defmodule BlockScoutWeb.AddressInternalTransactionControllerTest do
to_internal_transaction = insert(:internal_transaction, transaction: transaction, to_address: address, index: 2)
- path = address_internal_transaction_path(conn, :index, :en, address)
+ path = address_internal_transaction_path(conn, :index, address)
conn = get(conn, path)
actual_transaction_ids =
@@ -49,7 +48,7 @@ defmodule BlockScoutWeb.AddressInternalTransactionControllerTest do
test "includes USD exchange rate value for address in assigns", %{conn: conn} do
address = insert(:address)
- conn = get(conn, address_internal_transaction_path(BlockScoutWeb.Endpoint, :index, :en, address.hash))
+ conn = get(conn, address_internal_transaction_path(BlockScoutWeb.Endpoint, :index, address.hash))
assert %Token{} = conn.assigns.exchange_rate
end
@@ -118,7 +117,7 @@ defmodule BlockScoutWeb.AddressInternalTransactionControllerTest do
|> insert(transaction: transaction_3, from_address: address, index: 11)
conn =
- get(conn, address_internal_transaction_path(BlockScoutWeb.Endpoint, :index, :en, address.hash), %{
+ get(conn, address_internal_transaction_path(BlockScoutWeb.Endpoint, :index, address.hash), %{
"block_number" => Integer.to_string(b_block.number),
"transaction_index" => Integer.to_string(transaction_3.index),
"index" => Integer.to_string(index)
@@ -152,7 +151,7 @@ defmodule BlockScoutWeb.AddressInternalTransactionControllerTest do
)
end)
- conn = get(conn, address_internal_transaction_path(BlockScoutWeb.Endpoint, :index, :en, address.hash))
+ conn = get(conn, address_internal_transaction_path(BlockScoutWeb.Endpoint, :index, address.hash))
assert %{"block_number" => ^number, "index" => 11, "transaction_index" => ^transaction_index} =
conn.assigns.next_page_params
@@ -176,7 +175,7 @@ defmodule BlockScoutWeb.AddressInternalTransactionControllerTest do
)
end)
- conn = get(conn, address_internal_transaction_path(BlockScoutWeb.Endpoint, :index, :en, address.hash))
+ conn = get(conn, address_internal_transaction_path(BlockScoutWeb.Endpoint, :index, address.hash))
refute conn.assigns.next_page_params
end
diff --git a/apps/block_scout_web/test/block_scout_web/controllers/address_read_contract_controller_test.exs b/apps/block_scout_web/test/block_scout_web/controllers/address_read_contract_controller_test.exs
index 1a666a734c..8008c79d3a 100644
--- a/apps/block_scout_web/test/block_scout_web/controllers/address_read_contract_controller_test.exs
+++ b/apps/block_scout_web/test/block_scout_web/controllers/address_read_contract_controller_test.exs
@@ -5,7 +5,7 @@ defmodule BlockScoutWeb.AddressReadContractControllerTest do
describe "GET index/3" do
test "with invalid address hash", %{conn: conn} do
- conn = get(conn, address_read_contract_path(BlockScoutWeb.Endpoint, :index, :en, "invalid_address"))
+ conn = get(conn, address_read_contract_path(BlockScoutWeb.Endpoint, :index, "invalid_address"))
assert html_response(conn, 404)
end
@@ -13,7 +13,7 @@ defmodule BlockScoutWeb.AddressReadContractControllerTest do
test "with valid address that is not a contract", %{conn: conn} do
address = insert(:address)
- conn = get(conn, address_read_contract_path(BlockScoutWeb.Endpoint, :index, :en, address.hash))
+ conn = get(conn, address_read_contract_path(BlockScoutWeb.Endpoint, :index, address.hash))
assert html_response(conn, 404)
end
@@ -32,7 +32,7 @@ defmodule BlockScoutWeb.AddressReadContractControllerTest do
insert(:smart_contract, address_hash: contract_address.hash)
- conn = get(conn, address_read_contract_path(BlockScoutWeb.Endpoint, :index, :en, contract_address.hash))
+ conn = get(conn, address_read_contract_path(BlockScoutWeb.Endpoint, :index, contract_address.hash))
assert html_response(conn, 200)
assert contract_address.hash == conn.assigns.address.hash
diff --git a/apps/block_scout_web/test/block_scout_web/controllers/address_token_balance_controller_test.exs b/apps/block_scout_web/test/block_scout_web/controllers/address_token_balance_controller_test.exs
new file mode 100644
index 0000000000..6e73dc8d43
--- /dev/null
+++ b/apps/block_scout_web/test/block_scout_web/controllers/address_token_balance_controller_test.exs
@@ -0,0 +1,46 @@
+defmodule BlockScoutWeb.AddressTokenBalanceControllerTest do
+ use BlockScoutWeb.ConnCase
+
+ alias Explorer.Chain.Address
+ alias Explorer.Factory
+
+ describe "GET index/3" do
+ test "without AJAX", %{conn: conn} do
+ %Address{hash: hash} = Factory.insert(:address)
+
+ response_conn = get(conn, address_token_balance_path(conn, :index, :en, to_string(hash)))
+
+ assert html_response(response_conn, 404)
+ end
+
+ test "with AJAX without valid address", %{conn: conn} do
+ ajax_conn = ajax(conn)
+
+ response_conn = get(ajax_conn, address_token_balance_path(ajax_conn, :index, :en, "invalid_address"))
+
+ assert html_response(response_conn, 404)
+ end
+
+ test "with AJAX with valid address without address still returns token balances", %{conn: conn} do
+ ajax_conn = ajax(conn)
+
+ response_conn = get(ajax_conn, address_token_balance_path(ajax_conn, :index, :en, Factory.address_hash()))
+
+ assert html_response(response_conn, 200)
+ end
+
+ test "with AJAX with valid address with address returns token balances", %{conn: conn} do
+ %Address{hash: hash} = Factory.insert(:address)
+
+ ajax_conn = ajax(conn)
+
+ response_conn = get(ajax_conn, address_token_balance_path(ajax_conn, :index, :en, hash))
+
+ assert html_response(response_conn, 200)
+ end
+ end
+
+ defp ajax(conn) do
+ put_req_header(conn, "x-requested-with", "XMLHttpRequest")
+ end
+end
diff --git a/apps/block_scout_web/test/block_scout_web/controllers/address_transaction_controller_test.exs b/apps/block_scout_web/test/block_scout_web/controllers/address_transaction_controller_test.exs
index fd3dfee94d..4bb6b72cf7 100644
--- a/apps/block_scout_web/test/block_scout_web/controllers/address_transaction_controller_test.exs
+++ b/apps/block_scout_web/test/block_scout_web/controllers/address_transaction_controller_test.exs
@@ -1,20 +1,20 @@
defmodule BlockScoutWeb.AddressTransactionControllerTest do
use BlockScoutWeb.ConnCase
- import BlockScoutWeb.Router.Helpers, only: [address_transaction_path: 4]
+ import BlockScoutWeb.Router.Helpers, only: [address_transaction_path: 3]
alias Explorer.Chain.{Block, Transaction}
alias Explorer.ExchangeRates.Token
describe "GET index/2" do
test "with invalid address hash", %{conn: conn} do
- conn = get(conn, address_transaction_path(conn, :index, :en, "invalid_address"))
+ conn = get(conn, address_transaction_path(conn, :index, "invalid_address"))
assert html_response(conn, 422)
end
test "with valid address hash without address", %{conn: conn} do
- conn = get(conn, address_transaction_path(conn, :index, :en, "0x8bf38d4764929064f2d4d3a56520a76ab3df415b"))
+ conn = get(conn, address_transaction_path(conn, :index, "0x8bf38d4764929064f2d4d3a56520a76ab3df415b"))
assert html_response(conn, 404)
end
@@ -34,7 +34,7 @@ defmodule BlockScoutWeb.AddressTransactionControllerTest do
|> insert(to_address: address)
|> with_block(block)
- conn = get(conn, address_transaction_path(conn, :index, :en, address))
+ conn = get(conn, address_transaction_path(conn, :index, address))
actual_transaction_hashes =
conn.assigns.transactions
@@ -50,7 +50,7 @@ defmodule BlockScoutWeb.AddressTransactionControllerTest do
insert(:transaction, from_address: address, to_address: address)
- conn = get(conn, address_transaction_path(BlockScoutWeb.Endpoint, :index, :en, address))
+ conn = get(conn, address_transaction_path(BlockScoutWeb.Endpoint, :index, address))
assert html_response(conn, 200)
assert conn.status == 200
@@ -62,7 +62,7 @@ defmodule BlockScoutWeb.AddressTransactionControllerTest do
test "includes USD exchange rate value for address in assigns", %{conn: conn} do
address = insert(:address)
- conn = get(conn, address_transaction_path(BlockScoutWeb.Endpoint, :index, :en, address.hash))
+ conn = get(conn, address_transaction_path(BlockScoutWeb.Endpoint, :index, address.hash))
assert %Token{} = conn.assigns.exchange_rate
end
@@ -82,7 +82,7 @@ defmodule BlockScoutWeb.AddressTransactionControllerTest do
|> with_block()
conn =
- get(conn, address_transaction_path(BlockScoutWeb.Endpoint, :index, :en, address.hash), %{
+ get(conn, address_transaction_path(BlockScoutWeb.Endpoint, :index, address.hash), %{
"block_number" => Integer.to_string(block_number),
"index" => Integer.to_string(index)
})
@@ -103,7 +103,7 @@ defmodule BlockScoutWeb.AddressTransactionControllerTest do
|> insert_list(:transaction, from_address: address)
|> with_block(block)
- conn = get(conn, address_transaction_path(BlockScoutWeb.Endpoint, :index, :en, address.hash))
+ conn = get(conn, address_transaction_path(BlockScoutWeb.Endpoint, :index, address.hash))
assert %{"block_number" => ^number, "index" => 10} = conn.assigns.next_page_params
end
@@ -115,7 +115,7 @@ defmodule BlockScoutWeb.AddressTransactionControllerTest do
|> insert(from_address: address)
|> with_block()
- conn = get(conn, address_transaction_path(BlockScoutWeb.Endpoint, :index, :en, address.hash))
+ conn = get(conn, address_transaction_path(BlockScoutWeb.Endpoint, :index, address.hash))
refute conn.assigns.next_page_params
end
@@ -138,7 +138,7 @@ defmodule BlockScoutWeb.AddressTransactionControllerTest do
transaction: transaction
)
- conn = get(conn, address_transaction_path(conn, :index, :en, address))
+ conn = get(conn, address_transaction_path(conn, :index, address))
assert [transaction] == conn.assigns.transactions
end
diff --git a/apps/block_scout_web/test/block_scout_web/controllers/api_docs_controller_test.exs b/apps/block_scout_web/test/block_scout_web/controllers/api_docs_controller_test.exs
index ec61434594..3b2cb99ff0 100644
--- a/apps/block_scout_web/test/block_scout_web/controllers/api_docs_controller_test.exs
+++ b/apps/block_scout_web/test/block_scout_web/controllers/api_docs_controller_test.exs
@@ -1,11 +1,11 @@
defmodule BlockScoutWeb.APIDocsControllerTest do
use BlockScoutWeb.ConnCase
- import BlockScoutWeb.Router.Helpers, only: [api_docs_path: 3]
+ import BlockScoutWeb.Router.Helpers, only: [api_docs_path: 2]
describe "GET index/2" do
test "renders documentation tiles for each API module#action", %{conn: conn} do
- conn = get(conn, api_docs_path(BlockScoutWeb.Endpoint, :index, :en))
+ conn = get(conn, api_docs_path(BlockScoutWeb.Endpoint, :index))
documentation = BlockScoutWeb.Etherscan.get_documentation()
diff --git a/apps/block_scout_web/test/block_scout_web/controllers/block_controller_test.exs b/apps/block_scout_web/test/block_scout_web/controllers/block_controller_test.exs
index 3261c7d687..cca8f405ad 100644
--- a/apps/block_scout_web/test/block_scout_web/controllers/block_controller_test.exs
+++ b/apps/block_scout_web/test/block_scout_web/controllers/block_controller_test.exs
@@ -2,13 +2,11 @@ defmodule BlockScoutWeb.BlockControllerTest do
use BlockScoutWeb.ConnCase
alias Explorer.Chain.Block
- @locale "en"
-
describe "GET show/2" do
test "with block redirects to block transactions route", %{conn: conn} do
insert(:block, number: 3)
- conn = get(conn, "/en/blocks/3")
- assert redirected_to(conn) =~ "/en/blocks/3/transactions"
+ conn = get(conn, "/blocks/3")
+ assert redirected_to(conn) =~ "/blocks/3/transactions"
end
end
@@ -20,7 +18,7 @@ defmodule BlockScoutWeb.BlockControllerTest do
|> Stream.map(fn block -> block.number end)
|> Enum.reverse()
- conn = get(conn, block_path(conn, :index, @locale))
+ conn = get(conn, block_path(conn, :index))
assert conn.assigns.blocks |> Enum.map(fn block -> block.number end) == block_ids
end
@@ -32,7 +30,7 @@ defmodule BlockScoutWeb.BlockControllerTest do
|> insert_list(:transaction)
|> with_block(block)
- conn = get(conn, block_path(conn, :index, @locale))
+ conn = get(conn, block_path(conn, :index))
assert conn.assigns.blocks |> Enum.count() == 1
end
@@ -46,7 +44,7 @@ defmodule BlockScoutWeb.BlockControllerTest do
block = insert(:block)
conn =
- get(conn, block_path(conn, :index, @locale), %{
+ get(conn, block_path(conn, :index), %{
"block_number" => Integer.to_string(block.number)
})
@@ -64,7 +62,7 @@ defmodule BlockScoutWeb.BlockControllerTest do
|> insert_list(:block)
|> Enum.fetch!(10)
- conn = get(conn, block_path(conn, :index, @locale))
+ conn = get(conn, block_path(conn, :index))
assert %{"block_number" => ^number} = conn.assigns.next_page_params
end
@@ -72,7 +70,7 @@ defmodule BlockScoutWeb.BlockControllerTest do
test "next_page_params are empty if on last page", %{conn: conn} do
insert(:block)
- conn = get(conn, block_path(conn, :index, @locale))
+ conn = get(conn, block_path(conn, :index))
refute conn.assigns.next_page_params
end
diff --git a/apps/block_scout_web/test/block_scout_web/controllers/block_transaction_controller_test.exs b/apps/block_scout_web/test/block_scout_web/controllers/block_transaction_controller_test.exs
index 737dcdec7a..c94993b3e3 100644
--- a/apps/block_scout_web/test/block_scout_web/controllers/block_transaction_controller_test.exs
+++ b/apps/block_scout_web/test/block_scout_web/controllers/block_transaction_controller_test.exs
@@ -2,17 +2,17 @@ defmodule BlockScoutWeb.BlockTransactionControllerTest do
use BlockScoutWeb.ConnCase
alias Explorer.Chain.Block
- import BlockScoutWeb.Router.Helpers, only: [block_transaction_path: 4]
+ import BlockScoutWeb.Router.Helpers, only: [block_transaction_path: 3]
describe "GET index/2" do
test "with invalid block number", %{conn: conn} do
- conn = get(conn, block_transaction_path(conn, :index, :en, "unknown"))
+ conn = get(conn, block_transaction_path(conn, :index, "unknown"))
assert html_response(conn, 404)
end
test "with valid block number without block", %{conn: conn} do
- conn = get(conn, block_transaction_path(conn, :index, :en, "1"))
+ conn = get(conn, block_transaction_path(conn, :index, "1"))
assert html_response(conn, 404)
end
@@ -23,7 +23,7 @@ defmodule BlockScoutWeb.BlockTransactionControllerTest do
:transaction |> insert() |> with_block(block)
:transaction |> insert(to_address: nil) |> with_block(block)
- conn = get(conn, block_transaction_path(BlockScoutWeb.Endpoint, :index, :en, block.number))
+ conn = get(conn, block_transaction_path(BlockScoutWeb.Endpoint, :index, block.number))
assert html_response(conn, 200)
assert 2 == Enum.count(conn.assigns.transactions)
@@ -33,7 +33,7 @@ defmodule BlockScoutWeb.BlockTransactionControllerTest do
insert(:transaction)
block = insert(:block)
- conn = get(conn, block_transaction_path(BlockScoutWeb.Endpoint, :index, :en, block))
+ conn = get(conn, block_transaction_path(BlockScoutWeb.Endpoint, :index, block))
assert html_response(conn, 200)
assert Enum.empty?(conn.assigns.transactions)
@@ -43,7 +43,7 @@ defmodule BlockScoutWeb.BlockTransactionControllerTest do
block = insert(:block)
insert(:transaction)
- conn = get(conn, block_transaction_path(BlockScoutWeb.Endpoint, :index, :en, block))
+ conn = get(conn, block_transaction_path(BlockScoutWeb.Endpoint, :index, block))
assert html_response(conn, 200)
assert Enum.empty?(conn.assigns.transactions)
@@ -56,7 +56,7 @@ defmodule BlockScoutWeb.BlockTransactionControllerTest do
|> insert_list(:transaction)
|> with_block(block)
- conn = get(conn, block_transaction_path(BlockScoutWeb.Endpoint, :index, :en, block))
+ conn = get(conn, block_transaction_path(BlockScoutWeb.Endpoint, :index, block))
assert %{"block_number" => ^number, "index" => 10} = conn.assigns.next_page_params
end
@@ -68,7 +68,7 @@ defmodule BlockScoutWeb.BlockTransactionControllerTest do
|> insert()
|> with_block(block)
- conn = get(conn, block_transaction_path(BlockScoutWeb.Endpoint, :index, :en, block))
+ conn = get(conn, block_transaction_path(BlockScoutWeb.Endpoint, :index, block))
refute conn.assigns.next_page_params
end
diff --git a/apps/block_scout_web/test/block_scout_web/controllers/chain_controller_test.exs b/apps/block_scout_web/test/block_scout_web/controllers/chain_controller_test.exs
index 575266acba..a8011dce5e 100644
--- a/apps/block_scout_web/test/block_scout_web/controllers/chain_controller_test.exs
+++ b/apps/block_scout_web/test/block_scout_web/controllers/chain_controller_test.exs
@@ -1,26 +1,18 @@
defmodule BlockScoutWeb.ChainControllerTest do
use BlockScoutWeb.ConnCase
- import BlockScoutWeb.Router.Helpers, only: [chain_path: 3, block_path: 4, transaction_path: 4, address_path: 4]
+ import BlockScoutWeb.Router.Helpers, only: [chain_path: 2, block_path: 3, transaction_path: 3, address_path: 3]
- describe "GET index/2 without a locale" do
- test "redirects to the en locale", %{conn: conn} do
- conn = get(conn, "/")
-
- assert(redirected_to(conn) == "/en")
- end
- end
-
- describe "GET index/2 with a locale" do
+ describe "GET index/2" do
test "returns a welcome message", %{conn: conn} do
- conn = get(conn, chain_path(BlockScoutWeb.Endpoint, :show, %{locale: :en}))
+ conn = get(conn, chain_path(BlockScoutWeb.Endpoint, :show))
assert(html_response(conn, 200) =~ "POA")
end
test "returns a block", %{conn: conn} do
insert(:block, %{number: 23})
- conn = get(conn, "/en")
+ conn = get(conn, "/")
assert(List.first(conn.assigns.blocks).number == 23)
end
@@ -28,7 +20,7 @@ defmodule BlockScoutWeb.ChainControllerTest do
test "excludes all but the most recent five blocks", %{conn: conn} do
old_block = insert(:block)
insert_list(5, :block)
- conn = get(conn, "/en")
+ conn = get(conn, "/")
refute(Enum.member?(conn.assigns.blocks, old_block))
end
@@ -41,7 +33,7 @@ defmodule BlockScoutWeb.ChainControllerTest do
unassociated = insert(:transaction)
- conn = get(conn, "/en")
+ conn = get(conn, "/")
transaction_hashes = Enum.map(conn.assigns.transactions, fn transaction -> transaction.hash end)
@@ -55,7 +47,7 @@ defmodule BlockScoutWeb.ChainControllerTest do
|> insert()
|> with_block()
- conn = get(conn, "/en")
+ conn = get(conn, "/")
assert(List.first(conn.assigns.transactions).hash == transaction.hash)
end
@@ -64,7 +56,7 @@ defmodule BlockScoutWeb.ChainControllerTest do
today = Date.utc_today()
for day <- -40..0, do: insert(:market_history, date: Date.add(today, day))
- conn = get(conn, "/en")
+ conn = get(conn, "/")
assert Map.has_key?(conn.assigns, :market_history_data)
assert length(conn.assigns.market_history_data) == 30
@@ -74,9 +66,9 @@ defmodule BlockScoutWeb.ChainControllerTest do
describe "GET q/2" do
test "finds a block by block number", %{conn: conn} do
insert(:block, number: 37)
- conn = get(conn, "/en/search?q=37")
+ conn = get(conn, "/search?q=37")
- assert redirected_to(conn) == block_path(conn, :show, "en", "37")
+ assert redirected_to(conn) == block_path(conn, :show, "37")
end
test "finds a transaction by hash", %{conn: conn} do
@@ -85,27 +77,27 @@ defmodule BlockScoutWeb.ChainControllerTest do
|> insert()
|> with_block()
- conn = get(conn, "/en/search?q=#{to_string(transaction.hash)}")
+ conn = get(conn, "/search?q=#{to_string(transaction.hash)}")
- assert redirected_to(conn) == transaction_path(conn, :show, "en", transaction)
+ assert redirected_to(conn) == transaction_path(conn, :show, transaction)
end
test "finds an address by hash", %{conn: conn} do
address = insert(:address)
- conn = get(conn, "en/search?q=#{to_string(address.hash)}")
+ conn = get(conn, "search?q=#{to_string(address.hash)}")
- assert redirected_to(conn) == address_path(conn, :show, "en", address)
+ assert redirected_to(conn) == address_path(conn, :show, address)
end
test "finds an address by hash when there are extra spaces", %{conn: conn} do
address = insert(:address)
- conn = get(conn, "en/search?q=#{to_string(address.hash)} ")
+ conn = get(conn, "search?q=#{to_string(address.hash)}")
- assert redirected_to(conn) == address_path(conn, :show, "en", address)
+ assert redirected_to(conn) == address_path(conn, :show, address)
end
test "redirects to 404 when it finds nothing", %{conn: conn} do
- conn = get(conn, "en/search?q=zaphod")
+ conn = get(conn, "search?q=zaphod")
assert conn.status == 404
end
end
diff --git a/apps/block_scout_web/test/block_scout_web/controllers/pending_transaction_controller_test.exs b/apps/block_scout_web/test/block_scout_web/controllers/pending_transaction_controller_test.exs
index 4707f4c98e..bfd49aa286 100644
--- a/apps/block_scout_web/test/block_scout_web/controllers/pending_transaction_controller_test.exs
+++ b/apps/block_scout_web/test/block_scout_web/controllers/pending_transaction_controller_test.exs
@@ -2,7 +2,7 @@ defmodule BlockScoutWeb.PendingTransactionControllerTest do
use BlockScoutWeb.ConnCase
alias Explorer.Chain.{Hash, Transaction}
- import BlockScoutWeb.Router.Helpers, only: [pending_transaction_path: 3]
+ import BlockScoutWeb.Router.Helpers, only: [pending_transaction_path: 2]
describe "GET index/2" do
test "returns no transactions that are in a block", %{conn: conn} do
@@ -10,7 +10,7 @@ defmodule BlockScoutWeb.PendingTransactionControllerTest do
|> insert()
|> with_block()
- conn = get(conn, pending_transaction_path(BlockScoutWeb.Endpoint, :index, :en))
+ conn = get(conn, pending_transaction_path(BlockScoutWeb.Endpoint, :index))
assert html_response(conn, 200)
assert Enum.empty?(conn.assigns.transactions)
@@ -21,7 +21,7 @@ defmodule BlockScoutWeb.PendingTransactionControllerTest do
|> insert()
|> with_block()
- conn = get(conn, pending_transaction_path(BlockScoutWeb.Endpoint, :index, :en))
+ conn = get(conn, pending_transaction_path(BlockScoutWeb.Endpoint, :index))
assert html_response(conn, 200)
assert Enum.empty?(conn.assigns.transactions)
@@ -30,7 +30,7 @@ defmodule BlockScoutWeb.PendingTransactionControllerTest do
test "returns pending transactions", %{conn: conn} do
transaction = insert(:transaction)
- conn = get(conn, pending_transaction_path(BlockScoutWeb.Endpoint, :index, :en))
+ conn = get(conn, pending_transaction_path(BlockScoutWeb.Endpoint, :index))
actual_transaction_hashes =
conn.assigns.transactions
@@ -43,14 +43,14 @@ defmodule BlockScoutWeb.PendingTransactionControllerTest do
test "returns a count of pending transactions", %{conn: conn} do
insert(:transaction)
- conn = get(conn, pending_transaction_path(BlockScoutWeb.Endpoint, :index, :en))
+ conn = get(conn, pending_transaction_path(BlockScoutWeb.Endpoint, :index))
assert html_response(conn, 200)
assert 1 == conn.assigns.pending_transaction_count
end
test "works when there are no transactions", %{conn: conn} do
- conn = get(conn, pending_transaction_path(conn, :index, :en))
+ conn = get(conn, pending_transaction_path(conn, :index))
assert html_response(conn, 200)
end
@@ -64,7 +64,7 @@ defmodule BlockScoutWeb.PendingTransactionControllerTest do
%Transaction{inserted_at: inserted_at, hash: hash} = insert(:transaction)
conn =
- get(conn, pending_transaction_path(BlockScoutWeb.Endpoint, :index, :en), %{
+ get(conn, pending_transaction_path(BlockScoutWeb.Endpoint, :index), %{
"inserted_at" => DateTime.to_iso8601(inserted_at),
"hash" => Hash.to_string(hash)
})
@@ -85,7 +85,7 @@ defmodule BlockScoutWeb.PendingTransactionControllerTest do
converted_date = DateTime.to_iso8601(inserted_at)
- conn = get(conn, pending_transaction_path(BlockScoutWeb.Endpoint, :index, :en))
+ conn = get(conn, pending_transaction_path(BlockScoutWeb.Endpoint, :index))
assert %{"inserted_at" => ^converted_date, "hash" => ^hash} = conn.assigns.next_page_params
end
@@ -93,7 +93,7 @@ defmodule BlockScoutWeb.PendingTransactionControllerTest do
test "next_page_params are empty if on last page", %{conn: conn} do
insert(:transaction)
- conn = get(conn, pending_transaction_path(BlockScoutWeb.Endpoint, :index, :en))
+ conn = get(conn, pending_transaction_path(BlockScoutWeb.Endpoint, :index))
refute conn.assigns.next_page_params
end
diff --git a/apps/block_scout_web/test/block_scout_web/controllers/smart_contract_controller_test.exs b/apps/block_scout_web/test/block_scout_web/controllers/smart_contract_controller_test.exs
index 4190080bfc..3cd3cee7c8 100644
--- a/apps/block_scout_web/test/block_scout_web/controllers/smart_contract_controller_test.exs
+++ b/apps/block_scout_web/test/block_scout_web/controllers/smart_contract_controller_test.exs
@@ -9,7 +9,7 @@ defmodule BlockScoutWeb.SmartContractControllerTest do
test "only responds to ajax requests", %{conn: conn} do
smart_contract = insert(:smart_contract)
- path = smart_contract_path(BlockScoutWeb.Endpoint, :index, :en, hash: smart_contract.address_hash)
+ path = smart_contract_path(BlockScoutWeb.Endpoint, :index, hash: smart_contract.address_hash)
conn = get(conn, path)
@@ -23,7 +23,7 @@ defmodule BlockScoutWeb.SmartContractControllerTest do
blockchain_get_function_mock()
- path = smart_contract_path(BlockScoutWeb.Endpoint, :index, :en, hash: token_contract_address.hash)
+ path = smart_contract_path(BlockScoutWeb.Endpoint, :index, hash: token_contract_address.hash)
conn =
build_conn()
@@ -43,7 +43,6 @@ defmodule BlockScoutWeb.SmartContractControllerTest do
smart_contract_path(
BlockScoutWeb.Endpoint,
:show,
- :en,
smart_contract.address_hash,
function_name: "get",
args: []
@@ -63,7 +62,6 @@ defmodule BlockScoutWeb.SmartContractControllerTest do
smart_contract_path(
BlockScoutWeb.Endpoint,
:show,
- :en,
smart_contract.address_hash,
function_name: "get",
args: []
@@ -79,7 +77,6 @@ defmodule BlockScoutWeb.SmartContractControllerTest do
assert %{
function_name: "get",
layout: false,
- locale: "en",
outputs: [%{"name" => "", "type" => "uint256", "value" => 0}]
} = conn.assigns
end
diff --git a/apps/block_scout_web/test/block_scout_web/controllers/tokens/read_contract_controller_test.exs b/apps/block_scout_web/test/block_scout_web/controllers/tokens/read_contract_controller_test.exs
index d4f11f5c8b..5c188d1762 100644
--- a/apps/block_scout_web/test/block_scout_web/controllers/tokens/read_contract_controller_test.exs
+++ b/apps/block_scout_web/test/block_scout_web/controllers/tokens/read_contract_controller_test.exs
@@ -3,7 +3,7 @@ defmodule BlockScoutWeb.Tokens.ReadContractControllerTest do
describe "GET index/3" do
test "with invalid address hash", %{conn: conn} do
- conn = get(conn, token_read_contract_path(BlockScoutWeb.Endpoint, :index, :en, "invalid_address"))
+ conn = get(conn, token_read_contract_path(BlockScoutWeb.Endpoint, :index, "invalid_address"))
assert html_response(conn, 404)
end
@@ -26,7 +26,7 @@ defmodule BlockScoutWeb.Tokens.ReadContractControllerTest do
token: token
)
- conn = get(conn, token_read_contract_path(BlockScoutWeb.Endpoint, :index, :en, token.contract_address_hash))
+ conn = get(conn, token_read_contract_path(BlockScoutWeb.Endpoint, :index, token.contract_address_hash))
assert html_response(conn, 200)
assert token.contract_address_hash == conn.assigns.token.contract_address_hash
diff --git a/apps/block_scout_web/test/block_scout_web/controllers/transaction_controller_test.exs b/apps/block_scout_web/test/block_scout_web/controllers/transaction_controller_test.exs
index 90106238ce..60a9211009 100644
--- a/apps/block_scout_web/test/block_scout_web/controllers/transaction_controller_test.exs
+++ b/apps/block_scout_web/test/block_scout_web/controllers/transaction_controller_test.exs
@@ -3,7 +3,7 @@ defmodule BlockScoutWeb.TransactionControllerTest do
alias Explorer.Chain.{Block, Transaction}
import BlockScoutWeb.Router.Helpers,
- only: [transaction_path: 4, transaction_internal_transaction_path: 4, transaction_token_transfer_path: 4]
+ only: [transaction_path: 3, transaction_internal_transaction_path: 3, transaction_token_transfer_path: 3]
describe "GET index/2" do
test "returns a collated transactions", %{conn: conn} do
@@ -12,7 +12,7 @@ defmodule BlockScoutWeb.TransactionControllerTest do
|> insert()
|> with_block()
- conn = get(conn, "/en/transactions")
+ conn = get(conn, "/txs")
assert List.first(conn.assigns.transactions).hash == transaction.hash
end
@@ -22,7 +22,7 @@ defmodule BlockScoutWeb.TransactionControllerTest do
|> insert()
|> with_block()
- conn = get(conn, "/en/transactions")
+ conn = get(conn, "/txs")
assert is_integer(conn.assigns.transaction_estimated_count)
end
@@ -35,7 +35,7 @@ defmodule BlockScoutWeb.TransactionControllerTest do
insert(:transaction)
- conn = get(conn, "/en/transactions")
+ conn = get(conn, "/txs")
assert [%Transaction{hash: ^hash}] = conn.assigns.transactions
end
@@ -53,7 +53,7 @@ defmodule BlockScoutWeb.TransactionControllerTest do
|> with_block()
conn =
- get(conn, "/en/transactions", %{
+ get(conn, "/txs", %{
"block_number" => Integer.to_string(block_number),
"index" => Integer.to_string(index)
})
@@ -74,7 +74,7 @@ defmodule BlockScoutWeb.TransactionControllerTest do
|> insert_list(:transaction, from_address: address)
|> with_block(block)
- conn = get(conn, "/en/transactions")
+ conn = get(conn, "/txs")
assert %{"block_number" => ^number, "index" => 10} = conn.assigns.next_page_params
end
@@ -86,13 +86,13 @@ defmodule BlockScoutWeb.TransactionControllerTest do
|> insert(from_address: address)
|> with_block()
- conn = get(conn, "/en/transactions")
+ conn = get(conn, "/txs")
refute conn.assigns.next_page_params
end
test "works when there are no transactions", %{conn: conn} do
- conn = get(conn, "/en/transactions")
+ conn = get(conn, "/txs")
assert conn.assigns.transactions == []
end
@@ -100,23 +100,20 @@ defmodule BlockScoutWeb.TransactionControllerTest do
describe "GET show/3" do
test "redirects to transactions/:transaction_id/token_transfers when there are token transfers", %{conn: conn} do
- locale = "en"
transaction = insert(:transaction)
insert(:token_transfer, transaction: transaction)
- conn = get(conn, transaction_path(BlockScoutWeb.Endpoint, :show, locale, transaction))
+ conn = get(conn, transaction_path(BlockScoutWeb.Endpoint, :show, transaction))
- assert redirected_to(conn) =~ transaction_token_transfer_path(BlockScoutWeb.Endpoint, :index, locale, transaction)
+ assert redirected_to(conn) =~ transaction_token_transfer_path(BlockScoutWeb.Endpoint, :index, transaction)
end
test "redirects to transactions/:transaction_id/internal_transactions when there are no token transfers", %{
conn: conn
} do
- locale = "en"
transaction = insert(:transaction)
- conn = get(conn, transaction_path(BlockScoutWeb.Endpoint, :show, locale, transaction))
+ conn = get(conn, transaction_path(BlockScoutWeb.Endpoint, :show, transaction))
- assert redirected_to(conn) =~
- transaction_internal_transaction_path(BlockScoutWeb.Endpoint, :index, locale, transaction)
+ assert redirected_to(conn) =~ transaction_internal_transaction_path(BlockScoutWeb.Endpoint, :index, transaction)
end
end
end
diff --git a/apps/block_scout_web/test/block_scout_web/controllers/transaction_internal_transaction_controller_test.exs b/apps/block_scout_web/test/block_scout_web/controllers/transaction_internal_transaction_controller_test.exs
index 7c013aff7e..9b4dfbad06 100644
--- a/apps/block_scout_web/test/block_scout_web/controllers/transaction_internal_transaction_controller_test.exs
+++ b/apps/block_scout_web/test/block_scout_web/controllers/transaction_internal_transaction_controller_test.exs
@@ -1,7 +1,7 @@
defmodule BlockScoutWeb.TransactionInternalTransactionControllerTest do
use BlockScoutWeb.ConnCase
- import BlockScoutWeb.Router.Helpers, only: [transaction_internal_transaction_path: 4]
+ import BlockScoutWeb.Router.Helpers, only: [transaction_internal_transaction_path: 3]
alias Explorer.Chain.{Block, InternalTransaction, Transaction}
alias Explorer.ExchangeRates.Token
@@ -9,13 +9,13 @@ defmodule BlockScoutWeb.TransactionInternalTransactionControllerTest do
describe "GET index/3" do
test "with missing transaction", %{conn: conn} do
hash = transaction_hash()
- conn = get(conn, transaction_internal_transaction_path(BlockScoutWeb.Endpoint, :index, :en, hash))
+ conn = get(conn, transaction_internal_transaction_path(BlockScoutWeb.Endpoint, :index, hash))
assert html_response(conn, 404)
end
test "with invalid transaction hash", %{conn: conn} do
- conn = get(conn, transaction_internal_transaction_path(BlockScoutWeb.Endpoint, :index, :en, "nope"))
+ conn = get(conn, transaction_internal_transaction_path(BlockScoutWeb.Endpoint, :index, "nope"))
assert html_response(conn, 404)
end
@@ -28,7 +28,7 @@ defmodule BlockScoutWeb.TransactionInternalTransactionControllerTest do
|> insert()
|> with_block(block)
- conn = get(conn, transaction_internal_transaction_path(BlockScoutWeb.Endpoint, :index, :en, transaction.hash))
+ conn = get(conn, transaction_internal_transaction_path(BlockScoutWeb.Endpoint, :index, transaction.hash))
assert html_response(conn, 200)
assert conn.assigns.transaction.hash == transaction.hash
@@ -39,7 +39,7 @@ defmodule BlockScoutWeb.TransactionInternalTransactionControllerTest do
expected_internal_transaction = insert(:internal_transaction, transaction: transaction, index: 0)
insert(:internal_transaction, transaction: transaction, index: 1)
- path = transaction_internal_transaction_path(BlockScoutWeb.Endpoint, :index, :en, transaction.hash)
+ path = transaction_internal_transaction_path(BlockScoutWeb.Endpoint, :index, transaction.hash)
conn = get(conn, path)
@@ -55,7 +55,7 @@ defmodule BlockScoutWeb.TransactionInternalTransactionControllerTest do
test "includes USD exchange rate value for address in assigns", %{conn: conn} do
transaction = insert(:transaction)
- conn = get(conn, transaction_internal_transaction_path(BlockScoutWeb.Endpoint, :index, :en, transaction.hash))
+ conn = get(conn, transaction_internal_transaction_path(BlockScoutWeb.Endpoint, :index, transaction.hash))
assert %Token{} = conn.assigns.exchange_rate
end
@@ -80,7 +80,6 @@ defmodule BlockScoutWeb.TransactionInternalTransactionControllerTest do
transaction_internal_transaction_path(
BlockScoutWeb.Endpoint,
:index,
- :en,
internal_transaction.transaction_hash
)
)
@@ -102,7 +101,7 @@ defmodule BlockScoutWeb.TransactionInternalTransactionControllerTest do
|> Enum.map(& &1.index)
conn =
- get(conn, transaction_internal_transaction_path(BlockScoutWeb.Endpoint, :index, :en, transaction.hash), %{
+ get(conn, transaction_internal_transaction_path(BlockScoutWeb.Endpoint, :index, transaction.hash), %{
"index" => Integer.to_string(index)
})
@@ -131,7 +130,7 @@ defmodule BlockScoutWeb.TransactionInternalTransactionControllerTest do
)
end)
- conn = get(conn, transaction_internal_transaction_path(BlockScoutWeb.Endpoint, :index, :en, transaction.hash))
+ conn = get(conn, transaction_internal_transaction_path(BlockScoutWeb.Endpoint, :index, transaction.hash))
assert %{"block_number" => ^number, "index" => 50, "transaction_index" => ^transaction_index} =
conn.assigns.next_page_params
@@ -152,7 +151,7 @@ defmodule BlockScoutWeb.TransactionInternalTransactionControllerTest do
)
end)
- conn = get(conn, transaction_internal_transaction_path(BlockScoutWeb.Endpoint, :index, :en, transaction.hash))
+ conn = get(conn, transaction_internal_transaction_path(BlockScoutWeb.Endpoint, :index, transaction.hash))
refute conn.assigns.next_page_params
end
diff --git a/apps/block_scout_web/test/block_scout_web/controllers/transaction_log_controller_test.exs b/apps/block_scout_web/test/block_scout_web/controllers/transaction_log_controller_test.exs
index a02cb33efb..eb1550fd5a 100644
--- a/apps/block_scout_web/test/block_scout_web/controllers/transaction_log_controller_test.exs
+++ b/apps/block_scout_web/test/block_scout_web/controllers/transaction_log_controller_test.exs
@@ -1,13 +1,13 @@
defmodule BlockScoutWeb.TransactionLogControllerTest do
use BlockScoutWeb.ConnCase
- import BlockScoutWeb.Router.Helpers, only: [transaction_log_path: 4]
+ import BlockScoutWeb.Router.Helpers, only: [transaction_log_path: 3]
alias Explorer.ExchangeRates.Token
describe "GET index/2" do
test "with invalid transaction hash", %{conn: conn} do
- conn = get(conn, transaction_log_path(conn, :index, :en, "invalid_transaction_string"))
+ conn = get(conn, transaction_log_path(conn, :index, "invalid_transaction_string"))
assert html_response(conn, 404)
end
@@ -16,7 +16,7 @@ defmodule BlockScoutWeb.TransactionLogControllerTest do
conn =
get(
conn,
- transaction_log_path(conn, :index, :en, "0x3a3eb134e6792ce9403ea4188e5e79693de9e4c94e499db132be086400da79e6")
+ transaction_log_path(conn, :index, "0x3a3eb134e6792ce9403ea4188e5e79693de9e4c94e499db132be086400da79e6")
)
assert html_response(conn, 404)
@@ -31,7 +31,7 @@ defmodule BlockScoutWeb.TransactionLogControllerTest do
address = insert(:address)
insert(:log, address: address, transaction: transaction)
- conn = get(conn, transaction_log_path(conn, :index, :en, transaction))
+ conn = get(conn, transaction_log_path(conn, :index, transaction))
first_log = List.first(conn.assigns.logs)
@@ -47,7 +47,7 @@ defmodule BlockScoutWeb.TransactionLogControllerTest do
address = insert(:address)
insert(:log, address: address, transaction: transaction)
- conn = get(conn, transaction_log_path(conn, :index, :en, transaction))
+ conn = get(conn, transaction_log_path(conn, :index, transaction))
first_log = List.first(conn.assigns.logs)
@@ -56,7 +56,7 @@ defmodule BlockScoutWeb.TransactionLogControllerTest do
test "assigns no logs when there are none", %{conn: conn} do
transaction = insert(:transaction)
- path = transaction_log_path(conn, :index, :en, transaction)
+ path = transaction_log_path(conn, :index, transaction)
conn = get(conn, path)
@@ -77,7 +77,7 @@ defmodule BlockScoutWeb.TransactionLogControllerTest do
|> Enum.map(& &1.index)
conn =
- get(conn, transaction_log_path(conn, :index, :en, transaction), %{
+ get(conn, transaction_log_path(conn, :index, transaction), %{
"index" => Integer.to_string(log.index)
})
@@ -95,7 +95,7 @@ defmodule BlockScoutWeb.TransactionLogControllerTest do
1..60
|> Enum.map(fn index -> insert(:log, transaction: transaction, index: index) end)
- conn = get(conn, transaction_log_path(conn, :index, :en, transaction))
+ conn = get(conn, transaction_log_path(conn, :index, transaction))
assert %{"index" => 50} = conn.assigns.next_page_params
end
@@ -106,7 +106,7 @@ defmodule BlockScoutWeb.TransactionLogControllerTest do
|> insert()
|> with_block()
- conn = get(conn, transaction_log_path(conn, :index, :en, transaction))
+ conn = get(conn, transaction_log_path(conn, :index, transaction))
refute conn.assigns.next_page_params
end
@@ -115,7 +115,7 @@ defmodule BlockScoutWeb.TransactionLogControllerTest do
test "includes USD exchange rate value for address in assigns", %{conn: conn} do
transaction = insert(:transaction)
- conn = get(conn, transaction_log_path(BlockScoutWeb.Endpoint, :index, :en, transaction.hash))
+ conn = get(conn, transaction_log_path(BlockScoutWeb.Endpoint, :index, transaction.hash))
assert %Token{} = conn.assigns.exchange_rate
end
diff --git a/apps/block_scout_web/test/block_scout_web/controllers/transaction_token_transfer_controller_test.exs b/apps/block_scout_web/test/block_scout_web/controllers/transaction_token_transfer_controller_test.exs
index fdd7191d7b..d204099dad 100644
--- a/apps/block_scout_web/test/block_scout_web/controllers/transaction_token_transfer_controller_test.exs
+++ b/apps/block_scout_web/test/block_scout_web/controllers/transaction_token_transfer_controller_test.exs
@@ -1,7 +1,7 @@
defmodule BlockScoutWeb.TransactionTokenTransferControllerTest do
use BlockScoutWeb.ConnCase
- import BlockScoutWeb.Router.Helpers, only: [transaction_token_transfer_path: 4]
+ import BlockScoutWeb.Router.Helpers, only: [transaction_token_transfer_path: 3]
alias Explorer.ExchangeRates.Token
@@ -10,20 +10,20 @@ defmodule BlockScoutWeb.TransactionTokenTransferControllerTest do
transaction = insert(:transaction)
token_transfer = insert(:token_transfer, transaction: transaction)
- conn = get(conn, transaction_token_transfer_path(BlockScoutWeb.Endpoint, :index, :en, transaction.hash))
+ conn = get(conn, transaction_token_transfer_path(BlockScoutWeb.Endpoint, :index, transaction.hash))
assert List.first(conn.assigns.transaction.token_transfers).id == token_transfer.id
end
test "with missing transaction", %{conn: conn} do
hash = transaction_hash()
- conn = get(conn, transaction_token_transfer_path(BlockScoutWeb.Endpoint, :index, :en, hash))
+ conn = get(conn, transaction_token_transfer_path(BlockScoutWeb.Endpoint, :index, hash))
assert html_response(conn, 404)
end
test "with invalid transaction hash", %{conn: conn} do
- conn = get(conn, transaction_token_transfer_path(BlockScoutWeb.Endpoint, :index, :en, "nope"))
+ conn = get(conn, transaction_token_transfer_path(BlockScoutWeb.Endpoint, :index, "nope"))
assert html_response(conn, 404)
end
@@ -36,7 +36,7 @@ defmodule BlockScoutWeb.TransactionTokenTransferControllerTest do
|> insert()
|> with_block(block)
- conn = get(conn, transaction_token_transfer_path(BlockScoutWeb.Endpoint, :index, :en, transaction.hash))
+ conn = get(conn, transaction_token_transfer_path(BlockScoutWeb.Endpoint, :index, transaction.hash))
assert html_response(conn, 200)
assert conn.assigns.transaction.hash == transaction.hash
@@ -49,7 +49,7 @@ defmodule BlockScoutWeb.TransactionTokenTransferControllerTest do
insert(:token_transfer, transaction: transaction)
- path = transaction_token_transfer_path(BlockScoutWeb.Endpoint, :index, :en, transaction.hash)
+ path = transaction_token_transfer_path(BlockScoutWeb.Endpoint, :index, transaction.hash)
conn = get(conn, path)
@@ -65,7 +65,7 @@ defmodule BlockScoutWeb.TransactionTokenTransferControllerTest do
test "includes USD exchange rate value for address in assigns", %{conn: conn} do
transaction = insert(:transaction)
- conn = get(conn, transaction_token_transfer_path(BlockScoutWeb.Endpoint, :index, :en, transaction.hash))
+ conn = get(conn, transaction_token_transfer_path(BlockScoutWeb.Endpoint, :index, transaction.hash))
assert %Token{} = conn.assigns.exchange_rate
end
@@ -86,7 +86,7 @@ defmodule BlockScoutWeb.TransactionTokenTransferControllerTest do
end)
conn =
- get(conn, transaction_token_transfer_path(BlockScoutWeb.Endpoint, :index, :en, transaction.hash), %{
+ get(conn, transaction_token_transfer_path(BlockScoutWeb.Endpoint, :index, transaction.hash), %{
"inserted_at" => first_transfer_time |> DateTime.from_naive!("Etc/UTC") |> DateTime.to_iso8601()
})
@@ -112,7 +112,7 @@ defmodule BlockScoutWeb.TransactionTokenTransferControllerTest do
)
end)
- conn = get(conn, transaction_token_transfer_path(BlockScoutWeb.Endpoint, :index, :en, transaction.hash))
+ conn = get(conn, transaction_token_transfer_path(BlockScoutWeb.Endpoint, :index, transaction.hash))
assert Enum.any?(conn.assigns.next_page_params)
end
@@ -132,7 +132,7 @@ defmodule BlockScoutWeb.TransactionTokenTransferControllerTest do
)
end)
- conn = get(conn, transaction_token_transfer_path(BlockScoutWeb.Endpoint, :index, :en, transaction.hash))
+ conn = get(conn, transaction_token_transfer_path(BlockScoutWeb.Endpoint, :index, transaction.hash))
assert is_nil(conn.assigns.next_page_params)
end
diff --git a/apps/block_scout_web/test/block_scout_web/exchange_rates/usd_test.exs b/apps/block_scout_web/test/block_scout_web/exchange_rates/usd_test.exs
deleted file mode 100644
index d63fd31e18..0000000000
--- a/apps/block_scout_web/test/block_scout_web/exchange_rates/usd_test.exs
+++ /dev/null
@@ -1,48 +0,0 @@
-defmodule BlockScoutWeb.ExchangeRates.USDTest do
- use ExUnit.Case, async: true
-
- alias BlockScoutWeb.ExchangeRates.USD
- alias Explorer.ExchangeRates.Token
- alias Explorer.Chain.Wei
-
- describe "from/2" do
- test "with nil wei returns null object" do
- token = %Token{usd_value: Decimal.new(0.5)}
-
- assert USD.null() == USD.from(nil, token)
- end
-
- test "with nil token returns nil" do
- wei = %Wei{value: Decimal.new(10_000_000_000_000)}
-
- assert USD.null() == USD.from(wei, nil)
- end
-
- test "without a wei value returns nil" do
- wei = %Wei{value: nil}
- token = %Token{usd_value: Decimal.new(0.5)}
-
- assert USD.null() == USD.from(wei, token)
- end
-
- test "without an exchange rate returns nil" do
- wei = %Wei{value: Decimal.new(10_000_000_000_000)}
- token = %Token{usd_value: nil}
-
- assert USD.null() == USD.from(wei, token)
- end
-
- test "returns formatted usd value" do
- wei = %Wei{value: Decimal.new(10_000_000_000_000)}
- token = %Token{usd_value: Decimal.new(0.5)}
-
- assert %USD{value: Decimal.new(0.000005)} == USD.from(wei, token)
- end
-
- test "returns USD struct from decimal usd value" do
- value = Decimal.new(0.000005)
-
- assert %USD{value: ^value} = USD.from(value)
- end
- end
-end
diff --git a/apps/block_scout_web/test/block_scout_web/features/address_contract_verification_test.exs b/apps/block_scout_web/test/block_scout_web/features/address_contract_verification_test.exs
index 1f93e12fc5..b1b60ebd96 100644
--- a/apps/block_scout_web/test/block_scout_web/features/address_contract_verification_test.exs
+++ b/apps/block_scout_web/test/block_scout_web/features/address_contract_verification_test.exs
@@ -1,11 +1,9 @@
defmodule BlockScoutWeb.AddressContractVerificationTest do
use BlockScoutWeb.FeatureCase, async: true
- import Wallaby.Query
-
alias Plug.Conn
- alias Explorer.Chain.Address
alias Explorer.Factory
+ alias BlockScoutWeb.{AddressContractPage, ContractVerifyPage}
setup do
bypass = Bypass.open()
@@ -21,7 +19,7 @@ defmodule BlockScoutWeb.AddressContractVerificationTest do
%{name: name, source_code: source_code, bytecode: bytecode, version: version} = Factory.contract_code_info()
transaction = :transaction |> insert() |> with_block()
- address = %Address{hash: address_hash} = insert(:address, contract_code: bytecode)
+ address = insert(:address, contract_code: bytecode)
insert(
:internal_transaction_create,
@@ -32,33 +30,30 @@ defmodule BlockScoutWeb.AddressContractVerificationTest do
)
session
- |> visit("/en/addresses/#{address_hash}/contract_verifications/new")
- |> fill_in(text_field("Contract Name"), with: name)
- |> click(option(version))
- |> click(radio_button("No"))
- |> fill_in(text_field("Enter the Solidity Contract Code below"), with: source_code)
- |> click(button("Verify and publish"))
-
- assert current_path(session) =~ ~r/\/en\/addresses\/#{address_hash}\/contracts/
+ |> AddressContractPage.visit_page(address)
+ |> AddressContractPage.click_verify_and_publish()
+ |> ContractVerifyPage.fill_form(%{
+ contract_name: name,
+ version: version,
+ optimization: false,
+ source_code: source_code
+ })
+ |> ContractVerifyPage.verify_and_publish()
+
+ assert AddressContractPage.on_page?(session, address)
end
test "with invalid data shows error messages", %{session: session, bypass: bypass} do
Bypass.expect(bypass, fn conn -> Conn.resp(conn, 200, solc_bin_versions()) end)
session
- |> visit("/en/addresses/0x1e0eaa06d02f965be2dfe0bc9ff52b2d82133461/contract_verifications/new")
- |> fill_in(text_field("Contract Name"), with: "")
- |> fill_in(text_field("Enter the Solidity Contract Code below"), with: "")
- |> click(button("Verify and publish"))
- |> assert_has(
- css(
- "[data-test='contract-source-code-error']",
- text: "there was an error validating your contract, please try again."
- )
- )
+ |> ContractVerifyPage.visit_page("0x1e0eaa06d02f965be2dfe0bc9ff52b2d82133461")
+ |> ContractVerifyPage.fill_form(%{contract_name: "", version: nil, optimization: nil, source_code: ""})
+ |> ContractVerifyPage.verify_and_publish()
+ |> assert_has(ContractVerifyPage.validation_error())
end
- def solc_bin_versions() do
+ defp solc_bin_versions do
File.read!("./test/support/fixture/smart_contract/solc_bin.json")
end
end
diff --git a/apps/block_scout_web/test/block_scout_web/features/pages/address_contract_page.ex b/apps/block_scout_web/test/block_scout_web/features/pages/address_contract_page.ex
new file mode 100644
index 0000000000..e8110aa86d
--- /dev/null
+++ b/apps/block_scout_web/test/block_scout_web/features/pages/address_contract_page.ex
@@ -0,0 +1,23 @@
+defmodule BlockScoutWeb.AddressContractPage do
+ @moduledoc false
+
+ use Wallaby.DSL
+
+ import Wallaby.Query, only: [css: 1]
+
+ def on_page?(session, address) do
+ current_path(session) =~ address_contract_path(address)
+ end
+
+ def click_verify_and_publish(session) do
+ click(session, css("[data-test='verify_and_publish']"))
+ end
+
+ def visit_page(session, address) do
+ visit(session, address_contract_path(address))
+ end
+
+ defp address_contract_path(address) do
+ "/en/address/#{address.hash}/contracts"
+ end
+end
diff --git a/apps/block_scout_web/test/block_scout_web/features/pages/address_page.ex b/apps/block_scout_web/test/block_scout_web/features/pages/address_page.ex
index dd3a854d4c..601e5c148a 100644
--- a/apps/block_scout_web/test/block_scout_web/features/pages/address_page.ex
+++ b/apps/block_scout_web/test/block_scout_web/features/pages/address_page.ex
@@ -74,7 +74,7 @@ defmodule BlockScoutWeb.AddressPage do
def visit_page(session, %Address{hash: address_hash}), do: visit_page(session, address_hash)
def visit_page(session, address_hash) do
- visit(session, "/en/addresses/#{address_hash}")
+ visit(session, "/address/#{address_hash}")
end
def token_transfer(%Transaction{hash: transaction_hash}, %Address{hash: address_hash}, count: count) do
diff --git a/apps/block_scout_web/test/block_scout_web/features/pages/block_list_page.ex b/apps/block_scout_web/test/block_scout_web/features/pages/block_list_page.ex
index c6be65e0e8..6b87654b3e 100644
--- a/apps/block_scout_web/test/block_scout_web/features/pages/block_list_page.ex
+++ b/apps/block_scout_web/test/block_scout_web/features/pages/block_list_page.ex
@@ -8,7 +8,7 @@ defmodule BlockScoutWeb.BlockListPage do
alias Explorer.Chain.Block
def visit_page(session) do
- visit(session, "/en/blocks")
+ visit(session, "/blocks")
end
def block(%Block{number: block_number}) do
diff --git a/apps/block_scout_web/test/block_scout_web/features/pages/block_page.ex b/apps/block_scout_web/test/block_scout_web/features/pages/block_page.ex
index c80a30c213..406bdde61f 100644
--- a/apps/block_scout_web/test/block_scout_web/features/pages/block_page.ex
+++ b/apps/block_scout_web/test/block_scout_web/features/pages/block_page.ex
@@ -32,6 +32,6 @@ defmodule BlockScoutWeb.BlockPage do
end
def visit_page(session, %Block{number: block_number}) do
- visit(session, "/en/blocks/#{block_number}/transactions")
+ visit(session, "/blocks/#{block_number}/transactions")
end
end
diff --git a/apps/block_scout_web/test/block_scout_web/features/pages/chain_page.ex b/apps/block_scout_web/test/block_scout_web/features/pages/chain_page.ex
index 6f92efcd37..70d192881d 100644
--- a/apps/block_scout_web/test/block_scout_web/features/pages/chain_page.ex
+++ b/apps/block_scout_web/test/block_scout_web/features/pages/chain_page.ex
@@ -6,7 +6,6 @@ defmodule BlockScoutWeb.ChainPage do
import Wallaby.Query, only: [css: 1, css: 2]
alias Explorer.Chain.Transaction
- alias BlockScoutWeb.ChainView
def blocks(count: count) do
css("[data-selector='chain-block']", count: count)
@@ -16,10 +15,6 @@ defmodule BlockScoutWeb.ChainPage do
css("[data-test='contract-creation'] [data-address-hash='#{hash}']")
end
- def exchange_rate(token) do
- css("[data-selector='exchange-rate']", text: ChainView.format_exchange_rate(token))
- end
-
def non_loaded_transaction_count(count) do
css("[data-selector='channel-batching-count']", text: count)
end
diff --git a/apps/block_scout_web/test/block_scout_web/features/pages/contract_verify_page.ex b/apps/block_scout_web/test/block_scout_web/features/pages/contract_verify_page.ex
new file mode 100644
index 0000000000..0fcfd066a1
--- /dev/null
+++ b/apps/block_scout_web/test/block_scout_web/features/pages/contract_verify_page.ex
@@ -0,0 +1,51 @@
+defmodule BlockScoutWeb.ContractVerifyPage do
+ @moduledoc false
+
+ use Wallaby.DSL
+
+ import Wallaby.Query
+
+ def visit_page(session, address_hash) do
+ visit(session, "/en/address/#{address_hash}/contract_verifications/new")
+ end
+
+ def fill_form(session, %{
+ contract_name: contract_name,
+ version: version,
+ optimization: optimization,
+ source_code: source_code
+ }) do
+ session
+ |> fill_in(css("[data-test='contract_name']"), with: contract_name)
+ |> fill_in(text_field("Enter the Solidity Contract Code below"), with: source_code)
+
+ case version do
+ nil -> nil
+ _ -> click(session, option(version))
+ end
+
+ case optimization do
+ true ->
+ click(session, radio_button("Yes"))
+
+ false ->
+ click(session, radio_button("No"))
+
+ _ ->
+ nil
+ end
+
+ session
+ end
+
+ def validation_error do
+ css(
+ "[data-test='contract-source-code-error']",
+ text: "there was an error validating your contract, please try again."
+ )
+ end
+
+ def verify_and_publish(session) do
+ click(session, button("Verify and publish"))
+ end
+end
diff --git a/apps/block_scout_web/test/block_scout_web/features/pages/transaction_list_page.ex b/apps/block_scout_web/test/block_scout_web/features/pages/transaction_list_page.ex
index ca6dede9ae..479738a77d 100644
--- a/apps/block_scout_web/test/block_scout_web/features/pages/transaction_list_page.ex
+++ b/apps/block_scout_web/test/block_scout_web/features/pages/transaction_list_page.ex
@@ -32,6 +32,6 @@ defmodule BlockScoutWeb.TransactionListPage do
end
def visit_page(session) do
- visit(session, "/en/transactions")
+ visit(session, "/txs")
end
end
diff --git a/apps/block_scout_web/test/block_scout_web/features/pages/transaction_logs_page.ex b/apps/block_scout_web/test/block_scout_web/features/pages/transaction_logs_page.ex
index 0c95e11879..5a908cc967 100644
--- a/apps/block_scout_web/test/block_scout_web/features/pages/transaction_logs_page.ex
+++ b/apps/block_scout_web/test/block_scout_web/features/pages/transaction_logs_page.ex
@@ -4,7 +4,7 @@ defmodule BlockScoutWeb.TransactionLogsPage do
use Wallaby.DSL
import Wallaby.Query, only: [css: 1, css: 2]
- import BlockScoutWeb.Router.Helpers, only: [transaction_log_path: 4]
+ import BlockScoutWeb.Router.Helpers, only: [transaction_log_path: 3]
alias Explorer.Chain.{Address, Transaction}
alias BlockScoutWeb.Endpoint
@@ -14,7 +14,7 @@ defmodule BlockScoutWeb.TransactionLogsPage do
end
def visit_page(session, %Transaction{} = transaction) do
- visit(session, transaction_log_path(Endpoint, :index, :en, transaction))
+ visit(session, transaction_log_path(Endpoint, :index, transaction))
end
def click_address(session, %Address{hash: address_hash}) do
diff --git a/apps/block_scout_web/test/block_scout_web/features/pages/transaction_page.ex b/apps/block_scout_web/test/block_scout_web/features/pages/transaction_page.ex
index 0e662a914e..3b59ceae12 100644
--- a/apps/block_scout_web/test/block_scout_web/features/pages/transaction_page.ex
+++ b/apps/block_scout_web/test/block_scout_web/features/pages/transaction_page.ex
@@ -16,10 +16,10 @@ defmodule BlockScoutWeb.TransactionPage do
end
def visit_page(session, %Transaction{hash: transaction_hash}) do
- visit(session, "/en/transactions/#{transaction_hash}")
+ visit(session, "/tx/#{transaction_hash}")
end
def visit_page(session, transaction_hash = %Hash{}) do
- visit(session, "/en/transactions/#{transaction_hash}")
+ visit(session, "/tx/#{transaction_hash}")
end
end
diff --git a/apps/block_scout_web/test/block_scout_web/features/viewing_addresses_test.exs b/apps/block_scout_web/test/block_scout_web/features/viewing_addresses_test.exs
index 59f931a2d9..b5ca4a5a3e 100644
--- a/apps/block_scout_web/test/block_scout_web/features/viewing_addresses_test.exs
+++ b/apps/block_scout_web/test/block_scout_web/features/viewing_addresses_test.exs
@@ -2,7 +2,8 @@ defmodule BlockScoutWeb.ViewingAddressesTest do
use BlockScoutWeb.FeatureCase, async: true
alias Explorer.Chain.Wei
- alias BlockScoutWeb.AddressPage
+ alias Explorer.Factory
+ alias BlockScoutWeb.{AddressPage, AddressView}
setup do
block = insert(:block)
@@ -40,7 +41,7 @@ defmodule BlockScoutWeb.ViewingAddressesTest do
describe "viewing contract creator" do
test "see the contract creator and transaction links", %{session: session} do
address = insert(:address)
- contract = insert(:address, contract_code: Explorer.Factory.data("contract_code"))
+ contract = insert(:address, contract_code: Factory.data("contract_code"))
transaction = insert(:transaction, from_address: address, created_contract_address: contract)
internal_transaction =
@@ -52,8 +53,8 @@ defmodule BlockScoutWeb.ViewingAddressesTest do
created_contract_address: contract
)
- address_hash = BlockScoutWeb.AddressView.trimmed_hash(address.hash)
- transaction_hash = BlockScoutWeb.AddressView.trimmed_hash(transaction.hash)
+ address_hash = AddressView.trimmed_hash(address.hash)
+ transaction_hash = AddressView.trimmed_hash(transaction.hash)
session
|> AddressPage.visit_page(internal_transaction.created_contract_address)
@@ -62,9 +63,9 @@ defmodule BlockScoutWeb.ViewingAddressesTest do
test "see the contract creator and transaction links even when the creator is another contract", %{session: session} do
lincoln = insert(:address)
- contract = insert(:address, contract_code: Explorer.Factory.data("contract_code"))
+ contract = insert(:address, contract_code: Factory.data("contract_code"))
transaction = insert(:transaction)
- another_contract = insert(:address, contract_code: Explorer.Factory.data("contract_code"))
+ another_contract = insert(:address, contract_code: Factory.data("contract_code"))
insert(
:internal_transaction,
@@ -85,8 +86,8 @@ defmodule BlockScoutWeb.ViewingAddressesTest do
created_contract_address: another_contract
)
- contract_hash = BlockScoutWeb.AddressView.trimmed_hash(contract.hash)
- transaction_hash = BlockScoutWeb.AddressView.trimmed_hash(transaction.hash)
+ contract_hash = AddressView.trimmed_hash(contract.hash)
+ transaction_hash = AddressView.trimmed_hash(transaction.hash)
session
|> AddressPage.visit_page(internal_transaction.created_contract_address)
@@ -337,7 +338,7 @@ defmodule BlockScoutWeb.ViewingAddressesTest do
contract_token_address =
insert(
:address,
- contract_code: Explorer.Factory.data("contract_code")
+ contract_code: Factory.data("contract_code")
)
insert(:token, contract_address: contract_token_address)
diff --git a/apps/block_scout_web/test/block_scout_web/views/address_view_test.exs b/apps/block_scout_web/test/block_scout_web/views/address_view_test.exs
index 0f8c7a12c7..7ba5c71171 100644
--- a/apps/block_scout_web/test/block_scout_web/views/address_view_test.exs
+++ b/apps/block_scout_web/test/block_scout_web/views/address_view_test.exs
@@ -3,7 +3,6 @@ defmodule BlockScoutWeb.AddressViewTest do
alias Explorer.Chain.Data
alias BlockScoutWeb.AddressView
- alias Explorer.ExchangeRates.Token
describe "contract?/1" do
test "with a smart contract" do
@@ -18,26 +17,6 @@ defmodule BlockScoutWeb.AddressViewTest do
end
end
- describe "formatted_usd/2" do
- test "without a fetched_coin_balance returns nil" do
- address = build(:address, fetched_coin_balance: nil)
- token = %Token{usd_value: Decimal.new(0.5)}
- assert nil == AddressView.formatted_usd(address, token)
- end
-
- test "without a usd_value returns nil" do
- address = build(:address)
- token = %Token{usd_value: nil}
- assert nil == AddressView.formatted_usd(address, token)
- end
-
- test "returns formatted usd value" do
- address = build(:address, fetched_coin_balance: 10_000_000_000_000)
- token = %Token{usd_value: Decimal.new(0.5)}
- assert "$0.000005 USD" == AddressView.formatted_usd(address, token)
- end
- end
-
describe "qr_code/1" do
test "it returns an encoded value" do
address = build(:address)
diff --git a/apps/block_scout_web/test/block_scout_web/views/chain_view_test.exs b/apps/block_scout_web/test/block_scout_web/views/chain_view_test.exs
index 89657ae12b..87508724c7 100644
--- a/apps/block_scout_web/test/block_scout_web/views/chain_view_test.exs
+++ b/apps/block_scout_web/test/block_scout_web/views/chain_view_test.exs
@@ -1,7 +1,6 @@
defmodule BlockScoutWeb.ChainViewTest do
use BlockScoutWeb.ConnCase, async: true
- alias Explorer.ExchangeRates.Token
alias BlockScoutWeb.ChainView
describe "encode_market_history_data/1" do
@@ -17,22 +16,4 @@ defmodule BlockScoutWeb.ChainViewTest do
ChainView.encode_market_history_data(market_history_data)
end
end
-
- describe "format_exchange_rate/1" do
- test "returns a formatted usd value from a `Token`'s usd_value" do
- token = %Token{usd_value: Decimal.new(5.45)}
-
- assert "$5.45 USD" == ChainView.format_exchange_rate(token)
- assert nil == ChainView.format_exchange_rate(%Token{usd_value: nil})
- end
- end
-
- describe "format_market_cap/1" do
- test "returns a formatted usd value from a `Token`'s market_cap_usd" do
- token = %Token{market_cap_usd: Decimal.new(5.4)}
-
- assert "$5.40 USD" == ChainView.format_market_cap(token)
- assert nil == ChainView.format_market_cap(%Token{market_cap_usd: nil})
- end
- end
end
diff --git a/apps/block_scout_web/test/block_scout_web/views/currency_helpers_test.exs b/apps/block_scout_web/test/block_scout_web/views/currency_helpers_test.exs
index b47e5deeea..fc6e8496de 100644
--- a/apps/block_scout_web/test/block_scout_web/views/currency_helpers_test.exs
+++ b/apps/block_scout_web/test/block_scout_web/views/currency_helpers_test.exs
@@ -2,18 +2,9 @@ defmodule BlockScoutWeb.CurrencyHelpersTest do
use ExUnit.Case
alias BlockScoutWeb.CurrencyHelpers
- alias BlockScoutWeb.ExchangeRates.USD
doctest BlockScoutWeb.CurrencyHelpers, import: true
- test "with nil it returns nil" do
- assert nil == CurrencyHelpers.format_usd_value(nil)
- end
-
- test "with USD.null() it returns nil" do
- assert nil == CurrencyHelpers.format_usd_value(USD.null())
- end
-
describe "format_according_to_decimals/1" do
test "formats the amount as value considering the given decimals" do
amount = Decimal.new(205_000_000_000_000)
diff --git a/apps/block_scout_web/test/block_scout_web/views/transaction_view_test.exs b/apps/block_scout_web/test/block_scout_web/views/transaction_view_test.exs
index f05f163744..ccc5f7409a 100644
--- a/apps/block_scout_web/test/block_scout_web/views/transaction_view_test.exs
+++ b/apps/block_scout_web/test/block_scout_web/views/transaction_view_test.exs
@@ -2,7 +2,6 @@ defmodule BlockScoutWeb.TransactionViewTest do
use BlockScoutWeb.ConnCase, async: true
alias Explorer.Chain.Wei
- alias Explorer.ExchangeRates.Token
alias Explorer.Repo
alias BlockScoutWeb.TransactionView
@@ -18,21 +17,16 @@ defmodule BlockScoutWeb.TransactionViewTest do
gas_used: nil
)
- token = %Token{usd_value: Decimal.new(0.50)}
-
- expected_value = "<= 0.009 POA"
+ expected_value = "max of 0.009 POA"
assert expected_value == TransactionView.formatted_fee(transaction, denomination: :ether)
- assert "<= $0.004500 USD" == TransactionView.formatted_fee(transaction, exchange_rate: token)
end
- test "with fee and exchange_rate" do
+ test "with fee" do
{:ok, gas_price} = Wei.cast(3_000_000_000)
transaction = build(:transaction, gas_price: gas_price, gas_used: Decimal.new(1_034_234.0))
- token = %Token{usd_value: Decimal.new(0.50)}
expected_value = "0.003102702 POA"
assert expected_value == TransactionView.formatted_fee(transaction, denomination: :ether)
- assert "$0.001551 USD" == TransactionView.formatted_fee(transaction, exchange_rate: token)
end
test "with fee but no available exchange_rate" do
diff --git a/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc.ex b/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc.ex
index ef21cc3fcf..a86bd604b4 100644
--- a/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc.ex
+++ b/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc.ex
@@ -188,10 +188,15 @@ defmodule EthereumJSONRPC do
Transaction data is included for each block.
"""
def fetch_blocks_by_hash(block_hashes, json_rpc_named_arguments) do
- block_hashes
+ id_to_params =
+ block_hashes
+ |> Enum.map(fn block_hash -> %{hash: block_hash} end)
+ |> id_to_params()
+
+ id_to_params
|> get_block_by_hash_requests()
|> json_rpc(json_rpc_named_arguments)
- |> handle_get_blocks()
+ |> handle_get_blocks(id_to_params)
|> case do
{:ok, _next, results} -> {:ok, results}
{:error, reason} -> {:error, reason}
@@ -202,10 +207,15 @@ defmodule EthereumJSONRPC do
Fetches blocks by block number range.
"""
def fetch_blocks_by_range(_first.._last = range, json_rpc_named_arguments) do
- range
+ id_to_params =
+ range
+ |> Enum.map(fn number -> %{number: number} end)
+ |> id_to_params()
+
+ id_to_params
|> get_block_by_number_requests()
|> json_rpc(json_rpc_named_arguments)
- |> handle_get_blocks()
+ |> handle_get_blocks(id_to_params)
end
@doc """
@@ -284,14 +294,6 @@ defmodule EthereumJSONRPC do
transport.json_rpc(request, transport_options)
end
- @doc """
- Converts `t:nonce/0` to `t:non_neg_integer/0`
- """
- @spec nonce_to_integer(nonce) :: non_neg_integer()
- def nonce_to_integer(nonce) do
- quantity_to_integer(nonce)
- end
-
@doc """
Converts `t:quantity/0` to `t:non_neg_integer/0`.
"""
@@ -427,10 +429,10 @@ defmodule EthereumJSONRPC do
{:error, annotated_error}
end
- defp get_block_by_hash_requests(block_hashes) do
- for block_hash <- block_hashes do
- get_block_by_hash_request(%{id: block_hash, hash: block_hash, transactions: :full})
- end
+ defp get_block_by_hash_requests(id_to_params) do
+ Enum.map(id_to_params, fn {id, %{hash: hash}} ->
+ get_block_by_hash_request(%{id: id, hash: hash, transactions: :full})
+ end)
end
defp get_block_by_hash_request(%{id: id} = options) do
@@ -441,10 +443,10 @@ defmodule EthereumJSONRPC do
[hash, get_block_transactions(options)]
end
- defp get_block_by_number_requests(range) do
- for current <- range do
- get_block_by_number_request(%{id: current, quantity: current, transactions: :full})
- end
+ defp get_block_by_number_requests(id_to_params) do
+ Enum.map(id_to_params, fn {id, %{number: number}} ->
+ get_block_by_number_request(%{id: id, quantity: number, transactions: :full})
+ end)
end
defp get_block_by_number_request(%{id: id} = options) do
@@ -467,12 +469,6 @@ defmodule EthereumJSONRPC do
{:error, {:ok, tag}} ->
tag
-
- {{:ok, _}, {:ok, _}} ->
- raise ArgumentError, "Only one of :quantity or :tag can be passed to get_block_by_number_request"
-
- {:error, :error} ->
- raise ArgumentError, "One of :quantity or :tag MUST be passed to get_block_by_number_request"
end
end
@@ -483,26 +479,40 @@ defmodule EthereumJSONRPC do
end
end
- defp handle_get_blocks({:ok, results}) do
- {blocks, next} =
- Enum.reduce(results, {[], :more}, fn
- %{result: nil}, {blocks, _} -> {blocks, :end_of_chain}
- %{result: %{} = block}, {blocks, next} -> {[block | blocks], next}
- end)
+ defp handle_get_blocks({:ok, results}, id_to_params) when is_list(results) do
+ with {:ok, next, blocks} <- reduce_results(results, id_to_params) do
+ elixir_blocks = Blocks.to_elixir(blocks)
+ elixir_transactions = Blocks.elixir_to_transactions(elixir_blocks)
+ blocks_params = Blocks.elixir_to_params(elixir_blocks)
+ transactions_params = Transactions.elixir_to_params(elixir_transactions)
- elixir_blocks = Blocks.to_elixir(blocks)
- elixir_transactions = Blocks.elixir_to_transactions(elixir_blocks)
- blocks_params = Blocks.elixir_to_params(elixir_blocks)
- transactions_params = Transactions.elixir_to_params(elixir_transactions)
+ {:ok, next,
+ %{
+ blocks: blocks_params,
+ transactions: transactions_params
+ }}
+ end
+ end
- {:ok, next,
- %{
- blocks: blocks_params,
- transactions: transactions_params
- }}
+ defp handle_get_blocks({:error, _} = error, _id_to_params), do: error
+
+ defp reduce_results(results, id_to_params) do
+ Enum.reduce(results, {:ok, :more, []}, &reduce_result(&1, &2, id_to_params))
end
- defp handle_get_blocks({:error, _} = error), do: error
+ defp reduce_result(%{result: nil}, {:ok, _, blocks}, _id_to_params), do: {:ok, :end_of_chain, blocks}
+ defp reduce_result(%{result: %{} = block}, {:ok, next, blocks}, _id_to_params), do: {:ok, next, [block | blocks]}
+ defp reduce_result(%{result: _}, {:error, _} = error, _id_to_params), do: error
+
+ defp reduce_result(%{error: reason, id: id}, acc, id_to_params) do
+ data = Map.fetch!(id_to_params, id)
+ annotated_reason = Map.put(reason, :data, data)
+
+ case acc do
+ {:ok, _, _} -> {:error, [annotated_reason]}
+ {:error, reasons} -> {:error, [annotated_reason | reasons]}
+ end
+ end
defp handle_get_block_by_tag({:ok, %{"number" => quantity}}) do
{:ok, quantity_to_integer(quantity)}
diff --git a/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/receipt.ex b/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/receipt.ex
index 69975bf08f..0649d5ad0c 100644
--- a/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/receipt.ex
+++ b/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/receipt.ex
@@ -266,6 +266,7 @@ defmodule EthereumJSONRPC.Receipt do
defp elixir_reducer({:ok, {_, _}}, {:error, _reasons} = acc_error), do: acc_error
defp elixir_reducer({:error, reason}, {:ok, _}), do: {:error, [reason]}
defp elixir_reducer({:error, reason}, {:error, reasons}), do: {:error, [reason | reasons]}
+ defp elixir_reducer(:ignore, acc), do: acc
defp ok!({:ok, elixir}, _receipt), do: elixir
@@ -327,6 +328,8 @@ defmodule EthereumJSONRPC.Receipt do
case status do
"0x0" -> {:ok, {key, :error}}
"0x1" -> {:ok, {key, :ok}}
+ # pre-Byzantium / Ethereum Classic on Parity
+ nil -> :ignore
other -> {:error, {:unknown_value, %{key: key, value: other}}}
end
end
diff --git a/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/receipts.ex b/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/receipts.ex
index 0f5dd2edd2..6056e07ba4 100644
--- a/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/receipts.ex
+++ b/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/receipts.ex
@@ -132,11 +132,9 @@ defmodule EthereumJSONRPC.Receipts do
{requests, id_to_transaction_params}
end)
- with {:ok, responses} <- json_rpc(requests, json_rpc_named_arguments) do
- elixir_receipts =
- responses
- |> responses_to_receipts(id_to_transaction_params)
- |> to_elixir()
+ with {:ok, responses} <- json_rpc(requests, json_rpc_named_arguments),
+ {:ok, receipts} <- reduce_responses(responses, id_to_transaction_params) do
+ elixir_receipts = to_elixir(receipts)
elixir_logs = elixir_to_logs(elixir_receipts)
receipts = elixir_to_params(elixir_receipts)
@@ -220,20 +218,35 @@ defmodule EthereumJSONRPC.Receipts do
})
end
- defp response_to_receipt(%{result: nil}, _), do: %{}
+ defp response_to_receipt(%{id: id, result: nil}, id_to_transaction_params) do
+ data = Map.fetch!(id_to_transaction_params, id)
+ {:error, %{code: -32602, data: data, message: "Not Found"}}
+ end
defp response_to_receipt(%{id: id, result: receipt}, id_to_transaction_params) do
- gas =
- id_to_transaction_params
- |> Map.fetch!(id)
- |> Map.fetch!(:gas)
+ %{gas: gas} = Map.fetch!(id_to_transaction_params, id)
# gas from the transaction is needed for pre-Byzantium derived status
- Map.put(receipt, "gas", gas)
+ {:ok, Map.put(receipt, "gas", gas)}
+ end
+
+ defp response_to_receipt(%{id: id, error: reason}, id_to_transaction_params) do
+ data = Map.fetch!(id_to_transaction_params, id)
+ annotated_reason = Map.put(reason, :data, data)
+ {:error, annotated_reason}
end
- defp responses_to_receipts(responses, id_to_transaction_params)
+ defp reduce_responses(responses, id_to_transaction_params)
when is_list(responses) and is_map(id_to_transaction_params) do
- Enum.map(responses, &response_to_receipt(&1, id_to_transaction_params))
+ responses
+ |> Stream.map(&response_to_receipt(&1, id_to_transaction_params))
+ |> Enum.reduce({:ok, []}, &reduce_receipt(&1, &2))
end
+
+ defp reduce_receipt({:ok, receipt}, {:ok, receipts}) when is_list(receipts),
+ do: {:ok, [receipt | receipts]}
+
+ defp reduce_receipt({:ok, _}, {:error, _} = error), do: error
+ defp reduce_receipt({:error, reason}, {:ok, _}), do: {:error, [reason]}
+ defp reduce_receipt({:error, reason}, {:error, reasons}) when is_list(reasons), do: {:error, [reason | reasons]}
end
diff --git a/apps/ethereum_jsonrpc/test/ethereum_jsonrpc/receipt_test.exs b/apps/ethereum_jsonrpc/test/ethereum_jsonrpc/receipt_test.exs
index 60e80282d5..b54b2ae984 100644
--- a/apps/ethereum_jsonrpc/test/ethereum_jsonrpc/receipt_test.exs
+++ b/apps/ethereum_jsonrpc/test/ethereum_jsonrpc/receipt_test.exs
@@ -43,5 +43,10 @@ defmodule EthereumJSONRPC.ReceiptTest do
})
end
end
+
+ # Regression test for https://github.com/poanetwork/blockscout/issues/638
+ test ~s|"status" => nil is treated the same as no status| do
+ assert Receipt.to_elixir(%{"status" => nil, "transactionHash" => "0x0"}) == %{"transactionHash" => "0x0"}
+ end
end
end
diff --git a/apps/ethereum_jsonrpc/test/ethereum_jsonrpc/receipts_test.exs b/apps/ethereum_jsonrpc/test/ethereum_jsonrpc/receipts_test.exs
index 8d6d0e4acb..613d370d3c 100644
--- a/apps/ethereum_jsonrpc/test/ethereum_jsonrpc/receipts_test.exs
+++ b/apps/ethereum_jsonrpc/test/ethereum_jsonrpc/receipts_test.exs
@@ -130,5 +130,43 @@ defmodule EthereumJSONRPC.ReceiptsTest do
json_rpc_named_arguments
)
end
+
+ test "with errors return all errors", %{json_rpc_named_arguments: json_rpc_named_arguments} do
+ # Can't be faked reliably on real chain
+ moxed_json_rpc_named_arguments = Keyword.put(json_rpc_named_arguments, :transport, EthereumJSONRPC.Mox)
+
+ expect(EthereumJSONRPC.Mox, :json_rpc, fn json, _options ->
+ assert length(json) == 5
+
+ {:ok,
+ [
+ %{id: 0, result: %{}},
+ # :ok, :ok
+ %{id: 1, result: %{}},
+ # :error, :ok
+ %{id: 2, error: %{code: 2}},
+ # :ok, :error
+ %{id: 3, result: %{}},
+ # :error, :error
+ %{id: 4, error: %{code: 4}}
+ ]}
+ end)
+
+ assert {:error,
+ [
+ %{code: 4, data: %{gas: 4, hash: "0x4"}},
+ %{code: 2, data: %{gas: 2, hash: "0x2"}}
+ ]} =
+ Receipts.fetch(
+ [
+ %{gas: 0, hash: "0x0"},
+ %{gas: 1, hash: "0x1"},
+ %{gas: 2, hash: "0x2"},
+ %{gas: 3, hash: "0x3"},
+ %{gas: 4, hash: "0x4"}
+ ],
+ moxed_json_rpc_named_arguments
+ )
+ end
end
end
diff --git a/apps/ethereum_jsonrpc/test/ethereum_jsonrpc_test.exs b/apps/ethereum_jsonrpc/test/ethereum_jsonrpc_test.exs
index e7fba66202..d8d43b995a 100644
--- a/apps/ethereum_jsonrpc/test/ethereum_jsonrpc_test.exs
+++ b/apps/ethereum_jsonrpc/test/ethereum_jsonrpc_test.exs
@@ -164,6 +164,217 @@ defmodule EthereumJSONRPCTest do
end
end
+ describe "fetch_block_by_hash/2" do
+ test "can fetch blocks", %{json_rpc_named_arguments: json_rpc_named_arguments} do
+ %{block_hash: block_hash, transaction_hash: transaction_hash} =
+ case Keyword.fetch!(json_rpc_named_arguments, :variant) do
+ EthereumJSONRPC.Parity ->
+ %{
+ block_hash: "0x29c850324e357f3c0c836d79860c5af55f7b651e5d7ee253c1af1b14908af49c",
+ transaction_hash: "0xa2e81bb56b55ba3dab2daf76501b50dfaad240cccb905dbf89d65c7a84a4a48e"
+ }
+
+ EthereumJSONRPC.Geth ->
+ %{
+ block_hash: "0xe065eed62c152c8c3dd14d6e5948e652c3e36a9cdb10b79853802ef9fa1d536c",
+ transaction_hash: "0x615506d9872bb07faa2ce17c02b902148eae88ccba0298902be6a0dbba1124de"
+ }
+ end
+
+ if json_rpc_named_arguments[:transport] == EthereumJSONRPC.Mox do
+ expect(EthereumJSONRPC.Mox, :json_rpc, fn _json, _options ->
+ block_number = "0x0"
+
+ {:ok,
+ [
+ %{
+ result: %{
+ "difficulty" => "0x0",
+ "gasLimit" => "0x0",
+ "gasUsed" => "0x0",
+ "hash" => block_hash,
+ "miner" => "0x0",
+ "number" => block_number,
+ "parentHash" => "0x0",
+ "size" => "0x0",
+ "timestamp" => "0x0",
+ "totalDifficulty" => "0x0",
+ "transactions" => [
+ %{
+ "blockHash" => block_hash,
+ "blockNumber" => block_number,
+ "from" => "0x0",
+ "gas" => "0x0",
+ "gasPrice" => "0x0",
+ "hash" => transaction_hash,
+ "input" => "0x",
+ "nonce" => "0x0",
+ "r" => "0x0",
+ "s" => "0x0",
+ "to" => "0x0",
+ "transactionIndex" => "0x0",
+ "v" => "0x0",
+ "value" => "0x0"
+ }
+ ]
+ }
+ }
+ ]}
+ end)
+ end
+
+ assert {:ok, %{blocks: [_ | _], transactions: [_ | _]}} =
+ EthereumJSONRPC.fetch_blocks_by_hash([block_hash], json_rpc_named_arguments)
+ end
+
+ test "returns errors with block hash in data", %{json_rpc_named_arguments: json_rpc_named_arguments} do
+ if json_rpc_named_arguments[:transport] == EthereumJSONRPC.Mox do
+ expect(EthereumJSONRPC.Mox, :json_rpc, fn _json, _options ->
+ {:ok,
+ [
+ %{
+ error: %{
+ code: -32602,
+ message: "Hash too short"
+ },
+ id: 0,
+ jsonrpc: "2.0"
+ }
+ ]}
+ end)
+ end
+
+ assert {:error, [%{data: %{hash: "0x0"}}]} =
+ EthereumJSONRPC.fetch_blocks_by_hash(["0x0"], json_rpc_named_arguments)
+ end
+
+ test "full batch errors are returned", %{json_rpc_named_arguments: json_rpc_named_arguments} do
+ # I'm not sure how to reliably trigger this on the real chains, so only do mox
+ moxed_json_rpc_named_arguments = Keyword.put(json_rpc_named_arguments, :transport, EthereumJSONRPC.Mox)
+
+ error = {:error, %{"message" => "methodNotSupported"}}
+
+ expect(EthereumJSONRPC.Mox, :json_rpc, fn _json, _options ->
+ error
+ end)
+
+ assert EthereumJSONRPC.fetch_blocks_by_hash(["0x0"], moxed_json_rpc_named_arguments) == error
+ end
+ end
+
+ describe "fetch_block_by_range/2" do
+ test "returns errors with block number in data", %{json_rpc_named_arguments: json_rpc_named_arguments} do
+ if json_rpc_named_arguments[:transport] == EthereumJSONRPC.Mox do
+ expect(EthereumJSONRPC.Mox, :json_rpc, fn _json, _options ->
+ {:ok,
+ [
+ %{
+ error: %{
+ code: -32602,
+ message: "Invalid params: Invalid block number: number too large to fit in target type."
+ },
+ id: 0,
+ jsonrpc: "2.0"
+ },
+ %{
+ error: %{
+ code: -32602,
+ message: "Invalid params: Invalid block number: number too large to fit in target type."
+ },
+ id: 1,
+ jsonrpc: "2.0"
+ }
+ ]}
+ end)
+ end
+
+ assert {:error,
+ [%{data: %{number: 1_000_000_000_000_000_000_001}}, %{data: %{number: 1_000_000_000_000_000_000_000}}]} =
+ EthereumJSONRPC.fetch_blocks_by_range(
+ 1_000_000_000_000_000_000_000..1_000_000_000_000_000_000_001,
+ json_rpc_named_arguments
+ )
+ end
+
+ test "returns only errors if a mix of results and errors", %{json_rpc_named_arguments: json_rpc_named_arguments} do
+ # Can't be faked reliably on real chain
+ moxed_json_rpc_named_arguments = Keyword.put(json_rpc_named_arguments, :transport, EthereumJSONRPC.Mox)
+
+ expect(EthereumJSONRPC.Mox, :json_rpc, fn _json, _options ->
+ {:ok,
+ [
+ %{
+ error: %{
+ code: -32602,
+ message: "Invalid params: Invalid block number: number too large to fit in target type."
+ },
+ id: 0,
+ jsonrpc: "2.0"
+ },
+ %{
+ id: 1,
+ result: %{
+ "difficulty" => "0x0",
+ "gasLimit" => "0x0",
+ "gasUsed" => "0x0",
+ "hash" => "0x0",
+ "miner" => "0x0",
+ "number" => "0x0",
+ "parentHash" => "0x0",
+ "size" => "0x0",
+ "timestamp" => "0x0",
+ "totalDifficulty" => "0x0",
+ "transactions" => []
+ },
+ jsonrpc: "2.0"
+ }
+ ]}
+ end)
+
+ assert {:error, [%{data: %{number: 1_000_000_000_000_000_000_000}}]} =
+ EthereumJSONRPC.fetch_blocks_by_range(
+ 1_000_000_000_000_000_000_000..1_000_000_000_000_000_000_001,
+ moxed_json_rpc_named_arguments
+ )
+ end
+
+ test "nil result indicated end-of-chain", %{json_rpc_named_arguments: json_rpc_named_arguments} do
+ # Can't be faked reliably on real chain
+ moxed_json_rpc_named_arguments = Keyword.put(json_rpc_named_arguments, :transport, EthereumJSONRPC.Mox)
+
+ expect(EthereumJSONRPC.Mox, :json_rpc, fn _json, _options ->
+ {:ok,
+ [
+ %{
+ id: 0,
+ result: %{
+ "difficulty" => "0x0",
+ "gasLimit" => "0x0",
+ "gasUsed" => "0x0",
+ "hash" => "0x0",
+ "miner" => "0x0",
+ "number" => "0x0",
+ "parentHash" => "0x0",
+ "size" => "0x0",
+ "timestamp" => "0x0",
+ "totalDifficulty" => "0x0",
+ "transactions" => []
+ },
+ jsonrpc: "2.0"
+ },
+ %{
+ result: nil,
+ id: 1,
+ jsonrpc: "2.0"
+ }
+ ]}
+ end)
+
+ assert {:ok, :end_of_chain, %{blocks: [_], transactions: []}} =
+ EthereumJSONRPC.fetch_blocks_by_range(0..1, moxed_json_rpc_named_arguments)
+ end
+ end
+
describe "fetch_block_number_by_tag" do
@tag capture_log: false
test "with earliest", %{json_rpc_named_arguments: json_rpc_named_arguments} do
@@ -220,6 +431,113 @@ defmodule EthereumJSONRPCTest do
end
)
end
+
+ test "unknown errors are returned", %{json_rpc_named_arguments: json_rpc_named_arguments} do
+ # Can't be faked reliably on real chain
+ moxed_json_rpc_named_arguments = Keyword.put(json_rpc_named_arguments, :transport, EthereumJSONRPC.Mox)
+
+ unknown_error = {:error, %{"code" => 500, "message" => "Unknown error"}}
+
+ expect(EthereumJSONRPC.Mox, :json_rpc, fn _json, _options ->
+ unknown_error
+ end)
+
+ assert {:error, unknown_error} =
+ EthereumJSONRPC.fetch_block_number_by_tag("latest", moxed_json_rpc_named_arguments)
+ end
+ end
+
+ describe "fetch_pending_transactions/2" do
+ @tag :no_geth
+ test "pending transactions are returned", %{json_rpc_named_arguments: json_rpc_named_arguments} do
+ if json_rpc_named_arguments[:transport] == EthereumJSONRPC.Mox do
+ expect(EthereumJSONRPC.Mox, :json_rpc, fn _json, _options ->
+ {:ok,
+ [
+ %{
+ "blockHash" => nil,
+ "blockNumber" => nil,
+ "from" => "0x0",
+ "gas" => "0x0",
+ "gasPrice" => "0x0",
+ "hash" => "0x73c5599001f77bd570e32c4a5e63157200747910a502fae009821767c36b2ac9",
+ "input" => "0x",
+ "nonce" => "0x0",
+ "r" => "0x0",
+ "s" => "0x0",
+ "to" => "0x0",
+ "transactionIndex" => nil,
+ "v" => "0x0",
+ "value" => "0x0"
+ }
+ ]}
+ end)
+ end
+
+ assert {:ok, pending_transactions} = EthereumJSONRPC.fetch_pending_transactions(json_rpc_named_arguments)
+ # can't say more because there could be no pending transactions on test chains
+ assert is_list(pending_transactions)
+ end
+ end
+
+ describe "fetch_transaction_receipts/2" do
+ test "with invalid transaction hash", %{json_rpc_named_arguments: json_rpc_named_arguments} do
+ hash = "0x0000000000000000000000000000000000000000000000000000000000000000"
+
+ if json_rpc_named_arguments[:transport] == EthereumJSONRPC.Mox do
+ expect(EthereumJSONRPC.Mox, :json_rpc, fn _json, _options ->
+ {:ok, [%{id: 0, jsonrpc: "2.0", result: nil}]}
+ end)
+ end
+
+ assert {:error, [%{data: %{hash: ^hash}, message: "Not Found"}]} =
+ EthereumJSONRPC.fetch_transaction_receipts(
+ [%{hash: hash, gas: "0x0"}],
+ json_rpc_named_arguments
+ )
+ end
+
+ test "with valid transaction hash", %{json_rpc_named_arguments: json_rpc_named_arguments} do
+ hash =
+ case Keyword.fetch!(json_rpc_named_arguments, :variant) do
+ EthereumJSONRPC.Parity ->
+ "0xa2e81bb56b55ba3dab2daf76501b50dfaad240cccb905dbf89d65c7a84a4a48e"
+
+ EthereumJSONRPC.Geth ->
+ "0x615506d9872bb07faa2ce17c02b902148eae88ccba0298902be6a0dbba1124de"
+ end
+
+ if json_rpc_named_arguments[:transport] == EthereumJSONRPC.Mox do
+ expect(EthereumJSONRPC.Mox, :json_rpc, fn _json, _options ->
+ {:ok,
+ [
+ %{
+ id: 0,
+ jsonrpc: "2.0",
+ result: %{
+ "blockHash" => "0x29c850324e357f3c0c836d79860c5af55f7b651e5d7ee253c1af1b14908af49c",
+ "blockNumber" => "0x414911",
+ "contractAddress" => nil,
+ "cumulativeGasUsed" => "0x5208",
+ "gasUsed" => "0x5208",
+ "logs" => [],
+ "logsBloom" =>
+ "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
+ "root" => nil,
+ "status" => "0x1",
+ "transactionHash" => hash,
+ "transactionIndex" => "0x0"
+ }
+ }
+ ]}
+ end)
+ end
+
+ assert {:ok, %{logs: logs, receipts: [_]}} =
+ EthereumJSONRPC.fetch_transaction_receipts([%{hash: hash, gas: "0x0"}], json_rpc_named_arguments)
+
+ assert is_list(logs)
+ end
end
describe "subscribe/2" do
@@ -379,6 +697,12 @@ defmodule EthereumJSONRPCTest do
end
end
+ describe "unique_request_id" do
+ test "returns integer" do
+ assert is_integer(EthereumJSONRPC.unique_request_id())
+ end
+ end
+
describe "execute_contract_functions/3" do
test "executes the functions with the block_number" do
json_rpc_named_arguments = Application.get_env(:explorer, :json_rpc_named_arguments)
diff --git a/apps/explorer/test/explorer/import_test.exs b/apps/explorer/test/explorer/chain/import_test.exs
similarity index 67%
rename from apps/explorer/test/explorer/import_test.exs
rename to apps/explorer/test/explorer/chain/import_test.exs
index d1416b7396..4440845207 100644
--- a/apps/explorer/test/explorer/import_test.exs
+++ b/apps/explorer/test/explorer/chain/import_test.exs
@@ -19,6 +19,7 @@ defmodule Explorer.Chain.ImportTest do
doctest Import
describe "all/1" do
+ # set :timeout options to cover lines that use the timeout override when available
@import_data %{
blocks: %{
params: [
@@ -35,7 +36,8 @@ defmodule Explorer.Chain.ImportTest do
timestamp: Timex.parse!("2017-12-15T21:06:30.000000Z", "{ISO:Extended:Z}"),
total_difficulty: 12_590_447_576_074_723_148_144_860_474_975_121_280_509
}
- ]
+ ],
+ timeout: 5
},
broadcast: true,
internal_transactions: %{
@@ -52,8 +54,22 @@ defmodule Explorer.Chain.ImportTest do
transaction_hash: "0x53bd884872de3e488692881baeec262e7b95234d3965248c39fe992fffd433e5",
type: "call",
value: 0
+ },
+ %{
+ call_type: "call",
+ from_address_hash: "0xe8ddc5c7a2d2f0d7a9798459c0104fdf5e987aca",
+ gas: 4_677_320,
+ gas_used: 27770,
+ index: 1,
+ output: "0x",
+ to_address_hash: "0x8bf38d4764929064f2d4d3a56520a76ab3df415b",
+ trace_address: [],
+ transaction_hash: "0x53bd884872de3e488692881baeec262e7b95234d3965248c39fe992fffd433e5",
+ type: "call",
+ value: 0
}
- ]
+ ],
+ timeout: 5
},
logs: %{
params: [
@@ -68,7 +84,8 @@ defmodule Explorer.Chain.ImportTest do
transaction_hash: "0x53bd884872de3e488692881baeec262e7b95234d3965248c39fe992fffd433e5",
type: "mined"
}
- ]
+ ],
+ timeout: 5
},
transactions: %{
on_conflict: :replace_all,
@@ -95,14 +112,16 @@ defmodule Explorer.Chain.ImportTest do
v: 0xBE,
value: 0
}
- ]
+ ],
+ timeout: 5
},
addresses: %{
params: [
%{hash: "0x8bf38d4764929064f2d4d3a56520a76ab3df415b"},
%{hash: "0xe8ddc5c7a2d2f0d7a9798459c0104fdf5e987aca"},
%{hash: "0x515c09c5bba1ed566b02a5b0599ec5d5d0aee73d"}
- ]
+ ],
+ timeout: 5
},
tokens: %{
on_conflict: :nothing,
@@ -111,7 +130,8 @@ defmodule Explorer.Chain.ImportTest do
contract_address_hash: "0x8bf38d4764929064f2d4d3a56520a76ab3df415b",
type: "ERC-20"
}
- ]
+ ],
+ timeout: 5
},
token_transfers: %{
params: [
@@ -124,7 +144,8 @@ defmodule Explorer.Chain.ImportTest do
token_contract_address_hash: "0x8bf38d4764929064f2d4d3a56520a76ab3df415b",
transaction_hash: "0x53bd884872de3e488692881baeec262e7b95234d3965248c39fe992fffd433e5"
}
- ]
+ ],
+ timeout: 5
}
}
@@ -222,6 +243,15 @@ defmodule Explorer.Chain.ImportTest do
<<83, 189, 136, 72, 114, 222, 62, 72, 134, 146, 136, 27, 174, 236, 38, 46, 123, 149, 35, 77, 57,
101, 36, 140, 57, 254, 153, 47, 255, 212, 51, 229>>
}
+ },
+ %{
+ index: 1,
+ transaction_hash: %Hash{
+ byte_count: 32,
+ bytes:
+ <<83, 189, 136, 72, 114, 222, 62, 72, 134, 146, 136, 27, 174, 236, 38, 46, 123, 149, 35, 77, 57,
+ 101, 36, 140, 57, 254, 153, 47, 255, 212, 51, 229>>
+ }
}
],
logs: [
@@ -315,7 +345,8 @@ defmodule Explorer.Chain.ImportTest do
%{hash: "0xe8ddc5c7a2d2f0d7a9798459c0104fdf5e987aca"},
%{hash: "0x515c09c5bba1ed566b02a5b0599ec5d5d0aee73d"},
%{hash: "0x8bf38d4764929064f2d4d3a56520a76ab3df415b"}
- ]
+ ],
+ timeout: 5
},
tokens: %{
on_conflict: :nothing,
@@ -324,7 +355,8 @@ defmodule Explorer.Chain.ImportTest do
contract_address_hash: "0x8bf38d4764929064f2d4d3a56520a76ab3df415b",
type: "ERC-20"
}
- ]
+ ],
+ timeout: 5
},
token_balances: %{
params: [
@@ -343,7 +375,8 @@ defmodule Explorer.Chain.ImportTest do
token_contract_address_hash: "0x8bf38d4764929064f2d4d3a56520a76ab3df415b",
block_number: "37"
}
- ]
+ ],
+ timeout: 5
}
}
@@ -365,14 +398,8 @@ defmodule Explorer.Chain.ImportTest do
end
test "with invalid data" do
- invalid_transaction =
- @import_data
- |> Map.get(:internal_transactions)
- |> Map.get(:params)
- |> Enum.at(0)
- |> Map.delete(:call_type)
-
- invalid_import_data = put_in(@import_data, [:internal_transactions, :params], [invalid_transaction])
+ invalid_import_data =
+ update_in(@import_data, [:internal_transactions, :params, Access.at(0)], &Map.delete(&1, :call_type))
assert {:error, [changeset]} = Import.all(invalid_import_data)
assert changeset_errors(changeset)[:call_type] == ["can't be blank"]
@@ -651,5 +678,115 @@ defmodule Explorer.Chain.ImportTest do
assert transaction.created_contract_address_hash == nil
end
+
+ test "import balances" do
+ assert {:ok, _} =
+ Import.all(%{
+ addresses: %{
+ params: [%{hash: "0x8bf38d4764929064f2d4d3a56520a76ab3df415b"}]
+ },
+ balances: %{
+ params: [%{address_hash: "0x8bf38d4764929064f2d4d3a56520a76ab3df415b", block_number: 1}],
+ timeout: 5
+ }
+ })
+ end
+
+ test "transactions with multiple create internal transactions return error" do
+ assert {:error, :internal_transactions_indexed_at_transactions,
+ %{exception: %Postgrex.Error{postgres: %{code: :cardinality_violation}}, transaction_hashes: [_]},
+ _} =
+ Import.all(%{
+ blocks: %{
+ params: [
+ %{
+ difficulty: 340_282_366_920_938_463_463_374_607_431_768_211_454,
+ gas_limit: 6_946_336,
+ gas_used: 50450,
+ hash: "0xf6b4b8c88df3ebd252ec476328334dc026cf66606a84fb769b3d3cbccc8471bd",
+ miner_hash: "0xe8ddc5c7a2d2f0d7a9798459c0104fdf5e987aca",
+ nonce: 0,
+ number: 37,
+ parent_hash: "0xc37bbad7057945d1bf128c1ff009fb1ad632110bf6a000aac025a80f7766b66e",
+ size: 719,
+ timestamp: Timex.parse!("2017-12-15T21:06:30.000000Z", "{ISO:Extended:Z}"),
+ total_difficulty: 12_590_447_576_074_723_148_144_860_474_975_121_280_509
+ }
+ ],
+ timeout: 5
+ },
+ transactions: %{
+ on_conflict: :replace_all,
+ params: [
+ %{
+ block_hash: "0xf6b4b8c88df3ebd252ec476328334dc026cf66606a84fb769b3d3cbccc8471bd",
+ block_number: 37,
+ cumulative_gas_used: 50450,
+ from_address_hash: "0xe8ddc5c7a2d2f0d7a9798459c0104fdf5e987aca",
+ gas: 4_700_000,
+ gas_price: 100_000_000_000,
+ gas_used: 50450,
+ hash: "0x53bd884872de3e488692881baeec262e7b95234d3965248c39fe992fffd433e5",
+ index: 0,
+ input: "0x10855269000000000000000000000000862d67cb0773ee3f8ce7ea89b328ffea861ab3ef",
+ nonce: 4,
+ public_key:
+ "0xe5d196ad4ceada719d9e592f7166d0c75700f6eab2e3c3de34ba751ea786527cb3f6eb96ad9fdfdb9989ff572df50f1c42ef800af9c5207a38b929aff969b5c9",
+ r: 0xA7F8F45CCE375BB7AF8750416E1B03E0473F93C256DA2285D1134FC97A700E01,
+ s: 0x1F87A076F13824F4BE8963E3DFFD7300DAE64D5F23C9A062AF0C6EAD347C135F,
+ standard_v: 1,
+ status: :ok,
+ v: 0xBE,
+ value: 0
+ }
+ ],
+ timeout: 5
+ },
+ internal_transactions: %{
+ params: [
+ %{
+ created_contract_address_hash: "0xffc87239eb0267bc3ca2cd51d12fbf278e02ccb4",
+ created_contract_code:
+ "0x606060405260043610610062576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680630900f01014610067578063445df0ac146100a05780638da5cb5b146100c9578063fdacd5761461011e575b600080fd5b341561007257600080fd5b61009e600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610141565b005b34156100ab57600080fd5b6100b3610224565b6040518082815260200191505060405180910390f35b34156100d457600080fd5b6100dc61022a565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561012957600080fd5b61013f600480803590602001909190505061024f565b005b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610220578190508073ffffffffffffffffffffffffffffffffffffffff1663fdacd5766001546040518263ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180828152602001915050600060405180830381600087803b151561020b57600080fd5b6102c65a03f1151561021c57600080fd5b5050505b5050565b60015481565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614156102ac57806001819055505b505600a165627a7a72305820a9c628775efbfbc17477a472413c01ee9b33881f550c59d21bee9928835c854b0029",
+ from_address_hash: "0xe8ddc5c7a2d2f0d7a9798459c0104fdf5e987aca",
+ gas: 4_677_320,
+ gas_used: 27770,
+ index: 0,
+ init:
+ "0x6060604052341561000f57600080fd5b336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506102db8061005e6000396000f300606060405260043610610062576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680630900f01014610067578063445df0ac146100a05780638da5cb5b146100c9578063fdacd5761461011e575b600080fd5b341561007257600080fd5b61009e600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610141565b005b34156100ab57600080fd5b6100b3610224565b6040518082815260200191505060405180910390f35b34156100d457600080fd5b6100dc61022a565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561012957600080fd5b61013f600480803590602001909190505061024f565b005b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610220578190508073ffffffffffffffffffffffffffffffffffffffff1663fdacd5766001546040518263ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180828152602001915050600060405180830381600087803b151561020b57600080fd5b6102c65a03f1151561021c57600080fd5b5050505b5050565b60015481565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614156102ac57806001819055505b505600a165627a7a72305820a9c628775efbfbc17477a472413c01ee9b33881f550c59d21bee9928835c854b0029",
+ trace_address: [],
+ transaction_hash: "0x53bd884872de3e488692881baeec262e7b95234d3965248c39fe992fffd433e5",
+ type: "create",
+ value: 0
+ },
+ %{
+ created_contract_address_hash: "0xffc87239eb0267bc3ca2cd51d12fbf278e02ccb5",
+ created_contract_code:
+ "0x606060405260043610610062576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680630900f01014610067578063445df0ac146100a05780638da5cb5b146100c9578063fdacd5761461011e575b600080fd5b341561007257600080fd5b61009e600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610141565b005b34156100ab57600080fd5b6100b3610224565b6040518082815260200191505060405180910390f35b34156100d457600080fd5b6100dc61022a565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561012957600080fd5b61013f600480803590602001909190505061024f565b005b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610220578190508073ffffffffffffffffffffffffffffffffffffffff1663fdacd5766001546040518263ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180828152602001915050600060405180830381600087803b151561020b57600080fd5b6102c65a03f1151561021c57600080fd5b5050505b5050565b60015481565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614156102ac57806001819055505b505600a165627a7a72305820a9c628775efbfbc17477a472413c01ee9b33881f550c59d21bee9928835c854b0029",
+ from_address_hash: "0xe8ddc5c7a2d2f0d7a9798459c0104fdf5e987aca",
+ gas: 4_677_320,
+ gas_used: 27770,
+ index: 1,
+ init:
+ "0x6060604052341561000f57600080fd5b336000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055506102db8061005e6000396000f300606060405260043610610062576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680630900f01014610067578063445df0ac146100a05780638da5cb5b146100c9578063fdacd5761461011e575b600080fd5b341561007257600080fd5b61009e600480803573ffffffffffffffffffffffffffffffffffffffff16906020019091905050610141565b005b34156100ab57600080fd5b6100b3610224565b6040518082815260200191505060405180910390f35b34156100d457600080fd5b6100dc61022a565b604051808273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b341561012957600080fd5b61013f600480803590602001909190505061024f565b005b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161415610220578190508073ffffffffffffffffffffffffffffffffffffffff1663fdacd5766001546040518263ffffffff167c010000000000000000000000000000000000000000000000000000000002815260040180828152602001915050600060405180830381600087803b151561020b57600080fd5b6102c65a03f1151561021c57600080fd5b5050505b5050565b60015481565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6000809054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614156102ac57806001819055505b505600a165627a7a72305820a9c628775efbfbc17477a472413c01ee9b33881f550c59d21bee9928835c854b0029",
+ trace_address: [],
+ transaction_hash: "0x53bd884872de3e488692881baeec262e7b95234d3965248c39fe992fffd433e5",
+ type: "create",
+ value: 0
+ }
+ ],
+ timeout: 5
+ },
+ addresses: %{
+ params: [
+ %{hash: "0x8bf38d4764929064f2d4d3a56520a76ab3df415b"},
+ %{hash: "0xe8ddc5c7a2d2f0d7a9798459c0104fdf5e987aca"},
+ %{hash: "0xffc87239eb0267bc3ca2cd51d12fbf278e02ccb4"},
+ %{hash: "0xffc87239eb0267bc3ca2cd51d12fbf278e02ccb5"}
+ ],
+ timeout: 5
+ }
+ })
+ end
end
end
diff --git a/apps/explorer/test/explorer/chain_test.exs b/apps/explorer/test/explorer/chain_test.exs
index 4829116e2a..6fd9ebfa1c 100644
--- a/apps/explorer/test/explorer/chain_test.exs
+++ b/apps/explorer/test/explorer/chain_test.exs
@@ -8,6 +8,8 @@ defmodule Explorer.ChainTest do
alias Explorer.Chain.{
Address,
Block,
+ Data,
+ Hash,
InternalTransaction,
Log,
Token,
@@ -21,6 +23,12 @@ defmodule Explorer.ChainTest do
doctest Explorer.Chain
+ describe "address_estimated_count/1" do
+ test "returns integer" do
+ assert is_integer(Chain.address_estimated_count())
+ end
+ end
+
describe "address_to_transaction_count/1" do
test "without transactions" do
address = insert(:address)
@@ -269,6 +277,20 @@ defmodule Explorer.ChainTest do
end
end
+ describe "average_block_time/0" do
+ test "without blocks duration is 0" do
+ assert Chain.average_block_time() == Timex.Duration.parse!("PT0S")
+ end
+
+ test "with blocks is average duration between blocks" do
+ first_block = insert(:block)
+ second_block = insert(:block, timestamp: Timex.shift(first_block.timestamp, seconds: 3))
+ insert(:block, timestamp: Timex.shift(second_block.timestamp, seconds: 9))
+
+ assert Chain.average_block_time() == Timex.Duration.parse!("PT6S")
+ end
+ end
+
describe "balance/2" do
test "with Address.t with :wei" do
assert Chain.balance(%Address{fetched_coin_balance: %Wei{value: Decimal.new(1)}}, :wei) == Decimal.new(1)
@@ -306,7 +328,7 @@ defmodule Explorer.ChainTest do
assert [%Transaction{hash: ^transaction_hash}] = Chain.block_to_transactions(block)
end
- test "with transactions can be paginated" do
+ test "with transactions can be paginated by {index}" do
block = insert(:block)
second_page_hashes =
@@ -315,14 +337,14 @@ defmodule Explorer.ChainTest do
|> with_block(block)
|> Enum.map(& &1.hash)
- %Transaction{block_number: block_number, index: index} =
+ %Transaction{index: index} =
:transaction
|> insert()
|> with_block(block)
assert second_page_hashes ==
block
- |> Chain.block_to_transactions(paging_options: %PagingOptions{key: {block_number, index}, page_size: 50})
+ |> Chain.block_to_transactions(paging_options: %PagingOptions{key: {index}, page_size: 50})
|> Enum.map(& &1.hash)
|> Enum.reverse()
end
@@ -439,6 +461,74 @@ defmodule Explorer.ChainTest do
end
end
+ describe "fetch_token_transfers_from_token_hash/2" do
+ test "without token transfers" do
+ %Token{contract_address_hash: contract_address_hash} = insert(:token)
+
+ assert Chain.fetch_token_transfers_from_token_hash(contract_address_hash) == []
+ end
+
+ test "with token transfers" do
+ address = insert(:address)
+
+ transaction =
+ :transaction
+ |> insert()
+ |> with_block()
+
+ %TokenTransfer{id: token_transfer_id, token_contract_address_hash: token_contract_address_hash} =
+ insert(:token_transfer, to_address: address, transaction: transaction)
+
+ assert token_contract_address_hash
+ |> Chain.fetch_token_transfers_from_token_hash()
+ |> Enum.map(& &1.id) == [token_transfer_id]
+ end
+ end
+
+ describe "count_token_transfers_from_token_hash/1" do
+ test "without token transfers" do
+ %Token{contract_address_hash: contract_address_hash} = insert(:token)
+
+ assert Chain.count_token_transfers_from_token_hash(contract_address_hash) == 0
+ end
+
+ test "with token transfers" do
+ address = insert(:address)
+
+ transaction =
+ :transaction
+ |> insert()
+ |> with_block()
+
+ %TokenTransfer{token_contract_address_hash: token_contract_address_hash} =
+ insert(:token_transfer, to_address: address, transaction: transaction)
+
+ assert Chain.count_token_transfers_from_token_hash(token_contract_address_hash) == 1
+ end
+ end
+
+ describe "count_addresses_in_token_transfers_from_token_hash/1" do
+ test "without token transfers" do
+ %Token{contract_address_hash: contract_address_hash} = insert(:token)
+
+ assert Chain.count_addresses_in_token_transfers_from_token_hash(contract_address_hash) == 0
+ end
+
+ test "with token transfers" do
+ address = insert(:address)
+
+ transaction =
+ :transaction
+ |> insert()
+ |> with_block()
+
+ %TokenTransfer{token_contract_address_hash: token_contract_address_hash} =
+ insert(:token_transfer, to_address: address, transaction: transaction)
+
+ assert Chain.count_addresses_in_token_transfers_from_token_hash(token_contract_address_hash) == 2
+ end
+ end
+
describe "gas_price/2" do
test ":wei unit" do
assert Chain.gas_price(%Transaction{gas_price: %Wei{value: Decimal.new(1)}}, :wei) == Decimal.new(1)
@@ -590,6 +680,298 @@ defmodule Explorer.ChainTest do
end
end
+ # Full tests in `test/explorer/import_test.exs`
+ describe "import/1" do
+ @import_data %{
+ blocks: %{
+ params: [
+ %{
+ difficulty: 340_282_366_920_938_463_463_374_607_431_768_211_454,
+ gas_limit: 6_946_336,
+ gas_used: 50450,
+ hash: "0xf6b4b8c88df3ebd252ec476328334dc026cf66606a84fb769b3d3cbccc8471bd",
+ miner_hash: "0xe8ddc5c7a2d2f0d7a9798459c0104fdf5e987aca",
+ nonce: 0,
+ number: 37,
+ parent_hash: "0xc37bbad7057945d1bf128c1ff009fb1ad632110bf6a000aac025a80f7766b66e",
+ size: 719,
+ timestamp: Timex.parse!("2017-12-15T21:06:30.000000Z", "{ISO:Extended:Z}"),
+ total_difficulty: 12_590_447_576_074_723_148_144_860_474_975_121_280_509
+ }
+ ]
+ },
+ broadcast: true,
+ internal_transactions: %{
+ params: [
+ %{
+ call_type: "call",
+ from_address_hash: "0xe8ddc5c7a2d2f0d7a9798459c0104fdf5e987aca",
+ gas: 4_677_320,
+ gas_used: 27770,
+ index: 0,
+ output: "0x",
+ to_address_hash: "0x8bf38d4764929064f2d4d3a56520a76ab3df415b",
+ trace_address: [],
+ transaction_hash: "0x53bd884872de3e488692881baeec262e7b95234d3965248c39fe992fffd433e5",
+ type: "call",
+ value: 0
+ }
+ ]
+ },
+ logs: %{
+ params: [
+ %{
+ address_hash: "0x8bf38d4764929064f2d4d3a56520a76ab3df415b",
+ data: "0x0000000000000000000000000000000000000000000000000de0b6b3a7640000",
+ first_topic: "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
+ second_topic: "0x000000000000000000000000e8ddc5c7a2d2f0d7a9798459c0104fdf5e987aca",
+ third_topic: "0x000000000000000000000000515c09c5bba1ed566b02a5b0599ec5d5d0aee73d",
+ fourth_topic: nil,
+ index: 0,
+ transaction_hash: "0x53bd884872de3e488692881baeec262e7b95234d3965248c39fe992fffd433e5",
+ type: "mined"
+ }
+ ]
+ },
+ transactions: %{
+ on_conflict: :replace_all,
+ params: [
+ %{
+ block_hash: "0xf6b4b8c88df3ebd252ec476328334dc026cf66606a84fb769b3d3cbccc8471bd",
+ block_number: 37,
+ cumulative_gas_used: 50450,
+ from_address_hash: "0xe8ddc5c7a2d2f0d7a9798459c0104fdf5e987aca",
+ gas: 4_700_000,
+ gas_price: 100_000_000_000,
+ gas_used: 50450,
+ hash: "0x53bd884872de3e488692881baeec262e7b95234d3965248c39fe992fffd433e5",
+ index: 0,
+ input: "0x10855269000000000000000000000000862d67cb0773ee3f8ce7ea89b328ffea861ab3ef",
+ nonce: 4,
+ public_key:
+ "0xe5d196ad4ceada719d9e592f7166d0c75700f6eab2e3c3de34ba751ea786527cb3f6eb96ad9fdfdb9989ff572df50f1c42ef800af9c5207a38b929aff969b5c9",
+ r: 0xA7F8F45CCE375BB7AF8750416E1B03E0473F93C256DA2285D1134FC97A700E01,
+ s: 0x1F87A076F13824F4BE8963E3DFFD7300DAE64D5F23C9A062AF0C6EAD347C135F,
+ standard_v: 1,
+ status: :ok,
+ to_address_hash: "0x8bf38d4764929064f2d4d3a56520a76ab3df415b",
+ v: 0xBE,
+ value: 0
+ }
+ ]
+ },
+ addresses: %{
+ params: [
+ %{hash: "0x8bf38d4764929064f2d4d3a56520a76ab3df415b"},
+ %{hash: "0xe8ddc5c7a2d2f0d7a9798459c0104fdf5e987aca"},
+ %{hash: "0x515c09c5bba1ed566b02a5b0599ec5d5d0aee73d"}
+ ]
+ },
+ tokens: %{
+ on_conflict: :nothing,
+ params: [
+ %{
+ contract_address_hash: "0x8bf38d4764929064f2d4d3a56520a76ab3df415b",
+ type: "ERC-20"
+ }
+ ]
+ },
+ token_transfers: %{
+ params: [
+ %{
+ amount: Decimal.new(1_000_000_000_000_000_000),
+ block_number: 37,
+ log_index: 0,
+ from_address_hash: "0xe8ddc5c7a2d2f0d7a9798459c0104fdf5e987aca",
+ to_address_hash: "0x515c09c5bba1ed566b02a5b0599ec5d5d0aee73d",
+ token_contract_address_hash: "0x8bf38d4764929064f2d4d3a56520a76ab3df415b",
+ transaction_hash: "0x53bd884872de3e488692881baeec262e7b95234d3965248c39fe992fffd433e5"
+ }
+ ]
+ }
+ }
+
+ test "with valid data" do
+ difficulty = Decimal.new(340_282_366_920_938_463_463_374_607_431_768_211_454)
+ total_difficulty = Decimal.new(12_590_447_576_074_723_148_144_860_474_975_121_280_509)
+ token_transfer_amount = Decimal.new(1_000_000_000_000_000_000)
+
+ assert {:ok,
+ %{
+ addresses: [
+ %Address{
+ hash: %Hash{
+ byte_count: 20,
+ bytes:
+ <<81, 92, 9, 197, 187, 161, 237, 86, 107, 2, 165, 176, 89, 158, 197, 213, 208, 174, 231, 61>>
+ },
+ inserted_at: %{},
+ updated_at: %{}
+ },
+ %Address{
+ hash: %Hash{
+ byte_count: 20,
+ bytes:
+ <<139, 243, 141, 71, 100, 146, 144, 100, 242, 212, 211, 165, 101, 32, 167, 106, 179, 223, 65,
+ 91>>
+ },
+ inserted_at: %{},
+ updated_at: %{}
+ },
+ %Address{
+ hash: %Hash{
+ byte_count: 20,
+ bytes:
+ <<232, 221, 197, 199, 162, 210, 240, 215, 169, 121, 132, 89, 192, 16, 79, 223, 94, 152, 122,
+ 202>>
+ },
+ inserted_at: %{},
+ updated_at: %{}
+ }
+ ],
+ blocks: [
+ %Block{
+ difficulty: ^difficulty,
+ gas_limit: 6_946_336,
+ gas_used: 50450,
+ hash: %Hash{
+ byte_count: 32,
+ bytes:
+ <<246, 180, 184, 200, 141, 243, 235, 210, 82, 236, 71, 99, 40, 51, 77, 192, 38, 207, 102, 96,
+ 106, 132, 251, 118, 155, 61, 60, 188, 204, 132, 113, 189>>
+ },
+ miner_hash: %Hash{
+ byte_count: 20,
+ bytes:
+ <<232, 221, 197, 199, 162, 210, 240, 215, 169, 121, 132, 89, 192, 16, 79, 223, 94, 152, 122,
+ 202>>
+ },
+ nonce: %Explorer.Chain.Hash{
+ byte_count: 8,
+ bytes: <<0, 0, 0, 0, 0, 0, 0, 0>>
+ },
+ number: 37,
+ parent_hash: %Hash{
+ byte_count: 32,
+ bytes:
+ <<195, 123, 186, 215, 5, 121, 69, 209, 191, 18, 140, 31, 240, 9, 251, 26, 214, 50, 17, 11, 246,
+ 160, 0, 170, 192, 37, 168, 15, 119, 102, 182, 110>>
+ },
+ size: 719,
+ timestamp: %DateTime{
+ year: 2017,
+ month: 12,
+ day: 15,
+ hour: 21,
+ minute: 6,
+ second: 30,
+ microsecond: {0, 6},
+ std_offset: 0,
+ utc_offset: 0,
+ time_zone: "Etc/UTC",
+ zone_abbr: "UTC"
+ },
+ total_difficulty: ^total_difficulty,
+ inserted_at: %{},
+ updated_at: %{}
+ }
+ ],
+ internal_transactions: [
+ %{
+ index: 0,
+ transaction_hash: %Hash{
+ byte_count: 32,
+ bytes:
+ <<83, 189, 136, 72, 114, 222, 62, 72, 134, 146, 136, 27, 174, 236, 38, 46, 123, 149, 35, 77, 57,
+ 101, 36, 140, 57, 254, 153, 47, 255, 212, 51, 229>>
+ }
+ }
+ ],
+ logs: [
+ %Log{
+ address_hash: %Hash{
+ byte_count: 20,
+ bytes:
+ <<139, 243, 141, 71, 100, 146, 144, 100, 242, 212, 211, 165, 101, 32, 167, 106, 179, 223, 65,
+ 91>>
+ },
+ data: %Data{
+ bytes:
+ <<0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 224, 182, 179,
+ 167, 100, 0, 0>>
+ },
+ index: 0,
+ first_topic: "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
+ second_topic: "0x000000000000000000000000e8ddc5c7a2d2f0d7a9798459c0104fdf5e987aca",
+ third_topic: "0x000000000000000000000000515c09c5bba1ed566b02a5b0599ec5d5d0aee73d",
+ fourth_topic: nil,
+ transaction_hash: %Hash{
+ byte_count: 32,
+ bytes:
+ <<83, 189, 136, 72, 114, 222, 62, 72, 134, 146, 136, 27, 174, 236, 38, 46, 123, 149, 35, 77, 57,
+ 101, 36, 140, 57, 254, 153, 47, 255, 212, 51, 229>>
+ },
+ type: "mined",
+ inserted_at: %{},
+ updated_at: %{}
+ }
+ ],
+ transactions: [
+ %Hash{
+ byte_count: 32,
+ bytes:
+ <<83, 189, 136, 72, 114, 222, 62, 72, 134, 146, 136, 27, 174, 236, 38, 46, 123, 149, 35, 77, 57,
+ 101, 36, 140, 57, 254, 153, 47, 255, 212, 51, 229>>
+ }
+ ],
+ tokens: [
+ %Token{
+ contract_address_hash: %Hash{
+ byte_count: 20,
+ bytes:
+ <<139, 243, 141, 71, 100, 146, 144, 100, 242, 212, 211, 165, 101, 32, 167, 106, 179, 223, 65,
+ 91>>
+ },
+ type: "ERC-20",
+ inserted_at: %{},
+ updated_at: %{}
+ }
+ ],
+ token_transfers: [
+ %TokenTransfer{
+ amount: ^token_transfer_amount,
+ log_index: 0,
+ from_address_hash: %Hash{
+ byte_count: 20,
+ bytes:
+ <<232, 221, 197, 199, 162, 210, 240, 215, 169, 121, 132, 89, 192, 16, 79, 223, 94, 152, 122,
+ 202>>
+ },
+ to_address_hash: %Hash{
+ byte_count: 20,
+ bytes:
+ <<81, 92, 9, 197, 187, 161, 237, 86, 107, 2, 165, 176, 89, 158, 197, 213, 208, 174, 231, 61>>
+ },
+ token_contract_address_hash: %Hash{
+ byte_count: 20,
+ bytes:
+ <<139, 243, 141, 71, 100, 146, 144, 100, 242, 212, 211, 165, 101, 32, 167, 106, 179, 223, 65,
+ 91>>
+ },
+ transaction_hash: %Hash{
+ byte_count: 32,
+ bytes:
+ <<83, 189, 136, 72, 114, 222, 62, 72, 134, 146, 136, 27, 174, 236, 38, 46, 123, 149, 35, 77, 57,
+ 101, 36, 140, 57, 254, 153, 47, 255, 212, 51, 229>>
+ },
+ inserted_at: %{},
+ updated_at: %{}
+ }
+ ]
+ }} = Chain.import(@import_data)
+ end
+ end
+
describe "list_blocks/2" do
test "without blocks" do
assert [] = Chain.list_blocks()
@@ -774,6 +1156,126 @@ defmodule Explorer.ChainTest do
assert [second_pending, first_pending, sixth, fifth, fourth, third, second, first] == result
end
+ test "pages by {block_number, transaction_index, index}" do
+ address = insert(:address)
+
+ pending_transaction = insert(:transaction)
+
+ insert(
+ :internal_transaction,
+ transaction: pending_transaction,
+ to_address: address,
+ index: 0
+ )
+
+ insert(
+ :internal_transaction,
+ transaction: pending_transaction,
+ to_address: address,
+ index: 1
+ )
+
+ a_block = insert(:block, number: 2000)
+
+ first_a_transaction =
+ :transaction
+ |> insert()
+ |> with_block(a_block)
+
+ %InternalTransaction{id: first} =
+ insert(
+ :internal_transaction,
+ transaction: first_a_transaction,
+ to_address: address,
+ index: 0
+ )
+
+ %InternalTransaction{id: second} =
+ insert(
+ :internal_transaction,
+ transaction: first_a_transaction,
+ to_address: address,
+ index: 1
+ )
+
+ second_a_transaction =
+ :transaction
+ |> insert()
+ |> with_block(a_block)
+
+ %InternalTransaction{id: third} =
+ insert(
+ :internal_transaction,
+ transaction: second_a_transaction,
+ to_address: address,
+ index: 0
+ )
+
+ %InternalTransaction{id: fourth} =
+ insert(
+ :internal_transaction,
+ transaction: second_a_transaction,
+ to_address: address,
+ index: 1
+ )
+
+ b_block = insert(:block, number: 6000)
+
+ first_b_transaction =
+ :transaction
+ |> insert()
+ |> with_block(b_block)
+
+ %InternalTransaction{id: fifth} =
+ insert(
+ :internal_transaction,
+ transaction: first_b_transaction,
+ to_address: address,
+ index: 0
+ )
+
+ %InternalTransaction{id: sixth} =
+ insert(
+ :internal_transaction,
+ transaction: first_b_transaction,
+ to_address: address,
+ index: 1
+ )
+
+ # When paged, internal transactions need an associated block number, so `second_pending` and `first_pending` are
+ # excluded.
+ assert [sixth, fifth, fourth, third, second, first] ==
+ address
+ |> Chain.address_to_internal_transactions(
+ paging_options: %PagingOptions{key: {6001, 3, 2}, page_size: 8}
+ )
+ |> Enum.map(& &1.id)
+
+ # block number ==, transaction index ==, internal transaction index <
+ assert [fifth, fourth, third, second, first] ==
+ address
+ |> Chain.address_to_internal_transactions(
+ paging_options: %PagingOptions{key: {6000, 0, 1}, page_size: 8}
+ )
+ |> Enum.map(& &1.id)
+
+ # block number ==, transaction index <
+ assert [fourth, third, second, first] ==
+ address
+ |> Chain.address_to_internal_transactions(
+ paging_options: %PagingOptions{key: {6000, -1, -1}, page_size: 8}
+ )
+ |> Enum.map(& &1.id)
+
+ # block number <
+ assert [] ==
+ address
+ |> Chain.address_to_internal_transactions(
+ paging_options: %PagingOptions{key: {2000, -1, -1}, page_size: 8}
+ )
+ |> Enum.map(& &1.id)
+ end
+
test "excludes internal transactions of type `call` when they are alone in the parent transaction" do
address = insert(:address)
@@ -836,6 +1338,12 @@ defmodule Explorer.ChainTest do
end
end
+ describe "transaction_estimated_count/1" do
+ test "returns integer" do
+ assert is_integer(Chain.transaction_estimated_count())
+ end
+ end
+
describe "transaction_to_internal_transactions/1" do
test "with transaction without internal transactions" do
transaction = insert(:transaction)
@@ -955,6 +1463,31 @@ defmodule Explorer.ChainTest do
assert [first_id, second_id] == result
end
+
+ test "pages by index" do
+ transaction =
+ :transaction
+ |> insert()
+ |> with_block()
+
+ %InternalTransaction{id: first_id} = insert(:internal_transaction, transaction: transaction, index: 0)
+ %InternalTransaction{id: second_id} = insert(:internal_transaction, transaction: transaction, index: 1)
+
+ assert [^first_id, ^second_id] =
+ transaction
+ |> Chain.transaction_to_internal_transactions(paging_options: %PagingOptions{key: {-1}, page_size: 2})
+ |> Enum.map(& &1.id)
+
+ assert [^first_id] =
+ transaction
+ |> Chain.transaction_to_internal_transactions(paging_options: %PagingOptions{key: {-1}, page_size: 1})
+ |> Enum.map(& &1.id)
+
+ assert [^second_id] =
+ transaction
+ |> Chain.transaction_to_internal_transactions(paging_options: %PagingOptions{key: {0}, page_size: 2})
+ |> Enum.map(& &1.id)
+ end
end
describe "transaction_to_logs/2" do
diff --git a/apps/explorer/test/explorer/smart_contract/reader_test.exs b/apps/explorer/test/explorer/smart_contract/reader_test.exs
index 9643f79dac..473281d252 100644
--- a/apps/explorer/test/explorer/smart_contract/reader_test.exs
+++ b/apps/explorer/test/explorer/smart_contract/reader_test.exs
@@ -177,6 +177,20 @@ defmodule Explorer.SmartContract.ReaderTest do
}
] = Reader.query_function(smart_contract.address_hash, %{name: "get", args: []})
end
+
+ test "nil arguments is treated as []" do
+ smart_contract = insert(:smart_contract)
+
+ blockchain_get_function_mock()
+
+ assert [
+ %{
+ "name" => "",
+ "type" => "uint256",
+ "value" => 0
+ }
+ ] = Reader.query_function(smart_contract.address_hash, %{name: "get", args: nil})
+ end
end
describe "normalize_args/1" do
diff --git a/apps/explorer/test/support/factory.ex b/apps/explorer/test/support/factory.ex
index ec5d6f14f8..0c20ad8273 100644
--- a/apps/explorer/test/support/factory.ex
+++ b/apps/explorer/test/support/factory.ex
@@ -262,17 +262,6 @@ defmodule Explorer.Factory do
}
end
- def internal_transaction_suicide_factory() do
- %InternalTransaction{
- from_address: build(:address),
- trace_address: [],
- # caller MUST supply `transaction` because it can't be built lazily to allow overrides without creating an extra
- # transaction
- type: :suicide,
- value: sequence("internal_transaction_value", &Decimal.new(&1))
- }
- end
-
def log_factory do
%Log{
address: build(:address),
diff --git a/apps/indexer/lib/indexer/token_balances.ex b/apps/indexer/lib/indexer/token_balances.ex
index 3a1e6b180f..9fb12318cc 100644
--- a/apps/indexer/lib/indexer/token_balances.ex
+++ b/apps/indexer/lib/indexer/token_balances.ex
@@ -5,11 +5,26 @@ defmodule Indexer.TokenBalances do
alias Explorer.Token.BalanceReader
+ @doc """
+ Fetches TokenBalances from specific Addresses and Blocks in the Blockchain
+
+ Every `TokenBalance` is fetched asynchronously, but in case an exception is raised (such as a
+ timeout) during the RPC call the particular TokenBalance request is ignored.
+
+ ## token_balances
+
+ It is a list of a Map so that each map must have:
+
+ * `token_contract_address_hash` - The contract address that represents the Token in the blockchain.
+ * `address_hash` - The address_hash that we want to know the balance.
+ * `block_number` - The block number that the address_hash has the balance.
+ """
def fetch_token_balances_from_blockchain(token_balances) do
result =
token_balances
- |> Task.async_stream(&fetch_token_balance/1)
- |> Enum.map(&format_result/1)
+ |> Task.async_stream(&fetch_token_balance/1, on_timeout: :kill_task)
+ |> Stream.map(&format_task_results/1)
+ |> Enum.filter(&ignore_request_with_timeouts/1)
{:ok, result}
end
@@ -34,5 +49,9 @@ defmodule Indexer.TokenBalances do
Map.merge(token_balance, %{value: nil, value_fetched_at: nil})
end
- def format_result({_, token_balance}), do: token_balance
+ def format_task_results({:exit, :timeout}), do: {:error, :timeout}
+ def format_task_results({:ok, token_balance}), do: token_balance
+
+ def ignore_request_with_timeouts({:error, :timeout}), do: false
+ def ignore_request_with_timeouts(_token_balance), do: true
end
diff --git a/apps/indexer/test/indexer/token_balances_test.exs b/apps/indexer/test/indexer/token_balances_test.exs
index 3ec235b834..b5cc0f3e1f 100644
--- a/apps/indexer/test/indexer/token_balances_test.exs
+++ b/apps/indexer/test/indexer/token_balances_test.exs
@@ -60,6 +60,32 @@ defmodule Indexer.TokenBalancesTest do
value_fetched_at: nil
} = List.first(result)
end
+
+ test "ignores results that raised :timeout" do
+ address = insert(:address)
+ token = insert(:token, contract_address: build(:contract_address))
+ address_hash_string = Hash.to_string(address.hash)
+
+ token_balance_params = [
+ %{
+ token_contract_address_hash: Hash.to_string(token.contract_address_hash),
+ address_hash: address_hash_string,
+ block_number: 1_000
+ },
+ %{
+ token_contract_address_hash: Hash.to_string(token.contract_address_hash),
+ address_hash: address_hash_string,
+ block_number: 1_001
+ }
+ ]
+
+ get_balance_from_blockchain()
+ get_balance_from_blockchain_with_timeout()
+
+ {:ok, result} = TokenBalances.fetch_token_balances_from_blockchain(token_balance_params)
+
+ assert length(result) == 1
+ end
end
defp get_balance_from_blockchain() do
@@ -79,6 +105,16 @@ defmodule Indexer.TokenBalancesTest do
)
end
+ defp get_balance_from_blockchain_with_timeout() do
+ expect(
+ EthereumJSONRPC.Mox,
+ :json_rpc,
+ fn [%{id: _, method: _, params: [%{data: _, to: _}, _]}], _options ->
+ :timer.sleep(5001)
+ end
+ )
+ end
+
defp get_balance_from_blockchain_with_error() do
expect(
EthereumJSONRPC.Mox,
diff --git a/coveralls.json b/coveralls.json
index 4341e638c9..ed4fddeb93 100644
--- a/coveralls.json
+++ b/coveralls.json
@@ -1,7 +1,7 @@
{
"coverage_options": {
"treat_no_relevant_lines_as_covered": true,
- "minimum_coverage": 94.5
+ "minimum_coverage": 88
},
"terminal_options": {
"file_column_width": 120