File tree Expand file tree Collapse file tree 3 files changed +24
-3
lines changed
packages/sources/coinmetrics-lwba
test/integration/__snapshots__ Expand file tree Collapse file tree 3 files changed +24
-3
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' @chainlink/coinmetrics-lwba-adapter ' : minor
3
+ ---
4
+
5
+ Updates result to include mid
Original file line number Diff line number Diff line change @@ -2,6 +2,8 @@ import { makeConfig } from '@chainlink/coinmetrics-adapter/config'
2
2
import { endpoint } from '@chainlink/coinmetrics-adapter/endpoint/lwba'
3
3
import { expose , ServerInstance } from '@chainlink/external-adapter-framework'
4
4
import { Adapter } from '@chainlink/external-adapter-framework/adapter'
5
+ import { AdapterResponse } from '@chainlink/external-adapter-framework/util/types'
6
+ import { AdapterError } from '@chainlink/external-adapter-framework/validation/error'
5
7
6
8
export const config = makeConfig ( {
7
9
NAME : 'COINMETRICS_LWBA' ,
@@ -14,6 +16,20 @@ export const config = makeConfig({
14
16
15
17
const newEndpoint = Object . assign ( Object . create ( Object . getPrototypeOf ( endpoint ) ) , endpoint )
16
18
newEndpoint . aliases . push ( 'crypto' , 'price' )
19
+ const originalValidate = endpoint . customOutputValidation
20
+ newEndpoint . customOutputValidation = ( resp : AdapterResponse ) : AdapterError | undefined => {
21
+ const err = originalValidate ?.( resp )
22
+ if ( err ) {
23
+ return err
24
+ }
25
+ if ( ! resp . errorMessage ) {
26
+ const mid = ( resp . data as any ) ?. mid
27
+ if ( mid !== undefined ) {
28
+ resp . result = mid
29
+ }
30
+ }
31
+ return undefined // no validation error
32
+ }
17
33
18
34
export const adapter = new Adapter ( {
19
35
defaultEndpoint : newEndpoint . name ,
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ exports[`crypto-lwba websocket happy path returns a successful response 1`] = `
7
7
" bid" : 1562.3384315992228 ,
8
8
" mid" : 1562.3733948803842 ,
9
9
},
10
- " result" : null ,
10
+ " result" : 1562.3733948803842 ,
11
11
" statusCode" : 200 ,
12
12
" timestamps" : {
13
13
" providerDataReceivedUnixMs" : 1024 ,
@@ -24,7 +24,7 @@ exports[`crypto-lwba websocket happy path returns a successful response for cryp
24
24
" bid" : 1562.3384315992228 ,
25
25
" mid" : 1562.3733948803842 ,
26
26
},
27
- " result" : null ,
27
+ " result" : 1562.3733948803842 ,
28
28
" statusCode" : 200 ,
29
29
" timestamps" : {
30
30
" providerDataReceivedUnixMs" : 1024 ,
@@ -41,7 +41,7 @@ exports[`crypto-lwba websocket happy path returns a successful response for pric
41
41
" bid" : 1562.3384315992228 ,
42
42
" mid" : 1562.3733948803842 ,
43
43
},
44
- " result" : null ,
44
+ " result" : 1562.3733948803842 ,
45
45
" statusCode" : 200 ,
46
46
" timestamps" : {
47
47
" providerDataReceivedUnixMs" : 1024 ,
You can’t perform that action at this time.
0 commit comments