Merge branch 'master' into vb-bytecode-twin-at-api

pull/3637/head
Victor Baranov 4 years ago committed by GitHub
commit 4a597efdb8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      CHANGELOG.md
  2. 1
      apps/block_scout_web/assets/css/components/_dropdown.scss
  3. 44
      apps/block_scout_web/assets/css/components/_form.scss
  4. 20
      apps/block_scout_web/assets/css/components/_label.scss
  5. 27
      apps/block_scout_web/assets/css/components/_tile.scss
  6. 3
      apps/block_scout_web/assets/css/theme/_dark-theme.scss
  7. 50
      apps/block_scout_web/assets/js/pages/token/search.js
  8. 3
      apps/block_scout_web/assets/webpack.config.js
  9. 3
      apps/block_scout_web/config/config.exs
  10. 73
      apps/block_scout_web/lib/block_scout_web/controllers/tokens/bridged_tokens_controller.ex
  11. 12
      apps/block_scout_web/lib/block_scout_web/controllers/tokens/tokens_controller.ex
  12. 2
      apps/block_scout_web/lib/block_scout_web/templates/address/overview.html.eex
  13. 6
      apps/block_scout_web/lib/block_scout_web/templates/bridged_tokens/_tile.html.eex
  14. 12
      apps/block_scout_web/lib/block_scout_web/templates/bridged_tokens/index.html.eex
  15. 3
      apps/block_scout_web/lib/block_scout_web/templates/form/_tag.html.eex
  16. 2
      apps/block_scout_web/lib/block_scout_web/templates/layout/_footer.html.eex
  17. 13
      apps/block_scout_web/lib/block_scout_web/templates/layout/_topnav.html.eex
  18. 2
      apps/block_scout_web/lib/block_scout_web/templates/tokens/_tile.html.eex
  19. 13
      apps/block_scout_web/lib/block_scout_web/templates/tokens/index.html.eex
  20. 25
      apps/block_scout_web/lib/block_scout_web/templates/tokens/overview/_details.html.eex
  21. 1
      apps/block_scout_web/lib/block_scout_web/views/bridged_tokens_view.ex
  22. 3
      apps/block_scout_web/lib/block_scout_web/views/tokens/overview_view.ex
  23. 7
      apps/block_scout_web/lib/block_scout_web/views/tokens_view.ex
  24. 2
      apps/block_scout_web/lib/block_scout_web/web_router.ex
  25. 73
      apps/block_scout_web/priv/gettext/default.pot
  26. 73
      apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po
  27. 121
      apps/explorer/lib/explorer/chain.ex
  28. 1
      apps/explorer/lib/explorer/exchange_rates/source/coin_gecko.ex
  29. 5
      apps/indexer/lib/indexer/supervisor.ex

@ -2,6 +2,8 @@
### Features
- [#3637](https://github.com/poanetwork/blockscout/pull/3637) - getsourcecode API endpoint: show data for unverified contract from verified contract with the same bytecode
- [#3631](https://github.com/poanetwork/blockscout/pull/3631) - Tokens search
- [#3631](https://github.com/poanetwork/blockscout/pull/3631) - BSC OMNI bridge support
- [#3603](https://github.com/poanetwork/blockscout/pull/3603) - Display method output parameter name at contract read page
- [#3597](https://github.com/poanetwork/blockscout/pull/3597) - Show APY for delegators in Staking DApp
- [#3584](https://github.com/poanetwork/blockscout/pull/3584) - Token holders API endpoint
@ -20,6 +22,8 @@
- [#3577](https://github.com/poanetwork/blockscout/pull/3577) - Eliminate GraphiQL page XSS attack
### Chore
- [#3645](https://github.com/poanetwork/blockscout/pull/3645) - Change Twitter handle
- [#3644](https://github.com/poanetwork/blockscout/pull/3644) - Correct exchange rate for SURF.finance token
- [#3618](https://github.com/poanetwork/blockscout/pull/3618) - Contracts verification up to 10 libraries
- [#3616](https://github.com/poanetwork/blockscout/pull/3616) - POSDAO refactoring: use zero address instead of staker address for certain cases
- [#3612](https://github.com/poanetwork/blockscout/pull/3612) - POSDAO refactoring: use 'getDelegatorPools' getter instead of 'getStakerPools' in Staking DApp

@ -40,6 +40,7 @@ $dropdown-menu-item-hover-background: rgba($secondary, 0.1) !default;
font-size: 12px;
padding: 10px 20px;
transition: $transition-cont;
white-space: initial;
& {
&.active,

@ -112,3 +112,47 @@ $form-control-border-color-active: $primary !default;
}
}
}
.tokens-list-search-input-outer-container {
display: flex;
@include media-breakpoint-down(md) {
display: block;
}
}
.tokens-list-search-input-container {
float: right;
margin-left: auto;
position: relative;
@include media-breakpoint-down(md) {
width: 100%;
margin-bottom: 20px;
}
}
.tokens-list-search-input-container:before {
content: "";
position: absolute;
left: 10px;
top: 0;
bottom: 10px;
@include media-breakpoint-down(md) {
bottom: 0px;
}
width: 20px;
background: url("data:image/svg+xml,%3Csvg%20viewBox%3D%220%200%2016%2017%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2216%22%20height%3D%2217%22%3E%0A%20%20%20%20%3Cpath%20fill%3D%22%237DD79F%22%20fill-rule%3D%22evenodd%22%20d%3D%22M15.713%2015.727a.982.982%200%200%201-1.388%200l-2.289-2.29C10.773%2014.403%209.213%2015%207.5%2015A7.5%207.5%200%201%201%2015%207.5c0%201.719-.602%203.284-1.575%204.55l2.288%202.288a.983.983%200%200%201%200%201.389zM7.5%202a5.5%205.5%200%201%200%200%2011%205.5%205.5%200%201%200%200-11z%22%2F%3E%0A%3C%2Fsvg%3E") center / contain no-repeat;
}
.tokens-list-search-input-container.tokens:before {
bottom: 5px;
}
.tokens-list-search-input {
height: 40px;
width: 300px;
@include media-breakpoint-down(md) {
width: 100%;
}
padding: 10px 10px 10px 35px;
outline: none;
}

@ -1,10 +1,12 @@
.bs-label {
display: inline-block;
padding: 5px;
padding: 0 5px;
background: #f5f6fa;
color: #a3a9b5;
border-radius: 5px;
font-size: 10px;
height: 25px;
line-height: 25px;
&.right {
margin-left: auto;
float: right;
@ -17,6 +19,22 @@
background: $secondary;
color: #fff;
}
&.destination-eth {
background: #253358;
color: #fff;
}
&.destination-bsc {
background: #e7b941;
color: #fff;
}
&.bridged {
background: #70aee3;
color: #fff;
}
&.validator {
background: $primary;
color: #fff;
}
&.secondary {
background: $secondary;
color: #fff;

@ -578,3 +578,30 @@ $cube-quantity: 5;
.dark-theme-applied .dark-block-loader {
background-color: #313355;
}
.title-with-label {
display: inline-block;
vertical-align: middle;
margin-top: 3px;
@include media-breakpoint-down(sm) {
display: inline;
}
}
.view-original-token-container {
margin-top: 15px;
font-size: 12px;
}
.token-address-mobile {
@include media-breakpoint-down(sm) {
display: inline-block;
word-break: break-all;
}
}
.bridged-tokens-buttons-mobile {
@include media-breakpoint-down(sm) {
margin-top: 0.5em;
}
}

@ -1029,7 +1029,8 @@ $dark-stakes-banned-background: #3e314c;
color: #fff;
}
.bs-label.omni {
.bs-label.omni,
.bs-label.destination-eth {
background-color: $labels-dark;
}

@ -0,0 +1,50 @@
import $ from 'jquery'
import omit from 'lodash/omit'
import humps from 'humps'
import { createAsyncLoadStore } from '../../lib/async_listing_load'
import '../address'
const $searchInput = $('.tokens-list-search-input')
export const initialState = {
isSearch: false
}
export function reducer (state, action) {
switch (action.type) {
case 'PAGE_LOAD':
case 'ELEMENTS_LOAD': {
return Object.assign({}, state, omit(action, 'type'))
}
case 'START_SEARCH': {
return Object.assign({}, state, { pagesStack: [], isSearch: true })
}
default:
return state
}
}
if ($('[data-page="tokens"]').length) {
const store = createAsyncLoadStore(reducer, initialState, 'dataset.identifierLog')
store.dispatch({
type: 'PAGE_LOAD'
})
$searchInput.on('input', (event) => {
const value = $(event.target).val()
const loc = window.location.pathname
if (value.length >= 3 || value === '') {
$.ajax({
url: `${loc}?type=JSON&filter=${value}`,
type: 'GET',
dataType: 'json',
contentType: 'application/json; charset=utf-8'
}).done(response => store.dispatch(Object.assign({ type: 'ITEMS_FETCHED' }, humps.camelizeKeys(response))))
.fail(() => store.dispatch({ type: 'REQUEST_ERROR' }))
.always(() => store.dispatch({ type: 'FINISH_REQUEST' }))
}
})
}

@ -95,7 +95,8 @@ const appJs =
'try-api': './js/lib/try_api.js',
'try-eth-api': './js/lib/try_eth_api.js',
'async-listing-load': './js/lib/async_listing_load',
'non-critical': './css/non-critical.scss'
'non-critical': './css/non-critical.scss',
'tokens': './js/pages/token/search.js'
},
output: {
filename: '[name].js',

@ -35,7 +35,8 @@ config :block_scout_web,
api_url: System.get_env("API_URL"),
apps_menu: if(System.get_env("APPS_MENU", "false") == "true", do: true, else: false),
external_apps: System.get_env("EXTERNAL_APPS"),
omni_bridge_mediator: System.get_env("OMNI_BRIDGE_MEDIATOR"),
eth_omni_bridge_mediator: System.get_env("ETH_OMNI_BRIDGE_MEDIATOR"),
bsc_omni_bridge_mediator: System.get_env("BSC_OMNI_BRIDGE_MEDIATOR"),
amb_bridge_mediators: System.get_env("AMB_BRIDGE_MEDIATORS"),
foreign_json_rpc: System.get_env("FOREIGN_JSON_RPC", ""),
gas_price: System.get_env("GAS_PRICE", nil),

@ -7,11 +7,68 @@ defmodule BlockScoutWeb.BridgedTokensController do
alias Explorer.Chain
alias Phoenix.View
def show(conn, %{"type" => "JSON", "id" => "eth"} = params) do
get_items(conn, params, :eth)
end
def show(conn, %{"type" => "JSON", "id" => "bsc"} = params) do
get_items(conn, params, :bsc)
end
def show(conn, %{"id" => "eth"}) do
total_supply = Chain.total_supply()
render(conn, "index.html",
current_path: current_path(conn),
total_supply: total_supply,
chain: "Ethereum",
chain_id: 1
)
end
def show(conn, %{"id" => "bsc"}) do
total_supply = Chain.total_supply()
render(conn, "index.html",
current_path: current_path(conn),
total_supply: total_supply,
chain: "Binance Smart Chain",
chain_id: 56
)
end
def show(conn, _params) do
not_found(conn)
end
def index(conn, %{"type" => "JSON"} = params) do
tokens =
get_items(conn, params, :eth)
end
def index(conn, _params) do
total_supply = Chain.total_supply()
render(conn, "index.html",
current_path: current_path(conn),
total_supply: total_supply,
chain: "Ethereum",
chain_id: 1
)
end
defp get_items(conn, params, destination) do
filter =
if Map.has_key?(params, "filter") do
Map.get(params, "filter")
else
nil
end
paging_params =
params
|> paging_options()
|> Chain.list_top_bridged_tokens()
tokens = Chain.list_top_bridged_tokens(destination, filter, paging_params)
{tokens_page, next_page} = split_list_by_page(tokens)
@ -23,7 +80,8 @@ defmodule BlockScoutWeb.BridgedTokensController do
next_page_params ->
bridged_tokens_path(
conn,
:index,
:show,
destination,
Map.delete(next_page_params, "type")
)
end
@ -59,13 +117,4 @@ defmodule BlockScoutWeb.BridgedTokensController do
}
)
end
def index(conn, _params) do
total_supply = Chain.total_supply()
render(conn, "index.html",
current_path: current_path(conn),
total_supply: total_supply
)
end
end

@ -8,10 +8,18 @@ defmodule BlockScoutWeb.TokensController do
alias Phoenix.View
def index(conn, %{"type" => "JSON"} = params) do
tokens =
filter =
if Map.has_key?(params, "filter") do
Map.get(params, "filter")
else
nil
end
paging_params =
params
|> paging_options()
|> Chain.list_top_tokens()
tokens = Chain.list_top_tokens(filter, paging_params)
{tokens_page, next_page} = split_list_by_page(tokens)

@ -26,7 +26,7 @@
<%= nil %>
<% end %>
<h1 class="card-title lg-card-title">
<%= address_title(@address) %> <%= gettext "Details" %>
<div class="title-with-label"><%= address_title(@address) %> <%= gettext "Details" %></div>
<!-- buttons -->
<span class="overview-title-buttons float-right">
<span class="overview-title-item" data-clipboard-text="<%= @address %>">

@ -30,9 +30,13 @@
<i style="color: #f7b32b;" class="fa fa-info-circle ml-1" data-test="owl_info"></i>
</span>
<% end %>
<%= if @bridged_token.type do %>
<%= if @bridged_token && @bridged_token.type do %>
<div class="bs-label right <%= @bridged_token.type %>"><%= String.upcase(@bridged_token.type) %></div>
<% end %>
<%= if @bridged_token && @bridged_token.foreign_chain_id do %>
<% tag = Chain.chain_id_display_name(@bridged_token.foreign_chain_id) %>
<div class="bs-label right ml-2 destination-<%= tag %>"><%= String.upcase(tag) %></div>
<% end %>
</div>
</td>
<td class="stakes-td">

@ -1,7 +1,13 @@
<section class="container">
<section class="container" data-page="tokens">
<div class="card">
<div class="card-body" data-async-load data-async-listing="<%= @current_path %>">
<h1 class="card-title"><%= gettext "Bridged Tokens" %></h1>
<div class="tokens-list-search-input-outer-container">
<% tag = Chain.chain_id_display_name(@chain_id) %>
<h1 class="card-title"><div class="title-with-label"><%= gettext "Bridged Tokens from " %><%= @chain %></div><div class="bs-label ml-2 destination-<%= tag %>"><%= String.upcase(tag) %></div></h1>
<label class="tokens-list-search-input-container">
<input data-search-field="" class="form-control tokens-list-search-input" type="text" name="filter" placeholder="Token name or symbol" id="search-text-input" />
</label>
</div>
<div>
<p class="card-subtitle list-title-description">List of the tokens bridged through OmniBridge <span class="bs-label omni">OMNI</span> and Arbitrary Message Bridge <span class="bs-label amb">AMB</span> extensions</p>
<div class="list-top-pagination-container-wrapper">
@ -45,5 +51,5 @@
<%= render BlockScoutWeb.CommonComponentsView, "_pagination_container.html", position: "bottom", cur_page_number: "1", show_pagination_limit: true, data_next_page_button: true, data_prev_page_button: true %>
</div>
</div>
<script defer data-cfasync="false" src="<%= static_path(@conn, "/js/async-listing-load.js") %>"></script>
<script defer data-cfasync="false" src="<%= static_path(@conn, "/js/tokens.js") %>"></script>
</section>

@ -0,0 +1,3 @@
<div class="bs-label <%= @additional_classes |> Enum.join(" ") %>">
<%= @text %>
</div>

@ -22,7 +22,7 @@
<a href="https://github.com/poanetwork/blockscout" rel="noreferrer" target="_blank" class="footer-social-icon" title='<%= gettext("Github") %>'>
<i class="fab fa-github"></i>
</a>
<a href="https://www.twitter.com/_blockscout/" rel="noreferrer" target="_blank" class="footer-social-icon" title='<%= gettext("Twitter") %>'>
<a href="https://www.twitter.com/blockscoutcom/" rel="noreferrer" target="_blank" class="footer-social-icon" title='<%= gettext("Twitter") %>'>
<i class="fab fa-twitter"></i>
</a>
<a href="https://t.me/poa_network" rel="noreferrer" target="_blank" class="footer-social-icon" title='<%= gettext("Telegram") %>'>

@ -78,7 +78,7 @@
<%= gettext("Accounts") %>
<% end %>
</li>
<%= if Application.get_env(:block_scout_web, :omni_bridge_mediator) && Application.get_env(:block_scout_web, :omni_bridge_mediator) != "" do %>
<%= if Chain.bridged_tokens_enabled?() do %>
<li class="nav-item dropdown">
<a href="#" role="button" id="navbarTokensDropdown" class="nav-link topnav-nav-link dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="nav-link-icon">
@ -93,9 +93,14 @@
to: tokens_path(@conn, :index)
) %>
<%= link(
gettext("Bridged"),
class: "dropdown-item #{tab_status("bridged-tokens", @conn.request_path)}",
to: bridged_tokens_path(@conn, :index)
gettext("Bridged from Ethereum"),
class: "dropdown-item #{tab_status("bridged-tokens/eth", @conn.request_path)}",
to: bridged_tokens_path(@conn, :show, :eth)
) %>
<%= link(
gettext("Bridged from BSC"),
class: "dropdown-item #{tab_status("bridged-tokens/bsc", @conn.request_path)}",
to: bridged_tokens_path(@conn, :show, :bsc)
) %>
</div>
</li>

@ -20,7 +20,7 @@
use_custom_tooltip: false
%>
</td>
<%= if bridged_tokens_enabled?() do %>
<%= if Chain.bridged_tokens_enabled?() do %>
<td class="stakes-td">
<%= case @token.bridged do %>
<% nil -> %>

@ -1,9 +1,12 @@
<section class="container">
<section class="container" data-page="tokens">
<div class="card">
<div class="card-body" data-async-load data-async-listing="<%= @current_path %>">
<h1 class="card-title list-title-description"><%= gettext "Tokens" %></h1>
<h1 class="card-title list-title-description"><%= gettext "Tokens" %></h1>
<div class="list-top-pagination-container-wrapper">
<div class="list-top-pagination-container-wrapper tokens-list-search-input-outer-container" style="display: flex; float: right;">
<label class="tokens-list-search-input-container tokens mr-3">
<input data-search-field="" class="form-control tokens-list-search-input" type="text" name="filter" placeholder="Token name or symbol" id="search-text-input" />
</label>
<%= 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 %>
</div>
@ -21,7 +24,7 @@
<th class="stakes-table-th">
<div class="stakes-table-th-content">Address</div>
</th>
<%= if bridged_tokens_enabled?() do %>
<%= if Chain.bridged_tokens_enabled?() do %>
<th class="stakes-table-th">
<div class="stakes-table-th-content">Bridged?</div>
</th>
@ -48,5 +51,5 @@
<%= render BlockScoutWeb.CommonComponentsView, "_pagination_container.html", position: "bottom", cur_page_number: "1", show_pagination_limit: true, data_next_page_button: true, data_prev_page_button: true %>
</div>
</div>
<script defer data-cfasync="false" src="<%= static_path(@conn, "/js/async-listing-load.js") %>"></script>
<script defer data-cfasync="false" src="<%= static_path(@conn, "/js/tokens.js") %>"></script>
</section>

@ -20,13 +20,19 @@
<% true -> %>
<%= nil %>
<% end %>
<% foreign_chain_id = if Map.has_key?(@token, :foreign_chain_id), do: @token.foreign_chain_id, else: nil %>
<% tag = Chain.chain_id_display_name(foreign_chain_id) %>
<%= if token_name?(@token) do %>
<%= @token.name %>
<div class="title-with-label"><%= @token.name %></div>
<%= if tag !== "" do %>
<%= render BlockScoutWeb.FormView, "_tag.html", text: "bridged", additional_classes: ["bridged", "ml-1"] %>
<%= render BlockScoutWeb.FormView, "_tag.html", text: String.upcase(tag), additional_classes: ["destination-#{tag}", "ml-1"] %>
<% end %>
<% else %>
<%= gettext("Token Details") %>
<% end %>
<!-- buttons -->
<span class="overview-title-buttons token float-right">
<span class="overview-title-buttons token float-right <%= if @token.bridged, do: "bridged-tokens-buttons-mobile", else: "" %>">
<span class="overview-title-item" data-clipboard-text="<%= Address.checksum(@token.contract_address_hash) %>">
<span
aria-label='<%= gettext("Copy Address") %>'
@ -60,23 +66,20 @@
</span>
<!-- bridged token -->
<%= if @token.bridged do %>
<div style="margin-top: 15px; font-size: 12px;">
<span class="mr-4 mb-3 mb-md-0 text-muted" style="margin-right: 30px;">
Token is bridged
</span>
<div class="view-original-token-container">
<%= if Map.has_key?(@token, :foreign_token_contract_address_hash) do %>
<a data-test="original_token_contract_address" href=<%= foreign_bridged_token_explorer_link(@token) %> target="_blank">View Original Token <span class="external-token-icon"><%= render BlockScoutWeb.IconsView, "_external_link.html" %></span></a>
<% end %>
</div>
<div style="margin-top: 15px; font-size: 12px;">
<%= if Map.has_key?(@token, :custom_metadata) do %>
<%= if Map.has_key?(@token, :custom_metadata) do %>
<div style="margin-top: 15px; font-size: 12px;">
<%= @token.custom_metadata %>
<% end %>
</div>
</div>
<% end %>
<% end %>
</h1>
<h3><%= Address.checksum(@token.contract_address_hash) %></h3>
<h3 class="token-address-mobile"><%= Address.checksum(@token.contract_address_hash) %></h3>
<div class="d-flex flex-column flex-md-row justify-content-start text-muted">
<span class="mr-4 mb-3 mb-md-0">

@ -1,6 +1,7 @@
defmodule BlockScoutWeb.BridgedTokensView do
use BlockScoutWeb, :view
alias Explorer.Chain
alias Explorer.Chain.Token
@owl_token_amb "0x0905Ab807F8FD040255F0cF8fa14756c1D824931"

@ -106,6 +106,9 @@ defmodule BlockScoutWeb.Tokens.OverviewView do
1 ->
@etherscan_token_link
56 ->
"https://bscscan.com/token/"
_ ->
@etherscan_token_link
end

@ -1,17 +1,12 @@
defmodule BlockScoutWeb.TokensView do
use BlockScoutWeb, :view
alias Explorer.Chain
alias Explorer.Chain.Token
def decimals?(%Token{decimals: nil}), do: false
def decimals?(%Token{decimals: _}), do: true
def bridged_tokens_enabled? do
omni_bridge_mediator = Application.get_env(:block_scout_web, :omni_bridge_mediator)
omni_bridge_mediator && omni_bridge_mediator !== ""
end
def token_display_name(%Token{name: nil, symbol: nil}), do: ""
def token_display_name(%Token{name: "", symbol: ""}), do: ""

@ -79,7 +79,7 @@ defmodule BlockScoutWeb.WebRouter do
resources("/tokens", TokensController, only: [:index])
resources("/bridged-tokens", BridgedTokensController, only: [:index])
resources("/bridged-tokens", BridgedTokensController, only: [:index, :show])
resources "/address", AddressController, only: [:show] do
resources("/transactions", AddressTransactionController, only: [:index], as: :transaction)

@ -107,7 +107,7 @@ msgid "API for the %{subnetwork} - BlockScout"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/layout/_topnav.html.eex:119
#: lib/block_scout_web/templates/layout/_topnav.html.eex:124
msgid "APIs"
msgstr ""
@ -405,8 +405,8 @@ msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address/overview.html.eex:34
#: lib/block_scout_web/templates/address/overview.html.eex:38
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:32
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:36
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:38
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:42
msgid "Copy Address"
msgstr ""
@ -624,7 +624,7 @@ msgid "Error: Could not determine contract creator."
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/layout/_topnav.html.eex:133
#: lib/block_scout_web/templates/layout/_topnav.html.eex:138
msgid "Eth RPC"
msgstr ""
@ -725,7 +725,7 @@ msgid "Github"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/layout/_topnav.html.eex:123
#: lib/block_scout_web/templates/layout/_topnav.html.eex:128
msgid "GraphQL"
msgstr ""
@ -861,7 +861,7 @@ msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/tokens/instance/overview/_details.html.eex:10
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:26
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:32
msgid "Token Details"
msgstr ""
@ -1181,8 +1181,8 @@ msgstr ""
#: lib/block_scout_web/templates/address/overview.html.eex:158
#: lib/block_scout_web/templates/tokens/instance/overview/_details.html.eex:51
#: lib/block_scout_web/templates/tokens/instance/overview/_details.html.eex:107
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:52
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:137
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:58
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:140
msgid "QR Code"
msgstr ""
@ -1192,7 +1192,7 @@ msgid "Query"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/layout/_topnav.html.eex:128
#: lib/block_scout_web/templates/layout/_topnav.html.eex:133
msgid "RPC"
msgstr ""
@ -1250,13 +1250,13 @@ msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_logs/index.html.eex:14
#: lib/block_scout_web/templates/layout/_topnav.html.eex:210
#: lib/block_scout_web/templates/layout/_topnav.html.eex:254
#: lib/block_scout_web/templates/layout/_topnav.html.eex:215
#: lib/block_scout_web/templates/layout/_topnav.html.eex:259
msgid "Search"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/layout/_topnav.html.eex:204
#: lib/block_scout_web/templates/layout/_topnav.html.eex:209
msgid "Search by address, token symbol name, transaction hash, or block number"
msgstr ""
@ -1291,7 +1291,7 @@ msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address/overview.html.eex:55
#: lib/block_scout_web/templates/tokens/instance/overview/_details.html.eex:52
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:53
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:59
msgid "Show QR Code"
msgstr ""
@ -1453,7 +1453,7 @@ msgid "Topics"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:107
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:110
msgid "Total Supply"
msgstr ""
@ -1610,7 +1610,7 @@ msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/tokens/instance/overview/_details.html.eex:16
#: lib/block_scout_web/templates/tokens/instance/overview/_details.html.eex:20
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:87
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:90
msgid "View Contract"
msgstr ""
@ -1725,8 +1725,8 @@ msgstr ""
#: lib/block_scout_web/templates/address/overview.html.eex:167
#: lib/block_scout_web/templates/tokens/instance/overview/_details.html.eex:108
#: lib/block_scout_web/templates/tokens/instance/overview/_details.html.eex:116
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:138
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:146
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:141
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:149
msgid "Close"
msgstr ""
@ -1743,7 +1743,7 @@ msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/tokens/instance/overview/_details.html.eex:76
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:95
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:98
msgid "Decimals"
msgstr ""
@ -1861,7 +1861,7 @@ msgstr ""
#: lib/block_scout_web/templates/address_token/index.html.eex:8
#: lib/block_scout_web/templates/address_token_transfer/index.html.eex:11
#: lib/block_scout_web/templates/layout/_topnav.html.eex:87
#: lib/block_scout_web/templates/layout/_topnav.html.eex:108
#: lib/block_scout_web/templates/layout/_topnav.html.eex:113
#: lib/block_scout_web/templates/tokens/index.html.eex:4
#: lib/block_scout_web/views/address_view.ex:343
msgid "Tokens"
@ -1942,7 +1942,7 @@ msgid "Write Proxy"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/layout/_topnav.html.eex:147
#: lib/block_scout_web/templates/layout/_topnav.html.eex:152
msgid "Apps"
msgstr ""
@ -1952,7 +1952,7 @@ msgid "Copy Raw Trace"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/layout/_topnav.html.eex:208
#: lib/block_scout_web/templates/layout/_topnav.html.eex:213
msgid "Search by address, token symbol, name, transaction hash, or block number"
msgstr ""
@ -1976,16 +1976,6 @@ msgstr ""
msgid "page"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/layout/_topnav.html.eex:96
msgid "Bridged"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/bridged_tokens/index.html.eex:4
msgid "Bridged Tokens"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address/_custom_view_df_title.html.eex:9
#: lib/block_scout_web/templates/address/_custom_view_df_title.html.eex:13
@ -2609,7 +2599,7 @@ msgid "validator"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/layout/_topnav.html.eex:149
#: lib/block_scout_web/templates/layout/_topnav.html.eex:154
msgid "Stakes"
msgstr ""
@ -2620,12 +2610,12 @@ msgid "Contract is not verified. However, we found a verified contract with the
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/layout/_topnav.html.eex:155
#: lib/block_scout_web/templates/layout/_topnav.html.eex:160
msgid "Staking"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/layout/_topnav.html.eex:247
#: lib/block_scout_web/templates/layout/_topnav.html.eex:252
msgid "Press / and focus will be moved to the search field"
msgstr ""
@ -2686,3 +2676,18 @@ msgstr ""
#: lib/block_scout_web/templates/stakes/_table.html.eex:39
msgid "Approximate Current Annual Percentage Yield. If you see N/A, please wait for a few blocks (APY cannot be calculated at the very beginning of a staking epoch)."
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/bridged_tokens/index.html.eex:6
msgid "Bridged Tokens from "
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/layout/_topnav.html.eex:96
msgid "Bridged from Ethereum"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/layout/_topnav.html.eex:101
msgid "Bridged from BSC"
msgstr ""

@ -107,7 +107,7 @@ msgid "API for the %{subnetwork} - BlockScout"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/layout/_topnav.html.eex:119
#: lib/block_scout_web/templates/layout/_topnav.html.eex:124
msgid "APIs"
msgstr ""
@ -405,8 +405,8 @@ msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address/overview.html.eex:34
#: lib/block_scout_web/templates/address/overview.html.eex:38
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:32
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:36
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:38
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:42
msgid "Copy Address"
msgstr ""
@ -624,7 +624,7 @@ msgid "Error: Could not determine contract creator."
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/layout/_topnav.html.eex:133
#: lib/block_scout_web/templates/layout/_topnav.html.eex:138
msgid "Eth RPC"
msgstr ""
@ -725,7 +725,7 @@ msgid "Github"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/layout/_topnav.html.eex:123
#: lib/block_scout_web/templates/layout/_topnav.html.eex:128
msgid "GraphQL"
msgstr ""
@ -861,7 +861,7 @@ msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/tokens/instance/overview/_details.html.eex:10
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:26
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:32
msgid "Token Details"
msgstr ""
@ -1181,8 +1181,8 @@ msgstr ""
#: lib/block_scout_web/templates/address/overview.html.eex:158
#: lib/block_scout_web/templates/tokens/instance/overview/_details.html.eex:51
#: lib/block_scout_web/templates/tokens/instance/overview/_details.html.eex:107
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:52
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:137
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:58
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:140
msgid "QR Code"
msgstr ""
@ -1192,7 +1192,7 @@ msgid "Query"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/layout/_topnav.html.eex:128
#: lib/block_scout_web/templates/layout/_topnav.html.eex:133
msgid "RPC"
msgstr ""
@ -1250,13 +1250,13 @@ msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_logs/index.html.eex:14
#: lib/block_scout_web/templates/layout/_topnav.html.eex:210
#: lib/block_scout_web/templates/layout/_topnav.html.eex:254
#: lib/block_scout_web/templates/layout/_topnav.html.eex:215
#: lib/block_scout_web/templates/layout/_topnav.html.eex:259
msgid "Search"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/layout/_topnav.html.eex:204
#: lib/block_scout_web/templates/layout/_topnav.html.eex:209
msgid "Search by address, token symbol name, transaction hash, or block number"
msgstr ""
@ -1291,7 +1291,7 @@ msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address/overview.html.eex:55
#: lib/block_scout_web/templates/tokens/instance/overview/_details.html.eex:52
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:53
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:59
msgid "Show QR Code"
msgstr ""
@ -1453,7 +1453,7 @@ msgid "Topics"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:107
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:110
msgid "Total Supply"
msgstr ""
@ -1610,7 +1610,7 @@ msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/tokens/instance/overview/_details.html.eex:16
#: lib/block_scout_web/templates/tokens/instance/overview/_details.html.eex:20
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:87
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:90
msgid "View Contract"
msgstr ""
@ -1725,8 +1725,8 @@ msgstr ""
#: lib/block_scout_web/templates/address/overview.html.eex:167
#: lib/block_scout_web/templates/tokens/instance/overview/_details.html.eex:108
#: lib/block_scout_web/templates/tokens/instance/overview/_details.html.eex:116
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:138
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:146
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:141
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:149
msgid "Close"
msgstr ""
@ -1743,7 +1743,7 @@ msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/tokens/instance/overview/_details.html.eex:76
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:95
#: lib/block_scout_web/templates/tokens/overview/_details.html.eex:98
msgid "Decimals"
msgstr ""
@ -1861,7 +1861,7 @@ msgstr ""
#: lib/block_scout_web/templates/address_token/index.html.eex:8
#: lib/block_scout_web/templates/address_token_transfer/index.html.eex:11
#: lib/block_scout_web/templates/layout/_topnav.html.eex:87
#: lib/block_scout_web/templates/layout/_topnav.html.eex:108
#: lib/block_scout_web/templates/layout/_topnav.html.eex:113
#: lib/block_scout_web/templates/tokens/index.html.eex:4
#: lib/block_scout_web/views/address_view.ex:343
msgid "Tokens"
@ -1942,7 +1942,7 @@ msgid "Write Proxy"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/layout/_topnav.html.eex:147
#: lib/block_scout_web/templates/layout/_topnav.html.eex:152
msgid "Apps"
msgstr ""
@ -1952,7 +1952,7 @@ msgid "Copy Raw Trace"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/layout/_topnav.html.eex:208
#: lib/block_scout_web/templates/layout/_topnav.html.eex:213
msgid "Search by address, token symbol, name, transaction hash, or block number"
msgstr ""
@ -1976,16 +1976,6 @@ msgstr ""
msgid "page"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/layout/_topnav.html.eex:96
msgid "Bridged"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/bridged_tokens/index.html.eex:4
msgid "Bridged Tokens"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address/_custom_view_df_title.html.eex:9
#: lib/block_scout_web/templates/address/_custom_view_df_title.html.eex:13
@ -2609,7 +2599,7 @@ msgid "validator"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/layout/_topnav.html.eex:149
#: lib/block_scout_web/templates/layout/_topnav.html.eex:154
msgid "Stakes"
msgstr ""
@ -2620,12 +2610,12 @@ msgid "Contract is not verified. However, we found a verified contract with the
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/layout/_topnav.html.eex:155
#: lib/block_scout_web/templates/layout/_topnav.html.eex:160
msgid "Staking"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/layout/_topnav.html.eex:247
#: lib/block_scout_web/templates/layout/_topnav.html.eex:252
msgid "Press / and focus will be moved to the search field"
msgstr ""
@ -2686,3 +2676,18 @@ msgstr ""
#: lib/block_scout_web/templates/stakes/_table.html.eex:39
msgid "Approximate Current Annual Percentage Yield. If you see N/A, please wait for a few blocks (APY cannot be calculated at the very beginning of a staking epoch)."
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/bridged_tokens/index.html.eex:6
msgid "Bridged Tokens from "
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/layout/_topnav.html.eex:96
msgid "Bridged from Ethereum"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/layout/_topnav.html.eex:101
msgid "Bridged from BSC"
msgstr ""

@ -1822,21 +1822,23 @@ defmodule Explorer.Chain do
Lists the top `t:Explorer.Chain.Token.t/0`'s'.
"""
@spec list_top_tokens :: [{Token.t(), non_neg_integer()}]
def list_top_tokens(options \\ []) do
@spec list_top_tokens(String.t()) :: [{Token.t(), non_neg_integer()}]
def list_top_tokens(filter, options \\ []) do
paging_options = Keyword.get(options, :paging_options, @default_paging_options)
fetch_top_tokens(paging_options)
fetch_top_tokens(filter, paging_options)
end
@spec list_top_bridged_tokens :: [{Token.t(), non_neg_integer()}]
def list_top_bridged_tokens(options \\ []) do
@spec list_top_bridged_tokens(atom(), String.t(), [paging_options | necessity_by_association_option]) :: [
{Token.t(), non_neg_integer()}
]
def list_top_bridged_tokens(destination, filter, options \\ []) do
paging_options = Keyword.get(options, :paging_options, @default_paging_options)
fetch_top_bridged_tokens(paging_options)
fetch_top_bridged_tokens(destination, paging_options, filter)
end
defp fetch_top_tokens(paging_options) do
defp fetch_top_tokens(filter, paging_options) do
base_query =
from(t in Token,
where: t.total_supply > ^0,
@ -1844,21 +1846,35 @@ defmodule Explorer.Chain do
preload: [:contract_address]
)
base_query
|> page_tokens(paging_options)
|> limit(^paging_options.page_size)
base_query_with_paging =
base_query
|> page_tokens(paging_options)
|> limit(^paging_options.page_size)
query =
if filter && filter !== "" do
base_query_with_paging
|> where(fragment("to_tsvector('english', symbol || ' ' || name ) @@ to_tsquery(?)", ^filter))
else
base_query_with_paging
end
query
|> Repo.all()
end
defp fetch_top_bridged_tokens(paging_options) do
defp fetch_top_bridged_tokens(destination, paging_options, filter) do
chain_id = translate_destination_to_chain_id(destination)
bridged_tokens_query =
from(bt in BridgedToken,
select: bt
select: bt,
where: bt.foreign_chain_id == ^chain_id
)
base_query =
from(t in Token,
left_join: bt in subquery(bridged_tokens_query),
right_join: bt in subquery(bridged_tokens_query),
on: t.contract_address_hash == bt.home_token_contract_address_hash,
where: t.total_supply > ^0,
where: t.bridged,
@ -1867,12 +1883,31 @@ defmodule Explorer.Chain do
preload: [:contract_address]
)
base_query
|> page_tokens(paging_options)
|> limit(^paging_options.page_size)
base_query_with_paging =
base_query
|> page_tokens(paging_options)
|> limit(^paging_options.page_size)
query =
if filter && filter !== "" do
base_query_with_paging
|> where(fragment("to_tsvector('english', symbol || ' ' || name ) @@ to_tsquery(?)", ^filter))
else
base_query_with_paging
end
query
|> Repo.all()
end
defp translate_destination_to_chain_id(destination) do
case destination do
:eth -> 1
:bsc -> 56
_ -> 1
end
end
@doc """
Calls `reducer` on a stream of `t:Explorer.Chain.Block.t/0` without `t:Explorer.Chain.Block.Reward.t/0`.
"""
@ -3843,7 +3878,17 @@ defmodule Explorer.Chain do
set_token_bridged_status(token_address_hash, false)
created_from_int_tx && created_from_int_tx_success ->
extract_omni_bridged_token_metadata_wrapper(token_address_hash, created_from_int_tx_success)
extract_omni_bridged_token_metadata_wrapper(
token_address_hash,
created_from_int_tx_success,
:eth_omni_bridge_mediator
)
extract_omni_bridged_token_metadata_wrapper(
token_address_hash,
created_from_int_tx_success,
:bsc_omni_bridge_mediator
)
true ->
:ok
@ -3853,8 +3898,8 @@ defmodule Explorer.Chain do
:ok
end
defp extract_omni_bridged_token_metadata_wrapper(token_address_hash, created_from_int_tx_success) do
omni_bridge_mediator = Application.get_env(:block_scout_web, :omni_bridge_mediator)
defp extract_omni_bridged_token_metadata_wrapper(token_address_hash, created_from_int_tx_success, mediator) do
omni_bridge_mediator = Application.get_env(:block_scout_web, mediator)
%{transaction_hash: transaction_hash} = created_from_int_tx_success
if omni_bridge_mediator && omni_bridge_mediator !== "" do
@ -5746,4 +5791,42 @@ defmodule Explorer.Chain do
|> limit(1)
|> Repo.one()
end
def bridged_tokens_enabled? do
eth_omni_bridge_mediator = Application.get_env(:block_scout_web, :eth_omni_bridge_mediator)
bsc_omni_bridge_mediator = Application.get_env(:block_scout_web, :bsc_omni_bridge_mediator)
(eth_omni_bridge_mediator && eth_omni_bridge_mediator !== "") ||
(bsc_omni_bridge_mediator && bsc_omni_bridge_mediator !== "")
end
def bridged_tokens_eth_enabled? do
eth_omni_bridge_mediator = Application.get_env(:block_scout_web, :eth_omni_bridge_mediator)
eth_omni_bridge_mediator && eth_omni_bridge_mediator !== ""
end
def bridged_tokens_bsc_enabled? do
bsc_omni_bridge_mediator = Application.get_env(:block_scout_web, :bsc_omni_bridge_mediator)
bsc_omni_bridge_mediator && bsc_omni_bridge_mediator !== ""
end
def chain_id_display_name(nil), do: ""
def chain_id_display_name(chain_id) do
chain_id_int =
if is_integer(chain_id) do
chain_id
else
chain_id
|> Decimal.to_integer()
end
case chain_id_int do
1 -> "eth"
56 -> "bsc"
_ -> ""
end
end
end

@ -182,6 +182,7 @@ defmodule Explorer.ExchangeRates.Source.CoinGecko do
defp bridged_token_symbol_to_id_mapping_to_get_price(symbol) do
case symbol do
"UNI" -> "uniswap"
"SURF" -> "surf-finance"
_symbol -> nil
end
end

@ -5,6 +5,7 @@ defmodule Indexer.Supervisor do
use Supervisor
alias Explorer.Chain
alias Indexer.{Block, PendingOpsCleaner, SetAmbBridgedMetadataForTokens, SetOmniBridgedMetadataForTokens}
alias Indexer.Block.{Catchup, Realtime}
@ -129,10 +130,8 @@ defmodule Indexer.Supervisor do
{PendingOpsCleaner, [[], []]}
]
omni_bridge_mediator = Application.get_env(:block_scout_web, :omni_bridge_mediator)
extended_fetchers =
if omni_bridge_mediator && omni_bridge_mediator !== "" do
if Chain.bridged_tokens_enabled?() do
[{SetOmniBridgedMetadataForTokens, [[], []]} | basic_fetchers]
else
basic_fetchers

Loading…
Cancel
Save