Remove unnecessary function wrapper

Co-authored-by: Stamates <stamates@hotmail.com>
Co-authored-by: Tim Mecklem <timothy@mecklem.com>
pull/306/head
jimmay5469 7 years ago committed by Stamates
parent 753868a158
commit ef0d605b5c
  1. 44
      apps/explorer/lib/explorer/chain.ex

@ -149,8 +149,26 @@ defmodule Explorer.Chain do
""" """
@spec address_to_transactions(Address.t(), [paging_options | necessity_by_association_option]) :: Transaction.t() @spec address_to_transactions(Address.t(), [paging_options | necessity_by_association_option]) :: Transaction.t()
def address_to_transactions(%Address{hash: hash}, options \\ []) when is_list(options) do def address_to_transactions(
address_hash_to_transactions(hash, options) %Address{hash: %Hash{byte_count: unquote(Hash.Truncated.byte_count())} = address_hash},
options \\ []
)
when is_list(options) do
direction = Keyword.get(options, :direction)
necessity_by_association = Keyword.get(options, :necessity_by_association, %{})
paging_options = Keyword.get(options, :paging_options, %PagingOptions{page_size: 50})
Transaction
|> load_contract_creation()
|> select_merge([_, internal_transaction], %{
created_contract_address_hash: internal_transaction.created_contract_address_hash
})
|> where_address_fields_match(address_hash, direction)
|> page_transaction(paging_options)
|> limit(^paging_options.page_size)
|> order_by([transaction], desc: transaction.block_number, desc: transaction.index)
|> join_associations(necessity_by_association)
|> Repo.all()
end end
@doc """ @doc """
@ -2196,28 +2214,6 @@ defmodule Explorer.Chain do
|> Repo.insert() |> Repo.insert()
end end
defp address_hash_to_transactions(
%Hash{byte_count: unquote(Hash.Truncated.byte_count())} = address_hash,
options
)
when is_list(options) do
direction = Keyword.get(options, :direction)
necessity_by_association = Keyword.get(options, :necessity_by_association, %{})
paging_options = Keyword.get(options, :paging_options, %PagingOptions{page_size: 50})
Transaction
|> load_contract_creation()
|> select_merge([_, internal_transaction], %{
created_contract_address_hash: internal_transaction.created_contract_address_hash
})
|> where_address_fields_match(address_hash, direction)
|> page_transaction(paging_options)
|> limit(^paging_options.page_size)
|> order_by([transaction], desc: transaction.block_number, desc: transaction.index)
|> join_associations(necessity_by_association)
|> Repo.all()
end
@spec changes_list(params :: map, [{:for, module} | {:with, :atom}]) :: @spec changes_list(params :: map, [{:for, module} | {:with, :atom}]) ::
{:ok, changes :: map} | {:error, [Changeset.t()]} {:ok, changes :: map} | {:error, [Changeset.t()]}
defp changes_list(params, options) when is_list(options) do defp changes_list(params, options) when is_list(options) do

Loading…
Cancel
Save