@@ -4,19 +4,25 @@ import { StatusCodes } from "http-status-codes";
44import { updateConfiguration } from "../../../../db/configuration/updateConfiguration" ;
55import { getConfig } from "../../../../utils/cache/getConfig" ;
66import { createCustomError } from "../../../middleware/error" ;
7- import { standardResponseSchema } from "../../../schemas/sharedApiSchemas" ;
8- import { ReplySchema } from "./get" ;
7+ import {
8+ contractSubscriptionConfigurationSchema ,
9+ standardResponseSchema ,
10+ } from "../../../schemas/sharedApiSchemas" ;
911
10- const BodySchema = Type . Object ( {
12+ const requestBodySchema = Type . Object ( {
1113 maxBlocksToIndex : Type . Optional ( Type . Number ( { minimum : 1 , maximum : 25 } ) ) ,
12- contractSubscriptionsRetryDelaySeconds : Type . Optional ( Type . String ( ) ) ,
14+ contractSubscriptionsRequeryDelaySeconds : Type . Optional ( Type . String ( ) ) ,
15+ } ) ;
16+
17+ const responseSchema = Type . Object ( {
18+ result : contractSubscriptionConfigurationSchema ,
1319} ) ;
1420
1521export async function updateContractSubscriptionsConfiguration (
1622 fastify : FastifyInstance ,
1723) {
1824 fastify . route < {
19- Body : Static < typeof BodySchema > ;
25+ Body : Static < typeof requestBodySchema > ;
2026 } > ( {
2127 method : "POST" ,
2228 url : "/configuration/contract-subscriptions" ,
@@ -25,34 +31,34 @@ export async function updateContractSubscriptionsConfiguration(
2531 description : "Update the configuration for Contract Subscriptions" ,
2632 tags : [ "Configuration" ] ,
2733 operationId : "updateContractSubscriptionsConfiguration" ,
28- body : BodySchema ,
34+ body : requestBodySchema ,
2935 response : {
3036 ...standardResponseSchema ,
31- [ StatusCodes . OK ] : ReplySchema ,
37+ [ StatusCodes . OK ] : responseSchema ,
3238 } ,
3339 } ,
3440 handler : async ( req , res ) => {
35- const { maxBlocksToIndex, contractSubscriptionsRetryDelaySeconds } =
41+ const { maxBlocksToIndex, contractSubscriptionsRequeryDelaySeconds } =
3642 req . body ;
3743
38- if ( ! maxBlocksToIndex && ! contractSubscriptionsRetryDelaySeconds ) {
44+ if ( ! maxBlocksToIndex && ! contractSubscriptionsRequeryDelaySeconds ) {
3945 throw createCustomError (
4046 "At least one parameter is required" ,
4147 StatusCodes . BAD_REQUEST ,
4248 "BAD_REQUEST" ,
4349 ) ;
4450 }
4551
46- if ( contractSubscriptionsRetryDelaySeconds ) {
52+ if ( contractSubscriptionsRequeryDelaySeconds ) {
4753 try {
48- contractSubscriptionsRetryDelaySeconds . split ( "," ) . forEach ( ( d ) => {
54+ contractSubscriptionsRequeryDelaySeconds . split ( "," ) . forEach ( ( d ) => {
4955 if ( Number . isNaN ( parseInt ( d ) ) ) {
5056 throw "Invalid number" ;
5157 }
5258 } ) ;
5359 } catch {
5460 throw createCustomError (
55- 'At least one integer "contractSubscriptionsRetryDelaySeconds " is required' ,
61+ 'At least one integer "contractSubscriptionsRequeryDelaySeconds " is required' ,
5662 StatusCodes . BAD_REQUEST ,
5763 "BAD_REQUEST" ,
5864 ) ;
@@ -61,15 +67,16 @@ export async function updateContractSubscriptionsConfiguration(
6167
6268 await updateConfiguration ( {
6369 maxBlocksToIndex,
64- contractSubscriptionsRetryDelaySeconds,
70+ contractSubscriptionsRetryDelaySeconds :
71+ contractSubscriptionsRequeryDelaySeconds ,
6572 } ) ;
6673 const config = await getConfig ( false ) ;
6774
6875 res . status ( 200 ) . send ( {
6976 result : {
7077 maxBlocksToIndex : config . maxBlocksToIndex ,
71- contractSubscriptionsRetryDelaySeconds :
72- config . contractSubscriptionsRetryDelaySeconds ,
78+ contractSubscriptionsRequeryDelaySeconds :
79+ config . contractSubscriptionsRequeryDelaySeconds ,
7380 } ,
7481 } ) ;
7582 } ,
0 commit comments