fix: do not include unrelated token transfers in `tokenTransferTxs` (#10889)

* fix: do not include unrelated token transfers in `tokenTransferTxs`

* fix: increase `API_GRAPHQL_MAX_COMPLEXITY` for celo instances

* chore: add spec and doc
pull/10894/head
Fedor Ivanov 2 months ago committed by GitHub
parent 93a0657430
commit 6a22f3afc3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      .github/workflows/publish-docker-image-for-celo.yml
  2. 9
      apps/block_scout_web/lib/block_scout_web/graphql/celo/resolvers/token_transfer.ex
  3. 7
      apps/block_scout_web/lib/block_scout_web/graphql/celo/resolvers/token_transfer_tx.ex
  4. 23
      apps/explorer/lib/explorer/graphql/celo.ex

@ -36,7 +36,7 @@ jobs:
linux/amd64
linux/arm64/v8
build-args: |
API_GRAPHQL_MAX_COMPLEXITY=6650
API_GRAPHQL_MAX_COMPLEXITY=10400
CACHE_EXCHANGE_RATES_PERIOD=
API_V1_READ_METHODS_DISABLED=false
DISABLE_WEBAPP=false

@ -7,11 +7,10 @@ defmodule BlockScoutWeb.GraphQL.Celo.Resolvers.TokenTransfer do
alias Explorer.GraphQL.Celo, as: GraphQL
alias Explorer.Repo
def get_by(_, args, _) do
connection_args = Map.take(args, [:after, :before, :first, :last])
GraphQL.token_tx_transfers_query()
|> Connection.from_query(&Repo.all/1, connection_args, options(args))
def get_by(%{transaction_hash: hash}, args, _) do
hash
|> GraphQL.token_tx_transfers_query_by_txhash()
|> Connection.from_query(&Repo.all/1, args, options(args))
end
defp options(%{before: _}), do: []

@ -19,13 +19,6 @@ defmodule BlockScoutWeb.GraphQL.Celo.Resolvers.TokenTransferTx do
|> Connection.from_query(&Repo.all/1, connection_args, options(args))
end
def get_by(_, args, _) do
connection_args = Map.take(args, [:after, :before, :first, :last])
GraphQL.token_tx_transfers_query()
|> Connection.from_query(&Repo.all/1, connection_args, options(args))
end
defp options(%{before: _}), do: []
defp options(%{count: count}), do: [count: count]

@ -76,7 +76,8 @@ defmodule Explorer.GraphQL.Celo do
)
query
|> order_by([transaction: t],
|> order_by(
[transaction: t],
desc: t.block_number,
desc: t.hash,
asc: t.nonce,
@ -85,6 +86,26 @@ defmodule Explorer.GraphQL.Celo do
)
end
@doc """
Constructs a query to fetch token transfers within a given transaction.
## Parameters
- tx_hash: the hash of the transaction
## Returns
- Ecto query
"""
@spec token_tx_transfers_query_by_txhash(Hash.Full.t()) :: Ecto.Query.t()
def token_tx_transfers_query_by_txhash(tx_hash) do
query = token_tx_transfers_query()
from(
t in subquery(query),
where: t.transaction_hash == ^tx_hash,
order_by: [t.log_index]
)
end
@doc """
Constructs a query for token transfers filtered by a specific address.
"""

Loading…
Cancel
Save