Merge pull request #3536 from poanetwork/vb-revert-reason-in-call

Revert reason in the result of contract's method call
pull/3540/head
Victor Baranov 4 years ago committed by GitHub
commit 46a5d28ee7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      CHANGELOG.md
  2. 6
      apps/block_scout_web/lib/block_scout_web/controllers/smart_contract_controller.ex
  3. 4
      apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/encoder.ex
  4. 2
      apps/ethereum_jsonrpc/test/ethereum_jsonrpc/contract_test.exs
  5. 2
      apps/explorer/test/explorer/token/balance_reader_test.exs

@ -1,6 +1,7 @@
## Current ## Current
### Features ### Features
- [#3536](https://github.com/poanetwork/blockscout/pull/3536) - Revert reason in the result of contract's method call
- [#3532](https://github.com/poanetwork/blockscout/pull/3532) - Contract interaction: an easy setting of precision for integer input - [#3532](https://github.com/poanetwork/blockscout/pull/3532) - Contract interaction: an easy setting of precision for integer input
- [#3531](https://github.com/poanetwork/blockscout/pull/3531) - Allow double quotes in input data of contract methods - [#3531](https://github.com/poanetwork/blockscout/pull/3531) - Allow double quotes in input data of contract methods
- [#3515](https://github.com/poanetwork/blockscout/pull/3515) - CRC total balance - [#3515](https://github.com/poanetwork/blockscout/pull/3515) - CRC total balance

@ -4,6 +4,8 @@ defmodule BlockScoutWeb.SmartContractController do
alias Explorer.Chain alias Explorer.Chain
alias Explorer.SmartContract.{Reader, Writer} alias Explorer.SmartContract.{Reader, Writer}
@burn_address "0x0000000000000000000000000000000000000000"
def index(conn, %{"hash" => address_hash_string, "type" => contract_type, "action" => action}) do def index(conn, %{"hash" => address_hash_string, "type" => contract_type, "action" => action}) do
address_options = [ address_options = [
necessity_by_association: %{ necessity_by_association: %{
@ -17,9 +19,9 @@ defmodule BlockScoutWeb.SmartContractController do
implementation_address_hash_string = implementation_address_hash_string =
if contract_type == "proxy" do if contract_type == "proxy" do
Chain.get_implementation_address_hash(address.hash, address.smart_contract.abi) || Chain.get_implementation_address_hash(address.hash, address.smart_contract.abi) ||
"0x0000000000000000000000000000000000000000" @burn_address
else else
"0x0000000000000000000000000000000000000000" @burn_address
end end
functions = functions =

@ -47,6 +47,10 @@ defmodule EthereumJSONRPC.Encoder do
""" """
@spec decode_result(map(), %ABI.FunctionSelector{} | [%ABI.FunctionSelector{}]) :: @spec decode_result(map(), %ABI.FunctionSelector{} | [%ABI.FunctionSelector{}]) ::
{String.t(), {:ok, any()} | {:error, String.t() | :invalid_data}} {String.t(), {:ok, any()} | {:error, String.t() | :invalid_data}}
def decode_result(%{error: %{code: code, data: data, message: message}, id: id}, _selector) do
{id, {:error, "(#{code}) #{message} (#{data})"}}
end
def decode_result(%{error: %{code: code, message: message}, id: id}, _selector) do def decode_result(%{error: %{code: code, message: message}, id: id}, _selector) do
{id, {:error, "(#{code}) #{message}"}} {id, {:error, "(#{code}) #{message}"}}
end end

@ -82,7 +82,7 @@ defmodule EthereumJSONRPC.ContractTest do
blockchain_result = [ blockchain_result = [
{:ok, [42]}, {:ok, [42]},
{:ok, [52]}, {:ok, [52]},
{:error, "(-32015) Some error"} {:error, "(-32015) Some error (something)"}
] ]
assert EthereumJSONRPC.execute_contract_functions( assert EthereumJSONRPC.execute_contract_functions(

@ -55,7 +55,7 @@ defmodule Explorer.Token.BalanceReaderTest do
} }
]) ])
assert result == [{:error, "(-32015) VM execution error."}] assert result == [{:error, "(-32015) VM execution error. (Reverted 0x)"}]
end end
end end

Loading…
Cancel
Save