fix qr code

pull/2642/head
Ayrat Badykov 5 years ago
parent 834688d894
commit 8873774028
No known key found for this signature in database
GPG Key ID: B44668E265E9396F
  1. 2
      apps/block_scout_web/lib/block_scout_web/views/api_docs_view.ex
  2. 9
      apps/block_scout_web/lib/block_scout_web/views/tokens/instance/overview_view.ex

@ -34,7 +34,7 @@ defmodule BlockScoutWeb.APIDocsView do
end) end)
end end
defp blockscout_url do def blockscout_url do
url_params = Application.get_env(:block_scout_web, BlockScoutWeb.Endpoint)[:url] url_params = Application.get_env(:block_scout_web, BlockScoutWeb.Endpoint)[:url]
host = url_params[:host] host = url_params[:host]
path = url_params[:path] path = url_params[:path]

@ -4,6 +4,8 @@ defmodule BlockScoutWeb.Tokens.Instance.OverviewView do
alias BlockScoutWeb.CurrencyHelpers alias BlockScoutWeb.CurrencyHelpers
alias Explorer.Chain.{Address, SmartContract, Token} 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: nil}), do: false
def token_name?(%Token{name: _}), do: true 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 smart_contract_with_read_only_functions?(%Token{contract_address: %Address{smart_contract: nil}}), do: false
def qr_code(conn, token_id, hash) do def qr_code(conn, token_id, hash) do
conn token_instance_path = token_instance_path(conn, :show, to_string(token_id), to_string(hash))
|> token_instance_url(:show, to_string(token_id), to_string(hash))
url = blockscout_url() <> token_instance_path
url
|> QRCode.to_png() |> QRCode.to_png()
|> Base.encode64() |> Base.encode64()
end end

Loading…
Cancel
Save