Skip to content

Commit ec75450

Browse files
committed
preserve 200/errored shape in multiReserves for outsideUpdateWindow
1 parent 7b08500 commit ec75450

3 files changed

Lines changed: 16 additions & 17 deletions

File tree

packages/composites/proof-of-reserves/src/endpoint/multiReserves.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { Config } from '../config'
44
import {
55
getOutsideUpdateWindowDetails,
66
isOutsideUpdateWindowResponse,
7-
makeOutsideUpdateWindowResponse,
87
} from '../utils/outsideUpdateWindow'
98
import type { TInputParameters as SingleTInputParameters } from './reserves'
109
import { execute as singleExecute } from './reserves'
@@ -49,19 +48,21 @@ export const execute: ExecuteWithConfig<Config> = async (input, context, config)
4948
),
5049
)
5150

52-
const outsideWindowResult = results.find((r) => isOutsideUpdateWindowResponse(r))
53-
if (outsideWindowResult) {
54-
return makeOutsideUpdateWindowResponse(
55-
jobRunID,
56-
getOutsideUpdateWindowDetails(outsideWindowResult) ?? 'Outside schedule window',
57-
)
58-
}
59-
6051
const result = results
6152
.map((result) => {
6253
if (result.statusCode != 200 || !result.result) {
54+
// Preserve outsideUpdateWindow fields in the error body so monitoring
55+
// can detect a planned window pause vs an unplanned failure, while
56+
// keeping the existing 200/errored response shape.
57+
const outsideWindowDetails = isOutsideUpdateWindowResponse(result)
58+
? {
59+
outsideUpdateWindow: true,
60+
outsideUpdateWindowDetails: getOutsideUpdateWindowDetails(result),
61+
}
62+
: {}
6363
throw new AdapterError({
6464
...result,
65+
...outsideWindowDetails,
6566
})
6667
} else {
6768
// Scaling everything up to 18 to preserve precision

packages/composites/proof-of-reserves/test/integration/__snapshots__/adapter.test.ts.snap

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -108,17 +108,15 @@ exports[`execute multiReserves endpoint view-function-multi-chain should return
108108

109109
exports[`execute multiReserves endpoint - schedule window should return outsideUpdateWindow response when any sub-reserve is outside schedule window 1`] = `
110110
{
111-
"data": {
111+
"error": {
112+
"message": "Unspecified error",
113+
"name": "AdapterError",
112114
"outsideUpdateWindow": true,
113115
"outsideUpdateWindowDetails": "Outside schedule window. Current UTC: 2022-01-01T11:11:11.111Z, window: 2022-01-01T12:00:00.000Z - 2022-01-01T13:00:00.000Z",
114-
"result": null,
115-
"statusCode": 503,
116116
},
117117
"jobRunID": "1",
118-
"outsideUpdateWindow": true,
119-
"outsideUpdateWindowDetails": "Outside schedule window. Current UTC: 2022-01-01T11:11:11.111Z, window: 2022-01-01T12:00:00.000Z - 2022-01-01T13:00:00.000Z",
120-
"result": null,
121-
"statusCode": 503,
118+
"status": "errored",
119+
"statusCode": 200,
122120
}
123121
`;
124122

packages/composites/proof-of-reserves/test/integration/adapter.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ describe('execute', () => {
472472
.set('Accept', '*/*')
473473
.set('Content-Type', 'application/json')
474474
.expect('Content-Type', /json/)
475-
.expect(503)
475+
.expect(200)
476476
expect(response.body).toMatchSnapshot()
477477
})
478478
})

0 commit comments

Comments
 (0)