@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.
@@ -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.1";
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/index.d.ts CHANGED
@@ -7,3 +7,4 @@ export * from "./util/types/SecurityServiceTypes";
7
7
  export * from "./util/types/XykServiceTypes";
8
8
  export * from "./util/types/GenericTypes";
9
9
  export * from "./util/types/TransactionServiceTypes";
10
+ export { calculatePrettyBalance } from "./util/CalculatePrettyBalance";
package/dist/index.js CHANGED
@@ -7,4 +7,5 @@ export * from "./util/types/SecurityServiceTypes";
7
7
  export * from "./util/types/XykServiceTypes";
8
8
  export * from "./util/types/GenericTypes";
9
9
  export * from "./util/types/TransactionServiceTypes";
10
+ export { calculatePrettyBalance } from "./util/CalculatePrettyBalance";
10
11
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,EAAwD,MAAM,2BAA2B,CAAC;AACzH,cAAc,kCAAkC,CAAC;AACjD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,kCAAkC,CAAC;AACjD,cAAc,mCAAmC,CAAC;AAClD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sCAAsC,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,EAAwD,MAAM,2BAA2B,CAAC;AACzH,cAAc,kCAAkC,CAAC;AACjD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,kCAAkC,CAAC;AACjD,cAAc,mCAAmC,CAAC;AAClD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,sCAAsC,CAAC;AACrD,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC"}
@@ -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.1";
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;
@@ -5,7 +5,7 @@ import { NftService } from "./NftService";
5
5
  import { PricingService } from "./PricingService";
6
6
  import { TransactionService } from "./TransactionService";
7
7
  import { XykService } from "./XykService";
8
- export const userAgent = "com.covalenthq.sdk.typescript/0.6.1";
8
+ export const userAgent = "com.covalenthq.sdk.typescript/0.6.2";
9
9
  export class Response {
10
10
  }
11
11
  /**
@@ -0,0 +1 @@
1
+ export declare const calculatePrettyBalance: (value: number | bigint, decimals?: number, roundOff?: boolean, precision?: number) => string;
@@ -0,0 +1,22 @@
1
+ import Big from "big.js";
2
+ export const calculatePrettyBalance = (value, decimals = 18, roundOff = true, precision = 0) => {
3
+ const bigIntValue = BigInt(value);
4
+ const bigDecimalValue = new Big(bigIntValue.toString());
5
+ const _decimals = decimals || 18;
6
+ const _expoValue = BigInt(Math.pow(10, _decimals));
7
+ const bigDecimalExpo = new Big(_expoValue.toString());
8
+ const _calculated = bigDecimalValue.div(bigDecimalExpo);
9
+ // removes the decimal places, true by default so it adds decimals
10
+ if (!roundOff) {
11
+ return _calculated.toString();
12
+ }
13
+ let _decimalFixed = precision;
14
+ if (precision === 0) {
15
+ _decimalFixed = 2;
16
+ if (_calculated.lt(100)) {
17
+ _decimalFixed = 6;
18
+ }
19
+ }
20
+ return _calculated.toFixed(_decimalFixed);
21
+ };
22
+ //# sourceMappingURL=CalculatePrettyBalance.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CalculatePrettyBalance.js","sourceRoot":"","sources":["../../src/util/CalculatePrettyBalance.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,QAAQ,CAAC;AAEzB,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAClC,KAAsB,EACtB,WAAmB,EAAE,EACrB,WAAoB,IAAI,EACxB,YAAoB,CAAC,EACf,EAAE;IACR,MAAM,WAAW,GAAW,MAAM,CAAC,KAAK,CAAC,CAAC;IAC1C,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC,CAAC;IAExD,MAAM,SAAS,GAAW,QAAQ,IAAI,EAAE,CAAC;IACzC,MAAM,UAAU,GAAW,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,SAAS,CAAC,CAAC,CAAC;IAC3D,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC,CAAC;IACtD,MAAM,WAAW,GAAG,eAAe,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IAExD,kEAAkE;IAClE,IAAI,CAAC,QAAQ,EAAE;QACX,OAAO,WAAW,CAAC,QAAQ,EAAE,CAAC;KACjC;IACD,IAAI,aAAa,GAAG,SAAS,CAAC;IAC9B,IAAI,SAAS,KAAK,CAAC,EAAE;QACjB,aAAa,GAAG,CAAC,CAAC;QAClB,IAAI,WAAW,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE;YACrB,aAAa,GAAG,CAAC,CAAC;SACrB;KACJ;IACD,OAAO,WAAW,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;AAC9C,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@covalenthq/client-sdk",
3
- "version": "0.6.1",
3
+ "version": "0.6.2",
4
4
  "types": "dist/index.d.ts",
5
5
  "files": [
6
6
  "/dist"
@@ -11,6 +11,7 @@
11
11
  "dependencies": {
12
12
  "@rollup/plugin-commonjs": "^25.0.4",
13
13
  "@rollup/plugin-node-resolve": "^15.2.1",
14
+ "big.js": "^6.2.1",
14
15
  "chalk": "^4.1.2",
15
16
  "date-fns": "^2.30.0",
16
17
  "rollup": "^3.29.1",
@@ -19,6 +20,7 @@
19
20
  },
20
21
  "homepage": "https://github.com/covalenthq/covalent-api-sdk-ts#readme",
21
22
  "devDependencies": {
23
+ "@types/big.js": "^6.2.2",
22
24
  "@types/chalk": "^2.2.0",
23
25
  "@types/jest": "^29.5.5",
24
26
  "jest": "^29.6.1",