Merge pull request #5737 from blockscout/np-fix-token-balances

Fix double requests; Fix token balances dropdown view
pull/5767/head
Victor Baranov 2 years ago committed by GitHub
commit 4b98f3011c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      CHANGELOG.md
  2. 9
      apps/block_scout_web/assets/css/components/_token-balance-dropdown.scss
  3. 15
      apps/block_scout_web/assets/js/pages/address.js
  4. 2
      apps/block_scout_web/lib/block_scout_web/templates/address_coin_balance/index.html.eex
  5. 2
      apps/block_scout_web/lib/block_scout_web/templates/address_internal_transaction/index.html.eex
  6. 5
      apps/block_scout_web/lib/block_scout_web/templates/address_token_balance/_tokens.html.eex
  7. 2
      apps/block_scout_web/lib/block_scout_web/templates/address_token_transfer/index.html.eex

@ -6,6 +6,7 @@
- [#5699](https://github.com/blockscout/blockscout/pull/5699) - Switch to basic (non-pro) API endpoint for Coingecko requests, if API key is not provided - [#5699](https://github.com/blockscout/blockscout/pull/5699) - Switch to basic (non-pro) API endpoint for Coingecko requests, if API key is not provided
### Fixes ### Fixes
- [#5737](https://github.com/blockscout/blockscout/pull/5737) - Fix double requests; Fix token balances dropdown view
- [#5723](https://github.com/blockscout/blockscout/pull/5723) - Add nil clause for Data.to_string/1 - [#5723](https://github.com/blockscout/blockscout/pull/5723) - Add nil clause for Data.to_string/1
- [#5714](https://github.com/blockscout/blockscout/pull/5714) - Add clause for EthereumJSONRPC.Transaction.elixir_to_params/1 when gas_price is missing in the response - [#5714](https://github.com/blockscout/blockscout/pull/5714) - Add clause for EthereumJSONRPC.Transaction.elixir_to_params/1 when gas_price is missing in the response
- [#5697](https://github.com/blockscout/blockscout/pull/5697) - Gas price oracle: ignore gas price rounding for values less than 0.01 - [#5697](https://github.com/blockscout/blockscout/pull/5697) - Gas price oracle: ignore gas price rounding for values less than 0.01

@ -102,7 +102,16 @@
margin-left: 5px; margin-left: 5px;
} }
.ml-20px {
margin-left: 20px !important;
}
.dropdown-row { .dropdown-row {
padding-left: 5px; padding-left: 5px;
padding-right: 5px; padding-right: 5px;
}
.dropdown-amount {
font-size: 12px;
opacity: .65;
} }

@ -199,14 +199,14 @@ const elements = {
}, },
'[data-selector="current-coin-balance"]': { '[data-selector="current-coin-balance"]': {
render ($el, state, oldState) { render ($el, state, oldState) {
if (!state.newBlockNumber || state.newBlockNumber > oldState.newBlockNumber) return if (!state.newBlockNumber || state.newBlockNumber <= oldState.newBlockNumber) return
$el.empty().append(state.currentCoinBalance) $el.empty().append(state.currentCoinBalance)
updateAllCalculatedUsdValues() updateAllCalculatedUsdValues()
} }
}, },
'[data-selector="last-balance-update"]': { '[data-selector="last-balance-update"]': {
render ($el, state, oldState) { render ($el, state, oldState) {
if (!state.newBlockNumber || state.newBlockNumber > oldState.newBlockNumber) return if (!state.newBlockNumber || state.newBlockNumber <= oldState.newBlockNumber) return
$el.empty().append(state.currentCoinBalanceBlockNumber) $el.empty().append(state.currentCoinBalanceBlockNumber)
} }
}, },
@ -306,11 +306,12 @@ if ($addressDetailsPage.length) {
msg: humps.camelizeKeys(msg) msg: humps.camelizeKeys(msg)
})) }))
addressChannel.push('get_balance', {}) // following lines causes double /token-balances request
.receive('ok', (msg) => store.dispatch({ // addressChannel.push('get_balance', {})
type: 'RECEIVED_UPDATED_BALANCE', // .receive('ok', (msg) => store.dispatch({
msg: humps.camelizeKeys(msg) // type: 'RECEIVED_UPDATED_BALANCE',
})) // msg: humps.camelizeKeys(msg)
// }))
loadCounters(store) loadCounters(store)

@ -21,7 +21,7 @@
<span><%= gettext("There was a problem loading the chart.") %></span> <span><%= gettext("There was a problem loading the chart.") %></span>
</button> </button>
<div data-chart-container class="mb-4" style="display: none;"> <div data-chart-container class="mb-4" style="display: none;">
<canvas data-chart="coinBalanceHistoryChart" data-coin_balance_history_data_path="<%= AccessHelpers.get_path(@conn, :address_coin_balance_by_day_path, :index, @address.hash) %>" width="350" height="152"></canvas> <canvas data-chart="coinBalanceHistoryChart" data-coin_balance_history_data_path="<%= AccessHelpers.get_path(@conn, :address_coin_balance_by_day_path, :index, @address) %>" width="350" height="152"></canvas>
</div> </div>
<%= render BlockScoutWeb.CommonComponentsView, "_pagination_container.html", position: "top", cur_page_number: "1", show_pagination_limit: true, data_next_page_button: true, data_prev_page_button: true %> <%= render BlockScoutWeb.CommonComponentsView, "_pagination_container.html", position: "top", cur_page_number: "1", show_pagination_limit: true, data_next_page_button: true, data_prev_page_button: true %>

@ -6,7 +6,7 @@
<section data-page="address-internal-transactions"> <section data-page="address-internal-transactions">
<div class="card"> <div class="card">
<%= render BlockScoutWeb.AddressView, "_tabs.html", address: @address, is_proxy: is_proxy, conn: @conn %> <%= render BlockScoutWeb.AddressView, "_tabs.html", address: @address, is_proxy: is_proxy, conn: @conn %>
<div class="card-body" data-async-load data-async-listing="<%= @current_path %>"> <div class="card-body" data-async-load data-async-listing="<%= @current_path %>" data-no-self-calls>
<div data-selector="channel-batching-message" class="d-none"> <div data-selector="channel-batching-message" class="d-none">
<div data-selector="reload-button" class="alert alert-info"> <div data-selector="reload-button" class="alert alert-info">
<a href="#" class="alert-link"><span data-selector="channel-batching-count"></span> <%= gettext "More internal transactions have come in" %></a> <a href="#" class="alert-link"><span data-selector="channel-batching-count"></span> <%= gettext "More internal transactions have come in" %></a>

@ -32,7 +32,7 @@
additional_classes: ["token-wallet-icon"] additional_classes: ["token-wallet-icon"]
%> %>
<% end %> <% end %>
<p class="mb-0 col-md-6 pl-0 pr-0 el-1 flex-grow-2"><%= token_name(token) %> <p class="mb-0 col-md-6 pl-0 pr-0 el-1 flex-grow-2 <%= if System.get_env("DISPLAY_TOKEN_ICONS") !== "true", do: "ml-5px" %>"><%= token_name(token) %>
</p> </p>
<%= if token_balance.token.usd_value do %> <%= if token_balance.token.usd_value do %>
<p class="mb-0 col-md-6 text-right usd-total"> <p class="mb-0 col-md-6 text-right usd-total">
@ -41,8 +41,7 @@
<% end %> <% end %>
</div> </div>
<div class="row dropdown-row wh-sp"> <div class="row dropdown-row wh-sp">
<% col_md = if token_balance.token.usd_value, do: "col-md-6", else: "col-md-12" %> <p class="mb-0 ml-5px <%= if System.get_env("DISPLAY_TOKEN_ICONS") === "true", do: "ml-20px" %>">
<p class="mb-0 <%= col_md %> el-1 ml-5px">
<%= if token_balance.token_type == "ERC-721" && !is_nil(token_balance.token_id) do %> <%= if token_balance.token_type == "ERC-721" && !is_nil(token_balance.token_id) do %>
1 1
<% else %> <% else %>

@ -6,7 +6,7 @@
<section data-page="address-token-transfers" id="transfers"> <section data-page="address-token-transfers" id="transfers">
<div class="card"> <div class="card">
<%= render BlockScoutWeb.AddressView, "_tabs.html", address: @address, is_proxy: is_proxy, conn: @conn %> <%= render BlockScoutWeb.AddressView, "_tabs.html", address: @address, is_proxy: is_proxy, conn: @conn %>
<div data-async-load data-async-listing="<%= @current_path %>" class="card-body"> <div data-async-load data-async-listing="<%= @current_path %>" class="card-body" data-no-self-calls>
<%= if assigns[:token] do %> <%= if assigns[:token] do %>
<h2 class="card-title"> <h2 class="card-title">

Loading…
Cancel
Save