@chainlink/external-adapter-framework 0.0.14 → 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.
Files changed (292) hide show
  1. package/.c8rc.json +3 -0
  2. package/.eslintignore +10 -0
  3. package/.eslintrc.js +96 -0
  4. package/.github/README.MD +42 -0
  5. package/.github/actions/setup/action.yaml +13 -0
  6. package/.github/workflows/label.yaml +39 -0
  7. package/.github/workflows/main.yaml +39 -0
  8. package/.github/workflows/publish.yaml +17 -0
  9. package/.prettierignore +13 -0
  10. package/.yarnrc +0 -0
  11. package/README.md +103 -0
  12. package/dist/examples/coingecko/test/e2e/adapter.test.ts.js +82953 -0
  13. package/dist/examples/coingecko/test/integration/adapter.test.ts.js +91672 -0
  14. package/dist/main.js +72703 -0
  15. package/docker-compose.yaml +35 -0
  16. package/env.sh +54 -0
  17. package/env2.sh +55 -0
  18. package/jest.config.js +5 -0
  19. package/package.json +14 -3
  20. package/publish.sh +0 -0
  21. package/src/adapter.ts +263 -0
  22. package/src/background-executor.ts +52 -0
  23. package/src/cache/factory.ts +26 -0
  24. package/src/cache/index.ts +258 -0
  25. package/src/cache/local.ts +73 -0
  26. package/src/cache/metrics.ts +112 -0
  27. package/src/cache/redis.ts +93 -0
  28. package/src/config/index.ts +517 -0
  29. package/src/config/provider-limits.ts +127 -0
  30. package/src/examples/bank-frick/README.MD +10 -0
  31. package/src/examples/bank-frick/accounts.ts +246 -0
  32. package/src/examples/bank-frick/config/index.ts +53 -0
  33. package/src/examples/bank-frick/index.ts +13 -0
  34. package/src/examples/bank-frick/types.d.ts +38 -0
  35. package/src/examples/bank-frick/util.ts +55 -0
  36. package/src/examples/coingecko/src/config/index.ts +12 -0
  37. package/src/examples/coingecko/src/config/overrides.json +10826 -0
  38. package/src/examples/coingecko/src/cryptoUtils.ts +88 -0
  39. package/src/examples/coingecko/src/endpoint/coins.ts +54 -0
  40. package/src/examples/coingecko/src/endpoint/crypto-marketcap.ts +66 -0
  41. package/src/examples/coingecko/src/endpoint/crypto-volume.ts +66 -0
  42. package/src/examples/coingecko/src/endpoint/crypto.ts +63 -0
  43. package/src/examples/coingecko/src/endpoint/dominance.ts +40 -0
  44. package/src/examples/coingecko/src/endpoint/global-marketcap.ts +40 -0
  45. package/src/examples/coingecko/src/endpoint/index.ts +6 -0
  46. package/src/examples/coingecko/src/globalUtils.ts +78 -0
  47. package/src/examples/coingecko/src/index.ts +17 -0
  48. package/src/examples/coingecko/test/e2e/adapter.test.ts +278 -0
  49. package/src/examples/coingecko/test/integration/__snapshots__/adapter.test.ts.snap +15 -0
  50. package/src/examples/coingecko/test/integration/adapter.test.ts +281 -0
  51. package/src/examples/coingecko/test/integration/capturedRequests.json +1 -0
  52. package/src/examples/coingecko/test/integration/fixtures.ts +42 -0
  53. package/src/examples/coingecko-old/batch-warming.ts +79 -0
  54. package/src/examples/coingecko-old/index.ts +9 -0
  55. package/src/examples/coingecko-old/rest.ts +77 -0
  56. package/src/examples/ncfx/config/index.ts +12 -0
  57. package/src/examples/ncfx/index.ts +9 -0
  58. package/src/examples/ncfx/websocket.ts +99 -0
  59. package/src/index.ts +149 -0
  60. package/src/metrics/constants.ts +23 -0
  61. package/src/metrics/index.ts +115 -0
  62. package/src/metrics/util.ts +18 -0
  63. package/src/rate-limiting/background/fixed-frequency.ts +45 -0
  64. package/src/rate-limiting/index.ts +100 -0
  65. package/src/rate-limiting/metrics.ts +18 -0
  66. package/src/rate-limiting/request/simple-counting.ts +76 -0
  67. package/src/transports/batch-warming.ts +127 -0
  68. package/src/transports/index.ts +152 -0
  69. package/src/transports/metrics.ts +95 -0
  70. package/src/transports/rest.ts +168 -0
  71. package/src/transports/util.ts +63 -0
  72. package/src/transports/websocket.ts +245 -0
  73. package/src/util/index.ts +23 -0
  74. package/src/util/logger.ts +69 -0
  75. package/src/util/recordRequests.ts +47 -0
  76. package/src/util/request.ts +117 -0
  77. package/src/util/subscription-set/expiring-sorted-set.ts +54 -0
  78. package/src/util/subscription-set/subscription-set.ts +35 -0
  79. package/src/util/test-payload-loader.ts +87 -0
  80. package/src/validation/error.ts +116 -0
  81. package/src/validation/index.ts +110 -0
  82. package/src/validation/input-params.ts +45 -0
  83. package/src/validation/override-functions.ts +44 -0
  84. package/src/validation/overrideFunctions.ts +44 -0
  85. package/src/validation/preset-tokens.json +23 -0
  86. package/src/validation/validator.ts +384 -0
  87. package/test/adapter.test.ts +27 -0
  88. package/test/background-executor.test.ts +108 -0
  89. package/test/cache/cache-key.test.ts +114 -0
  90. package/test/cache/helper.ts +100 -0
  91. package/test/cache/local.test.ts +54 -0
  92. package/test/cache/redis.test.ts +89 -0
  93. package/test/correlation.test.ts +114 -0
  94. package/test/index.test.ts +37 -0
  95. package/test/metrics/feed-id.test.ts +38 -0
  96. package/test/metrics/helper.ts +14 -0
  97. package/test/metrics/labels.test.ts +36 -0
  98. package/test/metrics/metrics.test.ts +267 -0
  99. package/test/metrics/redis-metrics.test.ts +113 -0
  100. package/test/metrics/warmer-metrics.test.ts +193 -0
  101. package/test/metrics/ws-metrics.test.ts +225 -0
  102. package/test/rate-limit-config.test.ts +242 -0
  103. package/test/smoke/smoke.test.ts +166 -0
  104. package/test/smoke/test-payload-fail.json +3 -0
  105. package/test/smoke/test-payload.js +22 -0
  106. package/test/smoke/test-payload.json +7 -0
  107. package/test/transports/batch.test.ts +466 -0
  108. package/test/transports/rest.test.ts +242 -0
  109. package/test/transports/websocket.test.ts +183 -0
  110. package/test/tsconfig.json +5 -0
  111. package/test/util.ts +77 -0
  112. package/test/validation.test.ts +178 -0
  113. package/test.sh +20 -0
  114. package/test2.sh +2 -0
  115. package/tsconfig.json +28 -0
  116. package/typedoc.json +6 -0
  117. package/webpack.config.js +57 -0
  118. package/yarn-error.log +3778 -0
  119. package/adapter.d.ts +0 -107
  120. package/adapter.js +0 -115
  121. package/background-executor.d.ts +0 -11
  122. package/background-executor.js +0 -45
  123. package/cache/factory.d.ts +0 -6
  124. package/cache/factory.js +0 -55
  125. package/cache/index.d.ts +0 -94
  126. package/cache/index.js +0 -173
  127. package/cache/local.d.ts +0 -23
  128. package/cache/local.js +0 -83
  129. package/cache/metrics.d.ts +0 -27
  130. package/cache/metrics.js +0 -120
  131. package/cache/redis.d.ts +0 -16
  132. package/cache/redis.js +0 -100
  133. package/chainlink-external-adapter-framework-0.0.6.tgz +0 -0
  134. package/config/index.d.ts +0 -209
  135. package/config/index.js +0 -380
  136. package/config/provider-limits.d.ts +0 -31
  137. package/config/provider-limits.js +0 -79
  138. package/examples/bank-frick/accounts.d.ts +0 -39
  139. package/examples/bank-frick/accounts.js +0 -191
  140. package/examples/bank-frick/config/index.d.ts +0 -4
  141. package/examples/bank-frick/config/index.js +0 -54
  142. package/examples/bank-frick/index.d.ts +0 -2
  143. package/examples/bank-frick/index.js +0 -14
  144. package/examples/bank-frick/util.d.ts +0 -4
  145. package/examples/bank-frick/util.js +0 -39
  146. package/examples/coingecko/batch-warming.d.ts +0 -2
  147. package/examples/coingecko/batch-warming.js +0 -52
  148. package/examples/coingecko/index.d.ts +0 -2
  149. package/examples/coingecko/index.js +0 -10
  150. package/examples/coingecko/rest.d.ts +0 -2
  151. package/examples/coingecko/rest.js +0 -50
  152. package/examples/ncfx/config/index.d.ts +0 -12
  153. package/examples/ncfx/config/index.js +0 -15
  154. package/examples/ncfx/index.d.ts +0 -2
  155. package/examples/ncfx/index.js +0 -10
  156. package/examples/ncfx/websocket.d.ts +0 -36
  157. package/examples/ncfx/websocket.js +0 -72
  158. package/index.d.ts +0 -11
  159. package/index.js +0 -133
  160. package/metrics/constants.d.ts +0 -16
  161. package/metrics/constants.js +0 -25
  162. package/metrics/index.d.ts +0 -15
  163. package/metrics/index.js +0 -122
  164. package/metrics/util.d.ts +0 -7
  165. package/metrics/util.js +0 -9
  166. package/package/adapter.d.ts +0 -88
  167. package/package/adapter.js +0 -112
  168. package/package/background-executor.d.ts +0 -11
  169. package/package/background-executor.js +0 -45
  170. package/package/cache/factory.d.ts +0 -6
  171. package/package/cache/factory.js +0 -57
  172. package/package/cache/index.d.ts +0 -90
  173. package/package/cache/index.js +0 -169
  174. package/package/cache/local.d.ts +0 -23
  175. package/package/cache/local.js +0 -83
  176. package/package/cache/metrics.d.ts +0 -27
  177. package/package/cache/metrics.js +0 -120
  178. package/package/cache/redis.d.ts +0 -16
  179. package/package/cache/redis.js +0 -100
  180. package/package/config/index.d.ts +0 -195
  181. package/package/config/index.js +0 -365
  182. package/package/config/provider-limits.d.ts +0 -31
  183. package/package/config/provider-limits.js +0 -76
  184. package/package/examples/coingecko/batch-warming.d.ts +0 -2
  185. package/package/examples/coingecko/batch-warming.js +0 -52
  186. package/package/examples/coingecko/index.d.ts +0 -2
  187. package/package/examples/coingecko/index.js +0 -10
  188. package/package/examples/coingecko/rest.d.ts +0 -2
  189. package/package/examples/coingecko/rest.js +0 -50
  190. package/package/examples/ncfx/config/index.d.ts +0 -12
  191. package/package/examples/ncfx/config/index.js +0 -15
  192. package/package/examples/ncfx/index.d.ts +0 -2
  193. package/package/examples/ncfx/index.js +0 -10
  194. package/package/examples/ncfx/websocket.d.ts +0 -36
  195. package/package/examples/ncfx/websocket.js +0 -72
  196. package/package/index.d.ts +0 -12
  197. package/package/index.js +0 -92
  198. package/package/metrics/constants.d.ts +0 -16
  199. package/package/metrics/constants.js +0 -25
  200. package/package/metrics/index.d.ts +0 -15
  201. package/package/metrics/index.js +0 -123
  202. package/package/metrics/util.d.ts +0 -3
  203. package/package/metrics/util.js +0 -9
  204. package/package/package.json +0 -72
  205. package/package/rate-limiting/background/fixed-frequency.d.ts +0 -10
  206. package/package/rate-limiting/background/fixed-frequency.js +0 -37
  207. package/package/rate-limiting/index.d.ts +0 -54
  208. package/package/rate-limiting/index.js +0 -63
  209. package/package/rate-limiting/metrics.d.ts +0 -3
  210. package/package/rate-limiting/metrics.js +0 -44
  211. package/package/rate-limiting/request/simple-counting.d.ts +0 -20
  212. package/package/rate-limiting/request/simple-counting.js +0 -62
  213. package/package/test.d.ts +0 -1
  214. package/package/test.js +0 -6
  215. package/package/transports/batch-warming.d.ts +0 -34
  216. package/package/transports/batch-warming.js +0 -101
  217. package/package/transports/index.d.ts +0 -87
  218. package/package/transports/index.js +0 -87
  219. package/package/transports/metrics.d.ts +0 -21
  220. package/package/transports/metrics.js +0 -105
  221. package/package/transports/rest.d.ts +0 -43
  222. package/package/transports/rest.js +0 -129
  223. package/package/transports/util.d.ts +0 -8
  224. package/package/transports/util.js +0 -85
  225. package/package/transports/websocket.d.ts +0 -80
  226. package/package/transports/websocket.js +0 -169
  227. package/package/util/expiring-sorted-set.d.ts +0 -21
  228. package/package/util/expiring-sorted-set.js +0 -47
  229. package/package/util/index.d.ts +0 -11
  230. package/package/util/index.js +0 -35
  231. package/package/util/logger.d.ts +0 -42
  232. package/package/util/logger.js +0 -62
  233. package/package/util/request.d.ts +0 -55
  234. package/package/util/request.js +0 -2
  235. package/package/validation/error.d.ts +0 -50
  236. package/package/validation/error.js +0 -79
  237. package/package/validation/index.d.ts +0 -5
  238. package/package/validation/index.js +0 -86
  239. package/package/validation/input-params.d.ts +0 -15
  240. package/package/validation/input-params.js +0 -30
  241. package/package/validation/override-functions.d.ts +0 -3
  242. package/package/validation/override-functions.js +0 -40
  243. package/package/validation/preset-tokens.json +0 -23
  244. package/package/validation/validator.d.ts +0 -47
  245. package/package/validation/validator.js +0 -303
  246. package/rate-limiting/background/fixed-frequency.d.ts +0 -10
  247. package/rate-limiting/background/fixed-frequency.js +0 -35
  248. package/rate-limiting/index.d.ts +0 -54
  249. package/rate-limiting/index.js +0 -63
  250. package/rate-limiting/metrics.d.ts +0 -3
  251. package/rate-limiting/metrics.js +0 -44
  252. package/rate-limiting/request/simple-counting.d.ts +0 -20
  253. package/rate-limiting/request/simple-counting.js +0 -62
  254. package/test.d.ts +0 -1
  255. package/test.js +0 -6
  256. package/transports/batch-warming.d.ts +0 -35
  257. package/transports/batch-warming.js +0 -101
  258. package/transports/index.d.ts +0 -70
  259. package/transports/index.js +0 -87
  260. package/transports/metrics.d.ts +0 -21
  261. package/transports/metrics.js +0 -105
  262. package/transports/rest.d.ts +0 -44
  263. package/transports/rest.js +0 -131
  264. package/transports/util.d.ts +0 -8
  265. package/transports/util.js +0 -85
  266. package/transports/websocket.d.ts +0 -81
  267. package/transports/websocket.js +0 -168
  268. package/util/expiring-sorted-set.d.ts +0 -21
  269. package/util/expiring-sorted-set.js +0 -47
  270. package/util/index.d.ts +0 -12
  271. package/util/index.js +0 -35
  272. package/util/logger.d.ts +0 -42
  273. package/util/logger.js +0 -62
  274. package/util/request.d.ts +0 -57
  275. package/util/request.js +0 -2
  276. package/util/subscription-set/expiring-sorted-set.d.ts +0 -22
  277. package/util/subscription-set/expiring-sorted-set.js +0 -47
  278. package/util/subscription-set/subscription-set.d.ts +0 -18
  279. package/util/subscription-set/subscription-set.js +0 -19
  280. package/util/test-payload-loader.d.ts +0 -25
  281. package/util/test-payload-loader.js +0 -83
  282. package/validation/error.d.ts +0 -50
  283. package/validation/error.js +0 -79
  284. package/validation/index.d.ts +0 -5
  285. package/validation/index.js +0 -91
  286. package/validation/input-params.d.ts +0 -15
  287. package/validation/input-params.js +0 -30
  288. package/validation/override-functions.d.ts +0 -3
  289. package/validation/override-functions.js +0 -40
  290. package/validation/preset-tokens.json +0 -23
  291. package/validation/validator.d.ts +0 -47
  292. package/validation/validator.js +0 -303
package/.c8rc.json ADDED
@@ -0,0 +1,3 @@
1
+ {
2
+ "reporter": ["lcov", "text"]
3
+ }
package/.eslintignore ADDED
@@ -0,0 +1,10 @@
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 coverage output
6
+ coverage
7
+
8
+ .yarn
9
+ .vscode
10
+ webpack.config.js
package/.eslintrc.js ADDED
@@ -0,0 +1,96 @@
1
+ // https://github.com/typescript-eslint/typescript-eslint/blob/master/docs/getting-started/linting/README.md
2
+ module.exports = {
3
+ root: true,
4
+ parser: '@typescript-eslint/parser',
5
+ plugins: ['@typescript-eslint', 'eslint-plugin-tsdoc'],
6
+ extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'prettier'],
7
+ rules: {
8
+ 'tsdoc/syntax': 'warn',
9
+
10
+ // Problems
11
+ 'array-callback-return': [
12
+ 'error',
13
+ {
14
+ allowImplicit: false,
15
+ checkForEach: true,
16
+ },
17
+ ],
18
+ 'no-constant-binary-expression': 'error',
19
+ 'no-constructor-return': 'error',
20
+ 'no-duplicate-imports': 'error',
21
+ 'no-promise-executor-return': 'error',
22
+ 'no-self-compare': 'error',
23
+ 'no-template-curly-in-string': 'error',
24
+ 'no-unmodified-loop-condition': 'error',
25
+ 'no-unreachable-loop': 'error',
26
+ 'no-unused-private-class-members': 'error',
27
+ 'require-atomic-updates': 'error',
28
+
29
+ // Suggestions
30
+ 'capitalized-comments': ['error', 'always', { ignoreConsecutiveComments: true }],
31
+ complexity: ['error', 25], // TODO: Should be lower (15?), but validator has complex methods
32
+ curly: 'error',
33
+ 'default-case-last': 'error',
34
+ 'default-param-last': 'error',
35
+ eqeqeq: ['error', 'smart'],
36
+ 'func-names': 'error',
37
+ 'func-style': ['error', 'declaration', { allowArrowFunctions: true }],
38
+ 'grouped-accessor-pairs': ['error', 'getBeforeSet'],
39
+ 'max-depth': ['error', 4], // TODO: Should be lower (3), but validator has complex methods
40
+ 'max-nested-callbacks': ['error', 2],
41
+ 'max-params': ['error', 4], // TODO: Should be lower (3), but validator has complex methods,
42
+ 'new-cap': ['error', { newIsCapExceptions: ['ctor'] }],
43
+ 'no-caller': 'error',
44
+ 'no-confusing-arrow': [
45
+ 'error',
46
+ {
47
+ allowParens: true,
48
+ },
49
+ ],
50
+ 'no-console': ['warn'], // We want this to debug, but the check workflow should accept no warns
51
+ 'no-div-regex': 'error',
52
+ 'no-eval': 'error',
53
+ 'no-extend-native': 'error',
54
+ 'no-extra-bind': 'error',
55
+ 'no-extra-label': 'error',
56
+ 'no-extra-semi': 'error',
57
+ 'no-floating-decimal': 'error',
58
+ 'no-implied-eval': 'error',
59
+ 'no-invalid-this': 'error',
60
+ 'no-labels': 'error',
61
+ 'no-lonely-if': 'error',
62
+ 'no-multi-assign': 'error',
63
+ 'no-multi-str': 'error',
64
+ 'no-nested-ternary': 'error',
65
+ 'no-new': 'error',
66
+ 'no-new-func': 'error',
67
+ 'no-new-object': 'error',
68
+ 'no-new-wrappers': 'error',
69
+ 'no-param-reassign': 'error',
70
+ 'no-proto': 'error',
71
+ 'no-return-assign': 'error',
72
+ 'no-return-await': 'error',
73
+ 'no-sequences': 'error',
74
+ 'no-shadow': 'off',
75
+ '@typescript-eslint/no-shadow': 'error', // https://stackoverflow.com/questions/63961803/eslint-says-all-enums-in-typescript-app-are-already-declared-in-the-upper-scope
76
+ 'no-unneeded-ternary': 'error',
77
+ 'no-useless-call': 'error',
78
+ 'no-useless-computed-key': 'error',
79
+ 'no-useless-concat': 'error',
80
+ 'no-useless-rename': 'error',
81
+ 'no-var': 'error',
82
+ 'operator-assignment': ['error', 'always'],
83
+ 'prefer-arrow-callback': 'error',
84
+ 'prefer-const': 'error',
85
+ 'prefer-exponentiation-operator': 'error',
86
+ 'prefer-object-spread': 'error',
87
+ 'prefer-promise-reject-errors': 'error',
88
+ 'prefer-regex-literals': 'error',
89
+ 'prefer-rest-params': 'error',
90
+ 'prefer-spread': 'error',
91
+ 'prefer-template': 'error',
92
+ 'spaced-comment': ['error', 'always'],
93
+ 'symbol-description': 'error',
94
+ yoda: 'error',
95
+ },
96
+ }
@@ -0,0 +1,42 @@
1
+ # Github workflows for EAv3 Framework
2
+
3
+ **Please note that this work is in progress. The README may not be kept up to date as the CI process changes. This message will be removed when we're somewhat stable.**
4
+
5
+ ## Actions
6
+ ### setup
7
+ Runs yarn install, then yarn build. Split into an action to avoid boilerplate in jobs.
8
+
9
+ ## Workflows
10
+
11
+ ### main
12
+ Builds, tests, and lints the code. Triggered by any pull request action or a push on the master branch.
13
+
14
+ ### label
15
+
16
+ Adds a label to a PR based on the branch name, and adds a label instructing `npm version` how to bump the version number.
17
+
18
+ Labels are applied automatically only when a PR is opened. If it applies the wrong label (ex: your improvement is a minor ver, or some PR is a major ver), you can fix it by hand
19
+
20
+ #### Label mappings:
21
+
22
+ | Branch Prefix | Resulting label(s) | Version bump |
23
+ | --- |--------------------------------|--------------|
24
+ | release | release, major | major |
25
+ | feature/ | feature, minor | minor |
26
+ | bugfix/ | bugfix, patch | patch |
27
+ | hotfix/ | hotfix, patch | patch |
28
+ | fix/ | hotpix, patch | patch |
29
+ | chore/ | chore, patch | patch |
30
+ | improvement/ | improvement, patch | patch |
31
+ | documentation/ | documentation, no-version-tick | none |
32
+ | noop/ | no-version-tick | none |
33
+
34
+ ### publish
35
+ Bumps the version number based on the label if present, then builds and publishes the package to NPM. This step is skipped if the change doesn't result in a version bump.
36
+
37
+ This action **requires** any engineer to approve it.
38
+
39
+ ### Some steps that still need to be added in:
40
+ 1. Check that changelog has an entry matching the current version in package.json
41
+ 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
42
+ 3. npm-check step that produces a report as an artifact
@@ -0,0 +1,13 @@
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
@@ -0,0 +1,39 @@
1
+ # Adds labels to pull requests based on the branch name. Labels are required by the "publish" workflow to determine
2
+ name: 'Labels'
3
+ on:
4
+ pull_request:
5
+ # TODO below is commented temporarily for testing
6
+ # types:
7
+ # - opened
8
+
9
+ jobs:
10
+ publish: # Load the dependencies cache for all jobs
11
+ runs-on: ubuntu-latest
12
+ environment: main
13
+ steps:
14
+ - uses: actions/checkout@v3
15
+ - name: Calculate labels
16
+ id: calc-labels
17
+ run: |
18
+ echo "Calculating labels based on branch: ${{ github.head_ref }}
19
+ HR=${{ github.head_ref }}
20
+ if [[ $hr == "improvement/*" ]]; then
21
+ run: echo '::set-output name=LABELS::"improvement, patch"'
22
+ elif [[ $hr == "feature/*" ]]; then
23
+ run: echo '::set-output name=LABELS::"feature, minor"'
24
+ elif [[ $hr == "bugfix/*" ]]; then
25
+ run: echo '::set-output name=LABELS::"bugfix, patch"'
26
+ elif [[ $hr == "hotfix/*" ]]; then
27
+ run: echo '::set-output name=LABELS::"hotfix, patch"'
28
+ elif [[ $hr == "release/*" ]]; then
29
+ run: echo '::set-output name=LABELS::"release, major"'
30
+ elif [[ $hr == "chore/*" ]]; then
31
+ run: echo '::set-output name=LABELS::"chore, patch"'
32
+ elif [[ $hr == "docs/*" ]]; then
33
+ run: echo '::set-output name=LABELS::"docs, noop"'
34
+ else
35
+ run: echo '::set-output name=LABELS::"FIXME"'
36
+ fi
37
+ - uses: andymckay/labeler@master # Used in the official docs
38
+ with:
39
+ add-labels: ${{ steps.calc-labels.outputs.LABELS }}
@@ -0,0 +1,39 @@
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
@@ -0,0 +1,17 @@
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: npm publish --access restricted #scoped packages are restricted by default, but this is set because not all branches currently have a scoped package name
16
+ env:
17
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
@@ -0,0 +1,13 @@
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 ADDED
File without changes
package/README.md ADDED
@@ -0,0 +1,103 @@
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 | | |