@chainflip/utils 2.2.0-alpha.2 → 2.2.0-alpha.3

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/tron.cjs CHANGED
@@ -15,6 +15,11 @@ const isValidTronAddress = (address) => {
15
15
  return false;
16
16
  }
17
17
  };
18
+ const tronAddressToHex = (address) => {
19
+ const bytes = require_base58.decode(address);
20
+ (0, assert.default)(bytes.length === 25, "Invalid tron address length");
21
+ return (0, _noble_hashes_utils_js.bytesToHex)(bytes.slice(1, 21));
22
+ };
18
23
  const hexToTronAddress = (hex) => {
19
24
  const bytes = (0, _noble_hashes_utils_js.hexToBytes)(hex.startsWith("0x") ? hex.slice(2) : hex);
20
25
  (0, assert.default)(bytes.length === 20, "Invalid hex length");
@@ -30,4 +35,5 @@ const hexToTronAddress = (hex) => {
30
35
 
31
36
  //#endregion
32
37
  exports.hexToTronAddress = hexToTronAddress;
33
- exports.isValidTronAddress = isValidTronAddress;
38
+ exports.isValidTronAddress = isValidTronAddress;
39
+ exports.tronAddressToHex = tronAddressToHex;
package/dist/tron.d.cts CHANGED
@@ -1,5 +1,6 @@
1
1
  //#region src/tron.d.ts
2
2
  declare const isValidTronAddress: (address: string) => boolean;
3
+ declare const tronAddressToHex: (address: string) => string;
3
4
  declare const hexToTronAddress: (hex: string) => string;
4
5
  //#endregion
5
- export { hexToTronAddress, isValidTronAddress };
6
+ export { hexToTronAddress, isValidTronAddress, tronAddressToHex };
package/dist/tron.d.mts CHANGED
@@ -1,5 +1,6 @@
1
1
  //#region src/tron.d.ts
2
2
  declare const isValidTronAddress: (address: string) => boolean;
3
+ declare const tronAddressToHex: (address: string) => string;
3
4
  declare const hexToTronAddress: (hex: string) => string;
4
5
  //#endregion
5
- export { hexToTronAddress, isValidTronAddress };
6
+ export { hexToTronAddress, isValidTronAddress, tronAddressToHex };
package/dist/tron.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { decode, encode } from "./base58.mjs";
2
2
  import { sha256 } from "@noble/hashes/sha2.js";
3
- import { hexToBytes } from "@noble/hashes/utils.js";
3
+ import { bytesToHex, hexToBytes } from "@noble/hashes/utils.js";
4
4
  import assert from "assert";
5
5
 
6
6
  //#region src/tron.ts
@@ -12,6 +12,11 @@ const isValidTronAddress = (address) => {
12
12
  return false;
13
13
  }
14
14
  };
15
+ const tronAddressToHex = (address) => {
16
+ const bytes = decode(address);
17
+ assert(bytes.length === 25, "Invalid tron address length");
18
+ return bytesToHex(bytes.slice(1, 21));
19
+ };
15
20
  const hexToTronAddress = (hex) => {
16
21
  const bytes = hexToBytes(hex.startsWith("0x") ? hex.slice(2) : hex);
17
22
  assert(bytes.length === 20, "Invalid hex length");
@@ -26,4 +31,4 @@ const hexToTronAddress = (hex) => {
26
31
  };
27
32
 
28
33
  //#endregion
29
- export { hexToTronAddress, isValidTronAddress };
34
+ export { hexToTronAddress, isValidTronAddress, tronAddressToHex };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chainflip/utils",
3
- "version": "2.2.0-alpha.2",
3
+ "version": "2.2.0-alpha.3",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",