@arkecosystem/typescript-crypto 0.0.19 → 0.0.20

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/dist/index.js CHANGED
@@ -28332,11 +28332,11 @@ var UnitConverter = class {
28332
28332
  static formatUnits(value, unit = "ark") {
28333
28333
  switch (unit.toLowerCase()) {
28334
28334
  case "wei":
28335
- return bignumber_default(value).dividedBy(WEI_MULTIPLIER).toNumber();
28335
+ return bignumber_default(value).dividedBy(WEI_MULTIPLIER);
28336
28336
  case "gwei":
28337
- return bignumber_default(value).dividedBy(GWEI_MULTIPLIER).toNumber();
28337
+ return bignumber_default(value).dividedBy(GWEI_MULTIPLIER);
28338
28338
  case "ark":
28339
- return bignumber_default(value).dividedBy(ARK_MULTIPLIER).toNumber();
28339
+ return bignumber_default(value).dividedBy(ARK_MULTIPLIER);
28340
28340
  default:
28341
28341
  throw new Error(`Unsupported unit: ${unit}. Supported units are 'wei', 'gwei', and 'ark'.`);
28342
28342
  }
@@ -1,7 +1,7 @@
1
1
  import BigNumber from "bignumber.js";
2
2
  export declare class UnitConverter {
3
3
  static parseUnits(value: number | string, unit?: string): BigNumber;
4
- static formatUnits(value: string, unit?: string): number;
4
+ static formatUnits(value: string, unit?: string): BigNumber;
5
5
  static weiToArk(value: number | string, suffix?: string): string;
6
6
  static gweiToArk(value: number | string, suffix?: string): string;
7
7
  }
@@ -1 +1 @@
1
- {"version":3,"file":"UnitConverter.d.ts","sourceRoot":"","sources":["../../src/utils/UnitConverter.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,cAAc,CAAC;AAMrC,qBAAa,aAAa;IACzB,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,IAAI,SAAQ,GAAG,SAAS;IAalE,MAAM,CAAC,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,SAAQ,GAAG,MAAM;IAavD,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM;IAYhE,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM;CAWjE"}
1
+ {"version":3,"file":"UnitConverter.d.ts","sourceRoot":"","sources":["../../src/utils/UnitConverter.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,cAAc,CAAC;AAMrC,qBAAa,aAAa;IACzB,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,IAAI,SAAQ,GAAG,SAAS;IAalE,MAAM,CAAC,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,SAAQ,GAAG,SAAS;IAa1D,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM;IAYhE,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM;CAWjE"}
@@ -18,11 +18,11 @@ export class UnitConverter {
18
18
  static formatUnits(value, unit = "ark") {
19
19
  switch (unit.toLowerCase()) {
20
20
  case "wei":
21
- return BigNumber(value).dividedBy(WEI_MULTIPLIER).toNumber();
21
+ return BigNumber(value).dividedBy(WEI_MULTIPLIER);
22
22
  case "gwei":
23
- return BigNumber(value).dividedBy(GWEI_MULTIPLIER).toNumber();
23
+ return BigNumber(value).dividedBy(GWEI_MULTIPLIER);
24
24
  case "ark":
25
- return BigNumber(value).dividedBy(ARK_MULTIPLIER).toNumber();
25
+ return BigNumber(value).dividedBy(ARK_MULTIPLIER);
26
26
  default:
27
27
  throw new Error(`Unsupported unit: ${unit}. Supported units are 'wei', 'gwei', and 'ark'.`);
28
28
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arkecosystem/typescript-crypto",
3
- "version": "0.0.19",
3
+ "version": "0.0.20",
4
4
  "engines": {
5
5
  "node": ">=20.12.2"
6
6
  },
@@ -18,14 +18,14 @@ export class UnitConverter {
18
18
  }
19
19
  }
20
20
 
21
- static formatUnits(value: string, unit = "ark"): number {
21
+ static formatUnits(value: string, unit = "ark"): BigNumber {
22
22
  switch (unit.toLowerCase()) {
23
23
  case "wei":
24
- return BigNumber(value).dividedBy(WEI_MULTIPLIER).toNumber();
24
+ return BigNumber(value).dividedBy(WEI_MULTIPLIER);
25
25
  case "gwei":
26
- return BigNumber(value).dividedBy(GWEI_MULTIPLIER).toNumber();
26
+ return BigNumber(value).dividedBy(GWEI_MULTIPLIER);
27
27
  case "ark":
28
- return BigNumber(value).dividedBy(ARK_MULTIPLIER).toNumber();
28
+ return BigNumber(value).dividedBy(ARK_MULTIPLIER);
29
29
  default:
30
30
  throw new Error(`Unsupported unit: ${unit}. Supported units are 'wei', 'gwei', and 'ark'.`);
31
31
  }
@@ -41,39 +41,39 @@ it.each([
41
41
  });
42
42
 
43
43
  it.each([
44
- ["1", 1],
45
- ["10", 10],
46
- ["100", 100],
47
- ["1000", 1000],
48
- ["10000", 10000],
44
+ ["1", "1"],
45
+ ["10", "10"],
46
+ ["100", "100"],
47
+ ["1000", "1000"],
48
+ ["10000", "10000"],
49
49
  ])("should format units from wei [%s]", (formattedAmount, amount) => {
50
50
  const formattedValue = UnitConverter.formatUnits(formattedAmount, "wei");
51
51
 
52
- expect(formattedValue).toEqual(amount);
52
+ expect(formattedValue.toString()).toEqual(amount);
53
53
  });
54
54
 
55
55
  it.each([
56
- ["1000000000", 1],
57
- ["10000000000", 10],
58
- ["100000000000", 100],
59
- ["1000000000000", 1000],
60
- ["10000000000000", 10000],
56
+ ["1000000000", "1"],
57
+ ["10000000000", "10"],
58
+ ["100000000000", "100"],
59
+ ["1000000000000", "1000"],
60
+ ["10000000000000", "10000"],
61
61
  ])("should format units from gwei [%s]", (formattedAmount, amount) => {
62
62
  const formattedValue = UnitConverter.formatUnits(formattedAmount, "gwei");
63
63
 
64
- expect(formattedValue).toEqual(amount);
64
+ expect(formattedValue.toString()).toEqual(amount);
65
65
  });
66
66
 
67
67
  it.each([
68
- ["1000000000000000000", 1],
69
- ["10000000000000000000", 10],
70
- ["100000000000000000000", 100],
71
- ["1000000000000000000000", 1000],
72
- ["10000000000000000000000", 10000],
68
+ ["1000000000000000000", "1"],
69
+ ["10000000000000000000", "10"],
70
+ ["100000000000000000000", "100"],
71
+ ["1000000000000000000000", "1000"],
72
+ ["10000000000000000000000", "10000"],
73
73
  ])("should format units from ark [%s]", (formattedAmount, amount) => {
74
74
  const formattedValue = UnitConverter.formatUnits(formattedAmount);
75
75
 
76
- expect(formattedValue).toEqual(amount);
76
+ expect(formattedValue.toString()).toEqual(amount);
77
77
  });
78
78
 
79
79
  it("should throw exception for unsupported unit in parse", () => {