From 67f2f2fd35ae901e3654dc6c0ae3bf81fa2dc35e Mon Sep 17 00:00:00 2001 From: alias-bitsignal Date: Mon, 16 Dec 2024 13:59:11 +0100 Subject: [PATCH] circulating api updated --- .DS_Store | Bin 6148 -> 6148 bytes wallet/.DS_Store | Bin 8196 -> 8196 bytes wallet/crystals/.DS_Store | Bin 0 -> 8196 bytes wallet/crystals/060_ethbridge/__init__.py | 19 ++++++++++++++----- wallet/crystals/061_bscbridge/__init__.py | 21 +++++++++++++++------ 5 files changed, 29 insertions(+), 11 deletions(-) create mode 100644 wallet/crystals/.DS_Store diff --git a/.DS_Store b/.DS_Store index 4d8e3596f489fad554412424e07871fab1a667dd..54d4f7604869ef509dd5744ff3891473ca10c360 100644 GIT binary patch delta 130 zcmZoMXffEZlT~b2QbA5;afyM!HAW_87FITP4t5T1j>#8Ug(rVtb@Aim;EWfLs;)LP zH_%ZqG&Zf(QK&XFHL(P83@lA+YdJYYmG!NI;*chz{m)p8Tg?zjGDcNe!>C>$gM%TNp@^Z9p_rkBA(0`6p|~u# zC@&{JFC8cc(kFx>Kl!Y{3}sHBvV4YgAl75Z1WM;I6np06Cqq3Vz`(%LyE#m-lzC%? U0Mll6iEk{EFAD$KSi#E#0AT1nYybcN delta 44 zcmV+{0Mq}3K!iY$PXQCLP`eKS6O#-Ovy-_Irn8X}W&@Md94WDQ69cmc81@9Qcn1Su C=MQNB diff --git a/wallet/crystals/.DS_Store b/wallet/crystals/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..698db664b62d2645d655c60ebc58bbd5a12993a9 GIT binary patch literal 8196 zcmeHM!EO^V5FIChZd6JG0;xhmti-h{N!x%bE+H)kt^~mWP}t3`l2y0sD4R5@qDZ*| zzrZgbuKWl53nzGEyH(<}hyy~Euq%7K-gz_QXL~oZB_h!rMKz)gBJxmKR#wrRQ}{mD zrBW~>6-WU*QAi2pbVMT>E@`^~$ADwNG2j?*3^)cZ0|R(xbMY>C@9Vp+bqqKL{!0e< z`QW3nY#2GyQaw7*s1yLQgke?C=X8KEzL5`roN1}y zBuw%ljAvmo6rsGszOU3tG_-WBW56-6%m5#kb*j=fYI`An@6j59P?93_#uOli4)qpoh`W}J zHQ*mA8!_~In8^U&A|mSA@r(C=jts|n-^~1L*iVyuSgn2+g<|Q-)fI2WTlLV=ePc-jxbmq|QsS8nagY#1b2JWzlnilOr6Rgy(=+?1m%$`!VyZ+K;| z+^*c2Olps+n|^JlKHc;uwfgQJE~9p+KzW?Cy^Y&qSl*td64~j4kMq1O?XYEJy ze#6djYmlWf>#~V6&6?T^Ie5RA#~;w1-v;8`h{;6c3tgX_8mb#z^Zq#`kC50u&{_O?px?ppgHz7{4%l+uaZ&=^~FN1 zDb%*|DZx~ZxDyq*6>aIBg}er&-tU3>QYPUuz*jTtq?LH(<{7Hcu3@+jUlQ|+u|9l0 za7r=nlf{VDN&Pf;Qp>>WbI$rXcnvHBpUg$X0Ga_^2Z zE;|E79pDD%|4(sl-FJY?zG5yu$H3obK$H$z2Tj;L{RwHi;9T2BeTT}0^=4Ws2pW}+ jL#lKf^6Vdm==)G*OvA{TmKZ^C9|9B&u5k?fQwDwkE7v3! literal 0 HcmV?d00001 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):