@covalenthq/client-sdk 0.6.0 → 0.6.2
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 +10 -0
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.js +39 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/services/BalanceService.d.ts +20 -0
- package/dist/cjs/services/CovalentClient.d.ts +1 -1
- package/dist/cjs/util/CalculatePrettyBalance.d.ts +1 -0
- package/dist/cjs/util/types/BalanceServiceTypes.d.ts +18 -0
- package/dist/es/index.d.ts +1 -0
- package/dist/es/index.js +39 -2
- package/dist/es/index.js.map +1 -1
- package/dist/es/services/BalanceService.d.ts +20 -0
- package/dist/es/services/CovalentClient.d.ts +1 -1
- package/dist/es/util/CalculatePrettyBalance.d.ts +1 -0
- package/dist/es/util/types/BalanceServiceTypes.d.ts +18 -0
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +39 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/services/BalanceService.d.ts +20 -0
- package/dist/esm/services/CovalentClient.d.ts +1 -1
- package/dist/esm/util/CalculatePrettyBalance.d.ts +1 -0
- package/dist/esm/util/types/BalanceServiceTypes.d.ts +18 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/services/BalanceService.d.ts +20 -0
- package/dist/services/BalanceService.js +15 -0
- package/dist/services/BalanceService.js.map +1 -1
- package/dist/services/CovalentClient.d.ts +1 -1
- package/dist/services/CovalentClient.js +1 -1
- package/dist/util/CalculatePrettyBalance.d.ts +1 -0
- package/dist/util/CalculatePrettyBalance.js +22 -0
- package/dist/util/CalculatePrettyBalance.js.map +1 -0
- package/dist/util/types/BalanceServiceTypes.d.ts +18 -0
- package/package.json +3 -1
|
@@ -23,10 +23,14 @@ declare class BalanceItem {
|
|
|
23
23
|
contract_ticker_symbol: string;
|
|
24
24
|
/** * Use the relevant `contract_address` to lookup prices, logos, token transfers, etc. */
|
|
25
25
|
contract_address: string;
|
|
26
|
+
/** * A display-friendly name for the contract. */
|
|
27
|
+
contract_display_name: string;
|
|
26
28
|
/** * A list of supported standard ERC interfaces, eg: `ERC20` and `ERC721`. */
|
|
27
29
|
supports_erc: string;
|
|
28
30
|
/** * The contract logo URL. */
|
|
29
31
|
logo_url: string;
|
|
32
|
+
/** * The balance item logo URLs. */
|
|
33
|
+
logo_urls: LogoUrls;
|
|
30
34
|
/** * The timestamp when the token was transferred. */
|
|
31
35
|
last_transferred_at: Date;
|
|
32
36
|
/** * Indicates if a token is the chain's native gas token, eg: ETH on Ethereum. */
|
|
@@ -51,10 +55,26 @@ declare class BalanceItem {
|
|
|
51
55
|
pretty_quote: string;
|
|
52
56
|
/** * A prettier version of the 24h quote for rendering purposes. */
|
|
53
57
|
pretty_quote_24h: string;
|
|
58
|
+
/** * The protocol metadata. */
|
|
59
|
+
protocol_metadata: ProtocolMetadata;
|
|
54
60
|
/** * NFT-specific data. */
|
|
55
61
|
nft_data: NftData[];
|
|
56
62
|
constructor(data: BalanceItem);
|
|
57
63
|
}
|
|
64
|
+
declare class LogoUrls {
|
|
65
|
+
/** * The token logo URL. */
|
|
66
|
+
token_logo_url: string;
|
|
67
|
+
/** * The protocol logo URL. */
|
|
68
|
+
protocol_logo_url: string;
|
|
69
|
+
/** * The chain logo URL. */
|
|
70
|
+
chain_logo_url: string;
|
|
71
|
+
constructor(data: LogoUrls);
|
|
72
|
+
}
|
|
73
|
+
declare class ProtocolMetadata {
|
|
74
|
+
/** * The name of the protocol. */
|
|
75
|
+
protocol_name: string;
|
|
76
|
+
constructor(data: ProtocolMetadata);
|
|
77
|
+
}
|
|
58
78
|
declare class NftData {
|
|
59
79
|
/** * The token's id. */
|
|
60
80
|
token_id: bigint | null;
|
|
@@ -21,7 +21,7 @@ export type Chains = "btc-mainnet" | "eth-mainnet" | "matic-mainnet" | "bsc-main
|
|
|
21
21
|
* CovalentClient Class
|
|
22
22
|
*/
|
|
23
23
|
export type Quotes = "USD" | "CAD" | "EUR" | "SGD" | "INR" | "JPY" | "VND" | "CNY" | "KRW" | "RUB" | "TRY" | "NGN" | "ARS" | "AUD" | "CHF" | "GBP";
|
|
24
|
-
export declare const userAgent = "com.covalenthq.sdk.typescript/0.6.
|
|
24
|
+
export declare const userAgent = "com.covalenthq.sdk.typescript/0.6.2";
|
|
25
25
|
export declare class Response<T> {
|
|
26
26
|
data: T;
|
|
27
27
|
error: boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const calculatePrettyBalance: (value: number | bigint, decimals?: number, roundOff?: boolean, precision?: number) => string;
|
|
@@ -22,10 +22,14 @@ export interface BalanceItem {
|
|
|
22
22
|
contract_ticker_symbol: string;
|
|
23
23
|
/** * Use the relevant `contract_address` to lookup prices, logos, token transfers, etc. */
|
|
24
24
|
contract_address: string;
|
|
25
|
+
/** * A display-friendly name for the contract. */
|
|
26
|
+
contract_display_name: string;
|
|
25
27
|
/** * A list of supported standard ERC interfaces, eg: `ERC20` and `ERC721`. */
|
|
26
28
|
supports_erc: string;
|
|
27
29
|
/** * The contract logo URL. */
|
|
28
30
|
logo_url: string;
|
|
31
|
+
/** * The balance item logo URLs. */
|
|
32
|
+
logo_urls: LogoUrls;
|
|
29
33
|
/** * The timestamp when the token was transferred. */
|
|
30
34
|
last_transferred_at: Date;
|
|
31
35
|
/** * Indicates if a token is the chain's native gas token, eg: ETH on Ethereum. */
|
|
@@ -50,9 +54,23 @@ export interface BalanceItem {
|
|
|
50
54
|
pretty_quote: string;
|
|
51
55
|
/** * A prettier version of the 24h quote for rendering purposes. */
|
|
52
56
|
pretty_quote_24h: string;
|
|
57
|
+
/** * The protocol metadata. */
|
|
58
|
+
protocol_metadata: ProtocolMetadata;
|
|
53
59
|
/** * NFT-specific data. */
|
|
54
60
|
nft_data: NftData[];
|
|
55
61
|
}
|
|
62
|
+
export interface LogoUrls {
|
|
63
|
+
/** * The token logo URL. */
|
|
64
|
+
token_logo_url: string;
|
|
65
|
+
/** * The protocol logo URL. */
|
|
66
|
+
protocol_logo_url: string;
|
|
67
|
+
/** * The chain logo URL. */
|
|
68
|
+
chain_logo_url: string;
|
|
69
|
+
}
|
|
70
|
+
export interface ProtocolMetadata {
|
|
71
|
+
/** * The name of the protocol. */
|
|
72
|
+
protocol_name: string;
|
|
73
|
+
}
|
|
56
74
|
export interface PortfolioResponse {
|
|
57
75
|
/** * The requested address. */
|
|
58
76
|
address: string;
|
package/dist/esm/index.d.ts
CHANGED
package/dist/esm/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import chalk from 'chalk';
|
|
2
2
|
import { parseISO } from 'date-fns';
|
|
3
|
+
import Big from 'big.js';
|
|
3
4
|
|
|
4
5
|
const DEFAULT_BACKOFF_MAX_RETRIES = 5;
|
|
5
6
|
const BASE_DELAY_MS = 1000; // Base delay in milliseconds
|
|
@@ -522,6 +523,7 @@ class BalanceItem {
|
|
|
522
523
|
this.contract_name = data.contract_name;
|
|
523
524
|
this.contract_ticker_symbol = data.contract_ticker_symbol;
|
|
524
525
|
this.contract_address = data.contract_address;
|
|
526
|
+
this.contract_display_name = data.contract_display_name;
|
|
525
527
|
this.supports_erc = data.supports_erc;
|
|
526
528
|
this.logo_url = data.logo_url;
|
|
527
529
|
this.last_transferred_at = data.last_transferred_at && data.last_transferred_at !== null ? parseISO(data.last_transferred_at.toString()) : null;
|
|
@@ -536,9 +538,23 @@ class BalanceItem {
|
|
|
536
538
|
this.quote_24h = data.quote_24h;
|
|
537
539
|
this.pretty_quote = data.pretty_quote;
|
|
538
540
|
this.pretty_quote_24h = data.pretty_quote_24h;
|
|
541
|
+
this.logo_urls = data.logo_urls && data.logo_urls !== null ? new LogoUrls(data.logo_urls) : null;
|
|
542
|
+
this.protocol_metadata = data.protocol_metadata && data.protocol_metadata !== null ? new ProtocolMetadata(data.protocol_metadata) : null;
|
|
539
543
|
this.nft_data = data.nft_data && data.nft_data !== null ? data.nft_data.map((itemData) => new NftData$1(itemData)) : null;
|
|
540
544
|
}
|
|
541
545
|
}
|
|
546
|
+
class LogoUrls {
|
|
547
|
+
constructor(data) {
|
|
548
|
+
this.token_logo_url = data.token_logo_url;
|
|
549
|
+
this.protocol_logo_url = data.protocol_logo_url;
|
|
550
|
+
this.chain_logo_url = data.chain_logo_url;
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
class ProtocolMetadata {
|
|
554
|
+
constructor(data) {
|
|
555
|
+
this.protocol_name = data.protocol_name;
|
|
556
|
+
}
|
|
557
|
+
}
|
|
542
558
|
let NftData$1 = class NftData {
|
|
543
559
|
constructor(data) {
|
|
544
560
|
this.token_id = data.token_id && data.token_id !== null ? BigInt(data.token_id) : null;
|
|
@@ -5850,7 +5866,7 @@ class XykService {
|
|
|
5850
5866
|
}
|
|
5851
5867
|
}
|
|
5852
5868
|
|
|
5853
|
-
const userAgent = "com.covalenthq.sdk.typescript/0.6.
|
|
5869
|
+
const userAgent = "com.covalenthq.sdk.typescript/0.6.2";
|
|
5854
5870
|
/**
|
|
5855
5871
|
* CovalentClient Class
|
|
5856
5872
|
*/
|
|
@@ -5885,5 +5901,26 @@ class Client {
|
|
|
5885
5901
|
}
|
|
5886
5902
|
}
|
|
5887
5903
|
|
|
5888
|
-
|
|
5904
|
+
const calculatePrettyBalance = (value, decimals = 18, roundOff = true, precision = 0) => {
|
|
5905
|
+
const bigIntValue = BigInt(value);
|
|
5906
|
+
const bigDecimalValue = new Big(bigIntValue.toString());
|
|
5907
|
+
const _decimals = decimals || 18;
|
|
5908
|
+
const _expoValue = BigInt(Math.pow(10, _decimals));
|
|
5909
|
+
const bigDecimalExpo = new Big(_expoValue.toString());
|
|
5910
|
+
const _calculated = bigDecimalValue.div(bigDecimalExpo);
|
|
5911
|
+
// removes the decimal places, true by default so it adds decimals
|
|
5912
|
+
if (!roundOff) {
|
|
5913
|
+
return _calculated.toString();
|
|
5914
|
+
}
|
|
5915
|
+
let _decimalFixed = precision;
|
|
5916
|
+
if (precision === 0) {
|
|
5917
|
+
_decimalFixed = 2;
|
|
5918
|
+
if (_calculated.lt(100)) {
|
|
5919
|
+
_decimalFixed = 6;
|
|
5920
|
+
}
|
|
5921
|
+
}
|
|
5922
|
+
return _calculated.toFixed(_decimalFixed);
|
|
5923
|
+
};
|
|
5924
|
+
|
|
5925
|
+
export { Client, CovalentClient, calculatePrettyBalance };
|
|
5889
5926
|
//# sourceMappingURL=index.js.map
|