@chainlink/external-adapter-framework 0.0.19 → 0.0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/adapter.d.ts +139 -0
- package/background-executor.d.ts +9 -0
- package/background-executor.js +9 -4
- package/cache/factory.d.ts +6 -0
- package/cache/index.d.ts +94 -0
- package/cache/local.d.ts +23 -0
- package/cache/metrics.d.ts +27 -0
- package/cache/redis.d.ts +16 -0
- package/config/index.d.ts +258 -0
- package/config/provider-limits.d.ts +27 -0
- package/examples/bank-frick/accounts.d.ts +39 -0
- package/examples/bank-frick/config/index.d.ts +4 -0
- package/examples/bank-frick/index.d.ts +2 -0
- package/examples/bank-frick/util.d.ts +4 -0
- package/examples/coingecko/batch-warming.d.ts +7 -0
- package/examples/coingecko/index.d.ts +2 -0
- package/examples/coingecko/rest.d.ts +12 -0
- package/examples/coingecko/src/config/index.d.ts +2 -0
- package/examples/coingecko/src/config/index.js +1 -9
- package/examples/coingecko/src/config/overrides.json +0 -1
- package/examples/coingecko/src/cryptoUtils.d.ts +31 -0
- package/examples/coingecko/src/cryptoUtils.js +20 -1
- package/examples/coingecko/src/endpoint/coins.d.ts +9 -0
- package/examples/coingecko/src/endpoint/coins.js +3 -2
- package/examples/coingecko/src/endpoint/crypto-marketcap.d.ts +3 -0
- package/examples/coingecko/src/endpoint/crypto-marketcap.js +5 -22
- package/examples/coingecko/src/endpoint/crypto-volume.d.ts +3 -0
- package/examples/coingecko/src/endpoint/crypto-volume.js +5 -22
- package/examples/coingecko/src/endpoint/crypto.d.ts +3 -0
- package/examples/coingecko/src/endpoint/crypto.js +5 -25
- package/examples/coingecko/src/endpoint/dominance.d.ts +3 -0
- package/examples/coingecko/src/endpoint/dominance.js +4 -3
- package/examples/coingecko/src/endpoint/global-marketcap.d.ts +3 -0
- package/examples/coingecko/src/endpoint/global-marketcap.js +4 -3
- package/examples/coingecko/src/endpoint/index.d.ts +6 -0
- package/examples/coingecko/src/globalUtils.d.ts +27 -0
- package/examples/coingecko/src/globalUtils.js +6 -8
- package/examples/coingecko/src/index.d.ts +4 -0
- package/examples/coingecko/src/index.js +7 -3
- package/examples/coingecko-old/batch-warming.d.ts +7 -0
- package/examples/coingecko-old/index.d.ts +2 -0
- package/examples/coingecko-old/rest.d.ts +12 -0
- package/examples/ncfx/config/index.d.ts +12 -0
- package/examples/ncfx/index.d.ts +13 -0
- package/examples/ncfx/websocket.d.ts +47 -0
- package/index.d.ts +11 -0
- package/index.js +24 -7
- package/metrics/constants.d.ts +16 -0
- package/metrics/index.d.ts +15 -0
- package/metrics/index.js +7 -3
- package/metrics/util.d.ts +7 -0
- package/package.json +10 -4
- package/rate-limiting/background/fixed-frequency.d.ts +11 -0
- package/rate-limiting/index.d.ts +55 -0
- package/rate-limiting/metrics.d.ts +3 -0
- package/rate-limiting/request/simple-counting.d.ts +21 -0
- package/test.d.ts +1 -0
- package/transports/batch-warming.d.ts +35 -0
- package/transports/batch-warming.js +1 -1
- package/transports/index.d.ts +73 -0
- package/transports/index.js +3 -1
- package/transports/metrics.d.ts +22 -0
- package/transports/rest.d.ts +44 -0
- package/transports/util.d.ts +9 -0
- package/transports/websocket.d.ts +80 -0
- package/util/index.d.ts +12 -0
- package/util/logger.d.ts +42 -0
- package/util/request.d.ts +56 -0
- package/util/subscription-set/expiring-sorted-set.d.ts +22 -0
- package/util/subscription-set/subscription-set.d.ts +18 -0
- package/util/test-payload-loader.d.ts +25 -0
- package/validation/error.d.ts +50 -0
- package/validation/index.d.ts +5 -0
- package/validation/index.js +4 -2
- package/validation/input-params.d.ts +15 -0
- package/validation/override-functions.d.ts +3 -0
- package/validation/validator.d.ts +47 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { AxiosRequestConfig, AxiosResponse } from 'axios';
|
|
2
|
+
import { AdapterInputParameters, BankFrickAccountsRequestSchema, BankFrickAccountsResponseSchema, SigningAlgorithm } from './types';
|
|
3
|
+
import { customSettings } from './config';
|
|
4
|
+
import { Transport } from '../../transports';
|
|
5
|
+
import { AdapterRequest, AdapterResponse } from '../../util';
|
|
6
|
+
import { AdapterConfig } from '../../config';
|
|
7
|
+
import { Cache } from '../../cache';
|
|
8
|
+
import { AdapterDependencies, AdapterEndpoint } from '../../adapter';
|
|
9
|
+
/**
|
|
10
|
+
* RestTransport implementation for Bank Frick, which has unusually complex requirements for an EA
|
|
11
|
+
* The RestTransport is generally built to make a single request and return a single response.
|
|
12
|
+
* This transport instead is used to fetch and process pages of data, and also requires a JWT to run
|
|
13
|
+
*
|
|
14
|
+
* This transport does all the heavy lifting in setup(), which is where the paging happens, and it
|
|
15
|
+
* also has complex retry logic that will attempt to refresh the JWT when certain HTTP errors occur
|
|
16
|
+
*/
|
|
17
|
+
export declare class BankFrickAccountsTransport implements Transport<AdapterInputParameters, number, typeof customSettings> {
|
|
18
|
+
token: string;
|
|
19
|
+
cache: Cache;
|
|
20
|
+
initialize(dependencies: AdapterDependencies): Promise<void>;
|
|
21
|
+
hasBeenSetUp(): Promise<boolean>;
|
|
22
|
+
/**
|
|
23
|
+
* Creates an AxiosRequestConfig object for fetching a page of accounts from the Bank Frick API
|
|
24
|
+
*/
|
|
25
|
+
prepareRequest(firstPosition: number, inputParams: AdapterInputParameters, config: AdapterConfig<typeof customSettings>): AxiosRequestConfig<BankFrickAccountsRequestSchema>;
|
|
26
|
+
/**
|
|
27
|
+
* Request with retry logic for Bank Frick's API. In addition to standard retry logic, this function
|
|
28
|
+
* compares errors against expected errors from the Bank Frick API, and will throw without retries
|
|
29
|
+
* on a known fatal error, or try to refresh the JWT on a known auth error
|
|
30
|
+
**/
|
|
31
|
+
makeRequest(axiosRequest: AxiosRequestConfig<BankFrickAccountsRequestSchema>, config: AdapterConfig<typeof customSettings>, signingAlgorithm?: SigningAlgorithm): Promise<AxiosResponse<BankFrickAccountsResponseSchema>>;
|
|
32
|
+
validateInputParams(params: AdapterInputParameters): string[];
|
|
33
|
+
/**
|
|
34
|
+
* Fetches pages of data from the Bank Frick API, scans for accounts by IBAN, and returns the balance
|
|
35
|
+
* of all found accounts. Returns a 404 if any IBAN isn't found.
|
|
36
|
+
*/
|
|
37
|
+
setup(req: AdapterRequest<AdapterInputParameters>, config: AdapterConfig<typeof customSettings>): Promise<AdapterResponse<number>>;
|
|
38
|
+
}
|
|
39
|
+
export declare const accountsRestEndpoint: AdapterEndpoint<AdapterInputParameters, number, import("../../config").SettingsMap>;
|
|
@@ -0,0 +1,4 @@
|
|
|
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>;
|
|
@@ -0,0 +1,12 @@
|
|
|
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 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.NAME = 'COINGECKO';
|
|
5
|
-
exports.DEFAULT_ENDPOINT = 'crypto';
|
|
3
|
+
exports.PRO_API_ENDPOINT = exports.DEFAULT_API_ENDPOINT = void 0;
|
|
6
4
|
exports.DEFAULT_API_ENDPOINT = 'https://api.coingecko.com/api/v3';
|
|
7
5
|
exports.PRO_API_ENDPOINT = 'https://pro-api.coingecko.com/api/v3';
|
|
8
|
-
exports.customSettings = {
|
|
9
|
-
API_KEY: {
|
|
10
|
-
description: 'API key for the CoinGecko API',
|
|
11
|
-
type: 'string',
|
|
12
|
-
},
|
|
13
|
-
};
|
|
@@ -0,0 +1,31 @@
|
|
|
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,8 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.constructEntry = exports.buildBatchedRequestBody = void 0;
|
|
3
|
+
exports.constructEntry = exports.buildBatchedRequestBody = exports.cryptoInputParams = void 0;
|
|
4
4
|
const config_1 = require("./config");
|
|
5
5
|
const logger_1 = require("../../../util/logger");
|
|
6
|
+
exports.cryptoInputParams = {
|
|
7
|
+
coinid: {
|
|
8
|
+
description: 'The CoinGecko id or to query',
|
|
9
|
+
type: 'string',
|
|
10
|
+
required: false,
|
|
11
|
+
},
|
|
12
|
+
base: {
|
|
13
|
+
aliases: ['from', 'coin'],
|
|
14
|
+
type: 'string',
|
|
15
|
+
description: 'The symbol of symbols of the currency to query',
|
|
16
|
+
required: false,
|
|
17
|
+
},
|
|
18
|
+
quote: {
|
|
19
|
+
aliases: ['to', 'market'],
|
|
20
|
+
type: 'string',
|
|
21
|
+
description: 'The symbol of the currency to convert to',
|
|
22
|
+
required: true,
|
|
23
|
+
},
|
|
24
|
+
};
|
|
6
25
|
const buildBatchedRequestBody = (params, config) => {
|
|
7
26
|
return {
|
|
8
27
|
baseURL: config.API_KEY ? config_1.PRO_API_ENDPOINT : config_1.DEFAULT_API_ENDPOINT,
|
|
@@ -0,0 +1,9 @@
|
|
|
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,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.endpoint = exports.inputParameters = void 0;
|
|
4
|
+
const adapter_1 = require("../../../../../src/adapter");
|
|
4
5
|
const transports_1 = require("../../../../../src/transports");
|
|
5
6
|
const config_1 = require("../config");
|
|
6
7
|
exports.inputParameters = {};
|
|
@@ -26,8 +27,8 @@ const restEndpointTransport = new transports_1.RestTransport({
|
|
|
26
27
|
coalescing: true,
|
|
27
28
|
},
|
|
28
29
|
});
|
|
29
|
-
exports.endpoint = {
|
|
30
|
+
exports.endpoint = new adapter_1.AdapterEndpoint({
|
|
30
31
|
name: 'coins',
|
|
31
32
|
transport: restEndpointTransport,
|
|
32
33
|
inputParameters: exports.inputParameters,
|
|
33
|
-
};
|
|
34
|
+
});
|
|
@@ -1,26 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.endpoint =
|
|
3
|
+
exports.endpoint = void 0;
|
|
4
|
+
const adapter_1 = require("../../../../adapter");
|
|
4
5
|
const batch_warming_1 = require("../../../../transports/batch-warming");
|
|
5
|
-
const input_params_1 = require("../../../../validation/input-params");
|
|
6
6
|
const cryptoUtils_1 = require("../cryptoUtils");
|
|
7
|
-
exports.inputParameters = {
|
|
8
|
-
overrides: input_params_1.baseInputParameters['overrides'],
|
|
9
|
-
coinid: {
|
|
10
|
-
description: 'The CoinGecko id or to query',
|
|
11
|
-
required: false,
|
|
12
|
-
},
|
|
13
|
-
base: {
|
|
14
|
-
aliases: ['from', 'coin'],
|
|
15
|
-
description: 'The symbol of symbols of the currency to query',
|
|
16
|
-
required: false,
|
|
17
|
-
},
|
|
18
|
-
quote: {
|
|
19
|
-
aliases: ['to', 'market'],
|
|
20
|
-
description: 'The symbol of the currency to convert to',
|
|
21
|
-
required: true,
|
|
22
|
-
},
|
|
23
|
-
};
|
|
24
7
|
const batchEndpointTransport = new batch_warming_1.BatchWarmingTransport({
|
|
25
8
|
prepareRequest: (params, context) => {
|
|
26
9
|
const requestBody = (0, cryptoUtils_1.buildBatchedRequestBody)(params, context.adapterConfig);
|
|
@@ -38,9 +21,9 @@ const batchEndpointTransport = new batch_warming_1.BatchWarmingTransport({
|
|
|
38
21
|
return entries;
|
|
39
22
|
},
|
|
40
23
|
});
|
|
41
|
-
exports.endpoint = {
|
|
24
|
+
exports.endpoint = new adapter_1.AdapterEndpoint({
|
|
42
25
|
name: 'marketcap',
|
|
43
26
|
aliases: ['crypto-marketcap'],
|
|
44
27
|
transport: batchEndpointTransport,
|
|
45
|
-
inputParameters:
|
|
46
|
-
};
|
|
28
|
+
inputParameters: cryptoUtils_1.cryptoInputParams,
|
|
29
|
+
});
|
|
@@ -1,26 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.endpoint =
|
|
3
|
+
exports.endpoint = void 0;
|
|
4
|
+
const adapter_1 = require("../../../../adapter");
|
|
4
5
|
const batch_warming_1 = require("../../../../transports/batch-warming");
|
|
5
|
-
const input_params_1 = require("../../../../validation/input-params");
|
|
6
6
|
const cryptoUtils_1 = require("../cryptoUtils");
|
|
7
|
-
exports.inputParameters = {
|
|
8
|
-
overrides: input_params_1.baseInputParameters['overrides'],
|
|
9
|
-
coinid: {
|
|
10
|
-
description: 'The CoinGecko id or to query',
|
|
11
|
-
required: false,
|
|
12
|
-
},
|
|
13
|
-
base: {
|
|
14
|
-
aliases: ['from', 'coin'],
|
|
15
|
-
description: 'The symbol of symbols of the currency to query',
|
|
16
|
-
required: false,
|
|
17
|
-
},
|
|
18
|
-
quote: {
|
|
19
|
-
aliases: ['to', 'market'],
|
|
20
|
-
description: 'The symbol of the currency to convert to',
|
|
21
|
-
required: true,
|
|
22
|
-
},
|
|
23
|
-
};
|
|
24
7
|
const batchEndpointTransport = new batch_warming_1.BatchWarmingTransport({
|
|
25
8
|
prepareRequest: (params, context) => {
|
|
26
9
|
const requestBody = (0, cryptoUtils_1.buildBatchedRequestBody)(params, context.adapterConfig);
|
|
@@ -38,9 +21,9 @@ const batchEndpointTransport = new batch_warming_1.BatchWarmingTransport({
|
|
|
38
21
|
return entries;
|
|
39
22
|
},
|
|
40
23
|
});
|
|
41
|
-
exports.endpoint = {
|
|
24
|
+
exports.endpoint = new adapter_1.AdapterEndpoint({
|
|
42
25
|
name: 'volume',
|
|
43
26
|
aliases: ['crypto-volume'],
|
|
44
27
|
transport: batchEndpointTransport,
|
|
45
|
-
inputParameters:
|
|
46
|
-
};
|
|
28
|
+
inputParameters: cryptoUtils_1.cryptoInputParams,
|
|
29
|
+
});
|
|
@@ -1,26 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.endpoint =
|
|
3
|
+
exports.endpoint = void 0;
|
|
4
|
+
const adapter_1 = require("../../../../adapter");
|
|
4
5
|
const batch_warming_1 = require("../../../../transports/batch-warming");
|
|
5
|
-
const input_params_1 = require("../../../../validation/input-params");
|
|
6
6
|
const cryptoUtils_1 = require("../cryptoUtils");
|
|
7
|
-
exports.inputParameters = {
|
|
8
|
-
overrides: input_params_1.baseInputParameters['overrides'],
|
|
9
|
-
coinid: {
|
|
10
|
-
description: 'The CoinGecko id or to query',
|
|
11
|
-
required: false,
|
|
12
|
-
},
|
|
13
|
-
base: {
|
|
14
|
-
aliases: ['from', 'coin'],
|
|
15
|
-
description: 'The symbol of symbols of the currency to query',
|
|
16
|
-
required: false,
|
|
17
|
-
},
|
|
18
|
-
quote: {
|
|
19
|
-
aliases: ['to', 'market'],
|
|
20
|
-
description: 'The symbol of the currency to convert to',
|
|
21
|
-
required: true,
|
|
22
|
-
},
|
|
23
|
-
};
|
|
24
7
|
const batchEndpointTransport = new batch_warming_1.BatchWarmingTransport({
|
|
25
8
|
prepareRequest: (params, context) => {
|
|
26
9
|
return (0, cryptoUtils_1.buildBatchedRequestBody)(params, context.adapterConfig);
|
|
@@ -29,9 +12,6 @@ const batchEndpointTransport = new batch_warming_1.BatchWarmingTransport({
|
|
|
29
12
|
const entries = [];
|
|
30
13
|
for (const requestPayload of params) {
|
|
31
14
|
const entry = (0, cryptoUtils_1.constructEntry)(res, requestPayload, requestPayload.quote.toLowerCase());
|
|
32
|
-
// NOTE: the `entries` array is going to be shorter than the `params` array if one of the params has a bad token.
|
|
33
|
-
// Is that okay? I did this to avoid caching an invalid value for transient DP issues. Just want to make
|
|
34
|
-
// sure this works within the core framework
|
|
35
15
|
if (entry) {
|
|
36
16
|
entries.push(entry);
|
|
37
17
|
}
|
|
@@ -39,9 +19,9 @@ const batchEndpointTransport = new batch_warming_1.BatchWarmingTransport({
|
|
|
39
19
|
return entries;
|
|
40
20
|
},
|
|
41
21
|
});
|
|
42
|
-
exports.endpoint = {
|
|
22
|
+
exports.endpoint = new adapter_1.AdapterEndpoint({
|
|
43
23
|
name: 'crypto',
|
|
44
24
|
aliases: ['crypto-batched', 'batched', 'batch'],
|
|
45
25
|
transport: batchEndpointTransport,
|
|
46
|
-
inputParameters:
|
|
47
|
-
};
|
|
26
|
+
inputParameters: cryptoUtils_1.cryptoInputParams,
|
|
27
|
+
});
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.endpoint = void 0;
|
|
4
|
+
const adapter_1 = require("../../../../adapter");
|
|
4
5
|
const batch_warming_1 = require("../../../../transports/batch-warming");
|
|
5
6
|
const globalUtils_1 = require("../globalUtils");
|
|
6
7
|
const batchEndpointTransport = new batch_warming_1.BatchWarmingTransport({
|
|
7
8
|
prepareRequest: (params, context) => {
|
|
8
|
-
return (0, globalUtils_1.buildGlobalRequestBody)(context.adapterConfig);
|
|
9
|
+
return (0, globalUtils_1.buildGlobalRequestBody)(context.adapterConfig.API_KEY);
|
|
9
10
|
},
|
|
10
11
|
parseResponse: (params, res) => {
|
|
11
12
|
const entries = [];
|
|
@@ -18,9 +19,9 @@ const batchEndpointTransport = new batch_warming_1.BatchWarmingTransport({
|
|
|
18
19
|
return entries;
|
|
19
20
|
},
|
|
20
21
|
});
|
|
21
|
-
exports.endpoint = {
|
|
22
|
+
exports.endpoint = new adapter_1.AdapterEndpoint({
|
|
22
23
|
name: 'dominance',
|
|
23
24
|
aliases: ['market_cap_percentage'],
|
|
24
25
|
transport: batchEndpointTransport,
|
|
25
26
|
inputParameters: globalUtils_1.inputParameters,
|
|
26
|
-
};
|
|
27
|
+
});
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.endpoint = void 0;
|
|
4
|
+
const adapter_1 = require("../../../../adapter");
|
|
4
5
|
const batch_warming_1 = require("../../../../transports/batch-warming");
|
|
5
6
|
const globalUtils_1 = require("../globalUtils");
|
|
6
7
|
const batchEndpointTransport = new batch_warming_1.BatchWarmingTransport({
|
|
7
8
|
prepareRequest: (params, context) => {
|
|
8
|
-
return (0, globalUtils_1.buildGlobalRequestBody)(context.adapterConfig);
|
|
9
|
+
return (0, globalUtils_1.buildGlobalRequestBody)(context.adapterConfig.API_KEY);
|
|
9
10
|
},
|
|
10
11
|
parseResponse: (params, res) => {
|
|
11
12
|
const entries = [];
|
|
@@ -18,9 +19,9 @@ const batchEndpointTransport = new batch_warming_1.BatchWarmingTransport({
|
|
|
18
19
|
return entries;
|
|
19
20
|
},
|
|
20
21
|
});
|
|
21
|
-
exports.endpoint = {
|
|
22
|
+
exports.endpoint = new adapter_1.AdapterEndpoint({
|
|
22
23
|
name: 'globalmarketcap',
|
|
23
24
|
aliases: ['total_market_cap'],
|
|
24
25
|
transport: batchEndpointTransport,
|
|
25
26
|
inputParameters: globalUtils_1.inputParameters,
|
|
26
|
-
};
|
|
27
|
+
});
|
|
@@ -0,0 +1,6 @@
|
|
|
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';
|
|
@@ -0,0 +1,27 @@
|
|
|
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 {};
|
|
@@ -11,15 +11,14 @@ exports.inputParameters = {
|
|
|
11
11
|
required: true,
|
|
12
12
|
},
|
|
13
13
|
};
|
|
14
|
-
const buildGlobalRequestBody = (
|
|
15
|
-
const apiKey = {
|
|
16
|
-
x_cg_pro_api_key: config.API_KEY,
|
|
17
|
-
};
|
|
14
|
+
const buildGlobalRequestBody = (apiKey) => {
|
|
18
15
|
return {
|
|
19
|
-
baseURL:
|
|
16
|
+
baseURL: apiKey ? config_1.PRO_API_ENDPOINT : config_1.DEFAULT_API_ENDPOINT,
|
|
20
17
|
url: '/global',
|
|
21
18
|
method: 'GET',
|
|
22
|
-
params:
|
|
19
|
+
params: {
|
|
20
|
+
x_cg_pro_api_key: apiKey,
|
|
21
|
+
},
|
|
23
22
|
};
|
|
24
23
|
};
|
|
25
24
|
exports.buildGlobalRequestBody = buildGlobalRequestBody;
|
|
@@ -39,10 +38,9 @@ const constructEntry = (res, requestPayload, resultPath) => {
|
|
|
39
38
|
logger.warn(`Data for "${requestPayload.market}" not found".`);
|
|
40
39
|
return;
|
|
41
40
|
}
|
|
42
|
-
|
|
41
|
+
return {
|
|
43
42
|
params: requestPayload,
|
|
44
43
|
value: result,
|
|
45
44
|
};
|
|
46
|
-
return entry;
|
|
47
45
|
};
|
|
48
46
|
exports.constructEntry = constructEntry;
|
|
@@ -0,0 +1,4 @@
|
|
|
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>;
|
|
@@ -3,12 +3,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.adapter = void 0;
|
|
6
|
+
exports.server = exports.adapter = void 0;
|
|
7
|
+
const __1 = require("../../..");
|
|
8
|
+
const adapter_1 = require("../../../../src/adapter");
|
|
7
9
|
const overrides_json_1 = __importDefault(require("./config/overrides.json"));
|
|
8
10
|
const endpoint_1 = require("./endpoint");
|
|
9
|
-
exports.adapter = {
|
|
11
|
+
exports.adapter = new adapter_1.Adapter({
|
|
10
12
|
defaultEndpoint: 'crypto',
|
|
11
13
|
name: 'coingecko',
|
|
12
14
|
endpoints: [endpoint_1.crypto, endpoint_1.coins, endpoint_1.cryptoMarketcap, endpoint_1.cryptoVolume, endpoint_1.dominance, endpoint_1.globalMarketcap],
|
|
13
15
|
overrides: overrides_json_1.default['coingecko'],
|
|
14
|
-
};
|
|
16
|
+
});
|
|
17
|
+
const server = () => (0, __1.expose)(exports.adapter);
|
|
18
|
+
exports.server = server;
|
|
@@ -0,0 +1,12 @@
|
|
|
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 {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const customSettings: {
|
|
2
|
+
readonly USERNAME: {
|
|
3
|
+
readonly description: "Username for the NCFX API";
|
|
4
|
+
readonly type: "string";
|
|
5
|
+
readonly required: true;
|
|
6
|
+
};
|
|
7
|
+
readonly PASSWORD: {
|
|
8
|
+
readonly description: "Password for the NCFX API";
|
|
9
|
+
readonly type: "string";
|
|
10
|
+
readonly required: true;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
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
|
+
}>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { AdapterEndpoint } from '../../adapter';
|
|
2
|
+
import { WebSocketTransport } from '../../transports/websocket';
|
|
3
|
+
import { InputParameters } from '../../validation';
|
|
4
|
+
interface AdapterRequestParams {
|
|
5
|
+
base: string;
|
|
6
|
+
quote: string;
|
|
7
|
+
}
|
|
8
|
+
export declare const inputParameters: InputParameters;
|
|
9
|
+
interface ProviderMessage {
|
|
10
|
+
timestamp: string;
|
|
11
|
+
currencyPair: string;
|
|
12
|
+
bid: number;
|
|
13
|
+
offer: number;
|
|
14
|
+
mid: number;
|
|
15
|
+
changes: [
|
|
16
|
+
{
|
|
17
|
+
period: string;
|
|
18
|
+
change: number;
|
|
19
|
+
percentage: number;
|
|
20
|
+
}
|
|
21
|
+
];
|
|
22
|
+
}
|
|
23
|
+
export declare const websocketTransport: WebSocketTransport<AdapterRequestParams, ProviderMessage[], {
|
|
24
|
+
readonly USERNAME: {
|
|
25
|
+
readonly description: "Username for the NCFX API";
|
|
26
|
+
readonly type: "string";
|
|
27
|
+
readonly required: true;
|
|
28
|
+
};
|
|
29
|
+
readonly PASSWORD: {
|
|
30
|
+
readonly description: "Password for the NCFX API";
|
|
31
|
+
readonly type: "string";
|
|
32
|
+
readonly required: true;
|
|
33
|
+
};
|
|
34
|
+
}>;
|
|
35
|
+
export declare const webSocketEndpoint: AdapterEndpoint<AdapterRequestParams, unknown, {
|
|
36
|
+
readonly USERNAME: {
|
|
37
|
+
readonly description: "Username for the NCFX API";
|
|
38
|
+
readonly type: "string";
|
|
39
|
+
readonly required: true;
|
|
40
|
+
};
|
|
41
|
+
readonly PASSWORD: {
|
|
42
|
+
readonly description: "Password for the NCFX API";
|
|
43
|
+
readonly type: "string";
|
|
44
|
+
readonly required: true;
|
|
45
|
+
};
|
|
46
|
+
}>;
|
|
47
|
+
export {};
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { FastifyInstance } from 'fastify';
|
|
2
|
+
import { Adapter, AdapterDependencies } from './adapter';
|
|
3
|
+
/**
|
|
4
|
+
* Main function for the framework.
|
|
5
|
+
* Initializes config and dependencies, uses those to initialize Transports, and starts listening for requests.
|
|
6
|
+
*
|
|
7
|
+
* @param adapter - an object describing an External Adapter
|
|
8
|
+
* @param dependencies - an optional object with adapter dependencies to inject
|
|
9
|
+
* @returns a Promise that resolves to the http.Server listening for connections
|
|
10
|
+
*/
|
|
11
|
+
export declare const expose: (adapter: Adapter, dependencies?: Partial<AdapterDependencies>) => Promise<FastifyInstance | undefined>;
|