diff --git a/CHANGELOG.md b/CHANGELOG.md index 8774508569..21f4940457 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## Current ### Features +- [#4353](https://github.com/blockscout/blockscout/pull/4353) - Added live-reload on the token holders page ### Fixes - [#4388](https://github.com/blockscout/blockscout/pull/4388) - Fix internal server error on contract page for insctances without sourcify envs diff --git a/apps/block_scout_web/assets/js/lib/async_listing_load.js b/apps/block_scout_web/assets/js/lib/async_listing_load.js index de8a6d324b..1789c08e3f 100644 --- a/apps/block_scout_web/assets/js/lib/async_listing_load.js +++ b/apps/block_scout_web/assets/js/lib/async_listing_load.js @@ -307,7 +307,7 @@ export function refreshPage (store) { loadPage(store, store.getState().currentPagePath) } -function loadPage (store, path) { +export function loadPage (store, path) { store.dispatch({ type: 'START_REQUEST', path }) $.getJSON(path, merge({ type: 'JSON' }, store.getState().additionalParams)) .done(response => store.dispatch(Object.assign({ type: 'ITEMS_FETCHED' }, humps.camelizeKeys(response)))) diff --git a/apps/block_scout_web/assets/js/pages/token_counters.js b/apps/block_scout_web/assets/js/pages/token_counters.js index 8bfc337a39..e60e04418e 100644 --- a/apps/block_scout_web/assets/js/pages/token_counters.js +++ b/apps/block_scout_web/assets/js/pages/token_counters.js @@ -1,8 +1,9 @@ import $ from 'jquery' import omit from 'lodash/omit' import humps from 'humps' +import { subscribeChannel } from '../socket' import { createStore, connectElements } from '../lib/redux_helpers.js' -import '../lib/async_listing_load' +import { createAsyncLoadStore, loadPage } from '../lib/async_listing_load' import '../app' import { openQrModal @@ -21,8 +22,6 @@ export function reducer (state = initialState, action) { return Object.assign({}, state, omit(action, 'type')) } case 'CHANNEL_DISCONNECTED': { - if (state.beyondPageOne) return state - return Object.assign({}, state, { channelDisconnected: true }) @@ -86,11 +85,37 @@ function loadCounters (store) { const $tokenPage = $('[token-page]') if ($tokenPage.length) { + updateCounters() +} + +function updateCounters () { const store = createStore(reducer) connectElements({ store, elements }) loadCounters(store) } +if ($('[data-page="token-holders-list"]').length) { + const asyncElements = { + '[data-selector="channel-disconnected-message"]': { + render ($el, state) { + if (state.channelDisconnected) $el.show() + } + } + } + + const store = createAsyncLoadStore(reducer, initialState, null) + connectElements({ store, asyncElements }) + + const addressHash = $('[data-page="token-details"]')[0].dataset.pageAddressHash + const tokensChannel = subscribeChannel(`tokens:${addressHash}`) + tokensChannel.onError(() => store.dispatch({ type: 'CHANNEL_DISCONNECTED' })) + tokensChannel.on('token_transfer', (_msg) => { + const uri = new URL(window.location) + loadPage(store, uri.pathname + uri.search) + updateCounters() + }) +} + $('.btn-qr-icon').click(_event => { openQrModal() }) diff --git a/apps/block_scout_web/lib/block_scout_web/templates/tokens/holder/index.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/tokens/holder/index.html.eex index fcd080e6e7..caec14a4f4 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/tokens/holder/index.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/tokens/holder/index.html.eex @@ -7,11 +7,16 @@ conn: @conn ) %> -
+
<%= render OverviewView, "_tabs.html", assigns %>
+

<%= gettext "Token Holders" %>

diff --git a/apps/block_scout_web/priv/gettext/default.pot b/apps/block_scout_web/priv/gettext/default.pot index 84c3d2530a..fa50ed8fed 100644 --- a/apps/block_scout_web/priv/gettext/default.pot +++ b/apps/block_scout_web/priv/gettext/default.pot @@ -542,6 +542,7 @@ msgstr "" #: lib/block_scout_web/templates/address_contract_verification/new.html.eex:4 #: lib/block_scout_web/templates/address_contract_verification_via_flattened_code/new.html.eex:13 #: lib/block_scout_web/templates/address_contract_verification_via_json/new.html.eex:4 +#: lib/block_scout_web/templates/tokens/holder/index.html.eex:17 msgid "Connection Lost" msgstr "" @@ -1808,7 +1809,7 @@ msgstr "" #: lib/block_scout_web/templates/chain/show.html.eex:182 #: lib/block_scout_web/templates/pending_transaction/index.html.eex:21 #: lib/block_scout_web/templates/stakes/_table.html.eex:49 -#: lib/block_scout_web/templates/tokens/holder/index.html.eex:22 +#: lib/block_scout_web/templates/tokens/holder/index.html.eex:27 #: lib/block_scout_web/templates/tokens/instance/transfer/index.html.eex:23 #: lib/block_scout_web/templates/tokens/inventory/index.html.eex:22 #: lib/block_scout_web/templates/tokens/transfer/index.html.eex:21 @@ -2025,7 +2026,7 @@ msgid "There are no blocks." msgstr "" #, elixir-format -#: lib/block_scout_web/templates/tokens/holder/index.html.eex:27 +#: lib/block_scout_web/templates/tokens/holder/index.html.eex:32 msgid "There are no holders for this Token." msgstr "" @@ -2209,7 +2210,7 @@ msgid "Token Details" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/tokens/holder/index.html.eex:15 +#: lib/block_scout_web/templates/tokens/holder/index.html.eex:20 #: lib/block_scout_web/templates/tokens/overview/_tabs.html.eex:9 #: lib/block_scout_web/views/tokens/overview_view.ex:42 msgid "Token Holders" 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 84c3d2530a..e0e9d7581d 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 @@ -542,6 +542,7 @@ msgstr "" #: lib/block_scout_web/templates/address_contract_verification/new.html.eex:4 #: lib/block_scout_web/templates/address_contract_verification_via_flattened_code/new.html.eex:13 #: lib/block_scout_web/templates/address_contract_verification_via_json/new.html.eex:4 +#: lib/block_scout_web/templates/tokens/holder/index.html.eex:17 msgid "Connection Lost" msgstr "" @@ -1808,7 +1809,7 @@ msgstr "" #: lib/block_scout_web/templates/chain/show.html.eex:182 #: lib/block_scout_web/templates/pending_transaction/index.html.eex:21 #: lib/block_scout_web/templates/stakes/_table.html.eex:49 -#: lib/block_scout_web/templates/tokens/holder/index.html.eex:22 +#: lib/block_scout_web/templates/tokens/holder/index.html.eex:27 #: lib/block_scout_web/templates/tokens/instance/transfer/index.html.eex:23 #: lib/block_scout_web/templates/tokens/inventory/index.html.eex:22 #: lib/block_scout_web/templates/tokens/transfer/index.html.eex:21 @@ -2025,7 +2026,7 @@ msgid "There are no blocks." msgstr "" #, elixir-format -#: lib/block_scout_web/templates/tokens/holder/index.html.eex:27 +#: lib/block_scout_web/templates/tokens/holder/index.html.eex:32 msgid "There are no holders for this Token." msgstr "" @@ -2209,7 +2210,7 @@ msgid "Token Details" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/tokens/holder/index.html.eex:15 +#: lib/block_scout_web/templates/tokens/holder/index.html.eex:20 #: lib/block_scout_web/templates/tokens/overview/_tabs.html.eex:9 #: lib/block_scout_web/views/tokens/overview_view.ex:42 msgid "Token Holders" @@ -2795,12 +2796,12 @@ msgstr "" msgid "validator" msgstr "" -#, elixir-format +#, elixir-format, fuzzy #: lib/block_scout_web/templates/stakes/_stakes_modal_withdraw.html.eex:76 msgid "

Pending stake (stake placed on a candidate pool or placed during the current staking epoch) may be withdrawn now.

\n

Active stake (stake available after the current epoch) can be ordered for withdrawal from the pool, and will be available to claim after the current staking epoch is complete.

\n

If you have already ordered (and the staking window is still open), you may increase your current order by entering a positive value, or decrease your current order by entering a negative value in the box and clicking 'Order Withdrawal'. You must either keep the minimum stake amount in the pool, or order your entire stake for withdrawal.

\n" msgstr "" -#, elixir-format +#, elixir-format, fuzzy #: #: lib/block_scout_web/templates/stakes/_stakes_modal_become_candidate.html.eex:36 msgid "

To become a candidate, your staking address must be funded with %{tokenSymbol} tokens and %{coinSymbol} coins, and your OpenEthereum node must be active and configured with the mining address you specify here.

\n

To become a delegator, close this window and select an address from the list of pools you would like to place stake on. Click the Stake button next to the address to begin the process.

"