@chainlink/external-adapter-framework 0.0.21 → 0.0.25

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 (70) hide show
  1. package/package.json +1 -1
  2. package/adapter.d.ts +0 -139
  3. package/background-executor.d.ts +0 -9
  4. package/cache/factory.d.ts +0 -6
  5. package/cache/index.d.ts +0 -94
  6. package/cache/local.d.ts +0 -23
  7. package/cache/metrics.d.ts +0 -27
  8. package/cache/redis.d.ts +0 -16
  9. package/config/index.d.ts +0 -258
  10. package/config/provider-limits.d.ts +0 -27
  11. package/examples/bank-frick/accounts.d.ts +0 -39
  12. package/examples/bank-frick/config/index.d.ts +0 -4
  13. package/examples/bank-frick/index.d.ts +0 -2
  14. package/examples/bank-frick/util.d.ts +0 -4
  15. package/examples/coingecko/batch-warming.d.ts +0 -7
  16. package/examples/coingecko/batch-warming.js +0 -53
  17. package/examples/coingecko/index.d.ts +0 -2
  18. package/examples/coingecko/index.js +0 -11
  19. package/examples/coingecko/rest.d.ts +0 -12
  20. package/examples/coingecko/rest.js +0 -51
  21. package/examples/coingecko/src/config/index.d.ts +0 -2
  22. package/examples/coingecko/src/cryptoUtils.d.ts +0 -31
  23. package/examples/coingecko/src/endpoint/coins.d.ts +0 -9
  24. package/examples/coingecko/src/endpoint/crypto-marketcap.d.ts +0 -3
  25. package/examples/coingecko/src/endpoint/crypto-volume.d.ts +0 -3
  26. package/examples/coingecko/src/endpoint/crypto.d.ts +0 -3
  27. package/examples/coingecko/src/endpoint/dominance.d.ts +0 -3
  28. package/examples/coingecko/src/endpoint/global-marketcap.d.ts +0 -3
  29. package/examples/coingecko/src/endpoint/index.d.ts +0 -6
  30. package/examples/coingecko/src/globalUtils.d.ts +0 -27
  31. package/examples/coingecko/src/index.d.ts +0 -4
  32. package/examples/coingecko/test/e2e/adapter.test.js +0 -262
  33. package/examples/coingecko/test/integration/adapter.test.js +0 -264
  34. package/examples/coingecko/test/integration/capturedRequests.json +0 -1
  35. package/examples/coingecko/test/integration/fixtures.js +0 -41
  36. package/examples/coingecko-old/batch-warming.d.ts +0 -7
  37. package/examples/coingecko-old/index.d.ts +0 -2
  38. package/examples/coingecko-old/rest.d.ts +0 -12
  39. package/examples/ncfx/config/index.d.ts +0 -12
  40. package/examples/ncfx/index.d.ts +0 -13
  41. package/examples/ncfx/websocket.d.ts +0 -47
  42. package/index.d.ts +0 -11
  43. package/metrics/constants.d.ts +0 -16
  44. package/metrics/index.d.ts +0 -15
  45. package/metrics/util.d.ts +0 -7
  46. package/rate-limiting/background/fixed-frequency.d.ts +0 -11
  47. package/rate-limiting/index.d.ts +0 -55
  48. package/rate-limiting/metrics.d.ts +0 -3
  49. package/rate-limiting/request/simple-counting.d.ts +0 -21
  50. package/test.d.ts +0 -1
  51. package/test.js +0 -6
  52. package/transports/batch-warming.d.ts +0 -35
  53. package/transports/index.d.ts +0 -73
  54. package/transports/metrics.d.ts +0 -22
  55. package/transports/rest.d.ts +0 -44
  56. package/transports/util.d.ts +0 -9
  57. package/transports/websocket.d.ts +0 -80
  58. package/util/index.d.ts +0 -12
  59. package/util/logger.d.ts +0 -42
  60. package/util/recordRequests.js +0 -45
  61. package/util/request.d.ts +0 -56
  62. package/util/subscription-set/expiring-sorted-set.d.ts +0 -22
  63. package/util/subscription-set/subscription-set.d.ts +0 -18
  64. package/util/test-payload-loader.d.ts +0 -25
  65. package/validation/error.d.ts +0 -50
  66. package/validation/index.d.ts +0 -5
  67. package/validation/input-params.d.ts +0 -15
  68. package/validation/override-functions.d.ts +0 -3
  69. package/validation/overrideFunctions.js +0 -40
  70. package/validation/validator.d.ts +0 -47
@@ -1,4 +0,0 @@
1
- import { SigningAlgorithm } from './types';
2
- import { customSettings } from './config';
3
- import { AdapterConfig } from '../../config';
4
- export declare const generateJWT: (config: AdapterConfig<typeof customSettings>, signingAlgorithm?: SigningAlgorithm) => Promise<string>;
@@ -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,53 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.batchEndpoint = void 0;
4
- const adapter_1 = require("../../adapter");
5
- const batch_warming_1 = require("../../transports/batch-warming");
6
- const DEFAULT_URL = 'https://pro-api.coingecko.com/api/v3';
7
- const inputParameters = {
8
- coinid: {
9
- description: 'The CoinGecko id or array of ids of the coin(s) to query (Note: because of current limitations to use a dummy base will need to be supplied)',
10
- required: false,
11
- },
12
- base: {
13
- aliases: ['from', 'coin'],
14
- description: 'The symbol or array of symbols of the currency to query',
15
- required: true,
16
- },
17
- quote: {
18
- aliases: ['to', 'market'],
19
- description: 'The symbol of the currency to convert to',
20
- required: true,
21
- },
22
- };
23
- const batchEndpointTransport = new batch_warming_1.BatchWarmingTransport({
24
- prepareRequest: (params, context) => {
25
- return {
26
- baseURL: DEFAULT_URL,
27
- url: '/simple/price',
28
- method: 'GET',
29
- params: {
30
- ids: [...new Set(params.map((p) => p.base))].join(','),
31
- vs_currencies: [...new Set(params.map((p) => p.quote))].join(','),
32
- x_cg_pro_api_key: context.adapterConfig.API_KEY,
33
- },
34
- };
35
- },
36
- parseResponse: (res) => {
37
- const entries = [];
38
- for (const [base, entry] of Object.entries(res.data)) {
39
- for (const [quote, price] of Object.entries(entry)) {
40
- entries.push({
41
- params: { base, quote },
42
- value: price,
43
- });
44
- }
45
- }
46
- return entries;
47
- },
48
- });
49
- exports.batchEndpoint = new adapter_1.AdapterEndpoint({
50
- name: 'batch',
51
- transport: batchEndpointTransport,
52
- inputParameters,
53
- });
@@ -1,2 +0,0 @@
1
- import { Adapter } from '../../adapter';
2
- export declare const adapter: Adapter<import("../../config").SettingsMap>;
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.adapter = void 0;
4
- const adapter_1 = require("../../adapter");
5
- const batch_warming_1 = require("./batch-warming");
6
- const rest_1 = require("./rest");
7
- exports.adapter = new adapter_1.Adapter({
8
- name: 'coingecko',
9
- defaultEndpoint: 'batch',
10
- endpoints: [rest_1.restEndpoint, batch_warming_1.batchEndpoint],
11
- });
@@ -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,51 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.restEndpoint = void 0;
4
- const adapter_1 = require("../../adapter");
5
- const transports_1 = require("../../transports");
6
- const DEFAULT_URL = 'https://api.coingecko.com/api/v3';
7
- const inputParameters = {
8
- coinid: {
9
- description: 'The CoinGecko id or array of ids of the coin(s) to query (Note: because of current limitations to use a dummy base will need to be supplied)',
10
- required: false,
11
- },
12
- base: {
13
- aliases: ['from', 'coin'],
14
- description: 'The symbol or array of symbols of the currency to query',
15
- required: true,
16
- },
17
- quote: {
18
- aliases: ['to', 'market'],
19
- description: 'The symbol of the currency to convert to',
20
- required: true,
21
- },
22
- };
23
- const restEndpointTransport = new transports_1.RestTransport({
24
- prepareRequest: (req) => {
25
- return {
26
- baseURL: DEFAULT_URL,
27
- url: '/simple/price',
28
- method: 'GET',
29
- params: {
30
- ids: req.requestContext.data.base,
31
- vs_currencies: req.requestContext.data.quote,
32
- },
33
- };
34
- },
35
- parseResponse: (req, res) => {
36
- return {
37
- data: res.data,
38
- statusCode: 200,
39
- result: res.data[req.requestContext.data.base]?.[req.requestContext.data.quote],
40
- };
41
- },
42
- options: {
43
- coalescing: true,
44
- },
45
- });
46
- exports.restEndpoint = new adapter_1.AdapterEndpoint({
47
- name: 'rest',
48
- aliases: ['qwe'],
49
- transport: restEndpointTransport,
50
- inputParameters,
51
- });
@@ -1,2 +0,0 @@
1
- export declare const DEFAULT_API_ENDPOINT = "https://api.coingecko.com/api/v3";
2
- export declare const PRO_API_ENDPOINT = "https://pro-api.coingecko.com/api/v3";
@@ -1,31 +0,0 @@
1
- import { AxiosRequestConfig, AxiosResponse } from 'axios';
2
- import { AdapterConfig } from '../../../config';
3
- import { InputParameters } from '../../../validation';
4
- export interface CryptoRequestParams {
5
- coinid?: string;
6
- base?: string;
7
- quote: string;
8
- }
9
- export declare const cryptoInputParams: InputParameters;
10
- export interface ProviderRequestBody {
11
- ids: string;
12
- vs_currencies: string;
13
- include_market_cap?: boolean;
14
- include_24hr_vol?: boolean;
15
- }
16
- export interface ProviderResponseBody {
17
- [base: string]: {
18
- [quote: string]: number;
19
- };
20
- }
21
- interface ResultEntryWithoutOverrides {
22
- value: number;
23
- params: {
24
- quote: string;
25
- base?: string;
26
- coinid?: string;
27
- };
28
- }
29
- export declare const buildBatchedRequestBody: (params: CryptoRequestParams[], config: AdapterConfig) => AxiosRequestConfig<ProviderRequestBody>;
30
- export declare const constructEntry: (res: AxiosResponse<ProviderResponseBody>, requestPayload: CryptoRequestParams, resultPath: string) => ResultEntryWithoutOverrides | undefined;
31
- export {};
@@ -1,9 +0,0 @@
1
- import { AdapterEndpoint } from '../../../../../src/adapter';
2
- import { InputParameters } from '../../../../../src/validation';
3
- export declare const inputParameters: InputParameters;
4
- export interface CoinsResponse {
5
- id: string;
6
- symbol: string;
7
- name: string;
8
- }
9
- export declare const endpoint: AdapterEndpoint<import("../../../../util/request").AdapterRequestData, CoinsResponse[], import("../../../../config").SettingsMap>;
@@ -1,3 +0,0 @@
1
- import { AdapterEndpoint } from '../../../../adapter';
2
- import { CryptoRequestParams } from '../cryptoUtils';
3
- export declare const endpoint: AdapterEndpoint<CryptoRequestParams, unknown, import("../../../../config").SettingsMap>;
@@ -1,3 +0,0 @@
1
- import { AdapterEndpoint } from '../../../../adapter';
2
- import { CryptoRequestParams } from '../cryptoUtils';
3
- export declare const endpoint: AdapterEndpoint<CryptoRequestParams, unknown, import("../../../../config").SettingsMap>;
@@ -1,3 +0,0 @@
1
- import { AdapterEndpoint } from '../../../../adapter';
2
- import { CryptoRequestParams } from '../cryptoUtils';
3
- export declare const endpoint: AdapterEndpoint<CryptoRequestParams, unknown, import("../../../../config").SettingsMap>;
@@ -1,3 +0,0 @@
1
- import { AdapterEndpoint } from '../../../../adapter';
2
- import { AdapterRequestParams } from '../globalUtils';
3
- export declare const endpoint: AdapterEndpoint<AdapterRequestParams, unknown, import("../../../../config").SettingsMap>;
@@ -1,3 +0,0 @@
1
- import { AdapterEndpoint } from '../../../../adapter';
2
- import { AdapterRequestParams } from '../globalUtils';
3
- export declare const endpoint: AdapterEndpoint<AdapterRequestParams, unknown, import("../../../../config").SettingsMap>;
@@ -1,6 +0,0 @@
1
- export { endpoint as coins } from './coins';
2
- export { endpoint as crypto } from './crypto';
3
- export { endpoint as cryptoMarketcap } from './crypto-marketcap';
4
- export { endpoint as globalMarketcap } from './global-marketcap';
5
- export { endpoint as dominance } from './dominance';
6
- export { endpoint as cryptoVolume } from './crypto-volume';
@@ -1,27 +0,0 @@
1
- import { AxiosRequestConfig, AxiosResponse } from 'axios';
2
- import { InputParameters } from '../../../validation';
3
- export declare const inputParameters: InputParameters;
4
- export interface AdapterRequestParams {
5
- market: string;
6
- }
7
- export interface ProviderResponseBody {
8
- data: {
9
- active_cryptocurrencies: number;
10
- upcoming_icos: number;
11
- ongoing_icos: number;
12
- ended_icos: number;
13
- markets: number;
14
- total_market_cap: Record<string, number>;
15
- total_volume: Record<string, number>;
16
- market_cap_percentage: Record<string, number>;
17
- market_cap_change_percentage_24h_usd: number;
18
- updated_at: number;
19
- };
20
- }
21
- interface ResultEntry {
22
- value: number;
23
- params: AdapterRequestParams;
24
- }
25
- export declare const buildGlobalRequestBody: (apiKey?: string) => AxiosRequestConfig<never>;
26
- export declare const constructEntry: (res: AxiosResponse<ProviderResponseBody>, requestPayload: AdapterRequestParams, resultPath: 'total_market_cap' | 'market_cap_percentage') => ResultEntry | undefined;
27
- export {};
@@ -1,4 +0,0 @@
1
- /// <reference types="node" />
2
- import { Adapter } from '../../../../src/adapter';
3
- export declare const adapter: Adapter<import("../../../config").SettingsMap>;
4
- export declare const server: () => Promise<import("fastify").FastifyInstance<import("fastify").RawServerDefault, import("http").IncomingMessage, import("http").ServerResponse<import("http").IncomingMessage>, import("fastify").FastifyBaseLogger, import("fastify").FastifyTypeProviderDefault> | undefined>;
@@ -1,262 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- /* eslint-disable max-nested-callbacks */
7
- const index_1 = require("../../src/index");
8
- const __1 = require("../../../..");
9
- const supertest_1 = __importDefault(require("supertest"));
10
- let adapterServer;
11
- function sleep(ms) {
12
- // eslint-disable-next-line
13
- return new Promise((resolve) => setTimeout(resolve, ms));
14
- }
15
- describe('execute', () => {
16
- const id = '1';
17
- let req;
18
- jest.setTimeout(10000);
19
- const successfulRequests = {
20
- crypto: {
21
- id,
22
- data: {
23
- base: 'ETH',
24
- quote: 'USD',
25
- },
26
- },
27
- cryptoWithCoinid: {
28
- id,
29
- data: {
30
- coinid: 'bitcoin',
31
- quote: 'USD',
32
- },
33
- },
34
- cryptoWithOverride: {
35
- id,
36
- data: {
37
- base: 'BTC',
38
- quote: 'EUR',
39
- overrides: {
40
- coingecko: {
41
- BTC: 'solana',
42
- },
43
- },
44
- },
45
- },
46
- coins: {
47
- id,
48
- endpoint: 'coins',
49
- },
50
- marketcap: {
51
- id,
52
- endpoint: 'marketcap',
53
- data: {
54
- base: 'ETH',
55
- quote: 'USD',
56
- },
57
- },
58
- volume: {
59
- id,
60
- endpoint: 'volume',
61
- data: {
62
- base: 'ETH',
63
- quote: 'USD',
64
- },
65
- },
66
- globalmarketcap: {
67
- id,
68
- endpoint: 'globalmarketcap',
69
- data: {
70
- market: 'ETH',
71
- },
72
- },
73
- dominance: {
74
- id,
75
- endpoint: 'dominance',
76
- data: {
77
- market: 'ETH',
78
- },
79
- },
80
- };
81
- const errorRequests = {
82
- cryptoWithBadSymbol: {
83
- id,
84
- data: {
85
- base: 'ZWXK',
86
- quote: 'USD',
87
- },
88
- },
89
- cryptoWithBadOverride: {
90
- id,
91
- data: {
92
- base: 'LINK',
93
- quote: 'USD',
94
- overrides: {
95
- coingecko: {
96
- LINK: 'badtokenid',
97
- },
98
- },
99
- },
100
- },
101
- dominanceWithBadSymbol: {
102
- id,
103
- endpoint: 'dominance',
104
- data: {
105
- market: 'ZWXK',
106
- },
107
- },
108
- };
109
- beforeAll(async () => {
110
- try {
111
- adapterServer = await (0, __1.expose)(index_1.adapter);
112
- req = (0, supertest_1.default)('localhost:8080');
113
- }
114
- catch {
115
- throw new Error('Could not start server when running CoinGecko e2e tests');
116
- }
117
- if (!adapterServer) {
118
- throw new Error('Could not start server when running CoinGecko e2e tests');
119
- }
120
- // Send inital requests to warm the cache
121
- const pendingRequests = [];
122
- for (const reqData of Object.values(successfulRequests)) {
123
- pendingRequests.push(req.post('/').send(reqData));
124
- }
125
- for (const reqData of Object.values(errorRequests)) {
126
- pendingRequests.push(req.post('/').send(reqData));
127
- }
128
- // Wait for all the pending requests to be complete
129
- Promise.all(pendingRequests);
130
- // Sleep while the cache is filled
131
- await sleep(5000);
132
- });
133
- afterAll((done) => {
134
- if (adapterServer) {
135
- adapterServer.close(done());
136
- }
137
- });
138
- describe('crypto api', () => {
139
- it('should return success', async () => {
140
- // Send inital request to warm cache
141
- const response = await req
142
- .post('/')
143
- .send(successfulRequests.crypto)
144
- .set('Accept', '*/*')
145
- .set('Content-Type', 'application/json')
146
- .expect(200);
147
- expect(response.body.result).toBeGreaterThan(0);
148
- });
149
- it('should return success with coinid', async () => {
150
- const response = await req
151
- .post('/')
152
- .send(successfulRequests.cryptoWithCoinid)
153
- .set('Accept', '*/*')
154
- .set('Content-Type', 'application/json')
155
- .expect('Content-Type', /json/)
156
- .expect(200);
157
- expect(response.body.result).toBeGreaterThan(0);
158
- });
159
- it('should return error message for bad symbol', async () => {
160
- await req
161
- .post('/')
162
- .send(errorRequests.cryptoWithBadSymbol)
163
- .set('Accept', '*/*')
164
- .set('Content-Type', 'application/json')
165
- .expect(504);
166
- });
167
- it('should return success with override', async () => {
168
- const response = await req
169
- .post('/')
170
- .send(successfulRequests.cryptoWithOverride)
171
- .set('Accept', '*/*')
172
- .set('Content-Type', 'application/json')
173
- .expect('Content-Type', /json/)
174
- .expect(200);
175
- expect(response.body.result).toBeGreaterThan(0);
176
- });
177
- it('should return 504 for bad override', async () => {
178
- const response = await req
179
- .post('/')
180
- .send(errorRequests.cryptoWithBadOverride)
181
- .set('Accept', '*/*')
182
- .set('Content-Type', 'application/json')
183
- .expect(504);
184
- expect(typeof response.body.result === 'string');
185
- });
186
- it('should return 504 for bad symbol', async () => {
187
- await req
188
- .post('/')
189
- .send(errorRequests.cryptoWithBadSymbol)
190
- .set('Accept', '*/*')
191
- .set('Content-Type', 'application/json')
192
- .expect(504);
193
- });
194
- });
195
- describe('coins api', () => {
196
- it('should return success', async () => {
197
- await req
198
- .post('/')
199
- .send(successfulRequests.coins)
200
- .set('Accept', '*/*')
201
- .set('Content-Type', 'application/json')
202
- .expect('Content-Type', /json/)
203
- .expect(200);
204
- });
205
- });
206
- describe('volume api', () => {
207
- it('should return success', async () => {
208
- const response = await req
209
- .post('/')
210
- .send(successfulRequests.volume)
211
- .set('Accept', '*/*')
212
- .set('Content-Type', 'application/json')
213
- .expect('Content-Type', /json/)
214
- .expect(200);
215
- expect(response.body.result).toBeGreaterThan(0);
216
- });
217
- });
218
- describe('marketcap api', () => {
219
- it('should return success', async () => {
220
- const response = await req
221
- .post('/')
222
- .send(successfulRequests.marketcap)
223
- .set('Accept', '*/*')
224
- .set('Content-Type', 'application/json')
225
- .expect('Content-Type', /json/)
226
- .expect(200);
227
- expect(response.body.result).toBeGreaterThan(0);
228
- });
229
- });
230
- describe('globalmarketcap api', () => {
231
- it('should return success', async () => {
232
- const response = await req
233
- .post('/')
234
- .send(successfulRequests.globalmarketcap)
235
- .set('Accept', '*/*')
236
- .set('Content-Type', 'application/json')
237
- .expect('Content-Type', /json/)
238
- .expect(200);
239
- expect(response.body.result).toBeGreaterThan(0);
240
- });
241
- });
242
- describe('dominance api', () => {
243
- it('should return success', async () => {
244
- const response = await req
245
- .post('/')
246
- .send(successfulRequests.dominance)
247
- .set('Accept', '*/*')
248
- .set('Content-Type', 'application/json')
249
- .expect('Content-Type', /json/)
250
- .expect(200);
251
- expect(response.body.result).toBeGreaterThan(0);
252
- });
253
- it('should return 504 for bad symbol', async () => {
254
- await req
255
- .post('/')
256
- .send(errorRequests.dominanceWithBadSymbol)
257
- .set('Accept', '*/*')
258
- .set('Content-Type', 'application/json')
259
- .expect(504);
260
- });
261
- });
262
- });