From 352ee9d7bf781b9d73bd0bdfc31589189af41188 Mon Sep 17 00:00:00 2001 From: Victor Baranov Date: Tue, 29 Sep 2020 12:42:37 +0300 Subject: [PATCH] AMB bridged tokens --- CHANGELOG.md | 1 + apps/block_scout_web/assets/css/app.scss | 1 + .../assets/css/components/_label.scss | 19 ++ apps/block_scout_web/config/config.exs | 5 +- .../tokens/bridged_tokens_controller.ex | 3 +- .../templates/bridged_tokens/_tile.html.eex | 31 +- .../templates/bridged_tokens/index.html.eex | 1 + .../templates/layout/_topnav.html.eex | 2 +- .../views/bridged_tokens_view.ex | 19 ++ .../lib/block_scout_web/views/tokens_view.ex | 4 +- apps/explorer/lib/explorer/chain.ex | 282 +++++++++++++----- .../lib/explorer/chain/bridged_token.ex | 8 +- .../20200929075625_add_bridged_token_type.exs | 9 + .../set_amb_bridged_metadata_for_tokens.ex | 39 +++ ...> set_omni_bridged_metadata_for_tokens.ex} | 8 +- apps/indexer/lib/indexer/supervisor.ex | 19 +- 16 files changed, 356 insertions(+), 95 deletions(-) create mode 100644 apps/block_scout_web/assets/css/components/_label.scss create mode 100644 apps/explorer/priv/repo/migrations/20200929075625_add_bridged_token_type.exs create mode 100644 apps/indexer/lib/indexer/set_amb_bridged_metadata_for_tokens.ex rename apps/indexer/lib/indexer/{set_bridged_metadata_for_tokens.ex => set_omni_bridged_metadata_for_tokens.ex} (80%) diff --git a/CHANGELOG.md b/CHANGELOG.md index d61f364197..705fa4f3e6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## Current ### Features +- [#3320](https://github.com/poanetwork/blockscout/pull/3320) - Bridged tokens from AMB extensions support - [#3311](https://github.com/poanetwork/blockscout/pull/3311) - List of addresses with restricted access option - [#3293](https://github.com/poanetwork/blockscout/pull/3293) - Composite market cap for xDai: TokenBridge + OmniBridge - [#3282](https://github.com/poanetwork/blockscout/pull/3282), [#3318](https://github.com/poanetwork/blockscout/pull/3318) - Import bridged tokens custom metadata diff --git a/apps/block_scout_web/assets/css/app.scss b/apps/block_scout_web/assets/css/app.scss index e81af0781f..ded845b4b5 100644 --- a/apps/block_scout_web/assets/css/app.scss +++ b/apps/block_scout_web/assets/css/app.scss @@ -117,6 +117,7 @@ $fa-font-path: "~@fortawesome/fontawesome-free/webfonts"; @import "components/_erc721_token_image_container"; @import "components/_inventory_token_instance_image_container"; @import "components/_external_link"; +@import "components/_label"; @import "theme/dark-theme"; diff --git a/apps/block_scout_web/assets/css/components/_label.scss b/apps/block_scout_web/assets/css/components/_label.scss new file mode 100644 index 0000000000..20dd9fa3d5 --- /dev/null +++ b/apps/block_scout_web/assets/css/components/_label.scss @@ -0,0 +1,19 @@ +.bridged-token-label { + display: inline-block; + padding: 5px; + background: #f5f6fa; + color: #a3a9b5; + border-radius: 5px; + font-size: 10px; + &.right { + float: right; + } + &.omni { + background: $primary; + color: white; + } + &.amb { + background: $secondary; + color: white; + } +} \ No newline at end of file diff --git a/apps/block_scout_web/config/config.exs b/apps/block_scout_web/config/config.exs index 4f696156ea..4d5d3c6fe8 100644 --- a/apps/block_scout_web/config/config.exs +++ b/apps/block_scout_web/config/config.exs @@ -36,8 +36,9 @@ 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"), - multi_token_bridge_mediator: System.get_env("MULTI_TOKEN_BRIDGE_MEDIATOR"), - foreign_json_rpc: System.get_env("FOREIGN_JSON_RPC"), + omni_bridge_mediator: System.get_env("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/controllers/tokens/bridged_tokens_controller.ex b/apps/block_scout_web/lib/block_scout_web/controllers/tokens/bridged_tokens_controller.ex index 815077567f..3aeea6602f 100644 --- 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 @@ -31,11 +31,12 @@ defmodule BlockScoutWeb.BridgedTokensController do items = tokens_page |> Enum.with_index(1) - |> Enum.map(fn {token, index} -> + |> Enum.map(fn {[token, bridged_token], index} -> View.render_to_string( BridgedTokensView, "_tile.html", token: token, + bridged_token: bridged_token, index: index ) end) diff --git a/apps/block_scout_web/lib/block_scout_web/templates/bridged_tokens/_tile.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/bridged_tokens/_tile.html.eex index 094a16442a..49cad1f047 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/bridged_tokens/_tile.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/bridged_tokens/_tile.html.eex @@ -7,10 +7,33 @@ <% token = token_display_name(@token) %> - <%= link(token, - to: token_path(BlockScoutWeb.Endpoint, :show, @token.contract_address_hash), - "data-test": "token_link", - class: "text-truncate") %> +
+ <%= link(token, + to: token_path(BlockScoutWeb.Endpoint, :show, @token.contract_address_hash), + "data-test": "token_link", + class: "text-truncate") %> + <%= if @bridged_token.type do %> +
<%= String.upcase(@bridged_token.type) %>
+ <% end %> + <%= if owl_token_amb?(@token.contract_address.hash) do %> + + + + <% end %> + <%= if owl_token_omni?(@token.contract_address.hash) do %> + + + + <% end %> +
<%= render BlockScoutWeb.AddressView, diff --git a/apps/block_scout_web/lib/block_scout_web/templates/bridged_tokens/index.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/bridged_tokens/index.html.eex index 5b76450d69..6277ab16cd 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/bridged_tokens/index.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/bridged_tokens/index.html.eex @@ -2,6 +2,7 @@

<%= gettext "Bridged Tokens" %>

+

List of the tokens bridged through OmniBridge OMNI and Arbitrary Message Bridge AMB extensions

<%= 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 %> 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 c8b4a8f7b5..32e1d4ea9a 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 @@ -78,7 +78,7 @@ <%= gettext("Accounts") %> <% end %> - <%= if Application.get_env(:block_scout_web, :multi_token_bridge_mediator) && Application.get_env(:block_scout_web, :multi_token_bridge_mediator) != "" do %> + <%= if Application.get_env(:block_scout_web, :omni_bridge_mediator) && Application.get_env(:block_scout_web, :omni_bridge_mediator) != "" do %>