@covalenthq/client-sdk 0.6.7 → 0.7.1
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/README.md +1 -0
- package/dist/cjs/index.js +744 -193
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/services/BalanceService.d.ts +2 -1
- package/dist/cjs/services/BaseService.d.ts +55 -2
- package/dist/cjs/services/CovalentClient.d.ts +3 -1
- package/dist/cjs/services/NftService.d.ts +2 -1
- package/dist/cjs/services/PricingService.d.ts +2 -1
- package/dist/cjs/services/SecurityService.d.ts +2 -1
- package/dist/cjs/services/TransactionService.d.ts +5 -4
- package/dist/cjs/services/XykService.d.ts +2 -1
- package/dist/cjs/util/ApiKeyValidator.d.ts +8 -0
- package/dist/cjs/util/types/BaseServiceTypes.d.ts +36 -0
- package/dist/cjs/util/types/TransactionServiceTypes.d.ts +3 -3
- package/dist/es/index.js +744 -193
- package/dist/es/index.js.map +1 -1
- package/dist/es/services/BalanceService.d.ts +2 -1
- package/dist/es/services/BaseService.d.ts +55 -2
- package/dist/es/services/CovalentClient.d.ts +3 -1
- package/dist/es/services/NftService.d.ts +2 -1
- package/dist/es/services/PricingService.d.ts +2 -1
- package/dist/es/services/SecurityService.d.ts +2 -1
- package/dist/es/services/TransactionService.d.ts +5 -4
- package/dist/es/services/XykService.d.ts +2 -1
- package/dist/es/util/ApiKeyValidator.d.ts +8 -0
- package/dist/es/util/types/BaseServiceTypes.d.ts +36 -0
- package/dist/es/util/types/TransactionServiceTypes.d.ts +3 -3
- package/dist/esm/index.js +744 -193
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/services/BalanceService.d.ts +2 -1
- package/dist/esm/services/BaseService.d.ts +55 -2
- package/dist/esm/services/CovalentClient.d.ts +3 -1
- package/dist/esm/services/NftService.d.ts +2 -1
- package/dist/esm/services/PricingService.d.ts +2 -1
- package/dist/esm/services/SecurityService.d.ts +2 -1
- package/dist/esm/services/TransactionService.d.ts +5 -4
- package/dist/esm/services/XykService.d.ts +2 -1
- package/dist/esm/util/ApiKeyValidator.d.ts +8 -0
- package/dist/esm/util/types/BaseServiceTypes.d.ts +36 -0
- package/dist/esm/util/types/TransactionServiceTypes.d.ts +3 -3
- package/dist/services/BalanceService.d.ts +2 -1
- package/dist/services/BalanceService.js +75 -19
- package/dist/services/BalanceService.js.map +1 -1
- package/dist/services/BaseService.d.ts +55 -2
- package/dist/services/BaseService.js +212 -26
- package/dist/services/BaseService.js.map +1 -1
- package/dist/services/CovalentClient.d.ts +3 -1
- package/dist/services/CovalentClient.js +20 -15
- package/dist/services/CovalentClient.js.map +1 -1
- package/dist/services/NftService.d.ts +2 -1
- package/dist/services/NftService.js +152 -40
- package/dist/services/NftService.js.map +1 -1
- package/dist/services/PricingService.d.ts +2 -1
- package/dist/services/PricingService.js +14 -4
- package/dist/services/PricingService.js.map +1 -1
- package/dist/services/SecurityService.d.ts +2 -1
- package/dist/services/SecurityService.js +25 -7
- package/dist/services/SecurityService.js.map +1 -1
- package/dist/services/TransactionService.d.ts +5 -4
- package/dist/services/TransactionService.js +78 -33
- package/dist/services/TransactionService.js.map +1 -1
- package/dist/services/XykService.d.ts +2 -1
- package/dist/services/XykService.js +157 -43
- package/dist/services/XykService.js.map +1 -1
- package/dist/util/ApiHelpers.js +3 -3
- package/dist/util/ApiHelpers.js.map +1 -1
- package/dist/util/ApiKeyValidator.d.ts +8 -0
- package/dist/util/ApiKeyValidator.js +13 -0
- package/dist/util/ApiKeyValidator.js.map +1 -0
- package/dist/util/backoff.js +3 -3
- package/dist/util/backoff.js.map +1 -1
- package/dist/util/types/BaseServiceTypes.d.ts +36 -0
- package/dist/util/types/TransactionServiceTypes.d.ts +3 -3
- package/package.json +1 -1
|
@@ -483,8 +483,9 @@ export declare class BalanceService {
|
|
|
483
483
|
private apiKey;
|
|
484
484
|
private debug;
|
|
485
485
|
private threadCount;
|
|
486
|
+
private is_key_valid;
|
|
486
487
|
private LIMIT;
|
|
487
|
-
constructor(apiKey: string, debug
|
|
488
|
+
constructor(apiKey: string, debug: boolean, threadCount: number, is_key_valid: boolean);
|
|
488
489
|
/**
|
|
489
490
|
*
|
|
490
491
|
* Commonly used to fetch the native, fungible (ERC20), and non-fungible (ERC721 & ERC1155) tokens held by an address. Response includes spot prices and other metadata.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Chain, Response } from "./CovalentClient";
|
|
1
|
+
import { Chain, Quote, Response } from "./CovalentClient";
|
|
2
2
|
import { Chains } from "../util/Chains";
|
|
3
3
|
declare class BlockResponse {
|
|
4
4
|
/** * The timestamp when the response was generated. Useful to show data staleness to users. */
|
|
@@ -266,6 +266,45 @@ declare class ChainActivityEvent extends ChainItem {
|
|
|
266
266
|
last_seen_at: Date;
|
|
267
267
|
constructor(data: ChainActivityEvent);
|
|
268
268
|
}
|
|
269
|
+
declare class GasPricesResponse {
|
|
270
|
+
/** * The requested chain ID eg: `1`. */
|
|
271
|
+
chain_id: number;
|
|
272
|
+
/** * The requested chain name eg: `eth-mainnet`. */
|
|
273
|
+
chain_name: string;
|
|
274
|
+
/** * The requested quote currency eg: `USD`. */
|
|
275
|
+
quote_currency: string;
|
|
276
|
+
/** * The timestamp when the response was generated. Useful to show data staleness to users. */
|
|
277
|
+
updated_at: Date;
|
|
278
|
+
/** * The requested event type. */
|
|
279
|
+
event_type: string;
|
|
280
|
+
/** * The exchange rate for the requested quote currency. */
|
|
281
|
+
gas_quote_rate: number;
|
|
282
|
+
/** * List of response items. */
|
|
283
|
+
items: PriceItem[];
|
|
284
|
+
constructor(data: GasPricesResponse);
|
|
285
|
+
}
|
|
286
|
+
declare class PriceItem {
|
|
287
|
+
/** * The average gas price, in WEI, for the time interval. */
|
|
288
|
+
gas_price: string;
|
|
289
|
+
/** * The average gas spent for the time interval. */
|
|
290
|
+
gas_spent: string;
|
|
291
|
+
/** * The average gas spent in `quote-currency` denomination for the time interval. */
|
|
292
|
+
gas_quote: number;
|
|
293
|
+
/** * Other fees, when applicable. For example: OP chain L1 fees. */
|
|
294
|
+
other_fees: OtherFees;
|
|
295
|
+
/** * The sum of the L1 and L2 gas spent, in quote-currency, for the specified time interval. */
|
|
296
|
+
total_gas_quote: number;
|
|
297
|
+
/** * A prettier version of the total average gas spent, in quote-currency, for the specified time interval, for rendering purposes. */
|
|
298
|
+
pretty_total_gas_quote: string;
|
|
299
|
+
/** * The specified time interval. */
|
|
300
|
+
interval: string;
|
|
301
|
+
constructor(data: PriceItem);
|
|
302
|
+
}
|
|
303
|
+
declare class OtherFees {
|
|
304
|
+
/** * The calculated L1 gas spent, when applicable, in quote-currency, for the specified time interval. */
|
|
305
|
+
l1_gas_quote: number;
|
|
306
|
+
constructor(data: OtherFees);
|
|
307
|
+
}
|
|
269
308
|
export interface GetBlockHeightsQueryParamOpts {
|
|
270
309
|
/** * Number of items per page. Omitting this parameter defaults to 100. */
|
|
271
310
|
pageSize?: number;
|
|
@@ -312,6 +351,10 @@ export interface GetAddressActivityQueryParamOpts {
|
|
|
312
351
|
/** * Set to true to include testnets with activity in the response. By default, it's set to `false` and only returns mainnet activity. */
|
|
313
352
|
testnets?: boolean;
|
|
314
353
|
}
|
|
354
|
+
export interface GetGasPricesQueryParamOpts {
|
|
355
|
+
/** * The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`. */
|
|
356
|
+
quoteCurrency?: Quote;
|
|
357
|
+
}
|
|
315
358
|
/**
|
|
316
359
|
* Class A - Base
|
|
317
360
|
*
|
|
@@ -320,8 +363,9 @@ export declare class BaseService {
|
|
|
320
363
|
private apiKey;
|
|
321
364
|
private debug;
|
|
322
365
|
private threadCount;
|
|
366
|
+
private is_key_valid;
|
|
323
367
|
private LIMIT;
|
|
324
|
-
constructor(apiKey: string, debug
|
|
368
|
+
constructor(apiKey: string, debug: boolean, threadCount: number, is_key_valid: boolean);
|
|
325
369
|
/**
|
|
326
370
|
*
|
|
327
371
|
* Commonly used to fetch and render a single block for a block explorer.
|
|
@@ -463,5 +507,14 @@ export declare class BaseService {
|
|
|
463
507
|
*
|
|
464
508
|
*/
|
|
465
509
|
getAddressActivity(walletAddress: string, queryParamOpts?: GetAddressActivityQueryParamOpts): Promise<Response<ChainActivityResponse>>;
|
|
510
|
+
/**
|
|
511
|
+
*
|
|
512
|
+
* @param {string} chainName - The chain name eg: `eth-mainnet`.
|
|
513
|
+
* @param {string} eventType - The desired event type to retrieve gas prices for. Supports `erc20` transfer events, `uniswapv3` swap events and `nativetokens` transfers.
|
|
514
|
+
* @param {GetGasPricesQueryParamOpts} queryParamOpts
|
|
515
|
+
* - `quoteCurrency`: The currency to convert. Supports `USD`, `CAD`, `EUR`, `SGD`, `INR`, `JPY`, `VND`, `CNY`, `KRW`, `RUB`, `TRY`, `NGN`, `ARS`, `AUD`, `CHF`, and `GBP`.
|
|
516
|
+
*
|
|
517
|
+
*/
|
|
518
|
+
getGasPrices(chainName: Chains, eventType: string, queryParamOpts?: GetGasPricesQueryParamOpts): Promise<Response<GasPricesResponse>>;
|
|
466
519
|
}
|
|
467
520
|
export {};
|
|
@@ -7,7 +7,7 @@ import { TransactionService } from "./TransactionService";
|
|
|
7
7
|
import { XykService } from "./XykService";
|
|
8
8
|
export type Chain = "btc-mainnet" | "eth-mainnet" | "matic-mainnet" | "bsc-mainnet" | "avalanche-mainnet" | "optimism-mainnet" | "fantom-mainnet" | "moonbeam-mainnet" | "moonbeam-moonriver" | "rsk-mainnet" | "arbitrum-mainnet" | "palm-mainnet" | "klaytn-mainnet" | "heco-mainnet" | "nervos-godwoken-mainnet" | "axie-mainnet" | "evmos-mainnet" | "astar-mainnet" | "iotex-mainnet" | "harmony-mainnet" | "cronos-mainnet" | "aurora-mainnet" | "emerald-paratime-mainnet" | "boba-mainnet" | "eth-goerli" | "matic-mumbai" | "avalanche-testnet" | "bsc-testnet" | "moonbeam-moonbase-alpha" | "rsk-testnet" | "arbitrum-goerli" | "fantom-testnet" | "palm-testnet" | "heco-testnet" | "nervos-godwoken-testnet" | "evmos-testnet" | "astar-shiden" | "iotex-testnet" | "harmony-testnet" | "aurora-testnet" | "scroll-sepolia-testnet" | "covalent-internal-network-v1" | "defi-kingdoms-mainnet" | "swimmer-mainnet" | "boba-avalanche-mainnet" | "boba-bobabeam-mainnet" | "boba-bnb-mainnet" | "boba-rinkeby-testnet" | "boba-bobabase-testnet" | "boba-bnb-testnet" | "boba-avalanche-testnet" | "klaytn-testnet" | "gather-mainnet" | "gather-testnet" | "skale-calypso" | "skale-mainnet" | "skale-razor" | "avalanche-dexalot-mainnet" | "skale-omnus" | "avalanche-dexalot-testnet" | "astar-shibuya" | "cronos-testnet" | "defi-kingdoms-testnet" | "metis-mainnet" | "metis-stardust" | "milkomeda-a1-mainnet" | "milkomeda-a1-devnet" | "milkomeda-c1-mainnet" | "milkomeda-c1-devnet" | "swimmer-testnet" | "solana-mainnet" | "skale-europa" | "meter-mainnet" | "meter-testnet" | "skale-exorde" | "boba-goerli" | "neon-testnet" | "skale-staging-uum" | "skale-staging-lcc" | "arbitrum-nova-mainnet" | "canto-mainnet" | "bittorrent-mainnet" | "bittorrent-testnet" | "flarenetworks-flare-mainnet" | "flarenetworks-flare-testnet" | "flarenetworks-canary-mainnet" | "flarenetworks-canary-testnet" | "kcc-mainnet" | "kcc-testnet" | "polygon-zkevm-testnet" | "linea-testnet" | "base-testnet" | "mantle-testnet" | "scroll-alpha-testnet" | "oasys-mainnet" | "oasys-testnet" | "findora-mainnet" | "findora-forge-testnet" | "sx-mainnet" | "oasis-sapphire-mainnet" | "oasis-sapphire-testnet" | "optimism-goerli" | "polygon-zkevm-mainnet" | "horizen-yuma-testnet" | "clv-parachain" | "energi-mainnet" | "energi-testnet" | "horizen-gobi-testnet" | "eth-sepolia" | "skale-nebula" | "skale-battleground" | "avalanche-meld-testnet" | "gunzilla-testnet" | "ultron-mainnet" | "ultron-testnet" | "zora-mainnet" | "zora-testnet" | "neon-mainnet" | "avalanche-shrapnel-mainnet" | "base-mainnet" | "mantle-mainnet" | "avalanche-loco-legends-mainnet" | "linea-mainnet" | "horizen-eon-mainnet" | "avalanche-numbers" | "avalanche-dos" | "avalanche-step-network" | "avalanche-xplus" | "avalanche-xanachain" | "avalanche-meld-mainnet" | "opside-public-zkevm" | "opside-law-chain" | "avalanche-shrapnel-testnet" | "avalanche-loco-legends-testnet" | "opside-cb-zkevm" | "opside-pre-alpha-testnet" | "opside-era7" | "opside-xthrill" | "zksync-mainnet" | "metis-testnet" | "zksync-testnet" | "avalanche-blitz-testnet" | "avalanche-d-chain-testnet" | "avalanche-green-dot-testnet" | "avalanche-mintara-testnet" | "avalanche-beam-testnet" | "bnb-meta-apes-mainnet" | "bnb-antimatter-mainnet" | "bnb-antimatter-testnet" | "bnb-opbnb-testnet" | "opside-debox" | "opside-jackbot" | "opside-odx-zkevm-testnet" | "opside-readon-content-testnet" | "opside-relation" | "opside-soquest-zkevm" | "opside-vip3" | "opside-zkmeta" | "avalanche-pulsar-testnet" | "avalanche-uptn" | "bnb-fncy-mainnet" | "zetachain-testnet" | "kinto-testnet" | "mode-testnet" | "loot-mainnet" | "bnb-fncy-testnet" | "manta-testnet" | "pgn-mainnet" | "pgn-testnet" | "gnosis-mainnet" | "gnosis-testnet" | "rollux-mainnet" | "rollux-testnet" | "taiko-jolnir-testnet" | "optimism-sepolia" | "bnb-opbnb-mainnet" | "telos-mainnet" | "telos-testnet";
|
|
9
9
|
export type Quote = "USD" | "CAD" | "EUR" | "SGD" | "INR" | "JPY" | "VND" | "CNY" | "KRW" | "RUB" | "TRY" | "NGN" | "ARS" | "AUD" | "CHF" | "GBP";
|
|
10
|
-
export declare const userAgent = "com.covalenthq.sdk.typescript/0.
|
|
10
|
+
export declare const userAgent = "com.covalenthq.sdk.typescript/0.7.1";
|
|
11
11
|
export declare class Response<T> {
|
|
12
12
|
data: T;
|
|
13
13
|
error: boolean;
|
|
@@ -31,6 +31,7 @@ export declare class CovalentClient {
|
|
|
31
31
|
PricingService: PricingService;
|
|
32
32
|
TransactionService: TransactionService;
|
|
33
33
|
XykService: XykService;
|
|
34
|
+
private _is_key_valid;
|
|
34
35
|
constructor(apiKey: string, settings?: CovalentClientSettings);
|
|
35
36
|
}
|
|
36
37
|
/**
|
|
@@ -47,5 +48,6 @@ export declare class Client {
|
|
|
47
48
|
PricingService: PricingService;
|
|
48
49
|
TransactionService: TransactionService;
|
|
49
50
|
XykService: XykService;
|
|
51
|
+
private _is_key_valid;
|
|
50
52
|
constructor(apiKey: string, settings?: CovalentClientSettings);
|
|
51
53
|
}
|
|
@@ -483,8 +483,9 @@ export declare class NftService {
|
|
|
483
483
|
private apiKey;
|
|
484
484
|
private debug;
|
|
485
485
|
private threadCount;
|
|
486
|
+
private is_key_valid;
|
|
486
487
|
private LIMIT;
|
|
487
|
-
constructor(apiKey: string, debug
|
|
488
|
+
constructor(apiKey: string, debug: boolean, threadCount: number, is_key_valid: boolean);
|
|
488
489
|
/**
|
|
489
490
|
*
|
|
490
491
|
* Commonly used to fetch the list of NFT collections with downloaded and cached off chain data like token metadata and asset files.
|
|
@@ -69,8 +69,9 @@ export declare class PricingService {
|
|
|
69
69
|
private apiKey;
|
|
70
70
|
private debug;
|
|
71
71
|
private threadCount;
|
|
72
|
+
private is_key_valid;
|
|
72
73
|
private LIMIT;
|
|
73
|
-
constructor(apiKey: string, debug
|
|
74
|
+
constructor(apiKey: string, debug: boolean, threadCount: number, is_key_valid: boolean);
|
|
74
75
|
/**
|
|
75
76
|
*
|
|
76
77
|
* Commonly used to get historic prices of a token between date ranges. Supports native tokens.
|
|
@@ -136,8 +136,9 @@ export declare class SecurityService {
|
|
|
136
136
|
private apiKey;
|
|
137
137
|
private debug;
|
|
138
138
|
private threadCount;
|
|
139
|
+
private is_key_valid;
|
|
139
140
|
private LIMIT;
|
|
140
|
-
constructor(apiKey: string, debug
|
|
141
|
+
constructor(apiKey: string, debug: boolean, threadCount: number, is_key_valid: boolean);
|
|
141
142
|
/**
|
|
142
143
|
*
|
|
143
144
|
* Commonly used to get a list of approvals across all token contracts categorized by spenders for a wallet’s assets.
|
|
@@ -58,11 +58,11 @@ declare class Transaction {
|
|
|
58
58
|
/** * The explorer links for this transaction. */
|
|
59
59
|
explorers: Explorer[];
|
|
60
60
|
/** * The details for the dex transaction. */
|
|
61
|
-
dex_details: DexReport;
|
|
61
|
+
dex_details: DexReport[];
|
|
62
62
|
/** * The details for the NFT sale transaction. */
|
|
63
|
-
nft_sale_details: NftSalesReport;
|
|
63
|
+
nft_sale_details: NftSalesReport[];
|
|
64
64
|
/** * The details for the lending protocol transaction. */
|
|
65
|
-
lending_details: LendingReport;
|
|
65
|
+
lending_details: LendingReport[];
|
|
66
66
|
/** * The log events. */
|
|
67
67
|
log_events: LogEvent[];
|
|
68
68
|
/** * The details related to the safe transaction. */
|
|
@@ -477,8 +477,9 @@ export declare class TransactionService {
|
|
|
477
477
|
private apiKey;
|
|
478
478
|
private debug;
|
|
479
479
|
private threadCount;
|
|
480
|
+
private is_key_valid;
|
|
480
481
|
private LIMIT;
|
|
481
|
-
constructor(apiKey: string, debug
|
|
482
|
+
constructor(apiKey: string, debug: boolean, threadCount: number, is_key_valid: boolean);
|
|
482
483
|
/**
|
|
483
484
|
*
|
|
484
485
|
* Commonly used to fetch and render a single transaction including its decoded log events. Additionally return semantically decoded information for DEX trades, lending and NFT sales.
|
|
@@ -544,8 +544,9 @@ export declare class XykService {
|
|
|
544
544
|
private apiKey;
|
|
545
545
|
private debug;
|
|
546
546
|
private threadCount;
|
|
547
|
+
private is_key_valid;
|
|
547
548
|
private LIMIT;
|
|
548
|
-
constructor(apiKey: string, debug
|
|
549
|
+
constructor(apiKey: string, debug: boolean, threadCount: number, is_key_valid: boolean);
|
|
549
550
|
/**
|
|
550
551
|
*
|
|
551
552
|
* Commonly used to get all the pools of a particular DEX. Supports most common DEXs (Uniswap, SushiSwap, etc), and returns detailed trading data (volume, liquidity, swap counts, fees, LP token prices).
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare class ApiKeyValidator {
|
|
2
|
+
readonly _apiKey: string;
|
|
3
|
+
private static readonly _apiKeyV1Pattern;
|
|
4
|
+
private static readonly _apiKeyV2Pattern;
|
|
5
|
+
static readonly INVALID_API_KEY_MESSAGE = "Invalid or missing API key (sign up at covalenthq.com/platform)";
|
|
6
|
+
constructor(apiKey: string);
|
|
7
|
+
isValidApiKey(): boolean;
|
|
8
|
+
}
|
|
@@ -194,3 +194,39 @@ export interface ChainActivityEvent extends ChainItem {
|
|
|
194
194
|
/** * The timestamp when the address was last seen on the chain. */
|
|
195
195
|
last_seen_at: Date;
|
|
196
196
|
}
|
|
197
|
+
export interface GasPricesResponse {
|
|
198
|
+
/** * The requested chain ID eg: `1`. */
|
|
199
|
+
chain_id: number;
|
|
200
|
+
/** * The requested chain name eg: `eth-mainnet`. */
|
|
201
|
+
chain_name: string;
|
|
202
|
+
/** * The requested quote currency eg: `USD`. */
|
|
203
|
+
quote_currency: string;
|
|
204
|
+
/** * The timestamp when the response was generated. Useful to show data staleness to users. */
|
|
205
|
+
updated_at: Date;
|
|
206
|
+
/** * The requested event type. */
|
|
207
|
+
event_type: string;
|
|
208
|
+
/** * The exchange rate for the requested quote currency. */
|
|
209
|
+
gas_quote_rate: number;
|
|
210
|
+
/** * List of response items. */
|
|
211
|
+
items: PriceItem[];
|
|
212
|
+
}
|
|
213
|
+
export interface PriceItem {
|
|
214
|
+
/** * The average gas price, in WEI, for the time interval. */
|
|
215
|
+
gas_price: string;
|
|
216
|
+
/** * The average gas spent for the time interval. */
|
|
217
|
+
gas_spent: string;
|
|
218
|
+
/** * The average gas spent in `quote-currency` denomination for the time interval. */
|
|
219
|
+
gas_quote: number;
|
|
220
|
+
/** * Other fees, when applicable. For example: OP chain L1 fees. */
|
|
221
|
+
other_fees: OtherFees;
|
|
222
|
+
/** * The sum of the L1 and L2 gas spent, in quote-currency, for the specified time interval. */
|
|
223
|
+
total_gas_quote: number;
|
|
224
|
+
/** * A prettier version of the total average gas spent, in quote-currency, for the specified time interval, for rendering purposes. */
|
|
225
|
+
pretty_total_gas_quote: string;
|
|
226
|
+
/** * The specified time interval. */
|
|
227
|
+
interval: string;
|
|
228
|
+
}
|
|
229
|
+
export interface OtherFees {
|
|
230
|
+
/** * The calculated L1 gas spent, when applicable, in quote-currency, for the specified time interval. */
|
|
231
|
+
l1_gas_quote: number;
|
|
232
|
+
}
|
|
@@ -56,11 +56,11 @@ export interface Transaction {
|
|
|
56
56
|
/** * The explorer links for this transaction. */
|
|
57
57
|
explorers: Explorer[];
|
|
58
58
|
/** * The details for the dex transaction. */
|
|
59
|
-
dex_details: DexReport;
|
|
59
|
+
dex_details: DexReport[];
|
|
60
60
|
/** * The details for the NFT sale transaction. */
|
|
61
|
-
nft_sale_details: NftSalesReport;
|
|
61
|
+
nft_sale_details: NftSalesReport[];
|
|
62
62
|
/** * The details for the lending protocol transaction. */
|
|
63
|
-
lending_details: LendingReport;
|
|
63
|
+
lending_details: LendingReport[];
|
|
64
64
|
/** * The log events. */
|
|
65
65
|
log_events: LogEvent[];
|
|
66
66
|
/** * The details related to the safe transaction. */
|
|
@@ -483,8 +483,9 @@ export declare class BalanceService {
|
|
|
483
483
|
private apiKey;
|
|
484
484
|
private debug;
|
|
485
485
|
private threadCount;
|
|
486
|
+
private is_key_valid;
|
|
486
487
|
private LIMIT;
|
|
487
|
-
constructor(apiKey: string, debug
|
|
488
|
+
constructor(apiKey: string, debug: boolean, threadCount: number, is_key_valid: boolean);
|
|
488
489
|
/**
|
|
489
490
|
*
|
|
490
491
|
* Commonly used to fetch the native, fungible (ERC20), and non-fungible (ERC721 & ERC1155) tokens held by an address. Response includes spot prices and other metadata.
|
|
@@ -3,6 +3,7 @@ import { checkAndModifyResponse, debugOutput, paginateEndpoint } from "../util/A
|
|
|
3
3
|
import { parseISO } from "date-fns";
|
|
4
4
|
import { ExponentialBackoff } from "../util/backoff";
|
|
5
5
|
import pLimit from "p-limit";
|
|
6
|
+
import { ApiKeyValidator } from "../util/ApiKeyValidator";
|
|
6
7
|
class BalancesResponse {
|
|
7
8
|
constructor(data) {
|
|
8
9
|
this.address = data.address;
|
|
@@ -284,10 +285,11 @@ class NativeBalanceItem {
|
|
|
284
285
|
*
|
|
285
286
|
*/
|
|
286
287
|
export class BalanceService {
|
|
287
|
-
constructor(apiKey, debug = false, threadCount = 3) {
|
|
288
|
+
constructor(apiKey, debug = false, threadCount = 3, is_key_valid) {
|
|
288
289
|
this.apiKey = apiKey;
|
|
289
290
|
this.debug = debug;
|
|
290
291
|
this.threadCount = threadCount;
|
|
292
|
+
this.is_key_valid = is_key_valid;
|
|
291
293
|
this.LIMIT = pLimit(this.threadCount);
|
|
292
294
|
}
|
|
293
295
|
/**
|
|
@@ -312,6 +314,14 @@ export class BalanceService {
|
|
|
312
314
|
while (!success) {
|
|
313
315
|
try {
|
|
314
316
|
const urlParams = new URLSearchParams();
|
|
317
|
+
if (!this.is_key_valid) {
|
|
318
|
+
return {
|
|
319
|
+
data: null,
|
|
320
|
+
error: true,
|
|
321
|
+
error_code: 401,
|
|
322
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
323
|
+
};
|
|
324
|
+
}
|
|
315
325
|
if (queryParamOpts?.quoteCurrency !== undefined) {
|
|
316
326
|
urlParams.append("quote-currency", queryParamOpts?.quoteCurrency.toString());
|
|
317
327
|
}
|
|
@@ -337,8 +347,8 @@ export class BalanceService {
|
|
|
337
347
|
"X-Requested-With": userAgent
|
|
338
348
|
}
|
|
339
349
|
}));
|
|
340
|
-
debugOutput(response.url, response.status, startTime);
|
|
341
|
-
if (response.status === 429) {
|
|
350
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
351
|
+
if (response.status === null || response.status === 429) {
|
|
342
352
|
try {
|
|
343
353
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
344
354
|
}
|
|
@@ -347,7 +357,7 @@ export class BalanceService {
|
|
|
347
357
|
return {
|
|
348
358
|
data: null,
|
|
349
359
|
error: true,
|
|
350
|
-
error_code: response.status,
|
|
360
|
+
error_code: response.status ?? 429,
|
|
351
361
|
error_message: error.message
|
|
352
362
|
};
|
|
353
363
|
}
|
|
@@ -395,6 +405,14 @@ export class BalanceService {
|
|
|
395
405
|
while (!success) {
|
|
396
406
|
try {
|
|
397
407
|
const urlParams = new URLSearchParams();
|
|
408
|
+
if (!this.is_key_valid) {
|
|
409
|
+
return {
|
|
410
|
+
data: null,
|
|
411
|
+
error: true,
|
|
412
|
+
error_code: 401,
|
|
413
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
414
|
+
};
|
|
415
|
+
}
|
|
398
416
|
if (queryParamOpts?.quoteCurrency !== undefined) {
|
|
399
417
|
urlParams.append("quote-currency", queryParamOpts?.quoteCurrency.toString());
|
|
400
418
|
}
|
|
@@ -411,8 +429,8 @@ export class BalanceService {
|
|
|
411
429
|
"X-Requested-With": userAgent
|
|
412
430
|
}
|
|
413
431
|
}));
|
|
414
|
-
debugOutput(response.url, response.status, startTime);
|
|
415
|
-
if (response.status === 429) {
|
|
432
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
433
|
+
if (response.status === null || response.status === 429) {
|
|
416
434
|
try {
|
|
417
435
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
418
436
|
}
|
|
@@ -421,7 +439,7 @@ export class BalanceService {
|
|
|
421
439
|
return {
|
|
422
440
|
data: null,
|
|
423
441
|
error: true,
|
|
424
|
-
error_code: response.status,
|
|
442
|
+
error_code: response.status ?? 429,
|
|
425
443
|
error_message: error.message
|
|
426
444
|
};
|
|
427
445
|
}
|
|
@@ -471,6 +489,9 @@ export class BalanceService {
|
|
|
471
489
|
while (!success) {
|
|
472
490
|
try {
|
|
473
491
|
const urlParams = new URLSearchParams();
|
|
492
|
+
if (!this.is_key_valid) {
|
|
493
|
+
throw new Error(`An error occurred 401: ${ApiKeyValidator.INVALID_API_KEY_MESSAGE}`);
|
|
494
|
+
}
|
|
474
495
|
if (queryParamOpts?.quoteCurrency !== undefined) {
|
|
475
496
|
urlParams.append("quote-currency", queryParamOpts?.quoteCurrency.toString());
|
|
476
497
|
}
|
|
@@ -523,6 +544,14 @@ export class BalanceService {
|
|
|
523
544
|
while (!success) {
|
|
524
545
|
try {
|
|
525
546
|
const urlParams = new URLSearchParams();
|
|
547
|
+
if (!this.is_key_valid) {
|
|
548
|
+
return {
|
|
549
|
+
data: null,
|
|
550
|
+
error: true,
|
|
551
|
+
error_code: 401,
|
|
552
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
553
|
+
};
|
|
554
|
+
}
|
|
526
555
|
if (queryParamOpts?.quoteCurrency !== undefined) {
|
|
527
556
|
urlParams.append("quote-currency", queryParamOpts?.quoteCurrency.toString());
|
|
528
557
|
}
|
|
@@ -551,8 +580,8 @@ export class BalanceService {
|
|
|
551
580
|
"X-Requested-With": userAgent
|
|
552
581
|
}
|
|
553
582
|
}));
|
|
554
|
-
debugOutput(response.url, response.status, startTime);
|
|
555
|
-
if (response.status === 429) {
|
|
583
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
584
|
+
if (response.status === null || response.status === 429) {
|
|
556
585
|
try {
|
|
557
586
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
558
587
|
}
|
|
@@ -561,7 +590,7 @@ export class BalanceService {
|
|
|
561
590
|
return {
|
|
562
591
|
data: null,
|
|
563
592
|
error: true,
|
|
564
|
-
error_code: response.status,
|
|
593
|
+
error_code: response.status ?? 429,
|
|
565
594
|
error_message: error.message
|
|
566
595
|
};
|
|
567
596
|
}
|
|
@@ -609,6 +638,9 @@ export class BalanceService {
|
|
|
609
638
|
while (!success) {
|
|
610
639
|
try {
|
|
611
640
|
const urlParams = new URLSearchParams();
|
|
641
|
+
if (!this.is_key_valid) {
|
|
642
|
+
throw new Error(`An error occurred 401: ${ApiKeyValidator.INVALID_API_KEY_MESSAGE}`);
|
|
643
|
+
}
|
|
612
644
|
if (queryParamOpts?.blockHeight !== undefined) {
|
|
613
645
|
urlParams.append("block-height", queryParamOpts?.blockHeight.toString());
|
|
614
646
|
}
|
|
@@ -653,6 +685,14 @@ export class BalanceService {
|
|
|
653
685
|
while (!success) {
|
|
654
686
|
try {
|
|
655
687
|
const urlParams = new URLSearchParams();
|
|
688
|
+
if (!this.is_key_valid) {
|
|
689
|
+
return {
|
|
690
|
+
data: null,
|
|
691
|
+
error: true,
|
|
692
|
+
error_code: 401,
|
|
693
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
694
|
+
};
|
|
695
|
+
}
|
|
656
696
|
if (queryParamOpts?.blockHeight !== undefined) {
|
|
657
697
|
urlParams.append("block-height", queryParamOpts?.blockHeight.toString());
|
|
658
698
|
}
|
|
@@ -675,8 +715,8 @@ export class BalanceService {
|
|
|
675
715
|
"X-Requested-With": userAgent
|
|
676
716
|
}
|
|
677
717
|
}));
|
|
678
|
-
debugOutput(response.url, response.status, startTime);
|
|
679
|
-
if (response.status === 429) {
|
|
718
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
719
|
+
if (response.status === null || response.status === 429) {
|
|
680
720
|
try {
|
|
681
721
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
682
722
|
}
|
|
@@ -685,7 +725,7 @@ export class BalanceService {
|
|
|
685
725
|
return {
|
|
686
726
|
data: null,
|
|
687
727
|
error: true,
|
|
688
|
-
error_code: response.status,
|
|
728
|
+
error_code: response.status ?? 429,
|
|
689
729
|
error_message: error.message
|
|
690
730
|
};
|
|
691
731
|
}
|
|
@@ -738,6 +778,14 @@ export class BalanceService {
|
|
|
738
778
|
while (!success) {
|
|
739
779
|
try {
|
|
740
780
|
const urlParams = new URLSearchParams();
|
|
781
|
+
if (!this.is_key_valid) {
|
|
782
|
+
return {
|
|
783
|
+
data: null,
|
|
784
|
+
error: true,
|
|
785
|
+
error_code: 401,
|
|
786
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
787
|
+
};
|
|
788
|
+
}
|
|
741
789
|
if (queryParamOpts?.quoteCurrency !== undefined) {
|
|
742
790
|
urlParams.append("quote-currency", queryParamOpts?.quoteCurrency.toString());
|
|
743
791
|
}
|
|
@@ -769,8 +817,8 @@ export class BalanceService {
|
|
|
769
817
|
"X-Requested-With": userAgent
|
|
770
818
|
}
|
|
771
819
|
}));
|
|
772
|
-
debugOutput(response.url, response.status, startTime);
|
|
773
|
-
if (response.status === 429) {
|
|
820
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
821
|
+
if (response.status === null || response.status === 429) {
|
|
774
822
|
try {
|
|
775
823
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
776
824
|
}
|
|
@@ -779,7 +827,7 @@ export class BalanceService {
|
|
|
779
827
|
return {
|
|
780
828
|
data: null,
|
|
781
829
|
error: true,
|
|
782
|
-
error_code: response.status,
|
|
830
|
+
error_code: response.status ?? 429,
|
|
783
831
|
error_message: error.message
|
|
784
832
|
};
|
|
785
833
|
}
|
|
@@ -825,6 +873,14 @@ export class BalanceService {
|
|
|
825
873
|
while (!success) {
|
|
826
874
|
try {
|
|
827
875
|
const urlParams = new URLSearchParams();
|
|
876
|
+
if (!this.is_key_valid) {
|
|
877
|
+
return {
|
|
878
|
+
data: null,
|
|
879
|
+
error: true,
|
|
880
|
+
error_code: 401,
|
|
881
|
+
error_message: ApiKeyValidator.INVALID_API_KEY_MESSAGE
|
|
882
|
+
};
|
|
883
|
+
}
|
|
828
884
|
if (queryParamOpts?.quoteCurrency !== undefined) {
|
|
829
885
|
urlParams.append("quote-currency", queryParamOpts?.quoteCurrency.toString());
|
|
830
886
|
}
|
|
@@ -841,8 +897,8 @@ export class BalanceService {
|
|
|
841
897
|
"X-Requested-With": userAgent
|
|
842
898
|
}
|
|
843
899
|
}));
|
|
844
|
-
debugOutput(response.url, response.status, startTime);
|
|
845
|
-
if (response.status === 429) {
|
|
900
|
+
debugOutput(response.url, response.status ?? 429, startTime);
|
|
901
|
+
if (response.status === null || response.status === 429) {
|
|
846
902
|
try {
|
|
847
903
|
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
848
904
|
}
|
|
@@ -851,7 +907,7 @@ export class BalanceService {
|
|
|
851
907
|
return {
|
|
852
908
|
data: null,
|
|
853
909
|
error: true,
|
|
854
|
-
error_code: response.status,
|
|
910
|
+
error_code: response.status ?? 429,
|
|
855
911
|
error_message: error.message
|
|
856
912
|
};
|
|
857
913
|
}
|