Skip to content

Commit

Permalink
New market status adapter endpoint (#263)
Browse files Browse the repository at this point in the history
* New market status endpoint

* Run prettier
  • Loading branch information
martin-cll authored Jul 31, 2024
1 parent 970e2af commit d1bd1d5
Show file tree
Hide file tree
Showing 5 changed files with 567 additions and 477 deletions.
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodejs 22.1.0
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"pino-pretty": "9.1.0",
"prom-client": "13.2.0",
"redlock": "5.0.0-beta.2",
"yeoman-generator": "3.1.1",
"ws": "8.9.0"
"ws": "8.9.0",
"yeoman-generator": "3.1.1"
},
"scripts": {
"build": "mkdir -p ./dist/src && cp package.json dist/src && cp README.md dist/src && tsc && yarn build-generator",
Expand All @@ -39,6 +39,7 @@
"@types/node": "18.15.13",
"@types/sinonjs__fake-timers": "8.1.2",
"@types/ws": "8.5.3",
"@types/yeoman-generator": "5.2.11",
"@typescript-eslint/eslint-plugin": "5.59.0",
"@typescript-eslint/parser": "5.59.0",
"ava": "5.2.0",
Expand All @@ -52,8 +53,7 @@
"ts-node": "10.9.1",
"ts-node-dev": "2.0.0",
"typedoc": "0.23.21",
"typescript": "5.0.4",
"@types/yeoman-generator": "5.2.11"
"typescript": "5.0.4"
},
"prettier": {
"semi": false,
Expand Down
5 changes: 3 additions & 2 deletions src/adapter/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export * from './basic'
export * from './price'
export * from './endpoint'
export * from './types'
export * from './lwba'
export * from './market-status'
export * from './price'
export * from './types'
56 changes: 56 additions & 0 deletions src/adapter/market-status.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { TransportGenerics } from '../transports'
import { InputParametersDefinition } from '../validation/input-params'
import { AdapterEndpoint } from './endpoint'

/**
* Type for the base input parameter config that any [[MarketStatusEndpoint]] must extend
*/
export type MarketStatusEndpointInputParametersDefinition = InputParametersDefinition & {
market: {
aliases: readonly []
type: 'string'
description: 'The name of the market'
required: boolean
}
}

/**
* Base input parameter config that any [[MarketStatusEndpoint]] must extend
*/
export const marketStatusEndpointInputParametersDefinition = {
market: {
aliases: [],
type: 'string',
description: 'The name of the market',
required: true,
},
} as const satisfies MarketStatusEndpointInputParametersDefinition

export enum MarketStatus {
UNKNOWN = 0,
CLOSED = 1,
OPEN = 2,
}

export type MarketStatusResultResponse = {
Result: MarketStatus
Data: {
result: MarketStatus
}
}

/**
* Helper type structure that contains the different types passed to the generic parameters of a PriceEndpoint
*/
export type MarketStatusEndpointGenerics = TransportGenerics & {
Parameters: MarketStatusEndpointInputParametersDefinition
Response: MarketStatusResultResponse
}

/**
* A MarketStatusEndpoint is a specific type of AdapterEndpoint. Meant to comply with standard practices for
* Data Feeds, its InputParameters must extend the basic ones (base).
*/
export class MarketStatusEndpoint<
T extends MarketStatusEndpointGenerics,
> extends AdapterEndpoint<T> {}
Loading

0 comments on commit d1bd1d5

Please sign in to comment.