@chainlink/external-adapter-framework 0.0.15 → 0.0.16

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 (183) hide show
  1. package/adapter.js +128 -0
  2. package/background-executor.js +45 -0
  3. package/cache/factory.js +58 -0
  4. package/cache/index.js +173 -0
  5. package/cache/local.js +83 -0
  6. package/cache/metrics.js +120 -0
  7. package/cache/redis.js +100 -0
  8. package/chainlink-external-adapter-framework-v0.0.6.tgz +0 -0
  9. package/config/index.js +366 -0
  10. package/config/provider-limits.js +74 -0
  11. package/examples/bank-frick/accounts.js +192 -0
  12. package/examples/bank-frick/config/index.js +54 -0
  13. package/examples/bank-frick/index.js +15 -0
  14. package/examples/bank-frick/util.js +39 -0
  15. package/examples/coingecko/src/config/index.js +13 -0
  16. package/examples/coingecko/src/config/overrides.json +10826 -0
  17. package/examples/coingecko/src/cryptoUtils.js +41 -0
  18. package/examples/coingecko/src/endpoint/coins.js +33 -0
  19. package/examples/coingecko/src/endpoint/crypto-marketcap.js +46 -0
  20. package/examples/coingecko/src/endpoint/crypto-volume.js +46 -0
  21. package/examples/coingecko/src/endpoint/crypto.js +47 -0
  22. package/examples/coingecko/src/endpoint/dominance.js +26 -0
  23. package/examples/coingecko/src/endpoint/global-marketcap.js +26 -0
  24. package/examples/coingecko/src/endpoint/index.js +15 -0
  25. package/examples/coingecko/src/globalUtils.js +48 -0
  26. package/examples/coingecko/src/index.js +14 -0
  27. package/examples/coingecko/test/e2e/adapter.test.js +262 -0
  28. package/examples/coingecko/test/integration/adapter.test.js +264 -0
  29. package/examples/coingecko/test/integration/capturedRequests.json +1 -0
  30. package/examples/coingecko/test/integration/fixtures.js +41 -0
  31. package/examples/coingecko-old/batch-warming.js +53 -0
  32. package/examples/coingecko-old/index.js +11 -0
  33. package/examples/coingecko-old/rest.js +51 -0
  34. package/examples/ncfx/config/index.js +15 -0
  35. package/examples/ncfx/index.js +11 -0
  36. package/examples/ncfx/websocket.js +73 -0
  37. package/index.js +127 -0
  38. package/metrics/constants.js +25 -0
  39. package/metrics/index.js +122 -0
  40. package/metrics/util.js +9 -0
  41. package/package.json +5 -15
  42. package/rate-limiting/background/fixed-frequency.js +35 -0
  43. package/rate-limiting/index.js +84 -0
  44. package/rate-limiting/metrics.js +44 -0
  45. package/rate-limiting/request/simple-counting.js +62 -0
  46. package/test.js +6 -0
  47. package/transports/batch-warming.js +101 -0
  48. package/transports/index.js +87 -0
  49. package/transports/metrics.js +105 -0
  50. package/transports/rest.js +138 -0
  51. package/transports/util.js +86 -0
  52. package/transports/websocket.js +166 -0
  53. package/util/index.js +35 -0
  54. package/util/logger.js +62 -0
  55. package/util/recordRequests.js +45 -0
  56. package/util/request.js +2 -0
  57. package/util/subscription-set/expiring-sorted-set.js +47 -0
  58. package/util/subscription-set/subscription-set.js +19 -0
  59. package/util/test-payload-loader.js +83 -0
  60. package/validation/error.js +79 -0
  61. package/validation/index.js +91 -0
  62. package/validation/input-params.js +30 -0
  63. package/validation/override-functions.js +40 -0
  64. package/validation/overrideFunctions.js +40 -0
  65. package/validation/preset-tokens.json +23 -0
  66. package/validation/validator.js +303 -0
  67. package/.c8rc.json +0 -3
  68. package/.eslintignore +0 -10
  69. package/.eslintrc.js +0 -96
  70. package/.github/README.MD +0 -42
  71. package/.github/actions/setup/action.yaml +0 -13
  72. package/.github/workflows/label.yaml +0 -39
  73. package/.github/workflows/main.yaml +0 -39
  74. package/.github/workflows/publish.yaml +0 -17
  75. package/.prettierignore +0 -13
  76. package/.yarnrc +0 -0
  77. package/README.md +0 -103
  78. package/dist/examples/coingecko/test/e2e/adapter.test.ts.js +0 -82953
  79. package/dist/examples/coingecko/test/integration/adapter.test.ts.js +0 -91672
  80. package/dist/main.js +0 -72703
  81. package/docker-compose.yaml +0 -35
  82. package/env.sh +0 -54
  83. package/env2.sh +0 -55
  84. package/jest.config.js +0 -5
  85. package/publish.sh +0 -0
  86. package/src/adapter.ts +0 -263
  87. package/src/background-executor.ts +0 -52
  88. package/src/cache/factory.ts +0 -26
  89. package/src/cache/index.ts +0 -258
  90. package/src/cache/local.ts +0 -73
  91. package/src/cache/metrics.ts +0 -112
  92. package/src/cache/redis.ts +0 -93
  93. package/src/config/index.ts +0 -517
  94. package/src/config/provider-limits.ts +0 -127
  95. package/src/examples/bank-frick/README.MD +0 -10
  96. package/src/examples/bank-frick/accounts.ts +0 -246
  97. package/src/examples/bank-frick/config/index.ts +0 -53
  98. package/src/examples/bank-frick/index.ts +0 -13
  99. package/src/examples/bank-frick/types.d.ts +0 -38
  100. package/src/examples/bank-frick/util.ts +0 -55
  101. package/src/examples/coingecko/src/config/index.ts +0 -12
  102. package/src/examples/coingecko/src/config/overrides.json +0 -10826
  103. package/src/examples/coingecko/src/cryptoUtils.ts +0 -88
  104. package/src/examples/coingecko/src/endpoint/coins.ts +0 -54
  105. package/src/examples/coingecko/src/endpoint/crypto-marketcap.ts +0 -66
  106. package/src/examples/coingecko/src/endpoint/crypto-volume.ts +0 -66
  107. package/src/examples/coingecko/src/endpoint/crypto.ts +0 -63
  108. package/src/examples/coingecko/src/endpoint/dominance.ts +0 -40
  109. package/src/examples/coingecko/src/endpoint/global-marketcap.ts +0 -40
  110. package/src/examples/coingecko/src/endpoint/index.ts +0 -6
  111. package/src/examples/coingecko/src/globalUtils.ts +0 -78
  112. package/src/examples/coingecko/src/index.ts +0 -17
  113. package/src/examples/coingecko/test/e2e/adapter.test.ts +0 -278
  114. package/src/examples/coingecko/test/integration/__snapshots__/adapter.test.ts.snap +0 -15
  115. package/src/examples/coingecko/test/integration/adapter.test.ts +0 -281
  116. package/src/examples/coingecko/test/integration/capturedRequests.json +0 -1
  117. package/src/examples/coingecko/test/integration/fixtures.ts +0 -42
  118. package/src/examples/coingecko-old/batch-warming.ts +0 -79
  119. package/src/examples/coingecko-old/index.ts +0 -9
  120. package/src/examples/coingecko-old/rest.ts +0 -77
  121. package/src/examples/ncfx/config/index.ts +0 -12
  122. package/src/examples/ncfx/index.ts +0 -9
  123. package/src/examples/ncfx/websocket.ts +0 -99
  124. package/src/index.ts +0 -149
  125. package/src/metrics/constants.ts +0 -23
  126. package/src/metrics/index.ts +0 -115
  127. package/src/metrics/util.ts +0 -18
  128. package/src/rate-limiting/background/fixed-frequency.ts +0 -45
  129. package/src/rate-limiting/index.ts +0 -100
  130. package/src/rate-limiting/metrics.ts +0 -18
  131. package/src/rate-limiting/request/simple-counting.ts +0 -76
  132. package/src/transports/batch-warming.ts +0 -127
  133. package/src/transports/index.ts +0 -152
  134. package/src/transports/metrics.ts +0 -95
  135. package/src/transports/rest.ts +0 -168
  136. package/src/transports/util.ts +0 -63
  137. package/src/transports/websocket.ts +0 -245
  138. package/src/util/index.ts +0 -23
  139. package/src/util/logger.ts +0 -69
  140. package/src/util/recordRequests.ts +0 -47
  141. package/src/util/request.ts +0 -117
  142. package/src/util/subscription-set/expiring-sorted-set.ts +0 -54
  143. package/src/util/subscription-set/subscription-set.ts +0 -35
  144. package/src/util/test-payload-loader.ts +0 -87
  145. package/src/validation/error.ts +0 -116
  146. package/src/validation/index.ts +0 -110
  147. package/src/validation/input-params.ts +0 -45
  148. package/src/validation/override-functions.ts +0 -44
  149. package/src/validation/overrideFunctions.ts +0 -44
  150. package/src/validation/preset-tokens.json +0 -23
  151. package/src/validation/validator.ts +0 -384
  152. package/test/adapter.test.ts +0 -27
  153. package/test/background-executor.test.ts +0 -108
  154. package/test/cache/cache-key.test.ts +0 -114
  155. package/test/cache/helper.ts +0 -100
  156. package/test/cache/local.test.ts +0 -54
  157. package/test/cache/redis.test.ts +0 -89
  158. package/test/correlation.test.ts +0 -114
  159. package/test/index.test.ts +0 -37
  160. package/test/metrics/feed-id.test.ts +0 -38
  161. package/test/metrics/helper.ts +0 -14
  162. package/test/metrics/labels.test.ts +0 -36
  163. package/test/metrics/metrics.test.ts +0 -267
  164. package/test/metrics/redis-metrics.test.ts +0 -113
  165. package/test/metrics/warmer-metrics.test.ts +0 -193
  166. package/test/metrics/ws-metrics.test.ts +0 -225
  167. package/test/rate-limit-config.test.ts +0 -242
  168. package/test/smoke/smoke.test.ts +0 -166
  169. package/test/smoke/test-payload-fail.json +0 -3
  170. package/test/smoke/test-payload.js +0 -22
  171. package/test/smoke/test-payload.json +0 -7
  172. package/test/transports/batch.test.ts +0 -466
  173. package/test/transports/rest.test.ts +0 -242
  174. package/test/transports/websocket.test.ts +0 -183
  175. package/test/tsconfig.json +0 -5
  176. package/test/util.ts +0 -77
  177. package/test/validation.test.ts +0 -178
  178. package/test.sh +0 -20
  179. package/test2.sh +0 -2
  180. package/tsconfig.json +0 -28
  181. package/typedoc.json +0 -6
  182. package/webpack.config.js +0 -57
  183. package/yarn-error.log +0 -3778
package/.github/README.MD DELETED
@@ -1,42 +0,0 @@
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
@@ -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
- # 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 }}
@@ -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,17 +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: 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 }}
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 | | |