opnet 1.1.13 → 1.1.14

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.
@@ -1,4 +1,5 @@
1
1
  import { BigNumberish } from '../common/CommonTypes.js';
2
2
  export declare class BitcoinUtils {
3
3
  static formatUnits(value: BigNumberish, decimals?: number): string;
4
+ expandToDecimals(n: number | string, decimals: number | string): bigint;
4
5
  }
@@ -1 +1 @@
1
- export declare const version = "1.1.13";
1
+ export declare const version = "1.1.14";
package/build/_version.js CHANGED
@@ -1 +1 @@
1
- export const version = '1.1.13';
1
+ export const version = '1.1.14';
@@ -1,4 +1,5 @@
1
1
  import { BigNumberish } from '../common/CommonTypes.js';
2
2
  export declare class BitcoinUtils {
3
3
  static formatUnits(value: BigNumberish, decimals?: number): string;
4
+ expandToDecimals(n: number | string, decimals: number | string): bigint;
4
5
  }
@@ -4,4 +4,10 @@ export class BitcoinUtils {
4
4
  const bn = new BigNumber(value.toString());
5
5
  return bn.dividedBy(new BigNumber(10).pow(decimals)).toString();
6
6
  }
7
+ expandToDecimals(n, decimals) {
8
+ const amount = new BigNumber(n)
9
+ .multipliedBy(new BigNumber(10).pow(decimals))
10
+ .decimalPlaces(0);
11
+ return BigInt(amount.toString());
12
+ }
7
13
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "opnet",
3
3
  "type": "module",
4
- "version": "1.1.13",
4
+ "version": "1.1.14",
5
5
  "author": "OP_NET",
6
6
  "description": "The perfect library for building Bitcoin-based applications.",
7
7
  "engines": {
package/src/_version.ts CHANGED
@@ -1 +1 @@
1
- export const version = '1.1.13';
1
+ export const version = '1.1.14';
@@ -19,4 +19,18 @@ export class BitcoinUtils {
19
19
 
20
20
  return bn.dividedBy(new BigNumber(10).pow(decimals)).toString();
21
21
  }
22
+
23
+ /**
24
+ * Convert number or string to BigInt
25
+ * @param {number | string} n
26
+ * @param {number | string} decimals
27
+ * @returns {BigInt}
28
+ */
29
+ public expandToDecimals(n: number | string, decimals: number | string) {
30
+ const amount = new BigNumber(n)
31
+ .multipliedBy(new BigNumber(10).pow(decimals))
32
+ .decimalPlaces(0);
33
+
34
+ return BigInt(amount.toString());
35
+ }
22
36
  }