Skip to content

Commit 6849d0b

Browse files
Data Engine: Adds result selection and scaling (#4736)
1 parent 4ca2a61 commit 6849d0b

18 files changed

Lines changed: 441 additions & 57 deletions

File tree

.changeset/polite-frogs-pull.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@chainlink/data-engine-adapter': minor
3+
---
4+
5+
Add result selection via resultPath and decimal scaling via decimals params to data-engine WS transports.

.pnp.cjs

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/sources/data-engine/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"dependencies": {
3939
"@chainlink/data-streams-sdk": "1.2.0",
4040
"@chainlink/external-adapter-framework": "2.11.6",
41+
"decimal.js": "^10.5.0",
4142
"tslib": "2.4.1"
4243
}
4344
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* Shared input parameter definitions used across all data-engine endpoints.
3+
*/
4+
export const commonInputParams = {
5+
feedId: {
6+
required: true,
7+
type: 'string',
8+
description: 'The feed ID to subscribe to',
9+
},
10+
resultPath: {
11+
required: false,
12+
type: 'string',
13+
description: 'The data field to populate the top-level result',
14+
},
15+
decimals: {
16+
required: false,
17+
type: 'number',
18+
description: 'Number of decimals to scale the resultPath value to (from native 18)',
19+
},
20+
} as const

packages/sources/data-engine/src/endpoint/cryptoV3.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,11 @@ import { AdapterEndpoint } from '@chainlink/external-adapter-framework/adapter'
22
import { InputParameters } from '@chainlink/external-adapter-framework/validation'
33
import { config } from '../config'
44
import { cryptoV3Transport } from '../transport/cryptoV3'
5+
import { commonInputParams } from './common'
56

67
export const inputParameters = new InputParameters(
78
{
8-
feedId: {
9-
required: true,
10-
type: 'string',
11-
description: 'The feedId for crypto feed with v3 schema',
12-
},
9+
...commonInputParams,
1310
},
1411
[
1512
{
@@ -21,7 +18,7 @@ export const inputParameters = new InputParameters(
2118
export type BaseEndpointTypes = {
2219
Parameters: typeof inputParameters.definition
2320
Response: {
24-
Result: null
21+
Result: string | null
2522
Data: {
2623
bid: string
2724
ask: string

packages/sources/data-engine/src/endpoint/deutscheBoerseV11.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,11 @@ import { AdapterEndpoint } from '@chainlink/external-adapter-framework/adapter'
22
import { InputParameters } from '@chainlink/external-adapter-framework/validation'
33
import { config } from '../config'
44
import { deutscheBoerseV11Transport } from '../transport/deutscheBoerseV11'
5+
import { commonInputParams } from './common'
56

67
export const inputParameters = new InputParameters(
78
{
8-
feedId: {
9-
required: true,
10-
type: 'string',
11-
description: 'The feedId for Deutsche Boerse feed with v11 schema',
12-
},
9+
...commonInputParams,
1310
},
1411
[
1512
{
@@ -21,7 +18,7 @@ export const inputParameters = new InputParameters(
2118
export type BaseEndpointTypes = {
2219
Parameters: typeof inputParameters.definition
2320
Response: {
24-
Result: null
21+
Result: string | null
2522
Data: {
2623
mid: string
2724
lastSeenTimestampNs: string

packages/sources/data-engine/src/endpoint/rwaV8.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,11 @@ import { AdapterEndpoint } from '@chainlink/external-adapter-framework/adapter'
22
import { InputParameters } from '@chainlink/external-adapter-framework/validation'
33
import { config } from '../config'
44
import { rwaV8Transport } from '../transport/rwaV8'
5+
import { commonInputParams } from './common'
56

67
export const inputParameters = new InputParameters(
78
{
8-
feedId: {
9-
required: true,
10-
type: 'string',
11-
description: 'The feedId for RWA feed with v8 schema',
12-
},
9+
...commonInputParams,
1310
},
1411
[
1512
{
@@ -21,7 +18,7 @@ export const inputParameters = new InputParameters(
2118
export type BaseEndpointTypes = {
2219
Parameters: typeof inputParameters.definition
2320
Response: {
24-
Result: null
21+
Result: string | null
2522
Data: {
2623
midPrice: string
2724
marketStatus: number

packages/sources/data-engine/src/transport/cryptoV3.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { DecodedV3Report } from '@chainlink/data-streams-sdk'
22
import { BaseEndpointTypes } from '../endpoint/cryptoV3'
3-
import { createDataEngineTransport, DECIMALS } from './wsTransportBase'
3+
import { DECIMALS } from './utils'
4+
import { createDataEngineTransport } from './wsTransportBase'
45

56
export const cryptoV3Transport = createDataEngineTransport<BaseEndpointTypes, DecodedV3Report>({
67
schemaVersion: 'V3',

packages/sources/data-engine/src/transport/deutscheBoerseV11.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { DecodedV11Report } from '@chainlink/data-streams-sdk'
22
import { BaseEndpointTypes } from '../endpoint/deutscheBoerseV11'
3-
import { createDataEngineTransport, DECIMALS } from './wsTransportBase'
3+
import { DECIMALS } from './utils'
4+
import { createDataEngineTransport } from './wsTransportBase'
45

56
export const deutscheBoerseV11Transport = createDataEngineTransport<
67
BaseEndpointTypes,

packages/sources/data-engine/src/transport/rwaV8.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { DecodedV8Report } from '@chainlink/data-streams-sdk'
22
import { BaseEndpointTypes } from '../endpoint/rwaV8'
3-
import { createDataEngineTransport, DECIMALS } from './wsTransportBase'
3+
import { DECIMALS } from './utils'
4+
import { createDataEngineTransport } from './wsTransportBase'
45

56
export const rwaV8Transport = createDataEngineTransport<BaseEndpointTypes, DecodedV8Report>({
67
schemaVersion: 'V8',

0 commit comments

Comments
 (0)