Bump credo from 1.7.1 to 1.7.3 (#9117)

* Bump credo from 1.7.1 to 1.7.3

Bumps [credo](https://github.com/rrrene/credo) from 1.7.1 to 1.7.3.
- [Changelog](https://github.com/rrrene/credo/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rrrene/credo/commits/v1.7.3)

---
updated-dependencies:
- dependency-name: credo
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

* replace is_ with question mark

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Viktor Baranov <baranov.viktor.27@gmail.com>
pull/9198/head
dependabot[bot] 9 months ago committed by GitHub
parent 7f0cdc843c
commit 1352619a5a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 6
      apps/block_scout_web/lib/block_scout_web/captcha_helper.ex
  2. 2
      apps/block_scout_web/lib/block_scout_web/controllers/api/v2/smart_contract_controller.ex
  3. 10
      apps/block_scout_web/lib/block_scout_web/controllers/api/v2/token_controller.ex
  4. 12
      apps/block_scout_web/lib/block_scout_web/controllers/smart_contract_controller.ex
  5. 4
      apps/block_scout_web/lib/block_scout_web/controllers/tokens/instance/holder_controller.ex
  6. 2
      apps/block_scout_web/lib/block_scout_web/controllers/tokens/instance/metadata_controller.ex
  7. 4
      apps/block_scout_web/lib/block_scout_web/controllers/tokens/instance/transfer_controller.ex
  8. 2
      apps/block_scout_web/lib/block_scout_web/controllers/tokens/instance_controller.ex
  9. 2
      apps/block_scout_web/lib/block_scout_web/templates/csv_export/index.html.eex
  10. 10
      apps/block_scout_web/lib/block_scout_web/views/access_helper.ex
  11. 6
      apps/block_scout_web/lib/block_scout_web/views/address_view.ex
  12. 12
      apps/block_scout_web/lib/block_scout_web/views/api/v2/helper.ex
  13. 8
      apps/block_scout_web/lib/block_scout_web/views/api/v2/transaction_view.ex
  14. 2
      apps/explorer/lib/explorer/account/custom_abi.ex
  15. 6
      apps/explorer/lib/explorer/account/notifier/forbidden_address.ex
  16. 4
      apps/explorer/lib/explorer/account/notifier/notify.ex
  17. 12
      apps/explorer/lib/explorer/chain.ex
  18. 10
      apps/explorer/lib/explorer/chain/address.ex
  19. 4
      apps/explorer/lib/explorer/chain/block/reward.ex
  20. 10
      apps/explorer/lib/explorer/chain/cache/addresses_tabs_counters.ex
  21. 2
      apps/explorer/lib/explorer/chain/csv_export/address_internal_transaction_csv_exporter.ex
  22. 2
      apps/explorer/lib/explorer/chain/csv_export/address_transaction_csv_exporter.ex
  23. 10
      apps/explorer/lib/explorer/chain/csv_export/helper.ex
  24. 24
      apps/explorer/lib/explorer/chain/hash/address.ex
  25. 10
      apps/explorer/lib/explorer/chain/token/instance.ex
  26. 8
      apps/explorer/lib/explorer/chain/transaction.ex
  27. 4
      apps/indexer/lib/indexer/fetcher/polygon_edge.ex
  28. 8
      apps/indexer/lib/indexer/fetcher/token_instance/metadata_retriever.ex
  29. 6
      apps/indexer/lib/indexer/helper.ex
  30. 2
      apps/indexer/lib/indexer/transform/polygon_edge/deposit_executes.ex
  31. 2
      apps/indexer/lib/indexer/transform/polygon_edge/withdrawals.ex
  32. 4
      apps/indexer/lib/indexer/transform/transaction_actions.ex
  33. 4
      mix.lock

@ -18,7 +18,7 @@ defmodule BlockScoutWeb.CaptchaHelper do
case HTTPoison.post("https://www.google.com/recaptcha/api/siteverify", body, headers, []) do
{:ok, %HTTPoison.Response{status_code: 200, body: body}} ->
case Jason.decode!(body) do
%{"success" => true} = resp -> is_success?(resp)
%{"success" => true} = resp -> success?(resp)
_ -> false
end
@ -27,11 +27,11 @@ defmodule BlockScoutWeb.CaptchaHelper do
end
end
defp is_success?(%{"score" => score}) do
defp success?(%{"score" => score}) do
check_recaptcha_v3_score(score)
end
defp is_success?(_resp), do: true
defp success?(_resp), do: true
defp check_recaptcha_v3_score(score) do
if score >= 0.5 do

@ -205,7 +205,7 @@ defmodule BlockScoutWeb.API.V2.SmartContractController do
with {:format_address, {:ok, address_hash}} <- {:format_address, Chain.string_to_address_hash(address_hash_string)},
{:ok, false} <- AccessHelper.restricted_access?(address_hash_string, params),
{:address, {:ok, address}} <- {:address, Chain.hash_to_address(address_hash)},
{:is_smart_contract, true} <- {:is_smart_contract, Address.is_smart_contract(address)},
{:is_smart_contract, true} <- {:is_smart_contract, Address.smart_contract?(address)},
response = SolidityScan.solidityscan_request(address_hash_string),
{:is_empty_response, false} <- {:is_empty_response, is_nil(response)} do
conn

@ -104,7 +104,7 @@ defmodule BlockScoutWeb.API.V2.TokenController do
with {:format, {:ok, address_hash}} <- {:format, Chain.string_to_address_hash(address_hash_string)},
{:ok, false} <- AccessHelper.restricted_access?(address_hash_string, params),
{:not_found, {:ok, token}} <- {:not_found, Chain.token_from_address_hash(address_hash, @api_true)},
{:not_found, false} <- {:not_found, Chain.is_erc_20_token?(token)},
{:not_found, false} <- {:not_found, Chain.erc_20_token?(token)},
{:format, {:ok, holder_address_hash}} <- {:format, Chain.string_to_address_hash(holder_address_hash_string)},
{:ok, false} <- AccessHelper.restricted_access?(holder_address_hash_string, params) do
holder_address = Repo.get_by(Address, hash: holder_address_hash)
@ -160,7 +160,7 @@ defmodule BlockScoutWeb.API.V2.TokenController do
with {:format, {:ok, address_hash}} <- {:format, Chain.string_to_address_hash(address_hash_string)},
{:ok, false} <- AccessHelper.restricted_access?(address_hash_string, params),
{:not_found, {:ok, token}} <- {:not_found, Chain.token_from_address_hash(address_hash, @api_true)},
{:not_found, false} <- {:not_found, Chain.is_erc_20_token?(token)},
{:not_found, false} <- {:not_found, Chain.erc_20_token?(token)},
{:format, {token_id, ""}} <- {:format, Integer.parse(token_id_str)} do
token_instance =
case Chain.erc721_or_erc1155_token_instance_from_token_id_and_token_address(token_id, address_hash, @api_true) do
@ -186,7 +186,7 @@ defmodule BlockScoutWeb.API.V2.TokenController do
with {:format, {:ok, address_hash}} <- {:format, Chain.string_to_address_hash(address_hash_string)},
{:ok, false} <- AccessHelper.restricted_access?(address_hash_string, params),
{:not_found, {:ok, token}} <- {:not_found, Chain.token_from_address_hash(address_hash, @api_true)},
{:not_found, false} <- {:not_found, Chain.is_erc_20_token?(token)},
{:not_found, false} <- {:not_found, Chain.erc_20_token?(token)},
{:format, {token_id, ""}} <- {:format, Integer.parse(token_id_str)} do
paging_options = paging_options(params)
@ -216,7 +216,7 @@ defmodule BlockScoutWeb.API.V2.TokenController do
with {:format, {:ok, address_hash}} <- {:format, Chain.string_to_address_hash(address_hash_string)},
{:ok, false} <- AccessHelper.restricted_access?(address_hash_string, params),
{:not_found, {:ok, token}} <- {:not_found, Chain.token_from_address_hash(address_hash, @api_true)},
{:not_found, false} <- {:not_found, Chain.is_erc_20_token?(token)},
{:not_found, false} <- {:not_found, Chain.erc_20_token?(token)},
{:format, {token_id, ""}} <- {:format, Integer.parse(token_id_str)} do
paging_options = paging_options(params)
@ -250,7 +250,7 @@ defmodule BlockScoutWeb.API.V2.TokenController do
with {:format, {:ok, address_hash}} <- {:format, Chain.string_to_address_hash(address_hash_string)},
{:ok, false} <- AccessHelper.restricted_access?(address_hash_string, params),
{:not_found, {:ok, token}} <- {:not_found, Chain.token_from_address_hash(address_hash, @api_true)},
{:not_found, false} <- {:not_found, Chain.is_erc_20_token?(token)},
{:not_found, false} <- {:not_found, Chain.erc_20_token?(token)},
{:format, {token_id, ""}} <- {:format, Integer.parse(token_id_str)} do
conn
|> put_status(200)

@ -224,7 +224,7 @@ defmodule BlockScoutWeb.SmartContractController do
end
defp convert_map_to_array(map) do
if is_turned_out_array?(map) do
if turned_out_array?(map) do
map |> Map.values() |> try_to_map_elements()
else
try_to_map_elements(map)
@ -239,11 +239,11 @@ defmodule BlockScoutWeb.SmartContractController do
end
end
defp is_turned_out_array?(map) when is_map(map), do: Enum.all?(Map.keys(map), &is_integer?/1)
defp turned_out_array?(map) when is_map(map), do: Enum.all?(Map.keys(map), &integer?/1)
defp is_turned_out_array?(_), do: false
defp turned_out_array?(_), do: false
defp is_integer?(string) when is_binary(string) do
defp integer?(string) when is_binary(string) do
case string |> String.trim() |> Integer.parse() do
{_, ""} ->
true
@ -253,9 +253,9 @@ defmodule BlockScoutWeb.SmartContractController do
end
end
defp is_integer?(integer) when is_integer(integer), do: true
defp integer?(integer) when is_integer(integer), do: true
defp is_integer?(_), do: false
defp integer?(_), do: false
defp write_contract_api_disabled?(action), do: AddressView.contract_interaction_disabled?() && action == "write"
end

@ -12,7 +12,7 @@ defmodule BlockScoutWeb.Tokens.Instance.HolderController do
def index(conn, %{"token_id" => token_address_hash, "instance_id" => token_id_str, "type" => "JSON"} = params) do
with {:ok, address_hash} <- Chain.string_to_address_hash(token_address_hash),
{:ok, token} <- Chain.token_from_address_hash(address_hash),
false <- Chain.is_erc_20_token?(token),
false <- Chain.erc_20_token?(token),
{token_id, ""} <- Integer.parse(token_id_str),
token_holders <-
Chain.fetch_token_holders_from_token_hash_and_token_id(address_hash, token_id, paging_options(params)) do
@ -58,7 +58,7 @@ defmodule BlockScoutWeb.Tokens.Instance.HolderController do
with {:ok, hash} <- Chain.string_to_address_hash(token_address_hash),
{:ok, token} <- Chain.token_from_address_hash(hash, options),
false <- Chain.is_erc_20_token?(token),
false <- Chain.erc_20_token?(token),
{token_id, ""} <- Integer.parse(token_id_str) do
case Chain.erc721_or_erc1155_token_instance_from_token_id_and_token_address(token_id, hash) do
{:ok, token_instance} -> Helper.render(conn, token_instance, hash, token_id, token)

@ -9,7 +9,7 @@ defmodule BlockScoutWeb.Tokens.Instance.MetadataController do
with {:ok, hash} <- Chain.string_to_address_hash(token_address_hash),
{:ok, token} <- Chain.token_from_address_hash(hash, options),
false <- Chain.is_erc_20_token?(token),
false <- Chain.erc_20_token?(token),
{token_id, ""} <- Integer.parse(token_id_str),
{:ok, token_instance} <-
Chain.erc721_or_erc1155_token_instance_from_token_id_and_token_address(token_id, hash) do

@ -16,7 +16,7 @@ defmodule BlockScoutWeb.Tokens.Instance.TransferController do
def index(conn, %{"token_id" => token_address_hash, "instance_id" => token_id_str, "type" => "JSON"} = params) do
with {:ok, hash} <- Chain.string_to_address_hash(token_address_hash),
{:ok, token} <- Chain.token_from_address_hash(hash),
false <- Chain.is_erc_20_token?(token),
false <- Chain.erc_20_token?(token),
{token_id, ""} <- Integer.parse(token_id_str),
token_transfers <-
Chain.fetch_token_transfers_from_token_hash_and_token_id(hash, token_id, paging_options(params)) do
@ -61,7 +61,7 @@ defmodule BlockScoutWeb.Tokens.Instance.TransferController do
with {:ok, hash} <- Chain.string_to_address_hash(token_address_hash),
{:ok, token} <- Chain.token_from_address_hash(hash, options),
false <- Chain.is_erc_20_token?(token),
false <- Chain.erc_20_token?(token),
{token_id, ""} <- Integer.parse(token_id_str) do
case Chain.erc721_or_erc1155_token_instance_from_token_id_and_token_address(token_id, hash) do
{:ok, token_instance} -> Helper.render(conn, token_instance, hash, token_id, token)

@ -7,7 +7,7 @@ defmodule BlockScoutWeb.Tokens.InstanceController do
def show(conn, %{"token_id" => token_address_hash, "id" => token_id}) do
with {:ok, hash} <- Chain.string_to_address_hash(token_address_hash),
{:ok, token} <- Chain.token_from_address_hash(hash),
false <- Chain.is_erc_20_token?(token) do
false <- Chain.erc_20_token?(token) do
token_instance_transfer_path =
conn
|> token_instance_transfer_path(:index, token_address_hash, token_id)

@ -10,7 +10,7 @@
<h1 class="card-title list-title-description"><%= gettext "Export Data" %></h1>
<div>
<% filter_text = if Helper.is_valid_filter?(@filter_type, @filter_value, @type), do: " with applied filter by #{@filter_type} (#{@filter_value})", else: "" %>
<% filter_text = if Helper.valid_filter?(@filter_type, @filter_value, @type), do: " with applied filter by #{@filter_type} (#{@filter_value})", else: "" %>
<p class="card-subtitle list-title-description"><%= gettext("Export") %> <%= type_display_name(@type) %> <%= gettext("for address") %> <%= link(
@address_hash_string,
to: address_path(@conn, :show, @address_hash_string)

@ -93,10 +93,10 @@ defmodule BlockScoutWeb.AccessHelper do
Enum.member?(whitelisted_ips(rate_limit_config), ip_string) ->
rate_limit(ip_string, limit_by_whitelisted_ip, time_interval_limit)
is_api_v2_request?(conn) && !is_nil(token) && !is_nil(user_agent) ->
api_v2_request?(conn) && !is_nil(token) && !is_nil(user_agent) ->
rate_limit(token, api_v2_ui_limit, time_interval_limit)
is_api_v2_request?(conn) && !is_nil(user_agent) ->
api_v2_request?(conn) && !is_nil(user_agent) ->
rate_limit(ip_string, limit_by_ip, time_interval_by_ip)
true ->
@ -155,8 +155,8 @@ defmodule BlockScoutWeb.AccessHelper do
end
end
defp is_api_v2_request?(%Plug.Conn{request_path: "/api/v2/" <> _}), do: true
defp is_api_v2_request?(_), do: false
defp api_v2_request?(%Plug.Conn{request_path: "/api/v2/" <> _}), do: true
defp api_v2_request?(_), do: false
def conn_to_ip_string(conn) do
is_blockscout_behind_proxy = Application.get_env(:block_scout_web, :api_rate_limit)[:is_blockscout_behind_proxy]
@ -171,7 +171,7 @@ defmodule BlockScoutWeb.AccessHelper do
api_v2_temp_token_key = Application.get_env(:block_scout_web, :api_v2_temp_token_key)
conn = Conn.fetch_cookies(conn, signed: [api_v2_temp_token_key])
case is_api_v2_request?(conn) && conn.cookies[api_v2_temp_token_key] do
case api_v2_request?(conn) && conn.cookies[api_v2_temp_token_key] do
%{ip: ^ip_string} ->
conn.req_cookies[api_v2_temp_token_key]

@ -256,12 +256,12 @@ 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 || [], &is_read_function?(&1))
Enum.any?(address.smart_contract.abi || [], &read_function?(&1))
end
def smart_contract_with_read_only_functions?(%Address{smart_contract: _}), do: false
def is_read_function?(function), do: Helper.queriable_method?(function) || Helper.read_with_wallet_method?(function)
def read_function?(function), do: Helper.queriable_method?(function) || Helper.read_with_wallet_method?(function)
def smart_contract_is_proxy?(address, options \\ [])
@ -480,7 +480,7 @@ defmodule BlockScoutWeb.AddressView do
end
def check_custom_abi_for_having_read_functions(custom_abi),
do: !is_nil(custom_abi) && Enum.any?(custom_abi.abi, &is_read_function?(&1))
do: !is_nil(custom_abi) && Enum.any?(custom_abi.abi, &read_function?(&1))
def has_address_custom_abi_with_write_functions?(conn, address_hash) do
if contract_interaction_disabled?() do

@ -55,10 +55,10 @@ defmodule BlockScoutWeb.API.V2.Helper do
def address_with_info(%Address{} = address, _address_hash) do
%{
"hash" => Address.checksum(address),
"is_contract" => Address.is_smart_contract(address),
"is_contract" => Address.smart_contract?(address),
"name" => address_name(address),
"implementation_name" => implementation_name(address),
"is_verified" => is_verified(address),
"is_verified" => verified?(address),
"ens_domain_name" => address.ens_domain_name
}
end
@ -105,10 +105,10 @@ defmodule BlockScoutWeb.API.V2.Helper do
def implementation_name(_), do: nil
def is_verified(%Address{smart_contract: nil}), do: false
def is_verified(%Address{smart_contract: %{metadata_from_verified_twin: true}}), do: false
def is_verified(%Address{smart_contract: %NotLoaded{}}), do: nil
def is_verified(%Address{smart_contract: _}), do: true
def verified?(%Address{smart_contract: nil}), do: false
def verified?(%Address{smart_contract: %{metadata_from_verified_twin: true}}), do: false
def verified?(%Address{smart_contract: %NotLoaded{}}), do: nil
def verified?(%Address{smart_contract: _}), do: true
def market_cap(:standard, %{available_supply: available_supply, usd_value: usd_value, market_cap_usd: market_cap_usd})
when is_nil(available_supply) or is_nil(usd_value) do

@ -736,7 +736,7 @@ defmodule BlockScoutWeb.API.V2.TransactionView do
_,
skip_sc_check?
) do
if skip_sc_check? || Address.is_smart_contract(to_address) do
if skip_sc_check? || Address.smart_contract?(to_address) do
"0x" <> Base.encode16(method_id, case: :lower)
else
nil
@ -805,7 +805,7 @@ defmodule BlockScoutWeb.API.V2.TransactionView do
def tx_types(%Transaction{to_address: to_address} = tx, types, :contract_call) do
types =
if Address.is_smart_contract(to_address) do
if Address.smart_contract?(to_address) do
[:contract_call | types]
else
types
@ -827,7 +827,7 @@ defmodule BlockScoutWeb.API.V2.TransactionView do
def tx_types(tx, types, :rootstock_remasc) do
types =
if Transaction.is_rootstock_remasc_transaction(tx) do
if Transaction.rootstock_remasc_transaction?(tx) do
[:rootstock_remasc | types]
else
types
@ -837,7 +837,7 @@ defmodule BlockScoutWeb.API.V2.TransactionView do
end
def tx_types(tx, types, :rootstock_bridge) do
if Transaction.is_rootstock_bridge_transaction(tx) do
if Transaction.rootstock_bridge_transaction?(tx) do
[:rootstock_bridge | types]
else
types

@ -65,7 +65,7 @@ defmodule Explorer.Account.CustomABI do
defp check_smart_contract_address(custom_abi), do: custom_abi
defp check_smart_contract_address_inner(changeset, address_hash) do
if Chain.is_address_hash_is_smart_contract?(address_hash) do
if Chain.address_hash_is_smart_contract?(address_hash) do
changeset
else
add_error(changeset, :address_hash, "Address is not a smart contract")

@ -31,7 +31,7 @@ defmodule Explorer.Account.Notifier.ForbiddenAddress do
address_hash in blacklist() ->
{:error, "This address is blacklisted"}
is_contract(address_hash) ->
contract?(address_hash) ->
{:error, "This address isn't EOA"}
match?({:restricted_access, true}, AccessHelper.restricted_access?(to_string(address_hash), %{})) ->
@ -42,10 +42,10 @@ defmodule Explorer.Account.Notifier.ForbiddenAddress do
end
end
defp is_contract(%Explorer.Chain.Hash{} = address_hash) do
defp contract?(%Explorer.Chain.Hash{} = address_hash) do
case hash_to_address(address_hash) do
{:error, :not_found} -> false
{:ok, address} -> Address.is_smart_contract(address)
{:ok, address} -> Address.smart_contract?(address)
end
end

@ -117,7 +117,7 @@ defmodule Explorer.Account.Notifier.Notify do
direction = :incoming || :outgoing
"""
def build_watchlist_notification(%Explorer.Account.WatchlistAddress{} = address, summary, direction) do
if is_watched(address, summary, direction) do
if watched?(address, summary, direction) do
%WatchlistNotification{
watchlist_address_id: address.id,
watchlist_id: address.watchlist_id,
@ -140,7 +140,7 @@ defmodule Explorer.Account.Notifier.Notify do
end
end
defp is_watched(%WatchlistAddress{} = address, %{type: type}, direction) do
defp watched?(%WatchlistAddress{} = address, %{type: type}, direction) do
case {type, direction} do
{"COIN", :incoming} -> address.watch_coin_input
{"COIN", :outgoing} -> address.watch_coin_output

@ -4369,12 +4369,12 @@ defmodule Explorer.Chain do
Repo.one(query)
end
@spec is_erc_20_token?(Token.t()) :: bool
def is_erc_20_token?(token) do
is_erc_20_token_type?(token.type)
@spec erc_20_token?(Token.t()) :: bool
def erc_20_token?(token) do
erc_20_token_type?(token.type)
end
defp is_erc_20_token_type?(type) do
defp erc_20_token_type?(type) do
case type do
"ERC-20" -> true
_ -> false
@ -4826,9 +4826,9 @@ defmodule Explorer.Chain do
|> Repo.one()
end
def is_address_hash_is_smart_contract?(nil), do: false
def address_hash_is_smart_contract?(nil), do: false
def is_address_hash_is_smart_contract?(address_hash) do
def address_hash_is_smart_contract?(address_hash) do
with %Address{contract_code: bytecode} <- Repo.get_by(Address, hash: address_hash),
false <- is_nil(bytecode) do
true

@ -340,11 +340,11 @@ defmodule Explorer.Chain.Address do
@doc """
Checks if given address is smart-contract
"""
@spec is_smart_contract(any()) :: boolean() | nil
def is_smart_contract(%__MODULE__{contract_code: nil}), do: false
def is_smart_contract(%__MODULE__{contract_code: _}), do: true
def is_smart_contract(%NotLoaded{}), do: nil
def is_smart_contract(_), do: false
@spec smart_contract?(any()) :: boolean() | nil
def smart_contract?(%__MODULE__{contract_code: nil}), do: false
def smart_contract?(%__MODULE__{contract_code: _}), do: true
def smart_contract?(%NotLoaded{}), do: nil
def smart_contract?(_), do: false
defp get_addresses(options) do
accounts_with_n = fetch_top_addresses(options)

@ -143,7 +143,7 @@ defmodule Explorer.Chain.Block.Reward do
end
end
defp is_validator(mining_key) do
defp validator?(mining_key) do
validators_contract_address =
Application.get_env(:explorer, Explorer.Chain.Block.Reward, %{})[:validators_contract_address]
@ -191,7 +191,7 @@ defmodule Explorer.Chain.Block.Reward do
end
def get_validator_payout_key_by_mining(mining_key) do
is_validator = is_validator(mining_key)
is_validator = validator?(mining_key)
if is_validator do
keys_manager_contract_address =

@ -76,7 +76,7 @@ defmodule Explorer.Chain.Cache.AddressesTabsCounters do
def handle_cast({:set_txs_state, address_hash, %{txs_types: txs_types} = results}, state) do
address_hash = lowercased_string(address_hash)
if is_ignored?(state[address_hash]) do
if ignored?(state[address_hash]) do
{:noreply, state}
else
address_state =
@ -104,15 +104,15 @@ defmodule Explorer.Chain.Cache.AddressesTabsCounters do
end
end
defp is_ignored?({:updated, datetime}), do: is_up_to_date?(datetime, ttl())
defp is_ignored?(_), do: false
defp ignored?({:updated, datetime}), do: up_to_date?(datetime, ttl())
defp ignored?(_), do: false
defp check_staleness(nil), do: nil
defp check_staleness({datetime, counter}) when counter > 50, do: {datetime, counter, :limit_value}
defp check_staleness({datetime, counter}) do
status =
if is_up_to_date?(datetime, ttl()) do
if up_to_date?(datetime, ttl()) do
:up_to_date
else
:stale
@ -121,7 +121,7 @@ defmodule Explorer.Chain.Cache.AddressesTabsCounters do
{datetime, counter, status}
end
defp is_up_to_date?(datetime, ttl) do
defp up_to_date?(datetime, ttl) do
datetime
|> DateTime.add(ttl, :millisecond)
|> DateTime.compare(DateTime.utc_now()) != :lt

@ -34,7 +34,7 @@ defmodule Explorer.Chain.CSVExport.AddressInternalTransactionCsvExporter do
|> Keyword.put(:paging_options, paging_options)
|> Keyword.put(:from_block, from_block)
|> Keyword.put(:to_block, to_block)
|> (&if(Helper.is_valid_filter?(filter_type, filter_value, "internal_transactions"),
|> (&if(Helper.valid_filter?(filter_type, filter_value, "internal_transactions"),
do: &1 |> Keyword.put(:direction, String.to_atom(filter_value)),
else: &1
)).()

@ -34,7 +34,7 @@ defmodule Explorer.Chain.CSVExport.AddressTransactionCsvExporter do
|> Keyword.put(:paging_options, paging_options)
|> Keyword.put(:from_block, from_block)
|> Keyword.put(:to_block, to_block)
|> (&if(Helper.is_valid_filter?(filter_type, filter_value, "transactions"),
|> (&if(Helper.valid_filter?(filter_type, filter_value, "transactions"),
do: &1 |> Keyword.put(:direction, String.to_atom(filter_value)),
else: &1
)).()

@ -88,16 +88,16 @@ defmodule Explorer.Chain.CSVExport.Helper do
["to", "from"]
end
@spec is_valid_filter?(String.t(), String.t(), String.t()) :: boolean()
def is_valid_filter?(filter_type, filter_value, item_type) do
is_valid_filter_type(filter_type, filter_value, item_type) && is_valid_filter_value(filter_type, filter_value)
@spec valid_filter?(String.t(), String.t(), String.t()) :: boolean()
def valid_filter?(filter_type, filter_value, item_type) do
valid_filter_type?(filter_type, filter_value, item_type) && valid_filter_value?(filter_type, filter_value)
end
defp is_valid_filter_type(filter_type, filter_value, item_type) do
defp valid_filter_type?(filter_type, filter_value, item_type) do
filter_type in supported_filters(item_type) && filter_value && filter_value !== ""
end
defp is_valid_filter_value(filter_type, filter_value) do
defp valid_filter_value?(filter_type, filter_value) do
case filter_type do
"address" ->
filter_value in supported_address_filter_values()

@ -169,9 +169,9 @@ defmodule Explorer.Chain.Hash.Address do
@spec validate(String.t()) :: {:ok, String.t()} | {:error, :invalid_length | :invalid_characters | :invalid_checksum}
def validate("0x" <> hash) do
with {:length, true} <- {:length, String.length(hash) == 40},
{:hex, true} <- {:hex, is_hex?(hash)},
{:mixed_case, true} <- {:mixed_case, is_mixed_case?(hash)},
{:checksummed, true} <- {:checksummed, is_checksummed?(hash)} do
{:hex, true} <- {:hex, hex?(hash)},
{:mixed_case, true} <- {:mixed_case, mixed_case?(hash)},
{:checksummed, true} <- {:checksummed, checksummed?(hash)} do
{:ok, "0x" <> hash}
else
{:length, false} ->
@ -188,16 +188,16 @@ defmodule Explorer.Chain.Hash.Address do
end
end
@spec is_hex?(String.t()) :: boolean()
defp is_hex?(hash) do
@spec hex?(String.t()) :: boolean()
defp hex?(hash) do
case Regex.run(~r|[0-9a-f]{40}|i, hash) do
nil -> false
[_] -> true
end
end
@spec is_mixed_case?(String.t()) :: boolean()
defp is_mixed_case?(hash) do
@spec mixed_case?(String.t()) :: boolean()
defp mixed_case?(hash) do
upper_check = ~r|[0-9A-F]{40}|
lower_check = ~r|[0-9a-f]{40}|
@ -209,8 +209,8 @@ defmodule Explorer.Chain.Hash.Address do
end
end
@spec is_checksummed?(String.t()) :: boolean()
defp is_checksummed?(original_hash) do
@spec checksummed?(String.t()) :: boolean()
defp checksummed?(original_hash) do
lowercase_hash = String.downcase(original_hash)
sha3_hash = ExKeccak.hash_256(lowercase_hash)
@ -224,15 +224,15 @@ defmodule Explorer.Chain.Hash.Address do
<<checksum_digit::integer-size(4), remaining_sha3_hash::bits>> = sha3_hash
<<current_char::binary-size(1), remaining_address_hash::binary>> = address_hash
if is_proper_case?(checksum_digit, current_char) do
if proper_case?(checksum_digit, current_char) do
do_checksum_check(remaining_sha3_hash, remaining_address_hash)
else
false
end
end
@spec is_proper_case?(integer, String.t()) :: boolean()
defp is_proper_case?(checksum_digit, character) do
@spec proper_case?(integer, String.t()) :: boolean()
defp proper_case?(checksum_digit, character) do
case_map = %{
"0" => :both,
"1" => :both,

@ -444,10 +444,10 @@ defmodule Explorer.Chain.Token.Instance do
end
def put_is_unique(instance, token, options) do
%__MODULE__{instance | is_unique: is_unique?(instance, token, options)}
%__MODULE__{instance | is_unique: unique?(instance, token, options)}
end
defp is_unique?(
defp unique?(
%Instance{current_token_balance: %CurrentTokenBalance{value: %Decimal{} = value}} = instance,
token,
options
@ -455,15 +455,15 @@ defmodule Explorer.Chain.Token.Instance do
if Decimal.compare(value, 1) == :gt do
false
else
is_unique?(%Instance{instance | current_token_balance: nil}, token, options)
unique?(%Instance{instance | current_token_balance: nil}, token, options)
end
end
defp is_unique?(%Instance{current_token_balance: %CurrentTokenBalance{value: value}}, _token, _options)
defp unique?(%Instance{current_token_balance: %CurrentTokenBalance{value: value}}, _token, _options)
when value > 1,
do: false
defp is_unique?(instance, token, options),
defp unique?(instance, token, options),
do:
not (token.type == "ERC-1155") or
Chain.token_id_1155_is_unique?(token.contract_address_hash, instance.token_id, options)

@ -1124,8 +1124,8 @@ defmodule Explorer.Chain.Transaction do
@doc """
Returns true if the transaction is a Rootstock REMASC transaction.
"""
@spec is_rootstock_remasc_transaction(Explorer.Chain.Transaction.t()) :: boolean
def is_rootstock_remasc_transaction(%__MODULE__{to_address_hash: to_address_hash}) do
@spec rootstock_remasc_transaction?(Explorer.Chain.Transaction.t()) :: boolean
def rootstock_remasc_transaction?(%__MODULE__{to_address_hash: to_address_hash}) do
case Hash.Address.cast(Application.get_env(:explorer, __MODULE__)[:rootstock_remasc_address]) do
{:ok, address} -> address == to_address_hash
_ -> false
@ -1135,8 +1135,8 @@ defmodule Explorer.Chain.Transaction do
@doc """
Returns true if the transaction is a Rootstock bridge transaction.
"""
@spec is_rootstock_bridge_transaction(Explorer.Chain.Transaction.t()) :: boolean
def is_rootstock_bridge_transaction(%__MODULE__{to_address_hash: to_address_hash}) do
@spec rootstock_bridge_transaction?(Explorer.Chain.Transaction.t()) :: boolean
def rootstock_bridge_transaction?(%__MODULE__{to_address_hash: to_address_hash}) do
case Hash.Address.cast(Application.get_env(:explorer, __MODULE__)[:rootstock_bridge_address]) do
{:ok, address} -> address == to_address_hash
_ -> false

@ -83,7 +83,7 @@ defmodule Indexer.Fetcher.PolygonEdge do
{:reorg_monitor_started, !is_nil(Process.whereis(Indexer.Fetcher.PolygonEdge))},
polygon_edge_l1_rpc = Application.get_all_env(:indexer)[Indexer.Fetcher.PolygonEdge][:polygon_edge_l1_rpc],
{:rpc_l1_undefined, false} <- {:rpc_l1_undefined, is_nil(polygon_edge_l1_rpc)},
{:contract_is_valid, true} <- {:contract_is_valid, Helper.is_address_correct?(contract_address)},
{:contract_is_valid, true} <- {:contract_is_valid, Helper.address_correct?(contract_address)},
start_block_l1 = parse_integer(env[:start_block_l1]),
false <- is_nil(start_block_l1),
true <- start_block_l1 > 0,
@ -163,7 +163,7 @@ defmodule Indexer.Fetcher.PolygonEdge do
def init_l2(table, env, pid, contract_address, contract_name, table_name, entity_name, json_rpc_named_arguments)
when table in [Explorer.Chain.PolygonEdge.DepositExecute, Explorer.Chain.PolygonEdge.Withdrawal] do
with {:start_block_l2_undefined, false} <- {:start_block_l2_undefined, is_nil(env[:start_block_l2])},
{:contract_address_valid, true} <- {:contract_address_valid, Helper.is_address_correct?(contract_address)},
{:contract_address_valid, true} <- {:contract_address_valid, Helper.address_correct?(contract_address)},
start_block_l2 = parse_integer(env[:start_block_l2]),
false <- is_nil(start_block_l2),
true <- start_block_l2 > 0,

@ -215,8 +215,8 @@ defmodule Indexer.Fetcher.TokenInstance.MetadataRetriever do
end
defp check_content_type(content_type, uri, hex_token_id, body) do
image = is_image?(content_type)
video = is_video?(content_type)
image = image?(content_type)
video = video?(content_type)
if content_type && (image || video) do
json = if image, do: %{"image" => uri}, else: %{"animation_url" => uri}
@ -238,11 +238,11 @@ defmodule Indexer.Fetcher.TokenInstance.MetadataRetriever do
content_type
end
defp is_image?(content_type) do
defp image?(content_type) do
content_type && String.starts_with?(content_type, "image/")
end
defp is_video?(content_type) do
defp video?(content_type) do
content_type && String.starts_with?(content_type, "video/")
end

@ -24,12 +24,12 @@ defmodule Indexer.Helper do
end
end
@spec is_address_correct?(binary()) :: boolean()
def is_address_correct?(address) when is_binary(address) do
@spec address_correct?(binary()) :: boolean()
def address_correct?(address) when is_binary(address) do
String.match?(address, ~r/^0x[[:xdigit:]]{40}$/i)
end
def is_address_correct?(_address) do
def address_correct?(_address) do
false
end

@ -20,7 +20,7 @@ defmodule Indexer.Transform.PolygonEdge.DepositExecutes do
with false <-
is_nil(Application.get_env(:indexer, DepositExecute)[:start_block_l2]),
state_receiver = Application.get_env(:indexer, DepositExecute)[:state_receiver],
true <- Helper.is_address_correct?(state_receiver) do
true <- Helper.address_correct?(state_receiver) do
state_receiver = String.downcase(state_receiver)
state_sync_result_event_signature = DepositExecute.state_sync_result_event_signature()

@ -19,7 +19,7 @@ defmodule Indexer.Transform.PolygonEdge.Withdrawals do
items =
with false <- is_nil(Application.get_env(:indexer, Withdrawal)[:start_block_l2]),
state_sender = Application.get_env(:indexer, Withdrawal)[:state_sender],
true <- Helper.is_address_correct?(state_sender) do
true <- Helper.address_correct?(state_sender) do
state_sender = String.downcase(state_sender)
l2_state_synced_event_signature = Withdrawal.l2_state_synced_event_signature()

@ -677,10 +677,10 @@ defmodule Indexer.Transform.TransactionActions do
end)
|> Enum.map(fn {pool_address, pool} ->
token0 =
if Helper.is_address_correct?(pool.token0), do: String.downcase(pool.token0), else: burn_address_hash_string()
if Helper.address_correct?(pool.token0), do: String.downcase(pool.token0), else: burn_address_hash_string()
token1 =
if Helper.is_address_correct?(pool.token1), do: String.downcase(pool.token1), else: burn_address_hash_string()
if Helper.address_correct?(pool.token1), do: String.downcase(pool.token1), else: burn_address_hash_string()
fee = if pool.fee == "", do: 0, else: pool.fee

@ -9,7 +9,7 @@
"benchee": {:hex, :benchee, "1.3.0", "f64e3b64ad3563fa9838146ddefb2d2f94cf5b473bdfd63f5ca4d0657bf96694", [:mix], [{:deep_merge, "~> 1.0", [hex: :deep_merge, repo: "hexpm", optional: false]}, {:statistex, "~> 1.0", [hex: :statistex, repo: "hexpm", optional: false]}, {:table, "~> 0.1.0", [hex: :table, repo: "hexpm", optional: true]}], "hexpm", "34f4294068c11b2bd2ebf2c59aac9c7da26ffa0068afdf3419f1b176e16c5f81"},
"benchee_csv": {:hex, :benchee_csv, "1.0.0", "0b3b9223290bfcb8003552705bec9bcf1a89b4a83b70bd686e45295c264f3d16", [:mix], [{:benchee, ">= 0.99.0 and < 2.0.0", [hex: :benchee, repo: "hexpm", optional: false]}, {:csv, "~> 2.0", [hex: :csv, repo: "hexpm", optional: false]}], "hexpm", "cdefb804c021dcf7a99199492026584be9b5a21d6644ac0d01c81c5d97c520d5"},
"briefly": {:git, "https://github.com/CargoSense/briefly.git", "4836ba322ffb504a102a15cc6e35d928ef97120e", []},
"bunt": {:hex, :bunt, "0.2.1", "e2d4792f7bc0ced7583ab54922808919518d0e57ee162901a16a1b6664ef3b14", [:mix], [], "hexpm", "a330bfb4245239787b15005e66ae6845c9cd524a288f0d141c148b02603777a5"},
"bunt": {:hex, :bunt, "1.0.0", "081c2c665f086849e6d57900292b3a161727ab40431219529f13c4ddcf3e7a44", [:mix], [], "hexpm", "dc5f86aa08a5f6fa6b8096f0735c4e76d54ae5c9fa2c143e5a1fc7c1cd9bb6b5"},
"bureaucrat": {:hex, :bureaucrat, "0.2.9", "d98e4d2b9bdbf22e4a45c2113ce8b38b5b63278506c6ff918e3b943a4355d85b", [:mix], [{:inflex, ">= 1.10.0", [hex: :inflex, repo: "hexpm", optional: false]}, {:phoenix, ">= 1.2.0", [hex: :phoenix, repo: "hexpm", optional: true]}, {:plug, ">= 1.0.0", [hex: :plug, repo: "hexpm", optional: false]}, {:poison, "~> 1.5 or ~> 2.0 or ~> 3.0 or ~> 4.0", [hex: :poison, repo: "hexpm", optional: true]}], "hexpm", "111c8dd84382a62e1026ae011d592ceee918553e5203fe8448d9ba6ccbdfff7d"},
"bypass": {:hex, :bypass, "2.1.0", "909782781bf8e20ee86a9cabde36b259d44af8b9f38756173e8f5e2e1fabb9b1", [:mix], [{:plug, "~> 1.7", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 2.0", [hex: :plug_cowboy, repo: "hexpm", optional: false]}, {:ranch, "~> 1.3", [hex: :ranch, repo: "hexpm", optional: false]}], "hexpm", "d9b5df8fa5b7a6efa08384e9bbecfe4ce61c77d28a4282f79e02f1ef78d96b80"},
"castore": {:hex, :castore, "1.0.4", "ff4d0fb2e6411c0479b1d965a814ea6d00e51eb2f58697446e9c41a97d940b28", [:mix], [], "hexpm", "9418c1b8144e11656f0be99943db4caf04612e3eaecefb5dae9a2a87565584f8"},
@ -27,7 +27,7 @@
"cowboy": {:hex, :cowboy, "2.10.0", "ff9ffeff91dae4ae270dd975642997afe2a1179d94b1887863e43f681a203e26", [:make, :rebar3], [{:cowlib, "2.12.1", [hex: :cowlib, repo: "hexpm", optional: false]}, {:ranch, "1.8.0", [hex: :ranch, repo: "hexpm", optional: false]}], "hexpm", "3afdccb7183cc6f143cb14d3cf51fa00e53db9ec80cdcd525482f5e99bc41d6b"},
"cowboy_telemetry": {:hex, :cowboy_telemetry, "0.3.1", "ebd1a1d7aff97f27c66654e78ece187abdc646992714164380d8a041eda16754", [:rebar3], [{:cowboy, "~> 2.7", [hex: :cowboy, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "3a6efd3366130eab84ca372cbd4a7d3c3a97bdfcfb4911233b035d117063f0af"},
"cowlib": {:hex, :cowlib, "2.12.1", "a9fa9a625f1d2025fe6b462cb865881329b5caff8f1854d1cbc9f9533f00e1e1", [:make, :rebar3], [], "hexpm", "163b73f6367a7341b33c794c4e88e7dbfe6498ac42dcd69ef44c5bc5507c8db0"},
"credo": {:hex, :credo, "1.7.1", "6e26bbcc9e22eefbff7e43188e69924e78818e2fe6282487d0703652bc20fd62", [:mix], [{:bunt, "~> 0.2.1", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2.8", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "e9871c6095a4c0381c89b6aa98bc6260a8ba6addccf7f6a53da8849c748a58a2"},
"credo": {:hex, :credo, "1.7.3", "05bb11eaf2f2b8db370ecaa6a6bda2ec49b2acd5e0418bc106b73b07128c0436", [:mix], [{:bunt, "~> 0.2.1 or ~> 1.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:file_system, "~> 0.2 or ~> 1.0", [hex: :file_system, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "35ea675a094c934c22fb1dca3696f3c31f2728ae6ef5a53b5d648c11180a4535"},
"csv": {:hex, :csv, "2.5.0", "c47b5a5221bf2e56d6e8eb79e77884046d7fd516280dc7d9b674251e0ae46246", [:mix], [{:parallel_stream, "~> 1.0.4 or ~> 1.1.0", [hex: :parallel_stream, repo: "hexpm", optional: false]}], "hexpm", "e821f541487045c7591a1963eeb42afff0dfa99bdcdbeb3410795a2f59c77d34"},
"dataloader": {:hex, :dataloader, "1.0.11", "49bbfc7dd8a1990423c51000b869b1fecaab9e3ccd6b29eab51616ae8ad0a2f5", [:mix], [{:ecto, ">= 3.4.3 and < 4.0.0", [hex: :ecto, repo: "hexpm", optional: true]}, {:telemetry, "~> 1.0 or ~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "ba0b0ec532ec68e9d033d03553561d693129bd7cbd5c649dc7903f07ffba08fe"},
"db_connection": {:hex, :db_connection, "2.6.0", "77d835c472b5b67fc4f29556dee74bf511bbafecdcaf98c27d27fa5918152086", [:mix], [{:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "c2f992d15725e721ec7fbc1189d4ecdb8afef76648c746a8e1cad35e3b8a35f3"},

Loading…
Cancel
Save