diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d4771720c..0eed85aec8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ ## Current ### Features +- [#1928](https://github.com/poanetwork/blockscout/pull/1928) - pagination styles were updated +- [#1948](https://github.com/poanetwork/blockscout/pull/1948) - added ropsten theme and ropsten logo - [#1940](https://github.com/poanetwork/blockscout/pull/1940) - qr modal button and background issue - [#1936](https://github.com/poanetwork/blockscout/pull/1936) - added kovan, sokol themes and logos - [#1925](https://github.com/poanetwork/blockscout/pull/1925) - added dai theme and logo @@ -17,6 +19,7 @@ - [#1859](https://github.com/poanetwork/blockscout/pull/1859) - feat: show raw transaction traces - [#1920](https://github.com/poanetwork/blockscout/pull/1920) - fix: remove source code fields from list endpoint - [#1876](https://github.com/poanetwork/blockscout/pull/1876) - async calculate a count of blocks +- [#1941](https://github.com/poanetwork/blockscout/pull/1941) - feat: add on demand fetching and stale attr to rpc ### Fixes @@ -37,6 +40,7 @@ - [#1904](https://github.com/poanetwork/blockscout/pull/1904) - fix `BLOCK_COUNT_CACHE_TTL` env var type - [#1898](https://github.com/poanetwork/blockscout/pull/1898) - check if the constructor has arguments before verifying constructor arguments - [#1915](https://github.com/poanetwork/blockscout/pull/1915) - fallback to 2 latest evm versions +- [#1937](https://github.com/poanetwork/blockscout/pull/1937) - Check the presence of overlap[i] object before retrieving properties from it ### Chore diff --git a/apps/block_scout_web/assets/css/_helpers.scss b/apps/block_scout_web/assets/css/_helpers.scss index a7068b0b63..c26b5c5b22 100644 --- a/apps/block_scout_web/assets/css/_helpers.scss +++ b/apps/block_scout_web/assets/css/_helpers.scss @@ -20,4 +20,12 @@ @include media-breakpoint-down(md) { margin-right: 0; } -} \ No newline at end of file +} + +.clearfix:after { + clear: both; + content: " "; /* Older browser do not support empty content */ + display: block; + height: 0; + visibility: hidden; +} diff --git a/apps/block_scout_web/assets/css/app.scss b/apps/block_scout_web/assets/css/app.scss index 990583ecdf..567f3b0abf 100644 --- a/apps/block_scout_web/assets/css/app.scss +++ b/apps/block_scout_web/assets/css/app.scss @@ -69,7 +69,7 @@ $fa-font-path: "~@fortawesome/fontawesome-free/webfonts"; @import "components/panels"; @import "components/nav_tabs"; @import "components/dot"; -@import "components/pagination"; +@import "components/pagination_container"; @import "components/address_link"; @import "components/footer"; @import "components/filter"; diff --git a/apps/block_scout_web/assets/css/components/_card.scss b/apps/block_scout_web/assets/css/components/_card.scss index 2e2cba08a9..4c34e4a31b 100644 --- a/apps/block_scout_web/assets/css/components/_card.scss +++ b/apps/block_scout_web/assets/css/components/_card.scss @@ -67,7 +67,7 @@ $card-background-1-text-color: #fff !default; } .card-subtitle { - color: #aaa; + color: #333; font-size: 12px; font-weight: normal; line-height: 1.2; diff --git a/apps/block_scout_web/assets/css/components/_pagination.scss b/apps/block_scout_web/assets/css/components/_pagination.scss deleted file mode 100644 index b044e004bf..0000000000 --- a/apps/block_scout_web/assets/css/components/_pagination.scss +++ /dev/null @@ -1,42 +0,0 @@ -$pagination-page-link-background: #f5f6fa !default; -$pagination-page-link-color: #a3a9b5 !default; -$pagination-page-link-background-active: $primary !default; -$pagination-page-link-color-active: #fff !default; - -.pagination { - margin: 0; - padding: 30px; - - .page-item { - margin: 0 10px 0 0; - - &:last-child { - margin-right: 0; - } - } - - .page-link { - background-color: $pagination-page-link-background; - border: 1px solid $pagination-page-link-background; - color: $pagination-page-link-color; - display: block; - line-height: 1.25; - margin: 0; - padding: 0.5rem 0.75rem; - position: relative; - - &:hover { - background-color: darken($pagination-page-link-background, 5%); - border-color: darken($pagination-page-link-background, 5%); - } - - .active & { - &, - &:hover { - background-color: $pagination-page-link-background-active; - border-color: $pagination-page-link-background-active; - color: $pagination-page-link-color-active; - } - } - } -} diff --git a/apps/block_scout_web/assets/css/components/_pagination_container.scss b/apps/block_scout_web/assets/css/components/_pagination_container.scss new file mode 100644 index 0000000000..04e0d944e1 --- /dev/null +++ b/apps/block_scout_web/assets/css/components/_pagination_container.scss @@ -0,0 +1,113 @@ +$pagination-page-link-background: #f5f6fa !default; +$pagination-page-link-color: #a3a9b5 !default; +$pagination-page-link-background-active: $primary !default; +$pagination-page-link-color-active: #fff !default; + +@mixin pagination-container-base($background-color, $text-color) { + background-color: $background-color; + border: 1px solid $background-color; + color: $text-color; + + path { + fill: $text-color; + } +} + +.pagination-container { + display: flex; + justify-content: space-between; + + @include media-breakpoint-down(sm) { + flex-direction: column; + } + + &.position-bottom { + padding-top: 30px; + } + + &.position-top { + padding-bottom: 30px; + } + + .pagination-limit { + align-items: center; + color: #033333; + display: flex; + font-size: 12px; + font-weight: 600; + line-height: 1.2; + + @include media-breakpoint-down(sm) { + margin-bottom: 15px; + } + + select { + margin: 0 10px; + } + } + + .pagination { + margin: 0 0 0 auto; + padding: 0; + + @include media-breakpoint-down(sm) { + justify-content: space-between; + margin: 0; + } + + .page-item { + margin: 0 5px 0 0; + + &:last-child { + margin-right: 0; + } + + &.active .page-link { + @include pagination-container-base($pagination-page-link-background-active, $pagination-page-link-color-active); + cursor: default; + pointer-events: none; + + &:hover { + @include pagination-container-base($pagination-page-link-background-active, $pagination-page-link-color-active); + } + } + } + + .page-link { + @include pagination-container-base($pagination-page-link-background, $pagination-page-link-color); + align-items: center; + border-radius: 2px; + display: flex; + font-size: 12px; + font-weight: 600; + height: 24px; + margin: 0; + padding: 0 8px; + position: relative; + user-select: none; + text-align: center; + white-space: nowrap; + + &:not(.no-hover):hover { + @include pagination-container-base($pagination-page-link-background-active, $pagination-page-link-color-active); + } + + &[href=''] { + pointer-events: none; + } + + &.no-hover { + cursor: default; + } + + &[disabled] { + @include pagination-container-base($pagination-page-link-background, $pagination-page-link-color); + cursor: not-allowed; + opacity: 0.4; + outline: none; + pointer-events: none; + } + } + } + +} \ No newline at end of file diff --git a/apps/block_scout_web/assets/css/theme/_ropsten_variables.scss b/apps/block_scout_web/assets/css/theme/_ropsten_variables.scss index f916655071..88ac5632e0 100644 --- a/apps/block_scout_web/assets/css/theme/_ropsten_variables.scss +++ b/apps/block_scout_web/assets/css/theme/_ropsten_variables.scss @@ -1,8 +1,50 @@ -$primary: #2fa8f8; -$secondary: #a2daff; -$tertiary: #006aa7; +// general +$primary: #153550; +$secondary: #38a9f5; +$tertiary: #76f1ff; +$additional-font: #89cae6; +// footer $footer-background-color: $primary; $footer-title-color: #fff; -$footer-text-color: #fff; +$footer-text-color: #89cae6; $footer-item-disc-color: $secondary; +.footer-logo { filter: brightness(0) invert(1); } + +// dashboard +$dashboard-line-color-price: $tertiary; // price left border + +$dashboard-banner-chart-legend-value-color: $additional-font; // chart labels + +$dashboard-stats-item-value-color: $additional-font; // stat values + +$dashboard-stats-item-border-color: $tertiary; // stat border + +$dashboard-banner-gradient-start: $primary; // gradient begin + +$dashboard-banner-gradient-end: lighten($primary, 5); // gradient end + +$dashboard-banner-network-plain-container-background-color: #1c476c; // stats bg + + +// navigation +.navbar { box-shadow: 0px 0px 30px 0px rgba(21, 53, 80, 0.12); } // header shadow +$header-icon-border-color-hover: $secondary; // top border on hover +$header-icon-color-hover: $secondary; // nav icon on hover +.dropdown-item:hover, .dropdown-item:focus { background-color: $secondary !important; } // dropdown item on hover + +// buttons +$btn-line-bg: #fff; // button bg +$btn-line-color: $secondary; // button border and font color && hover bg color +$btn-copy-color: $secondary; // btn copy +$btn-qr-color: $secondary; // btn qr-code + +//links & tile +.tile a { color: $secondary !important; } // links color for badges +.tile-type-block { + border-left: 4px solid $secondary; +} // tab active bg + +// card +$card-background-1: $secondary; +$card-tab-active: $secondary; 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 2e9e4e371b..71be924c95 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 @@ -145,11 +145,11 @@ export const elements = { }, '[data-async-listing] [data-next-page-button]': { render ($el, state) { - if (state.requestError) return $el.hide() - if (!state.nextPagePath) return $el.hide() - if (state.loading) return $el.hide() + if (state.requestError || !state.nextPagePath || state.loading) { + return $el.attr('disabled', 'disabled') + } - $el.show() + $el.attr('disabled', false) $el.attr('href', state.nextPagePath) } }, diff --git a/apps/block_scout_web/assets/js/lib/list_morph.js b/apps/block_scout_web/assets/js/lib/list_morph.js index 4f3b0736c4..175acb7c3f 100644 --- a/apps/block_scout_web/assets/js/lib/list_morph.js +++ b/apps/block_scout_web/assets/js/lib/list_morph.js @@ -42,8 +42,8 @@ export default function (container, newElements, { key, horizontal } = {}) { // update kept items currentList = currentList.map(({ el }, i) => ({ - id: overlap[i].id, - el: el.outerHTML === overlap[i].el.outerHTML ? el : morph(el, overlap[i].el) + id: overlap[i] && overlap[i].id, + el: el.outerHTML === overlap[i] && overlap[i].el && overlap[i].el.outerHTML ? el : morph(el, overlap[i].el) })) // add new items diff --git a/apps/block_scout_web/assets/static/images/ropsten_logo.svg b/apps/block_scout_web/assets/static/images/ropsten_logo.svg index ba886bc6f3..4b302960ce 100644 --- a/apps/block_scout_web/assets/static/images/ropsten_logo.svg +++ b/apps/block_scout_web/assets/static/images/ropsten_logo.svg @@ -1,48 +1 @@ - - - - -testnet-logo - - - - - - - - - - - - - - + diff --git a/apps/block_scout_web/lib/block_scout_web/controllers/api/rpc/address_controller.ex b/apps/block_scout_web/lib/block_scout_web/controllers/api/rpc/address_controller.ex index c2bbfd5317..be10089bad 100644 --- a/apps/block_scout_web/lib/block_scout_web/controllers/api/rpc/address_controller.ex +++ b/apps/block_scout_web/lib/block_scout_web/controllers/api/rpc/address_controller.ex @@ -4,6 +4,7 @@ defmodule BlockScoutWeb.API.RPC.AddressController do alias BlockScoutWeb.API.RPC.Helpers alias Explorer.{Chain, Etherscan} alias Explorer.Chain.{Address, Wei} + alias Indexer.Fetcher.CoinBalanceOnDemand def listaccounts(conn, params) do options = @@ -279,12 +280,15 @@ defmodule BlockScoutWeb.API.RPC.AddressController do offset = (max(page_number, 1) - 1) * page_size # limit is just page_size - Chain.list_ordered_addresses(offset, page_size) + offset + |> Chain.list_ordered_addresses(page_size) + |> trigger_balances_and_add_status() end defp hashes_to_addresses(address_hashes) do address_hashes |> Chain.hashes_to_addresses() + |> trigger_balances_and_add_status() |> add_not_found_addresses(address_hashes) end @@ -307,6 +311,18 @@ defmodule BlockScoutWeb.API.RPC.AddressController do end) end + defp trigger_balances_and_add_status(addresses) do + Enum.map(addresses, fn address -> + case CoinBalanceOnDemand.trigger_fetch(address) do + :current -> + %{address | stale?: false} + + _ -> + %{address | stale?: true} + end + end) + end + defp to_contract_address_hash(nil), do: {:contract_address, {:ok, nil}} defp to_contract_address_hash(address_hash_string) do diff --git a/apps/block_scout_web/lib/block_scout_web/etherscan.ex b/apps/block_scout_web/lib/block_scout_web/etherscan.ex index 27bc197195..3621a12d10 100644 --- a/apps/block_scout_web/lib/block_scout_web/etherscan.ex +++ b/apps/block_scout_web/lib/block_scout_web/etherscan.ex @@ -21,15 +21,18 @@ defmodule BlockScoutWeb.Etherscan do "result" => [ %{ "account" => "0xddbd2b932c763ba5b1b7ae3b362eac3e8d40121a", - "balance" => "40807168566070000000000" + "balance" => "40807168566070000000000", + "stale" => true }, %{ "account" => "0x63a9975ba31b0b9626b34300f7f627147df1f526", - "balance" => "332567136222827062478" + "balance" => "332567136222827062478", + "stale" => false }, %{ "account" => "0x198ef1ec325a96cc354c7266a038be8b5c558f67", - "balance" => "185178830000000000" + "balance" => "185178830000000000", + "stale" => false } ] } @@ -496,6 +499,13 @@ defmodule BlockScoutWeb.Etherscan do example: ~s("0x95426f2bc716022fcf1def006dbc4bb81f5b5164") } + @stale_type %{ + type: "boolean", + definition: + "Represents whether or not the balance has not been checked in the last 24 hours, and will be rechecked.", + example: true + } + @transaction_hash_type %{ type: "transaction hash", definition: @@ -571,7 +581,8 @@ defmodule BlockScoutWeb.Etherscan do name: "AddressBalance", fields: %{ address: @address_hash_type, - balance: @wei_type + balance: @wei_type, + stale: @stale_type } } @@ -988,7 +999,16 @@ defmodule BlockScoutWeb.Etherscan do @account_balance_action %{ name: "balance", - description: "Get balance for address. Also available through a GraphQL 'addresses' query.", + description: """ + Get balance for address. Also available through a GraphQL 'addresses' query. + + If the balance hasn't been updated in a long time, we will double check + with the node to fetch the absolute latest balance. This will not be + reflected in the current request, but once it is updated, subsequent requests + will show the updated balance. If you want to know whether or not we are checking + for another balance, use the `balancemulti` action. That contains a property + called `stale` that will let you know to recheck that balance in the near future. + """, required_params: [ %{ key: "address", @@ -1022,7 +1042,15 @@ defmodule BlockScoutWeb.Etherscan do @account_balancemulti_action %{ name: "balancemulti", - description: "Get balance for multiple addresses. Also available through a GraphQL 'addresses' query.", + description: """ + Get balance for multiple addresses. Also available through a GraphQL 'addresses' query. + + If the balance hasn't been updated in a long time, we will double check + with the node to fetch the absolute latest balance. This will not be + reflected in the current request, but once it is updated, subsequent requests + will show the updated balance. You can know that this is taking place via + the `stale` attribute, which is set to `true` if a new balance is being fetched. + """, required_params: [ %{ key: "address", diff --git a/apps/block_scout_web/lib/block_scout_web/templates/address/index.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/address/index.html.eex index fca5d5b50d..91697de0c9 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/address/index.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/address/index.html.eex @@ -1,47 +1,20 @@
- <%= if @next_page_path do %> - " class="button button-secondary button-small float-right ml-1"> - <%= gettext("Next") %> - - <% end %> - <%= if @prev_page_path do %> - " class="button button-secondary button-small float-right"> - <%= gettext("Back") %> - - <% end %> +

<%= gettext "Addresses" %>

-

<%= gettext "Addresses" %>

-

- <%= gettext "Showing " %> - <%= Cldr.Number.to_string!(@page_address_count, format: "#,###") %> - <%= gettext " addresses of" %> - <%= Cldr.Number.to_string!(@address_count, format: "#,###") %> - <%= gettext "total addresses with a balance" %> - <%= gettext " (page" %> - <%= Cldr.Number.to_string!(@cur_page_number, format: "#,###)") %> -

+ <%= render BlockScoutWeb.CommonComponentsView, "_pagination_container.html", position: "top", prev_page_path: @prev_page_path, next_page_path: @next_page_path, cur_page_number: @cur_page_number, show_pagination_limit: true %> - +
<%= for {{address, tx_count}, index} <- Enum.with_index(@address_tx_count_pairs, 1) do %> <%= render "_tile.html", address: address, index: index, exchange_rate: @exchange_rate, total_supply: @total_supply, tx_count: tx_count, validation_count: validation_count(address) %> <% end %> -
- <%= if @next_page_path do %> - " class="button button-secondary button-small float-right mt-0 mb-0 ml-1"> - <%= gettext("Next") %> - - <% end %> - <%= if @prev_page_path do %> - " class="button button-secondary button-small float-right mt-0 mb-0"> - <%= gettext("Back") %> - - <% end %> - +
+ + <%= render BlockScoutWeb.CommonComponentsView, "_pagination_container.html", position: "bottom", prev_page_path: @prev_page_path, next_page_path: @next_page_path, cur_page_number: @cur_page_number, show_pagination_limit: true %>
diff --git a/apps/block_scout_web/lib/block_scout_web/templates/address_coin_balance/index.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/address_coin_balance/index.html.eex index a41a641fad..f8693b2692 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/address_coin_balance/index.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/address_coin_balance/index.html.eex @@ -13,20 +13,22 @@

<%= gettext "Balances" %>

-
+ +
<%= gettext("Loading chart") %>...
- -
+ + <%= render BlockScoutWeb.CommonComponentsView, "_pagination_container.html", position: "top", cur_page_number: "1", show_pagination_limit: true, data_next_page_button: true %>
- diff --git a/apps/block_scout_web/lib/block_scout_web/templates/address_token_transfer/index.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/address_token_transfer/index.html.eex index 389dd2aefb..33f29839bb 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/address_token_transfer/index.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/address_token_transfer/index.html.eex @@ -8,6 +8,9 @@

<%= gettext "Tokens" %> / <%= token_name(@token) %>

+ + <%= render BlockScoutWeb.CommonComponentsView, "_pagination_container.html", position: "top", cur_page_number: "1", show_pagination_limit: true, data_next_page_button: true %> +
@@ -15,18 +18,27 @@ <%= gettext("Loading...") %>
+ + +
+ + <%= render BlockScoutWeb.CommonComponentsView, "_pagination_container.html", position: "bottom", cur_page_number: "1", show_pagination_limit: true, data_next_page_button: true %> + + +
- diff --git a/apps/block_scout_web/lib/block_scout_web/templates/block_transaction/index.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/block_transaction/index.html.eex index 54aa04d947..79574e8fee 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/block_transaction/index.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/block_transaction/index.html.eex @@ -15,6 +15,15 @@

<%= gettext "Transactions" %>

+ + <%= if @next_page_params do %> + <%= render BlockScoutWeb.CommonComponentsView, "_pagination_container.html", position: "top", cur_page_number: "1", show_pagination_limit: true, next_page_path: transaction_path(@conn, :index, @next_page_params) %> + <% end %> + + <%= if !@next_page_params do %> + <%= render BlockScoutWeb.CommonComponentsView, "_pagination_container.html", position: "top", cur_page_number: "1", show_pagination_limit: true %> + <% end %> + <%= if Enum.count(@transactions) > 0 do %> <%= for transaction <- @transactions do %> @@ -27,6 +36,15 @@
<% end %> + <%= if @next_page_params do %> + <%= render BlockScoutWeb.CommonComponentsView, "_pagination_container.html", position: "bottom", cur_page_number: "1", show_pagination_limit: true, next_page_path: transaction_path(@conn, :index, @next_page_params) %> + <% end %> + + <%= if !@next_page_params do %> + <%= render BlockScoutWeb.CommonComponentsView, "_pagination_container.html", position: "bottom", cur_page_number: "1", show_pagination_limit: true %> + <% end %> + + diff --git a/apps/block_scout_web/lib/block_scout_web/templates/common_components/_pagination.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/common_components/_pagination.html.eex deleted file mode 100644 index 84ab89ee80..0000000000 --- a/apps/block_scout_web/lib/block_scout_web/templates/common_components/_pagination.html.eex +++ /dev/null @@ -1,9 +0,0 @@ - \ No newline at end of file diff --git a/apps/block_scout_web/lib/block_scout_web/templates/common_components/_pagination_container.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/common_components/_pagination_container.html.eex new file mode 100644 index 0000000000..6f33bcf854 --- /dev/null +++ b/apps/block_scout_web/lib/block_scout_web/templates/common_components/_pagination_container.html.eex @@ -0,0 +1,60 @@ +
+ <%= if assigns[:show_pagination_limit] do %> + +
+ <%= gettext "Show" %> + + <%= gettext "Records" %> +
+ <% end %> + + +
\ No newline at end of file diff --git a/apps/block_scout_web/lib/block_scout_web/templates/pending_transaction/index.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/pending_transaction/index.html.eex index cbd3b28eca..8c57144734 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/pending_transaction/index.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/pending_transaction/index.html.eex @@ -1,12 +1,10 @@
-

<%= gettext "Pending Transactions" %>

-

- <%= gettext("Showing") %> - <%= Cldr.Number.to_string!(@pending_transaction_count, format: "#,###") %> - <%= gettext("Pending Transactions") %> -

+

<%= gettext "Pending Transactions" %>

+ + <%= render BlockScoutWeb.CommonComponentsView, "_pagination_container.html", position: "top", cur_page_number: "1", show_pagination_limit: true, data_next_page_button: true %> +
<%= gettext "More transactions have come in" %> @@ -33,9 +31,15 @@ <%= gettext("Loading") %>...
+ + <%= render BlockScoutWeb.CommonComponentsView, "_pagination_container.html", position: "bottom", cur_page_number: "1", show_pagination_limit: true, data_next_page_button: true %> + + +
diff --git a/apps/block_scout_web/lib/block_scout_web/templates/transaction_raw_trace/index.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/transaction_raw_trace/index.html.eex index 2695dea13b..0d973adf5d 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/transaction_raw_trace/index.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/transaction_raw_trace/index.html.eex @@ -2,16 +2,15 @@ <%= render BlockScoutWeb.TransactionView, "overview.html", assigns %>
-
- <%= render BlockScoutWeb.TransactionView, "_tabs.html", assigns %> -
- + <%= render BlockScoutWeb.TransactionView, "_tabs.html", assigns %>

<%= gettext "Raw Trace" %>

<%= if Enum.count(@internal_transactions) > 0 do %>
<%= for {line, number} <- raw_traces_with_lines(@internal_transactions) do %>
<%= line %>
<% end %>
<% else %> - No trace entries found. +
+ No trace entries found. +
<% end %>
diff --git a/apps/block_scout_web/lib/block_scout_web/templates/transaction_token_transfer/index.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/transaction_token_transfer/index.html.eex index 74cb6cb4fd..45da95e2b5 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/transaction_token_transfer/index.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/transaction_token_transfer/index.html.eex @@ -5,6 +5,15 @@ <%= render BlockScoutWeb.TransactionView, "_tabs.html", assigns %>

<%= gettext "Token Transfers" %>

+ + <%= if @next_page_params do %> + <%= render BlockScoutWeb.CommonComponentsView, "_pagination_container.html", position: "top", cur_page_number: "1", show_pagination_limit: true, next_page_path: transaction_token_transfer_path(@conn, :index, @transaction, @next_page_params) %> + <% end %> + + <%= if !@next_page_params do %> + <%= render BlockScoutWeb.CommonComponentsView, "_pagination_container.html", position: "top", cur_page_number: "1", show_pagination_limit: true %> + <% end %> + <%= if Enum.any?(@token_transfers) do %> <%= for token_transfer <- @token_transfers do %> <%= render "_token_transfer.html", token_transfer: token_transfer, conn: @conn %> @@ -14,18 +23,29 @@ <%= gettext "There are no token transfers for this transaction." %>
<% end %> + + <%= if @next_page_params do %> + <%= render BlockScoutWeb.CommonComponentsView, "_pagination_container.html", position: "bottom", cur_page_number: "1", show_pagination_limit: true, next_page_path: transaction_token_transfer_path(@conn, :index, @transaction, @next_page_params) %> + <% end %> + + <%= if !@next_page_params do %> + <%= render BlockScoutWeb.CommonComponentsView, "_pagination_container.html", position: "bottom", cur_page_number: "1", show_pagination_limit: true %> + <% end %> + + - <%= if @next_page_params do %> - <%= link( - gettext("Older"), - class: "button button-secondary button-sm u-float-left mt-3", - to: transaction_token_transfer_path( - @conn, - :index, - @transaction, - @next_page_params - ) - ) %> - <% end %> diff --git a/apps/block_scout_web/lib/block_scout_web/views/api/rpc/address_view.ex b/apps/block_scout_web/lib/block_scout_web/views/api/rpc/address_view.ex index 5dd7146279..9c403a4201 100644 --- a/apps/block_scout_web/lib/block_scout_web/views/api/rpc/address_view.ex +++ b/apps/block_scout_web/lib/block_scout_web/views/api/rpc/address_view.ex @@ -17,13 +17,7 @@ defmodule BlockScoutWeb.API.RPC.AddressView do end def render("balancemulti.json", %{addresses: addresses}) do - data = - Enum.map(addresses, fn address -> - %{ - "account" => "#{address.hash}", - "balance" => balance(address) - } - end) + data = Enum.map(addresses, &render_address/1) RPCView.render("show.json", data: data) end @@ -61,10 +55,19 @@ defmodule BlockScoutWeb.API.RPC.AddressView do RPCView.render("error.json", assigns) end + defp render_address(address) do + %{ + "account" => "#{address.hash}", + "balance" => balance(address), + "stale" => address.stale? || false + } + end + defp prepare_account(address) do %{ - "balance" => to_string(address.fetched_coin_balance.value), - "address" => to_string(address.hash) + "balance" => to_string(address.fetched_coin_balance && address.fetched_coin_balance.value), + "address" => to_string(address.hash), + "stale" => address.stale? || false } end diff --git a/apps/block_scout_web/priv/gettext/default.pot b/apps/block_scout_web/priv/gettext/default.pot index b72a79cff6..7922c7d2f0 100644 --- a/apps/block_scout_web/priv/gettext/default.pot +++ b/apps/block_scout_web/priv/gettext/default.pot @@ -28,7 +28,7 @@ msgid "%{block_type} Height:" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/block/index.html.eex:9 +#: lib/block_scout_web/templates/block/index.html.eex:10 msgid "%{block_type}s" msgstr "" @@ -98,20 +98,20 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/address/_validator_metadata_modal.html.eex:16 -#: lib/block_scout_web/templates/transaction_log/index.html.eex:13 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:22 #: lib/block_scout_web/views/address_view.ex:101 msgid "Address" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address/index.html.eex:15 +#: lib/block_scout_web/templates/address/index.html.eex:4 #: lib/block_scout_web/templates/tokens/overview/_details.html.eex:59 msgid "Addresses" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_internal_transaction/index.html.eex:25 -#: lib/block_scout_web/templates/address_transaction/index.html.eex:21 +#: lib/block_scout_web/templates/address_internal_transaction/index.html.eex:27 +#: lib/block_scout_web/templates/address_transaction/index.html.eex:23 #: lib/block_scout_web/views/address_internal_transaction_view.ex:8 #: lib/block_scout_web/views/address_transaction_view.ex:8 msgid "All" @@ -245,8 +245,8 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/address_transaction/index.html.eex:11 -#: lib/block_scout_web/templates/pending_transaction/index.html.eex:17 -#: lib/block_scout_web/templates/transaction/index.html.eex:17 +#: lib/block_scout_web/templates/pending_transaction/index.html.eex:15 +#: lib/block_scout_web/templates/transaction/index.html.eex:15 msgid "Connection Lost, click to load newer transactions" msgstr "" @@ -335,8 +335,8 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:18 -#: lib/block_scout_web/templates/transaction_log/index.html.eex:58 -#: lib/block_scout_web/templates/transaction_log/index.html.eex:124 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:67 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:133 msgid "Data" msgstr "" @@ -414,8 +414,8 @@ msgid "Forked Blocks (Reorgs)" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_internal_transaction/index.html.eex:42 -#: lib/block_scout_web/templates/address_transaction/index.html.eex:38 +#: lib/block_scout_web/templates/address_internal_transaction/index.html.eex:44 +#: lib/block_scout_web/templates/address_transaction/index.html.eex:40 #: lib/block_scout_web/views/address_internal_transaction_view.ex:7 #: lib/block_scout_web/views/address_transaction_view.ex:7 msgid "From" @@ -479,7 +479,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/address/_tabs.html.eex:14 -#: lib/block_scout_web/templates/address_internal_transaction/index.html.eex:55 +#: lib/block_scout_web/templates/address_internal_transaction/index.html.eex:19 #: lib/block_scout_web/templates/transaction/_tabs.html.eex:11 #: lib/block_scout_web/templates/transaction_internal_transaction/index.html.eex:6 #: lib/block_scout_web/views/address_view.ex:297 @@ -547,8 +547,8 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/chain/show.html.eex:111 -#: lib/block_scout_web/templates/pending_transaction/index.html.eex:12 -#: lib/block_scout_web/templates/transaction/index.html.eex:12 +#: lib/block_scout_web/templates/pending_transaction/index.html.eex:10 +#: lib/block_scout_web/templates/transaction/index.html.eex:10 msgid "More transactions have come in" msgstr "" @@ -561,7 +561,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/api_docs/_action_tile.html.eex:52 #: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:16 -#: lib/block_scout_web/templates/transaction_log/index.html.eex:55 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:64 msgid "Name" msgstr "" @@ -572,15 +572,13 @@ msgstr "" #, elixir-format #: -#: lib/block_scout_web/templates/transaction_internal_transaction/index.html.eex:19 -#: lib/block_scout_web/templates/transaction_log/index.html.eex:144 +#: lib/block_scout_web/templates/transaction_internal_transaction/index.html.eex:37 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:162 msgid "Newer" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address/index.html.eex:6 -#: lib/block_scout_web/templates/address/index.html.eex:36 -#: lib/block_scout_web/templates/address_token/index.html.eex:22 +#: lib/block_scout_web/templates/address_token/index.html.eex:39 msgid "Next" msgstr "" @@ -608,17 +606,17 @@ msgid "OUT" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_coin_balance/index.html.eex:52 -#: lib/block_scout_web/templates/address_internal_transaction/index.html.eex:73 -#: lib/block_scout_web/templates/address_token_transfer/index.html.eex:28 -#: lib/block_scout_web/templates/address_transaction/index.html.eex:72 -#: lib/block_scout_web/templates/address_validation/index.html.eex:31 -#: lib/block_scout_web/templates/block/index.html.eex:23 -#: lib/block_scout_web/templates/block_transaction/index.html.eex:32 -#: lib/block_scout_web/templates/pending_transaction/index.html.eex:37 -#: lib/block_scout_web/templates/tokens/transfer/index.html.eex:34 -#: lib/block_scout_web/templates/transaction/index.html.eex:44 -#: lib/block_scout_web/templates/transaction_token_transfer/index.html.eex:21 +#: lib/block_scout_web/templates/address_coin_balance/index.html.eex:57 +#: lib/block_scout_web/templates/address_internal_transaction/index.html.eex:81 +#: lib/block_scout_web/templates/address_token_transfer/index.html.eex:38 +#: lib/block_scout_web/templates/address_transaction/index.html.eex:80 +#: lib/block_scout_web/templates/address_validation/index.html.eex:38 +#: lib/block_scout_web/templates/block/index.html.eex:30 +#: lib/block_scout_web/templates/block_transaction/index.html.eex:50 +#: lib/block_scout_web/templates/pending_transaction/index.html.eex:39 +#: lib/block_scout_web/templates/tokens/transfer/index.html.eex:43 +#: lib/block_scout_web/templates/transaction/index.html.eex:45 +#: lib/block_scout_web/templates/transaction_token_transfer/index.html.eex:38 msgid "Older" msgstr "" @@ -656,7 +654,6 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/pending_transaction/index.html.eex:4 -#: lib/block_scout_web/templates/pending_transaction/index.html.eex:8 msgid "Pending Transactions" msgstr "" @@ -735,12 +732,6 @@ msgstr "" msgid "Show QR Code" msgstr "" -#, elixir-format -#: lib/block_scout_web/templates/pending_transaction/index.html.eex:6 -#: lib/block_scout_web/templates/transaction/index.html.eex:6 -msgid "Showing" -msgstr "" - #, elixir-format #: lib/block_scout_web/templates/transaction/_emission_reward_tile.html.eex:8 #: lib/block_scout_web/views/transaction_view.ex:210 @@ -765,33 +756,33 @@ msgid "There are no holders for this Token." msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_internal_transaction/index.html.eex:61 +#: lib/block_scout_web/templates/address_internal_transaction/index.html.eex:65 msgid "There are no internal transactions for this address." msgstr "" #, elixir-format #: -#: lib/block_scout_web/templates/transaction_internal_transaction/index.html.eex:13 +#: lib/block_scout_web/templates/transaction_internal_transaction/index.html.eex:22 msgid "There are no internal transactions for this transaction." msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction_log/index.html.eex:138 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:147 msgid "There are no logs for this transaction." msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_token_transfer/index.html.eex:19 +#: lib/block_scout_web/templates/address_token_transfer/index.html.eex:23 msgid "There are no token transfers for this address." msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction_token_transfer/index.html.eex:14 +#: lib/block_scout_web/templates/transaction_token_transfer/index.html.eex:23 msgid "There are no token transfers for this transaction." msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_token/index.html.eex:15 +#: lib/block_scout_web/templates/address_token/index.html.eex:24 msgid "There are no tokens for this address." msgstr "" @@ -801,17 +792,17 @@ msgid "There are no tokens." msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_transaction/index.html.eex:57 +#: lib/block_scout_web/templates/address_transaction/index.html.eex:62 msgid "There are no transactions for this address." msgstr "" #, elixir-format -#: lib/block_scout_web/templates/block_transaction/index.html.eex:26 +#: lib/block_scout_web/templates/block_transaction/index.html.eex:35 msgid "There are no transactions for this block." msgstr "" #, elixir-format -#: lib/block_scout_web/templates/tokens/transfer/index.html.eex:21 +#: lib/block_scout_web/templates/tokens/transfer/index.html.eex:25 msgid "There are no transfers for this Token." msgstr "" @@ -821,8 +812,8 @@ msgid "This transaction is pending confirmation." msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_internal_transaction/index.html.eex:31 -#: lib/block_scout_web/templates/address_transaction/index.html.eex:27 +#: lib/block_scout_web/templates/address_internal_transaction/index.html.eex:33 +#: lib/block_scout_web/templates/address_transaction/index.html.eex:29 #: lib/block_scout_web/views/address_internal_transaction_view.ex:6 #: lib/block_scout_web/views/address_transaction_view.ex:6 msgid "To" @@ -883,7 +874,7 @@ msgid "Top Accounts - %{subnetwork} Explorer" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction_log/index.html.eex:94 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:103 msgid "Topics" msgstr "" @@ -925,7 +916,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/address/_tabs.html.eex:3 -#: lib/block_scout_web/templates/address_transaction/index.html.eex:50 +#: lib/block_scout_web/templates/address_transaction/index.html.eex:15 #: lib/block_scout_web/templates/block_transaction/index.html.eex:10 #: lib/block_scout_web/templates/block_transaction/index.html.eex:17 #: lib/block_scout_web/templates/chain/show.html.eex:108 @@ -977,7 +968,6 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/transaction/index.html.eex:4 -#: lib/block_scout_web/templates/transaction/index.html.eex:8 msgid "Validated Transactions" msgstr "" @@ -1074,11 +1064,6 @@ msgstr "" msgid "string" msgstr "" -#, elixir-format -#: lib/block_scout_web/templates/address/index.html.eex:21 -msgid "total addresses with a balance" -msgstr "" - #, elixir-format #: lib/block_scout_web/views/address_contract_view.ex:19 msgid "true" @@ -1118,9 +1103,9 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/address_read_contract/index.html.eex:14 -#: lib/block_scout_web/templates/address_token_transfer/index.html.eex:16 -#: lib/block_scout_web/templates/address_validation/index.html.eex:19 -#: lib/block_scout_web/templates/address_validation/index.html.eex:38 +#: lib/block_scout_web/templates/address_token_transfer/index.html.eex:19 +#: lib/block_scout_web/templates/address_validation/index.html.eex:22 +#: lib/block_scout_web/templates/address_validation/index.html.eex:47 #: lib/block_scout_web/templates/chain/show.html.eex:99 #: lib/block_scout_web/templates/chain/show.html.eex:125 #: lib/block_scout_web/templates/tokens/read_contract/index.html.eex:21 @@ -1143,22 +1128,22 @@ msgid "GraphQL" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_coin_balance/index.html.eex:60 -#: lib/block_scout_web/templates/address_internal_transaction/index.html.eex:69 -#: lib/block_scout_web/templates/address_internal_transaction/index.html.eex:80 -#: lib/block_scout_web/templates/address_token_transfer/index.html.eex:35 -#: lib/block_scout_web/templates/address_transaction/index.html.eex:66 -#: lib/block_scout_web/templates/address_transaction/index.html.eex:80 -#: lib/block_scout_web/templates/block/index.html.eex:15 -#: lib/block_scout_web/templates/block/index.html.eex:30 -#: lib/block_scout_web/templates/pending_transaction/index.html.eex:34 -#: lib/block_scout_web/templates/pending_transaction/index.html.eex:44 +#: lib/block_scout_web/templates/address_coin_balance/index.html.eex:66 +#: lib/block_scout_web/templates/address_internal_transaction/index.html.eex:73 +#: lib/block_scout_web/templates/address_internal_transaction/index.html.eex:90 +#: lib/block_scout_web/templates/address_token_transfer/index.html.eex:47 +#: lib/block_scout_web/templates/address_transaction/index.html.eex:71 +#: lib/block_scout_web/templates/address_transaction/index.html.eex:89 +#: lib/block_scout_web/templates/block/index.html.eex:19 +#: lib/block_scout_web/templates/block/index.html.eex:39 +#: lib/block_scout_web/templates/pending_transaction/index.html.eex:32 +#: lib/block_scout_web/templates/pending_transaction/index.html.eex:48 #: lib/block_scout_web/templates/tokens/holder/index.html.eex:33 #: lib/block_scout_web/templates/tokens/holder/index.html.eex:44 -#: lib/block_scout_web/templates/tokens/transfer/index.html.eex:29 -#: lib/block_scout_web/templates/tokens/transfer/index.html.eex:41 -#: lib/block_scout_web/templates/transaction/index.html.eex:38 -#: lib/block_scout_web/templates/transaction/index.html.eex:52 +#: lib/block_scout_web/templates/tokens/transfer/index.html.eex:34 +#: lib/block_scout_web/templates/tokens/transfer/index.html.eex:52 +#: lib/block_scout_web/templates/transaction/index.html.eex:36 +#: lib/block_scout_web/templates/transaction/index.html.eex:54 msgid "Loading" msgstr "" @@ -1253,18 +1238,18 @@ msgid "Static Call" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction_log/index.html.eex:24 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:33 msgid "Decoded" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction_log/index.html.eex:57 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:66 msgid "Indexed?" msgstr "" #, elixir-format #: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:17 -#: lib/block_scout_web/templates/transaction_log/index.html.eex:56 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:65 msgid "Type" msgstr "" @@ -1274,7 +1259,7 @@ msgid "Method Id" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction_log/index.html.eex:29 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:38 msgid "To see decoded input data, the contract must be verified." msgstr "" @@ -1290,13 +1275,13 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/transaction/_decoded_input.html.eex:11 -#: lib/block_scout_web/templates/transaction_log/index.html.eex:32 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:41 msgid "Verify the contract " msgstr "" #, elixir-format #: lib/block_scout_web/templates/transaction/_decoded_input.html.eex:11 -#: lib/block_scout_web/templates/transaction_log/index.html.eex:32 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:41 msgid "here" msgstr "" @@ -1312,41 +1297,41 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:28 -#: lib/block_scout_web/templates/transaction_log/index.html.eex:68 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:77 msgid "Copy Value" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction_log/index.html.eex:39 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:48 msgid "Failed to decode log data." msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction_log/index.html.eex:52 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:61 msgid "Log Data" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_coin_balance/index.html.eex:32 -#: lib/block_scout_web/templates/address_internal_transaction/index.html.eex:57 -#: lib/block_scout_web/templates/address_token_transfer/index.html.eex:23 -#: lib/block_scout_web/templates/address_transaction/index.html.eex:52 -#: lib/block_scout_web/templates/address_validation/index.html.eex:26 +#: lib/block_scout_web/templates/address_coin_balance/index.html.eex:34 +#: lib/block_scout_web/templates/address_internal_transaction/index.html.eex:61 +#: lib/block_scout_web/templates/address_token_transfer/index.html.eex:28 +#: lib/block_scout_web/templates/address_transaction/index.html.eex:57 +#: lib/block_scout_web/templates/address_validation/index.html.eex:29 #: lib/block_scout_web/templates/chain/show.html.eex:91 -#: lib/block_scout_web/templates/pending_transaction/index.html.eex:21 +#: lib/block_scout_web/templates/pending_transaction/index.html.eex:19 #: lib/block_scout_web/templates/tokens/holder/index.html.eex:19 -#: lib/block_scout_web/templates/tokens/transfer/index.html.eex:17 -#: lib/block_scout_web/templates/transaction/index.html.eex:22 +#: lib/block_scout_web/templates/tokens/transfer/index.html.eex:20 +#: lib/block_scout_web/templates/transaction/index.html.eex:20 msgid "Something went wrong, click to reload." msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_validation/index.html.eex:22 +#: lib/block_scout_web/templates/address_validation/index.html.eex:25 msgid "There are no blocks validated by this address." msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction/index.html.eex:28 +#: lib/block_scout_web/templates/transaction/index.html.eex:26 msgid "There are no transactions." msgstr "" @@ -1367,34 +1352,34 @@ msgid "Coin Balance History" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_coin_balance/index.html.eex:46 +#: lib/block_scout_web/templates/address_coin_balance/index.html.eex:48 msgid "Loading balances" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_coin_balance/index.html.eex:21 +#: lib/block_scout_web/templates/address_coin_balance/index.html.eex:22 #: lib/block_scout_web/templates/chain/show.html.eex:13 msgid "Loading chart" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_coin_balance/index.html.eex:37 +#: lib/block_scout_web/templates/address_coin_balance/index.html.eex:39 msgid "There is no coin history for this address." msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_coin_balance/index.html.eex:24 +#: lib/block_scout_web/templates/address_coin_balance/index.html.eex:25 #: lib/block_scout_web/templates/chain/show.html.eex:16 msgid "There was a problem loading the chart." msgstr "" #, elixir-format -#: lib/block_scout_web/templates/pending_transaction/index.html.eex:25 +#: lib/block_scout_web/templates/pending_transaction/index.html.eex:23 msgid "There are no pending transactions." msgstr "" #, elixir-format -#: lib/block_scout_web/templates/block/index.html.eex:19 +#: lib/block_scout_web/templates/block/index.html.eex:23 msgid "There are no blocks." msgstr "" @@ -1727,33 +1712,36 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/transaction/_tabs.html.eex:24 -#: lib/block_scout_web/templates/transaction_raw_trace/index.html.eex:10 +#: lib/block_scout_web/templates/transaction_raw_trace/index.html.eex:7 #: lib/block_scout_web/views/transaction_view.ex:341 msgid "Raw Trace" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address/index.html.eex:22 -msgid " (page" +#: lib/block_scout_web/templates/chain/show.html.eex:64 +msgid "Total blocks" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address/index.html.eex:19 -msgid " addresses of" +#: +#: lib/block_scout_web/templates/common_components/_pagination_container.html.eex:37 +msgid "Page" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address/index.html.eex:11 -#: lib/block_scout_web/templates/address/index.html.eex:41 -msgid "Back" +#: +#: lib/block_scout_web/templates/common_components/_pagination_container.html.eex:11 +msgid "Records" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address/index.html.eex:17 -msgid "Showing " +#: +#: lib/block_scout_web/templates/common_components/_pagination_container.html.eex:5 +msgid "Show" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/chain/show.html.eex:64 -msgid "Total blocks" +#: +#: lib/block_scout_web/templates/common_components/_pagination_container.html.eex:37 +msgid "of" msgstr "" 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 db0457f814..8925a95acf 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 @@ -28,7 +28,7 @@ msgid "%{block_type} Height:" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/block/index.html.eex:9 +#: lib/block_scout_web/templates/block/index.html.eex:10 msgid "%{block_type}s" msgstr "" @@ -98,20 +98,20 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/address/_validator_metadata_modal.html.eex:16 -#: lib/block_scout_web/templates/transaction_log/index.html.eex:13 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:22 #: lib/block_scout_web/views/address_view.ex:101 msgid "Address" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address/index.html.eex:15 +#: lib/block_scout_web/templates/address/index.html.eex:4 #: lib/block_scout_web/templates/tokens/overview/_details.html.eex:59 msgid "Addresses" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_internal_transaction/index.html.eex:25 -#: lib/block_scout_web/templates/address_transaction/index.html.eex:21 +#: lib/block_scout_web/templates/address_internal_transaction/index.html.eex:27 +#: lib/block_scout_web/templates/address_transaction/index.html.eex:23 #: lib/block_scout_web/views/address_internal_transaction_view.ex:8 #: lib/block_scout_web/views/address_transaction_view.ex:8 msgid "All" @@ -245,8 +245,8 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/address_transaction/index.html.eex:11 -#: lib/block_scout_web/templates/pending_transaction/index.html.eex:17 -#: lib/block_scout_web/templates/transaction/index.html.eex:17 +#: lib/block_scout_web/templates/pending_transaction/index.html.eex:15 +#: lib/block_scout_web/templates/transaction/index.html.eex:15 msgid "Connection Lost, click to load newer transactions" msgstr "" @@ -335,8 +335,8 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:18 -#: lib/block_scout_web/templates/transaction_log/index.html.eex:58 -#: lib/block_scout_web/templates/transaction_log/index.html.eex:124 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:67 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:133 msgid "Data" msgstr "" @@ -414,8 +414,8 @@ msgid "Forked Blocks (Reorgs)" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_internal_transaction/index.html.eex:42 -#: lib/block_scout_web/templates/address_transaction/index.html.eex:38 +#: lib/block_scout_web/templates/address_internal_transaction/index.html.eex:44 +#: lib/block_scout_web/templates/address_transaction/index.html.eex:40 #: lib/block_scout_web/views/address_internal_transaction_view.ex:7 #: lib/block_scout_web/views/address_transaction_view.ex:7 msgid "From" @@ -479,7 +479,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/address/_tabs.html.eex:14 -#: lib/block_scout_web/templates/address_internal_transaction/index.html.eex:55 +#: lib/block_scout_web/templates/address_internal_transaction/index.html.eex:19 #: lib/block_scout_web/templates/transaction/_tabs.html.eex:11 #: lib/block_scout_web/templates/transaction_internal_transaction/index.html.eex:6 #: lib/block_scout_web/views/address_view.ex:297 @@ -547,8 +547,8 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/chain/show.html.eex:111 -#: lib/block_scout_web/templates/pending_transaction/index.html.eex:12 -#: lib/block_scout_web/templates/transaction/index.html.eex:12 +#: lib/block_scout_web/templates/pending_transaction/index.html.eex:10 +#: lib/block_scout_web/templates/transaction/index.html.eex:10 msgid "More transactions have come in" msgstr "" @@ -561,7 +561,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/api_docs/_action_tile.html.eex:52 #: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:16 -#: lib/block_scout_web/templates/transaction_log/index.html.eex:55 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:64 msgid "Name" msgstr "" @@ -572,15 +572,13 @@ msgstr "" #, elixir-format #: -#: lib/block_scout_web/templates/transaction_internal_transaction/index.html.eex:19 -#: lib/block_scout_web/templates/transaction_log/index.html.eex:144 +#: lib/block_scout_web/templates/transaction_internal_transaction/index.html.eex:37 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:162 msgid "Newer" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address/index.html.eex:6 -#: lib/block_scout_web/templates/address/index.html.eex:36 -#: lib/block_scout_web/templates/address_token/index.html.eex:22 +#: lib/block_scout_web/templates/address_token/index.html.eex:39 msgid "Next" msgstr "" @@ -608,17 +606,17 @@ msgid "OUT" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_coin_balance/index.html.eex:52 -#: lib/block_scout_web/templates/address_internal_transaction/index.html.eex:73 -#: lib/block_scout_web/templates/address_token_transfer/index.html.eex:28 -#: lib/block_scout_web/templates/address_transaction/index.html.eex:72 -#: lib/block_scout_web/templates/address_validation/index.html.eex:31 -#: lib/block_scout_web/templates/block/index.html.eex:23 -#: lib/block_scout_web/templates/block_transaction/index.html.eex:32 -#: lib/block_scout_web/templates/pending_transaction/index.html.eex:37 -#: lib/block_scout_web/templates/tokens/transfer/index.html.eex:34 -#: lib/block_scout_web/templates/transaction/index.html.eex:44 -#: lib/block_scout_web/templates/transaction_token_transfer/index.html.eex:21 +#: lib/block_scout_web/templates/address_coin_balance/index.html.eex:57 +#: lib/block_scout_web/templates/address_internal_transaction/index.html.eex:81 +#: lib/block_scout_web/templates/address_token_transfer/index.html.eex:38 +#: lib/block_scout_web/templates/address_transaction/index.html.eex:80 +#: lib/block_scout_web/templates/address_validation/index.html.eex:38 +#: lib/block_scout_web/templates/block/index.html.eex:30 +#: lib/block_scout_web/templates/block_transaction/index.html.eex:50 +#: lib/block_scout_web/templates/pending_transaction/index.html.eex:39 +#: lib/block_scout_web/templates/tokens/transfer/index.html.eex:43 +#: lib/block_scout_web/templates/transaction/index.html.eex:45 +#: lib/block_scout_web/templates/transaction_token_transfer/index.html.eex:38 msgid "Older" msgstr "" @@ -656,7 +654,6 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/pending_transaction/index.html.eex:4 -#: lib/block_scout_web/templates/pending_transaction/index.html.eex:8 msgid "Pending Transactions" msgstr "" @@ -735,12 +732,6 @@ msgstr "" msgid "Show QR Code" msgstr "" -#, elixir-format -#: lib/block_scout_web/templates/pending_transaction/index.html.eex:6 -#: lib/block_scout_web/templates/transaction/index.html.eex:6 -msgid "Showing" -msgstr "" - #, elixir-format #: lib/block_scout_web/templates/transaction/_emission_reward_tile.html.eex:8 #: lib/block_scout_web/views/transaction_view.ex:210 @@ -765,33 +756,33 @@ msgid "There are no holders for this Token." msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_internal_transaction/index.html.eex:61 +#: lib/block_scout_web/templates/address_internal_transaction/index.html.eex:65 msgid "There are no internal transactions for this address." msgstr "" #, elixir-format #: -#: lib/block_scout_web/templates/transaction_internal_transaction/index.html.eex:13 +#: lib/block_scout_web/templates/transaction_internal_transaction/index.html.eex:22 msgid "There are no internal transactions for this transaction." msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction_log/index.html.eex:138 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:147 msgid "There are no logs for this transaction." msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_token_transfer/index.html.eex:19 +#: lib/block_scout_web/templates/address_token_transfer/index.html.eex:23 msgid "There are no token transfers for this address." msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction_token_transfer/index.html.eex:14 +#: lib/block_scout_web/templates/transaction_token_transfer/index.html.eex:23 msgid "There are no token transfers for this transaction." msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_token/index.html.eex:15 +#: lib/block_scout_web/templates/address_token/index.html.eex:24 msgid "There are no tokens for this address." msgstr "" @@ -801,17 +792,17 @@ msgid "There are no tokens." msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_transaction/index.html.eex:57 +#: lib/block_scout_web/templates/address_transaction/index.html.eex:62 msgid "There are no transactions for this address." msgstr "" #, elixir-format -#: lib/block_scout_web/templates/block_transaction/index.html.eex:26 +#: lib/block_scout_web/templates/block_transaction/index.html.eex:35 msgid "There are no transactions for this block." msgstr "" #, elixir-format -#: lib/block_scout_web/templates/tokens/transfer/index.html.eex:21 +#: lib/block_scout_web/templates/tokens/transfer/index.html.eex:25 msgid "There are no transfers for this Token." msgstr "" @@ -821,8 +812,8 @@ msgid "This transaction is pending confirmation." msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_internal_transaction/index.html.eex:31 -#: lib/block_scout_web/templates/address_transaction/index.html.eex:27 +#: lib/block_scout_web/templates/address_internal_transaction/index.html.eex:33 +#: lib/block_scout_web/templates/address_transaction/index.html.eex:29 #: lib/block_scout_web/views/address_internal_transaction_view.ex:6 #: lib/block_scout_web/views/address_transaction_view.ex:6 msgid "To" @@ -883,7 +874,7 @@ msgid "Top Accounts - %{subnetwork} Explorer" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction_log/index.html.eex:94 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:103 msgid "Topics" msgstr "" @@ -925,7 +916,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/address/_tabs.html.eex:3 -#: lib/block_scout_web/templates/address_transaction/index.html.eex:50 +#: lib/block_scout_web/templates/address_transaction/index.html.eex:15 #: lib/block_scout_web/templates/block_transaction/index.html.eex:10 #: lib/block_scout_web/templates/block_transaction/index.html.eex:17 #: lib/block_scout_web/templates/chain/show.html.eex:108 @@ -977,7 +968,6 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/transaction/index.html.eex:4 -#: lib/block_scout_web/templates/transaction/index.html.eex:8 msgid "Validated Transactions" msgstr "" @@ -1074,11 +1064,6 @@ msgstr "" msgid "string" msgstr "" -#, elixir-format -#: lib/block_scout_web/templates/address/index.html.eex:21 -msgid "total addresses with a balance" -msgstr "" - #, elixir-format #: lib/block_scout_web/views/address_contract_view.ex:19 msgid "true" @@ -1118,9 +1103,9 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/address_read_contract/index.html.eex:14 -#: lib/block_scout_web/templates/address_token_transfer/index.html.eex:16 -#: lib/block_scout_web/templates/address_validation/index.html.eex:19 -#: lib/block_scout_web/templates/address_validation/index.html.eex:38 +#: lib/block_scout_web/templates/address_token_transfer/index.html.eex:19 +#: lib/block_scout_web/templates/address_validation/index.html.eex:22 +#: lib/block_scout_web/templates/address_validation/index.html.eex:47 #: lib/block_scout_web/templates/chain/show.html.eex:99 #: lib/block_scout_web/templates/chain/show.html.eex:125 #: lib/block_scout_web/templates/tokens/read_contract/index.html.eex:21 @@ -1143,22 +1128,22 @@ msgid "GraphQL" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_coin_balance/index.html.eex:60 -#: lib/block_scout_web/templates/address_internal_transaction/index.html.eex:69 -#: lib/block_scout_web/templates/address_internal_transaction/index.html.eex:80 -#: lib/block_scout_web/templates/address_token_transfer/index.html.eex:35 -#: lib/block_scout_web/templates/address_transaction/index.html.eex:66 -#: lib/block_scout_web/templates/address_transaction/index.html.eex:80 -#: lib/block_scout_web/templates/block/index.html.eex:15 -#: lib/block_scout_web/templates/block/index.html.eex:30 -#: lib/block_scout_web/templates/pending_transaction/index.html.eex:34 -#: lib/block_scout_web/templates/pending_transaction/index.html.eex:44 +#: lib/block_scout_web/templates/address_coin_balance/index.html.eex:66 +#: lib/block_scout_web/templates/address_internal_transaction/index.html.eex:73 +#: lib/block_scout_web/templates/address_internal_transaction/index.html.eex:90 +#: lib/block_scout_web/templates/address_token_transfer/index.html.eex:47 +#: lib/block_scout_web/templates/address_transaction/index.html.eex:71 +#: lib/block_scout_web/templates/address_transaction/index.html.eex:89 +#: lib/block_scout_web/templates/block/index.html.eex:19 +#: lib/block_scout_web/templates/block/index.html.eex:39 +#: lib/block_scout_web/templates/pending_transaction/index.html.eex:32 +#: lib/block_scout_web/templates/pending_transaction/index.html.eex:48 #: lib/block_scout_web/templates/tokens/holder/index.html.eex:33 #: lib/block_scout_web/templates/tokens/holder/index.html.eex:44 -#: lib/block_scout_web/templates/tokens/transfer/index.html.eex:29 -#: lib/block_scout_web/templates/tokens/transfer/index.html.eex:41 -#: lib/block_scout_web/templates/transaction/index.html.eex:38 -#: lib/block_scout_web/templates/transaction/index.html.eex:52 +#: lib/block_scout_web/templates/tokens/transfer/index.html.eex:34 +#: lib/block_scout_web/templates/tokens/transfer/index.html.eex:52 +#: lib/block_scout_web/templates/transaction/index.html.eex:36 +#: lib/block_scout_web/templates/transaction/index.html.eex:54 msgid "Loading" msgstr "" @@ -1253,18 +1238,18 @@ msgid "Static Call" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction_log/index.html.eex:24 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:33 msgid "Decoded" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction_log/index.html.eex:57 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:66 msgid "Indexed?" msgstr "" #, elixir-format #: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:17 -#: lib/block_scout_web/templates/transaction_log/index.html.eex:56 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:65 msgid "Type" msgstr "" @@ -1274,7 +1259,7 @@ msgid "Method Id" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction_log/index.html.eex:29 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:38 msgid "To see decoded input data, the contract must be verified." msgstr "" @@ -1290,13 +1275,13 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/transaction/_decoded_input.html.eex:11 -#: lib/block_scout_web/templates/transaction_log/index.html.eex:32 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:41 msgid "Verify the contract " msgstr "" #, elixir-format #: lib/block_scout_web/templates/transaction/_decoded_input.html.eex:11 -#: lib/block_scout_web/templates/transaction_log/index.html.eex:32 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:41 msgid "here" msgstr "" @@ -1312,41 +1297,41 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:28 -#: lib/block_scout_web/templates/transaction_log/index.html.eex:68 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:77 msgid "Copy Value" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction_log/index.html.eex:39 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:48 msgid "Failed to decode log data." msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction_log/index.html.eex:52 +#: lib/block_scout_web/templates/transaction_log/index.html.eex:61 msgid "Log Data" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_coin_balance/index.html.eex:32 -#: lib/block_scout_web/templates/address_internal_transaction/index.html.eex:57 -#: lib/block_scout_web/templates/address_token_transfer/index.html.eex:23 -#: lib/block_scout_web/templates/address_transaction/index.html.eex:52 -#: lib/block_scout_web/templates/address_validation/index.html.eex:26 +#: lib/block_scout_web/templates/address_coin_balance/index.html.eex:34 +#: lib/block_scout_web/templates/address_internal_transaction/index.html.eex:61 +#: lib/block_scout_web/templates/address_token_transfer/index.html.eex:28 +#: lib/block_scout_web/templates/address_transaction/index.html.eex:57 +#: lib/block_scout_web/templates/address_validation/index.html.eex:29 #: lib/block_scout_web/templates/chain/show.html.eex:91 -#: lib/block_scout_web/templates/pending_transaction/index.html.eex:21 +#: lib/block_scout_web/templates/pending_transaction/index.html.eex:19 #: lib/block_scout_web/templates/tokens/holder/index.html.eex:19 -#: lib/block_scout_web/templates/tokens/transfer/index.html.eex:17 -#: lib/block_scout_web/templates/transaction/index.html.eex:22 +#: lib/block_scout_web/templates/tokens/transfer/index.html.eex:20 +#: lib/block_scout_web/templates/transaction/index.html.eex:20 msgid "Something went wrong, click to reload." msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_validation/index.html.eex:22 +#: lib/block_scout_web/templates/address_validation/index.html.eex:25 msgid "There are no blocks validated by this address." msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction/index.html.eex:28 +#: lib/block_scout_web/templates/transaction/index.html.eex:26 msgid "There are no transactions." msgstr "" @@ -1367,34 +1352,34 @@ msgid "Coin Balance History" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_coin_balance/index.html.eex:46 +#: lib/block_scout_web/templates/address_coin_balance/index.html.eex:48 msgid "Loading balances" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_coin_balance/index.html.eex:21 +#: lib/block_scout_web/templates/address_coin_balance/index.html.eex:23 #: lib/block_scout_web/templates/chain/show.html.eex:13 msgid "Loading chart" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_coin_balance/index.html.eex:37 +#: lib/block_scout_web/templates/address_coin_balance/index.html.eex:39 msgid "There is no coin history for this address." msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_coin_balance/index.html.eex:24 +#: lib/block_scout_web/templates/address_coin_balance/index.html.eex:26 #: lib/block_scout_web/templates/chain/show.html.eex:16 msgid "There was a problem loading the chart." msgstr "" #, elixir-format -#: lib/block_scout_web/templates/pending_transaction/index.html.eex:25 +#: lib/block_scout_web/templates/pending_transaction/index.html.eex:23 msgid "There are no pending transactions." msgstr "" #, elixir-format -#: lib/block_scout_web/templates/block/index.html.eex:19 +#: lib/block_scout_web/templates/block/index.html.eex:23 msgid "There are no blocks." msgstr "" @@ -1727,33 +1712,36 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/transaction/_tabs.html.eex:24 -#: lib/block_scout_web/templates/transaction_raw_trace/index.html.eex:10 +#: lib/block_scout_web/templates/transaction_raw_trace/index.html.eex:7 #: lib/block_scout_web/views/transaction_view.ex:341 msgid "Raw Trace" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address/index.html.eex:22 -msgid " (page" +#: lib/block_scout_web/templates/chain/show.html.eex:64 +msgid "Total blocks" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address/index.html.eex:19 -msgid " addresses of" +#: +#: lib/block_scout_web/templates/common_components/_pagination_container.html.eex:37 +msgid "Page" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address/index.html.eex:11 -#: lib/block_scout_web/templates/address/index.html.eex:41 -msgid "Back" +#: +#: lib/block_scout_web/templates/common_components/_pagination_container.html.eex:11 +msgid "Records" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address/index.html.eex:17 -msgid "Showing " +#: +#: lib/block_scout_web/templates/common_components/_pagination_container.html.eex:5 +msgid "Show" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/chain/show.html.eex:64 -msgid "Total blocks" +#: +#: lib/block_scout_web/templates/common_components/_pagination_container.html.eex:37 +msgid "of" msgstr "" diff --git a/apps/block_scout_web/test/block_scout_web/controllers/api/rpc/address_controller_test.exs b/apps/block_scout_web/test/block_scout_web/controllers/api/rpc/address_controller_test.exs index 6e0eccc7c0..b3b8f0b08b 100644 --- a/apps/block_scout_web/test/block_scout_web/controllers/api/rpc/address_controller_test.exs +++ b/apps/block_scout_web/test/block_scout_web/controllers/api/rpc/address_controller_test.exs @@ -1,13 +1,44 @@ defmodule BlockScoutWeb.API.RPC.AddressControllerTest do - use BlockScoutWeb.ConnCase + use BlockScoutWeb.ConnCase, async: false + import Mox + + alias BlockScoutWeb.API.RPC.AddressController alias Explorer.Chain + alias Explorer.Chain.{BlockNumberCache, Events.Subscriber, Transaction, Wei} + alias Explorer.Counters.{AddressesWithBalanceCounter, AverageBlockTime} + alias Indexer.Fetcher.CoinBalanceOnDemand alias Explorer.Repo - alias Explorer.Chain.{Transaction, Wei} - alias BlockScoutWeb.API.RPC.AddressController + + setup :set_mox_global + setup :verify_on_exit! + + setup do + mocked_json_rpc_named_arguments = [ + transport: EthereumJSONRPC.Mox, + transport_options: [] + ] + + start_supervised!({Task.Supervisor, name: Indexer.TaskSupervisor}) + start_supervised!(AverageBlockTime) + start_supervised!({CoinBalanceOnDemand, [mocked_json_rpc_named_arguments, [name: CoinBalanceOnDemand]]}) + start_supervised!(AddressesWithBalanceCounter) + + Application.put_env(:explorer, AverageBlockTime, enabled: true) + BlockNumberCache.setup(cache_period: 0) + + on_exit(fn -> + Application.put_env(:explorer, AverageBlockTime, enabled: false) + end) + + :ok + end describe "listaccounts" do setup do + Subscriber.to(:addresses, :on_demand) + Subscriber.to(:address_coin_balances, :on_demand) + %{params: %{"module" => "account", "action" => "listaccounts"}} end @@ -47,6 +78,73 @@ defmodule BlockScoutWeb.API.RPC.AddressControllerTest do } ] = response["result"] end + + test "with a stale balance", %{conn: conn, params: params} do + now = Timex.now() + + mining_address = + insert(:address, + fetched_coin_balance: 0, + fetched_coin_balance_block_number: 2, + inserted_at: Timex.shift(now, minutes: -10) + ) + + mining_address_hash = to_string(mining_address.hash) + # we space these very far apart so that we know it will consider the 0th block stale (it calculates how far + # back we'd need to go to get 24 hours in the past) + insert(:block, number: 0, timestamp: Timex.shift(now, hours: -50), miner: mining_address) + insert(:block, number: 1, timestamp: Timex.shift(now, hours: -25), miner: mining_address) + AverageBlockTime.refresh() + + address = + insert(:address, + fetched_coin_balance: 100, + fetched_coin_balance_block_number: 0, + inserted_at: Timex.shift(now, minutes: -5) + ) + + address_hash = to_string(address.hash) + + expect(EthereumJSONRPC.Mox, :json_rpc, 1, fn [ + %{ + id: id, + method: "eth_getBalance", + params: [^address_hash, "0x1"] + } + ], + _options -> + {:ok, [%{id: id, jsonrpc: "2.0", result: "0x02"}]} + end) + + response = + conn + |> get("/api", params) + |> json_response(200) + + assert response["message"] == "OK" + assert response["status"] == "1" + + assert [ + %{ + "address" => ^mining_address_hash, + "balance" => "0", + "stale" => false + }, + %{ + "address" => ^address_hash, + "balance" => "100", + "stale" => true + } + ] = response["result"] + + {:ok, expected_wei} = Wei.cast(2) + + assert_receive({:chain_event, :addresses, :on_demand, [received_address]}) + + assert received_address.hash == address.hash + assert received_address.fetched_coin_balance == expected_wei + assert received_address.fetched_coin_balance_block_number == 1 + end end describe "balance" do @@ -140,7 +238,7 @@ defmodule BlockScoutWeb.API.RPC.AddressControllerTest do expected_result = Enum.map(addresses, fn address -> - %{"account" => "#{address.hash}", "balance" => "#{address.fetched_coin_balance.value}"} + %{"account" => "#{address.hash}", "balance" => "#{address.fetched_coin_balance.value}", "stale" => false} end) assert response = @@ -209,8 +307,8 @@ defmodule BlockScoutWeb.API.RPC.AddressControllerTest do } expected_result = [ - %{"account" => address1, "balance" => "0"}, - %{"account" => address2, "balance" => "0"} + %{"account" => address1, "balance" => "0", "stale" => false}, + %{"account" => address2, "balance" => "0", "stale" => false} ] assert response = @@ -242,7 +340,7 @@ defmodule BlockScoutWeb.API.RPC.AddressControllerTest do expected_result = Enum.map(addresses, fn address -> - %{"account" => "#{address.hash}", "balance" => "#{address.fetched_coin_balance.value}"} + %{"account" => "#{address.hash}", "balance" => "#{address.fetched_coin_balance.value}", "stale" => false} end) assert response = @@ -266,8 +364,8 @@ defmodule BlockScoutWeb.API.RPC.AddressControllerTest do } expected_result = [ - %{"account" => address2_hash, "balance" => "0"}, - %{"account" => "#{address1.hash}", "balance" => "#{address1.fetched_coin_balance.value}"} + %{"account" => address2_hash, "balance" => "0", "stale" => false}, + %{"account" => "#{address1.hash}", "balance" => "#{address1.fetched_coin_balance.value}", "stale" => false} ] assert response = @@ -314,7 +412,7 @@ defmodule BlockScoutWeb.API.RPC.AddressControllerTest do } expected_result = [ - %{"account" => "#{address.hash}", "balance" => "#{address.fetched_coin_balance.value}"} + %{"account" => "#{address.hash}", "balance" => "#{address.fetched_coin_balance.value}", "stale" => false} ] assert response = diff --git a/apps/explorer/lib/explorer/chain/address.ex b/apps/explorer/lib/explorer/chain/address.ex index be2866fa35..a565306fd7 100644 --- a/apps/explorer/lib/explorer/chain/address.ex +++ b/apps/explorer/lib/explorer/chain/address.ex @@ -76,6 +76,7 @@ defmodule Explorer.Chain.Address do field(:contract_code, Data) field(:nonce, :integer) field(:has_decompiled_code?, :boolean, virtual: true) + field(:stale?, :boolean, virtual: true) has_one(:smart_contract, SmartContract) has_one(:token, Token, foreign_key: :contract_address_hash)