chore: Exclude write methods from read tabs (#10111)

* Exclude write methods from Read tab

* Reverse corresponding test
pull/10204/head
Victor Baranov 6 months ago committed by GitHub
parent a072be34b7
commit 59170c0d81
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 3
      apps/explorer/lib/explorer/smart_contract/helper.ex
  2. 4
      apps/explorer/test/explorer/smart_contract/helper_test.exs

@ -5,6 +5,7 @@ defmodule Explorer.SmartContract.Helper do
alias Explorer.{Chain, Helper}
alias Explorer.Chain.{Hash, SmartContract}
alias Explorer.SmartContract.Writer
alias Phoenix.HTML
def queriable_method?(method) do
@ -25,7 +26,7 @@ defmodule Explorer.SmartContract.Helper do
def read_with_wallet_method?(function),
do:
!error?(function) && !event?(function) && !constructor?(function) &&
!empty_outputs?(function)
!empty_outputs?(function) && !Writer.write_function?(function)
def empty_outputs?(function), do: is_nil(function["outputs"]) || function["outputs"] == []

@ -126,7 +126,7 @@ defmodule Explorer.SmartContract.HelperTest do
end
describe "read_with_wallet_method?" do
test "returns payable method with output in the read tab" do
test "doesn't return payable method with output in the read tab" do
function = %{
"type" => "function",
"stateMutability" => "payable",
@ -135,7 +135,7 @@ defmodule Explorer.SmartContract.HelperTest do
"inputs" => []
}
assert Helper.read_with_wallet_method?(function)
refute Helper.read_with_wallet_method?(function)
end
test "doesn't return payable method with no output in the read tab" do

Loading…
Cancel
Save