From 8873774028097992195eaa710611db088e0157dc Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Wed, 4 Sep 2019 14:39:11 +0300 Subject: [PATCH] fix qr code --- .../lib/block_scout_web/views/api_docs_view.ex | 2 +- .../views/tokens/instance/overview_view.ex | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/apps/block_scout_web/lib/block_scout_web/views/api_docs_view.ex b/apps/block_scout_web/lib/block_scout_web/views/api_docs_view.ex index 363a4a0179..a75bd2dcbf 100644 --- a/apps/block_scout_web/lib/block_scout_web/views/api_docs_view.ex +++ b/apps/block_scout_web/lib/block_scout_web/views/api_docs_view.ex @@ -34,7 +34,7 @@ defmodule BlockScoutWeb.APIDocsView do end) end - defp blockscout_url do + def blockscout_url do url_params = Application.get_env(:block_scout_web, BlockScoutWeb.Endpoint)[:url] host = url_params[:host] path = url_params[:path] diff --git a/apps/block_scout_web/lib/block_scout_web/views/tokens/instance/overview_view.ex b/apps/block_scout_web/lib/block_scout_web/views/tokens/instance/overview_view.ex index 41db88febe..e4a6ef6039 100644 --- a/apps/block_scout_web/lib/block_scout_web/views/tokens/instance/overview_view.ex +++ b/apps/block_scout_web/lib/block_scout_web/views/tokens/instance/overview_view.ex @@ -4,6 +4,8 @@ defmodule BlockScoutWeb.Tokens.Instance.OverviewView do alias BlockScoutWeb.CurrencyHelpers alias Explorer.Chain.{Address, SmartContract, Token} + import BlockScoutWeb.APIDocsView, only: [blockscout_url: 0] + def token_name?(%Token{name: nil}), do: false def token_name?(%Token{name: _}), do: true @@ -28,8 +30,11 @@ defmodule BlockScoutWeb.Tokens.Instance.OverviewView do def smart_contract_with_read_only_functions?(%Token{contract_address: %Address{smart_contract: nil}}), do: false def qr_code(conn, token_id, hash) do - conn - |> token_instance_url(:show, to_string(token_id), to_string(hash)) + token_instance_path = token_instance_path(conn, :show, to_string(token_id), to_string(hash)) + + url = blockscout_url() <> token_instance_path + + url |> QRCode.to_png() |> Base.encode64() end