diff --git a/.github/workflows/publish-docker-image-for-celo.yml b/.github/workflows/publish-docker-image-for-celo.yml index 6843e949f2..5aa28a8903 100644 --- a/.github/workflows/publish-docker-image-for-celo.yml +++ b/.github/workflows/publish-docker-image-for-celo.yml @@ -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 diff --git a/apps/block_scout_web/lib/block_scout_web/graphql/celo/resolvers/token_transfer.ex b/apps/block_scout_web/lib/block_scout_web/graphql/celo/resolvers/token_transfer.ex index 31e4a252c3..bf21bc8b5c 100644 --- a/apps/block_scout_web/lib/block_scout_web/graphql/celo/resolvers/token_transfer.ex +++ b/apps/block_scout_web/lib/block_scout_web/graphql/celo/resolvers/token_transfer.ex @@ -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: [] diff --git a/apps/block_scout_web/lib/block_scout_web/graphql/celo/resolvers/token_transfer_tx.ex b/apps/block_scout_web/lib/block_scout_web/graphql/celo/resolvers/token_transfer_tx.ex index 557b30dde0..f038c3b92c 100644 --- a/apps/block_scout_web/lib/block_scout_web/graphql/celo/resolvers/token_transfer_tx.ex +++ b/apps/block_scout_web/lib/block_scout_web/graphql/celo/resolvers/token_transfer_tx.ex @@ -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] diff --git a/apps/explorer/lib/explorer/graphql/celo.ex b/apps/explorer/lib/explorer/graphql/celo.ex index 3b92d12082..4705274ca0 100644 --- a/apps/explorer/lib/explorer/graphql/celo.ex +++ b/apps/explorer/lib/explorer/graphql/celo.ex @@ -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. """