From 8ee634421604df6959b041494c8cafcb23b81765 Mon Sep 17 00:00:00 2001 From: drethereum Date: Tue, 5 Dec 2023 09:36:25 -0700 Subject: [PATCH] revert --- macros/streamline/functions.py.sql | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/macros/streamline/functions.py.sql b/macros/streamline/functions.py.sql index 9f95a22..bc64d11 100644 --- a/macros/streamline/functions.py.sql +++ b/macros/streamline/functions.py.sql @@ -317,8 +317,29 @@ def transform_hex_to_tezos(input, prefix): full_hash = prefixed_hash + checksum - tezos_address = fsc_utils.create_udf_hex_to_base58(full_hash.hex()) + tezos_address = transform_hex_to_base58(full_hash.hex()) return tezos_address +def transform_hex_to_base58(input): + if input is None: + return None + + ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz" + byte_array = bytes.fromhex(input) + num = int.from_bytes(byte_array, 'big') + + encoded = '' + while num > 0: + num, remainder = divmod(num, 58) + encoded = ALPHABET[remainder] + encoded + + for byte in byte_array: + if byte == 0: + encoded = '1' + encoded + else: + break + + return encoded + {% endmacro %} \ No newline at end of file