|
|
@ -3581,11 +3581,11 @@ defmodule Explorer.Chain do |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
@doc """ |
|
|
|
@doc """ |
|
|
|
Fetches bridges status for tokens. |
|
|
|
Fetches bridged status for tokens and metadata. |
|
|
|
""" |
|
|
|
""" |
|
|
|
def fetch_tokens_bridged_status(token_addresses) do |
|
|
|
def fetch_tokens_bridged_status(token_addresses) do |
|
|
|
Enum.each(token_addresses, fn token_address_hash -> |
|
|
|
Enum.each(token_addresses, fn token_address_hash -> |
|
|
|
created_from_factory_query = |
|
|
|
created_from_int_tx_success_query = |
|
|
|
from( |
|
|
|
from( |
|
|
|
it in InternalTransaction, |
|
|
|
it in InternalTransaction, |
|
|
|
inner_join: t in assoc(it, :transaction), |
|
|
|
inner_join: t in assoc(it, :transaction), |
|
|
@ -3593,13 +3593,53 @@ defmodule Explorer.Chain do |
|
|
|
where: t.status == ^1 |
|
|
|
where: t.status == ^1 |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
created_from_factory = |
|
|
|
created_from_int_tx_success = |
|
|
|
created_from_factory_query |
|
|
|
created_from_int_tx_success_query |
|
|
|
|> Repo.one() |
|
|
|
|> Repo.one() |
|
|
|
|
|
|
|
|
|
|
|
if created_from_factory do |
|
|
|
created_from_tx_query = |
|
|
|
|
|
|
|
from( |
|
|
|
|
|
|
|
t in Transaction, |
|
|
|
|
|
|
|
where: t.created_contract_address_hash == ^token_address_hash |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
created_from_tx = |
|
|
|
|
|
|
|
created_from_tx_query |
|
|
|
|
|
|
|
|> Repo.all() |
|
|
|
|
|
|
|
|> Enum.count() > 0 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
created_from_int_tx_query = |
|
|
|
|
|
|
|
from( |
|
|
|
|
|
|
|
it in InternalTransaction, |
|
|
|
|
|
|
|
where: it.created_contract_address_hash == ^token_address_hash |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
created_from_int_tx = |
|
|
|
|
|
|
|
created_from_int_tx_query |
|
|
|
|
|
|
|
|> Repo.all() |
|
|
|
|
|
|
|
|> Enum.count() > 0 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cond do |
|
|
|
|
|
|
|
created_from_tx -> |
|
|
|
|
|
|
|
set_token_bridged_status(token_address_hash, false) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
created_from_int_tx && !created_from_int_tx_success -> |
|
|
|
|
|
|
|
set_token_bridged_status(token_address_hash, false) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
created_from_int_tx && created_from_int_tx_success -> |
|
|
|
|
|
|
|
extract_bridged_token_metadata_wrapper(token_address_hash, created_from_int_tx_success) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
true -> |
|
|
|
|
|
|
|
:ok |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
:ok |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
defp extract_bridged_token_metadata_wrapper(token_address_hash, created_from_int_tx_success) do |
|
|
|
multi_token_bridge_mediator = Application.get_env(:block_scout_web, :multi_token_bridge_mediator) |
|
|
|
multi_token_bridge_mediator = Application.get_env(:block_scout_web, :multi_token_bridge_mediator) |
|
|
|
%{transaction_hash: transaction_hash} = created_from_factory |
|
|
|
%{transaction_hash: transaction_hash} = created_from_int_tx_success |
|
|
|
|
|
|
|
|
|
|
|
if multi_token_bridge_mediator && multi_token_bridge_mediator !== "" do |
|
|
|
if multi_token_bridge_mediator && multi_token_bridge_mediator !== "" do |
|
|
|
{:ok, multi_token_bridge_mediator_hash} = Chain.string_to_address_hash(multi_token_bridge_mediator) |
|
|
|
{:ok, multi_token_bridge_mediator_hash} = Chain.string_to_address_hash(multi_token_bridge_mediator) |
|
|
@ -3616,6 +3656,18 @@ defmodule Explorer.Chain do |
|
|
|
|> Repo.all() |
|
|
|
|> Repo.all() |
|
|
|
|
|
|
|
|
|
|
|
if Enum.count(created_by_amb_mediator) > 0 do |
|
|
|
if Enum.count(created_by_amb_mediator) > 0 do |
|
|
|
|
|
|
|
extract_bridged_token_metadata( |
|
|
|
|
|
|
|
token_address_hash, |
|
|
|
|
|
|
|
multi_token_bridge_mediator, |
|
|
|
|
|
|
|
multi_token_bridge_mediator_hash |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
set_token_bridged_status(token_address_hash, false) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
defp extract_bridged_token_metadata(token_address_hash, multi_token_bridge_mediator, multi_token_bridge_mediator_hash) do |
|
|
|
json_rpc_named_arguments = Application.get_env(:explorer, :json_rpc_named_arguments) |
|
|
|
json_rpc_named_arguments = Application.get_env(:explorer, :json_rpc_named_arguments) |
|
|
|
# keccak 256 from getTokenInterfacesVersion() |
|
|
|
# keccak 256 from getTokenInterfacesVersion() |
|
|
|
get_token_interfaces_version_signature = "0x859ba28c" |
|
|
|
get_token_interfaces_version_signature = "0x859ba28c" |
|
|
@ -3652,8 +3704,7 @@ defmodule Explorer.Chain do |
|
|
|
|> json_rpc(json_rpc_named_arguments) do |
|
|
|
|> json_rpc(json_rpc_named_arguments) do |
|
|
|
"0x" <> foreign_token_address_no_prefix = foreign_token_address_abi_encoded |
|
|
|
"0x" <> foreign_token_address_no_prefix = foreign_token_address_abi_encoded |
|
|
|
|
|
|
|
|
|
|
|
<<_prefix::binary-size(24), foreign_token_address_hash_string_raw::binary()>> = |
|
|
|
<<_prefix::binary-size(24), foreign_token_address_hash_string_raw::binary()>> = foreign_token_address_no_prefix |
|
|
|
foreign_token_address_no_prefix |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreign_token_address_hash_string = "0x" <> foreign_token_address_hash_string_raw |
|
|
|
foreign_token_address_hash_string = "0x" <> foreign_token_address_hash_string_raw |
|
|
|
|
|
|
|
|
|
|
@ -3679,16 +3730,6 @@ defmodule Explorer.Chain do |
|
|
|
|
|
|
|
|
|
|
|
set_token_bridged_status(token_address_hash, true) |
|
|
|
set_token_bridged_status(token_address_hash, true) |
|
|
|
end |
|
|
|
end |
|
|
|
else |
|
|
|
|
|
|
|
set_token_bridged_status(token_address_hash, false) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
set_token_bridged_status(token_address_hash, false) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
:ok |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
defp set_token_bridged_status(token_address_hash, status) do |
|
|
|
defp set_token_bridged_status(token_address_hash, status) do |
|
|
|