From 6709d4655abe8ff823fd604a23abff0b11d596f5 Mon Sep 17 00:00:00 2001 From: drethereum <71602799+drethereum@users.noreply.github.com> Date: Thu, 27 Jun 2024 12:58:40 -0600 Subject: [PATCH] update udf (#95) --- macros/core/functions.py.sql | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/macros/core/functions.py.sql b/macros/core/functions.py.sql index 8474cb4..36d2fe4 100644 --- a/macros/core/functions.py.sql +++ b/macros/core/functions.py.sql @@ -132,6 +132,14 @@ def transform_base58_to_hex(base58): base_count = len(ALPHABET) num = 0 + leading_zeros = 0 + + for char in base58: + if char == '1': + leading_zeros += 1 + else: + break + for char in base58: num *= base_count if char in ALPHABET: @@ -144,7 +152,9 @@ def transform_base58_to_hex(base58): if len(hex_string) % 2 != 0: hex_string = '0' + hex_string - return '0x' + hex_string + hex_leading_zeros = '00' * leading_zeros + + return '0x' + hex_leading_zeros + hex_string {% endmacro %}