From 0353d0829c2a21392262f13465b3269c4344c344 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 22 Aug 2024 15:29:01 +0800 Subject: [PATCH 1/2] fix the process_jetton_data function --- TonTools/Providers/utils.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/TonTools/Providers/utils.py b/TonTools/Providers/utils.py index b43d685..e00e0f8 100644 --- a/TonTools/Providers/utils.py +++ b/TonTools/Providers/utils.py @@ -25,12 +25,13 @@ def process_jetton_data(data): url = Cell.one_from_boc(b64decode(data)).bits.get_top_upped_array().decode().split('\x01')[-1] return url else: - symbol = Cell.one_from_boc(b64decode(data)).refs[0].refs[1].refs[0].refs[1].refs[0].bits.get_top_upped_array().decode().split('\x00')[-1] - desc1 = unicodedata.normalize("NFKD", Cell.one_from_boc(b64decode(data)).refs[0].refs[1].refs[1].refs[0].refs[0].bits.get_top_upped_array().decode().split('\x00')[-1]) # Cell.one_from_boc(b64decode(data)).refs[0].refs[1].refs[1].refs[0].refs - desc2 = unicodedata.normalize("NFKD", Cell.one_from_boc(b64decode(data)).refs[0].refs[1].refs[1].refs[0].refs[0].refs[0].bits.get_top_upped_array().decode().split('\x00')[-1]) if len(Cell.one_from_boc(b64decode(data)).refs[0].refs[1].refs[1].refs[0].refs[0].refs) else '' - decimals = Cell.one_from_boc(b64decode(data)).refs[0].refs[1].refs[1].refs[1].refs[0].bits.get_top_upped_array().decode().split('\x00')[-1] - name = Cell.one_from_boc(b64decode(data)).refs[0].refs[1].refs[0].refs[0].refs[0].bits.get_top_upped_array().decode().split('\x00')[-1] - image = Cell.one_from_boc(b64decode(data)).refs[0].refs[0].refs[0].bits.get_top_upped_array().decode().split('\x00')[-1] + symbol = Cell.one_from_boc(b64decode(data)).refs[0].refs[0].refs[1].refs[0].bits.get_top_upped_array().decode().split('\x00')[-1] + desc1 = unicodedata.normalize("NFKD", Cell.one_from_boc(b64decode(data)).refs[0].refs[1].refs[0].refs[0].bits.get_top_upped_array().decode().split('\x00')[-1]) # Cell.one_from_boc(b64decode(data)).refs[0].refs[1].refs[1].refs[0].refs + desc2 = unicodedata.normalize("NFKD", Cell.one_from_boc(b64decode(data)).refs[0].refs[1].refs[0].refs[0].refs[0].bits.get_top_upped_array().decode().split('\x00')[-1]) if len(Cell.one_from_boc(b64decode(data)).refs[0].refs[1].refs[0].refs[0].refs) else '' + decimals = Cell.one_from_boc(b64decode(data)).refs[0].refs[1].refs[1].refs[0].bits.get_top_upped_array().decode().split('\x00')[-1] + name = Cell.one_from_boc(b64decode(data)).refs[0].refs[0].refs[0].refs[0].bits.get_top_upped_array().decode().split('\x00')[-1] + # image = Cell.one_from_boc(b64decode(data)).refs[0].refs[0].refs[0].bits.get_top_upped_array().decode().split('\x00')[-1] + image = "" return { 'name': name, 'description': desc1 + desc2, From 12e2886c17d0910b204eb7ada8e3370afd6d711e Mon Sep 17 00:00:00 2001 From: root Date: Fri, 23 Aug 2024 11:16:19 +0800 Subject: [PATCH 2/2] fix return url --- TonTools/Providers/utils.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/TonTools/Providers/utils.py b/TonTools/Providers/utils.py index e00e0f8..a372098 100644 --- a/TonTools/Providers/utils.py +++ b/TonTools/Providers/utils.py @@ -21,16 +21,16 @@ def is_hex(str): def process_jetton_data(data): - if not len(Cell.one_from_boc(b64decode(data)).refs): - url = Cell.one_from_boc(b64decode(data)).bits.get_top_upped_array().decode().split('\x01')[-1] - return url - else: + try: + if Cell.one_from_boc(b64decode(data)).refs[0].refs[0].refs[0].bits: + url = Cell.one_from_boc(b64decode(data)).refs[0].refs[0].refs[0].bits.get_top_upped_array().decode().split('\x00')[-1] + return url + except: symbol = Cell.one_from_boc(b64decode(data)).refs[0].refs[0].refs[1].refs[0].bits.get_top_upped_array().decode().split('\x00')[-1] desc1 = unicodedata.normalize("NFKD", Cell.one_from_boc(b64decode(data)).refs[0].refs[1].refs[0].refs[0].bits.get_top_upped_array().decode().split('\x00')[-1]) # Cell.one_from_boc(b64decode(data)).refs[0].refs[1].refs[1].refs[0].refs desc2 = unicodedata.normalize("NFKD", Cell.one_from_boc(b64decode(data)).refs[0].refs[1].refs[0].refs[0].refs[0].bits.get_top_upped_array().decode().split('\x00')[-1]) if len(Cell.one_from_boc(b64decode(data)).refs[0].refs[1].refs[0].refs[0].refs) else '' decimals = Cell.one_from_boc(b64decode(data)).refs[0].refs[1].refs[1].refs[0].bits.get_top_upped_array().decode().split('\x00')[-1] name = Cell.one_from_boc(b64decode(data)).refs[0].refs[0].refs[0].refs[0].bits.get_top_upped_array().decode().split('\x00')[-1] - # image = Cell.one_from_boc(b64decode(data)).refs[0].refs[0].refs[0].bits.get_top_upped_array().decode().split('\x00')[-1] image = "" return { 'name': name,