@covalenthq/client-sdk 0.7.5 → 0.7.6
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 +20 -0
- package/dist/cjs/index.js +455 -357
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/services/BalanceService.d.ts +2 -1
- package/dist/cjs/services/BaseService.d.ts +2 -1
- package/dist/cjs/services/CovalentClient.d.ts +4 -2
- 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 +8 -4
- package/dist/cjs/services/XykService.d.ts +62 -8
- package/dist/cjs/util/ApiHelpers.d.ts +1 -1
- package/dist/cjs/util/types/XykServiceTypes.d.ts +46 -8
- package/dist/es/index.js +455 -357
- package/dist/es/index.js.map +1 -1
- package/dist/es/services/BalanceService.d.ts +2 -1
- package/dist/es/services/BaseService.d.ts +2 -1
- package/dist/es/services/CovalentClient.d.ts +4 -2
- 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 +8 -4
- package/dist/es/services/XykService.d.ts +62 -8
- package/dist/es/util/ApiHelpers.d.ts +1 -1
- package/dist/es/util/types/XykServiceTypes.d.ts +46 -8
- package/dist/esm/index.js +455 -357
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/services/BalanceService.d.ts +2 -1
- package/dist/esm/services/BaseService.d.ts +2 -1
- package/dist/esm/services/CovalentClient.d.ts +4 -2
- 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 +8 -4
- package/dist/esm/services/XykService.d.ts +62 -8
- package/dist/esm/util/ApiHelpers.d.ts +1 -1
- package/dist/esm/util/types/XykServiceTypes.d.ts +46 -8
- package/dist/services/BalanceService.d.ts +2 -1
- package/dist/services/BalanceService.js +40 -33
- package/dist/services/BalanceService.js.map +1 -1
- package/dist/services/BaseService.d.ts +2 -1
- package/dist/services/BaseService.js +66 -55
- package/dist/services/BaseService.js.map +1 -1
- package/dist/services/CovalentClient.d.ts +4 -2
- package/dist/services/CovalentClient.js +17 -17
- package/dist/services/CovalentClient.js.map +1 -1
- package/dist/services/NftService.d.ts +2 -1
- package/dist/services/NftService.js +82 -68
- package/dist/services/NftService.js.map +1 -1
- package/dist/services/PricingService.d.ts +2 -1
- package/dist/services/PricingService.js +8 -6
- package/dist/services/PricingService.js.map +1 -1
- package/dist/services/SecurityService.d.ts +2 -1
- package/dist/services/SecurityService.js +14 -11
- package/dist/services/SecurityService.js.map +1 -1
- package/dist/services/TransactionService.d.ts +8 -4
- package/dist/services/TransactionService.js +95 -79
- package/dist/services/TransactionService.js.map +1 -1
- package/dist/services/XykService.d.ts +62 -8
- package/dist/services/XykService.js +122 -78
- package/dist/services/XykService.js.map +1 -1
- package/dist/util/ApiHelpers.d.ts +1 -1
- package/dist/util/ApiHelpers.js +6 -5
- package/dist/util/ApiHelpers.js.map +1 -1
- package/dist/util/types/XykServiceTypes.d.ts +46 -8
- package/package.json +1 -1
|
@@ -484,8 +484,9 @@ export declare class BalanceService {
|
|
|
484
484
|
private debug;
|
|
485
485
|
private threadCount;
|
|
486
486
|
private is_key_valid;
|
|
487
|
+
private enableRetry;
|
|
487
488
|
private LIMIT;
|
|
488
|
-
constructor(apiKey: string, debug: boolean, threadCount: number, is_key_valid: boolean);
|
|
489
|
+
constructor(apiKey: string, debug: boolean, threadCount: number, is_key_valid: boolean, enableRetry?: boolean);
|
|
489
490
|
/**
|
|
490
491
|
*
|
|
491
492
|
* 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.
|
|
@@ -364,8 +364,9 @@ export declare class BaseService {
|
|
|
364
364
|
private debug;
|
|
365
365
|
private threadCount;
|
|
366
366
|
private is_key_valid;
|
|
367
|
+
private enableRetry;
|
|
367
368
|
private LIMIT;
|
|
368
|
-
constructor(apiKey: string, debug: boolean, threadCount: number, is_key_valid: boolean);
|
|
369
|
+
constructor(apiKey: string, debug: boolean, threadCount: number, is_key_valid: boolean, enableRetry?: boolean);
|
|
369
370
|
/**
|
|
370
371
|
*
|
|
371
372
|
* Commonly used to fetch and render a single block for a block explorer.
|
|
@@ -7,11 +7,11 @@ 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-l2-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" | "avalanche-hubble-exchange-testnet" | "avalanche-miho-testnet" | "avalanche-bulletin-testnet" | "avalanche-kiwi-testnet" | "avalanche-hero-testnet" | "avalanche-avacloud-testnet" | "avalanche-thirdweb-testnet" | "avalanche-mondrian-testnet" | "avalanche-conduit-testnet" | "avalanche-nmac-testnet" | "avalanche-orderly-testnet" | "avalanche-amplify-testnet" | "avalanche-mirai-testnet" | "avalanche-wagmi-testnet" | "avalanche-playa3ull-testnet" | "avalanche-beam-mainnet" | "scroll-mainnet" | "eth-holesky";
|
|
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.7.
|
|
10
|
+
export declare const userAgent = "com.covalenthq.sdk.typescript/0.7.6";
|
|
11
11
|
export declare class Response<T> {
|
|
12
12
|
data: T;
|
|
13
13
|
error: boolean;
|
|
14
|
-
error_code: number;
|
|
14
|
+
error_code: number | string;
|
|
15
15
|
error_message: string;
|
|
16
16
|
}
|
|
17
17
|
export interface CovalentClientSettings {
|
|
@@ -19,6 +19,8 @@ export interface CovalentClientSettings {
|
|
|
19
19
|
debug?: boolean;
|
|
20
20
|
/** * The number of concurrent requests allowed. */
|
|
21
21
|
threadCount?: number;
|
|
22
|
+
/** Toggle to turn on and off retry logic */
|
|
23
|
+
enableRetry?: boolean;
|
|
22
24
|
}
|
|
23
25
|
/**
|
|
24
26
|
* CovalentClient Class
|
|
@@ -484,8 +484,9 @@ export declare class NftService {
|
|
|
484
484
|
private debug;
|
|
485
485
|
private threadCount;
|
|
486
486
|
private is_key_valid;
|
|
487
|
+
private enableRetry;
|
|
487
488
|
private LIMIT;
|
|
488
|
-
constructor(apiKey: string, debug: boolean, threadCount: number, is_key_valid: boolean);
|
|
489
|
+
constructor(apiKey: string, debug: boolean, threadCount: number, is_key_valid: boolean, enableRetry?: boolean);
|
|
489
490
|
/**
|
|
490
491
|
*
|
|
491
492
|
* Commonly used to fetch the list of NFT collections with downloaded and cached off chain data like token metadata and asset files.
|
|
@@ -70,8 +70,9 @@ export declare class PricingService {
|
|
|
70
70
|
private debug;
|
|
71
71
|
private threadCount;
|
|
72
72
|
private is_key_valid;
|
|
73
|
+
private enableRetry;
|
|
73
74
|
private LIMIT;
|
|
74
|
-
constructor(apiKey: string, debug: boolean, threadCount: number, is_key_valid: boolean);
|
|
75
|
+
constructor(apiKey: string, debug: boolean, threadCount: number, is_key_valid: boolean, enableRetry?: boolean);
|
|
75
76
|
/**
|
|
76
77
|
*
|
|
77
78
|
* Commonly used to get historic prices of a token between date ranges. Supports native tokens.
|
|
@@ -137,8 +137,9 @@ export declare class SecurityService {
|
|
|
137
137
|
private debug;
|
|
138
138
|
private threadCount;
|
|
139
139
|
private is_key_valid;
|
|
140
|
+
private enableRetry;
|
|
140
141
|
private LIMIT;
|
|
141
|
-
constructor(apiKey: string, debug: boolean, threadCount: number, is_key_valid: boolean);
|
|
142
|
+
constructor(apiKey: string, debug: boolean, threadCount: number, is_key_valid: boolean, enableRetry?: boolean);
|
|
142
143
|
/**
|
|
143
144
|
*
|
|
144
145
|
* Commonly used to get a list of approvals across all token contracts categorized by spenders for a wallet’s assets.
|
|
@@ -339,6 +339,7 @@ declare class RecentTransactionsResponse {
|
|
|
339
339
|
private _apiKey;
|
|
340
340
|
private _threadCount;
|
|
341
341
|
private _urlParams;
|
|
342
|
+
private _enableRetry;
|
|
342
343
|
/** * The requested address. */
|
|
343
344
|
address: string;
|
|
344
345
|
/** * The timestamp when the response was generated. Useful to show data staleness to users. */
|
|
@@ -354,7 +355,7 @@ declare class RecentTransactionsResponse {
|
|
|
354
355
|
links: PaginationLinks;
|
|
355
356
|
/** * List of response items. */
|
|
356
357
|
items: Transaction[];
|
|
357
|
-
constructor(data: RecentTransactionsResponse, _debug: boolean, _apiKey: string, _threadCount: number, _urlParams: URLSearchParams);
|
|
358
|
+
constructor(data: RecentTransactionsResponse, _debug: boolean, _apiKey: string, _threadCount: number, _urlParams: URLSearchParams, _enableRetry: boolean);
|
|
358
359
|
prev(): Promise<Response<RecentTransactionsResponse>>;
|
|
359
360
|
next(): Promise<Response<RecentTransactionsResponse>>;
|
|
360
361
|
}
|
|
@@ -412,6 +413,7 @@ declare class TransactionsResponse {
|
|
|
412
413
|
private _apiKey;
|
|
413
414
|
private _threadCount;
|
|
414
415
|
private _urlParams;
|
|
416
|
+
private _enableRetry;
|
|
415
417
|
/** * The requested address. */
|
|
416
418
|
address: string;
|
|
417
419
|
/** * The timestamp when the response was generated. Useful to show data staleness to users. */
|
|
@@ -427,7 +429,7 @@ declare class TransactionsResponse {
|
|
|
427
429
|
links: PaginationLinks;
|
|
428
430
|
/** * List of response items. */
|
|
429
431
|
items: Transaction[];
|
|
430
|
-
constructor(data: TransactionsResponse, _debug: boolean, _apiKey: string, _threadCount: number, _urlParams: URLSearchParams);
|
|
432
|
+
constructor(data: TransactionsResponse, _debug: boolean, _apiKey: string, _threadCount: number, _urlParams: URLSearchParams, _enableRetry: boolean);
|
|
431
433
|
prev(): Promise<Response<TransactionsResponse>>;
|
|
432
434
|
next(): Promise<Response<TransactionsResponse>>;
|
|
433
435
|
}
|
|
@@ -436,6 +438,7 @@ declare class TransactionsTimeBucketResponse {
|
|
|
436
438
|
private _apiKey;
|
|
437
439
|
private _threadCount;
|
|
438
440
|
private _urlParams;
|
|
441
|
+
private _enableRetry;
|
|
439
442
|
/** * The requested address. */
|
|
440
443
|
address: string;
|
|
441
444
|
/** * The timestamp when the response was generated. Useful to show data staleness to users. */
|
|
@@ -452,7 +455,7 @@ declare class TransactionsTimeBucketResponse {
|
|
|
452
455
|
links: PaginationLinks;
|
|
453
456
|
/** * List of response items. */
|
|
454
457
|
items: Transaction[];
|
|
455
|
-
constructor(data: TransactionsTimeBucketResponse, _debug: boolean, _apiKey: string, _threadCount: number, _urlParams: URLSearchParams);
|
|
458
|
+
constructor(data: TransactionsTimeBucketResponse, _debug: boolean, _apiKey: string, _threadCount: number, _urlParams: URLSearchParams, _enableRetry: boolean);
|
|
456
459
|
prev(): Promise<Response<TransactionsTimeBucketResponse>>;
|
|
457
460
|
next(): Promise<Response<TransactionsTimeBucketResponse>>;
|
|
458
461
|
}
|
|
@@ -511,8 +514,9 @@ export declare class TransactionService {
|
|
|
511
514
|
private debug;
|
|
512
515
|
private threadCount;
|
|
513
516
|
private is_key_valid;
|
|
517
|
+
private enableRetry;
|
|
514
518
|
private LIMIT;
|
|
515
|
-
constructor(apiKey: string, debug: boolean, threadCount: number, is_key_valid: boolean);
|
|
519
|
+
constructor(apiKey: string, debug: boolean, threadCount: number, is_key_valid: boolean, enableRetry?: boolean);
|
|
516
520
|
/**
|
|
517
521
|
*
|
|
518
522
|
* 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.
|
|
@@ -256,6 +256,8 @@ declare class PoolsDexDataItem {
|
|
|
256
256
|
volume_7d_quote: number;
|
|
257
257
|
/** * The fee 24h converted to fiat in `quote-currency`. */
|
|
258
258
|
fee_24h_quote: number;
|
|
259
|
+
/** * The annual fee percentage. */
|
|
260
|
+
annualized_fee: number;
|
|
259
261
|
/** * A prettier version of the volume 24h quote for rendering purposes. */
|
|
260
262
|
pretty_volume_24h_quote: string;
|
|
261
263
|
/** * A prettier version of the volume 7d quote for rendering purposes. */
|
|
@@ -316,6 +318,8 @@ declare class UniswapLikeToken {
|
|
|
316
318
|
/** * The asset balance. Use `contract_decimals` to scale this balance for display purposes. */
|
|
317
319
|
balance: bigint | null;
|
|
318
320
|
quote: number;
|
|
321
|
+
/** * A prettier version of the quote for rendering purposes. */
|
|
322
|
+
pretty_quote: string;
|
|
319
323
|
/** * The exchange rate for the requested quote currency. */
|
|
320
324
|
quote_rate: number;
|
|
321
325
|
constructor(data: UniswapLikeToken);
|
|
@@ -332,6 +336,8 @@ declare class UniswapLikeTokenWithSupply {
|
|
|
332
336
|
/** * The asset balance. Use `contract_decimals` to scale this balance for display purposes. */
|
|
333
337
|
balance: bigint | null;
|
|
334
338
|
quote: number;
|
|
339
|
+
/** * A prettier version of the quote for rendering purposes. */
|
|
340
|
+
pretty_quote: string;
|
|
335
341
|
/** * The exchange rate for the requested quote currency. */
|
|
336
342
|
quote_rate: number;
|
|
337
343
|
/** * Total supply of this pool token. */
|
|
@@ -444,12 +450,51 @@ declare class ExchangeTransaction {
|
|
|
444
450
|
total_quote: number;
|
|
445
451
|
/** * A prettier version of the total quote for rendering purposes. */
|
|
446
452
|
pretty_total_quote: string;
|
|
453
|
+
/** * The value attached to this tx. */
|
|
454
|
+
value: bigint | null;
|
|
455
|
+
/** * The value attached in `quote-currency` to this tx. */
|
|
456
|
+
value_quote: number;
|
|
457
|
+
/** * A prettier version of the quote for rendering purposes. */
|
|
458
|
+
pretty_value_quote: string;
|
|
459
|
+
/** * The requested chain native gas token metadata. */
|
|
460
|
+
gas_metadata: ContractMetadata;
|
|
461
|
+
/** * The amount of gas supplied for this tx. */
|
|
462
|
+
gas_offered: string;
|
|
463
|
+
/** * The gas spent for this tx. */
|
|
464
|
+
gas_spent: string;
|
|
465
|
+
/** * The gas price at the time of this tx. */
|
|
466
|
+
gas_price: string;
|
|
467
|
+
/** * The total transaction fees (`gas_price` * `gas_spent`) paid for this tx, denoted in wei. */
|
|
468
|
+
fees_paid: bigint | null;
|
|
469
|
+
/** * The gas spent in `quote-currency` denomination. */
|
|
470
|
+
gas_quote: number;
|
|
471
|
+
/** * A prettier version of the quote for rendering purposes. */
|
|
472
|
+
pretty_gas_quote: string;
|
|
473
|
+
/** * The native gas exchange rate for the requested `quote-currency`. */
|
|
474
|
+
gas_quote_rate: number;
|
|
475
|
+
/** * The requested quote currency eg: `USD`. */
|
|
476
|
+
quote_currency: string;
|
|
447
477
|
token_0: PoolToken;
|
|
448
478
|
token_1: PoolToken;
|
|
449
479
|
token_0_quote_rate: number;
|
|
450
480
|
token_1_quote_rate: number;
|
|
451
481
|
constructor(data: ExchangeTransaction);
|
|
452
482
|
}
|
|
483
|
+
declare class ContractMetadata {
|
|
484
|
+
/** * Use contract decimals to format the token balance for display purposes - divide the balance by `10^{contract_decimals}`. */
|
|
485
|
+
contract_decimals: number;
|
|
486
|
+
/** * The string returned by the `name()` method. */
|
|
487
|
+
contract_name: string;
|
|
488
|
+
/** * The ticker symbol for this contract. This field is set by a developer and non-unique across a network. */
|
|
489
|
+
contract_ticker_symbol: string;
|
|
490
|
+
/** * Use the relevant `contract_address` to lookup prices, logos, token transfers, etc. */
|
|
491
|
+
contract_address: string;
|
|
492
|
+
/** * A list of supported standard ERC interfaces, eg: `ERC20` and `ERC721`. */
|
|
493
|
+
supports_erc: string;
|
|
494
|
+
/** * The contract logo URL. */
|
|
495
|
+
logo_url: string;
|
|
496
|
+
constructor(data: ContractMetadata);
|
|
497
|
+
}
|
|
453
498
|
declare class PoolToken {
|
|
454
499
|
/** * Use contract decimals to format the token balance for display purposes - divide the balance by `10^{contract_decimals}`. */
|
|
455
500
|
contract_decimals: number;
|
|
@@ -512,13 +557,17 @@ declare class UniswapLikeEcosystemCharts {
|
|
|
512
557
|
/** * The requested quote currency eg: `USD`. */
|
|
513
558
|
quote_currency: string;
|
|
514
559
|
gas_token_price_quote: number;
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
560
|
+
total_swaps_24h: number;
|
|
561
|
+
total_active_pairs_7d: number;
|
|
562
|
+
total_fees_24h: number;
|
|
563
|
+
/** * A prettier version of the gas quote for rendering purposes. */
|
|
564
|
+
pretty_gas_token_price_quote: string;
|
|
565
|
+
/** * A prettier version of the 24h total fees for rendering purposes. */
|
|
566
|
+
pretty_total_fees_24h: string;
|
|
567
|
+
volume_chart_7d: VolumeEcosystemChart[];
|
|
568
|
+
volume_chart_30d: VolumeEcosystemChart[];
|
|
569
|
+
liquidity_chart_7d: LiquidityEcosystemChart[];
|
|
570
|
+
liquidity_chart_30d: LiquidityEcosystemChart[];
|
|
522
571
|
constructor(data: UniswapLikeEcosystemCharts);
|
|
523
572
|
}
|
|
524
573
|
declare class VolumeEcosystemChart {
|
|
@@ -530,6 +579,8 @@ declare class VolumeEcosystemChart {
|
|
|
530
579
|
/** * The requested quote currency eg: `USD`. */
|
|
531
580
|
quote_currency: string;
|
|
532
581
|
volume_quote: number;
|
|
582
|
+
/** * A prettier version of the volume quote for rendering purposes. */
|
|
583
|
+
pretty_volume_quote: string;
|
|
533
584
|
swap_count_24: number;
|
|
534
585
|
constructor(data: VolumeEcosystemChart);
|
|
535
586
|
}
|
|
@@ -542,6 +593,8 @@ declare class LiquidityEcosystemChart {
|
|
|
542
593
|
/** * The requested quote currency eg: `USD`. */
|
|
543
594
|
quote_currency: string;
|
|
544
595
|
liquidity_quote: number;
|
|
596
|
+
/** * A prettier version of the liquidity quote for rendering purposes. */
|
|
597
|
+
pretty_liquidity_quote: string;
|
|
545
598
|
constructor(data: LiquidityEcosystemChart);
|
|
546
599
|
}
|
|
547
600
|
declare class HealthDataResponse {
|
|
@@ -587,8 +640,9 @@ export declare class XykService {
|
|
|
587
640
|
private debug;
|
|
588
641
|
private threadCount;
|
|
589
642
|
private is_key_valid;
|
|
643
|
+
private enableRetry;
|
|
590
644
|
private LIMIT;
|
|
591
|
-
constructor(apiKey: string, debug: boolean, threadCount: number, is_key_valid: boolean);
|
|
645
|
+
constructor(apiKey: string, debug: boolean, threadCount: number, is_key_valid: boolean, enableRetry?: boolean);
|
|
592
646
|
/**
|
|
593
647
|
*
|
|
594
648
|
* 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).
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare function checkAndModifyResponse(jsonObj: any): void;
|
|
2
2
|
export declare function debugOutput(url: string, responseStatus: number, startTime: number | [number, number] | undefined): Promise<void>;
|
|
3
3
|
type Constructor<T> = new (...args: any[]) => T;
|
|
4
|
-
export declare function paginateEndpoint<T1, T2>(url: string, apiKey: string, urlsParams: URLSearchParams, dataClassConstructor: Constructor<T1>, debug: boolean, threadCount: number): AsyncIterable<T1>;
|
|
4
|
+
export declare function paginateEndpoint<T1, T2>(url: string, apiKey: string, urlsParams: URLSearchParams, dataClassConstructor: Constructor<T1>, debug: boolean, threadCount: number, enableRetry: boolean): AsyncIterable<T1>;
|
|
5
5
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Pagination } from "./GenericTypes";
|
|
1
|
+
import { Pagination, ContractMetadata } from "./GenericTypes";
|
|
2
2
|
export interface PoolResponse {
|
|
3
3
|
/** * The timestamp when the response was generated. Useful to show data staleness to users. */
|
|
4
4
|
updated_at: Date;
|
|
@@ -232,6 +232,8 @@ export interface PoolsDexDataItem {
|
|
|
232
232
|
volume_7d_quote: number;
|
|
233
233
|
/** * The fee 24h converted to fiat in `quote-currency`. */
|
|
234
234
|
fee_24h_quote: number;
|
|
235
|
+
/** * The annual fee percentage. */
|
|
236
|
+
annualized_fee: number;
|
|
235
237
|
/** * A prettier version of the volume 24h quote for rendering purposes. */
|
|
236
238
|
pretty_volume_24h_quote: string;
|
|
237
239
|
/** * A prettier version of the volume 7d quote for rendering purposes. */
|
|
@@ -288,6 +290,8 @@ export interface UniswapLikeToken {
|
|
|
288
290
|
/** * The asset balance. Use `contract_decimals` to scale this balance for display purposes. */
|
|
289
291
|
balance: bigint | null;
|
|
290
292
|
quote: number;
|
|
293
|
+
/** * A prettier version of the quote for rendering purposes. */
|
|
294
|
+
pretty_quote: string;
|
|
291
295
|
/** * The exchange rate for the requested quote currency. */
|
|
292
296
|
quote_rate: number;
|
|
293
297
|
}
|
|
@@ -303,6 +307,8 @@ export interface UniswapLikeTokenWithSupply {
|
|
|
303
307
|
/** * The asset balance. Use `contract_decimals` to scale this balance for display purposes. */
|
|
304
308
|
balance: bigint | null;
|
|
305
309
|
quote: number;
|
|
310
|
+
/** * A prettier version of the quote for rendering purposes. */
|
|
311
|
+
pretty_quote: string;
|
|
306
312
|
/** * The exchange rate for the requested quote currency. */
|
|
307
313
|
quote_rate: number;
|
|
308
314
|
/** * Total supply of this pool token. */
|
|
@@ -409,6 +415,30 @@ export interface ExchangeTransaction {
|
|
|
409
415
|
total_quote: number;
|
|
410
416
|
/** * A prettier version of the total quote for rendering purposes. */
|
|
411
417
|
pretty_total_quote: string;
|
|
418
|
+
/** * The value attached to this tx. */
|
|
419
|
+
value: bigint | null;
|
|
420
|
+
/** * The value attached in `quote-currency` to this tx. */
|
|
421
|
+
value_quote: number;
|
|
422
|
+
/** * A prettier version of the quote for rendering purposes. */
|
|
423
|
+
pretty_value_quote: string;
|
|
424
|
+
/** * The requested chain native gas token metadata. */
|
|
425
|
+
gas_metadata: ContractMetadata;
|
|
426
|
+
/** * The amount of gas supplied for this tx. */
|
|
427
|
+
gas_offered: string;
|
|
428
|
+
/** * The gas spent for this tx. */
|
|
429
|
+
gas_spent: string;
|
|
430
|
+
/** * The gas price at the time of this tx. */
|
|
431
|
+
gas_price: string;
|
|
432
|
+
/** * The total transaction fees (`gas_price` * `gas_spent`) paid for this tx, denoted in wei. */
|
|
433
|
+
fees_paid: bigint | null;
|
|
434
|
+
/** * The gas spent in `quote-currency` denomination. */
|
|
435
|
+
gas_quote: number;
|
|
436
|
+
/** * A prettier version of the quote for rendering purposes. */
|
|
437
|
+
pretty_gas_quote: string;
|
|
438
|
+
/** * The native gas exchange rate for the requested `quote-currency`. */
|
|
439
|
+
gas_quote_rate: number;
|
|
440
|
+
/** * The requested quote currency eg: `USD`. */
|
|
441
|
+
quote_currency: string;
|
|
412
442
|
token_0: PoolToken;
|
|
413
443
|
token_1: PoolToken;
|
|
414
444
|
token_0_quote_rate: number;
|
|
@@ -472,13 +502,17 @@ export interface UniswapLikeEcosystemCharts {
|
|
|
472
502
|
/** * The requested quote currency eg: `USD`. */
|
|
473
503
|
quote_currency: string;
|
|
474
504
|
gas_token_price_quote: number;
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
505
|
+
total_swaps_24h: number;
|
|
506
|
+
total_active_pairs_7d: number;
|
|
507
|
+
total_fees_24h: number;
|
|
508
|
+
/** * A prettier version of the gas quote for rendering purposes. */
|
|
509
|
+
pretty_gas_token_price_quote: string;
|
|
510
|
+
/** * A prettier version of the 24h total fees for rendering purposes. */
|
|
511
|
+
pretty_total_fees_24h: string;
|
|
512
|
+
volume_chart_7d: VolumeEcosystemChart[];
|
|
513
|
+
volume_chart_30d: VolumeEcosystemChart[];
|
|
514
|
+
liquidity_chart_7d: LiquidityEcosystemChart[];
|
|
515
|
+
liquidity_chart_30d: LiquidityEcosystemChart[];
|
|
482
516
|
}
|
|
483
517
|
export interface VolumeEcosystemChart {
|
|
484
518
|
/** * The name of the DEX, eg: `uniswap_v2`. */
|
|
@@ -489,6 +523,8 @@ export interface VolumeEcosystemChart {
|
|
|
489
523
|
/** * The requested quote currency eg: `USD`. */
|
|
490
524
|
quote_currency: string;
|
|
491
525
|
volume_quote: number;
|
|
526
|
+
/** * A prettier version of the volume quote for rendering purposes. */
|
|
527
|
+
pretty_volume_quote: string;
|
|
492
528
|
swap_count_24: number;
|
|
493
529
|
}
|
|
494
530
|
export interface LiquidityEcosystemChart {
|
|
@@ -500,6 +536,8 @@ export interface LiquidityEcosystemChart {
|
|
|
500
536
|
/** * The requested quote currency eg: `USD`. */
|
|
501
537
|
quote_currency: string;
|
|
502
538
|
liquidity_quote: number;
|
|
539
|
+
/** * A prettier version of the liquidity quote for rendering purposes. */
|
|
540
|
+
pretty_liquidity_quote: string;
|
|
503
541
|
}
|
|
504
542
|
export interface HealthDataResponse {
|
|
505
543
|
/** * The timestamp when the response was generated. Useful to show data staleness to users. */
|
|
@@ -484,8 +484,9 @@ export declare class BalanceService {
|
|
|
484
484
|
private debug;
|
|
485
485
|
private threadCount;
|
|
486
486
|
private is_key_valid;
|
|
487
|
+
private enableRetry;
|
|
487
488
|
private LIMIT;
|
|
488
|
-
constructor(apiKey: string, debug: boolean, threadCount: number, is_key_valid: boolean);
|
|
489
|
+
constructor(apiKey: string, debug: boolean, threadCount: number, is_key_valid: boolean, enableRetry?: boolean);
|
|
489
490
|
/**
|
|
490
491
|
*
|
|
491
492
|
* 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.
|
|
@@ -285,11 +285,12 @@ class NativeBalanceItem {
|
|
|
285
285
|
*
|
|
286
286
|
*/
|
|
287
287
|
export class BalanceService {
|
|
288
|
-
constructor(apiKey, debug = false, threadCount = 3, is_key_valid) {
|
|
288
|
+
constructor(apiKey, debug = false, threadCount = 3, is_key_valid, enableRetry = true) {
|
|
289
289
|
this.apiKey = apiKey;
|
|
290
290
|
this.debug = debug;
|
|
291
291
|
this.threadCount = threadCount;
|
|
292
292
|
this.is_key_valid = is_key_valid;
|
|
293
|
+
this.enableRetry = enableRetry;
|
|
293
294
|
this.LIMIT = pLimit(this.threadCount);
|
|
294
295
|
}
|
|
295
296
|
/**
|
|
@@ -337,6 +338,7 @@ export class BalanceService {
|
|
|
337
338
|
if (queryParamOpts?.noNftAssetMetadata !== undefined) {
|
|
338
339
|
urlParams.append("no-nft-asset-metadata", queryParamOpts?.noNftAssetMetadata.toString());
|
|
339
340
|
}
|
|
341
|
+
const url = `https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/balances_v2/?${urlParams}`;
|
|
340
342
|
let startTime;
|
|
341
343
|
if (this.debug) {
|
|
342
344
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -347,10 +349,10 @@ export class BalanceService {
|
|
|
347
349
|
"X-Requested-With": userAgent
|
|
348
350
|
}
|
|
349
351
|
}));
|
|
350
|
-
debugOutput(response.url, response.status
|
|
351
|
-
if (response.status === null || response.status === 429) {
|
|
352
|
+
debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
|
|
353
|
+
if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
|
|
352
354
|
try {
|
|
353
|
-
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
355
|
+
data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
|
|
354
356
|
}
|
|
355
357
|
catch (error) {
|
|
356
358
|
success = true;
|
|
@@ -380,8 +382,8 @@ export class BalanceService {
|
|
|
380
382
|
return {
|
|
381
383
|
data: null,
|
|
382
384
|
error: true,
|
|
383
|
-
error_code: data ? data.error_code : response.status,
|
|
384
|
-
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
385
|
+
error_code: error.cause ? error.cause.code : data ? data.error_code : response ? response.status : "Unknown Error Code",
|
|
386
|
+
error_message: error.cause ? error.cause.message : data ? data.error_message : response && response.status === 500 ? "Internal server error" : !response ? "Unknown Error" : "401 Authorization Required"
|
|
385
387
|
};
|
|
386
388
|
}
|
|
387
389
|
}
|
|
@@ -419,6 +421,7 @@ export class BalanceService {
|
|
|
419
421
|
if (queryParamOpts?.days !== undefined) {
|
|
420
422
|
urlParams.append("days", queryParamOpts?.days.toString());
|
|
421
423
|
}
|
|
424
|
+
const url = `https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/portfolio_v2/?${urlParams}`;
|
|
422
425
|
let startTime;
|
|
423
426
|
if (this.debug) {
|
|
424
427
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -429,10 +432,10 @@ export class BalanceService {
|
|
|
429
432
|
"X-Requested-With": userAgent
|
|
430
433
|
}
|
|
431
434
|
}));
|
|
432
|
-
debugOutput(response.url, response.status
|
|
433
|
-
if (response.status === null || response.status === 429) {
|
|
435
|
+
debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
|
|
436
|
+
if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
|
|
434
437
|
try {
|
|
435
|
-
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
438
|
+
data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
|
|
436
439
|
}
|
|
437
440
|
catch (error) {
|
|
438
441
|
success = true;
|
|
@@ -462,8 +465,8 @@ export class BalanceService {
|
|
|
462
465
|
return {
|
|
463
466
|
data: null,
|
|
464
467
|
error: true,
|
|
465
|
-
error_code: data ? data.error_code : response.status,
|
|
466
|
-
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
468
|
+
error_code: error.cause ? error.cause.code : data ? data.error_code : response ? response.status : "Unknown Error Code",
|
|
469
|
+
error_message: error.cause ? error.cause.message : data ? data.error_message : response && response.status === 500 ? "Internal server error" : !response ? "Unknown Error" : "401 Authorization Required"
|
|
467
470
|
};
|
|
468
471
|
}
|
|
469
472
|
}
|
|
@@ -510,7 +513,7 @@ export class BalanceService {
|
|
|
510
513
|
if (queryParamOpts?.pageNumber !== undefined) {
|
|
511
514
|
urlParams.append("page-number", queryParamOpts?.pageNumber.toString());
|
|
512
515
|
}
|
|
513
|
-
for await (res of paginateEndpoint(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/transfers_v2/`, this.apiKey, urlParams, BlockTransactionWithContractTransfers, this.debug, this.threadCount)) {
|
|
516
|
+
for await (res of paginateEndpoint(`https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/transfers_v2/`, this.apiKey, urlParams, BlockTransactionWithContractTransfers, this.debug, this.threadCount, this.enableRetry)) {
|
|
514
517
|
yield res;
|
|
515
518
|
}
|
|
516
519
|
success = true;
|
|
@@ -570,6 +573,7 @@ export class BalanceService {
|
|
|
570
573
|
if (queryParamOpts?.pageNumber !== undefined) {
|
|
571
574
|
urlParams.append("page-number", queryParamOpts?.pageNumber.toString());
|
|
572
575
|
}
|
|
576
|
+
const url = `https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/transfers_v2/?${urlParams}`;
|
|
573
577
|
let startTime;
|
|
574
578
|
if (this.debug) {
|
|
575
579
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -580,10 +584,10 @@ export class BalanceService {
|
|
|
580
584
|
"X-Requested-With": userAgent
|
|
581
585
|
}
|
|
582
586
|
}));
|
|
583
|
-
debugOutput(response.url, response.status
|
|
584
|
-
if (response.status === null || response.status === 429) {
|
|
587
|
+
debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
|
|
588
|
+
if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
|
|
585
589
|
try {
|
|
586
|
-
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
590
|
+
data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
|
|
587
591
|
}
|
|
588
592
|
catch (error) {
|
|
589
593
|
success = true;
|
|
@@ -613,8 +617,8 @@ export class BalanceService {
|
|
|
613
617
|
return {
|
|
614
618
|
data: null,
|
|
615
619
|
error: true,
|
|
616
|
-
error_code: data ? data.error_code : response.status,
|
|
617
|
-
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
620
|
+
error_code: error.cause ? error.cause.code : data ? data.error_code : response ? response.status : "Unknown Error Code",
|
|
621
|
+
error_message: error.cause ? error.cause.message : data ? data.error_message : response && response.status === 500 ? "Internal server error" : !response ? "Unknown Error" : "401 Authorization Required"
|
|
618
622
|
};
|
|
619
623
|
}
|
|
620
624
|
}
|
|
@@ -653,7 +657,7 @@ export class BalanceService {
|
|
|
653
657
|
if (queryParamOpts?.date !== undefined) {
|
|
654
658
|
urlParams.append("date", queryParamOpts?.date.toString());
|
|
655
659
|
}
|
|
656
|
-
for await (res of paginateEndpoint(`https://api.covalenthq.com/v1/${chainName}/tokens/${tokenAddress}/token_holders_v2/`, this.apiKey, urlParams, TokenHolder, this.debug, this.threadCount)) {
|
|
660
|
+
for await (res of paginateEndpoint(`https://api.covalenthq.com/v1/${chainName}/tokens/${tokenAddress}/token_holders_v2/`, this.apiKey, urlParams, TokenHolder, this.debug, this.threadCount, this.enableRetry)) {
|
|
657
661
|
yield res;
|
|
658
662
|
}
|
|
659
663
|
success = true;
|
|
@@ -705,6 +709,7 @@ export class BalanceService {
|
|
|
705
709
|
if (queryParamOpts?.date !== undefined) {
|
|
706
710
|
urlParams.append("date", queryParamOpts?.date.toString());
|
|
707
711
|
}
|
|
712
|
+
const url = `https://api.covalenthq.com/v1/${chainName}/tokens/${tokenAddress}/token_holders_v2/?${urlParams}`;
|
|
708
713
|
let startTime;
|
|
709
714
|
if (this.debug) {
|
|
710
715
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -715,10 +720,10 @@ export class BalanceService {
|
|
|
715
720
|
"X-Requested-With": userAgent
|
|
716
721
|
}
|
|
717
722
|
}));
|
|
718
|
-
debugOutput(response.url, response.status
|
|
719
|
-
if (response.status === null || response.status === 429) {
|
|
723
|
+
debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
|
|
724
|
+
if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
|
|
720
725
|
try {
|
|
721
|
-
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
726
|
+
data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
|
|
722
727
|
}
|
|
723
728
|
catch (error) {
|
|
724
729
|
success = true;
|
|
@@ -748,8 +753,8 @@ export class BalanceService {
|
|
|
748
753
|
return {
|
|
749
754
|
data: null,
|
|
750
755
|
error: true,
|
|
751
|
-
error_code: data ? data.error_code : response.status,
|
|
752
|
-
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
756
|
+
error_code: error.cause ? error.cause.code : data ? data.error_code : response ? response.status : "Unknown Error Code",
|
|
757
|
+
error_message: error.cause ? error.cause.message : data ? data.error_message : response && response.status === 500 ? "Internal server error" : !response ? "Unknown Error" : "401 Authorization Required"
|
|
753
758
|
};
|
|
754
759
|
}
|
|
755
760
|
}
|
|
@@ -807,6 +812,7 @@ export class BalanceService {
|
|
|
807
812
|
if (queryParamOpts?.date !== undefined) {
|
|
808
813
|
urlParams.append("date", queryParamOpts?.date.toString());
|
|
809
814
|
}
|
|
815
|
+
const url = `https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/historical_balances/?${urlParams}`;
|
|
810
816
|
let startTime;
|
|
811
817
|
if (this.debug) {
|
|
812
818
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -817,10 +823,10 @@ export class BalanceService {
|
|
|
817
823
|
"X-Requested-With": userAgent
|
|
818
824
|
}
|
|
819
825
|
}));
|
|
820
|
-
debugOutput(response.url, response.status
|
|
821
|
-
if (response.status === null || response.status === 429) {
|
|
826
|
+
debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
|
|
827
|
+
if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
|
|
822
828
|
try {
|
|
823
|
-
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
829
|
+
data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
|
|
824
830
|
}
|
|
825
831
|
catch (error) {
|
|
826
832
|
success = true;
|
|
@@ -850,8 +856,8 @@ export class BalanceService {
|
|
|
850
856
|
return {
|
|
851
857
|
data: null,
|
|
852
858
|
error: true,
|
|
853
|
-
error_code: data ? data.error_code : response.status,
|
|
854
|
-
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
859
|
+
error_code: error.cause ? error.cause.code : data ? data.error_code : response ? response.status : "Unknown Error Code",
|
|
860
|
+
error_message: error.cause ? error.cause.message : data ? data.error_message : response && response.status === 500 ? "Internal server error" : !response ? "Unknown Error" : "401 Authorization Required"
|
|
855
861
|
};
|
|
856
862
|
}
|
|
857
863
|
}
|
|
@@ -887,6 +893,7 @@ export class BalanceService {
|
|
|
887
893
|
if (queryParamOpts?.blockHeight !== undefined) {
|
|
888
894
|
urlParams.append("block-height", queryParamOpts?.blockHeight.toString());
|
|
889
895
|
}
|
|
896
|
+
const url = `https://api.covalenthq.com/v1/${chainName}/address/${walletAddress}/balances_native/?${urlParams}`;
|
|
890
897
|
let startTime;
|
|
891
898
|
if (this.debug) {
|
|
892
899
|
startTime = typeof performance !== 'undefined' ? performance.now() : process.hrtime();
|
|
@@ -897,10 +904,10 @@ export class BalanceService {
|
|
|
897
904
|
"X-Requested-With": userAgent
|
|
898
905
|
}
|
|
899
906
|
}));
|
|
900
|
-
debugOutput(response.url, response.status
|
|
901
|
-
if (response.status === null || response.status === 429) {
|
|
907
|
+
debugOutput(response ? response.url : url, response ? response.status : 429, startTime);
|
|
908
|
+
if ((this.enableRetry === true) && (!response || response.status === null || response.status === 429)) {
|
|
902
909
|
try {
|
|
903
|
-
data = await this.LIMIT(() => backoff.backOff(response.url));
|
|
910
|
+
data = await this.LIMIT(() => backoff.backOff(response ? response.url : url));
|
|
904
911
|
}
|
|
905
912
|
catch (error) {
|
|
906
913
|
success = true;
|
|
@@ -930,8 +937,8 @@ export class BalanceService {
|
|
|
930
937
|
return {
|
|
931
938
|
data: null,
|
|
932
939
|
error: true,
|
|
933
|
-
error_code: data ? data.error_code : response.status,
|
|
934
|
-
error_message: data ? data.error_message : response.status === 500 ? "Internal server error" : "401 Authorization Required"
|
|
940
|
+
error_code: error.cause ? error.cause.code : data ? data.error_code : response ? response.status : "Unknown Error Code",
|
|
941
|
+
error_message: error.cause ? error.cause.message : data ? data.error_message : response && response.status === 500 ? "Internal server error" : !response ? "Unknown Error" : "401 Authorization Required"
|
|
935
942
|
};
|
|
936
943
|
}
|
|
937
944
|
}
|