Add check mark in tab when smart contract is verified

pull/182/head
Amanda Sposito 7 years ago
parent 8fbab5cac3
commit 57f6b4d6d1
  1. 1
      apps/explorer/lib/explorer/chain.ex
  2. 3
      apps/explorer/test/explorer/smart_contract/verifier_test.exs
  3. 12
      apps/explorer_web/lib/explorer_web/templates/address_internal_transaction/index.html.eex
  4. 12
      apps/explorer_web/lib/explorer_web/templates/address_transaction/index.html.eex
  5. 5
      apps/explorer_web/lib/explorer_web/views/address_contract_view.ex
  6. 2
      apps/explorer_web/lib/explorer_web/views/address_internal_transaction_view.ex
  7. 2
      apps/explorer_web/lib/explorer_web/views/address_transaction_view.ex
  8. 6
      apps/explorer_web/lib/explorer_web/views/address_view.ex

@ -491,6 +491,7 @@ defmodule Explorer.Chain do
query = query =
from( from(
address in Address, address in Address,
preload: [:smart_contract],
where: address.hash == ^hash where: address.hash == ^hash
) )

@ -64,8 +64,7 @@ defmodule Explorer.SmartContract.VerifierTest do
address_hash = "0x0f95fa9bc0383e699325f2658d04e8d96d87b90c" address_hash = "0x0f95fa9bc0383e699325f2658d04e8d96d87b90c"
params = %{ params = %{
"contract_source_code" => "contract_source_code" => "pragma solidity ^0.4.24; contract SimpleStorage { ",
"pragma solidity ^0.4.24; contract SimpleStorage { ",
"compiler" => "0.4.24", "compiler" => "0.4.24",
"name" => "SimpleStorage", "name" => "SimpleStorage",
"optimization" => false "optimization" => false

@ -24,10 +24,14 @@
<%= if contract?(@address) do %> <%= if contract?(@address) do %>
<li class="nav-item"> <li class="nav-item">
<%= link( <%= link(
gettext("Code"), to: address_contract_path(@conn, :index, @conn.assigns.locale, @conn.params["address_id"]),
class: "nav-link", class: "nav-link") do %>
to: address_contract_path(@conn, :index, @conn.assigns.locale, @conn.params["address_id"]) <%= gettext("Code") %>
) %>
<%= if smart_contract_verified?(@address) do %>
<i class="far fa-check-circle"></i>
<% end %>
<% end %>
</li> </li>
<% end %> <% end %>
</ul> </ul>

@ -24,10 +24,14 @@
<%= if contract?(@address) do %> <%= if contract?(@address) do %>
<li class="nav-item"> <li class="nav-item">
<%= link( <%= link(
gettext("Code"), to: address_contract_path(@conn, :index, @conn.assigns.locale, @conn.params["address_id"]),
class: "nav-link", class: "nav-link") do %>
to: address_contract_path(@conn, :index, @conn.assigns.locale, @conn.params["address_id"]) <%= gettext("Code") %>
) %>
<%= if smart_contract_verified?(@address) do %>
<i class="far fa-check-circle"></i>
<% end %>
<% end %>
</li> </li>
<% end %> <% end %>
</ul> </ul>

@ -1,8 +1,5 @@
defmodule ExplorerWeb.AddressContractView do defmodule ExplorerWeb.AddressContractView do
use ExplorerWeb, :view use ExplorerWeb, :view
alias Explorer.Chain.{Address, SmartContract} import ExplorerWeb.AddressView, only: [smart_contract_verified?: 1]
def smart_contract_verified?(%Address{smart_contract: nil}), do: false
def smart_contract_verified?(%Address{smart_contract: %SmartContract{}}), do: true
end end

@ -1,7 +1,7 @@
defmodule ExplorerWeb.AddressInternalTransactionView do defmodule ExplorerWeb.AddressInternalTransactionView do
use ExplorerWeb, :view use ExplorerWeb, :view
import ExplorerWeb.AddressView, only: [contract?: 1] import ExplorerWeb.AddressView, only: [contract?: 1, smart_contract_verified?: 1]
def format_current_filter(filter) do def format_current_filter(filter) do
case filter do case filter do

@ -1,7 +1,7 @@
defmodule ExplorerWeb.AddressTransactionView do defmodule ExplorerWeb.AddressTransactionView do
use ExplorerWeb, :view use ExplorerWeb, :view
import ExplorerWeb.AddressView, only: [contract?: 1] import ExplorerWeb.AddressView, only: [contract?: 1, smart_contract_verified?: 1]
alias ExplorerWeb.TransactionView alias ExplorerWeb.TransactionView

@ -1,7 +1,8 @@
defmodule ExplorerWeb.AddressView do defmodule ExplorerWeb.AddressView do
use ExplorerWeb, :view use ExplorerWeb, :view
alias Explorer.Chain.{Address, Wei} alias Explorer.Chain.{Address, Wei, SmartContract}
alias Explorer.ExchangeRates.Token alias Explorer.ExchangeRates.Token
alias ExplorerWeb.ExchangeRates.USD alias ExplorerWeb.ExchangeRates.USD
@ -51,4 +52,7 @@ defmodule ExplorerWeb.AddressView do
|> QRCode.to_png() |> QRCode.to_png()
|> Base.encode64() |> Base.encode64()
end end
def smart_contract_verified?(%Address{smart_contract: %SmartContract{}}), do: true
def smart_contract_verified?(%Address{smart_contract: nil}), do: false
end end

Loading…
Cancel
Save