@chainflip/utils 0.4.16 → 0.5.0

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/base58.cjs CHANGED
@@ -44,7 +44,17 @@ function assert(condition, message = "assertion failed", Constructor = Error) {
44
44
  }
45
45
 
46
46
  // src/bytes.ts
47
- var convertBase = (bytes, fromBase, toBase) => {
47
+ var hexToBytes = (input) => {
48
+ assert(/^0x[\da-f]*$/i.test(input) && input.length % 2 === 0, "Invalid hex string");
49
+ const hex = input.slice(2);
50
+ const bytes = new Uint8Array(hex.length / 2);
51
+ for (let i = 0; i < hex.length; i += 2) {
52
+ bytes[i / 2] = Number.parseInt(hex.slice(i, i + 2), 16);
53
+ }
54
+ return bytes;
55
+ };
56
+ var convertBase = (inputBytes, fromBase, toBase) => {
57
+ const bytes = typeof inputBytes === "string" ? hexToBytes(inputBytes) : new Uint8Array(inputBytes);
48
58
  const result = [];
49
59
  for (const byte of bytes) {
50
60
  let carry = byte;
package/dist/base58.d.cts CHANGED
@@ -1,5 +1,7 @@
1
+ import { Bytelike } from './types.cjs';
2
+
1
3
  declare const CHARSET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
2
- declare const encode: (bytes: Uint8Array | number[]) => string;
4
+ declare const encode: (bytes: Bytelike) => string;
3
5
  declare const decode: (input: string) => Uint8Array;
4
6
 
5
7
  export { CHARSET, decode, encode };
package/dist/base58.d.ts CHANGED
@@ -1,5 +1,7 @@
1
+ import { Bytelike } from './types.js';
2
+
1
3
  declare const CHARSET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
2
- declare const encode: (bytes: Uint8Array | number[]) => string;
4
+ declare const encode: (bytes: Bytelike) => string;
3
5
  declare const decode: (input: string) => Uint8Array;
4
6
 
5
7
  export { CHARSET, decode, encode };
package/dist/base58.js CHANGED
@@ -2,8 +2,8 @@ import {
2
2
  CHARSET,
3
3
  decode,
4
4
  encode
5
- } from "./chunk-F4PFSMIC.js";
6
- import "./chunk-2KA626OL.js";
5
+ } from "./chunk-HOUVS5DD.js";
6
+ import "./chunk-W23CNAUU.js";
7
7
  import "./chunk-ZHIKNZLU.js";
8
8
  import "./chunk-HBIFE4XN.js";
9
9
  export {
package/dist/bytes.cjs CHANGED
@@ -59,7 +59,8 @@ var hexToBytes = (input) => {
59
59
  }
60
60
  return bytes;
61
61
  };
62
- var convertBase = (bytes, fromBase, toBase) => {
62
+ var convertBase = (inputBytes, fromBase, toBase) => {
63
+ const bytes = typeof inputBytes === "string" ? hexToBytes(inputBytes) : new Uint8Array(inputBytes);
63
64
  const result = [];
64
65
  for (const byte of bytes) {
65
66
  let carry = byte;
package/dist/bytes.d.cts CHANGED
@@ -1,8 +1,8 @@
1
- import { HexString } from './types.cjs';
1
+ import { HexString, Bytelike } from './types.cjs';
2
2
 
3
3
  declare const bytesToHex: (input: Uint8Array | number[]) => `0x${string}`;
4
4
  declare const hexToBytes: (input: HexString) => Uint8Array;
5
- declare const encodeBytesWithCharset: (bytes: Uint8Array | number[], charset: string) => string;
5
+ declare const encodeBytesWithCharset: (bytes: Bytelike, charset: string) => string;
6
6
  declare const decodeBytesWithCharset: (input: string, charset: string) => Uint8Array;
7
7
  declare function reverseBytes(input: HexString): HexString;
8
8
  declare function reverseBytes(input: string): string;
package/dist/bytes.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { HexString } from './types.js';
1
+ import { HexString, Bytelike } from './types.js';
2
2
 
3
3
  declare const bytesToHex: (input: Uint8Array | number[]) => `0x${string}`;
4
4
  declare const hexToBytes: (input: HexString) => Uint8Array;
5
- declare const encodeBytesWithCharset: (bytes: Uint8Array | number[], charset: string) => string;
5
+ declare const encodeBytesWithCharset: (bytes: Bytelike, charset: string) => string;
6
6
  declare const decodeBytesWithCharset: (input: string, charset: string) => Uint8Array;
7
7
  declare function reverseBytes(input: HexString): HexString;
8
8
  declare function reverseBytes(input: string): string;
package/dist/bytes.js CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  encodeBytesWithCharset,
5
5
  hexToBytes,
6
6
  reverseBytes
7
- } from "./chunk-2KA626OL.js";
7
+ } from "./chunk-W23CNAUU.js";
8
8
  import "./chunk-ZHIKNZLU.js";
9
9
  import "./chunk-HBIFE4XN.js";
10
10
  export {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  decodeBytesWithCharset,
3
3
  encodeBytesWithCharset
4
- } from "./chunk-2KA626OL.js";
4
+ } from "./chunk-W23CNAUU.js";
5
5
 
6
6
  // src/base58.ts
7
7
  var CHARSET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
@@ -16,7 +16,8 @@ var hexToBytes = (input) => {
16
16
  }
17
17
  return bytes;
18
18
  };
19
- var convertBase = (bytes, fromBase, toBase) => {
19
+ var convertBase = (inputBytes, fromBase, toBase) => {
20
+ const bytes = typeof inputBytes === "string" ? hexToBytes(inputBytes) : new Uint8Array(inputBytes);
20
21
  const result = [];
21
22
  for (const byte of bytes) {
22
23
  let carry = byte;
package/dist/consts.cjs CHANGED
@@ -41,14 +41,14 @@ var chainflipLinks = {
41
41
  website: "https://chainflip.io/",
42
42
  discord: "https://discord.gg/chainflip-community",
43
43
  twitter: "https://twitter.com/chainflip",
44
- telegram: "https://t.me/chainflip",
44
+ telegram: "https://t.me/chainflip_io_chat",
45
45
  blog: "https://blog.chainflip.io/",
46
46
  docs: "https://docs.chainflip.io/"
47
47
  };
48
48
  var chainflipCommunityLinks = {
49
49
  discord: "https://discord.gg/chainflip-community",
50
50
  twitter: "https://twitter.com/chainflip",
51
- telegram: "https://t.me/chainflip"
51
+ telegram: "https://t.me/chainflip_io_chat"
52
52
  };
53
53
  var brokerAliasMap = {
54
54
  cFLRQDfEdmnv6d2XfHJNRBQHi4fruPMReLSfvB8WWD2ENbqj7: {
@@ -128,6 +128,10 @@ var brokerAliasMap = {
128
128
  cFL4To8Uow6B1hk4dNrhWhvKpkBtnUTrVdWCEKCaXiXMMztjM: {
129
129
  name: "SwapKit",
130
130
  twitter: "@SwapKitPowered"
131
+ },
132
+ cFKe4xhoVd783CUTYNxMua4eVE3pSDnbvjLXVRpeq2qC9bSZi: {
133
+ name: "Cake Wallet",
134
+ twitter: "@cakewallet"
131
135
  }
132
136
  };
133
137
  var lpAliasMap = {
package/dist/consts.js CHANGED
@@ -8,14 +8,14 @@ var chainflipLinks = {
8
8
  website: "https://chainflip.io/",
9
9
  discord: "https://discord.gg/chainflip-community",
10
10
  twitter: "https://twitter.com/chainflip",
11
- telegram: "https://t.me/chainflip",
11
+ telegram: "https://t.me/chainflip_io_chat",
12
12
  blog: "https://blog.chainflip.io/",
13
13
  docs: "https://docs.chainflip.io/"
14
14
  };
15
15
  var chainflipCommunityLinks = {
16
16
  discord: "https://discord.gg/chainflip-community",
17
17
  twitter: "https://twitter.com/chainflip",
18
- telegram: "https://t.me/chainflip"
18
+ telegram: "https://t.me/chainflip_io_chat"
19
19
  };
20
20
  var brokerAliasMap = {
21
21
  cFLRQDfEdmnv6d2XfHJNRBQHi4fruPMReLSfvB8WWD2ENbqj7: {
@@ -95,6 +95,10 @@ var brokerAliasMap = {
95
95
  cFL4To8Uow6B1hk4dNrhWhvKpkBtnUTrVdWCEKCaXiXMMztjM: {
96
96
  name: "SwapKit",
97
97
  twitter: "@SwapKitPowered"
98
+ },
99
+ cFKe4xhoVd783CUTYNxMua4eVE3pSDnbvjLXVRpeq2qC9bSZi: {
100
+ name: "Cake Wallet",
101
+ twitter: "@cakewallet"
98
102
  }
99
103
  };
100
104
  var lpAliasMap = {
package/dist/ss58.cjs CHANGED
@@ -725,7 +725,8 @@ var hexToBytes = (input) => {
725
725
  }
726
726
  return bytes;
727
727
  };
728
- var convertBase = (bytes, fromBase, toBase) => {
728
+ var convertBase = (inputBytes, fromBase, toBase) => {
729
+ const bytes = typeof inputBytes === "string" ? hexToBytes(inputBytes) : new Uint8Array(inputBytes);
729
730
  const result = [];
730
731
  for (const byte of bytes) {
731
732
  let carry = byte;
package/dist/ss58.d.cts CHANGED
@@ -1,11 +1,11 @@
1
- import { HexString } from './types.cjs';
1
+ import { Bytelike, HexString } from './types.cjs';
2
2
 
3
3
  declare const decode: (input: string) => {
4
4
  data: Uint8Array;
5
5
  ss58Format: number;
6
6
  };
7
7
  declare const encode: ({ data: input, ss58Format, }: {
8
- data: Uint8Array | HexString;
8
+ data: Bytelike;
9
9
  ss58Format: number;
10
10
  }) => string;
11
11
  declare const toPublicKey: (address: string) => HexString;
package/dist/ss58.d.ts CHANGED
@@ -1,11 +1,11 @@
1
- import { HexString } from './types.js';
1
+ import { Bytelike, HexString } from './types.js';
2
2
 
3
3
  declare const decode: (input: string) => {
4
4
  data: Uint8Array;
5
5
  ss58Format: number;
6
6
  };
7
7
  declare const encode: ({ data: input, ss58Format, }: {
8
- data: Uint8Array | HexString;
8
+ data: Bytelike;
9
9
  ss58Format: number;
10
10
  }) => string;
11
11
  declare const toPublicKey: (address: string) => HexString;
package/dist/ss58.js CHANGED
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  decode,
3
3
  encode
4
- } from "./chunk-F4PFSMIC.js";
4
+ } from "./chunk-HOUVS5DD.js";
5
5
  import {
6
6
  bytesToHex,
7
7
  hexToBytes
8
- } from "./chunk-2KA626OL.js";
8
+ } from "./chunk-W23CNAUU.js";
9
9
  import {
10
10
  assert
11
11
  } from "./chunk-ZHIKNZLU.js";
package/dist/types.d.cts CHANGED
@@ -1,3 +1,4 @@
1
1
  type HexString = `0x${string}`;
2
+ type Bytelike = Uint8Array | number[] | HexString;
2
3
 
3
- export type { HexString };
4
+ export type { Bytelike, HexString };
package/dist/types.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  type HexString = `0x${string}`;
2
+ type Bytelike = Uint8Array | number[] | HexString;
2
3
 
3
- export type { HexString };
4
+ export type { Bytelike, HexString };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chainflip/utils",
3
- "version": "0.4.16",
3
+ "version": "0.5.0",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",