@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 +6 -0
- package/dist/blake2Concat.d.ts +1 -0
- package/dist/blake2Concat.js +6 -0
- package/dist/decodeAnyAddress.d.ts +1 -0
- package/dist/decodeAnyAddress.js +15 -0
- package/dist/encodeAnyAddress.d.ts +1 -0
- package/dist/encodeAnyAddress.js +14 -0
- package/dist/hasOwnProperty.d.ts +1 -0
- package/dist/hasOwnProperty.js +3 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +5 -0
- package/dist/twox64Concat.d.ts +2 -0
- package/dist/twox64Concat.js +6 -0
- package/package.json +4 -1
package/CHANGELOG.md
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
export declare function blake2Concat(input: Uint8Array): `0x${string}`;
|
@@ -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>;
|
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";
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@talismn/util",
|
3
|
-
"version": "0.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": {
|