Skip to content

Commit

Permalink
Update ex_abi to 0.5.7; add decoding revert reason for contract inter…
Browse files Browse the repository at this point in the history
…action tx
  • Loading branch information
nikitosing committed Oct 17, 2021
1 parent eaadac2 commit 0762186
Show file tree
Hide file tree
Showing 9 changed files with 244 additions and 183 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## Current

### Features
- [#4777](https://github.com/blockscout/blockscout/pull/4777) - Added decoding revert reason
- [#4761](https://github.com/blockscout/blockscout/pull/4761) - ERC-1155 support
- [#4739](https://github.com/blockscout/blockscout/pull/4739) - Improve logs and inputs decoding
- [#4747](https://github.com/blockscout/blockscout/pull/4747) - Advanced CSV export
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<div class="table-responsive text-center">
<table style="color: black;" summary="<%= gettext "Transaction Inputs" %>" class="table thead-light table-bordered">
<%= if !assigns[:error] do %>
<tr>
<td><%= gettext "Method Id" %></td>
<td colspan="3"><code>0x<%= @method_id %></code></td>
</tr>
<% end %>
<tr>
<td><%= gettext "Method Id" %></td>
<td colspan="3"><code>0x<%= @method_id %></code></td>
</tr>
<tr>
<td>Call</td>
<td><%= if assigns[:error], do: gettext("Error"), else: gettext("Call") %></td>
<td colspan="3"><code><%= @text %></code></td>
</tr>
</table>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,25 @@
text: gettext("The revert reason of the transaction.") %>
<%= gettext "Revert reason" %> </dt>
<dd class="col-sm-9 col-lg-10">
<%= BlockScoutWeb.TransactionView.transaction_revert_reason(@transaction) %>
<%= case BlockScoutWeb.TransactionView.transaction_revert_reason(@transaction) do %>
<% {:error, :contract_not_verified, []} -> %>
<div class="tx-raw-input">
<div class="tile tile-muted">
<pre class="pre-scrollable pre-scrollable-shorty pre-wrap mb-0"><code><%= BlockScoutWeb.TransactionView.get_pure_transaction_revert_reason(@transaction) %></code></pre>
</div>
</div>
<% {:error, :contract_not_verified, candidates} -> %>
<% {:ok, method_id, text, mapping} = Enum.at(candidates, 0) %>
<%= render(BlockScoutWeb.TransactionView, "_decoded_input_body.html", method_id: method_id, text: text, mapping: mapping, error: true) %>
<% {:ok, method_id, text, mapping} -> %>
<%= render(BlockScoutWeb.TransactionView, "_decoded_input_body.html", method_id: method_id, text: text, mapping: mapping, error: true) %>
<% _ -> %>
<div class="tx-raw-input">
<div class="tile tile-muted">
<pre class="pre-scrollable pre-scrollable-shorty pre-wrap mb-0"><code><%= BlockScoutWeb.TransactionView.get_pure_transaction_revert_reason(@transaction) %></code></pre>
</div>
</div>
<% end %>
</dd>
</dl>
<% end %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,9 +328,11 @@ defmodule BlockScoutWeb.TransactionView do
end

def transaction_revert_reason(transaction) do
Chain.transaction_to_revert_reason(transaction)
transaction |> Chain.transaction_to_revert_reason() |> decoded_revert_reason(transaction)
end

def get_pure_transaction_revert_reason(transaction), do: Chain.transaction_to_revert_reason(transaction)

def empty_exchange_rate?(exchange_rate) do
Token.null?(exchange_rate)
end
Expand Down Expand Up @@ -371,6 +373,10 @@ defmodule BlockScoutWeb.TransactionView do
Transaction.decoded_input_data(transaction)
end

def decoded_revert_reason(revert_reason, transaction) do
Transaction.decoded_revert_reason(transaction, revert_reason)
end

@doc """
Converts a transaction's gas price to a displayable value.
"""
Expand Down
Loading

0 comments on commit 0762186

Please sign in to comment.