diff --git a/lib/starknet_explorer/transaction.ex b/lib/starknet_explorer/transaction.ex index 07d22b84..02de7acc 100644 --- a/lib/starknet_explorer/transaction.ex +++ b/lib/starknet_explorer/transaction.ex @@ -191,7 +191,9 @@ defmodule StarknetExplorer.Transaction do |> Repo.paginate(params) end - def paginate_transactions_for_index(params, network) do + def paginate_transactions_for_index(params, network, filter \\ "ALL") + + def paginate_transactions_for_index(params, network, "ALL") do query = from t in Transaction, where: t.network == ^network, @@ -209,6 +211,24 @@ defmodule StarknetExplorer.Transaction do query |> Repo.paginate(Map.put(params, :options, %{total_entries: total_rows})) end + def paginate_transactions_for_index(params, network, filter) do + query = + from t in Transaction, + where: t.network == ^network and t.type == ^filter, + join: b in Block, + on: t.block_number == b.number and t.network == b.network, + select: %{hash: t.hash, type: t.type, timestamp: b.timestamp, status: b.status}, + order_by: [desc: b.timestamp] + + total_rows = + case StarknetExplorer.Counts.get(network) do + nil -> get_total_count(network) + entities_count -> entities_count.transactions + end + + query |> Repo.paginate(Map.put(params, :options, %{total_entries: total_rows})) + end + @spec rename_rpc_fields(map) :: map def rename_rpc_fields(rpc_tx = %{"transaction_hash" => th}) do rpc_tx diff --git a/lib/starknet_explorer_web/live/pages/block_detail.ex b/lib/starknet_explorer_web/live/pages/block_detail.ex index 55190831..569df15b 100644 --- a/lib/starknet_explorer_web/live/pages/block_detail.ex +++ b/lib/starknet_explorer_web/live/pages/block_detail.ex @@ -496,7 +496,7 @@ defmodule StarknetExplorerWeb.BlockDetailLive do class="dropdown relative bg-[#232331] p-5 mb-2 rounded-md lg:hidden" phx-hook="Dropdown" > - <%= assigns.view %> + <%= assigns.tx_filter %> diff --git a/lib/starknet_explorer_web/live/transaction_index_live.ex b/lib/starknet_explorer_web/live/transaction_index_live.ex index 111083c9..6c06720f 100644 --- a/lib/starknet_explorer_web/live/transaction_index_live.ex +++ b/lib/starknet_explorer_web/live/transaction_index_live.ex @@ -11,6 +11,7 @@ defmodule StarknetExplorerWeb.TransactionIndexLive do