Merge pull request #3574 from poanetwork/vb-uni-id

Correct UNI token CoinGecko ID
pull/3577/head
Victor Baranov 4 years ago committed by GitHub
commit f49e72681e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      CHANGELOG.md
  2. 51
      apps/explorer/lib/explorer/exchange_rates/source/coin_gecko.ex

@ -6,6 +6,7 @@
### Fixes ### Fixes
### Chore ### Chore
- [#3574](https://github.com/poanetwork/blockscout/pull/3574) - Correct UNI token price
- [#3567](https://github.com/poanetwork/blockscout/pull/3567) - Force to show filter at the page where filtered items list is empty - [#3567](https://github.com/poanetwork/blockscout/pull/3567) - Force to show filter at the page where filtered items list is empty
- [#3565](https://github.com/poanetwork/blockscout/pull/3565) - Staking dapp: unhealthy state alert message - [#3565](https://github.com/poanetwork/blockscout/pull/3565) - Staking dapp: unhealthy state alert message

@ -124,29 +124,35 @@ defmodule Explorer.ExchangeRates.Source.CoinGecko do
end end
def coin_id(symbol) do def coin_id(symbol) do
url = "#{base_url()}/coins/list" id_mapping = bridged_token_symbol_to_id_mapping_to_get_price(symbol)
symbol_downcase = String.downcase(symbol) if id_mapping do
{:ok, id_mapping}
case Source.http_request(url) do else
{:ok, data} = resp -> url = "#{base_url()}/coins/list"
if is_list(data) do
symbol_data = symbol_downcase = String.downcase(symbol)
Enum.find(data, fn item ->
item["symbol"] == symbol_downcase case Source.http_request(url) do
end) {:ok, data} = resp ->
if is_list(data) do
if symbol_data do symbol_data =
{:ok, symbol_data["id"]} Enum.find(data, fn item ->
item["symbol"] == symbol_downcase
end)
if symbol_data do
{:ok, symbol_data["id"]}
else
{:error, :not_found}
end
else else
{:error, :not_found} resp
end end
else
resp
end
resp -> resp ->
resp resp
end
end end
end end
@ -172,4 +178,11 @@ defmodule Explorer.ExchangeRates.Source.CoinGecko do
defp config(key) do defp config(key) do
Application.get_env(:explorer, __MODULE__, [])[key] Application.get_env(:explorer, __MODULE__, [])[key]
end end
defp bridged_token_symbol_to_id_mapping_to_get_price(symbol) do
case symbol do
"UNI" -> "uniswap"
_symbol -> nil
end
end
end end

Loading…
Cancel
Save