mirror of
https://github.com/FlipsideCrypto/aleo-models.git
synced 2026-02-06 09:26:46 +00:00
switched to FSC udfs and deleted custom udf
This commit is contained in:
parent
003009fa77
commit
14647d1bd2
@ -1,24 +0,0 @@
|
||||
{% macro create_decode_128_udf() %}
|
||||
CREATE OR REPLACE FUNCTION {{ target.database }}.{{ target.schema }}.decode_u128_to_ascii(input STRING)
|
||||
RETURNS STRING
|
||||
LANGUAGE JAVASCRIPT
|
||||
AS
|
||||
$$
|
||||
if (!INPUT) return null;
|
||||
|
||||
// Remove any 'u128' suffix if present
|
||||
let cleanInput = INPUT.replace('u128', '').trim();
|
||||
|
||||
// Convert the numeric string to a BigInt
|
||||
let num = BigInt(cleanInput);
|
||||
|
||||
// Convert to ASCII
|
||||
let result = '';
|
||||
while (num > 0n) {
|
||||
result = String.fromCharCode(Number(num & 0xFFn)) + result;
|
||||
num = num >> 8n;
|
||||
}
|
||||
|
||||
return result.trim();
|
||||
$$;
|
||||
{% endmacro %}
|
||||
@ -65,7 +65,7 @@ cleaned_strings as (
|
||||
tx_id,
|
||||
block_id,
|
||||
block_timestamp,
|
||||
split_part(token_id_raw, 'field', 1) as token_id,
|
||||
token_id_raw,
|
||||
split_part(name_raw, 'u', 1) as name_encoded,
|
||||
split_part(symbol_raw, 'u', 1) as symbol_encoded,
|
||||
split_part(decimals_raw, 'u', 1) as decimals,
|
||||
@ -79,9 +79,9 @@ select
|
||||
tx_id,
|
||||
block_id,
|
||||
block_timestamp,
|
||||
token_id,
|
||||
decode_u128_to_ascii(name_encoded) as token_name,
|
||||
decode_u128_to_ascii(symbol_encoded) as symbol,
|
||||
token_id_raw as token_id,
|
||||
utils.udf_hex_to_string(substr(utils.udf_int_to_hex(name_encoded), 3)) as token_name,
|
||||
utils.udf_hex_to_string(substr(utils.udf_int_to_hex(symbol_encoded), 3)) as symbol,
|
||||
decimals,
|
||||
max_supply,
|
||||
external_auth_required,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user