@talismn/util 0.2.0 → 0.2.1
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 +9 -0
- package/dist/declarations/src/index.d.ts +1 -0
- package/dist/declarations/src/isBigInt.d.ts +1 -0
- package/dist/declarations/src/isEthereumAddress.d.ts +1 -1
- package/dist/talismn-util.cjs.dev.js +5 -2
- package/dist/talismn-util.cjs.prod.js +5 -2
- package/dist/talismn-util.esm.js +5 -3
- package/package.json +11 -11
package/CHANGELOG.md
CHANGED
@@ -8,6 +8,7 @@ export * from "./encodeAnyAddress";
|
|
8
8
|
export * from "./formatDecimals";
|
9
9
|
export * from "./hasOwnProperty";
|
10
10
|
export * from "./isArrayOf";
|
11
|
+
export * from "./isBigInt";
|
11
12
|
export * from "./isEthereumAddress";
|
12
13
|
export * from "./planckToTokens";
|
13
14
|
export * from "./sleep";
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const isBigInt: (value: unknown) => value is bigint;
|
@@ -1 +1 @@
|
|
1
|
-
export declare const isEthereumAddress: (address: string) =>
|
1
|
+
export declare const isEthereumAddress: (address: string | undefined | null) => address is `0x${string}`;
|
@@ -158,7 +158,9 @@ function isArrayOf(array, func) {
|
|
158
158
|
return false;
|
159
159
|
}
|
160
160
|
|
161
|
-
const
|
161
|
+
const isBigInt = value => typeof value === "bigint";
|
162
|
+
|
163
|
+
const isEthereumAddress = address => !!address && address.startsWith("0x") && address.length === 42;
|
162
164
|
|
163
165
|
function planckToTokens(planck, tokenDecimals) {
|
164
166
|
if (typeof planck !== "string" || typeof tokenDecimals !== "number") return;
|
@@ -170,7 +172,7 @@ function planckToTokens(planck, tokenDecimals) {
|
|
170
172
|
|
171
173
|
const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));
|
172
174
|
|
173
|
-
const throwAfter = (ms, reason) => new Promise((_, reject) => setTimeout(() => reject(reason), ms));
|
175
|
+
const throwAfter = (ms, reason) => new Promise((_, reject) => setTimeout(() => reject(new Error(reason)), ms));
|
174
176
|
|
175
177
|
function tokensToPlanck(tokens, tokenDecimals) {
|
176
178
|
if (typeof tokens !== "string" || typeof tokenDecimals !== "number") return;
|
@@ -195,6 +197,7 @@ exports.encodeAnyAddress = encodeAnyAddress;
|
|
195
197
|
exports.formatDecimals = formatDecimals;
|
196
198
|
exports.hasOwnProperty = hasOwnProperty;
|
197
199
|
exports.isArrayOf = isArrayOf;
|
200
|
+
exports.isBigInt = isBigInt;
|
198
201
|
exports.isEthereumAddress = isEthereumAddress;
|
199
202
|
exports.planckToTokens = planckToTokens;
|
200
203
|
exports.sleep = sleep;
|
@@ -158,7 +158,9 @@ function isArrayOf(array, func) {
|
|
158
158
|
return false;
|
159
159
|
}
|
160
160
|
|
161
|
-
const
|
161
|
+
const isBigInt = value => typeof value === "bigint";
|
162
|
+
|
163
|
+
const isEthereumAddress = address => !!address && address.startsWith("0x") && address.length === 42;
|
162
164
|
|
163
165
|
function planckToTokens(planck, tokenDecimals) {
|
164
166
|
if (typeof planck !== "string" || typeof tokenDecimals !== "number") return;
|
@@ -170,7 +172,7 @@ function planckToTokens(planck, tokenDecimals) {
|
|
170
172
|
|
171
173
|
const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));
|
172
174
|
|
173
|
-
const throwAfter = (ms, reason) => new Promise((_, reject) => setTimeout(() => reject(reason), ms));
|
175
|
+
const throwAfter = (ms, reason) => new Promise((_, reject) => setTimeout(() => reject(new Error(reason)), ms));
|
174
176
|
|
175
177
|
function tokensToPlanck(tokens, tokenDecimals) {
|
176
178
|
if (typeof tokens !== "string" || typeof tokenDecimals !== "number") return;
|
@@ -195,6 +197,7 @@ exports.encodeAnyAddress = encodeAnyAddress;
|
|
195
197
|
exports.formatDecimals = formatDecimals;
|
196
198
|
exports.hasOwnProperty = hasOwnProperty;
|
197
199
|
exports.isArrayOf = isArrayOf;
|
200
|
+
exports.isBigInt = isBigInt;
|
198
201
|
exports.isEthereumAddress = isEthereumAddress;
|
199
202
|
exports.planckToTokens = planckToTokens;
|
200
203
|
exports.sleep = sleep;
|
package/dist/talismn-util.esm.js
CHANGED
@@ -150,7 +150,9 @@ function isArrayOf(array, func) {
|
|
150
150
|
return false;
|
151
151
|
}
|
152
152
|
|
153
|
-
const
|
153
|
+
const isBigInt = value => typeof value === "bigint";
|
154
|
+
|
155
|
+
const isEthereumAddress = address => !!address && address.startsWith("0x") && address.length === 42;
|
154
156
|
|
155
157
|
function planckToTokens(planck, tokenDecimals) {
|
156
158
|
if (typeof planck !== "string" || typeof tokenDecimals !== "number") return;
|
@@ -162,7 +164,7 @@ function planckToTokens(planck, tokenDecimals) {
|
|
162
164
|
|
163
165
|
const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));
|
164
166
|
|
165
|
-
const throwAfter = (ms, reason) => new Promise((_, reject) => setTimeout(() => reject(reason), ms));
|
167
|
+
const throwAfter = (ms, reason) => new Promise((_, reject) => setTimeout(() => reject(new Error(reason)), ms));
|
166
168
|
|
167
169
|
function tokensToPlanck(tokens, tokenDecimals) {
|
168
170
|
if (typeof tokens !== "string" || typeof tokenDecimals !== "number") return;
|
@@ -177,4 +179,4 @@ function twox64Concat(input) {
|
|
177
179
|
return u8aToHex(u8aConcat(xxhashAsU8a(input, bitLength), u8aToU8a(input)));
|
178
180
|
}
|
179
181
|
|
180
|
-
export { BigMath, Deferred, MAX_DECIMALS_FORMAT, blake2Concat, classNames, decodeAnyAddress, encodeAnyAddress, formatDecimals, hasOwnProperty, isArrayOf, isEthereumAddress, planckToTokens, sleep, throwAfter, tokensToPlanck, twox64Concat };
|
182
|
+
export { BigMath, Deferred, MAX_DECIMALS_FORMAT, blake2Concat, classNames, decodeAnyAddress, encodeAnyAddress, formatDecimals, hasOwnProperty, isArrayOf, isBigInt, isEthereumAddress, planckToTokens, sleep, throwAfter, tokensToPlanck, twox64Concat };
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@talismn/util",
|
3
|
-
"version": "0.2.
|
3
|
+
"version": "0.2.1",
|
4
4
|
"author": "Talisman",
|
5
5
|
"homepage": "https://talisman.xyz",
|
6
6
|
"license": "GPL-3.0-or-later",
|
@@ -26,20 +26,20 @@
|
|
26
26
|
"clean": "rm -rf dist && rm -rf .turbo rm -rf node_modules"
|
27
27
|
},
|
28
28
|
"dependencies": {
|
29
|
-
"bignumber.js": "^9.1.
|
30
|
-
"tailwind-merge": "^1.
|
29
|
+
"bignumber.js": "^9.1.2",
|
30
|
+
"tailwind-merge": "^1.14.0"
|
31
31
|
},
|
32
32
|
"devDependencies": {
|
33
|
-
"@polkadot/keyring": "^12.2
|
34
|
-
"@polkadot/util": "^12.2
|
35
|
-
"@polkadot/util-crypto": "^12.2
|
36
|
-
"@talismn/eslint-config": "0.0.
|
33
|
+
"@polkadot/keyring": "^12.3.2",
|
34
|
+
"@polkadot/util": "^12.3.2",
|
35
|
+
"@polkadot/util-crypto": "^12.3.2",
|
36
|
+
"@talismn/eslint-config": "0.0.3",
|
37
37
|
"@talismn/tsconfig": "0.0.2",
|
38
38
|
"@types/jest": "^27.5.1",
|
39
|
-
"eslint": "^8.
|
40
|
-
"jest": "^
|
41
|
-
"ts-jest": "^
|
42
|
-
"typescript": "^
|
39
|
+
"eslint": "^8.52.0",
|
40
|
+
"jest": "^29.7.0",
|
41
|
+
"ts-jest": "^29.1.1",
|
42
|
+
"typescript": "^5.2.2"
|
43
43
|
},
|
44
44
|
"peerDependencies": {
|
45
45
|
"@polkadot/keyring": "12.x",
|