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 1899f4e
Show file tree
Hide file tree
Showing 9 changed files with 489 additions and 160 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
10 changes: 10 additions & 0 deletions specs/templates/2-api-params.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,16 @@ parameters:
in: query
required: false
allowEmptyValue: true
_extended:
deprecated: false
name: _extended
description: Controls whether or not certain optional fields supported by a given endpoint are populated as a part of the call
schema:
type: boolean
example: "false"
in: query
required: false
allowEmptyValue: true
_history:
deprecated: false
name: _history
Expand Down
117 changes: 117 additions & 0 deletions specs/templates/3-api-requestBodies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,30 @@ requestBodies:
_addresses:
- ##payment_addresses1_rb##
- ##payment_addresses2_rb##
payment_addresses_with_extended:
content:
application/json:
schema:
required:
- _addresses
type: object
properties:
_addresses:
format: text
type: array
items:
type: string
description: Array of Cardano payment address(es) in bech32 format
_extended:
format: boolean
type: boolean
description: Controls whether or not certain optional fields supported by a given endpoint are populated as a part of the call
example:
_addresses:
- ##payment_addresses1_rb##
- ##payment_addresses2_rb##
_extended:
- "true"
address_txs:
content:
application/json:
Expand Down Expand Up @@ -107,6 +131,31 @@ requestBodies:
_stake_addresses:
- ##stake_addresses1_rb##
- ##stake_addresses2_rb##
todo: add examples referencing all existing param

stake_addresses_with_extended:
content:
application/json:
schema:
required:
- _stake_addresses
type: object
properties:
_stake_addresses:
format: text
type: array
items:
type: string
description: Array of Cardano stake address(es) in bech32 format
_extended:
format: boolean
type: boolean
description: Controls whether or not certain optional fields supported by a given endpoint are populated as a part of the call
example:
_stake_addresses:
- ##stake_addresses1_rb##
- ##stake_addresses2_rb##
_extended: "true"
stake_addresses:
content:
application/json:
Expand Down Expand Up @@ -162,10 +211,15 @@ requestBodies:
items:
type: string
description: Array of Cardano payment credential(s) in hex format
_extended:
format: boolean
type: boolean
description: Controls whether or not certain optional fields supported by a given endpoint are populated as a part of the call
example:
_payment_credentials:
- ##credential_txs_payment_credentials1_rb##
- ##credential_txs_payment_credentials2_rb##
_extended: true
tx_ids:
content:
application/json:
Expand Down Expand Up @@ -227,6 +281,22 @@ requestBodies:
- ##pool_ids_pool_bech32_ids1_rb##
- ##pool_ids_pool_bech32_ids2_rb##
- ##pool_ids_pool_bech32_ids3_rb##
script_hashes:
content:
application/json:
schema:
type: object
properties:
_script_hashes:
format: text
type: array
items:
type: string
description: Array of Cardano script hashes
example:
_script_hashes:
- ##script_hashes1_rb##
- ##script_hashes2_rb##
datum_hashes:
content:
application/json:
Expand Down Expand Up @@ -263,3 +333,50 @@ requestBodies:
_asset_list:
- ##asset1_rb##
- ##asset2_rb##
asset_list_with_extended:
content:
application/json:
schema:
required:
- _asset_list
type: object
properties:
_asset_list:
format: text
type: array
description: Array of array of policy ID and asset names (hex)
items:
type: array
items:
type: string
_extended:
format: boolean
type: boolean
description: Controls whether or not certain optional fields supported by a given endpoint are populated as a part of the call
example:
_asset_list:
- ##asset1_rb##
- ##asset2_rb##
_extended: true
utxo_refs_with_extended:
content:
application/json:
schema:
required:
- _utxo_refs
type: object
properties:
_utxo_refs:
format: text
type: array
items:
type: string
description: Array of Cardano utxo references in the form "hash#index"
_extended:
format: boolean
type: boolean
description: Controls whether or not certain optional fields supported by a given endpoint are populated as a part of the call
example:
_utxo_refs:
- ##utxo_ref1_rb##
- ##utxo_ref2_rb##
Loading

0 comments on commit 1899f4e

Please sign in to comment.