Support stateMutability=view to define reading functions in smart-contracts

pull/3034/head
Victor Baranov 5 years ago
parent b9950e39e4
commit b6674224c9
  1. 1
      CHANGELOG.md
  2. 2
      apps/block_scout_web/lib/block_scout_web/views/address_view.ex
  3. 2
      apps/block_scout_web/lib/block_scout_web/views/tokens/instance/overview_view.ex
  4. 2
      apps/block_scout_web/lib/block_scout_web/views/tokens/overview_view.ex
  5. 2
      apps/explorer/lib/explorer/smart_contract/reader.ex

@ -7,6 +7,7 @@
- [#2834](https://github.com/poanetwork/blockscout/pull/2834) - always redirect to checksummed hash
### Fixes
- [#3034](https://github.com/poanetwork/blockscout/pull/3034) - Support stateMutability=view to define reading functions in smart-contracts
- [#3029](https://github.com/poanetwork/blockscout/pull/3029) - Fix transactions and blocks appearance on the main page
- [#3028](https://github.com/poanetwork/blockscout/pull/3028) - Decrease polling period value for realtime fetcher
- [#3027](https://github.com/poanetwork/blockscout/pull/3027) - Rescue for SUPPORTED_CHAINS env var parsing

@ -206,7 +206,7 @@ defmodule BlockScoutWeb.AddressView do
def smart_contract_verified?(%Address{smart_contract: nil}), do: false
def smart_contract_with_read_only_functions?(%Address{smart_contract: %SmartContract{}} = address) do
Enum.any?(address.smart_contract.abi, & &1["constant"])
Enum.any?(address.smart_contract.abi, &(&1["constant"] || &1["stateMutability"] == "view"))
end
def smart_contract_with_read_only_functions?(%Address{smart_contract: nil}), do: false

@ -47,7 +47,7 @@ defmodule BlockScoutWeb.Tokens.Instance.OverviewView do
def smart_contract_with_read_only_functions?(
%Token{contract_address: %Address{smart_contract: %SmartContract{}}} = token
) do
Enum.any?(token.contract_address.smart_contract.abi, & &1["constant"])
Enum.any?(token.contract_address.smart_contract.abi, &(&1["constant"] || &1["stateMutability"] == "view"))
end
def smart_contract_with_read_only_functions?(%Token{contract_address: %Address{smart_contract: nil}}), do: false

@ -43,7 +43,7 @@ defmodule BlockScoutWeb.Tokens.OverviewView do
def smart_contract_with_read_only_functions?(
%Token{contract_address: %Address{smart_contract: %SmartContract{}}} = token
) do
Enum.any?(token.contract_address.smart_contract.abi, & &1["constant"])
Enum.any?(token.contract_address.smart_contract.abi, &(&1["constant"] || &1["stateMutability"] == "view"))
end
def smart_contract_with_read_only_functions?(%Token{contract_address: %Address{smart_contract: nil}}), do: false

@ -175,7 +175,7 @@ defmodule Explorer.SmartContract.Reader do
_ ->
abi
|> Enum.filter(& &1["constant"])
|> Enum.filter(&(&1["constant"] || &1["stateMutability"] == "view"))
|> Enum.map(&fetch_current_value_from_blockchain(&1, abi, contract_address_hash))
end
end

Loading…
Cancel
Save