Run mix gettext.extract --merge

Run mix format.

Conform to circle ci tests.

Format, tests, gettext.

Removed unecessary tab in `address_validation_controller.ex`
Fixed tests in `chain_text.exs` (address_to_validation_count/1 &
get_blocks_validated_by_address/2).
Ran `mix format` and `mix gettext.extract --merge
Changed == to === in address.js to appease the all powerful eslint.
pull/738/head
Lokraan 6 years ago
parent d4aedd08f4
commit 10e17d34db
  1. 2
      apps/block_scout_web/assets/js/pages/address.js
  2. 5
      apps/block_scout_web/lib/block_scout_web/controllers/address_token_transfer_controller.ex
  3. 2
      apps/block_scout_web/lib/block_scout_web/controllers/address_validation_controller.ex
  4. 2
      apps/block_scout_web/lib/block_scout_web/templates/address/overview.html.eex
  5. 4
      apps/block_scout_web/lib/block_scout_web/views/address_internal_transaction_view.ex
  6. 4
      apps/block_scout_web/lib/block_scout_web/views/address_transaction_view.ex
  7. 407
      apps/block_scout_web/priv/gettext/default.pot
  8. 409
      apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po
  9. 4
      apps/explorer/lib/explorer/chain.ex
  10. 76
      apps/explorer/test/explorer/chain_test.exs

@ -174,7 +174,7 @@ if ($addressDetailsPage.length) {
prependWithClingBottom($transactionsList, state.newTransactions.slice(oldState.newTransactions.length).reverse().join('')) prependWithClingBottom($transactionsList, state.newTransactions.slice(oldState.newTransactions.length).reverse().join(''))
updateAllAges() updateAllAges()
} }
if (oldState.newBlock !== state.newBlock && state.minerHash == state.addressHash) { if (oldState.newBlock !== state.newBlock && state.minerHash === state.addressHash) {
const len = $validationsList.children().length const len = $validationsList.children().length
$validationsList $validationsList
.children() .children()

@ -4,7 +4,7 @@ defmodule BlockScoutWeb.AddressTokenTransferController do
alias Explorer.{Chain, Market} alias Explorer.{Chain, Market}
alias Explorer.ExchangeRates.Token alias Explorer.ExchangeRates.Token
import BlockScoutWeb.AddressController, only: [transaction_count: 1] import BlockScoutWeb.AddressController, only: [transaction_count: 1, validation_count: 1]
import BlockScoutWeb.Chain, import BlockScoutWeb.Chain,
only: [next_page_params: 3, paging_options: 1, split_list_by_page: 1] only: [next_page_params: 3, paging_options: 1, split_list_by_page: 1]
@ -34,7 +34,8 @@ defmodule BlockScoutWeb.AddressTokenTransferController do
next_page_params: next_page_params(next_page, transactions_paginated, params), next_page_params: next_page_params(next_page, transactions_paginated, params),
token: token, token: token,
transaction_count: transaction_count(address), transaction_count: transaction_count(address),
transactions: transactions_paginated transactions: transactions_paginated,
validation_count: validation_count(address)
) )
else else
:error -> :error ->

@ -1,6 +1,6 @@
defmodule BlockScoutWeb.AddressValidationController do defmodule BlockScoutWeb.AddressValidationController do
@moduledoc """ @moduledoc """
Display all the blocks that this address validates. Display all the blocks that this address validates.
""" """
use BlockScoutWeb, :controller use BlockScoutWeb, :controller

@ -25,7 +25,7 @@
<span data-selector="transaction-count"> <span data-selector="transaction-count">
<%= Cldr.Number.to_string!(@transaction_count, format: "#,###") %> <%= Cldr.Number.to_string!(@transaction_count, format: "#,###") %>
</span> <%= gettext("Transactions") %> </span> <%= gettext("Transactions") %>
<%= if @validation_count > 0 do %> <%= if validator?(@validation_count) do %>
<span data-selector="validation-count"> <span data-selector="validation-count">
<%= Cldr.Number.to_string!(@validation_count, format: "#,###") %> <%= Cldr.Number.to_string!(@validation_count, format: "#,###") %>
</span> <%= gettext("Blocks Validated") %> </span> <%= gettext("Blocks Validated") %>

@ -2,9 +2,7 @@ defmodule BlockScoutWeb.AddressInternalTransactionView do
use BlockScoutWeb, :view use BlockScoutWeb, :view
import BlockScoutWeb.AddressView, import BlockScoutWeb.AddressView,
only: [contract?: 1, smart_contract_verified?: 1, smart_contract_with_read_only_functions?: 1, only: [contract?: 1, smart_contract_verified?: 1, smart_contract_with_read_only_functions?: 1, validator?: 1]
validator?: 1
]
def format_current_filter(filter) do def format_current_filter(filter) do
case filter do case filter do

@ -2,9 +2,7 @@ defmodule BlockScoutWeb.AddressTransactionView do
use BlockScoutWeb, :view use BlockScoutWeb, :view
import BlockScoutWeb.AddressView, import BlockScoutWeb.AddressView,
only: [contract?: 1, smart_contract_verified?: 1, smart_contract_with_read_only_functions?: 1, only: [contract?: 1, smart_contract_verified?: 1, smart_contract_with_read_only_functions?: 1, validator?: 1]
validator?: 1
]
def format_current_filter(filter) do def format_current_filter(filter) do
case filter do case filter do

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -826,7 +826,6 @@ defmodule Explorer.Chain do
end end
@doc """ @doc """
<<<<<<< HEAD
Lists the top 250 `t:Explorer.Chain.Address.t/0`'s' in descending order based on coin balance. Lists the top 250 `t:Explorer.Chain.Address.t/0`'s' in descending order based on coin balance.
""" """
@ -840,8 +839,6 @@ defmodule Explorer.Chain do
end end
@doc """ @doc """
=======
>>>>>>> Fix queries.
Finds all Blocks validated by the address given. Finds all Blocks validated by the address given.
## Options ## Options
@ -1925,4 +1922,3 @@ defmodule Explorer.Chain do
|> Repo.all() |> Repo.all()
end end
end end

@ -1034,78 +1034,64 @@ defmodule Explorer.ChainTest do
end end
describe "get_blocks_validated_by_address/2" do describe "get_blocks_validated_by_address/2" do
test "without blocks" do test "returns nothing when there are no blocks" do
address = insert(:address) address = insert(:address)
assert [] = Chain.get_blocks_validated_by_address([], address) assert [] = Chain.get_blocks_validated_by_address(address)
end end
test "with blocks" do
address = insert(:address)
address2 = insert(:address)
%Block{hash: hash, miner_hash: miner_hash} = test "returns the blocks validated by a specified address" do
insert(:block, miner: address, miner_hash: adress.hash) address = insert(:address)
another_address = insert(:address)
%Block{hash: hash, miner_hash: miner_hash} = block = insert(:block, miner: address, miner_hash: address.hash)
insert(:block, miner: address2, miner_hash: adress2.hash) insert(:block, miner: another_address, miner_hash: another_address.hash)
assert [%Block{hash: ^hash, miner: ^address, miner_hash: ^address.hash}] == results =
Chain.get_blocks_validated_by_address([], address) address
|> Chain.get_blocks_validated_by_address()
|> Enum.map(& &1.hash)
assert [%Block{hash: ^hash, miner: ^address, miner_hash: ^address.hash}] == assert results == [block.hash]
Chain.get_blocks_validated_by_address([], address2)
end end
test "with blocks can be paginated" do test "with blocks can be paginated" do
address = insert(:address) address = insert(:address)
address2 = insert(:address)
second_page_hashes = first_page_block = insert(:block, miner: address, miner_hash: address.hash, number: 0)
50 second_page_block = insert(:block, miner: address, miner_hash: address.hash, number: 2)
|> insert_list(:block, miner: address, miner_hash: adress.hash)
|> Enum.map(& &1.hash)
second_page_hashes2 =
50
|> insert_list(:block, miner: address2, miner_hash: adress.hash2)
|> Enum.map(& &1.hash)
assert second_page_hashes == assert [first_page_block.number] ==
[paging_options: %PagingOptions{key: {inserted_at, hash}, page_size: 50}] [paging_options: %PagingOptions{key: {1}, page_size: 1}]
|> Chain.get_blocks_validated_by_address([], address) |> Chain.get_blocks_validated_by_address(address)
|> Enum.map(& &1.hash) |> Enum.map(& &1.number)
|> Enum.reverse() |> Enum.reverse()
assert second_page_hashes2 == assert [second_page_block.number] ==
[paging_options: %PagingOptions{key: {inserted_at, hash}, page_size: 50}] [paging_options: %PagingOptions{key: {3}, page_size: 1}]
|> Chain.get_blocks_validated_by_address([], address2) |> Chain.get_blocks_validated_by_address(address)
|> Enum.map(& &1.hash) |> Enum.map(& &1.number)
|> Enum.reverse() |> Enum.reverse()
end end
end end
describe "address_to_validation_count/1" do describe "address_to_validation_count/1" do
test "without blocks" do test "returns 0 when there aren't any blocks" do
address = insert(:address) address = insert(:address)
assert 0 = Chain.address_to_validation_count(address) assert 0 = Chain.address_to_validation_count(address)
end end
test "with blocks" do test "returns the number of blocks mined by addres" do
address = insert(:address) address = insert(:address)
address2 = insert(:address) another_address = insert(:address)
%Block{hash: hash, miner_hash: miner_hash} =
insert(:block, miner: address, miner_hash: adress.hash)
%Block{hash: hash, miner_hash: miner_hash} = insert(:block, miner: address, miner_hash: address.hash)
insert(:block, miner: address2, miner_hash: adress2.hash) insert(:block, miner: another_address, miner_hash: another_address.hash)
%Block{hash: hash, miner_hash: miner_hash} = insert(:block, miner: another_address, miner_hash: another_address.hash)
insert(:block, miner: address2, miner_hash: adress2.hash)
assert 1 = Chain.address_to_validation_count(address) assert 1 = Chain.address_to_validation_count(address)
assert 2 = Chain.address_to_validation_count(address) assert 2 = Chain.address_to_validation_count(another_address)
end end
end end

Loading…
Cancel
Save