|
|
|
@ -149,8 +149,26 @@ defmodule Explorer.Chain do |
|
|
|
|
|
|
|
|
|
""" |
|
|
|
|
@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 |
|
|
|
|
address_hash_to_transactions(hash, options) |
|
|
|
|
def address_to_transactions( |
|
|
|
|
%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 |
|
|
|
|
|
|
|
|
|
@doc """ |
|
|
|
@ -2196,28 +2214,6 @@ defmodule Explorer.Chain do |
|
|
|
|
|> Repo.insert() |
|
|
|
|
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}]) :: |
|
|
|
|
{:ok, changes :: map} | {:error, [Changeset.t()]} |
|
|
|
|
defp changes_list(params, options) when is_list(options) do |
|
|
|
|