Merge pull request #4776 from blockscout/np-add-reverted-msgs-view

Added view for unsuccessfully fetched values from read functions
pull/4777/head
Victor Baranov 3 years ago committed by GitHub
commit 2bd8c5ff34
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      CHANGELOG.md
  2. 50
      apps/block_scout_web/lib/block_scout_web/templates/smart_contract/_functions.html.eex
  3. 9
      apps/block_scout_web/lib/block_scout_web/views/smart_contract_view.ex
  4. 4
      apps/block_scout_web/priv/gettext/default.pot
  5. 4
      apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po

@ -1,6 +1,7 @@
## Current ## Current
### Features ### Features
- [#4776](https://github.com/blockscout/blockscout/pull/4776) - Added view for unsuccessfully fetched values from read functions
- [#4761](https://github.com/blockscout/blockscout/pull/4761) - ERC-1155 support - [#4761](https://github.com/blockscout/blockscout/pull/4761) - ERC-1155 support
- [#4739](https://github.com/blockscout/blockscout/pull/4739) - Improve logs and inputs decoding - [#4739](https://github.com/blockscout/blockscout/pull/4739) - Improve logs and inputs decoding
- [#4747](https://github.com/blockscout/blockscout/pull/4747) - Advanced CSV export - [#4747](https://github.com/blockscout/blockscout/pull/4747) - Advanced CSV export

@ -105,32 +105,38 @@
<div data-function-response></div> <div data-function-response></div>
</div> </div>
<% else %> <% else %>
<%= if outputs?(function["outputs"]) do %> <%= cond do %>
<% length = Enum.count(function["outputs"]) %> <%= outputs?(function["outputs"]) -> %>
<%= for {output, index} <- Enum.with_index(function["outputs"]) do %> <% length = Enum.count(function["outputs"]) %>
<%= if address?(output["type"]) do %> <%= for {output, index} <- Enum.with_index(function["outputs"]) do %>
<div class="py-2 word-break-all"> <%= if address?(output["type"]) do %>
<%= link(
output["value"],
to: address_path(@conn, :show, output["value"])) %><%= if length > 1 and index < length - 1 do %>,&#160;<% end %>
</div>
<% else %>
<%= if output["type"] == "uint256" do %>
<div class="py-2 word-break-all"> <div class="py-2 word-break-all">
<div data-wei-ether-converter> <%= link(
<span data-conversion-unit data-original-value="<%= output["value"] %>"><%= output["value"] %></span> output["value"],
<span class="py-2 px-2"> to: address_path(@conn, :show, output["value"])) %><%= if length > 1 and index < length - 1 do %>,&#160;<% end %>
<input class="wei-ether" type="checkbox" autocomplete="off"> </div>
<span class="d-inline-block" data-conversion-text-wei><%= gettext("WEI")%></span>
<span class="d-none" data-conversion-text-eth><%= gettext("ETH")%></span>
</span>
</div>
</div>
<% else %> <% else %>
<%= raw(values_only(output["value"], output["type"], output["components"])) %> <%= if output["type"] == "uint256" do %>
<div class="py-2 word-break-all">
<div data-wei-ether-converter>
<span data-conversion-unit data-original-value="<%= output["value"] %>"><%= output["value"] %></span>
<span class="py-2 px-2">
<input class="wei-ether" type="checkbox" autocomplete="off">
<span class="d-inline-block" data-conversion-text-wei><%= gettext("WEI")%></span>
<span class="d-none" data-conversion-text-eth><%= gettext("ETH")%></span>
</span>
</div>
</div>
<% else %>
<%= raw(values_only(output["value"], output["type"], output["components"])) %>
<% end %>
<% end %> <% end %>
<% end %> <% end %>
<% end %> <% error?(function["outputs"]) -> %>
<% {:error, text_error} = function["outputs"] %>
<div class="alert alert-danger py-2 word-break-all" style="margin-bottom: 0;"><%= text_error %></div>
<% true -> %>
<% nil %>
<% end %> <% end %>
<% end %> <% end %>
</div> </div>

@ -26,6 +26,15 @@ defmodule BlockScoutWeb.SmartContractView do
def outputs?(outputs) when is_nil(outputs), do: false def outputs?(outputs) when is_nil(outputs), do: false
def error?(outputs) when not is_nil(outputs) do
case outputs do
{:error, _} -> true
_ -> false
end
end
def error?(outputs) when is_nil(outputs), do: false
def address?(type), do: type in ["address", "address payable"] def address?(type), do: type in ["address", "address payable"]
def int?(type), do: String.contains?(type, "int") && !String.contains?(type, "[") def int?(type), do: String.contains?(type, "int") && !String.contains?(type, "[")

@ -999,7 +999,7 @@ msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/address_token/overview.html.eex:1 #: lib/block_scout_web/templates/address_token/overview.html.eex:1
#: lib/block_scout_web/templates/smart_contract/_functions.html.eex:89 lib/block_scout_web/templates/smart_contract/_functions.html.eex:89 #: lib/block_scout_web/templates/smart_contract/_functions.html.eex:89 lib/block_scout_web/templates/smart_contract/_functions.html.eex:89
#: lib/block_scout_web/templates/smart_contract/_functions.html.eex:125 #: lib/block_scout_web/templates/smart_contract/_functions.html.eex:126
msgid "ETH" msgid "ETH"
msgstr "" msgstr ""
@ -2938,7 +2938,7 @@ msgid "Vyper contract"
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/smart_contract/_functions.html.eex:124 #: lib/block_scout_web/templates/smart_contract/_functions.html.eex:125
msgid "WEI" msgid "WEI"
msgstr "" msgstr ""

@ -999,7 +999,7 @@ msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/address_token/overview.html.eex:1 #: lib/block_scout_web/templates/address_token/overview.html.eex:1
#: lib/block_scout_web/templates/smart_contract/_functions.html.eex:89 lib/block_scout_web/templates/smart_contract/_functions.html.eex:89 #: lib/block_scout_web/templates/smart_contract/_functions.html.eex:89 lib/block_scout_web/templates/smart_contract/_functions.html.eex:89
#: lib/block_scout_web/templates/smart_contract/_functions.html.eex:125 #: lib/block_scout_web/templates/smart_contract/_functions.html.eex:126
msgid "ETH" msgid "ETH"
msgstr "" msgstr ""
@ -2938,7 +2938,7 @@ msgid "Vyper contract"
msgstr "" msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/smart_contract/_functions.html.eex:124 #: lib/block_scout_web/templates/smart_contract/_functions.html.eex:125
msgid "WEI" msgid "WEI"
msgstr "" msgstr ""

Loading…
Cancel
Save