@covalenthq/client-sdk 0.6.1 → 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 +24 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/services/CovalentClient.d.ts +1 -1
- package/dist/cjs/util/CalculatePrettyBalance.d.ts +1 -0
- package/dist/es/index.d.ts +1 -0
- package/dist/es/index.js +24 -2
- package/dist/es/index.js.map +1 -1
- package/dist/es/services/CovalentClient.d.ts +1 -1
- package/dist/es/util/CalculatePrettyBalance.d.ts +1 -0
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +24 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/services/CovalentClient.d.ts +1 -1
- package/dist/esm/util/CalculatePrettyBalance.d.ts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.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/package.json +3 -1
|
@@ -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;
|
package/dist/es/index.d.ts
CHANGED
package/dist/es/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
|
|
@@ -5865,7 +5866,7 @@ class XykService {
|
|
|
5865
5866
|
}
|
|
5866
5867
|
}
|
|
5867
5868
|
|
|
5868
|
-
const userAgent = "com.covalenthq.sdk.typescript/0.6.
|
|
5869
|
+
const userAgent = "com.covalenthq.sdk.typescript/0.6.2";
|
|
5869
5870
|
/**
|
|
5870
5871
|
* CovalentClient Class
|
|
5871
5872
|
*/
|
|
@@ -5900,5 +5901,26 @@ class Client {
|
|
|
5900
5901
|
}
|
|
5901
5902
|
}
|
|
5902
5903
|
|
|
5903
|
-
|
|
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 };
|
|
5904
5926
|
//# sourceMappingURL=index.js.map
|