@chainlink/external-adapter-framework 0.0.12 → 0.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintignore +1 -0
- package/.github/README.MD +35 -10
- package/.github/workflows/label.yaml +39 -0
- package/.github/workflows/publish.yaml +0 -3
- package/dist/examples/coingecko/test/e2e/adapter.test.ts.js +82953 -0
- package/dist/examples/coingecko/test/integration/adapter.test.ts.js +91672 -0
- package/dist/main.js +72703 -0
- package/jest.config.js +5 -0
- package/package.json +14 -3
- package/src/config/provider-limits.ts +14 -17
- package/src/examples/coingecko/src/config/index.ts +12 -0
- package/src/examples/coingecko/src/config/overrides.json +10826 -0
- package/src/examples/coingecko/src/cryptoUtils.ts +88 -0
- package/src/examples/coingecko/src/endpoint/coins.ts +54 -0
- package/src/examples/coingecko/src/endpoint/crypto-marketcap.ts +66 -0
- package/src/examples/coingecko/src/endpoint/crypto-volume.ts +66 -0
- package/src/examples/coingecko/src/endpoint/crypto.ts +63 -0
- package/src/examples/coingecko/src/endpoint/dominance.ts +40 -0
- package/src/examples/coingecko/src/endpoint/global-marketcap.ts +40 -0
- package/src/examples/coingecko/src/endpoint/index.ts +6 -0
- package/src/examples/coingecko/src/globalUtils.ts +78 -0
- package/src/examples/coingecko/src/index.ts +17 -0
- package/src/examples/coingecko/test/e2e/adapter.test.ts +278 -0
- package/src/examples/coingecko/test/integration/__snapshots__/adapter.test.ts.snap +15 -0
- package/src/examples/coingecko/test/integration/adapter.test.ts +281 -0
- package/src/examples/coingecko/test/integration/capturedRequests.json +1 -0
- package/src/examples/coingecko/test/integration/fixtures.ts +42 -0
- package/src/examples/{coingecko → coingecko-old}/batch-warming.ts +1 -0
- package/src/examples/{coingecko → coingecko-old}/index.ts +0 -0
- package/src/examples/{coingecko → coingecko-old}/rest.ts +0 -0
- package/src/transports/batch-warming.ts +7 -2
- package/src/transports/rest.ts +5 -1
- package/src/util/index.ts +1 -0
- package/src/util/recordRequests.ts +47 -0
- package/src/validation/overrideFunctions.ts +44 -0
- package/test/metrics/warmer-metrics.test.ts +1 -0
- package/test/{smoke.test.ts → smoke/smoke.test.ts} +13 -13
- package/{test-payload-fail.json → test/smoke/test-payload-fail.json} +0 -0
- package/{test-payload.js → test/smoke/test-payload.js} +0 -0
- package/{test-payload.json → test/smoke/test-payload.json} +0 -0
- package/test/transports/batch.test.ts +1 -0
- package/tsconfig.json +4 -1
- package/webpack.config.js +39 -5
- package/yarn-error.log +3778 -0
- package/dist/src/adapter.d.ts +0 -135
- package/dist/src/adapter.js +0 -145
- package/dist/src/background-executor.d.ts +0 -11
- package/dist/src/background-executor.js +0 -45
- package/dist/src/cache/factory.d.ts +0 -6
- package/dist/src/cache/factory.js +0 -55
- package/dist/src/cache/index.d.ts +0 -94
- package/dist/src/cache/index.js +0 -173
- package/dist/src/cache/local.d.ts +0 -23
- package/dist/src/cache/local.js +0 -83
- package/dist/src/cache/metrics.d.ts +0 -27
- package/dist/src/cache/metrics.js +0 -120
- package/dist/src/cache/redis.d.ts +0 -16
- package/dist/src/cache/redis.js +0 -100
- package/dist/src/chainlink-external-adapter-framework-0.0.6.tgz +0 -0
- package/dist/src/config/index.d.ts +0 -214
- package/dist/src/config/index.js +0 -380
- package/dist/src/config/provider-limits.d.ts +0 -31
- package/dist/src/config/provider-limits.js +0 -75
- package/dist/src/examples/bank-frick/accounts.d.ts +0 -39
- package/dist/src/examples/bank-frick/accounts.js +0 -192
- package/dist/src/examples/bank-frick/config/index.d.ts +0 -4
- package/dist/src/examples/bank-frick/config/index.js +0 -54
- package/dist/src/examples/bank-frick/index.d.ts +0 -2
- package/dist/src/examples/bank-frick/index.js +0 -15
- package/dist/src/examples/bank-frick/util.d.ts +0 -4
- package/dist/src/examples/bank-frick/util.js +0 -39
- package/dist/src/examples/coingecko/batch-warming.d.ts +0 -7
- package/dist/src/examples/coingecko/batch-warming.js +0 -53
- package/dist/src/examples/coingecko/index.d.ts +0 -2
- package/dist/src/examples/coingecko/index.js +0 -11
- package/dist/src/examples/coingecko/rest.d.ts +0 -12
- package/dist/src/examples/coingecko/rest.js +0 -51
- package/dist/src/examples/ncfx/config/index.d.ts +0 -12
- package/dist/src/examples/ncfx/config/index.js +0 -15
- package/dist/src/examples/ncfx/index.d.ts +0 -13
- package/dist/src/examples/ncfx/index.js +0 -11
- package/dist/src/examples/ncfx/websocket.d.ts +0 -47
- package/dist/src/examples/ncfx/websocket.js +0 -73
- package/dist/src/index.d.ts +0 -11
- package/dist/src/index.js +0 -128
- package/dist/src/metrics/constants.d.ts +0 -16
- package/dist/src/metrics/constants.js +0 -25
- package/dist/src/metrics/index.d.ts +0 -15
- package/dist/src/metrics/index.js +0 -122
- package/dist/src/metrics/util.d.ts +0 -7
- package/dist/src/metrics/util.js +0 -9
- package/dist/src/package/adapter.d.ts +0 -88
- package/dist/src/package/adapter.js +0 -112
- package/dist/src/package/background-executor.d.ts +0 -11
- package/dist/src/package/background-executor.js +0 -45
- package/dist/src/package/cache/factory.d.ts +0 -6
- package/dist/src/package/cache/factory.js +0 -57
- package/dist/src/package/cache/index.d.ts +0 -90
- package/dist/src/package/cache/index.js +0 -169
- package/dist/src/package/cache/local.d.ts +0 -23
- package/dist/src/package/cache/local.js +0 -83
- package/dist/src/package/cache/metrics.d.ts +0 -27
- package/dist/src/package/cache/metrics.js +0 -120
- package/dist/src/package/cache/redis.d.ts +0 -16
- package/dist/src/package/cache/redis.js +0 -100
- package/dist/src/package/config/index.d.ts +0 -195
- package/dist/src/package/config/index.js +0 -365
- package/dist/src/package/config/provider-limits.d.ts +0 -31
- package/dist/src/package/config/provider-limits.js +0 -76
- package/dist/src/package/examples/coingecko/batch-warming.d.ts +0 -2
- package/dist/src/package/examples/coingecko/batch-warming.js +0 -52
- package/dist/src/package/examples/coingecko/index.d.ts +0 -2
- package/dist/src/package/examples/coingecko/index.js +0 -10
- package/dist/src/package/examples/coingecko/rest.d.ts +0 -2
- package/dist/src/package/examples/coingecko/rest.js +0 -50
- package/dist/src/package/examples/ncfx/config/index.d.ts +0 -12
- package/dist/src/package/examples/ncfx/config/index.js +0 -15
- package/dist/src/package/examples/ncfx/index.d.ts +0 -2
- package/dist/src/package/examples/ncfx/index.js +0 -10
- package/dist/src/package/examples/ncfx/websocket.d.ts +0 -36
- package/dist/src/package/examples/ncfx/websocket.js +0 -72
- package/dist/src/package/index.d.ts +0 -12
- package/dist/src/package/index.js +0 -92
- package/dist/src/package/metrics/constants.d.ts +0 -16
- package/dist/src/package/metrics/constants.js +0 -25
- package/dist/src/package/metrics/index.d.ts +0 -15
- package/dist/src/package/metrics/index.js +0 -123
- package/dist/src/package/metrics/util.d.ts +0 -3
- package/dist/src/package/metrics/util.js +0 -9
- package/dist/src/package/package.json +0 -72
- package/dist/src/package/rate-limiting/background/fixed-frequency.d.ts +0 -10
- package/dist/src/package/rate-limiting/background/fixed-frequency.js +0 -37
- package/dist/src/package/rate-limiting/index.d.ts +0 -54
- package/dist/src/package/rate-limiting/index.js +0 -63
- package/dist/src/package/rate-limiting/metrics.d.ts +0 -3
- package/dist/src/package/rate-limiting/metrics.js +0 -44
- package/dist/src/package/rate-limiting/request/simple-counting.d.ts +0 -20
- package/dist/src/package/rate-limiting/request/simple-counting.js +0 -62
- package/dist/src/package/test.d.ts +0 -1
- package/dist/src/package/test.js +0 -6
- package/dist/src/package/transports/batch-warming.d.ts +0 -34
- package/dist/src/package/transports/batch-warming.js +0 -101
- package/dist/src/package/transports/index.d.ts +0 -87
- package/dist/src/package/transports/index.js +0 -87
- package/dist/src/package/transports/metrics.d.ts +0 -21
- package/dist/src/package/transports/metrics.js +0 -105
- package/dist/src/package/transports/rest.d.ts +0 -43
- package/dist/src/package/transports/rest.js +0 -129
- package/dist/src/package/transports/util.d.ts +0 -8
- package/dist/src/package/transports/util.js +0 -85
- package/dist/src/package/transports/websocket.d.ts +0 -80
- package/dist/src/package/transports/websocket.js +0 -169
- package/dist/src/package/util/expiring-sorted-set.d.ts +0 -21
- package/dist/src/package/util/expiring-sorted-set.js +0 -47
- package/dist/src/package/util/index.d.ts +0 -11
- package/dist/src/package/util/index.js +0 -35
- package/dist/src/package/util/logger.d.ts +0 -42
- package/dist/src/package/util/logger.js +0 -62
- package/dist/src/package/util/request.d.ts +0 -55
- package/dist/src/package/util/request.js +0 -2
- package/dist/src/package/validation/error.d.ts +0 -50
- package/dist/src/package/validation/error.js +0 -79
- package/dist/src/package/validation/index.d.ts +0 -5
- package/dist/src/package/validation/index.js +0 -86
- package/dist/src/package/validation/input-params.d.ts +0 -15
- package/dist/src/package/validation/input-params.js +0 -30
- package/dist/src/package/validation/override-functions.d.ts +0 -3
- package/dist/src/package/validation/override-functions.js +0 -40
- package/dist/src/package/validation/preset-tokens.json +0 -23
- package/dist/src/package/validation/validator.d.ts +0 -47
- package/dist/src/package/validation/validator.js +0 -303
- package/dist/src/package.json +0 -72
- package/dist/src/rate-limiting/background/fixed-frequency.d.ts +0 -11
- package/dist/src/rate-limiting/background/fixed-frequency.js +0 -35
- package/dist/src/rate-limiting/index.d.ts +0 -55
- package/dist/src/rate-limiting/index.js +0 -63
- package/dist/src/rate-limiting/metrics.d.ts +0 -3
- package/dist/src/rate-limiting/metrics.js +0 -44
- package/dist/src/rate-limiting/request/simple-counting.d.ts +0 -21
- package/dist/src/rate-limiting/request/simple-counting.js +0 -62
- package/dist/src/test.d.ts +0 -1
- package/dist/src/test.js +0 -6
- package/dist/src/transports/batch-warming.d.ts +0 -35
- package/dist/src/transports/batch-warming.js +0 -101
- package/dist/src/transports/index.d.ts +0 -70
- package/dist/src/transports/index.js +0 -87
- package/dist/src/transports/metrics.d.ts +0 -22
- package/dist/src/transports/metrics.js +0 -105
- package/dist/src/transports/rest.d.ts +0 -44
- package/dist/src/transports/rest.js +0 -131
- package/dist/src/transports/util.d.ts +0 -8
- package/dist/src/transports/util.js +0 -85
- package/dist/src/transports/websocket.d.ts +0 -80
- package/dist/src/transports/websocket.js +0 -166
- package/dist/src/util/expiring-sorted-set.d.ts +0 -21
- package/dist/src/util/expiring-sorted-set.js +0 -47
- package/dist/src/util/index.d.ts +0 -12
- package/dist/src/util/index.js +0 -35
- package/dist/src/util/logger.d.ts +0 -42
- package/dist/src/util/logger.js +0 -62
- package/dist/src/util/request.d.ts +0 -57
- package/dist/src/util/request.js +0 -2
- package/dist/src/util/subscription-set/expiring-sorted-set.d.ts +0 -22
- package/dist/src/util/subscription-set/expiring-sorted-set.js +0 -47
- package/dist/src/util/subscription-set/subscription-set.d.ts +0 -18
- package/dist/src/util/subscription-set/subscription-set.js +0 -19
- package/dist/src/util/test-payload-loader.d.ts +0 -25
- package/dist/src/util/test-payload-loader.js +0 -83
- package/dist/src/validation/error.d.ts +0 -50
- package/dist/src/validation/error.js +0 -79
- package/dist/src/validation/index.d.ts +0 -5
- package/dist/src/validation/index.js +0 -91
- package/dist/src/validation/input-params.d.ts +0 -15
- package/dist/src/validation/input-params.js +0 -30
- package/dist/src/validation/override-functions.d.ts +0 -3
- package/dist/src/validation/override-functions.js +0 -40
- package/dist/src/validation/preset-tokens.json +0 -23
- package/dist/src/validation/validator.d.ts +0 -47
- package/dist/src/validation/validator.js +0 -303
- package/src/test.ts +0 -5
package/jest.config.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chainlink/external-adapter-framework",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.15",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"dependencies": {
|
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
"ioredis": "^5.0.4",
|
|
10
10
|
"pino": "^7.9.2",
|
|
11
11
|
"prom-client": "13.2.0",
|
|
12
|
+
"supertest": "^6.2.4",
|
|
13
|
+
"ts-jest": "^28.0.7",
|
|
12
14
|
"ts-node": "^10.9.1",
|
|
13
15
|
"typescript": "^4.6.3",
|
|
14
16
|
"ws": "^8.5.0"
|
|
@@ -20,12 +22,16 @@
|
|
|
20
22
|
"test-debug": "LOG_LEVEL=trace DEBUG=true EA_PORT=0 c8 ava --verbose",
|
|
21
23
|
"build": "tsc",
|
|
22
24
|
"lint": "eslint ./src && prettier --check ./src/**/*.ts",
|
|
23
|
-
"
|
|
25
|
+
"lint-fix": "eslint --fix ./src && prettier --write ./src/**/*.ts",
|
|
26
|
+
"dev": "NODE_ENV=develop tsnd --respawn --transpile-only --project tsconfig.json './src/test.ts'",
|
|
27
|
+
"verify": "yarn lint && yarn build && yarn build -p ./test/tsconfig.json && yarn test"
|
|
24
28
|
},
|
|
25
29
|
"devDependencies": {
|
|
26
30
|
"@sinonjs/fake-timers": "^9.1.2",
|
|
31
|
+
"@types/jest": "^28.1.7",
|
|
27
32
|
"@types/node": "^18.6.5",
|
|
28
33
|
"@types/sinonjs__fake-timers": "^8.1.2",
|
|
34
|
+
"@types/supertest": "^2.0.12",
|
|
29
35
|
"@types/ws": "^8.5.3",
|
|
30
36
|
"@typescript-eslint/eslint-plugin": "^5.17.0",
|
|
31
37
|
"@typescript-eslint/parser": "^5.17.0",
|
|
@@ -38,8 +44,13 @@
|
|
|
38
44
|
"nock": "^13.2.4",
|
|
39
45
|
"pino-pretty": "^7.6.0",
|
|
40
46
|
"prettier": "^2.6.1",
|
|
47
|
+
"ts-loader": "^9.3.1",
|
|
48
|
+
"ts-node-dev": "2.0.0",
|
|
41
49
|
"typedoc": "^0.22.15",
|
|
42
|
-
"
|
|
50
|
+
"url": "^0.11.0",
|
|
51
|
+
"webpack": "^5.74.0",
|
|
52
|
+
"webpack-cli": "^4.10.0",
|
|
53
|
+
"webpack-merge": "^5.8.0"
|
|
43
54
|
},
|
|
44
55
|
"prettier": {
|
|
45
56
|
"semi": false,
|
|
@@ -21,12 +21,8 @@ type WSTier = {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
export interface Limits {
|
|
24
|
-
http:
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
ws: {
|
|
28
|
-
[tierName: string]: WSTier
|
|
29
|
-
}
|
|
24
|
+
http: Record<string, HTTPTier>
|
|
25
|
+
ws: Record<string, WSTier>
|
|
30
26
|
}
|
|
31
27
|
|
|
32
28
|
interface ProviderRateLimit {
|
|
@@ -94,19 +90,20 @@ const getProviderLimits = (
|
|
|
94
90
|
return limitsConfig
|
|
95
91
|
}
|
|
96
92
|
|
|
97
|
-
const
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
})
|
|
103
|
-
const _formatProvider = (ls: Limits) => {
|
|
104
|
-
const http = _formatProtocol(ls.http)
|
|
105
|
-
const ws = _formatProtocol(ls?.ws)
|
|
106
|
-
return { http, ws }
|
|
93
|
+
const objectKeysToLowercase = <T>(obj: Record<string, T>): Record<string, T> => {
|
|
94
|
+
const lower: Record<string, T> = {}
|
|
95
|
+
|
|
96
|
+
for (const key in obj) {
|
|
97
|
+
lower[key.toLowerCase()] = obj[key]
|
|
107
98
|
}
|
|
108
99
|
|
|
109
|
-
return
|
|
100
|
+
return lower
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const parseLimits = (limits: Limits): Limits => {
|
|
104
|
+
limits.http = objectKeysToLowercase(limits.http)
|
|
105
|
+
limits.ws = objectKeysToLowercase(limits.ws)
|
|
106
|
+
return limits
|
|
110
107
|
}
|
|
111
108
|
|
|
112
109
|
const calculateWSLimits = (providerLimit: WSTier): WSTier => {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export const NAME = 'COINGECKO'
|
|
2
|
+
|
|
3
|
+
export const DEFAULT_ENDPOINT = 'crypto'
|
|
4
|
+
export const DEFAULT_API_ENDPOINT = 'https://api.coingecko.com/api/v3'
|
|
5
|
+
export const PRO_API_ENDPOINT = 'https://pro-api.coingecko.com/api/v3'
|
|
6
|
+
|
|
7
|
+
export const customSettings = {
|
|
8
|
+
API_KEY: {
|
|
9
|
+
description: 'API key for the CoinGecko API',
|
|
10
|
+
type: 'string',
|
|
11
|
+
},
|
|
12
|
+
} as const
|