Skip to content

Commit

Permalink
Fix ABI read functions filter (#7636)
Browse files Browse the repository at this point in the history
* Fix ABI read functions filter

* Changelog

* Drop empty_inputs?/1
  • Loading branch information
nikitosing committed Jun 5, 2023
1 parent e81f2ee commit 566a670
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

### Fixes

- [#7636](https://github.com/blockscout/blockscout/pull/7636) - Remove receive from read methods
- [#7635](https://github.com/blockscout/blockscout/pull/7635) - Fix single 1155 transfer displaying
- [#7629](https://github.com/blockscout/blockscout/pull/7629) - Fix NFT fetcher
- [#7614](https://github.com/blockscout/blockscout/pull/7614) - API and smart-contracts fixes and improvements
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,7 @@ defmodule BlockScoutWeb.API.V2.SmartContractControllerTest do
"inputs" => [%{"type" => "bool", "name" => "disable", "internalType" => "bool"}]
},
%{"type" => "fallback"},
%{"type" => "receive"},
%{
"type" => "function",
"stateMutability" => "view",
Expand Down Expand Up @@ -626,6 +627,7 @@ defmodule BlockScoutWeb.API.V2.SmartContractControllerTest do
} in response

refute %{"type" => "fallback"} in response
refute %{"type" => "receive"} in response
end

test "get array of addresses within read-methods", %{conn: conn} do
Expand Down
9 changes: 2 additions & 7 deletions apps/explorer/lib/explorer/smart_contract/helper.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ defmodule Explorer.SmartContract.Helper do

def constructor?(function), do: function["type"] == "constructor"

def fallback?(function), do: function["type"] == "fallback"

def event?(function), do: function["type"] == "event"

def error?(function), do: function["type"] == "error"
Expand All @@ -24,13 +22,10 @@ defmodule Explorer.SmartContract.Helper do
@spec read_with_wallet_method?(%{}) :: true | false
def read_with_wallet_method?(function),
do:
!error?(function) && !event?(function) && !constructor?(function) && !fallback?(function) &&
nonpayable?(function) &&
!error?(function) && !event?(function) && !constructor?(function) && nonpayable?(function) &&
!empty_outputs?(function)

def empty_inputs?(function), do: function["inputs"] == []

def empty_outputs?(function), do: function["outputs"] == []
def empty_outputs?(function), do: is_nil(function["outputs"]) || function["outputs"] == []

def payable?(function), do: function["stateMutability"] == "payable" || function["payable"]

Expand Down

0 comments on commit 566a670

Please sign in to comment.