Fix foreign chaind detection

pull/3227/head
Victor Baranov 4 years ago
parent 85f7f197d7
commit dd03109511
  1. 18
      apps/block_scout_web/lib/block_scout_web/views/tokens/overview_view.ex
  2. 2
      apps/explorer/lib/explorer/chain.ex

@ -6,6 +6,8 @@ defmodule BlockScoutWeb.Tokens.OverviewView do
alias BlockScoutWeb.{CurrencyHelpers, LayoutView} alias BlockScoutWeb.{CurrencyHelpers, LayoutView}
@tabs ["token_transfers", "token_holders", "read_contract", "inventory"] @tabs ["token_transfers", "token_holders", "read_contract", "inventory"]
@etherscan_token_link "https://etherscan.io/token/"
@blockscout_base_link "https://blockscout.com/"
def decimals?(%Token{decimals: nil}), do: false def decimals?(%Token{decimals: nil}), do: false
def decimals?(%Token{decimals: _}), do: true def decimals?(%Token{decimals: _}), do: true
@ -71,16 +73,20 @@ defmodule BlockScoutWeb.Tokens.OverviewView do
base_token_explorer_link <> foreign_token_contract_address_hash_string base_token_explorer_link <> foreign_token_contract_address_hash_string
end end
# credo:disable-for-next-line /Complexity/
defp get_base_token_explorer_link(chain_id) when not is_nil(chain_id) do defp get_base_token_explorer_link(chain_id) when not is_nil(chain_id) do
case Decimal.to_integer(chain_id) do case Decimal.to_integer(chain_id) do
181 ->
@blockscout_base_link <> "poa/qdai/tokens/"
100 -> 100 ->
"https://blockscout.com/poa/xdai/tokens/" @blockscout_base_link <> "poa/xdai/tokens/"
99 -> 99 ->
"https://blockscout.com/poa/core/tokens/" @blockscout_base_link <> "poa/core/tokens/"
77 -> 77 ->
"https://blockscout.com/poa/sokol/tokens/" @blockscout_base_link <> "poa/sokol/tokens/"
42 -> 42 ->
"https://kovan.etherscan.io/token/" "https://kovan.etherscan.io/token/"
@ -95,12 +101,12 @@ defmodule BlockScoutWeb.Tokens.OverviewView do
"https://goerli.etherscan.io/token/" "https://goerli.etherscan.io/token/"
1 -> 1 ->
"https://etherscan.io/token/" @etherscan_token_link
_ -> _ ->
"https://etherscan.io/token/" @etherscan_token_link
end end
end end
defp get_base_token_explorer_link(_), do: "https://etherscan.io/" defp get_base_token_explorer_link(_), do: @etherscan_token_link
end end

@ -3480,7 +3480,7 @@ defmodule Explorer.Chain do
|> json_rpc(json_rpc_named_arguments) |> json_rpc(json_rpc_named_arguments)
"0x" <> foreign_chain_id_abi_encoded_no_prefix = foreign_chain_id_abi_encoded "0x" <> foreign_chain_id_abi_encoded_no_prefix = foreign_chain_id_abi_encoded
{foreign_chain_id, _} = Integer.parse(foreign_chain_id_abi_encoded_no_prefix) {foreign_chain_id, _} = Integer.parse(foreign_chain_id_abi_encoded_no_prefix, 16)
set_bridged_token_metadata(token_address_hash, %{ set_bridged_token_metadata(token_address_hash, %{
foreign_chain_id: foreign_chain_id, foreign_chain_id: foreign_chain_id,

Loading…
Cancel
Save