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 =
from(
address in Address,
preload: [:smart_contract],
where: address.hash == ^hash
)

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

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

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

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

@ -1,7 +1,7 @@
defmodule ExplorerWeb.AddressInternalTransactionView do
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
case filter do

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

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

Loading…
Cancel
Save