From da090554869bce33a6202a40a979936a1f843a70 Mon Sep 17 00:00:00 2001 From: mainnet-pat Date: Tue, 17 Dec 2024 20:34:09 +0000 Subject: [PATCH 1/2] Add 'locking_bytecode_hex' computed field --- .../metadata/databases/default/tables/public_output.yaml | 6 ++++++ .../migrations/default/1616195337538_init/up.sql | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/images/hasura/hasura-data/metadata/databases/default/tables/public_output.yaml b/images/hasura/hasura-data/metadata/databases/default/tables/public_output.yaml index be40ea2..327e34e 100644 --- a/images/hasura/hasura-data/metadata/databases/default/tables/public_output.yaml +++ b/images/hasura/hasura-data/metadata/databases/default/tables/public_output.yaml @@ -22,6 +22,11 @@ computed_fields: function: name: output_locking_bytecode_pattern schema: public + - name: locking_bytecode_hex + definition: + function: + name: output_locking_bytecode_hex + schema: public select_permissions: - role: public permission: @@ -36,5 +41,6 @@ select_permissions: - nonfungible_token_commitment computed_fields: - locking_bytecode_pattern + - locking_bytecode_hex filter: {} limit: 5000 diff --git a/images/hasura/hasura-data/migrations/default/1616195337538_init/up.sql b/images/hasura/hasura-data/migrations/default/1616195337538_init/up.sql index b3c9e28..33fd9da 100644 --- a/images/hasura/hasura-data/migrations/default/1616195337538_init/up.sql +++ b/images/hasura/hasura-data/migrations/default/1616195337538_init/up.sql @@ -525,6 +525,13 @@ AS $$ $$; COMMENT ON FUNCTION output_locking_bytecode_pattern (output) IS 'Extract the first byte of each instruction for the locking bytecode of an output. The resulting pattern excludes the contents of pushed values such that similar bytecode sequences produce the same pattern.'; +CREATE FUNCTION output_locking_bytecode_hex(output_row output) RETURNS text + LANGUAGE sql IMMUTABLE +AS $$ + SELECT encode($1.locking_bytecode, 'hex'); +$$; +COMMENT ON FUNCTION output_locking_bytecode_hex (output) IS 'Transform output locking bytecode to hex string.'; + CREATE FUNCTION input_unlocking_bytecode_pattern(input_row input) RETURNS text LANGUAGE sql IMMUTABLE AS $$ From aed9567b74ae8ee6686c976a0a50a45b4587d7a5 Mon Sep 17 00:00:00 2001 From: mainnet-pat Date: Wed, 18 Dec 2024 09:02:20 +0000 Subject: [PATCH 2/2] Add 'unlocking_bytecode_hex' computed field --- .../metadata/databases/default/tables/public_input.yaml | 6 ++++++ .../migrations/default/1616195337538_init/up.sql | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/images/hasura/hasura-data/metadata/databases/default/tables/public_input.yaml b/images/hasura/hasura-data/metadata/databases/default/tables/public_input.yaml index afa0264..8bb6c9d 100644 --- a/images/hasura/hasura-data/metadata/databases/default/tables/public_input.yaml +++ b/images/hasura/hasura-data/metadata/databases/default/tables/public_input.yaml @@ -35,6 +35,11 @@ computed_fields: function: name: input_unlocking_bytecode_pattern schema: public + - name: unlocking_bytecode_hex + definition: + function: + name: input_unlocking_bytecode_hex + schema: public - name: value_satoshis definition: function: @@ -53,6 +58,7 @@ select_permissions: computed_fields: - redeem_bytecode_pattern - unlocking_bytecode_pattern + - unlocking_bytecode_hex - value_satoshis filter: {} limit: 1000 diff --git a/images/hasura/hasura-data/migrations/default/1616195337538_init/up.sql b/images/hasura/hasura-data/migrations/default/1616195337538_init/up.sql index 33fd9da..0f14fa0 100644 --- a/images/hasura/hasura-data/migrations/default/1616195337538_init/up.sql +++ b/images/hasura/hasura-data/migrations/default/1616195337538_init/up.sql @@ -539,6 +539,13 @@ AS $$ $$; COMMENT ON FUNCTION input_unlocking_bytecode_pattern (input) IS 'Extract the first byte of each instruction for the unlocking bytecode of an input. The resulting pattern excludes the contents of pushed values such that similar bytecode sequences produce the same pattern.'; +CREATE FUNCTION input_unlocking_bytecode_hex(input_row input) RETURNS text + LANGUAGE sql IMMUTABLE +AS $$ + SELECT encode($1.unlocking_bytecode, 'hex'); +$$; +COMMENT ON FUNCTION input_unlocking_bytecode_hex (input) IS 'Transform input unlocking bytecode to hex string.'; + CREATE FUNCTION parse_bytecode_pattern_with_pushdata_lengths(bytecode bytea) RETURNS bytea LANGUAGE plpgsql IMMUTABLE AS $$