Allow payable function with output appear in the Read tab

pull/9073/head
Viktor Baranov 10 months ago
parent 61d72759d0
commit 05242dbb66
  1. 1
      CHANGELOG.md
  2. 2
      apps/explorer/lib/explorer/smart_contract/helper.ex
  3. 26
      apps/explorer/test/explorer/smart_contract/helper_test.exs
  4. 1
      cspell.json

@ -7,6 +7,7 @@
### Fixes
- [#9075](https://github.com/blockscout/blockscout/pull/9075) - Fix fetching contract codes
- [#9073](https://github.com/blockscout/blockscout/pull/9073) - Allow payable function with output appear in the Read tab
### Chore

@ -23,7 +23,7 @@ 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) && nonpayable?(function) &&
!error?(function) && !event?(function) && !constructor?(function) &&
!empty_outputs?(function)
def empty_outputs?(function), do: is_nil(function["outputs"]) || function["outputs"] == []

@ -124,4 +124,30 @@ defmodule Explorer.SmartContract.HelperTest do
refute Helper.nonpayable?(function)
end
end
describe "read_with_wallet_method?" do
test "returns payable method with output in the read tab" do
function = %{
"type" => "function",
"stateMutability" => "payable",
"outputs" => [%{"type" => "address", "name" => "", "internalType" => "address"}],
"name" => "returnaddress",
"inputs" => []
}
assert Helper.read_with_wallet_method?(function)
end
test "doesn't return payable method with no output in the read tab" do
function = %{
"type" => "function",
"stateMutability" => "payable",
"outputs" => [],
"name" => "returnaddress",
"inputs" => []
}
refute Helper.read_with_wallet_method?(function)
end
end
end

@ -389,6 +389,7 @@
"rerequest",
"reshows",
"retryable",
"returnaddress",
"reuseaddr",
"RPC's",
"RPCs",

Loading…
Cancel
Save