@@ -4,19 +4,25 @@ import { StatusCodes } from "http-status-codes";
4
4
import { updateConfiguration } from "../../../../db/configuration/updateConfiguration" ;
5
5
import { getConfig } from "../../../../utils/cache/getConfig" ;
6
6
import { 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" ;
9
11
10
- const BodySchema = Type . Object ( {
12
+ const requestBodySchema = Type . Object ( {
11
13
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 ,
13
19
} ) ;
14
20
15
21
export async function updateContractSubscriptionsConfiguration (
16
22
fastify : FastifyInstance ,
17
23
) {
18
24
fastify . route < {
19
- Body : Static < typeof BodySchema > ;
25
+ Body : Static < typeof requestBodySchema > ;
20
26
} > ( {
21
27
method : "POST" ,
22
28
url : "/configuration/contract-subscriptions" ,
@@ -25,34 +31,34 @@ export async function updateContractSubscriptionsConfiguration(
25
31
description : "Update the configuration for Contract Subscriptions" ,
26
32
tags : [ "Configuration" ] ,
27
33
operationId : "updateContractSubscriptionsConfiguration" ,
28
- body : BodySchema ,
34
+ body : requestBodySchema ,
29
35
response : {
30
36
...standardResponseSchema ,
31
- [ StatusCodes . OK ] : ReplySchema ,
37
+ [ StatusCodes . OK ] : responseSchema ,
32
38
} ,
33
39
} ,
34
40
handler : async ( req , res ) => {
35
- const { maxBlocksToIndex, contractSubscriptionsRetryDelaySeconds } =
41
+ const { maxBlocksToIndex, contractSubscriptionsRequeryDelaySeconds } =
36
42
req . body ;
37
43
38
- if ( ! maxBlocksToIndex && ! contractSubscriptionsRetryDelaySeconds ) {
44
+ if ( ! maxBlocksToIndex && ! contractSubscriptionsRequeryDelaySeconds ) {
39
45
throw createCustomError (
40
46
"At least one parameter is required" ,
41
47
StatusCodes . BAD_REQUEST ,
42
48
"BAD_REQUEST" ,
43
49
) ;
44
50
}
45
51
46
- if ( contractSubscriptionsRetryDelaySeconds ) {
52
+ if ( contractSubscriptionsRequeryDelaySeconds ) {
47
53
try {
48
- contractSubscriptionsRetryDelaySeconds . split ( "," ) . forEach ( ( d ) => {
54
+ contractSubscriptionsRequeryDelaySeconds . split ( "," ) . forEach ( ( d ) => {
49
55
if ( Number . isNaN ( parseInt ( d ) ) ) {
50
56
throw "Invalid number" ;
51
57
}
52
58
} ) ;
53
59
} catch {
54
60
throw createCustomError (
55
- 'At least one integer "contractSubscriptionsRetryDelaySeconds " is required' ,
61
+ 'At least one integer "contractSubscriptionsRequeryDelaySeconds " is required' ,
56
62
StatusCodes . BAD_REQUEST ,
57
63
"BAD_REQUEST" ,
58
64
) ;
@@ -61,15 +67,16 @@ export async function updateContractSubscriptionsConfiguration(
61
67
62
68
await updateConfiguration ( {
63
69
maxBlocksToIndex,
64
- contractSubscriptionsRetryDelaySeconds,
70
+ contractSubscriptionsRetryDelaySeconds :
71
+ contractSubscriptionsRequeryDelaySeconds ,
65
72
} ) ;
66
73
const config = await getConfig ( false ) ;
67
74
68
75
res . status ( 200 ) . send ( {
69
76
result : {
70
77
maxBlocksToIndex : config . maxBlocksToIndex ,
71
- contractSubscriptionsRetryDelaySeconds :
72
- config . contractSubscriptionsRetryDelaySeconds ,
78
+ contractSubscriptionsRequeryDelaySeconds :
79
+ config . contractSubscriptionsRequeryDelaySeconds ,
73
80
} ,
74
81
} ) ;
75
82
} ,
0 commit comments