Skip to content

Commit

Permalink
modification
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjtalkshow committed Oct 26, 2024
1 parent b3d2827 commit eb800dc
Showing 1 changed file with 15 additions and 18 deletions.
33 changes: 15 additions & 18 deletions web_app/contract_tools/mixins/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,25 +31,22 @@ async def get_current_prices(cls) -> Dict[str, str]:
"""
prices = {}

try:
response = await APIRequest(base_url=AVNU_PRICE_URL).fetch("")
if not response:
return prices
response = await APIRequest(base_url=AVNU_PRICE_URL).fetch("")
if not response:
return prices

for token_data in response:
try:
address = token_data.get("address")
current_price = token_data.get("currentPrice")
if address and current_price is not None:
symbol = TokenParams.get_token_symbol(address)
if symbol:
prices[symbol] = str(Decimal(current_price))
except AttributeError as e:
print(f"AttributeError while parsing price for {address}: {str(e)}")
except TypeError as e:
print(f"TypeError while parsing price for {address}: {str(e)}")
except Exception as e: # handle if API request fails
print(f"Failed to fetch prices from API due to an error: {e}")
for token_data in response:
try:
address = token_data.get("address")
current_price = token_data.get("currentPrice")
if address and current_price is not None:
symbol = TokenParams.get_token_symbol(address)
if symbol:
prices[symbol] = str(Decimal(current_price))
except AttributeError as e:
print(f"AttributeError while parsing price for {address}: {str(e)}")
except TypeError as e:
print(f"TypeError while parsing price for {address}: {str(e)}")

return prices

Expand Down

0 comments on commit eb800dc

Please sign in to comment.