@talismn/util 0.1.1 → 0.1.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @talismn/util
2
2
 
3
+ ## 0.1.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 2ccd51b: feat: implemented @talismn/balances-substrate-native
8
+
3
9
  ## 0.1.1
4
10
 
5
11
  ### Patch Changes
@@ -0,0 +1 @@
1
+ export declare function blake2Concat(input: Uint8Array): `0x${string}`;
@@ -0,0 +1,6 @@
1
+ import { u8aConcat, u8aToHex, u8aToU8a } from "@polkadot/util";
2
+ import { blake2AsU8a } from "@polkadot/util-crypto";
3
+ const bitLength = 128;
4
+ export function blake2Concat(input) {
5
+ return u8aToHex(u8aConcat(blake2AsU8a(input, bitLength), u8aToU8a(input)));
6
+ }
@@ -0,0 +1 @@
1
+ export declare function decodeAnyAddress(encoded?: string | Uint8Array | null | undefined, ignoreChecksum?: boolean | undefined, ss58Format?: number | undefined): Uint8Array;
@@ -0,0 +1,15 @@
1
+ import { decodeAddress } from "@polkadot/keyring";
2
+ import { hexToU8a } from "@polkadot/util";
3
+ import { isEthereumAddress } from "@polkadot/util-crypto";
4
+ export function decodeAnyAddress(encoded, ignoreChecksum, ss58Format) {
5
+ try {
6
+ return decodeAddress(encoded, ignoreChecksum, ss58Format);
7
+ }
8
+ catch (error) {
9
+ if (typeof encoded !== "string")
10
+ throw error;
11
+ if (!isEthereumAddress(encoded))
12
+ throw error;
13
+ return hexToU8a(encoded.slice("0x".length));
14
+ }
15
+ }
@@ -0,0 +1 @@
1
+ export declare function encodeAnyAddress(key: string | Uint8Array, ss58Format?: number | undefined): string;
@@ -0,0 +1,14 @@
1
+ import { encodeAddress } from "@polkadot/keyring";
2
+ import { ethereumEncode, isEthereumAddress } from "@polkadot/util-crypto";
3
+ export function encodeAnyAddress(key, ss58Format) {
4
+ try {
5
+ return encodeAddress(key, ss58Format);
6
+ }
7
+ catch (error) {
8
+ if (typeof key !== "string")
9
+ throw error;
10
+ if (!isEthereumAddress(key))
11
+ throw error;
12
+ return ethereumEncode(key);
13
+ }
14
+ }
@@ -0,0 +1 @@
1
+ export declare function hasOwnProperty<X, Y extends PropertyKey>(obj: X, prop: Y): obj is X & Record<Y, unknown>;
@@ -0,0 +1,3 @@
1
+ export function hasOwnProperty(obj, prop) {
2
+ return prop in obj;
3
+ }
package/dist/index.d.ts CHANGED
@@ -1,7 +1,12 @@
1
1
  export * from "./BigMath";
2
2
  export * from "./FunctionPropertyNames";
3
+ export * from "./blake2Concat";
4
+ export * from "./decodeAnyAddress";
5
+ export * from "./encodeAnyAddress";
3
6
  export * from "./formatDecimals";
4
7
  export * from "./getBase64ImageUrl";
8
+ export * from "./hasOwnProperty";
5
9
  export * from "./isArrayOf";
6
10
  export * from "./planckToTokens";
7
11
  export * from "./tokensToPlanck";
12
+ export * from "./twox64Concat";
package/dist/index.js CHANGED
@@ -1,7 +1,12 @@
1
1
  export * from "./BigMath";
2
2
  export * from "./FunctionPropertyNames";
3
+ export * from "./blake2Concat";
4
+ export * from "./decodeAnyAddress";
5
+ export * from "./encodeAnyAddress";
3
6
  export * from "./formatDecimals";
4
7
  export * from "./getBase64ImageUrl";
8
+ export * from "./hasOwnProperty";
5
9
  export * from "./isArrayOf";
6
10
  export * from "./planckToTokens";
7
11
  export * from "./tokensToPlanck";
12
+ export * from "./twox64Concat";
@@ -0,0 +1,2 @@
1
+ /// <reference types="node" />
2
+ export declare function twox64Concat(input: string | Buffer | Uint8Array): `0x${string}`;
@@ -0,0 +1,6 @@
1
+ import { u8aConcat, u8aToHex, u8aToU8a } from "@polkadot/util";
2
+ import { xxhashAsU8a } from "@polkadot/util-crypto";
3
+ const bitLength = 64;
4
+ export function twox64Concat(input) {
5
+ return u8aToHex(u8aConcat(xxhashAsU8a(input, bitLength), u8aToU8a(input)));
6
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@talismn/util",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "author": "Talisman",
5
5
  "homepage": "https://talisman.xyz",
6
6
  "license": "UNLICENSED",
@@ -30,6 +30,9 @@
30
30
  "clean": "rm -rf dist && rm -rf .turbo rm -rf node_modules"
31
31
  },
32
32
  "dependencies": {
33
+ "@polkadot/keyring": "^10.1.7",
34
+ "@polkadot/util": "^10.1.7",
35
+ "@polkadot/util-crypto": "^10.1.7",
33
36
  "bignumber.js": "^9.1.0"
34
37
  },
35
38
  "devDependencies": {