diff --git a/.DS_Store b/.DS_Store index 4d8e359..54d4f76 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/wallet/.DS_Store b/wallet/.DS_Store index eac1e08..7e0c064 100644 Binary files a/wallet/.DS_Store and b/wallet/.DS_Store differ diff --git a/wallet/crystals/.DS_Store b/wallet/crystals/.DS_Store new file mode 100644 index 0000000..698db66 Binary files /dev/null and b/wallet/crystals/.DS_Store differ diff --git a/wallet/crystals/060_ethbridge/__init__.py b/wallet/crystals/060_ethbridge/__init__.py index 2ad03ad..5735261 100644 --- a/wallet/crystals/060_ethbridge/__init__.py +++ b/wallet/crystals/060_ethbridge/__init__.py @@ -8,6 +8,9 @@ from modules.helpers import base_path from hashlib import sha256 from decimal import Decimal, getcontext, ROUND_HALF_EVEN +import aiohttp +import ssl +import certifi DEFAULT_THEME_PATH = path.join(base_path(), "crystals/060_ethbridge/themes/default") @@ -46,6 +49,11 @@ def f8_to_int(a_str: str): # Helper function to convert a legacy string 0.8f to compact int format return int(Decimal(a_str) * DECIMAL_1E8) +async def fetch_json(url): + ssl_context = ssl.create_default_context(cafile=certifi.where()) + async with aiohttp.ClientSession() as session: + async with session.get(url, ssl=ssl_context) as response: + return await response.json() class EthbridgeHandler(CrystalHandler): @@ -75,11 +83,12 @@ async def about(self, params=None): self.bismuth_vars['extra']["footer"] += f'\n' self.bismuth_vars['extra']["circulating"] = "N/A" try: - res = await async_get_with_http_fallback("https://hypernodes.bismuth.live/api/coinsupply.php") - # print(res) - self.bismuth_vars['extra']["circulating"] = res["circulating"] - except: - pass + url = "https://bismuth.im/api/info/coinsupply" + res = await fetch_json(url) + if res: + self.bismuth_vars['extra']["circulating"] = res.get("circulating", "N/A") + except Exception as e: + print(f"Error in about method: {e}") self.render("about.html", bismuth=self.bismuth_vars) async def message_popup(self, params=None): diff --git a/wallet/crystals/061_bscbridge/__init__.py b/wallet/crystals/061_bscbridge/__init__.py index 126c75d..b66edd0 100644 --- a/wallet/crystals/061_bscbridge/__init__.py +++ b/wallet/crystals/061_bscbridge/__init__.py @@ -8,6 +8,9 @@ from modules.helpers import base_path from hashlib import sha256 from decimal import Decimal, getcontext, ROUND_HALF_EVEN +import aiohttp +import ssl +import certifi DEFAULT_THEME_PATH = path.join(base_path(), "crystals/061_bscbridge/themes/default") @@ -45,6 +48,11 @@ def f8_to_int(a_str: str): # Helper function to convert a legacy string 0.8f to compact int format return int(Decimal(a_str) * DECIMAL_1E8) +async def fetch_json(url): + ssl_context = ssl.create_default_context(cafile=certifi.where()) + async with aiohttp.ClientSession() as session: + async with session.get(url, ssl=ssl_context) as response: + return await response.json() class BscbridgeHandler(CrystalHandler): @@ -69,16 +77,17 @@ def initialize(self): @staticmethod def sha256(txid: str): return sha256(txid.encode('utf-8')).hexdigest() - + async def about(self, params=None): self.bismuth_vars['extra']["footer"] += f'\n' self.bismuth_vars['extra']["circulating"] = "N/A" try: - res = await async_get_with_http_fallback("https://hypernodes.bismuth.live/api/coinsupply.php") - # print(res) - self.bismuth_vars['extra']["circulating"] = res["circulating"] - except: - pass + url = "https://bismuth.im/api/info/coinsupply" + res = await fetch_json(url) + if res: + self.bismuth_vars['extra']["circulating"] = res.get("circulating", "N/A") + except Exception as e: + print(f"Error in about method: {e}") self.render("about.html", bismuth=self.bismuth_vars) async def message_popup(self, params=None):