Skip to content

Commit

Permalink
Update specs/addendum to koios-1.0.11rc (#233)
Browse files Browse the repository at this point in the history
  • Loading branch information
hodlonaut authored and rdlrt committed Sep 11, 2023
1 parent c6465fd commit bf18ede
Show file tree
Hide file tree
Showing 13 changed files with 2,106 additions and 715 deletions.
17 changes: 9 additions & 8 deletions files/grest/rpc/script/datum_info.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
CREATE OR REPLACE FUNCTION grest.datum_info(_datum_hashes text [])
RETURNS TABLE (
hash text,
datum_hash text,
creation_tx_hash text,
value jsonb,
bytes text
)
Expand All @@ -13,14 +14,14 @@ BEGIN
FROM UNNEST(_datum_hashes) AS d_hash;
RETURN QUERY
SELECT
ENCODE(d.hash, 'hex'),
ENCODE(d.hash,'hex'),
ENCODE(tx.hash,'hex') AS creation_tx_hash,
d.value,
ENCODE(d.bytes, 'hex')
FROM
datum AS d
WHERE
d.hash = ANY(_datum_hashes_decoded);
ENCODE(d.bytes,'hex')
FROM datum AS d
INNER JOIN tx ON tx.id = d.tx_id
WHERE d.hash = ANY(_datum_hashes_decoded);
END;
$$;

COMMENT ON FUNCTION grest.datum_info IS 'Get information about a given data FROM hashes.'; -- noqa: LT01
COMMENT ON FUNCTION grest.datum_info IS 'Get information about a given datum FROM hashes.'; -- noqa: LT01
20 changes: 10 additions & 10 deletions files/grest/rpc/script/native_script_list.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@ CREATE OR REPLACE FUNCTION grest.native_script_list()
RETURNS TABLE (
script_hash text,
creation_tx_hash text,
type scripttype,
script jsonb
type text,
size word31type
)
LANGUAGE plpgsql
AS $$
BEGIN
RETURN QUERY
SELECT
ENCODE(script.hash, 'hex'),
ENCODE(tx.hash, 'hex'),
script.type,
script.json
FROM script
INNER JOIN tx ON tx.id = script.tx_id
WHERE script.type IN ('timelock', 'multisig');
ENCODE(s.hash, 'hex')::text AS script_hash,
ENCODE(tx.hash, 'hex')::text AS creation_tx_hash,
s.type::text AS type,
s.serialised_size AS size
FROM script AS s
INNER JOIN tx ON tx.id = s.tx_id
WHERE s.type IN ('timelock', 'multisig');
END;
$$;

COMMENT ON FUNCTION grest.native_script_list IS 'Get a list of all native(multisig/timelock) script hashes with creation tx hash, type and script in json format.'; --noqa: LT01
COMMENT ON FUNCTION grest.native_script_list IS 'Get a list of all native(multisig/timelock) script hashes with creation tx hash, type and script size.'; --noqa: LT01
18 changes: 11 additions & 7 deletions files/grest/rpc/script/plutus_script_list.sql
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
CREATE OR REPLACE FUNCTION grest.plutus_script_list()
RETURNS TABLE (
script_hash text,
creation_tx_hash text
creation_tx_hash text,
type text,
size word31type
)
LANGUAGE plpgsql
AS $$
BEGIN
RETURN QUERY
SELECT
ENCODE(script.hash, 'hex') AS script_hash,
ENCODE(tx.hash, 'hex') AS creation_tx_hash
FROM script
INNER JOIN tx ON tx.id = script.tx_id
WHERE script.type IN ('plutusV1', 'plutusV2');
ENCODE(s.hash,'hex')::text AS script_hash,
ENCODE(tx.hash,'hex')::text AS creation_tx_hash,
s.type::text AS type,
s.serialised_size AS size
FROM script AS s
INNER JOIN tx ON tx.id = s.tx_id
WHERE s.type IN ('plutusV1', 'plutusV2');
END;
$$;

COMMENT ON FUNCTION grest.plutus_script_list IS 'Get a list of all plutus script hashes with creation tx hash.'; --noqa: LT01
COMMENT ON FUNCTION grest.plutus_script_list IS 'Get a list of all plutus script hashes with creation tx hash.'; --noqa: LT01
32 changes: 32 additions & 0 deletions files/grest/rpc/script/script_info.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
CREATE OR REPLACE FUNCTION grest.script_info(_script_hashes text [])
RETURNS TABLE (
script_hash text,
creation_tx_hash text,
type text,
value jsonb,
bytes text,
size word31type
)
LANGUAGE plpgsql
AS $$
DECLARE
_script_hashes_decoded bytea[];
BEGIN
SELECT INTO _script_hashes_decoded ARRAY_AGG(DECODE(s_hash, 'hex'))
FROM UNNEST(_script_hashes) AS s_hash;
RETURN QUERY
SELECT
ENCODE(s.hash,'hex') AS script_hash,
ENCODE(tx.hash,'hex') AS creation_tx_hash,
s.type::text AS type,
s.json AS value,
ENCODE(s.bytes,'hex')::text AS bytes,
s.serialised_size AS size
FROM script AS s
INNER JOIN tx ON tx.id = s.tx_id
WHERE s.hash = ANY(_script_hashes_decoded)
;
END;
$$;

COMMENT ON FUNCTION grest.script_info IS 'Get information about a given script FROM hashes.'; -- noqa: LT01
Loading

0 comments on commit bf18ede

Please sign in to comment.