@talismn/util 0.0.0-pr672-20230404063840 → 0.0.0-pr677-20230413171850
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
@@ -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;
|
@@ -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;
|
@@ -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
|
|
@@ -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.0.0-
|
3
|
+
"version": "0.0.0-pr677-20230413171850",
|
4
4
|
"author": "Talisman",
|
5
5
|
"homepage": "https://talisman.xyz",
|
6
6
|
"license": "UNLICENSED",
|
@@ -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,
|