From 678927883fc7342b980ee5bf8d4de8b1f683cd88 Mon Sep 17 00:00:00 2001 From: Viktor Baranov Date: Wed, 22 Jun 2022 16:50:02 +0300 Subject: [PATCH] Remove bridged tokens functionality from Blockscout core --- .dialyzer-ignore | 4 +- CHANGELOG.md | 1 + .../assets/js/lib/autocomplete.js | 2 +- .../assets/js/lib/token_icon.js | 9 +- .../assets/js/pages/token/overview.js | 4 +- apps/block_scout_web/config/config.exs | 4 - .../lib/block_scout_web/chain.ex | 2 +- .../controllers/address_controller.ex | 63 +- .../controllers/address_token_controller.ex | 3 +- .../controllers/api/rpc/token_controller.ex | 39 - .../controllers/chain_controller.ex | 5 +- .../tokens/bridged_tokens_controller.ex | 116 --- .../lib/block_scout_web/etherscan.ex | 112 +-- .../templates/address_token/_tokens.html.eex | 15 +- .../_token_balances.html.eex | 6 +- .../address_token_balance/_tokens.html.eex | 20 +- .../templates/bridged_tokens/_tile.html.eex | 97 -- .../templates/bridged_tokens/index.html.eex | 70 -- .../templates/chain/show.html.eex | 15 - .../templates/layout/_topnav.html.eex | 74 +- .../templates/layout/app.html.eex | 1 - .../templates/search/_tile.html.eex | 4 +- .../tokens/overview/_details.html.eex | 15 - .../views/address_token_balance_view.ex | 4 +- .../lib/block_scout_web/views/address_view.ex | 16 - .../views/api/rpc/token_view.ex | 27 - .../views/bridged_tokens_view.ex | 49 - .../lib/block_scout_web/views/chain_view.ex | 13 - .../views/tokens/overview_view.ex | 56 -- .../lib/block_scout_web/web_router.ex | 2 - apps/block_scout_web/priv/gettext/default.pot | 119 +-- .../priv/gettext/en/LC_MESSAGES/default.po | 119 +-- .../controllers/address_controller_test.exs | 3 +- .../views/address_token_balance_view_test.exs | 32 +- apps/explorer/config/config.exs | 20 - apps/explorer/lib/explorer/chain.ex | 937 +----------------- .../chain/address/current_token_balance.ex | 6 +- .../lib/explorer/chain/bridged_token.ex | 97 -- .../chain/cache/token_exchange_rate.ex | 55 +- .../explorer/chain/import/runner/tokens.ex | 4 +- .../lib/explorer/chain/supply/token_bridge.ex | 298 ------ apps/explorer/lib/explorer/chain/token.ex | 5 +- apps/explorer/lib/explorer/counters/bridge.ex | 194 ---- .../lib/explorer/exchange_rates/source.ex | 6 +- .../exchange_rates/source/coin_gecko.ex | 4 +- .../exchange_rates/source/token_bridge.ex | 71 -- apps/explorer/lib/explorer/market/market.ex | 43 +- .../20220622140604_remove_bridged_tokens.exs | 11 + .../address/current_token_balance_test.exs | 4 +- .../chain/supply/token_bridge_test.exs | 67 -- apps/explorer/test/explorer/chain_test.exs | 2 +- .../source/token_bridge_test.exs | 45 - .../indexer/calc_lp_tokens_total_liquidity.ex | 52 - .../fetcher/token_balance_on_demand.ex | 4 +- .../set_amb_bridged_metadata_for_tokens.ex | 44 - .../set_omni_bridged_metadata_for_tokens.ex | 54 - apps/indexer/lib/indexer/supervisor.ex | 26 +- docker-compose/envs/common-blockscout.env | 7 +- docker/Makefile | 16 +- 59 files changed, 218 insertions(+), 2975 deletions(-) delete mode 100644 apps/block_scout_web/lib/block_scout_web/controllers/tokens/bridged_tokens_controller.ex delete mode 100644 apps/block_scout_web/lib/block_scout_web/templates/bridged_tokens/_tile.html.eex delete mode 100644 apps/block_scout_web/lib/block_scout_web/templates/bridged_tokens/index.html.eex delete mode 100644 apps/block_scout_web/lib/block_scout_web/views/bridged_tokens_view.ex delete mode 100644 apps/explorer/lib/explorer/chain/bridged_token.ex delete mode 100644 apps/explorer/lib/explorer/chain/supply/token_bridge.ex delete mode 100644 apps/explorer/lib/explorer/counters/bridge.ex delete mode 100644 apps/explorer/lib/explorer/exchange_rates/source/token_bridge.ex create mode 100644 apps/explorer/priv/repo/migrations/20220622140604_remove_bridged_tokens.exs delete mode 100644 apps/explorer/test/explorer/chain/supply/token_bridge_test.exs delete mode 100644 apps/explorer/test/explorer/exchange_rates/source/token_bridge_test.exs delete mode 100644 apps/indexer/lib/indexer/calc_lp_tokens_total_liquidity.ex delete mode 100644 apps/indexer/lib/indexer/set_amb_bridged_metadata_for_tokens.ex delete mode 100644 apps/indexer/lib/indexer/set_omni_bridged_metadata_for_tokens.ex diff --git a/.dialyzer-ignore b/.dialyzer-ignore index 1ce4c12fc4..7f10f09ac2 100644 --- a/.dialyzer-ignore +++ b/.dialyzer-ignore @@ -20,8 +20,8 @@ lib/block_scout_web/views/layout_view.ex:145: The call 'Elixir.Poison.Parser':'p lib/block_scout_web/views/layout_view.ex:237: The call 'Elixir.Poison.Parser':'parse!' lib/explorer/smart_contract/reader.ex:435 lib/indexer/fetcher/token_total_supply_on_demand.ex:16 -lib/explorer/exchange_rates/source.ex:120 -lib/explorer/exchange_rates/source.ex:123 +lib/explorer/exchange_rates/source.ex:116 +lib/explorer/exchange_rates/source.ex:119 lib/explorer/smart_contract/solidity/verifier.ex:223 lib/block_scout_web/templates/address_contract/index.html.eex:158 lib/block_scout_web/templates/address_contract/index.html.eex:195 diff --git a/CHANGELOG.md b/CHANGELOG.md index 8063124f55..7436c84186 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ - [#5690](https://github.com/blockscout/blockscout/pull/5690) - Allow special characters for password in DB URL parser ### Chore +- [#5703](https://github.com/blockscout/blockscout/pull/5703) - Remove bridged tokens functionality from Blockscout core - [#5700](https://github.com/blockscout/blockscout/pull/5700) - Remove Staking dapp logic from Blockscout core - [#5696](https://github.com/blockscout/blockscout/pull/5696) - Update .tool-versions - [#5695](https://github.com/blockscout/blockscout/pull/5695) - Decimal hex package update 1.9 -> 2.0 diff --git a/apps/block_scout_web/assets/js/lib/autocomplete.js b/apps/block_scout_web/assets/js/lib/autocomplete.js index 2d5100a56c..a9a5c2531a 100644 --- a/apps/block_scout_web/assets/js/lib/autocomplete.js +++ b/apps/block_scout_web/assets/js/lib/autocomplete.js @@ -99,7 +99,7 @@ const resultItemElement = async (item, data) => { const $searchInput = $('#main-search-autocomplete') const chainID = $searchInput.data('chain-id') const displayTokenIcons = $searchInput.data('display-token-icons') - appendTokenIcon($tokenIconContainer, chainID, data.value.address_hash, data.value.foreign_chain_id, data.value.foreign_token_hash, displayTokenIcons, 15) + appendTokenIcon($tokenIconContainer, chainID, data.value.address_hash, displayTokenIcons, 15) } const config = (id) => { return { diff --git a/apps/block_scout_web/assets/js/lib/token_icon.js b/apps/block_scout_web/assets/js/lib/token_icon.js index 14fa339aa3..6f283cb3c2 100644 --- a/apps/block_scout_web/assets/js/lib/token_icon.js +++ b/apps/block_scout_web/assets/js/lib/token_icon.js @@ -21,14 +21,9 @@ function getTokenIconUrl (chainID, addressHash) { } } -function appendTokenIcon ($tokenIconContainer, chainID, addressHash, foreignChainID, foreignAddressHash, displayTokenIcons, size) { +function appendTokenIcon ($tokenIconContainer, chainID, addressHash, displayTokenIcons, size) { const iconSize = size || 20 - let tokenIconURL = null - if (foreignChainID) { - tokenIconURL = getTokenIconUrl(foreignChainID.toString(), foreignAddressHash) - } else if (chainID) { - tokenIconURL = getTokenIconUrl(chainID.toString(), addressHash) - } + const tokenIconURL = getTokenIconUrl(chainID.toString(), addressHash) if (displayTokenIcons) { checkLink(tokenIconURL) .then(checkTokenIconLink => { diff --git a/apps/block_scout_web/assets/js/pages/token/overview.js b/apps/block_scout_web/assets/js/pages/token/overview.js index 59d7e500b0..9f7fa4f193 100644 --- a/apps/block_scout_web/assets/js/pages/token/overview.js +++ b/apps/block_scout_web/assets/js/pages/token/overview.js @@ -5,9 +5,7 @@ if ($('[data-page="token-details"]').length) { const $tokenIconContainer = $('#token-icon') const chainID = $tokenIconContainer.data('chain-id') const addressHash = $tokenIconContainer.data('address-hash') - const foreignChainID = $tokenIconContainer.data('foreign-chain-id') - const foreignAddressHash = $tokenIconContainer.data('foreign-address-hash') const displayTokenIcons = $tokenIconContainer.data('display-token-icons') - appendTokenIcon($tokenIconContainer, chainID, addressHash, foreignChainID, foreignAddressHash, displayTokenIcons) + appendTokenIcon($tokenIconContainer, chainID, addressHash, displayTokenIcons) } diff --git a/apps/block_scout_web/config/config.exs b/apps/block_scout_web/config/config.exs index 48a17a9572..104e9c8b76 100644 --- a/apps/block_scout_web/config/config.exs +++ b/apps/block_scout_web/config/config.exs @@ -33,10 +33,6 @@ 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"), - 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), restricted_list: System.get_env("RESTRICTED_LIST", nil), restricted_list_key: System.get_env("RESTRICTED_LIST_KEY", nil), diff --git a/apps/block_scout_web/lib/block_scout_web/chain.ex b/apps/block_scout_web/lib/block_scout_web/chain.ex index 2c41638717..927e5f2546 100644 --- a/apps/block_scout_web/lib/block_scout_web/chain.ex +++ b/apps/block_scout_web/lib/block_scout_web/chain.ex @@ -341,7 +341,7 @@ defmodule BlockScoutWeb.Chain do %{"address_hash" => to_string(address_hash), "value" => Decimal.to_integer(value)} end - defp paging_params({%CurrentTokenBalance{value: value}, _, %Token{name: name, type: type}}) do + defp paging_params({%CurrentTokenBalance{value: value}, %Token{name: name, type: type}}) do %{"token_name" => name, "token_type" => type, "value" => Decimal.to_integer(value)} end diff --git a/apps/block_scout_web/lib/block_scout_web/controllers/address_controller.ex b/apps/block_scout_web/lib/block_scout_web/controllers/address_controller.ex index 2ca87dff15..13cf9c20d2 100644 --- a/apps/block_scout_web/lib/block_scout_web/controllers/address_controller.ex +++ b/apps/block_scout_web/lib/block_scout_web/controllers/address_controller.ex @@ -7,12 +7,11 @@ defmodule BlockScoutWeb.AddressController do AccessHelpers, AddressTransactionController, AddressView, - Controller, - CurrencyHelpers + Controller } alias Explorer.Counters.{AddressTokenTransfersCounter, AddressTransactionsCounter, AddressTransactionsGasUsageCounter} - alias Explorer.{Chain, CustomContractsHelpers, Market} + alias Explorer.{Chain, Market} alias Explorer.Chain.Wei alias Explorer.ExchangeRates.Token alias Indexer.Fetcher.CoinBalanceOnDemand @@ -143,7 +142,7 @@ defmodule BlockScoutWeb.AddressController do def address_counters(conn, %{"id" => address_hash_string}) do with {:ok, address_hash} <- Chain.string_to_address_hash(address_hash_string), {:ok, address} <- Chain.hash_to_address(address_hash) do - {validation_count, crc_total_worth} = address_counters(address) + {validation_count} = address_counters(address) transactions_from_db = address.transactions_count || 0 token_transfers_from_db = address.token_transfers_count || 0 @@ -153,8 +152,7 @@ defmodule BlockScoutWeb.AddressController do transaction_count: transactions_from_db, token_transfer_count: token_transfers_from_db, gas_usage_count: address_gas_usage_from_db, - validation_count: validation_count, - crc_total_worth: crc_total_worth + validation_count: validation_count }) else _ -> @@ -162,8 +160,7 @@ defmodule BlockScoutWeb.AddressController do transaction_count: 0, token_transfer_count: 0, gas_usage_count: 0, - validation_count: 0, - crc_total_worth: 0 + validation_count: 0 }) end end @@ -174,11 +171,6 @@ defmodule BlockScoutWeb.AddressController do validation_count(address) end) - crc_total_worth_task = - Task.async(fn -> - crc_total_worth(address) - end) - Task.start_link(fn -> transaction_count(address) end) @@ -192,8 +184,7 @@ defmodule BlockScoutWeb.AddressController do end) [ - validation_count_task, - crc_total_worth_task + validation_count_task ] |> Task.yield_many(:infinity) |> Enum.map(fn {_task, res} -> @@ -226,46 +217,4 @@ defmodule BlockScoutWeb.AddressController do defp validation_count(address) do Chain.address_to_validation_count(address.hash) end - - defp crc_total_worth(address) do - circles_total_balance(address.hash) - end - - defp circles_total_balance(address_hash) do - circles_addresses_list = CustomContractsHelpers.get_custom_addresses_list(:circles_addresses) - - token_balances = - address_hash - |> Chain.fetch_last_token_balances() - - token_balances_except_bridged = - token_balances - |> Enum.filter(fn {_, _, token} -> !token.bridged end) - - circles_total_balance_raw = - if Enum.count(circles_addresses_list) > 0 do - token_balances_except_bridged - |> Enum.reduce(Decimal.new(0), fn {token_balance, _, token}, acc_balance -> - {:ok, token_address} = Chain.hash_to_address(token.contract_address_hash) - - from_address = AddressView.from_address_hash(token_address) - - created_from_address_hash = - if from_address, - do: "0x" <> Base.encode16(from_address.bytes, case: :lower), - else: nil - - if Enum.member?(circles_addresses_list, created_from_address_hash) && token.name == "Circles" && - token.symbol == "CRC" do - Decimal.add(acc_balance, token_balance.value) - else - acc_balance - end - end) - else - Decimal.new(0) - end - - CurrencyHelpers.format_according_to_decimals(circles_total_balance_raw, Decimal.new(18)) - end end diff --git a/apps/block_scout_web/lib/block_scout_web/controllers/address_token_controller.ex b/apps/block_scout_web/lib/block_scout_web/controllers/address_token_controller.ex index f24f22284e..99b29f4082 100644 --- a/apps/block_scout_web/lib/block_scout_web/controllers/address_token_controller.ex +++ b/apps/block_scout_web/lib/block_scout_web/controllers/address_token_controller.ex @@ -33,13 +33,12 @@ defmodule BlockScoutWeb.AddressTokenController do items = tokens |> Market.add_price() - |> Enum.map(fn {token_balance, bridged_token, token} -> + |> Enum.map(fn {token_balance, token} -> View.render_to_string( AddressTokenView, "_tokens.html", token_balance: token_balance, token: token, - bridged_token: bridged_token, address: address, conn: conn ) diff --git a/apps/block_scout_web/lib/block_scout_web/controllers/api/rpc/token_controller.ex b/apps/block_scout_web/lib/block_scout_web/controllers/api/rpc/token_controller.ex index dfaa0a0ff9..f2f8afb82a 100644 --- a/apps/block_scout_web/lib/block_scout_web/controllers/api/rpc/token_controller.ex +++ b/apps/block_scout_web/lib/block_scout_web/controllers/api/rpc/token_controller.ex @@ -4,8 +4,6 @@ defmodule BlockScoutWeb.API.RPC.TokenController do alias BlockScoutWeb.API.RPC.Helpers alias Explorer.{Chain, PagingOptions} - @default_page_size 50 - def gettoken(conn, params) do with {:contractaddress_param, {:ok, contractaddress_param}} <- fetch_contractaddress(params), {:format, {:ok, address_hash}} <- to_address_hash(contractaddress_param), @@ -52,47 +50,10 @@ defmodule BlockScoutWeb.API.RPC.TokenController do end end - def bridgedtokenlist(conn, params) do - chainid = params |> Map.get("chainid") - destination = translate_chain_id_to_destination(chainid) - - params_with_paging_options = Helpers.put_pagination_options(%{}, params) - - page_number = - if Map.has_key?(params_with_paging_options, :page_number), do: params_with_paging_options.page_number, else: 1 - - page_size = - if Map.has_key?(params_with_paging_options, :page_size), - do: params_with_paging_options.page_size, - else: @default_page_size - - options = [ - paging_options: %PagingOptions{ - key: nil, - page_number: page_number, - page_size: page_size - } - ] - - from_api = true - bridged_tokens = Chain.list_top_bridged_tokens(destination, nil, from_api, options) - render(conn, "bridgedtokenlist.json", %{bridged_tokens: bridged_tokens}) - end - defp fetch_contractaddress(params) do {:contractaddress_param, Map.fetch(params, "contractaddress")} end - defp translate_chain_id_to_destination(destination) do - case destination do - "1" -> :eth - "42" -> :kovan - "56" -> :bsc - "99" -> :poa - wrong_chain_id -> wrong_chain_id - end - end - defp to_address_hash(address_hash_string) do {:format, Chain.string_to_address_hash(address_hash_string)} end diff --git a/apps/block_scout_web/lib/block_scout_web/controllers/chain_controller.ex b/apps/block_scout_web/lib/block_scout_web/controllers/chain_controller.ex index f744e74bfc..6d112bdc45 100644 --- a/apps/block_scout_web/lib/block_scout_web/controllers/chain_controller.ex +++ b/apps/block_scout_web/lib/block_scout_web/controllers/chain_controller.ex @@ -9,7 +9,7 @@ defmodule BlockScoutWeb.ChainController do alias Explorer.Chain.Cache.Block, as: BlockCache alias Explorer.Chain.Cache.GasUsage alias Explorer.Chain.Cache.Transaction, as: TransactionCache - alias Explorer.Chain.Supply.{RSK, TokenBridge} + alias Explorer.Chain.Supply.RSK alias Explorer.Chain.Transaction.History.TransactionStats alias Explorer.Counters.AverageBlockTime alias Explorer.ExchangeRates.Token @@ -27,9 +27,6 @@ defmodule BlockScoutWeb.ChainController do RSK -> RSK - TokenBridge -> - TokenBridge - _ -> :standard end diff --git a/apps/block_scout_web/lib/block_scout_web/controllers/tokens/bridged_tokens_controller.ex b/apps/block_scout_web/lib/block_scout_web/controllers/tokens/bridged_tokens_controller.ex deleted file mode 100644 index 20be49ada8..0000000000 --- a/apps/block_scout_web/lib/block_scout_web/controllers/tokens/bridged_tokens_controller.ex +++ /dev/null @@ -1,116 +0,0 @@ -defmodule BlockScoutWeb.BridgedTokensController do - use BlockScoutWeb, :controller - - import BlockScoutWeb.Chain, only: [paging_options: 1, next_page_params: 3, split_list_by_page: 1] - - alias BlockScoutWeb.{BridgedTokensView, Controller} - 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 - render(conn, "index.html", - current_path: Controller.current_full_path(conn), - chain: "Ethereum", - chain_id: 1, - destination: :eth - ) - end - - def show(conn, %{"id" => "bsc"}) do - render(conn, "index.html", - current_path: Controller.current_full_path(conn), - chain: "Binance Smart Chain", - chain_id: 56, - destination: :bsc - ) - end - - def show(conn, _params) do - not_found(conn) - end - - def index(conn, %{"type" => "JSON"} = params) do - get_items(conn, params, :eth) - end - - def index(conn, _params) do - render(conn, "index.html", - current_path: Controller.current_full_path(conn), - chain: "Ethereum", - chain_id: 1, - destination: :eth - ) - 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() - - from_api = false - tokens = Chain.list_top_bridged_tokens(destination, filter, from_api, paging_params) - - {tokens_page, next_page} = split_list_by_page(tokens) - - next_page_path = - case next_page_params(next_page, tokens_page, params) do - nil -> - nil - - next_page_params -> - bridged_tokens_path( - conn, - :show, - destination, - Map.delete(next_page_params, "type") - ) - end - - items_count_str = Map.get(params, "items_count") - - items_count = - if items_count_str do - {items_count, _} = Integer.parse(items_count_str) - items_count - else - 0 - end - - items = - tokens_page - |> Enum.with_index(1) - |> Enum.map(fn {[token, bridged_token], index} -> - View.render_to_string( - BridgedTokensView, - "_tile.html", - token: token, - bridged_token: bridged_token, - destination: destination, - index: items_count + index - ) - end) - - json( - conn, - %{ - items: items, - next_page_path: next_page_path - } - ) - end -end 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 8f458907eb..1766274929 100644 --- a/apps/block_scout_web/lib/block_scout_web/etherscan.ex +++ b/apps/block_scout_web/lib/block_scout_web/etherscan.ex @@ -293,35 +293,6 @@ defmodule BlockScoutWeb.Etherscan do "result" => nil } - @token_bridgedtokenlist_example_value %{ - "status" => "1", - "message" => "OK", - "result" => [ - %{ - "foreignChainId" => "1", - "foreignTokenContractAddressHash" => "0x0ae055097c6d159879521c384f1d2123d1f195e6", - "homeContractAddressHash" => "0xb7d311e2eb55f2f68a9440da38e7989210b9a05e", - "homeDecimals" => "18", - "homeHolderCount" => 393, - "homeName" => "STAKE on xDai", - "homeSymbol" => "STAKE", - "homeTotalSupply" => "1484374.775044204093387391", - "homeUsdValue" => "18807028.39981006586321824397" - }, - %{ - "foreignChainId" => "1", - "foreignTokenContractAddressHash" => "0xf5581dfefd8fb0e4aec526be659cfab1f8c781da", - "homeContractAddressHash" => "0xd057604a14982fe8d88c5fc25aac3267ea142a08", - "homeDecimals" => "18", - "homeHolderCount" => 73, - "homeName" => "HOPR Token on xDai", - "homeSymbol" => "HOPR", - "homeTotalSupply" => "26600449.86076749062791602", - "homeUsdValue" => "6638727.472651464170990256943" - } - ] - } - @stats_tokensupply_example_value %{ "status" => "1", "message" => "OK", @@ -622,12 +593,6 @@ defmodule BlockScoutWeb.Etherscan do enum_interpretation: %{"0" => "error", "1" => "ok"} } - @success_status_type %{ - type: "status", - enum: ~s(["1"]), - enum_interpretation: %{"1" => "ok"} - } - @jsonrpc_version_type %{ type: "string", example: ~s("2.0") @@ -773,37 +738,6 @@ defmodule BlockScoutWeb.Etherscan do } } - @bridged_token_details %{ - name: "Bridged Token Detail", - fields: %{ - foreignChainId: %{ - type: "value", - definition: "Chain ID of the chain where original token exists.", - example: ~s("1") - }, - foreignTokenContractAddressHash: @address_hash_type, - homeContractAddressHash: @address_hash_type, - homeDecimals: @token_decimal_type, - homeHolderCount: %{ - type: "value", - definition: "Token holders count.", - example: ~s("393") - }, - homeName: @token_name_type, - homeSymbol: @token_symbol_type, - homeTotalSupply: %{ - type: "value", - definition: "Total supply of the token on the home side (where token was bridged).", - example: ~s("1484374.775044204093387391") - }, - homeUsdValue: %{ - type: "value", - definition: "Total supply of the token on the home side (where token was bridged) in USD.", - example: ~s("6638727.472651464170990256943") - } - } - } - @address_balance %{ name: "AddressBalance", fields: %{ @@ -2055,49 +1989,6 @@ defmodule BlockScoutWeb.Etherscan do ] } - @token_bridgedtokenlist_action %{ - name: "bridgedTokenList", - description: "Get bridged tokens list.", - required_params: [], - optional_params: [ - %{ - key: "chainid", - type: "integer", - description: "A nonnegative integer that represents the chain id, where original token exists." - }, - %{ - key: "page", - type: "integer", - description: - "A nonnegative integer that represents the page number to be used for pagination. 'offset' must be provided in conjunction." - }, - %{ - key: "offset", - type: "integer", - description: - "A nonnegative integer that represents the maximum number of records to return when paginating. 'page' must be provided in conjunction." - } - ], - responses: [ - %{ - code: "200", - description: "successful operation", - example_value: Jason.encode!(@token_bridgedtokenlist_example_value), - model: %{ - name: "Result", - fields: %{ - status: @success_status_type, - message: @message_type, - result: %{ - type: "array", - array_type: @bridged_token_details - } - } - } - } - ] - } - @stats_tokensupply_action %{ name: "tokensupply", description: @@ -3028,8 +2919,7 @@ defmodule BlockScoutWeb.Etherscan do name: "token", actions: [ @token_gettoken_action, - @token_gettokenholders_action, - @token_bridgedtokenlist_action + @token_gettokenholders_action ] } diff --git a/apps/block_scout_web/lib/block_scout_web/templates/address_token/_tokens.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/address_token/_tokens.html.eex index 5fa75a64d4..f42fd4c167 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/address_token/_tokens.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/address_token/_tokens.html.eex @@ -3,8 +3,8 @@ <%= if System.get_env("DISPLAY_TOKEN_ICONS") === "true" do %> - <% chain_id_for_token_icon = if @bridged_token && @bridged_token.foreign_chain_id, do: @bridged_token.foreign_chain_id |> Decimal.to_integer() |> to_string(), else: System.get_env("CHAIN_ID") %> - <% address_hash = if @bridged_token && @bridged_token.foreign_token_contract_address_hash, do: @bridged_token.foreign_token_contract_address_hash, else: @token.contract_address_hash %> + <% chain_id_for_token_icon = System.get_env("CHAIN_ID") %> + <% address_hash = @token.contract_address_hash %> <%= render BlockScoutWeb.TokensView, "_token_icon.html", @@ -38,17 +38,10 @@

- <%= if @bridged_token && @bridged_token.lp_token && @bridged_token.custom_cap do %> - <% lp_token_balance_usd = @token_balance.value |> Decimal.div(@token_balance.token.total_supply) |> Decimal.mult(@bridged_token.custom_cap) |> Decimal.round(4) %> + <%= if @token_balance.token.usd_value do %>

- <%= ChainView.format_usd_value(lp_token_balance_usd) %> + <%= ChainView.format_usd_value(Chain.balance_in_usd(@token_balance)) %>

- <% else %> - <%= if @token_balance.token.usd_value do %> -

- <%= ChainView.format_usd_value(Chain.balance_in_usd(@token_balance)) %> -

- <% end %> <% end %> diff --git a/apps/block_scout_web/lib/block_scout_web/templates/address_token_balance/_token_balances.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/address_token_balance/_token_balances.html.eex index 7dfb671666..d0c1adf636 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/address_token_balance/_token_balances.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/address_token_balance/_token_balances.html.eex @@ -47,7 +47,7 @@ placeholder: gettext("Search tokens") ) %> - <%= if Enum.any?(@token_balances, fn {token_balance, _, _} -> token_balance.token.type == "ERC-721" end) do %> + <%= if Enum.any?(@token_balances, fn {token_balance, _} -> token_balance.token.type == "ERC-721" end) do %> <%= render( "_tokens.html", conn: @conn, @@ -56,7 +56,7 @@ ) %> <% end %> - <%= if Enum.any?(@token_balances, fn {token_balance, _, _} -> token_balance.token.type == "ERC-1155" end) do %> + <%= if Enum.any?(@token_balances, fn {token_balance, _} -> token_balance.token.type == "ERC-1155" end) do %> <%= render( "_tokens.html", conn: @conn, @@ -65,7 +65,7 @@ ) %> <% end %> - <%= if Enum.any?(@token_balances, fn {token_balance, _, _} -> token_balance.token.type == "ERC-20" end) do %> + <%= if Enum.any?(@token_balances, fn {token_balance, _} -> token_balance.token.type == "ERC-20" end) do %> <%= render( "_tokens.html", conn: @conn, diff --git a/apps/block_scout_web/lib/block_scout_web/templates/address_token_balance/_tokens.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/address_token_balance/_tokens.html.eex index 93b6220ce0..ed696b319a 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/address_token_balance/_tokens.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/address_token_balance/_tokens.html.eex @@ -3,7 +3,7 @@ <%= @type %> (<%= Enum.count(@token_balances)%>) - <%= for {token_balance, bridged_token, token} <- sort_by_usd_value_and_name(@token_balances) do %> + <%= for {token_balance, token} <- sort_by_usd_value_and_name(@token_balances) do %>
<% end %> diff --git a/apps/block_scout_web/lib/block_scout_web/templates/layout/_topnav.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/layout/_topnav.html.eex index efafe9ffdd..bd8a2e8be7 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/layout/_topnav.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/layout/_topnav.html.eex @@ -59,60 +59,26 @@ <% end %> - <%= if Chain.bridged_tokens_enabled?() do %> - - <% else %> - - <% end %> + <% end %> <%= if Application.get_env(:block_scout_web, BlockScoutWeb.ApiRouter)[:reading_enabled] || Application.get_env(:block_scout_web, :api_url) do %>