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/templates/address/overview.html.eex
  4. 4
      apps/block_scout_web/lib/block_scout_web/views/address_internal_transaction_view.ex
  5. 4
      apps/block_scout_web/lib/block_scout_web/views/address_transaction_view.ex
  6. 407
      apps/block_scout_web/priv/gettext/default.pot
  7. 409
      apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po
  8. 4
      apps/explorer/lib/explorer/chain.ex
  9. 70
      apps/explorer/test/explorer/chain_test.exs

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

@ -4,7 +4,7 @@ defmodule BlockScoutWeb.AddressTokenTransferController do
alias Explorer.{Chain, Market}
alias Explorer.ExchangeRates.Token
import BlockScoutWeb.AddressController, only: [transaction_count: 1]
import BlockScoutWeb.AddressController, only: [transaction_count: 1, validation_count: 1]
import BlockScoutWeb.Chain,
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),
token: token,
transaction_count: transaction_count(address),
transactions: transactions_paginated
transactions: transactions_paginated,
validation_count: validation_count(address)
)
else
:error ->

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

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

@ -2,9 +2,7 @@ defmodule BlockScoutWeb.AddressTransactionView do
use BlockScoutWeb, :view
import BlockScoutWeb.AddressView,
only: [contract?: 1, smart_contract_verified?: 1, smart_contract_with_read_only_functions?: 1,
validator?: 1
]
only: [contract?: 1, smart_contract_verified?: 1, smart_contract_with_read_only_functions?: 1, validator?: 1]
def format_current_filter(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
@doc """
<<<<<<< HEAD
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
@doc """
=======
>>>>>>> Fix queries.
Finds all Blocks validated by the address given.
## Options
@ -1925,4 +1922,3 @@ defmodule Explorer.Chain do
|> Repo.all()
end
end

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

Loading…
Cancel
Save