From a4ff4a46fbc96d1769e4862600d8d2a166cbcae3 Mon Sep 17 00:00:00 2001 From: drethereum Date: Thu, 20 Jun 2024 17:27:19 -0600 Subject: [PATCH] leading zeroes --- macros/streamline/functions.py.sql | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/macros/streamline/functions.py.sql b/macros/streamline/functions.py.sql index 8fd9a46..8b1d2da 100644 --- a/macros/streamline/functions.py.sql +++ b/macros/streamline/functions.py.sql @@ -189,6 +189,14 @@ def transform_base58_to_hex(input): base_count = len(ALPHABET) num = 0 + leading_zeros = 0 + + for char in input: + if char == '1': + leading_zeros += 1 + else: + break + for char in input: num *= base_count if char in ALPHABET: @@ -201,7 +209,9 @@ def transform_base58_to_hex(input): 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 %}