From 625063725c77936b2ef6fd6c6b6407dfb13e3b1a Mon Sep 17 00:00:00 2001 From: Miles Zhang Date: Sun, 18 Feb 2024 11:22:39 +0800 Subject: [PATCH] fix: when coinmarketcap can't fetch usd price, return 0 Signed-off-by: Miles Zhang --- lib/godwoken_explorer/exchange_rates/source/coin_market_cap.ex | 2 +- lib/godwoken_explorer/graphql/resolovers/udt.ex | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/godwoken_explorer/exchange_rates/source/coin_market_cap.ex b/lib/godwoken_explorer/exchange_rates/source/coin_market_cap.ex index a6e405ca..2558c218 100644 --- a/lib/godwoken_explorer/exchange_rates/source/coin_market_cap.ex +++ b/lib/godwoken_explorer/exchange_rates/source/coin_market_cap.ex @@ -138,7 +138,7 @@ defmodule GodwokenExplorer.ExchangeRates.Source.CoinMarketCap do token_properties["quote"]["USD"]["price"] do to_decimal(token_properties["quote"]["USD"]["price"]) else - 1 + 0 end end diff --git a/lib/godwoken_explorer/graphql/resolovers/udt.ex b/lib/godwoken_explorer/graphql/resolovers/udt.ex index d3a67898..104bc8ee 100644 --- a/lib/godwoken_explorer/graphql/resolovers/udt.ex +++ b/lib/godwoken_explorer/graphql/resolovers/udt.ex @@ -86,7 +86,7 @@ defmodule GodwokenExplorer.Graphql.Resolvers.UDT do if exchange_rate == 0 do Decimal.new(0) else - Decimal.new(exchange_rate) + exchange_rate end {:ok, %{symbol: symbol, exchange_rate: exchange_rate, timestamp: timestamp}}