From 4156c30de119feb7d57747bef5b65a5f4b1aebba Mon Sep 17 00:00:00 2001 From: 1000101 Date: Mon, 18 Dec 2023 01:47:41 +0100 Subject: [PATCH] feat(cip-1694): epochs parameters --- src/routes/epochs/latest/parameters.ts | 5 +- src/routes/epochs/number/parameters.ts | 5 +- src/sql/epochs/epochs_latest_parameters.sql | 55 ++++++++++++++++----- src/sql/epochs/epochs_number_parameters.sql | 55 ++++++++++++++++----- 4 files changed, 92 insertions(+), 28 deletions(-) diff --git a/src/routes/epochs/latest/parameters.ts b/src/routes/epochs/latest/parameters.ts index 407da9c7..cf3b6bea 100644 --- a/src/routes/epochs/latest/parameters.ts +++ b/src/routes/epochs/latest/parameters.ts @@ -1,4 +1,4 @@ -import { getSchemaForEndpoint } from '@blockfrost/openapi'; +//import { getSchemaForEndpoint } from '@blockfrost/openapi'; import { FastifyInstance } from 'fastify'; import { SQLQuery } from '../../../sql/index.js'; @@ -12,7 +12,8 @@ async function route(fastify: FastifyInstance) { fastify.route({ url: '/epochs/latest/parameters', method: 'GET', - schema: getSchemaForEndpoint('/epochs/latest/parameters'), + // TODO: once it gets into openapi + //schema: getSchemaForEndpoint('/epochs/latest/parameters'), handler: async (_request, reply) => { const clientDbSync = await getDbSync(fastify); diff --git a/src/routes/epochs/number/parameters.ts b/src/routes/epochs/number/parameters.ts index 1142fd57..ee3bc5ae 100644 --- a/src/routes/epochs/number/parameters.ts +++ b/src/routes/epochs/number/parameters.ts @@ -1,4 +1,4 @@ -import { getSchemaForEndpoint } from '@blockfrost/openapi'; +//import { getSchemaForEndpoint } from '@blockfrost/openapi'; import { FastifyInstance, FastifyRequest } from 'fastify'; import { SQLQuery } from '../../../sql/index.js'; @@ -13,7 +13,8 @@ async function route(fastify: FastifyInstance) { fastify.route({ url: '/epochs/:number/parameters', method: 'GET', - schema: getSchemaForEndpoint('/epochs/{number}/parameters'), + // TODO: once it gets into openapi + //schema: getSchemaForEndpoint('/epochs/{number}/parameters'), handler: async (request: FastifyRequest, reply) => { const clientDbSync = await getDbSync(fastify); diff --git a/src/sql/epochs/epochs_latest_parameters.sql b/src/sql/epochs/epochs_latest_parameters.sql index 811dded1..30a8b4fe 100644 --- a/src/sql/epochs/epochs_latest_parameters.sql +++ b/src/sql/epochs/epochs_latest_parameters.sql @@ -4,8 +4,10 @@ SELECT epoch_no AS "epoch", max_block_size AS "max_block_size", max_tx_size AS "max_tx_size", max_bh_size AS "max_block_header_size", - key_deposit::TEXT AS "key_deposit", -- cast to TEXT to avoid number overflow - pool_deposit::TEXT AS "pool_deposit", -- cast to TEXT to avoid number overflow + key_deposit::TEXT AS "key_deposit", + -- cast to TEXT to avoid number overflow + pool_deposit::TEXT AS "pool_deposit", + -- cast to TEXT to avoid number overflow max_epoch AS "e_max", optimal_pool_count AS "n_opt", influence AS "a0", @@ -15,23 +17,52 @@ SELECT epoch_no AS "epoch", extra_entropy AS "extra_entropy", protocol_major AS "protocol_major_ver", protocol_minor AS "protocol_minor_ver", - min_utxo_value::TEXT AS "min_utxo", -- cast to TEXT to avoid number overflow - min_pool_cost::TEXT AS "min_pool_cost", -- cast to TEXT to avoid number overflow + min_utxo_value::TEXT AS "min_utxo", + -- cast to TEXT to avoid number overflow + min_pool_cost::TEXT AS "min_pool_cost", + -- cast to TEXT to avoid number overflow encode(nonce, 'hex') AS "nonce", cm.costs AS "cost_models", price_mem AS "price_mem", price_step AS "price_step", - max_tx_ex_mem::TEXT AS "max_tx_ex_mem", -- cast to TEXT to avoid number overflow - max_tx_ex_steps::TEXT AS "max_tx_ex_steps", -- cast to TEXT to avoid number overflow - max_block_ex_mem::TEXT AS "max_block_ex_mem", -- cast to TEXT to avoid number overflow - max_block_ex_steps::TEXT AS "max_block_ex_steps", -- cast to TEXT to avoid number overflow - max_val_size::TEXT AS "max_val_size", -- cast to TEXT to avoid number overflow + max_tx_ex_mem::TEXT AS "max_tx_ex_mem", + -- cast to TEXT to avoid number overflow + max_tx_ex_steps::TEXT AS "max_tx_ex_steps", + -- cast to TEXT to avoid number overflow + max_block_ex_mem::TEXT AS "max_block_ex_mem", + -- cast to TEXT to avoid number overflow + max_block_ex_steps::TEXT AS "max_block_ex_steps", + -- cast to TEXT to avoid number overflow + max_val_size::TEXT AS "max_val_size", + -- cast to TEXT to avoid number overflow collateral_percent AS "collateral_percent", max_collateral_inputs AS "max_collateral_inputs", - coins_per_utxo_size::TEXT AS "coins_per_utxo_size", -- cast to TEXT to avoid number overflow - coins_per_utxo_size::TEXT AS "coins_per_utxo_word" -- deprecated + coins_per_utxo_size::TEXT AS "coins_per_utxo_size", + -- cast to TEXT to avoid number overflow + coins_per_utxo_size::TEXT AS "coins_per_utxo_word", + -- deprecated + pvt_motion_no_confidence AS "pvt_motion_no_confidence", + pvt_committee_normal AS "pvt_committee_normal", + pvt_committee_no_confidence AS "pvt_committee_no_confidence", + pvt_hard_fork_initiation AS "pvt_hard_fork_initiation", + dvt_motion_no_confidence AS "dvt_motion_no_confidence", + dvt_committee_normal AS "dvt_committee_normal", + dvt_committee_no_confidence AS "dvt_committee_no_confidence", + dvt_update_to_constitution AS "dvt_update_to_constitution", + dvt_hard_fork_initiation AS "dvt_hard_fork_initiation", + dvt_p_p_network_group AS "dvt_p_p_network_group", + dvt_p_p_economic_group AS "dvt_p_p_economic_group", + dvt_p_p_technical_group AS "dvt_p_p_technical_group", + dvt_p_p_gov_group AS "dvt_p_p_gov_group", + dvt_treasury_withdrawal AS "dvt_treasury_withdrawal", + committee_min_size AS "committee_min_size", + committee_max_term_length AS "committee_max_term_length", + gov_action_lifetime AS "gov_action_lifetime", + gov_action_deposit AS "gov_action_deposit", + drep_deposit AS "drep_deposit", + drep_activity AS "drep_activity" FROM epoch_param ep -LEFT JOIN cost_model cm ON (ep.cost_model_id = cm.id) + LEFT JOIN cost_model cm ON (ep.cost_model_id = cm.id) WHERE epoch_no = ( SELECT MAX(no) FROM epoch diff --git a/src/sql/epochs/epochs_number_parameters.sql b/src/sql/epochs/epochs_number_parameters.sql index cb32cf75..badec1f5 100644 --- a/src/sql/epochs/epochs_number_parameters.sql +++ b/src/sql/epochs/epochs_number_parameters.sql @@ -4,8 +4,10 @@ SELECT epoch_no AS "epoch", max_block_size AS "max_block_size", max_tx_size AS "max_tx_size", max_bh_size AS "max_block_header_size", - key_deposit::TEXT AS "key_deposit", -- cast to TEXT to avoid number overflow - pool_deposit::TEXT AS "pool_deposit", -- cast to TEXT to avoid number overflow + key_deposit::TEXT AS "key_deposit", + -- cast to TEXT to avoid number overflow + pool_deposit::TEXT AS "pool_deposit", + -- cast to TEXT to avoid number overflow max_epoch AS "e_max", optimal_pool_count AS "n_opt", influence AS "a0", @@ -15,21 +17,50 @@ SELECT epoch_no AS "epoch", extra_entropy AS "extra_entropy", protocol_major AS "protocol_major_ver", protocol_minor AS "protocol_minor_ver", - min_utxo_value::TEXT AS "min_utxo", -- cast to TEXT to avoid number overflow - min_pool_cost::TEXT AS "min_pool_cost", -- cast to TEXT to avoid number overflow + min_utxo_value::TEXT AS "min_utxo", + -- cast to TEXT to avoid number overflow + min_pool_cost::TEXT AS "min_pool_cost", + -- cast to TEXT to avoid number overflow encode(nonce, 'hex') AS "nonce", cm.costs AS "cost_models", price_mem AS "price_mem", price_step AS "price_step", - max_tx_ex_mem::TEXT AS "max_tx_ex_mem", -- cast to TEXT to avoid number overflow - max_tx_ex_steps::TEXT AS "max_tx_ex_steps", -- cast to TEXT to avoid number overflow - max_block_ex_mem::TEXT AS "max_block_ex_mem", -- cast to TEXT to avoid number overflow - max_block_ex_steps::TEXT AS "max_block_ex_steps", -- cast to TEXT to avoid number overflow - max_val_size::TEXT AS "max_val_size", -- cast to TEXT to avoid number overflow + max_tx_ex_mem::TEXT AS "max_tx_ex_mem", + -- cast to TEXT to avoid number overflow + max_tx_ex_steps::TEXT AS "max_tx_ex_steps", + -- cast to TEXT to avoid number overflow + max_block_ex_mem::TEXT AS "max_block_ex_mem", + -- cast to TEXT to avoid number overflow + max_block_ex_steps::TEXT AS "max_block_ex_steps", + -- cast to TEXT to avoid number overflow + max_val_size::TEXT AS "max_val_size", + -- cast to TEXT to avoid number overflow collateral_percent AS "collateral_percent", max_collateral_inputs AS "max_collateral_inputs", - coins_per_utxo_size::TEXT AS "coins_per_utxo_size", -- cast to TEXT to avoid number overflow - coins_per_utxo_size::TEXT AS "coins_per_utxo_word" -- deprecated + coins_per_utxo_size::TEXT AS "coins_per_utxo_size", + -- cast to TEXT to avoid number overflow + coins_per_utxo_size::TEXT AS "coins_per_utxo_word", + -- deprecated + pvt_motion_no_confidence AS "pvt_motion_no_confidence", + pvt_committee_normal AS "pvt_committee_normal", + pvt_committee_no_confidence AS "pvt_committee_no_confidence", + pvt_hard_fork_initiation AS "pvt_hard_fork_initiation", + dvt_motion_no_confidence AS "dvt_motion_no_confidence", + dvt_committee_normal AS "dvt_committee_normal", + dvt_committee_no_confidence AS "dvt_committee_no_confidence", + dvt_update_to_constitution AS "dvt_update_to_constitution", + dvt_hard_fork_initiation AS "dvt_hard_fork_initiation", + dvt_p_p_network_group AS "dvt_p_p_network_group", + dvt_p_p_economic_group AS "dvt_p_p_economic_group", + dvt_p_p_technical_group AS "dvt_p_p_technical_group", + dvt_p_p_gov_group AS "dvt_p_p_gov_group", + dvt_treasury_withdrawal AS "dvt_treasury_withdrawal", + committee_min_size AS "committee_min_size", + committee_max_term_length AS "committee_max_term_length", + gov_action_lifetime AS "gov_action_lifetime", + gov_action_deposit AS "gov_action_deposit", + drep_deposit AS "drep_deposit", + drep_activity AS "drep_activity" FROM epoch_param ep -LEFT JOIN cost_model cm ON (ep.cost_model_id = cm.id) + LEFT JOIN cost_model cm ON (ep.cost_model_id = cm.id) WHERE epoch_no = $1 \ No newline at end of file