fix: Fix scam badge value in some API endpoints (#11054)

pull/11066/head
Victor Baranov 3 weeks ago committed by GitHub
parent 16faddc70b
commit 97d8a2b2df
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      apps/block_scout_web/lib/block_scout_web/channels/address_channel.ex
  2. 2
      apps/block_scout_web/lib/block_scout_web/controllers/api/v2/address_controller.ex
  3. 2
      apps/block_scout_web/lib/block_scout_web/controllers/api/v2/block_controller.ex
  4. 2
      apps/block_scout_web/lib/block_scout_web/controllers/api/v2/main_page_controller.ex
  5. 8
      apps/block_scout_web/lib/block_scout_web/controllers/api/v2/transaction_controller.ex
  6. 10
      apps/block_scout_web/lib/block_scout_web/microservice_interfaces/transaction_interpretation.ex
  7. 2
      apps/block_scout_web/lib/block_scout_web/models/transaction_state_helper.ex
  8. 2
      apps/block_scout_web/lib/block_scout_web/notifier.ex
  9. 4
      apps/block_scout_web/lib/block_scout_web/views/api/v2/helper.ex
  10. 4
      apps/explorer/lib/explorer/chain/advanced_filter.ex
  11. 4
      apps/explorer/lib/explorer/chain/internal_transaction.ex
  12. 8
      apps/explorer/lib/explorer/chain/token_transfer.ex

@ -49,7 +49,7 @@ defmodule BlockScoutWeb.AddressChannel do
end end
@transaction_associations [ @transaction_associations [
from_address: [:names, :smart_contract, :proxy_implementations], from_address: [:scam_badge, :names, :smart_contract, :proxy_implementations],
to_address: [ to_address: [
:scam_badge, :scam_badge,
:names, :names,

@ -53,7 +53,7 @@ defmodule BlockScoutWeb.API.V2.AddressController do
necessity_by_association: necessity_by_association:
%{ %{
[created_contract_address: [:scam_badge, :names, :smart_contract, :proxy_implementations]] => :optional, [created_contract_address: [:scam_badge, :names, :smart_contract, :proxy_implementations]] => :optional,
[from_address: [:names, :smart_contract, :proxy_implementations]] => :optional, [from_address: [:scam_badge, :names, :smart_contract, :proxy_implementations]] => :optional,
[to_address: [:scam_badge, :names, :smart_contract, :proxy_implementations]] => :optional, [to_address: [:scam_badge, :names, :smart_contract, :proxy_implementations]] => :optional,
:block => :optional :block => :optional
} }

@ -85,7 +85,7 @@ defmodule BlockScoutWeb.API.V2.BlockController do
necessity_by_association: necessity_by_association:
%{ %{
[created_contract_address: [:scam_badge, :names, :smart_contract, :proxy_implementations]] => :optional, [created_contract_address: [:scam_badge, :names, :smart_contract, :proxy_implementations]] => :optional,
[from_address: [:names, :smart_contract, :proxy_implementations]] => :optional, [from_address: [:scam_badge, :names, :smart_contract, :proxy_implementations]] => :optional,
[to_address: [:scam_badge, :names, :smart_contract, :proxy_implementations]] => :optional, [to_address: [:scam_badge, :names, :smart_contract, :proxy_implementations]] => :optional,
:block => :optional :block => :optional
} }

@ -25,7 +25,7 @@ defmodule BlockScoutWeb.API.V2.MainPageController do
%{ %{
:block => :required, :block => :required,
[created_contract_address: [:scam_badge, :names, :smart_contract, :proxy_implementations]] => :optional, [created_contract_address: [:scam_badge, :names, :smart_contract, :proxy_implementations]] => :optional,
[from_address: [:names, :smart_contract, :proxy_implementations]] => :optional, [from_address: [:scam_badge, :names, :smart_contract, :proxy_implementations]] => :optional,
[to_address: [:scam_badge, :names, :smart_contract, :proxy_implementations]] => :optional [to_address: [:scam_badge, :names, :smart_contract, :proxy_implementations]] => :optional
} }
|> Map.merge(@chain_type_transaction_necessity_by_association), |> Map.merge(@chain_type_transaction_necessity_by_association),

@ -78,7 +78,7 @@ defmodule BlockScoutWeb.API.V2.TransactionController do
:proxy_implementations :proxy_implementations
] ]
] => :optional, ] => :optional,
[from_address: [:names, :smart_contract, :proxy_implementations]] => [from_address: [:scam_badge, :names, :smart_contract, :proxy_implementations]] =>
:optional, :optional,
[ [
to_address: [ to_address: [
@ -573,7 +573,7 @@ defmodule BlockScoutWeb.API.V2.TransactionController do
options = options =
[ [
necessity_by_association: %{ necessity_by_association: %{
[from_address: [:names, :smart_contract, :proxy_implementations]] => :optional, [from_address: [:scam_badge, :names, :smart_contract, :proxy_implementations]] => :optional,
[to_address: [:scam_badge, :names, :smart_contract, :proxy_implementations]] => :optional [to_address: [:scam_badge, :names, :smart_contract, :proxy_implementations]] => :optional
} }
] ]
@ -600,8 +600,8 @@ defmodule BlockScoutWeb.API.V2.TransactionController do
options = options =
[ [
necessity_by_association: %{ necessity_by_association: %{
[from_address: [:names, :smart_contract, :proxy_implementations]] => :optional, [from_address: [:scam_badge, :names, :smart_contract, :proxy_implementations]] => :optional,
[to_address: [:names, :smart_contract, :proxy_implementations]] => :optional [to_address: [:scam_badge, :names, :smart_contract, :proxy_implementations]] => :optional
} }
] ]
|> Keyword.merge(@api_true) |> Keyword.merge(@api_true)

@ -109,7 +109,7 @@ defmodule BlockScoutWeb.MicroserviceInterfaces.TransactionInterpretation do
Chain.select_repo(@api_true).preload(transaction, [ Chain.select_repo(@api_true).preload(transaction, [
:block, :block,
to_address: [:scam_badge, :names, :smart_contract], to_address: [:scam_badge, :names, :smart_contract],
from_address: [:names, :smart_contract], from_address: [:scam_badge, :names, :smart_contract],
created_contract_address: [:scam_badge, :names, :token, :smart_contract] created_contract_address: [:scam_badge, :names, :token, :smart_contract]
]) ])
@ -176,8 +176,8 @@ defmodule BlockScoutWeb.MicroserviceInterfaces.TransactionInterpretation do
full_options = full_options =
[ [
necessity_by_association: %{ necessity_by_association: %{
[from_address: [:names, :smart_contract, :proxy_implementations]] => :optional, [from_address: [:scam_badge, :names, :smart_contract, :proxy_implementations]] => :optional,
[to_address: [:names, :smart_contract, :proxy_implementations]] => :optional [to_address: [:scam_badge, :names, :smart_contract, :proxy_implementations]] => :optional
} }
] ]
|> Keyword.merge(@api_true) |> Keyword.merge(@api_true)
@ -254,8 +254,8 @@ defmodule BlockScoutWeb.MicroserviceInterfaces.TransactionInterpretation do
token_transfer_options = token_transfer_options =
[ [
necessity_by_association: %{ necessity_by_association: %{
[from_address: [:names, :smart_contract, :proxy_implementations]] => :optional, [from_address: [:scam_badge, :names, :smart_contract, :proxy_implementations]] => :optional,
[to_address: [:names, :smart_contract, :proxy_implementations]] => :optional, [to_address: [:scam_badge, :names, :smart_contract, :proxy_implementations]] => :optional,
:token => :optional :token => :optional
} }
] ]

@ -77,7 +77,7 @@ defmodule BlockScoutWeb.Models.TransactionStateHelper do
to_address: [:scam_badge, :names, :smart_contract, :proxy_implementations] to_address: [:scam_badge, :names, :smart_contract, :proxy_implementations]
], ],
block: [miner: [:names, :smart_contract, :proxy_implementations]], block: [miner: [:names, :smart_contract, :proxy_implementations]],
from_address: [:names, :smart_contract, :proxy_implementations], from_address: [:scam_badge, :names, :smart_contract, :proxy_implementations],
to_address: [:scam_badge, :names, :smart_contract, :proxy_implementations] to_address: [:scam_badge, :names, :smart_contract, :proxy_implementations]
) )

@ -206,7 +206,7 @@ defmodule BlockScoutWeb.Notifier do
base_preloads = [ base_preloads = [
:block, :block,
created_contract_address: [:scam_badge, :names, :smart_contract, :proxy_implementations], created_contract_address: [:scam_badge, :names, :smart_contract, :proxy_implementations],
from_address: [:names, :smart_contract, :proxy_implementations], from_address: [:scam_badge, :names, :smart_contract, :proxy_implementations],
to_address: [:scam_badge, :names, :smart_contract, :proxy_implementations] to_address: [:scam_badge, :names, :smart_contract, :proxy_implementations]
] ]

@ -159,6 +159,10 @@ defmodule BlockScoutWeb.API.V2.Helper do
def address_name(_), do: nil def address_name(_), do: nil
def address_marked_as_scam?(%Address{scam_badge: %Ecto.Association.NotLoaded{}}) do
false
end
def address_marked_as_scam?(%Address{scam_badge: scam_badge}) when not is_nil(scam_badge) do def address_marked_as_scam?(%Address{scam_badge: scam_badge}) when not is_nil(scam_badge) do
true true
end end

@ -115,8 +115,8 @@ defmodule Explorer.Chain.AdvancedFilter do
|> Enum.sort(&sort_function/2) |> Enum.sort(&sort_function/2)
|> take_page_size(paging_options) |> take_page_size(paging_options)
|> Chain.select_repo(options).preload( |> Chain.select_repo(options).preload(
from_address: [:names, :smart_contract, :proxy_implementations], from_address: [:scam_badge, :names, :smart_contract, :proxy_implementations],
to_address: [:names, :smart_contract, :proxy_implementations], to_address: [:scam_badge, :names, :smart_contract, :proxy_implementations],
created_contract_address: [:names, :smart_contract, :proxy_implementations] created_contract_address: [:names, :smart_contract, :proxy_implementations]
) )
end end

@ -832,8 +832,8 @@ defmodule Explorer.Chain.InternalTransaction do
preloads = preloads =
DenormalizationHelper.extend_transaction_preload([ DenormalizationHelper.extend_transaction_preload([
:block, :block,
[from_address: [:names, :smart_contract, :proxy_implementations]], [from_address: [:scam_badge, :names, :smart_contract, :proxy_implementations]],
[to_address: [:names, :smart_contract, :proxy_implementations]] [to_address: [:scam_badge, :names, :smart_contract, :proxy_implementations]]
]) ])
__MODULE__ __MODULE__

@ -239,7 +239,7 @@ defmodule Explorer.Chain.TokenTransfer do
DenormalizationHelper.extend_transaction_preload([ DenormalizationHelper.extend_transaction_preload([
:transaction, :transaction,
:token, :token,
[from_address: [:names, :smart_contract, :proxy_implementations]], [from_address: [:scam_badge, :names, :smart_contract, :proxy_implementations]],
[to_address: [:scam_badge, :names, :smart_contract, :proxy_implementations]] [to_address: [:scam_badge, :names, :smart_contract, :proxy_implementations]]
]) ])
@ -266,7 +266,7 @@ defmodule Explorer.Chain.TokenTransfer do
DenormalizationHelper.extend_transaction_preload([ DenormalizationHelper.extend_transaction_preload([
:transaction, :transaction,
:token, :token,
[from_address: [:names, :smart_contract, :proxy_implementations]], [from_address: [:scam_badge, :names, :smart_contract, :proxy_implementations]],
[to_address: [:scam_badge, :names, :smart_contract, :proxy_implementations]] [to_address: [:scam_badge, :names, :smart_contract, :proxy_implementations]]
]) ])
@ -299,8 +299,8 @@ defmodule Explorer.Chain.TokenTransfer do
DenormalizationHelper.extend_transaction_preload([ DenormalizationHelper.extend_transaction_preload([
:transaction, :transaction,
:token, :token,
[from_address: [:names, :smart_contract, :proxy_implementations]], [from_address: [:scam_badge, :names, :smart_contract, :proxy_implementations]],
[to_address: [:names, :smart_contract, :proxy_implementations]] [to_address: [:scam_badge, :names, :smart_contract, :proxy_implementations]]
]) ])
only_consensus_transfers_query() only_consensus_transfers_query()

Loading…
Cancel
Save