@talismn/util 0.0.0-pr708-20230419032011 → 0.0.0-pr716-20230419110638
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 +4 -2
- package/dist/declarations/src/BigMath.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 +4 -4
package/CHANGELOG.md
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
# @talismn/util
|
2
2
|
|
3
|
-
## 0.0.0-
|
3
|
+
## 0.0.0-pr716-20230419110638
|
4
4
|
|
5
5
|
### Patch Changes
|
6
6
|
|
7
|
-
-
|
7
|
+
- f7aca48b: eslint rules
|
8
|
+
- 01bf239b: feat: crowdloan and nom pool balances
|
9
|
+
- 01bf239b: fix: packages publishing with incorrect interdependency versions
|
8
10
|
|
9
11
|
## 0.1.8
|
10
12
|
|
@@ -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)
|
@@ -170,6 +170,8 @@ function isArrayOf(array, func) {
|
|
170
170
|
return false;
|
171
171
|
}
|
172
172
|
|
173
|
+
const isEthereumAddress = address => address.startsWith("0x") && address.length === 42;
|
174
|
+
|
173
175
|
function planckToTokens(planck, tokenDecimals) {
|
174
176
|
if (typeof planck !== "string" || typeof tokenDecimals !== "number") return;
|
175
177
|
const base = 10;
|
@@ -206,6 +208,7 @@ exports.formatDecimals = formatDecimals;
|
|
206
208
|
exports.getBase64ImageUrl = getBase64ImageUrl;
|
207
209
|
exports.hasOwnProperty = hasOwnProperty;
|
208
210
|
exports.isArrayOf = isArrayOf;
|
211
|
+
exports.isEthereumAddress = isEthereumAddress;
|
209
212
|
exports.planckToTokens = planckToTokens;
|
210
213
|
exports.sleep = sleep;
|
211
214
|
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)
|
@@ -170,6 +170,8 @@ function isArrayOf(array, func) {
|
|
170
170
|
return false;
|
171
171
|
}
|
172
172
|
|
173
|
+
const isEthereumAddress = address => address.startsWith("0x") && address.length === 42;
|
174
|
+
|
173
175
|
function planckToTokens(planck, tokenDecimals) {
|
174
176
|
if (typeof planck !== "string" || typeof tokenDecimals !== "number") return;
|
175
177
|
const base = 10;
|
@@ -206,6 +208,7 @@ exports.formatDecimals = formatDecimals;
|
|
206
208
|
exports.getBase64ImageUrl = getBase64ImageUrl;
|
207
209
|
exports.hasOwnProperty = hasOwnProperty;
|
208
210
|
exports.isArrayOf = isArrayOf;
|
211
|
+
exports.isEthereumAddress = isEthereumAddress;
|
209
212
|
exports.planckToTokens = planckToTokens;
|
210
213
|
exports.sleep = sleep;
|
211
214
|
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
|
}
|
@@ -90,7 +90,7 @@ function encodeAnyAddress(key, ss58Format) {
|
|
90
90
|
return encodeAddress(key, ss58Format);
|
91
91
|
} catch (error) {
|
92
92
|
if (typeof key !== "string") throw error;
|
93
|
-
if (!isEthereumAddress(key)) throw error;
|
93
|
+
if (!isEthereumAddress$1(key)) throw error;
|
94
94
|
return ethereumEncode(key);
|
95
95
|
}
|
96
96
|
}
|
@@ -162,6 +162,8 @@ function isArrayOf(array, func) {
|
|
162
162
|
return false;
|
163
163
|
}
|
164
164
|
|
165
|
+
const isEthereumAddress = address => address.startsWith("0x") && address.length === 42;
|
166
|
+
|
165
167
|
function planckToTokens(planck, tokenDecimals) {
|
166
168
|
if (typeof planck !== "string" || typeof tokenDecimals !== "number") return;
|
167
169
|
const base = 10;
|
@@ -187,4 +189,4 @@ function twox64Concat(input) {
|
|
187
189
|
return u8aToHex(u8aConcat(xxhashAsU8a(input, bitLength), u8aToU8a(input)));
|
188
190
|
}
|
189
191
|
|
190
|
-
export { BigMath, Deferred, MAX_DECIMALS_FORMAT, blake2Concat, classNames, decodeAnyAddress, encodeAnyAddress, formatDecimals, getBase64ImageUrl, hasOwnProperty, isArrayOf, planckToTokens, sleep, throwAfter, tokensToPlanck, twox64Concat };
|
192
|
+
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.0.0-
|
3
|
+
"version": "0.0.0-pr716-20230419110638",
|
4
4
|
"author": "Talisman",
|
5
5
|
"homepage": "https://talisman.xyz",
|
6
6
|
"license": "UNLICENSED",
|
@@ -32,8 +32,8 @@
|
|
32
32
|
"@polkadot/keyring": "^11.1.1",
|
33
33
|
"@polkadot/util": "^11.1.1",
|
34
34
|
"@polkadot/util-crypto": "^11.1.1",
|
35
|
-
"@talismn/eslint-config": "
|
36
|
-
"@talismn/tsconfig": "
|
35
|
+
"@talismn/eslint-config": "0.0.0-pr716-20230419110638",
|
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",
|
@@ -43,7 +43,7 @@
|
|
43
43
|
"peerDependencies": {
|
44
44
|
"@polkadot/keyring": "11.x",
|
45
45
|
"@polkadot/util": "11.x",
|
46
|
-
"@polkadot/util-crypto": "
|
46
|
+
"@polkadot/util-crypto": "11.x"
|
47
47
|
},
|
48
48
|
"eslintConfig": {
|
49
49
|
"root": true,
|