@talismn/util 0.1.8 → 0.1.9
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/BigMath.d.ts +1 -1
- package/dist/declarations/src/deferred.d.ts +1 -1
- package/dist/declarations/src/index.d.ts +1 -0
- package/dist/declarations/src/isEthereumAddress.d.ts +1 -0
- package/dist/talismn-util.cjs.dev.js +6 -3
- package/dist/talismn-util.cjs.prod.js +6 -3
- package/dist/talismn-util.esm.js +9 -7
- package/package.json +10 -10
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
# @talismn/util
|
2
2
|
|
3
|
+
## 0.1.9
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- f7aca48b: eslint rules
|
8
|
+
- 01bf239b: feat: crowdloan and nom pool balances
|
9
|
+
- 48f0222e: fix: removed some explicit `any`s
|
10
|
+
- 01bf239b: fix: packages publishing with incorrect interdependency versions
|
11
|
+
|
3
12
|
## 0.1.8
|
4
13
|
|
5
14
|
### Patch Changes
|
@@ -8,7 +8,7 @@
|
|
8
8
|
export declare function Deferred<T>(): {
|
9
9
|
promise: Promise<T>;
|
10
10
|
resolve: (value: T | PromiseLike<T>) => void;
|
11
|
-
reject: (reason?:
|
11
|
+
reject: (reason?: unknown) => void;
|
12
12
|
isPending: () => boolean;
|
13
13
|
isResolved: () => boolean;
|
14
14
|
isRejected: () => boolean;
|
@@ -9,6 +9,7 @@ export * from "./formatDecimals";
|
|
9
9
|
export * from "./getBase64ImageUrl";
|
10
10
|
export * from "./hasOwnProperty";
|
11
11
|
export * from "./isArrayOf";
|
12
|
+
export * from "./isEthereumAddress";
|
12
13
|
export * from "./planckToTokens";
|
13
14
|
export * from "./sleep";
|
14
15
|
export * from "./throwAfter";
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const isEthereumAddress: (address: string) => boolean;
|
@@ -17,11 +17,11 @@ var BigNumber__default = /*#__PURE__*/_interopDefault(BigNumber);
|
|
17
17
|
*/
|
18
18
|
const BigMath = {
|
19
19
|
abs(x) {
|
20
|
-
return x <
|
20
|
+
return x < 0n ? -x : x;
|
21
21
|
},
|
22
22
|
sign(x) {
|
23
|
-
if (x ===
|
24
|
-
return x <
|
23
|
+
if (x === 0n) return 0n;
|
24
|
+
return x < 0n ? -1n : 1n;
|
25
25
|
},
|
26
26
|
// TODO: Improve our babel/tsc config to let us use the `**` operator on bigint values.
|
27
27
|
// Error thrown: Exponentiation cannot be performed on 'bigint' values unless the 'target' option is set to 'es2016' or later. ts(2791)
|
@@ -169,6 +169,8 @@ function isArrayOf(array, func) {
|
|
169
169
|
return false;
|
170
170
|
}
|
171
171
|
|
172
|
+
const isEthereumAddress = address => address.startsWith("0x") && address.length === 42;
|
173
|
+
|
172
174
|
function planckToTokens(planck, tokenDecimals) {
|
173
175
|
if (typeof planck !== "string" || typeof tokenDecimals !== "number") return;
|
174
176
|
const base = 10;
|
@@ -205,6 +207,7 @@ exports.formatDecimals = formatDecimals;
|
|
205
207
|
exports.getBase64ImageUrl = getBase64ImageUrl;
|
206
208
|
exports.hasOwnProperty = hasOwnProperty;
|
207
209
|
exports.isArrayOf = isArrayOf;
|
210
|
+
exports.isEthereumAddress = isEthereumAddress;
|
208
211
|
exports.planckToTokens = planckToTokens;
|
209
212
|
exports.sleep = sleep;
|
210
213
|
exports.throwAfter = throwAfter;
|
@@ -17,11 +17,11 @@ var BigNumber__default = /*#__PURE__*/_interopDefault(BigNumber);
|
|
17
17
|
*/
|
18
18
|
const BigMath = {
|
19
19
|
abs(x) {
|
20
|
-
return x <
|
20
|
+
return x < 0n ? -x : x;
|
21
21
|
},
|
22
22
|
sign(x) {
|
23
|
-
if (x ===
|
24
|
-
return x <
|
23
|
+
if (x === 0n) return 0n;
|
24
|
+
return x < 0n ? -1n : 1n;
|
25
25
|
},
|
26
26
|
// TODO: Improve our babel/tsc config to let us use the `**` operator on bigint values.
|
27
27
|
// Error thrown: Exponentiation cannot be performed on 'bigint' values unless the 'target' option is set to 'es2016' or later. ts(2791)
|
@@ -169,6 +169,8 @@ function isArrayOf(array, func) {
|
|
169
169
|
return false;
|
170
170
|
}
|
171
171
|
|
172
|
+
const isEthereumAddress = address => address.startsWith("0x") && address.length === 42;
|
173
|
+
|
172
174
|
function planckToTokens(planck, tokenDecimals) {
|
173
175
|
if (typeof planck !== "string" || typeof tokenDecimals !== "number") return;
|
174
176
|
const base = 10;
|
@@ -205,6 +207,7 @@ exports.formatDecimals = formatDecimals;
|
|
205
207
|
exports.getBase64ImageUrl = getBase64ImageUrl;
|
206
208
|
exports.hasOwnProperty = hasOwnProperty;
|
207
209
|
exports.isArrayOf = isArrayOf;
|
210
|
+
exports.isEthereumAddress = isEthereumAddress;
|
208
211
|
exports.planckToTokens = planckToTokens;
|
209
212
|
exports.sleep = sleep;
|
210
213
|
exports.throwAfter = throwAfter;
|
package/dist/talismn-util.esm.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { u8aToHex, u8aConcat, u8aToU8a, hexToU8a } from '@polkadot/util';
|
2
|
-
import { blake2AsU8a, isEthereumAddress, ethereumEncode, xxhashAsU8a } from '@polkadot/util-crypto';
|
2
|
+
import { blake2AsU8a, isEthereumAddress as isEthereumAddress$1, ethereumEncode, xxhashAsU8a } from '@polkadot/util-crypto';
|
3
3
|
import { decodeAddress, encodeAddress } from '@polkadot/keyring';
|
4
4
|
import BigNumber from 'bignumber.js';
|
5
5
|
|
@@ -9,11 +9,11 @@ import BigNumber from 'bignumber.js';
|
|
9
9
|
*/
|
10
10
|
const BigMath = {
|
11
11
|
abs(x) {
|
12
|
-
return x <
|
12
|
+
return x < 0n ? -x : x;
|
13
13
|
},
|
14
14
|
sign(x) {
|
15
|
-
if (x ===
|
16
|
-
return x <
|
15
|
+
if (x === 0n) return 0n;
|
16
|
+
return x < 0n ? -1n : 1n;
|
17
17
|
},
|
18
18
|
// TODO: Improve our babel/tsc config to let us use the `**` operator on bigint values.
|
19
19
|
// Error thrown: Exponentiation cannot be performed on 'bigint' values unless the 'target' option is set to 'es2016' or later. ts(2791)
|
@@ -44,7 +44,7 @@ function decodeAnyAddress(encoded, ignoreChecksum, ss58Format) {
|
|
44
44
|
return decodeAddress(encoded, ignoreChecksum, ss58Format);
|
45
45
|
} catch (error) {
|
46
46
|
if (typeof encoded !== "string") throw error;
|
47
|
-
if (!isEthereumAddress(encoded)) throw error;
|
47
|
+
if (!isEthereumAddress$1(encoded)) throw error;
|
48
48
|
return hexToU8a(encoded.slice("0x".length));
|
49
49
|
}
|
50
50
|
}
|
@@ -89,7 +89,7 @@ function encodeAnyAddress(key, ss58Format) {
|
|
89
89
|
return encodeAddress(key, ss58Format);
|
90
90
|
} catch (error) {
|
91
91
|
if (typeof key !== "string") throw error;
|
92
|
-
if (!isEthereumAddress(key)) throw error;
|
92
|
+
if (!isEthereumAddress$1(key)) throw error;
|
93
93
|
return ethereumEncode(key);
|
94
94
|
}
|
95
95
|
}
|
@@ -161,6 +161,8 @@ function isArrayOf(array, func) {
|
|
161
161
|
return false;
|
162
162
|
}
|
163
163
|
|
164
|
+
const isEthereumAddress = address => address.startsWith("0x") && address.length === 42;
|
165
|
+
|
164
166
|
function planckToTokens(planck, tokenDecimals) {
|
165
167
|
if (typeof planck !== "string" || typeof tokenDecimals !== "number") return;
|
166
168
|
const base = 10;
|
@@ -186,4 +188,4 @@ function twox64Concat(input) {
|
|
186
188
|
return u8aToHex(u8aConcat(xxhashAsU8a(input, bitLength), u8aToU8a(input)));
|
187
189
|
}
|
188
190
|
|
189
|
-
export { BigMath, Deferred, MAX_DECIMALS_FORMAT, blake2Concat, classNames, decodeAnyAddress, encodeAnyAddress, formatDecimals, getBase64ImageUrl, hasOwnProperty, isArrayOf, planckToTokens, sleep, throwAfter, tokensToPlanck, twox64Concat };
|
191
|
+
export { BigMath, Deferred, MAX_DECIMALS_FORMAT, blake2Concat, classNames, decodeAnyAddress, encodeAnyAddress, formatDecimals, getBase64ImageUrl, hasOwnProperty, isArrayOf, isEthereumAddress, planckToTokens, sleep, throwAfter, tokensToPlanck, twox64Concat };
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@talismn/util",
|
3
|
-
"version": "0.1.
|
3
|
+
"version": "0.1.9",
|
4
4
|
"author": "Talisman",
|
5
5
|
"homepage": "https://talisman.xyz",
|
6
6
|
"license": "UNLICENSED",
|
@@ -22,18 +22,18 @@
|
|
22
22
|
},
|
23
23
|
"scripts": {
|
24
24
|
"test": "jest",
|
25
|
-
"lint": "eslint
|
25
|
+
"lint": "eslint src --max-warnings 0",
|
26
26
|
"clean": "rm -rf dist && rm -rf .turbo rm -rf node_modules"
|
27
27
|
},
|
28
28
|
"dependencies": {
|
29
29
|
"bignumber.js": "^9.1.1"
|
30
30
|
},
|
31
31
|
"devDependencies": {
|
32
|
-
"@polkadot/keyring": "^
|
33
|
-
"@polkadot/util": "^
|
34
|
-
"@polkadot/util-crypto": "^
|
35
|
-
"@talismn/eslint-config": "
|
36
|
-
"@talismn/tsconfig": "
|
32
|
+
"@polkadot/keyring": "^12.2.1",
|
33
|
+
"@polkadot/util": "^12.2.1",
|
34
|
+
"@polkadot/util-crypto": "^12.2.1",
|
35
|
+
"@talismn/eslint-config": "0.0.2",
|
36
|
+
"@talismn/tsconfig": "0.0.2",
|
37
37
|
"@types/jest": "^27.5.1",
|
38
38
|
"eslint": "^8.4.0",
|
39
39
|
"jest": "^28.1.0",
|
@@ -41,9 +41,9 @@
|
|
41
41
|
"typescript": "^4.6.4"
|
42
42
|
},
|
43
43
|
"peerDependencies": {
|
44
|
-
"@polkadot/keyring": "
|
45
|
-
"@polkadot/util": "
|
46
|
-
"@polkadot/util-crypto": "
|
44
|
+
"@polkadot/keyring": "12.x",
|
45
|
+
"@polkadot/util": "12.x",
|
46
|
+
"@polkadot/util-crypto": "12.x"
|
47
47
|
},
|
48
48
|
"eslintConfig": {
|
49
49
|
"root": true,
|