Refactor runtime config (#7119)

* Refactor runtime config

* Process reviewer comments

* Invalidate GA cache
pull/7147/head
Victor Baranov 2 years ago committed by GitHub
parent d3758c0d7d
commit c6decf3371
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 26
      .github/workflows/config.yml
  2. 1
      CHANGELOG.md
  3. 14
      apps/block_scout_web/lib/block_scout_web.ex
  4. 6
      apps/block_scout_web/lib/block_scout_web/channels/token_channel.ex
  5. 4
      apps/block_scout_web/lib/block_scout_web/controllers/address_coin_balance_by_day_controller.ex
  6. 6
      apps/block_scout_web/lib/block_scout_web/controllers/address_coin_balance_controller.ex
  7. 4
      apps/block_scout_web/lib/block_scout_web/controllers/address_contract_controller.ex
  8. 4
      apps/block_scout_web/lib/block_scout_web/controllers/address_controller.ex
  9. 4
      apps/block_scout_web/lib/block_scout_web/controllers/address_decompiled_contract_controller.ex
  10. 6
      apps/block_scout_web/lib/block_scout_web/controllers/address_internal_transaction_controller.ex
  11. 6
      apps/block_scout_web/lib/block_scout_web/controllers/address_logs_controller.ex
  12. 6
      apps/block_scout_web/lib/block_scout_web/controllers/address_read_contract_controller.ex
  13. 4
      apps/block_scout_web/lib/block_scout_web/controllers/address_read_proxy_controller.ex
  14. 4
      apps/block_scout_web/lib/block_scout_web/controllers/address_token_balance_controller.ex
  15. 6
      apps/block_scout_web/lib/block_scout_web/controllers/address_token_controller.ex
  16. 10
      apps/block_scout_web/lib/block_scout_web/controllers/address_token_transfer_controller.ex
  17. 6
      apps/block_scout_web/lib/block_scout_web/controllers/address_transaction_controller.ex
  18. 6
      apps/block_scout_web/lib/block_scout_web/controllers/address_validation_controller.ex
  19. 6
      apps/block_scout_web/lib/block_scout_web/controllers/address_write_contract_controller.ex
  20. 4
      apps/block_scout_web/lib/block_scout_web/controllers/address_write_proxy_controller.ex
  21. 14
      apps/block_scout_web/lib/block_scout_web/controllers/api/eth_rpc/eth_controller.ex
  22. 6
      apps/block_scout_web/lib/block_scout_web/controllers/api/rpc/address_controller.ex
  23. 10
      apps/block_scout_web/lib/block_scout_web/controllers/api/rpc/contract_controller.ex
  24. 2
      apps/block_scout_web/lib/block_scout_web/controllers/api/rpc/helper.ex
  25. 6
      apps/block_scout_web/lib/block_scout_web/controllers/api/rpc/rpc_translator.ex
  26. 4
      apps/block_scout_web/lib/block_scout_web/controllers/api/rpc/token_controller.ex
  27. 30
      apps/block_scout_web/lib/block_scout_web/controllers/api/v2/address_controller.ex
  28. 18
      apps/block_scout_web/lib/block_scout_web/controllers/api/v2/smart_contract_controller.ex
  29. 18
      apps/block_scout_web/lib/block_scout_web/controllers/api/v2/token_controller.ex
  30. 26
      apps/block_scout_web/lib/block_scout_web/controllers/api/v2/transaction_controller.ex
  31. 14
      apps/block_scout_web/lib/block_scout_web/controllers/api/v2/verification_controller.ex
  32. 4
      apps/block_scout_web/lib/block_scout_web/controllers/csv_export_controller.ex
  33. 12
      apps/block_scout_web/lib/block_scout_web/controllers/tokens/contract_controller.ex
  34. 6
      apps/block_scout_web/lib/block_scout_web/controllers/tokens/holder_controller.ex
  35. 4
      apps/block_scout_web/lib/block_scout_web/controllers/tokens/inventory_controller.ex
  36. 4
      apps/block_scout_web/lib/block_scout_web/controllers/tokens/token_controller.ex
  37. 6
      apps/block_scout_web/lib/block_scout_web/controllers/tokens/transfer_controller.ex
  38. 10
      apps/block_scout_web/lib/block_scout_web/controllers/transaction_controller.ex
  39. 10
      apps/block_scout_web/lib/block_scout_web/controllers/transaction_internal_transaction_controller.ex
  40. 10
      apps/block_scout_web/lib/block_scout_web/controllers/transaction_log_controller.ex
  41. 6
      apps/block_scout_web/lib/block_scout_web/controllers/transaction_raw_trace_controller.ex
  42. 10
      apps/block_scout_web/lib/block_scout_web/controllers/transaction_state_controller.ex
  43. 10
      apps/block_scout_web/lib/block_scout_web/controllers/transaction_token_transfer_controller.ex
  44. 2
      apps/block_scout_web/lib/block_scout_web/templates/address/_balance_dropdown.html.eex
  45. 30
      apps/block_scout_web/lib/block_scout_web/templates/address/_tabs.html.eex
  46. 2
      apps/block_scout_web/lib/block_scout_web/templates/address/_tile.html.eex
  47. 10
      apps/block_scout_web/lib/block_scout_web/templates/address/overview.html.eex
  48. 2
      apps/block_scout_web/lib/block_scout_web/templates/address_coin_balance/index.html.eex
  49. 6
      apps/block_scout_web/lib/block_scout_web/templates/address_internal_transaction/index.html.eex
  50. 2
      apps/block_scout_web/lib/block_scout_web/templates/address_token/_tokens.html.eex
  51. 2
      apps/block_scout_web/lib/block_scout_web/templates/address_token_balance/_token_balances.html.eex
  52. 6
      apps/block_scout_web/lib/block_scout_web/templates/address_token_balance/_tokens.html.eex
  53. 6
      apps/block_scout_web/lib/block_scout_web/templates/address_token_transfer/index.html.eex
  54. 6
      apps/block_scout_web/lib/block_scout_web/templates/address_transaction/index.html.eex
  55. 2
      apps/block_scout_web/lib/block_scout_web/templates/block/_tile.html.eex
  56. 2
      apps/block_scout_web/lib/block_scout_web/templates/block/overview.html.eex
  57. 2
      apps/block_scout_web/lib/block_scout_web/templates/chain/_block.html.eex
  58. 4
      apps/block_scout_web/lib/block_scout_web/templates/internal_transaction/_tile.html.eex
  59. 2
      apps/block_scout_web/lib/block_scout_web/templates/layout/_search.html.eex
  60. 2
      apps/block_scout_web/lib/block_scout_web/templates/search/_tile.html.eex
  61. 2
      apps/block_scout_web/lib/block_scout_web/templates/search/results.html.eex
  62. 2
      apps/block_scout_web/lib/block_scout_web/templates/tokens/_tile.html.eex
  63. 2
      apps/block_scout_web/lib/block_scout_web/templates/tokens/index.html.eex
  64. 10
      apps/block_scout_web/lib/block_scout_web/templates/tokens/overview/_details.html.eex
  65. 14
      apps/block_scout_web/lib/block_scout_web/templates/tokens/overview/_tabs.html.eex
  66. 6
      apps/block_scout_web/lib/block_scout_web/templates/transaction/_emission_reward_tile.html.eex
  67. 10
      apps/block_scout_web/lib/block_scout_web/templates/transaction/_tabs.html.eex
  68. 6
      apps/block_scout_web/lib/block_scout_web/templates/transaction/_tile.html.eex
  69. 4
      apps/block_scout_web/lib/block_scout_web/templates/transaction/_token_transfer.html.eex
  70. 2
      apps/block_scout_web/lib/block_scout_web/templates/transaction/overview.html.eex
  71. 8
      apps/block_scout_web/lib/block_scout_web/views/access_helper.ex
  72. 2
      apps/block_scout_web/lib/block_scout_web/views/account/watchlist_address_view.ex
  73. 2
      apps/block_scout_web/lib/block_scout_web/views/address_coin_balance_view.ex
  74. 2
      apps/block_scout_web/lib/block_scout_web/views/address_internal_transaction_view.ex
  75. 2
      apps/block_scout_web/lib/block_scout_web/views/address_token_balance_view.ex
  76. 2
      apps/block_scout_web/lib/block_scout_web/views/address_token_transfer_view.ex
  77. 2
      apps/block_scout_web/lib/block_scout_web/views/address_transaction_view.ex
  78. 4
      apps/block_scout_web/lib/block_scout_web/views/address_view.ex
  79. 8
      apps/block_scout_web/lib/block_scout_web/views/api/v2/token_view.ex
  80. 4
      apps/block_scout_web/lib/block_scout_web/views/api/v2/transaction_view.ex
  81. 4
      apps/block_scout_web/lib/block_scout_web/views/currency_helper.ex
  82. 2
      apps/block_scout_web/lib/block_scout_web/views/error_helper.ex
  83. 2
      apps/block_scout_web/lib/block_scout_web/views/nft_helper.ex
  84. 2
      apps/block_scout_web/lib/block_scout_web/views/render_helper.ex
  85. 4
      apps/block_scout_web/lib/block_scout_web/views/script_helper.ex
  86. 10
      apps/block_scout_web/lib/block_scout_web/views/tab_helper.ex
  87. 10
      apps/block_scout_web/lib/block_scout_web/views/tokens/helper.ex
  88. 8
      apps/block_scout_web/lib/block_scout_web/views/tokens/instance/overview_view.ex
  89. 6
      apps/block_scout_web/lib/block_scout_web/views/tokens/overview_view.ex
  90. 10
      apps/block_scout_web/lib/block_scout_web/views/transaction_view.ex
  91. 2
      apps/block_scout_web/lib/block_scout_web/views/wei_helper.ex
  92. 4
      apps/block_scout_web/priv/gettext/default.pot
  93. 4
      apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po
  94. 4
      apps/block_scout_web/test/block_scout_web/controllers/api/rpc/address_controller_test.exs
  95. 4
      apps/block_scout_web/test/block_scout_web/controllers/api/rpc/eth_controller_test.exs
  96. 4
      apps/block_scout_web/test/block_scout_web/controllers/api/v2/stats_controller_test.exs
  97. 2
      apps/block_scout_web/test/block_scout_web/controllers/transaction_state_controller_test.exs
  98. 28
      apps/block_scout_web/test/block_scout_web/views/currency_helper_test.exs
  99. 14
      apps/block_scout_web/test/block_scout_web/views/error_helper_test.exs
  100. 10
      apps/block_scout_web/test/block_scout_web/views/nft_helper_test.exs
  101. Some files were not shown because too many files have changed in this diff Show More

@ -40,7 +40,7 @@ jobs:
path: |
deps
_build
key: ${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-mixlockhash_14-${{ hashFiles('mix.lock') }}
key: ${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-mixlockhash_15-${{ hashFiles('mix.lock') }}
restore-keys: |
${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-
@ -100,7 +100,7 @@ jobs:
path: |
deps
_build
key: ${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-mixlockhash_14-${{ hashFiles('mix.lock') }}
key: ${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-mixlockhash_15-${{ hashFiles('mix.lock') }}
restore-keys: |
${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-"
@ -124,7 +124,7 @@ jobs:
path: |
deps
_build
key: ${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-mixlockhash_14-${{ hashFiles('mix.lock') }}
key: ${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-mixlockhash_15-${{ hashFiles('mix.lock') }}
restore-keys: |
${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-"
@ -147,7 +147,7 @@ jobs:
path: |
deps
_build
key: ${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-mixlockhash_14-${{ hashFiles('mix.lock') }}
key: ${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-mixlockhash_15-${{ hashFiles('mix.lock') }}
restore-keys: |
${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-"
@ -187,7 +187,7 @@ jobs:
path: |
deps
_build
key: ${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-mixlockhash_14-${{ hashFiles('mix.lock') }}
key: ${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-mixlockhash_15-${{ hashFiles('mix.lock') }}
restore-keys: |
${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-"
@ -213,7 +213,7 @@ jobs:
path: |
deps
_build
key: ${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-mixlockhash_14-${{ hashFiles('mix.lock') }}
key: ${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-mixlockhash_15-${{ hashFiles('mix.lock') }}
restore-keys: |
${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-"
@ -242,7 +242,7 @@ jobs:
path: |
deps
_build
key: ${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-mixlockhash_14-${{ hashFiles('mix.lock') }}
key: ${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-mixlockhash_15-${{ hashFiles('mix.lock') }}
restore-keys: |
${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-"
@ -287,7 +287,7 @@ jobs:
path: |
deps
_build
key: ${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-mixlockhash_14-${{ hashFiles('mix.lock') }}
key: ${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-mixlockhash_15-${{ hashFiles('mix.lock') }}
restore-keys: |
${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-"
@ -333,7 +333,7 @@ jobs:
path: |
deps
_build
key: ${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-mixlockhash_14-${{ hashFiles('mix.lock') }}
key: ${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-mixlockhash_15-${{ hashFiles('mix.lock') }}
restore-keys: |
${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-"
@ -392,7 +392,7 @@ jobs:
path: |
deps
_build
key: ${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-mixlockhash_14-${{ hashFiles('mix.lock') }}
key: ${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-mixlockhash_15-${{ hashFiles('mix.lock') }}
restore-keys: |
${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-"
@ -448,7 +448,7 @@ jobs:
path: |
deps
_build
key: ${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-mixlockhash_14-${{ hashFiles('mix.lock') }}
key: ${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-mixlockhash_15-${{ hashFiles('mix.lock') }}
restore-keys: |
${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-"
@ -515,7 +515,7 @@ jobs:
path: |
deps
_build
key: ${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-mixlockhash_14-${{ hashFiles('mix.lock') }}
key: ${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-mixlockhash_15-${{ hashFiles('mix.lock') }}
restore-keys: |
${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-"
@ -581,7 +581,7 @@ jobs:
path: |
deps
_build
key: ${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-mixlockhash_14-${{ hashFiles('mix.lock') }}
key: ${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-mixlockhash_15-${{ hashFiles('mix.lock') }}
restore-keys: |
${{ runner.os }}-${{ env.ELIXIR_VERSION }}-${{ env.OTP_VERSION }}-${{ env.MIX_ENV }}-deps-"

@ -27,6 +27,7 @@
- [#7144](https://github.com/blockscout/blockscout/pull/7144) - Update Blockscout logo
- [#7136](https://github.com/blockscout/blockscout/pull/7136) - Add release link or commit hash to docker images
- [#7097](https://github.com/blockscout/blockscout/pull/7097) - Force display token instance page
- [#7119](https://github.com/blockscout/blockscout/pull/7119) - Refactor runtime config
- [#7072](https://github.com/blockscout/blockscout/pull/7072) - Add a separate docker compose for geth with clique consensus
- [#7056](https://github.com/blockscout/blockscout/pull/7056) - Add path_helper in interact.js
- [#7040](https://github.com/blockscout/blockscout/pull/7040) - Use alias BlockScoutWeb.Cldr.Number

@ -26,7 +26,7 @@ defmodule BlockScoutWeb do
import BlockScoutWeb.Router.Helpers
import BlockScoutWeb.WebRouter.Helpers, except: [static_path: 2]
import BlockScoutWeb.Gettext
import BlockScoutWeb.ErrorHelpers
import BlockScoutWeb.ErrorHelper
import Plug.Conn
alias BlockScoutWeb.AdminRouter.Helpers, as: AdminRoutes
@ -46,14 +46,14 @@ defmodule BlockScoutWeb do
use Phoenix.HTML
import BlockScoutWeb.{
CurrencyHelpers,
ErrorHelpers,
CurrencyHelper,
ErrorHelper,
Gettext,
Router.Helpers,
TabHelpers,
Tokens.Helpers,
Views.ScriptHelpers,
WeiHelpers
TabHelper,
Tokens.Helper,
Views.ScriptHelper,
WeiHelper
}
import BlockScoutWeb.WebRouter.Helpers, except: [static_path: 2]

@ -4,7 +4,7 @@ defmodule BlockScoutWeb.TokenChannel do
"""
use BlockScoutWeb, :channel
alias BlockScoutWeb.{CurrencyHelpers, TokensView}
alias BlockScoutWeb.{CurrencyHelper, TokensView}
alias BlockScoutWeb.Tokens.TransferView
alias Explorer.Chain
alias Explorer.Chain.Hash
@ -64,8 +64,8 @@ defmodule BlockScoutWeb.TokenChannel do
push(socket, "total_supply", %{
total_supply:
if(TokensView.decimals?(token),
do: CurrencyHelpers.format_according_to_decimals(token.total_supply, token.decimals),
else: CurrencyHelpers.format_integer_to_currency(token.total_supply)
do: CurrencyHelper.format_according_to_decimals(token.total_supply, token.decimals),
else: CurrencyHelper.format_integer_to_currency(token.total_supply)
)
})

@ -5,12 +5,12 @@ defmodule BlockScoutWeb.AddressCoinBalanceByDayController do
use BlockScoutWeb, :controller
alias BlockScoutWeb.AccessHelpers
alias BlockScoutWeb.AccessHelper
alias Explorer.Chain
def index(conn, %{"address_id" => address_hash_string, "type" => "JSON"} = params) do
with {:ok, address_hash} <- Chain.string_to_address_hash(address_hash_string),
{:ok, false} <- AccessHelpers.restricted_access?(address_hash_string, params) do
{:ok, false} <- AccessHelper.restricted_access?(address_hash_string, params) do
balances_by_day =
address_hash
|> Chain.address_to_balances_by_day()

@ -9,7 +9,7 @@ defmodule BlockScoutWeb.AddressCoinBalanceController do
import BlockScoutWeb.Chain, only: [paging_options: 1, next_page_params: 3, split_list_by_page: 1]
import BlockScoutWeb.Models.GetAddressTags, only: [get_address_tags: 2]
alias BlockScoutWeb.{AccessHelpers, AddressCoinBalanceView, Controller}
alias BlockScoutWeb.{AccessHelper, AddressCoinBalanceView, Controller}
alias Explorer.{Chain, Market}
alias Explorer.Chain.{Address, Wei}
alias Explorer.ExchangeRates.Token
@ -19,7 +19,7 @@ defmodule BlockScoutWeb.AddressCoinBalanceController do
def index(conn, %{"address_id" => address_hash_string, "type" => "JSON"} = params) do
with {:ok, address_hash} <- Chain.string_to_address_hash(address_hash_string),
:ok <- Chain.check_address_exists(address_hash),
{:ok, false} <- AccessHelpers.restricted_access?(address_hash_string, params) do
{:ok, false} <- AccessHelper.restricted_access?(address_hash_string, params) do
full_options = paging_options(params)
coin_balances_plus_one = Chain.address_to_coin_balances(address_hash, full_options)
@ -72,7 +72,7 @@ defmodule BlockScoutWeb.AddressCoinBalanceController do
def index(conn, %{"address_id" => address_hash_string} = params) do
with {:ok, address_hash} <- Chain.string_to_address_hash(address_hash_string),
{:ok, address} <- Chain.hash_to_address(address_hash),
{:ok, false} <- AccessHelpers.restricted_access?(address_hash_string, params) do
{:ok, false} <- AccessHelper.restricted_access?(address_hash_string, params) do
render(conn, "index.html",
address: address,
coin_balance_status: CoinBalanceOnDemand.trigger_fetch(address),

@ -5,7 +5,7 @@ defmodule BlockScoutWeb.AddressContractController do
import BlockScoutWeb.Account.AuthController, only: [current_user: 1]
import BlockScoutWeb.Models.GetAddressTags, only: [get_address_tags: 2]
alias BlockScoutWeb.AccessHelpers
alias BlockScoutWeb.AccessHelper
alias Explorer.{Chain, Market}
alias Explorer.ExchangeRates.Token
alias Explorer.SmartContract.Solidity.PublishHelper
@ -23,7 +23,7 @@ defmodule BlockScoutWeb.AddressContractController do
]
with {:ok, address_hash} <- Chain.string_to_address_hash(address_hash_string),
{:ok, false} <- AccessHelpers.restricted_access?(address_hash_string, params),
{:ok, false} <- AccessHelper.restricted_access?(address_hash_string, params),
_ <- PublishHelper.check_and_verify(address_hash_string),
{:ok, address} <- Chain.find_contract_address(address_hash, address_options, true) do
render(

@ -8,7 +8,7 @@ defmodule BlockScoutWeb.AddressController do
import BlockScoutWeb.Models.GetAddressTags, only: [get_address_tags: 2]
alias BlockScoutWeb.{
AccessHelpers,
AccessHelper,
AddressTransactionController,
AddressView,
Controller
@ -95,7 +95,7 @@ defmodule BlockScoutWeb.AddressController do
def show(conn, %{"id" => address_hash_string} = params) do
with {:ok, address_hash} <- Chain.string_to_address_hash(address_hash_string),
{:ok, address} <- Chain.hash_to_address(address_hash),
{:ok, false} <- AccessHelpers.restricted_access?(address_hash_string, params) do
{:ok, false} <- AccessHelper.restricted_access?(address_hash_string, params) do
render(
conn,
"_show_address_transactions.html",

@ -4,7 +4,7 @@ defmodule BlockScoutWeb.AddressDecompiledContractController do
import BlockScoutWeb.Account.AuthController, only: [current_user: 1]
import BlockScoutWeb.Models.GetAddressTags, only: [get_address_tags: 2]
alias BlockScoutWeb.AccessHelpers
alias BlockScoutWeb.AccessHelper
alias Explorer.{Chain, Market}
alias Explorer.ExchangeRates.Token
alias Indexer.Fetcher.CoinBalanceOnDemand
@ -12,7 +12,7 @@ defmodule BlockScoutWeb.AddressDecompiledContractController do
def index(conn, %{"address_id" => address_hash_string} = params) do
with {:ok, address_hash} <- Chain.string_to_address_hash(address_hash_string),
{:ok, address} <- Chain.find_decompiled_contract_address(address_hash),
{:ok, false} <- AccessHelpers.restricted_access?(address_hash_string, params) do
{:ok, false} <- AccessHelper.restricted_access?(address_hash_string, params) do
render(
conn,
"index.html",

@ -9,7 +9,7 @@ defmodule BlockScoutWeb.AddressInternalTransactionController do
import BlockScoutWeb.Chain, only: [current_filter: 1, paging_options: 1, next_page_params: 3, split_list_by_page: 1]
import BlockScoutWeb.Models.GetAddressTags, only: [get_address_tags: 2]
alias BlockScoutWeb.{AccessHelpers, Controller, InternalTransactionView}
alias BlockScoutWeb.{AccessHelper, Controller, InternalTransactionView}
alias Explorer.{Chain, Market}
alias Explorer.Chain.{Address, Wei}
alias Explorer.ExchangeRates.Token
@ -20,7 +20,7 @@ defmodule BlockScoutWeb.AddressInternalTransactionController do
with {:ok, address_hash} <- Chain.string_to_address_hash(address_hash_string),
{:ok, address} <-
Chain.hash_to_address(address_hash, [necessity_by_association: %{:smart_contract => :optional}], false),
{:ok, false} <- AccessHelpers.restricted_access?(address_hash_string, params) do
{:ok, false} <- AccessHelper.restricted_access?(address_hash_string, params) do
full_options =
[
necessity_by_association: %{
@ -79,7 +79,7 @@ defmodule BlockScoutWeb.AddressInternalTransactionController do
def index(conn, %{"address_id" => address_hash_string} = params) do
with {:ok, address_hash} <- Chain.string_to_address_hash(address_hash_string),
{:ok, address} <- Chain.hash_to_address(address_hash),
{:ok, false} <- AccessHelpers.restricted_access?(address_hash_string, params) do
{:ok, false} <- AccessHelper.restricted_access?(address_hash_string, params) do
render(
conn,
"index.html",

@ -9,7 +9,7 @@ defmodule BlockScoutWeb.AddressLogsController do
import BlockScoutWeb.Models.GetAddressTags, only: [get_address_tags: 2]
alias BlockScoutWeb.{AccessHelpers, AddressLogsView, Controller}
alias BlockScoutWeb.{AccessHelper, AddressLogsView, Controller}
alias Explorer.{Chain, Market}
alias Explorer.ExchangeRates.Token
alias Indexer.Fetcher.CoinBalanceOnDemand
@ -20,7 +20,7 @@ defmodule BlockScoutWeb.AddressLogsController do
def index(conn, %{"address_id" => address_hash_string, "type" => "JSON"} = params) do
with {:ok, address_hash} <- Chain.string_to_address_hash(address_hash_string),
:ok <- Chain.check_address_exists(address_hash),
{:ok, false} <- AccessHelpers.restricted_access?(address_hash_string, params) do
{:ok, false} <- AccessHelper.restricted_access?(address_hash_string, params) do
logs_plus_one = Chain.address_to_logs(address_hash, paging_options(params))
{results, next_page} = split_list_by_page(logs_plus_one)
@ -60,7 +60,7 @@ defmodule BlockScoutWeb.AddressLogsController do
def index(conn, %{"address_id" => address_hash_string} = params) do
with {:ok, address_hash} <- Chain.string_to_address_hash(address_hash_string),
{:ok, address} <- Chain.hash_to_address(address_hash),
{:ok, false} <- AccessHelpers.restricted_access?(address_hash_string, params) do
{:ok, false} <- AccessHelper.restricted_access?(address_hash_string, params) do
render(
conn,
"index.html",

@ -11,7 +11,7 @@ defmodule BlockScoutWeb.AddressReadContractController do
import BlockScoutWeb.Account.AuthController, only: [current_user: 1]
import BlockScoutWeb.Models.GetAddressTags, only: [get_address_tags: 2]
alias BlockScoutWeb.AccessHelpers
alias BlockScoutWeb.AccessHelper
alias BlockScoutWeb.AddressView
alias Explorer.{Chain, Market}
alias Explorer.Chain.Address
@ -47,7 +47,7 @@ defmodule BlockScoutWeb.AddressReadContractController do
{:ok, address} <- Chain.find_contract_address(address_hash, address_options, true),
false <- is_nil(address.smart_contract),
need_wallet? <- Reader.read_functions_required_wallet_from_abi(address.smart_contract.abi) != [],
{:ok, false} <- AccessHelpers.restricted_access?(address_hash_string, params) do
{:ok, false} <- AccessHelper.restricted_access?(address_hash_string, params) do
render(
conn,
"index.html",
@ -66,7 +66,7 @@ defmodule BlockScoutWeb.AddressReadContractController do
if custom_abi? do
with {:ok, address_hash} <- Chain.string_to_address_hash(address_hash_string),
{:ok, address} <- Chain.find_contract_address(address_hash, address_options, false),
{:ok, false} <- AccessHelpers.restricted_access?(address_hash_string, params) do
{:ok, false} <- AccessHelper.restricted_access?(address_hash_string, params) do
render(
conn,
"index.html",

@ -5,7 +5,7 @@ defmodule BlockScoutWeb.AddressReadProxyController do
import BlockScoutWeb.Account.AuthController, only: [current_user: 1]
import BlockScoutWeb.Models.GetAddressTags, only: [get_address_tags: 2]
alias BlockScoutWeb.AccessHelpers
alias BlockScoutWeb.AccessHelper
alias Explorer.{Chain, Market}
alias Explorer.Chain.Address
alias Explorer.ExchangeRates.Token
@ -25,7 +25,7 @@ defmodule BlockScoutWeb.AddressReadProxyController do
with {:ok, address_hash} <- Chain.string_to_address_hash(address_hash_string),
{:ok, address} <- Chain.find_contract_address(address_hash, address_options, true),
false <- is_nil(address.smart_contract),
{:ok, false} <- AccessHelpers.restricted_access?(address_hash_string, params) do
{:ok, false} <- AccessHelper.restricted_access?(address_hash_string, params) do
render(
conn,
"index.html",

@ -1,7 +1,7 @@
defmodule BlockScoutWeb.AddressTokenBalanceController do
use BlockScoutWeb, :controller
alias BlockScoutWeb.AccessHelpers
alias BlockScoutWeb.AccessHelper
alias Explorer.Chain
alias Explorer.Chain.Address
alias Indexer.Fetcher.TokenBalanceOnDemand
@ -17,7 +17,7 @@ defmodule BlockScoutWeb.AddressTokenBalanceController do
TokenBalanceOnDemand.trigger_fetch(address_hash, token_balances)
end)
case AccessHelpers.restricted_access?(address_hash_string, params) do
case AccessHelper.restricted_access?(address_hash_string, params) do
{:ok, false} ->
conn
|> put_status(200)

@ -5,7 +5,7 @@ defmodule BlockScoutWeb.AddressTokenController do
import BlockScoutWeb.Account.AuthController, only: [current_user: 1]
import BlockScoutWeb.Models.GetAddressTags, only: [get_address_tags: 2]
alias BlockScoutWeb.{AccessHelpers, AddressTokenView, Controller}
alias BlockScoutWeb.{AccessHelper, AddressTokenView, Controller}
alias Explorer.{Chain, Market}
alias Explorer.Chain.Address
alias Explorer.ExchangeRates.Token
@ -15,7 +15,7 @@ defmodule BlockScoutWeb.AddressTokenController do
def index(conn, %{"address_id" => address_hash_string, "type" => "JSON"} = params) do
with {:ok, address_hash} <- Chain.string_to_address_hash(address_hash_string),
{:ok, address} <- Chain.hash_to_address(address_hash, [], false),
{:ok, false} <- AccessHelpers.restricted_access?(address_hash_string, params) do
{:ok, false} <- AccessHelper.restricted_access?(address_hash_string, params) do
token_balances_plus_one =
address_hash
|> Chain.fetch_paginated_last_token_balances(paging_options(params))
@ -66,7 +66,7 @@ defmodule BlockScoutWeb.AddressTokenController do
def index(conn, %{"address_id" => address_hash_string} = params) do
with {:ok, address_hash} <- Chain.string_to_address_hash(address_hash_string),
{:ok, address} <- Chain.hash_to_address(address_hash),
{:ok, false} <- AccessHelpers.restricted_access?(address_hash_string, params) do
{:ok, false} <- AccessHelper.restricted_access?(address_hash_string, params) do
render(
conn,
"index.html",

@ -4,7 +4,7 @@ defmodule BlockScoutWeb.AddressTokenTransferController do
import BlockScoutWeb.Account.AuthController, only: [current_user: 1]
import BlockScoutWeb.Models.GetAddressTags, only: [get_address_tags: 2]
alias BlockScoutWeb.{AccessHelpers, Controller, TransactionView}
alias BlockScoutWeb.{AccessHelper, Controller, TransactionView}
alias Explorer.ExchangeRates.Token
alias Explorer.{Chain, Market}
alias Explorer.Chain.Address
@ -45,7 +45,7 @@ defmodule BlockScoutWeb.AddressTokenTransferController do
{:ok, token_hash} <- Chain.string_to_address_hash(token_hash_string),
{:ok, address} <- Chain.hash_to_address(address_hash),
{:ok, _} <- Chain.token_from_address_hash(token_hash),
{:ok, false} <- AccessHelpers.restricted_access?(address_hash_string, params) do
{:ok, false} <- AccessHelper.restricted_access?(address_hash_string, params) do
transactions =
Chain.address_to_transactions_with_token_transfers(
address_hash,
@ -103,7 +103,7 @@ defmodule BlockScoutWeb.AddressTokenTransferController do
{:ok, token_hash} <- Chain.string_to_address_hash(token_hash_string),
{:ok, address} <- Chain.hash_to_address(address_hash),
{:ok, token} <- Chain.token_from_address_hash(token_hash),
{:ok, false} <- AccessHelpers.restricted_access?(address_hash_string, params) do
{:ok, false} <- AccessHelper.restricted_access?(address_hash_string, params) do
render(
conn,
"index.html",
@ -136,7 +136,7 @@ defmodule BlockScoutWeb.AddressTokenTransferController do
) do
with {:ok, address_hash} <- Chain.string_to_address_hash(address_hash_string),
{:ok, address} <- Chain.hash_to_address(address_hash),
{:ok, false} <- AccessHelpers.restricted_access?(address_hash_string, params) do
{:ok, false} <- AccessHelper.restricted_access?(address_hash_string, params) do
options =
@transaction_necessity_by_association
|> Keyword.merge(paging_options(params))
@ -195,7 +195,7 @@ defmodule BlockScoutWeb.AddressTokenTransferController do
) do
with {:ok, address_hash} <- Chain.string_to_address_hash(address_hash_string),
{:ok, address} <- Chain.hash_to_address(address_hash),
{:ok, false} <- AccessHelpers.restricted_access?(address_hash_string, params) do
{:ok, false} <- AccessHelper.restricted_access?(address_hash_string, params) do
render(
conn,
"index.html",

@ -11,7 +11,7 @@ defmodule BlockScoutWeb.AddressTransactionController do
import BlockScoutWeb.Models.GetAddressTags, only: [get_address_tags: 2]
alias BlockScoutWeb.{AccessHelpers, Controller, TransactionView}
alias BlockScoutWeb.{AccessHelper, Controller, TransactionView}
alias Explorer.{Chain, Market}
alias Explorer.Chain.{
@ -48,7 +48,7 @@ defmodule BlockScoutWeb.AddressTransactionController do
with {:ok, address_hash} <- Chain.string_to_address_hash(address_hash_string),
{:ok, address} <- Chain.hash_to_address(address_hash, address_options, false),
{:ok, false} <- AccessHelpers.restricted_access?(address_hash_string, params) do
{:ok, false} <- AccessHelper.restricted_access?(address_hash_string, params) do
options =
@transaction_necessity_by_association
|> Keyword.merge(paging_options(params))
@ -117,7 +117,7 @@ defmodule BlockScoutWeb.AddressTransactionController do
def index(conn, %{"address_id" => address_hash_string} = params) do
with {:ok, address_hash} <- Chain.string_to_address_hash(address_hash_string),
{:ok, address} <- Chain.hash_to_address(address_hash),
{:ok, false} <- AccessHelpers.restricted_access?(address_hash_string, params) do
{:ok, false} <- AccessHelper.restricted_access?(address_hash_string, params) do
render(
conn,
"index.html",

@ -11,7 +11,7 @@ defmodule BlockScoutWeb.AddressValidationController do
import BlockScoutWeb.Models.GetAddressTags, only: [get_address_tags: 2]
alias BlockScoutWeb.{AccessHelpers, BlockView, Controller}
alias BlockScoutWeb.{AccessHelper, BlockView, Controller}
alias Explorer.ExchangeRates.Token
alias Explorer.{Chain, Market}
alias Indexer.Fetcher.CoinBalanceOnDemand
@ -20,7 +20,7 @@ defmodule BlockScoutWeb.AddressValidationController do
def index(conn, %{"address_id" => address_hash_string, "type" => "JSON"} = params) do
with {:ok, address_hash} <- Chain.string_to_address_hash(address_hash_string),
{:ok, _} <- Chain.find_or_insert_address_from_hash(address_hash, [], false),
{:ok, false} <- AccessHelpers.restricted_access?(address_hash_string, params) do
{:ok, false} <- AccessHelper.restricted_access?(address_hash_string, params) do
full_options =
Keyword.merge(
[
@ -75,7 +75,7 @@ defmodule BlockScoutWeb.AddressValidationController do
def index(conn, %{"address_id" => address_hash_string} = params) do
with {:ok, address_hash} <- Chain.string_to_address_hash(address_hash_string),
{:ok, address} <- Chain.find_or_insert_address_from_hash(address_hash),
{:ok, false} <- AccessHelpers.restricted_access?(address_hash_string, params) do
{:ok, false} <- AccessHelper.restricted_access?(address_hash_string, params) do
render(
conn,
"index.html",

@ -11,7 +11,7 @@ defmodule BlockScoutWeb.AddressWriteContractController do
import BlockScoutWeb.Account.AuthController, only: [current_user: 1]
import BlockScoutWeb.Models.GetAddressTags, only: [get_address_tags: 2]
alias BlockScoutWeb.AccessHelpers
alias BlockScoutWeb.AccessHelper
alias BlockScoutWeb.AddressView
alias Explorer.{Chain, Market}
alias Explorer.Chain.Address
@ -42,7 +42,7 @@ defmodule BlockScoutWeb.AddressWriteContractController do
{:ok, address_hash} <- Chain.string_to_address_hash(address_hash_string),
{:ok, address} <- Chain.find_contract_address(address_hash, address_options, true),
false <- is_nil(address.smart_contract),
{:ok, false} <- AccessHelpers.restricted_access?(address_hash_string, params) do
{:ok, false} <- AccessHelper.restricted_access?(address_hash_string, params) do
render(
conn,
"index.html",
@ -60,7 +60,7 @@ defmodule BlockScoutWeb.AddressWriteContractController do
if custom_abi? do
with {:ok, address_hash} <- Chain.string_to_address_hash(address_hash_string),
{:ok, address} <- Chain.find_contract_address(address_hash, address_options, false),
{:ok, false} <- AccessHelpers.restricted_access?(address_hash_string, params) do
{:ok, false} <- AccessHelper.restricted_access?(address_hash_string, params) do
render(
conn,
"index.html",

@ -5,7 +5,7 @@ defmodule BlockScoutWeb.AddressWriteProxyController do
import BlockScoutWeb.Account.AuthController, only: [current_user: 1]
import BlockScoutWeb.Models.GetAddressTags, only: [get_address_tags: 2]
alias BlockScoutWeb.{AccessHelpers, AddressView}
alias BlockScoutWeb.{AccessHelper, AddressView}
alias Explorer.{Chain, Market}
alias Explorer.Chain.Address
alias Explorer.ExchangeRates.Token
@ -26,7 +26,7 @@ defmodule BlockScoutWeb.AddressWriteProxyController do
{:ok, address_hash} <- Chain.string_to_address_hash(address_hash_string),
{:ok, address} <- Chain.find_contract_address(address_hash, address_options, true),
false <- is_nil(address.smart_contract),
{:ok, false} <- AccessHelpers.restricted_access?(address_hash_string, params) do
{:ok, false} <- AccessHelper.restricted_access?(address_hash_string, params) do
render(
conn,
"index.html",

@ -1,12 +1,12 @@
defmodule BlockScoutWeb.API.EthRPC.EthController do
use BlockScoutWeb, :controller
alias BlockScoutWeb.AccessHelpers
alias BlockScoutWeb.AccessHelper
alias BlockScoutWeb.API.EthRPC.View, as: EthRPCView
alias Explorer.EthRPC
def eth_request(%{body_params: %{"_json" => requests}} = conn, _) when is_list(requests) do
case AccessHelpers.check_rate_limit(conn) do
case AccessHelper.check_rate_limit(conn) do
:ok ->
responses = EthRPC.responses(requests)
@ -16,12 +16,12 @@ defmodule BlockScoutWeb.API.EthRPC.EthController do
|> render("responses.json", %{responses: responses})
:rate_limit_reached ->
AccessHelpers.handle_rate_limit_deny(conn)
AccessHelper.handle_rate_limit_deny(conn)
end
end
def eth_request(%{body_params: %{"_json" => request}} = conn, _) do
case AccessHelpers.check_rate_limit(conn) do
case AccessHelper.check_rate_limit(conn) do
:ok ->
[response] = EthRPC.responses([request])
@ -31,12 +31,12 @@ defmodule BlockScoutWeb.API.EthRPC.EthController do
|> render("response.json", %{response: response})
:rate_limit_reached ->
AccessHelpers.handle_rate_limit_deny(conn)
AccessHelper.handle_rate_limit_deny(conn)
end
end
def eth_request(conn, request) do
case AccessHelpers.check_rate_limit(conn) do
case AccessHelper.check_rate_limit(conn) do
:ok ->
# In the case that the JSON body is sent up w/o a json content type,
# Phoenix encodes it as a single key value pair, with the value being
@ -57,7 +57,7 @@ defmodule BlockScoutWeb.API.EthRPC.EthController do
|> render("response.json", %{response: response})
:rate_limit_reached ->
AccessHelpers.handle_rate_limit_deny(conn)
AccessHelper.handle_rate_limit_deny(conn)
end
end
end

@ -1,7 +1,7 @@
defmodule BlockScoutWeb.API.RPC.AddressController do
use BlockScoutWeb, :controller
alias BlockScoutWeb.API.RPC.Helpers
alias BlockScoutWeb.API.RPC.Helper
alias Explorer.{Chain, Etherscan}
alias Explorer.Chain.{Address, Wei}
alias Explorer.Etherscan.{Addresses, Blocks}
@ -221,7 +221,7 @@ defmodule BlockScoutWeb.API.RPC.AddressController do
end
def getminedblocks(conn, params) do
options = Helpers.put_pagination_options(%{}, params)
options = Helper.put_pagination_options(%{}, params)
with {:address_param, {:ok, address_param}} <- fetch_address(params),
{:format, {:ok, address_hash}} <- to_address_hash(address_param),
@ -248,7 +248,7 @@ defmodule BlockScoutWeb.API.RPC.AddressController do
def optional_params(params) do
%{}
|> put_order_by_direction(params)
|> Helpers.put_pagination_options(params)
|> Helper.put_pagination_options(params)
|> put_block(params, "start_block")
|> put_block(params, "end_block")
|> put_filter_by(params)

@ -3,12 +3,12 @@ defmodule BlockScoutWeb.API.RPC.ContractController do
require Logger
alias BlockScoutWeb.API.RPC.{AddressController, Helpers}
alias BlockScoutWeb.API.RPC.{AddressController, Helper}
alias Explorer.Chain
alias Explorer.Chain.{Address, Hash, SmartContract}
alias Explorer.Chain.SmartContract.VerificationStatus
alias Explorer.Etherscan.Contracts
alias Explorer.SmartContract.Helper
alias Explorer.SmartContract.Helper, as: SmartContractHelper
alias Explorer.SmartContract.Solidity.{Publisher, PublishHelper}
alias Explorer.SmartContract.Solidity.PublisherWorker, as: SolidityPublisherWorker
alias Explorer.SmartContract.Vyper.Publisher, as: VyperPublisher
@ -179,11 +179,11 @@ defmodule BlockScoutWeb.API.RPC.ContractController do
jsons =
files_array
|> Enum.filter(fn file -> Helper.json_file?(file.filename) end)
|> Enum.filter(fn file -> SmartContractHelper.json_file?(file.filename) end)
sols =
files_array
|> Enum.filter(fn file -> Helper.sol_file?(file.filename) end)
|> Enum.filter(fn file -> SmartContractHelper.sol_file?(file.filename) end)
if length(jsons) > 0 and length(sols) > 0 do
{:ok, files_array}
@ -311,7 +311,7 @@ defmodule BlockScoutWeb.API.RPC.ContractController do
end
def listcontracts(conn, params) do
with pagination_options <- Helpers.put_pagination_options(%{}, params),
with pagination_options <- Helper.put_pagination_options(%{}, params),
{:params, {:ok, options}} <- {:params, add_filters(pagination_options, params)} do
options_with_defaults =
options

@ -1,4 +1,4 @@
defmodule BlockScoutWeb.API.RPC.Helpers do
defmodule BlockScoutWeb.API.RPC.Helper do
@moduledoc """
Small helpers for RPC api controllers.
"""

@ -18,7 +18,7 @@ defmodule BlockScoutWeb.API.RPC.RPCTranslator do
import Plug.Conn
import Phoenix.Controller, only: [put_view: 2]
alias BlockScoutWeb.AccessHelpers
alias BlockScoutWeb.AccessHelper
alias BlockScoutWeb.API.APILogger
alias BlockScoutWeb.API.RPC.RPCView
alias Phoenix.Controller
@ -33,7 +33,7 @@ defmodule BlockScoutWeb.API.RPC.RPCTranslator do
{:ok, {controller, write_actions}} <- translate_module(translations, module),
{:ok, action} <- translate_action(action),
true <- action_accessed?(action, write_actions),
:ok <- AccessHelpers.check_rate_limit(conn),
:ok <- AccessHelper.check_rate_limit(conn),
{:ok, conn} <- call_controller(conn, controller, action) do
conn
else
@ -56,7 +56,7 @@ defmodule BlockScoutWeb.API.RPC.RPCTranslator do
|> halt()
:rate_limit_reached ->
AccessHelpers.handle_rate_limit_deny(conn)
AccessHelper.handle_rate_limit_deny(conn)
_ ->
conn

@ -1,7 +1,7 @@
defmodule BlockScoutWeb.API.RPC.TokenController do
use BlockScoutWeb, :controller
alias BlockScoutWeb.API.RPC.Helpers
alias BlockScoutWeb.API.RPC.Helper
alias Explorer.{Chain, PagingOptions}
def gettoken(conn, params) do
@ -22,7 +22,7 @@ defmodule BlockScoutWeb.API.RPC.TokenController do
end
def gettokenholders(conn, params) do
with pagination_options <- Helpers.put_pagination_options(%{}, params),
with pagination_options <- Helper.put_pagination_options(%{}, params),
{:contractaddress_param, {:ok, contractaddress_param}} <- fetch_contractaddress(params),
{:format, {:ok, address_hash}} <- to_address_hash(contractaddress_param) do
options_with_defaults =

@ -13,7 +13,7 @@ defmodule BlockScoutWeb.API.V2.AddressController do
import BlockScoutWeb.PagingHelper,
only: [delete_parameters_from_next_page_params: 1, token_transfers_types_options: 1]
alias BlockScoutWeb.AccessHelpers
alias BlockScoutWeb.AccessHelper
alias BlockScoutWeb.API.V2.{BlockView, TransactionView}
alias Explorer.ExchangeRates.Token
alias Explorer.{Chain, Market}
@ -59,7 +59,7 @@ defmodule BlockScoutWeb.API.V2.AddressController do
def address(conn, %{"address_hash" => address_hash_string} = params) do
with {:format, {:ok, address_hash}} <- {:format, Chain.string_to_address_hash(address_hash_string)},
{:ok, false} <- AccessHelpers.restricted_access?(address_hash_string, params),
{:ok, false} <- AccessHelper.restricted_access?(address_hash_string, params),
{:not_found, {:ok, address}} <- {:not_found, Chain.hash_to_address(address_hash, @address_options)} do
CoinBalanceOnDemand.trigger_fetch(address)
@ -71,7 +71,7 @@ defmodule BlockScoutWeb.API.V2.AddressController do
def counters(conn, %{"address_hash" => address_hash_string} = params) do
with {:format, {:ok, address_hash}} <- {:format, Chain.string_to_address_hash(address_hash_string)},
{:ok, false} <- AccessHelpers.restricted_access?(address_hash_string, params),
{:ok, false} <- AccessHelper.restricted_access?(address_hash_string, params),
{:not_found, {:ok, address}} <- {:not_found, Chain.hash_to_address(address_hash, @api_true, false)} do
{validation_count} = Chain.address_counters(address, @api_true)
@ -90,7 +90,7 @@ defmodule BlockScoutWeb.API.V2.AddressController do
def token_balances(conn, %{"address_hash" => address_hash_string} = params) do
with {:format, {:ok, address_hash}} <- {:format, Chain.string_to_address_hash(address_hash_string)},
{:ok, false} <- AccessHelpers.restricted_access?(address_hash_string, params),
{:ok, false} <- AccessHelper.restricted_access?(address_hash_string, params),
{:not_found, {:ok, _address}} <- {:not_found, Chain.hash_to_address(address_hash, @api_true, false)} do
token_balances =
address_hash
@ -108,7 +108,7 @@ defmodule BlockScoutWeb.API.V2.AddressController do
def transactions(conn, %{"address_hash" => address_hash_string} = params) do
with {:format, {:ok, address_hash}} <- {:format, Chain.string_to_address_hash(address_hash_string)},
{:ok, false} <- AccessHelpers.restricted_access?(address_hash_string, params),
{:ok, false} <- AccessHelper.restricted_access?(address_hash_string, params),
{:not_found, {:ok, _address}} <- {:not_found, Chain.hash_to_address(address_hash, @api_true, false)} do
options =
@transaction_necessity_by_association
@ -134,8 +134,8 @@ defmodule BlockScoutWeb.API.V2.AddressController do
) do
with {:format, {:ok, address_hash}} <- {:format, Chain.string_to_address_hash(address_hash_string)},
{:format, {:ok, token_address_hash}} <- {:format, Chain.string_to_address_hash(token_address_hash_string)},
{:ok, false} <- AccessHelpers.restricted_access?(address_hash_string, params),
{:ok, false} <- AccessHelpers.restricted_access?(token_address_hash_string, params),
{:ok, false} <- AccessHelper.restricted_access?(address_hash_string, params),
{:ok, false} <- AccessHelper.restricted_access?(token_address_hash_string, params),
{:not_found, {:ok, _address}} <- {:not_found, Chain.hash_to_address(address_hash, @api_true, false)},
{:not_found, {:ok, _}} <- {:not_found, Chain.token_from_address_hash(token_address_hash, @api_true)} do
paging_options = paging_options(params)
@ -178,7 +178,7 @@ defmodule BlockScoutWeb.API.V2.AddressController do
def token_transfers(conn, %{"address_hash" => address_hash_string} = params) do
with {:format, {:ok, address_hash}} <- {:format, Chain.string_to_address_hash(address_hash_string)},
{:ok, false} <- AccessHelpers.restricted_access?(address_hash_string, params),
{:ok, false} <- AccessHelper.restricted_access?(address_hash_string, params),
{:not_found, {:ok, _address}} <- {:not_found, Chain.hash_to_address(address_hash, @api_true, false)} do
paging_options = paging_options(params)
@ -210,7 +210,7 @@ defmodule BlockScoutWeb.API.V2.AddressController do
def internal_transactions(conn, %{"address_hash" => address_hash_string} = params) do
with {:format, {:ok, address_hash}} <- {:format, Chain.string_to_address_hash(address_hash_string)},
{:ok, false} <- AccessHelpers.restricted_access?(address_hash_string, params),
{:ok, false} <- AccessHelper.restricted_access?(address_hash_string, params),
{:not_found, {:ok, _address}} <- {:not_found, Chain.hash_to_address(address_hash, @api_true, false)} do
full_options =
[
@ -245,7 +245,7 @@ defmodule BlockScoutWeb.API.V2.AddressController do
def logs(conn, %{"address_hash" => address_hash_string, "topic" => topic} = params) do
with {:format, {:ok, address_hash}} <- {:format, Chain.string_to_address_hash(address_hash_string)},
{:ok, false} <- AccessHelpers.restricted_access?(address_hash_string, params),
{:ok, false} <- AccessHelper.restricted_access?(address_hash_string, params),
{:not_found, {:ok, _address}} <- {:not_found, Chain.hash_to_address(address_hash, @api_true, false)} do
prepared_topic = String.trim(topic)
@ -268,7 +268,7 @@ defmodule BlockScoutWeb.API.V2.AddressController do
def logs(conn, %{"address_hash" => address_hash_string} = params) do
with {:format, {:ok, address_hash}} <- {:format, Chain.string_to_address_hash(address_hash_string)},
{:ok, false} <- AccessHelpers.restricted_access?(address_hash_string, params),
{:ok, false} <- AccessHelper.restricted_access?(address_hash_string, params),
{:not_found, {:ok, _address}} <- {:not_found, Chain.hash_to_address(address_hash, @api_true, false)} do
options = params |> paging_options() |> Keyword.merge(@api_true)
@ -287,7 +287,7 @@ defmodule BlockScoutWeb.API.V2.AddressController do
def blocks_validated(conn, %{"address_hash" => address_hash_string} = params) do
with {:format, {:ok, address_hash}} <- {:format, Chain.string_to_address_hash(address_hash_string)},
{:ok, false} <- AccessHelpers.restricted_access?(address_hash_string, params),
{:ok, false} <- AccessHelper.restricted_access?(address_hash_string, params),
{:not_found, {:ok, _address}} <- {:not_found, Chain.hash_to_address(address_hash, @api_true, false)} do
full_options =
[
@ -315,7 +315,7 @@ defmodule BlockScoutWeb.API.V2.AddressController do
def coin_balance_history(conn, %{"address_hash" => address_hash_string} = params) do
with {:format, {:ok, address_hash}} <- {:format, Chain.string_to_address_hash(address_hash_string)},
{:ok, false} <- AccessHelpers.restricted_access?(address_hash_string, params),
{:ok, false} <- AccessHelper.restricted_access?(address_hash_string, params),
{:not_found, {:ok, _address}} <- {:not_found, Chain.hash_to_address(address_hash, @api_true, false)} do
full_options = params |> paging_options() |> Keyword.merge(@api_true)
@ -334,7 +334,7 @@ defmodule BlockScoutWeb.API.V2.AddressController do
def coin_balance_history_by_day(conn, %{"address_hash" => address_hash_string} = params) do
with {:format, {:ok, address_hash}} <- {:format, Chain.string_to_address_hash(address_hash_string)},
{:ok, false} <- AccessHelpers.restricted_access?(address_hash_string, params),
{:ok, false} <- AccessHelper.restricted_access?(address_hash_string, params),
{:not_found, {:ok, _address}} <- {:not_found, Chain.hash_to_address(address_hash, @api_true, false)} do
balances_by_day =
address_hash
@ -348,7 +348,7 @@ defmodule BlockScoutWeb.API.V2.AddressController do
def tokens(conn, %{"address_hash" => address_hash_string} = params) do
with {:format, {:ok, address_hash}} <- {:format, Chain.string_to_address_hash(address_hash_string)},
{:ok, false} <- AccessHelpers.restricted_access?(address_hash_string, params),
{:ok, false} <- AccessHelper.restricted_access?(address_hash_string, params),
{:not_found, {:ok, _address}} <- {:not_found, Chain.hash_to_address(address_hash, @api_true, false)} do
results_plus_one =
address_hash

@ -8,7 +8,7 @@ defmodule BlockScoutWeb.API.V2.SmartContractController do
import Explorer.SmartContract.Solidity.Verifier, only: [parse_boolean: 1]
alias BlockScoutWeb.{AccessHelpers, AddressView}
alias BlockScoutWeb.{AccessHelper, AddressView}
alias Ecto.Association.NotLoaded
alias Explorer.Chain
alias Explorer.Chain.SmartContract
@ -32,7 +32,7 @@ defmodule BlockScoutWeb.API.V2.SmartContractController do
def smart_contract(conn, %{"address_hash" => address_hash_string} = params) do
with {:format, {:ok, address_hash}} <- {:format, Chain.string_to_address_hash(address_hash_string)},
{:ok, false} <- AccessHelpers.restricted_access?(address_hash_string, params),
{:ok, false} <- AccessHelper.restricted_access?(address_hash_string, params),
_ <- PublishHelper.check_and_verify(address_hash_string),
{:not_found, {:ok, address}} <-
{:not_found, Chain.find_contract_address(address_hash, @smart_contract_address_options, true)} do
@ -44,7 +44,7 @@ defmodule BlockScoutWeb.API.V2.SmartContractController do
def methods_read(conn, %{"address_hash" => address_hash_string, "is_custom_abi" => "true"} = params) do
with {:format, {:ok, address_hash}} <- {:format, Chain.string_to_address_hash(address_hash_string)},
{:ok, false} <- AccessHelpers.restricted_access?(address_hash_string, params),
{:ok, false} <- AccessHelper.restricted_access?(address_hash_string, params),
custom_abi <- AddressView.fetch_custom_abi(conn, address_hash_string),
{:not_found, true} <- {:not_found, AddressView.check_custom_abi_for_having_read_functions(custom_abi)} do
read_only_functions_from_abi =
@ -60,7 +60,7 @@ defmodule BlockScoutWeb.API.V2.SmartContractController do
def methods_read(conn, %{"address_hash" => address_hash_string} = params) do
with {:format, {:ok, address_hash}} <- {:format, Chain.string_to_address_hash(address_hash_string)},
{:ok, false} <- AccessHelpers.restricted_access?(address_hash_string, params),
{:ok, false} <- AccessHelper.restricted_access?(address_hash_string, params),
smart_contract <- Chain.address_hash_to_smart_contract(address_hash, @api_true),
{:not_found, false} <- {:not_found, is_nil(smart_contract)} do
read_only_functions_from_abi = Reader.read_only_functions(smart_contract, address_hash, params["from"])
@ -77,7 +77,7 @@ defmodule BlockScoutWeb.API.V2.SmartContractController do
with {:contract_interaction_disabled, false} <-
{:contract_interaction_disabled, AddressView.contract_interaction_disabled?()},
{:format, {:ok, _address_hash}} <- {:format, Chain.string_to_address_hash(address_hash_string)},
{:ok, false} <- AccessHelpers.restricted_access?(address_hash_string, params),
{:ok, false} <- AccessHelper.restricted_access?(address_hash_string, params),
custom_abi <- AddressView.fetch_custom_abi(conn, address_hash_string),
{:not_found, true} <- {:not_found, AddressView.check_custom_abi_for_having_write_functions(custom_abi)} do
conn
@ -90,7 +90,7 @@ defmodule BlockScoutWeb.API.V2.SmartContractController do
with {:contract_interaction_disabled, false} <-
{:contract_interaction_disabled, AddressView.contract_interaction_disabled?()},
{:format, {:ok, address_hash}} <- {:format, Chain.string_to_address_hash(address_hash_string)},
{:ok, false} <- AccessHelpers.restricted_access?(address_hash_string, params),
{:ok, false} <- AccessHelper.restricted_access?(address_hash_string, params),
smart_contract <- Chain.address_hash_to_smart_contract(address_hash, @api_true),
{:not_found, false} <- {:not_found, is_nil(smart_contract)} do
conn
@ -101,7 +101,7 @@ defmodule BlockScoutWeb.API.V2.SmartContractController do
def methods_read_proxy(conn, %{"address_hash" => address_hash_string} = params) do
with {:format, {:ok, address_hash}} <- {:format, Chain.string_to_address_hash(address_hash_string)},
{:ok, false} <- AccessHelpers.restricted_access?(address_hash_string, params),
{:ok, false} <- AccessHelper.restricted_access?(address_hash_string, params),
{:not_found, {:ok, address}} <-
{:not_found, Chain.find_contract_address(address_hash, @smart_contract_address_options)},
{:not_found, false} <- {:not_found, is_nil(address.smart_contract)} do
@ -123,7 +123,7 @@ defmodule BlockScoutWeb.API.V2.SmartContractController do
with {:contract_interaction_disabled, false} <-
{:contract_interaction_disabled, AddressView.contract_interaction_disabled?()},
{:format, {:ok, address_hash}} <- {:format, Chain.string_to_address_hash(address_hash_string)},
{:ok, false} <- AccessHelpers.restricted_access?(address_hash_string, params),
{:ok, false} <- AccessHelper.restricted_access?(address_hash_string, params),
{:not_found, {:ok, address}} <-
{:not_found, Chain.find_contract_address(address_hash, @smart_contract_address_options)},
{:not_found, false} <- {:not_found, is_nil(address.smart_contract)} do
@ -149,7 +149,7 @@ defmodule BlockScoutWeb.API.V2.SmartContractController do
contract_type = if type == "proxy", do: :proxy, else: :regular
with {:format, {:ok, address_hash}} <- {:format, Chain.string_to_address_hash(address_hash_string)},
{:ok, false} <- AccessHelpers.restricted_access?(address_hash_string, params),
{:ok, false} <- AccessHelper.restricted_access?(address_hash_string, params),
{:not_found, {:ok, address}} <-
{:not_found,
Chain.find_contract_address(address_hash,

@ -1,7 +1,7 @@
defmodule BlockScoutWeb.API.V2.TokenController do
use BlockScoutWeb, :controller
alias BlockScoutWeb.AccessHelpers
alias BlockScoutWeb.AccessHelper
alias BlockScoutWeb.API.V2.TransactionView
alias Explorer.Chain
alias Indexer.Fetcher.TokenTotalSupplyOnDemand
@ -25,7 +25,7 @@ defmodule BlockScoutWeb.API.V2.TokenController do
def token(conn, %{"address_hash" => address_hash_string} = params) do
with {:format, {:ok, address_hash}} <- {:format, Chain.string_to_address_hash(address_hash_string)},
{:ok, false} <- AccessHelpers.restricted_access?(address_hash_string, params),
{:ok, false} <- AccessHelper.restricted_access?(address_hash_string, params),
{:not_found, {:ok, token}} <- {:not_found, Chain.token_from_address_hash(address_hash, @api_true)} do
TokenTotalSupplyOnDemand.trigger_fetch(address_hash)
@ -37,7 +37,7 @@ defmodule BlockScoutWeb.API.V2.TokenController do
def counters(conn, %{"address_hash" => address_hash_string} = params) do
with {:format, {:ok, address_hash}} <- {:format, Chain.string_to_address_hash(address_hash_string)},
{:ok, false} <- AccessHelpers.restricted_access?(address_hash_string, params),
{:ok, false} <- AccessHelper.restricted_access?(address_hash_string, params),
{:not_found, {:ok, _}} <- {:not_found, Chain.token_from_address_hash(address_hash, @api_true)} do
{transfer_count, token_holder_count} = Chain.fetch_token_counters(address_hash, 30_000)
@ -47,7 +47,7 @@ defmodule BlockScoutWeb.API.V2.TokenController do
def transfers(conn, %{"address_hash" => address_hash_string} = params) do
with {:format, {:ok, address_hash}} <- {:format, Chain.string_to_address_hash(address_hash_string)},
{:ok, false} <- AccessHelpers.restricted_access?(address_hash_string, params),
{:ok, false} <- AccessHelper.restricted_access?(address_hash_string, params),
{:not_found, {:ok, _}} <- {:not_found, Chain.token_from_address_hash(address_hash, @api_true)} do
paging_options = paging_options(params)
@ -73,7 +73,7 @@ defmodule BlockScoutWeb.API.V2.TokenController do
def holders(conn, %{"address_hash" => address_hash_string} = params) do
with {:format, {:ok, address_hash}} <- {:format, Chain.string_to_address_hash(address_hash_string)},
{:ok, false} <- AccessHelpers.restricted_access?(address_hash_string, params),
{:ok, false} <- AccessHelper.restricted_access?(address_hash_string, params),
{:not_found, {:ok, token}} <- {:not_found, Chain.token_from_address_hash(address_hash, @api_true)} do
results_plus_one =
Chain.fetch_token_holders_from_token_hash(address_hash, Keyword.merge(paging_options(params), @api_true))
@ -91,7 +91,7 @@ defmodule BlockScoutWeb.API.V2.TokenController do
def instances(conn, %{"address_hash" => address_hash_string} = params) do
with {:format, {:ok, address_hash}} <- {:format, Chain.string_to_address_hash(address_hash_string)},
{:ok, false} <- AccessHelpers.restricted_access?(address_hash_string, params),
{:ok, false} <- AccessHelper.restricted_access?(address_hash_string, params),
{:not_found, {:ok, token}} <- {:not_found, Chain.token_from_address_hash(address_hash, @api_true)} do
results_plus_one =
Chain.address_to_unique_tokens(
@ -112,7 +112,7 @@ defmodule BlockScoutWeb.API.V2.TokenController do
def instance(conn, %{"address_hash" => address_hash_string, "token_id" => token_id_str} = params) do
with {:format, {:ok, address_hash}} <- {:format, Chain.string_to_address_hash(address_hash_string)},
{:ok, false} <- AccessHelpers.restricted_access?(address_hash_string, params),
{: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)},
{:format, {token_id, ""}} <- {:format, Integer.parse(token_id_str)} do
@ -133,7 +133,7 @@ defmodule BlockScoutWeb.API.V2.TokenController do
def transfers_by_instance(conn, %{"address_hash" => address_hash_string, "token_id" => token_id_str} = params) do
with {:format, {:ok, address_hash}} <- {:format, Chain.string_to_address_hash(address_hash_string)},
{:ok, false} <- AccessHelpers.restricted_access?(address_hash_string, params),
{: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)},
{:format, {token_id, ""}} <- {:format, Integer.parse(token_id_str)} do
@ -161,7 +161,7 @@ defmodule BlockScoutWeb.API.V2.TokenController do
def transfers_count_by_instance(conn, %{"address_hash" => address_hash_string, "token_id" => token_id_str} = params) do
with {:format, {:ok, address_hash}} <- {:format, Chain.string_to_address_hash(address_hash_string)},
{:ok, false} <- AccessHelpers.restricted_access?(address_hash_string, params),
{: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)},
{:format, {token_id, ""}} <- {:format, Integer.parse(token_id_str)} do

@ -14,7 +14,7 @@ defmodule BlockScoutWeb.API.V2.TransactionController do
type_filter_options: 1
]
alias BlockScoutWeb.AccessHelpers
alias BlockScoutWeb.AccessHelper
alias BlockScoutWeb.Models.TransactionStateHelper
alias Explorer.Chain
alias Indexer.Fetcher.FirstTraceOnDemand
@ -72,8 +72,8 @@ defmodule BlockScoutWeb.API.V2.TransactionController do
necessity_by_association: Map.put(@transaction_necessity_by_association, :transaction_actions, :optional),
api?: true
)},
{:ok, false} <- AccessHelpers.restricted_access?(to_string(transaction.from_address_hash), params),
{:ok, false} <- AccessHelpers.restricted_access?(to_string(transaction.to_address_hash), params),
{:ok, false} <- AccessHelper.restricted_access?(to_string(transaction.from_address_hash), params),
{:ok, false} <- AccessHelper.restricted_access?(to_string(transaction.to_address_hash), params),
preloaded <-
Chain.preload_token_transfers(transaction, @token_transfers_in_tx_necessity_by_association, @api_true, false) do
conn
@ -109,8 +109,8 @@ defmodule BlockScoutWeb.API.V2.TransactionController do
with {:format, {:ok, transaction_hash}} <- {:format, Chain.string_to_transaction_hash(transaction_hash_string)},
{:not_found, {:ok, transaction}} <-
{:not_found, Chain.hash_to_transaction(transaction_hash, @api_true)},
{:ok, false} <- AccessHelpers.restricted_access?(to_string(transaction.from_address_hash), params),
{:ok, false} <- AccessHelpers.restricted_access?(to_string(transaction.to_address_hash), params) do
{:ok, false} <- AccessHelper.restricted_access?(to_string(transaction.from_address_hash), params),
{:ok, false} <- AccessHelper.restricted_access?(to_string(transaction.to_address_hash), params) do
if is_nil(transaction.block_number) do
conn
|> put_status(200)
@ -138,8 +138,8 @@ defmodule BlockScoutWeb.API.V2.TransactionController do
with {:format, {:ok, transaction_hash}} <- {:format, Chain.string_to_transaction_hash(transaction_hash_string)},
{:not_found, {:ok, transaction}} <-
{:not_found, Chain.hash_to_transaction(transaction_hash, @api_true)},
{:ok, false} <- AccessHelpers.restricted_access?(to_string(transaction.from_address_hash), params),
{:ok, false} <- AccessHelpers.restricted_access?(to_string(transaction.to_address_hash), params) do
{:ok, false} <- AccessHelper.restricted_access?(to_string(transaction.from_address_hash), params),
{:ok, false} <- AccessHelper.restricted_access?(to_string(transaction.to_address_hash), params) do
paging_options = paging_options(params)
full_options =
@ -171,8 +171,8 @@ defmodule BlockScoutWeb.API.V2.TransactionController do
with {:format, {:ok, transaction_hash}} <- {:format, Chain.string_to_transaction_hash(transaction_hash_string)},
{:not_found, {:ok, transaction}} <-
{:not_found, Chain.hash_to_transaction(transaction_hash, @api_true)},
{:ok, false} <- AccessHelpers.restricted_access?(to_string(transaction.from_address_hash), params),
{:ok, false} <- AccessHelpers.restricted_access?(to_string(transaction.to_address_hash), params) do
{:ok, false} <- AccessHelper.restricted_access?(to_string(transaction.from_address_hash), params),
{:ok, false} <- AccessHelper.restricted_access?(to_string(transaction.to_address_hash), params) do
full_options =
@internal_transaction_necessity_by_association
|> Keyword.merge(paging_options(params))
@ -200,8 +200,8 @@ defmodule BlockScoutWeb.API.V2.TransactionController do
with {:format, {:ok, transaction_hash}} <- {:format, Chain.string_to_transaction_hash(transaction_hash_string)},
{:not_found, {:ok, transaction}} <-
{:not_found, Chain.hash_to_transaction(transaction_hash, @api_true)},
{:ok, false} <- AccessHelpers.restricted_access?(to_string(transaction.from_address_hash), params),
{:ok, false} <- AccessHelpers.restricted_access?(to_string(transaction.to_address_hash), params) do
{:ok, false} <- AccessHelper.restricted_access?(to_string(transaction.from_address_hash), params),
{:ok, false} <- AccessHelper.restricted_access?(to_string(transaction.to_address_hash), params) do
full_options =
[
necessity_by_association: %{
@ -241,8 +241,8 @@ defmodule BlockScoutWeb.API.V2.TransactionController do
Map.merge(@transaction_necessity_by_association, %{[block: [miner: :names]] => :optional}),
api?: true
)},
{:ok, false} <- AccessHelpers.restricted_access?(to_string(transaction.from_address_hash), params),
{:ok, false} <- AccessHelpers.restricted_access?(to_string(transaction.to_address_hash), params) do
{:ok, false} <- AccessHelper.restricted_access?(to_string(transaction.from_address_hash), params),
{:ok, false} <- AccessHelper.restricted_access?(to_string(transaction.to_address_hash), params) do
state_changes = TransactionStateHelper.state_changes(transaction)
conn

@ -3,7 +3,7 @@ defmodule BlockScoutWeb.API.V2.VerificationController do
import Explorer.SmartContract.Solidity.Verifier, only: [parse_boolean: 1]
alias BlockScoutWeb.AccessHelpers
alias BlockScoutWeb.AccessHelper
alias BlockScoutWeb.API.V2.ApiView
alias Explorer.Chain
alias Explorer.SmartContract.Solidity.PublisherWorker, as: SolidityPublisherWorker
@ -46,7 +46,7 @@ defmodule BlockScoutWeb.API.V2.VerificationController do
params
) do
with {:format, {:ok, address_hash}} <- {:format, Chain.string_to_address_hash(address_hash_string)},
{:ok, false} <- AccessHelpers.restricted_access?(address_hash_string, params),
{:ok, false} <- AccessHelper.restricted_access?(address_hash_string, params),
{:already_verified, false} <-
{:already_verified, Chain.smart_contract_fully_verified?(address_hash, @api_true)} do
verification_params =
@ -81,7 +81,7 @@ defmodule BlockScoutWeb.API.V2.VerificationController do
%{"address_hash" => address_hash_string, "files" => files, "compiler_version" => compiler_version} = params
) do
with {:format, {:ok, address_hash}} <- {:format, Chain.string_to_address_hash(address_hash_string)},
{:ok, false} <- AccessHelpers.restricted_access?(address_hash_string, params),
{:ok, false} <- AccessHelper.restricted_access?(address_hash_string, params),
{:already_verified, false} <-
{:already_verified, Chain.smart_contract_fully_verified?(address_hash, @api_true)},
files_array <- PublishHelper.prepare_files_array(files),
@ -109,7 +109,7 @@ defmodule BlockScoutWeb.API.V2.VerificationController do
with {:not_found, true} <-
{:not_found, Application.get_env(:explorer, Explorer.ThirdPartyIntegrations.Sourcify)[:enabled]},
{:format, {:ok, address_hash}} <- {:format, Chain.string_to_address_hash(address_hash_string)},
{:ok, false} <- AccessHelpers.restricted_access?(address_hash_string, params),
{:ok, false} <- AccessHelper.restricted_access?(address_hash_string, params),
{:already_verified, false} <-
{:already_verified, Chain.smart_contract_fully_verified?(address_hash, @api_true)},
files_array <- PublishHelper.prepare_files_array(files),
@ -135,7 +135,7 @@ defmodule BlockScoutWeb.API.V2.VerificationController do
) do
with {:not_found, true} <- {:not_found, RustVerifierInterface.enabled?()},
{:format, {:ok, address_hash}} <- {:format, Chain.string_to_address_hash(address_hash_string)},
{:ok, false} <- AccessHelpers.restricted_access?(address_hash_string, params),
{:ok, false} <- AccessHelper.restricted_access?(address_hash_string, params),
{:already_verified, false} <-
{:already_verified, Chain.smart_contract_fully_verified?(address_hash, @api_true)},
libraries <- Map.get(params, "libraries", "{}"),
@ -172,7 +172,7 @@ defmodule BlockScoutWeb.API.V2.VerificationController do
params
) do
with {:format, {:ok, address_hash}} <- {:format, Chain.string_to_address_hash(address_hash_string)},
{:ok, false} <- AccessHelpers.restricted_access?(address_hash_string, params),
{:ok, false} <- AccessHelper.restricted_access?(address_hash_string, params),
{:already_verified, false} <-
{:already_verified, Chain.smart_contract_fully_verified?(address_hash, @api_true)} do
verification_params =
@ -199,7 +199,7 @@ defmodule BlockScoutWeb.API.V2.VerificationController do
) do
with {:not_found, true} <- {:not_found, RustVerifierInterface.enabled?()},
{:format, {:ok, address_hash}} <- {:format, Chain.string_to_address_hash(address_hash_string)},
{:ok, false} <- AccessHelpers.restricted_access?(address_hash_string, params),
{:ok, false} <- AccessHelper.restricted_access?(address_hash_string, params),
{:already_verified, false} <-
{:already_verified, Chain.smart_contract_fully_verified?(address_hash, @api_true)} do
verification_params =

@ -1,13 +1,13 @@
defmodule BlockScoutWeb.CsvExportController do
use BlockScoutWeb, :controller
alias BlockScoutWeb.AccessHelpers
alias BlockScoutWeb.AccessHelper
alias Explorer.Chain
def index(conn, %{"address" => address_hash_string, "type" => type} = params) do
with {:ok, address_hash} <- Chain.string_to_address_hash(address_hash_string),
:ok <- Chain.check_address_exists(address_hash),
{:ok, false} <- AccessHelpers.restricted_access?(address_hash_string, params),
{:ok, false} <- AccessHelper.restricted_access?(address_hash_string, params),
true <- supported_export_type(type) do
render(conn, "index.html", address_hash_string: address_hash_string, type: type)
else

@ -4,7 +4,7 @@ defmodule BlockScoutWeb.Tokens.ContractController do
import BlockScoutWeb.Account.AuthController, only: [current_user: 1]
import BlockScoutWeb.Models.GetAddressTags, only: [get_address_tags: 2]
alias BlockScoutWeb.{AccessHelpers, TabHelpers}
alias BlockScoutWeb.{AccessHelper, TabHelper}
alias Explorer.Chain
alias Explorer.Chain.Address
@ -14,19 +14,19 @@ defmodule BlockScoutWeb.Tokens.ContractController do
with {:ok, address_hash} <- Chain.string_to_address_hash(address_hash_string),
:ok <- Chain.check_verified_smart_contract_exists(address_hash),
{:ok, token} <- Chain.token_from_address_hash(address_hash, options),
{:ok, false} <- AccessHelpers.restricted_access?(address_hash_string, params) do
{:ok, false} <- AccessHelper.restricted_access?(address_hash_string, params) do
%{type: type, action: action} =
cond do
TabHelpers.tab_active?("read-contract", conn.request_path) ->
TabHelper.tab_active?("read-contract", conn.request_path) ->
%{type: :regular, action: :read}
TabHelpers.tab_active?("write-contract", conn.request_path) ->
TabHelper.tab_active?("write-contract", conn.request_path) ->
%{type: :regular, action: :write}
TabHelpers.tab_active?("read-proxy", conn.request_path) ->
TabHelper.tab_active?("read-proxy", conn.request_path) ->
%{type: :proxy, action: :read}
TabHelpers.tab_active?("write-proxy", conn.request_path) ->
TabHelper.tab_active?("write-proxy", conn.request_path) ->
%{type: :proxy, action: :write}
end

@ -4,7 +4,7 @@ defmodule BlockScoutWeb.Tokens.HolderController do
import BlockScoutWeb.Account.AuthController, only: [current_user: 1]
import BlockScoutWeb.Models.GetAddressTags, only: [get_address_tags: 2]
alias BlockScoutWeb.{AccessHelpers, Controller}
alias BlockScoutWeb.{AccessHelper, Controller}
alias BlockScoutWeb.Tokens.HolderView
alias Explorer.Chain
alias Explorer.Chain.Address
@ -22,7 +22,7 @@ defmodule BlockScoutWeb.Tokens.HolderController do
with {:ok, address_hash} <- Chain.string_to_address_hash(address_hash_string),
{:ok, token} <- Chain.token_from_address_hash(address_hash),
token_balances <- Chain.fetch_token_holders_from_token_hash(address_hash, paging_options(params)),
{:ok, false} <- AccessHelpers.restricted_access?(address_hash_string, params) do
{:ok, false} <- AccessHelper.restricted_access?(address_hash_string, params) do
{token_balances_paginated, next_page} = split_list_by_page(token_balances)
next_page_path =
@ -62,7 +62,7 @@ defmodule BlockScoutWeb.Tokens.HolderController do
with {:ok, address_hash} <- Chain.string_to_address_hash(address_hash_string),
{:ok, token} <- Chain.token_from_address_hash(address_hash, options),
{:ok, false} <- AccessHelpers.restricted_access?(address_hash_string, params) do
{:ok, false} <- AccessHelper.restricted_access?(address_hash_string, params) do
render(
conn,
"index.html",

@ -1,7 +1,7 @@
defmodule BlockScoutWeb.Tokens.InventoryController do
use BlockScoutWeb, :controller
alias BlockScoutWeb.AccessHelpers
alias BlockScoutWeb.AccessHelper
alias BlockScoutWeb.Tokens.{HolderController, InventoryView}
alias Explorer.Chain
alias Phoenix.View
@ -16,7 +16,7 @@ defmodule BlockScoutWeb.Tokens.InventoryController do
def index(conn, %{"token_id" => address_hash_string, "type" => "JSON"} = params) do
with {:ok, address_hash} <- Chain.string_to_address_hash(address_hash_string),
{:ok, token} <- Chain.token_from_address_hash(address_hash),
{:ok, false} <- AccessHelpers.restricted_access?(address_hash_string, params) do
{:ok, false} <- AccessHelper.restricted_access?(address_hash_string, params) do
unique_token_instances =
Chain.address_to_unique_tokens(
token.contract_address_hash,

@ -3,11 +3,11 @@ defmodule BlockScoutWeb.Tokens.TokenController do
require Logger
alias BlockScoutWeb.AccessHelpers
alias BlockScoutWeb.AccessHelper
alias Explorer.Chain
def show(conn, %{"id" => address_hash_string}) do
redirect(conn, to: AccessHelpers.get_path(conn, :token_transfer_path, :index, address_hash_string))
redirect(conn, to: AccessHelper.get_path(conn, :token_transfer_path, :index, address_hash_string))
end
def token_counters(conn, %{"id" => address_hash_string}) do

@ -4,7 +4,7 @@ defmodule BlockScoutWeb.Tokens.TransferController do
import BlockScoutWeb.Account.AuthController, only: [current_user: 1]
import BlockScoutWeb.Models.GetAddressTags, only: [get_address_tags: 2]
alias BlockScoutWeb.{AccessHelpers, Controller}
alias BlockScoutWeb.{AccessHelper, Controller}
alias BlockScoutWeb.Tokens.TransferView
alias Explorer.Chain
alias Explorer.Chain.Address
@ -20,7 +20,7 @@ defmodule BlockScoutWeb.Tokens.TransferController do
with {:ok, address_hash} <- Chain.string_to_address_hash(address_hash_string),
{:ok, token} <- Chain.token_from_address_hash(address_hash),
token_transfers <- Chain.fetch_token_transfers_from_token_hash(address_hash, paging_options(params)),
{:ok, false} <- AccessHelpers.restricted_access?(address_hash_string, params) do
{:ok, false} <- AccessHelper.restricted_access?(address_hash_string, params) do
{token_transfers_paginated, next_page} = split_list_by_page(token_transfers)
next_page_path =
@ -67,7 +67,7 @@ defmodule BlockScoutWeb.Tokens.TransferController do
with {:ok, address_hash} <- Chain.string_to_address_hash(address_hash_string),
{:ok, token} <- Chain.token_from_address_hash(address_hash, options),
{:ok, false} <- AccessHelpers.restricted_access?(address_hash_string, params) do
{:ok, false} <- AccessHelper.restricted_access?(address_hash_string, params) do
render(
conn,
"index.html",

@ -16,7 +16,7 @@ defmodule BlockScoutWeb.TransactionController do
import BlockScoutWeb.Models.GetTransactionTags, only: [get_transaction_with_addresses_tags: 2]
alias BlockScoutWeb.{
AccessHelpers,
AccessHelper,
Controller,
TransactionInternalTransactionController,
TransactionTokenTransferController,
@ -156,8 +156,8 @@ defmodule BlockScoutWeb.TransactionController do
transaction_hash,
necessity_by_association: @necessity_by_association
),
{:ok, false} <- AccessHelpers.restricted_access?(to_string(transaction.from_address_hash), params),
{:ok, false} <- AccessHelpers.restricted_access?(to_string(transaction.to_address_hash), params) do
{:ok, false} <- AccessHelper.restricted_access?(to_string(transaction.from_address_hash), params),
{:ok, false} <- AccessHelper.restricted_access?(to_string(transaction.to_address_hash), params) do
render(
conn,
"show_token_transfers.html",
@ -194,8 +194,8 @@ defmodule BlockScoutWeb.TransactionController do
transaction_hash,
necessity_by_association: @necessity_by_association
),
{:ok, false} <- AccessHelpers.restricted_access?(to_string(transaction.from_address_hash), params),
{:ok, false} <- AccessHelpers.restricted_access?(to_string(transaction.to_address_hash), params) do
{:ok, false} <- AccessHelper.restricted_access?(to_string(transaction.from_address_hash), params),
{:ok, false} <- AccessHelper.restricted_access?(to_string(transaction.to_address_hash), params) do
render(
conn,
"show_internal_transactions.html",

@ -6,7 +6,7 @@ defmodule BlockScoutWeb.TransactionInternalTransactionController do
import BlockScoutWeb.Models.GetAddressTags, only: [get_address_tags: 2]
import BlockScoutWeb.Models.GetTransactionTags, only: [get_transaction_with_addresses_tags: 2]
alias BlockScoutWeb.{AccessHelpers, Controller, InternalTransactionView, TransactionController}
alias BlockScoutWeb.{AccessHelper, Controller, InternalTransactionView, TransactionController}
alias Explorer.{Chain, Market}
alias Explorer.ExchangeRates.Token
alias Phoenix.View
@ -15,8 +15,8 @@ defmodule BlockScoutWeb.TransactionInternalTransactionController do
with {:ok, transaction_hash} <- Chain.string_to_transaction_hash(transaction_hash_string),
:ok <- Chain.check_transaction_exists(transaction_hash),
{:ok, transaction} <- Chain.hash_to_transaction(transaction_hash, []),
{:ok, false} <- AccessHelpers.restricted_access?(to_string(transaction.from_address_hash), params),
{:ok, false} <- AccessHelpers.restricted_access?(to_string(transaction.to_address_hash), params) do
{:ok, false} <- AccessHelper.restricted_access?(to_string(transaction.from_address_hash), params),
{:ok, false} <- AccessHelper.restricted_access?(to_string(transaction.to_address_hash), params) do
full_options =
Keyword.merge(
[
@ -97,8 +97,8 @@ defmodule BlockScoutWeb.TransactionInternalTransactionController do
:token_transfers => :optional
}
),
{:ok, false} <- AccessHelpers.restricted_access?(to_string(transaction.from_address_hash), params),
{:ok, false} <- AccessHelpers.restricted_access?(to_string(transaction.to_address_hash), params) do
{:ok, false} <- AccessHelper.restricted_access?(to_string(transaction.from_address_hash), params),
{:ok, false} <- AccessHelper.restricted_access?(to_string(transaction.to_address_hash), params) do
render(
conn,
"index.html",

@ -6,7 +6,7 @@ defmodule BlockScoutWeb.TransactionLogController do
import BlockScoutWeb.Models.GetAddressTags, only: [get_address_tags: 2]
import BlockScoutWeb.Models.GetTransactionTags, only: [get_transaction_with_addresses_tags: 2]
alias BlockScoutWeb.{AccessHelpers, Controller, TransactionController, TransactionLogView}
alias BlockScoutWeb.{AccessHelper, Controller, TransactionController, TransactionLogView}
alias Explorer.{Chain, Market}
alias Explorer.ExchangeRates.Token
alias Phoenix.View
@ -17,8 +17,8 @@ defmodule BlockScoutWeb.TransactionLogController do
Chain.hash_to_transaction(transaction_hash,
necessity_by_association: %{[to_address: :smart_contract] => :optional}
),
{:ok, false} <- AccessHelpers.restricted_access?(to_string(transaction.from_address_hash), params),
{:ok, false} <- AccessHelpers.restricted_access?(to_string(transaction.to_address_hash), params) do
{:ok, false} <- AccessHelper.restricted_access?(to_string(transaction.from_address_hash), params),
{:ok, false} <- AccessHelper.restricted_access?(to_string(transaction.to_address_hash), params) do
full_options =
Keyword.merge(
[
@ -89,8 +89,8 @@ defmodule BlockScoutWeb.TransactionLogController do
:token_transfers => :optional
}
),
{:ok, false} <- AccessHelpers.restricted_access?(to_string(transaction.from_address_hash), params),
{:ok, false} <- AccessHelpers.restricted_access?(to_string(transaction.to_address_hash), params) do
{:ok, false} <- AccessHelper.restricted_access?(to_string(transaction.from_address_hash), params),
{:ok, false} <- AccessHelper.restricted_access?(to_string(transaction.to_address_hash), params) do
render(
conn,
"index.html",

@ -5,7 +5,7 @@ defmodule BlockScoutWeb.TransactionRawTraceController do
import BlockScoutWeb.Models.GetAddressTags, only: [get_address_tags: 2]
import BlockScoutWeb.Models.GetTransactionTags, only: [get_transaction_with_addresses_tags: 2]
alias BlockScoutWeb.{AccessHelpers, TransactionController}
alias BlockScoutWeb.{AccessHelper, TransactionController}
alias EthereumJSONRPC
alias Explorer.{Chain, Market}
alias Explorer.ExchangeRates.Token
@ -25,8 +25,8 @@ defmodule BlockScoutWeb.TransactionRawTraceController do
:token_transfers => :optional
}
),
{:ok, false} <- AccessHelpers.restricted_access?(to_string(transaction.from_address_hash), params),
{:ok, false} <- AccessHelpers.restricted_access?(to_string(transaction.to_address_hash), params) do
{:ok, false} <- AccessHelper.restricted_access?(to_string(transaction.from_address_hash), params),
{:ok, false} <- AccessHelper.restricted_access?(to_string(transaction.to_address_hash), params) do
if is_nil(transaction.block_number) do
render_raw_trace(conn, [], transaction, hash)
else

@ -2,7 +2,7 @@ defmodule BlockScoutWeb.TransactionStateController do
use BlockScoutWeb, :controller
alias BlockScoutWeb.{
AccessHelpers,
AccessHelper,
Controller,
Models.TransactionStateHelper,
TransactionController,
@ -33,9 +33,9 @@ defmodule BlockScoutWeb.TransactionStateController do
}
),
{:ok, false} <-
AccessHelpers.restricted_access?(to_string(transaction.from_address_hash), params),
AccessHelper.restricted_access?(to_string(transaction.from_address_hash), params),
{:ok, false} <-
AccessHelpers.restricted_access?(to_string(transaction.to_address_hash), params) do
AccessHelper.restricted_access?(to_string(transaction.to_address_hash), params) do
state_changes = TransactionStateHelper.state_changes(transaction)
rendered_changes =
@ -87,9 +87,9 @@ defmodule BlockScoutWeb.TransactionStateController do
}
),
{:ok, false} <-
AccessHelpers.restricted_access?(to_string(transaction.from_address_hash), params),
AccessHelper.restricted_access?(to_string(transaction.from_address_hash), params),
{:ok, false} <-
AccessHelpers.restricted_access?(to_string(transaction.to_address_hash), params) do
AccessHelper.restricted_access?(to_string(transaction.to_address_hash), params) do
render(
conn,
"index.html",

@ -6,7 +6,7 @@ defmodule BlockScoutWeb.TransactionTokenTransferController do
import BlockScoutWeb.Models.GetAddressTags, only: [get_address_tags: 2]
import BlockScoutWeb.Models.GetTransactionTags, only: [get_transaction_with_addresses_tags: 2]
alias BlockScoutWeb.{AccessHelpers, Controller, TransactionController, TransactionTokenTransferView}
alias BlockScoutWeb.{AccessHelper, Controller, TransactionController, TransactionTokenTransferView}
alias Explorer.{Chain, Market}
alias Explorer.ExchangeRates.Token
alias Phoenix.View
@ -22,8 +22,8 @@ defmodule BlockScoutWeb.TransactionTokenTransferController do
transaction_hash,
[]
),
{:ok, false} <- AccessHelpers.restricted_access?(to_string(transaction.from_address_hash), params),
{:ok, false} <- AccessHelpers.restricted_access?(to_string(transaction.to_address_hash), params) do
{:ok, false} <- AccessHelper.restricted_access?(to_string(transaction.from_address_hash), params),
{:ok, false} <- AccessHelper.restricted_access?(to_string(transaction.to_address_hash), params) do
full_options =
Keyword.merge(
[
@ -100,8 +100,8 @@ defmodule BlockScoutWeb.TransactionTokenTransferController do
:token_transfers => :optional
}
),
{:ok, false} <- AccessHelpers.restricted_access?(to_string(transaction.from_address_hash), params),
{:ok, false} <- AccessHelpers.restricted_access?(to_string(transaction.to_address_hash), params) do
{:ok, false} <- AccessHelper.restricted_access?(to_string(transaction.from_address_hash), params),
{:ok, false} <- AccessHelper.restricted_access?(to_string(transaction.to_address_hash), params) do
render(
conn,
"index.html",

@ -1,7 +1,7 @@
<div
class="address-current-balance"
data-token-balance-dropdown
data-api_path="<%= AccessHelpers.get_path(@conn, :address_token_balance_path, :index, Address.checksum(@address.hash)) %>"
data-api_path="<%= AccessHelper.get_path(@conn, :address_token_balance_path, :index, Address.checksum(@address.hash)) %>"
>
<span data-loading class="mb-0">
<%= render BlockScoutWeb.CommonComponentsView, "_loading_spinner.html", loading_text: gettext("Fetching tokens...") %>

@ -1,26 +1,26 @@
<% dark_forest_addresses_list_0_4 = CustomContractsHelpers.get_custom_addresses_list(:dark_forest_addresses) %>
<% dark_forest_addresses_list_0_5 = CustomContractsHelpers.get_custom_addresses_list(:dark_forest_addresses_v_0_5) %>
<% dark_forest_addresses_list_0_4 = CustomContractsHelper.get_custom_addresses_list(:dark_forest_addresses) %>
<% dark_forest_addresses_list_0_5 = CustomContractsHelper.get_custom_addresses_list(:dark_forest_addresses_v_0_5) %>
<% dark_forest_addresses_list = dark_forest_addresses_list_0_4 ++ dark_forest_addresses_list_0_5 %>
<% current_address = "0x" <> Base.encode16(@address.hash.bytes, case: :lower) %>
<div id="address-tabs" class="card-tabs js-card-tabs">
<%= link(
gettext("Transactions"),
class: "card-tab #{tab_status("transactions", @conn.request_path)}",
to: AccessHelpers.get_path(@conn, :address_transaction_path, :index, @address.hash)
to: AccessHelper.get_path(@conn, :address_transaction_path, :index, @address.hash)
) %>
<%= if Chain.check_if_token_transfers_at_address(@address.hash) do %>
<%= link(
gettext("Token Transfers"),
class: "card-tab #{tab_status("token-transfers", @conn.request_path)}",
"data-test": "token_transfers_tab_link",
to: AccessHelpers.get_path(@conn, :address_token_transfers_path, :index, @address.hash)
to: AccessHelper.get_path(@conn, :address_token_transfers_path, :index, @address.hash)
) %>
<% end %>
<%= if Chain.check_if_tokens_at_address(@address.hash) do %>
<%= link(
gettext("Tokens"),
class: "card-tab #{tab_status("tokens", @conn.request_path)}",
to: AccessHelpers.get_path(@conn, :address_token_path, :index, @address.hash),
to: AccessHelper.get_path(@conn, :address_token_path, :index, @address.hash),
"data-test": "tokens_tab_link"
) %>
<% end %>
@ -28,19 +28,19 @@
gettext("Internal Transactions"),
class: "card-tab #{tab_status("internal-transactions", @conn.request_path)}",
"data-test": "internal_transactions_tab_link",
to: AccessHelpers.get_path(@conn, :address_internal_transaction_path, :index, @address.hash)
to: AccessHelper.get_path(@conn, :address_internal_transaction_path, :index, @address.hash)
) %>
<%= link(
gettext("Coin Balance History"),
class: "card-tab #{tab_status("coin-balances", @conn.request_path)}",
"data-test": "coin_balance_tab_link",
to: AccessHelpers.get_path(@conn, :address_coin_balance_path, :index, @address.hash)
to: AccessHelper.get_path(@conn, :address_coin_balance_path, :index, @address.hash)
) %>
<%= if Chain.check_if_logs_at_address(@address.hash) do %>
<%= link(
gettext("Logs"),
class: "card-tab #{tab_status("logs", @conn.request_path)}",
to: AccessHelpers.get_path(@conn, :address_logs_path, :index, @address.hash)
to: AccessHelper.get_path(@conn, :address_logs_path, :index, @address.hash)
) %>
<% end %>
<%= if Chain.check_if_validated_blocks_at_address(@address.hash) do %>
@ -48,12 +48,12 @@
gettext("Blocks Validated"),
class: "card-tab #{tab_status("validations", @conn.request_path)}",
"data-test": "validations_tab_link",
to: AccessHelpers.get_path(@conn, :address_validation_path, :index, @address.hash)
to: AccessHelper.get_path(@conn, :address_validation_path, :index, @address.hash)
) %>
<% end %>
<%= if contract?(@address) do %>
<%= link(
to: AccessHelpers.get_path(@conn, :address_contract_path, :index, @address.hash),
to: AccessHelper.get_path(@conn, :address_contract_path, :index, @address.hash),
class: "card-tab #{tab_status("contracts", @conn.request_path)}") do %>
<%= gettext("Code") %>
<%= if smart_contract_verified?(@address) do %>
@ -70,7 +70,7 @@
<% end %>
<%= if has_decompiled_code?(@address) do %>
<%= link(
to: AccessHelpers.get_path(@conn, :address_decompiled_contract_path, :index, @address.hash),
to: AccessHelper.get_path(@conn, :address_decompiled_contract_path, :index, @address.hash),
class: "card-tab #{tab_status("decompiled-contracts", @conn.request_path)}") do %>
<%= gettext("Decompiled code") %>
<i class="fa-regular fa-check-circle"></i>
@ -79,28 +79,28 @@
<%= if smart_contract_with_read_only_functions?(@address) || has_address_custom_abi_with_read_functions?(@conn, @address.hash) do %>
<%= link(
gettext("Read Contract"),
to: AccessHelpers.get_path(@conn, :address_read_contract_path, :index, @address.hash),
to: AccessHelper.get_path(@conn, :address_read_contract_path, :index, @address.hash),
class: "card-tab #{tab_status("read-contract", @conn.request_path)}")
%>
<% end %>
<%= if @is_proxy do %>
<%= link(
gettext("Read Proxy"),
to: AccessHelpers.get_path(@conn, :address_read_proxy_path, :index, @address.hash),
to: AccessHelper.get_path(@conn, :address_read_proxy_path, :index, @address.hash),
class: "card-tab #{tab_status("read-proxy", @conn.request_path)}")
%>
<% end %>
<%= if smart_contract_with_write_functions?(@address) || has_address_custom_abi_with_write_functions?(@conn, @address.hash) do %>
<%= link(
gettext("Write Contract"),
to: AccessHelpers.get_path(@conn, :address_write_contract_path, :index, @address.hash),
to: AccessHelper.get_path(@conn, :address_write_contract_path, :index, @address.hash),
class: "card-tab #{tab_status("write-contract", @conn.request_path)}")
%>
<% end %>
<%= if smart_contract_with_write_functions?(@address) && @is_proxy do %>
<%= link(
gettext("Write Proxy"),
to: AccessHelpers.get_path(@conn, :address_write_proxy_path, :index, @address.hash),
to: AccessHelper.get_path(@conn, :address_write_proxy_path, :index, @address.hash),
class: "card-tab #{tab_status("write-proxy", @conn.request_path)}")
%>
<% end %>

@ -6,7 +6,7 @@
</span>
</td>
<td class="stakes-td">
<%= @address |> BlockScoutWeb.AddressView.address_partial_selector(nil, nil) |> BlockScoutWeb.RenderHelpers.render_partial() %>
<%= @address |> BlockScoutWeb.AddressView.address_partial_selector(nil, nil) |> BlockScoutWeb.RenderHelper.render_partial() %>
</td>
<td class="stakes-td">
<span data-test="address_balance"><%= balance(@address) %></span>

@ -1,8 +1,8 @@
<section class="address-overview" data-page="address-details" data-page-address-hash="<%= @address.hash %>" data-async-counters="<%= @counters_path %>">
<%= render BlockScoutWeb.Advertisement.TextAdView, "index.html", conn: @conn %>
<% dark_forest_addresses_list_0_4 = CustomContractsHelpers.get_custom_addresses_list(:dark_forest_addresses) %>
<% dark_forest_addresses_list_0_5 = CustomContractsHelpers.get_custom_addresses_list(:dark_forest_addresses_v_0_5) %>
<% circles_addresses_list = CustomContractsHelpers.get_custom_addresses_list(:circles_addresses) %>
<% dark_forest_addresses_list_0_4 = CustomContractsHelper.get_custom_addresses_list(:dark_forest_addresses) %>
<% dark_forest_addresses_list_0_5 = CustomContractsHelper.get_custom_addresses_list(:dark_forest_addresses_v_0_5) %>
<% circles_addresses_list = CustomContractsHelper.get_custom_addresses_list(:circles_addresses) %>
<% current_address = "0x" <> Base.encode16(@address.hash.bytes, case: :lower) %>
<% created_from_address_hash = if from_address_hash(@address), do: "0x" <> Base.encode16(from_address_hash(@address).bytes, case: :lower), else: nil %>
<div class="row js-ad-dependant-mb-2 js-ad-dependant-mb-5-reverse">
@ -195,7 +195,7 @@
<% end %>
</a>
<% else %>
<a href="<%= AccessHelpers.get_path(@conn, :address_transaction_path, :index, @address.hash)%>#txs" class="page-link bs-label large btn-no-border-link-to-tems" data-selector="transaction-count">
<a href="<%= AccessHelper.get_path(@conn, :address_transaction_path, :index, @address.hash)%>#txs" class="page-link bs-label large btn-no-border-link-to-tems" data-selector="transaction-count">
<%= if @address.token_transfers_count do %>
<%= Number.Delimit.number_to_delimited(@address.transactions_count, precision: 0) %> <%= gettext("Transactions") %>
<% else %>
@ -222,7 +222,7 @@
<% end %>
</a>
<% else %>
<a href="<%= AccessHelpers.get_path(@conn, :address_token_transfers_path, :index, @address.hash)%>#transfers" class="page-link bs-label large btn-no-border-link-to-tems" data-selector="transfer-count">
<a href="<%= AccessHelper.get_path(@conn, :address_token_transfers_path, :index, @address.hash)%>#transfers" class="page-link bs-label large btn-no-border-link-to-tems" data-selector="transfer-count">
<%= if @address.token_transfers_count do %>
<%= Number.Delimit.number_to_delimited(@address.token_transfers_count, precision: 0) %> <%= gettext("Transfers") %>
<% else %>

@ -21,7 +21,7 @@
<span><%= gettext("There was a problem loading the chart.") %></span>
</button>
<div data-chart-container class="mb-4" style="display: none;">
<canvas data-chart="coinBalanceHistoryChart" data-coin_balance_history_data_path="<%= AccessHelpers.get_path(@conn, :address_coin_balance_by_day_path, :index, @address) %>" width="350" height="152"></canvas>
<canvas data-chart="coinBalanceHistoryChart" data-coin_balance_history_data_path="<%= AccessHelper.get_path(@conn, :address_coin_balance_by_day_path, :index, @address) %>" width="350" height="152"></canvas>
</div>
<%= render BlockScoutWeb.CommonComponentsView, "_pagination_container.html", position: "top", cur_page_number: "1", show_pagination_limit: true, data_next_page_button: true, data_prev_page_button: true %>

@ -24,19 +24,19 @@
<div class="dropdown-menu dropdown-menu-right filter" aria-labelledby="dropdownMenu2">
<%= link(
gettext("All"),
to: AccessHelpers.get_path(@conn, :address_internal_transaction_path, :index, @address.hash),
to: AccessHelper.get_path(@conn, :address_internal_transaction_path, :index, @address.hash),
class: "address__link address__link--active dropdown-item",
"data-test": "filter_option"
) %>
<%= link(
gettext("To"),
to: AccessHelpers.get_path(@conn, :address_internal_transaction_path, :index, @address.hash, %{:filter => "to"}),
to: AccessHelper.get_path(@conn, :address_internal_transaction_path, :index, @address.hash, %{:filter => "to"}),
class: "address__link address__link--active dropdown-item",
"data-test": "filter_option"
) %>
<%= link(
gettext("From"),
to: AccessHelpers.get_path(@conn, :address_internal_transaction_path, :index, @address.hash, %{:filter => "from"}),
to: AccessHelper.get_path(@conn, :address_internal_transaction_path, :index, @address.hash, %{:filter => "from"}),
class: "address__link address__link--active dropdown-item",
"data-test": "filter_option"
) %>

@ -2,7 +2,7 @@
<td class="stakes-td">
</td>
<td>
<%= if System.get_env("DISPLAY_TOKEN_ICONS") === "true" do %>
<%= if Application.get_env(:block_scout_web, :display_token_icons) do %>
<% chain_id_for_token_icon = Application.get_env(:block_scout_web, :chain_id) %>
<% address_hash = @token.contract_address_hash %>
<%=

@ -23,7 +23,7 @@
</span>
</a>
<% else %>
<a href="<%= AccessHelpers.get_path(@conn, :address_token_path, :index, @address_hash) %>#tokens" style="text-decoration: none;">
<a href="<%= AccessHelper.get_path(@conn, :address_token_path, :index, @address_hash) %>#tokens" style="text-decoration: none;">
<span class="btn-wallet-icon">
<i class="fa-solid fa-wallet" style="line-height: 31px;"></i>
</span>

@ -21,7 +21,7 @@
class: "dropdown-item"
) do %>
<div class="row dropdown-row wh-sp">
<%= if System.get_env("DISPLAY_TOKEN_ICONS") === "true" do %>
<%= if Application.get_env(:block_scout_web, :display_token_icons) do %>
<% chain_id_for_token_icon = Application.get_env(:block_scout_web, :chain_id) %>
<% address_hash = token.contract_address_hash %>
<%=
@ -32,7 +32,7 @@
additional_classes: ["token-wallet-icon"]
%>
<% end %>
<p class="mb-0 col-md-6 pl-0 pr-0 el-1 flex-grow-2 <%= if System.get_env("DISPLAY_TOKEN_ICONS") !== "true", do: "ml-5px" %>"><%= token_name(token) %>
<p class="mb-0 col-md-6 pl-0 pr-0 el-1 flex-grow-2 <%= if !Application.get_env(:block_scout_web, :display_token_icons), do: "ml-5px" %>"><%= token_name(token) %>
</p>
<%= if token.fiat_value && token.decimals do %>
<p class="mb-0 col-md-6 text-right usd-total">
@ -48,7 +48,7 @@
<% end %>
</div>
<div class="row dropdown-row wh-sp">
<p class="mb-0 ml-5px dropdown-amount <%= if System.get_env("DISPLAY_TOKEN_ICONS") === "true", do: "ml-20px" %>">
<p class="mb-0 ml-5px dropdown-amount <%= if Application.get_env(:block_scout_web, :display_token_icons), do: "ml-20px" %>">
<%= if token_balance.token_type == "ERC-721" && !is_nil(token_balance.token_id) do %>
1
<% else %>

@ -26,19 +26,19 @@
<div class="dropdown-menu dropdown-menu-right filter" aria-labelledby="dropdownMenu2">
<%= link(
gettext("All"),
to: AccessHelpers.get_path(@conn, :address_token_transfers_path, :index, to_string(@address.hash)),
to: AccessHelper.get_path(@conn, :address_token_transfers_path, :index, to_string(@address.hash)),
class: "address__link address__link--active dropdown-item",
"data-test": "filter_option"
) %>
<%= link(
gettext("To"),
to: AccessHelpers.get_path(@conn, :address_token_transfers_path, :index, to_string(@address.hash), %{:filter => "to"}),
to: AccessHelper.get_path(@conn, :address_token_transfers_path, :index, to_string(@address.hash), %{:filter => "to"}),
class: "address__link address__link--active dropdown-item",
"data-test": "filter_option"
) %>
<%= link(
gettext("From"),
to: AccessHelpers.get_path(@conn, :address_token_transfers_path, :index, to_string(@address.hash), %{:filter => "from"}),
to: AccessHelper.get_path(@conn, :address_token_transfers_path, :index, to_string(@address.hash), %{:filter => "from"}),
class: "address__link address__link--active dropdown-item",
"data-test": "filter_option"
) %>

@ -20,19 +20,19 @@
<div class="dropdown-menu dropdown-menu-right filter" aria-labelledby="dropdownMenu2">
<%= link(
gettext("All"),
to: AccessHelpers.get_path(@conn, :address_transaction_path, :index, @address.hash),
to: AccessHelper.get_path(@conn, :address_transaction_path, :index, @address.hash),
class: "address__link address__link--active dropdown-item",
"data-test": "filter_option"
) %>
<%= link(
gettext("To"),
to: AccessHelpers.get_path(@conn, :address_transaction_path, :index, @address.hash, %{:filter => "to"}),
to: AccessHelper.get_path(@conn, :address_transaction_path, :index, @address.hash, %{:filter => "to"}),
class: "address__link address__link--active dropdown-item",
"data-test": "filter_option"
) %>
<%= link(
gettext("From"),
to: AccessHelpers.get_path(@conn, :address_transaction_path, :index, @address.hash, %{:filter => "from"}),
to: AccessHelper.get_path(@conn, :address_transaction_path, :index, @address.hash, %{:filter => "from"}),
class: "address__link address__link--active dropdown-item",
"data-test": "filter_option"
) %>

@ -35,7 +35,7 @@
<!-- age -->
<span data-from-now="<%= @block.timestamp %>"></span>
</div>
<%= if System.get_env("HIDE_BLOCK_MINER") !== "true" do %>
<%= if !Application.get_env(:block_scout_web, :hide_block_miner) do %>
<div class="text-nowrap text-truncate mt-3 mt-md-0">
<!-- validator -->
<%= gettext "Miner" %>

@ -90,7 +90,7 @@
</dd>
</dl>
<!-- Miner/Validator -->
<%= if System.get_env("HIDE_BLOCK_MINER") !== "true" do %>
<%= if !Application.get_env(:block_scout_web, :hide_block_miner) do %>
<dl class="row">
<dt class="col-sm-3 col-lg-2 text-muted">
<%= render BlockScoutWeb.CommonComponentsView, "_i_tooltip_2.html",

@ -11,7 +11,7 @@
<span class="mr-2"><%= gettext("%{count} Transactions", count: Enum.count(@block.transactions)) %></span>
<span class="text-nowrap" data-from-now="<%= @block.timestamp %>"> </span>
</div>
<%= if System.get_env("HIDE_BLOCK_MINER") !== "true" do %>
<%= if !Application.get_env(:block_scout_web, :hide_block_miner) do %>
<div class="text-truncate">
<%= gettext "Miner" %>
<%= render BlockScoutWeb.AddressView,

@ -15,9 +15,9 @@
<div class="col-md-7 col-lg-8 d-flex flex-column pr-2 pr-sm-2 pr-md-0">
<%= render BlockScoutWeb.TransactionView, "_link.html", transaction_hash: @internal_transaction.transaction_hash %>
<span class="text-nowrap">
<%= @internal_transaction |> BlockScoutWeb.AddressView.address_partial_selector(:from, assigns[:current_address]) |> (&(if is_list(&1), do: Keyword.put(&1, :ignore_implementation_name, true), else: &1)).() |> BlockScoutWeb.RenderHelpers.render_partial() %>
<%= @internal_transaction |> BlockScoutWeb.AddressView.address_partial_selector(:from, assigns[:current_address]) |> (&(if is_list(&1), do: Keyword.put(&1, :ignore_implementation_name, true), else: &1)).() |> BlockScoutWeb.RenderHelper.render_partial() %>
&rarr;
<%= @internal_transaction |> BlockScoutWeb.AddressView.address_partial_selector(:to, assigns[:current_address]) |> (&(if is_list(&1), do: Keyword.put(&1, :ignore_implementation_name, true), else: &1)).() |> BlockScoutWeb.RenderHelpers.render_partial() %>
<%= @internal_transaction |> BlockScoutWeb.AddressView.address_partial_selector(:to, assigns[:current_address]) |> (&(if is_list(&1), do: Keyword.put(&1, :ignore_implementation_name, true), else: &1)).() |> BlockScoutWeb.RenderHelper.render_partial() %>
</span>
<span class="d-flex flex-md-row flex-column mt-3 mt-md-0">
<span class="tile-title">

@ -7,7 +7,7 @@
class="main-search-autocomplete"
data-test="search_input"
data-chain-id="<%= Application.get_env(:block_scout_web, :chain_id) %>"
data-display-token-icons="<%= System.get_env("DISPLAY_TOKEN_ICONS") %>"
data-display-token-icons="<%= Application.get_env(:block_scout_web, :display_token_icons) %>"
type="text"
tabindex="1"
>

@ -8,7 +8,7 @@
class="token-icon mr-1"
data-address-hash="<%= @result.address_hash %>"
>
<%= if System.get_env("DISPLAY_TOKEN_ICONS") === "true" do %>
<%= if Application.get_env(:block_scout_web, :display_token_icons) do %>
<% chain_id_for_token_icon = Application.get_env(:block_scout_web, :chain_id) %>
<% address_hash = @result.address_hash %>
<%=

@ -2,7 +2,7 @@
class="container"
data-page="search-results"
data-chain-id="<%= Application.get_env(:block_scout_web, :chain_id) %>"
data-display-token-icons="<%= System.get_env("DISPLAY_TOKEN_ICONS") %>"
data-display-token-icons="<%= Application.get_env(:block_scout_web, :display_token_icons) %>"
>
<%= render BlockScoutWeb.Advertisement.TextAdView, "index.html", conn: @conn %>
<div class="card">

@ -6,7 +6,7 @@
</span>
</td>
<td class="token-icon">
<%= if System.get_env("DISPLAY_TOKEN_ICONS") === "true" do %>
<%= if Application.get_env(:block_scout_web, :display_token_icons) do %>
<% chain_id_for_token_icon = Application.get_env(:block_scout_web, :chain_id) %>
<% foreign_token_contract_address_hash = nil %>
<% token_hash_for_token_icon = if foreign_token_contract_address_hash, do: foreign_token_contract_address_hash, else: Address.checksum(@token.contract_address_hash) %>

@ -2,7 +2,7 @@
class="container"
data-page="tokens"
data-chain-id="<%= Application.get_env(:block_scout_web, :chain_id) %>"
data-display-token-icons="<%= System.get_env("DISPLAY_TOKEN_ICONS") %>"
data-display-token-icons="<%= Application.get_env(:block_scout_web, :display_token_icons) %>"
>
<%= render BlockScoutWeb.Advertisement.TextAdView, "index.html", conn: @conn %>
<div class="card">

@ -1,4 +1,4 @@
<% circles_addresses_list = CustomContractsHelpers.get_custom_addresses_list(:circles_addresses) %>
<% circles_addresses_list = CustomContractsHelper.get_custom_addresses_list(:circles_addresses) %>
<% address_hash_str = "0x" <> Base.encode16(@token.contract_address_hash.bytes, case: :lower) %>
<% {:ok, created_from_address} = if @token.contract_address_hash, do: Chain.hash_to_address(@token.contract_address_hash), else: {:ok, nil} %>
<% created_from_address_hash = if from_address_hash(created_from_address), do: "0x" <> Base.encode16(from_address_hash(created_from_address).bytes, case: :lower), else: nil %>
@ -27,7 +27,7 @@
id="token-icon"
data-chain-id="<%= Application.get_env(:block_scout_web, :chain_id) %>"
data-address-hash="<%= Address.checksum(@token.contract_address_hash) %>"
data-display-token-icons="<%= System.get_env("DISPLAY_TOKEN_ICONS") %>">
data-display-token-icons="<%= Application.get_env(:block_scout_web, :display_token_icons) %>">
</span>
<div class="title-with-label"><%= @token.name %></div>
<% else %>
@ -54,7 +54,7 @@
<dd class="col-sm-8 col-md-8 col-lg-9 contract-address">
<%= link(
@token.contract_address_hash,
to: AccessHelpers.get_path(@conn, :address_path, :show,
to: AccessHelper.get_path(@conn, :address_path, :show,
Address.checksum(@token.contract_address_hash)),
"data-test": "token_contract_address"
)
@ -108,7 +108,7 @@
<%= gettext("Holders") %>
</dt>
<dd class="col-sm-8 col-md-8 col-lg-9">
<% link = if @conn.request_path |> String.contains?("/token-holders"), do: "", else: AccessHelpers.get_path(@conn, :token_holder_path, :index, @token.contract_address_hash) %>
<% link = if @conn.request_path |> String.contains?("/token-holders"), do: "", else: AccessHelper.get_path(@conn, :token_holder_path, :index, @token.contract_address_hash) %>
<a href="<%= link %>#holders" class="page-link bs-label large btn-no-border-link-to-tems" token-holder-count><%= render BlockScoutWeb.CommonComponentsView, "_loading_spinner.html", loading_text: gettext("Fetching holders...") %></a>
</dd>
</dl>
@ -119,7 +119,7 @@
<%= gettext("Transfers") %>
</dt>
<dd class="col-sm-8 col-md-8 col-lg-9">
<% link = if @conn.request_path |> String.contains?("/token-transfers"), do: "", else: AccessHelpers.get_path(@conn, :token_transfer_path, :index, @token.contract_address_hash) %>
<% link = if @conn.request_path |> String.contains?("/token-transfers"), do: "", else: AccessHelper.get_path(@conn, :token_transfer_path, :index, @token.contract_address_hash) %>
<a href="<%= link %>#transfers" class="page-link bs-label large btn-no-border-link-to-tems" token-transfer-count><%= render BlockScoutWeb.CommonComponentsView, "_loading_spinner.html", loading_text: gettext("Fetching transfers...") %></a>
</dd>
</dl>

@ -4,49 +4,49 @@
<%= link(
gettext("Token Transfers"),
class: "card-tab #{tab_status("token-transfers", @conn.request_path)}",
to: AccessHelpers.get_path(@conn, :token_path, :show, @token.contract_address_hash)
to: AccessHelper.get_path(@conn, :token_path, :show, @token.contract_address_hash)
)
%>
<%= link(
gettext("Token Holders"),
class: "card-tab #{tab_status("token-holders", @conn.request_path)}",
"data-test": "token_holders_tab",
to: AccessHelpers.get_path(@conn, :token_holder_path, :index, address_hash)
to: AccessHelper.get_path(@conn, :token_holder_path, :index, address_hash)
)
%>
<%= if display_inventory?(@token) do %>
<%= link(
gettext("Inventory"),
class: "card-tab #{tab_status("inventory", @conn.request_path)}",
to: AccessHelpers.get_path(@conn, :token_inventory_path, :index, address_hash)
to: AccessHelper.get_path(@conn, :token_inventory_path, :index, address_hash)
)
%>
<% end %>
<%= if smart_contract_with_read_only_functions?(@token) do %>
<%= link(
gettext("Read Contract"),
to: AccessHelpers.get_path(@conn, :token_read_contract_path, :index, address_hash),
to: AccessHelper.get_path(@conn, :token_read_contract_path, :index, address_hash),
class: "card-tab #{tab_status("read-contract", @conn.request_path)}")
%>
<% end %>
<%= if smart_contract_with_write_functions?(@token) do %>
<%= link(
gettext("Write Contract"),
to: AccessHelpers.get_path(@conn, :token_write_contract_path, :index, address_hash),
to: AccessHelper.get_path(@conn, :token_write_contract_path, :index, address_hash),
class: "card-tab #{tab_status("write-contract", @conn.request_path)}")
%>
<% end %>
<%= if is_proxy do %>
<%= link(
gettext("Read Proxy"),
to: AccessHelpers.get_path(@conn, :token_read_proxy_path, :index, address_hash),
to: AccessHelper.get_path(@conn, :token_read_proxy_path, :index, address_hash),
class: "card-tab #{tab_status("read-proxy", @conn.request_path)}")
%>
<% end %>
<%= if smart_contract_with_write_functions?(@token) && is_proxy do %>
<%= link(
gettext("Write Proxy"),
to: AccessHelpers.get_path(@conn, :token_write_proxy_path, :index, address_hash),
to: AccessHelper.get_path(@conn, :token_write_proxy_path, :index, address_hash),
class: "card-tab #{tab_status("write-proxy", @conn.request_path)}")
%>
<% end %>

@ -14,9 +14,9 @@
to: block_path(BlockScoutWeb.Endpoint, :show, @validator.block.hash),
class: "text-truncate") %>
<span class="text-nowrap">
<%= @emission_funds |> BlockScoutWeb.AddressView.address_partial_selector(nil, @current_address) |> BlockScoutWeb.RenderHelpers.render_partial() %>
<%= @emission_funds |> BlockScoutWeb.AddressView.address_partial_selector(nil, @current_address) |> BlockScoutWeb.RenderHelper.render_partial() %>
&rarr;
<%= @validator |> BlockScoutWeb.AddressView.address_partial_selector(nil, @current_address) |> BlockScoutWeb.RenderHelpers.render_partial() %>
<%= @validator |> BlockScoutWeb.AddressView.address_partial_selector(nil, @current_address) |> BlockScoutWeb.RenderHelper.render_partial() %>
</span>
<span class="d-flex flex-md-row flex-column mt-3 mt-md-0">
<span class="tile-title">
@ -26,7 +26,7 @@
</div>
<div class="col-md-3 col-lg-2 d-flex flex-row flex-md-column flex-nowrap justify-content-start text-md-right mt-3 mt-md-0">
<span class="mr-2 mr-md-0 order-1">
<%= @validator |> block_number() |> BlockScoutWeb.RenderHelpers.render_partial() %>
<%= @validator |> block_number() |> BlockScoutWeb.RenderHelper.render_partial() %>
</span>
<span class="mr-2 mr-md-0 order-2" data-from-now="<%= block_timestamp(@validator) %>"></span>
</div>

@ -3,32 +3,32 @@
<%= link(
gettext("Token Transfers"),
class: "card-tab #{tab_status("token-transfers", @conn.request_path, @show_token_transfers)}",
to: AccessHelpers.get_path(@conn, :transaction_token_transfer_path, :index, @transaction)
to: AccessHelper.get_path(@conn, :transaction_token_transfer_path, :index, @transaction)
)
%>
<% end %>
<%= link(
gettext("Internal Transactions"),
class: "card-tab #{tab_status("internal-transactions", @conn.request_path, @show_token_transfers)}",
to: AccessHelpers.get_path(@conn, :transaction_internal_transaction_path, :index, @transaction)
to: AccessHelper.get_path(@conn, :transaction_internal_transaction_path, :index, @transaction)
)
%>
<%= link(
gettext("Logs"),
class: "card-tab #{tab_status("logs", @conn.request_path)}",
to: AccessHelpers.get_path(@conn, :transaction_log_path, :index, @transaction),
to: AccessHelper.get_path(@conn, :transaction_log_path, :index, @transaction),
"data-test": "transaction_logs_link"
)
%>
<%= link(
gettext("Raw Trace"),
class: "card-tab #{tab_status("raw-trace", @conn.request_path)}",
to: AccessHelpers.get_path(@conn, :transaction_raw_trace_path, :index, @transaction)
to: AccessHelper.get_path(@conn, :transaction_raw_trace_path, :index, @transaction)
) %>
<%= link(
gettext("State changes"),
class: "card-tab #{tab_status("state", @conn.request_path)}",
to: AccessHelpers.get_path(@conn, :transaction_state_path, :index, @transaction)
to: AccessHelper.get_path(@conn, :transaction_state_path, :index, @transaction)
)
%>
</div>

@ -40,9 +40,9 @@
</div>
</span>
<span>
<%= @transaction |> BlockScoutWeb.AddressView.address_partial_selector(:from, assigns[:current_address]) |> BlockScoutWeb.RenderHelpers.render_partial() %>
<%= @transaction |> BlockScoutWeb.AddressView.address_partial_selector(:from, assigns[:current_address]) |> BlockScoutWeb.RenderHelper.render_partial() %>
&rarr;
<%= @transaction |> BlockScoutWeb.AddressView.address_partial_selector(:to, assigns[:current_address]) |> BlockScoutWeb.RenderHelpers.render_partial() %>
<%= @transaction |> BlockScoutWeb.AddressView.address_partial_selector(:to, assigns[:current_address]) |> BlockScoutWeb.RenderHelper.render_partial() %>
</span>
<span class="d-flex flex-md-row flex-column mt-3 mt-md-0">
<span class="tile-title">
@ -78,7 +78,7 @@
<!-- Block info -->
<div class="col-md-3 col-lg-2 d-flex flex-row flex-md-column flex-nowrap justify-content-center text-md-right mt-3 mt-md-0 tile-bottom">
<span class="mr-2 mr-md-0 order-1">
<%= @transaction |> block_number() |> BlockScoutWeb.RenderHelpers.render_partial() %>
<%= @transaction |> block_number() |> BlockScoutWeb.RenderHelper.render_partial() %>
</span>
<span class="mr-2 mr-md-0 order-2" in-tile data-from-now="<%= block_timestamp(@transaction) %>"></span>
<%= if from_or_to_address?(@transaction, assigns[:current_address]) do %>

@ -12,11 +12,11 @@
<% end %>
<% end %>
<span class="d-inline-block tile-type-token-transfer-short-name">
<%= @token_transfer |> BlockScoutWeb.AddressView.address_partial_selector(:from, @address, true) |> BlockScoutWeb.RenderHelpers.render_partial() %>
<%= @token_transfer |> BlockScoutWeb.AddressView.address_partial_selector(:from, @address, true) |> BlockScoutWeb.RenderHelper.render_partial() %>
</span>
&rarr;
<span class="d-inline-block tile-type-token-transfer-short-name">
<%= @token_transfer |> BlockScoutWeb.AddressView.address_partial_selector(:to, @address, true) |> BlockScoutWeb.RenderHelpers.render_partial() %>
<%= @token_transfer |> BlockScoutWeb.AddressView.address_partial_selector(:to, @address, true) |> BlockScoutWeb.RenderHelper.render_partial() %>
</span>
</span>
<span class="col-xs-12 col-lg-4 ml-3 ml-sm-0">

@ -22,7 +22,7 @@
<% priority_fee = if is_nil(priority_fee_per_gas), do: nil, else: Wei.mult(priority_fee_per_gas, @transaction.gas_used) %>
<% decoded_input_data = decoded_input_data(@transaction) %>
<% status = transaction_status(@transaction) %>
<% circles_addresses_list = CustomContractsHelpers.get_custom_addresses_list(:circles_addresses) %>
<% circles_addresses_list = CustomContractsHelper.get_custom_addresses_list(:circles_addresses) %>
<% address_hash_str = if to_address_hash, do: "0x" <> Base.encode16(to_address_hash.bytes, case: :lower), else: nil %>
<% {:ok, created_from_address} = if to_address_hash, do: Chain.hash_to_address(to_address_hash), else: {:ok, nil} %>
<% created_from_address_hash_str = if from_address_hash(created_from_address), do: "0x" <> Base.encode16(from_address_hash(created_from_address).bytes, case: :lower), else: nil %>

@ -1,6 +1,6 @@
defmodule BlockScoutWeb.AccessHelpers do
defmodule BlockScoutWeb.AccessHelper do
@moduledoc """
Helpers to restrict access to some pages filtering by address
Helper to restrict access to some pages filtering by address
"""
import Phoenix.Controller
@ -8,14 +8,14 @@ defmodule BlockScoutWeb.AccessHelpers do
alias BlockScoutWeb.API.APILogger
alias BlockScoutWeb.API.RPC.RPCView
alias BlockScoutWeb.WebRouter.Helpers
alias Explorer.AccessHelpers
alias Explorer.AccessHelper
alias Explorer.Account.Api.Key, as: ApiKey
alias Plug.Conn
alias RemoteIp
def restricted_access?(address_hash, params) do
AccessHelpers.restricted_access?(address_hash, params)
AccessHelper.restricted_access?(address_hash, params)
end
def get_path(conn, path, template, address_hash) do

@ -1,7 +1,7 @@
defmodule BlockScoutWeb.Account.WatchlistAddressView do
use BlockScoutWeb, :view
import BlockScoutWeb.AddressView, only: [trimmed_hash: 1]
import BlockScoutWeb.WeiHelpers, only: [format_wei_value: 2]
import BlockScoutWeb.WeiHelper, only: [format_wei_value: 2]
def balance_ether(nil), do: ""

@ -1,7 +1,7 @@
defmodule BlockScoutWeb.AddressCoinBalanceView do
use BlockScoutWeb, :view
alias BlockScoutWeb.AccessHelpers
alias BlockScoutWeb.AccessHelper
alias Explorer.Chain.Wei
def format(%Wei{} = value) do

@ -1,7 +1,7 @@
defmodule BlockScoutWeb.AddressInternalTransactionView do
use BlockScoutWeb, :view
alias BlockScoutWeb.AccessHelpers
alias BlockScoutWeb.AccessHelper
alias Explorer.Chain.Address
def format_current_filter(filter) do

@ -1,7 +1,7 @@
defmodule BlockScoutWeb.AddressTokenBalanceView do
use BlockScoutWeb, :view
alias BlockScoutWeb.AccessHelpers
alias BlockScoutWeb.AccessHelper
alias Explorer.Chain
alias Explorer.Chain.Address
alias Explorer.Counters.AddressTokenUsdSum

@ -1,7 +1,7 @@
defmodule BlockScoutWeb.AddressTokenTransferView do
use BlockScoutWeb, :view
alias BlockScoutWeb.AccessHelpers
alias BlockScoutWeb.AccessHelper
alias Explorer.Chain.Address
def format_current_filter(filter) do

@ -1,7 +1,7 @@
defmodule BlockScoutWeb.AddressTransactionView do
use BlockScoutWeb, :view
alias BlockScoutWeb.AccessHelpers
alias BlockScoutWeb.AccessHelper
alias Explorer.Chain.Address
def format_current_filter(filter) do

@ -3,9 +3,9 @@ defmodule BlockScoutWeb.AddressView do
require Logger
alias BlockScoutWeb.{AccessHelpers, LayoutView}
alias BlockScoutWeb.{AccessHelper, LayoutView}
alias Explorer.Account.CustomABI
alias Explorer.{Chain, CustomContractsHelpers, Repo}
alias Explorer.{Chain, CustomContractsHelper, Repo}
alias Explorer.Chain.{Address, Hash, InternalTransaction, SmartContract, Token, TokenTransfer, Transaction, Wei}
alias Explorer.Chain.Block.Reward
alias Explorer.ExchangeRates.Token, as: TokenExchangeRate

@ -1,6 +1,6 @@
defmodule BlockScoutWeb.API.V2.TokenView do
alias BlockScoutWeb.API.V2.Helper
alias BlockScoutWeb.NFTHelpers
alias BlockScoutWeb.NFTHelper
alias Explorer.Chain
alias Explorer.Chain.Address
@ -70,9 +70,9 @@ defmodule BlockScoutWeb.API.V2.TokenView do
"metadata" => instance.metadata,
"owner" => instance.owner && Helper.address_with_info(conn, instance.owner, instance.owner.hash),
"token" => render("token.json", %{token: token}),
"external_app_url" => NFTHelpers.external_url(instance),
"animation_url" => instance.metadata && NFTHelpers.retrieve_image(instance.metadata["animation_url"]),
"image_url" => instance.metadata && NFTHelpers.get_media_src(instance.metadata, false),
"external_app_url" => NFTHelper.external_url(instance),
"animation_url" => instance.metadata && NFTHelper.retrieve_image(instance.metadata["animation_url"]),
"image_url" => instance.metadata && NFTHelper.get_media_src(instance.metadata, false),
"is_unique" =>
not (token.type == "ERC-1155") or
Chain.token_id_1155_is_unique?(token.contract_address_hash, instance.token_id, @api_true)

@ -4,7 +4,7 @@ defmodule BlockScoutWeb.API.V2.TransactionView do
alias BlockScoutWeb.API.V2.{ApiView, Helper, TokenView}
alias BlockScoutWeb.{ABIEncodedValueView, TransactionView}
alias BlockScoutWeb.Models.GetTransactionTags
alias BlockScoutWeb.Tokens.Helpers
alias BlockScoutWeb.Tokens.Helper, as: TokensHelper
alias BlockScoutWeb.TransactionStateView
alias Ecto.Association.NotLoaded
alias Explorer.ExchangeRates.Token, as: TokenRate
@ -123,7 +123,7 @@ defmodule BlockScoutWeb.API.V2.TransactionView do
end
def prepare_token_transfer_total(token_transfer) do
case Helpers.token_transfer_amount_for_api(token_transfer) do
case TokensHelper.token_transfer_amount_for_api(token_transfer) do
{:ok, :erc721_instance} ->
%{"token_id" => List.first(token_transfer.token_ids)}

@ -1,4 +1,4 @@
defmodule BlockScoutWeb.CurrencyHelpers do
defmodule BlockScoutWeb.CurrencyHelper do
@moduledoc """
Helper functions for interacting with `t:BlockScoutWeb.ExchangeRates.USD.t/0` values.
"""
@ -10,7 +10,7 @@ defmodule BlockScoutWeb.CurrencyHelpers do
## Examples
iex> BlockScoutWeb.CurrencyHelpers.format_integer_to_currency(1000000)
iex> BlockScoutWeb.CurrencyHelper.format_integer_to_currency(1000000)
"1,000,000"
"""
@spec format_integer_to_currency(non_neg_integer() | nil) :: String.t()

@ -1,4 +1,4 @@
defmodule BlockScoutWeb.ErrorHelpers do
defmodule BlockScoutWeb.ErrorHelper do
@moduledoc """
Conveniences for translating and building error messages.
"""

@ -1,4 +1,4 @@
defmodule BlockScoutWeb.NFTHelpers do
defmodule BlockScoutWeb.NFTHelper do
@moduledoc """
Module with functions for NFT view
"""

@ -1,4 +1,4 @@
defmodule BlockScoutWeb.RenderHelpers do
defmodule BlockScoutWeb.RenderHelper do
@moduledoc """
Helper functions to render partials from view modules
"""

@ -1,6 +1,6 @@
defmodule BlockScoutWeb.Views.ScriptHelpers do
defmodule BlockScoutWeb.Views.ScriptHelper do
@moduledoc """
Helpers for rendering view specific script tags.
Helper for rendering view specific script tags.
"""
import Phoenix.HTML, only: [sigil_E: 2]

@ -1,4 +1,4 @@
defmodule BlockScoutWeb.TabHelpers do
defmodule BlockScoutWeb.TabHelper do
@moduledoc """
Helper functions for dealing with tabs, which are very common between pages.
"""
@ -13,10 +13,10 @@ defmodule BlockScoutWeb.TabHelpers do
## Examples
iex> BlockScoutWeb.TabHelpers.tab_status("token", "/page/0xSom3tH1ng/token")
iex> BlockScoutWeb.TabHelper.tab_status("token", "/page/0xSom3tH1ng/token")
"active"
iex> BlockScoutWeb.TabHelpers.tab_status("token", "/page/0xSom3tH1ng/token_transfer")
iex> BlockScoutWeb.TabHelper.tab_status("token", "/page/0xSom3tH1ng/token_transfer")
nil
"""
def tab_status(tab_name, request_path, show_token_transfers \\ false) do
@ -56,10 +56,10 @@ defmodule BlockScoutWeb.TabHelpers do
## Examples
iex> BlockScoutWeb.TabHelpers.tab_active?("token", "/page/0xSom3tH1ng/token")
iex> BlockScoutWeb.TabHelper.tab_active?("token", "/page/0xSom3tH1ng/token")
true
iex> BlockScoutWeb.TabHelpers.tab_active?("token", "/page/0xSom3tH1ng/token_transfer")
iex> BlockScoutWeb.TabHelper.tab_active?("token", "/page/0xSom3tH1ng/token_transfer")
false
"""
def tab_active?("transactions", "/address/" <> "0x" <> <<_address_hash::binary-size(40)>>), do: true

@ -1,9 +1,9 @@
defmodule BlockScoutWeb.Tokens.Helpers do
defmodule BlockScoutWeb.Tokens.Helper do
@moduledoc """
Helper functions for interacting with `t:BlockScoutWeb.Chain.Token` attributes.
"""
alias BlockScoutWeb.{AddressView, CurrencyHelpers}
alias BlockScoutWeb.{AddressView, CurrencyHelper}
alias Explorer.Chain.{Address, Token}
@doc """
@ -29,11 +29,11 @@ defmodule BlockScoutWeb.Tokens.Helpers do
end
defp do_token_transfer_amount(%Token{type: "ERC-20", decimals: nil}, amount, _amounts, _token_ids) do
{:ok, CurrencyHelpers.format_according_to_decimals(amount, Decimal.new(0))}
{:ok, CurrencyHelper.format_according_to_decimals(amount, Decimal.new(0))}
end
defp do_token_transfer_amount(%Token{type: "ERC-20", decimals: decimals}, amount, _amounts, _token_ids) do
{:ok, CurrencyHelpers.format_according_to_decimals(amount, decimals)}
{:ok, CurrencyHelper.format_according_to_decimals(amount, decimals)}
end
defp do_token_transfer_amount(%Token{type: "ERC-721"}, _amount, _amounts, _token_ids) do
@ -42,7 +42,7 @@ defmodule BlockScoutWeb.Tokens.Helpers do
defp do_token_transfer_amount(%Token{type: "ERC-1155", decimals: decimals}, amount, amounts, token_ids) do
if amount do
{:ok, :erc1155_instance, CurrencyHelpers.format_according_to_decimals(amount, decimals)}
{:ok, :erc1155_instance, CurrencyHelper.format_according_to_decimals(amount, decimals)}
else
{:ok, :erc1155_instance, amounts, token_ids, decimals}
end

@ -1,13 +1,13 @@
defmodule BlockScoutWeb.Tokens.Instance.OverviewView do
use BlockScoutWeb, :view
alias BlockScoutWeb.{CurrencyHelpers, NFTHelpers}
alias BlockScoutWeb.{CurrencyHelper, NFTHelper}
alias Explorer.Chain
alias Explorer.Chain.{Address, SmartContract, Token}
alias Explorer.SmartContract.Helper
import BlockScoutWeb.APIDocsView, only: [blockscout_url: 1]
import BlockScoutWeb.NFTHelpers, only: [external_url: 1]
import BlockScoutWeb.NFTHelper, only: [external_url: 1]
@tabs ["token-transfers", "metadata"]
@stub_image "/images/controller.svg"
@ -25,7 +25,7 @@ defmodule BlockScoutWeb.Tokens.Instance.OverviewView do
def media_src(nil, _), do: @stub_image
def media_src(instance, high_quality_media?) do
NFTHelpers.get_media_src(instance.metadata, high_quality_media?) || media_src(nil)
NFTHelper.get_media_src(instance.metadata, high_quality_media?) || media_src(nil)
end
def media_type("data:image/" <> _data) do
@ -80,7 +80,7 @@ defmodule BlockScoutWeb.Tokens.Instance.OverviewView do
end
def total_supply_usd(token) do
tokens = CurrencyHelpers.divide_decimals(token.total_supply, token.decimals)
tokens = CurrencyHelper.divide_decimals(token.total_supply, token.decimals)
price = token.fiat_value
Decimal.mult(tokens, price)
end

@ -1,11 +1,11 @@
defmodule BlockScoutWeb.Tokens.OverviewView do
use BlockScoutWeb, :view
alias Explorer.{Chain, CustomContractsHelpers}
alias Explorer.{Chain, CustomContractsHelper}
alias Explorer.Chain.{Address, SmartContract, Token}
alias Explorer.SmartContract.{Helper, Writer}
alias BlockScoutWeb.{AccessHelpers, CurrencyHelpers, LayoutView}
alias BlockScoutWeb.{AccessHelper, CurrencyHelper, LayoutView}
import BlockScoutWeb.AddressView, only: [from_address_hash: 1, contract_interaction_disabled?: 0]
@ -78,7 +78,7 @@ defmodule BlockScoutWeb.Tokens.OverviewView do
if Map.has_key?(token, :custom_cap) && token.custom_cap do
token.custom_cap
else
tokens = CurrencyHelpers.divide_decimals(token.total_supply, token.decimals)
tokens = CurrencyHelper.divide_decimals(token.total_supply, token.decimals)
price = token.fiat_value
Decimal.mult(tokens, price)
end

@ -1,10 +1,10 @@
defmodule BlockScoutWeb.TransactionView do
use BlockScoutWeb, :view
alias BlockScoutWeb.{AccessHelpers, AddressView, BlockView, TabHelpers}
alias BlockScoutWeb.{AccessHelper, AddressView, BlockView, TabHelper}
alias BlockScoutWeb.Account.AuthController
alias BlockScoutWeb.Cldr.Number
alias Explorer.{Chain, CustomContractsHelpers, Repo}
alias Explorer.{Chain, CustomContractsHelper, Repo}
alias Explorer.Chain.Block.Reward
alias Explorer.Chain.{Address, Block, InternalTransaction, Transaction, Wei}
alias Explorer.Counters.AverageBlockTime
@ -13,7 +13,7 @@ defmodule BlockScoutWeb.TransactionView do
import BlockScoutWeb.Gettext
import BlockScoutWeb.AddressView, only: [from_address_hash: 1, short_token_id: 2, tag_name_to_label: 1]
import BlockScoutWeb.Tokens.Helpers
import BlockScoutWeb.Tokens.Helper
@tabs ["token-transfers", "internal-transactions", "logs", "raw-trace", "state"]
@ -524,7 +524,7 @@ defmodule BlockScoutWeb.TransactionView do
"""
def current_tab_name(request_path) do
@tabs
|> Enum.filter(&TabHelpers.tab_active?(&1, request_path))
|> Enum.filter(&TabHelper.tab_active?(&1, request_path))
|> tab_name()
end
@ -559,7 +559,7 @@ defmodule BlockScoutWeb.TransactionView do
end
defp show_tenderly_link? do
System.get_env("SHOW_TENDERLY_LINK") == "true"
Application.get_env(:block_scout_web, :show_tenderly_link)
end
defp tenderly_chain_path do

@ -1,4 +1,4 @@
defmodule BlockScoutWeb.WeiHelpers do
defmodule BlockScoutWeb.WeiHelper do
@moduledoc """
Helper functions for interacting with `t:Explorer.Chain.Wei.t/0` values.
"""

@ -1411,7 +1411,7 @@ msgstr ""
#: lib/block_scout_web/templates/chain/gas_price_oracle_legend_item.html.eex:22
#: lib/block_scout_web/templates/chain/gas_price_oracle_legend_item.html.eex:38
#: lib/block_scout_web/views/block_view.ex:22
#: lib/block_scout_web/views/wei_helpers.ex:77
#: lib/block_scout_web/views/wei_helper.ex:77
#, elixir-autogen, elixir-format
msgid "Gwei"
msgstr ""
@ -3251,7 +3251,7 @@ msgstr ""
msgid "We recommend using flattened code. This is necessary if your code utilizes a library or inherits dependencies. Use the"
msgstr ""
#: lib/block_scout_web/views/wei_helpers.ex:76
#: lib/block_scout_web/views/wei_helper.ex:76
#, elixir-autogen, elixir-format
msgid "Wei"
msgstr ""

@ -1411,7 +1411,7 @@ msgstr ""
#: lib/block_scout_web/templates/chain/gas_price_oracle_legend_item.html.eex:22
#: lib/block_scout_web/templates/chain/gas_price_oracle_legend_item.html.eex:38
#: lib/block_scout_web/views/block_view.ex:22
#: lib/block_scout_web/views/wei_helpers.ex:77
#: lib/block_scout_web/views/wei_helper.ex:77
#, elixir-autogen, elixir-format
msgid "Gwei"
msgstr ""
@ -3251,7 +3251,7 @@ msgstr ""
msgid "We recommend using flattened code. This is necessary if your code utilizes a library or inherits dependencies. Use the"
msgstr ""
#: lib/block_scout_web/views/wei_helpers.ex:76
#: lib/block_scout_web/views/wei_helper.ex:76
#, elixir-autogen, elixir-format
msgid "Wei"
msgstr ""

@ -24,10 +24,10 @@ defmodule BlockScoutWeb.API.RPC.AddressControllerTest do
start_supervised!({CoinBalanceOnDemand, [mocked_json_rpc_named_arguments, [name: CoinBalanceOnDemand]]})
start_supervised!(AddressesCounter)
Application.put_env(:explorer, AverageBlockTime, enabled: true)
Application.put_env(:explorer, AverageBlockTime, enabled: true, cache_period: 1_800_000)
on_exit(fn ->
Application.put_env(:explorer, AverageBlockTime, enabled: false)
Application.put_env(:explorer, AverageBlockTime, enabled: false, cache_period: 1_800_000)
end)
:ok

@ -16,10 +16,10 @@ defmodule BlockScoutWeb.API.RPC.EthControllerTest do
start_supervised!({CoinBalanceOnDemand, [mocked_json_rpc_named_arguments, [name: CoinBalanceOnDemand]]})
start_supervised!(AddressesCounter)
Application.put_env(:explorer, AverageBlockTime, enabled: true)
Application.put_env(:explorer, AverageBlockTime, enabled: true, cache_period: 1_800_000)
on_exit(fn ->
Application.put_env(:explorer, AverageBlockTime, enabled: false)
Application.put_env(:explorer, AverageBlockTime, enabled: false, cache_period: 1_800_000)
end)
:ok

@ -8,10 +8,10 @@ defmodule BlockScoutWeb.API.V2.StatsControllerTest do
start_supervised!(AddressesCounter)
start_supervised!(AverageBlockTime)
Application.put_env(:explorer, AverageBlockTime, enabled: true)
Application.put_env(:explorer, AverageBlockTime, enabled: true, cache_period: 1_800_000)
on_exit(fn ->
Application.put_env(:explorer, AverageBlockTime, enabled: false)
Application.put_env(:explorer, AverageBlockTime, enabled: false, cache_period: 1_800_000)
end)
:ok

@ -4,7 +4,7 @@ defmodule BlockScoutWeb.TransactionStateControllerTest do
import Mox
import BlockScoutWeb.WebRouter.Helpers, only: [transaction_state_path: 3]
import BlockScoutWeb.WeiHelpers, only: [format_wei_value: 2]
import BlockScoutWeb.WeiHelper, only: [format_wei_value: 2]
import EthereumJSONRPC, only: [integer_to_quantity: 1]
alias Explorer.Chain.Wei

@ -1,82 +1,82 @@
defmodule BlockScoutWeb.CurrencyHelpersTest do
defmodule BlockScoutWeb.CurrencyHelperTest do
use ExUnit.Case
alias BlockScoutWeb.CurrencyHelpers
alias BlockScoutWeb.CurrencyHelper
doctest BlockScoutWeb.CurrencyHelpers, import: true
doctest BlockScoutWeb.CurrencyHelper, import: true
describe "format_according_to_decimals/1" do
test "formats the amount as value considering the given decimals" do
amount = Decimal.new(205_000_000_000_000)
decimals = Decimal.new(12)
assert CurrencyHelpers.format_according_to_decimals(amount, decimals) == "205"
assert CurrencyHelper.format_according_to_decimals(amount, decimals) == "205"
end
test "considers the decimal places according to the given decimals" do
amount = Decimal.new(205_000)
decimals = Decimal.new(12)
assert CurrencyHelpers.format_according_to_decimals(amount, decimals) == "0.000000205"
assert CurrencyHelper.format_according_to_decimals(amount, decimals) == "0.000000205"
end
test "does not consider right zeros in decimal places" do
amount = Decimal.new(90_000_000)
decimals = Decimal.new(6)
assert CurrencyHelpers.format_according_to_decimals(amount, decimals) == "90"
assert CurrencyHelper.format_according_to_decimals(amount, decimals) == "90"
end
test "returns the full number when there is no right zeros in decimal places" do
amount = Decimal.new(9_324_876)
decimals = Decimal.new(6)
assert CurrencyHelpers.format_according_to_decimals(amount, decimals) == "9.324876"
assert CurrencyHelper.format_according_to_decimals(amount, decimals) == "9.324876"
end
test "formats the value considering thousands separators" do
amount = Decimal.new(1_000_450)
decimals = Decimal.new(2)
assert CurrencyHelpers.format_according_to_decimals(amount, decimals) == "10,004.5"
assert CurrencyHelper.format_according_to_decimals(amount, decimals) == "10,004.5"
end
test "supports value as integer" do
amount = 1_000_450
decimals = Decimal.new(2)
assert CurrencyHelpers.format_according_to_decimals(amount, decimals) == "10,004.5"
assert CurrencyHelper.format_according_to_decimals(amount, decimals) == "10,004.5"
end
test "considers 0 when decimals is nil" do
amount = 1_000_450
decimals = nil
assert CurrencyHelpers.format_according_to_decimals(amount, decimals) == "1,000,450"
assert CurrencyHelper.format_according_to_decimals(amount, decimals) == "1,000,450"
end
end
describe "format_integer_to_currency/1" do
test "formats the integer value to a currency format" do
assert CurrencyHelpers.format_integer_to_currency(9000) == "9,000"
assert CurrencyHelper.format_integer_to_currency(9000) == "9,000"
end
end
describe "divide_decimals/2" do
test "divide by the given decimal amount" do
result = CurrencyHelpers.divide_decimals(Decimal.new(1000), Decimal.new(3))
result = CurrencyHelper.divide_decimals(Decimal.new(1000), Decimal.new(3))
expected_result = Decimal.new(1)
assert Decimal.compare(result, expected_result) == :eq
end
test "work when number of decimals is bigger than the number's digits" do
result = CurrencyHelpers.divide_decimals(Decimal.new(1000), Decimal.new(5))
result = CurrencyHelper.divide_decimals(Decimal.new(1000), Decimal.new(5))
expected_result = Decimal.from_float(0.01)
assert Decimal.compare(result, expected_result) == :eq
end
test "return the same number when number of decimals is 0" do
result = CurrencyHelpers.divide_decimals(Decimal.new(1000), Decimal.new(0))
result = CurrencyHelper.divide_decimals(Decimal.new(1000), Decimal.new(0))
expected_result = Decimal.new(1000)
assert Decimal.compare(result, expected_result) == :eq
end

@ -1,8 +1,8 @@
defmodule BlockScoutWeb.ErrorHelpersTest do
defmodule BlockScoutWeb.ErrorHelperTest do
use BlockScoutWeb.ConnCase, async: true
import Phoenix.HTML.Tag, only: [content_tag: 3]
alias BlockScoutWeb.ErrorHelpers
alias BlockScoutWeb.ErrorHelper
@changeset %{
errors: [
@ -12,19 +12,19 @@ defmodule BlockScoutWeb.ErrorHelpersTest do
describe "error_tag tests" do
test "error_tag/2 renders spans with default options" do
assert ErrorHelpers.error_tag(@changeset, :contract_code) == [
assert ErrorHelper.error_tag(@changeset, :contract_code) == [
content_tag(:span, "has already been taken", class: "has-error")
]
end
test "error_tag/3 overrides default options" do
assert ErrorHelpers.error_tag(@changeset, :contract_code, class: "something-else") == [
assert ErrorHelper.error_tag(@changeset, :contract_code, class: "something-else") == [
content_tag(:span, "has already been taken", class: "something-else")
]
end
test "error_tag/3 merges given options with default ones" do
assert ErrorHelpers.error_tag(@changeset, :contract_code, data_hidden: true) == [
assert ErrorHelper.error_tag(@changeset, :contract_code, data_hidden: true) == [
content_tag(:span, "has already been taken", class: "has-error", data_hidden: true)
]
end
@ -32,11 +32,11 @@ defmodule BlockScoutWeb.ErrorHelpersTest do
describe "translate_error/1 tests" do
test "returns errors" do
assert ErrorHelpers.translate_error({"test", []}) == "test"
assert ErrorHelper.translate_error({"test", []}) == "test"
end
test "returns errors with count" do
assert ErrorHelpers.translate_error({"%{count} test", [count: 1]}) == "1 test"
assert ErrorHelper.translate_error({"%{count} test", [count: 1]}) == "1 test"
end
end
end

@ -1,28 +1,28 @@
defmodule BlockScoutWeb.NFTHelpersTest do
defmodule BlockScoutWeb.NFTHelperTest do
use BlockScoutWeb.ConnCase, async: true
alias BlockScoutWeb.NFTHelpers
alias BlockScoutWeb.NFTHelper
describe "compose_ipfs_url/1" do
test "transforms ipfs link like ipfs://${id}" do
url = "ipfs://QmYFf7D2UtqnNz8Lu57Gnk3dxgdAiuboPWMEaNNjhr29tS/hidden.png"
assert "https://ipfs.io/ipfs/QmYFf7D2UtqnNz8Lu57Gnk3dxgdAiuboPWMEaNNjhr29tS/hidden.png" ==
NFTHelpers.compose_ipfs_url(url)
NFTHelper.compose_ipfs_url(url)
end
test "transforms ipfs link like ipfs://ipfs" do
url = "ipfs://ipfs/Qmbgk4Ps5kiVdeYCHufMFgqzWLFuovFRtenY5P8m9vr9XW/animation.mp4"
assert "https://ipfs.io/ipfs/Qmbgk4Ps5kiVdeYCHufMFgqzWLFuovFRtenY5P8m9vr9XW/animation.mp4" ==
NFTHelpers.compose_ipfs_url(url)
NFTHelper.compose_ipfs_url(url)
end
test "transforms ipfs link in different case" do
url = "IpFs://baFybeid4ed2ua7fwupv4nx2ziczr3edhygl7ws3yx6y2juon7xakgj6cfm/51.json"
assert "https://ipfs.io/ipfs/baFybeid4ed2ua7fwupv4nx2ziczr3edhygl7ws3yx6y2juon7xakgj6cfm/51.json" ==
NFTHelpers.compose_ipfs_url(url)
NFTHelper.compose_ipfs_url(url)
end
end
end

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save