@chainlink/external-adapter-framework 0.0.12 → 0.0.14

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.
Files changed (278) hide show
  1. package/adapter.d.ts +107 -0
  2. package/adapter.js +115 -0
  3. package/{dist/src/package/background-executor.d.ts → background-executor.d.ts} +0 -0
  4. package/{dist/src/background-executor.js → background-executor.js} +0 -0
  5. package/{dist/src/cache → cache}/factory.d.ts +0 -0
  6. package/{dist/src/cache → cache}/factory.js +0 -0
  7. package/{dist/src/cache → cache}/index.d.ts +8 -8
  8. package/{dist/src/cache → cache}/index.js +0 -0
  9. package/{dist/src/cache → cache}/local.d.ts +0 -0
  10. package/{dist/src/cache → cache}/local.js +0 -0
  11. package/{dist/src/cache → cache}/metrics.d.ts +0 -0
  12. package/{dist/src/cache → cache}/metrics.js +0 -0
  13. package/{dist/src/cache → cache}/redis.d.ts +0 -0
  14. package/{dist/src/cache → cache}/redis.js +0 -0
  15. package/{dist/src/chainlink-external-adapter-framework-0.0.6.tgz → chainlink-external-adapter-framework-0.0.6.tgz} +0 -0
  16. package/{dist/src/config → config}/index.d.ts +0 -5
  17. package/{dist/src/config → config}/index.js +5 -5
  18. package/{dist/src/config → config}/provider-limits.d.ts +0 -0
  19. package/{dist/src/config → config}/provider-limits.js +5 -1
  20. package/{dist/src/examples → examples}/bank-frick/accounts.d.ts +1 -1
  21. package/{dist/src/examples → examples}/bank-frick/accounts.js +2 -3
  22. package/{dist/src/examples → examples}/bank-frick/config/index.d.ts +0 -0
  23. package/{dist/src/examples → examples}/bank-frick/config/index.js +0 -0
  24. package/{dist/src/package/examples/coingecko → examples/bank-frick}/index.d.ts +0 -0
  25. package/{dist/src/examples → examples}/bank-frick/index.js +2 -3
  26. package/{dist/src/examples → examples}/bank-frick/util.d.ts +0 -0
  27. package/{dist/src/examples → examples}/bank-frick/util.js +0 -0
  28. package/{dist/src/package/examples → examples}/coingecko/batch-warming.d.ts +0 -0
  29. package/{dist/src/package/examples → examples}/coingecko/batch-warming.js +0 -0
  30. package/{dist/src/package/examples/ncfx → examples/coingecko}/index.d.ts +0 -0
  31. package/{dist/src/package/examples → examples}/coingecko/index.js +0 -0
  32. package/{dist/src/package/examples → examples}/coingecko/rest.d.ts +0 -0
  33. package/{dist/src/package/examples → examples}/coingecko/rest.js +0 -0
  34. package/{dist/src/examples → examples}/ncfx/config/index.d.ts +0 -0
  35. package/{dist/src/examples → examples}/ncfx/config/index.js +0 -0
  36. package/examples/ncfx/index.d.ts +2 -0
  37. package/{dist/src/package/examples → examples}/ncfx/index.js +0 -0
  38. package/{dist/src/package/examples → examples}/ncfx/websocket.d.ts +0 -0
  39. package/{dist/src/package/examples → examples}/ncfx/websocket.js +0 -0
  40. package/{dist/src/index.d.ts → index.d.ts} +0 -0
  41. package/{dist/src/index.js → index.js} +18 -13
  42. package/{dist/src/metrics → metrics}/constants.d.ts +0 -0
  43. package/{dist/src/metrics → metrics}/constants.js +0 -0
  44. package/{dist/src/metrics → metrics}/index.d.ts +0 -0
  45. package/{dist/src/metrics → metrics}/index.js +0 -0
  46. package/metrics/util.d.ts +7 -0
  47. package/{dist/src/metrics → metrics}/util.js +0 -0
  48. package/{dist/src/package → package}/adapter.d.ts +0 -0
  49. package/{dist/src/package → package}/adapter.js +0 -0
  50. package/{dist/src → package}/background-executor.d.ts +2 -2
  51. package/{dist/src/package → package}/background-executor.js +0 -0
  52. package/{dist/src/package → package}/cache/factory.d.ts +0 -0
  53. package/{dist/src/package → package}/cache/factory.js +0 -0
  54. package/{dist/src/package → package}/cache/index.d.ts +0 -0
  55. package/{dist/src/package → package}/cache/index.js +0 -0
  56. package/{dist/src/package → package}/cache/local.d.ts +0 -0
  57. package/{dist/src/package → package}/cache/local.js +0 -0
  58. package/{dist/src/package → package}/cache/metrics.d.ts +0 -0
  59. package/{dist/src/package → package}/cache/metrics.js +0 -0
  60. package/{dist/src/package → package}/cache/redis.d.ts +0 -0
  61. package/{dist/src/package → package}/cache/redis.js +0 -0
  62. package/{dist/src/package → package}/config/index.d.ts +0 -0
  63. package/{dist/src/package → package}/config/index.js +0 -0
  64. package/{dist/src/package → package}/config/provider-limits.d.ts +0 -0
  65. package/{dist/src/package → package}/config/provider-limits.js +0 -0
  66. package/package/examples/coingecko/batch-warming.d.ts +2 -0
  67. package/{dist/src → package}/examples/coingecko/batch-warming.js +2 -3
  68. package/package/examples/coingecko/index.d.ts +2 -0
  69. package/{dist/src → package}/examples/coingecko/index.js +2 -3
  70. package/package/examples/coingecko/rest.d.ts +2 -0
  71. package/{dist/src → package}/examples/coingecko/rest.js +2 -3
  72. package/{dist/src/package → package}/examples/ncfx/config/index.d.ts +0 -0
  73. package/{dist/src/package → package}/examples/ncfx/config/index.js +0 -0
  74. package/package/examples/ncfx/index.d.ts +2 -0
  75. package/{dist/src → package}/examples/ncfx/index.js +2 -3
  76. package/{dist/src → package}/examples/ncfx/websocket.d.ts +1 -12
  77. package/{dist/src → package}/examples/ncfx/websocket.js +2 -3
  78. package/{dist/src/package → package}/index.d.ts +0 -0
  79. package/{dist/src/package → package}/index.js +0 -0
  80. package/{dist/src/package → package}/metrics/constants.d.ts +0 -0
  81. package/{dist/src/package → package}/metrics/constants.js +0 -0
  82. package/{dist/src/package → package}/metrics/index.d.ts +0 -0
  83. package/{dist/src/package → package}/metrics/index.js +0 -0
  84. package/{dist/src/package → package}/metrics/util.d.ts +0 -0
  85. package/{dist/src/package → package}/metrics/util.js +0 -0
  86. package/{dist/src → package}/package.json +0 -0
  87. package/{dist/src/package → package}/rate-limiting/background/fixed-frequency.d.ts +0 -0
  88. package/{dist/src/package → package}/rate-limiting/background/fixed-frequency.js +0 -0
  89. package/{dist/src/package → package}/rate-limiting/index.d.ts +0 -0
  90. package/{dist/src/package → package}/rate-limiting/index.js +0 -0
  91. package/{dist/src/package → package}/rate-limiting/metrics.d.ts +0 -0
  92. package/{dist/src/package → package}/rate-limiting/metrics.js +0 -0
  93. package/{dist/src/package → package}/rate-limiting/request/simple-counting.d.ts +0 -0
  94. package/{dist/src/package → package}/rate-limiting/request/simple-counting.js +0 -0
  95. package/{dist/src/package → package}/test.d.ts +0 -0
  96. package/{dist/src/package → package}/test.js +0 -0
  97. package/{dist/src/package → package}/transports/batch-warming.d.ts +0 -0
  98. package/{dist/src/package → package}/transports/batch-warming.js +0 -0
  99. package/{dist/src/package → package}/transports/index.d.ts +0 -0
  100. package/{dist/src/package → package}/transports/index.js +0 -0
  101. package/{dist/src/package → package}/transports/metrics.d.ts +0 -0
  102. package/{dist/src/package → package}/transports/metrics.js +0 -0
  103. package/{dist/src/package → package}/transports/rest.d.ts +0 -0
  104. package/{dist/src/package → package}/transports/rest.js +0 -0
  105. package/{dist/src/package → package}/transports/util.d.ts +0 -0
  106. package/{dist/src/package → package}/transports/util.js +0 -0
  107. package/{dist/src/package → package}/transports/websocket.d.ts +0 -0
  108. package/{dist/src/package → package}/transports/websocket.js +0 -0
  109. package/{dist/src/package → package}/util/expiring-sorted-set.d.ts +0 -0
  110. package/{dist/src/package → package}/util/expiring-sorted-set.js +0 -0
  111. package/{dist/src/package → package}/util/index.d.ts +0 -0
  112. package/{dist/src/package → package}/util/index.js +0 -0
  113. package/{dist/src/package → package}/util/logger.d.ts +0 -0
  114. package/{dist/src/package → package}/util/logger.js +0 -0
  115. package/{dist/src/package → package}/util/request.d.ts +0 -0
  116. package/{dist/src/package → package}/util/request.js +0 -0
  117. package/{dist/src/package → package}/validation/error.d.ts +0 -0
  118. package/{dist/src/package → package}/validation/error.js +0 -0
  119. package/{dist/src/package → package}/validation/index.d.ts +0 -0
  120. package/{dist/src/package → package}/validation/index.js +0 -0
  121. package/{dist/src/package → package}/validation/input-params.d.ts +0 -0
  122. package/{dist/src/package → package}/validation/input-params.js +0 -0
  123. package/{dist/src/package → package}/validation/override-functions.d.ts +0 -0
  124. package/{dist/src/package → package}/validation/override-functions.js +0 -0
  125. package/{dist/src/package → package}/validation/preset-tokens.json +0 -0
  126. package/{dist/src/package → package}/validation/validator.d.ts +0 -0
  127. package/{dist/src/package → package}/validation/validator.js +0 -0
  128. package/package.json +1 -1
  129. package/{dist/src/rate-limiting → rate-limiting}/background/fixed-frequency.d.ts +1 -2
  130. package/{dist/src/rate-limiting → rate-limiting}/background/fixed-frequency.js +0 -0
  131. package/{dist/src/rate-limiting → rate-limiting}/index.d.ts +1 -2
  132. package/{dist/src/rate-limiting → rate-limiting}/index.js +0 -0
  133. package/{dist/src/rate-limiting → rate-limiting}/metrics.d.ts +0 -0
  134. package/{dist/src/rate-limiting → rate-limiting}/metrics.js +0 -0
  135. package/{dist/src/rate-limiting → rate-limiting}/request/simple-counting.d.ts +1 -2
  136. package/{dist/src/rate-limiting → rate-limiting}/request/simple-counting.js +0 -0
  137. package/{dist/src/test.d.ts → test.d.ts} +0 -0
  138. package/{dist/src/test.js → test.js} +0 -0
  139. package/{dist/src/transports → transports}/batch-warming.d.ts +0 -0
  140. package/{dist/src/transports → transports}/batch-warming.js +0 -0
  141. package/{dist/src/transports → transports}/index.d.ts +2 -2
  142. package/{dist/src/transports → transports}/index.js +0 -0
  143. package/{dist/src/transports → transports}/metrics.d.ts +1 -2
  144. package/{dist/src/transports → transports}/metrics.js +0 -0
  145. package/{dist/src/transports → transports}/rest.d.ts +0 -0
  146. package/{dist/src/transports → transports}/rest.js +0 -0
  147. package/{dist/src/transports → transports}/util.d.ts +0 -0
  148. package/{dist/src/transports → transports}/util.js +0 -0
  149. package/{dist/src/transports → transports}/websocket.d.ts +3 -2
  150. package/{dist/src/transports → transports}/websocket.js +6 -4
  151. package/{dist/src/util → util}/expiring-sorted-set.d.ts +0 -0
  152. package/{dist/src/util → util}/expiring-sorted-set.js +0 -0
  153. package/{dist/src/util → util}/index.d.ts +0 -0
  154. package/{dist/src/util → util}/index.js +0 -0
  155. package/{dist/src/util → util}/logger.d.ts +0 -0
  156. package/{dist/src/util → util}/logger.js +0 -0
  157. package/{dist/src/util → util}/request.d.ts +2 -2
  158. package/{dist/src/util → util}/request.js +0 -0
  159. package/{dist/src/util → util}/subscription-set/expiring-sorted-set.d.ts +0 -0
  160. package/{dist/src/util → util}/subscription-set/expiring-sorted-set.js +0 -0
  161. package/{dist/src/util → util}/subscription-set/subscription-set.d.ts +0 -0
  162. package/{dist/src/util → util}/subscription-set/subscription-set.js +0 -0
  163. package/{dist/src/util → util}/test-payload-loader.d.ts +0 -0
  164. package/{dist/src/util → util}/test-payload-loader.js +0 -0
  165. package/{dist/src/validation → validation}/error.d.ts +2 -2
  166. package/{dist/src/validation → validation}/error.js +0 -0
  167. package/{dist/src/validation → validation}/index.d.ts +0 -0
  168. package/{dist/src/validation → validation}/index.js +0 -0
  169. package/{dist/src/validation → validation}/input-params.d.ts +0 -0
  170. package/{dist/src/validation → validation}/input-params.js +0 -0
  171. package/validation/override-functions.d.ts +3 -0
  172. package/{dist/src/validation → validation}/override-functions.js +0 -0
  173. package/{dist/src/validation → validation}/preset-tokens.json +0 -0
  174. package/{dist/src/validation → validation}/validator.d.ts +0 -0
  175. package/{dist/src/validation → validation}/validator.js +0 -0
  176. package/.c8rc.json +0 -3
  177. package/.eslintignore +0 -9
  178. package/.eslintrc.js +0 -96
  179. package/.github/README.MD +0 -17
  180. package/.github/actions/setup/action.yaml +0 -13
  181. package/.github/workflows/main.yaml +0 -39
  182. package/.github/workflows/publish.yaml +0 -20
  183. package/.prettierignore +0 -13
  184. package/.yarnrc +0 -0
  185. package/README.md +0 -103
  186. package/dist/src/adapter.d.ts +0 -135
  187. package/dist/src/adapter.js +0 -145
  188. package/dist/src/examples/bank-frick/index.d.ts +0 -2
  189. package/dist/src/examples/coingecko/batch-warming.d.ts +0 -7
  190. package/dist/src/examples/coingecko/index.d.ts +0 -2
  191. package/dist/src/examples/coingecko/rest.d.ts +0 -12
  192. package/dist/src/examples/ncfx/index.d.ts +0 -13
  193. package/dist/src/metrics/util.d.ts +0 -7
  194. package/dist/src/package/package.json +0 -72
  195. package/dist/src/validation/override-functions.d.ts +0 -3
  196. package/docker-compose.yaml +0 -35
  197. package/env.sh +0 -54
  198. package/env2.sh +0 -55
  199. package/publish.sh +0 -0
  200. package/src/adapter.ts +0 -263
  201. package/src/background-executor.ts +0 -52
  202. package/src/cache/factory.ts +0 -26
  203. package/src/cache/index.ts +0 -258
  204. package/src/cache/local.ts +0 -73
  205. package/src/cache/metrics.ts +0 -112
  206. package/src/cache/redis.ts +0 -93
  207. package/src/config/index.ts +0 -517
  208. package/src/config/provider-limits.ts +0 -130
  209. package/src/examples/bank-frick/README.MD +0 -10
  210. package/src/examples/bank-frick/accounts.ts +0 -246
  211. package/src/examples/bank-frick/config/index.ts +0 -53
  212. package/src/examples/bank-frick/index.ts +0 -13
  213. package/src/examples/bank-frick/types.d.ts +0 -38
  214. package/src/examples/bank-frick/util.ts +0 -55
  215. package/src/examples/coingecko/batch-warming.ts +0 -78
  216. package/src/examples/coingecko/index.ts +0 -9
  217. package/src/examples/coingecko/rest.ts +0 -77
  218. package/src/examples/ncfx/config/index.ts +0 -12
  219. package/src/examples/ncfx/index.ts +0 -9
  220. package/src/examples/ncfx/websocket.ts +0 -99
  221. package/src/index.ts +0 -149
  222. package/src/metrics/constants.ts +0 -23
  223. package/src/metrics/index.ts +0 -115
  224. package/src/metrics/util.ts +0 -18
  225. package/src/rate-limiting/background/fixed-frequency.ts +0 -45
  226. package/src/rate-limiting/index.ts +0 -100
  227. package/src/rate-limiting/metrics.ts +0 -18
  228. package/src/rate-limiting/request/simple-counting.ts +0 -76
  229. package/src/test.ts +0 -5
  230. package/src/transports/batch-warming.ts +0 -122
  231. package/src/transports/index.ts +0 -152
  232. package/src/transports/metrics.ts +0 -95
  233. package/src/transports/rest.ts +0 -164
  234. package/src/transports/util.ts +0 -63
  235. package/src/transports/websocket.ts +0 -245
  236. package/src/util/index.ts +0 -22
  237. package/src/util/logger.ts +0 -69
  238. package/src/util/request.ts +0 -117
  239. package/src/util/subscription-set/expiring-sorted-set.ts +0 -54
  240. package/src/util/subscription-set/subscription-set.ts +0 -35
  241. package/src/util/test-payload-loader.ts +0 -87
  242. package/src/validation/error.ts +0 -116
  243. package/src/validation/index.ts +0 -110
  244. package/src/validation/input-params.ts +0 -45
  245. package/src/validation/override-functions.ts +0 -44
  246. package/src/validation/preset-tokens.json +0 -23
  247. package/src/validation/validator.ts +0 -384
  248. package/test/adapter.test.ts +0 -27
  249. package/test/background-executor.test.ts +0 -108
  250. package/test/cache/cache-key.test.ts +0 -114
  251. package/test/cache/helper.ts +0 -100
  252. package/test/cache/local.test.ts +0 -54
  253. package/test/cache/redis.test.ts +0 -89
  254. package/test/correlation.test.ts +0 -114
  255. package/test/index.test.ts +0 -37
  256. package/test/metrics/feed-id.test.ts +0 -38
  257. package/test/metrics/helper.ts +0 -14
  258. package/test/metrics/labels.test.ts +0 -36
  259. package/test/metrics/metrics.test.ts +0 -267
  260. package/test/metrics/redis-metrics.test.ts +0 -113
  261. package/test/metrics/warmer-metrics.test.ts +0 -192
  262. package/test/metrics/ws-metrics.test.ts +0 -225
  263. package/test/rate-limit-config.test.ts +0 -242
  264. package/test/smoke.test.ts +0 -166
  265. package/test/transports/batch.test.ts +0 -465
  266. package/test/transports/rest.test.ts +0 -242
  267. package/test/transports/websocket.test.ts +0 -183
  268. package/test/tsconfig.json +0 -5
  269. package/test/util.ts +0 -77
  270. package/test/validation.test.ts +0 -178
  271. package/test-payload-fail.json +0 -3
  272. package/test-payload.js +0 -22
  273. package/test-payload.json +0 -7
  274. package/test.sh +0 -20
  275. package/test2.sh +0 -2
  276. package/tsconfig.json +0 -25
  277. package/typedoc.json +0 -6
  278. package/webpack.config.js +0 -23
package/.github/README.MD DELETED
@@ -1,17 +0,0 @@
1
- # Github workflows for EAv3 Framework
2
-
3
- **Please note that this work is in progress. The README may not be accurate**
4
-
5
- ## Overview
6
- This directory contains a basic GitHub workflow that builds, tests, and ultimately publishes the EAv3 Framework to NPM
7
- 1. Setup (caches dependencies to speed up other steps)
8
- 2. Build/Prepare/Preflight (all the following happen at the same time)
9
- 1. yarn build => publish artifact of build
10
- 2. yarn lint
11
- 3. yarn test
12
- 3. Publish (currently unimplemented)
13
-
14
- ### Some steps that still need to be added in:
15
- 1. Check that changelog has an entry matching the current version in package.json
16
- 2. Check if a package is already published to NPM, and DON'T overwrite it unless a parameter explicitly allowing an overwrite has been passed
17
- 3. npm-check step that produces a report as an artifact
@@ -1,13 +0,0 @@
1
- name: 'Setup'
2
- description: 'Sets up the project, installs dependencies, and builds'
3
- runs:
4
- using: 'composite'
5
- steps:
6
- - uses: actions/setup-node@v3
7
- with:
8
- node-version: 16.x
9
- registry-url: https://registry.npmjs.org
10
- always-auth: true
11
- cache: yarn
12
- - run: yarn install --frozen-lockfile
13
- shell: bash
@@ -1,39 +0,0 @@
1
- # This is the entry point for CI. It will setup the application, then run lint, test, and eventually publish if not the master or main branch
2
- name: 'Main'
3
- on:
4
- push:
5
- branches:
6
- - master
7
- pull_request: ~
8
-
9
- jobs:
10
- setup: # Load the dependencies cache for all jobs
11
- runs-on: ubuntu-latest
12
- steps:
13
- - uses: actions/checkout@v3
14
- - uses: ./.github/actions/setup
15
- build:
16
- needs: setup
17
- runs-on: ubuntu-latest
18
- concurrency: build-${{ github.ref}}
19
- steps:
20
- - uses: actions/checkout@v3
21
- - uses: ./.github/actions/setup
22
- - run: yarn build
23
- lint:
24
- needs: setup
25
- runs-on: ubuntu-latest
26
- concurrency: lint-${{ github.ref }}
27
- steps:
28
- - uses: actions/checkout@v3
29
- - uses: ./.github/actions/setup
30
- - run: yarn lint
31
- - run: yarn prettier --check **/*.{ts,md}
32
- test:
33
- needs: setup
34
- concurrency: test-${{ github.ref }}
35
- runs-on: ubuntu-latest
36
- steps:
37
- - uses: actions/checkout@v3
38
- - uses: ./.github/actions/setup
39
- - run: yarn test
@@ -1,20 +0,0 @@
1
- # This is the entry point for CI. It will setup the application, then run lint, test, and eventually publish if not the master or main branch
2
- name: 'Publish'
3
- on:
4
- workflow_dispatch:
5
- push:
6
- branches:
7
- - master
8
- jobs:
9
- publish: # Load the dependencies cache for all jobs
10
- runs-on: ubuntu-latest
11
- environment: main
12
- steps:
13
- - uses: actions/checkout@v3
14
- - uses: ./.github/actions/setup
15
- - run: yarn build
16
- - run: cp package.json dist/src/
17
- - run: npm publish --access restricted #scoped packages are restricted by default, but this is set because not all branches currently have a scoped package name
18
- working-directory: dist/src
19
- env:
20
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
package/.prettierignore DELETED
@@ -1,13 +0,0 @@
1
- # don't ever lint node_modules
2
- node_modules
3
- # don't lint build output (make sure it's set to your correct build folder name)
4
- dist
5
- # don't lint nyc coverage output
6
- coverage
7
- test-payload.json
8
- .yarn
9
- .vscode
10
- .pnp.cjs
11
- .pnp.loader.mjs
12
-
13
- packages/k6/k8s/templates
package/.yarnrc DELETED
File without changes
package/README.md DELETED
@@ -1,103 +0,0 @@
1
- # EA Framework v3
2
-
3
- External adapters and its core framework serve as middleware to facilitate connections between Chainlink Nodes and Data Providers (DP). Their main purpose is threefold:
4
-
5
- - Abstract provider specific details, specifically:
6
- - Transport (REST, WebSockets, RPC, SSE, etc.)
7
- - Authentication (login flows, keys)
8
- - Accept normalized request payloads and translate into the provider's interface (this also includes things like symbols/tickers)
9
- - Parse provider responses into the desired data points (e.g. price from crypto endpoint)
10
- - Make the overall system more efficient by using as few resources (e.g. API credits, networking traffic, CPU usage) as possible to fetch data, achieved by features like:
11
- - Caching: since DPs update data at various times and a request to their API incurs a certain latency, EAs keep a cache of values to
12
- - Provide responses to the Chainlink Nodes as quickly as possible
13
- - Communicate with DPs only when necessary
14
- - Cache Warming: in order to make as many of the requests to EAs be fulfilled from the cache, EAs fetch values from DPs asynchronously to keep the local ones fresh.
15
- - Batching: the CL Node requests feeds individually, but it's common for DPs to provide batch endpoints to get many data points at once. With Batching, EAs keep track of incoming requests and consolidate them into one batched request.
16
- - Rate limiting: the EA framework additionally checks request rates (frequency) to make sure they fall within acceptable limits (like quotas for the DP's API, or adjusting based on the NOP's API tier).
17
- - Perform off chain computations (think aggregations, indexing, or any sort of data processing)
18
-
19
- By providing a framework that gives users easy access to those features, we reduce the complexity required for Nodes to communicate with DPs since by using EAs there is only one standardized way to do so, while at the same time optimizing said communication so it's as resource efficient as possible. It also makes internal and external development easier and faster, by serving as a strict guideline to implement and add new providers.
20
-
21
- ## Qs
22
-
23
- - Store entire response in cache?
24
- - Check for valid result in adapter response?
25
-
26
- ## Env vars
27
-
28
- These are all existing env vars, marked DONE if they have been ported to this version, or N/A if the new version disregards them altogether.
29
-
30
- | Name | State | Comments |
31
- | :----------------------------------------- | :---: | :----------------------------------------------------------- |
32
- | API_TIMEOUT | N/A | Only used for WS with handler.noHTtp = true |
33
- | BASE_URL | √ | |
34
- | CACHE_ENABLED | N/A | Cache is integral to this fw, not including this for now |
35
- | CACHE_KEY_IGNORED_PROPS | ?? | Do we want this to be available in v3. Used for feed id |
36
- | CACHE_KEY_GROUP | ?? | Dunno if this applies to this fw |
37
- | CACHE_MAX_AGE | √ | |
38
- | CACHE_MAX_ITEMS | - | Should add when replacing obj in local impl with LRU package |
39
- | CACHE_MIN_AGE | - | Used for rate limiting |
40
- | CACHE_REDIS_CONNECTION_TIMEOUT | - | TODO: Redis |
41
- | CACHE_REDIS_HOST | - | TODO: Redis |
42
- | CACHE_REDIS_MAX_QUEUED_ITEMS | - | TODO: Redis |
43
- | CACHE_REDIS_MAX_RECONNECT_COOLDOWN | - | TODO: Redis |
44
- | CACHE_REDIS_PASSWORD | - | TODO: Redis |
45
- | CACHE_REDIS_PATH | - | TODO: Redis |
46
- | CACHE_REDIS_PORT | - | TODO: Redis |
47
- | CACHE_REDIS_TIMEOUT | - | TODO: Redis |
48
- | CACHE_REDIS_URL | - | TODO: Redis |
49
- | CACHE_TYPE | - | TODO: Cache factory |
50
- | CACHE_UPDATE_AGE_ON_GET | N/A | No longer used in EA currently, apparently |
51
- | DEBUG | | |
52
- | DEFAULT_WS_HEARTBEAT_INTERVAL | | |
53
- | EA_HOST | | |
54
- | EA_PORT | √ | |
55
- | ENV_ADAPTER_URL | | |
56
- | ENV_API_ENDPOINT | | |
57
- | ENV_API_KEY | | |
58
- | ENV_API_TIMEOUT | | |
59
- | ENV_API_VERBOSE | | |
60
- | ENV_WS_API_ENDPOINT | | |
61
- | ENV_WS_API_KEY | | |
62
- | ERROR_CAPACITY | | |
63
- | EXPERIMENTAL_METRICS_ENABLED | √ | Maintaining for backwards compatibility. Defaults to true |
64
- | LEGACY_ENV_ADAPTER_URL | | |
65
- | LOG_LEVEL | | |
66
- | METRICS_ENABLED | √ | Defaults to true |
67
- | METRICS_NAME | √ | |
68
- | METRICS_PORT | √ | |
69
- | METRICS_USE_BASE_URL | √ | |
70
- | NODE_ENV | | |
71
- | npm_package_version | | |
72
- | RATE_LIMIT_API_TIER | | |
73
- | RATE_LIMIT_CAPACITY | | |
74
- | RATE_LIMIT_CAPACITY_MINUTE | | |
75
- | RATE_LIMIT_CAPACITY_SECOND | | |
76
- | RATE_LIMIT_ENABLED | | |
77
- | RECORD | | |
78
- | REQUEST_COALESCING_ENABLED | | |
79
- | REQUEST_COALESCING_ENTROPY_MAX | | |
80
- | REQUEST_COALESCING_INTERVAL | | |
81
- | REQUEST_COALESCING_INTERVAL_COEFFICIENT | | |
82
- | REQUEST_COALESCING_INTERVAL_MAX | | |
83
- | REQUEST_COALESCING_MAX_RETRIES | | |
84
- | RETRY | | |
85
- | SERVER_RATE_LIMIT_MAX | | |
86
- | SERVER_SLOW_DOWN_AFTER_FACTOR | | |
87
- | SERVER_SLOW_DOWN_DELAY_MS | | |
88
- | TIMEOUT | | |
89
- | WARMUP_ENABLED | | |
90
- | WARMUP_INTERVAL | | |
91
- | WARMUP_SUBSCRIPTION_TTL | | |
92
- | WARMUP_UNHEALTHY_THRESHOLD | | |
93
- | WS_CONNECTION_KEY | | |
94
- | WS_CONNECTION_LIMIT | | |
95
- | WS_CONNECTION_RETRY_DELAY | | |
96
- | WS_CONNECTION_RETRY_LIMIT | | |
97
- | WS_CONNECTION_TTL | | |
98
- | WS_ENABLED | N/A | Shouldn't be part of this fw |
99
- | WS_SUBSCRIPTION_LIMIT | | |
100
- | WS_SUBSCRIPTION_PRIORITY_LIST | | |
101
- | WS_SUBSCRIPTION_TTL | | |
102
- | WS_SUBSCRIPTION_UNRESPONSIVE_TTL | | |
103
- | WS_TIME_UNTIL_HANDLE_NEXT_MESSAGE_OVERRIDE | | |
@@ -1,135 +0,0 @@
1
- import { Cache } from './cache';
2
- import { AdapterConfig, BaseAdapterConfig, CustomSettingsType, SettingsMap } from './config';
3
- import { AdapterRateLimitTier, BackgroundExecuteRateLimiter, RequestRateLimiter } from './rate-limiting';
4
- import { Transport } from './transports';
5
- import { SubscriptionSetFactory } from './util';
6
- import { InputParameters } from './validation/input-params';
7
- /**
8
- * Dependencies that will be injected into the Adapter on startup
9
- */
10
- export interface AdapterDependencies {
11
- cache: Cache;
12
- requestRateLimiter: RequestRateLimiter;
13
- backgroundExecuteRateLimiter: BackgroundExecuteRateLimiter;
14
- subscriptionSetFactory: SubscriptionSetFactory;
15
- }
16
- /**
17
- * Context that will be used on background executions of a Transport.
18
- * For example, the endpointName used to log statements or generate Cache keys.
19
- */
20
- export interface AdapterContext<CustomSettings extends CustomSettingsType<CustomSettings> = SettingsMap> {
21
- adapterEndpoint: AdapterEndpoint<unknown, unknown, CustomSettings>;
22
- adapterConfig: AdapterConfig<CustomSettings>;
23
- }
24
- /**
25
- * Structure to describe rate limits specs for the Adapter
26
- */
27
- interface AdapterRateLimitingConfig {
28
- /** Adapter rate limits, gotten from the specific tier requested */
29
- tiers: Record<string, AdapterRateLimitTier>;
30
- }
31
- /**
32
- * Main structure of an External Adapter
33
- */
34
- export interface AdapterParams<CustomSettings extends SettingsMap> {
35
- /** Name of the adapter */
36
- name: string;
37
- /** If present, the string that will be used for requests with no specified endpoint */
38
- defaultEndpoint?: string;
39
- /**
40
- * List of [[AdapterEndpoint]]s in the adapter. This is purposefully typed any; it's the correct type in this case.
41
- *
42
- * When you try to create an adapter and you provide an endpoint, if these generics were set to "unknown" instead
43
- * what would happen is that Typescript would check if the types match, and would fail to assign unknown to the
44
- * specific Params or Result in the transport itself.
45
- * We also can't use generics, because if we had more than one transport with different requests (very likely)
46
- * then those new types wouldn't match with each other.
47
- */
48
- endpoints: AdapterEndpoint<any, any, CustomSettings>[];
49
- /** Map of overrides to the default config values for an Adapter */
50
- envDefaultOverrides?: Partial<BaseAdapterConfig>;
51
- /** List of custom env vars for this particular adapter (e.g. RPC_URL) */
52
- customSettings?: SettingsMap;
53
- /** Configuration relevant to outbound (EA --\> DP) communication rate limiting */
54
- rateLimiting?: AdapterRateLimitingConfig;
55
- /** Overrides for converting the 'base' parameter that are hardcoded into the adapter. */
56
- overrides?: Record<string, string>;
57
- }
58
- /**
59
- * Structure to describe rate limits specs for a specific adapter endpoint
60
- */
61
- export interface EndpointRateLimitingConfig {
62
- /**
63
- * How much of the total limit for the adapter will be assigned to this specific endpoint.
64
- * Should be a non-zero positive number up to 100.
65
- * Endpoints in the same adapter without a specific allocation will divide the remaining limits equally.
66
- */
67
- allocationPercentage: number;
68
- }
69
- /**
70
- * Structure to describe a specific endpoint in an [[Adapter]]
71
- */
72
- export interface AdapterEndpointParams<Params, Result, CustomSettings extends SettingsMap> {
73
- /** Name that will be used to match input params to this endpoint (case insensitive) */
74
- name: string;
75
- /** List of alternative endpoint names that will resolve to this same transport (case insensitive) */
76
- aliases?: string[];
77
- /** Transport that will be used to handle data processing and communication for this endpoint */
78
- transport: Transport<Params, Result, CustomSettings>;
79
- /** Specification of what the body of a request hitting this endpoint should look like (used for validation) */
80
- inputParameters: InputParameters;
81
- /** Specific details related to the rate limiting for this endpoint in particular */
82
- rateLimiting?: EndpointRateLimitingConfig;
83
- }
84
- export declare class AdapterEndpoint<Params, Result, CustomSettings extends SettingsMap> implements AdapterEndpointParams<Params, Result, CustomSettings> {
85
- name: string;
86
- aliases?: string[] | undefined;
87
- transport: Transport<Params, Result, CustomSettings>;
88
- inputParameters: InputParameters;
89
- rateLimiting?: EndpointRateLimitingConfig | undefined;
90
- constructor(params: AdapterEndpointParams<Params, Result, CustomSettings>);
91
- }
92
- export declare class Adapter<CustomSettings extends SettingsMap = SettingsMap> implements AdapterParams<CustomSettings> {
93
- name: string;
94
- defaultEndpoint?: string | undefined;
95
- endpoints: AdapterEndpoint<unknown, unknown, CustomSettings>[];
96
- envDefaultOverrides?: Partial<BaseAdapterConfig> | undefined;
97
- customSettings?: SettingsMap | undefined;
98
- rateLimiting?: AdapterRateLimitingConfig | undefined;
99
- overrides?: Record<string, string> | undefined;
100
- initialized: boolean;
101
- /** Object containing alias translations for all endpoints */
102
- endpointsMap: Record<string, AdapterEndpoint<unknown, unknown, CustomSettings>>;
103
- /** Initialized dependencies that the adapter will use */
104
- dependencies: AdapterDependencies;
105
- /** Configuration params for various adapter properties */
106
- config: AdapterConfig;
107
- constructor(params: AdapterParams<CustomSettings>);
108
- /**
109
- * Initializes all of the [[Transport]]s in the adapter, passing along any [[AdapterDependencies]] and [[AdapterConfig]].
110
- * Additionally, it builds a map out of all the endpoint names and aliases (checking for duplicates).
111
- */
112
- initialize(dependencies?: Partial<AdapterDependencies>): Promise<void>;
113
- /**
114
- * Takes an adapter and normalizes all endpoint names and aliases, as well as the default endpoint.
115
- * i.e. makes them lowercase for now
116
- * @param adapter - an instance of an Adapter
117
- */
118
- private normalizeEndpointNames;
119
- /**
120
- * This function will take an adapter structure and go through each endpoint, calculating
121
- * each one's allocation of the total rate limits that are set for the adapter as a whole.
122
- *
123
- * @param adapter - the adapter to initialize rate limiting for
124
- */
125
- private calculateRateLimitAllocations;
126
- /**
127
- * This function will process dependencies for an adapter, such as caches or rate limiters,
128
- * in order to inject them into transports and other relevant places later in the lifecycle.
129
- *
130
- * @param inputDependencies - a partial obj of initialized dependencies to override the created ones
131
- * @returns a set of AdapterDependencies all initialized
132
- */
133
- initializeDependencies(inputDependencies?: Partial<AdapterDependencies>): AdapterDependencies;
134
- }
135
- export {};
@@ -1,145 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Adapter = exports.AdapterEndpoint = void 0;
4
- const cache_1 = require("./cache");
5
- const config_1 = require("./config");
6
- const rate_limiting_1 = require("./rate-limiting");
7
- const util_1 = require("./util");
8
- const logger = (0, util_1.makeLogger)('Adapter');
9
- class AdapterEndpoint {
10
- constructor(params) {
11
- this.name = params.name;
12
- this.aliases = params.aliases;
13
- this.transport = params.transport;
14
- this.inputParameters = params.inputParameters;
15
- this.rateLimiting = params.rateLimiting;
16
- }
17
- }
18
- exports.AdapterEndpoint = AdapterEndpoint;
19
- // /**
20
- // * Structure to describe an adapter that has been initialized
21
- // */
22
- // export interface InitializedAdapter<Params, Result, CustomSettings extends SettingsMap>
23
- // extends AdapterParams<Params, Result, CustomSettings> {
24
- // /** Object containing alias translations for all endpoints */
25
- // endpointsMap: Record<string, AdapterEndpoint<Params, Result, CustomSettings>>
26
- // /** Initialized dependencies that the adapter will use */
27
- // dependencies: AdapterDependencies
28
- // /** Configuration params for various adapter properties */
29
- // config: AdapterConfig
30
- // }
31
- class Adapter {
32
- constructor(params) {
33
- // After initialization
34
- this.initialized = false;
35
- /** Object containing alias translations for all endpoints */
36
- this.endpointsMap = {};
37
- // Copy over params
38
- this.name = params.name;
39
- this.defaultEndpoint = params.defaultEndpoint?.toLowerCase();
40
- this.endpoints = params.endpoints;
41
- this.envDefaultOverrides = params.envDefaultOverrides;
42
- this.customSettings = params.customSettings;
43
- this.rateLimiting = params.rateLimiting;
44
- this.overrides = params.overrides;
45
- this.config = (0, config_1.buildAdapterConfig)({
46
- overrides: this.envDefaultOverrides,
47
- customSettings: this.customSettings,
48
- });
49
- this.normalizeEndpointNames();
50
- this.calculateRateLimitAllocations();
51
- }
52
- /**
53
- * Initializes all of the [[Transport]]s in the adapter, passing along any [[AdapterDependencies]] and [[AdapterConfig]].
54
- * Additionally, it builds a map out of all the endpoint names and aliases (checking for duplicates).
55
- */
56
- async initialize(dependencies) {
57
- if (this.initialized) {
58
- throw new Error('This adapter has already been initialized!');
59
- }
60
- this.dependencies = this.initializeDependencies(dependencies);
61
- for (const endpoint of this.endpoints) {
62
- // Add aliases to map to use in validation
63
- const aliases = [endpoint.name, ...(endpoint.aliases || [])];
64
- for (const alias of aliases) {
65
- if (this.endpointsMap[alias]) {
66
- throw new Error(`Duplicate endpoint / alias: "${alias}"`);
67
- }
68
- this.endpointsMap[alias] = endpoint;
69
- }
70
- logger.debug(`Initializing transport for endpoint "${endpoint.name}"...`);
71
- await endpoint.transport.initialize(this.dependencies);
72
- }
73
- logger.debug('Adapter initialization complete.');
74
- this.initialized = true;
75
- }
76
- /**
77
- * Takes an adapter and normalizes all endpoint names and aliases, as well as the default endpoint.
78
- * i.e. makes them lowercase for now
79
- * @param adapter - an instance of an Adapter
80
- */
81
- normalizeEndpointNames() {
82
- for (const endpoint of this.endpoints) {
83
- endpoint.name = endpoint.name.toLowerCase();
84
- endpoint.aliases = endpoint.aliases?.map((a) => a.toLowerCase());
85
- }
86
- }
87
- /**
88
- * This function will take an adapter structure and go through each endpoint, calculating
89
- * each one's allocation of the total rate limits that are set for the adapter as a whole.
90
- *
91
- * @param adapter - the adapter to initialize rate limiting for
92
- */
93
- calculateRateLimitAllocations() {
94
- const numberOfEndpoints = this.endpoints.length;
95
- const endpointsWithExplicitAllocations = this.endpoints.filter((e) => e.rateLimiting);
96
- const totalExplicitAllocation = endpointsWithExplicitAllocations
97
- .map((e) => e.rateLimiting?.allocationPercentage || 0)
98
- .reduce((sum, next) => sum + next, 0);
99
- if (totalExplicitAllocation > 100) {
100
- throw new Error('The total allocation set for all endpoints summed cannot exceed 100%');
101
- }
102
- if (totalExplicitAllocation === 100 &&
103
- numberOfEndpoints - endpointsWithExplicitAllocations.length > 0) {
104
- throw new Error('The explicit allocation is at 100% but there are endpoints with implicit allocation');
105
- }
106
- const implicitAllocation = 100 - totalExplicitAllocation;
107
- logger.debug('Adapter rate limit allocations:');
108
- for (const endpoint of this.endpoints) {
109
- if (!endpoint.rateLimiting) {
110
- endpoint.rateLimiting = {
111
- allocationPercentage: implicitAllocation / (numberOfEndpoints - endpointsWithExplicitAllocations.length),
112
- };
113
- }
114
- logger.debug(`Endpoint [${endpoint.name}] - ${endpoint.rateLimiting?.allocationPercentage}%`);
115
- }
116
- }
117
- /**
118
- * This function will process dependencies for an adapter, such as caches or rate limiters,
119
- * in order to inject them into transports and other relevant places later in the lifecycle.
120
- *
121
- * @param inputDependencies - a partial obj of initialized dependencies to override the created ones
122
- * @returns a set of AdapterDependencies all initialized
123
- */
124
- initializeDependencies(inputDependencies) {
125
- const dependencies = inputDependencies || {};
126
- if (!dependencies.cache) {
127
- dependencies.cache = cache_1.CacheFactory.buildCache(this.config);
128
- }
129
- // In the future we might want something more complex, but for now it's better to simplify
130
- // and just use the same rate limiting for everything. Once we have a more complex use case we
131
- // can think of ways to make this more configurable.
132
- const rateLimitingTier = (0, rate_limiting_1.getRateLimitingTier)(this.rateLimiting?.tiers, this.config.RATE_LIMIT_API_TIER);
133
- if (!dependencies.requestRateLimiter) {
134
- dependencies.requestRateLimiter = new rate_limiting_1.SimpleCountingRateLimiter().initialize(this.endpoints, rateLimitingTier);
135
- }
136
- if (!dependencies.backgroundExecuteRateLimiter) {
137
- dependencies.backgroundExecuteRateLimiter = new rate_limiting_1.FixedFrequencyRateLimiter().initialize(this.endpoints, rateLimitingTier);
138
- }
139
- if (!dependencies.subscriptionSetFactory) {
140
- dependencies.subscriptionSetFactory = new util_1.SubscriptionSetFactory(this.config);
141
- }
142
- return dependencies;
143
- }
144
- }
145
- exports.Adapter = Adapter;
@@ -1,2 +0,0 @@
1
- import { Adapter } from '../../adapter';
2
- export declare const adapter: Adapter<import("../../config").SettingsMap>;
@@ -1,7 +0,0 @@
1
- import { AdapterEndpoint } from '../../adapter';
2
- interface AdapterRequestParams {
3
- base: string;
4
- quote: string;
5
- }
6
- export declare const batchEndpoint: AdapterEndpoint<AdapterRequestParams, unknown, import("../../config").SettingsMap>;
7
- export {};
@@ -1,2 +0,0 @@
1
- import { Adapter } from '../../adapter';
2
- export declare const adapter: Adapter<import("../../config").SettingsMap>;
@@ -1,12 +0,0 @@
1
- import { AdapterEndpoint } from '../../adapter';
2
- interface AdapterRequestParams {
3
- base: string;
4
- quote: string;
5
- }
6
- interface ProviderResponseBody {
7
- [base: string]: {
8
- [quote: string]: number;
9
- };
10
- }
11
- export declare const restEndpoint: AdapterEndpoint<AdapterRequestParams, ProviderResponseBody, import("../../config").SettingsMap>;
12
- export {};
@@ -1,13 +0,0 @@
1
- import { Adapter } from '../../adapter';
2
- export declare const adapter: Adapter<{
3
- readonly USERNAME: {
4
- readonly description: "Username for the NCFX API";
5
- readonly type: "string";
6
- readonly required: true;
7
- };
8
- readonly PASSWORD: {
9
- readonly description: "Password for the NCFX API";
10
- readonly type: "string";
11
- readonly required: true;
12
- };
13
- }>;
@@ -1,7 +0,0 @@
1
- import { AdapterMetricsMeta, AdapterRequestData } from '../util';
2
- import { AdapterEndpoint } from '../adapter';
3
- import { AdapterConfig, SettingsMap } from '../config';
4
- export declare const getMetricsMeta: <Params, Result, CustomSettings extends SettingsMap>({ adapterEndpoint, adapterConfig, }: {
5
- adapterEndpoint: AdapterEndpoint<Params, Result, CustomSettings>;
6
- adapterConfig: AdapterConfig<CustomSettings>;
7
- }, data: AdapterRequestData) => AdapterMetricsMeta;
@@ -1,72 +0,0 @@
1
- {
2
- "name": "@chainlink/external-adapter-framework",
3
- "version": "0.0.6",
4
- "main": "dist/index.js",
5
- "license": "MIT",
6
- "dependencies": {
7
- "axios": "^0.27.2",
8
- "fastify": "^3.29.0",
9
- "ioredis": "^5.0.4",
10
- "pino": "^7.9.2",
11
- "prom-client": "13.2.0",
12
- "ts-node": "^10.9.1",
13
- "typescript": "^4.6.3",
14
- "ws": "^8.5.0"
15
- },
16
- "scripts": {
17
- "start": "ts-node src/test.ts",
18
- "generate-docs": "typedoc src/**/*.ts",
19
- "test": "LOG_LEVEL=error EA_PORT=0 c8 ava",
20
- "test-debug": "LOG_LEVEL=trace DEBUG=true EA_PORT=0 c8 ava --verbose",
21
- "build": "tsc",
22
- "lint": "eslint ./src"
23
- },
24
- "devDependencies": {
25
- "@sinonjs/fake-timers": "^9.1.2",
26
- "@types/node": "^18.6.5",
27
- "@types/sinonjs__fake-timers": "^8.1.2",
28
- "@types/ws": "^8.5.3",
29
- "@typescript-eslint/eslint-plugin": "^5.17.0",
30
- "@typescript-eslint/parser": "^5.17.0",
31
- "ava": "^4.2.0",
32
- "c8": "^7.11.2",
33
- "eslint": "^8.14.0",
34
- "eslint-config-prettier": "^8.5.0",
35
- "eslint-plugin-tsdoc": "^0.2.16",
36
- "mock-socket": "^9.1.3",
37
- "nock": "^13.2.4",
38
- "pino-pretty": "^7.6.0",
39
- "prettier": "^2.6.1",
40
- "ts-loader": "^9.3.1",
41
- "typedoc": "^0.22.15",
42
- "webpack": "^5.74.0",
43
- "webpack-cli": "^4.10.0"
44
- },
45
- "prettier": {
46
- "semi": false,
47
- "singleQuote": true,
48
- "printWidth": 100,
49
- "endOfLine": "auto",
50
- "trailingComma": "all",
51
- "arrowParens": "always"
52
- },
53
- "optionalDependencies": {
54
- "bufferutil": "^4.0.6",
55
- "utf-8-validate": "^5.0.9"
56
- },
57
- "ava": {
58
- "files": [
59
- "test/**/*.test.ts"
60
- ],
61
- "extensions": [
62
- "ts"
63
- ],
64
- "require": [
65
- "ts-node/register"
66
- ],
67
- "workerThreads": false,
68
- "environmentVariables": {
69
- "METRICS_ENABLED": "false"
70
- }
71
- }
72
- }
@@ -1,3 +0,0 @@
1
- import { Adapter } from '../adapter';
2
- import { AdapterRequest } from '../util/request';
3
- export declare const performSymbolOverrides: (adapter: Adapter, req: AdapterRequest) => void;