|
|
|
@ -37,7 +37,8 @@ defmodule BlockScoutWeb.API.V2.SearchView do |
|
|
|
|
"circulating_market_cap" => |
|
|
|
|
search_result.circulating_market_cap && to_string(search_result.circulating_market_cap), |
|
|
|
|
"is_verified_via_admin_panel" => search_result.is_verified_via_admin_panel, |
|
|
|
|
"certified" => if(search_result.certified, do: search_result.certified, else: false) |
|
|
|
|
"certified" => if(search_result.certified, do: search_result.certified, else: false), |
|
|
|
|
"priority" => search_result.priority |
|
|
|
|
} |
|
|
|
|
end |
|
|
|
|
|
|
|
|
@ -49,19 +50,21 @@ defmodule BlockScoutWeb.API.V2.SearchView do |
|
|
|
|
"url" => address_path(Endpoint, :show, search_result.address_hash), |
|
|
|
|
"is_smart_contract_verified" => search_result.verified, |
|
|
|
|
"ens_info" => search_result[:ens_info], |
|
|
|
|
"certified" => if(search_result.certified, do: search_result.certified, else: false) |
|
|
|
|
"certified" => if(search_result.certified, do: search_result.certified, else: false), |
|
|
|
|
"priority" => search_result.priority |
|
|
|
|
} |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def prepare_search_result(%{type: address_or_contract_or_label} = search_result) |
|
|
|
|
when address_or_contract_or_label in ["address", "label"] do |
|
|
|
|
when address_or_contract_or_label in ["address", "label", "ens_domain"] do |
|
|
|
|
%{ |
|
|
|
|
"type" => search_result.type, |
|
|
|
|
"name" => search_result.name, |
|
|
|
|
"address" => search_result.address_hash, |
|
|
|
|
"url" => address_path(Endpoint, :show, search_result.address_hash), |
|
|
|
|
"is_smart_contract_verified" => search_result.verified, |
|
|
|
|
"ens_info" => search_result[:ens_info] |
|
|
|
|
"ens_info" => search_result[:ens_info], |
|
|
|
|
"priority" => search_result.priority |
|
|
|
|
} |
|
|
|
|
end |
|
|
|
|
|
|
|
|
@ -82,7 +85,8 @@ defmodule BlockScoutWeb.API.V2.SearchView do |
|
|
|
|
"block_hash" => block_hash, |
|
|
|
|
"url" => block_path(Endpoint, :show, block_hash), |
|
|
|
|
"timestamp" => search_result.timestamp, |
|
|
|
|
"block_type" => block |> BlockView.block_type() |> String.downcase() |
|
|
|
|
"block_type" => block |> BlockView.block_type() |> String.downcase(), |
|
|
|
|
"priority" => search_result.priority |
|
|
|
|
} |
|
|
|
|
end |
|
|
|
|
|
|
|
|
@ -93,7 +97,8 @@ defmodule BlockScoutWeb.API.V2.SearchView do |
|
|
|
|
"type" => search_result.type, |
|
|
|
|
"tx_hash" => tx_hash, |
|
|
|
|
"url" => transaction_path(Endpoint, :show, tx_hash), |
|
|
|
|
"timestamp" => search_result.timestamp |
|
|
|
|
"timestamp" => search_result.timestamp, |
|
|
|
|
"priority" => search_result.priority |
|
|
|
|
} |
|
|
|
|
end |
|
|
|
|
|
|
|
|
@ -103,7 +108,8 @@ defmodule BlockScoutWeb.API.V2.SearchView do |
|
|
|
|
%{ |
|
|
|
|
"type" => search_result.type, |
|
|
|
|
"user_operation_hash" => user_operation_hash, |
|
|
|
|
"timestamp" => search_result.timestamp |
|
|
|
|
"timestamp" => search_result.timestamp, |
|
|
|
|
"priority" => search_result.priority |
|
|
|
|
} |
|
|
|
|
end |
|
|
|
|
|
|
|
|
@ -113,7 +119,8 @@ defmodule BlockScoutWeb.API.V2.SearchView do |
|
|
|
|
%{ |
|
|
|
|
"type" => search_result.type, |
|
|
|
|
"blob_hash" => blob_hash, |
|
|
|
|
"timestamp" => search_result.timestamp |
|
|
|
|
"timestamp" => search_result.timestamp, |
|
|
|
|
"priority" => search_result.priority |
|
|
|
|
} |
|
|
|
|
end |
|
|
|
|
|
|
|
|
@ -132,6 +139,10 @@ defmodule BlockScoutWeb.API.V2.SearchView do |
|
|
|
|
%{"type" => "address", "parameter" => Address.checksum(item.hash)} |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
defp redirect_search_results(%{address_hash: address_hash}) do |
|
|
|
|
%{"type" => "address", "parameter" => address_hash} |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
defp redirect_search_results(%Block{} = item) do |
|
|
|
|
%{"type" => "block", "parameter" => to_string(item.hash)} |
|
|
|
|
end |
|
|
|
|