From e6dc4e073c68c4c248db88fb283fb6a8450fd48c Mon Sep 17 00:00:00 2001 From: Vadim Date: Thu, 21 Nov 2019 15:49:37 +0300 Subject: [PATCH] Rename some DB fields --- .../channels/stakes_channel.ex | 6 ++--- .../controllers/stakes_controller.ex | 4 ++-- .../templates/stakes/_rows.html.eex | 4 ++-- .../_stakes_modal_delegators_list.html.eex | 10 ++++----- .../stakes/_stakes_modal_move.html.eex | 2 +- .../stakes/_stakes_modal_pool_info.html.eex | 2 +- apps/explorer/lib/explorer/chain.ex | 22 +++++++++---------- .../import/runner/staking_pools_delegators.ex | 6 ++--- .../lib/explorer/chain/staking_pool.ex | 2 +- .../explorer/chain/staking_pools_delegator.ex | 14 ++++++------ .../lib/explorer/staking/contract_state.ex | 4 ++-- .../explorer/staking/stake_snapshotting.ex | 4 ++-- ...112839_create_staking_pools_delegators.exs | 8 +++---- ...0190807111216_remove_duplicate_indexes.exs | 4 ++-- .../chain/staking_pools_delegator_test.exs | 2 +- apps/explorer/test/support/factory.ex | 4 ++-- 16 files changed, 49 insertions(+), 49 deletions(-) diff --git a/apps/block_scout_web/lib/block_scout_web/channels/stakes_channel.ex b/apps/block_scout_web/lib/block_scout_web/channels/stakes_channel.ex index 4045608014..7c11511d6d 100644 --- a/apps/block_scout_web/lib/block_scout_web/channels/stakes_channel.ex +++ b/apps/block_scout_web/lib/block_scout_web/channels/stakes_channel.ex @@ -62,7 +62,7 @@ defmodule BlockScoutWeb.StakesChannel do pool_staking_address |> Chain.staking_pool_delegators() |> Enum.sort_by(fn staker -> - staker_address = to_string(staker.delegator_address_hash) + staker_address = to_string(staker.address_hash) cond do staker_address == pool_staking_address -> 0 @@ -148,7 +148,7 @@ defmodule BlockScoutWeb.StakesChannel do token = ContractState.get(:token) min_from_stake = - if delegator_from.delegator_address_hash == delegator_from.pool_address_hash do + if delegator_from.address_hash == delegator_from.staking_address_hash do ContractState.get(:min_candidate_stake) else ContractState.get(:min_delegator_stake) @@ -201,7 +201,7 @@ defmodule BlockScoutWeb.StakesChannel do delegator = Chain.staking_pool_delegator(staking_address, socket.assigns.account) min_stake = - if delegator.delegator_address_hash == delegator.pool_address_hash do + if delegator.address_hash == delegator.staking_address_hash do ContractState.get(:min_candidate_stake) else ContractState.get(:min_delegator_stake) diff --git a/apps/block_scout_web/lib/block_scout_web/controllers/stakes_controller.ex b/apps/block_scout_web/lib/block_scout_web/controllers/stakes_controller.ex index f28519102f..6ca15827e9 100644 --- a/apps/block_scout_web/lib/block_scout_web/controllers/stakes_controller.ex +++ b/apps/block_scout_web/lib/block_scout_web/controllers/stakes_controller.ex @@ -25,7 +25,7 @@ defmodule BlockScoutWeb.StakesController do account = if account_address = conn.assigns[:account] do account_address - |> Chain.get_total_staked() + |> Chain.get_total_staked_and_ordered() |> Map.merge(%{ address: account_address, balance: Chain.fetch_last_token_balance(account_address, token.contract_address_hash), @@ -141,7 +141,7 @@ defmodule BlockScoutWeb.StakesController do end defp stake_allowed?(pool, delegator) do - Decimal.positive?(pool.self_staked_amount) or delegator.delegator_address_hash == pool.staking_address_hash + Decimal.positive?(pool.self_staked_amount) or delegator.address_hash == pool.staking_address_hash end defp move_allowed?(nil), do: false diff --git a/apps/block_scout_web/lib/block_scout_web/templates/stakes/_rows.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/stakes/_rows.html.eex index 8ac2afb7c7..2aa0b50325 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/stakes/_rows.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/stakes/_rows.html.eex @@ -36,7 +36,7 @@ <%= gettext("Banned until block #%{banned_until} (%{estimated_unban_day})", banned_until: @pool.banned_until, estimated_unban_day: estimated_unban_day(@pool.banned_until, @average_block_time)) %> <%= if @delegator && - @delegator.delegator_address_hash != @pool.staking_address_hash && + @delegator.address_hash != @pool.staking_address_hash && @pool.are_delegators_banned && @pool.banned_until != @pool.banned_delegators_until do %> <%= raw(".
") %> @@ -47,7 +47,7 @@ <%= if !@pool.is_banned || (!@pool.are_delegators_banned && @delegator && - @delegator.delegator_address_hash != @pool.staking_address_hash + @delegator.address_hash != @pool.staking_address_hash ) do %>
<%= if @buttons.move do %> diff --git a/apps/block_scout_web/lib/block_scout_web/templates/stakes/_stakes_modal_delegators_list.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/stakes/_stakes_modal_delegators_list.html.eex index 61b0e3f3df..bb9824bf7b 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/stakes/_stakes_modal_delegators_list.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/stakes/_stakes_modal_delegators_list.html.eex @@ -63,13 +63,13 @@ <%= link( - BlockScoutWeb.AddressView.trimmed_hash(staker.delegator_address_hash), - to: address_path(@conn, :show, staker.delegator_address_hash), + BlockScoutWeb.AddressView.trimmed_hash(staker.address_hash), + to: address_path(@conn, :show, staker.address_hash), target: "_blank" ) %> - <%= if staker.delegator_address_hash == @pool.staking_address_hash do %> + <%= if staker.address_hash == @pool.staking_address_hash do %> <%= render( BlockScoutWeb.CommonComponentsView, @@ -78,7 +78,7 @@ ) %> <% end %> - <%= if to_string(staker.delegator_address_hash) == @account do %> + <%= if to_string(staker.address_hash) == @account do %>
<% reward = - if staker.delegator_address_hash == @pool.staking_address_hash do + if staker.address_hash == @pool.staking_address_hash do %{ reward_ratio: @pool.validator_reward_ratio, snapshotted_reward_ratio: @pool.snapshotted_validator_reward_ratio diff --git a/apps/block_scout_web/lib/block_scout_web/templates/stakes/_stakes_modal_move.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/stakes/_stakes_modal_move.html.eex index 7283a66111..84cc730e97 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/stakes/_stakes_modal_move.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/stakes/_stakes_modal_move.html.eex @@ -22,7 +22,7 @@ <%= for %{pool: pool} <- @pools, pool.staking_address_hash != @pool_from.staking_address_hash, - Decimal.positive?(pool.self_staked_amount) or pool.staking_address_hash == @delegator_from.delegator_address_hash do %> + Decimal.positive?(pool.self_staked_amount) or pool.staking_address_hash == @delegator_from.address_hash do %>