Skip to content
This repository has been archived by the owner on Feb 24, 2025. It is now read-only.

Commit

Permalink
Add sanction tag to read contract controllers + templates (#983)
Browse files Browse the repository at this point in the history
* Add sanctioned addresses to read contract + proxy controller & token contract controller.

* Fix checks.
  • Loading branch information
rkachowski authored Oct 18, 2023
1 parent 732db76 commit 4c4f1b1
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ defmodule BlockScoutWeb.AddressReadContractController do
type: :regular,
action: :read,
custom_abi: custom_abi?,
exchange_rate: Market.get_exchange_rate(Explorer.coin()) || Token.null()
exchange_rate: Market.get_exchange_rate(Explorer.coin()) || Token.null(),
sanctions: Explorer.Celo.SanctionCache.get_sanction_list()
]

with {:ok, address_hash} <- Chain.string_to_address_hash(address_hash_string),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ defmodule BlockScoutWeb.AddressReadProxyController do
exchange_rate: Market.get_exchange_rate(Explorer.coin()) || Token.null(),
counters_path: address_path(conn, :address_counters, %{"id" => Address.checksum(address_hash)}),
tags: get_address_tags(address_hash, current_user(conn)),
celo_epoch: EpochUtil.get_address_summary(address)
celo_epoch: EpochUtil.get_address_summary(address),
sanctions: Explorer.Celo.SanctionCache.get_sanction_list()
)
else
_ ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ defmodule BlockScoutWeb.Tokens.ContractController do
import BlockScoutWeb.Models.GetAddressTags, only: [get_address_tags: 2]

alias BlockScoutWeb.{AccessHelpers, TabHelpers}
alias Explorer.Celo.SanctionCache
alias Explorer.{Chain, Market}
alias Explorer.Chain.Address

Expand Down Expand Up @@ -37,7 +38,8 @@ defmodule BlockScoutWeb.Tokens.ContractController do
action: action,
token: Market.add_price(token),
counters_path: token_path(conn, :token_counters, %{"id" => Address.checksum(address_hash)}),
tags: get_address_tags(address_hash, current_user(conn))
tags: get_address_tags(address_hash, current_user(conn)),
sanctions: SanctionCache.get_sanction_list()
)
else
{:restricted_access, _} ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,13 @@
tags: @tags,
celo_epoch: @celo_epoch
%>
<%
{:ok, sanctions} = Jason.encode(@sanctions)
%>

<div class="card">
<%= render BlockScoutWeb.AddressView, "_tabs.html", address: @address, is_proxy: is_proxy, conn: @conn %>
<div id="sanctions" data-sanctions=<%= sanctions %> hidden ></div>
<%= render BlockScoutWeb.AddressView, "_tabs.html", address: @address, is_proxy: is_proxy, conn: @conn %>
<%= if @need_wallet do %>
<div class="card-misc-container">
<%= render BlockScoutWeb.SmartContractView, "_connect_container.html" %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@
tags: @tags,
celo_epoch: @celo_epoch
%>
<%
{:ok, sanctions} = Jason.encode(@sanctions)
%>

<div class="card">
<div id="sanctions" data-sanctions=<%= sanctions %> hidden ></div>
<%= render BlockScoutWeb.AddressView, "_tabs.html", address: @address, is_proxy: is_proxy, conn: @conn %>
<!-- loaded via AJAX -->
<div class="card-body" data-smart-contract-functions data-hash="<%= to_string(@address.hash) %>" data-type="<%= @type %>" data-action="<%= @action %>" data-url="<%= smart_contract_path(@conn, :index) %>">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,13 @@
conn: @conn
) %>

<%
{:ok, sanctions} = Jason.encode(@sanctions)
%>

<section>
<div class="card">
<div id="sanctions" data-sanctions=<%= sanctions %> hidden ></div>
<%= render OverviewView, "_tabs.html", assigns %>
<!-- loaded via AJAX -->
<div class="card-body" data-smart-contract-functions data-hash="<%= Address.checksum(@token.contract_address.hash) %>" data-type="<%= @type %>" data-action="<%= @action %>" data-url="<%= smart_contract_path(@conn, :index) %>">
Expand Down
14 changes: 7 additions & 7 deletions apps/block_scout_web/priv/gettext/default.pot
Original file line number Diff line number Diff line change
Expand Up @@ -918,7 +918,7 @@ msgstr ""
msgid "Current transaction state: Success, Failed (Error), or Pending (In Process)"
msgstr ""

#: lib/block_scout_web/templates/address_read_contract/index.html.eex:29
#: lib/block_scout_web/templates/address_read_contract/index.html.eex:33
#: lib/block_scout_web/templates/address_write_contract/index.html.eex:32
#, elixir-autogen, elixir-format
msgid "Custom"
Expand All @@ -932,7 +932,7 @@ msgstr ""
msgid "Custom ABI"
msgstr ""

#: lib/block_scout_web/templates/address_read_contract/index.html.eex:34
#: lib/block_scout_web/templates/address_read_contract/index.html.eex:38
#: lib/block_scout_web/templates/address_write_contract/index.html.eex:37
#, elixir-autogen, elixir-format
msgid "Custom ABI from account"
Expand Down Expand Up @@ -1566,13 +1566,13 @@ msgstr ""
#: lib/block_scout_web/templates/address_contract_verification_via_multi_part_files/new.html.eex:99
#: lib/block_scout_web/templates/address_contract_verification_via_standard_json_input/new.html.eex:49
#: lib/block_scout_web/templates/address_contract_verification_vyper/new.html.eex:45
#: lib/block_scout_web/templates/address_read_contract/index.html.eex:50
#: lib/block_scout_web/templates/address_read_contract/index.html.eex:58
#: lib/block_scout_web/templates/address_read_proxy/index.html.eex:21
#: lib/block_scout_web/templates/address_read_contract/index.html.eex:54
#: lib/block_scout_web/templates/address_read_contract/index.html.eex:62
#: lib/block_scout_web/templates/address_read_proxy/index.html.eex:25
#: lib/block_scout_web/templates/address_write_contract/index.html.eex:53
#: lib/block_scout_web/templates/address_write_contract/index.html.eex:61
#: lib/block_scout_web/templates/address_write_proxy/index.html.eex:26
#: lib/block_scout_web/templates/tokens/contract/index.html.eex:17
#: lib/block_scout_web/templates/tokens/contract/index.html.eex:22
#, elixir-autogen, elixir-format
msgid "Loading..."
msgstr ""
Expand Down Expand Up @@ -2986,7 +2986,7 @@ msgstr ""
msgid "Value"
msgstr ""

#: lib/block_scout_web/templates/address_read_contract/index.html.eex:26
#: lib/block_scout_web/templates/address_read_contract/index.html.eex:30
#: lib/block_scout_web/templates/address_write_contract/index.html.eex:29
#: lib/block_scout_web/templates/verified_contracts/_tile.html.eex:49
#: lib/block_scout_web/templates/verified_contracts/index.html.eex:74
Expand Down
14 changes: 7 additions & 7 deletions apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po
Original file line number Diff line number Diff line change
Expand Up @@ -918,7 +918,7 @@ msgstr ""
msgid "Current transaction state: Success, Failed (Error), or Pending (In Process)"
msgstr ""

#: lib/block_scout_web/templates/address_read_contract/index.html.eex:29
#: lib/block_scout_web/templates/address_read_contract/index.html.eex:33
#: lib/block_scout_web/templates/address_write_contract/index.html.eex:32
#, elixir-autogen, elixir-format
msgid "Custom"
Expand All @@ -932,7 +932,7 @@ msgstr ""
msgid "Custom ABI"
msgstr ""

#: lib/block_scout_web/templates/address_read_contract/index.html.eex:34
#: lib/block_scout_web/templates/address_read_contract/index.html.eex:38
#: lib/block_scout_web/templates/address_write_contract/index.html.eex:37
#, elixir-autogen, elixir-format
msgid "Custom ABI from account"
Expand Down Expand Up @@ -1566,13 +1566,13 @@ msgstr ""
#: lib/block_scout_web/templates/address_contract_verification_via_multi_part_files/new.html.eex:99
#: lib/block_scout_web/templates/address_contract_verification_via_standard_json_input/new.html.eex:49
#: lib/block_scout_web/templates/address_contract_verification_vyper/new.html.eex:45
#: lib/block_scout_web/templates/address_read_contract/index.html.eex:50
#: lib/block_scout_web/templates/address_read_contract/index.html.eex:58
#: lib/block_scout_web/templates/address_read_proxy/index.html.eex:21
#: lib/block_scout_web/templates/address_read_contract/index.html.eex:54
#: lib/block_scout_web/templates/address_read_contract/index.html.eex:62
#: lib/block_scout_web/templates/address_read_proxy/index.html.eex:25
#: lib/block_scout_web/templates/address_write_contract/index.html.eex:53
#: lib/block_scout_web/templates/address_write_contract/index.html.eex:61
#: lib/block_scout_web/templates/address_write_proxy/index.html.eex:26
#: lib/block_scout_web/templates/tokens/contract/index.html.eex:17
#: lib/block_scout_web/templates/tokens/contract/index.html.eex:22
#, elixir-autogen, elixir-format
msgid "Loading..."
msgstr ""
Expand Down Expand Up @@ -2986,7 +2986,7 @@ msgstr ""
msgid "Value"
msgstr ""

#: lib/block_scout_web/templates/address_read_contract/index.html.eex:26
#: lib/block_scout_web/templates/address_read_contract/index.html.eex:30
#: lib/block_scout_web/templates/address_write_contract/index.html.eex:29
#: lib/block_scout_web/templates/verified_contracts/_tile.html.eex:49
#: lib/block_scout_web/templates/verified_contracts/index.html.eex:74
Expand Down

0 comments on commit 4c4f1b1

Please sign in to comment.