pull/2642/head
Ayrat Badykov 5 years ago
parent 97dc5adbad
commit 471b905930
No known key found for this signature in database
GPG Key ID: B44668E265E9396F
  1. 15
      apps/block_scout_web/lib/block_scout_web/templates/tokens/instance/overview/_tabs.html.eex
  2. 10
      apps/block_scout_web/lib/block_scout_web/views/tokens/instance/overview_view.ex

@ -0,0 +1,15 @@
<div class="card-tabs js-card-tabs">
<%= link(
gettext("Token Transfers"),
class: "card-tab #{tab_status("token_transfers", @conn.request_path)}",
to: token_path(@conn, :show, @token.contract_address_hash)
)
%>
<%= if smart_contract_with_read_only_functions?(@token) do %>
<%= link(
gettext("Read Contract"),
to: token_read_contract_path(@conn, :index, @token.contract_address_hash),
class: "card-tab #{tab_status("read_contract", @conn.request_path)}")
%>
<% end %>
</div>

@ -1,8 +1,8 @@
defmodule BlockScoutWeb.Tokens.Instance.OverviewView do defmodule BlockScoutWeb.Tokens.Instance.OverviewView do
use BlockScoutWeb, :view use BlockScoutWeb, :view
alias Explorer.Chain.Token
alias BlockScoutWeb.CurrencyHelpers alias BlockScoutWeb.CurrencyHelpers
alias Explorer.Chain.{Address, SmartContract, Token}
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
@ -18,4 +18,12 @@ defmodule BlockScoutWeb.Tokens.Instance.OverviewView do
price = token.usd_value price = token.usd_value
Decimal.mult(tokens, price) Decimal.mult(tokens, price)
end end
def smart_contract_with_read_only_functions?(
%Token{contract_address: %Address{smart_contract: %SmartContract{}}} = token
) do
Enum.any?(token.contract_address.smart_contract.abi, & &1["constant"])
end
def smart_contract_with_read_only_functions?(%Token{contract_address: %Address{smart_contract: nil}}), do: false
end end

Loading…
Cancel
Save