fix: add smart contracts preloads to from_address (#10236)

pull/10239/head
Maxim Filonov 5 months ago committed by GitHub
parent 68ca0ed8ff
commit 569cb8bbb6
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/main_page_controller.ex
  4. 3
      apps/block_scout_web/lib/block_scout_web/controllers/api/v2/transaction_controller.ex
  5. 2
      apps/block_scout_web/lib/block_scout_web/endpoint.ex
  6. 15
      apps/block_scout_web/lib/block_scout_web/notifier.ex
  7. 2
      apps/explorer/lib/explorer/chain.ex

@ -337,7 +337,7 @@ defmodule BlockScoutWeb.AddressChannel do
transactions
|> Repo.preload([
[
from_address: [:names],
from_address: [:names, :smart_contract, :proxy_implementations],
to_address: [:names, :smart_contract, :proxy_implementations],
created_contract_address: [:names, :smart_contract, :proxy_implementations]
]

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

@ -14,7 +14,7 @@ defmodule BlockScoutWeb.API.V2.MainPageController do
necessity_by_association: %{
:block => :required,
[created_contract_address: [:names, :smart_contract, :proxy_implementations]] => :optional,
[from_address: [:names, :smart_contract]] => :optional,
[from_address: [:names, :smart_contract, :proxy_implementations]] => :optional,
[to_address: [:names, :smart_contract, :proxy_implementations]] => :optional
},
paging_options: %PagingOptions{page_size: 6},

@ -63,7 +63,8 @@ defmodule BlockScoutWeb.API.V2.TransactionController do
:proxy_implementations
]
] => :optional,
[from_address: :names] => :optional,
[from_address: [:names, :smart_contract, :proxy_implementations]] =>
:optional,
[to_address: [:names, :smart_contract, :proxy_implementations]] => :optional
}
|> Map.merge(@chain_type_transaction_necessity_by_association)

@ -69,7 +69,7 @@ defmodule BlockScoutWeb.Endpoint do
plug(BlockScoutWeb.Prometheus.Exporter)
# 'x-apollo-tracing' header for https://www.graphqlbin.com to work with our GraphQL endpoint
plug(CORSPlug, origin: :self, headers: ["x-apollo-tracing" | CORSPlug.defaults()[:headers]])
plug(CORSPlug, headers: ["x-apollo-tracing" | CORSPlug.defaults()[:headers]])
plug(BlockScoutWeb.Router)
end

@ -175,10 +175,8 @@ defmodule BlockScoutWeb.Notifier do
DenormalizationHelper.extend_transaction_preload([
:token,
:transaction,
from_address: :smart_contract,
to_address: :smart_contract,
from_address: :names,
to_address: :names
from_address: [:names, :smart_contract, :proxy_implementations],
to_address: [:names, :smart_contract, :proxy_implementations]
])
))
)
@ -202,12 +200,9 @@ defmodule BlockScoutWeb.Notifier do
def handle_event({:chain_event, :transactions, :realtime, transactions}) do
base_preloads = [
:block,
created_contract_address: :names,
from_address: :names,
to_address: :names,
created_contract_address: :smart_contract,
from_address: :smart_contract,
to_address: :smart_contract
created_contract_address: [:names, :smart_contract, :proxy_implementations],
from_address: [:names, :smart_contract, :proxy_implementations],
to_address: [:names, :smart_contract, :proxy_implementations]
]
preloads = if API_V2.enabled?(), do: [:token_transfers | base_preloads], else: base_preloads

@ -403,7 +403,7 @@ defmodule Explorer.Chain do
base
else
base
|> preload(transaction: [:from_address, to_address: [:proxy_implementations]])
|> preload(transaction: [from_address: [:proxy_implementations], to_address: [:proxy_implementations]])
end
preloaded_query

Loading…
Cancel
Save